-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathgenerate-versions.ts
More file actions
18 lines (14 loc) · 904 Bytes
/
generate-versions.ts
File metadata and controls
18 lines (14 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Generates src/generatedOnBuild/versions.ts from package-lock.json @github/copilot version.
// Run automatically via prebuild hook.
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const packageLock = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package-lock.json"), "utf-8"));
const cliVersion = packageLock.packages["node_modules/@github/copilot"].version;
const code = `// Generated by scripts/generate-versions.ts - DO NOT EDIT
export const PREFERRED_CLI_VERSION = "${cliVersion}";
`;
fs.mkdirSync(path.join(__dirname, "..", "src", "generatedOnBuild"), { recursive: true });
fs.writeFileSync(path.join(__dirname, "..", "src", "generatedOnBuild", "versions.ts"), code);
console.log(`Generated src/generatedOnBuild/versions.ts with PREFERRED_CLI_VERSION="${cliVersion}"`);