@intellectual-frontiers/libraries 0.2.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +75 -21
- package/dist/affected.d.ts +15 -2
- package/dist/affected.js +51 -20
- package/dist/dev.d.ts +83 -0
- package/dist/dev.js +359 -0
- package/dist/family.d.ts +58 -0
- package/dist/family.js +125 -0
- package/dist/generate-ontology.js +4 -0
- package/dist/generate-workflows.js +2 -10
- package/dist/install-bun.js +19 -14
- package/dist/libraries.d.ts +8 -0
- package/dist/libraries.js +24 -3
- package/dist/license/standard.d.ts +46 -0
- package/dist/license/standard.js +43 -0
- package/dist/license/third-party.d.ts +25 -0
- package/dist/license/third-party.js +71 -0
- package/dist/license.d.ts +61 -0
- package/dist/license.js +204 -0
- package/dist/link.d.ts +12 -0
- package/dist/link.js +98 -0
- package/dist/pack-library.d.ts +2 -0
- package/dist/pack-library.js +21 -3
- package/dist/pins.d.ts +34 -7
- package/dist/pins.js +36 -9
- package/dist/plan.d.ts +28 -0
- package/dist/plan.js +135 -0
- package/dist/readme.d.ts +59 -0
- package/dist/readme.js +272 -0
- package/dist/releasing.d.ts +176 -0
- package/dist/releasing.js +680 -0
- package/dist/versions.js +4 -7
- package/dist/workflows/definitions.d.ts +33 -30
- package/dist/workflows/definitions.js +201 -278
- package/dist/workflows/model.d.ts +19 -3
- package/dist/workflows/render.js +10 -2
- package/package.json +44 -14
- package/src/affected.ts +56 -17
- package/src/dev.ts +379 -0
- package/src/family.ts +144 -0
- package/src/generate-ontology.ts +4 -0
- package/src/generate-workflows.ts +3 -11
- package/src/install-bun.ts +16 -13
- package/src/libraries.ts +27 -3
- package/src/license/standard.ts +67 -0
- package/src/license/third-party.ts +87 -0
- package/src/license.ts +222 -0
- package/src/link.ts +97 -0
- package/src/pack-library.ts +21 -3
- package/src/pins.ts +55 -10
- package/src/plan.ts +143 -0
- package/src/readme.ts +278 -0
- package/src/releasing.ts +735 -0
- package/src/versions.ts +3 -7
- package/src/workflows/definitions.ts +262 -397
- package/src/workflows/model.ts +15 -3
- package/src/workflows/render.ts +10 -2
package/dist/dev.js
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The development loop (commons 0001-libraries FR-011, FR-012): the libraries a working tree changes, and the libraries that depend on them, type-checked and tested in parallel processes and no more than they need, with a calm summary. It is
|
|
3
|
+
* what a person or an agent runs between two edits; the release loop (the packing of every library, the register, the versions) is another command and is never part of this one.
|
|
4
|
+
*
|
|
5
|
+
* bun run dev:check the libraries affected since origin/main (and the files not yet committed), their types and their tests
|
|
6
|
+
* bun run dev:check --only system,net those libraries and their dependents, whatever changed
|
|
7
|
+
* bun run dev:check --files a.ts,b/c.ts the libraries these files affect (paths from the repository's root)
|
|
8
|
+
* bun run dev:check --all every library
|
|
9
|
+
* bun run dev:check --list say what is affected and run nothing
|
|
10
|
+
* other flags: --base REF (origin/main by default), --no-types, --no-tests, --no-license, --bail (stop at the first failing test), --repo DIR
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* Nothing is installed per library. The repository's root installs the packages every library shares (`bun install`, once), the libraries are linked under `commons/node_modules` (a link for each folder whose package
|
|
14
|
+
* name is `@intellectual-frontiers/<folder>`, and `@intellectual-frontiers/commons` for `commons/ts`), so that a library that imports another by its package name reads the checkout's source, never a copy from a
|
|
15
|
+
* registry: the `exports` of each package are the sources. A library with a package of its own outside the shared set (a database driver) is installed in its folder, once. The affected libraries are those of
|
|
16
|
+
* `affected.ts` (the same code the workflow of CI runs); TypeScript 7 checks each library's own `tsconfig.json`, several at a time, and the tests of each run in a `bun test` process of its own, from its folder as `verify` runs them, several at a time.
|
|
17
|
+
*
|
|
18
|
+
* @limits
|
|
19
|
+
* It proves less than `bun run verify` of a library: no specification check, no trace, no packing, no Node 26, no other system than this one. CI runs those on the libraries a push affects.
|
|
20
|
+
* A change of a file that no library reads affects no library, and nothing is run.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { bunCounts } from "./dev.ts";
|
|
25
|
+
* bunCounts(" 913 pass\n 3 skip\n 0 fail\nRan 917 tests across 141 files. [55.88s]\n"); // { pass: 913, skip: 3, fail: 0, files: 141 }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* Spec: 0001-libraries FR-011
|
|
29
|
+
*
|
|
30
|
+
* @module
|
|
31
|
+
*/
|
|
32
|
+
import process from "node:process";
|
|
33
|
+
import { absurd, err, ok } from "@intellectual-frontiers/core";
|
|
34
|
+
import { stdio } from "@intellectual-frontiers/system";
|
|
35
|
+
import { existsSync, readDirSync, readTextFileSync } from "@intellectual-frontiers/system/fs";
|
|
36
|
+
import { dirname, join, resolve } from "@intellectual-frontiers/system/path";
|
|
37
|
+
import { build, run } from "@intellectual-frontiers/system/proc";
|
|
38
|
+
import { currentLook } from "@intellectual-frontiers/system/tty";
|
|
39
|
+
import { flag, formatUsageError, helpText, many, parseArgs, value } from "@intellectual-frontiers/terminal/args";
|
|
40
|
+
import { label, paint } from "@intellectual-frontiers/terminal/palette";
|
|
41
|
+
import { affectedBy, changedSince, everyLibrary } from "./affected.js";
|
|
42
|
+
import { linkAll } from "./link.js";
|
|
43
|
+
import { judge as judgeLicense, sentence as licenseSentence } from "./license.js";
|
|
44
|
+
/** The counts in the end of what `bun test` printed, or undefined where it printed none. */
|
|
45
|
+
export function bunCounts(text) {
|
|
46
|
+
const n = (word) => Number(new RegExp(`^\\s*(\\d+) ${word}\\s*$`, "m").exec(text)?.[1] ?? 0);
|
|
47
|
+
const ran = /^Ran \d+ tests? across (\d+) files?/m.exec(text);
|
|
48
|
+
return ran?.[1] === undefined ? undefined : { pass: n("pass"), skip: n("skip"), fail: n("fail"), files: Number(ran[1]) };
|
|
49
|
+
}
|
|
50
|
+
/** The lines of `bun test`'s output that say what failed: the failing tests and the error lines above each, in order. */
|
|
51
|
+
export function failureLines(text) {
|
|
52
|
+
const lines = text.split("\n");
|
|
53
|
+
const out = [];
|
|
54
|
+
lines.forEach((l, i) => {
|
|
55
|
+
if (!/^\(fail\)/.test(l) && !/^error:/.test(l))
|
|
56
|
+
return;
|
|
57
|
+
if (/^\(fail\)/.test(l))
|
|
58
|
+
out.push(l);
|
|
59
|
+
else {
|
|
60
|
+
out.push(l);
|
|
61
|
+
for (const next of lines.slice(i + 1, i + 6))
|
|
62
|
+
if (/^\s+at |^\s+\d+ \|/.test(next))
|
|
63
|
+
out.push(next);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return out.length > 0 ? out : lines.slice(-30);
|
|
67
|
+
}
|
|
68
|
+
/** The first lines of a compiler's output, so a long one does not bury the summary. */
|
|
69
|
+
export function head(lines, n) {
|
|
70
|
+
return lines.length <= n ? lines : [...lines.slice(0, n), `... and ${lines.length - n} more`];
|
|
71
|
+
}
|
|
72
|
+
/** The packages a library declares that neither are libraries of the repository nor are installed at the root: the ones it must install itself. */
|
|
73
|
+
export function ownPackages(pkg, shared) {
|
|
74
|
+
const out = new Set();
|
|
75
|
+
for (const field of ["dependencies", "devDependencies"]) {
|
|
76
|
+
const o = pkg[field];
|
|
77
|
+
if (typeof o !== "object" || o === null)
|
|
78
|
+
continue;
|
|
79
|
+
for (const [k, v] of Object.entries(o))
|
|
80
|
+
if (typeof v === "string" && !v.startsWith("link:") && !shared.has(k))
|
|
81
|
+
out.add(k);
|
|
82
|
+
}
|
|
83
|
+
return [...out].sort();
|
|
84
|
+
}
|
|
85
|
+
const readJson = (file) => {
|
|
86
|
+
try {
|
|
87
|
+
const x = JSON.parse(readTextFileSync(file));
|
|
88
|
+
return typeof x === "object" && x !== null && !Array.isArray(x) ? Object.fromEntries(Object.entries(x)) : {};
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return {};
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
/** Links the libraries under `commons/node_modules` where they are not linked yet (`link.ts`, which `bun run dev:check` runs before this command can import any of them). */
|
|
95
|
+
export function linkLibraries(repo) {
|
|
96
|
+
const r = linkAll(repo);
|
|
97
|
+
return "problem" in r ? err(r.problem) : ok(r.made);
|
|
98
|
+
}
|
|
99
|
+
/** The revision a loop compares with where none is given: `origin/main`, else `main`, else `HEAD` (the working tree alone). */
|
|
100
|
+
export async function defaultBase(repo) {
|
|
101
|
+
for (const ref of ["origin/main", "main"]) {
|
|
102
|
+
const r = await run(["git", "-C", repo, "rev-parse", "--verify", "--quiet", ref]);
|
|
103
|
+
if (r.code === 0)
|
|
104
|
+
return ref;
|
|
105
|
+
}
|
|
106
|
+
return "HEAD";
|
|
107
|
+
}
|
|
108
|
+
/** What a scope affects: the libraries and why, or why it cannot be said. */
|
|
109
|
+
export async function affectedOf(repo, scope) {
|
|
110
|
+
switch (scope.kind) {
|
|
111
|
+
case "all":
|
|
112
|
+
return ok({ libs: everyLibrary(repo), why: "every library" });
|
|
113
|
+
case "files":
|
|
114
|
+
return ok({ libs: affectedBy(repo, scope.files, "code"), why: `${scope.files.length} named files` });
|
|
115
|
+
case "only": {
|
|
116
|
+
const all = everyLibrary(repo);
|
|
117
|
+
const unknown = scope.names.filter((n) => !all.some((l) => l.name === n));
|
|
118
|
+
if (unknown.length > 0)
|
|
119
|
+
return err(`no library named ${unknown.join(", ")} (they are: ${all.map((l) => l.name).join(", ")})`);
|
|
120
|
+
const roots = all.filter((l) => scope.names.includes(l.name)).flatMap((l) => `commons/${l.name}/library.ts`);
|
|
121
|
+
return ok({ libs: affectedBy(repo, roots, "code"), why: `${scope.names.join(", ")} and what imports them` });
|
|
122
|
+
}
|
|
123
|
+
case "since": {
|
|
124
|
+
const changed = await changedSince(repo, scope.base);
|
|
125
|
+
if (changed === undefined)
|
|
126
|
+
return ok({ libs: everyLibrary(repo), why: `git cannot say what changed since ${scope.base}` });
|
|
127
|
+
return ok({ libs: affectedBy(repo, changed, "code"), why: `${changed.length} files changed since ${scope.base}` });
|
|
128
|
+
}
|
|
129
|
+
default:
|
|
130
|
+
return absurd(scope);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** The compiler's program for this system: the one the root installs. */
|
|
134
|
+
const tscOf = (repo) => join(repo, "node_modules", ".bin", build.os === "windows" ? "tsc.cmd" : "tsc");
|
|
135
|
+
/** Runs `job` over `items`, at most `width` at a time, and gives the results in the order of the items. */
|
|
136
|
+
export async function pool(items, width, job) {
|
|
137
|
+
const out = [];
|
|
138
|
+
const results = new Map();
|
|
139
|
+
let next = 0;
|
|
140
|
+
const worker = async () => {
|
|
141
|
+
for (let i = next++; i < items.length; i = next++) {
|
|
142
|
+
const item = items[i];
|
|
143
|
+
if (item !== undefined)
|
|
144
|
+
results.set(i, await job(item));
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
await Promise.all(Array.from({ length: Math.max(1, Math.min(width, items.length)) }, worker));
|
|
148
|
+
for (let i = 0; i < items.length; i++) {
|
|
149
|
+
const r = results.get(i);
|
|
150
|
+
if (r !== undefined)
|
|
151
|
+
out.push(r);
|
|
152
|
+
}
|
|
153
|
+
return out;
|
|
154
|
+
}
|
|
155
|
+
const seconds = (since) => `${((performance.now() - since) / 1000).toFixed(1)}s`;
|
|
156
|
+
const plural = (n, one, many_ = `${one}s`) => `${n} ${n === 1 ? one : many_}`;
|
|
157
|
+
/** What the loop needs installed: the root's packages, the links, and the packages of a library that has its own. */
|
|
158
|
+
export async function prepare(repo, libs) {
|
|
159
|
+
const said = [];
|
|
160
|
+
if (!existsSync(tscOf(repo))) {
|
|
161
|
+
const r = await run(["bun", "install", "--frozen-lockfile"], { cwd: repo });
|
|
162
|
+
if (r.code !== 0)
|
|
163
|
+
return err(`bun install at the root failed:\n${r.stderr.trim()}`);
|
|
164
|
+
said.push("installed the packages of the root");
|
|
165
|
+
}
|
|
166
|
+
const linked = linkLibraries(repo);
|
|
167
|
+
if (linked.kind === "err")
|
|
168
|
+
return linked;
|
|
169
|
+
if (linked.value > 0)
|
|
170
|
+
said.push(`linked ${plural(linked.value, "package")} under commons/node_modules`);
|
|
171
|
+
const rootPkg = readJson(join(repo, "package.json"));
|
|
172
|
+
const shared = new Set(["dependencies", "devDependencies"].flatMap((f) => {
|
|
173
|
+
const o = rootPkg[f];
|
|
174
|
+
return typeof o === "object" && o !== null ? Object.keys(o) : [];
|
|
175
|
+
}));
|
|
176
|
+
for (const l of libs) {
|
|
177
|
+
const own = ownPackages(readJson(join(repo, l.folder, "package.json")), shared);
|
|
178
|
+
if (own.length === 0 || existsSync(join(repo, l.folder, "node_modules")))
|
|
179
|
+
continue;
|
|
180
|
+
const r = await run(["bun", "install", "--frozen-lockfile"], { cwd: join(repo, l.folder) });
|
|
181
|
+
if (r.code !== 0)
|
|
182
|
+
return err(`bun install in ${l.folder} failed:\n${r.stderr.trim()}`);
|
|
183
|
+
said.push(`installed ${l.folder}'s own packages (${own.join(", ")})`);
|
|
184
|
+
}
|
|
185
|
+
return ok(said);
|
|
186
|
+
}
|
|
187
|
+
/** TypeScript on the libraries, several at a time. */
|
|
188
|
+
export async function typeCheck(repo, libs, width) {
|
|
189
|
+
const t0 = performance.now();
|
|
190
|
+
const checked = libs.filter((l) => existsSync(join(repo, l.folder, "tsconfig.json")));
|
|
191
|
+
const results = await pool(checked, width, async (l) => {
|
|
192
|
+
const r = await run([tscOf(repo), "-p", "tsconfig.json", "--pretty", "false"], { cwd: join(repo, l.folder) });
|
|
193
|
+
return { name: l.name, code: r.code, lines: `${r.stdout}${r.stderr}`.split("\n").filter((x) => x.trim() !== "") };
|
|
194
|
+
});
|
|
195
|
+
const bad = results.filter((r) => r.code !== 0);
|
|
196
|
+
if (bad.length === 0)
|
|
197
|
+
return { kind: "passed", detail: `${plural(checked.length, "library", "libraries")} in ${seconds(t0)}` };
|
|
198
|
+
return {
|
|
199
|
+
kind: "failed",
|
|
200
|
+
detail: `${bad.map((b) => b.name).join(", ")} in ${seconds(t0)}`,
|
|
201
|
+
output: bad.flatMap((b) => head(b.lines, 25).map((x) => `${b.name}: ${x}`)),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/** The license of the repository and of each library, as the check of `license.ts` finds it: a library with no `LICENSE` fails here, and the sentence says the command that writes it. */
|
|
205
|
+
export async function licenseStage(repo) {
|
|
206
|
+
const t0 = performance.now();
|
|
207
|
+
const { findings } = await judgeLicense(repo);
|
|
208
|
+
if (findings.length === 0)
|
|
209
|
+
return { kind: "passed", detail: `every LICENSE is the official text in ${seconds(t0)}` };
|
|
210
|
+
return { kind: "failed", detail: plural(findings.length, "finding", "findings"), output: findings.map(licenseSentence) };
|
|
211
|
+
}
|
|
212
|
+
/** The sum of counts. */
|
|
213
|
+
export const addCounts = (a, b) => ({ pass: a.pass + b.pass, skip: a.skip + b.skip, fail: a.fail + b.fail, files: a.files + b.files });
|
|
214
|
+
/**
|
|
215
|
+
* The tests of the libraries: one `bun test suite/` process for each library, from its folder as its `verify` runs it, several at a time and the largest suites first. One process for all of them would be fewer, but a
|
|
216
|
+
* test may set what is global to its process (the tracer of a process, a working folder), and what it sets must not reach the tests of another library.
|
|
217
|
+
*/
|
|
218
|
+
export async function runTests(repo, libs, width, bail) {
|
|
219
|
+
const t0 = performance.now();
|
|
220
|
+
const files = (l) => readDirSync(join(repo, l.folder, "suite")).length;
|
|
221
|
+
const suites = libs.filter((l) => existsSync(join(repo, l.folder, "suite"))).sort((a, b) => files(b) - files(a));
|
|
222
|
+
if (suites.length === 0)
|
|
223
|
+
return { kind: "skipped", detail: "no library of these has a suite" };
|
|
224
|
+
const results = await pool(suites, width, async (l) => {
|
|
225
|
+
const r = await run(["bun", "test", ...(bail ? ["--bail"] : []), "suite/"], { cwd: join(repo, l.folder), env: { CI: "" } });
|
|
226
|
+
const text = `${r.stdout}\n${r.stderr}`;
|
|
227
|
+
return { name: l.name, code: r.code, counts: bunCounts(text), text };
|
|
228
|
+
});
|
|
229
|
+
const total = results.reduce((sum, r) => (r.counts === undefined ? sum : addCounts(sum, r.counts)), { pass: 0, skip: 0, fail: 0, files: 0 });
|
|
230
|
+
const detail = `${total.pass} pass${total.skip > 0 ? `, ${total.skip} skipped` : ""}${total.fail > 0 ? `, ${total.fail} fail` : ""} in ${plural(total.files, "file")} of ${plural(suites.length, "library", "libraries")}, ${seconds(t0)}`;
|
|
231
|
+
const bad = results.filter((r) => r.code !== 0 || r.counts === undefined);
|
|
232
|
+
if (bad.length === 0)
|
|
233
|
+
return { kind: "passed", detail };
|
|
234
|
+
return {
|
|
235
|
+
kind: "failed",
|
|
236
|
+
detail,
|
|
237
|
+
output: bad.flatMap((r) => [
|
|
238
|
+
...(r.counts === undefined ? [`${r.name}: bun test ended with ${r.code} and no summary`] : []),
|
|
239
|
+
...head(failureLines(r.text), 40).map((l) => `${r.name}: ${l}`),
|
|
240
|
+
]),
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
/** The summary the loop prints: one line for what it looked at, one for each stage, and what failed under it. */
|
|
244
|
+
export function summaryLines(look, what, stages, notes, took) {
|
|
245
|
+
const out = [];
|
|
246
|
+
out.push(`${paint("accent", "dev:check", look)} ${what.why}`);
|
|
247
|
+
for (const n of notes)
|
|
248
|
+
out.push(` ${label("hint", n, look)}`);
|
|
249
|
+
if (what.libs.length === 0)
|
|
250
|
+
out.push(` ${label("skipped", "nothing is affected: no library reads what changed", look)}`);
|
|
251
|
+
else
|
|
252
|
+
out.push(` ${paint("dim", "affected", look)} ${plural(what.libs.length, "library", "libraries")}: ${what.libs.join(", ")}`);
|
|
253
|
+
for (const s of stages) {
|
|
254
|
+
const o = s.outcome;
|
|
255
|
+
switch (o.kind) {
|
|
256
|
+
case "passed":
|
|
257
|
+
out.push(` ${label("done", `${s.name.padEnd(6)} ${o.detail}`, look)}`);
|
|
258
|
+
break;
|
|
259
|
+
case "skipped":
|
|
260
|
+
out.push(` ${label("skipped", `${s.name.padEnd(6)} ${o.detail}`, look)}`);
|
|
261
|
+
break;
|
|
262
|
+
case "failed":
|
|
263
|
+
out.push(` ${label("failed", `${s.name.padEnd(6)} ${o.detail}`, look)}`, ...o.output.map((l) => ` ${l}`));
|
|
264
|
+
break;
|
|
265
|
+
default:
|
|
266
|
+
return absurd(o);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (stages.length === 0)
|
|
270
|
+
return out;
|
|
271
|
+
const failed = stages.some((s) => s.outcome.kind === "failed");
|
|
272
|
+
out.push(` ${failed ? label("failed", `not ready to push (${took})`, look) : label("done", `ready to push (${took})`, look)}`);
|
|
273
|
+
return out;
|
|
274
|
+
}
|
|
275
|
+
const OPTIONS = {
|
|
276
|
+
base: value({ help: "The revision to compare with (origin/main, else main, else HEAD).", valueName: "REF" }),
|
|
277
|
+
files: many({ help: "A file that changed (from the repository's root); the libraries it affects. Repeat or separate with commas.", valueName: "FILE" }),
|
|
278
|
+
only: many({ help: "A library, and what depends on it, whatever changed. Repeat or separate with commas.", valueName: "NAME" }),
|
|
279
|
+
all: flag({ help: "Every library." }),
|
|
280
|
+
list: flag({ help: "Say what is affected and run nothing." }),
|
|
281
|
+
types: flag({ help: "Type-check the libraries (on by default).", negatable: true, default: true }),
|
|
282
|
+
tests: flag({ help: "Run their tests (on by default).", negatable: true, default: true }),
|
|
283
|
+
license: flag({ help: "Check the license files of the repository (on by default).", negatable: true, default: true }),
|
|
284
|
+
bail: flag({ help: "Stop the tests at the first one that fails." }),
|
|
285
|
+
repo: value({ help: "The repository (the working folder, or the one above it that has commons/, by default).", valueName: "DIR" }),
|
|
286
|
+
};
|
|
287
|
+
const commas = (xs) => xs
|
|
288
|
+
.flatMap((x) => x.split(","))
|
|
289
|
+
.map((x) => x.trim())
|
|
290
|
+
.filter((x) => x !== "");
|
|
291
|
+
/** The root of the repository that holds `from`: the nearest folder above it that has `commons/libraries/library.ts`. */
|
|
292
|
+
export function repoRootOf(from) {
|
|
293
|
+
for (let d = resolve(from);; d = dirname(d)) {
|
|
294
|
+
if (existsSync(join(d, "commons", "libraries", "library.ts")))
|
|
295
|
+
return d;
|
|
296
|
+
if (dirname(d) === d)
|
|
297
|
+
return undefined;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/** The command line. Returns the exit status: 0 where what is affected passed, 1 where a stage failed, 2 for a command line that does not fit. */
|
|
301
|
+
export async function main(argv) {
|
|
302
|
+
const parsed = parseArgs(argv, OPTIONS);
|
|
303
|
+
if (parsed.kind === "err") {
|
|
304
|
+
stdio.stderr.writeSync(`${formatUsageError(parsed.error, "dev:check")}\n`);
|
|
305
|
+
return 2;
|
|
306
|
+
}
|
|
307
|
+
if (parsed.value.kind === "help") {
|
|
308
|
+
stdio.stdout.writeSync(`${helpText("dev:check", "Type-check and test the libraries a change affects, and those that depend on them.", OPTIONS)}\n`);
|
|
309
|
+
return 0;
|
|
310
|
+
}
|
|
311
|
+
const o = parsed.value.options;
|
|
312
|
+
const repo = o.repo === undefined ? repoRootOf(process.cwd()) : resolve(o.repo);
|
|
313
|
+
if (repo === undefined) {
|
|
314
|
+
stdio.stderr.writeSync("dev:check: no repository with commons/libraries here or above; give --repo DIR\n");
|
|
315
|
+
return 2;
|
|
316
|
+
}
|
|
317
|
+
const look = currentLook("stdout");
|
|
318
|
+
const t0 = performance.now();
|
|
319
|
+
const files = commas(o.files ?? []);
|
|
320
|
+
const only = commas(o.only ?? []);
|
|
321
|
+
const scope = o.all
|
|
322
|
+
? { kind: "all" }
|
|
323
|
+
: files.length > 0
|
|
324
|
+
? { kind: "files", files }
|
|
325
|
+
: only.length > 0
|
|
326
|
+
? { kind: "only", names: only }
|
|
327
|
+
: { kind: "since", base: o.base ?? (await defaultBase(repo)) };
|
|
328
|
+
const found = await affectedOf(repo, scope);
|
|
329
|
+
if (found.kind === "err") {
|
|
330
|
+
stdio.stderr.writeSync(`dev:check: ${found.error}\n`);
|
|
331
|
+
return 2;
|
|
332
|
+
}
|
|
333
|
+
const { libs, why } = found.value;
|
|
334
|
+
const names = libs.map((l) => l.name);
|
|
335
|
+
const stages = [];
|
|
336
|
+
let notes = [];
|
|
337
|
+
if (libs.length > 0 && !o.list) {
|
|
338
|
+
const ready = await prepare(repo, libs);
|
|
339
|
+
if (ready.kind === "err") {
|
|
340
|
+
stdio.stderr.writeSync(`dev:check: ${ready.error}\n`);
|
|
341
|
+
return 1;
|
|
342
|
+
}
|
|
343
|
+
notes = ready.value;
|
|
344
|
+
const cpus = Math.max(2, globalThis.navigator?.hardwareConcurrency ?? 4);
|
|
345
|
+
const width = Math.min(8, cpus);
|
|
346
|
+
const [types, tests] = await Promise.all([
|
|
347
|
+
o.types ? typeCheck(repo, libs, width) : Promise.resolve({ kind: "skipped", detail: "--no-types" }),
|
|
348
|
+
o.tests ? runTests(repo, libs, cpus, o.bail) : Promise.resolve({ kind: "skipped", detail: "--no-tests" }),
|
|
349
|
+
]);
|
|
350
|
+
stages.push({ name: "types", outcome: types }, { name: "tests", outcome: tests });
|
|
351
|
+
}
|
|
352
|
+
if (!o.list && o.license)
|
|
353
|
+
stages.push({ name: "license", outcome: await licenseStage(repo) });
|
|
354
|
+
for (const l of summaryLines(look, { why, libs: names }, stages, notes, seconds(t0)))
|
|
355
|
+
stdio.stdout.writeSync(`${l}\n`);
|
|
356
|
+
return stages.some((s) => s.outcome.kind === "failed") ? 1 : 0;
|
|
357
|
+
}
|
|
358
|
+
if (import.meta.main)
|
|
359
|
+
process.exitCode = await main(process.argv.slice(2));
|
package/dist/family.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The families of the libraries of commons and the names held for them (commons 0027-commons-libraries FR-023, FR-024; commons 0033-kanon FR-021, FR-024): what the `family` field of a manifest
|
|
3
|
+
* says, the reservations (names no library may take unless it is of the family they are held for), and the findings of the two sides of a family held together, the host's table and each member's
|
|
4
|
+
* manifest.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Pure: it takes the libraries as data and returns one sentence for each finding. A library names its host and its role (`host`, `dialect` or `plugin`); the host's `kanon` table says what its
|
|
8
|
+
* dialects and plugins are and how their packages are named (`@intellectual-frontiers/kanon`: `family`, `instances`, `plugins`), so the name of a member is checked against the host's rule and
|
|
9
|
+
* never against a rule written here. A reservation is data: an exact name or a prefix, and the host that may hold it. It reserves a name without a folder, so that no empty library is created to hold one.
|
|
10
|
+
*
|
|
11
|
+
* Spec: 0001-libraries FR-016
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import { type Result } from "@intellectual-frontiers/core";
|
|
16
|
+
import { type Table } from "@intellectual-frontiers/kanon";
|
|
17
|
+
/** The roles a library has in a family: a closed union. */
|
|
18
|
+
export declare const ROLES: readonly ["host", "dialect", "plugin"];
|
|
19
|
+
/** The role of a library in a family. */
|
|
20
|
+
export type Role = (typeof ROLES)[number];
|
|
21
|
+
/** What a manifest says of its family: the host's library name and its own role. */
|
|
22
|
+
export type LibraryFamily = {
|
|
23
|
+
readonly host: string;
|
|
24
|
+
readonly role: Role;
|
|
25
|
+
};
|
|
26
|
+
/** How a reservation holds names: one exact name, or every name that begins with a prefix. */
|
|
27
|
+
export type Match = {
|
|
28
|
+
readonly kind: "exact";
|
|
29
|
+
readonly name: string;
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: "prefix";
|
|
32
|
+
readonly prefix: string;
|
|
33
|
+
};
|
|
34
|
+
/** A held name: what it matches, the host whose family may use it and why it is held. */
|
|
35
|
+
export type Reservation = {
|
|
36
|
+
readonly match: Match;
|
|
37
|
+
readonly host: string;
|
|
38
|
+
readonly reason: string;
|
|
39
|
+
};
|
|
40
|
+
/** The names held, as data: the check reads them and no folder holds them. */
|
|
41
|
+
export declare const RESERVED: readonly Reservation[];
|
|
42
|
+
/** Whether a library name is one a match holds. */
|
|
43
|
+
export declare function matches(match: Match, name: string): boolean;
|
|
44
|
+
/** The family field of a manifest, from what it says: the host's name and the role, or why it is not one. */
|
|
45
|
+
export declare function decodeFamily(input: {
|
|
46
|
+
readonly host: string;
|
|
47
|
+
readonly role: Role;
|
|
48
|
+
}): Result<LibraryFamily, string>;
|
|
49
|
+
/** What the check reads of a library: its name, its family and its table. */
|
|
50
|
+
export type Entry = {
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly family?: LibraryFamily;
|
|
53
|
+
readonly kanon?: Table;
|
|
54
|
+
};
|
|
55
|
+
/** The findings of the names held: a library whose name a reservation holds and that is not of the family the name is held for. */
|
|
56
|
+
export declare function reservationFindings(libraries: readonly Entry[], reserved?: readonly Reservation[]): readonly string[];
|
|
57
|
+
/** The findings of a family held together: each member's name against the host's rule, each declared member registered, and each registered member declared (0033-kanon FR-021). */
|
|
58
|
+
export declare function familyFindings(libraries: readonly Entry[]): readonly string[];
|
package/dist/family.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The families of the libraries of commons and the names held for them (commons 0027-commons-libraries FR-023, FR-024; commons 0033-kanon FR-021, FR-024): what the `family` field of a manifest
|
|
3
|
+
* says, the reservations (names no library may take unless it is of the family they are held for), and the findings of the two sides of a family held together, the host's table and each member's
|
|
4
|
+
* manifest.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Pure: it takes the libraries as data and returns one sentence for each finding. A library names its host and its role (`host`, `dialect` or `plugin`); the host's `kanon` table says what its
|
|
8
|
+
* dialects and plugins are and how their packages are named (`@intellectual-frontiers/kanon`: `family`, `instances`, `plugins`), so the name of a member is checked against the host's rule and
|
|
9
|
+
* never against a rule written here. A reservation is data: an exact name or a prefix, and the host that may hold it. It reserves a name without a folder, so that no empty library is created to hold one.
|
|
10
|
+
*
|
|
11
|
+
* Spec: 0001-libraries FR-016
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import { absurd, err, ok } from "@intellectual-frontiers/core";
|
|
16
|
+
import { classify, parsePackageName } from "@intellectual-frontiers/kanon";
|
|
17
|
+
/** The roles a library has in a family: a closed union. */
|
|
18
|
+
export const ROLES = ["host", "dialect", "plugin"];
|
|
19
|
+
/** The scope of the packages of commons. */
|
|
20
|
+
const SCOPE = "@intellectual-frontiers/";
|
|
21
|
+
/** The reason the names of the retired fleet engine are held (intellectual-frontiers/.github#11). */
|
|
22
|
+
const ARCHON = "held for the fleet library and its dialects and plugins, which replace the retired fleet engine (intellectual-frontiers/.github#11)";
|
|
23
|
+
/** The names held, as data: the check reads them and no folder holds them. */
|
|
24
|
+
export const RESERVED = [
|
|
25
|
+
{ match: { kind: "exact", name: "archon" }, host: "archon", reason: ARCHON },
|
|
26
|
+
{ match: { kind: "prefix", prefix: "archon-" }, host: "archon", reason: ARCHON },
|
|
27
|
+
{ match: { kind: "exact", name: "signing" }, host: "signing", reason: "held for the signing library of the fleet libraries (intellectual-frontiers/.github#11)" },
|
|
28
|
+
{ match: { kind: "exact", name: "gitops" }, host: "gitops", reason: "held for the gitops library of the fleet libraries (intellectual-frontiers/.github#11)" },
|
|
29
|
+
{ match: { kind: "exact", name: "estate" }, host: "estate", reason: "held for the estate library of the fleet libraries (intellectual-frontiers/.github#11)" },
|
|
30
|
+
{ match: { kind: "exact", name: "toolchain" }, host: "toolchain", reason: "held for the toolchain library of the fleet libraries (intellectual-frontiers/.github#11)" },
|
|
31
|
+
];
|
|
32
|
+
/** Whether a library name is one a match holds. */
|
|
33
|
+
export function matches(match, name) {
|
|
34
|
+
switch (match.kind) {
|
|
35
|
+
case "exact":
|
|
36
|
+
return name === match.name;
|
|
37
|
+
case "prefix":
|
|
38
|
+
return name.startsWith(match.prefix);
|
|
39
|
+
default:
|
|
40
|
+
return absurd(match);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** The family field of a manifest, from what it says: the host's name and the role, or why it is not one. */
|
|
44
|
+
export function decodeFamily(input) {
|
|
45
|
+
return /^[a-z][a-z0-9-]*$/.test(input.host)
|
|
46
|
+
? ok({ host: input.host, role: input.role })
|
|
47
|
+
: err(`library.family.host ${JSON.stringify(input.host)} is not a library name`);
|
|
48
|
+
}
|
|
49
|
+
/** The findings of the names held: a library whose name a reservation holds and that is not of the family the name is held for. */
|
|
50
|
+
export function reservationFindings(libraries, reserved = RESERVED) {
|
|
51
|
+
const out = [];
|
|
52
|
+
for (const l of libraries)
|
|
53
|
+
for (const r of reserved) {
|
|
54
|
+
if (!matches(r.match, l.name))
|
|
55
|
+
continue;
|
|
56
|
+
if (l.family?.host !== r.host)
|
|
57
|
+
out.push(`commons/${l.name}: the name is ${r.reason}, so the manifest declares family: { host: "${r.host}", role } (0033-kanon FR-024)`);
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
/** The findings of a family held together: each member's name against the host's rule, each declared member registered, and each registered member declared (0033-kanon FR-021). */
|
|
63
|
+
export function familyFindings(libraries) {
|
|
64
|
+
const out = [];
|
|
65
|
+
const by = new Map(libraries.map((l) => [l.name, l]));
|
|
66
|
+
for (const l of libraries) {
|
|
67
|
+
const f = l.family;
|
|
68
|
+
if (f === undefined) {
|
|
69
|
+
for (const h of libraries) {
|
|
70
|
+
const rule = h.kanon?.family;
|
|
71
|
+
const pkg = parsePackageName(`${SCOPE}${l.name}`);
|
|
72
|
+
if (rule !== undefined && h.kanon !== undefined && pkg.kind === "ok" && h.name !== l.name) {
|
|
73
|
+
const member = classify(rule, h.kanon.package, pkg.value);
|
|
74
|
+
if (member !== undefined && member.kind !== "host")
|
|
75
|
+
out.push(`commons/${l.name}: the name is a ${member.kind} of ${h.name} by its family rule, and the manifest declares no family (0033-kanon FR-021)`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
switch (f.role) {
|
|
81
|
+
case "host":
|
|
82
|
+
if (l.name !== f.host)
|
|
83
|
+
out.push(`commons/${l.name}: it declares itself the host of the family ${f.host}, and a host is named as its family (0033-kanon FR-021)`);
|
|
84
|
+
break;
|
|
85
|
+
case "dialect":
|
|
86
|
+
case "plugin": {
|
|
87
|
+
const host = by.get(f.host);
|
|
88
|
+
if (host === undefined || host.family?.role !== "host" || host.kanon === undefined) {
|
|
89
|
+
out.push(`commons/${l.name}: its family host ${f.host} is not a library that declares family role host and a kanon table (0033-kanon FR-021)`);
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
const rule = host.kanon.family;
|
|
93
|
+
const pkg = parsePackageName(`${SCOPE}${l.name}`);
|
|
94
|
+
const member = rule === undefined || pkg.kind === "err" ? undefined : classify(rule, host.kanon.package, pkg.value);
|
|
95
|
+
if (member === undefined || member.kind !== f.role)
|
|
96
|
+
out.push(`commons/${l.name}: the family rule of ${f.host} does not read the name as a ${f.role} (0033-kanon FR-021)`);
|
|
97
|
+
const declared = f.role === "dialect"
|
|
98
|
+
? host.kanon.instances.some((i) => i.kind === "package" && i.package === `${SCOPE}${l.name}`)
|
|
99
|
+
: host.kanon.plugins.some((p) => p.package === `${SCOPE}${l.name}`);
|
|
100
|
+
if (!declared)
|
|
101
|
+
out.push(`commons/${l.name}: the kanon table of ${f.host} does not declare it as a ${f.role} (0033-kanon FR-020)`);
|
|
102
|
+
if (l.kanon === undefined || l.kanon.extends !== host.kanon.package)
|
|
103
|
+
out.push(`commons/${l.name}: a ${f.role} of ${f.host} declares a kanon table with extends: "${host.kanon.package}" (0033-kanon FR-020)`);
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
default:
|
|
107
|
+
return absurd(f.role);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
for (const h of libraries) {
|
|
111
|
+
if (h.kanon === undefined)
|
|
112
|
+
continue;
|
|
113
|
+
const members = [
|
|
114
|
+
...h.kanon.instances.flatMap((i) => (i.kind === "package" ? [{ role: "dialect", pkg: i.package }] : [])),
|
|
115
|
+
...h.kanon.plugins.map((p) => ({ role: "plugin", pkg: p.package })),
|
|
116
|
+
];
|
|
117
|
+
for (const m of members) {
|
|
118
|
+
const name = m.pkg.slice(SCOPE.length);
|
|
119
|
+
const l = by.get(name);
|
|
120
|
+
if (l === undefined || l.family?.host !== h.name || l.family.role !== m.role)
|
|
121
|
+
out.push(`commons/${h.name}: its kanon table declares ${m.pkg} as a ${m.role}, and no library of that name declares family: { host: "${h.name}", role: "${m.role}" } (0033-kanon FR-021)`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
@@ -42,6 +42,8 @@ export const MIZAN = {
|
|
|
42
42
|
["dcterms", "http://purl.org/dc/terms/"],
|
|
43
43
|
["pm", "https://www.intellectualfrontiers.com/ontology/packaging#"],
|
|
44
44
|
["schema", "https://schema.org/"],
|
|
45
|
+
["dcat", "http://www.w3.org/ns/dcat#"],
|
|
46
|
+
["purl", "https://github.com/package-url/purl-spec#"],
|
|
45
47
|
],
|
|
46
48
|
files,
|
|
47
49
|
ontology: mizanOntology,
|
|
@@ -64,6 +66,8 @@ export const MIZAN = {
|
|
|
64
66
|
dcterms: "http://purl.org/dc/terms/",
|
|
65
67
|
pm: "https://www.intellectualfrontiers.com/ontology/packaging#",
|
|
66
68
|
schema: "https://schema.org/",
|
|
69
|
+
dcat: "http://www.w3.org/ns/dcat#",
|
|
70
|
+
purl: "https://github.com/package-url/purl-spec#",
|
|
67
71
|
},
|
|
68
72
|
viewTitle: "Mizan: the shared ontology",
|
|
69
73
|
license: CC0,
|
|
@@ -22,7 +22,6 @@ import process from "node:process";
|
|
|
22
22
|
import { ACTIONS, workflows } from "./workflows/definitions.js";
|
|
23
23
|
import { validateAction, validateWorkflow } from "./workflows/model.js";
|
|
24
24
|
import { renderAction, renderWorkflow } from "./workflows/render.js";
|
|
25
|
-
import { inputsOf } from "./affected.js";
|
|
26
25
|
import { readLibraries } from "./libraries.js";
|
|
27
26
|
import { existsSync, readDirSync, readTextFileSync, writeTextFileSync, mkdirSync } from "@intellectual-frontiers/system/fs";
|
|
28
27
|
import { stdio } from "@intellectual-frontiers/system";
|
|
@@ -32,23 +31,16 @@ const FOLDER = ".github/workflows";
|
|
|
32
31
|
export function outputs(repo) {
|
|
33
32
|
const root = repo.replace(/[\\/]$/, "");
|
|
34
33
|
const problems = [];
|
|
35
|
-
const libraries = [];
|
|
36
34
|
for (const f of readLibraries(root)) {
|
|
37
35
|
if ("problem" in f)
|
|
38
36
|
problems.push(`commons/${f.dir}/library.ts: ${f.problem}`);
|
|
39
37
|
else {
|
|
40
38
|
if (f.library.distribution.includes("npm") && !existsSync(`${root}/commons/${f.library.name}/tools/pack.ts`))
|
|
41
|
-
problems.push(`commons/${f.library.name} is published to npm and has no tools/pack.ts, which
|
|
42
|
-
libraries.push({
|
|
43
|
-
name: f.library.name,
|
|
44
|
-
verify: f.library.verify,
|
|
45
|
-
paths: inputsOf(root, f.library.name).paths,
|
|
46
|
-
distribution: f.library.distribution,
|
|
47
|
-
});
|
|
39
|
+
problems.push(`commons/${f.library.name} is published to npm and has no tools/pack.ts, which the release workflow runs (0030-generated-workflows FR-009)`);
|
|
48
40
|
}
|
|
49
41
|
}
|
|
50
42
|
const files = new Map();
|
|
51
|
-
for (const w of workflows(
|
|
43
|
+
for (const w of workflows()) {
|
|
52
44
|
problems.push(...validateWorkflow(w));
|
|
53
45
|
files.set(`${FOLDER}/${w.file}.auto.yml`, renderWorkflow(w));
|
|
54
46
|
}
|
package/dist/install-bun.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Bun at the version commons pins (
|
|
3
|
-
* 0005-typescript-runtime FR-026), fetched from
|
|
2
|
+
* Bun at the version commons pins (its version, address, SHA-256, format and folder per platform in `commons/generated/pins.auto.env`, commons
|
|
3
|
+
* 0005-typescript-runtime FR-026, 0002-packaging FR-019), fetched from that address with retries, kept only where its SHA-256 is the pinned one, unpacked by the
|
|
4
4
|
* kernel's own zip reader and put in a folder; nothing but IFC TypeScript itself, so it runs on Node 26 (or Bun) on Linux, macOS
|
|
5
5
|
* and Windows with no shell, no Python and no unzip. CI's `.github/actions/bun` runs it.
|
|
6
6
|
*
|
|
@@ -17,7 +17,7 @@ import { chmod, ensureDir, readFile, readTextFile, writeFile, writeTextFile } fr
|
|
|
17
17
|
import { downloadVerified, Retries } from "@intellectual-frontiers/net/net";
|
|
18
18
|
import { dirname, fromFileUrl, join, resolve } from "@intellectual-frontiers/system/path";
|
|
19
19
|
import { args, build, env, exit } from "@intellectual-frontiers/system/proc";
|
|
20
|
-
import {
|
|
20
|
+
import { describePinProblem, pinDownload, pinSuffix, readEnvFile } from "./pins.js";
|
|
21
21
|
/** Stop with a message and status 1. */
|
|
22
22
|
function stop(message) {
|
|
23
23
|
console.error(`install-bun: ${message}`);
|
|
@@ -29,26 +29,31 @@ if (given === undefined)
|
|
|
29
29
|
stop("give the folder to put Bun in");
|
|
30
30
|
const dest = resolve(given);
|
|
31
31
|
const pins = readEnvFile(await readTextFile(join(ROOT, "commons", "generated", "pins.auto.env")));
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
32
|
+
const suffix = pinSuffix(build.os, build.arch);
|
|
33
|
+
if (suffix === undefined)
|
|
34
34
|
stop(`Bun has no build for ${build.os} on ${build.arch}`);
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const pin = pinDownload(pins, "BUN", suffix);
|
|
36
|
+
if (pin.kind === "err")
|
|
37
|
+
stop(describePinProblem(pin.error));
|
|
38
|
+
const download = pin.value;
|
|
39
|
+
if (download.format !== "zip")
|
|
40
|
+
stop(`commons pins Bun as ${download.format}, and this installer unpacks a zip`);
|
|
41
|
+
const sum = sha256Of(download.sha256);
|
|
42
|
+
if (sum === undefined)
|
|
43
|
+
stop(`commons pins no SHA-256 of Bun for ${suffix}`);
|
|
39
44
|
const retries = new Retries({ tries: 5, base: 2, cap: 30 }, (line) => console.error(line));
|
|
40
|
-
const
|
|
41
|
-
const zip = await downloadVerified(retries, url, sum, join(dest, "cache"));
|
|
45
|
+
const zip = await downloadVerified(retries, download.url, sum, join(dest, "cache"));
|
|
42
46
|
if (zip.kind === "err")
|
|
43
47
|
stop(zip.error);
|
|
44
48
|
const files = await unzip(await readFile(zip.value));
|
|
45
49
|
if (files.kind === "err")
|
|
46
50
|
stop(formatArchiveError(files.error));
|
|
47
51
|
const exe = build.os === "windows" ? "bun.exe" : "bun";
|
|
48
|
-
const
|
|
52
|
+
const inside = download.binPath === "" ? exe : `${download.binPath}/${exe}`;
|
|
53
|
+
const bytes = files.value.get(inside);
|
|
49
54
|
if (bytes === undefined)
|
|
50
|
-
stop(`the zip holds no
|
|
51
|
-
const bin = join(dest, `bun-${version}`);
|
|
55
|
+
stop(`the zip holds no ${inside}`);
|
|
56
|
+
const bin = join(dest, `bun-${download.version}`);
|
|
52
57
|
await ensureDir(bin);
|
|
53
58
|
await writeFile(join(bin, exe), bytes);
|
|
54
59
|
await chmod(join(bin, exe), 0o755);
|