@seasb/metafab 0.0.1 → 1.0.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/README.md +46 -1
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +317 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/build.d.ts +2 -0
- package/dist/commands/build.js +70 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/check.d.ts +2 -0
- package/dist/commands/check.js +41 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/create.d.ts +2 -0
- package/dist/commands/create.js +74 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/detach.d.ts +2 -0
- package/dist/commands/detach.js +24 -0
- package/dist/commands/detach.js.map +1 -0
- package/dist/commands/diff.d.ts +2 -0
- package/dist/commands/diff.js +35 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/import.d.ts +2 -0
- package/dist/commands/import.js +107 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +77 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/map.d.ts +2 -0
- package/dist/commands/map.js +43 -0
- package/dist/commands/map.js.map +1 -0
- package/dist/commands/not-implemented.d.ts +2 -0
- package/dist/commands/not-implemented.js +19 -0
- package/dist/commands/not-implemented.js.map +1 -0
- package/dist/commands/pipeline-add.d.ts +2 -0
- package/dist/commands/pipeline-add.js +67 -0
- package/dist/commands/pipeline-add.js.map +1 -0
- package/dist/commands/pipeline-remove.d.ts +2 -0
- package/dist/commands/pipeline-remove.js +44 -0
- package/dist/commands/pipeline-remove.js.map +1 -0
- package/dist/commands/publish.d.ts +2 -0
- package/dist/commands/publish.js +147 -0
- package/dist/commands/publish.js.map +1 -0
- package/dist/commands/types.d.ts +45 -0
- package/dist/commands/types.js +2 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/commands/update.d.ts +2 -0
- package/dist/commands/update.js +97 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/core/adopt.d.ts +53 -0
- package/dist/core/adopt.js +676 -0
- package/dist/core/adopt.js.map +1 -0
- package/dist/core/build/agents.d.ts +23 -0
- package/dist/core/build/agents.js +60 -0
- package/dist/core/build/agents.js.map +1 -0
- package/dist/core/build/index.d.ts +4 -0
- package/dist/core/build/index.js +5 -0
- package/dist/core/build/index.js.map +1 -0
- package/dist/core/build/markers.d.ts +34 -0
- package/dist/core/build/markers.js +97 -0
- package/dist/core/build/markers.js.map +1 -0
- package/dist/core/build/plan.d.ts +48 -0
- package/dist/core/build/plan.js +792 -0
- package/dist/core/build/plan.js.map +1 -0
- package/dist/core/build/skill.d.ts +60 -0
- package/dist/core/build/skill.js +275 -0
- package/dist/core/build/skill.js.map +1 -0
- package/dist/core/check/drift.d.ts +13 -0
- package/dist/core/check/drift.js +205 -0
- package/dist/core/check/drift.js.map +1 -0
- package/dist/core/check/index.d.ts +12 -0
- package/dist/core/check/index.js +78 -0
- package/dist/core/check/index.js.map +1 -0
- package/dist/core/check/markers.d.ts +9 -0
- package/dist/core/check/markers.js +220 -0
- package/dist/core/check/markers.js.map +1 -0
- package/dist/core/config/destinations.d.ts +5 -0
- package/dist/core/config/destinations.js +20 -0
- package/dist/core/config/destinations.js.map +1 -0
- package/dist/core/config/load.d.ts +4 -0
- package/dist/core/config/load.js +41 -0
- package/dist/core/config/load.js.map +1 -0
- package/dist/core/config/parse.d.ts +8 -0
- package/dist/core/config/parse.js +198 -0
- package/dist/core/config/parse.js.map +1 -0
- package/dist/core/config/source.d.ts +14 -0
- package/dist/core/config/source.js +44 -0
- package/dist/core/config/source.js.map +1 -0
- package/dist/core/config/types.d.ts +48 -0
- package/dist/core/config/types.js +2 -0
- package/dist/core/config/types.js.map +1 -0
- package/dist/core/config/validate.d.ts +11 -0
- package/dist/core/config/validate.js +351 -0
- package/dist/core/config/validate.js.map +1 -0
- package/dist/core/config/writers.d.ts +14 -0
- package/dist/core/config/writers.js +261 -0
- package/dist/core/config/writers.js.map +1 -0
- package/dist/core/config.d.ts +7 -0
- package/dist/core/config.js +8 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/discovery.d.ts +34 -0
- package/dist/core/discovery.js +272 -0
- package/dist/core/discovery.js.map +1 -0
- package/dist/core/edit/create.d.ts +18 -0
- package/dist/core/edit/create.js +190 -0
- package/dist/core/edit/create.js.map +1 -0
- package/dist/core/edit/document.d.ts +4 -0
- package/dist/core/edit/document.js +16 -0
- package/dist/core/edit/document.js.map +1 -0
- package/dist/core/edit/factory-yaml.d.ts +17 -0
- package/dist/core/edit/factory-yaml.js +211 -0
- package/dist/core/edit/factory-yaml.js.map +1 -0
- package/dist/core/edit/files.d.ts +6 -0
- package/dist/core/edit/files.js +47 -0
- package/dist/core/edit/files.js.map +1 -0
- package/dist/core/edit/index.d.ts +9 -0
- package/dist/core/edit/index.js +10 -0
- package/dist/core/edit/index.js.map +1 -0
- package/dist/core/edit/map.d.ts +24 -0
- package/dist/core/edit/map.js +82 -0
- package/dist/core/edit/map.js.map +1 -0
- package/dist/core/edit/names.d.ts +2 -0
- package/dist/core/edit/names.js +17 -0
- package/dist/core/edit/names.js.map +1 -0
- package/dist/core/edit/paths.d.ts +8 -0
- package/dist/core/edit/paths.js +76 -0
- package/dist/core/edit/paths.js.map +1 -0
- package/dist/core/edit/pipeline.d.ts +19 -0
- package/dist/core/edit/pipeline.js +146 -0
- package/dist/core/edit/pipeline.js.map +1 -0
- package/dist/core/edit/skill.d.ts +1 -0
- package/dist/core/edit/skill.js +10 -0
- package/dist/core/edit/skill.js.map +1 -0
- package/dist/core/factory/discovery.d.ts +9 -0
- package/dist/core/factory/discovery.js +139 -0
- package/dist/core/factory/discovery.js.map +1 -0
- package/dist/core/factory/factory-yaml.d.ts +16 -0
- package/dist/core/factory/factory-yaml.js +375 -0
- package/dist/core/factory/factory-yaml.js.map +1 -0
- package/dist/core/factory/index.d.ts +5 -0
- package/dist/core/factory/index.js +6 -0
- package/dist/core/factory/index.js.map +1 -0
- package/dist/core/factory/lines.d.ts +8 -0
- package/dist/core/factory/lines.js +11 -0
- package/dist/core/factory/lines.js.map +1 -0
- package/dist/core/factory/load.d.ts +4 -0
- package/dist/core/factory/load.js +81 -0
- package/dist/core/factory/load.js.map +1 -0
- package/dist/core/factory/requires.d.ts +9 -0
- package/dist/core/factory/requires.js +123 -0
- package/dist/core/factory/requires.js.map +1 -0
- package/dist/core/factory/types.d.ts +45 -0
- package/dist/core/factory/types.js +2 -0
- package/dist/core/factory/types.js.map +1 -0
- package/dist/core/factory/validate.d.ts +41 -0
- package/dist/core/factory/validate.js +441 -0
- package/dist/core/factory/validate.js.map +1 -0
- package/dist/core/hooks/index.d.ts +8 -0
- package/dist/core/hooks/index.js +15 -0
- package/dist/core/hooks/index.js.map +1 -0
- package/dist/core/hooks/script.d.ts +21 -0
- package/dist/core/hooks/script.js +34 -0
- package/dist/core/hooks/script.js.map +1 -0
- package/dist/core/hooks/sync.d.ts +17 -0
- package/dist/core/hooks/sync.js +262 -0
- package/dist/core/hooks/sync.js.map +1 -0
- package/dist/core/import/conflicts.d.ts +82 -0
- package/dist/core/import/conflicts.js +256 -0
- package/dist/core/import/conflicts.js.map +1 -0
- package/dist/core/import/copy.d.ts +10 -0
- package/dist/core/import/copy.js +76 -0
- package/dist/core/import/copy.js.map +1 -0
- package/dist/core/import/file-tree.d.ts +43 -0
- package/dist/core/import/file-tree.js +107 -0
- package/dist/core/import/file-tree.js.map +1 -0
- package/dist/core/import/index.d.ts +5 -0
- package/dist/core/import/index.js +6 -0
- package/dist/core/import/index.js.map +1 -0
- package/dist/core/import/pipeline-changes.d.ts +8 -0
- package/dist/core/import/pipeline-changes.js +89 -0
- package/dist/core/import/pipeline-changes.js.map +1 -0
- package/dist/core/import/run.d.ts +76 -0
- package/dist/core/import/run.js +258 -0
- package/dist/core/import/run.js.map +1 -0
- package/dist/core/init/gitattributes.d.ts +20 -0
- package/dist/core/init/gitattributes.js +89 -0
- package/dist/core/init/gitattributes.js.map +1 -0
- package/dist/core/init/index.d.ts +4 -0
- package/dist/core/init/index.js +5 -0
- package/dist/core/init/index.js.map +1 -0
- package/dist/core/init/name.d.ts +1 -0
- package/dist/core/init/name.js +4 -0
- package/dist/core/init/name.js.map +1 -0
- package/dist/core/init/run.d.ts +51 -0
- package/dist/core/init/run.js +261 -0
- package/dist/core/init/run.js.map +1 -0
- package/dist/core/init/targets.d.ts +17 -0
- package/dist/core/init/targets.js +87 -0
- package/dist/core/init/targets.js.map +1 -0
- package/dist/core/merge.d.ts +88 -0
- package/dist/core/merge.js +239 -0
- package/dist/core/merge.js.map +1 -0
- package/dist/core/publish/exclude.d.ts +9 -0
- package/dist/core/publish/exclude.js +32 -0
- package/dist/core/publish/exclude.js.map +1 -0
- package/dist/core/publish/git-target.d.ts +32 -0
- package/dist/core/publish/git-target.js +447 -0
- package/dist/core/publish/git-target.js.map +1 -0
- package/dist/core/publish/index.d.ts +10 -0
- package/dist/core/publish/index.js +11 -0
- package/dist/core/publish/index.js.map +1 -0
- package/dist/core/publish/npm-target.d.ts +15 -0
- package/dist/core/publish/npm-target.js +170 -0
- package/dist/core/publish/npm-target.js.map +1 -0
- package/dist/core/publish/package-json.d.ts +31 -0
- package/dist/core/publish/package-json.js +74 -0
- package/dist/core/publish/package-json.js.map +1 -0
- package/dist/core/publish/prepare.d.ts +24 -0
- package/dist/core/publish/prepare.js +93 -0
- package/dist/core/publish/prepare.js.map +1 -0
- package/dist/core/publish/provenance.d.ts +1 -0
- package/dist/core/publish/provenance.js +20 -0
- package/dist/core/publish/provenance.js.map +1 -0
- package/dist/core/publish/publish.d.ts +13 -0
- package/dist/core/publish/publish.js +130 -0
- package/dist/core/publish/publish.js.map +1 -0
- package/dist/core/publish/readme.d.ts +22 -0
- package/dist/core/publish/readme.js +112 -0
- package/dist/core/publish/readme.js.map +1 -0
- package/dist/core/publish/stage.d.ts +19 -0
- package/dist/core/publish/stage.js +333 -0
- package/dist/core/publish/stage.js.map +1 -0
- package/dist/core/publish/types.d.ts +71 -0
- package/dist/core/publish/types.js +2 -0
- package/dist/core/publish/types.js.map +1 -0
- package/dist/core/requires/check.d.ts +15 -0
- package/dist/core/requires/check.js +83 -0
- package/dist/core/requires/check.js.map +1 -0
- package/dist/core/requires/index.d.ts +4 -0
- package/dist/core/requires/index.js +5 -0
- package/dist/core/requires/index.js.map +1 -0
- package/dist/core/requires/inspect.d.ts +44 -0
- package/dist/core/requires/inspect.js +114 -0
- package/dist/core/requires/inspect.js.map +1 -0
- package/dist/core/requires/paths.d.ts +29 -0
- package/dist/core/requires/paths.js +83 -0
- package/dist/core/requires/paths.js.map +1 -0
- package/dist/core/requires/setup.d.ts +37 -0
- package/dist/core/requires/setup.js +147 -0
- package/dist/core/requires/setup.js.map +1 -0
- package/dist/core/setup.d.ts +27 -0
- package/dist/core/setup.js +84 -0
- package/dist/core/setup.js.map +1 -0
- package/dist/core/sources/cache.d.ts +38 -0
- package/dist/core/sources/cache.js +200 -0
- package/dist/core/sources/cache.js.map +1 -0
- package/dist/core/sources/containment.d.ts +21 -0
- package/dist/core/sources/containment.js +50 -0
- package/dist/core/sources/containment.js.map +1 -0
- package/dist/core/sources/env.d.ts +12 -0
- package/dist/core/sources/env.js +28 -0
- package/dist/core/sources/env.js.map +1 -0
- package/dist/core/sources/extract.d.ts +25 -0
- package/dist/core/sources/extract.js +676 -0
- package/dist/core/sources/extract.js.map +1 -0
- package/dist/core/sources/git-process.d.ts +26 -0
- package/dist/core/sources/git-process.js +51 -0
- package/dist/core/sources/git-process.js.map +1 -0
- package/dist/core/sources/git.d.ts +41 -0
- package/dist/core/sources/git.js +511 -0
- package/dist/core/sources/git.js.map +1 -0
- package/dist/core/sources/https.d.ts +21 -0
- package/dist/core/sources/https.js +208 -0
- package/dist/core/sources/https.js.map +1 -0
- package/dist/core/sources/index.d.ts +13 -0
- package/dist/core/sources/index.js +14 -0
- package/dist/core/sources/index.js.map +1 -0
- package/dist/core/sources/npm-cli.d.ts +19 -0
- package/dist/core/sources/npm-cli.js +43 -0
- package/dist/core/sources/npm-cli.js.map +1 -0
- package/dist/core/sources/npm.d.ts +29 -0
- package/dist/core/sources/npm.js +386 -0
- package/dist/core/sources/npm.js.map +1 -0
- package/dist/core/sources/parse.d.ts +32 -0
- package/dist/core/sources/parse.js +389 -0
- package/dist/core/sources/parse.js.map +1 -0
- package/dist/core/sources/path.d.ts +10 -0
- package/dist/core/sources/path.js +316 -0
- package/dist/core/sources/path.js.map +1 -0
- package/dist/core/sources/redact.d.ts +2 -0
- package/dist/core/sources/redact.js +70 -0
- package/dist/core/sources/redact.js.map +1 -0
- package/dist/core/sources/resolve.d.ts +9 -0
- package/dist/core/sources/resolve.js +29 -0
- package/dist/core/sources/resolve.js.map +1 -0
- package/dist/core/sources/types.d.ts +86 -0
- package/dist/core/sources/types.js +2 -0
- package/dist/core/sources/types.js.map +1 -0
- package/dist/core/sources/validate.d.ts +9 -0
- package/dist/core/sources/validate.js +111 -0
- package/dist/core/sources/validate.js.map +1 -0
- package/dist/core/summary.d.ts +77 -0
- package/dist/core/summary.js +405 -0
- package/dist/core/summary.js.map +1 -0
- package/dist/core/update/clashes.d.ts +63 -0
- package/dist/core/update/clashes.js +192 -0
- package/dist/core/update/clashes.js.map +1 -0
- package/dist/core/update/detach.d.ts +21 -0
- package/dist/core/update/detach.js +38 -0
- package/dist/core/update/detach.js.map +1 -0
- package/dist/core/update/diff.d.ts +58 -0
- package/dist/core/update/diff.js +180 -0
- package/dist/core/update/diff.js.map +1 -0
- package/dist/core/update/fetch.d.ts +34 -0
- package/dist/core/update/fetch.js +73 -0
- package/dist/core/update/fetch.js.map +1 -0
- package/dist/core/update/index.d.ts +6 -0
- package/dist/core/update/index.js +7 -0
- package/dist/core/update/index.js.map +1 -0
- package/dist/core/update/restore.d.ts +20 -0
- package/dist/core/update/restore.js +195 -0
- package/dist/core/update/restore.js.map +1 -0
- package/dist/core/update/run.d.ts +113 -0
- package/dist/core/update/run.js +1132 -0
- package/dist/core/update/run.js.map +1 -0
- package/dist/core/update/select.d.ts +39 -0
- package/dist/core/update/select.js +157 -0
- package/dist/core/update/select.js.map +1 -0
- package/dist/core/update/spelling.d.ts +51 -0
- package/dist/core/update/spelling.js +185 -0
- package/dist/core/update/spelling.js.map +1 -0
- package/dist/core/update/trees.d.ts +24 -0
- package/dist/core/update/trees.js +72 -0
- package/dist/core/update/trees.js.map +1 -0
- package/dist/errors.d.ts +29 -0
- package/dist/errors.js +24 -0
- package/dist/errors.js.map +1 -0
- package/dist/help.d.ts +46 -0
- package/dist/help.js +103 -0
- package/dist/help.js.map +1 -0
- package/dist/input.d.ts +25 -0
- package/dist/input.js +173 -0
- package/dist/input.js.map +1 -0
- package/dist/output.d.ts +21 -0
- package/dist/output.js +37 -0
- package/dist/output.js.map +1 -0
- package/dist/util/frontmatter.d.ts +12 -0
- package/dist/util/frontmatter.js +58 -0
- package/dist/util/frontmatter.js.map +1 -0
- package/dist/util/fs.d.ts +32 -0
- package/dist/util/fs.js +126 -0
- package/dist/util/fs.js.map +1 -0
- package/dist/util/git-names.d.ts +8 -0
- package/dist/util/git-names.js +25 -0
- package/dist/util/git-names.js.map +1 -0
- package/dist/util/git.d.ts +12 -0
- package/dist/util/git.js +33 -0
- package/dist/util/git.js.map +1 -0
- package/dist/util/suggest.d.ts +6 -0
- package/dist/util/suggest.js +48 -0
- package/dist/util/suggest.js.map +1 -0
- package/dist/util/text.d.ts +8 -0
- package/dist/util/text.js +19 -0
- package/dist/util/text.js.map +1 -0
- package/dist/util/version.d.ts +7 -0
- package/dist/util/version.js +13 -0
- package/dist/util/version.js.map +1 -0
- package/dist/util/yaml.d.ts +30 -0
- package/dist/util/yaml.js +201 -0
- package/dist/util/yaml.js.map +1 -0
- package/package.json +50 -3
- package/resources/metafab-skill/SKILL.md +99 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { ExitCode, MetafabError } from "../../errors.js";
|
|
3
|
+
import { npmInvocation } from "../sources/npm-cli.js";
|
|
4
|
+
import { redact } from "../sources/redact.js";
|
|
5
|
+
import { provenanceEnabled } from "./provenance.js";
|
|
6
|
+
const MAX_OUTPUT = 32 * 1024 * 1024;
|
|
7
|
+
function npmMessage(failure) {
|
|
8
|
+
const raw = (failure.stderr ?? "").trim() || (failure.stdout ?? "").trim() || failure.message || "";
|
|
9
|
+
const lines = raw
|
|
10
|
+
.split("\n")
|
|
11
|
+
.map((line) => line.replace(/^npm (?:error|notice) /i, "").trimEnd())
|
|
12
|
+
.filter((line) => line !== "" && !line.startsWith("A complete log of this run can be found"));
|
|
13
|
+
return lines.join("\n") || "npm failed";
|
|
14
|
+
}
|
|
15
|
+
function publishError(message, code, exitCode, cause) {
|
|
16
|
+
return new MetafabError(redact(message), { exitCode, code, cause });
|
|
17
|
+
}
|
|
18
|
+
function notFound(result) {
|
|
19
|
+
const output = `${result.stderr}\n${result.stdout}`;
|
|
20
|
+
return /\bE404\b|404 Not Found/i.test(output);
|
|
21
|
+
}
|
|
22
|
+
async function tryNpm(args, env) {
|
|
23
|
+
const npm = await npmInvocation({ env });
|
|
24
|
+
try {
|
|
25
|
+
const { stdout, stderr } = await new Promise((resolve, reject) => {
|
|
26
|
+
execFile(npm.command, [...npm.args, ...args], { env, encoding: "utf8", maxBuffer: MAX_OUTPUT, windowsHide: true }, (error, stdout, stderr) => {
|
|
27
|
+
if (error === null)
|
|
28
|
+
resolve({ stdout, stderr });
|
|
29
|
+
else
|
|
30
|
+
reject(Object.assign(error, { stdout, stderr }));
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return { ok: true, stdout, stderr };
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
const failure = error;
|
|
37
|
+
return {
|
|
38
|
+
ok: false,
|
|
39
|
+
stdout: failure.stdout ?? "",
|
|
40
|
+
stderr: failure.stderr ?? failure.message ?? "",
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function isRecord(value) {
|
|
45
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
46
|
+
}
|
|
47
|
+
function parseJson(value, context) {
|
|
48
|
+
try {
|
|
49
|
+
return JSON.parse(value);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw publishError(`${context}: npm returned invalid JSON`, "publish-npm-invalid-json", ExitCode.Failed, error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function manifestHashes(dist) {
|
|
56
|
+
return {
|
|
57
|
+
...(typeof dist.integrity === "string" && dist.integrity !== ""
|
|
58
|
+
? { integrity: dist.integrity }
|
|
59
|
+
: {}),
|
|
60
|
+
...(typeof dist.shasum === "string" && dist.shasum !== "" ? { shasum: dist.shasum } : {}),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async function packedHashes(root, env) {
|
|
64
|
+
const context = "Cannot pack the fab for the npm target";
|
|
65
|
+
const result = await tryNpm(["pack", root, "--dry-run", "--json", "--ignore-scripts"], env);
|
|
66
|
+
if (!result.ok) {
|
|
67
|
+
throw publishError(`${context}: ${npmMessage(result)}`, "publish-npm-failed", ExitCode.Failed);
|
|
68
|
+
}
|
|
69
|
+
const parsed = parseJson(result.stdout, context);
|
|
70
|
+
const manifest = Array.isArray(parsed) ? parsed[0] : undefined;
|
|
71
|
+
if (!isRecord(manifest)) {
|
|
72
|
+
throw publishError(`${context}: npm pack returned no package`, "publish-npm-failed", ExitCode.Failed);
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
...(typeof manifest.integrity === "string" ? { integrity: manifest.integrity } : {}),
|
|
76
|
+
...(typeof manifest.shasum === "string" ? { shasum: manifest.shasum } : {}),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
async function publishedHashes(name, version, env) {
|
|
80
|
+
const context = `Cannot read npm package "${name}@${version}"`;
|
|
81
|
+
const result = await tryNpm(["view", `${name}@${version}`, "--json"], env);
|
|
82
|
+
if (!result.ok) {
|
|
83
|
+
throw publishError(`${context}: ${npmMessage(result)}`, "publish-npm-failed", ExitCode.FetchFailed);
|
|
84
|
+
}
|
|
85
|
+
const parsed = parseJson(result.stdout, context);
|
|
86
|
+
if (!isRecord(parsed) || !isRecord(parsed.dist)) {
|
|
87
|
+
throw publishError(`${context}: npm returned an unexpected response`, "publish-npm-failed", ExitCode.Failed);
|
|
88
|
+
}
|
|
89
|
+
return manifestHashes(parsed.dist);
|
|
90
|
+
}
|
|
91
|
+
function sameContent(published, packed) {
|
|
92
|
+
// Integrity covers the tarball bytes that the registry stores. A registry
|
|
93
|
+
// that reports only a SHA-1 shasum is compared on that instead.
|
|
94
|
+
if (published.integrity !== undefined)
|
|
95
|
+
return published.integrity === packed.integrity;
|
|
96
|
+
if (published.shasum !== undefined)
|
|
97
|
+
return published.shasum === packed.shasum;
|
|
98
|
+
// Nothing to compare with: an existing version can never be proven identical.
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Whether `name@version` is on the registry, and if so whether it carries the
|
|
103
|
+
* same tarball as the staged fab would. A 404 means the version is new.
|
|
104
|
+
*/
|
|
105
|
+
export async function npmVersionState(publish, version, root, options = {}) {
|
|
106
|
+
if (publish.name === undefined) {
|
|
107
|
+
throw publishError("The npm target requires publish.name.", "publish-missing-setting", ExitCode.Failed);
|
|
108
|
+
}
|
|
109
|
+
const env = options.env ?? process.env;
|
|
110
|
+
const context = `Cannot check npm package "${publish.name}@${version}"`;
|
|
111
|
+
const viewed = await tryNpm(["view", `${publish.name}@${version}`, "version", "--json"], env);
|
|
112
|
+
if (!viewed.ok) {
|
|
113
|
+
if (notFound(viewed))
|
|
114
|
+
return { exists: false, identical: false };
|
|
115
|
+
throw publishError(`${context}: ${npmMessage(viewed)}`, "publish-npm-failed", ExitCode.FetchFailed);
|
|
116
|
+
}
|
|
117
|
+
const [published, packed] = await Promise.all([
|
|
118
|
+
publishedHashes(publish.name, version, env),
|
|
119
|
+
packedHashes(root, env),
|
|
120
|
+
]);
|
|
121
|
+
return { exists: true, identical: sameContent(published, packed) };
|
|
122
|
+
}
|
|
123
|
+
function forward(stream, onText, collect) {
|
|
124
|
+
stream?.on("data", (chunk) => {
|
|
125
|
+
const text = chunk.toString();
|
|
126
|
+
collect(text);
|
|
127
|
+
onText(text);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
async function publishNpm(args, env, onText) {
|
|
131
|
+
const npm = await npmInvocation({ env });
|
|
132
|
+
let stdout = "";
|
|
133
|
+
let stderr = "";
|
|
134
|
+
await new Promise((resolve, reject) => {
|
|
135
|
+
const child = execFile(npm.command, [...npm.args, ...args], { env, encoding: "utf8", maxBuffer: MAX_OUTPUT, windowsHide: true }, (error) => {
|
|
136
|
+
if (error === null)
|
|
137
|
+
resolve();
|
|
138
|
+
else
|
|
139
|
+
reject(Object.assign(error, { stdout, stderr }));
|
|
140
|
+
});
|
|
141
|
+
forward(child.stdout, onText, (text) => {
|
|
142
|
+
stdout += text;
|
|
143
|
+
});
|
|
144
|
+
forward(child.stderr, onText, (text) => {
|
|
145
|
+
stderr += text;
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/** `npm publish` in the staging directory, streaming its output to the report's stderr. */
|
|
150
|
+
export async function publishNpmFab(publish, version, root, options = {}) {
|
|
151
|
+
if (publish.name === undefined) {
|
|
152
|
+
throw publishError("The npm target requires publish.name.", "publish-missing-setting", ExitCode.Failed);
|
|
153
|
+
}
|
|
154
|
+
const env = options.env ?? process.env;
|
|
155
|
+
const onText = options.stderr ?? ((text) => process.stderr.write(text));
|
|
156
|
+
const args = ["publish", root, "--access", publish.access ?? "public", "--ignore-scripts"];
|
|
157
|
+
if (options.tag !== undefined)
|
|
158
|
+
args.push("--tag", options.tag);
|
|
159
|
+
if (provenanceEnabled(env))
|
|
160
|
+
args.push("--provenance");
|
|
161
|
+
try {
|
|
162
|
+
await publishNpm(args, env, onText);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
const detail = npmMessage(error);
|
|
166
|
+
throw publishError(`Cannot publish ${publish.name}@${version}: ${detail}`, "publish-npm-failed", ExitCode.Failed, error);
|
|
167
|
+
}
|
|
168
|
+
return `Published ${publish.name}@${version} to npm${options.tag === undefined ? "" : ` with tag ${options.tag}`}.`;
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=npm-target.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm-target.js","sourceRoot":"","sources":["../../../src/core/publish/npm-target.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAepD,MAAM,UAAU,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEpC,SAAS,UAAU,CAAC,OAAmB;IACrC,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;IACpG,MAAM,KAAK,GAAG,GAAG;SACd,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;SACpE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,yCAAyC,CAAC,CAAC,CAAC;IAChG,OAAO,KAAK,CAAC,IAA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AAI,OAAO,CAAC,GAAG,CAAC;IACvC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhF,MAAM,IAAI,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,MAAM,IAAI,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IAC3F,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS;QAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC/D,IAAI,iBAAiB,CAAC,GAAG,CAAC;QAAE,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAEtD,IAAI,CAAC;QACH,MAAM,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,UAAU,CAAC,KAAmB,CAAC,CAAC;QAC/C,MAAM,YAAY,CAChB,kBAAkB,OAAO,CAAC,IAAI,IAAI,OAAO,KAAK,MAAM,EAAE,EACtD,oBAAoB,EACpB,QAAQ,CAAC,MAAM,EACf,KAAK,CACN,CAAC;IACJ,CAAC;IAED,OAAO,aAAa,OAAO,CAAC,IAAI,IAAI,OAAO,UAAU,OAAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;AACtH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { PublishConfig } from "../config/types.js";
|
|
2
|
+
import type { Factory } from "../factory/index.js";
|
|
3
|
+
export declare const FAB_KEYWORD = "metafab";
|
|
4
|
+
export declare const FAB_FILES: readonly [".factory", "README.md"];
|
|
5
|
+
export interface FabPackageJson {
|
|
6
|
+
name: string;
|
|
7
|
+
version: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
keywords: string[];
|
|
10
|
+
files: string[];
|
|
11
|
+
/** Named by a provenance bundle, when CI supplies it. */
|
|
12
|
+
repository?: string;
|
|
13
|
+
metafab: {
|
|
14
|
+
format: 1;
|
|
15
|
+
};
|
|
16
|
+
license?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The repository a provenance bundle names. npm requires `repository` in the
|
|
20
|
+
* `package.json` to match the bundle, so when CI can attest provenance the
|
|
21
|
+
* repository comes from the same environment. Version 1 has no
|
|
22
|
+
* `publish.repository` setting, so detection is the only source.
|
|
23
|
+
*/
|
|
24
|
+
export declare function provenanceRepository(env?: NodeJS.ProcessEnv): string | undefined;
|
|
25
|
+
/** `metafab` first, then `publish.keywords`, without empty values or duplicates. */
|
|
26
|
+
export declare function keywordsFor(publish: PublishConfig): string[];
|
|
27
|
+
/**
|
|
28
|
+
* The npm `package.json` for a fab. `files` and `metafab.format` are fixed by
|
|
29
|
+
* the fab layout, so they are not configurable.
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildPackageJson(factory: Factory, publish: PublishConfig, env?: NodeJS.ProcessEnv): FabPackageJson;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ExitCode, MetafabError } from "../../errors.js";
|
|
2
|
+
import { provenanceEnabled } from "./provenance.js";
|
|
3
|
+
export const FAB_KEYWORD = "metafab";
|
|
4
|
+
export const FAB_FILES = [".factory", "README.md"];
|
|
5
|
+
function nonEmpty(value) {
|
|
6
|
+
const trimmed = value?.trim();
|
|
7
|
+
return trimmed === undefined || trimmed === "" ? undefined : trimmed;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The repository a provenance bundle names. npm requires `repository` in the
|
|
11
|
+
* `package.json` to match the bundle, so when CI can attest provenance the
|
|
12
|
+
* repository comes from the same environment. Version 1 has no
|
|
13
|
+
* `publish.repository` setting, so detection is the only source.
|
|
14
|
+
*/
|
|
15
|
+
export function provenanceRepository(env = process.env) {
|
|
16
|
+
if (!provenanceEnabled(env))
|
|
17
|
+
return undefined;
|
|
18
|
+
const slug = nonEmpty(env.GITHUB_REPOSITORY);
|
|
19
|
+
if (slug !== undefined) {
|
|
20
|
+
const server = nonEmpty(env.GITHUB_SERVER_URL)?.replace(/\/+$/, "") ?? "https://github.com";
|
|
21
|
+
return `${server}/${slug}`;
|
|
22
|
+
}
|
|
23
|
+
return nonEmpty(env.CI_PROJECT_URL)?.replace(/\/+$/, "");
|
|
24
|
+
}
|
|
25
|
+
function missingSetting(key) {
|
|
26
|
+
return new MetafabError(`The npm target requires "${key}".`, {
|
|
27
|
+
exitCode: ExitCode.Failed,
|
|
28
|
+
code: "publish-missing-setting",
|
|
29
|
+
problems: [
|
|
30
|
+
{
|
|
31
|
+
level: "error",
|
|
32
|
+
file: ".factory/metafab.yaml",
|
|
33
|
+
message: `The npm target requires "${key}".`,
|
|
34
|
+
fix: `Add "${key}" to the publish section`,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** `metafab` first, then `publish.keywords`, without empty values or duplicates. */
|
|
40
|
+
export function keywordsFor(publish) {
|
|
41
|
+
const seen = new Set();
|
|
42
|
+
const keywords = [];
|
|
43
|
+
for (const keyword of [FAB_KEYWORD, ...(publish.keywords ?? [])]) {
|
|
44
|
+
const value = keyword.trim();
|
|
45
|
+
if (value === "" || seen.has(value))
|
|
46
|
+
continue;
|
|
47
|
+
seen.add(value);
|
|
48
|
+
keywords.push(value);
|
|
49
|
+
}
|
|
50
|
+
return keywords;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The npm `package.json` for a fab. `files` and `metafab.format` are fixed by
|
|
54
|
+
* the fab layout, so they are not configurable.
|
|
55
|
+
*/
|
|
56
|
+
export function buildPackageJson(factory, publish, env = process.env) {
|
|
57
|
+
if (publish.name === undefined)
|
|
58
|
+
throw missingSetting("publish.name");
|
|
59
|
+
if (publish.version === undefined)
|
|
60
|
+
throw missingSetting("publish.version");
|
|
61
|
+
const description = publish.description ?? factory.factoryYaml?.description;
|
|
62
|
+
const repository = provenanceRepository(env);
|
|
63
|
+
return {
|
|
64
|
+
name: publish.name,
|
|
65
|
+
version: publish.version,
|
|
66
|
+
...(description === undefined ? {} : { description }),
|
|
67
|
+
keywords: keywordsFor(publish),
|
|
68
|
+
files: [...FAB_FILES],
|
|
69
|
+
...(repository === undefined ? {} : { repository }),
|
|
70
|
+
metafab: { format: factory.factoryYaml?.format ?? 1 },
|
|
71
|
+
...(publish.license === undefined ? {} : { license: publish.license }),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=package-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-json.js","sourceRoot":"","sources":["../../../src/core/publish/package-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AACrC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,UAAU,EAAE,WAAW,CAAU,CAAC;AAc5D,SAAS,QAAQ,CAAC,KAAyB;IACzC,MAAM,OAAO,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IAC9B,OAAO,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAG,GAAsB,OAAO,CAAC,GAAG;IACvE,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IAE9C,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;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AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAgB,EAChB,OAAsB,EACtB,GAAG,GAAsB,OAAO,CAAC,GAAG;IAEpC,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;QAAE,MAAM,cAAc,CAAC,cAAc,CAAC,CAAC;IACrE,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS;QAAE,MAAM,cAAc,CAAC,iBAAiB,CAAC,CAAC;IAE3E,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC;IAC5E,MAAM,UAAU,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;IAE7C,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;QACrD,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC;QAC9B,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;QACrB,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;QACnD,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,MAAM,IAAI,CAAC,EAAE;QACrD,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;KACvE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Config, PublishConfig } from "../config/types.js";
|
|
2
|
+
import type { Factory } from "../factory/index.js";
|
|
3
|
+
import type { PreparedFab, PublishTargetName } from "./types.js";
|
|
4
|
+
/** A `publish` section that has a version and at least one target. */
|
|
5
|
+
export type ValidPublishConfig = PublishConfig & {
|
|
6
|
+
version: string;
|
|
7
|
+
};
|
|
8
|
+
/** The targets a `publish` section enables: `name` adds npm, `git` adds Git. */
|
|
9
|
+
export declare function publishTargets(publish: PublishConfig): PublishTargetName[];
|
|
10
|
+
/**
|
|
11
|
+
* The `publish` section a publish needs, or the problems to report instead.
|
|
12
|
+
* The command checks it before it runs anything else, and `prepareFab` uses the
|
|
13
|
+
* same function, so both report the same problems.
|
|
14
|
+
*/
|
|
15
|
+
export declare function requirePublishConfig(config: Config): ValidPublishConfig;
|
|
16
|
+
/**
|
|
17
|
+
* Builds the complete fab in a temporary directory: the staged `.factory/`,
|
|
18
|
+
* the README at the root and, for the npm target, `package.json`. It publishes
|
|
19
|
+
* nothing, so `--dry-run` and the real run report from the same data.
|
|
20
|
+
*
|
|
21
|
+
* `files` and `size` describe what the npm package holds when npm is a target
|
|
22
|
+
* (`package.json` included) and what the Git fab holds otherwise.
|
|
23
|
+
*/
|
|
24
|
+
export declare function prepareFab(factory: Factory, config: Config): Promise<PreparedFab>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { stat, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { ExitCode, MetafabError } from "../../errors.js";
|
|
4
|
+
import { listFiles } from "../../util/fs.js";
|
|
5
|
+
import { buildPackageJson } from "./package-json.js";
|
|
6
|
+
import { resolveReadme } from "./readme.js";
|
|
7
|
+
import { stageFab } from "./stage.js";
|
|
8
|
+
const CONFIG_FILE = ".factory/metafab.yaml";
|
|
9
|
+
function publishProblem(message, fix) {
|
|
10
|
+
return {
|
|
11
|
+
level: "error",
|
|
12
|
+
file: CONFIG_FILE,
|
|
13
|
+
message,
|
|
14
|
+
fix,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** The targets a `publish` section enables: `name` adds npm, `git` adds Git. */
|
|
18
|
+
export function publishTargets(publish) {
|
|
19
|
+
const targets = [];
|
|
20
|
+
if (publish.name !== undefined)
|
|
21
|
+
targets.push("npm");
|
|
22
|
+
if (publish.git !== undefined)
|
|
23
|
+
targets.push("git");
|
|
24
|
+
return targets;
|
|
25
|
+
}
|
|
26
|
+
async function fabFileSize(root, file) {
|
|
27
|
+
return (await stat(path.join(root, ...file.split("/")))).size;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The `publish` section a publish needs, or the problems to report instead.
|
|
31
|
+
* The command checks it before it runs anything else, and `prepareFab` uses the
|
|
32
|
+
* same function, so both report the same problems.
|
|
33
|
+
*/
|
|
34
|
+
export function requirePublishConfig(config) {
|
|
35
|
+
const publish = config.publish;
|
|
36
|
+
if (publish === undefined) {
|
|
37
|
+
throw new MetafabError('"publish" is not configured.', {
|
|
38
|
+
exitCode: ExitCode.Failed,
|
|
39
|
+
code: "publish-not-configured",
|
|
40
|
+
problems: [
|
|
41
|
+
publishProblem('The configuration has no "publish" section.', 'Add a "publish" section with "version" and "name" or "git"'),
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (publishTargets(publish).length === 0) {
|
|
46
|
+
throw new MetafabError('"publish" names no target.', {
|
|
47
|
+
exitCode: ExitCode.Failed,
|
|
48
|
+
code: "publish-no-target",
|
|
49
|
+
problems: [
|
|
50
|
+
publishProblem('"publish" requires "name" or "git".', 'Add "name" for npm or "git" for a fab repository'),
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (publish.version === undefined) {
|
|
55
|
+
throw new MetafabError('"publish.version" is required.', {
|
|
56
|
+
exitCode: ExitCode.Failed,
|
|
57
|
+
code: "publish-missing-setting",
|
|
58
|
+
problems: [publishProblem('"publish.version" is required.', 'Add "version" to "publish"')],
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return publish;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Builds the complete fab in a temporary directory: the staged `.factory/`,
|
|
65
|
+
* the README at the root and, for the npm target, `package.json`. It publishes
|
|
66
|
+
* nothing, so `--dry-run` and the real run report from the same data.
|
|
67
|
+
*
|
|
68
|
+
* `files` and `size` describe what the npm package holds when npm is a target
|
|
69
|
+
* (`package.json` included) and what the Git fab holds otherwise.
|
|
70
|
+
*/
|
|
71
|
+
export async function prepareFab(factory, config) {
|
|
72
|
+
const publish = requirePublishConfig(config);
|
|
73
|
+
const targets = publishTargets(publish);
|
|
74
|
+
const staged = await stageFab(factory, { exclude: publish.exclude, targets });
|
|
75
|
+
try {
|
|
76
|
+
const readme = await resolveReadme(factory.root, factory, publish, staged.factory);
|
|
77
|
+
await writeFile(path.join(staged.root, "README.md"), readme, "utf8");
|
|
78
|
+
if (targets.includes("npm")) {
|
|
79
|
+
const packageJson = `${JSON.stringify(buildPackageJson(factory, publish), null, 2)}\n`;
|
|
80
|
+
await writeFile(path.join(staged.root, "package.json"), packageJson, "utf8");
|
|
81
|
+
}
|
|
82
|
+
const files = await listFiles(staged.root);
|
|
83
|
+
let size = 0;
|
|
84
|
+
for (const file of files)
|
|
85
|
+
size += await fabFileSize(staged.root, file);
|
|
86
|
+
return { ...staged, files, size, targets };
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
await staged.cleanup();
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=prepare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../../src/core/publish/prepare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EA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AE,CAAC,CAAC,IAAI,CAAC;YACvF,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QAC/E,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,IAAI,IAAI,MAAM,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEvE,OAAO,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC7C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACvB,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function provenanceEnabled(env?: NodeJS.ProcessEnv): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* npm can attach provenance only where the CI system hands it an OIDC token:
|
|
3
|
+
* GitHub Actions through `ACTIONS_ID_TOKEN_REQUEST_URL`, GitLab CI through
|
|
4
|
+
* `SIGSTORE_ID_TOKEN`. v1 detects the bundle and never overrides it with a flag
|
|
5
|
+
* (plan 1.011, open question 2).
|
|
6
|
+
*/
|
|
7
|
+
function enabled(value) {
|
|
8
|
+
if (value === undefined)
|
|
9
|
+
return false;
|
|
10
|
+
const normalized = value.trim().toLowerCase();
|
|
11
|
+
return normalized !== "" && normalized !== "false" && normalized !== "0";
|
|
12
|
+
}
|
|
13
|
+
export function provenanceEnabled(env = process.env) {
|
|
14
|
+
if (enabled(env.GITHUB_ACTIONS) && enabled(env.ACTIONS_ID_TOKEN_REQUEST_URL))
|
|
15
|
+
return true;
|
|
16
|
+
if (enabled(env.GITLAB_CI) && enabled(env.SIGSTORE_ID_TOKEN))
|
|
17
|
+
return true;
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=provenance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provenance.js","sourceRoot":"","sources":["../../../src/core/publish/provenance.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,SAAS,OAAO,CAAC,KAAyB;IACxC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,OAAO,UAAU,KAAK,EAAE,IAAI,UAAU,KAAK,OAAO,IAAI,UAAU,KAAK,GAAG,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAG,GAAsB,OAAO,CAAC,GAAG;IACpE,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1F,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1E,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PublishConfig } from "../config/types.js";
|
|
2
|
+
import type { PreparedFab, PublishOptions, PublishResult } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Publishes one prepared fab to every configured target.
|
|
5
|
+
*
|
|
6
|
+
* The version preflight runs for every target before anything is published: a
|
|
7
|
+
* version that exists with different content refuses the whole publish, while a
|
|
8
|
+
* version that exists with identical content is skipped. A target failure is
|
|
9
|
+
* reported in its result and the remaining targets are not attempted; a failure
|
|
10
|
+
* that names problems, or asks for an exit code other than 1, carries both back
|
|
11
|
+
* so the command reports them.
|
|
12
|
+
*/
|
|
13
|
+
export declare function publishFab(prepared: PreparedFab, publish: PublishConfig, options?: PublishOptions): Promise<PublishResult>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ExitCode, MetafabError } from "../../errors.js";
|
|
2
|
+
import { gitVersionState, publishGitFab } from "./git-target.js";
|
|
3
|
+
import { npmVersionState, publishNpmFab } from "./npm-target.js";
|
|
4
|
+
/**
|
|
5
|
+
* Publish order. Git goes first because its push is atomic and its preflight is
|
|
6
|
+
* the strongest, so a half-published release can be finished by a re-run that
|
|
7
|
+
* skips the target already carrying these bytes (plan 1.011, open question 1).
|
|
8
|
+
*/
|
|
9
|
+
const PUBLISH_ORDER = ["git", "npm"];
|
|
10
|
+
function versionConflict(target, version) {
|
|
11
|
+
const label = target === "npm" ? "npm" : "Git fab repository";
|
|
12
|
+
return new MetafabError(`Version ${version} is already published to ${label} with different content.`, {
|
|
13
|
+
exitCode: ExitCode.Failed,
|
|
14
|
+
code: "publish-version-exists",
|
|
15
|
+
problems: [
|
|
16
|
+
{
|
|
17
|
+
level: "error",
|
|
18
|
+
file: ".factory/metafab.yaml",
|
|
19
|
+
message: `The ${label} already has ${version} with different content.`,
|
|
20
|
+
fix: "Bump publish.version; a published version cannot change",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function skippedDetail(target, version) {
|
|
26
|
+
return target === "npm"
|
|
27
|
+
? `${version} is already on npm with identical content.`
|
|
28
|
+
: `v${version} is already in the fab repository with identical content.`;
|
|
29
|
+
}
|
|
30
|
+
/** How many of a failure's paths its target detail names; the problems carry all. */
|
|
31
|
+
const DETAIL_PATHS = 3;
|
|
32
|
+
function failureDetail(error) {
|
|
33
|
+
const message = error instanceof Error && error.message.trim() !== "" ? error.message.trim() : String(error);
|
|
34
|
+
if (!(error instanceof MetafabError))
|
|
35
|
+
return message;
|
|
36
|
+
const files = [...new Set((error.problems ?? []).map((problem) => problem.file))];
|
|
37
|
+
if (files.length === 0)
|
|
38
|
+
return message;
|
|
39
|
+
if (files.length === 1)
|
|
40
|
+
return `${message} (${files[0]})`;
|
|
41
|
+
// A failed list may name thousands of paths; the reported problems carry
|
|
42
|
+
// every one, so the detail only counts them and shows the first few.
|
|
43
|
+
const shown = files.slice(0, DETAIL_PATHS).join(", ");
|
|
44
|
+
const more = files.length > DETAIL_PATHS ? ` and ${files.length - DETAIL_PATHS} more` : "";
|
|
45
|
+
return `${message} (${files.length} paths: ${shown}${more})`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Publishes one prepared fab to every configured target.
|
|
49
|
+
*
|
|
50
|
+
* The version preflight runs for every target before anything is published: a
|
|
51
|
+
* version that exists with different content refuses the whole publish, while a
|
|
52
|
+
* version that exists with identical content is skipped. A target failure is
|
|
53
|
+
* reported in its result and the remaining targets are not attempted; a failure
|
|
54
|
+
* that names problems, or asks for an exit code other than 1, carries both back
|
|
55
|
+
* so the command reports them.
|
|
56
|
+
*/
|
|
57
|
+
export async function publishFab(prepared, publish, options = {}) {
|
|
58
|
+
const version = publish.version;
|
|
59
|
+
if (version === undefined) {
|
|
60
|
+
throw new MetafabError('"publish.version" is required.', {
|
|
61
|
+
exitCode: ExitCode.Failed,
|
|
62
|
+
code: "publish-missing-setting",
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const context = {
|
|
66
|
+
...options,
|
|
67
|
+
interactive: options.interactive ?? (process.stdin.isTTY === true && options.json !== true),
|
|
68
|
+
};
|
|
69
|
+
const targets = PUBLISH_ORDER.filter((target) => prepared.targets.includes(target));
|
|
70
|
+
const existing = new Map();
|
|
71
|
+
for (const target of targets) {
|
|
72
|
+
if (target === "git") {
|
|
73
|
+
const state = await gitVersionState(publish, version, prepared.root, context);
|
|
74
|
+
if (state.tagExists && !state.identical)
|
|
75
|
+
throw versionConflict("git", version);
|
|
76
|
+
existing.set(target, state.tagExists ? "identical" : "new");
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const state = await npmVersionState(publish, version, prepared.root, context);
|
|
80
|
+
if (state.exists && !state.identical)
|
|
81
|
+
throw versionConflict("npm", version);
|
|
82
|
+
existing.set(target, state.exists ? "identical" : "new");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const results = new Map();
|
|
86
|
+
let failed;
|
|
87
|
+
const problems = [];
|
|
88
|
+
let exitCode;
|
|
89
|
+
for (const target of targets) {
|
|
90
|
+
if (existing.get(target) === "identical") {
|
|
91
|
+
results.set(target, { target, status: "skipped", detail: skippedDetail(target, version) });
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (failed !== undefined) {
|
|
95
|
+
results.set(target, {
|
|
96
|
+
target,
|
|
97
|
+
status: "skipped",
|
|
98
|
+
detail: `Not attempted: the ${failed} target failed.`,
|
|
99
|
+
});
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
const detail = target === "git"
|
|
104
|
+
? await publishGitFab(publish, version, prepared.root, context)
|
|
105
|
+
: await publishNpmFab(publish, version, prepared.root, context);
|
|
106
|
+
results.set(target, { target, status: "published", detail });
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
// Head protection is a refusal the command must report with its own exit
|
|
110
|
+
// code, and it happens before this target changes anything.
|
|
111
|
+
if (error instanceof MetafabError && error.exitCode === ExitCode.NotOwned)
|
|
112
|
+
throw error;
|
|
113
|
+
// A target that names its problems, such as the files Git lost, keeps
|
|
114
|
+
// them: the command reports them and exits with the target's code.
|
|
115
|
+
if (error instanceof MetafabError) {
|
|
116
|
+
problems.push(...(error.problems ?? []));
|
|
117
|
+
exitCode = error.exitCode;
|
|
118
|
+
}
|
|
119
|
+
results.set(target, { target, status: "failed", detail: failureDetail(error) });
|
|
120
|
+
failed = target;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
version,
|
|
125
|
+
targets: prepared.targets.map((target) => results.get(target)),
|
|
126
|
+
...(problems.length === 0 ? {} : { problems }),
|
|
127
|
+
...(exitCode === undefined ? {} : { exitCode }),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=publish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../src/core/publish/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGzD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AASjE;;;;GAIG;AACH,MAAM,aAAa,GAAwB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAE1D,SAAS,eAAe,CAAC,MAAyB,EAAE,OAAe;IACjE,MAAM,KAAK,GAAG,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,oBAAoB,CAAC;IAC9D,OAAO,IAAI,YAAY,CAAC,WAAW,OAAO,4BAA4B,KAAK,0BAA0B,EAAE;QACrG,QAAQ,EAAE,QAAQ,CAAC,MAAM;QACzB,IAAI,EAAE,wBAAwB;QAC9B,QAAQ,EAAE;YACR;gBACE,KAAK,EAAE,OAAO;gBACd,IAAI,EAAE,uBAAuB;gBAC7B,OAAO,EAAE,OAAO,KAAK,gBAAgB,OAAO,0BAA0B;gBACtE,GAAG,EAAE,yDAAyD;aAC/D;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,aAAa,CAAC,MAAyB,EAAE,OAAe;IAC/D,OAAO,MAAM,KAAK,KAAK;QACrB,CAAC,CAAC,GAAG,OAAO,4CAA4C;QACxD,CAAC,CAAC,IAAI,OAAO,2DAA2D,CAAC;AAC7E,CAAC;AAED,qFAAqF;AACrF,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB,SAAS,aAAa,CAAC,KAAc;IACnC,MAA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,QAAQ,CAAC,QAAQ;gBAAE,MAAM,KAAK,CAAC;YACvF,sEAAsE;YACtE,mEAAmE;YACnE,IAAI,KAAK,YAAY,YAAY,EAAE,CAAC;gBAClC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC;gBACzC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;YAC5B,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAChF,MAAM,GAAG,MAAM,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO;QACP,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAC3B,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAwB,CACvD;QACD,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;QAC9C,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;KAChD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PublishConfig } from "../config/types.js";
|
|
2
|
+
import type { Factory } from "../factory/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* The source an importer names: the npm package when there is one, else the Git
|
|
5
|
+
* URL without credentials, in the form `import` accepts (`https://` and
|
|
6
|
+
* `file://` gain `git+`). The README is published, so a token in `publish.git`
|
|
7
|
+
* must never reach it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function publishSource(publish: PublishConfig): string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* The README written when a project has neither `publish.readme` nor
|
|
12
|
+
* `.factory/README.md`: what the factory is, how it runs and how to import it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function generateReadme(factory: Factory, publish: PublishConfig): string;
|
|
15
|
+
/**
|
|
16
|
+
* The README at the fab root: `publish.readme`, else `.factory/README.md`, else
|
|
17
|
+
* a generated one. `.factory/README.md` is never copied into the fab itself.
|
|
18
|
+
*
|
|
19
|
+
* The generated README describes `published`, the staged factory, so a name or
|
|
20
|
+
* description that `publish.exclude` removes is not published.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveReadme(repositoryRoot: string, factory: Factory, publish: PublishConfig, published?: Factory): Promise<string>;
|