From 90ecd71f3dc4dbe2008e5f307c864b07cf659cba Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sun, 16 Sep 2018 12:52:57 +0000 Subject: [PATCH 01/40] chore(package): update tslint-plugin-prettier to version 2.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f73923fc..4e9a6882 100644 --- a/package.json +++ b/package.json @@ -155,7 +155,7 @@ "@types/node": "^10.7.0", "prettier": "^1.14.2", "tslint": "^5.11.0", - "tslint-plugin-prettier": "^1.3.0", + "tslint-plugin-prettier": "^2.0.0", "typescript": "^3.0.1", "vscode": "^1.1.21" }, From 70d4dc1ebf9b8ee2b9f25d2262b369204090d760 Mon Sep 17 00:00:00 2001 From: Blackcatz1911 Date: Mon, 17 Sep 2018 10:24:21 +0200 Subject: [PATCH 02/40] Updated: German translation --- package.nls.de.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/package.nls.de.json b/package.nls.de.json index 1823b4a2..9fbee39b 100644 --- a/package.nls.de.json +++ b/package.nls.de.json @@ -1,13 +1,13 @@ { "ext.config.title": "Code Settings Sync Konfiguration", "ext.config.gist": "GitHub Gist-ID für Settings Sync.", - "ext.config.lastUpload": "Zeitstempel des letzten Uploads von Settings Sync. Leeren um Download zu forcieren.", - "ext.config.lastDownload": "Zeitstepel des letzten Downloads von Settings Sync. Leeren um Download zu forcieren.", + "ext.config.lastUpload": "Zeitstempel des letzten Uploads von Settings Sync. Leeren um Download zu erzwingen.", + "ext.config.lastDownload": "Zeitstepel des letzten Downloads von Settings Sync. Leeren um Download zu erzwingen.", "ext.config.autoDownload": "Auf true setzen um die Einstellungen beim Programmstart automatisch herunterzuladen. [Programmneustart benötigt]", "ext.config.autoUpload": "Auf true setzen um die Einstellungen bei Änderung automatisch hochzuladen. [Programmneustart benötigt]", "ext.config.forceDownload": "Auf true setzen um selbst bei aktuellen Einstellung die Daten neu herunterzuladen.", "ext.config.host": "Falls erwünscht, GitHub Enterprise Host definieren.", - "ext.config.pathPrefix": "Falls erwünscht, GitHub Enterprise api prefix definieren. Normalerweise '/api/v3'. Wird nur verwended wenn ein Host definiert ist.", + "ext.config.pathPrefix": "Falls erwünscht, GitHub Enterprise API-Prefix definieren. Normalerweise '/api/v3'. Wird nur verwended wenn ein Host definiert ist.", "ext.config.quietSync": "Zeigt bei true Ergebnisse nur in der Statusleiste statt einer Zusammenfassung an.", "ext.config.askGistName": "Fragt nach Gist-Namen bei Erstellung. Hilft dir, das Gist zu identifizieren, solltest du mehrere benutzen.", "ext.config.removeExtensions": "Auf false setzen wenn Erweiterungen beim Herunterladen der Einstellungen nicht entfernt werden sollen.", @@ -39,9 +39,9 @@ "cmd.otherOptions.shareSetting": "Sync : Einstellungen via öffentlichem Gist teilen", "cmd.otherOptions.shareSetting.beforeConfirm": "Sync : derzeitiges Gist entfernen und Einstellungen zu neuem Gist hinzufügen. Fortfahren?", "cmd.otherOptions.downloadSetting": "Sync : Einstellungen von öffentlichem Gist laden", - "cmd.otherOptions.toggleForceDownload": "Sync : Forcierter Download an/aus", - "cmd.otherOptions.toggleForceDownload.on": "Sync : Forcierter Download an.", - "cmd.otherOptions.toggleForceDownload.off": "Sync : Forcierter Download aus.", + "cmd.otherOptions.toggleForceDownload": "Sync : Erzwungener Download an/aus", + "cmd.otherOptions.toggleForceDownload.on": "Sync : Erzwungener Download an.", + "cmd.otherOptions.toggleForceDownload.off": "Sync : Erzwungener Download aus.", "cmd.otherOptions.toggleAutoUpload": "Sync : Automatischer Upload nach Änderung an/aus", "cmd.otherOptions.toggleAutoUpload.on": "Sync : Automatischer Upload nach Änderung an. Programmneustart notwendig.", "cmd.otherOptions.toggleAutoUpload.off": "Sync : Automatischer Upload nach Änderung aus.", @@ -78,8 +78,8 @@ "common.error.invalidGistId": "Sync : ungültige Gist Id. Bitte verifizieren: https://gist.github.com//.", "common.error.tokenNotSave": "Sync : Token nicht gesichert.", "common.error.gistNotSave": "Sync : Gist nicht gesichert.", - "common.action.openExtPage": "Open Extension Page", - "common.action.openExtTutorial": "Open Tutorial", + "common.action.openExtPage": "Erweiterungsseite öffnen", + "common.action.openExtTutorial": "Anleitung öffnen", "common.action.releaseNotes": "Versionshinweise", "common.action.writeReview": "Bewertung schreiben", "common.action.support": "Projekt unterstützen", @@ -92,4 +92,4 @@ "common.prompt.enterGistId": "Gist-ID der vorherig hochgeladeenen Einstellungen eingeben. Du kannst sie außerdem manuell in den Einstellungen setzen (sync.gist). [Enter] um fortzufahren, [Escape] um abzubrechen).", "common.prompt.enterGithubAccessToken": "Du kannst den Token auch manuell hinzufügen (Benutzerordner/syncLocalSettings.json). [Enter] um fortzufahren, [Escape] um abzurechen." -} \ No newline at end of file +} From 54752d3f1f2b23d446d1814f21cc07088bf79453 Mon Sep 17 00:00:00 2001 From: Shan Date: Wed, 19 Sep 2018 02:30:18 +0500 Subject: [PATCH 03/40] #641 --- src/commons.ts | 91 +++++++++++++++++++++++++------------------------- src/setting.ts | 2 +- src/sync.ts | 13 +++----- 3 files changed, 50 insertions(+), 56 deletions(-) diff --git a/src/commons.ts b/src/commons.ts index 88662ffa..ea84e5b6 100644 --- a/src/commons.ts +++ b/src/commons.ts @@ -418,53 +418,52 @@ export default class Commons { const writeReview = localize("common.action.writeReview"); const support = localize("common.action.support"); const joinCommunity = localize("common.action.joinCommunity"); - // TODO : Remove this, v3.1 Specific only. - vscode.window.showInformationMessage( - "Some Settings are updated. You can remove unnecessary sync settings from code. Read Sync guide for details." - ); - vscode.window - .showInformationMessage( - localize("common.info.updateTo", Environment.getVersion()), - releaseNotes, - writeReview, - support, - joinCommunity - ) - .then((val: string) => { - if (val === releaseNotes) { - vscode.commands.executeCommand( - "vscode.open", - vscode.Uri.parse( - "http://shanalikhan.github.io/2016/05/14/Visual-studio-code-sync-settings-release-notes.html" - ) - ); - } - if (val === writeReview) { - vscode.commands.executeCommand( - "vscode.open", - vscode.Uri.parse( - "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync#review-details" - ) - ); - } - if (val === support) { - vscode.commands.executeCommand( - "vscode.open", - vscode.Uri.parse( - "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=4W3EWHHBSYMM8&lc=IE&item_name=Code%20Settings%20Sync&item_number=visual%20studio%20code%20settings%20sync¤cy_code=USD&bn=PP-DonationsBF:btn_donate_SM.gif:NonHosted" - ) - ); - } - if (val === joinCommunity) { - vscode.commands.executeCommand( - "vscode.open", - vscode.Uri.parse( - "https://join.slack.com/t/codesettingssync/shared_invite/enQtMzE3MjY5NTczNDMwLTYwMTIwNGExOGE2MTJkZWU0OTU5MmI3ZTc4N2JkZjhjMzY1OTk5OGExZjkwMDMzMDU4ZTBlYjk5MGQwZmMyNzk" - ) - ); - } - }); + if (!customSettings.disableUpdateMessage) { + vscode.window + .showInformationMessage( + localize("common.info.updateTo", Environment.getVersion()), + releaseNotes, + writeReview, + support, + joinCommunity + ) + .then((val: string) => { + if (val === releaseNotes) { + vscode.commands.executeCommand( + "vscode.open", + vscode.Uri.parse( + "http://shanalikhan.github.io/2016/05/14/Visual-studio-code-sync-settings-release-notes.html" + ) + ); + } + if (val === writeReview) { + vscode.commands.executeCommand( + "vscode.open", + vscode.Uri.parse( + "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync#review-details" + ) + ); + } + if (val === support) { + vscode.commands.executeCommand( + "vscode.open", + vscode.Uri.parse( + "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=4W3EWHHBSYMM8&lc=IE&item_name=Code%20Settings%20Sync&item_number=visual%20studio%20code%20settings%20sync¤cy_code=USD&bn=PP-DonationsBF:btn_donate_SM.gif:NonHosted" + ) + ); + } + if (val === joinCommunity) { + vscode.commands.executeCommand( + "vscode.open", + vscode.Uri.parse( + "https://join.slack.com/t/codesettingssync/shared_invite/enQtMzE3MjY5NTczNDMwLTYwMTIwNGExOGE2MTJkZWU0OTU5MmI3ZTc4N2JkZjhjMzY1OTk5OGExZjkwMDMzMDU4ZTBlYjk5MGQwZmMyNzk" + ) + ); + } + }); + } } + if (fileChanged) { customSettings.version = Environment.CURRENT_VERSION; await this.SetCustomSettings(customSettings); diff --git a/src/setting.ts b/src/setting.ts index c0177d2d..021e0074 100644 --- a/src/setting.ts +++ b/src/setting.ts @@ -47,7 +47,7 @@ export class CustomSettings { public downloadPublicGist: boolean = false; public supportedFileExtensions: string[] = ["json", "code-snippets"]; public openTokenLink: boolean = true; - public useCliBaseInstallation: boolean = true; + public disableUpdateMessage: boolean = false; public lastUpload: Date = null; public lastDownload: Date = null; public githubEnterpriseUrl: string = null; diff --git a/src/sync.ts b/src/sync.ts index 16d497be..e555564d 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -502,16 +502,11 @@ export class Sync { } try { - // TODO: Remove Older installation way in next version. let useCli = true; - if (customSettings.useCliBaseInstallation) { - const autoUpdate: boolean = vscode.workspace - .getConfiguration("extensions") - .get("autoUpdate"); - useCli = autoUpdate; - } else { - useCli = false; - } + const autoUpdate: boolean = vscode.workspace + .getConfiguration("extensions") + .get("autoUpdate"); + useCli = autoUpdate; addedExtensions = await PluginService.InstallExtensions( content, From 38b3b3cadb1f9cdf1da1ff98437aca4f3122d294 Mon Sep 17 00:00:00 2001 From: Peter Squicciarini Date: Wed, 19 Sep 2018 09:50:10 -0400 Subject: [PATCH 04/40] Add support for VSCodium --- src/environmentPath.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/environmentPath.ts b/src/environmentPath.ts index 8203dae5..c60c825a 100644 --- a/src/environmentPath.ts +++ b/src/environmentPath.ts @@ -102,13 +102,15 @@ export class Environment { }); } - const possibleCodePaths = [ - this.isInsiders - ? "/Code - Insiders" - : this.isOss - ? "/Code - OSS" - : "/Code" - ]; + const possibleCodePaths = []; + if (this.isInsiders) { + possibleCodePaths.push("/Code - Insiders"); + } else if (this.isOss) { + possibleCodePaths.push("/Code - OSS"); + possibleCodePaths.push("/VSCodium"); + } else { + possibleCodePaths.push("/Code"); + } for (const possibleCodePath of possibleCodePaths) { try { fs.statSync(this.PATH + possibleCodePath); From 1948e5bfa4d10c4bd447a93e8a52e38ade9080a4 Mon Sep 17 00:00:00 2001 From: Takara Hokao Date: Wed, 26 Sep 2018 23:28:36 +0900 Subject: [PATCH 05/40] Corrected the message to be displayed --- src/sync.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sync.ts b/src/sync.ts index e555564d..919f06b4 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -810,7 +810,7 @@ export class Sync { ); } else { vscode.window.showInformationMessage( - localize("cmd.otherOptions.preserve.info.done1", input, val) + localize("cmd.otherOptions.preserve.info.done2", input, val) ); } } From bef2a5df6bff63919850c9872d8ac3781670ea11 Mon Sep 17 00:00:00 2001 From: Takara Hokao Date: Wed, 26 Sep 2018 23:24:14 +0900 Subject: [PATCH 06/40] Add Japanese translation file --- package.nls.ja.json | 94 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 package.nls.ja.json diff --git a/package.nls.ja.json b/package.nls.ja.json new file mode 100644 index 00000000..6b748fcb --- /dev/null +++ b/package.nls.ja.json @@ -0,0 +1,94 @@ +{ + "ext.config.title": "Code Settings Sync 設定", + "ext.config.gist": "Settings Sync で使用する GitHub GIST ID", + "ext.config.lastUpload": "Settings Sync 最終アップロード日時. 手動でダウンロードする場合は空にしてください.", + "ext.config.lastDownload": "Settings Sync 最終ダウンロード日時. 手動でダウンロードする場合は空にしてください.", + "ext.config.autoDownload": "エディタを開いたときに設定を自動でダウンロードする場合は true にしてください. [再起動が必要です]", + "ext.config.autoUpload": "変更したときに設定を自動でアップロードする場合は true にしてください. [再起動が必要です]", + "ext.config.forceDownload": "ローカルの設定が更新されていても, リモート設定をダウンロードしたい場合は true にしてください.", + "ext.config.host": "必要に応じて GitHub Enterprise のホストを指定してください.", + "ext.config.pathPrefix": "必要に応じて GitHub Enterprise API プリフィックスを指定してください. 通常であれば '/api/v3'. hostフィールドが指定されているときだけ使います.", + "ext.config.quietSync": "true にした場合, サイレントモードになります. 出力パネルではなくステータスバーに同期結果を表示します.", + "ext.config.askGistName": "作成時に gist 名を尋ねます. 複数の gist を使用しているときにgistを識別するのに役に立ちます.", + "ext.config.removeExtensions": "ダウンロード時に拡張機能を削除したくない場合 false にします.", + "ext.config.syncExtensions": "拡張機能を同期したくない場合 false にします.", + "cmd.howSetting.title": "Sync : 設定方法", + "cmd.updateSettings.title": "Sync : 設定をアップロード", + "cmd.updateSettings.info.uploading": "Sync : Github に設定を アップロード / 更新.", + "cmd.updateSettings.info.uploadingFile": "Sync : ファイルのアップロード中です.", + "cmd.updateSettings.info.uploadingDone": "Sync : アップロード完了. GIST ID : {0} . この ID をコピーして他のデバイスでの同期に使用してください.", + "cmd.updateSettings.info.uploadingSuccess": "Sync : アップロードされました.", + "cmd.updateSettings.info.shareGist": "Sync : 他の拡張機能ユーザーに ID を共有して設定を共有します.", + "cmd.updateSettings.info.readding": "Sync : 設定と拡張機能を読み込みます.", + "cmd.updateSettings.info.newGistCreated": "Sync : 新しい gist を作成しました.", + "cmd.updateSettings.warning.noToken": "Sync : ローカルの同期設定ファイルで GitHub トークンを設定するか, 'downloadPublicGist' を無効にしてください.", + "cmd.updateSettings.error.newGistCreateFail": "Sync : Gist を作成することができません.", + "cmd.updateSettings.error.readGistFail": "Sync : GIST ID: {0} 読み取ることができません.", + "cmd.updateSettings.error.gistNotSave": "Sync : GIST が保存されていません", + "cmd.downloadSettings.title": "Sync : 設定をダウンロード", + "cmd.downloadSettings.info.downloaded": "Sync : ダウンロードが完了しました.", + "cmd.downloadSettings.info.readdingOnline": "Sync : オンラインの設定を読み込み中です.", + "cmd.downloadSettings.info.gotLatestVersion": "Sync : 既に最新の設定を持っています.", + "cmd.downloadSettings.error.removeExtFail": "Sync : 一部の拡張機能を削除できません.", + "cmd.downloadSettings.error.unableSave": "Sync : 拡張機能の設定ファイルを保存できません.", + "cmd.resetSettings.title": "Sync : 拡張機能の設定をリセット", + "cmd.resetSettings.info.resetting": "Sync : 設定をリセット中です.", + "cmd.resetSettings.info.settingClear": "Sync : 設定がクリアされました.", + "cmd.otherOptions.title": "Sync : 詳細なオプション", + "cmd.otherOptions.editLocalSetting": "Sync : 拡張機能のローカル設定の編集", + "cmd.otherOptions.shareSetting": "Sync : 公開 GIST で設定の共有", + "cmd.otherOptions.shareSetting.beforeConfirm": "Sync : これにより, 現在の GIST が削除され, 新しく公開 GIST に設定がアップロードされます. 続行しますか?", + "cmd.otherOptions.downloadSetting": "Sync : 公開 GIST から設定のダウンロード", + "cmd.otherOptions.toggleForceDownload": "Sync : 強制ダウンロード ON / OFF 切り替え", + "cmd.otherOptions.toggleForceDownload.on": "Sync : 強制ダウンロードを ON にしました.", + "cmd.otherOptions.toggleForceDownload.off": "Sync : 強制ダウンロードを OFF にしました.", + "cmd.otherOptions.toggleAutoUpload": "Sync : 設定変更時の自動アップロード ON / OFF 切り替え", + "cmd.otherOptions.toggleAutoUpload.on": "Sync : 設定変更時の自動アップロードを ON にしました. 再起動後に反映されます.", + "cmd.otherOptions.toggleAutoUpload.off": "Sync : 設定変更時の自動アップロードを OFF にしました.", + "cmd.otherOptions.toggleAutoDownload": "Sync : 起動時の自動ダウンロード ON / OFF 切り替え", + "cmd.otherOptions.toggleAutoDownload.on": "Sync : VSCode 起動時の自動ダウンロードを ON にしました.", + "cmd.otherOptions.toggleAutoDownload.off": "Sync : VSCode 起動時の自動ダウンロードを OFF にしました.", + "cmd.otherOptions.toggleSummaryPage": "Sync : アップロード / ダウンロード 時のサイレントモード ON / OFF 切り替え", + "cmd.otherOptions.preserve": "Sync : ダウンロード後に上書きをしないように設定を保存", + "cmd.otherOptions.preserve.placeholder": "保存する settings.json のキーを入力してください.", + "cmd.otherOptions.preserve.prompt": "例 : 'http.proxy' => このコンピュータのプロキシを保存して, それで上書きします. 空の場合プロキシを削除します.", + "cmd.otherOptions.preserve.info.done1": "Sync : 終了します. {0} の値はダウンロード後 settings.json から削除されます.", + "cmd.otherOptions.preserve.info.done2": "Sync : 終了します. ダウンロード後に {0} : {1} で settings.json に保持します.", + "cmd.otherOptions.joinCommunity": "Sync : コミュニティに参加する", + "cmd.otherOptions.openIssue": "Sync : Issue を作成する", + "cmd.otherOptions.releaseNotes": "Sync : リリースノート", + "cmd.otherOptions.quietSync.on": "Sync : サイレントモードを ON にしました. ステータスバーは ダウンロード / アップロード時に更新されます.", + "cmd.otherOptions.quietSync.off": "Sync : サイレントモードを OFF にしました. 要約は ダウンロード / アップロード 時に表示されます.", + "cmd.otherOptions.warning.tokenNotRequire": "Sync : Settings Sync はこれ以降 GitHub Token を尋ねません.", + "cmd.otherOptions.error.toggleFail": "Sync : 切り替えできません.", + "common.info.installed": "Sync : 設定を作成しました, インストールありがとうございます!", + "common.info.needHelp": "Sync : この拡張機能の設定をお手伝いしますか?", + "common.info.excludeFile": "Sync : アップロードとダウンロードの設定で ファイル / フォルダ を除外することができます.", + "common.info.updating": "Sync : アップデート中です ... お待ちください.", + "common.info.initAutoUpload": "Sync : 5秒後に自動アップロードを開始します.", + "common.info.setToken": "Sync : GitHub token を `syncLocalSettings.json` に手動で設定できます", + "common.info.tokenSaved": "Sync : トークンが保存されました", + "common.info.gistSaved": "Sync : Gist が保存されました", + "common.info.updateTo": "Sync : v{0} への更新", + "common.info.donate": "Sync : この拡張機能を気に入りましたか? レビューや寄付はどうですか? (^_-)", + "common.error.message": "Sync : エラーログがコンソールに表示されます (ヘルプ > 開発者ツールの切り替え).", + "common.error.connection": "Sync : インターネットに接続されてない, もしくは GitHub に接族ができません. コンソールに例外が出力されました", + "common.error.canNotSave": "Sync : 設定が保存できません. 有効な JSON settings.json ファイルがあることを確認してください. ( 例 : 後続のカンマがない )", + "common.error.invalidToken": "Sync : 無効もしくは期限切れの GitHub Token です. README に記載のスコープで新しいトークンを生成してください. コンソールに例外が出力されました.", + "common.error.invalidGistId": "Sync : 無効な Gist Id が入力されました. あなたの gist を確認してください : https://gist.github.com//.", + "common.error.tokenNotSave": "Sync : トークンが保存されませんでした.", + "common.error.gistNotSave": "Sync : Gist が保存されませんでした.", + "common.action.openExtPage": "拡張機能のページを開きます", + "common.action.openExtTutorial": "チュートリアルを開きます", + "common.action.releaseNotes": "リリースノート", + "common.action.writeReview": "レビューを書きます", + "common.action.support": "このプロジェクトをサポートします", + "common.action.joinCommunity": "コミュニティに参加します", + "common.action.donate": "寄付します", + "common.placeholder.enterGithubAccessToken": "GitHub の個人アクセストークンを入力してください", + "common.placeholder.enterGistId": "Gist Id を入力してください", + "common.placeholder.multipleGist": "Gist 名 (例 : Personal Settings)", + "common.prompt.multipleGist": "複数の gist を持っている場合に設定を識別できます.", + "common.prompt.enterGistId": "以前にアップロードした設定の Gist Id を入力してください. コード設定で手動で設定する事もできます (sync.gist). 確定するには [Enter], キャンセルするには [Esc] を押してください.", + "common.prompt.enterGithubAccessToken": "手動でトークンを追加する事もできます (ユーザーフォルダ / syncLocalSettings.json). 確定するには [Enter], キャンセルするには [Esc] を押してください." +} From ceb955da3b3401a22287b5937285b16053080c11 Mon Sep 17 00:00:00 2001 From: Takara Hokao Date: Thu, 4 Oct 2018 13:06:58 +0900 Subject: [PATCH 07/40] be able to upload additional file --- src/service/fileService.ts | 25 +++++++++++++++++++++++++ src/setting.ts | 1 + src/sync.ts | 12 ++++++++++++ 3 files changed, 38 insertions(+) diff --git a/src/service/fileService.ts b/src/service/fileService.ts index b72f7f8c..b335831f 100644 --- a/src/service/fileService.ts +++ b/src/service/fileService.ts @@ -12,6 +12,8 @@ export class File { ) {} } export class FileService { + public static CUSTOMIZED_SYNC_PREFIX = "|customized_sync|"; + public static async ReadFile(filePath: string): Promise { try { const data = await fs.readFile(filePath, { encoding: "utf8" }); @@ -193,4 +195,27 @@ export class FileService { throw err; } } + + public static async GetCustomFile( + filePath: string, + fileName: string + ): Promise { + const fileExists: boolean = await FileService.FileExists(filePath); + + if (!fileExists) { + return null; + } + + const content = await FileService.ReadFile(filePath); + + if (content === null) { + return null; + } + + // for identifing Customized Sync file + const gistName: string = FileService.CUSTOMIZED_SYNC_PREFIX + fileName; + + const file: File = new File(fileName, content, filePath, gistName); + return file; + } } diff --git a/src/setting.ts b/src/setting.ts index 021e0074..f7c75363 100644 --- a/src/setting.ts +++ b/src/setting.ts @@ -52,4 +52,5 @@ export class CustomSettings { public lastDownload: Date = null; public githubEnterpriseUrl: string = null; public askGistName: boolean = false; + public customFiles: { [key: string]: string } = {}; } diff --git a/src/sync.ts b/src/sync.ts index 919f06b4..03570609 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -188,6 +188,18 @@ export class Sync { return matchedFolders.length > 0; }); } + const customFileKeys: string[] = Object.keys( + customSettings.customFiles + ); + if (customFileKeys.length > 0) { + for (const key of customFileKeys) { + const val = customSettings.customFiles[key]; + const customFile: File = await FileService.GetCustomFile(val, key); + if (customFile !== null) { + allSettingFiles.push(customFile); + } + } + } } else { Commons.LogException(null, common.ERROR_MESSAGE, true); return; From 601c1e86501d2012a4644d26f5bb7eebd3b951dc Mon Sep 17 00:00:00 2001 From: Takara Hokao Date: Thu, 4 Oct 2018 13:09:51 +0900 Subject: [PATCH 08/40] be able to download additional files --- src/service/fileService.ts | 16 ++++++++++++++++ src/sync.ts | 29 ++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/service/fileService.ts b/src/service/fileService.ts index b335831f..9b09d7e7 100644 --- a/src/service/fileService.ts +++ b/src/service/fileService.ts @@ -218,4 +218,20 @@ export class FileService { const file: File = new File(fileName, content, filePath, gistName); return file; } + + public static async CreateCustomDirTree(filePath: string): Promise { + const dir = path.dirname(filePath); + const fileExists = await FileService.FileExists(dir); + + if (!fileExists) { + // mkdir recursively + await fs.mkdirs(dir); + } + + return filePath; + } + + public static ExtractFileName(fullPath: string): string { + return path.basename(fullPath); + } } diff --git a/src/sync.ts b/src/sync.ts index 03570609..2892f2d7 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -449,7 +449,21 @@ export class Sync { keys.forEach(gistName => { if (res.data.files[gistName]) { if (res.data.files[gistName].content) { - if (gistName.indexOf(".") > -1) { + const prefix = FileService.CUSTOMIZED_SYNC_PREFIX; + if (gistName.indexOf(prefix) > -1) { + const fileName = gistName.split(prefix).join(""); // |customized_sync|.htmlhintrc => .htmlhintrc + if (!(fileName in customSettings.customFiles)) { + // syncLocalSettings.json > customFiles doesn't have key + return; + } + const f: File = new File( + fileName, + res.data.files[gistName].content, + customSettings.customFiles[fileName], + gistName + ); + updatedFiles.push(f); + } else if (gistName.indexOf(".") > -1) { if ( env.OsType === OsType.Mac && gistName === env.FILE_KEYBINDING_DEFAULT @@ -571,10 +585,15 @@ export class Sync { if (file.gistName === env.FILE_KEYBINDING_MAC) { file.fileName = env.FILE_KEYBINDING_DEFAULT; } - const filePath: string = await FileService.CreateDirTree( - env.USER_FOLDER, - file.fileName - ); + let filePath: string = ""; + if (file.filePath !== null) { + filePath = await FileService.CreateCustomDirTree(file.filePath); + } else { + filePath = await FileService.CreateDirTree( + env.USER_FOLDER, + file.fileName + ); + } actionList.push( FileService.WriteFile(filePath, content) From 7fa4345d6b987b7eeddb2006ef59923b8a198cc5 Mon Sep 17 00:00:00 2001 From: Takara Hokao Date: Thu, 4 Oct 2018 13:10:54 +0900 Subject: [PATCH 09/40] create new advanced setting to add Customized Sync file --- package.nls.ja.json | 4 ++++ package.nls.json | 4 ++++ src/sync.ts | 28 ++++++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/package.nls.ja.json b/package.nls.ja.json index 6b748fcb..7223d0c2 100644 --- a/package.nls.ja.json +++ b/package.nls.ja.json @@ -54,6 +54,10 @@ "cmd.otherOptions.preserve.prompt": "例 : 'http.proxy' => このコンピュータのプロキシを保存して, それで上書きします. 空の場合プロキシを削除します.", "cmd.otherOptions.preserve.info.done1": "Sync : 終了します. {0} の値はダウンロード後 settings.json から削除されます.", "cmd.otherOptions.preserve.info.done2": "Sync : 終了します. ダウンロード後に {0} : {1} で settings.json に保持します.", + "cmd.otherOptions.customizedSync": "Sync: カスタム同期", + "cmd.otherOptions.customizedSync.placeholder": "追加でアップロードするファイルの絶対パスを入力してください.", + "cmd.otherOptions.customizedSync.prompt": "(ex. /path/to/.eslint) はアップロードされ, 指定したパスにダウンロードされます.", + "cmd.otherOptions.customizedSync.done": "Sync : {0} を登録しました.", "cmd.otherOptions.joinCommunity": "Sync : コミュニティに参加する", "cmd.otherOptions.openIssue": "Sync : Issue を作成する", "cmd.otherOptions.releaseNotes": "Sync : リリースノート", diff --git a/package.nls.json b/package.nls.json index bc89355d..f2b883b7 100644 --- a/package.nls.json +++ b/package.nls.json @@ -54,6 +54,10 @@ "cmd.otherOptions.preserve.prompt": "Example : Write 'http.proxy' => store this computer proxy and overwrite it , if set empty it will remove proxy.", "cmd.otherOptions.preserve.info.done1": "Sync : Done. {0} value will be removed from settings.json after downloading.", "cmd.otherOptions.preserve.info.done2": "Sync : Done. Extension will keep {0} : {1} in setting.json after downloading.", + "cmd.otherOptions.customizedSync": "Sync: Customized Sync", + "cmd.otherOptions.customizedSync.placeholder": "Enter an absolute path of the additional uploaded file.", + "cmd.otherOptions.customizedSync.prompt": "(ex. /path/to/.eslint) will be uploaded and downloaded to the specified path.", + "cmd.otherOptions.customizedSync.done": "Sync : {0} has been registered.", "cmd.otherOptions.joinCommunity": "Sync : Join Community", "cmd.otherOptions.openIssue": "Sync : Open Issue", "cmd.otherOptions.releaseNotes": "Sync : Release Notes", diff --git a/src/sync.ts b/src/sync.ts index 2892f2d7..ceacc3cb 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -730,6 +730,7 @@ export class Sync { "cmd.otherOptions.toggleAutoDownload", "cmd.otherOptions.toggleSummaryPage", "cmd.otherOptions.preserve", + "cmd.otherOptions.customizedSync", "cmd.otherOptions.joinCommunity", "cmd.otherOptions.openIssue", "cmd.otherOptions.releaseNotes" @@ -848,6 +849,29 @@ export class Sync { } }, 8: async () => { + // add customized sync file + const options: vscode.InputBoxOptions = { + ignoreFocusOut: true, + placeHolder: localize("cmd.otherOptions.customizedSync.placeholder"), + prompt: localize("cmd.otherOptions.customizedSync.prompt") + }; + const input = await vscode.window.showInputBox(options); + + if (input) { + const fileName: string = FileService.ExtractFileName(input); + if (fileName === "") { + return; + } + customSettings.customFiles[fileName] = input; + const done: boolean = await common.SetCustomSettings(customSettings); + if (done) { + vscode.window.showInformationMessage( + localize("cmd.otherOptions.customizedSync.done", fileName) + ); + } + } + }, + 9: async () => { vscode.commands.executeCommand( "vscode.open", vscode.Uri.parse( @@ -855,7 +879,7 @@ export class Sync { ) ); }, - 9: async () => { + 10: async () => { vscode.commands.executeCommand( "vscode.open", vscode.Uri.parse( @@ -863,7 +887,7 @@ export class Sync { ) ); }, - 10: async () => { + 11: async () => { vscode.commands.executeCommand( "vscode.open", vscode.Uri.parse( From 1413137aaed6558342b702ab9fbb6f476f77dac8 Mon Sep 17 00:00:00 2001 From: Takara Hokao Date: Sun, 7 Oct 2018 22:38:48 +0900 Subject: [PATCH 10/40] fix typo eslint => eslintrc --- package.nls.ja.json | 2 +- package.nls.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.nls.ja.json b/package.nls.ja.json index 7223d0c2..69690bfa 100644 --- a/package.nls.ja.json +++ b/package.nls.ja.json @@ -56,7 +56,7 @@ "cmd.otherOptions.preserve.info.done2": "Sync : 終了します. ダウンロード後に {0} : {1} で settings.json に保持します.", "cmd.otherOptions.customizedSync": "Sync: カスタム同期", "cmd.otherOptions.customizedSync.placeholder": "追加でアップロードするファイルの絶対パスを入力してください.", - "cmd.otherOptions.customizedSync.prompt": "(ex. /path/to/.eslint) はアップロードされ, 指定したパスにダウンロードされます.", + "cmd.otherOptions.customizedSync.prompt": "(ex. /path/to/.eslintrc) はアップロードされ, 指定したパスにダウンロードされます.", "cmd.otherOptions.customizedSync.done": "Sync : {0} を登録しました.", "cmd.otherOptions.joinCommunity": "Sync : コミュニティに参加する", "cmd.otherOptions.openIssue": "Sync : Issue を作成する", diff --git a/package.nls.json b/package.nls.json index f2b883b7..91cf71a0 100644 --- a/package.nls.json +++ b/package.nls.json @@ -56,7 +56,7 @@ "cmd.otherOptions.preserve.info.done2": "Sync : Done. Extension will keep {0} : {1} in setting.json after downloading.", "cmd.otherOptions.customizedSync": "Sync: Customized Sync", "cmd.otherOptions.customizedSync.placeholder": "Enter an absolute path of the additional uploaded file.", - "cmd.otherOptions.customizedSync.prompt": "(ex. /path/to/.eslint) will be uploaded and downloaded to the specified path.", + "cmd.otherOptions.customizedSync.prompt": "(ex. /path/to/.eslintrc) will be uploaded and downloaded to the specified path.", "cmd.otherOptions.customizedSync.done": "Sync : {0} has been registered.", "cmd.otherOptions.joinCommunity": "Sync : Join Community", "cmd.otherOptions.openIssue": "Sync : Open Issue", From 84c12f45b3560f32953910fcf9dbf6445627e068 Mon Sep 17 00:00:00 2001 From: Takara Hokao Date: Sun, 7 Oct 2018 22:41:44 +0900 Subject: [PATCH 11/40] Add Import Custom File to workspace option --- package.nls.ja.json | 3 ++ package.nls.json | 3 ++ src/service/fileService.ts | 4 ++ src/sync.ts | 86 +++++++++++++++++++++++++++++++++++++- 4 files changed, 94 insertions(+), 2 deletions(-) diff --git a/package.nls.ja.json b/package.nls.ja.json index 69690bfa..0af461c7 100644 --- a/package.nls.ja.json +++ b/package.nls.ja.json @@ -58,6 +58,9 @@ "cmd.otherOptions.customizedSync.placeholder": "追加でアップロードするファイルの絶対パスを入力してください.", "cmd.otherOptions.customizedSync.prompt": "(ex. /path/to/.eslintrc) はアップロードされ, 指定したパスにダウンロードされます.", "cmd.otherOptions.customizedSync.done": "Sync : {0} を登録しました.", + "cmd.otherOptions.downloadCustomFile": "Sync: カスタムファイルのインポート", + "cmd.otherOptions.downloadCustomFile.placeholder": "作業中のworkspaceのルートディレクトリにダウンロードするファイルを選択してください.", + "cmd.otherOptions.downloadCustomFile.done": "{0} にダウンロードしました.", "cmd.otherOptions.joinCommunity": "Sync : コミュニティに参加する", "cmd.otherOptions.openIssue": "Sync : Issue を作成する", "cmd.otherOptions.releaseNotes": "Sync : リリースノート", diff --git a/package.nls.json b/package.nls.json index 91cf71a0..79d8384f 100644 --- a/package.nls.json +++ b/package.nls.json @@ -58,6 +58,9 @@ "cmd.otherOptions.customizedSync.placeholder": "Enter an absolute path of the additional uploaded file.", "cmd.otherOptions.customizedSync.prompt": "(ex. /path/to/.eslintrc) will be uploaded and downloaded to the specified path.", "cmd.otherOptions.customizedSync.done": "Sync : {0} has been registered.", + "cmd.otherOptions.downloadCustomFile": "Sync: Import Custom File to workspace", + "cmd.otherOptions.downloadCustomFile.placeholder": "Select the file you want to download to the root of the workspace you are working on.", + "cmd.otherOptions.downloadCustomFile.done": "Downloaded {0}.", "cmd.otherOptions.joinCommunity": "Sync : Join Community", "cmd.otherOptions.openIssue": "Sync : Open Issue", "cmd.otherOptions.releaseNotes": "Sync : Release Notes", diff --git a/src/service/fileService.ts b/src/service/fileService.ts index 9b09d7e7..50779568 100644 --- a/src/service/fileService.ts +++ b/src/service/fileService.ts @@ -234,4 +234,8 @@ export class FileService { public static ExtractFileName(fullPath: string): string { return path.basename(fullPath); } + + public static ConcatPath(...filePaths: string[]): string { + return filePaths.join(path.sep); + } } diff --git a/src/sync.ts b/src/sync.ts index ceacc3cb..3865f9ca 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -731,6 +731,7 @@ export class Sync { "cmd.otherOptions.toggleSummaryPage", "cmd.otherOptions.preserve", "cmd.otherOptions.customizedSync", + "cmd.otherOptions.downloadCustomFile", "cmd.otherOptions.joinCommunity", "cmd.otherOptions.openIssue", "cmd.otherOptions.releaseNotes" @@ -872,6 +873,50 @@ export class Sync { } }, 9: async () => { + // Import customized sync file to workspace + const customFiles = await this.getCustomFilesFromGist( + customSettings, + setting + ); + if (customFiles.length < 1) { + return; + } + const options: vscode.QuickPickOptions = { + ignoreFocusOut: true, + placeHolder: localize( + "cmd.otherOptions.downloadCustomFile.placeholder" + ) + }; + const fileName = await vscode.window.showQuickPick( + customFiles.map(file => { + return file.fileName; + }), + options + ); + // if not pick anyone, do nothing + if (!fileName) { + return; + } + const selected = customFiles.find(f => { + return f.fileName === fileName; + }); + if (selected && vscode.workspace.rootPath) { + const downloadPath = FileService.ConcatPath( + vscode.workspace.rootPath, + selected.fileName + ); + const done = await FileService.WriteFile( + downloadPath, + selected.content + ); + if (done) { + vscode.window.showInformationMessage( + localize("cmd.otherOptions.downloadCustomFile.done", downloadPath) + ); + } + } + }, + 10: async () => { vscode.commands.executeCommand( "vscode.open", vscode.Uri.parse( @@ -879,7 +924,7 @@ export class Sync { ) ); }, - 10: async () => { + 11: async () => { vscode.commands.executeCommand( "vscode.open", vscode.Uri.parse( @@ -887,7 +932,7 @@ export class Sync { ) ); }, - 11: async () => { + 12: async () => { vscode.commands.executeCommand( "vscode.open", vscode.Uri.parse( @@ -975,4 +1020,41 @@ export class Sync { return; } } + + private async getCustomFilesFromGist( + customSettings: CustomSettings, + syncSetting: ExtensionConfig + ): Promise { + const github = new GitHubService( + customSettings.token, + customSettings.githubEnterpriseUrl + ); + const res = await github.ReadGist(syncSetting.gist); + if (!res) { + Commons.LogException(res, "Sync : Unable to Read Gist.", true); + return []; + } + const keys = Object.keys(res.data.files); + const customFiles: File[] = []; + keys.forEach(gistName => { + if (res.data.files[gistName]) { + if (res.data.files[gistName].content) { + const prefix = FileService.CUSTOMIZED_SYNC_PREFIX; + if (gistName.indexOf(prefix) > -1) { + const fileName = gistName.split(prefix).join(""); // |customized_sync|.htmlhintrc => .htmlhintrc + const f: File = new File( + fileName, + res.data.files[gistName].content, + fileName in customSettings.customFiles + ? customSettings.customFiles[fileName] + : null, + gistName + ); + customFiles.push(f); + } + } + } + }); + return customFiles; + } } From 699e87d7493b6a43e8b349e1120168c4744d1272 Mon Sep 17 00:00:00 2001 From: Takara Hokao Date: Sun, 7 Oct 2018 23:27:42 +0900 Subject: [PATCH 12/40] unify display message: Custom Sync File --- package.nls.ja.json | 4 ++-- package.nls.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.nls.ja.json b/package.nls.ja.json index 0af461c7..2a48f1d2 100644 --- a/package.nls.ja.json +++ b/package.nls.ja.json @@ -54,11 +54,11 @@ "cmd.otherOptions.preserve.prompt": "例 : 'http.proxy' => このコンピュータのプロキシを保存して, それで上書きします. 空の場合プロキシを削除します.", "cmd.otherOptions.preserve.info.done1": "Sync : 終了します. {0} の値はダウンロード後 settings.json から削除されます.", "cmd.otherOptions.preserve.info.done2": "Sync : 終了します. ダウンロード後に {0} : {1} で settings.json に保持します.", - "cmd.otherOptions.customizedSync": "Sync: カスタム同期", + "cmd.otherOptions.customizedSync": "Sync : カスタム同期ファイルパスの追加", "cmd.otherOptions.customizedSync.placeholder": "追加でアップロードするファイルの絶対パスを入力してください.", "cmd.otherOptions.customizedSync.prompt": "(ex. /path/to/.eslintrc) はアップロードされ, 指定したパスにダウンロードされます.", "cmd.otherOptions.customizedSync.done": "Sync : {0} を登録しました.", - "cmd.otherOptions.downloadCustomFile": "Sync: カスタムファイルのインポート", + "cmd.otherOptions.downloadCustomFile": "Sync : カスタム同期ファイルのインポート", "cmd.otherOptions.downloadCustomFile.placeholder": "作業中のworkspaceのルートディレクトリにダウンロードするファイルを選択してください.", "cmd.otherOptions.downloadCustomFile.done": "{0} にダウンロードしました.", "cmd.otherOptions.joinCommunity": "Sync : コミュニティに参加する", diff --git a/package.nls.json b/package.nls.json index 79d8384f..a5a51a40 100644 --- a/package.nls.json +++ b/package.nls.json @@ -54,11 +54,11 @@ "cmd.otherOptions.preserve.prompt": "Example : Write 'http.proxy' => store this computer proxy and overwrite it , if set empty it will remove proxy.", "cmd.otherOptions.preserve.info.done1": "Sync : Done. {0} value will be removed from settings.json after downloading.", "cmd.otherOptions.preserve.info.done2": "Sync : Done. Extension will keep {0} : {1} in setting.json after downloading.", - "cmd.otherOptions.customizedSync": "Sync: Customized Sync", + "cmd.otherOptions.customizedSync": "Sync : Add Custom Sync File path", "cmd.otherOptions.customizedSync.placeholder": "Enter an absolute path of the additional uploaded file.", "cmd.otherOptions.customizedSync.prompt": "(ex. /path/to/.eslintrc) will be uploaded and downloaded to the specified path.", "cmd.otherOptions.customizedSync.done": "Sync : {0} has been registered.", - "cmd.otherOptions.downloadCustomFile": "Sync: Import Custom File to workspace", + "cmd.otherOptions.downloadCustomFile": "Sync : Import Custom Sync File to workspace", "cmd.otherOptions.downloadCustomFile.placeholder": "Select the file you want to download to the root of the workspace you are working on.", "cmd.otherOptions.downloadCustomFile.done": "Downloaded {0}.", "cmd.otherOptions.joinCommunity": "Sync : Join Community", From 9ba0d02532739b1dcb5ef3e19b898e6805684af2 Mon Sep 17 00:00:00 2001 From: Shan Khan Date: Mon, 8 Oct 2018 13:40:13 +0500 Subject: [PATCH 13/40] Test Directory --- test/index.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/index.ts diff --git a/test/index.ts b/test/index.ts new file mode 100644 index 00000000..e69de29b From 8c2700f8c1a5bf95598431173cc0a9ae5e4f7a5f Mon Sep 17 00:00:00 2001 From: Brian Mayo Date: Fri, 5 Oct 2018 04:06:26 -0300 Subject: [PATCH 14/40] =Adding HostName property. Get hostname using 'os.hostname()' --- src/environmentPath.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/environmentPath.ts b/src/environmentPath.ts index c60c825a..9bef73a0 100644 --- a/src/environmentPath.ts +++ b/src/environmentPath.ts @@ -27,6 +27,7 @@ export class Environment { public ExtensionFolder: string = null; public PATH: string = null; public OsType: OsType = null; + public HostName: string = null; public FILE_SETTING: string = null; public FILE_LAUNCH: string = null; @@ -73,6 +74,7 @@ export class Environment { process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; this.PATH = process.env.APPDATA; this.OsType = OsType.Windows; + this.HostName = os.hostname(); if (!this.PATH) { if (process.platform === "darwin") { From 1d33a3d49835a51bfcb0e2bc45323fa05f82a713 Mon Sep 17 00:00:00 2001 From: Brian Mayo Date: Fri, 5 Oct 2018 04:12:29 -0300 Subject: [PATCH 15/40] =Need definition for supported OS's. Using strict match regex to get @sync pragmas. Should it support multiple spaces? Replacing settings.json content before writing file. Should be better removing lines instead of add comments? Replacing settings.json before upload to remove @sync ignore pragms. --- src/sync.ts | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 1 deletion(-) diff --git a/src/sync.ts b/src/sync.ts index 919f06b4..53d1f066 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -16,6 +16,8 @@ import { LocalConfig } from "./setting"; +const OS_SUPPORTED = ["windows", "linux", "mac", "darwin"]; + export class Sync { constructor(private context: vscode.ExtensionContext) {} /** @@ -208,6 +210,25 @@ export class Sync { allSettingFiles.push(snippetFile); } } + + if (snippetFile.fileName === env.FILE_SETTING_NAME) { + snippetFile.content = removeIgnoredSettings(snippetFile.content); + } + } + + function removeIgnoredSettings(settingsContent: string): string { + let result: string = settingsContent; + const ignoreSettings: RegExpMatchArray = settingsContent.match( + /\/\/\s\@sync\signore\n.+,?/g // should be space or hypen? + ); + + if (ignoreSettings !== null) { + for (const line of ignoreSettings) { + result = result.replace(line, ""); // remove line? + } + } + + return result; } const extProp: CloudSetting = new CloudSetting(); @@ -359,6 +380,87 @@ export class Sync { return; } + function GetOsEnum(osName: string) { + switch (osName.toLocaleLowerCase()) { + case "windows": + return OsType.Windows; + case "linux": + return OsType.Linux; + case "mac": // should we define unique names for each OS? + case "darwin": + return OsType.Mac; + } + } + + function ProcessPragmaSettings(settingsContent: string): string { + let result: string = settingsContent; + const pragmaSettings: RegExpMatchArray = settingsContent.match( + /\/\/\s\@sync\s(os=(\w+)\s?)?(host=(\w+)\s?)?\n(.+),?/g // should support multiple spaces and line-breaks? + ); + + if (pragmaSettings !== null) { + for (const line of pragmaSettings) { + // line e.g.: // @sync os=windows host=Laptop\n"window.menuBarVisibility": "none", + if (line.indexOf("os=") === -1 && line.indexOf("host=") === -1) { + continue; + } + + // check OS pragma + try { + const osMatch: RegExpMatchArray = line.match(/os=(\w+)/); + if (osMatch !== null) { + const osFromPragma = osMatch[1]; + if ( + osFromPragma && + OS_SUPPORTED.includes(osFromPragma) && + GetOsEnum(osFromPragma) !== env.OsType + ) { + // should remove or comment the line? + // result = result.replace(line, ""); + // handle multiple line breaks ? + const commentedLine = line.replace(/\n(.+)/, settingLine => { + return `\n\t// ${settingLine.trim()}`; + }); + + result = result.replace(line, commentedLine); + } + } + + // check OS pragma + const hostMatch: RegExpMatchArray = line.match(/host=(\w+)/); + if (hostMatch !== null) { + const hostFromPragma = hostMatch[1]; + if ( + hostFromPragma && + hostFromPragma.toLowerCase() !== + env.HostName.toLocaleLowerCase() // should be case sensitive? + ) { + const commentedLine = line.replace(/\n(.+)/, settingLine => { + return `\n\t// ${settingLine.trim()}`; + }); + + result = result.replace(line, commentedLine); + } + } + } catch (e) { + continue; + } + } + } + + const ignoreSettings: RegExpMatchArray = settingsContent.match( + /\/\/\s\@sync\signore\n.+,?/g // should be space or hypen? + ); + + if (ignoreSettings !== null) { + for (const line of ignoreSettings) { + result = result.replace(line, ""); // remove line? + } + } + + return result; + } + async function StartDownload( syncSetting: ExtensionConfig, customSettings: CustomSettings @@ -466,7 +568,7 @@ export class Sync { for (const file of updatedFiles) { let writeFile: boolean = false; - const content: string = file.content; + let content: string = file.content; if (content !== "") { if (file.gistName === env.FILE_EXTENSION_NAME) { @@ -564,6 +666,10 @@ export class Sync { file.fileName ); + if (file.gistName === env.FILE_SETTING_NAME) { + content = ProcessPragmaSettings(content); + } + actionList.push( FileService.WriteFile(filePath, content) .then(() => { From c6e99f07851af359eeade705ff76f73ea4caf475 Mon Sep 17 00:00:00 2001 From: Brian Mayo Date: Sun, 7 Oct 2018 17:57:34 -0300 Subject: [PATCH 16/40] Added English message for OSNotSupported message while processing uploading content --- package.nls.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.nls.json b/package.nls.json index bc89355d..a59c0df2 100644 --- a/package.nls.json +++ b/package.nls.json @@ -22,6 +22,7 @@ "cmd.updateSettings.info.readding": "Sync : Reading Settings and Extensions.", "cmd.updateSettings.info.newGistCreated": "Sync : New gist created.", "cmd.updateSettings.warning.noToken": "Sync : Set GitHub Token or disable 'downloadPublicGist' from local Sync settings file.", + "cmd.updateSettings.warning.OSNotSupported": "Sync Pragma OS value {0} not supported at line {1}", "cmd.updateSettings.error.newGistCreateFail": "Sync : Unable to create Gist.", "cmd.updateSettings.error.readGistFail": "Sync : GIST ID: {0} UNABLE TO READ.", "cmd.updateSettings.error.gistNotSave": "Sync : GIST NOT SAVED", From 989847e3a1b95e62730b643cbddbe946839d77f5 Mon Sep 17 00:00:00 2001 From: Brian Mayo Date: Sun, 7 Oct 2018 17:58:24 -0300 Subject: [PATCH 17/40] mocha and chai packages added as dev dependencies. Test script not working while compiling. --- package.json | 327 ++++++++++++++++++++++++++------------------------- 1 file changed, 165 insertions(+), 162 deletions(-) diff --git a/package.json b/package.json index f73923fc..419379ae 100644 --- a/package.json +++ b/package.json @@ -1,171 +1,174 @@ { - "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.1.2", - "icon": "images/cloud.png", - "publisher": "Shan", - "author": { - "name": "Shan Khan", - "url": "http://shanalikhan.github.io", - "email": "shanalikhan@hotmail.com" + "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.1.2", + "icon": "images/cloud.png", + "publisher": "Shan", + "author": { + "name": "Shan Khan", + "url": "http://shanalikhan.github.io", + "email": "shanalikhan@hotmail.com" + }, + "homepage": "https://shanalikhan.github.io", + "galleryBanner": { + "color": "#3B4859", + "theme": "dark" + }, + "badges": [ + { + "url": "https://vsmarketplacebadge.apphb.com/version/Shan.code-settings-sync.svg", + "description": "Latest Version", + "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" }, - "homepage": "https://shanalikhan.github.io", - "galleryBanner": { - "color": "#3B4859", - "theme": "dark" + { + "url": "https://vsmarketplacebadge.apphb.com/installs/Shan.code-settings-sync.svg", + "description": "Total Downloads", + "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" }, - "badges": [ - { - "url": "https://vsmarketplacebadge.apphb.com/version/Shan.code-settings-sync.svg", - "description": "Latest Version", - "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" - }, - { - "url": "https://vsmarketplacebadge.apphb.com/installs/Shan.code-settings-sync.svg", - "description": "Total Downloads", - "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" - }, - { - "url": "https://vsmarketplacebadge.apphb.com/rating/Shan.code-settings-sync.svg", - "description": "Ratings", - "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" - }, - { - "url": "https://img.shields.io/badge/Join%20Community-slack-green.svg", - "description": "Join Slack Community", - "href": "https://join.slack.com/t/codesettingssync/shared_invite/enQtMzE3MjY5NTczNDMwLTYwMTIwNGExOGE2MTJkZWU0OTU5MmI3ZTc4N2JkZjhjMzY1OTk5OGExZjkwMDMzMDU4ZTBlYjk5MGQwZmMyNzk" - } - ], - "repository": { - "type": "git", - "url": "https://github.com/shanalikhan/code-settings-sync.git" + { + "url": "https://vsmarketplacebadge.apphb.com/rating/Shan.code-settings-sync.svg", + "description": "Ratings", + "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" }, - "bugs": { - "url": "https://github.com/shanalikhan/code-settings-sync/issues", - "email": "shanalikhan@hotmail.com" - }, - "engines": { - "vscode": "^1.8.0" - }, - "categories": [ - "Other" - ], - "keywords": [ - "vscode-sync", - "vscode-settings-sync", - "code-settings-sync", - "settings-sync", - "workspace-sync", - "multi-root ready" + { + "url": "https://img.shields.io/badge/Join%20Community-slack-green.svg", + "description": "Join Slack Community", + "href": "https://join.slack.com/t/codesettingssync/shared_invite/enQtMzE3MjY5NTczNDMwLTYwMTIwNGExOGE2MTJkZWU0OTU5MmI3ZTc4N2JkZjhjMzY1OTk5OGExZjkwMDMzMDU4ZTBlYjk5MGQwZmMyNzk" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/shanalikhan/code-settings-sync.git" + }, + "bugs": { + "url": "https://github.com/shanalikhan/code-settings-sync/issues", + "email": "shanalikhan@hotmail.com" + }, + "engines": { + "vscode": "^1.8.0" + }, + "categories": [ + "Other" + ], + "keywords": [ + "vscode-sync", + "vscode-settings-sync", + "code-settings-sync", + "settings-sync", + "workspace-sync", + "multi-root ready" + ], + "activationEvents": [ + "*" + ], + "main": "./out/src/extension", + "contributes": { + "commands": [ + { + "command": "extension.HowSettings", + "title": "%cmd.howSetting.title%" + }, + { + "command": "extension.downloadSettings", + "title": "%cmd.downloadSettings.title%" + }, + { + "command": "extension.updateSettings", + "title": "%cmd.updateSettings.title%" + }, + { + "command": "extension.resetSettings", + "title": "%cmd.resetSettings.title%" + }, + { + "command": "extension.otherOptions", + "title": "%cmd.otherOptions.title%" + } ], - "activationEvents": [ - "*" + "keybindings": [ + { + "key": "alt+shift+u", + "command": "extension.updateSettings" + }, + { + "key": "alt+shift+d", + "command": "extension.downloadSettings" + } ], - "main": "./out/src/extension", - "contributes": { - "commands": [ - { - "command": "extension.HowSettings", - "title": "%cmd.howSetting.title%" - }, - { - "command": "extension.downloadSettings", - "title": "%cmd.downloadSettings.title%" - }, - { - "command": "extension.updateSettings", - "title": "%cmd.updateSettings.title%" - }, - { - "command": "extension.resetSettings", - "title": "%cmd.resetSettings.title%" - }, - { - "command": "extension.otherOptions", - "title": "%cmd.otherOptions.title%" - } - ], - "keybindings": [ - { - "key": "alt+shift+u", - "command": "extension.updateSettings" - }, - { - "key": "alt+shift+d", - "command": "extension.downloadSettings" - } - ], - "configuration": { - "properties": { - "sync.gist": { - "type": "string", - "default": "", - "description": "%ext.config.gist%" - }, - "sync.autoDownload": { - "type": "boolean", - "default": false, - "description": "%ext.config.autoDownload%" - }, - "sync.autoUpload": { - "type": "boolean", - "default": false, - "description": "%ext.config.autoUpload%" - }, - "sync.forceDownload": { - "type": "boolean", - "default": false, - "description": "%ext.config.forceDownload%" - }, - "sync.quietSync": { - "type": "boolean", - "default": false, - "description": "%ext.config.quietSync%" - }, - "sync.askGistName": { - "type": "boolean", - "default": false, - "description": "%ext.config.askGistName%" - }, - "sync.removeExtensions": { - "type": "boolean", - "default": true, - "description": "%ext.config.removeExtensions%" - }, - "sync.syncExtensions": { - "type": "boolean", - "default": true, - "description": "%ext.config.syncExtensions%" - } - }, - "title": "%ext.config.title%" + "configuration": { + "properties": { + "sync.gist": { + "type": "string", + "default": "", + "description": "%ext.config.gist%" + }, + "sync.autoDownload": { + "type": "boolean", + "default": false, + "description": "%ext.config.autoDownload%" + }, + "sync.autoUpload": { + "type": "boolean", + "default": false, + "description": "%ext.config.autoUpload%" + }, + "sync.forceDownload": { + "type": "boolean", + "default": false, + "description": "%ext.config.forceDownload%" + }, + "sync.quietSync": { + "type": "boolean", + "default": false, + "description": "%ext.config.quietSync%" + }, + "sync.askGistName": { + "type": "boolean", + "default": false, + "description": "%ext.config.askGistName%" + }, + "sync.removeExtensions": { + "type": "boolean", + "default": true, + "description": "%ext.config.removeExtensions%" + }, + "sync.syncExtensions": { + "type": "boolean", + "default": true, + "description": "%ext.config.syncExtensions%" } - }, - "scripts": { - "vscode:prepublish": "npm run tslint-check && npm run compile", - "compile": "tsc -p ./", - "watch": "tsc -watch -p ./", - "postinstall": "node ./node_modules/vscode/bin/install", - "tslint-check": "tslint -c ./tslint.json ./src/**/*.ts ./src/*.ts", - "format": "prettier --write './src/**/*.ts'" - }, - "devDependencies": { - "@types/fs-extra": "^5.0.4", - "@types/node": "^10.7.0", - "prettier": "^1.14.2", - "tslint": "^5.11.0", - "tslint-plugin-prettier": "^1.3.0", - "typescript": "^3.0.1", - "vscode": "^1.1.21" - }, - "dependencies": { - "@octokit/rest": "^15.10.0", - "adm-zip": "^0.4.11", - "chokidar": "^2.0.2", - "fs-extra": "^7.0.0", - "https-proxy-agent": "^2.1.1", - "lockfile": "^1.0.4", - "temp": "^0.8.3" + }, + "title": "%ext.config.title%" } + }, + "scripts": { + "vscode:prepublish": "npm run tslint-check && npm run compile", + "compile": "tsc -p ./", + "watch": "tsc -watch -p ./", + "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" + }, + "devDependencies": { + "@types/fs-extra": "^5.0.4", + "@types/node": "^10.7.0", + "chai": "^4.2.0", + "mocha": "^5.2.0", + "prettier": "^1.14.2", + "tslint": "^5.11.0", + "tslint-plugin-prettier": "^1.3.0", + "typescript": "^3.0.1", + "vscode": "^1.1.21" + }, + "dependencies": { + "@octokit/rest": "^15.10.0", + "adm-zip": "^0.4.11", + "chokidar": "^2.0.2", + "fs-extra": "^7.0.0", + "https-proxy-agent": "^2.1.1", + "lockfile": "^1.0.4", + "temp": "^0.8.3" + } } From c5a8ac979e08c6e24fd9ebd3d5519c52d5d301e5 Mon Sep 17 00:00:00 2001 From: Brian Mayo Date: Sun, 7 Oct 2018 17:59:26 -0300 Subject: [PATCH 18/40] Moving pragma functions to a separated file --- src/sync.ts | 109 +++++----------------------------------------------- 1 file changed, 10 insertions(+), 99 deletions(-) diff --git a/src/sync.ts b/src/sync.ts index 53d1f066..40257f07 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -16,7 +16,7 @@ import { LocalConfig } from "./setting"; -const OS_SUPPORTED = ["windows", "linux", "mac", "darwin"]; +import PragmaUtil from "./pragmaUtil"; export class Sync { constructor(private context: vscode.ExtensionContext) {} @@ -212,23 +212,11 @@ export class Sync { } if (snippetFile.fileName === env.FILE_SETTING_NAME) { - snippetFile.content = removeIgnoredSettings(snippetFile.content); - } - } - - function removeIgnoredSettings(settingsContent: string): string { - let result: string = settingsContent; - const ignoreSettings: RegExpMatchArray = settingsContent.match( - /\/\/\s\@sync\signore\n.+,?/g // should be space or hypen? - ); - - if (ignoreSettings !== null) { - for (const line of ignoreSettings) { - result = result.replace(line, ""); // remove line? - } + snippetFile.content = PragmaUtil.processBeforeUpload( + snippetFile.content, + vscode.window + ); } - - return result; } const extProp: CloudSetting = new CloudSetting(); @@ -380,87 +368,6 @@ export class Sync { return; } - function GetOsEnum(osName: string) { - switch (osName.toLocaleLowerCase()) { - case "windows": - return OsType.Windows; - case "linux": - return OsType.Linux; - case "mac": // should we define unique names for each OS? - case "darwin": - return OsType.Mac; - } - } - - function ProcessPragmaSettings(settingsContent: string): string { - let result: string = settingsContent; - const pragmaSettings: RegExpMatchArray = settingsContent.match( - /\/\/\s\@sync\s(os=(\w+)\s?)?(host=(\w+)\s?)?\n(.+),?/g // should support multiple spaces and line-breaks? - ); - - if (pragmaSettings !== null) { - for (const line of pragmaSettings) { - // line e.g.: // @sync os=windows host=Laptop\n"window.menuBarVisibility": "none", - if (line.indexOf("os=") === -1 && line.indexOf("host=") === -1) { - continue; - } - - // check OS pragma - try { - const osMatch: RegExpMatchArray = line.match(/os=(\w+)/); - if (osMatch !== null) { - const osFromPragma = osMatch[1]; - if ( - osFromPragma && - OS_SUPPORTED.includes(osFromPragma) && - GetOsEnum(osFromPragma) !== env.OsType - ) { - // should remove or comment the line? - // result = result.replace(line, ""); - // handle multiple line breaks ? - const commentedLine = line.replace(/\n(.+)/, settingLine => { - return `\n\t// ${settingLine.trim()}`; - }); - - result = result.replace(line, commentedLine); - } - } - - // check OS pragma - const hostMatch: RegExpMatchArray = line.match(/host=(\w+)/); - if (hostMatch !== null) { - const hostFromPragma = hostMatch[1]; - if ( - hostFromPragma && - hostFromPragma.toLowerCase() !== - env.HostName.toLocaleLowerCase() // should be case sensitive? - ) { - const commentedLine = line.replace(/\n(.+)/, settingLine => { - return `\n\t// ${settingLine.trim()}`; - }); - - result = result.replace(line, commentedLine); - } - } - } catch (e) { - continue; - } - } - } - - const ignoreSettings: RegExpMatchArray = settingsContent.match( - /\/\/\s\@sync\signore\n.+,?/g // should be space or hypen? - ); - - if (ignoreSettings !== null) { - for (const line of ignoreSettings) { - result = result.replace(line, ""); // remove line? - } - } - - return result; - } - async function StartDownload( syncSetting: ExtensionConfig, customSettings: CustomSettings @@ -667,7 +574,11 @@ export class Sync { ); if (file.gistName === env.FILE_SETTING_NAME) { - content = ProcessPragmaSettings(content); + content = PragmaUtil.processBeforeWrite( + content, + env.OsType, + localSettings.customConfig.hostName + ); } actionList.push( From 16aadd8af38e61b309f4a92d2733d3cce7536e38 Mon Sep 17 00:00:00 2001 From: Brian Mayo Date: Sun, 7 Oct 2018 18:00:39 -0300 Subject: [PATCH 19/40] Added Pragma util static class. Support for host, env and os values in every orther. Remove whitespaces before upload. Alert user if OS value is not a valid OS. --- src/pragmaUtil.ts | 229 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 src/pragmaUtil.ts diff --git a/src/pragmaUtil.ts b/src/pragmaUtil.ts new file mode 100644 index 00000000..ca6fc04d --- /dev/null +++ b/src/pragmaUtil.ts @@ -0,0 +1,229 @@ +import { OsType } from "./enums"; +import localize from "./localize"; + +const SUPPORTED_OS = ["windows", "linux", "mac"]; + +export function GetOsEnum(osName: string): OsType { + switch (osName.toLowerCase()) { + case "windows": + return OsType.Windows; + case "linux": + return OsType.Linux; + case "mac": + return OsType.Mac; + } +} + +/** + * Comment/Uncomment lines if matches OS name or Hostname. + * Usage: @sync os=[OS name] host=[hostName] + * Notes: Hostname must be defined in sync.host setting. It could be used for parse any JSON valid string. + * @export + * @class PragmaUtil + */ +export default class PragmaUtil { + /** + * Process @sync pragma statements before file is saved. + * Comment lines that don't match with the user OS or host value. + * @static + * @param {string} settingsContent a valid JSON string + * @returns {string} + * @memberof PragmaUtil + */ + public static processBeforeWrite( + settingsContent: string, + osType: OsType, + hostName: string + ): string { + let result: string = settingsContent; + + const pragmaSettingsBlocks: RegExpMatchArray = result.match( + this.PragmaRegExp + ); + + if (pragmaSettingsBlocks !== null) { + for (let block of pragmaSettingsBlocks) { + // line e.g.: // @sync os=windows host=Laptop\n"window.menuBarVisibility": "none", + + try { + // check OS pragma + const osMatch: RegExpMatchArray = block.match(/os=(\w+)/); + if (osMatch !== null) { + const osFromPragma = osMatch[1].toLowerCase(); + + if (!SUPPORTED_OS.includes(osFromPragma)) { + continue; + } + if (GetOsEnum(osFromPragma) !== osType) { + result = result.replace(block, this.commentLineAfterBreak(block)); + continue; // no need to lookup the host name + } + } + + // check host pragma + const hostMatch: RegExpMatchArray = block.match(/host=(\S+)/); + if (hostMatch !== null) { + const hostFromPragma = hostMatch[1]; + if ( + hostName === null || + hostName === "" || + hostFromPragma.toLowerCase() !== hostName.toLowerCase() + ) { + result = result.replace(block, this.commentLineAfterBreak(block)); + continue; + } + } + + // check env pragma + const envMatch: RegExpMatchArray = block.match(/env=(\S+)/); + if (envMatch !== null) { + const envFromPragma = envMatch[1]; + if (!process.env[envFromPragma.toUpperCase()]) { + result = result.replace(block, this.commentLineAfterBreak(block)); + } + } + } catch (e) { + continue; + } + } + } + + result = this.removeIgnoreBlocks(result); + + return result; + } + + /** + * Remove @sync-ignore settings before upload. + * + * @static + * @param {string} settingsContent + * @param {require('vscode').window} window + * @returns {string} + * @memberof PragmaUtil + */ + public static processBeforeUpload(settingsContent: string, window): string { + let result: string = settingsContent; + result = this.removeIgnoreBlocks(result); + + const lines = result.split("\n"); + + // alert not supported OS + const pragmaMatches: RegExpMatchArray = result.match(this.PragmaRegExp); + if (pragmaMatches) { + for (let block of pragmaMatches) { + try { + let newBlock: string; + const osMatch: RegExpMatchArray = block.match( + this.OSPragmaWhiteSpacesSupportRegExp + ); + if (osMatch !== null) { + const osFromPragma = osMatch[1] || osMatch[2] || osMatch[3]; + + if (osFromPragma !== "" && /\s/.test(osFromPragma)) { + newBlock = block.replace(osFromPragma, osFromPragma.trimLeft()); + result = result.replace(block, newBlock); + block = newBlock; + } + + const trimmed = osFromPragma.toLowerCase().trim(); + if (!SUPPORTED_OS.includes(trimmed)) { + console.warn("Sync: Invalid OS", osFromPragma); + if (window !== null) { + window.showWarningMessage( + localize( + "cmd.updateSettings.warning.OSNotSupported", + trimmed, + lines.indexOf(block) + ) + ); + } + } + } + + const hostMatch: RegExpMatchArray = block.match( + this.HostPragmaWhiteSpacesSupportRegExp + ); + if (hostMatch !== null) { + const hostFromPragma = hostMatch[1] || hostMatch[2] || hostMatch[3]; + if (hostFromPragma !== "" && /\s/.test(hostFromPragma)) { + newBlock = block.replace( + hostFromPragma, + hostFromPragma.trimLeft() + ); + result = result.replace(block, newBlock); + + block = newBlock; + } + } + + const envMatch: RegExpMatchArray = block.match( + this.EnvPragmaWhiteSpacesSupportRegExp + ); + if (envMatch !== null) { + const envFromPragma = envMatch[1] || envMatch[2] || envMatch[3]; + if (envFromPragma !== "" && /\s/.test(envFromPragma)) { + result = result.replace( + block, + block.replace(envFromPragma, envFromPragma.trimLeft()) + ); + } + } + } catch (e) { + console.log("Sync: Proccess before upload error.", e.message); + continue; + } + } + } + + return result; + } + + public static removeIgnoreBlocks(settingsContent: string): string { + let result: string = settingsContent; + result = result.replace(/\@sync ignore/g, "@sync-ignore"); + const ignoreSettingsBlocks: RegExpMatchArray = result.match( + this.IgnorePragmaRegExp + ); + + if (ignoreSettingsBlocks !== null) { + for (const block of ignoreSettingsBlocks) { + result = result.replace(block, ""); + } + } + + return result; + } + + public static matchPragmaSettings(settingsContent: string): RegExpMatchArray { + return settingsContent.match(this.PragmaRegExp); + } + + /** + * Insert Javascript comment slashes + * + * @private + * @param {string} settingContent + * @param {string} line + * @returns {strign} + * @memberof PragmaUtil + */ + public static commentLineAfterBreak(block: string): string { + const settingLine = block.match(/\n[ \t]*(.+)/); + if ( + settingLine !== null && + settingLine[1] && + !settingLine[1].startsWith("//") + ) { + return block.replace(settingLine[1], l => "// " + l); + } + + return block; + } + + private static readonly PragmaRegExp: RegExp = /\/\/[ \t]*\@sync[ \t]+(?:os=.+[ \t]*)?(?:host=.+[ \t]*)?(?:env=.+[ \t]*)?\n[ \t]*.+,?/g; + private static readonly IgnorePragmaRegExp: RegExp = /\/\/[ \t]*\@sync-ignore.*\n.+,?/g; + private static readonly HostPragmaWhiteSpacesSupportRegExp = /(?:host=(.+)os=)|(?:host=(.+)env=)|host=(.+)\n?/; + private static readonly OSPragmaWhiteSpacesSupportRegExp = /(?:os=(.+)host=)|(?:os=(.+)env=)|os=(.+)\n?/; + private static readonly EnvPragmaWhiteSpacesSupportRegExp = /(?:env=(.+)host=)|(?:env=(.+)os=)|env=(.+)\n?/; +} From 60659f3604ff9b69c9de21639443d03502621e82 Mon Sep 17 00:00:00 2001 From: Brian Mayo Date: Sun, 7 Oct 2018 18:01:05 -0300 Subject: [PATCH 20/40] Added hostName property to CustomSettings --- src/setting.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/setting.ts b/src/setting.ts index 021e0074..791c17d7 100644 --- a/src/setting.ts +++ b/src/setting.ts @@ -52,4 +52,5 @@ export class CustomSettings { public lastDownload: Date = null; public githubEnterpriseUrl: string = null; public askGistName: boolean = false; + public hostName: string = null; } From e856d041bd65c7a296de305422e282a0d7e11100 Mon Sep 17 00:00:00 2001 From: Brian Mayo Date: Sun, 7 Oct 2018 18:02:07 -0300 Subject: [PATCH 21/40] Tests files added. Estructure test per feature. --- test/index.js | 8 ++++++ test/pragmaUtil/index.js | 45 +++++++++++++++++++++++++++++++ test/pragmaUtil/testSettings.json | 32 ++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 test/index.js create mode 100644 test/pragmaUtil/index.js create mode 100644 test/pragmaUtil/testSettings.json diff --git a/test/index.js b/test/index.js new file mode 100644 index 00000000..a5874a69 --- /dev/null +++ b/test/index.js @@ -0,0 +1,8 @@ +const chai = require("chai") +const expect = chai.expect + +global.expect = expect + +describe('PragmaUtil', () => { + require('./pragmaUtil') +}) \ No newline at end of file diff --git a/test/pragmaUtil/index.js b/test/pragmaUtil/index.js new file mode 100644 index 00000000..da3f129d --- /dev/null +++ b/test/pragmaUtil/index.js @@ -0,0 +1,45 @@ +const fs = require('fs') +const expect = require('chai').expect + +let test_settings = null + +const OSTypes = require('../../out/src/enums').OsType +const PragmaUtil = require('../../out/src/pragmaUtil').default + +describe('Process before upload', function () { + this.beforeAll(() => { + test_settings = fs.readFileSync(__dirname + '/testSettings.json', 'utf8') + }) + + it('should remove @sync-ignore and @sync ignore lines', () => { + expect(PragmaUtil.removeIgnoreBlocks(test_settings)).to.not.contains('@sync-ignore').and.not.contains('@sync ignore') + }) + + it('should trim os, host and env', () => { + expect(PragmaUtil.processBeforeUpload(test_settings)).to.match(/@sync os=linux host=trim env=TEST_ENV/) + }) + + it('should comment line after linebreak', () => { + const line = '// @sync host=mac1 os=_mac_\n\t"mac": 3,' + expect(PragmaUtil.commentLineAfterBreak(line)).to.match(/\/\/\s"mac"/) + }) + + it('should get eight @sync pragma valid lines', () => { + const processed = PragmaUtil.processBeforeUpload(test_settings) + expect(PragmaUtil.matchPragmaSettings(processed).length).to.be.equals(8) + }) + + it('should not comment os=linux settings lines', () => { + let processed = PragmaUtil.processBeforeUpload(test_settings) + processed = PragmaUtil.processBeforeWrite(processed, OSTypes['Linux'], null) + expect(processed).to.match(/\s+"not_commented"/) + + }) + + + it('should leave only settings that matches with os=mac host=mac2 env=TEST_ENV', () => { + const processed = PragmaUtil.processBeforeUpload(test_settings) + process.env["TEST_ENV"] = true + expect(PragmaUtil.processBeforeWrite(processed, OSTypes['Mac'], 'mac2')).to.match(/\n\s+"mac2"/).and.match(/\n\s+"mactest"/) + }) +}) \ No newline at end of file diff --git a/test/pragmaUtil/testSettings.json b/test/pragmaUtil/testSettings.json new file mode 100644 index 00000000..b09b43ae --- /dev/null +++ b/test/pragmaUtil/testSettings.json @@ -0,0 +1,32 @@ +{ + + // @sync os=windows host=test + "test1": 1, + + // @sync os=windows host=test + "test2": 2, + + // @sync os= linux host= trim env= TEST_ENV + "test3": 3, + + // @sync os=linux + "not_commented": 2, + + // @sync host=_mac1_ os=mac + "mac": 3, + + // @sync host=mac2 os=mac env=TEST_ENV + "mac2": 3, + + // @sync os=mac + "mactest": "", + + // @sync host=test1 + "onlyHost": "", + + // @sync-ignore + "test4": 12, + + // @sync ignore + "test5": 12 +} \ No newline at end of file From f5fe925837d9d189ae7e0763f539e46c087ad23b Mon Sep 17 00:00:00 2001 From: Brian Mayo Date: Sun, 7 Oct 2018 18:08:49 -0300 Subject: [PATCH 22/40] Added some documentation. hostName property on custom config. --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c10b065b..82ce88ba 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ 5. Auto upload Settings on file change. 6. Share the Gist with other users and let them download your settings. 7. Supports GitHub Enterprise +8. Support pragmas with @sync keywords: host, os and env are supported. ``` @@ -247,7 +248,8 @@ You can customize the sync: "useCliBaseInstallation": true, "lastUpload": null, "lastDownload": null, - "githubEnterpriseUrl": null + "githubEnterpriseUrl": null, + "hostName": null } ``` From c88d41c4a029407ad82f944d4e165341ccd6a820 Mon Sep 17 00:00:00 2001 From: Brian Mayo Date: Mon, 8 Oct 2018 00:13:40 -0300 Subject: [PATCH 23/40] uncomment lines function. Uncomment all @sync settings before upload. Only insert comments if it doesn't match with matchine os or host or env. Uncomment line before write if it matched. --- src/pragmaUtil.ts | 32 ++++++++++++++++++++++++------- test/pragmaUtil/index.js | 16 ++++++++++++++++ test/pragmaUtil/testSettings.json | 4 ++-- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/pragmaUtil.ts b/src/pragmaUtil.ts index ca6fc04d..0aa2d561 100644 --- a/src/pragmaUtil.ts +++ b/src/pragmaUtil.ts @@ -42,9 +42,8 @@ export default class PragmaUtil { ); if (pragmaSettingsBlocks !== null) { - for (let block of pragmaSettingsBlocks) { + for (const block of pragmaSettingsBlocks) { // line e.g.: // @sync os=windows host=Laptop\n"window.menuBarVisibility": "none", - try { // check OS pragma const osMatch: RegExpMatchArray = block.match(/os=(\w+)/); @@ -78,10 +77,14 @@ export default class PragmaUtil { const envMatch: RegExpMatchArray = block.match(/env=(\S+)/); if (envMatch !== null) { const envFromPragma = envMatch[1]; - if (!process.env[envFromPragma.toUpperCase()]) { + if (process.env[envFromPragma.toUpperCase()] === undefined) { result = result.replace(block, this.commentLineAfterBreak(block)); + continue; } } + + // if os, host and evn matched the current machine make sure to uncomment the setting + result = result.replace(block, this.uncommentLineAfterBreak(block)); } catch (e) { continue; } @@ -163,12 +166,14 @@ export default class PragmaUtil { if (envMatch !== null) { const envFromPragma = envMatch[1] || envMatch[2] || envMatch[3]; if (envFromPragma !== "" && /\s/.test(envFromPragma)) { - result = result.replace( - block, - block.replace(envFromPragma, envFromPragma.trimLeft()) - ); + newBlock = block.replace(envFromPragma, envFromPragma.trimLeft()); + result = result.replace(block, newBlock); + block = newBlock; } } + + // uncomment line before upload + result = result.replace(block, this.uncommentLineAfterBreak(block)); } catch (e) { console.log("Sync: Proccess before upload error.", e.message); continue; @@ -221,6 +226,19 @@ export default class PragmaUtil { return block; } + public static uncommentLineAfterBreak(block: string): string { + const settingLine = block.match(/\n[ \t]*(.+)/); + if ( + settingLine !== null && + settingLine[1] && + settingLine[1].startsWith("//") + ) { + return block.replace(settingLine[1], l => l.replace("//", "")); + } + + return block; + } + private static readonly PragmaRegExp: RegExp = /\/\/[ \t]*\@sync[ \t]+(?:os=.+[ \t]*)?(?:host=.+[ \t]*)?(?:env=.+[ \t]*)?\n[ \t]*.+,?/g; private static readonly IgnorePragmaRegExp: RegExp = /\/\/[ \t]*\@sync-ignore.*\n.+,?/g; private static readonly HostPragmaWhiteSpacesSupportRegExp = /(?:host=(.+)os=)|(?:host=(.+)env=)|host=(.+)\n?/; diff --git a/test/pragmaUtil/index.js b/test/pragmaUtil/index.js index da3f129d..40dc4c63 100644 --- a/test/pragmaUtil/index.js +++ b/test/pragmaUtil/index.js @@ -24,11 +24,27 @@ describe('Process before upload', function () { expect(PragmaUtil.commentLineAfterBreak(line)).to.match(/\/\/\s"mac"/) }) + it('should uncomment line after linebreak', () => { + const line = '// @sync host=mac1 os=_mac_\n\t//"mac": 3,' + expect(PragmaUtil.uncommentLineAfterBreak(line)).to.match(/\t"mac"/) + }) + it('should get eight @sync pragma valid lines', () => { const processed = PragmaUtil.processBeforeUpload(test_settings) expect(PragmaUtil.matchPragmaSettings(processed).length).to.be.equals(8) }) + it('should uncomment all lines', () => { + const commentedSettings = ` + // @sync os=linux + // "window": 1, + // @sync os=mac + // "mac": 1 + ` + + expect(PragmaUtil.processBeforeUpload(commentedSettings)).to.match(/\s+"window"/).and.to.match(/\s+"mac"/) + }) + it('should not comment os=linux settings lines', () => { let processed = PragmaUtil.processBeforeUpload(test_settings) processed = PragmaUtil.processBeforeWrite(processed, OSTypes['Linux'], null) diff --git a/test/pragmaUtil/testSettings.json b/test/pragmaUtil/testSettings.json index b09b43ae..17a21cc3 100644 --- a/test/pragmaUtil/testSettings.json +++ b/test/pragmaUtil/testSettings.json @@ -7,7 +7,7 @@ "test2": 2, // @sync os= linux host= trim env= TEST_ENV - "test3": 3, + //"test2": 3, // @sync os=linux "not_commented": 2, @@ -16,7 +16,7 @@ "mac": 3, // @sync host=mac2 os=mac env=TEST_ENV - "mac2": 3, + //"mac2": 3, // @sync os=mac "mactest": "", From a369cc41710ecb226f9fb17f368351423b48f511 Mon Sep 17 00:00:00 2001 From: Brian Mayo Date: Mon, 8 Oct 2018 03:34:21 -0300 Subject: [PATCH 24/40] Do replace ments one time per setting pragma. Test uncoment function. More redeable settings json for testing. --- src/pragmaUtil.ts | 32 ++++++++++++++++--------------- test/pragmaUtil/index.js | 11 +++++++++++ test/pragmaUtil/testSettings.json | 14 +++++++------- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/pragmaUtil.ts b/src/pragmaUtil.ts index 0aa2d561..c355db79 100644 --- a/src/pragmaUtil.ts +++ b/src/pragmaUtil.ts @@ -114,19 +114,20 @@ export default class PragmaUtil { // alert not supported OS const pragmaMatches: RegExpMatchArray = result.match(this.PragmaRegExp); if (pragmaMatches) { - for (let block of pragmaMatches) { + for (const block of pragmaMatches) { try { - let newBlock: string; - const osMatch: RegExpMatchArray = block.match( + let newBlock: string = block; + const osMatch: RegExpMatchArray = newBlock.match( this.OSPragmaWhiteSpacesSupportRegExp ); if (osMatch !== null) { const osFromPragma = osMatch[1] || osMatch[2] || osMatch[3]; if (osFromPragma !== "" && /\s/.test(osFromPragma)) { - newBlock = block.replace(osFromPragma, osFromPragma.trimLeft()); - result = result.replace(block, newBlock); - block = newBlock; + newBlock = newBlock.replace( + osFromPragma, + osFromPragma.trimLeft() + ); } const trimmed = osFromPragma.toLowerCase().trim(); @@ -144,19 +145,16 @@ export default class PragmaUtil { } } - const hostMatch: RegExpMatchArray = block.match( + const hostMatch: RegExpMatchArray = newBlock.match( this.HostPragmaWhiteSpacesSupportRegExp ); if (hostMatch !== null) { const hostFromPragma = hostMatch[1] || hostMatch[2] || hostMatch[3]; if (hostFromPragma !== "" && /\s/.test(hostFromPragma)) { - newBlock = block.replace( + newBlock = newBlock.replace( hostFromPragma, hostFromPragma.trimLeft() ); - result = result.replace(block, newBlock); - - block = newBlock; } } @@ -166,14 +164,18 @@ export default class PragmaUtil { if (envMatch !== null) { const envFromPragma = envMatch[1] || envMatch[2] || envMatch[3]; if (envFromPragma !== "" && /\s/.test(envFromPragma)) { - newBlock = block.replace(envFromPragma, envFromPragma.trimLeft()); - result = result.replace(block, newBlock); - block = newBlock; + newBlock = newBlock.replace( + envFromPragma, + envFromPragma.trimLeft() + ); } } // uncomment line before upload - result = result.replace(block, this.uncommentLineAfterBreak(block)); + result = result.replace( + block, + this.uncommentLineAfterBreak(newBlock) + ); } catch (e) { console.log("Sync: Proccess before upload error.", e.message); continue; diff --git a/test/pragmaUtil/index.js b/test/pragmaUtil/index.js index 40dc4c63..8564c430 100644 --- a/test/pragmaUtil/index.js +++ b/test/pragmaUtil/index.js @@ -45,6 +45,17 @@ describe('Process before upload', function () { expect(PragmaUtil.processBeforeUpload(commentedSettings)).to.match(/\s+"window"/).and.to.match(/\s+"mac"/) }) + it('should uncomment lines before write file for os=linux', () => { + const commentedSettings = `{ + // @sync os=linux + // "linux": 1, + // @sync os=mac + "mac": 1 + }` + const processed = PragmaUtil.processBeforeWrite(commentedSettings, OSTypes['Linux'], null) + expect(processed).to.match(/\s+"linux"/).and.to.match(/.+\/\/\s+"mac"/) + }) + it('should not comment os=linux settings lines', () => { let processed = PragmaUtil.processBeforeUpload(test_settings) processed = PragmaUtil.processBeforeWrite(processed, OSTypes['Linux'], null) diff --git a/test/pragmaUtil/testSettings.json b/test/pragmaUtil/testSettings.json index 17a21cc3..de217cce 100644 --- a/test/pragmaUtil/testSettings.json +++ b/test/pragmaUtil/testSettings.json @@ -1,19 +1,19 @@ { - // @sync os=windows host=test - "test1": 1, + // @sync os=windows host=h1 + "setting.test": 1, - // @sync os=windows host=test - "test2": 2, + // @sync os=windows host=h2 + "setting.test": 2, // @sync os= linux host= trim env= TEST_ENV - //"test2": 3, + //"setting.test": 3, // @sync os=linux - "not_commented": 2, + "not_commented": 4, // @sync host=_mac1_ os=mac - "mac": 3, + "setting.test": 5, // @sync host=mac2 os=mac env=TEST_ENV //"mac2": 3, From a4c11c1f5710b73a2555b94c4ec7c258e8487b99 Mon Sep 17 00:00:00 2001 From: Brian Mayo Date: Mon, 8 Oct 2018 20:24:04 -0300 Subject: [PATCH 25/40] Add SUPPORTED_OS and osTypeFromString to environmentPath.ts as requested. Get OS from OsType enum. Remove os.hostName() --- src/environmentPath.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/environmentPath.ts b/src/environmentPath.ts index 9bef73a0..8e378fdc 100644 --- a/src/environmentPath.ts +++ b/src/environmentPath.ts @@ -7,6 +7,16 @@ import * as path from "path"; import * as vscode from "vscode"; import { OsType } from "./enums"; +export const SUPPORTED_OS: string[] = Object.keys(OsType) + .filter(k => !/\d/.test(k)) + .map(k => k.toLowerCase()); // . ["windows", "linux", "mac"]; + +export function osTypeFromString(osName: string): OsType { + const capitalized: string = + osName[0].toUpperCase() + osName.substr(1).toLowerCase(); + return OsType[capitalized]; +} + export class Environment { public static CURRENT_VERSION: number = 312; public static getVersion(): string { @@ -27,7 +37,6 @@ export class Environment { public ExtensionFolder: string = null; public PATH: string = null; public OsType: OsType = null; - public HostName: string = null; public FILE_SETTING: string = null; public FILE_LAUNCH: string = null; @@ -74,7 +83,6 @@ export class Environment { process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; this.PATH = process.env.APPDATA; this.OsType = OsType.Windows; - this.HostName = os.hostname(); if (!this.PATH) { if (process.platform === "darwin") { From d85af224d4d1d4577ec65f064397bbc90e82be1d Mon Sep 17 00:00:00 2001 From: Brian Mayo Date: Mon, 8 Oct 2018 20:27:27 -0300 Subject: [PATCH 26/40] Check valid JSON before writting file. All the comments and trilling commas are removed. Must check this. If not valid OS is detected inform user. Added function to remove comments from text. --- src/pragmaUtil.ts | 168 ++++++++++++++++++++++++---------------------- 1 file changed, 87 insertions(+), 81 deletions(-) diff --git a/src/pragmaUtil.ts b/src/pragmaUtil.ts index c355db79..a4075248 100644 --- a/src/pragmaUtil.ts +++ b/src/pragmaUtil.ts @@ -1,19 +1,7 @@ import { OsType } from "./enums"; +import { osTypeFromString, SUPPORTED_OS } from "./environmentPath"; import localize from "./localize"; -const SUPPORTED_OS = ["windows", "linux", "mac"]; - -export function GetOsEnum(osName: string): OsType { - switch (osName.toLowerCase()) { - case "windows": - return OsType.Windows; - case "linux": - return OsType.Linux; - case "mac": - return OsType.Mac; - } -} - /** * Comment/Uncomment lines if matches OS name or Hostname. * Usage: @sync os=[OS name] host=[hostName] @@ -42,27 +30,36 @@ export default class PragmaUtil { ); if (pragmaSettingsBlocks !== null) { + let osMatch: RegExpMatchArray; + let osFromPragma: string; + + let hostMatch: RegExpMatchArray; + let hostFromPragma: string; + + let envMatch: RegExpMatchArray; + let envFromPragma: string; + for (const block of pragmaSettingsBlocks) { // line e.g.: // @sync os=windows host=Laptop\n"window.menuBarVisibility": "none", try { // check OS pragma - const osMatch: RegExpMatchArray = block.match(/os=(\w+)/); + osMatch = block.match(/os=(\w+)/); if (osMatch !== null) { - const osFromPragma = osMatch[1].toLowerCase(); + osFromPragma = osMatch[1].toLowerCase(); if (!SUPPORTED_OS.includes(osFromPragma)) { continue; } - if (GetOsEnum(osFromPragma) !== osType) { + if (osTypeFromString(osFromPragma) !== osType) { result = result.replace(block, this.commentLineAfterBreak(block)); continue; // no need to lookup the host name } } // check host pragma - const hostMatch: RegExpMatchArray = block.match(/host=(\S+)/); + hostMatch = block.match(/host=(\S+)/); if (hostMatch !== null) { - const hostFromPragma = hostMatch[1]; + hostFromPragma = hostMatch[1]; if ( hostName === null || hostName === "" || @@ -74,9 +71,9 @@ export default class PragmaUtil { } // check env pragma - const envMatch: RegExpMatchArray = block.match(/env=(\S+)/); + envMatch = block.match(/env=(\S+)/); if (envMatch !== null) { - const envFromPragma = envMatch[1]; + envFromPragma = envMatch[1]; if (process.env[envFromPragma.toUpperCase()] === undefined) { result = result.replace(block, this.commentLineAfterBreak(block)); continue; @@ -86,6 +83,7 @@ export default class PragmaUtil { // if os, host and evn matched the current machine make sure to uncomment the setting result = result.replace(block, this.uncommentLineAfterBreak(block)); } catch (e) { + console.error("Sync: Error processing pragmas ", e.message); continue; } } @@ -93,6 +91,19 @@ export default class PragmaUtil { result = this.removeIgnoreBlocks(result); + // check is a valid JSON + + try { + // remove comments and trailing comma + const uncommented = this.removeAllComments(result).replace( + /,\s*\}/g, + " }" + ); + JSON.parse(uncommented); + } catch (e) { + console.error("Sync: Result content is not a valid JSON.", e.message); + } + return result; } @@ -101,85 +112,76 @@ export default class PragmaUtil { * * @static * @param {string} settingsContent - * @param {require('vscode').window} window * @returns {string} * @memberof PragmaUtil */ - public static processBeforeUpload(settingsContent: string, window): string { + public static processBeforeUpload(settingsContent: string): string { let result: string = settingsContent; result = this.removeIgnoreBlocks(result); - const lines = result.split("\n"); + const lines = result.split("\n").map(l => l.trim()); // alert not supported OS const pragmaMatches: RegExpMatchArray = result.match(this.PragmaRegExp); if (pragmaMatches) { - for (const block of pragmaMatches) { - try { - let newBlock: string = block; - const osMatch: RegExpMatchArray = newBlock.match( - this.OSPragmaWhiteSpacesSupportRegExp - ); - if (osMatch !== null) { - const osFromPragma = osMatch[1] || osMatch[2] || osMatch[3]; + let newBlock: string; - if (osFromPragma !== "" && /\s/.test(osFromPragma)) { - newBlock = newBlock.replace( - osFromPragma, - osFromPragma.trimLeft() - ); - } + let osMatch: RegExpMatchArray; + let osFromPragma: string; - const trimmed = osFromPragma.toLowerCase().trim(); - if (!SUPPORTED_OS.includes(trimmed)) { - console.warn("Sync: Invalid OS", osFromPragma); - if (window !== null) { - window.showWarningMessage( - localize( - "cmd.updateSettings.warning.OSNotSupported", - trimmed, - lines.indexOf(block) - ) - ); - } - } + let hostMatch: RegExpMatchArray; + let hostFromPragma: string; + + let envMatch: RegExpMatchArray; + let envFromPragma: string; + + for (const block of pragmaMatches) { + newBlock = block; + osMatch = newBlock.match(this.OSPragmaWhiteSpacesSupportRegExp); + if (osMatch !== null) { + osFromPragma = osMatch[1] || osMatch[2] || osMatch[3]; + + if (osFromPragma !== "" && /\s/.test(osFromPragma)) { + newBlock = newBlock.replace(osFromPragma, osFromPragma.trimLeft()); } - const hostMatch: RegExpMatchArray = newBlock.match( - this.HostPragmaWhiteSpacesSupportRegExp - ); - if (hostMatch !== null) { - const hostFromPragma = hostMatch[1] || hostMatch[2] || hostMatch[3]; - if (hostFromPragma !== "" && /\s/.test(hostFromPragma)) { - newBlock = newBlock.replace( - hostFromPragma, - hostFromPragma.trimLeft() - ); - } + const trimmed = osFromPragma.toLowerCase().trim(); + if (!SUPPORTED_OS.includes(trimmed)) { + console.warn("Sync: Invalid OS", osFromPragma); + throw new Error( + localize( + "cmd.updateSettings.warning.OSNotSupported", + trimmed, + lines.indexOf(block.split("\n")[0]) + 1 + ) + ); } + } - const envMatch: RegExpMatchArray = block.match( - this.EnvPragmaWhiteSpacesSupportRegExp - ); - if (envMatch !== null) { - const envFromPragma = envMatch[1] || envMatch[2] || envMatch[3]; - if (envFromPragma !== "" && /\s/.test(envFromPragma)) { - newBlock = newBlock.replace( - envFromPragma, - envFromPragma.trimLeft() - ); - } + hostMatch = newBlock.match(this.HostPragmaWhiteSpacesSupportRegExp); + if (hostMatch !== null) { + hostFromPragma = hostMatch[1] || hostMatch[2] || hostMatch[3]; + if (hostFromPragma !== "" && /\s/.test(hostFromPragma)) { + newBlock = newBlock.replace( + hostFromPragma, + hostFromPragma.trimLeft() + ); } + } - // uncomment line before upload - result = result.replace( - block, - this.uncommentLineAfterBreak(newBlock) - ); - } catch (e) { - console.log("Sync: Proccess before upload error.", e.message); - continue; + envMatch = block.match(this.EnvPragmaWhiteSpacesSupportRegExp); + if (envMatch !== null) { + envFromPragma = envMatch[1] || envMatch[2] || envMatch[3]; + if (envFromPragma !== "" && /\s/.test(envFromPragma)) { + newBlock = newBlock.replace( + envFromPragma, + envFromPragma.trimLeft() + ); + } } + + // uncomment line before upload + result = result.replace(block, this.uncommentLineAfterBreak(newBlock)); } } @@ -222,7 +224,7 @@ export default class PragmaUtil { settingLine[1] && !settingLine[1].startsWith("//") ) { - return block.replace(settingLine[1], l => "// " + l); + return block.replace(settingLine[1], l => "//" + l); } return block; @@ -241,6 +243,10 @@ export default class PragmaUtil { return block; } + public static removeAllComments(text: string): string { + return text.replace(/\s(\/\/.+)|(\/\*.+\*\/)/g, ""); + } + private static readonly PragmaRegExp: RegExp = /\/\/[ \t]*\@sync[ \t]+(?:os=.+[ \t]*)?(?:host=.+[ \t]*)?(?:env=.+[ \t]*)?\n[ \t]*.+,?/g; private static readonly IgnorePragmaRegExp: RegExp = /\/\/[ \t]*\@sync-ignore.*\n.+,?/g; private static readonly HostPragmaWhiteSpacesSupportRegExp = /(?:host=(.+)os=)|(?:host=(.+)env=)|host=(.+)\n?/; From c1f03c2163da35b3905f308240bab3a0c3fc2896 Mon Sep 17 00:00:00 2001 From: Brian Mayo Date: Mon, 8 Oct 2018 20:28:28 -0300 Subject: [PATCH 27/40] Chatch exception during upload. Should it abort upload? --- src/sync.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/sync.ts b/src/sync.ts index 40257f07..5c96edcd 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -212,10 +212,15 @@ export class Sync { } if (snippetFile.fileName === env.FILE_SETTING_NAME) { - snippetFile.content = PragmaUtil.processBeforeUpload( - snippetFile.content, - vscode.window - ); + try { + snippetFile.content = PragmaUtil.processBeforeUpload( + snippetFile.content + ); + } catch (e) { + Commons.LogException(null, e.message, true); + console.error(e); + return; + } } } From 2b0a3b92d58f66c549cab70f17fb22175240b492 Mon Sep 17 00:00:00 2001 From: Brian Mayo Date: Mon, 8 Oct 2018 20:30:10 -0300 Subject: [PATCH 28/40] Adding VS Code tests in typescript. Run test changing launch mode to "Launch Test". Remove javascript files. --- test/extension.test.ts | 3 ++ test/index.js | 8 ---- test/index.ts | 8 ++++ test/pragmaUtil/index.js | 72 ------------------------------- test/pragmaUtil/index.ts | 92 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 80 deletions(-) create mode 100644 test/extension.test.ts delete mode 100644 test/index.js delete mode 100644 test/pragmaUtil/index.js create mode 100644 test/pragmaUtil/index.ts diff --git a/test/extension.test.ts b/test/extension.test.ts new file mode 100644 index 00000000..1f248602 --- /dev/null +++ b/test/extension.test.ts @@ -0,0 +1,3 @@ +describe("PragmaUtil", () => { + require("./pragmaUtil"); +}); diff --git a/test/index.js b/test/index.js deleted file mode 100644 index a5874a69..00000000 --- a/test/index.js +++ /dev/null @@ -1,8 +0,0 @@ -const chai = require("chai") -const expect = chai.expect - -global.expect = expect - -describe('PragmaUtil', () => { - require('./pragmaUtil') -}) \ No newline at end of file diff --git a/test/index.ts b/test/index.ts index e69de29b..abb2dd76 100644 --- a/test/index.ts +++ b/test/index.ts @@ -0,0 +1,8 @@ +import * as testRunner from "vscode/lib/testrunner"; + +testRunner.configure({ + ui: "bdd", + useColors: true, + timeout: 5000 +}); +module.exports = testRunner; diff --git a/test/pragmaUtil/index.js b/test/pragmaUtil/index.js deleted file mode 100644 index 8564c430..00000000 --- a/test/pragmaUtil/index.js +++ /dev/null @@ -1,72 +0,0 @@ -const fs = require('fs') -const expect = require('chai').expect - -let test_settings = null - -const OSTypes = require('../../out/src/enums').OsType -const PragmaUtil = require('../../out/src/pragmaUtil').default - -describe('Process before upload', function () { - this.beforeAll(() => { - test_settings = fs.readFileSync(__dirname + '/testSettings.json', 'utf8') - }) - - it('should remove @sync-ignore and @sync ignore lines', () => { - expect(PragmaUtil.removeIgnoreBlocks(test_settings)).to.not.contains('@sync-ignore').and.not.contains('@sync ignore') - }) - - it('should trim os, host and env', () => { - expect(PragmaUtil.processBeforeUpload(test_settings)).to.match(/@sync os=linux host=trim env=TEST_ENV/) - }) - - it('should comment line after linebreak', () => { - const line = '// @sync host=mac1 os=_mac_\n\t"mac": 3,' - expect(PragmaUtil.commentLineAfterBreak(line)).to.match(/\/\/\s"mac"/) - }) - - it('should uncomment line after linebreak', () => { - const line = '// @sync host=mac1 os=_mac_\n\t//"mac": 3,' - expect(PragmaUtil.uncommentLineAfterBreak(line)).to.match(/\t"mac"/) - }) - - it('should get eight @sync pragma valid lines', () => { - const processed = PragmaUtil.processBeforeUpload(test_settings) - expect(PragmaUtil.matchPragmaSettings(processed).length).to.be.equals(8) - }) - - it('should uncomment all lines', () => { - const commentedSettings = ` - // @sync os=linux - // "window": 1, - // @sync os=mac - // "mac": 1 - ` - - expect(PragmaUtil.processBeforeUpload(commentedSettings)).to.match(/\s+"window"/).and.to.match(/\s+"mac"/) - }) - - it('should uncomment lines before write file for os=linux', () => { - const commentedSettings = `{ - // @sync os=linux - // "linux": 1, - // @sync os=mac - "mac": 1 - }` - const processed = PragmaUtil.processBeforeWrite(commentedSettings, OSTypes['Linux'], null) - expect(processed).to.match(/\s+"linux"/).and.to.match(/.+\/\/\s+"mac"/) - }) - - it('should not comment os=linux settings lines', () => { - let processed = PragmaUtil.processBeforeUpload(test_settings) - processed = PragmaUtil.processBeforeWrite(processed, OSTypes['Linux'], null) - expect(processed).to.match(/\s+"not_commented"/) - - }) - - - it('should leave only settings that matches with os=mac host=mac2 env=TEST_ENV', () => { - const processed = PragmaUtil.processBeforeUpload(test_settings) - process.env["TEST_ENV"] = true - expect(PragmaUtil.processBeforeWrite(processed, OSTypes['Mac'], 'mac2')).to.match(/\n\s+"mac2"/).and.match(/\n\s+"mactest"/) - }) -}) \ No newline at end of file diff --git a/test/pragmaUtil/index.ts b/test/pragmaUtil/index.ts new file mode 100644 index 00000000..36dce643 --- /dev/null +++ b/test/pragmaUtil/index.ts @@ -0,0 +1,92 @@ +import { expect } from "chai"; +import fs = require("fs"); +import { OsType } from "../../src/enums"; +import PragmaUtil from "../../src/pragmaUtil"; + +let testSettings = null; + +describe("Process before upload", function() { + this.beforeAll(() => { + testSettings = fs.readFileSync( + __dirname + "/../../../test/pragmaUtil/testSettings.json", + "utf8" + ); + }); + + it("should remove @sync-ignore and @sync ignore lines", () => { + expect(PragmaUtil.removeIgnoreBlocks(testSettings)) + .to.not.contains("@sync-ignore") + .and.not.contains("@sync ignore"); + }); + + it("should trim os, host and env", () => { + expect(PragmaUtil.processBeforeUpload(testSettings)).to.match( + /@sync os=linux host=trim env=TEST_ENV/ + ); + }); + + it("should comment line after linebreak", () => { + const line = '// @sync host=mac1 os=_mac_\n\t"mac": 3,'; + expect(PragmaUtil.commentLineAfterBreak(line)).to.match(/\/\/\s*"mac"/); + }); + + it("should uncomment line after linebreak", () => { + const line = '// @sync host=mac1 os=_mac_\n\t//"mac": 3,'; + expect(PragmaUtil.uncommentLineAfterBreak(line)).to.match(/\s*"mac"/); + }); + + it("should get eight @sync pragma valid lines", () => { + const processed = PragmaUtil.processBeforeUpload(testSettings); + expect(PragmaUtil.matchPragmaSettings(processed).length).to.be.equals(8); + }); + + it("should uncomment all lines", () => { + const commentedSettings = ` + // @sync os=linux + // "window": 1, + // @sync os=mac + // "mac": 1 + `; + + expect(PragmaUtil.processBeforeUpload(commentedSettings)) + .to.match(/\s+"window"/) + .and.to.match(/\s+"mac"/); + }); + + it("should uncomment lines before write file for os=linux", () => { + const commentedSettings = `{ + // @sync os=linux + // "linux": 1, + // @sync os=mac + "mac": 1 + }`; + const processed = PragmaUtil.processBeforeWrite( + commentedSettings, + OsType.Linux, + null + ); + expect(processed) + .to.match(/\s+"linux"/) + .and.to.match(/.+\/\/"mac"/); + }); + + it("should not comment os=linux settings lines", () => { + let processed = PragmaUtil.processBeforeUpload(testSettings); + processed = PragmaUtil.processBeforeWrite(processed, OsType.Linux, null); + expect(processed).to.match(/\s+"not_commented"/); + }); + + it("should leave only settings that matches with os=mac host=mac2 env=TEST_ENV", () => { + const processed = PragmaUtil.processBeforeUpload(testSettings); + // tslint:disable-next-line:no-string-literal + process.env["TEST_ENV"] = "1"; + expect(PragmaUtil.processBeforeWrite(processed, OsType.Mac, "mac2")) + .to.match(/\n\s+"mac2"/) + .and.match(/\n\s+"mactest"/); + }); + + it("should remove all comments and parse JSON", () => { + const possibleJson = PragmaUtil.removeAllComments(testSettings); + expect(JSON.parse.bind(null, possibleJson)).to.not.throw(); + }); +}); From 5811d1eef4805549bb71a8bdc096a92a363c845e Mon Sep 17 00:00:00 2001 From: David Strobach Date: Sun, 23 Sep 2018 16:40:46 +0200 Subject: [PATCH 29/40] Environment - treat non-OSS instalations on Linux as XDG --- src/environmentPath.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/environmentPath.ts b/src/environmentPath.ts index 8e378fdc..ee09b949 100644 --- a/src/environmentPath.ts +++ b/src/environmentPath.ts @@ -69,7 +69,6 @@ export class Environment { this.isOss = /\boss\b/.test(this.context.asAbsolutePath("")); const isXdg = !this.isInsiders && - !!this.isOss && process.platform === "linux" && !!process.env.XDG_DATA_HOME; this.homeDir = isXdg From a2f096bb488a9f35e3bdc5d95b541445d86a318f Mon Sep 17 00:00:00 2001 From: Shan Khan Date: Tue, 9 Oct 2018 15:21:31 +0500 Subject: [PATCH 30/40] Improvements #628 , #629 --- package.json | 2 ++ package.nls.json | 3 ++- src/commons.ts | 3 +-- src/setting.ts | 3 --- src/sync.ts | 45 +++++++++++++++++++++------------------------ 5 files changed, 26 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 419379ae..8b80ad0d 100644 --- a/package.json +++ b/package.json @@ -154,6 +154,8 @@ "devDependencies": { "@types/fs-extra": "^5.0.4", "@types/node": "^10.7.0", + "@types/chai":"4.1.6", + "@types/mocha": "^5.2.0", "chai": "^4.2.0", "mocha": "^5.2.0", "prettier": "^1.14.2", diff --git a/package.nls.json b/package.nls.json index ed9c4648..82d9a237 100644 --- a/package.nls.json +++ b/package.nls.json @@ -98,5 +98,6 @@ "common.placeholder.multipleGist": "Gist Name (e.g : Personal Settings)", "common.prompt.multipleGist": "Allows you to identify the settings if you have multiple gist.", "common.prompt.enterGistId": "Enter Gist Id from previously uploaded settings. You can also set manually in code settings (sync.gist). Press [Enter] or [Esc] to cancel.", - "common.prompt.enterGithubAccessToken": "You can manually add token also (User Folder / syncLocalSettings.json). Press [Enter] or [Esc] to cancel." + "common.prompt.enterGithubAccessToken": "You can manually add token also (User Folder / syncLocalSettings.json). Press [Enter] or [Esc] to cancel.", + "common.prompt.restartCode":"Do you want to reload to apply extensions and configurations ?" } diff --git a/src/commons.ts b/src/commons.ts index ea84e5b6..d679d130 100644 --- a/src/commons.ts +++ b/src/commons.ts @@ -11,6 +11,7 @@ import { CustomSettings, ExtensionConfig, LocalConfig } from "./setting"; import { Util } from "./util"; export default class Commons { + public static outputChannel: vscode.OutputChannel = null; public static LogException( error: any, message: string, @@ -76,7 +77,6 @@ export default class Commons { private static configWatcher = null; private static extensionWatcher = null; - private static outputChannel: vscode.OutputChannel = null; public ERROR_MESSAGE: string = localize("common.error.message"); @@ -639,7 +639,6 @@ export default class Commons { } const outputChannel = Commons.outputChannel; - outputChannel.clear(); outputChannel.appendLine( `CODE SETTINGS SYNC ${upload ? "UPLOAD" : "DOWNLOAD"} SUMMARY` ); diff --git a/src/setting.ts b/src/setting.ts index e0585e41..59c5513a 100644 --- a/src/setting.ts +++ b/src/setting.ts @@ -52,9 +52,6 @@ export class CustomSettings { public lastDownload: Date = null; public githubEnterpriseUrl: string = null; public askGistName: boolean = false; - public customFiles: { [key: string]: string } = {}; - public hostName: string = null; - } diff --git a/src/sync.ts b/src/sync.ts index 4b4b9e42..2d5fafb4 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -525,21 +525,6 @@ export class Sync { deletedExtensions = uncompletedExtensions; } } - let outputChannel: vscode.OutputChannel = null; - if (!syncSetting.quietSync) { - outputChannel = vscode.window.createOutputChannel( - "Code Settings Sync" - ); - outputChannel.clear(); - outputChannel.appendLine( - `CODE SETTINGS SYNC - COMMAND LINE EXTENSION DOWNLOAD SUMMARY` - ); - outputChannel.appendLine( - `Version: ${Environment.getVersion()}` - ); - outputChannel.appendLine(`--------------------`); - outputChannel.show(); - } try { let useCli = true; @@ -547,6 +532,18 @@ export class Sync { .getConfiguration("extensions") .get("autoUpdate"); useCli = autoUpdate; + if (useCli) { + if (!syncSetting.quietSync) { + Commons.outputChannel = vscode.window.createOutputChannel( + "Code Settings Sync" + ); + Commons.outputChannel.clear(); + Commons.outputChannel.appendLine( + `COMMAND LINE EXTENSION DOWNLOAD SUMMARY` + ); + Commons.outputChannel.appendLine(`--------------------`); + } + } addedExtensions = await PluginService.InstallExtensions( content, @@ -557,7 +554,7 @@ export class Sync { env.isInsiders, (message: string, dispose: boolean) => { if (!syncSetting.quietSync) { - outputChannel.appendLine(message); + Commons.outputChannel.appendLine(message); } else { console.log(message); if (dispose) { @@ -569,16 +566,8 @@ export class Sync { } } ); - if (!syncSetting.quietSync) { - outputChannel.clear(); - outputChannel.dispose(); - } } catch (extensions) { addedExtensions = extensions; - if (!syncSetting.quietSync) { - outputChannel.clear(); - outputChannel.dispose(); - } } } } else { @@ -647,6 +636,14 @@ export class Sync { null, localSettings ); + const message = await vscode.window.showInformationMessage( + localize("common.prompt.restartCode"), + "Yes" + ); + + if (message === "Yes") { + vscode.commands.executeCommand("workbench.action.reloadWindow"); + } vscode.window.setStatusBarMessage("").dispose(); } else { vscode.window.setStatusBarMessage("").dispose(); From d789023b87dd29da55411d589d7c975136dd1427 Mon Sep 17 00:00:00 2001 From: Tomato Date: Tue, 9 Oct 2018 17:20:58 +0200 Subject: [PATCH 31/40] minor grammatical fixes --- package.nls.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.nls.json b/package.nls.json index 82d9a237..76545864 100644 --- a/package.nls.json +++ b/package.nls.json @@ -5,7 +5,7 @@ "ext.config.lastDownload": "Settings Sync last download date. Set it as empty if you want to manually hit download.", "ext.config.autoDownload": "Set it true to Auto Download the settings on code start. [Code Restart Required]", "ext.config.autoUpload": "Set it true to Auto Upload on the settings change. [Code Restart Required]", - "ext.config.forceDownload": "Set it to true if you want to download the settings even when you have latest settings.", + "ext.config.forceDownload": "Set it to true if you want to download the settings even when you have the latest settings.", "ext.config.host": "Set it to your GitHub Enterprise host if you want to use GHE.", "ext.config.pathPrefix": "Set it to your GitHub Enterprise API prefix if you want to use GHE. Normally '/api/v3'. Only used when host is set.", "ext.config.quietSync": "When set to true, will show the result in status bar instead of summary page.", @@ -29,7 +29,7 @@ "cmd.downloadSettings.title": "Sync : Download Settings", "cmd.downloadSettings.info.downloaded": "Sync : Download Complete.", "cmd.downloadSettings.info.readdingOnline": "Sync : Reading Settings Online.", - "cmd.downloadSettings.info.gotLatestVersion": "Sync : You already have latest version of saved settings.", + "cmd.downloadSettings.info.gotLatestVersion": "Sync : You already have the latest version of saved settings.", "cmd.downloadSettings.error.removeExtFail": "Sync : Unable to remove some extensions.", "cmd.downloadSettings.error.unableSave": "Sync : Unable to save extension settings file.", "cmd.resetSettings.title": "Sync : Reset Extension Settings", @@ -98,6 +98,6 @@ "common.placeholder.multipleGist": "Gist Name (e.g : Personal Settings)", "common.prompt.multipleGist": "Allows you to identify the settings if you have multiple gist.", "common.prompt.enterGistId": "Enter Gist Id from previously uploaded settings. You can also set manually in code settings (sync.gist). Press [Enter] or [Esc] to cancel.", - "common.prompt.enterGithubAccessToken": "You can manually add token also (User Folder / syncLocalSettings.json). Press [Enter] or [Esc] to cancel.", - "common.prompt.restartCode":"Do you want to reload to apply extensions and configurations ?" + "common.prompt.enterGithubAccessToken": "You also manually add a token (User Folder / syncLocalSettings.json). Press [Enter] or [Esc] to cancel.", + "common.prompt.restartCode":"Do you want to reload to apply extensions and configurations?" } From 3879ab389f4a5cd5fcd96995583c70e1bc496b87 Mon Sep 17 00:00:00 2001 From: Takara Hokao Date: Tue, 9 Oct 2018 20:06:48 +0900 Subject: [PATCH 32/40] add fileService.test.ts --- test/service/fileService/dummyrc | 3 ++ test/service/fileService/fileService.test.ts | 36 ++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 test/service/fileService/dummyrc create mode 100644 test/service/fileService/fileService.test.ts diff --git a/test/service/fileService/dummyrc b/test/service/fileService/dummyrc new file mode 100644 index 00000000..02eb9c90 --- /dev/null +++ b/test/service/fileService/dummyrc @@ -0,0 +1,3 @@ +{ + "hoge": true, +} \ No newline at end of file diff --git a/test/service/fileService/fileService.test.ts b/test/service/fileService/fileService.test.ts new file mode 100644 index 00000000..b73a7a8e --- /dev/null +++ b/test/service/fileService/fileService.test.ts @@ -0,0 +1,36 @@ +import { expect } from "chai"; + +import { File, FileService } from "../../../src/service/fileService"; + +describe("FileService", () => { + it("should get custom file info", async () => { + const expected = new File( + "dummyrc", + '{\n "hoge": true,\n}', + __dirname + "/../../../../test/service/fileService/dummyrc", + "|customized_sync|dummyrc" + ); + const actual = await FileService.GetCustomFile( + __dirname + "/../../../../test/service/fileService/dummyrc", // __dirname => out/src/test/service + "dummyrc" + ); + expect(actual).to.deep.equals(expected); + }); + + it("should return null if file does not exists", async () => { + const actual = await FileService.GetCustomFile( + __dirname + "/../../../../test/service/fileService/hoge", + "hoge" + ); + expect(actual).to.be.equals(null); + }); + + it("should join by path separator", () => { + const actual = FileService.ConcatPath( + "/User/path/to", + "hoge/piyo", + "hoge.txt" + ); + expect(actual).to.be.equals("/User/path/to/hoge/piyo/hoge.txt"); + }); +}); From 276c430a3f5fae39c0e52fe74df8b346c185d062 Mon Sep 17 00:00:00 2001 From: Shan Khan Date: Thu, 11 Oct 2018 14:41:03 +0500 Subject: [PATCH 33/40] Version Change --- package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index a2d41d9a..25567657 100644 --- a/package.json +++ b/package.json @@ -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.1.2", + "version": "3.2.0", "icon": "images/cloud.png", "publisher": "Shan", "author": { @@ -46,7 +46,7 @@ "email": "shanalikhan@hotmail.com" }, "engines": { - "vscode": "^1.8.0" + "vscode": "^1.28.0" }, "categories": [ "Other" @@ -153,23 +153,23 @@ }, "devDependencies": { "@types/fs-extra": "^5.0.4", - "@types/node": "^10.7.0", + "@types/node": "^10.11.6", "@types/chai":"4.1.6", "@types/mocha": "^5.2.0", "chai": "^4.2.0", "mocha": "^5.2.0", - "prettier": "^1.14.2", + "prettier": "^1.14.3", "tslint": "^5.11.0", "tslint-plugin-prettier": "^2.0.0", - "typescript": "^3.0.1", + "typescript": "^3.1.2", "vscode": "^1.1.21" }, "dependencies": { - "@octokit/rest": "^15.10.0", + "@octokit/rest": "^15.13.0", "adm-zip": "^0.4.11", - "chokidar": "^2.0.2", + "chokidar": "^2.0.4", "fs-extra": "^7.0.0", - "https-proxy-agent": "^2.1.1", + "https-proxy-agent": "^2.2.1", "lockfile": "^1.0.4", "temp": "^0.8.3" } From f5577da6b612d3cd20f9bcf3bddeeb5e254590e3 Mon Sep 17 00:00:00 2001 From: Shan Khan Date: Thu, 11 Oct 2018 14:42:52 +0500 Subject: [PATCH 34/40] #331 --- src/environmentPath.ts | 101 ++++++++++++++++++++++------------------- src/sync.ts | 1 + 2 files changed, 56 insertions(+), 46 deletions(-) diff --git a/src/environmentPath.ts b/src/environmentPath.ts index ee09b949..ad0fb54a 100644 --- a/src/environmentPath.ts +++ b/src/environmentPath.ts @@ -18,7 +18,7 @@ export function osTypeFromString(osName: string): OsType { } export class Environment { - public static CURRENT_VERSION: number = 312; + public static CURRENT_VERSION: number = 320; public static getVersion(): string { return ( Environment.CURRENT_VERSION.toString().slice(0, 1) + @@ -31,8 +31,9 @@ export class Environment { public isInsiders: boolean = false; public isOss: boolean = false; + public isPortable : boolean = false; public homeDir: string | null = null; - public USER_FOLDER = null; + public USER_FOLDER : string = null; public ExtensionFolder: string = null; public PATH: string = null; @@ -61,11 +62,10 @@ export class Environment { public FILE_CLOUDSETTINGS_NAME: string = "cloudSettings"; public FOLDER_SNIPPETS: string = null; - public APP_SUMMARY_NAME: string = "syncSummary.txt"; - public APP_SUMMARY: string = null; constructor(private context: vscode.ExtensionContext) { this.isInsiders = /insiders/.test(this.context.asAbsolutePath("")); + this.isPortable = process.env.VSCODE_PORTABLE ? true : false; this.isOss = /\boss\b/.test(this.context.asAbsolutePath("")); const isXdg = !this.isInsiders && @@ -77,13 +77,12 @@ export class Environment { const configSuffix = `${isXdg ? "" : "."}vscode${ this.isInsiders ? "-insiders" : this.isOss ? "-oss" : "" }`; - this.ExtensionFolder = path.join(this.homeDir, configSuffix, "extensions"); - + process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; this.PATH = process.env.APPDATA; this.OsType = OsType.Windows; - if (!this.PATH) { + if (!this.PATH && !this.isPortable) { if (process.platform === "darwin") { this.PATH = process.env.HOME + "/Library/Application Support"; this.OsType = OsType.Mac; @@ -99,6 +98,19 @@ export class Environment { } } + if (!this.PATH && this.isPortable) { + 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 { + this.PATH = process.env.VSCODE_PORTABLE; + this.OsType = OsType.Linux; + } + } + if (this.OsType === OsType.Linux) { const myExt = "chmod +x " + @@ -110,46 +122,43 @@ export class Environment { // command output is in stdout }); } - - const possibleCodePaths = []; - if (this.isInsiders) { - possibleCodePaths.push("/Code - Insiders"); - } else if (this.isOss) { - possibleCodePaths.push("/Code - OSS"); - possibleCodePaths.push("/VSCodium"); - } else { - possibleCodePaths.push("/Code"); - } - for (const possibleCodePath of possibleCodePaths) { - try { - fs.statSync(this.PATH + possibleCodePath); - this.PATH = this.PATH + possibleCodePath; - break; - } catch (e) { - console.error("Error :" + possibleCodePath); - console.error(e); + if(!this.isPortable){ + const possibleCodePaths = []; + if (this.isInsiders) { + possibleCodePaths.push("/Code - Insiders"); + } else if (this.isOss) { + possibleCodePaths.push("/Code - OSS"); + possibleCodePaths.push("/VSCodium"); + } else { + possibleCodePaths.push("/Code"); + } + for (const possibleCodePath of possibleCodePaths) { + try { + fs.statSync(this.PATH + possibleCodePath); + this.PATH = this.PATH + possibleCodePath; + break; + } catch (e) { + console.error("Error :" + possibleCodePath); + console.error(e); + } } + this.ExtensionFolder = path.join(this.homeDir, configSuffix, "extensions"); + this.USER_FOLDER = this.PATH.concat("/User/"); + } - this.USER_FOLDER = this.PATH.concat("/User/"); - - this.FILE_EXTENSION = this.PATH.concat("/User/", this.FILE_EXTENSION_NAME); - this.FILE_SETTING = this.PATH.concat("/User/", this.FILE_SETTING_NAME); - this.FILE_LAUNCH = this.PATH.concat("/User/", this.FILE_LAUNCH_NAME); - this.FILE_KEYBINDING = this.PATH.concat( - "/User/", - this.FILE_KEYBINDING_NAME - ); - this.FILE_LOCALE = this.PATH.concat("/User/", this.FILE_LOCALE_NAME); - this.FOLDER_SNIPPETS = this.PATH.concat("/User/snippets/"); - this.APP_SUMMARY = this.PATH.concat("/User/", this.APP_SUMMARY_NAME); - this.FILE_CLOUDSETTINGS = this.PATH.concat( - "/User/", - this.FILE_CLOUDSETTINGS_NAME - ); - this.FILE_CUSTOMIZEDSETTINGS = this.PATH.concat( - "/User/", - this.FILE_CUSTOMIZEDSETTINGS_NAME - ); - this.FILE_SYNC_LOCK = this.PATH.concat("/User/", this.FILE_SYNC_LOCK_NAME); + else{ + this.USER_FOLDER = this.PATH.concat("/user-data/User/"); + this.ExtensionFolder = this.PATH.concat("/extensions/") + } + + this.FILE_EXTENSION = this.USER_FOLDER.concat(this.FILE_EXTENSION_NAME); + this.FILE_SETTING = this.USER_FOLDER.concat(this.FILE_SETTING_NAME); + this.FILE_LAUNCH = this.USER_FOLDER.concat(this.FILE_LAUNCH_NAME); + this.FILE_KEYBINDING = this.USER_FOLDER.concat(this.FILE_KEYBINDING_NAME); + this.FILE_LOCALE = this.USER_FOLDER.concat(this.FILE_LOCALE_NAME); + this.FOLDER_SNIPPETS = this.USER_FOLDER.concat("/snippets/"); + this.FILE_CLOUDSETTINGS = this.USER_FOLDER.concat(this.FILE_CLOUDSETTINGS_NAME); + this.FILE_CUSTOMIZEDSETTINGS = this.USER_FOLDER.concat(this.FILE_CUSTOMIZEDSETTINGS_NAME); + this.FILE_SYNC_LOCK = this.USER_FOLDER.concat(this.FILE_SYNC_LOCK_NAME); } } diff --git a/src/sync.ts b/src/sync.ts index 2d5fafb4..05876c71 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -542,6 +542,7 @@ export class Sync { `COMMAND LINE EXTENSION DOWNLOAD SUMMARY` ); Commons.outputChannel.appendLine(`--------------------`); + Commons.outputChannel.show(); } } From 6d1b44bd93c32dfc7fda3a2f010f998b662a1885 Mon Sep 17 00:00:00 2001 From: Shan Khan Date: Fri, 12 Oct 2018 17:06:16 +0500 Subject: [PATCH 35/40] #513 --- src/commons.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commons.ts b/src/commons.ts index d679d130..ffec1634 100644 --- a/src/commons.ts +++ b/src/commons.ts @@ -169,14 +169,12 @@ export default class Commons { requiredFileChanged = path.indexOf(this.en.FILE_SYNC_LOCK_NAME) === -1 && path.indexOf(".DS_Store") === -1 && - path.indexOf(this.en.APP_SUMMARY_NAME) === -1 && path.indexOf(this.en.FILE_CUSTOMIZEDSETTINGS_NAME) === -1; } else { requiredFileChanged = path.indexOf(this.en.FILE_SYNC_LOCK_NAME) === -1 && path.indexOf("workspaceStorage") === -1 && path.indexOf(".DS_Store") === -1 && - path.indexOf(this.en.APP_SUMMARY_NAME) === -1 && path.indexOf(this.en.FILE_CUSTOMIZEDSETTINGS_NAME) === -1; } @@ -481,7 +479,9 @@ export default class Commons { setting[keyName] = ""; } if (keyName.toLowerCase() !== "token") { - allKeysUpdated.push(config.update(keyName, setting[keyName], true)); + if (config.get(keyName) !== setting[keyName]) { + allKeysUpdated.push(config.update(keyName, setting[keyName], true)); + } } }); From e68a2438660567c8116afce677d5e182442b7b67 Mon Sep 17 00:00:00 2001 From: NavyAdmiral <40662484+NavyAdmiral@users.noreply.github.com> Date: Mon, 15 Oct 2018 04:48:09 -0400 Subject: [PATCH 36/40] Add webpack bundling (#676) * Update issue templates * add webpack bundling for faster startup * no conflicts --- .github/ISSUE_TEMPLATE/---bug-report.md | 2 + .vscode/launch.json | 2 +- package.json | 315 ++++++++++++------------ webpack.config.js | 44 ++++ 4 files changed, 207 insertions(+), 156 deletions(-) create mode 100644 webpack.config.js diff --git a/.github/ISSUE_TEMPLATE/---bug-report.md b/.github/ISSUE_TEMPLATE/---bug-report.md index ab54326b..95b73a63 100644 --- a/.github/ISSUE_TEMPLATE/---bug-report.md +++ b/.github/ISSUE_TEMPLATE/---bug-report.md @@ -10,6 +10,8 @@ A clear and concise description of what the bug is. 🌴 **Visual Studio Code Version :** [ VERSION_HERE ] 🌴 **Code Settings Sync Version :** [ VERSION_HERE ] +🌴 **Standard or Insiders :** [ _here_ ] +🌴 **OSS or Portable :** [ _here_ ] 🌴 **Operating System :** [ VERSION_HERE ] 🌴 **Occurs On:** [Upload / Download / Help Configuring ] 🌴 **Proxy Enabled:** [ Yes / No ] diff --git a/.vscode/launch.json b/.vscode/launch.json index 73c6c6b9..35677aff 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,7 @@ "args": ["--extensionDevelopmentPath=${workspaceRoot}"], "stopOnEntry": false, "sourceMaps": true, - "outFiles": ["${workspaceRoot}/out/src/**/*.js"], + "outFiles": ["${workspaceRoot}/out/**/*.js"], "preLaunchTask": "npm" }, { diff --git a/package.json b/package.json index 25567657..5710ef06 100644 --- a/package.json +++ b/package.json @@ -1,176 +1,181 @@ { - "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.0", - "icon": "images/cloud.png", - "publisher": "Shan", - "author": { - "name": "Shan Khan", - "url": "http://shanalikhan.github.io", - "email": "shanalikhan@hotmail.com" - }, - "homepage": "https://shanalikhan.github.io", - "galleryBanner": { - "color": "#3B4859", - "theme": "dark" - }, - "badges": [ - { - "url": "https://vsmarketplacebadge.apphb.com/version/Shan.code-settings-sync.svg", - "description": "Latest Version", - "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" + "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.0", + "icon": "images/cloud.png", + "publisher": "Shan", + "author": { + "name": "Shan Khan", + "url": "http://shanalikhan.github.io", + "email": "shanalikhan@hotmail.com" }, - { - "url": "https://vsmarketplacebadge.apphb.com/installs/Shan.code-settings-sync.svg", - "description": "Total Downloads", - "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" + "homepage": "https://shanalikhan.github.io", + "galleryBanner": { + "color": "#3B4859", + "theme": "dark" }, - { - "url": "https://vsmarketplacebadge.apphb.com/rating/Shan.code-settings-sync.svg", - "description": "Ratings", - "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" - }, - { - "url": "https://img.shields.io/badge/Join%20Community-slack-green.svg", - "description": "Join Slack Community", - "href": "https://join.slack.com/t/codesettingssync/shared_invite/enQtMzE3MjY5NTczNDMwLTYwMTIwNGExOGE2MTJkZWU0OTU5MmI3ZTc4N2JkZjhjMzY1OTk5OGExZjkwMDMzMDU4ZTBlYjk5MGQwZmMyNzk" - } - ], - "repository": { - "type": "git", - "url": "https://github.com/shanalikhan/code-settings-sync.git" - }, - "bugs": { - "url": "https://github.com/shanalikhan/code-settings-sync/issues", - "email": "shanalikhan@hotmail.com" - }, - "engines": { - "vscode": "^1.28.0" - }, - "categories": [ - "Other" - ], - "keywords": [ - "vscode-sync", - "vscode-settings-sync", - "code-settings-sync", - "settings-sync", - "workspace-sync", - "multi-root ready" - ], - "activationEvents": [ - "*" - ], - "main": "./out/src/extension", - "contributes": { - "commands": [ - { - "command": "extension.HowSettings", - "title": "%cmd.howSetting.title%" - }, + "badges": [ { - "command": "extension.downloadSettings", - "title": "%cmd.downloadSettings.title%" + "url": "https://vsmarketplacebadge.apphb.com/version/Shan.code-settings-sync.svg", + "description": "Latest Version", + "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" }, { - "command": "extension.updateSettings", - "title": "%cmd.updateSettings.title%" + "url": "https://vsmarketplacebadge.apphb.com/installs/Shan.code-settings-sync.svg", + "description": "Total Downloads", + "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" }, { - "command": "extension.resetSettings", - "title": "%cmd.resetSettings.title%" + "url": "https://vsmarketplacebadge.apphb.com/rating/Shan.code-settings-sync.svg", + "description": "Ratings", + "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" }, { - "command": "extension.otherOptions", - "title": "%cmd.otherOptions.title%" + "url": "https://img.shields.io/badge/Join%20Community-slack-green.svg", + "description": "Join Slack Community", + "href": "https://join.slack.com/t/codesettingssync/shared_invite/enQtMzE3MjY5NTczNDMwLTYwMTIwNGExOGE2MTJkZWU0OTU5MmI3ZTc4N2JkZjhjMzY1OTk5OGExZjkwMDMzMDU4ZTBlYjk5MGQwZmMyNzk" } ], - "keybindings": [ - { - "key": "alt+shift+u", - "command": "extension.updateSettings" - }, - { - "key": "alt+shift+d", - "command": "extension.downloadSettings" - } + "repository": { + "type": "git", + "url": "https://github.com/shanalikhan/code-settings-sync.git" + }, + "bugs": { + "url": "https://github.com/shanalikhan/code-settings-sync/issues", + "email": "shanalikhan@hotmail.com" + }, + "engines": { + "vscode": "^1.28.0" + }, + "categories": [ + "Other" ], - "configuration": { - "properties": { - "sync.gist": { - "type": "string", - "default": "", - "description": "%ext.config.gist%" - }, - "sync.autoDownload": { - "type": "boolean", - "default": false, - "description": "%ext.config.autoDownload%" - }, - "sync.autoUpload": { - "type": "boolean", - "default": false, - "description": "%ext.config.autoUpload%" + "keywords": [ + "vscode-sync", + "vscode-settings-sync", + "code-settings-sync", + "settings-sync", + "workspace-sync", + "multi-root ready" + ], + "activationEvents": [ + "*" + ], + "main": "./out/extension", + "contributes": { + "commands": [ + { + "command": "extension.HowSettings", + "title": "%cmd.howSetting.title%" }, - "sync.forceDownload": { - "type": "boolean", - "default": false, - "description": "%ext.config.forceDownload%" + { + "command": "extension.downloadSettings", + "title": "%cmd.downloadSettings.title%" }, - "sync.quietSync": { - "type": "boolean", - "default": false, - "description": "%ext.config.quietSync%" + { + "command": "extension.updateSettings", + "title": "%cmd.updateSettings.title%" }, - "sync.askGistName": { - "type": "boolean", - "default": false, - "description": "%ext.config.askGistName%" + { + "command": "extension.resetSettings", + "title": "%cmd.resetSettings.title%" }, - "sync.removeExtensions": { - "type": "boolean", - "default": true, - "description": "%ext.config.removeExtensions%" + { + "command": "extension.otherOptions", + "title": "%cmd.otherOptions.title%" + } + ], + "keybindings": [ + { + "key": "alt+shift+u", + "command": "extension.updateSettings" }, - "sync.syncExtensions": { - "type": "boolean", - "default": true, - "description": "%ext.config.syncExtensions%" + { + "key": "alt+shift+d", + "command": "extension.downloadSettings" } - }, - "title": "%ext.config.title%" + ], + "configuration": { + "properties": { + "sync.gist": { + "type": "string", + "default": "", + "description": "%ext.config.gist%" + }, + "sync.autoDownload": { + "type": "boolean", + "default": false, + "description": "%ext.config.autoDownload%" + }, + "sync.autoUpload": { + "type": "boolean", + "default": false, + "description": "%ext.config.autoUpload%" + }, + "sync.forceDownload": { + "type": "boolean", + "default": false, + "description": "%ext.config.forceDownload%" + }, + "sync.quietSync": { + "type": "boolean", + "default": false, + "description": "%ext.config.quietSync%" + }, + "sync.askGistName": { + "type": "boolean", + "default": false, + "description": "%ext.config.askGistName%" + }, + "sync.removeExtensions": { + "type": "boolean", + "default": true, + "description": "%ext.config.removeExtensions%" + }, + "sync.syncExtensions": { + "type": "boolean", + "default": true, + "description": "%ext.config.syncExtensions%" + } + }, + "title": "%ext.config.title%" + } + }, + "scripts": { + "vscode:prepublish": "npm run tslint-check && npm run compile", + "compile": "webpack --mode production", + "compile:dev": "webpack --mode development", + "compile:watch": "webpack --mode development --watch", + "watch": "tsc -watch -p ./", + "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" + }, + "devDependencies": { + "@types/fs-extra": "^5.0.4", + "@types/node": "^10.11.6", + "@types/chai":"4.1.6", + "@types/mocha": "^5.2.0", + "chai": "^4.2.0", + "mocha": "^5.2.0", + "prettier": "^1.14.3", + "ts-loader": "^5.2.1", + "tslint": "^5.11.0", + "tslint-plugin-prettier": "^2.0.0", + "typescript": "^3.1.2", + "vscode": "^1.1.21", + "webpack": "^4.20.2", + "webpack-cli": "^3.1.2" + }, + "dependencies": { + "@octokit/rest": "^15.13.0", + "adm-zip": "^0.4.11", + "chokidar": "^2.0.4", + "fs-extra": "^7.0.0", + "https-proxy-agent": "^2.2.1", + "lockfile": "^1.0.4", + "temp": "^0.8.3" } - }, - "scripts": { - "vscode:prepublish": "npm run tslint-check && npm run compile", - "compile": "tsc -p ./", - "watch": "tsc -watch -p ./", - "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" - }, - "devDependencies": { - "@types/fs-extra": "^5.0.4", - "@types/node": "^10.11.6", - "@types/chai":"4.1.6", - "@types/mocha": "^5.2.0", - "chai": "^4.2.0", - "mocha": "^5.2.0", - "prettier": "^1.14.3", - "tslint": "^5.11.0", - "tslint-plugin-prettier": "^2.0.0", - "typescript": "^3.1.2", - "vscode": "^1.1.21" - }, - "dependencies": { - "@octokit/rest": "^15.13.0", - "adm-zip": "^0.4.11", - "chokidar": "^2.0.4", - "fs-extra": "^7.0.0", - "https-proxy-agent": "^2.2.1", - "lockfile": "^1.0.4", - "temp": "^0.8.3" } -} diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 00000000..d97e76b0 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,44 @@ +const path = require('path') +const config = { + target: 'node', + entry: './src/extension.ts', + output: { + path: path.resolve(__dirname, 'out'), + filename: 'extension.js', + libraryTarget: 'commonjs2', + devtoolModuleFilenameTemplate: 'file:///[absolute-resource-path]' + }, + devtool: 'source-map', + externals: { + vscode: 'commonjs vscode', + fsevents: 'commonjs fsevents', + 'utf-8-validate': 'utf-8-validate', + 'bufferutil': 'bufferutil' + }, + resolve: { + extensions: ['tsx', '.ts', '.jsx', '.js'] + }, + node: { + __dirname: false, + __filename: false, + }, + module: { + rules: [ + { + test: /\.ts$/, + exclude: /node_modules/, + use: [ + { + loader: 'ts-loader' + } + ] + }, + { + type: 'javascript/auto', + test: /\.mjs$/, + use: [] + } + ] + } +} +module.exports = config From 29839a915ebc61877c8ffce54333e6996fc55962 Mon Sep 17 00:00:00 2001 From: Shan Khan Date: Tue, 16 Oct 2018 14:07:09 +0500 Subject: [PATCH 37/40] Revert "Add webpack bundling (#676)" (#679) This reverts commit e68a2438660567c8116afce677d5e182442b7b67. --- .github/ISSUE_TEMPLATE/---bug-report.md | 2 - .vscode/launch.json | 2 +- package.json | 315 ++++++++++++------------ webpack.config.js | 44 ---- 4 files changed, 156 insertions(+), 207 deletions(-) delete mode 100644 webpack.config.js diff --git a/.github/ISSUE_TEMPLATE/---bug-report.md b/.github/ISSUE_TEMPLATE/---bug-report.md index 95b73a63..ab54326b 100644 --- a/.github/ISSUE_TEMPLATE/---bug-report.md +++ b/.github/ISSUE_TEMPLATE/---bug-report.md @@ -10,8 +10,6 @@ A clear and concise description of what the bug is. 🌴 **Visual Studio Code Version :** [ VERSION_HERE ] 🌴 **Code Settings Sync Version :** [ VERSION_HERE ] -🌴 **Standard or Insiders :** [ _here_ ] -🌴 **OSS or Portable :** [ _here_ ] 🌴 **Operating System :** [ VERSION_HERE ] 🌴 **Occurs On:** [Upload / Download / Help Configuring ] 🌴 **Proxy Enabled:** [ Yes / No ] diff --git a/.vscode/launch.json b/.vscode/launch.json index 35677aff..73c6c6b9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,7 @@ "args": ["--extensionDevelopmentPath=${workspaceRoot}"], "stopOnEntry": false, "sourceMaps": true, - "outFiles": ["${workspaceRoot}/out/**/*.js"], + "outFiles": ["${workspaceRoot}/out/src/**/*.js"], "preLaunchTask": "npm" }, { diff --git a/package.json b/package.json index 5710ef06..25567657 100644 --- a/package.json +++ b/package.json @@ -1,181 +1,176 @@ { - "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.0", - "icon": "images/cloud.png", - "publisher": "Shan", - "author": { - "name": "Shan Khan", - "url": "http://shanalikhan.github.io", - "email": "shanalikhan@hotmail.com" + "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.0", + "icon": "images/cloud.png", + "publisher": "Shan", + "author": { + "name": "Shan Khan", + "url": "http://shanalikhan.github.io", + "email": "shanalikhan@hotmail.com" + }, + "homepage": "https://shanalikhan.github.io", + "galleryBanner": { + "color": "#3B4859", + "theme": "dark" + }, + "badges": [ + { + "url": "https://vsmarketplacebadge.apphb.com/version/Shan.code-settings-sync.svg", + "description": "Latest Version", + "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" }, - "homepage": "https://shanalikhan.github.io", - "galleryBanner": { - "color": "#3B4859", - "theme": "dark" + { + "url": "https://vsmarketplacebadge.apphb.com/installs/Shan.code-settings-sync.svg", + "description": "Total Downloads", + "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" }, - "badges": [ + { + "url": "https://vsmarketplacebadge.apphb.com/rating/Shan.code-settings-sync.svg", + "description": "Ratings", + "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" + }, + { + "url": "https://img.shields.io/badge/Join%20Community-slack-green.svg", + "description": "Join Slack Community", + "href": "https://join.slack.com/t/codesettingssync/shared_invite/enQtMzE3MjY5NTczNDMwLTYwMTIwNGExOGE2MTJkZWU0OTU5MmI3ZTc4N2JkZjhjMzY1OTk5OGExZjkwMDMzMDU4ZTBlYjk5MGQwZmMyNzk" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/shanalikhan/code-settings-sync.git" + }, + "bugs": { + "url": "https://github.com/shanalikhan/code-settings-sync/issues", + "email": "shanalikhan@hotmail.com" + }, + "engines": { + "vscode": "^1.28.0" + }, + "categories": [ + "Other" + ], + "keywords": [ + "vscode-sync", + "vscode-settings-sync", + "code-settings-sync", + "settings-sync", + "workspace-sync", + "multi-root ready" + ], + "activationEvents": [ + "*" + ], + "main": "./out/src/extension", + "contributes": { + "commands": [ + { + "command": "extension.HowSettings", + "title": "%cmd.howSetting.title%" + }, { - "url": "https://vsmarketplacebadge.apphb.com/version/Shan.code-settings-sync.svg", - "description": "Latest Version", - "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" + "command": "extension.downloadSettings", + "title": "%cmd.downloadSettings.title%" }, { - "url": "https://vsmarketplacebadge.apphb.com/installs/Shan.code-settings-sync.svg", - "description": "Total Downloads", - "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" + "command": "extension.updateSettings", + "title": "%cmd.updateSettings.title%" }, { - "url": "https://vsmarketplacebadge.apphb.com/rating/Shan.code-settings-sync.svg", - "description": "Ratings", - "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" + "command": "extension.resetSettings", + "title": "%cmd.resetSettings.title%" }, { - "url": "https://img.shields.io/badge/Join%20Community-slack-green.svg", - "description": "Join Slack Community", - "href": "https://join.slack.com/t/codesettingssync/shared_invite/enQtMzE3MjY5NTczNDMwLTYwMTIwNGExOGE2MTJkZWU0OTU5MmI3ZTc4N2JkZjhjMzY1OTk5OGExZjkwMDMzMDU4ZTBlYjk5MGQwZmMyNzk" + "command": "extension.otherOptions", + "title": "%cmd.otherOptions.title%" } ], - "repository": { - "type": "git", - "url": "https://github.com/shanalikhan/code-settings-sync.git" - }, - "bugs": { - "url": "https://github.com/shanalikhan/code-settings-sync/issues", - "email": "shanalikhan@hotmail.com" - }, - "engines": { - "vscode": "^1.28.0" - }, - "categories": [ - "Other" - ], - "keywords": [ - "vscode-sync", - "vscode-settings-sync", - "code-settings-sync", - "settings-sync", - "workspace-sync", - "multi-root ready" - ], - "activationEvents": [ - "*" + "keybindings": [ + { + "key": "alt+shift+u", + "command": "extension.updateSettings" + }, + { + "key": "alt+shift+d", + "command": "extension.downloadSettings" + } ], - "main": "./out/extension", - "contributes": { - "commands": [ - { - "command": "extension.HowSettings", - "title": "%cmd.howSetting.title%" + "configuration": { + "properties": { + "sync.gist": { + "type": "string", + "default": "", + "description": "%ext.config.gist%" }, - { - "command": "extension.downloadSettings", - "title": "%cmd.downloadSettings.title%" + "sync.autoDownload": { + "type": "boolean", + "default": false, + "description": "%ext.config.autoDownload%" }, - { - "command": "extension.updateSettings", - "title": "%cmd.updateSettings.title%" + "sync.autoUpload": { + "type": "boolean", + "default": false, + "description": "%ext.config.autoUpload%" }, - { - "command": "extension.resetSettings", - "title": "%cmd.resetSettings.title%" + "sync.forceDownload": { + "type": "boolean", + "default": false, + "description": "%ext.config.forceDownload%" }, - { - "command": "extension.otherOptions", - "title": "%cmd.otherOptions.title%" - } - ], - "keybindings": [ - { - "key": "alt+shift+u", - "command": "extension.updateSettings" + "sync.quietSync": { + "type": "boolean", + "default": false, + "description": "%ext.config.quietSync%" }, - { - "key": "alt+shift+d", - "command": "extension.downloadSettings" - } - ], - "configuration": { - "properties": { - "sync.gist": { - "type": "string", - "default": "", - "description": "%ext.config.gist%" - }, - "sync.autoDownload": { - "type": "boolean", - "default": false, - "description": "%ext.config.autoDownload%" - }, - "sync.autoUpload": { - "type": "boolean", - "default": false, - "description": "%ext.config.autoUpload%" - }, - "sync.forceDownload": { - "type": "boolean", - "default": false, - "description": "%ext.config.forceDownload%" - }, - "sync.quietSync": { - "type": "boolean", - "default": false, - "description": "%ext.config.quietSync%" - }, - "sync.askGistName": { - "type": "boolean", - "default": false, - "description": "%ext.config.askGistName%" - }, - "sync.removeExtensions": { - "type": "boolean", - "default": true, - "description": "%ext.config.removeExtensions%" - }, - "sync.syncExtensions": { - "type": "boolean", - "default": true, - "description": "%ext.config.syncExtensions%" - } + "sync.askGistName": { + "type": "boolean", + "default": false, + "description": "%ext.config.askGistName%" }, - "title": "%ext.config.title%" - } - }, - "scripts": { - "vscode:prepublish": "npm run tslint-check && npm run compile", - "compile": "webpack --mode production", - "compile:dev": "webpack --mode development", - "compile:watch": "webpack --mode development --watch", - "watch": "tsc -watch -p ./", - "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" - }, - "devDependencies": { - "@types/fs-extra": "^5.0.4", - "@types/node": "^10.11.6", - "@types/chai":"4.1.6", - "@types/mocha": "^5.2.0", - "chai": "^4.2.0", - "mocha": "^5.2.0", - "prettier": "^1.14.3", - "ts-loader": "^5.2.1", - "tslint": "^5.11.0", - "tslint-plugin-prettier": "^2.0.0", - "typescript": "^3.1.2", - "vscode": "^1.1.21", - "webpack": "^4.20.2", - "webpack-cli": "^3.1.2" - }, - "dependencies": { - "@octokit/rest": "^15.13.0", - "adm-zip": "^0.4.11", - "chokidar": "^2.0.4", - "fs-extra": "^7.0.0", - "https-proxy-agent": "^2.2.1", - "lockfile": "^1.0.4", - "temp": "^0.8.3" + "sync.removeExtensions": { + "type": "boolean", + "default": true, + "description": "%ext.config.removeExtensions%" + }, + "sync.syncExtensions": { + "type": "boolean", + "default": true, + "description": "%ext.config.syncExtensions%" + } + }, + "title": "%ext.config.title%" } + }, + "scripts": { + "vscode:prepublish": "npm run tslint-check && npm run compile", + "compile": "tsc -p ./", + "watch": "tsc -watch -p ./", + "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" + }, + "devDependencies": { + "@types/fs-extra": "^5.0.4", + "@types/node": "^10.11.6", + "@types/chai":"4.1.6", + "@types/mocha": "^5.2.0", + "chai": "^4.2.0", + "mocha": "^5.2.0", + "prettier": "^1.14.3", + "tslint": "^5.11.0", + "tslint-plugin-prettier": "^2.0.0", + "typescript": "^3.1.2", + "vscode": "^1.1.21" + }, + "dependencies": { + "@octokit/rest": "^15.13.0", + "adm-zip": "^0.4.11", + "chokidar": "^2.0.4", + "fs-extra": "^7.0.0", + "https-proxy-agent": "^2.2.1", + "lockfile": "^1.0.4", + "temp": "^0.8.3" } +} diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index d97e76b0..00000000 --- a/webpack.config.js +++ /dev/null @@ -1,44 +0,0 @@ -const path = require('path') -const config = { - target: 'node', - entry: './src/extension.ts', - output: { - path: path.resolve(__dirname, 'out'), - filename: 'extension.js', - libraryTarget: 'commonjs2', - devtoolModuleFilenameTemplate: 'file:///[absolute-resource-path]' - }, - devtool: 'source-map', - externals: { - vscode: 'commonjs vscode', - fsevents: 'commonjs fsevents', - 'utf-8-validate': 'utf-8-validate', - 'bufferutil': 'bufferutil' - }, - resolve: { - extensions: ['tsx', '.ts', '.jsx', '.js'] - }, - node: { - __dirname: false, - __filename: false, - }, - module: { - rules: [ - { - test: /\.ts$/, - exclude: /node_modules/, - use: [ - { - loader: 'ts-loader' - } - ] - }, - { - type: 'javascript/auto', - test: /\.mjs$/, - use: [] - } - ] - } -} -module.exports = config From 7e899ef1f791cca0518e1187d4a1de4199b5ff54 Mon Sep 17 00:00:00 2001 From: Shan Date: Wed, 17 Oct 2018 01:12:39 +0500 Subject: [PATCH 38/40] Gist Object changed --- package.json | 320 +++++++++++++++++------------------ src/environmentPath.ts | 32 ++-- src/service/githubService.ts | 2 +- src/sync.ts | 5 +- 4 files changed, 181 insertions(+), 178 deletions(-) diff --git a/package.json b/package.json index 5710ef06..ad1d70dc 100644 --- a/package.json +++ b/package.json @@ -1,181 +1,181 @@ { - "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.0", - "icon": "images/cloud.png", - "publisher": "Shan", - "author": { - "name": "Shan Khan", - "url": "http://shanalikhan.github.io", - "email": "shanalikhan@hotmail.com" + "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.0", + "icon": "images/cloud.png", + "publisher": "Shan", + "author": { + "name": "Shan Khan", + "url": "http://shanalikhan.github.io", + "email": "shanalikhan@hotmail.com" + }, + "homepage": "https://shanalikhan.github.io", + "galleryBanner": { + "color": "#3B4859", + "theme": "dark" + }, + "badges": [ + { + "url": "https://vsmarketplacebadge.apphb.com/version/Shan.code-settings-sync.svg", + "description": "Latest Version", + "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" }, - "homepage": "https://shanalikhan.github.io", - "galleryBanner": { - "color": "#3B4859", - "theme": "dark" + { + "url": "https://vsmarketplacebadge.apphb.com/installs/Shan.code-settings-sync.svg", + "description": "Total Downloads", + "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" }, - "badges": [ + { + "url": "https://vsmarketplacebadge.apphb.com/rating/Shan.code-settings-sync.svg", + "description": "Ratings", + "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" + }, + { + "url": "https://img.shields.io/badge/Join%20Community-slack-green.svg", + "description": "Join Slack Community", + "href": "https://join.slack.com/t/codesettingssync/shared_invite/enQtMzE3MjY5NTczNDMwLTYwMTIwNGExOGE2MTJkZWU0OTU5MmI3ZTc4N2JkZjhjMzY1OTk5OGExZjkwMDMzMDU4ZTBlYjk5MGQwZmMyNzk" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/shanalikhan/code-settings-sync.git" + }, + "bugs": { + "url": "https://github.com/shanalikhan/code-settings-sync/issues", + "email": "shanalikhan@hotmail.com" + }, + "engines": { + "vscode": "^1.28.0" + }, + "categories": [ + "Other" + ], + "keywords": [ + "vscode-sync", + "vscode-settings-sync", + "code-settings-sync", + "settings-sync", + "workspace-sync", + "multi-root ready" + ], + "activationEvents": [ + "*" + ], + "main": "./out/extension", + "contributes": { + "commands": [ + { + "command": "extension.HowSettings", + "title": "%cmd.howSetting.title%" + }, { - "url": "https://vsmarketplacebadge.apphb.com/version/Shan.code-settings-sync.svg", - "description": "Latest Version", - "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" + "command": "extension.downloadSettings", + "title": "%cmd.downloadSettings.title%" }, { - "url": "https://vsmarketplacebadge.apphb.com/installs/Shan.code-settings-sync.svg", - "description": "Total Downloads", - "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" + "command": "extension.updateSettings", + "title": "%cmd.updateSettings.title%" }, { - "url": "https://vsmarketplacebadge.apphb.com/rating/Shan.code-settings-sync.svg", - "description": "Ratings", - "href": "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync" + "command": "extension.resetSettings", + "title": "%cmd.resetSettings.title%" }, { - "url": "https://img.shields.io/badge/Join%20Community-slack-green.svg", - "description": "Join Slack Community", - "href": "https://join.slack.com/t/codesettingssync/shared_invite/enQtMzE3MjY5NTczNDMwLTYwMTIwNGExOGE2MTJkZWU0OTU5MmI3ZTc4N2JkZjhjMzY1OTk5OGExZjkwMDMzMDU4ZTBlYjk5MGQwZmMyNzk" + "command": "extension.otherOptions", + "title": "%cmd.otherOptions.title%" } ], - "repository": { - "type": "git", - "url": "https://github.com/shanalikhan/code-settings-sync.git" - }, - "bugs": { - "url": "https://github.com/shanalikhan/code-settings-sync/issues", - "email": "shanalikhan@hotmail.com" - }, - "engines": { - "vscode": "^1.28.0" - }, - "categories": [ - "Other" - ], - "keywords": [ - "vscode-sync", - "vscode-settings-sync", - "code-settings-sync", - "settings-sync", - "workspace-sync", - "multi-root ready" - ], - "activationEvents": [ - "*" + "keybindings": [ + { + "key": "alt+shift+u", + "command": "extension.updateSettings" + }, + { + "key": "alt+shift+d", + "command": "extension.downloadSettings" + } ], - "main": "./out/extension", - "contributes": { - "commands": [ - { - "command": "extension.HowSettings", - "title": "%cmd.howSetting.title%" + "configuration": { + "properties": { + "sync.gist": { + "type": "string", + "default": "", + "description": "%ext.config.gist%" }, - { - "command": "extension.downloadSettings", - "title": "%cmd.downloadSettings.title%" + "sync.autoDownload": { + "type": "boolean", + "default": false, + "description": "%ext.config.autoDownload%" }, - { - "command": "extension.updateSettings", - "title": "%cmd.updateSettings.title%" + "sync.autoUpload": { + "type": "boolean", + "default": false, + "description": "%ext.config.autoUpload%" }, - { - "command": "extension.resetSettings", - "title": "%cmd.resetSettings.title%" + "sync.forceDownload": { + "type": "boolean", + "default": false, + "description": "%ext.config.forceDownload%" }, - { - "command": "extension.otherOptions", - "title": "%cmd.otherOptions.title%" - } - ], - "keybindings": [ - { - "key": "alt+shift+u", - "command": "extension.updateSettings" + "sync.quietSync": { + "type": "boolean", + "default": false, + "description": "%ext.config.quietSync%" }, - { - "key": "alt+shift+d", - "command": "extension.downloadSettings" - } - ], - "configuration": { - "properties": { - "sync.gist": { - "type": "string", - "default": "", - "description": "%ext.config.gist%" - }, - "sync.autoDownload": { - "type": "boolean", - "default": false, - "description": "%ext.config.autoDownload%" - }, - "sync.autoUpload": { - "type": "boolean", - "default": false, - "description": "%ext.config.autoUpload%" - }, - "sync.forceDownload": { - "type": "boolean", - "default": false, - "description": "%ext.config.forceDownload%" - }, - "sync.quietSync": { - "type": "boolean", - "default": false, - "description": "%ext.config.quietSync%" - }, - "sync.askGistName": { - "type": "boolean", - "default": false, - "description": "%ext.config.askGistName%" - }, - "sync.removeExtensions": { - "type": "boolean", - "default": true, - "description": "%ext.config.removeExtensions%" - }, - "sync.syncExtensions": { - "type": "boolean", - "default": true, - "description": "%ext.config.syncExtensions%" - } + "sync.askGistName": { + "type": "boolean", + "default": false, + "description": "%ext.config.askGistName%" }, - "title": "%ext.config.title%" - } - }, - "scripts": { - "vscode:prepublish": "npm run tslint-check && npm run compile", - "compile": "webpack --mode production", - "compile:dev": "webpack --mode development", - "compile:watch": "webpack --mode development --watch", - "watch": "tsc -watch -p ./", - "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" - }, - "devDependencies": { - "@types/fs-extra": "^5.0.4", - "@types/node": "^10.11.6", - "@types/chai":"4.1.6", - "@types/mocha": "^5.2.0", - "chai": "^4.2.0", - "mocha": "^5.2.0", - "prettier": "^1.14.3", - "ts-loader": "^5.2.1", - "tslint": "^5.11.0", - "tslint-plugin-prettier": "^2.0.0", - "typescript": "^3.1.2", - "vscode": "^1.1.21", - "webpack": "^4.20.2", - "webpack-cli": "^3.1.2" - }, - "dependencies": { - "@octokit/rest": "^15.13.0", - "adm-zip": "^0.4.11", - "chokidar": "^2.0.4", - "fs-extra": "^7.0.0", - "https-proxy-agent": "^2.2.1", - "lockfile": "^1.0.4", - "temp": "^0.8.3" + "sync.removeExtensions": { + "type": "boolean", + "default": true, + "description": "%ext.config.removeExtensions%" + }, + "sync.syncExtensions": { + "type": "boolean", + "default": true, + "description": "%ext.config.syncExtensions%" + } + }, + "title": "%ext.config.title%" } + }, + "scripts": { + "vscode:prepublish": "npm run tslint-check && npm run compile", + "compile": "webpack --mode production", + "compile:dev": "webpack --mode development", + "compile:watch": "webpack --mode development --watch", + "watch": "tsc -watch -p ./", + "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" + }, + "devDependencies": { + "@types/fs-extra": "^5.0.4", + "@types/node": "^10.11.6", + "@types/chai": "4.1.6", + "@types/mocha": "^5.2.0", + "chai": "^4.2.0", + "mocha": "^5.2.0", + "prettier": "^1.14.3", + "ts-loader": "^5.2.1", + "tslint": "^5.11.0", + "tslint-plugin-prettier": "^2.0.0", + "typescript": "^3.1.2", + "vscode": "^1.1.21", + "webpack": "^4.20.2", + "webpack-cli": "^3.1.2" + }, + "dependencies": { + "@octokit/rest": "^15.13.0", + "adm-zip": "^0.4.11", + "chokidar": "^2.0.4", + "fs-extra": "^7.0.0", + "https-proxy-agent": "^2.2.1", + "lockfile": "^1.0.4", + "temp": "^0.8.3" } +} diff --git a/src/environmentPath.ts b/src/environmentPath.ts index ad0fb54a..2230aab3 100644 --- a/src/environmentPath.ts +++ b/src/environmentPath.ts @@ -31,9 +31,9 @@ export class Environment { public isInsiders: boolean = false; public isOss: boolean = false; - public isPortable : boolean = false; + public isPortable: boolean = false; public homeDir: string | null = null; - public USER_FOLDER : string = null; + public USER_FOLDER: string = null; public ExtensionFolder: string = null; public PATH: string = null; @@ -77,7 +77,7 @@ export class Environment { const configSuffix = `${isXdg ? "" : "."}vscode${ this.isInsiders ? "-insiders" : this.isOss ? "-oss" : "" }`; - + process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; this.PATH = process.env.APPDATA; this.OsType = OsType.Windows; @@ -107,7 +107,7 @@ export class Environment { this.OsType = OsType.Linux; } else { this.PATH = process.env.VSCODE_PORTABLE; - this.OsType = OsType.Linux; + this.OsType = OsType.Windows; } } @@ -122,7 +122,7 @@ export class Environment { // command output is in stdout }); } - if(!this.isPortable){ + if (!this.isPortable) { const possibleCodePaths = []; if (this.isInsiders) { possibleCodePaths.push("/Code - Insiders"); @@ -142,23 +142,29 @@ export class Environment { console.error(e); } } - this.ExtensionFolder = path.join(this.homeDir, configSuffix, "extensions"); + this.ExtensionFolder = path.join( + this.homeDir, + configSuffix, + "extensions" + ); this.USER_FOLDER = this.PATH.concat("/User/"); - - } - else{ + } else { this.USER_FOLDER = this.PATH.concat("/user-data/User/"); - this.ExtensionFolder = this.PATH.concat("/extensions/") + this.ExtensionFolder = this.PATH.concat("/extensions/"); } - + this.FILE_EXTENSION = this.USER_FOLDER.concat(this.FILE_EXTENSION_NAME); this.FILE_SETTING = this.USER_FOLDER.concat(this.FILE_SETTING_NAME); this.FILE_LAUNCH = this.USER_FOLDER.concat(this.FILE_LAUNCH_NAME); this.FILE_KEYBINDING = this.USER_FOLDER.concat(this.FILE_KEYBINDING_NAME); this.FILE_LOCALE = this.USER_FOLDER.concat(this.FILE_LOCALE_NAME); this.FOLDER_SNIPPETS = this.USER_FOLDER.concat("/snippets/"); - this.FILE_CLOUDSETTINGS = this.USER_FOLDER.concat(this.FILE_CLOUDSETTINGS_NAME); - this.FILE_CUSTOMIZEDSETTINGS = this.USER_FOLDER.concat(this.FILE_CUSTOMIZEDSETTINGS_NAME); + this.FILE_CLOUDSETTINGS = this.USER_FOLDER.concat( + this.FILE_CLOUDSETTINGS_NAME + ); + this.FILE_CUSTOMIZEDSETTINGS = this.USER_FOLDER.concat( + this.FILE_CUSTOMIZEDSETTINGS_NAME + ); this.FILE_SYNC_LOCK = this.USER_FOLDER.concat(this.FILE_SYNC_LOCK_NAME); } } diff --git a/src/service/githubService.ts b/src/service/githubService.ts index 6eca12ea..5d80aeb4 100644 --- a/src/service/githubService.ts +++ b/src/service/githubService.ts @@ -15,7 +15,7 @@ export class GitHubService { public userName: string = null; public name: string = null; private github: GitHubApi = null; - private GIST_JSON_EMPTY: GitHubApi.GistsCreateParams = { + private GIST_JSON_EMPTY: any = { description: "Visual Studio Code Sync Settings Gist", public: false, files: { diff --git a/src/sync.ts b/src/sync.ts index 05876c71..2a68fc84 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -208,10 +208,7 @@ export class Sync { } for (const snippetFile of contentFiles) { - if ( - snippetFile.fileName !== env.APP_SUMMARY_NAME && - snippetFile.fileName !== env.FILE_KEYBINDING_MAC - ) { + if (snippetFile.fileName !== env.FILE_KEYBINDING_MAC) { if (snippetFile.content !== "") { if (snippetFile.fileName === env.FILE_KEYBINDING_NAME) { snippetFile.gistName = From f6ee4d9948b04931be441edc0bb8181c5541b2f3 Mon Sep 17 00:00:00 2001 From: Shan Khan Date: Wed, 17 Oct 2018 01:28:42 +0500 Subject: [PATCH 39/40] Update package.json --- package.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/package.json b/package.json index d166735a..25567657 100644 --- a/package.json +++ b/package.json @@ -62,11 +62,7 @@ "activationEvents": [ "*" ], -<<<<<<< HEAD - "main": "./out/extension", -======= "main": "./out/src/extension", ->>>>>>> v3.2 "contributes": { "commands": [ { From fb704006af918bb9b0ea3a9b654fa564f51ac2e9 Mon Sep 17 00:00:00 2001 From: Shan Khan Date: Wed, 17 Oct 2018 14:26:53 +0500 Subject: [PATCH 40/40] v3.2 change log --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60915606..9788f7f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +# ChangeLog : Settings Sync [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Synchronize%20your%20%40VisualStudio%20%40code%20Settings%20Across%20Multiple%20Machines%20using%20%40github%20GIST%20by%20%40itsShanKhan&url=https://github.com/shanalikhan/code-settings-sync&via=code&hashtags=code,vscode,SettingsSync,developers) + +[![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) +[![Follow](https://img.shields.io/twitter/follow/itsShanKhan.svg?style=social&label=Follow)](https://twitter.com/intent/follow?screen_name=itsShanKhan) + +#### Version - 3.2.0 - 17 Oct, 2018 + +* Prompt to reload VSCode after installing extensions [#629](https://github.com/shanalikhan/code-settings-sync/issues/629) +* Keep output of CLI installation command [#628](https://github.com/shanalikhan/code-settings-sync/issues/628) +* Dont write default settings sync config to code settings.json [#513](https://github.com/shanalikhan/code-settings-sync/issues/513) +* vscodium download settings fails [#650](https://github.com/shanalikhan/code-settings-sync/issues/650) - Thanks for PR [#651](https://github.com/shanalikhan/code-settings-sync/pull/651) by [@stripedpajamas](https://github.com/stripedpajamas) +* Does not work with Portable Visual Studio Code [#331](https://github.com/shanalikhan/code-settings-sync/issues/331) +* Flatpak Support for Settings Sync [#621](https://github.com/shanalikhan/code-settings-sync/issues/621) - Thanks for PR [#657](https://github.com/shanalikhan/code-settings-sync/pull/657) by [@laloch](https://github.com/laloch) +* Per-platform / per-hostname inline settings [#640](https://github.com/shanalikhan/code-settings-sync/issues/640) - Thanks for PR [#667](https://github.com/shanalikhan/code-settings-sync/pull/667) by [@ioprotium](https://github.com/ioprotium) +* Idea/Suggestion: Adds support to sync custom files [#258](https://github.com/shanalikhan/code-settings-sync/issues/258) - Thanks for PR [#258](https://github.com/shanalikhan/code-settings-sync/pull/258) by [@tkrtmy](https://github.com/tkrtmy) + + #### Version - 3.1.2 * Extension CLI Download Improvements.