@kungfu-tech/buildchain 3.0.4-alpha.7 → 3.0.4-alpha.8

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.
@@ -54,10 +54,7 @@ function legacyBuildchainWorkflowRefs(cwd) {
54
54
  if (!fs.existsSync(workflowRoot)) return [];
55
55
  return fs
56
56
  .readdirSync(workflowRoot, { withFileTypes: true })
57
- .filter(
58
- (entry) =>
59
- entry.isFile() && /\.ya?ml$/i.test(entry.name),
60
- )
57
+ .filter((entry) => entry.isFile() && /\.ya?ml$/i.test(entry.name))
61
58
  .filter((entry) =>
62
59
  /uses:\s*kungfu-systems\/buildchain\/[^\s]+@v2(?:[-.][^\s]+)?/i.test(
63
60
  fs.readFileSync(path.join(workflowRoot, entry.name), "utf8"),
@@ -289,3 +286,28 @@ export function writePaperFleetUpdate(plan) {
289
286
  results,
290
287
  };
291
288
  }
289
+
290
+ export function paperFleetTransitionWorkspace(workspaceText, lockText) {
291
+ const source = String(workspaceText || "");
292
+ if (!/@kungfu-tech\/buildchain@[0-9A-Za-z]/.test(String(lockText || ""))) {
293
+ return source;
294
+ }
295
+ const lines = source.replace(/\r\n/g, "\n").split("\n");
296
+ const keyIndex = lines.findIndex((line) =>
297
+ /^minimumReleaseAgeExclude:\s*(?:#.*)?$/.test(line),
298
+ );
299
+ if (keyIndex < 0) {
300
+ throw new Error(
301
+ "paper fleet lock refresh requires a generated minimumReleaseAgeExclude block",
302
+ );
303
+ }
304
+ const retained = lines.filter(
305
+ (line, index) =>
306
+ index <= keyIndex ||
307
+ !/^\s*-\s+['"]?@kungfu-tech\/buildchain(?:@[^'"\s]+)?['"]?\s*(?:#.*)?$/.test(
308
+ line,
309
+ ),
310
+ );
311
+ retained.splice(keyIndex + 1, 0, " - '@kungfu-tech/buildchain'");
312
+ return retained.join("\n");
313
+ }
@@ -74,6 +74,7 @@ export {
74
74
  collectPaperFleetAudit,
75
75
  discoverPaperFleet,
76
76
  planPaperFleetUpdate,
77
+ paperFleetTransitionWorkspace,
77
78
  writePaperFleetUpdate,
78
79
  } from "./paper-fleet.js";
79
80
 
@@ -1,4 +1,5 @@
1
1
  import { spawnSync } from "node:child_process";
2
+ import fs from "node:fs";
2
3
  import path from "node:path";
3
4
  import {
4
5
  PAPER_FLEET_AUDIT_CONTRACT,
@@ -17,6 +18,7 @@ import {
17
18
  planPaperMigration,
18
19
  planPaperScaffold,
19
20
  planPaperFleetUpdate,
21
+ paperFleetTransitionWorkspace,
20
22
  writePaperFleetUpdate,
21
23
  writePaperMigration,
22
24
  writePaperScaffold,
@@ -467,9 +469,26 @@ function runFleetAudit(options) {
467
469
  function refreshFleetLocks(result) {
468
470
  for (const entry of result.results || []) {
469
471
  if (!entry.ok) continue;
470
- const lock = commandResult("pnpm", ["install", "--lockfile-only"], {
471
- cwd: entry.cwd,
472
- });
472
+ const workspacePath = path.resolve(entry.cwd, "pnpm-workspace.yaml");
473
+ const lockPath = path.resolve(entry.cwd, "pnpm-lock.yaml");
474
+ const finalWorkspace = fs.readFileSync(workspacePath, "utf8");
475
+ const transitionWorkspace = paperFleetTransitionWorkspace(
476
+ finalWorkspace,
477
+ fs.existsSync(lockPath) ? fs.readFileSync(lockPath, "utf8") : "",
478
+ );
479
+ let lock;
480
+ try {
481
+ if (transitionWorkspace !== finalWorkspace) {
482
+ fs.writeFileSync(workspacePath, transitionWorkspace);
483
+ }
484
+ lock = commandResult("pnpm", ["install", "--lockfile-only"], {
485
+ cwd: entry.cwd,
486
+ });
487
+ } finally {
488
+ if (fs.readFileSync(workspacePath, "utf8") !== finalWorkspace) {
489
+ fs.writeFileSync(workspacePath, finalWorkspace);
490
+ }
491
+ }
473
492
  if (lock.ok) continue;
474
493
  return {
475
494
  ...result,