Repository navigation
Expand file tree
/
Copy pathpackage-vscode.mjs
More file actions
41 lines (34 loc) · 1.91 KB
/
Copy pathpackage-vscode.mjs
File metadata and controls
41 lines (34 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Builds and packages the VS Code extension into a .vsix installer.
// Output: dist/installers/<name>-<version>.vsix
//
// Cross-platform (macOS / Linux / Windows). Uses @vscode/vsce via npx.
import { execFileSync } from "node:child_process";
import { mkdirSync, copyFileSync, readFileSync, existsSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname, resolve } from "node:path";
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const vscodeDir = resolve(root, "vscode");
const outDir = resolve(root, "dist", "installers");
mkdirSync(outDir, { recursive: true });
const run = (cmd, args, cwd) =>
execFileSync(cmd, args, { cwd, stdio: "inherit", shell: process.platform === "win32" });
// 1. Build the shared web renderer the extension embeds — unless the caller
// (build-installers.ps1) already built it this run. Re-running esbuild here
// is pure waste, and on a memory-starved Windows runner each extra native
// esbuild spawn is another chance to hard-crash (exit 0xC0000409).
if (process.env.REV_GRAPH_SKIP_WEBVIEW_BUILD === "1") {
console.log("==> Reusing already-built web renderer (skip flag set)");
} else {
console.log("==> Building shared web renderer");
run("npm", ["run", "build:webview"], root);
}
// 2. Make the LICENSE available inside the extension package.
const rootLicense = resolve(root, "LICENSE");
if (existsSync(rootLicense)) copyFileSync(rootLicense, resolve(vscodeDir, "LICENSE"));
// 3. Package. --no-dependencies: extension.js is already bundled by esbuild,
// so no node_modules need to be included.
const pkg = JSON.parse(readFileSync(resolve(vscodeDir, "package.json"), "utf8"));
const outFile = resolve(outDir, `${pkg.name}-${pkg.version}.vsix`);
console.log("==> Packaging VS Code extension");
run("npx", ["--yes", "@vscode/vsce", "package", "--no-dependencies", "-o", outFile], vscodeDir);
console.log("\nVS Code installer: " + outFile);