-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.mjs
51 lines (42 loc) · 1.39 KB
/
build.mjs
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
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env zx
import "npm:[email protected]/globals";
import { parse as parseJson } from "npm:[email protected]";
import * as fs from "node:fs";
const tsconfigPath = "./pyright/packages/pyright-internal/tsconfig.json";
const packagePath = "./pyright/packages/pyright-internal/package.json";
const tsconfig = await readJson(tsconfigPath);
const packageJson = await readJson(packagePath);
tsconfig.compilerOptions = Object.assign(tsconfig.compilerOptions, {
declaration: true,
preserveConstEnums: true,
});
fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, undefined, 2));
cd("pyright");
await $`npm ci`;
cd("./packages/pyright-internal");
await $`npm ci`;
await $`npm run build`;
await $`mv out/packages/pyright-internal/src ../../../dist`;
cd("../../../");
const date = await $`date '+%Y%m%d'`;
packageJson.name = "@zzzen/pyright-internal";
packageJson.repository = "github:Zzzen/pyright-packager";
packageJson.version = `1.2.0-dev.${date.stdout.trim()}`;
packageJson.private = false;
fs.writeFileSync("package.json", JSON.stringify(packageJson, undefined, 2));
/**
*
* @param {string} path
*/
async function readJson(path) {
const content = await Deno.readTextFile(path);
const errors = [];
const val = parseJson(content, errors, {
allowTrailingComma: true,
});
if (errors.length > 0) {
console.error(errors);
throw new Error(`failed to parse json: ${path}`);
}
return val;
}