@kungfu-tech/buildchain 0.0.0-bootstrap.0 → 2.0.13-alpha.10
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 +262 -0
- package/bin/buildchain.mjs +222 -0
- package/docs/cli.md +124 -0
- package/docs/lifecycle-protocol.md +422 -0
- package/docs/publish-transaction.md +285 -0
- package/docs/reusable-build-surface.md +350 -0
- package/docs/web-surface-deployments.md +211 -0
- package/package.json +52 -1
- package/packages/core/README.md +15 -0
- package/packages/core/buildchain-config.js +721 -0
- package/packages/core/index.js +40 -0
- package/packages/core/package-manager.js +291 -0
- package/packages/core/publish-transaction.js +418 -0
- package/packages/core/release-line-dry-run.js +296 -0
- package/scripts/aggregate-build-summary.mjs +88 -0
- package/scripts/build-contract-core.mjs +731 -0
- package/scripts/check-inventory.mjs +325 -0
- package/scripts/init-repo.mjs +316 -0
- package/scripts/npm-publish-dry-run.mjs +176 -0
- package/scripts/npm-publish-transaction.mjs +268 -0
- package/scripts/publish-source-ref-resolver.mjs +113 -0
- package/scripts/release-line-dry-run.mjs +53 -0
- package/scripts/release-line-policy.mjs +141 -0
- package/scripts/release-transaction.mjs +212 -0
- package/scripts/resolve-build-contract.mjs +63 -0
- package/scripts/resolve-publish-gate.mjs +33 -0
- package/scripts/resolve-publish-source.mjs +99 -0
- package/scripts/run-lifecycle-core.mjs +162 -0
- package/scripts/run-lifecycle.mjs +40 -0
- package/scripts/strip-trailing-whitespace.mjs +14 -0
- package/scripts/tsup-action.config.mjs +19 -0
- package/scripts/verify-publish-source-lock.mjs +37 -0
- package/scripts/verify-release-pr.mjs +34 -0
- package/scripts/web-surface-core.mjs +382 -0
- package/scripts/web-surface.mjs +112 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
import {
|
|
6
|
+
defaultWebSurfaceAlias,
|
|
7
|
+
planWebSurfaceCleanup,
|
|
8
|
+
planWebSurfaceDeploy,
|
|
9
|
+
validateWebSurfaceProject,
|
|
10
|
+
} from "./web-surface-core.mjs";
|
|
11
|
+
import { writeGitHubOutputs } from "./build-contract-core.mjs";
|
|
12
|
+
|
|
13
|
+
function readArg(name, fallback = "") {
|
|
14
|
+
const index = process.argv.indexOf(`--${name}`);
|
|
15
|
+
if (index === -1) {
|
|
16
|
+
return fallback;
|
|
17
|
+
}
|
|
18
|
+
return process.argv[index + 1] || "";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function readBooleanArg(name, fallback = true) {
|
|
22
|
+
const value = readArg(name, "");
|
|
23
|
+
if (!value) {
|
|
24
|
+
return fallback;
|
|
25
|
+
}
|
|
26
|
+
return value === "true" || value === "1";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function writeJson(result, outputPath) {
|
|
30
|
+
const json = `${JSON.stringify(result, null, 2)}\n`;
|
|
31
|
+
if (outputPath) {
|
|
32
|
+
fs.mkdirSync(path.dirname(path.resolve(outputPath)), { recursive: true });
|
|
33
|
+
fs.writeFileSync(outputPath, json);
|
|
34
|
+
} else {
|
|
35
|
+
process.stdout.write(json);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function webSurfaceCli() {
|
|
40
|
+
const mode = readArg("mode", process.env.BUILDCHAIN_WEB_SURFACE_MODE || "validate");
|
|
41
|
+
const cwd = readArg("cwd", process.env.BUILDCHAIN_WORKDIR || process.cwd());
|
|
42
|
+
const channel = readArg("channel", process.env.BUILDCHAIN_WEB_SURFACE_CHANNEL || "preview");
|
|
43
|
+
const sourceSha = readArg("source-sha", process.env.BUILDCHAIN_SOURCE_SHA || process.env.GITHUB_SHA || "");
|
|
44
|
+
const pullNumber = readArg("pull-number", process.env.BUILDCHAIN_PULL_NUMBER || "");
|
|
45
|
+
const output = readArg("output", process.env.BUILDCHAIN_WEB_SURFACE_OUTPUT || "");
|
|
46
|
+
|
|
47
|
+
if (mode === "validate") {
|
|
48
|
+
const result = validateWebSurfaceProject(cwd);
|
|
49
|
+
writeJson(result, output);
|
|
50
|
+
writeGitHubOutputs({
|
|
51
|
+
"project-type": result.project?.type || "",
|
|
52
|
+
"web-surface-site": result.project?.site || result.project?.name || "",
|
|
53
|
+
});
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (mode === "deploy-plan" || mode === "manifest") {
|
|
58
|
+
const alias = readArg(
|
|
59
|
+
"alias",
|
|
60
|
+
process.env.BUILDCHAIN_WEB_SURFACE_ALIAS || defaultWebSurfaceAlias({ channel, sourceSha, pullNumber }),
|
|
61
|
+
);
|
|
62
|
+
const result = planWebSurfaceDeploy({
|
|
63
|
+
cwd,
|
|
64
|
+
channel,
|
|
65
|
+
alias,
|
|
66
|
+
sourceSha,
|
|
67
|
+
artifactHash: readArg("artifact-hash", process.env.BUILDCHAIN_WEB_SURFACE_ARTIFACT_HASH || ""),
|
|
68
|
+
artifactPath: readArg("artifact-path", process.env.BUILDCHAIN_WEB_SURFACE_ARTIFACT_PATH || ""),
|
|
69
|
+
dryRun: readBooleanArg("dry-run", true),
|
|
70
|
+
});
|
|
71
|
+
const outputResult = mode === "manifest" ? result.manifest : result;
|
|
72
|
+
writeJson(outputResult, output);
|
|
73
|
+
writeGitHubOutputs({
|
|
74
|
+
"web-surface-channel": result.channel,
|
|
75
|
+
"web-surface-alias": result.alias,
|
|
76
|
+
"web-surface-url": result.url,
|
|
77
|
+
"web-surface-artifact-hash": result.artifact.hash,
|
|
78
|
+
"web-surface-manifest-json": JSON.stringify(result.manifest),
|
|
79
|
+
});
|
|
80
|
+
return outputResult;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (mode === "cleanup-plan") {
|
|
84
|
+
const aliases = readArg("aliases", process.env.BUILDCHAIN_WEB_SURFACE_ALIASES || "")
|
|
85
|
+
.split(",")
|
|
86
|
+
.map((entry) => entry.trim())
|
|
87
|
+
.filter(Boolean);
|
|
88
|
+
const result = planWebSurfaceCleanup({
|
|
89
|
+
cwd,
|
|
90
|
+
channel,
|
|
91
|
+
aliases,
|
|
92
|
+
dryRun: readBooleanArg("dry-run", true),
|
|
93
|
+
});
|
|
94
|
+
writeJson(result, output);
|
|
95
|
+
writeGitHubOutputs({
|
|
96
|
+
"web-surface-cleanup-count": String(result.entries.length),
|
|
97
|
+
"web-surface-cleanup-plan-json": JSON.stringify(result),
|
|
98
|
+
});
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
throw new Error(`unsupported web-surface mode: ${mode}`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
106
|
+
try {
|
|
107
|
+
webSurfaceCli();
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error(`::error::${String(error.message || error).replace(/\r?\n/g, "%0A")}`);
|
|
110
|
+
process.exitCode = 1;
|
|
111
|
+
}
|
|
112
|
+
}
|