Skip to content

Commit cba025d

Browse files
committed
make releasing new versions easier
1 parent 8f6470a commit cba025d

File tree

3 files changed

+42
-41
lines changed

3 files changed

+42
-41
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,7 @@
14691469
"vscode:prepublish": "tsc -p ./",
14701470
"vscode:uninstall": "node ./out/uninstall.js",
14711471
"compile": "tsc -p ./",
1472-
"lint": "eslint src; prettier --check .",
1472+
"lint": "tsc -p ./; eslint src; prettier --check .",
14731473
"watch": "tsc -watch -p ./",
14741474
"pretest": "npm run compile",
14751475
"test": "node ./out/test/runTest.js",

src/_bundled_versions.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/// Release ID for serve-d "nightly" release (API ID)
2+
export const nightlyReleaseId = 20717582;
3+
4+
/// Gets the URL for the binary tarball containing DCD, which is preloaded alongside serve-d to ensure DCD is installed
5+
export function getBundledDCDUrl(): string | undefined {
6+
const latest = "0.15.2";
7+
8+
if (process.platform === "linux" && process.arch === "x64") {
9+
return `https://github.com/dlang-community/DCD/releases/download/v${latest}/dcd-v${latest}-linux-x86_64.tar.gz`;
10+
} else if (process.platform === "linux" && process.arch === "arm64") {
11+
return `https://github.com/dlang-community/DCD/releases/download/v${latest}/dcd-v${latest}-linux-aarch64.tar.gz`;
12+
} else if (process.platform === "darwin" && process.arch === "arm64") {
13+
return `https://github.com/dlang-community/DCD/releases/download/v${latest}/dcd-v${latest}-osx-aarch64.tar.gz`;
14+
} else if (process.platform === "darwin" && process.arch === "x64") {
15+
return `https://github.com/dlang-community/DCD/releases/download/v${latest}/dcd-v${latest}-osx-x86_64.tar.gz`;
16+
} else if (
17+
process.platform === "win32" &&
18+
(process.arch === "x64" ||
19+
process.env.PROCESSOR_ARCHITEW6432 === "AMD64" ||
20+
process.env.PROCESSOR_ARCHITEW6432 === "IA64")
21+
) {
22+
return `https://github.com/dlang-community/DCD/releases/download/v${latest}/dcd-v${latest}-windows-x86_64.zip`;
23+
} else {
24+
return undefined;
25+
}
26+
}

src/installer.ts

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as rimraf from "rimraf";
1111
import * as AdmZip from "adm-zip";
1212
import * as async from "async";
1313
import * as mkdirp from "mkdirp";
14+
import { getBundledDCDUrl, nightlyReleaseId } from "./_bundled_versions";
1415

1516
function gitPath() {
1617
return vscode.workspace.getConfiguration("git").get("path", "git") || "git";
@@ -117,7 +118,6 @@ export interface Release {
117118
asset?: ReleaseAsset;
118119
}
119120

120-
const nightlyReleaseId = 20717582;
121121
const servedVersionCache = {
122122
release: <Release | undefined>undefined,
123123
channel: "",
@@ -273,14 +273,14 @@ function findFirstMatchingAsset(name: string | "nightly", assets: ReleaseAsset[]
273273
for (let i = 0; i < assets.length; i++) {
274274
const asset = assets[i];
275275
let test = asset.name;
276-
if (test.startsWith("serve-d")) test = test.substr("serve-d".length);
277-
if (test.startsWith("-") || test.startsWith("_")) test = test.substr(1);
276+
if (test.startsWith("serve-d")) test = test.substring("serve-d".length);
277+
if (test.startsWith("-") || test.startsWith("_")) test = test.substring(1);
278278

279279
if (!test.startsWith(os)) continue;
280-
test = test.substr(os.length);
281-
if (test.startsWith("-") || test.startsWith("_")) test = test.substr(1);
282-
if (test.startsWith("nightly")) test = test.substr("nightly".length);
283-
if (test.startsWith("-") || test.startsWith("_")) test = test.substr(1);
280+
test = test.substring(os.length);
281+
if (test.startsWith("-") || test.startsWith("_")) test = test.substring(1);
282+
if (test.startsWith("nightly")) test = test.substring("nightly".length);
283+
if (test.startsWith("-") || test.startsWith("_")) test = test.substring(1);
284284

285285
// remaining:
286286
// either x86_64-20191017-4b5427.tar.xz
@@ -291,18 +291,18 @@ function findFirstMatchingAsset(name: string | "nightly", assets: ReleaseAsset[]
291291
}
292292
return undefined;
293293
} else {
294-
if (name.startsWith("v")) name = name.substr(1);
294+
if (name.startsWith("v")) name = name.substring(1);
295295

296296
for (let i = 0; i < assets.length; i++) {
297297
const asset = assets[i];
298298
let test = asset.name;
299-
if (test.startsWith("serve-d")) test = test.substr("serve-d".length);
300-
if (test.startsWith("-") || test.startsWith("_")) test = test.substr(1);
301-
if (test.startsWith(name)) test = test.substr(name.length);
302-
if (test.startsWith("-") || test.startsWith("_")) test = test.substr(1);
299+
if (test.startsWith("serve-d")) test = test.substring("serve-d".length);
300+
if (test.startsWith("-") || test.startsWith("_")) test = test.substring(1);
301+
if (test.startsWith(name)) test = test.substring(name.length);
302+
if (test.startsWith("-") || test.startsWith("_")) test = test.substring(1);
303303

304304
const dot = test.indexOf(".");
305-
if (dot != -1) test = test.substr(0, dot);
305+
if (dot != -1) test = test.substring(0, dot);
306306

307307
if (test == `${os}-${arch}` || test == os) return asset;
308308
}
@@ -362,33 +362,8 @@ export function installServeD(
362362
};
363363

364364
// add DCD binaries here as well
365-
if (process.platform == "linux" && process.arch == "x64") {
366-
urls.push({
367-
url: "https://github.com/dlang-community/DCD/releases/download/v0.15.2/dcd-v0.15.2-linux-x86_64.tar.gz",
368-
title: "DCD",
369-
});
370-
} else if (process.platform == "darwin" && process.arch == "x64") {
371-
urls.push({
372-
url: "https://github.com/dlang-community/DCD/releases/download/v0.15.2/dcd-v0.15.2-osx-x86_64.tar.gz",
373-
title: "DCD",
374-
});
375-
} else if (process.platform == "darwin" && process.arch == "arm64") {
376-
urls.push({
377-
url: "https://github.com/dlang-community/DCD/releases/download/v0.15.2/dcd-v0.15.2-osx-arm64.tar.gz",
378-
title: "DCD",
379-
});
380-
} else if (process.platform == "win32") {
381-
if (process.arch == "x64")
382-
urls.push({
383-
url: "https://github.com/dlang-community/DCD/releases/download/v0.15.2/dcd-v0.15.2-windows-x86_64.zip",
384-
title: "DCD",
385-
});
386-
else
387-
urls.push({
388-
url: "https://github.com/dlang-community/DCD/releases/download/v0.15.2/dcd-v0.15.2-windows-x86.zip",
389-
title: "DCD",
390-
});
391-
}
365+
const bundledDCD = getBundledDCDUrl();
366+
if (bundledDCD) urls.push({ url: bundledDCD, title: "DCD" });
392367

393368
return (env: NodeJS.ProcessEnv) =>
394369
new Promise((done) => {

0 commit comments

Comments
 (0)