@intellectual-frontiers/libraries 0.4.0 → 0.5.0

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.
Files changed (64) hide show
  1. package/LICENSE +75 -21
  2. package/dist/affected.d.ts +1 -1
  3. package/dist/dev.d.ts +2 -0
  4. package/dist/dev.js +14 -2
  5. package/dist/family.js +1 -0
  6. package/dist/generate-ontology.js +4 -0
  7. package/dist/imports/nist-sp-800-53.auto.prov.ttl +22 -0
  8. package/dist/imports/schema-org.auto.prov.ttl +22 -0
  9. package/dist/install-bun.js +19 -14
  10. package/dist/libraries.d.ts +39 -2
  11. package/dist/libraries.js +80 -9
  12. package/dist/license/PolyForm-Noncommercial-1.0.0.md +73 -0
  13. package/dist/license/standard.d.ts +46 -0
  14. package/dist/license/standard.js +43 -0
  15. package/dist/license/third-party.d.ts +25 -0
  16. package/dist/license/third-party.js +71 -0
  17. package/dist/license.d.ts +61 -0
  18. package/dist/license.js +204 -0
  19. package/dist/link.d.ts +1 -1
  20. package/dist/link.js +4 -4
  21. package/dist/metapackages.d.ts +62 -0
  22. package/dist/metapackages.js +190 -0
  23. package/dist/mod.d.ts +1 -1
  24. package/dist/mod.js +1 -1
  25. package/dist/pack-library.d.ts +9 -0
  26. package/dist/pack-library.js +46 -58
  27. package/dist/pack-metapackage.d.ts +22 -0
  28. package/dist/pack-metapackage.js +147 -0
  29. package/dist/pins.d.ts +34 -7
  30. package/dist/pins.js +36 -9
  31. package/dist/readme.d.ts +71 -0
  32. package/dist/readme.js +310 -0
  33. package/dist/releasing.d.ts +8 -1
  34. package/dist/releasing.js +44 -14
  35. package/dist/workflows/definitions.d.ts +2 -2
  36. package/dist/workflows/definitions.js +32 -114
  37. package/dist/workflows/model.d.ts +6 -0
  38. package/dist/workflows/render.js +2 -0
  39. package/dist/workflows/schema/github-workflow.schema.json +2290 -0
  40. package/package.json +39 -14
  41. package/src/affected.ts +1 -1
  42. package/src/dev.ts +13 -2
  43. package/src/family.ts +1 -0
  44. package/src/generate-ontology.ts +4 -0
  45. package/src/imports/nist-sp-800-53.auto.prov.ttl +22 -0
  46. package/src/imports/schema-org.auto.prov.ttl +22 -0
  47. package/src/install-bun.ts +16 -13
  48. package/src/libraries.ts +100 -8
  49. package/src/license/PolyForm-Noncommercial-1.0.0.md +73 -0
  50. package/src/license/standard.ts +67 -0
  51. package/src/license/third-party.ts +87 -0
  52. package/src/license.ts +222 -0
  53. package/src/link.ts +4 -4
  54. package/src/metapackages.ts +206 -0
  55. package/src/mod.ts +1 -1
  56. package/src/pack-library.ts +52 -55
  57. package/src/pack-metapackage.ts +137 -0
  58. package/src/pins.ts +55 -10
  59. package/src/readme.ts +320 -0
  60. package/src/releasing.ts +47 -16
  61. package/src/workflows/definitions.ts +36 -133
  62. package/src/workflows/model.ts +6 -0
  63. package/src/workflows/render.ts +1 -0
  64. package/src/workflows/schema/github-workflow.schema.json +2290 -0
package/LICENSE CHANGED
@@ -1,21 +1,75 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Intellectual Frontiers
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ Required Notice: Copyright Intellectual Frontiers LLC (https://github.com/intellectual-frontiers/.github)
2
+
3
+ # PolyForm Noncommercial License 1.0.0
4
+
5
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
6
+
7
+ ## Acceptance
8
+
9
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
14
+
15
+ ## Distribution License
16
+
17
+ The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
18
+
19
+ ## Notices
20
+
21
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
22
+
23
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
24
+
25
+ ## Changes and New Works License
26
+
27
+ The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
28
+
29
+ ## Patent License
30
+
31
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
32
+
33
+ ## Noncommercial Purposes
34
+
35
+ Any noncommercial purpose is a permitted purpose.
36
+
37
+ ## Personal Uses
38
+
39
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
40
+
41
+ ## Noncommercial Organizations
42
+
43
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
44
+
45
+ ## Fair Use
46
+
47
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
48
+
49
+ ## No Other Rights
50
+
51
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
52
+
53
+ ## Patent Defense
54
+
55
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
56
+
57
+ ## Violations
58
+
59
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
60
+
61
+ ## No Liability
62
+
63
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
64
+
65
+ ## Definitions
66
+
67
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
68
+
69
+ **You** refers to the individual or entity agreeing to these terms.
70
+
71
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
72
+
73
+ **Your licenses** are all the licenses granted to you for the software under these terms.
74
+
75
+ **Use** means anything you do with the software requiring one of your licenses.
@@ -1,7 +1,7 @@
1
1
  import { type Library } from "./libraries.js";
2
2
  /** What a library reads: its folder, the folders and files it takes from others, what it depends on, and the files it imports one by one. */
3
3
  export type Inputs = {
4
- /** The paths of the library's inputs: `commons/<name>/` and each folder (`commons/ts/kernel/**`) or file the library takes from another. */
4
+ /** The paths of the library's inputs: `commons/<name>/` and each folder (`commons/core/src/**`) or file the library takes from another. */
5
5
  readonly paths: readonly string[];
6
6
  /** The folders of commons that the library depends on through its package. */
7
7
  readonly dependsOn: readonly string[];
package/dist/dev.d.ts CHANGED
@@ -60,6 +60,8 @@ export declare function pool<T, R>(items: readonly T[], width: number, job: (ite
60
60
  export declare function prepare(repo: string, libs: readonly Lib[]): Promise<Result<readonly string[], string>>;
61
61
  /** TypeScript on the libraries, several at a time. */
62
62
  export declare function typeCheck(repo: string, libs: readonly Lib[], width: number): Promise<Outcome>;
63
+ /** 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. */
64
+ export declare function licenseStage(repo: string): Promise<Outcome>;
63
65
  /** The sum of counts. */
64
66
  export declare const addCounts: (a: Counts, b: Counts) => Counts;
65
67
  /**
package/dist/dev.js CHANGED
@@ -7,11 +7,11 @@
7
7
  * bun run dev:check --files a.ts,b/c.ts the libraries these files affect (paths from the repository's root)
8
8
  * bun run dev:check --all every library
9
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, --bail (stop at the first failing test), --repo DIR
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
11
  *
12
12
  * @remarks
13
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
14
+ * name is `@intellectual-frontiers/<folder>`), so that a library that imports another by its package name reads the checkout's source, never a copy from a
15
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
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
17
  *
@@ -40,6 +40,7 @@ import { flag, formatUsageError, helpText, many, parseArgs, value } from "@intel
40
40
  import { label, paint } from "@intellectual-frontiers/terminal/palette";
41
41
  import { affectedBy, changedSince, everyLibrary } from "./affected.js";
42
42
  import { linkAll } from "./link.js";
43
+ import { judge as judgeLicense, sentence as licenseSentence } from "./license.js";
43
44
  /** The counts in the end of what `bun test` printed, or undefined where it printed none. */
44
45
  export function bunCounts(text) {
45
46
  const n = (word) => Number(new RegExp(`^\\s*(\\d+) ${word}\\s*$`, "m").exec(text)?.[1] ?? 0);
@@ -200,6 +201,14 @@ export async function typeCheck(repo, libs, width) {
200
201
  output: bad.flatMap((b) => head(b.lines, 25).map((x) => `${b.name}: ${x}`)),
201
202
  };
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
+ }
203
212
  /** The sum of counts. */
204
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 });
205
214
  /**
@@ -271,6 +280,7 @@ const OPTIONS = {
271
280
  list: flag({ help: "Say what is affected and run nothing." }),
272
281
  types: flag({ help: "Type-check the libraries (on by default).", negatable: true, default: true }),
273
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 }),
274
284
  bail: flag({ help: "Stop the tests at the first one that fails." }),
275
285
  repo: value({ help: "The repository (the working folder, or the one above it that has commons/, by default).", valueName: "DIR" }),
276
286
  };
@@ -339,6 +349,8 @@ export async function main(argv) {
339
349
  ]);
340
350
  stages.push({ name: "types", outcome: types }, { name: "tests", outcome: tests });
341
351
  }
352
+ if (!o.list && o.license)
353
+ stages.push({ name: "license", outcome: await licenseStage(repo) });
342
354
  for (const l of summaryLines(look, { why, libs: names }, stages, notes, seconds(t0)))
343
355
  stdio.stdout.writeSync(`${l}\n`);
344
356
  return stages.some((s) => s.outcome.kind === "failed") ? 1 : 0;
package/dist/family.js CHANGED
@@ -27,6 +27,7 @@ export const RESERVED = [
27
27
  { match: { kind: "exact", name: "signing" }, host: "signing", reason: "held for the signing library of the fleet libraries (intellectual-frontiers/.github#11)" },
28
28
  { match: { kind: "exact", name: "gitops" }, host: "gitops", reason: "held for the gitops library of the fleet libraries (intellectual-frontiers/.github#11)" },
29
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)" },
30
31
  ];
31
32
  /** Whether a library name is one a match holds. */
32
33
  export function matches(match, name) {
@@ -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,
@@ -0,0 +1,22 @@
1
+ # AUTO-GENERATED with ../../../ontology/src/standards/nist-sp-800-53/controls.auto.ts by commons/mizan/src/integrations/pure/import-oscal-catalog.ts (commons 0019-mizan-integrations FR-009). Do not edit.
2
+
3
+ @prefix dcterms: <http://purl.org/dc/terms/> .
4
+ @prefix prov: <http://www.w3.org/ns/prov#> .
5
+
6
+ <urn:ifc:mizan:module:nist-sp-800-53> a prov:Entity ;
7
+ dcterms:source "../../../ontology/src/standards/nist-sp-800-53/controls.auto.ts" ;
8
+ prov:wasGeneratedBy <urn:ifc:mizan:import:nist-sp-800-53:64ca6b4161de51ab6af098a7d101d326f14c95e1abf721396cd8a049e8115eeb> ;
9
+ prov:wasDerivedFrom <urn:sha256:64ca6b4161de51ab6af098a7d101d326f14c95e1abf721396cd8a049e8115eeb> .
10
+
11
+ <urn:ifc:mizan:import:nist-sp-800-53:64ca6b4161de51ab6af098a7d101d326f14c95e1abf721396cd8a049e8115eeb> a prov:Activity ;
12
+ prov:used <urn:sha256:64ca6b4161de51ab6af098a7d101d326f14c95e1abf721396cd8a049e8115eeb> ;
13
+ prov:wasAssociatedWith <urn:ifc:mizan:generator:commons:mizan:src:integrations:pure:import-oscal-catalog.ts> .
14
+
15
+ <urn:ifc:mizan:generator:commons:mizan:src:integrations:pure:import-oscal-catalog.ts> a prov:SoftwareAgent .
16
+
17
+ <urn:sha256:64ca6b4161de51ab6af098a7d101d326f14c95e1abf721396cd8a049e8115eeb> a prov:Entity ;
18
+ dcterms:title "NIST SP 800-53 Rev. 5.2.0 (OSCAL catalog)" ;
19
+ dcterms:publisher "National Institute of Standards and Technology" ;
20
+ dcterms:hasVersion "5.2.0" ;
21
+ dcterms:source <https://raw.githubusercontent.com/usnistgov/oscal-content/f0de6d8d8c059d374f15e0ae07508d82e370fc1d/nist.gov/SP800-53/rev5/json/NIST_SP-800-53_rev5_catalog.json> ;
22
+ dcterms:license <https://spdx.org/licenses/Public domain (a work of the United States Government, 17 U.S.C. 105).html> .
@@ -0,0 +1,22 @@
1
+ # AUTO-GENERATED with ../../../ontology/src/supply-chain/packaging/schema.auto.ts by commons/mizan/src/integrations/pure/import-vocabulary.ts (commons 0019-mizan-integrations FR-009). Do not edit.
2
+
3
+ @prefix dcterms: <http://purl.org/dc/terms/> .
4
+ @prefix prov: <http://www.w3.org/ns/prov#> .
5
+
6
+ <urn:ifc:mizan:module:schema-org> a prov:Entity ;
7
+ dcterms:source "../../../ontology/src/supply-chain/packaging/schema.auto.ts" ;
8
+ prov:wasGeneratedBy <urn:ifc:mizan:import:schema-org:7f15ca89398c4f235f478a4b3b8d1f975d63c5a860b77c8a8fce01f791b7ae2f> ;
9
+ prov:wasDerivedFrom <urn:sha256:7f15ca89398c4f235f478a4b3b8d1f975d63c5a860b77c8a8fce01f791b7ae2f> .
10
+
11
+ <urn:ifc:mizan:import:schema-org:7f15ca89398c4f235f478a4b3b8d1f975d63c5a860b77c8a8fce01f791b7ae2f> a prov:Activity ;
12
+ prov:used <urn:sha256:7f15ca89398c4f235f478a4b3b8d1f975d63c5a860b77c8a8fce01f791b7ae2f> ;
13
+ prov:wasAssociatedWith <urn:ifc:mizan:generator:commons:mizan:src:integrations:pure:import-vocabulary.ts> .
14
+
15
+ <urn:ifc:mizan:generator:commons:mizan:src:integrations:pure:import-vocabulary.ts> a prov:SoftwareAgent .
16
+
17
+ <urn:sha256:7f15ca89398c4f235f478a4b3b8d1f975d63c5a860b77c8a8fce01f791b7ae2f> a prov:Entity ;
18
+ dcterms:title "schema.org" ;
19
+ dcterms:publisher "Schema.org Community Group" ;
20
+ dcterms:hasVersion "30.1" ;
21
+ dcterms:source <https://schema.org/version/30.1/schemaorg-current-https.ttl> ;
22
+ dcterms:license <https://spdx.org/licenses/CC-BY-SA-3.0.html> .
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Bun at the version commons pins (`BUN_VERSION` and its SHA-256 per platform in `commons/generated/pins.auto.env`, commons
3
- * 0005-typescript-runtime FR-026), fetched from Bun's release with retries, kept only where its SHA-256 is the pinned one, unpacked by the
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-practice 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 { bunTarget, readEnvFile } from "./pins.js";
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 platform = bunTarget(build.os, build.arch);
33
- if (platform === undefined)
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 version = pins.get("BUN_VERSION");
36
- const sum = sha256Of(pins.get(`BUN_SHA256_${platform.key}`) ?? "");
37
- if (version === undefined || sum === undefined)
38
- stop(`commons pins no Bun for ${platform.key}`);
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 url = `https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-${platform.target}.zip`;
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 bytes = files.value.get(`bun-${platform.target}/${exe}`);
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 bun-${platform.target}/${exe}`);
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);
@@ -1,4 +1,5 @@
1
- import { type Result } from "@intellectual-frontiers/core";
1
+ import { type Brand, type Result } from "@intellectual-frontiers/core";
2
+ import { type SpdxId } from "./license/standard.js";
2
3
  import { type Table } from "@intellectual-frontiers/kanon";
3
4
  import { type LevelKey } from "@intellectual-frontiers/mizan/levels";
4
5
  import { type LibraryFamily } from "./family.js";
@@ -10,6 +11,7 @@ export declare const LIBRARIES_SPEC = "0027-commons-libraries";
10
11
  export declare const FIRST_GENERATED = 101;
11
12
  /** The marker that opens the generated section, and the one that closes it. */
12
13
  export declare const BEGIN = "<!-- libraries:begin -->";
14
+ /** The marker that ends the generated section of the libraries in a document. */
13
15
  export declare const END = "<!-- libraries:end -->";
14
16
  /** A library's manifest. */
15
17
  export type Library = {
@@ -33,11 +35,43 @@ export type Library = {
33
35
  readonly kanon?: Table;
34
36
  /** Its host and its role where it is of a family (a host, a dialect of it or a plugin of it; 0033-kanon FR-021, 0027-commons-libraries FR-023). */
35
37
  readonly family?: LibraryFamily;
38
+ /** The license its `LICENSE` and its packed `package.json` carry, where it is not the default of the repository (`license/standard.ts`; commons 0035-licensing FR-003). */
39
+ readonly license?: SpdxId;
40
+ /** The constants of its sources that say its own version (`ERGONEX_VERSION`), each a file from the library's folder and the name of the constant: the release rewrites them with the version, and a check finds one that disagrees. */
41
+ readonly versionConstants?: readonly VersionConstant[];
42
+ /** The package the library publishes where it is not `@intellectual-frontiers/<name>` (the `data` library publishes `@intellectual-frontiers/arcactl`; commons 0036-distribution FR-009). */
43
+ readonly publishes?: PackageName;
44
+ /** Why the library is kept out of the release: it is verified and packed like any other, and has no release record entry, no tag, no set and no registry (FR-0xx of 0001-libraries). */
45
+ readonly held?: HeldReason;
46
+ /** The set the library is, where it is a metapackage: a folder with no code of its own whose package depends on the libraries of the set at exact versions (commons 0036-distribution FR-005). */
47
+ readonly bundle?: BundleName;
48
+ };
49
+ /** The reason a library is held out of the release: a non-empty sentence, made only by {@link parseHeldReason}. */
50
+ export type HeldReason = Brand<string, "held reason">;
51
+ /** A held reason from text, or why the text is not one. */
52
+ export declare function parseHeldReason(text: string): Result<HeldReason, string>;
53
+ /** The scope of the packages of commons. */
54
+ export declare const PACKAGE_SCOPE = "@intellectual-frontiers/";
55
+ /** The sets that a metapackage is: the whole of commons, and the four roles of the libraries; a closed union, and the name of the folder and of the package of each. */
56
+ export declare const BUNDLES: readonly ["commons", "foundation", "patterns", "programs", "standards"];
57
+ /** The name of a set of libraries a metapackage is. */
58
+ export type BundleName = (typeof BUNDLES)[number];
59
+ /** The name of a package of commons: `@intellectual-frontiers/` and a name, made only by {@link parsePackageName}. */
60
+ export type PackageName = Brand<string, "package name">;
61
+ /** A package name of commons from text, or why the text is not one. */
62
+ export declare function parsePackageName(text: string): Result<PackageName, string>;
63
+ /** The package a library publishes: the one its manifest names in `publishes`, else `@intellectual-frontiers/<name>` (commons 0036-distribution FR-009). */
64
+ export declare function publishedPackage(l: Pick<Library, "name" | "publishes">): string;
65
+ /** A constant of a library's sources that holds the library's version: the file (from the library's folder) and the constant's name. */
66
+ export type VersionConstant = {
67
+ readonly file: string;
68
+ readonly name: string;
36
69
  };
37
70
  /** The lowest conformance level that requires a library to declare `kanon`; none yet (0033-kanon FR-014, OQ-1): a level asks for it by naming itself here. */
38
71
  export declare const KANON_REQUIRED_FROM: LevelKey | undefined;
39
72
  /** The registries a library may be published to: the kinds only, never a host or a credential (0027-commons-libraries FR-018). */
40
73
  export declare const REGISTRIES: readonly ["github", "npm"];
74
+ /** A registry a library is distributed to: github or npm. */
41
75
  export type Registry = (typeof REGISTRIES)[number];
42
76
  /** Where a manifest that declares no distribution is published. */
43
77
  export declare const DEFAULT_DISTRIBUTION: readonly Registry[];
@@ -64,7 +98,10 @@ export declare function requirementOf(id: string, l: Library): string;
64
98
  export declare function rowOf(id: string, l: Library): string;
65
99
  /** The ids the section already gives each library, by name, read from its text between the markers. */
66
100
  export declare function idsIn(spec: string): ReadonlyMap<string, string>;
67
- /** The id each library has: the one it had, or the next number after the greatest. */
101
+ /**
102
+ * The id each library has: the one it had, or the next number after the greatest. A number belongs to the first library that holds it in the specification: where a second one holds it (two branches each gave the next number to a
103
+ * library, and a merge kept both), the second is given the next number after the greatest, so that the generator makes the section again with one number for each library.
104
+ */
68
105
  export declare function idsFor(libraries: readonly Library[], had: ReadonlyMap<string, string>): ReadonlyMap<string, string>;
69
106
  /** The text of the specification and of the register, made again from the libraries: nothing where the specification has no markers. */
70
107
  export declare function generated(spec: string, enforcement: string, libraries: readonly Library[]): Result<{
package/dist/libraries.js CHANGED
@@ -80,7 +80,8 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
80
80
  * @module
81
81
  */
82
82
  import process from "node:process";
83
- import { array, describe, formatDecodeError, literal, object, unknownValue, string, err, ok, } from "@intellectual-frontiers/core";
83
+ import { array, describe, formatDecodeError, literal, object, unknownValue, string, err, ok, refine, } from "@intellectual-frontiers/core";
84
+ import { parseSpdxId } from "./license/standard.js";
84
85
  import { exportedLiteral } from "@intellectual-frontiers/formats/ts-literal";
85
86
  import { decodeTable } from "@intellectual-frontiers/kanon";
86
87
  import { existsSync, readDirSync, readTextFileSync, writeTextFileSync } from "@intellectual-frontiers/system/fs";
@@ -96,6 +97,7 @@ export const LIBRARIES_SPEC = "0027-commons-libraries";
96
97
  export const FIRST_GENERATED = 101;
97
98
  /** The marker that opens the generated section, and the one that closes it. */
98
99
  export const BEGIN = "<!-- libraries:begin -->";
100
+ /** The marker that ends the generated section of the libraries in a document. */
99
101
  export const END = "<!-- libraries:end -->";
100
102
  /** Where the generated section begins and ends: the markers on lines of their own (a requirement may name them in its text). */
101
103
  function bounds(spec) {
@@ -103,6 +105,26 @@ function bounds(spec) {
103
105
  const to = spec.indexOf(`\n${END}\n`, from);
104
106
  return from < 0 || to < 0 ? undefined : { from: from + 1, to: to + 1 };
105
107
  }
108
+ const heldDecoder = refine(string, "held reason", (t) => t.trim() !== "" && t.trim() === t && !t.includes("\n"));
109
+ /** A held reason from text, or why the text is not one. */
110
+ export function parseHeldReason(text) {
111
+ const r = heldDecoder(text, "held");
112
+ return r.kind === "ok" ? ok(r.value) : err("library.held is one non-empty line that says why the library is kept out of the release");
113
+ }
114
+ /** The scope of the packages of commons. */
115
+ export const PACKAGE_SCOPE = "@intellectual-frontiers/";
116
+ /** The sets that a metapackage is: the whole of commons, and the four roles of the libraries; a closed union, and the name of the folder and of the package of each. */
117
+ export const BUNDLES = ["commons", "foundation", "patterns", "programs", "standards"];
118
+ const packageNameDecoder = refine(string, "package name", (t) => /^@intellectual-frontiers\/[a-z][a-z0-9-]*$/.test(t));
119
+ /** A package name of commons from text, or why the text is not one. */
120
+ export function parsePackageName(text) {
121
+ const r = packageNameDecoder(text, "package");
122
+ return r.kind === "ok" ? ok(r.value) : err(`${JSON.stringify(text)} is not a package of commons (@intellectual-frontiers/ and a name of lower-case letters, digits and hyphens)`);
123
+ }
124
+ /** The package a library publishes: the one its manifest names in `publishes`, else `@intellectual-frontiers/<name>` (commons 0036-distribution FR-009). */
125
+ export function publishedPackage(l) {
126
+ return l.publishes ?? `${PACKAGE_SCOPE}${l.name}`;
127
+ }
106
128
  /** The lowest conformance level that requires a library to declare `kanon`; none yet (0033-kanon FR-014, OQ-1): a level asks for it by naming itself here. */
107
129
  export const KANON_REQUIRED_FROM = undefined;
108
130
  /** The registries a library may be published to: the kinds only, never a host or a credential (0027-commons-libraries FR-018). */
@@ -123,8 +145,16 @@ const nameDecoder = (input, path = "$") => {
123
145
  ? r
124
146
  : err({ kind: "decode", path, expected: "a name of lower-case letters, digits and hyphens", found: describe(input) });
125
147
  };
126
- const body = object({ name: nameDecoder, verify: nonEmpty, version: nonEmpty, exports: array(nonEmpty) }, { level: literal(...LEVELS), specKit: nonEmpty, summary: nonEmpty, distribution: array(literal(...REGISTRIES)), kanon: unknownValue, family: object({ host: nonEmpty, role: literal(...ROLES) }) });
127
- const FIELDS = ["name", "level", "specKit", "verify", "version", "exports", "summary", "distribution", "kanon", "family"];
148
+ const constantName = (input, path = "$") => {
149
+ const r = string(input, path);
150
+ if (r.kind === "err")
151
+ return r;
152
+ return /^[A-Za-z_][A-Za-z0-9_]*$/.test(r.value)
153
+ ? r
154
+ : err({ kind: "decode", path, expected: "the name of a constant: letters, digits and underscores", found: describe(input) });
155
+ };
156
+ const body = object({ name: nameDecoder, verify: nonEmpty, version: nonEmpty, exports: array(nonEmpty) }, { level: literal(...LEVELS), specKit: nonEmpty, summary: nonEmpty, distribution: array(literal(...REGISTRIES)), kanon: unknownValue, family: object({ host: nonEmpty, role: literal(...ROLES) }), license: nonEmpty, versionConstants: array(object({ file: nonEmpty, name: constantName })), publishes: nonEmpty, bundle: literal(...BUNDLES), held: string });
157
+ const FIELDS = ["name", "level", "specKit", "verify", "version", "exports", "summary", "distribution", "kanon", "family", "license", "versionConstants", "publishes", "bundle", "held"];
128
158
  /** The manifest read from the text of its file: `export const library = { ... }` and no other export, read as data and never run (0027-commons-libraries FR-012). */
129
159
  export function decodeLibrarySource(source) {
130
160
  const exports = source.split("\n").filter((l) => /^export\s/.test(l));
@@ -145,9 +175,18 @@ export function decodeLibrarySource(source) {
145
175
  return err(formatDecodeError(r.error));
146
176
  const v = r.value;
147
177
  const distribution = v.distribution ?? DEFAULT_DISTRIBUTION;
148
- if (distribution.length === 0 || new Set(distribution).size !== distribution.length)
178
+ let held;
179
+ if (v.held !== undefined) {
180
+ const h = parseHeldReason(v.held);
181
+ if (h.kind === "err")
182
+ return err(h.error);
183
+ held = h.value;
184
+ if (v.publishes !== undefined || v.bundle !== undefined)
185
+ return err("library.held is not given with library.publishes or library.bundle: a held library is published nowhere");
186
+ }
187
+ if (held === undefined && (distribution.length === 0 || new Set(distribution).size !== distribution.length))
149
188
  return err("library.distribution lists each registry once and at least one (FR-015)");
150
- if (!distribution.includes("github"))
189
+ if (held === undefined && !distribution.includes("github"))
151
190
  return err("library.distribution includes github: a library is published to the GitHub package registry whatever else it is published to (FR-015, FR-016)");
152
191
  let kanon;
153
192
  if (v.kanon !== undefined) {
@@ -163,6 +202,24 @@ export function decodeLibrarySource(source) {
163
202
  return f;
164
203
  family = f.value;
165
204
  }
205
+ let license;
206
+ if (v.license !== undefined) {
207
+ const l = parseSpdxId(v.license);
208
+ if (l.kind === "err")
209
+ return err(`library.license: ${l.error}`);
210
+ license = l.value;
211
+ }
212
+ let publishes;
213
+ if (v.publishes !== undefined) {
214
+ const p = parsePackageName(v.publishes);
215
+ if (p.kind === "err")
216
+ return err(`library.publishes: ${p.error}`);
217
+ publishes = p.value;
218
+ }
219
+ if (v.bundle !== undefined && v.bundle !== v.name)
220
+ return err(`library.bundle ${v.bundle} is the set of the metapackage of that name: the folder is named ${v.bundle}, and this one is ${v.name} (0036-distribution FR-005)`);
221
+ if (v.bundle !== undefined && publishes !== undefined)
222
+ return err("library.bundle and library.publishes are not both given: a metapackage publishes the package of its folder (0036-distribution FR-005)");
166
223
  return ok({
167
224
  name: v.name,
168
225
  level: v.level ?? DEFAULT_LIBRARY_LEVEL,
@@ -174,6 +231,11 @@ export function decodeLibrarySource(source) {
174
231
  distribution,
175
232
  ...(kanon === undefined ? {} : { kanon }),
176
233
  ...(family === undefined ? {} : { family }),
234
+ ...(license === undefined ? {} : { license }),
235
+ ...(v.versionConstants === undefined ? {} : { versionConstants: v.versionConstants }),
236
+ ...(publishes === undefined ? {} : { publishes }),
237
+ ...(v.bundle === undefined ? {} : { bundle: v.bundle }),
238
+ ...(held === undefined ? {} : { held }),
177
239
  });
178
240
  }
179
241
  /** The manifests of `commons/*`, in the order of the folders' names: every folder that holds a `library.ts`. */
@@ -282,8 +344,10 @@ const list = (items) => {
282
344
  export function requirementOf(id, l) {
283
345
  const kit = l.specKit === undefined ? "" : `, its spec kit at \`commons/${l.name}/${l.specKit}\``;
284
346
  const summary = l.summary === undefined ? "" : ` ${l.summary}`;
285
- const where = l.distribution.map((r) => REGISTRY_NAME[r]).join(" and ");
286
- return `- **${id}**: \`commons/${l.name}\` MUST be a library at conformance level ${l.level} (\`${LEVEL_TERM[l.level]}\`): the package \`@intellectual-frontiers/${l.name}\` at version \`${l.version}\`${kit}, exporting ${list(l.exports)}, published to ${where}, proved by \`cd commons/${l.name} && ${l.verify}\`.${summary}`;
347
+ const where = l.held === undefined ? l.distribution.map((r) => REGISTRY_NAME[r]).join(" and ") : `no registry (held out of the release: ${l.held})`;
348
+ const own = l.publishes === undefined ? `@intellectual-frontiers/${l.name}` : l.publishes;
349
+ const sets = l.bundle === undefined ? "" : `, a metapackage with no code of its own (the set ${l.bundle}, 0036-distribution FR-005)`;
350
+ return `- **${id}**: \`commons/${l.name}\` MUST be a library at conformance level ${l.level} (\`${LEVEL_TERM[l.level]}\`): the package \`${own}\`${sets} at version \`${l.version}\`${kit}, exporting ${list(l.exports)}, published to ${where}, proved by \`cd commons/${l.name} && ${l.verify}\`.${summary}`;
287
351
  }
288
352
  /** The row of `enforcement.tsv` of a library's requirement. */
289
353
  export function rowOf(id, l) {
@@ -303,13 +367,20 @@ export function idsIn(spec) {
303
367
  }
304
368
  return out;
305
369
  }
306
- /** The id each library has: the one it had, or the next number after the greatest. */
370
+ /**
371
+ * The id each library has: the one it had, or the next number after the greatest. A number belongs to the first library that holds it in the specification: where a second one holds it (two branches each gave the next number to a
372
+ * library, and a merge kept both), the second is given the next number after the greatest, so that the generator makes the section again with one number for each library.
373
+ */
307
374
  export function idsFor(libraries, had) {
308
375
  const out = new Map();
376
+ const first = new Map();
377
+ for (const [name, id] of had)
378
+ if (!first.has(id))
379
+ first.set(id, name);
309
380
  let next = Math.max(FIRST_GENERATED - 1, ...[...had.values()].map((id) => Number(id.slice(3)))) + 1;
310
381
  for (const l of libraries) {
311
382
  const id = had.get(l.name);
312
- if (id !== undefined)
383
+ if (id !== undefined && first.get(id) === l.name)
313
384
  out.set(l.name, id);
314
385
  else
315
386
  out.set(l.name, `FR-${String(next++).padStart(3, "0")}`);
@@ -0,0 +1,73 @@
1
+ # PolyForm Noncommercial License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
4
+
5
+ ## Acceptance
6
+
7
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
12
+
13
+ ## Distribution License
14
+
15
+ The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
16
+
17
+ ## Notices
18
+
19
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
20
+
21
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
22
+
23
+ ## Changes and New Works License
24
+
25
+ The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
26
+
27
+ ## Patent License
28
+
29
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
30
+
31
+ ## Noncommercial Purposes
32
+
33
+ Any noncommercial purpose is a permitted purpose.
34
+
35
+ ## Personal Uses
36
+
37
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
38
+
39
+ ## Noncommercial Organizations
40
+
41
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
42
+
43
+ ## Fair Use
44
+
45
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
46
+
47
+ ## No Other Rights
48
+
49
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
50
+
51
+ ## Patent Defense
52
+
53
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
54
+
55
+ ## Violations
56
+
57
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
58
+
59
+ ## No Liability
60
+
61
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
62
+
63
+ ## Definitions
64
+
65
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
66
+
67
+ **You** refers to the individual or entity agreeing to these terms.
68
+
69
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
70
+
71
+ **Your licenses** are all the licenses granted to you for the software under these terms.
72
+
73
+ **Use** means anything you do with the software requiring one of your licenses.