diff --git a/.gitignore b/.gitignore
index 8a0ac487..9e98ed35 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,7 @@
out
node_modules
*.vsix
-package-lock.json
\ No newline at end of file
+package-lock.json
+*.lock
+package-lock.json
+*.log
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 0ee038e9..16e9a25b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,7 +12,8 @@ before_install:
install:
- vsce package
script:
- - echo "npm test temporarily disabled"
+ - npm run tslint-check
+ - npm run compile
deploy:
provider: script
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 074a5ca3..e30cdac4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,19 @@
+#### Version - 3.1.0
+* Option to Install Extensions Using CLI [#434](https://github.com/shanalikhan/code-settings-sync/issues/434)
+ - Code Team hasn't provided API to install extension, but as CLI is available Settings Sync will start using code cli to download extensions. Live Status will be displayed while downloading.
+ - Note : This feature wont work in Mac as I cant test on Mac. You will be facing problems, for this I need Mac users to help and fix it.
+ - Fixes : [#337](https://github.com/shanalikhan/code-settings-sync/issues/337), [#566](https://github.com/shanalikhan/code-settings-sync/issues/566) and [#577](https://github.com/shanalikhan/code-settings-sync/issues/577)
+* Unify the code style by using tslint and prettier - Thanks for PR [#595](https://github.com/shanalikhan/code-settings-sync/pull/595) by [@axetroy](https://github.com/axetroy)
+ - Fixes : [#578](https://github.com/shanalikhan/code-settings-sync/issues/578), [#597](https://github.com/shanalikhan/code-settings-sync/issues/597), [#486](https://github.com/shanalikhan/code-settings-sync/issues/486) by upgrading all the packages like Github Api.
+* Don't introduce "sync.*" settings which is equal to default behavior after DL/UL - [#513](https://github.com/shanalikhan/code-settings-sync/issues/513)
+ - Settings Sync configuration has been changed, Readme is updated.
+* Added German localization - Thanks for PR [#588](https://github.com/shanalikhan/code-settings-sync/pull/588) by [@ljosberinn](https://github.com/ljosberinn)
+* Missing partial i18n translation - Thanks for PR [#593](https://github.com/shanalikhan/code-settings-sync/pull/593) by [@axetroy](https://github.com/axetroy)
+* Documentation Improvement - Thanks for PR [#603](https://github.com/shanalikhan/code-settings-sync/pull/603) by [@MastaCoder](https://github.com/MastaCoder)
+* Fix slack img in README and Update tutorial message - Thanks for PR [#607](https://github.com/shanalikhan/code-settings-sync/pull/607) and [#608](https://github.com/shanalikhan/code-settings-sync/pull/608) by [@fr3fou](https://github.com/fr3fou)
+* Ignored extensions can be accidentally deleted if removeExtensions is enabled. - Thanks for PR [#604](https://github.com/shanalikhan/code-settings-sync/pull/604) by [@leepowellcouk](https://github.com/leepowellcouk)
+* Error Translation - Thanks for PR [#616](https://github.com/shanalikhan/code-settings-sync/pull/616) by [@Xiongqi-XQ](https://github.com/Xiongqi-XQ)
+
#### Version - 3.0.0
* Bug Fix for OSS Variant [#549](https://github.com/shanalikhan/code-settings-sync/issues/549) - Thanks for PR [@rudfoss](https://github.com/rudfoss)
@@ -6,18 +22,7 @@
* Setting to disable opening of github page [#576](https://github.com/shanalikhan/code-settings-sync/pull/576)
* Update adm-zip to the latest version [#551](https://github.com/shanalikhan/code-settings-sync/pull/551)
-
-#### Version - 2.9.2
-
-* Critical Bug Fix - Extension Download Fails [#540](https://github.com/shanalikhan/code-settings-sync/issues/540)
-
-
-#### Version - 2.9.1
-
-* Bug Fix for OSS Variant [#510](https://github.com/shanalikhan/code-settings-sync/issues/510) - Thanks for PR [@JacobHenner](https://github.com/JacobHenner)
-* Readme Typo Fix [#531](https://github.com/shanalikhan/code-settings-sync/issues/531) - Thanks for PR [@x4m3](https://github.com/x4m3)
-* syncLocalSettings does not support replacing setting with "False" value [#516](https://github.com/shanalikhan/code-settings-sync/issues/516) - Thanks for PR [@leepowellcouk](https://github.com/leepowellcouk)
-* add support for xdg environment paths [#532](https://github.com/shanalikhan/code-settings-sync/pull/532) - Thanks for PR [@Dennor](https://github.com/Dennor)
+For Previous releases change log view the [post](http://shanalikhan.github.io/2016/05/14/Visual-studio-code-sync-settings-release-notes.html)
## [Contributions](https://github.com/shanalikhan/code-settings-sync/blob/master/CONTRIBUTING.md)
@@ -30,13 +35,12 @@ I also welcome financial contributions in case of special feature requests on my
### Community
-You may join slack community and disscus the ideas over there and chat with me.
+You may join slack community and disscus the ideas over there.
-
+
I'm looking for contributors to work with me so we can make the extension smoother and more feature rich.
Let me know if anyone is willing to [contribute](https://github.com/shanalikhan/code-settings-sync/blob/master/CONTRIBUTING.md).
-For Previous releases change log view the [post](http://shanalikhan.github.io/2016/05/14/Visual-studio-code-sync-settings-release-notes.html)
diff --git a/README.md b/README.md
index 1552d3e8..c10b065b 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@
[![Follow](https://img.shields.io/twitter/follow/itsShanKhan.svg?style=social&label=Follow)](https://twitter.com/intent/follow?screen_name=itsShanKhan)
-
+
@@ -22,7 +22,7 @@
1. Use your GitHub account token and Gist.
2. Easy to Upload and Download on one click.
3. Show a summary page at the end with details about config and extensions effected.
-4. Auto Download Latest Settings on Startup.
+4. Auto download Latest Settings on Startup.
5. Auto upload Settings on file change.
6. Share the Gist with other users and let them download your settings.
7. Supports GitHub Enterprise
@@ -36,7 +36,7 @@ All extensions and complete User Folder that Contains
2. Keybinding File
3. Launch File
4. Snippets Folder
-5. VSCode Extensions Settings
+5. VSCode Extensions & Extensions Configurations
6. Workspaces Folder
```
@@ -46,9 +46,6 @@ All extensions and complete User Folder that Contains
2. Download Key : Shift + Alt + D
```
-
-
-
## Steps To Get a Personal Access Token from GitHub
This extension requires a Personal Access Token from your GitHub account. You can create one by simply following the steps shown in the pictures below. Make sure you add **Gist** in scope.
@@ -172,46 +169,61 @@ Other users can give your Gist Id to download the Gist, but they can't upload th
## Settings
+There are two types of settings in Settings Sync.
+I will recommend you to read the configurations details [here](https://medium.com/@itsShanKhan/visual-studio-code-settings-sync-configurations-ed8dd6fd9753).
-For details regarding settings keys, click [here](https://medium.com/@itsShanKhan/visual-studio-code-settings-sync-configurations-ed8dd6fd9753)
+### Gist Settings
+
+Gist Settings are stored in `settings.json` file of Code.
+You can customize the settings in gist settings like:
+
+```
+1. Configure Gist Id (Environment)
+2. Configure auto upload / download for Github Gist
+3. Configure extension sync behaviour
+4. Configure force download
+5. Configure quiet sync
+```
```json
"sync.gist": "0c929b1a6c51015cdc9e0fe2e369ea4c",
- "sync.lastUpload": "2018-03-04T14:21:39.841Z",
"sync.autoDownload": false,
"sync.autoUpload": false,
- "sync.lastDownload": "2018-03-04T14:21:39.841Z",
- "sync.forceDownload": true,
- "sync.host": "",
- "sync.pathPrefix": "",
+ "sync.forceDownload": false,
"sync.quietSync": false,
"sync.askGistName": false,
"sync.removeExtensions": true,
"sync.syncExtensions": true
```
-## Customized Sync
+### Global Settings
+
+Global settings are present in `syncLocalSettings.json` inside `User` folder. These settings will be shared across multiple Gist Environments.
+
+On Windows, this is `%APPDATA%\Code\User\syncLocalSettings.json`.
-Extension will create the `syncLocalSettings.json` inside `User` folder upon code start.
-On Windows, this is `%APPDATA%\Code\User\syncLocalSettings.json`.
-Mac, `$HOME/Library/Application Support/Code/User/syncLocalSettings.json`.
-Linux, `~/.config/Code/User/syncLocalSettings.json`.
+Mac, `$HOME/Library/Application Support/Code/User/syncLocalSettings.json`.
+
+Linux, `~/.config/Code/User/syncLocalSettings.json`.
You can customize the sync:
```
1. Options by which files / folders and settings to exclude from upload.
-2. The Gist Description when creating new Gist.
+2. Configure default Gist Environment name.
3. Replace the code settings after downloading.
4. Change the Gist description while creating new one in github.
+5. Configure Github Enterprise Url
```
-The JSON will be created as:
-
```json
{
- "ignoreUploadFiles": [ "projects.json", "projects_cache_vscode.json",
- "projects_cache_git.json", "projects_cache_svn.json", "gpm_projects.json",
+ "ignoreUploadFiles": [
+ "projects.json",
+ "projects_cache_vscode.json",
+ "projects_cache_git.json",
+ "projects_cache_svn.json",
+ "gpm_projects.json",
"gpm-recentItems.json"
],
"ignoreUploadFolders": [
@@ -221,19 +233,25 @@ The JSON will be created as:
"ignored_extension_name"
],
"replaceCodeSettings": {
- "http.proxy": "http://my.proxy.address:8080"
+ "http.proxy": "http://my.proxy.address:8080"
},
"gistDescription": "Visual Studio Code Settings Sync Gist",
- "version": 290,
+ "version": 310,
"token": "YOUR_GITHUB_TOKEN_HERE",
"downloadPublicGist": false,
"supportedFileExtensions": [
- "json", "code-snippets"
- ]
+ "json",
+ "code-snippets"
+ ],
+ "openTokenLink": true,
+ "useCliBaseInstallation": true,
+ "lastUpload": null,
+ "lastDownload": null,
+ "githubEnterpriseUrl": null
}
```
-For settings details, visit my post [here](https://medium.com/@itsShanKhan/visual-studio-code-settings-sync-configurations-ed8dd6fd9753)
+I will recommend you to read the configurations details [here](https://medium.com/@itsShanKhan/visual-studio-code-settings-sync-configurations-ed8dd6fd9753).
## How To Contribute
diff --git a/images/slack.png b/images/slack.png
new file mode 100644
index 00000000..725f2271
Binary files /dev/null and b/images/slack.png differ
diff --git a/package.json b/package.json
index b30b09a4..34f7d92c 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.0.0",
+ "version": "3.1.0",
"icon": "images/cloud.png",
"publisher": "Shan",
"author": {
@@ -60,12 +60,7 @@
"multi-root ready"
],
"activationEvents": [
- "*",
- "onCommand:extension.updateSettings",
- "onCommand:extension.downloadSettings",
- "onCommand:extension.resetSettings",
- "onCommand:extension.HowSettings",
- "onCommand:extension.otherOptions"
+ "*"
],
"main": "./out/src/extension",
"contributes": {
@@ -108,16 +103,6 @@
"default": "",
"description": "%ext.config.gist%"
},
- "sync.lastUpload": {
- "type": "string",
- "default": "",
- "description": "%ext.config.lastUpload%"
- },
- "sync.lastDownload": {
- "type": "string",
- "default": "",
- "description": "%ext.config.lastDownload%"
- },
"sync.autoDownload": {
"type": "boolean",
"default": false,
@@ -133,16 +118,6 @@
"default": false,
"description": "%ext.config.forceDownload%"
},
- "sync.host": {
- "type": "string",
- "default": "",
- "description": "%ext.config.host%"
- },
- "sync.pathPrefix": {
- "type": "string",
- "default": "",
- "description": "%ext.config.pathPrefix%"
- },
"sync.quietSync": {
"type": "boolean",
"default": false,
@@ -168,25 +143,29 @@
}
},
"scripts": {
- "vscode:prepublish": "npm run compile",
+ "vscode:prepublish": "npm run tslint-check && npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
- "postinstall": "node ./node_modules/vscode/bin/install"
+ "postinstall": "node ./node_modules/vscode/bin/install",
+ "tslint-check": "tslint -c ./tslint.json ./src/**/*.ts ./src/*.ts",
+ "format": "prettier --write './src/**/*.ts'"
},
"devDependencies": {
- "typescript": "^2.8.3",
- "vscode": "^1.1.6",
- "@types/node": "^10.0.3"
+ "@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": {
- "adm-zip": "0.4.7",
+ "@octokit/rest": "^15.10.0",
+ "adm-zip": "^0.4.11",
"chokidar": "^2.0.2",
- "fs": "^0.0.2",
- "github": "^11.0.0",
+ "fs-extra": "^7.0.0",
"https-proxy-agent": "^2.1.1",
- "ncp": "^2.0.0",
- "proper-lockfile": "^2.0.1",
- "rimraf": "^2.6.2",
+ "lockfile": "^1.0.4",
"temp": "^0.8.3"
}
}
diff --git a/package.nls.de.json b/package.nls.de.json
new file mode 100644
index 00000000..1823b4a2
--- /dev/null
+++ b/package.nls.de.json
@@ -0,0 +1,95 @@
+{
+ "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.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.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.",
+ "ext.config.syncExtensions": "Auf false setzen wenn Erweiterungen nicht synchronisiert werden sollen.",
+ "cmd.howSetting.title": "Sync : Einrichtungsanleitung",
+ "cmd.updateSettings.title": "Sync : Einstellungen aktualisieren/hochladen",
+ "cmd.updateSettings.info.uploading": "Sync : Aktualisiere Daten auf GitHub.",
+ "cmd.updateSettings.info.uploadingFile": "Sync : Lädt Dateien hoch.",
+ "cmd.updateSettings.info.uploadingDone": "Sync : Upload abgeschlossen. Gist-ID : {0} . Diese ID bitte kopieren und für die Synchronisierung auf anderen Geräten verwenden.",
+ "cmd.updateSettings.info.uploadingSuccess": "Sync : Erfolgreich hochgeladen.",
+ "cmd.updateSettings.info.shareGist": "Sync : Teile diese ID mit anderen Benutzern der Erweiterung um die Einstellungen zu teilen.",
+ "cmd.updateSettings.info.readding": "Sync : Lese Einstellungen und Erweiterungen.",
+ "cmd.updateSettings.info.newGistCreated": "Sync : Neues Gist erstellt.",
+ "cmd.updateSettings.warning.noToken": "Sync : GitHub Token definieren oder 'downloadPublicGist' innerhalb der lokalen Sync-Einstellungen deaktivieren.",
+ "cmd.updateSettings.error.newGistCreateFail": "Sync : Kann Gist nicht erstellen.",
+ "cmd.updateSettings.error.readGistFail": "Sync : Gist-ID: {0} UNLESBAR.",
+ "cmd.updateSettings.error.gistNotSave": "Sync : GIST NICHT GESICHERT",
+ "cmd.downloadSettings.title": "Sync : Einstellungen herunterladen",
+ "cmd.downloadSettings.info.readdingOnline": "Sync : Lese Online-Einstellungen.",
+ "cmd.downloadSettings.info.gotLatestVersion": "Sync : Du hast bereits die aktuellesten Einstellungen.",
+ "cmd.downloadSettings.error.removeExtFail": "Sync : Kann manche Erweiterungen nicht entfernen.",
+ "cmd.downloadSettings.error.unableSave": "Sync : Konnte Erweiterungseinstellungen nicht in Datei speichern.",
+ "cmd.resetSettings.title": "Sync : Einstellungen zurücksetzen",
+ "cmd.downloadSettings.info.downloaded": "Sync : Download vollständig.",
+ "cmd.resetSettings.info.resetting": "Sync : Setze Einstellungen zurück.",
+ "cmd.resetSettings.info.settingClear": "Sync : Einstellungen zurückgesetzt.",
+ "cmd.otherOptions.title": "Sync : Erweiterte Optionen",
+ "cmd.otherOptions.editLocalSetting": "Sync : Lokale Erweiterungseinstellungen bearbeiten",
+ "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.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.",
+ "cmd.otherOptions.toggleAutoDownload": "Sync : Automatischer Download bei Start an/aus",
+ "cmd.otherOptions.toggleAutoDownload.on": "Sync : Automatischer Download bei Start an.",
+ "cmd.otherOptions.toggleAutoDownload.off": "Sync : Automatischer Download bei Start aus.",
+ "cmd.otherOptions.toggleSummaryPage": "Sync : Zusammenfassung nach Up-/Download anzeigen an/aus",
+ "cmd.otherOptions.preserve": "Sync : Einstellungen erhalten um Überschreiben nach Download verhindern",
+ "cmd.otherOptions.preserve.placeholder": "Zu erhaltenden Schlüssel aus settings.json eingeben.",
+ "cmd.otherOptions.preserve.prompt": "Beispiel : 'http.proxy' => der derzeitig eingestellte Proxy bleibt erhalten und wird anschließend überschrieben; falls leer gelassen wird der Proxy entfernt.",
+ "cmd.otherOptions.preserve.info.done1": "Sync : Fertig. {0} Wert wird nach Download von settings.json entfert.",
+ "cmd.otherOptions.preserve.info.done2": "Sync : Fertig. Erweiterung erhält nach dem Download {0} : {1} in setting.json.",
+ "cmd.otherOptions.joinCommunity": "Sync : Community beitreten",
+ "cmd.otherOptions.openIssue": "Sync : Issue erstellen",
+ "cmd.otherOptions.releaseNotes": "Sync : Versionshinweise",
+ "cmd.otherOptions.quietSync.on": "Sync : Statusleiste wird bei Up-/Download aktualisiert.",
+ "cmd.otherOptions.quietSync.off": "Sync : Zusammenfassung wird bei Up-/Download angezeigt.",
+ "cmd.otherOptions.warning.tokenNotRequire": "Sync : Settings Sync wird ab jetzt nicht mehr nach einem GitHub-Token fragen.",
+ "cmd.otherOptions.error.toggleFail": "Sync : Konnte Einstellung nicht ändern.",
+ "common.info.installed": "Sync : Einstellungen erstellt. Danke für das Benutzen dieser Erweiterung!",
+ "common.info.needHelp": "Sync : Benötigst du Hilfe bei der Einrichtung der Erweiterung?",
+ "common.info.excludeFile": "Sync : Du kannst beliebige Dateien/Ordner vom Upload und Einstellungen zum Download ausschließen.",
+ "common.info.updating": "Sync : Aktualisieren... bitte warten.",
+ "common.info.initAutoUpload": "Sync : Autoupload beginnt in 5 Sekunden.",
+ "common.info.setToken": "Sync : Du kannst den GitHub-Token nun manuell in `syncLocalSettings.json` definieren`",
+ "common.info.tokenSaved": "Sync : Token gesichert",
+ "common.info.gistSaved": "Sync : Gist gesichert",
+ "common.info.updateTo": "Sync : Auf v{0} aktualisiert",
+ "common.info.donate": "Sync : Gefällt dir die Erweiterung? Schon an eine Bewertung oder an eine kleine Spende gedacht? ;)",
+ "common.error.message": "Sync : Fehler in Konsole geloggt (Hilfe -> Entwicklerkonsole anzeigen).",
+ "common.error.connection": "Sync : Keine Verbindung zum Internet oder Verbindung zu GitHub nicht möglich. Fehler in Konsole geloggt.",
+ "common.error.canNotSave": "Sync : Kann Einstellungen nicht speicihern. Bitte settings.json validieren (z.B. unnötige Kommas)",
+ "common.error.invalidToken": "Sync : ungültiger / abgelaufener GitHub Token. Bitte neuen Token mit in Readme genannten Zugriffsrechten generieren. Fehler in Konsole geloggt.",
+ "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.releaseNotes": "Versionshinweise",
+ "common.action.writeReview": "Bewertung schreiben",
+ "common.action.support": "Projekt unterstützen",
+ "common.action.joinCommunity": "Community beitreten",
+ "common.action.donate": "Spenden",
+ "common.placeholder.enterGithubAccessToken": "GitHub Personal Access Token eingeben",
+ "common.placeholder.enterGistId": "Gist-ID eingeben",
+ "common.placeholder.multipleGist": "Gist-Name [ z.B. Persönliche Einstellungen ]",
+ "common.prompt.multipleGist": "Ermöglicht dir im Falle mehrerer Gists die Einstellungen zu identizifieren.",
+ "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
diff --git a/package.nls.json b/package.nls.json
index d7b9a2d1..bc89355d 100644
--- a/package.nls.json
+++ b/package.nls.json
@@ -7,7 +7,7 @@
"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.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.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.",
"ext.config.askGistName": "Ask gist name upon creating. Helps you to identify the gist if you have multiple gists.",
"ext.config.removeExtensions": "Set it to false if you dont want to remove extensions while downloading.",
@@ -26,16 +26,18 @@
"cmd.updateSettings.error.readGistFail": "Sync : GIST ID: {0} UNABLE TO READ.",
"cmd.updateSettings.error.gistNotSave": "Sync : GIST NOT SAVED",
"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.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",
"cmd.resetSettings.info.resetting": "Sync : Resetting Your Settings.",
"cmd.resetSettings.info.settingClear": "Sync : Settings Cleared.",
"cmd.otherOptions.title": "Sync : Advanced Options",
"cmd.otherOptions.editLocalSetting": "Sync : Edit Extension Local Settings",
"cmd.otherOptions.shareSetting": "Sync : Share Settings with Public GIST",
- "cmd.otherOptions.shareSetting.beforeConfirm": "Sync : This will remove current GIST and upload settings on new public GIST. Do you want to continue ?",
+ "cmd.otherOptions.shareSetting.beforeConfirm": "Sync : This will remove current GIST and upload settings on new public GIST. Do you want to continue?",
"cmd.otherOptions.downloadSetting": "Sync : Download Settings from Public GIST",
"cmd.otherOptions.toggleForceDownload": "Sync : Toggle Force Download",
"cmd.otherOptions.toggleForceDownload.on": "Sync : Force Download Turned On.",
@@ -59,8 +61,8 @@
"cmd.otherOptions.quietSync.off": "Sync : Summary will be shown upon download / upload.",
"cmd.otherOptions.warning.tokenNotRequire": "Sync : Settings Sync will not ask for GitHub Token from now on.",
"cmd.otherOptions.error.toggleFail": "Sync : Unable to Toggle.",
- "common.info.installed": "Sync : Settings Created. Thank You for Installing !",
- "common.info.needHelp": "Sync : Need Help regarding configuring this extension ?",
+ "common.info.installed": "Sync : Settings created, thank you for installing!",
+ "common.info.needHelp": "Sync : Need Help configuring this extension?",
"common.info.excludeFile": "Sync : You can exclude any file / folder for upload and settings for download.",
"common.info.updating": "Sync : Updating In Progress ... Please Wait.",
"common.info.initAutoUpload": "Sync : Auto Upload Initiating In 5 Seconds.",
@@ -68,7 +70,7 @@
"common.info.tokenSaved": "Sync : Token Saved",
"common.info.gistSaved": "Sync : Gist Saved",
"common.info.updateTo": "Sync : Updated to v{0}",
- "common.info.donate": "Sync : Do you like this extension ? How about writing a review or send me some donation ;)",
+ "common.info.donate": "Sync : Do you like this extension? How about writing a review or sending a donation? ;)",
"common.error.message": "Sync : Error Logged In Console (Help menu > Toggle Developer Tools).",
"common.error.connection": "Sync : Internet Not Connected or Unable to Connect to GitHub. Exception Logged in Console",
"common.error.canNotSave": "Sync : Unable to Save Settings. Please make sure you have valid JSON settings.json file. ( e.g : No trailing commas )",
@@ -85,8 +87,8 @@
"common.action.donate": "Donate Now",
"common.placeholder.enterGithubAccessToken": "Enter GitHub Personal Access Token",
"common.placeholder.enterGistId": "Enter Gist Id",
- "common.placeholder.multipleGist": "Gist Name [ e.g : Personal Settings ]",
+ "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 press / type 'esc' to cancel.",
- "common.prompt.enterGithubAccessToken": "You can manually add token also (User Folder / syncLocalSettings.json). Press [Enter] or press / type 'esc' to cancel."
-}
\ No newline at end of file
+ "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."
+}
diff --git a/package.nls.zh-cn.json b/package.nls.zh-cn.json
index 97f05bba..a020644f 100644
--- a/package.nls.zh-cn.json
+++ b/package.nls.zh-cn.json
@@ -10,7 +10,7 @@
"ext.config.pathPrefix": "如果你是 Github 企业用户, 设置 Github 的 API 前缀. 通常是 '/api/v3'. 只在 host 字段设置后生效",
"ext.config.quietSync": "如果设置为 true, 开启静默模式. 上传和下载的概要信息显示在状态栏而非输出面板",
"ext.config.askGistName": "在创建时询问 gist 的名称. 能够帮助你识别多个 gist.",
- "ext.config.removeExtensions": "设置为 false 如果你想在下载时移除扩展.",
+ "ext.config.removeExtensions": "设置为 false 如果你不想在下载时移除扩展.",
"ext.config.syncExtensions": "设置为 false 如果你不想上传/下载扩展.",
"cmd.howSetting.title": "Sync : 如何配置",
"cmd.updateSettings.title": "Sync : 上传设置",
@@ -25,10 +25,12 @@
"cmd.updateSettings.error.newGistCreateFail": "Sync : 无法创建 Gist",
"cmd.updateSettings.error.readGistFail": "Sync : 不能读取 ID 为 {0} 的 Gist",
"cmd.updateSettings.error.gistNotSave": "Sync : Gist 未保存",
- "cmd.downloadSettings.title": "Sync : 下载设置",
+ "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 : 设置清除完毕",
@@ -89,4 +91,4 @@
"common.prompt.multipleGist": "如果你有多个 Gist 设置, 请输入名称扩展才得以识别",
"common.prompt.enterGistId": "请输入上一次上传设置的 Gist Id. 你也可以手动添加到 VSCode 的配置文件 (sync.gist 字段). 按下 [Enter] 确认或者 输入 'esc' 取消",
"common.prompt.enterGithubAccessToken": "链接打开了! 你可以手动添加到 用户目录/syncLocalSettings.json. 按下 [Enter] 确认或者 输入 'esc' 取消"
-}
\ No newline at end of file
+}
diff --git a/src/commons.ts b/src/commons.ts
index 05443104..88662ffa 100644
--- a/src/commons.ts
+++ b/src/commons.ts
@@ -1,634 +1,715 @@
"use strict";
-import * as fs from 'fs';
-import * as path from 'path';
-import * as vscode from 'vscode';
+import * as chokidar from "chokidar";
+import * as fs from "fs-extra";
+import * as vscode from "vscode";
+import { Environment } from "./environmentPath";
+import localize from "./localize";
+import * as lockfile from "./lockfile";
+import { File, FileService } from "./service/fileService";
+import { ExtensionInformation } from "./service/pluginService";
+import { CustomSettings, ExtensionConfig, LocalConfig } from "./setting";
+import { Util } from "./util";
-import { Environment } from './environmentPath';
-import localize from './localize';
-import { File, FileService } from './service/fileService';
-import { ExtensionInformation } from './service/pluginService';
-import { CustomSettings, ExtensionConfig, LocalConfig } from './setting';
+export default class Commons {
+ public static LogException(
+ error: any,
+ message: string,
+ msgBox: boolean,
+ callback?: () => void
+ ): void {
+ if (error) {
+ console.error(error);
+ if (error.code === 500) {
+ message = localize("common.error.connection");
+ msgBox = false;
+ } else if (error.code === 4) {
+ message = localize("common.error.canNotSave");
+ } else if (error.message) {
+ try {
+ message = JSON.parse(error.message).message;
+ if (message.toLowerCase() === "bad credentials") {
+ msgBox = true;
+ message = localize("common.error.invalidToken");
+ // vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://github.com/settings/tokens'));
+ }
+ if (message.toLowerCase() === "not found") {
+ msgBox = true;
+ message = localize("common.error.invalidGistId");
+ }
+ } catch (error) {
+ // message = error.message;
+ }
+ }
+ }
-const chokidar = require('chokidar');
-const lockfile = require('proper-lockfile');
+ if (msgBox === true) {
+ vscode.window.showErrorMessage(message);
+ vscode.window.setStatusBarMessage("").dispose();
+ } else {
+ vscode.window.setStatusBarMessage(message, 5000);
+ }
-export default class Commons {
+ if (callback) {
+ callback.apply(this);
+ }
+ }
+
+ public static GetInputBox(token: boolean) {
+ if (token) {
+ const options: vscode.InputBoxOptions = {
+ placeHolder: localize("common.placeholder.enterGithubAccessToken"),
+ password: false,
+ prompt: localize("common.prompt.enterGithubAccessToken"),
+ ignoreFocusOut: true
+ };
+ return options;
+ } else {
+ const options: vscode.InputBoxOptions = {
+ placeHolder: localize("common.placeholder.enterGistId"),
+ password: false,
+ prompt: localize("common.prompt.enterGistId"),
+ ignoreFocusOut: true
+ };
+ return options;
+ }
+ }
- public ERROR_MESSAGE: string = localize("common.error.message");
- private static configWatcher = null;
- private static extensionWatcher = null;
- private static outputChannel: vscode.OutputChannel = null;
+ private static configWatcher = null;
+ private static extensionWatcher = null;
+ private static outputChannel: vscode.OutputChannel = null;
- constructor(private en: Environment, private context: vscode.ExtensionContext) {
+ public ERROR_MESSAGE: string = localize("common.error.message");
+ constructor(
+ private en: Environment,
+ private context: vscode.ExtensionContext
+ ) {}
+
+ public async StartWatch(): Promise {
+ const lockExist: boolean = await FileService.FileExists(
+ this.en.FILE_SYNC_LOCK
+ );
+ if (!lockExist) {
+ fs.closeSync(fs.openSync(this.en.FILE_SYNC_LOCK, "w"));
}
- public static LogException(error: any, message: string, msgBox: boolean, callback?: Function): void {
+ // check is sync locking
+ if (await lockfile.Check(this.en.FILE_SYNC_LOCK)) {
+ await lockfile.Unlock(this.en.FILE_SYNC_LOCK);
+ }
- if (error) {
- console.error(error);
- if (error.code == 500) {
- message = localize("common.error.connection");
- msgBox = false;
- }
- else if (error.code == 4) {
- message = localize("common.error.canNotSave");
- }
- else if (error.message) {
- try {
- message = JSON.parse(error.message).message;
- if (message.toLowerCase() == 'bad credentials') {
- msgBox = true;
- message = localize("common.error.invalidToken");
- //vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://github.com/settings/tokens'));
- }
- if (message.toLowerCase() == 'not found') {
- msgBox = true;
- message = localize("common.error.invalidGistId")
- }
- } catch (error) {
- //message = error.message;
- }
+ let uploadStopped: boolean = true;
+ Commons.extensionWatcher = chokidar.watch(this.en.ExtensionFolder, {
+ depth: 0,
+ ignoreInitial: true
+ });
+ Commons.configWatcher = chokidar.watch(this.en.PATH + "/User/", {
+ depth: 2,
+ ignoreInitial: true
+ });
+
+ // TODO : Uncomment the following lines when code allows feature to update Issue in github code repo - #14444
+
+ // Commons.extensionWatcher.on('addDir', (path, stat)=> {
+ // if (uploadStopped) {
+ // uploadStopped = false;
+ // this.InitiateAutoUpload().then((resolve) => {
+ // uploadStopped = resolve;
+ // }, (reject) => {
+ // uploadStopped = reject;
+ // });
+ // }
+ // else {
+ // vscode.window.setStatusBarMessage("");
+ // vscode.window.setStatusBarMessage("Sync : Updating In Progres... Please Wait.", 3000);
+ // }
+ // });
+ // Commons.extensionWatcher.on('unlinkDir', (path)=> {
+ // if (uploadStopped) {
+ // uploadStopped = false;
+ // this.InitiateAutoUpload().then((resolve) => {
+ // uploadStopped = resolve;
+ // }, (reject) => {
+ // uploadStopped = reject;
+ // });
+ // }
+ // else {
+ // vscode.window.setStatusBarMessage("");
+ // vscode.window.setStatusBarMessage("Sync : Updating In Progres... Please Wait.", 3000);
+ // }
+ // });
+
+ Commons.configWatcher.on("change", async (path: string) => {
+ // check sync is locking
+ if (await lockfile.Check(this.en.FILE_SYNC_LOCK)) {
+ uploadStopped = false;
+ }
+
+ if (!uploadStopped) {
+ vscode.window.setStatusBarMessage("").dispose();
+ vscode.window.setStatusBarMessage(
+ localize("common.info.updating"),
+ 3000
+ );
+ return false;
+ }
+
+ uploadStopped = false;
+ await lockfile.Lock(this.en.FILE_SYNC_LOCK);
+ const settings: ExtensionConfig = this.GetSettings();
+ const customSettings: CustomSettings = await this.GetCustomSettings();
+ if (customSettings == null) {
+ return;
+ }
+
+ let requiredFileChanged: boolean = false;
+ if (
+ customSettings.ignoreUploadFolders.indexOf("workspaceStorage") === -1
+ ) {
+ 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;
+ }
+
+ console.log("Sync : File Change Detected On : " + path);
+
+ if (requiredFileChanged) {
+ if (settings.autoUpload) {
+ if (
+ customSettings.ignoreUploadFolders.indexOf("workspaceStorage") > -1
+ ) {
+ const fileType: string = path.substring(
+ path.lastIndexOf("."),
+ path.length
+ );
+ if (fileType.indexOf("json") === -1) {
+ console.log(
+ "Sync : Cannot Initiate Auto-upload on This File (Not JSON)."
+ );
+ uploadStopped = true;
+ return;
}
+ }
+
+ console.log("Sync : Initiating Auto-upload For File : " + path);
+ this.InitiateAutoUpload(path)
+ .then(isDone => {
+ uploadStopped = isDone;
+ return lockfile.Unlock(this.en.FILE_SYNC_LOCK);
+ })
+ .catch(() => {
+ uploadStopped = true;
+ return lockfile.Unlock(this.en.FILE_SYNC_LOCK);
+ });
}
-
- if (msgBox == true) {
- vscode.window.showErrorMessage(message);
- vscode.window.setStatusBarMessage("").dispose();
+ } else {
+ uploadStopped = true;
+ await lockfile.Unlock(this.en.FILE_SYNC_LOCK);
+ }
+ });
+ }
+
+ public async InitiateAutoUpload(path: string): Promise {
+ vscode.window.setStatusBarMessage("").dispose();
+ vscode.window.setStatusBarMessage(
+ localize("common.info.initAutoUpload"),
+ 5000
+ );
+
+ await Util.Sleep(3000);
+
+ vscode.commands.executeCommand(
+ "extension.updateSettings",
+ "forceUpdate",
+ path
+ );
+
+ return true;
+ }
+
+ public CloseWatch(): void {
+ if (Commons.configWatcher != null) {
+ Commons.configWatcher.close();
+ }
+ if (Commons.extensionWatcher != null) {
+ Commons.extensionWatcher.close();
+ }
+ }
+
+ public async InitalizeSettings(
+ askToken: boolean,
+ askGist: boolean
+ ): Promise {
+ const settings: LocalConfig = new LocalConfig();
+ const extSettings: ExtensionConfig = this.GetSettings();
+ const cusSettings: CustomSettings = await this.GetCustomSettings();
+
+ if (cusSettings.token === "") {
+ if (askToken === true) {
+ askToken = !cusSettings.downloadPublicGist;
+ }
+
+ if (askToken) {
+ if (cusSettings.openTokenLink) {
+ vscode.commands.executeCommand(
+ "vscode.open",
+ vscode.Uri.parse("https://github.com/settings/tokens")
+ );
}
- else {
- vscode.window.setStatusBarMessage(message, 5000);
+ const tokTemp: string = await this.GetTokenAndSave(cusSettings);
+ if (!tokTemp) {
+ const msg = localize("common.error.tokenNotSave");
+ vscode.window.showErrorMessage(msg);
+ throw new Error(msg);
}
+ cusSettings.token = tokTemp;
+ }
+ }
- if (callback) {
- callback.apply(this);
+ if (extSettings.gist === "") {
+ if (askGist) {
+ const gistTemp: string = await this.GetGistAndSave(extSettings);
+ if (!gistTemp) {
+ const msg = localize("common.error.gistNotSave");
+ vscode.window.showErrorMessage(msg);
+ throw new Error(msg);
}
+ extSettings.gist = gistTemp;
+ }
}
-
- public async StartWatch(): Promise {
-
- let lockExist: boolean = await FileService.FileExists(this.en.FILE_SYNC_LOCK);
- if (!lockExist) {
- fs.closeSync(fs.openSync(this.en.FILE_SYNC_LOCK, 'w'));
+ settings.customConfig = cusSettings;
+ settings.extConfig = extSettings;
+ return settings;
+ }
+
+ public async GetCustomSettings(): Promise {
+ let customSettings: CustomSettings = new CustomSettings();
+ try {
+ const customExist: boolean = await FileService.FileExists(
+ this.en.FILE_CUSTOMIZEDSETTINGS
+ );
+ if (customExist) {
+ const customSettingStr: string = await FileService.ReadFile(
+ this.en.FILE_CUSTOMIZEDSETTINGS
+ );
+ const tempObj: {
+ [key: string]: any;
+ ignoreUploadSettings: string[];
+ } = JSON.parse(customSettingStr);
+ if (!Array.isArray(tempObj.ignoreUploadSettings)) {
+ tempObj.ignoreUploadSettings = [];
}
-
- let self: Commons = this;
- let locked: boolean = lockfile.checkSync(this.en.FILE_SYNC_LOCK);
- if (locked) {
- lockfile.unlockSync(this.en.FILE_SYNC_LOCK);
+ Object.assign(customSettings, tempObj);
+ customSettings.token = customSettings.token.trim();
+ return customSettings;
+ }
+ } catch (e) {
+ Commons.LogException(
+ e,
+ "Sync : Unable to read " +
+ this.en.FILE_CUSTOMIZEDSETTINGS_NAME +
+ ". Make sure its Valid JSON.",
+ true
+ );
+ vscode.commands.executeCommand(
+ "vscode.open",
+ vscode.Uri.parse(
+ "http://shanalikhan.github.io/2017/02/19/Option-to-ignore-settings-folders-code-settings-sync.html"
+ )
+ );
+ customSettings = null;
+ return customSettings;
+ }
+ }
+
+ public async SetCustomSettings(setting: CustomSettings): Promise {
+ try {
+ const json: { [key: string]: any; ignoreUploadSettings: string[] } = {
+ ...setting
+ };
+ delete json.ignoreUploadSettings;
+ await FileService.WriteFile(
+ this.en.FILE_CUSTOMIZEDSETTINGS,
+ JSON.stringify(json)
+ );
+ return true;
+ } catch (e) {
+ Commons.LogException(
+ e,
+ "Sync : Unable to write " + this.en.FILE_CUSTOMIZEDSETTINGS_NAME,
+ true
+ );
+ return false;
+ }
+ }
+
+ public async StartMigrationProcess(): Promise {
+ const fileExist: boolean = await FileService.FileExists(
+ this.en.FILE_CUSTOMIZEDSETTINGS
+ );
+ let customSettings: CustomSettings = null;
+ const firstTime: boolean = !fileExist;
+ let fileChanged: boolean = firstTime;
+
+ if (fileExist) {
+ customSettings = await this.GetCustomSettings();
+ } else {
+ customSettings = new CustomSettings();
+ }
+ // vscode.workspace.getConfiguration().update("sync.version", undefined, true);
+
+ if (firstTime) {
+ const openExtensionPage = localize("common.action.openExtPage");
+ const openExtensionTutorial = localize("common.action.openExtTutorial");
+ vscode.window.showInformationMessage(localize("common.info.installed"));
+ vscode.window
+ .showInformationMessage(
+ localize("common.info.needHelp"),
+ openExtensionPage
+ )
+ .then((val: string) => {
+ if (val === openExtensionPage) {
+ vscode.commands.executeCommand(
+ "vscode.open",
+ vscode.Uri.parse(
+ "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync"
+ )
+ );
+ }
+ });
+ vscode.window
+ .showInformationMessage(
+ localize("common.info.excludeFile"),
+ openExtensionTutorial
+ )
+ .then((val: string) => {
+ if (val === openExtensionTutorial) {
+ vscode.commands.executeCommand(
+ "vscode.open",
+ vscode.Uri.parse(
+ "https://shanalikhan.github.io/2016/07/31/Visual-Studio-code-sync-setting-edit-manually.html"
+ )
+ );
+ }
+ });
+ } else if (customSettings.version < Environment.CURRENT_VERSION) {
+ fileChanged = true;
+ if (this.context.globalState.get("synctoken")) {
+ const token = this.context.globalState.get("synctoken");
+ if (token !== "") {
+ customSettings.token = String(token);
+ this.context.globalState.update("synctoken", "");
+ vscode.window.showInformationMessage(
+ localize("common.info.setToken")
+ );
}
- let uploadStopped: boolean = true;
- Commons.extensionWatcher = chokidar.watch(this.en.ExtensionFolder, { depth: 0, ignoreInitial: true });
- Commons.configWatcher = chokidar.watch(this.en.PATH + "/User/", { depth: 2, ignoreInitial: true });
-
- //TODO : Uncomment the following lines when code allows feature to update Issue in github code repo - #14444
-
- // Commons.extensionWatcher.on('addDir', (path, stat)=> {
- // if (uploadStopped) {
- // uploadStopped = false;
- // this.InitiateAutoUpload().then((resolve) => {
- // uploadStopped = resolve;
- // }, (reject) => {
- // uploadStopped = reject;
- // });
- // }
- // else {
- // vscode.window.setStatusBarMessage("");
- // vscode.window.setStatusBarMessage("Sync : Updating In Progres... Please Wait.", 3000);
- // }
- // });
- // Commons.extensionWatcher.on('unlinkDir', (path)=> {
- // if (uploadStopped) {
- // uploadStopped = false;
- // this.InitiateAutoUpload().then((resolve) => {
- // uploadStopped = resolve;
- // }, (reject) => {
- // uploadStopped = reject;
- // });
- // }
- // else {
- // vscode.window.setStatusBarMessage("");
- // vscode.window.setStatusBarMessage("Sync : Updating In Progres... Please Wait.", 3000);
- // }
- // });
-
- Commons.configWatcher.on('change', async (path: string) => {
- let locked: boolean = lockfile.checkSync(this.en.FILE_SYNC_LOCK);
- if (locked) {
- uploadStopped = false;
- }
-
- if (uploadStopped) {
- uploadStopped = false;
- lockfile.lockSync(self.en.FILE_SYNC_LOCK);
- let settings: ExtensionConfig = this.GetSettings();
- let customSettings: CustomSettings = await this.GetCustomSettings();
- if (customSettings == null) {
- return;
- }
-
- let requiredFileChanged: boolean = false;
- if (customSettings.ignoreUploadFolders.indexOf("workspaceStorage") == -1) {
- requiredFileChanged = (path.indexOf(self.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(self.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);
- }
-
- console.log("Sync : File Change Detected On : " + path);
-
- if (requiredFileChanged) {
- if (settings.autoUpload) {
- if (customSettings.ignoreUploadFolders.indexOf("workspaceStorage") > -1) {
- let fileType: string = path.substring(path.lastIndexOf('.'), path.length);
- if (fileType.indexOf('json') == -1) {
- console.log("Sync : Cannot Initiate Auto-upload on This File (Not JSON).");
- uploadStopped = true;
- return;
- }
- }
-
- console.log("Sync : Initiating Auto-upload For File : " + path);
- this.InitiateAutoUpload(path).then((resolve) => {
- uploadStopped = resolve;
- lockfile.unlockSync(self.en.FILE_SYNC_LOCK);
- }, (reject) => {
- lockfile.unlockSync(self.en.FILE_SYNC_LOCK);
- uploadStopped = true;
- });
- }
- } else {
- uploadStopped = true;
- lockfile.unlockSync(self.en.FILE_SYNC_LOCK);
- }
- }
- else {
- vscode.window.setStatusBarMessage("").dispose();
- vscode.window.setStatusBarMessage(localize("common.info.updating"), 3000);
- }
+ }
+
+ const releaseNotes = localize("common.action.releaseNotes");
+ 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"
+ )
+ );
+ }
});
}
-
- public async InitiateAutoUpload(path: string): Promise {
-
- return new Promise(async (resolve, reject) => {
- vscode.window.setStatusBarMessage("").dispose();
- vscode.window.setStatusBarMessage(localize("common.info.initAutoUpload"), 5000);
-
- setTimeout(function () {
- vscode.commands.executeCommand('extension.updateSettings', "forceUpdate", path).then((res) => {
- resolve(true);
- });
- }, 3000);
- });
+ if (fileChanged) {
+ customSettings.version = Environment.CURRENT_VERSION;
+ await this.SetCustomSettings(customSettings);
}
-
- public CloseWatch(): void {
- if (Commons.configWatcher != null) {
- Commons.configWatcher.close();
- }
- if (Commons.extensionWatcher != null) {
- Commons.extensionWatcher.close();
+ return true;
+ }
+
+ public async SaveSettings(setting: ExtensionConfig): Promise {
+ const config = vscode.workspace.getConfiguration("sync");
+ const allKeysUpdated = new Array>();
+
+ const keys = Object.keys(setting);
+ keys.forEach(async keyName => {
+ if (setting[keyName] == null) {
+ setting[keyName] = "";
+ }
+ if (keyName.toLowerCase() !== "token") {
+ allKeysUpdated.push(config.update(keyName, setting[keyName], true));
+ }
+ });
+
+ try {
+ await Promise.all(allKeysUpdated);
+ if (this.context.globalState.get("syncCounter")) {
+ const counter = this.context.globalState.get("syncCounter");
+ let count: number = parseInt(counter + "", 10);
+ if (count % 450 === 0) {
+ this.DonateMessage();
}
+ count = count + 1;
+ this.context.globalState.update("syncCounter", count);
+ } else {
+ this.context.globalState.update("syncCounter", 1);
+ }
+ return true;
+ } catch (err) {
+ Commons.LogException(err, this.ERROR_MESSAGE, true);
+ return false;
}
-
- public async InitalizeSettings(askToken: boolean, askGist: boolean): Promise {
- let me: Commons = this;
- return new Promise(async (resolve, reject) => {
- var settings: LocalConfig = new LocalConfig();
- var extSettings: ExtensionConfig = me.GetSettings()
- var cusSettings: CustomSettings = await me.GetCustomSettings();
-
- if (cusSettings.token == "") {
- if (askToken == true) {
- askToken = !cusSettings.downloadPublicGist;
- }
-
- if (askToken) {
- if (cusSettings.openTokenLink) {
- vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://github.com/settings/tokens'));
- }
- let tokTemp: string = await me.GetTokenAndSave(cusSettings);
- if (!tokTemp) {
- vscode.window.showErrorMessage(localize("common.error.tokenNotSave"));
- reject(false);
- }
- cusSettings.token = tokTemp;
- }
- }
-
-
- if (extSettings.gist == "") {
- if (askGist) {
- let gistTemp: string = await me.GetGistAndSave(extSettings);
- if (!gistTemp) {
- vscode.window.showErrorMessage(localize("common.error.gistNotSave"));
- reject(false);
- }
- extSettings.gist = gistTemp;
- }
- }
- settings.customConfig = cusSettings;
- settings.extConfig = extSettings;
- resolve(settings);
- });
+ }
+
+ public async DonateMessage(): Promise {
+ const donateNow = localize("common.action.donate");
+ const writeReview = localize("common.action.writeReview");
+ const res = await vscode.window.showInformationMessage(
+ localize("common.info.donate"),
+ donateNow,
+ writeReview
+ );
+
+ if (res === donateNow) {
+ 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"
+ )
+ );
+ } else if (res === writeReview) {
+ vscode.commands.executeCommand(
+ "vscode.open",
+ vscode.Uri.parse(
+ "https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync#review-details"
+ )
+ );
}
+ }
- public async GetCustomSettings(): Promise {
- let me: Commons = this;
- return new Promise(async (resolve, reject) => {
-
- let customSettings: CustomSettings = new CustomSettings();
- try {
- let customExist: boolean = await FileService.FileExists(me.en.FILE_CUSTOMIZEDSETTINGS);
- if (customExist) {
- let customSettingStr: string = await FileService.ReadFile(me.en.FILE_CUSTOMIZEDSETTINGS);
- let tempObj: Object = JSON.parse(customSettingStr);
- if (!Array.isArray(tempObj["ignoreUploadSettings"])) {
- tempObj["ignoreUploadSettings"] = new Array();
- }
- Object.assign(customSettings, tempObj);
- customSettings.token = customSettings.token.trim();
- resolve(customSettings);
- }
- }
- catch (e) {
- Commons.LogException(e, "Sync : Unable to read " + this.en.FILE_CUSTOMIZEDSETTINGS_NAME + ". Make sure its Valid JSON.", true);
- vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('http://shanalikhan.github.io/2017/02/19/Option-to-ignore-settings-folders-code-settings-sync.html'));
- customSettings = null;
- resolve(customSettings);
- }
- });
- }
+ public GetSettings(): ExtensionConfig {
+ const settings = new ExtensionConfig();
- public async SetCustomSettings(setting: CustomSettings): Promise {
- let me: Commons = this;
- return new Promise(async (resolve, reject) => {
- try {
- let json: Object = Object.assign(setting);
- delete json["ignoreUploadSettings"]
- await FileService.WriteFile(me.en.FILE_CUSTOMIZEDSETTINGS, JSON.stringify(json));
- resolve(true);
- }
- catch (e) {
- Commons.LogException(e, "Sync : Unable to write " + this.en.FILE_CUSTOMIZEDSETTINGS_NAME, true);
- resolve(false);
- }
- });
+ for (const key of Object.keys(settings)) {
+ if (key !== "token") {
+ settings[key] = vscode.workspace.getConfiguration("sync").get(key);
+ }
}
- public StartMigrationProcess(): Promise {
- let me: Commons = this;
- let settingKeys = Object.keys(new ExtensionConfig());
- return new Promise(async (resolve, reject) => {
-
- let settings: ExtensionConfig = await me.GetSettings();
- let fileExist: boolean = await FileService.FileExists(me.en.FILE_CUSTOMIZEDSETTINGS);
- let customSettings: CustomSettings = null;
- let firstTime: boolean = !fileExist;
- let fileChanged: boolean = firstTime;
+ settings.gist = settings.gist.trim();
+ return settings;
+ }
- if (fileExist) {
- customSettings = await me.GetCustomSettings();
- }
- else {
- customSettings = new CustomSettings();
- }
- //vscode.workspace.getConfiguration().update("sync.version", undefined, true);
-
- if (firstTime) {
- const openExtensionPage = localize("common.action.openExtPage");
- const openExtensionTutorial = localize("common.action.openExtTutorial");
- vscode.window.showInformationMessage(localize("common.info.installed"));
- vscode.window.showInformationMessage(localize("common.info.needHelp"), openExtensionPage).then(function (val: string) {
- if (val == openExtensionPage) {
- vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync'))
- }
- });
- vscode.window.showInformationMessage(localize("common.info.excludeFile"), openExtensionTutorial).then(function (val: string) {
- if (val == openExtensionTutorial) {
- vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('http://shanalikhan.github.io/2017/02/19/Option-to-ignore-settings-folders-code-settings-sync.html'))
- }
- });
- }
- else if (customSettings.version < Environment.CURRENT_VERSION) {
- fileChanged = true;
- if (this.context.globalState.get('synctoken')) {
- let token = this.context.globalState.get('synctoken');
- if (token != "") {
- customSettings.token = String(token);
- this.context.globalState.update("synctoken", "");
- vscode.window.showInformationMessage(localize("common.info.setToken"));
- }
- }
-
- const releaseNotes = localize("common.action.releaseNotes");
- const writeReview = localize("common.action.writeReview");
- const support = localize("common.action.support");
- const joinCommunity = localize("common.action.joinCommunity");
-
- vscode.window.showInformationMessage(localize("common.info.updateTo", Environment.getVersion()), releaseNotes, writeReview, support, joinCommunity).then(function (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 me.SetCustomSettings(customSettings);
- }
- resolve(true);
- });
- }
+ public async GetTokenAndSave(sett: CustomSettings): Promise {
+ const opt = Commons.GetInputBox(true);
- public async SaveSettings(setting: ExtensionConfig): Promise {
- let me: Commons = this;
- let config = vscode.workspace.getConfiguration('sync');
- let allKeysUpdated = new Array>();
-
- return new Promise((resolve, reject) => {
-
- let keys = Object.keys(setting);
- keys.forEach(async keyName => {
- if ((keyName == "lastDownload" || keyName == "lastUpload") && setting[keyName]) {
- try {
- let zz = new Date(setting[keyName]);
- setting[keyName] = zz;
- } catch (e) {
- setting[keyName] = new Date();
- }
- }
- if (setting[keyName] == null) {
- setting[keyName] = "";
- }
- if (keyName.toLowerCase() == "token") {
- allKeysUpdated.push(me.context.globalState.update("synctoken", setting[keyName]));
- }
- else {
- allKeysUpdated.push(config.update(keyName, setting[keyName], true));
- }
- });
+ const token = ((await vscode.window.showInputBox(opt)) || "").trim();
- Promise.all(allKeysUpdated).then(function (a) {
-
- if (me.context.globalState.get('syncCounter')) {
- let counter = me.context.globalState.get('syncCounter');
- let count: number = parseInt(String(counter));
- if (count % 450 == 0) {
- me.DonateMessage();
- }
- count = count + 1;
- me.context.globalState.update("syncCounter", count)
- }
- else {
- me.context.globalState.update("syncCounter", 1)
- }
- resolve(true);
- }, function (b: any) {
- Commons.LogException(b, me.ERROR_MESSAGE, true);
- reject(false);
- });
- });
+ if (token && token !== "esc") {
+ sett.token = token;
+ const saved = await this.SetCustomSettings(sett);
+ if (saved) {
+ vscode.window.setStatusBarMessage(
+ localize("common.info.tokenSaved"),
+ 1000
+ );
+ }
}
- public DonateMessage(): void {
- const donateNow = localize("common.action.donate");
- const writeReview = localize("common.action.writeReview");
- vscode.window.showInformationMessage(localize("common.info.donate"), donateNow, writeReview).then((res) => {
- if (res == donateNow) {
- 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'));
- } else if (res == writeReview) {
- vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync#review-details'));
- }
- });
+ return token;
+ }
+ public async GetGistAndSave(sett: ExtensionConfig): Promise {
+ const opt = Commons.GetInputBox(false);
+
+ const gist = ((await vscode.window.showInputBox(opt)) || "").trim();
+
+ if (gist && gist !== "esc") {
+ sett.gist = gist;
+ const saved = await this.SaveSettings(sett);
+ if (saved) {
+ vscode.window.setStatusBarMessage(
+ localize("common.info.gistSaved"),
+ 1000
+ );
+ }
+ return gist;
+ }
+ }
+
+ /**
+ * IgnoreSettings
+ */
+ public async GetIgnoredSettings(settings: string[]): Promise