@intellectual-frontiers/libraries 0.4.1 → 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.
- package/dist/affected.d.ts +1 -1
- package/dist/dev.js +1 -1
- package/dist/imports/nist-sp-800-53.auto.prov.ttl +22 -0
- package/dist/imports/schema-org.auto.prov.ttl +22 -0
- package/dist/install-bun.js +1 -1
- package/dist/libraries.d.ts +34 -2
- package/dist/libraries.js +70 -9
- package/dist/license/PolyForm-Noncommercial-1.0.0.md +73 -0
- package/dist/link.d.ts +1 -1
- package/dist/link.js +4 -4
- package/dist/metapackages.d.ts +62 -0
- package/dist/metapackages.js +190 -0
- package/dist/mod.d.ts +1 -1
- package/dist/mod.js +1 -1
- package/dist/pack-library.d.ts +7 -0
- package/dist/pack-library.js +31 -56
- package/dist/pack-metapackage.d.ts +22 -0
- package/dist/pack-metapackage.js +147 -0
- package/dist/pins.d.ts +1 -1
- package/dist/pins.js +1 -1
- package/dist/readme.d.ts +13 -1
- package/dist/readme.js +42 -4
- package/dist/releasing.d.ts +8 -1
- package/dist/releasing.js +44 -14
- package/dist/workflows/definitions.d.ts +2 -2
- package/dist/workflows/definitions.js +31 -113
- package/dist/workflows/model.d.ts +2 -0
- package/dist/workflows/render.js +2 -0
- package/dist/workflows/schema/github-workflow.schema.json +2290 -0
- package/package.json +28 -13
- package/src/affected.ts +1 -1
- package/src/dev.ts +1 -1
- package/src/imports/nist-sp-800-53.auto.prov.ttl +22 -0
- package/src/imports/schema-org.auto.prov.ttl +22 -0
- package/src/install-bun.ts +1 -1
- package/src/libraries.ts +88 -8
- package/src/license/PolyForm-Noncommercial-1.0.0.md +73 -0
- package/src/link.ts +4 -4
- package/src/metapackages.ts +206 -0
- package/src/mod.ts +1 -1
- package/src/pack-library.ts +37 -53
- package/src/pack-metapackage.ts +137 -0
- package/src/pins.ts +1 -1
- package/src/readme.ts +46 -4
- package/src/releasing.ts +47 -16
- package/src/workflows/definitions.ts +34 -131
- package/src/workflows/model.ts +2 -0
- package/src/workflows/render.ts +1 -0
- package/src/workflows/schema/github-workflow.schema.json +2290 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The metapackages of commons (commons 0036-distribution FR-005 to FR-008): five packages with no code of their own, each a set of libraries at the exact versions of one release. `@intellectual-frontiers/commons` is every
|
|
3
|
+
* consumer-facing library; `foundation`, `patterns`, `programs` and `standards` are the four roles of the libraries. A repository other than `.github` installs commons by installing one of them, or a library, from a registry.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Pure: the libraries as data give the members of a set, the exact dependencies of its package, the file that records them, the `package.json` and the README that are published. The role of a library is read from `ROLE_OF` of
|
|
7
|
+
* `readme.ts`, the one place that says it, and the set of a role is the role's: `foundation`, `pattern` (`patterns`), `program` (`programs`) and `standard` (`standards`). A library is consumer-facing where its distribution
|
|
8
|
+
* names npm and it is not a metapackage and not held back ({@link HELD_BACK}); the package of a member is the package it publishes ({@link publishedPackage}). A member whose role is not known is a problem and never a member
|
|
9
|
+
* of no set. The effects (writing the files, packing) are `pack-metapackage.ts`.
|
|
10
|
+
*
|
|
11
|
+
* @limits
|
|
12
|
+
* It reads no file and knows no registry. It does not know what is published: a release that has not published a member makes the set refer to a version npm does not hold yet, which the release's order prevents.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { dependenciesOf } from "./metapackages.ts";
|
|
17
|
+
* dependenciesOf([{ library: "core", package: "@intellectual-frontiers/core", version: "0.1.5" }]); // { "@intellectual-frontiers/core": "0.1.5" }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Spec: 0001-libraries FR-023
|
|
21
|
+
*
|
|
22
|
+
* @module
|
|
23
|
+
*/
|
|
24
|
+
import { absurd, err, ok } from "@intellectual-frontiers/core";
|
|
25
|
+
import { BUNDLES, publishedPackage } from "./libraries.js";
|
|
26
|
+
import { DEFAULT_LICENSE } from "./license/standard.js";
|
|
27
|
+
import { ROLE_OF } from "./readme.js";
|
|
28
|
+
/** The libraries that are not in any set yet, each with why: they declare npm and are not ready to be installed (commons 0036-distribution FR-006). A library leaves this list when its owner releases it. */
|
|
29
|
+
export const HELD_BACK = new Map([
|
|
30
|
+
["archon", "the Archon library is not released yet"],
|
|
31
|
+
["archon-dialect-apt", "a dialect of Archon, which is not released yet"],
|
|
32
|
+
["archon-dialect-homebrew", "a dialect of Archon, which is not released yet"],
|
|
33
|
+
["archon-dialect-mise", "a dialect of Archon, which is not released yet"],
|
|
34
|
+
["archon-dialect-native-pinned", "a dialect of Archon, which is not released yet"],
|
|
35
|
+
["archon-dialect-winget", "a dialect of Archon, which is not released yet"],
|
|
36
|
+
["package-managers", "the kit of the dialects of Archon and Toolchain, which are not released yet"],
|
|
37
|
+
["toolchain", "the Toolchain library is not released yet"],
|
|
38
|
+
]);
|
|
39
|
+
/** The roles' sets: a role is in exactly one. */
|
|
40
|
+
export const BUNDLE_OF_ROLE = {
|
|
41
|
+
foundation: "foundation",
|
|
42
|
+
pattern: "patterns",
|
|
43
|
+
program: "programs",
|
|
44
|
+
standard: "standards",
|
|
45
|
+
};
|
|
46
|
+
/** Whether a library is installed by a set: it names npm, it is no metapackage and it is not held back. */
|
|
47
|
+
export function isConsumerFacing(l) {
|
|
48
|
+
return l.held === undefined && l.bundle === undefined && l.distribution.includes("npm") && !HELD_BACK.has(l.name);
|
|
49
|
+
}
|
|
50
|
+
/** Whether a set holds a library of this role. */
|
|
51
|
+
function holds(bundle, role) {
|
|
52
|
+
switch (bundle) {
|
|
53
|
+
case "commons":
|
|
54
|
+
return true;
|
|
55
|
+
case "foundation":
|
|
56
|
+
case "patterns":
|
|
57
|
+
case "programs":
|
|
58
|
+
case "standards":
|
|
59
|
+
return BUNDLE_OF_ROLE[role] === bundle;
|
|
60
|
+
default:
|
|
61
|
+
return absurd(bundle);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** The members of a set, in the order of their packages' names; the problem where a consumer-facing library has no role in `ROLE_OF`. */
|
|
65
|
+
export function membersOf(bundle, libraries) {
|
|
66
|
+
const out = [];
|
|
67
|
+
for (const l of libraries) {
|
|
68
|
+
if (!isConsumerFacing(l))
|
|
69
|
+
continue;
|
|
70
|
+
const role = ROLE_OF.get(l.name);
|
|
71
|
+
if (role === undefined)
|
|
72
|
+
return err(`commons/${l.name} has no role in ROLE_OF (commons/libraries/src/readme.ts), so no set can hold it`);
|
|
73
|
+
if (holds(bundle, role))
|
|
74
|
+
out.push({ library: l.name, package: publishedPackage(l), version: l.version });
|
|
75
|
+
}
|
|
76
|
+
return ok(out.sort((a, b) => (a.package < b.package ? -1 : a.package > b.package ? 1 : 0)));
|
|
77
|
+
}
|
|
78
|
+
/** The exact dependencies of the package of a set: each member's package at its version, no range. */
|
|
79
|
+
export function dependenciesOf(members) {
|
|
80
|
+
return Object.fromEntries(members.map((m) => [m.package, m.version]));
|
|
81
|
+
}
|
|
82
|
+
/** What the generated file of a set holds: the set and its exact dependencies. */
|
|
83
|
+
export function setFileText(bundle, members) {
|
|
84
|
+
return `${JSON.stringify({ generated: "bun commons/libraries/src/pack-metapackage.ts; do not edit (commons 0036-distribution FR-007)", set: bundle, dependencies: dependenciesOf(members) }, null, 2)}\n`;
|
|
85
|
+
}
|
|
86
|
+
/** The generated file of a set, from its folder. */
|
|
87
|
+
export const SET_FILE = "dependencies.auto.json";
|
|
88
|
+
/** The dependencies a generated file holds, or why its text is not one. */
|
|
89
|
+
export function readSetFile(text) {
|
|
90
|
+
let json;
|
|
91
|
+
try {
|
|
92
|
+
json = JSON.parse(text);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return err(`${SET_FILE} is not JSON`);
|
|
96
|
+
}
|
|
97
|
+
const deps = typeof json === "object" && json !== null && "dependencies" in json ? json.dependencies : undefined;
|
|
98
|
+
if (typeof deps !== "object" || deps === null || Array.isArray(deps))
|
|
99
|
+
return err(`${SET_FILE} has no dependencies`);
|
|
100
|
+
const out = {};
|
|
101
|
+
for (const [k, v] of Object.entries(deps)) {
|
|
102
|
+
if (typeof v !== "string")
|
|
103
|
+
return err(`${SET_FILE}: ${k} has no version`);
|
|
104
|
+
out[k] = v;
|
|
105
|
+
}
|
|
106
|
+
return ok(out);
|
|
107
|
+
}
|
|
108
|
+
/** What a set is for, in words, for its README. */
|
|
109
|
+
const PURPOSE = {
|
|
110
|
+
commons: "Every consumer-facing library of Intellectual Frontiers Commons, at the versions of one release.",
|
|
111
|
+
foundation: "The foundation libraries: errors as values and decoders, formats, cryptography, the system, the terminal, telemetry, the network, the test runtime, RDF, the Git host and the lint rules.",
|
|
112
|
+
patterns: "The pattern libraries: the headless program pattern and the layers of Kanon.",
|
|
113
|
+
programs: "The program libraries: the operations program of a repository, workspaces, data, integrations and the rest of the programs.",
|
|
114
|
+
standards: "The standards libraries: Mizan, the ontologies, the quality standards and the standards of integrations.",
|
|
115
|
+
};
|
|
116
|
+
/** The text of a set's own `description`, which the package carries. */
|
|
117
|
+
export function descriptionOf(bundle) {
|
|
118
|
+
return `${PURPOSE[bundle]} No code of its own: it depends on each library at one exact version.`;
|
|
119
|
+
}
|
|
120
|
+
/** The scope of the packages. */
|
|
121
|
+
const SCOPE = "@intellectual-frontiers";
|
|
122
|
+
/** The README of a set's package: what it holds, how to install it from npm and from the GitHub package registry, and how to keep one copy of each library. */
|
|
123
|
+
export function readmeOf(bundle, members) {
|
|
124
|
+
const name = `${SCOPE}/${bundle}`;
|
|
125
|
+
const rows = members.map((m) => `| \`${m.package}\` | \`${m.version}\` |`);
|
|
126
|
+
return [
|
|
127
|
+
`# ${name}`,
|
|
128
|
+
"",
|
|
129
|
+
descriptionOf(bundle),
|
|
130
|
+
"",
|
|
131
|
+
"```sh",
|
|
132
|
+
`bun add ${name}@<version> # or: npm install --save-exact ${name}@<version>`,
|
|
133
|
+
"```",
|
|
134
|
+
"",
|
|
135
|
+
`The package has no code of its own. Its dependencies are the libraries below, each at one exact version, so that one version of \`${name}\` is one coherent set. Pin it exactly, and import the libraries by their own names.`,
|
|
136
|
+
"",
|
|
137
|
+
"| Library | Version |",
|
|
138
|
+
"| --- | --- |",
|
|
139
|
+
...rows,
|
|
140
|
+
"",
|
|
141
|
+
"## One copy of each library",
|
|
142
|
+
"",
|
|
143
|
+
"Where another package of your tree depends on one of these libraries at a range, make the tree hold one copy: add",
|
|
144
|
+
"",
|
|
145
|
+
"```json",
|
|
146
|
+
`{ "overrides": { "${SCOPE}/core": "<the version above>" } }`,
|
|
147
|
+
"```",
|
|
148
|
+
"",
|
|
149
|
+
"to your `package.json` for each library you find twice (`bun pm ls --all`, `npm ls @intellectual-frontiers/core`). `repoctl hygiene` names the library that is installed twice.",
|
|
150
|
+
"",
|
|
151
|
+
"## From the GitHub package registry",
|
|
152
|
+
"",
|
|
153
|
+
"The same package is on the GitHub package registry of the organization. Put the scoped line in `.npmrc` and a token that may read packages in the environment:",
|
|
154
|
+
"",
|
|
155
|
+
"```sh",
|
|
156
|
+
"@intellectual-frontiers:registry=https://npm.pkg.github.com",
|
|
157
|
+
"//npm.pkg.github.com/:_authToken=${ERGONEX_GITHUB_TOKEN}",
|
|
158
|
+
"```",
|
|
159
|
+
"",
|
|
160
|
+
`License: ${DEFAULT_LICENSE}. Sources and specifications: https://github.com/intellectual-frontiers/.github/tree/main/commons/${bundle}`,
|
|
161
|
+
"",
|
|
162
|
+
].join("\n");
|
|
163
|
+
}
|
|
164
|
+
/** The `package.json` that is published for a set: no code, one empty entry, the exact dependencies. */
|
|
165
|
+
export function publishedManifest(bundle, version, dependencies, license) {
|
|
166
|
+
return {
|
|
167
|
+
name: `${SCOPE}/${bundle}`,
|
|
168
|
+
version,
|
|
169
|
+
description: descriptionOf(bundle),
|
|
170
|
+
license,
|
|
171
|
+
type: "module",
|
|
172
|
+
engines: { node: ">=26" },
|
|
173
|
+
sideEffects: false,
|
|
174
|
+
types: "./index.d.ts",
|
|
175
|
+
exports: { ".": { types: "./index.d.ts", default: "./index.js" } },
|
|
176
|
+
dependencies,
|
|
177
|
+
files: ["index.js", "index.d.ts", "README.md", "LICENSE"],
|
|
178
|
+
repository: { type: "git", url: "git+https://github.com/intellectual-frontiers/.github.git", directory: `commons/${bundle}` },
|
|
179
|
+
homepage: `https://github.com/intellectual-frontiers/.github/tree/main/commons/${bundle}`,
|
|
180
|
+
bugs: { url: "https://github.com/intellectual-frontiers/.github/issues" },
|
|
181
|
+
keywords: ["intellectual-frontiers", "commons", bundle],
|
|
182
|
+
publishConfig: { access: "public" },
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/** The one file of code of a set's package, and its declaration: an empty module, so that the entry imports. */
|
|
186
|
+
export const ENTRY_JS = "export {};\n";
|
|
187
|
+
/** The declaration of {@link ENTRY_JS}. */
|
|
188
|
+
export const ENTRY_DTS = "export {};\n";
|
|
189
|
+
/** Every set, in the order the README lists them. */
|
|
190
|
+
export const ALL_BUNDLES = BUNDLES;
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What of Mizan is still in this package (commons 0032-
|
|
2
|
+
* What of Mizan is still in this package (commons 0032-libraries-by-concern): the commands that need the whole repository. `check.ts` holds a repository's spec kit and ontologies, `versions.ts` and
|
|
3
3
|
* `changes.ts` are the commands of the release check and the change-control check, `libraries.ts` reads the manifests of the libraries, `newer.ts` reports a standard newer than its pin, `generate-ontology.ts` writes the Turtle of the ontologies and
|
|
4
4
|
* `oscal-register.ts` the register of proofs as OSCAL. The harness, the rules, the levels, the integrations, the change-control and release rules as plugins, and the trace of requirements are the
|
|
5
5
|
* library `mizan` (`@intellectual-frontiers/mizan`), and the ontologies are the library `ontology` (`@intellectual-frontiers/ontology`).
|
package/dist/mod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What of Mizan is still in this package (commons 0032-
|
|
2
|
+
* What of Mizan is still in this package (commons 0032-libraries-by-concern): the commands that need the whole repository. `check.ts` holds a repository's spec kit and ontologies, `versions.ts` and
|
|
3
3
|
* `changes.ts` are the commands of the release check and the change-control check, `libraries.ts` reads the manifests of the libraries, `newer.ts` reports a standard newer than its pin, `generate-ontology.ts` writes the Turtle of the ontologies and
|
|
4
4
|
* `oscal-register.ts` the register of proofs as OSCAL. The harness, the rules, the levels, the integrations, the change-control and release rules as plugins, and the trace of requirements are the
|
|
5
5
|
* library `mizan` (`@intellectual-frontiers/mizan`), and the ontologies are the library `ontology` (`@intellectual-frontiers/ontology`).
|
package/dist/pack-library.d.ts
CHANGED
|
@@ -31,6 +31,13 @@ export type Packed = {
|
|
|
31
31
|
export type PackOptions = {
|
|
32
32
|
/** Types the compiler is given (`["node"]` for a library that names Node's). */
|
|
33
33
|
readonly types?: readonly string[];
|
|
34
|
+
/**
|
|
35
|
+
* Commands of a package that is not a bundle: each command's name and the module, in `src/`, whose `main(argv)` gives the exit status; the package gets a one-line launcher for each (`<command>.mjs`, which Node and Bun run), made
|
|
36
|
+
* from the compiled module. The files under `src/` that are not TypeScript (a stylesheet a module reads beside itself) are published beside the sources and beside the compiled modules.
|
|
37
|
+
*/
|
|
38
|
+
readonly launchers?: Readonly<Record<string, string>>;
|
|
39
|
+
/** Packages the published package may use where they are installed beside it and does not need (loaded by name at run time): written as optional peer dependencies, name and range. */
|
|
40
|
+
readonly optionalPeers?: Readonly<Record<string, string>>;
|
|
34
41
|
/** A bundled package: the code of each entry and of each command is one file (`bun build`), and only the declarations the entries reach are published. */
|
|
35
42
|
readonly bundle?: {
|
|
36
43
|
/** The commands: their name, and the source that is the command's entry from the library's folder. */
|
package/dist/pack-library.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The package of a library of commons (commons 0032-
|
|
2
|
+
* The package of a library of commons (commons 0032-libraries-by-concern FR-005, FR-013): the library's sources compiled by the TypeScript 7 compiler into ECMAScript modules and their declarations, the
|
|
3
3
|
* `package.json` that is published (each `exports` entry naming its `types`, the source for Bun and the compiled file for everything else), and the tarball. The same inspection that the packer makes before it
|
|
4
4
|
* packs is `inspectPackage`, which a test runs again on the tarball it unpacks.
|
|
5
5
|
*
|
|
@@ -30,7 +30,6 @@ import { basename, dirname, join, relative, resolve, toPosix } from "@intellectu
|
|
|
30
30
|
import { env, run, which } from "@intellectual-frontiers/system/proc";
|
|
31
31
|
/** The scope of the packages of commons. */
|
|
32
32
|
export const SCOPE = "@intellectual-frontiers";
|
|
33
|
-
const obj = (v) => (isObject(v) ? v : {});
|
|
34
33
|
const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
35
34
|
const text = (v) => (typeof v === "string" ? v : "");
|
|
36
35
|
/** A text file copied: every file of a package is text. */
|
|
@@ -148,7 +147,7 @@ export function inspectPackage(stage) {
|
|
|
148
147
|
if (pkg === undefined)
|
|
149
148
|
continue;
|
|
150
149
|
if (pkg === `${SCOPE}/commons`)
|
|
151
|
-
found.push(`${d} imports ${s}: the package ${pkg} is
|
|
150
|
+
found.push(`${d} imports ${s}: the package ${pkg} is a metapackage with no code: import the library that holds what is used`);
|
|
152
151
|
else if (pkg !== name && !declared.has(pkg))
|
|
153
152
|
found.push(`${d} imports ${pkg}, which is not a dependency of ${name}`);
|
|
154
153
|
}
|
|
@@ -170,7 +169,7 @@ export function inspectPackage(stage) {
|
|
|
170
169
|
if (pkg === undefined)
|
|
171
170
|
continue;
|
|
172
171
|
if (pkg === `${SCOPE}/commons`)
|
|
173
|
-
found.push(`${f} imports ${s}: the package ${pkg} is
|
|
172
|
+
found.push(`${f} imports ${s}: the package ${pkg} is a metapackage with no code: import the library that holds what is used`);
|
|
174
173
|
else if (pkg !== name && !declared.has(pkg))
|
|
175
174
|
found.push(`${f} imports ${pkg}, which is not a dependency of ${name}`);
|
|
176
175
|
}
|
|
@@ -191,15 +190,16 @@ function libraryOf(commons, name) {
|
|
|
191
190
|
if (!existsSync(pkg))
|
|
192
191
|
return undefined;
|
|
193
192
|
const lib = join(commons, name, "library.ts");
|
|
194
|
-
const
|
|
195
|
-
|
|
193
|
+
const source = existsSync(lib) ? readTextFileSync(lib) : "";
|
|
194
|
+
const npm = /distribution:\s*\[[^\]]*"npm"/.test(source);
|
|
195
|
+
const held = /\bheld:\s*"/.test(source);
|
|
196
|
+
return { version: text(JSON.parse(readTextFileSync(pkg))["version"]), npm, held };
|
|
196
197
|
}
|
|
197
198
|
/**
|
|
198
|
-
* The declarations of a bundle: from the entries' declarations in the compiler's output, every declaration reached by a relative import is published,
|
|
199
|
-
*
|
|
200
|
-
* its types are made of is still lifted out of `commons/ts` a library at a time (commons 0032-lifting-libraries); a library that has been lifted is a dependency and is not vendored.
|
|
199
|
+
* The declarations of a bundle: from the entries' declarations in the compiler's output, every declaration reached by a relative import is published, those of a file outside the library's own `src/` under `dist/vendor/`
|
|
200
|
+
* with the specifiers that name it rewritten to relative ones. A library of commons that a bundle uses is a dependency and is not vendored.
|
|
201
201
|
*/
|
|
202
|
-
function vendorDeclarations(outRoot, lib, entries,
|
|
202
|
+
function vendorDeclarations(outRoot, lib, entries, stageDist) {
|
|
203
203
|
const found = [];
|
|
204
204
|
const placed = new Map(); // a file of the compiler's output, and where it goes under the stage's dist/
|
|
205
205
|
const place = (file) => {
|
|
@@ -221,27 +221,10 @@ function vendorDeclarations(outRoot, lib, entries, commonsPkg, stageDist) {
|
|
|
221
221
|
for (const s of specifiersOf(readTextFileSync(file))) {
|
|
222
222
|
if (s.startsWith("."))
|
|
223
223
|
todo.push(join(dirname(file), s.replace(/\.(?:js|ts|mjs)$/, "") + ".d.ts"));
|
|
224
|
-
else if (s.startsWith(`${SCOPE}/commons/`)) {
|
|
225
|
-
const target = commonsPkg.exports.get(`./${s.slice(`${SCOPE}/commons/`.length)}`);
|
|
226
|
-
if (target === undefined)
|
|
227
|
-
found.push(`${dest} imports ${s}, which the exports of commons do not name`);
|
|
228
|
-
else
|
|
229
|
-
todo.push(join(outRoot, commonsPkg.folder, target.replace(/^\.\//, "").replace(/\.ts$/, "") + ".d.ts"));
|
|
230
|
-
}
|
|
231
224
|
}
|
|
232
225
|
}
|
|
233
226
|
for (const [file, dest] of placed) {
|
|
234
227
|
let source = rewriteDeclarationSpecifiers(readTextFileSync(file));
|
|
235
|
-
source = source.replace(new RegExp(`((?:from\\s+|import\\(\\s*|import\\s+)["'])${SCOPE}/commons/([^"']+)(["'])`, "g"), (whole, pre, sub, post) => {
|
|
236
|
-
const target = commonsPkg.exports.get(`./${sub}`);
|
|
237
|
-
if (target === undefined)
|
|
238
|
-
return whole;
|
|
239
|
-
const there = place(join(outRoot, commonsPkg.folder, target.replace(/^\.\//, "").replace(/\.ts$/, "") + ".d.ts"));
|
|
240
|
-
let rel = toPosix(relative(dirname(dest), there)).replace(/\.d\.ts$/, ".js");
|
|
241
|
-
if (!rel.startsWith("."))
|
|
242
|
-
rel = `./${rel}`;
|
|
243
|
-
return `${pre}${rel}${post}`;
|
|
244
|
-
});
|
|
245
228
|
// a relative import that leaves the library's own tree (a type the compiler named by its path in commons) goes to where that declaration was placed
|
|
246
229
|
source = source.replace(/((?:from\s+|import\(\s*|import\s+)["'])(\.[^"']+)(["'])/g, (whole, pre, spec, post) => {
|
|
247
230
|
const target = join(dirname(file), spec.replace(/\.(?:js|ts|mjs)$/, "") + ".d.ts");
|
|
@@ -259,20 +242,8 @@ function vendorDeclarations(outRoot, lib, entries, commonsPkg, stageDist) {
|
|
|
259
242
|
}
|
|
260
243
|
return found;
|
|
261
244
|
}
|
|
262
|
-
/** The compiler's `paths` for the packages of commons that are not on npm: each entry of `commons/ts/package.json` (`./ts/kernel`) names the source that the specifier `@intellectual-frontiers/commons/ts/kernel` is. */
|
|
263
|
-
function commonsPaths(commons, dist) {
|
|
264
|
-
const file = join(commons, "ts", "package.json");
|
|
265
|
-
const out = {};
|
|
266
|
-
if (!existsSync(file))
|
|
267
|
-
return out;
|
|
268
|
-
for (const [k, v] of Object.entries(obj(obj(JSON.parse(readTextFileSync(file)))["exports"]))) {
|
|
269
|
-
if (typeof v === "string" && v.endsWith(".ts"))
|
|
270
|
-
out[`${SCOPE}/commons/${k.replace(/^\.\//, "")}`] = [toPosix(relative(dist, join(commons, "ts", v)))];
|
|
271
|
-
}
|
|
272
|
-
return out;
|
|
273
|
-
}
|
|
274
245
|
/** What a package adds to the common form. */
|
|
275
|
-
/** Whether a declaration of the package names a `node:` module: a package whose types name Node's needs `@types/node` where it is type-checked (a peer dependency, FR-013 of 0032-
|
|
246
|
+
/** Whether a declaration of the package names a `node:` module: a package whose types name Node's needs `@types/node` where it is type-checked (a peer dependency, FR-013 of 0032-libraries-by-concern). */
|
|
276
247
|
function namesNodeTypes(folder) {
|
|
277
248
|
if (!existsSync(folder))
|
|
278
249
|
return false;
|
|
@@ -308,7 +279,7 @@ export async function packLibrary(root, options = {}) {
|
|
|
308
279
|
removeSync(dist, { recursive: true });
|
|
309
280
|
mkdirSync(stage, { recursive: true });
|
|
310
281
|
// the compiler's configuration for this build: the base of commons, emitting modules and declarations of src/ and nothing else
|
|
311
|
-
const base = relative(dist, join(commons, "
|
|
282
|
+
const base = relative(dist, join(commons, "tsconfig.base.json"));
|
|
312
283
|
writeTextFileSync(join(dist, "tsconfig.build.json"), JSON.stringify({
|
|
313
284
|
extends: toPosix(base),
|
|
314
285
|
compilerOptions: {
|
|
@@ -321,8 +292,6 @@ export async function packLibrary(root, options = {}) {
|
|
|
321
292
|
skipLibCheck: true,
|
|
322
293
|
// another library of commons is read where the package manager linked it (under node_modules), so that a declaration names it by its package and its entry and never by the path of its sources
|
|
323
294
|
preserveSymlinks: true,
|
|
324
|
-
// a bundle's declarations are made from the sources of the packages of commons that are not on npm, which the compiler emits only when it reads them as sources and not through node_modules
|
|
325
|
-
...(bundle === undefined ? {} : { paths: commonsPaths(commons, dist) }),
|
|
326
295
|
},
|
|
327
296
|
include: [toPosix(relative(dist, join(root, "src"))) + "/**/*.ts"],
|
|
328
297
|
}, null, 2));
|
|
@@ -345,25 +314,21 @@ export async function packLibrary(root, options = {}) {
|
|
|
345
314
|
}
|
|
346
315
|
}
|
|
347
316
|
else {
|
|
348
|
-
const commonsPkgFile = join(commons, "ts", "package.json");
|
|
349
|
-
const commonsExports = new Map();
|
|
350
|
-
if (existsSync(commonsPkgFile)) {
|
|
351
|
-
const declared = obj(obj(JSON.parse(readTextFileSync(commonsPkgFile)))["exports"]);
|
|
352
|
-
for (const [k, v] of Object.entries(declared))
|
|
353
|
-
if (typeof v === "string")
|
|
354
|
-
commonsExports.set(k, v);
|
|
355
|
-
}
|
|
356
317
|
const entryFiles = Object.values(ownExports).map((e) => join(out, (targetsOf(e)["default"] ?? text(e)).replace(/^\.\/src\//, "").replace(/\.ts$/, "") + ".d.ts"));
|
|
357
|
-
findings.push(...vendorDeclarations(join(dist, "out"), basename(resolve(root)), entryFiles,
|
|
318
|
+
findings.push(...vendorDeclarations(join(dist, "out"), basename(resolve(root)), entryFiles, join(stage, "dist")));
|
|
358
319
|
}
|
|
359
320
|
// the sources, for the `bun` condition (a bundle has no source to offer: what it imports is not on npm)
|
|
360
321
|
if (bundle === undefined) {
|
|
361
322
|
for (const f of filesUnder(join(root, "src"))) {
|
|
362
|
-
if (!f.endsWith(".ts"))
|
|
363
|
-
continue;
|
|
364
323
|
const target = join(stage, "src", f);
|
|
365
324
|
mkdirSync(dirname(target), { recursive: true });
|
|
366
325
|
copyFileSync(join(root, "src", f), target);
|
|
326
|
+
if (!f.endsWith(".ts")) {
|
|
327
|
+
// a file that is not TypeScript is read beside the module that reads it, from the sources and from the compiled modules alike
|
|
328
|
+
const compiled = join(stage, "dist", f);
|
|
329
|
+
mkdirSync(dirname(compiled), { recursive: true });
|
|
330
|
+
copyFileSync(join(root, "src", f), compiled);
|
|
331
|
+
}
|
|
367
332
|
}
|
|
368
333
|
}
|
|
369
334
|
// the entries: each names its declarations, its source (Bun) and its compiled file
|
|
@@ -385,6 +350,13 @@ export async function packLibrary(root, options = {}) {
|
|
|
385
350
|
}
|
|
386
351
|
// the commands of a bundle: one file each, with the line that runs it under Node
|
|
387
352
|
const binOut = {};
|
|
353
|
+
for (const [cmd, source] of Object.entries(options.launchers ?? {})) {
|
|
354
|
+
const rel = toPosix(source).replace(/^\.?\/?(src\/)?/, "").replace(/\.ts$/, "");
|
|
355
|
+
const file = join(stage, `${cmd}.mjs`);
|
|
356
|
+
await writeTextFile(file, `#!/usr/bin/env node\nimport { main } from "./dist/${rel}.js";\n\nprocess.exit(await main(process.argv.slice(2)));\n`);
|
|
357
|
+
await chmod(file, 0o755);
|
|
358
|
+
binOut[cmd] = `./${cmd}.mjs`;
|
|
359
|
+
}
|
|
388
360
|
for (const [cmd, source] of Object.entries(bundle?.bin ?? {})) {
|
|
389
361
|
const file = join(stage, `${cmd}.mjs`);
|
|
390
362
|
const bundled = await run([bun, "build", join(root, source), "--target=node", "--format=esm", "--outfile", file], { cwd: root });
|
|
@@ -427,7 +399,7 @@ export async function packLibrary(root, options = {}) {
|
|
|
427
399
|
const lib = libraryOf(commons, pkg.slice(SCOPE.length + 1));
|
|
428
400
|
if (lib === undefined)
|
|
429
401
|
findings.push(`${file} imports ${pkg}, which is no library of commons`);
|
|
430
|
-
else if (!lib.npm)
|
|
402
|
+
else if (!lib.npm && !(libraryOf(commons, short)?.held === true && lib.held))
|
|
431
403
|
findings.push(`${file} imports ${pkg}, which is not published to npm`);
|
|
432
404
|
else
|
|
433
405
|
dependencies[pkg] = lib.version;
|
|
@@ -458,7 +430,10 @@ export async function packLibrary(root, options = {}) {
|
|
|
458
430
|
...(Object.keys(dependencies).length === 0
|
|
459
431
|
? {}
|
|
460
432
|
: { dependencies: Object.fromEntries(Object.entries(dependencies).sort(([a], [b]) => (a < b ? -1 : 1))) }),
|
|
461
|
-
...(namesNodeTypes(join(stage, "dist"))
|
|
433
|
+
...(namesNodeTypes(join(stage, "dist")) || options.optionalPeers !== undefined
|
|
434
|
+
? { peerDependencies: { ...(namesNodeTypes(join(stage, "dist")) ? { "@types/node": ">=26" } : {}), ...(options.optionalPeers ?? {}) } }
|
|
435
|
+
: {}),
|
|
436
|
+
...(options.optionalPeers === undefined ? {} : { peerDependenciesMeta: Object.fromEntries(Object.keys(options.optionalPeers).map((n) => [n, { optional: true }])) }),
|
|
462
437
|
files: [
|
|
463
438
|
...(Object.keys(exportsOut).length === 0 ? [] : ["dist"]),
|
|
464
439
|
...(bundle === undefined ? ["src"] : []),
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Library } from "./libraries.js";
|
|
2
|
+
/** The metapackages of a repository: the libraries whose manifest names a set. */
|
|
3
|
+
export declare function metapackagesOf(repo: string): readonly (Library & {
|
|
4
|
+
readonly bundle: NonNullable<Library["bundle"]>;
|
|
5
|
+
})[];
|
|
6
|
+
/** The files that are not what the manifests make (from the repository's root), and what is wrong with reading them; with `write`, the files are written. */
|
|
7
|
+
export declare function synchronize(repo: string, write: boolean): {
|
|
8
|
+
readonly stale: readonly string[];
|
|
9
|
+
readonly problems: readonly string[];
|
|
10
|
+
};
|
|
11
|
+
/** What packing a metapackage gave: the staged folder, the tarball where nothing was wrong, and what was wrong. */
|
|
12
|
+
export type PackedSet = {
|
|
13
|
+
readonly stage: string;
|
|
14
|
+
readonly tarball: string | undefined;
|
|
15
|
+
readonly findings: readonly string[];
|
|
16
|
+
};
|
|
17
|
+
/** Stages, inspects and packs the metapackage in the folder `root` (`commons/<set>/`). */
|
|
18
|
+
export declare function packMetapackage(root: string): Promise<PackedSet>;
|
|
19
|
+
/** The command line of a metapackage's `tools/pack.ts`: pack, print what was found (or the tarball) and the exit status. */
|
|
20
|
+
export declare function main(root: string, argv: readonly string[]): Promise<number>;
|
|
21
|
+
/** The command line of the generator: 0, or 1 where a file is not what the manifests make (with `--check`) or a manifest is wrong. */
|
|
22
|
+
export declare function generate(argv: readonly string[]): number;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The generator and the packer of the metapackages (commons 0036-distribution FR-007, FR-008): the file of each set that records its exact dependencies, and the tarball of its package.
|
|
3
|
+
*
|
|
4
|
+
* bun commons/libraries/src/pack-metapackage.ts write the file `dependencies.auto.json` of every metapackage again from the manifests
|
|
5
|
+
* bun commons/libraries/src/pack-metapackage.ts --check write nothing and exit 1 where a file is not what the manifests make
|
|
6
|
+
* bun tools/pack.ts [--check] (in the folder of a metapackage) stage, inspect and pack its package
|
|
7
|
+
* other flags: --repo DIR (the repository, the working folder by default)
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* A metapackage is a folder `commons/<set>/` whose manifest names `bundle`; the folder holds the manifest, a private `package.json`, the `LICENSE` and `tools/pack.ts`, and nothing that is code. Its members come from the manifests
|
|
11
|
+
* ({@link membersOf}) and are written to `dependencies.auto.json` in its folder, so that a change of the set is a change of the folder, which the release sees. The packer writes the staged package (`package.json` with the
|
|
12
|
+
* exact dependencies, an empty `index.js` and its declaration, the README, the `LICENSE`), inspects it with the same inspection as every library's and packs it with `bun pm pack`.
|
|
13
|
+
*
|
|
14
|
+
* @limits
|
|
15
|
+
* It writes the files named above and runs `bun pm pack`; it asks no registry.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { synchronize } from "./pack-metapackage.ts";
|
|
20
|
+
* synchronize(".", false).problems; // []
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Spec: 0001-libraries FR-023
|
|
24
|
+
*
|
|
25
|
+
* @module
|
|
26
|
+
*/
|
|
27
|
+
import process from "node:process";
|
|
28
|
+
import { err, ok } from "@intellectual-frontiers/core";
|
|
29
|
+
import { stdio } from "@intellectual-frontiers/system";
|
|
30
|
+
import { existsSync, mkdirSync, readTextFileSync, removeSync, writeTextFileSync } from "@intellectual-frontiers/system/fs";
|
|
31
|
+
import { join, resolve } from "@intellectual-frontiers/system/path";
|
|
32
|
+
import { env, run, which } from "@intellectual-frontiers/system/proc";
|
|
33
|
+
import { decodeLibrarySource, LIBRARY_FILE, readLibraries } from "./libraries.js";
|
|
34
|
+
import { licenseOf } from "./license.js";
|
|
35
|
+
import { ENTRY_DTS, ENTRY_JS, membersOf, publishedManifest, readmeOf, readSetFile, SET_FILE, setFileText } from "./metapackages.js";
|
|
36
|
+
import { inspectPackage, tarballName } from "./pack-library.js";
|
|
37
|
+
/** The metapackages of a repository: the libraries whose manifest names a set. */
|
|
38
|
+
export function metapackagesOf(repo) {
|
|
39
|
+
return readLibraries(repo).flatMap((f) => {
|
|
40
|
+
if (!("library" in f))
|
|
41
|
+
return [];
|
|
42
|
+
const l = f.library;
|
|
43
|
+
return l.bundle === undefined ? [] : [{ ...l, bundle: l.bundle }];
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** The files that are not what the manifests make (from the repository's root), and what is wrong with reading them; with `write`, the files are written. */
|
|
47
|
+
export function synchronize(repo, write) {
|
|
48
|
+
const root = repo.replace(/[\\/]$/, "");
|
|
49
|
+
const libraries = readLibraries(root).flatMap((f) => ("library" in f ? [f.library] : []));
|
|
50
|
+
const stale = [];
|
|
51
|
+
const problems = [];
|
|
52
|
+
for (const m of metapackagesOf(root)) {
|
|
53
|
+
const members = membersOf(m.bundle, libraries);
|
|
54
|
+
if (members.kind === "err") {
|
|
55
|
+
problems.push(members.error);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const path = `commons/${m.name}/${SET_FILE}`;
|
|
59
|
+
const file = join(root, path);
|
|
60
|
+
const want = setFileText(m.bundle, members.value);
|
|
61
|
+
if (existsSync(file) && readTextFileSync(file) === want)
|
|
62
|
+
continue;
|
|
63
|
+
stale.push(path);
|
|
64
|
+
if (write)
|
|
65
|
+
writeTextFileSync(file, want);
|
|
66
|
+
}
|
|
67
|
+
return { stale, problems };
|
|
68
|
+
}
|
|
69
|
+
/** The manifest of the metapackage at `root`, or why it is none. */
|
|
70
|
+
function manifestAt(root) {
|
|
71
|
+
const file = join(root, LIBRARY_FILE);
|
|
72
|
+
if (!existsSync(file))
|
|
73
|
+
return err(`${file} is missing`);
|
|
74
|
+
const r = decodeLibrarySource(readTextFileSync(file));
|
|
75
|
+
if (r.kind === "err")
|
|
76
|
+
return err(r.error);
|
|
77
|
+
return r.value.bundle === undefined ? err(`${file} names no bundle: it is not a metapackage`) : ok(r.value);
|
|
78
|
+
}
|
|
79
|
+
/** Stages, inspects and packs the metapackage in the folder `root` (`commons/<set>/`). */
|
|
80
|
+
export async function packMetapackage(root) {
|
|
81
|
+
const own = manifestAt(root);
|
|
82
|
+
const dist = join(root, "dist");
|
|
83
|
+
const stage = join(dist, "package");
|
|
84
|
+
if (own.kind === "err")
|
|
85
|
+
return { stage, tarball: undefined, findings: [own.error] };
|
|
86
|
+
const l = own.value;
|
|
87
|
+
const bundle = l.bundle;
|
|
88
|
+
if (bundle === undefined)
|
|
89
|
+
return { stage, tarball: undefined, findings: [`${l.name} names no bundle`] };
|
|
90
|
+
const setFile = join(root, SET_FILE);
|
|
91
|
+
if (!existsSync(setFile))
|
|
92
|
+
return { stage, tarball: undefined, findings: [`${SET_FILE} is missing: run bun commons/libraries/src/pack-metapackage.ts`] };
|
|
93
|
+
const deps = readSetFile(readTextFileSync(setFile));
|
|
94
|
+
if (deps.kind === "err")
|
|
95
|
+
return { stage, tarball: undefined, findings: [deps.error] };
|
|
96
|
+
if (existsSync(dist))
|
|
97
|
+
removeSync(dist, { recursive: true });
|
|
98
|
+
mkdirSync(stage, { recursive: true });
|
|
99
|
+
const members = Object.entries(deps.value).map(([pkg, version]) => ({ library: pkg.slice(pkg.indexOf("/") + 1), package: pkg, version }));
|
|
100
|
+
const manifest = publishedManifest(bundle, l.version, deps.value, licenseOf(l));
|
|
101
|
+
writeTextFileSync(join(stage, "package.json"), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
102
|
+
writeTextFileSync(join(stage, "index.js"), ENTRY_JS);
|
|
103
|
+
writeTextFileSync(join(stage, "index.d.ts"), ENTRY_DTS);
|
|
104
|
+
writeTextFileSync(join(stage, "README.md"), readmeOf(bundle, members));
|
|
105
|
+
const findings = [];
|
|
106
|
+
if (existsSync(join(root, "LICENSE")))
|
|
107
|
+
writeTextFileSync(join(stage, "LICENSE"), readTextFileSync(join(root, "LICENSE")));
|
|
108
|
+
else
|
|
109
|
+
findings.push(`commons/${l.name} has no LICENSE; run: bun commons/libraries/src/license.ts`);
|
|
110
|
+
if (Object.keys(deps.value).length === 0)
|
|
111
|
+
findings.push(`${l.name}: the set has no member`);
|
|
112
|
+
findings.push(...inspectPackage(stage));
|
|
113
|
+
if (findings.length > 0)
|
|
114
|
+
return { stage, tarball: undefined, findings };
|
|
115
|
+
const packed = await run([which("bun") ?? "bun", "pm", "pack", "--destination", dist], { cwd: stage });
|
|
116
|
+
if (packed.code !== 0)
|
|
117
|
+
return { stage, tarball: undefined, findings: [`bun pm pack stopped: ${packed.stderr || packed.stdout}`.trim()] };
|
|
118
|
+
return { stage, tarball: join(dist, tarballName(`@intellectual-frontiers/${bundle}`, l.version)), findings: [] };
|
|
119
|
+
}
|
|
120
|
+
/** The command line of a metapackage's `tools/pack.ts`: pack, print what was found (or the tarball) and the exit status. */
|
|
121
|
+
export async function main(root, argv) {
|
|
122
|
+
if (argv.includes("--check") && (env.get("IFC_SKIP_PACK") ?? "") !== "") {
|
|
123
|
+
stdio.stdout.writeSync("pack check skipped: the set did not change in this push (IFC_SKIP_PACK); the release packs it\n");
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
const r = await packMetapackage(root);
|
|
127
|
+
for (const f of r.findings)
|
|
128
|
+
stdio.stderr.writeSync(`${f}\n`);
|
|
129
|
+
if (r.tarball === undefined)
|
|
130
|
+
return 1;
|
|
131
|
+
stdio.stdout.writeSync(`${argv.includes("--check") ? `packed ${r.tarball}: nothing wrong` : r.tarball}\n`);
|
|
132
|
+
return 0;
|
|
133
|
+
}
|
|
134
|
+
/** The command line of the generator: 0, or 1 where a file is not what the manifests make (with `--check`) or a manifest is wrong. */
|
|
135
|
+
export function generate(argv) {
|
|
136
|
+
const at = argv.indexOf("--repo");
|
|
137
|
+
const repo = at >= 0 ? resolve(argv[at + 1] ?? ".") : resolve(".");
|
|
138
|
+
const check = argv.includes("--check");
|
|
139
|
+
const r = synchronize(repo, !check);
|
|
140
|
+
for (const p of r.problems)
|
|
141
|
+
stdio.stderr.writeSync(`${p}\n`);
|
|
142
|
+
for (const s of r.stale)
|
|
143
|
+
stdio.stderr.writeSync(check ? `${s} is not what the manifests make; run: bun commons/libraries/src/pack-metapackage.ts\n` : `wrote ${s}\n`);
|
|
144
|
+
return r.problems.length > 0 || (check && r.stale.length > 0) ? 1 : 0;
|
|
145
|
+
}
|
|
146
|
+
if (import.meta.main)
|
|
147
|
+
process.exitCode = generate(process.argv.slice(2));
|
package/dist/pins.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Commons' pins as the tools read them (commons 0005-typescript-
|
|
2
|
+
* Commons' pins as the tools read them (commons 0005-typescript-practice FR-026, 0002-packaging FR-019): the `KEY=value` lines of `pins.auto.env`, the suffix of a platform's
|
|
3
3
|
* variables, and the download of a pin on a platform (its version, address, SHA-256, format and folder), all taken from the file and written nowhere else.
|
|
4
4
|
*
|
|
5
5
|
* Spec: 0001-libraries FR-006
|
package/dist/pins.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Commons' pins as the tools read them (commons 0005-typescript-
|
|
2
|
+
* Commons' pins as the tools read them (commons 0005-typescript-practice FR-026, 0002-packaging FR-019): the `KEY=value` lines of `pins.auto.env`, the suffix of a platform's
|
|
3
3
|
* variables, and the download of a pin on a platform (its version, address, SHA-256, format and folder), all taken from the file and written nowhere else.
|
|
4
4
|
*
|
|
5
5
|
* Spec: 0001-libraries FR-006
|
package/dist/readme.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type Brand, type Result } from "@intellectual-frontiers/core";
|
|
2
2
|
import { type Library, type Registry } from "./libraries.js";
|
|
3
|
-
/** The marker that opens the generated table
|
|
3
|
+
/** The marker that opens the generated table. */
|
|
4
4
|
export declare const BEGIN = "<!-- libraries-map:begin -->";
|
|
5
|
+
/** The marker that closes the generated table. */
|
|
5
6
|
export declare const END = "<!-- libraries-map:end -->";
|
|
6
7
|
/** What a library is for in the whole: a closed union. */
|
|
7
8
|
export declare const ROLES: readonly ["foundation", "pattern", "program", "standard"];
|
|
@@ -24,6 +25,8 @@ export type Row = {
|
|
|
24
25
|
readonly level: string;
|
|
25
26
|
readonly distribution: readonly Registry[];
|
|
26
27
|
readonly published: boolean;
|
|
28
|
+
/** Why the library is held out of the release, where it is. */
|
|
29
|
+
readonly held: string | undefined;
|
|
27
30
|
};
|
|
28
31
|
/**
|
|
29
32
|
* The `summary` of an `about.ts`, read as data: the double-quoted string literals after `summary:`, joined by `+`, and nothing run.
|
|
@@ -48,6 +51,15 @@ export declare function rowsOf(repo: string): {
|
|
|
48
51
|
readonly rows: readonly Row[];
|
|
49
52
|
readonly problems: readonly string[];
|
|
50
53
|
};
|
|
54
|
+
/** One row of the table of the metapackages: the package and what it is. */
|
|
55
|
+
export type BundleRow = {
|
|
56
|
+
readonly name: string;
|
|
57
|
+
readonly purpose: string;
|
|
58
|
+
};
|
|
59
|
+
/** The rows of the metapackages of a repository, in the order of their folders' names: each the package and the first clause of the summary its manifest gives. */
|
|
60
|
+
export declare function bundlesOf(repo: string): readonly BundleRow[];
|
|
61
|
+
/** The table of the metapackages, as Markdown, with the sentence that introduces it; nothing where a repository has none. */
|
|
62
|
+
export declare function bundlesTableOf(rows: readonly BundleRow[]): string;
|
|
51
63
|
/** The README made again from its text and the table: the text between the markers (on lines of their own) replaced; an error where the markers are missing. */
|
|
52
64
|
export declare function withTable(readme: string, table: string): Result<string, string>;
|
|
53
65
|
/** The result of a run: whether README.md is stale, and the problems found. With `write`, the file is written where it is stale. */
|