aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-03-19 08:32:57 +0000
committerAleksey Kladov <[email protected]>2020-03-19 08:37:03 +0000
commit3d1cb5e20f7a05314f6fd4261076b0a85546cfe4 (patch)
tree6fd47ffb498891ca24b2972dabfdd58a3f737644 /editors/code
parentaca3c3086ee99f5770a60970e20af640c895d42a (diff)
Simplify extension tag sniffing
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/package.json4
-rw-r--r--editors/code/src/config.ts20
-rw-r--r--editors/code/src/main.ts4
3 files changed, 11 insertions, 17 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index 150c36845..9f2fe06f3 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -5,8 +5,8 @@
5 "preview": true, 5 "preview": true,
6 "private": true, 6 "private": true,
7 "icon": "icon.png", 7 "icon": "icon.png",
8 "//": "The real version is in release.yaml, this one just needs to be bigger", 8 "version": "0.4.0-dev",
9 "version": "0.2.20200309-nightly", 9 "releaseTag": "nightly",
10 "publisher": "matklad", 10 "publisher": "matklad",
11 "repository": { 11 "repository": {
12 "url": "https://github.com/rust-analyzer/rust-analyzer.git", 12 "url": "https://github.com/rust-analyzer/rust-analyzer.git",
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index 28698ab8e..54b905303 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -38,23 +38,17 @@ export class Config {
38 ] 38 ]
39 .map(opt => `${this.rootSection}.${opt}`); 39 .map(opt => `${this.rootSection}.${opt}`);
40 40
41 readonly packageJsonVersion = vscode 41 readonly packageJsonVersion: string = vscode
42 .extensions 42 .extensions
43 .getExtension(this.extensionId)! 43 .getExtension(this.extensionId)!
44 .packageJSON 44 .packageJSON
45 .version as string; // n.n.YYYYMMDD[-nightly] 45 .version;
46 46
47 /** 47 readonly releaseTag: string = vscode
48 * Either `nightly` or `YYYY-MM-DD` (i.e. `stable` release) 48 .extensions
49 */ 49 .getExtension(this.extensionId)!
50 readonly extensionReleaseTag: string = (() => { 50 .packageJSON
51 if (this.packageJsonVersion.endsWith(NIGHTLY_TAG)) return NIGHTLY_TAG; 51 .releaseTag;
52
53 const realVersionRegexp = /^\d+\.\d+\.(\d{4})(\d{2})(\d{2})/;
54 const [, yyyy, mm, dd] = this.packageJsonVersion.match(realVersionRegexp)!;
55
56 return `${yyyy}-${mm}-${dd}`;
57 })();
58 52
59 private cfg!: vscode.WorkspaceConfiguration; 53 private cfg!: vscode.WorkspaceConfiguration;
60 54
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index d907f3e6f..5297614a9 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -111,7 +111,7 @@ async function bootstrap(config: Config, state: PersistentState): Promise<string
111 111
112async function bootstrapExtension(config: Config, state: PersistentState): Promise<void> { 112async function bootstrapExtension(config: Config, state: PersistentState): Promise<void> {
113 if (config.channel === "stable") { 113 if (config.channel === "stable") {
114 if (config.extensionReleaseTag === NIGHTLY_TAG) { 114 if (config.releaseTag === NIGHTLY_TAG) {
115 vscode.window.showWarningMessage(`You are running a nightly version of rust-analyzer extension. 115 vscode.window.showWarningMessage(`You are running a nightly version of rust-analyzer extension.
116To switch to stable, uninstall the extension and re-install it from the marketplace`); 116To switch to stable, uninstall the extension and re-install it from the marketplace`);
117 } 117 }
@@ -219,7 +219,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string
219 if (userResponse !== "Download now") return dest; 219 if (userResponse !== "Download now") return dest;
220 } 220 }
221 221
222 const release = await fetchRelease(config.extensionReleaseTag); 222 const release = await fetchRelease(config.releaseTag);
223 const artifact = release.assets.find(artifact => artifact.name === binaryName); 223 const artifact = release.assets.find(artifact => artifact.name === binaryName);
224 assert(!!artifact, `Bad release: ${JSON.stringify(release)}`); 224 assert(!!artifact, `Bad release: ${JSON.stringify(release)}`);
225 225