Skip to content

Commit

Permalink
v3.2.4 (#724)
Browse files Browse the repository at this point in the history
* add support for Coder.com (#714)

Checks for extension `coder.coder` to tell if the IDE is Coder + VS
Code or just a regular VS Code installation.

* add webpack bundling for faster startup

* use tsc to compile tests

* make tests run

* v3.2.3 release

* v3.2.4

* Always use VSCODE_PORTABLE env when portable

Mac will no longer use Application Support while in portable mode

* Token error on HTTP 401

- Display token error on 401, as the current method was displaying generic error for me. Also opens GitHub tokens page on error
> Doesn’t listen for 403 errors as this shouldn’t ever happen with current setup, but we could add later
- Use error.status instead of error.code to avoid depreciation logging

* Fix loading language bundles and add missing dependencies (#736)

* add webpack bundling for faster startup

* use tsc to compile tests

* make tests run

* rebase on v3.2.3

* fix loading language bundles
  • Loading branch information
shanalikhan authored Dec 13, 2018
1 parent 3646117 commit b6c9f4c
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/out/src/**/*.js"],
"outFiles": ["${workspaceRoot}/out/**/*.js"],
"preLaunchTask": "npm"
},
{
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

[![Version](https://vsmarketplacebadge.apphb.com/version/Shan.code-settings-sync.svg)](https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync) [![Travis](https://img.shields.io/travis/rust-lang/rust.svg)](https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync) [![Master course](https://img.shields.io/badge/Supported%20by-VSCode%20Power%20User%20Course%20%E2%86%92-gray.svg?colorA=444444&colorB=4F44D6)](https://t.co/8BEMyhpKU5?amp=1)

#### Version - 3.2.3 - 11 Dec, 2018

* Startup : Long startup activation time on the first start [#656](https://github.com/shanalikhan/code-settings-sync/issues/656) - Thanks for PR [#717](https://github.com/shanalikhan/code-settings-sync/pull/717) by [@thejewdude](https://github.com/thejewdude)
* Feature : Adding coder.com support [#714](https://github.com/shanalikhan/code-settings-sync/issues/714) - Thanks for PR [#720](https://github.com/shanalikhan/code-settings-sync/pull/720) by [@deansheather](https://github.com/deansheather)

#### Version - 3.2.2 - 26 Nov, 2018

Expand Down
30 changes: 17 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "code-settings-sync",
"displayName": "Settings Sync",
"description": "Synchronize Settings, Snippets, Themes, File Icons, Launch, Keybindings, Workspaces and Extensions Across Multiple Machines Using GitHub Gist.",
"version": "3.2.2",
"version": "3.2.4",
"icon": "images/cloud.png",
"publisher": "Shan",
"author": {
Expand Down Expand Up @@ -62,7 +62,7 @@
"activationEvents": [
"*"
],
"main": "./out/src/extension",
"main": "./out/extension.js",
"contributes": {
"commands": [
{
Expand Down Expand Up @@ -143,29 +143,33 @@
}
},
"scripts": {
"vscode:prepublish": "npm run tslint-check && npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"vscode:prepublish": "npm run tslint-check && webpack --mode production",
"compile": "webpack",
"watch": "webpack --mode development --watch",
"postinstall": "node ./node_modules/vscode/bin/install",
"tslint-check": "tslint -c ./tslint.json ./src/**/*.ts ./src/*.ts",
"format": "prettier --write './src/**/*.ts'",
"test": "npm run vscode:prepublish && node ./node_modules/bin/mocha --recursive"
"test": "npm run tslint-check && tsc -p ./ && mocha --recursive \"./out/test/**/*.js\""
},
"devDependencies": {
"@types/fs-extra": "^5.0.4",
"@types/node": "^10.12.10",
"@types/chai": "4.1.7",
"@types/fs-extra": "^5.0.4",
"@types/mocha": "^5.2.5",
"@types/node": "^10.12.10",
"chai": "^4.2.0",
"clean-webpack-plugin": "^1.0.0",
"mocha": "^5.2.0",
"prettier": "^1.15.2",
"prettier": "^1.15.3",
"ts-loader": "^5.3.0",
"tslint": "^5.11.0",
"tslint-plugin-prettier": "^2.0.0",
"typescript": "^3.1.2",
"vscode": "^1.1.21"
"tslint-plugin-prettier": "^2.0.1",
"typescript": "^3.2.2",
"vscode": "^1.1.26",
"webpack": "^4.26.1",
"webpack-cli": "^3.1.2"
},
"dependencies": {
"@octokit/rest": "^16.0.1",
"@octokit/rest": "^16.2.0",
"adm-zip": "^0.4.13",
"chokidar": "^2.0.4",
"fs-extra": "^7.0.1",
Expand Down
20 changes: 10 additions & 10 deletions src/commons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@ export default class Commons {
): void {
if (error) {
console.error(error);
if (error.code === 500) {
if (error.status === 500) {
message = localize("common.error.connection");
msgBox = false;
} else if (error.code === 4) {
} else if (error.status === 401) {
msgBox = true;
message = localize("common.error.invalidToken");
} else if (error.status === 4) {
message = localize("common.error.canNotSave");
} else if (error.message) {
try {
message = JSON.parse(error.message).message;
if (message.toLowerCase() === "bad credentials") {
msgBox = true;
message = localize("common.error.invalidToken");
// vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://github.com/settings/tokens'));
}
if (message.toLowerCase() === "not found") {
msgBox = true;
message = localize("common.error.invalidGistId");
Expand Down Expand Up @@ -647,9 +645,11 @@ export default class Commons {
outputChannel.appendLine(`--------------------`);

outputChannel.appendLine(`Files ${upload ? "Upload" : "Download"}ed:`);
files.filter(item => item.fileName.indexOf(".") > 0).forEach(item => {
outputChannel.appendLine(` ${item.fileName} > ${item.gistName}`);
});
files
.filter(item => item.fileName.indexOf(".") > 0)
.forEach(item => {
outputChannel.appendLine(` ${item.fileName} > ${item.gistName}`);
});

outputChannel.appendLine(``);
outputChannel.appendLine(`Extensions Ignored:`);
Expand Down
25 changes: 15 additions & 10 deletions src/environmentPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function osTypeFromString(osName: string): OsType {
}

export class Environment {
public static CURRENT_VERSION: number = 322;
public static CURRENT_VERSION: number = 324;
public static getVersion(): string {
return (
Environment.CURRENT_VERSION.toString().slice(0, 1) +
Expand All @@ -31,6 +31,7 @@ export class Environment {
public isInsiders: boolean = false;
public isOss: boolean = false;
public isPortable: boolean = false;
public isCoderCom: boolean = false;
public homeDir: string | null = null;
public USER_FOLDER: string = null;

Expand Down Expand Up @@ -66,14 +67,17 @@ export class Environment {
this.isInsiders = /insiders/.test(this.context.asAbsolutePath(""));
this.isPortable = process.env.VSCODE_PORTABLE ? true : false;
this.isOss = /\boss\b/.test(this.context.asAbsolutePath(""));
this.isCoderCom =
vscode.extensions.getExtension("coder.coder") !== undefined;
const isXdg =
!this.isInsiders &&
!this.isCoderCom &&
process.platform === "linux" &&
!!process.env.XDG_DATA_HOME;
this.homeDir = isXdg
? process.env.XDG_DATA_HOME
: process.env[process.platform === "win32" ? "USERPROFILE" : "HOME"];
const configSuffix = `${isXdg ? "" : "."}vscode${
const configSuffix = `${isXdg || this.isCoderCom ? "" : "."}vscode${
this.isInsiders ? "-insiders" : this.isOss ? "-oss" : ""
}`;

Expand All @@ -84,10 +88,14 @@ export class Environment {
this.PATH = process.env.HOME + "/Library/Application Support";
this.OsType = OsType.Mac;
} else if (process.platform === "linux") {
this.PATH =
isXdg && !!process.env.XDG_CONFIG_HOME
? process.env.XDG_CONFIG_HOME
: os.homedir() + "/.config";
if (!this.isCoderCom) {
this.PATH =
isXdg && !!process.env.XDG_CONFIG_HOME
? process.env.XDG_CONFIG_HOME
: os.homedir() + "/.config";
} else {
this.PATH = "/tmp";
}
this.OsType = OsType.Linux;
} else if (process.platform === "win32") {
this.PATH = process.env.APPDATA;
Expand All @@ -99,17 +107,14 @@ export class Environment {
}

if (this.isPortable) {
this.PATH = process.env.VSCODE_PORTABLE;
if (process.platform === "darwin") {
this.PATH = process.env.HOME + "/Library/Application Support";
this.OsType = OsType.Mac;
} else if (process.platform === "linux") {
this.PATH = process.env.VSCODE_PORTABLE;
this.OsType = OsType.Linux;
} else if (process.platform === "win32") {
this.PATH = process.env.VSCODE_PORTABLE;
this.OsType = OsType.Windows;
} else {
this.PATH = process.env.VSCODE_PORTABLE;
this.OsType = OsType.Linux;
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/localize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as fs from "fs-extra";
import * as path from "path";
import { extensions } from "vscode";

interface IConfig {
locale?: string;
Expand Down Expand Up @@ -49,7 +50,8 @@ export class Localize {
const defaultResvoleLanguage = ".nls.json";
let resolvedLanguage: string = "";
// TODO: it should read the extension root path from context
const rootPath = path.join(__dirname, "..", "..");
const rootPath = extensions.getExtension("Shan.code-settings-sync")
.extensionPath;
const file = path.join(rootPath, "package");
const options = this.options;

Expand Down Expand Up @@ -80,15 +82,17 @@ export class Localize {
// then merger the Language pack
// just in case the resolveLanguage bundle missing the translation and fallback with default language
if (resolvedLanguage !== defaultResvoleLanguage) {
defaultLanguageBundle = require(path.join(file + defaultResvoleLanguage));
defaultLanguageBundle = JSON.parse(
fs.readFileSync(path.join(file + defaultResvoleLanguage), "utf-8")
);
}

const languageFilePath = path.join(file + resolvedLanguage);

const isExistResolvedLanguage = await fs.pathExists(languageFilePath);

const ResolvedLanguageBundle = isExistResolvedLanguage
? require(languageFilePath)
? JSON.parse(fs.readFileSync(languageFilePath, "utf-8"))
: {};

// merger with default language bundle
Expand Down
2 changes: 1 addition & 1 deletion src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ export class Sync {
const autoUpdate: boolean = vscode.workspace
.getConfiguration("extensions")
.get("autoUpdate");
useCli = autoUpdate;
useCli = autoUpdate && !env.isCoderCom;
if (useCli) {
if (!syncSetting.quietSync) {
Commons.outputChannel = vscode.window.createOutputChannel(
Expand Down
44 changes: 44 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//@ts-check
/** @typedef {import('webpack').Configuration} WebpackOptions **/

"use strict";

const path = require("path");
const CleanWebpackPlugin = require("clean-webpack-plugin");

/** @type WebpackOptions */
const config = {
mode: "none",
target: "node",
entry: "./src/extension.ts",
output: {
filename: "extension.js",
path: path.resolve(__dirname, "out"),
libraryTarget: "commonjs2",
devtoolModuleFilenameTemplate: "file:///[absolute-resource-path]"
},
resolve: {
extensions: [".ts", ".js"],
alias: {
deepmerge$: path.resolve(__dirname, "node_modules/deepmerge/dist/umd.js")
}
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
loader: "ts-loader"
}
]
},
externals: {
vscode: "commonjs vscode",
fsevents: "commonjs fsevents",
"original-fs": "commonjs original-fs"
},
devtool: "source-map",
plugins: [new CleanWebpackPlugin(["out"])]
};

module.exports = config;

0 comments on commit b6c9f4c

Please sign in to comment.