@kungfu-tech/buildchain 3.0.4-alpha.5 → 3.0.4-alpha.7
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/AGENTS.md +14 -5
- package/dist/site/buildchain-contract.json +4 -4
- package/dist/site/buildchain-site.json +13 -13
- package/dist/site/kfd-claims.json +2 -2
- package/dist/site/kfd-upstream-aggregate.json +1 -1
- package/dist/site/manual-registry.json +3 -3
- package/dist/site/node-api-registry.json +17 -17
- package/dist/site/page-registry.json +6 -6
- package/dist/site/public-surface-audit.json +1 -1
- package/dist/site/publication-registry.json +4 -4
- package/dist/site/site-manifest.json +7 -7
- package/docs/cli.md +2 -1
- package/docs/install.md +7 -8
- package/docs/node-api-reference.md +36 -36
- package/package.json +1 -1
- package/packages/core/paper-agent-entry.js +8 -4
- package/packages/core/paper-repository.js +1 -0
- package/packages/core/paper.js +72 -0
package/packages/core/paper.js
CHANGED
|
@@ -113,6 +113,7 @@ const PAPER_SCAFFOLD_PATHS = Object.freeze([
|
|
|
113
113
|
PAPER_PATHS.buildWorkflow,
|
|
114
114
|
PAPER_PATHS.verifyWorkflow,
|
|
115
115
|
PAPER_PATHS.releaseWorkflow,
|
|
116
|
+
PAPER_PATHS.pnpmWorkspace,
|
|
116
117
|
PAPER_PATHS.provisioningAuthority,
|
|
117
118
|
"Makefile",
|
|
118
119
|
"package.json",
|
|
@@ -134,6 +135,7 @@ const DEFAULT_TOOLCHAIN_COMMAND = "latexmk -pdf -outdir=_build paper/main.tex";
|
|
|
134
135
|
const SHA256_PATTERN = /^sha256:[0-9a-f]{64}$/i;
|
|
135
136
|
const GIT_SHA_PATTERN = /^[0-9a-f]{40}$/i;
|
|
136
137
|
const PACKAGE_PATTERN = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i;
|
|
138
|
+
const BUILDCHAIN_PACKAGE_NAME = "@kungfu-tech/buildchain";
|
|
137
139
|
|
|
138
140
|
function toPosix(value) {
|
|
139
141
|
return String(value || "")
|
|
@@ -149,6 +151,66 @@ function jsonText(value) {
|
|
|
149
151
|
return `${JSON.stringify(value, null, 2)}\n`;
|
|
150
152
|
}
|
|
151
153
|
|
|
154
|
+
function paperPnpmWorkspace(current, buildchainVersion) {
|
|
155
|
+
const entry = `${BUILDCHAIN_PACKAGE_NAME}@${buildchainVersion}`;
|
|
156
|
+
const source = String(current || "");
|
|
157
|
+
const lines = source ? source.replace(/\r\n/g, "\n").split("\n") : [];
|
|
158
|
+
if (lines.at(-1) === "") lines.pop();
|
|
159
|
+
const keyLines = lines
|
|
160
|
+
.map((line, index) =>
|
|
161
|
+
/^minimumReleaseAgeExclude:\s*(?:#.*)?$/.test(line) ? index : -1,
|
|
162
|
+
)
|
|
163
|
+
.filter((index) => index >= 0);
|
|
164
|
+
const unsupportedKey = lines.some(
|
|
165
|
+
(line) =>
|
|
166
|
+
/^minimumReleaseAgeExclude\s*:/.test(line) &&
|
|
167
|
+
!/^minimumReleaseAgeExclude:\s*(?:#.*)?$/.test(line),
|
|
168
|
+
);
|
|
169
|
+
if (unsupportedKey || keyLines.length > 1) {
|
|
170
|
+
throw new Error(
|
|
171
|
+
"paper migration requires minimumReleaseAgeExclude to be one top-level block sequence",
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
if (keyLines.length === 0) {
|
|
175
|
+
const prefix = lines.length > 0 ? [...lines, ""] : [];
|
|
176
|
+
return `${[...prefix, "minimumReleaseAgeExclude:", ` - '${entry}'`].join(
|
|
177
|
+
"\n",
|
|
178
|
+
)}\n`;
|
|
179
|
+
}
|
|
180
|
+
const keyIndex = keyLines[0];
|
|
181
|
+
let blockEnd = lines.length;
|
|
182
|
+
for (let index = keyIndex + 1; index < lines.length; index += 1) {
|
|
183
|
+
if (/^[^\s#]/.test(lines[index])) {
|
|
184
|
+
blockEnd = index;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const retained = [];
|
|
189
|
+
for (const line of lines.slice(keyIndex + 1, blockEnd)) {
|
|
190
|
+
if (!line.trim() || /^\s*#/.test(line)) {
|
|
191
|
+
retained.push(line);
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const item = line.match(/^\s*-\s+(.+?)\s*(?:#.*)?$/);
|
|
195
|
+
if (!item) {
|
|
196
|
+
throw new Error(
|
|
197
|
+
"paper migration requires minimumReleaseAgeExclude to contain scalar package entries",
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
const value = item[1]
|
|
201
|
+
.trim()
|
|
202
|
+
.replace(/^'(.*)'$/, "$1")
|
|
203
|
+
.replace(/^"(.*)"$/, "$1");
|
|
204
|
+
if (!value.startsWith(`${BUILDCHAIN_PACKAGE_NAME}@`)) retained.push(line);
|
|
205
|
+
}
|
|
206
|
+
return `${[
|
|
207
|
+
...lines.slice(0, keyIndex + 1),
|
|
208
|
+
...retained,
|
|
209
|
+
` - '${entry}'`,
|
|
210
|
+
...lines.slice(blockEnd),
|
|
211
|
+
].join("\n")}\n`;
|
|
212
|
+
}
|
|
213
|
+
|
|
152
214
|
function existingFileFact(cwd, relativePath) {
|
|
153
215
|
const filePath = path.resolve(cwd, relativePath);
|
|
154
216
|
if (!fs.existsSync(filePath) || !fs.statSync(filePath).isFile()) {
|
|
@@ -421,6 +483,7 @@ ${passportInput} secrets:
|
|
|
421
483
|
BUILDCHAIN_GENERATED_WRITE_APP_CLIENT_ID: \${{ secrets.BUILDCHAIN_GENERATED_WRITE_APP_CLIENT_ID }}
|
|
422
484
|
BUILDCHAIN_GENERATED_WRITE_APP_PRIVATE_KEY: \${{ secrets.BUILDCHAIN_GENERATED_WRITE_APP_PRIVATE_KEY }}
|
|
423
485
|
BUILDCHAIN_GENERATED_WRITE_TOKEN: \${{ secrets.BUILDCHAIN_GENERATED_WRITE_TOKEN }}
|
|
486
|
+
BUILDCHAIN_PROMOTION_TOKEN: \${{ secrets.BUILDCHAIN_PROMOTION_TOKEN }}
|
|
424
487
|
`;
|
|
425
488
|
}
|
|
426
489
|
|
|
@@ -603,6 +666,7 @@ function scaffoldFiles({
|
|
|
603
666
|
[PAPER_PATHS.buildWorkflow, buildWorkflow],
|
|
604
667
|
[PAPER_PATHS.verifyWorkflow, verifyWorkflow],
|
|
605
668
|
[PAPER_PATHS.releaseWorkflow, releaseWorkflow],
|
|
669
|
+
[PAPER_PATHS.pnpmWorkspace, paperPnpmWorkspace("", buildchainVersion)],
|
|
606
670
|
[PAPER_PATHS.provisioningAuthority, jsonText(provisioningAuthority)],
|
|
607
671
|
...agentEntry,
|
|
608
672
|
[
|
|
@@ -924,12 +988,20 @@ function migrationFiles({
|
|
|
924
988
|
currentPackage.value,
|
|
925
989
|
runtimeIdentity.version,
|
|
926
990
|
);
|
|
991
|
+
const pnpmWorkspacePath = path.resolve(cwd, PAPER_PATHS.pnpmWorkspace);
|
|
992
|
+
const pnpmWorkspace = paperPnpmWorkspace(
|
|
993
|
+
fs.existsSync(pnpmWorkspacePath)
|
|
994
|
+
? fs.readFileSync(pnpmWorkspacePath, "utf8")
|
|
995
|
+
: "",
|
|
996
|
+
runtimeIdentity.version,
|
|
997
|
+
);
|
|
927
998
|
const files = new Map([
|
|
928
999
|
[PAPER_PATHS.contractLock, contractLockText],
|
|
929
1000
|
[PAPER_PATHS.versionPin, `${runtimeIdentity.version}\n`],
|
|
930
1001
|
[PAPER_PATHS.buildWorkflow, buildWorkflow],
|
|
931
1002
|
[PAPER_PATHS.verifyWorkflow, verifyWorkflow],
|
|
932
1003
|
[PAPER_PATHS.releaseWorkflow, releaseWorkflow],
|
|
1004
|
+
[PAPER_PATHS.pnpmWorkspace, pnpmWorkspace],
|
|
933
1005
|
[PAPER_PATHS.provisioningAuthority, jsonText(provisioningAuthority)],
|
|
934
1006
|
...agentEntry,
|
|
935
1007
|
["package.json", jsonText(packageJson)],
|