shiplane 0.1.0 → 0.3.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.
Files changed (40) hide show
  1. package/dist/{budget-C8_aayQk.js → budget-CTjB1v-Z.js} +70 -27
  2. package/dist/budget-CTjB1v-Z.js.map +1 -0
  3. package/dist/cli.js +81 -36
  4. package/dist/cli.js.map +1 -1
  5. package/dist/display-IqkJ6uCw.js +96 -0
  6. package/dist/display-IqkJ6uCw.js.map +1 -0
  7. package/dist/index-oKnmZ8qV.d.ts +245 -0
  8. package/dist/index.d.ts +3 -2
  9. package/dist/index.js +4 -3
  10. package/dist/{issues-C5fKq1Jv.js → issues-TcWtMTv5.js} +1 -1
  11. package/dist/{issues-C5fKq1Jv.js.map → issues-TcWtMTv5.js.map} +1 -1
  12. package/dist/memory.d.ts +2 -0
  13. package/dist/memory.js +2 -0
  14. package/dist/package-registry.fake-CC37ptzf.d.ts +444 -0
  15. package/dist/package-registry.fake-Ciqc4ujx.js +633 -0
  16. package/dist/package-registry.fake-Ciqc4ujx.js.map +1 -0
  17. package/dist/perEnv-B7AiYnW_.js +11 -0
  18. package/dist/perEnv-B7AiYnW_.js.map +1 -0
  19. package/dist/plugin.d.ts +12 -5
  20. package/dist/plugin.js +8 -7
  21. package/dist/{readStatus-D5YVR5ZC.js → readStatus-Bo7hpUT3.js} +1397 -520
  22. package/dist/readStatus-Bo7hpUT3.js.map +1 -0
  23. package/dist/{shell-server-hosting.adapter-Bgl6-IWw.js → shell-server-hosting.adapter-DobfDqFm.js} +2 -2
  24. package/dist/{shell-server-hosting.adapter-Bgl6-IWw.js.map → shell-server-hosting.adapter-DobfDqFm.js.map} +1 -1
  25. package/dist/{src-Dlr2Sgs8.js → src-CGASfBy2.js} +3 -3
  26. package/dist/src-CGASfBy2.js.map +1 -0
  27. package/dist/{index-QneBUiDD.d.ts → static-hosting.port-mknLsxwR.d.ts} +61 -244
  28. package/dist/testing.d.ts +60 -468
  29. package/dist/testing.js +11 -625
  30. package/dist/testing.js.map +1 -1
  31. package/dist/{web-app.module-Bw-npC4Z.js → web-app.module-6KrXIU7j.js} +4 -11
  32. package/dist/web-app.module-6KrXIU7j.js.map +1 -0
  33. package/package.json +6 -1
  34. package/dist/budget-C8_aayQk.js.map +0 -1
  35. package/dist/display-DM0xtQbT.js +0 -55
  36. package/dist/display-DM0xtQbT.js.map +0 -1
  37. package/dist/readStatus-D5YVR5ZC.js.map +0 -1
  38. package/dist/src-Dlr2Sgs8.js.map +0 -1
  39. package/dist/tags-DL74ni09.d.ts +0 -19
  40. package/dist/web-app.module-Bw-npC4Z.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { a as releaseFlow, i as backendService, n as publishedPackage, r as mobileApp, t as webApp } from "./web-app.module-Bw-npC4Z.js";
2
- import { C as changelogSection, D as tagName, E as releaseTags, O as expandPatterns, S as cameWithRelease, a as deployRunTitle, c as shipsFrom, d as changesetApps, f as packageBumps, h as unreleasedChangesets, i as minutesBudget, k as workspacePatterns, l as webShip, m as unreleasedApps, p as splitChangesets, r as deployEstimate, s as onlyVersionFiles, u as appBumps, v as CommandFailed, w as firstRelease, x as DEFAULT_TAG_FORMAT, y as releaseSource } from "./budget-C8_aayQk.js";
1
+ import { a as releaseFlow, i as backendService, n as publishedPackage, r as mobileApp, t as webApp } from "./web-app.module-6KrXIU7j.js";
2
+ import { A as expandPatterns, C as cameWithRelease, D as releaseTags, O as tagFormatNamed, S as TAG_FORMATS, T as firstRelease, a as CommandFailed, c as onlyVersionFiles, d as appBumps, f as changesetApps, g as unreleasedChangesets, h as unreleasedApps, i as minutesBudget, j as workspacePatterns, k as tagName, l as shipsFrom, m as splitChangesets, o as deployRunTitle, p as packageBumps, r as deployEstimate, u as webShip, w as changelogSection, x as DEFAULT_TAG_FORMAT, y as releaseSource } from "./budget-CTjB1v-Z.js";
3
3
  import { z } from "zod";
4
4
  import { styleText } from "node:util";
5
5
  import fs from "node:fs";
@@ -8,6 +8,7 @@ import { Document, LineCounter, isMap, isScalar, isSeq, parseDocument } from "ya
8
8
  import { fileURLToPath } from "node:url";
9
9
  import { createJiti } from "jiti";
10
10
  import { execFile, spawn } from "node:child_process";
11
+ import ora from "ora";
11
12
  //#region src/adapters/files/node-files.adapter.ts
12
13
  /** The repository on disk, under `root`. */
13
14
  const nodeFiles = (root) => {
@@ -20,7 +21,8 @@ const nodeFiles = (root) => {
20
21
  fs.writeFileSync(at(file), text);
21
22
  },
22
23
  remove: (file) => fs.rmSync(at(file), { force: true }),
23
- list: (dir) => fs.existsSync(at(dir)) ? fs.readdirSync(at(dir)) : []
24
+ list: (dir) => fs.existsSync(at(dir)) ? fs.readdirSync(at(dir)) : [],
25
+ folders: (dir) => fs.existsSync(at(dir)) ? fs.readdirSync(at(dir), { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name) : []
24
26
  };
25
27
  };
26
28
  //#endregion
@@ -136,6 +138,7 @@ const keysAt = (schema, at) => {
136
138
  /** What a unit file naming this module may hold: `module`, then its adapter's settings. */
137
139
  const unitSchema = (module) => z.strictObject({
138
140
  module: z.literal(module.name).describe(`The module that ships this app, with ${module.provider}`),
141
+ buildCommand: z.string().optional().describe("How to build this app, when its package.json has no \"build\" script"),
139
142
  ...mapShape(module.settings.shape, deepStrict)
140
143
  });
141
144
  /** The JSON Schema editors read for `shiplane.unit.yml`: the module an app names picks its keys. */
@@ -230,10 +233,13 @@ const readUnitFile = (file, text, modules, features = []) => {
230
233
  if (!module) return problem(file, lineAt(["module"]), `no module named "${named}" in shiplane.config.ts`, didYouMean(named, names) ?? oneOf);
231
234
  const parsed = unitSchema(module).safeParse(data);
232
235
  if (!parsed.success) return { problems: parsed.error.issues.flatMap((issue) => describeIssue(issue, file, module, lineAt)) };
236
+ const options = Object.fromEntries(Object.entries(data).filter(([key]) => key !== "module" && key !== "buildCommand"));
237
+ const buildCommand = typeof data.buildCommand === "string" ? data.buildCommand : void 0;
233
238
  return {
234
239
  unit: {
235
240
  module: named,
236
- options: Object.fromEntries(Object.entries(data).filter(([key]) => key !== "module")),
241
+ ...buildCommand ? { buildCommand } : {},
242
+ options,
237
243
  lineOf: (at) => lineAt(at)
238
244
  },
239
245
  problems: []
@@ -267,6 +273,8 @@ const confirm = async ({ prompter, options, output }, question, initial = false)
267
273
  };
268
274
  /** `api`, `api and admin`, `api, admin and landing`. */
269
275
  const listed = (names) => names.length < 2 ? names.join("") : `${names.slice(0, -1).join(", ")} and ${names.slice(-1).join("")}`;
276
+ /** The keys a screen offers, each the same way: `d see the diff o open it on GitHub`. */
277
+ const keyHints = (hints) => hints.map(({ key, label }) => `${paint("cyan", key)} ${paint("dim", label)}`).join(" ");
270
278
  //#endregion
271
279
  //#region src/domain/codeScope.ts
272
280
  const NOT_SHIPPED = [
@@ -520,16 +528,37 @@ const releasePackage = (files) => {
520
528
  ...manifest.devDependencies
521
529
  } ? "shiplane" : INSTALLED;
522
530
  };
523
- /** The flow init writes: git, GitHub, GitHub Actions and changesets, each from its plugin. */
524
- const FLOW_PLUGINS = {
525
- git: ["gitSourceControl"],
526
- github: ["gitHubActionsCiPipeline", "gitHubCodeHost"],
527
- changesets: ["changesetsVersioning"]
528
- };
529
531
  const importLine = (names, from) => `import { ${[...new Set(names)].sort().join(", ")} } from "${from}";`;
530
- /** A root config with today's flow and these modules, in the order given. */
531
- const renderConfig = (entries, pkg = INSTALLED) => {
532
- const byPlugin = new Map(Object.entries(FLOW_PLUGINS).map(([plugin, names]) => [pluginPackage(plugin), [...names]]));
532
+ const FLOW_PORTS = [
533
+ "sourceControl",
534
+ "codeHost",
535
+ "ciPipeline",
536
+ "versioning"
537
+ ];
538
+ /** The flow init writes when nothing else is chosen: git, GitHub, GitHub Actions, changesets. */
539
+ const DEFAULT_FLOW = {
540
+ sourceControl: {
541
+ factory: "gitSourceControl",
542
+ from: pluginPackage("git")
543
+ },
544
+ codeHost: {
545
+ factory: "gitHubCodeHost",
546
+ from: pluginPackage("github")
547
+ },
548
+ ciPipeline: {
549
+ factory: "gitHubActionsCiPipeline",
550
+ from: pluginPackage("github")
551
+ },
552
+ versioning: {
553
+ factory: "changesetsVersioning",
554
+ from: pluginPackage("changesets")
555
+ }
556
+ };
557
+ /** A root config with this flow (today's by default) and these modules, in the order given. */
558
+ const renderConfig = (entries, pkg = INSTALLED, flow = DEFAULT_FLOW, units) => {
559
+ const byPlugin = /* @__PURE__ */ new Map();
560
+ const add = (from, name) => byPlugin.set(from, [...byPlugin.get(from) ?? [], name]);
561
+ FLOW_PORTS.forEach((port) => add(flow[port].from, flow[port].factory));
533
562
  const own = [
534
563
  "defineRelease",
535
564
  "releaseFlow",
@@ -537,19 +566,19 @@ const renderConfig = (entries, pkg = INSTALLED) => {
537
566
  ];
538
567
  entries.forEach(({ adapter, from }) => {
539
568
  if (from === pkg) own.push(adapter);
540
- else byPlugin.set(from, [...byPlugin.get(from) ?? [], adapter]);
569
+ else add(from, adapter);
541
570
  });
571
+ const local = (from) => from.startsWith(".");
542
572
  return [
543
573
  importLine(own, pkg),
544
- ...[...byPlugin].sort(([a], [b]) => a.localeCompare(b)).map(([from, names]) => importLine(names, from)),
574
+ ...[...byPlugin].filter(([from]) => !local(from)).sort(([a], [b]) => a.localeCompare(b)).map(([from, names]) => importLine(names, from)),
575
+ ...[...byPlugin].filter(([from]) => local(from)).sort(([a], [b]) => a.localeCompare(b)).map(([from, names]) => importLine(names, from)),
545
576
  "",
546
577
  "export default defineRelease({",
547
578
  " flow: releaseFlow({",
548
- " sourceControl: gitSourceControl(),",
549
- " codeHost: gitHubCodeHost(),",
550
- " ciPipeline: gitHubActionsCiPipeline(),",
551
- " versioning: changesetsVersioning(),",
579
+ ...FLOW_PORTS.map((port) => ` ${port}: ${flow[port].factory}(),`),
552
580
  " }),",
581
+ ...units ? [` units: [${units.map((unit) => JSON.stringify(unit)).join(", ")}],`] : [],
553
582
  " // What gets released, in this order. The first app is the repository's Latest release.",
554
583
  " modules: [",
555
584
  ...entries.map((entry) => ` ${moduleCall(entry)},`),
@@ -1090,8 +1119,12 @@ const checkModules = (modules, features) => {
1090
1119
  };
1091
1120
  const tagFormatOf = (tag) => {
1092
1121
  if (tag === void 0) return DEFAULT_TAG_FORMAT;
1093
- if (typeof tag !== "string" || !tag.includes("{version}")) throw new Error("tag must name the version, such as tag: \"v{version}\"");
1094
- return tag;
1122
+ const format = typeof tag === "string" ? tagFormatNamed(tag) : void 0;
1123
+ if (!format?.includes("{version}")) {
1124
+ const names = Object.keys(TAG_FORMATS).map((name) => `"${name}"`).join(", ");
1125
+ throw new Error(`tag is one of ${names}, or a format naming the version, such as "v{version}"`);
1126
+ }
1127
+ return format;
1095
1128
  };
1096
1129
  const releasesCommitsOf = (choice) => {
1097
1130
  if (choice === void 0 || choice === "ignore") return false;
@@ -1121,12 +1154,19 @@ const readConfig = async (file, aliases) => {
1121
1154
  units,
1122
1155
  display: {
1123
1156
  verbose: flag(display.verbose),
1124
- mascot: flag(display.mascot)
1157
+ mascot: mascotOf(display.mascot)
1125
1158
  },
1126
1159
  tagFormat: tagFormatOf(loaded.tag),
1127
1160
  releasesCommits: releasesCommitsOf(loaded.commitsWithoutChangeset)
1128
1161
  };
1129
1162
  };
1163
+ /** A config's mascot: true, false, frames per mood, or a function; anything else is ignored. */
1164
+ const mascotOf = (value) => {
1165
+ if (typeof value === "boolean" || typeof value === "function") return value;
1166
+ if (!isRecord(value)) return void 0;
1167
+ const frames = Object.entries(value).filter(([, list]) => Array.isArray(list) && list.every((frame) => typeof frame === "string"));
1168
+ return frames.length > 0 ? Object.fromEntries(frames) : void 0;
1169
+ };
1130
1170
  /** Apps in release order: by module as the config lists them, then by name. */
1131
1171
  const inReleaseOrder = (read, modules) => {
1132
1172
  const rank = (unit) => modules.findIndex(({ name }) => name === unit.module);
@@ -1206,6 +1246,7 @@ const loadRelease = async (root, options = {}) => {
1206
1246
  packageName: manifest.name,
1207
1247
  version: manifest.version,
1208
1248
  module: result.unit.module,
1249
+ ...result.unit.buildCommand ? { buildCommand: result.unit.buildCommand } : {},
1209
1250
  options: result.unit.options,
1210
1251
  after: []
1211
1252
  },
@@ -1222,6 +1263,11 @@ const loadRelease = async (root, options = {}) => {
1222
1263
  problems.push(...referenceProblems(entry, ordered));
1223
1264
  entry.unit.after = [...new Set(referencesIn(entry.unit.options).map(({ unit }) => unit))].filter((name) => name !== entry.unit.name && ordered.some(({ unit }) => unit.name === name));
1224
1265
  });
1266
+ if (ordered.length > 1 && !config.tagFormat.includes("{name}")) problems.push({
1267
+ file: path.basename(configFile),
1268
+ message: `tag "${config.tagFormat}" names no unit, so ${ordered.length} units would share each tag`,
1269
+ hint: "add {name} to the format, such as \"{name}--v{version}\", or release one unit"
1270
+ });
1225
1271
  return {
1226
1272
  root,
1227
1273
  flow: config.flow,
@@ -1361,13 +1407,69 @@ const sentence = (items) => items.length < 2 ? items.join("") : `${items.slice(0
1361
1407
  const MAX_LINE = 100;
1362
1408
  /** One app's release commit: `chore(api): release v0.0.4`. */
1363
1409
  const releaseCommitTitle = ({ app, to }) => `chore(${app}): release v${to}`;
1364
- /** Conventional and short: `chore(api): release v0.0.4`, or `chore(release): ...` for several apps. */
1365
- const releaseTitle = (bumps) => {
1410
+ MAX_LINE - 9;
1411
+ const counted = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
1412
+ /** What a title calls a unit of each module kind; several kinds at once are apps. */
1413
+ const NOUN = {
1414
+ "published-package": "package",
1415
+ "backend-service": "service",
1416
+ "web-app": "web app",
1417
+ "mobile-app": "mobile app",
1418
+ "internal-tool": "tool"
1419
+ };
1420
+ /**
1421
+ * The apps, gathered into families in their own order: a root moving with its `root-*` apps
1422
+ * (`shiplane`, `shiplane-npm`) is one family; any other app is a family of one.
1423
+ */
1424
+ const releaseFamilies = (bumps) => {
1425
+ return bumps.filter(({ app }) => !bumps.some((other) => other.app !== app && app.startsWith(`${other.app}-`))).map((root) => bumps.filter(({ app }) => app === root.app || app.startsWith(`${root.app}-`)));
1426
+ };
1427
+ /** One family as a title names it: `api v0.0.4`, `shiplane and 7 plugins v0.1.0`, `api v0.3.0 and 2 more services`. */
1428
+ const familyLabel = ([root, ...members], kindOf) => {
1429
+ if (!root) return "";
1430
+ if (members.length < 2) return [root, ...members].map(({ app, to }) => `${app} v${to}`).join(", ");
1431
+ const kinds = new Set([root, ...members].map(({ app }) => kindOf(app)));
1432
+ const [kind] = kinds;
1433
+ const noun = kinds.size === 1 && kind && NOUN[kind] || "app";
1434
+ const rest = noun === "package" ? counted(members.length, "plugin") : `${members.length} more ${counted(members.length, noun).replace(/^\d+ /, "")}`;
1435
+ return members.every(({ to }) => to === root.to) ? `${root.app} and ${rest} v${root.to}` : `${root.app} v${root.to} and ${rest}`;
1436
+ };
1437
+ /**
1438
+ * The release PRs a release opens, all from main at once: one per app, a family counting as one.
1439
+ * Apps `linked` (one changeset naming both, or one moving with the other) share a PR, so no two
1440
+ * PRs ever touch the same file.
1441
+ */
1442
+ const releasePrGroups = (bumps, linked) => {
1443
+ const groups = releaseFamilies(bumps).map((family) => new Set(family.map(({ app }) => app)));
1444
+ const merged = linked.reduce((current, apps) => {
1445
+ const touched = current.filter((group) => apps.some((app) => group.has(app)));
1446
+ if (touched.length < 2) return current;
1447
+ const union = new Set(touched.flatMap((group) => [...group]));
1448
+ return [...current.filter((group) => !touched.includes(group)), union];
1449
+ }, groups);
1450
+ const order = (group) => bumps.findIndex(({ app }) => group.has(app));
1451
+ return merged.sort((left, right) => order(left) - order(right)).map((group) => bumps.filter(({ app }) => group.has(app)));
1452
+ };
1453
+ /** Whether a title still fits once a squash merge appends its PR number. */
1454
+ const titleFits = (title) => title.length <= 91;
1455
+ /**
1456
+ * Conventional, and naming every app it brings, never a bare count: `chore(api): release v0.0.4`,
1457
+ * `chore(release): api v0.0.2 and admin v0.1.0`, or, when listing each one is too long, families
1458
+ * by their root: `chore(release): shiplane and 7 plugins v0.1.0, landing v1.2.0 and expo v2.1.0`.
1459
+ * One release is one PR: a title too long even then stays whole, see `titleFits`.
1460
+ */
1461
+ const releaseTitle = (bumps, kindOf = () => void 0) => {
1366
1462
  const [first, ...others] = bumps;
1367
1463
  if (!first) return "chore(release): package changelogs";
1368
1464
  if (others.length === 0) return releaseCommitTitle(first);
1369
- const named = `chore(release): ${sentence(bumps.map(({ app, to }) => `${app} v${to}`))}`;
1370
- return named.length <= MAX_LINE ? named : `chore(release): ${bumps.length} apps`;
1465
+ const families = releaseFamilies(bumps);
1466
+ const [only] = families;
1467
+ if (families.length === 1 && only?.[0]) return releaseCommitTitle(only[0]);
1468
+ const every = `chore(release): ${sentence(bumps.map(({ app, to }) => `${app} v${to}`))}`;
1469
+ if (titleFits(every)) return every;
1470
+ families.sort((left, right) => Number(right.length > 1) - Number(left.length > 1));
1471
+ const labels = families.map((family) => familyLabel(family, kindOf));
1472
+ return `chore(release): ${labels.at(-1)?.includes(" and ") ? labels.join(", ") : sentence(labels)}`;
1371
1473
  };
1372
1474
  /** A bullet wrapped to commitlint's 100-character body lines, continued under its text. */
1373
1475
  const bullet = (text) => text.split(" ").reduce((lines, word) => {
@@ -1454,192 +1556,447 @@ const WAIT_KEYS = {
1454
1556
  /** What a key does while the release waits for its pull request to merge. */
1455
1557
  const waitKey = (name) => name && WAIT_KEYS[name] || null;
1456
1558
  //#endregion
1457
- //#region src/application/steps.ts
1458
- const MAX_OUTPUT_LINES = 40;
1459
- const reasonOf$1 = (error) => error instanceof Error ? error.message : String(error);
1460
- /** What the failed command printed, so the person reads why without running it again. */
1461
- const printOutput = ({ output }, error) => {
1462
- if (!(error instanceof CommandFailed) || !error.output) return;
1463
- const lines = error.output.split("\n");
1464
- const shown = lines.slice(-MAX_OUTPUT_LINES);
1465
- if (shown.length < lines.length) output.line(paint("dim", ` … ${lines.length - shown.length} earlier lines`));
1466
- shown.forEach((line) => output.line(paint("dim", ` │ ${line}`)));
1467
- };
1468
- /** Takes back the steps that ran, newest first; one that cannot be undone never stops the rest. */
1469
- const cancel = async (context, ran) => {
1470
- const undos = ran.flatMap(({ undo }) => undo ? [undo] : []).reverse();
1471
- const kept = ran.flatMap((step) => step.kept ? [step.kept] : []);
1472
- if (undos.length === 0 && kept.length === 0) return;
1473
- const left = [];
1474
- for (const undo of undos) try {
1475
- await context.progress.during(`undo: ${undo.label}`, "working", undo.run);
1476
- } catch (error) {
1477
- left.push(undo);
1478
- context.progress.say("worried", `${paint("red", "✗")} undo ${undo.label}: ${reasonOf$1(error)}`);
1479
- }
1480
- if (left.length === 0 && kept.length === 0) {
1481
- context.progress.say("resting", paint("dim", "Cancelled: everything this run did is undone."));
1482
- return;
1559
+ //#region src/domain/companions.ts
1560
+ /** The shortest chain of moving packages from `from` to one a changeset names, breadth first. */
1561
+ const chainTo = (from, dependencies, moving, named) => {
1562
+ const seen = /* @__PURE__ */ new Set();
1563
+ let paths = [[from]];
1564
+ while (paths.length > 0) {
1565
+ const next = [];
1566
+ for (const path of paths) {
1567
+ const last = path[path.length - 1] ?? from;
1568
+ for (const dependency of dependencies[last] ?? []) {
1569
+ if (!moving.has(dependency) || seen.has(dependency)) continue;
1570
+ seen.add(dependency);
1571
+ const chain = [...path, dependency];
1572
+ if (named.has(dependency)) return chain.slice(1);
1573
+ next.push(chain);
1574
+ }
1575
+ }
1576
+ paths = next;
1483
1577
  }
1484
- const commands = [...new Set([...left, ...kept].flatMap(({ byHand }) => byHand()))];
1485
- const these = commands.length > 1 ? "these" : "this";
1486
- const ask = kept.length === 0 ? "run these to finish the cleanup:" : `run ${these} to finish:`;
1487
- fail(context, "Cancelled, not all of it", [...kept.map(({ label }) => label), ask].join("; "), commands);
1578
+ return [];
1488
1579
  };
1489
1580
  /**
1490
- * Runs steps in order, each shown with its place in the run. At the first failure it says why,
1491
- * with the command's own output, and undoes the steps that ran.
1581
+ * Preview: the units a release moves that the person did not pick. changesets moves a unit whenever
1582
+ * a workspace package it uses moves, so it cannot stay behind; this says through which package.
1492
1583
  */
1493
- const runSteps = async (context, steps) => {
1494
- for (const [index, step] of steps.entries()) try {
1495
- await context.progress.during(step.label, "working", step.run, {
1496
- index,
1497
- total: steps.length
1498
- });
1499
- } catch (error) {
1500
- fail(context, `${step.label} failed`, `${reasonOf$1(error)}, the steps after it did not run.`);
1501
- printOutput(context, error);
1502
- await cancel(context, steps.slice(0, index));
1503
- return false;
1504
- }
1505
- return true;
1506
- };
1507
- /** A branch from main; undone by dropping the changes made on it and the branch itself. */
1508
- const branchStep = ({ services: { sourceControl: source } }, branch) => {
1509
- let untracked = /* @__PURE__ */ new Set();
1510
- return {
1511
- label: `branch ${branch} from main`,
1512
- run: async () => {
1513
- untracked = new Set(await source.changedFiles());
1514
- await source.createBranch(branch);
1515
- },
1516
- undo: {
1517
- label: `delete ${branch}`,
1518
- run: async () => {
1519
- const created = (await source.changedFiles()).filter((file) => !untracked.has(file));
1520
- await source.discard(created);
1521
- await source.switchTo("main");
1522
- await source.deleteBranch(branch);
1523
- },
1524
- byHand: () => [
1525
- "git reset --hard",
1526
- "git switch main",
1527
- `git branch -D ${branch}`
1528
- ]
1529
- }
1530
- };
1531
- };
1532
- const pushStep = ({ services: { sourceControl: source } }, branch) => ({
1533
- label: `push ${branch}`,
1534
- run: () => source.push(branch),
1535
- undo: {
1536
- label: `delete ${branch} on origin`,
1537
- run: () => source.deleteRemoteBranch(branch),
1538
- byHand: () => [`git push origin --delete ${branch}`]
1539
- }
1540
- });
1541
- /** Opens a pull request; undone by closing it, with a comment saying why. */
1542
- const openPrStep = ({ services: { codeHost: host } }, label, open) => {
1543
- let opened = null;
1544
- return {
1545
- label,
1546
- run: async () => {
1547
- opened = await open();
1548
- },
1549
- undo: {
1550
- label: "close the pull request",
1551
- run: async () => {
1552
- if (opened) await host.closePr(opened, "The release stopped part way, so it closed this.");
1553
- },
1554
- byHand: () => opened ? [`gh pr close ${opened.number}`] : []
1555
- }
1556
- };
1584
+ const draggedUnits = (plan, dependencies, units, scope) => {
1585
+ const moving = new Set(plan.releases.map(({ name }) => name));
1586
+ const named = new Set(plan.releases.filter(({ changesets }) => changesets.length > 0).map(({ name }) => name));
1587
+ const picked = units.filter(({ name }) => scope.has(name));
1588
+ return units.flatMap(({ name: app, packageName }) => {
1589
+ const release = plan.releases.find(({ name }) => name === packageName);
1590
+ if (scope.has(app) || !release) return [];
1591
+ const chain = chainTo(packageName, dependencies, moving, named);
1592
+ const source = chain[chain.length - 1];
1593
+ const movers = picked.filter((unit) => plan.changesets.some(({ releases }) => releases.some(({ name }) => name === source) && releases.some(({ name }) => name === unit.packageName))).map(({ name }) => name);
1594
+ const whose = movers.length > 0 ? `${movers.join(", ")}'s changes move` : "this release moves";
1595
+ return [{
1596
+ app,
1597
+ version: release.newVersion,
1598
+ with: movers,
1599
+ why: chain.length > 0 ? `uses ${chain.join(" → ")}, which ${whose}` : "moves with this release"
1600
+ }];
1601
+ });
1557
1602
  };
1558
- //#endregion
1559
- //#region src/application/openReleasePr.ts
1560
- const plural$1 = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
1561
- /** What happens to a unit once the release PR merges: its module ships the version to preview. */
1562
- const shipsOnMerge = (context, { contributions, companions }) => (bump) => {
1563
- const contributed = contributions[bump.app]?.onMerge;
1564
- if (contributed) return contributed;
1565
- const unit = context.release.units.find(({ name }) => name === bump.app);
1566
- const along = companions.find(({ app }) => app === bump.app);
1567
- const reason = along ? ` (not picked: ${along.why})` : bump.movedWith.length > 0 ? ` (moved with ${bump.movedWith.join(", ")})` : "";
1568
- return `${environmentLabel(context, [bump.app], "preview") === "live" ? "Ship live" : "Ship to preview"} with ${(unit && moduleOf(context, unit)?.provider) ?? "its target"}${reason}`;
1603
+ const OWN_CHANGE = /^- ([0-9a-f]{7,40}): /gm;
1604
+ const DEPENDENCY_CHANGES = /^- Updated dependencies \[([^\]]+)\]/gm;
1605
+ /** The changes a version carries: its own, and those a package it uses moved for. */
1606
+ const changeIds = (notes) => new Set([...[...notes.matchAll(OWN_CHANGE)].flatMap(([, id]) => id ? [id] : []), ...[...notes.matchAll(DEPENDENCY_CHANGES)].flatMap(([, ids]) => (ids ?? "").split(",").map((id) => id.trim()))]);
1607
+ /** A change's first line in these notes, with an ellipsis when it goes on. */
1608
+ const summaryOf = (notes, id) => {
1609
+ const lines = notes.split("\n");
1610
+ const index = lines.findIndex((line) => line.startsWith(`- ${id}: `));
1611
+ const first = lines[index]?.slice(`- ${id}: `.length).trim();
1612
+ if (index < 0 || !first) return null;
1613
+ return /^ {2}\S/.test(lines[index + 1] ?? "") ? `${first}…` : first;
1569
1614
  };
1570
- /** Units going out unpicked, each with the package that takes it along. */
1571
- const printCompanions = ({ output, release }, { companions, split }) => {
1572
- if (companions.length === 0) return;
1573
- const names = companions.map(({ app }) => app);
1574
- const verb = names.length === 1 ? "is not picked but ships too" : "are not picked but ship too";
1575
- output.line(` ${paint(["bold", "yellow"], "!")} ${paint("bold", `${listed(names)} ${verb}:`)}`);
1576
- companions.forEach(({ app, version, why }) => {
1577
- const packageName = release.units.find(({ name }) => name === app)?.packageName;
1578
- const waiting = split.waits.filter(({ releases }) => releases.some(({ name }) => name === packageName)).length;
1579
- const own = waiting > 0 ? ` · picking it ships its ${plural$1(waiting, "changeset")} too` : "";
1580
- output.line(` ${app.padEnd(11)}${version.padEnd(20)}${paint("dim", `${why}${own}`)}`);
1581
- });
1582
- output.line();
1615
+ /** The packages listed under the `Updated dependencies` line that names this change. */
1616
+ const packagesMovedFor = (notes, id) => {
1617
+ const lines = notes.split("\n");
1618
+ const start = lines.findIndex((line) => line.startsWith("- Updated dependencies [") && line.includes(id));
1619
+ if (start < 0) return [];
1620
+ const listed = lines.slice(start + 1);
1621
+ const end = listed.findIndex((line) => !/^ {2}- \S+@/.test(line));
1622
+ return (end < 0 ? listed : listed.slice(0, end)).map((line) => line.trim().slice(2).replace(/@[^@]*$/, ""));
1583
1623
  };
1584
- /** The table a person reads before anything is written: each unit, its move, what ships. */
1585
- const printSummary = (context, prepared) => {
1586
- const { output, release } = context;
1587
- const { bumps, packages, pending, held, unreleased, contributions, companions } = prepared;
1588
- const dot = paint("dim", "·");
1589
- const stays = held.filter((app) => !bumps.some((bump) => bump.app === app));
1590
- const heldLabel = stays.length > 0 ? ` ${dot} ${stays.join(", ")} held` : "";
1591
- const where = environmentLabel(context, bumps.map(({ app }) => app), "preview");
1592
- output.line();
1593
- output.line(` ${paint("bold", "Release")} ${dot} ${where} ${dot} ${plural$1(pending, "changeset")}${heldLabel}`);
1594
- output.line();
1595
- const width = Math.max(13, ...release.units.map(({ name }) => name.length)) + 2;
1596
- output.line(paint("dim", ` ${"Unit".padEnd(width)}${"Version".padEnd(20)}${where === "live" ? "Ships live" : "Ships to preview"}`));
1597
- release.units.forEach((unit) => {
1598
- const bump = bumps.find(({ app }) => app === unit.name);
1599
- const version = bump ? `${bump.from} → ${bump.to}` : unit.version;
1600
- const left = unreleased.find(({ app }) => app === unit.name);
1601
- const ships = (() => {
1602
- if (held.includes(unit.name) && !bump) return paint("yellow", "⏸ held, its changesets stay pending");
1603
- if (left && !bump) return paint("yellow", `! ${plural$1(left.commits.length, "commit")} since ${left.version}, no changeset: not in this release`);
1604
- const contributed = contributions[unit.name]?.summary;
1605
- if (contributed && contributed.length > 0) return contributed.join(`\n ${" ".repeat(width + 20)}`);
1606
- if (!bump) return paint("dim", "– nothing changed");
1607
- const along = companions.some(({ app }) => app === unit.name) ? paint("yellow", " not picked, goes along") : "";
1608
- return `${paint("green", "↑ ship")} ${paint("dim", moduleOf(context, unit)?.provider ?? "")}${along}`;
1609
- })();
1610
- output.line(` ${unit.name.padEnd(width)}${version.padEnd(20)}${ships}`);
1611
- });
1612
- if (packages > 0) output.line(` ${"packages".padEnd(width)}${`${packages} bumped`.padEnd(20)}${paint("dim", "changelogs only, nothing published")}`);
1613
- output.line();
1614
- printCompanions(context, prepared);
1624
+ /** Why two versions went out together: the change they share, or the package both moved for. */
1625
+ const sharedReason = (partner, other, id) => {
1626
+ const summary = summaryOf(partner.notes, id) ?? summaryOf(other.notes, id);
1627
+ if (summary) return ` for: ${summary}`;
1628
+ const theirs = new Set(packagesMovedFor(partner.notes, id));
1629
+ const both = packagesMovedFor(other.notes, id).filter((name) => theirs.has(name));
1630
+ return both.length > 0 ? `: both use ${both.join(", ")}, which moved` : "";
1615
1631
  };
1616
1632
  /**
1617
- * Versions what `prepared` covers on one branch from main, opens its PR, and goes back to main.
1618
- * Null, with what to do, when it must not run.
1633
+ * Production: the units preview runs with the picked ones that are not picked. Two versions went to
1634
+ * preview together when their notes share a change, their own or one a package they use moved for.
1619
1635
  */
1620
- const openReleasePr = async (context, prepared) => {
1621
- const { output, services, clock } = context;
1622
- printSummary(context, prepared);
1623
- const blocked = Object.values(prepared.contributions).find((entry) => entry.blocked)?.blocked;
1624
- if (blocked) {
1625
- fail(context, blocked.title, blocked.detail, blocked.commands);
1626
- return null;
1627
- }
1628
- const source = releaseSource("build", "preview", await services.sourceControl.position());
1629
- if (!source.allowed) {
1630
- fail(context, source.why === "not-main" ? "Not from main" : "main is behind origin", "a release versions what is merged.", [
1631
- "git switch main",
1632
- "git pull",
1633
- "shiplane"
1634
- ]);
1635
- return null;
1636
- }
1637
- if (!await services.sourceControl.isClean()) {
1638
- fail(context, "Uncommitted changes", "commit or stash them first, the release PR commits every change.");
1639
- return null;
1640
- }
1636
+ const releasedTogether = (picked, others) => others.flatMap((other) => {
1637
+ const ids = changeIds(other.notes);
1638
+ const partners = picked.flatMap((partner) => {
1639
+ const shared = [...changeIds(partner.notes)].find((id) => ids.has(id));
1640
+ return shared ? [{
1641
+ partner,
1642
+ shared
1643
+ }] : [];
1644
+ });
1645
+ const [first] = partners;
1646
+ if (!first) return [];
1647
+ const names = partners.map(({ partner }) => `${partner.app} ${partner.version}`).join(", ");
1648
+ return [{
1649
+ app: other.app,
1650
+ version: other.version,
1651
+ with: partners.map(({ partner }) => partner.app),
1652
+ why: `went to preview with ${names}${sharedReason(first.partner, other, first.shared)}`
1653
+ }];
1654
+ });
1655
+ //#endregion
1656
+ //#region src/application/readScope.ts
1657
+ const MANIFEST = "package.json";
1658
+ const unitRefs = (units) => units.map(({ name, packageName }) => ({
1659
+ name,
1660
+ packageName
1661
+ }));
1662
+ /** The units the pending changesets name. */
1663
+ const namedUnits = async ({ release, services }) => new Set((await services.versioning.pending()).flatMap(({ text }) => changesetApps(text, unitRefs(release.units))));
1664
+ /** Units whose folder moved since their current version, that no changeset or bump ships. */
1665
+ const findUnreleased = async ({ release, services: { sourceControl: source } }, named) => {
1666
+ if (!release.releasesCommits) return [];
1667
+ return unreleasedApps((await Promise.all(release.units.map(async ({ name, dir, version }) => {
1668
+ const since = await source.tagCommit(tagName(name, version, release.tagFormat)) ?? (await source.versionCommit(dir, "package.json", version))?.sha;
1669
+ if (!since) return [];
1670
+ return [{
1671
+ app: name,
1672
+ version,
1673
+ commits: await source.subjectsSince(since, dir, UNIT_FILES)
1674
+ }];
1675
+ }))).flat(), named);
1676
+ };
1677
+ /** A tag's deploy on an environment, from every record the host keeps. */
1678
+ const deployedOn = (history, tag, environment) => {
1679
+ const states = history.filter(({ title }) => title === deployRunTitle(tag, environment)).map(({ state }) => state);
1680
+ if (states.includes("done")) return "done";
1681
+ return states.includes("running") ? "running" : "none";
1682
+ };
1683
+ /**
1684
+ * Each unit as the first question sees it: git for what is new, the host's deploy records for what
1685
+ * each environment runs (offline, nothing counts as deployed).
1686
+ */
1687
+ const readScope = async (context, environment) => {
1688
+ const { release, services } = context;
1689
+ const pending = await services.versioning.pending();
1690
+ const refs = unitRefs(release.units);
1691
+ const named = pending.map(({ text }) => changesetApps(text, refs));
1692
+ const unreleased = await findUnreleased(context, new Set(named.flat()));
1693
+ const [deployed, tags] = await Promise.all([services.codeHost.deployments().catch(() => []), services.sourceControl.tags()]);
1694
+ return Promise.all(release.units.map(async (unit) => {
1695
+ const tag = tagName(unit.name, unit.version, context.release.tagFormat);
1696
+ const target = moduleOf(context, unit);
1697
+ const decidedBy = target?.decidedBy;
1698
+ const commit = await services.sourceControl.versionCommit(unit.dir, MANIFEST, unit.version);
1699
+ const tagged = await services.sourceControl.tagCommit(tag) !== null;
1700
+ const live = async (on) => {
1701
+ if (!target?.live || !tagged) return deployedOn(deployed, tag, on) === "done";
1702
+ const { head } = await services.sourceControl.position();
1703
+ const input = jobInput(context, target, unit, {
1704
+ tag,
1705
+ environment: on,
1706
+ commit: head
1707
+ });
1708
+ return target.live(decideContext(context), input).catch(() => false);
1709
+ };
1710
+ return {
1711
+ app: unit.name,
1712
+ version: unit.version,
1713
+ changesets: named.filter((apps) => apps.includes(unit.name)).length,
1714
+ commits: unreleased.find((entry) => entry.app === unit.name)?.commits.length ?? 0,
1715
+ tagged,
1716
+ versioned: commit !== null && cameWithRelease({
1717
+ app: unit.name,
1718
+ version: unit.version,
1719
+ commit
1720
+ }),
1721
+ firstRelease: !tagged && commit !== null && firstRelease(unit.name, unit.version, tags, context.release.tagFormat),
1722
+ onChannel: await live(environment),
1723
+ onPreview: await live("preview"),
1724
+ ...decidedBy ? { decidedBy } : {},
1725
+ ...target?.releaseOnly ? { releaseOnly: true } : {}
1726
+ };
1727
+ }));
1728
+ };
1729
+ //#endregion
1730
+ //#region src/application/prepareRelease.ts
1731
+ const NOTHING_HELD = {
1732
+ ships: [],
1733
+ waits: []
1734
+ };
1735
+ /** The person's answer to a plugin's choice; the suggestion without a terminal or with --yes. */
1736
+ const choose = async ({ prompter, options }, choice) => {
1737
+ if (!choice) return null;
1738
+ if (options.yes || !prompter.interactive) return choice.suggested;
1739
+ return prompter.select(choice.question, choice.options, choice.suggested);
1740
+ };
1741
+ /** What each picked unit's plugin adds, given the unit's bump so far. One at a time: it may ask. */
1742
+ const contributionsOf = async (context, scope, bumps, known = {}) => {
1743
+ const { head } = await context.services.sourceControl.position();
1744
+ const contributions = {};
1745
+ for (const unit of context.release.units.filter(({ name }) => scope.has(name))) {
1746
+ const answered = known[unit.name];
1747
+ if (answered) {
1748
+ contributions[unit.name] = answered;
1749
+ continue;
1750
+ }
1751
+ const module = moduleOf(context, unit);
1752
+ const version = module?.version?.bind(module);
1753
+ if (!module || !version) continue;
1754
+ const input = jobInput(context, module, unit, {
1755
+ tag: tagName(unit.name, unit.version, context.release.tagFormat),
1756
+ environment: "preview",
1757
+ commit: head
1758
+ });
1759
+ const bump = bumps.find(({ app }) => app === unit.name);
1760
+ const contribute = (chosen) => version(decideContext(context), {
1761
+ ...input,
1762
+ bump,
1763
+ chosen
1764
+ });
1765
+ const suggested = await contribute();
1766
+ const chosen = await choose(context, suggested.choice);
1767
+ contributions[unit.name] = chosen && chosen !== suggested.choice?.suggested ? await contribute(chosen) : suggested;
1768
+ }
1769
+ return contributions;
1770
+ };
1771
+ /** What a release PR covering `scope` would version, computed without writing anything. */
1772
+ const prepareRelease = async (context, scope, known = {}) => {
1773
+ const { release, services } = context;
1774
+ const refs = unitRefs(release.units);
1775
+ const [dependencies, named, base, pendingFiles] = await Promise.all([
1776
+ services.versioning.dependencies(),
1777
+ namedUnits(context),
1778
+ services.versioning.plan([], []),
1779
+ services.versioning.pending()
1780
+ ]);
1781
+ const baseBumps = appBumps(base, dependencies, refs);
1782
+ const unreleased = await findUnreleased(context, new Set([...named, ...baseBumps.map(({ app }) => app)]));
1783
+ const held = [...named].filter((app) => !scope.has(app));
1784
+ const adopted = unreleased.filter(({ app }) => scope.has(app)).flatMap(({ app, version, commits }) => {
1785
+ const ref = refs.find(({ name }) => name === app);
1786
+ return ref ? unreleasedChangesets(ref, version, commits) : [];
1787
+ });
1788
+ const split = held.length > 0 ? splitChangesets(base.changesets, held, refs) : NOTHING_HELD;
1789
+ const picked = held.length > 0 || adopted.length > 0 ? await services.versioning.plan(adopted, split.waits) : base;
1790
+ const contributions = await contributionsOf(context, scope, appBumps(picked, dependencies, refs), known);
1791
+ const contributed = Object.values(contributions).flatMap(({ added }) => added);
1792
+ const added = [...adopted, ...contributed];
1793
+ const plan = contributed.length > 0 ? await services.versioning.plan(added, split.waits) : picked;
1794
+ return {
1795
+ pending: (held.length > 0 ? split.ships.length : pendingFiles.length) + added.length,
1796
+ held,
1797
+ unreleased: unreleased.filter(({ app }) => !scope.has(app)),
1798
+ split,
1799
+ bumps: appBumps(plan, dependencies, refs),
1800
+ companions: draggedUnits(plan, dependencies, refs, scope),
1801
+ packages: packageBumps(plan, refs),
1802
+ added,
1803
+ shipped: plan.changesets,
1804
+ contributions
1805
+ };
1806
+ };
1807
+ //#endregion
1808
+ //#region src/application/steps.ts
1809
+ const MAX_OUTPUT_LINES = 40;
1810
+ const reasonOf$1 = (error) => error instanceof Error ? error.message : String(error);
1811
+ /** What the failed command printed, so the person reads why without running it again. */
1812
+ const printOutput = ({ output }, error) => {
1813
+ if (!(error instanceof CommandFailed) || !error.output) return;
1814
+ const lines = error.output.split("\n");
1815
+ const shown = lines.slice(-MAX_OUTPUT_LINES);
1816
+ if (shown.length < lines.length) output.line(paint("dim", ` … ${lines.length - shown.length} earlier lines`));
1817
+ shown.forEach((line) => output.line(paint("dim", ` │ ${line}`)));
1818
+ };
1819
+ /** Takes back the steps that ran, newest first; one that cannot be undone never stops the rest. */
1820
+ const cancel = async (context, ran) => {
1821
+ const undos = ran.flatMap(({ undo }) => undo ? [undo] : []).reverse();
1822
+ const kept = ran.flatMap((step) => step.kept ? [step.kept] : []);
1823
+ if (undos.length === 0 && kept.length === 0) return;
1824
+ const left = [];
1825
+ for (const undo of undos) try {
1826
+ await context.progress.during(`undo: ${undo.label}`, "working", undo.run);
1827
+ } catch (error) {
1828
+ left.push(undo);
1829
+ context.progress.say("worried", `${paint("red", "✗")} undo ${undo.label}: ${reasonOf$1(error)}`);
1830
+ }
1831
+ if (left.length === 0 && kept.length === 0) {
1832
+ context.progress.say("resting", paint("dim", "Cancelled: everything this run did is undone."));
1833
+ return;
1834
+ }
1835
+ const commands = [...new Set([...left, ...kept].flatMap(({ byHand }) => byHand()))];
1836
+ const these = commands.length > 1 ? "these" : "this";
1837
+ const ask = kept.length === 0 ? "run these to finish the cleanup:" : `run ${these} to finish:`;
1838
+ fail(context, "Cancelled, not all of it", [...kept.map(({ label }) => label), ask].join("; "), commands);
1839
+ };
1840
+ /**
1841
+ * Runs steps in order, each shown with its place in the run. At the first failure it says why,
1842
+ * with the command's own output, and undoes the steps that ran.
1843
+ */
1844
+ const runSteps = async (context, steps) => {
1845
+ for (const [index, step] of steps.entries()) try {
1846
+ await context.progress.during(step.label, "working", step.run, {
1847
+ index,
1848
+ total: steps.length
1849
+ });
1850
+ } catch (error) {
1851
+ fail(context, `${step.label} failed`, `${reasonOf$1(error)}, the steps after it did not run.`);
1852
+ printOutput(context, error);
1853
+ await cancel(context, steps.slice(0, index));
1854
+ return false;
1855
+ }
1856
+ return true;
1857
+ };
1858
+ /** A branch from main; undone by dropping the changes made on it and the branch itself. */
1859
+ const branchStep = ({ services: { sourceControl: source } }, branch) => {
1860
+ let untracked = /* @__PURE__ */ new Set();
1861
+ return {
1862
+ label: `branch ${branch} from main`,
1863
+ run: async () => {
1864
+ untracked = new Set(await source.changedFiles());
1865
+ await source.createBranch(branch);
1866
+ },
1867
+ undo: {
1868
+ label: `delete ${branch}`,
1869
+ run: async () => {
1870
+ const created = (await source.changedFiles()).filter((file) => !untracked.has(file));
1871
+ await source.discard(created);
1872
+ await source.switchTo("main");
1873
+ await source.deleteBranch(branch);
1874
+ },
1875
+ byHand: () => [
1876
+ "git reset --hard",
1877
+ "git switch main",
1878
+ `git branch -D ${branch}`
1879
+ ]
1880
+ }
1881
+ };
1882
+ };
1883
+ const pushStep = ({ services: { sourceControl: source } }, branch) => ({
1884
+ label: `push ${branch}`,
1885
+ run: () => source.push(branch),
1886
+ undo: {
1887
+ label: `delete ${branch} on origin`,
1888
+ run: () => source.deleteRemoteBranch(branch),
1889
+ byHand: () => [`git push origin --delete ${branch}`]
1890
+ }
1891
+ });
1892
+ /** Opens a pull request; undone by closing it, with a comment saying why. */
1893
+ const openPrStep = ({ services: { codeHost: host } }, label, open) => {
1894
+ let opened = null;
1895
+ return {
1896
+ label,
1897
+ run: async () => {
1898
+ opened = await open();
1899
+ },
1900
+ undo: {
1901
+ label: "close the pull request",
1902
+ run: async () => {
1903
+ if (opened) await host.closePr(opened, "The release stopped part way, so it closed this.");
1904
+ },
1905
+ byHand: () => opened ? [`gh pr close ${opened.number}`] : []
1906
+ }
1907
+ };
1908
+ };
1909
+ //#endregion
1910
+ //#region src/application/openReleasePr.ts
1911
+ const plural$2 = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
1912
+ /** What happens to a unit once the release PR merges: its module ships the version to preview. */
1913
+ const shipsOnMerge = (context, { contributions, companions }) => (bump) => {
1914
+ const contributed = contributions[bump.app]?.onMerge;
1915
+ if (contributed) return contributed;
1916
+ const unit = context.release.units.find(({ name }) => name === bump.app);
1917
+ const along = companions.find(({ app }) => app === bump.app);
1918
+ const reason = along ? ` (not picked: ${along.why})` : bump.movedWith.length > 0 ? ` (moved with ${bump.movedWith.join(", ")})` : "";
1919
+ return `${environmentLabel(context, [bump.app], "preview") === "live" ? "Ship live" : "Ship to preview"} with ${(unit && moduleOf(context, unit)?.provider) ?? "its target"}${reason}`;
1920
+ };
1921
+ /** Units going out unpicked, each with the package that takes it along. */
1922
+ const printCompanions = ({ output, release }, { companions, split }) => {
1923
+ if (companions.length === 0) return;
1924
+ const names = companions.map(({ app }) => app);
1925
+ const verb = names.length === 1 ? "is not picked but ships too" : "are not picked but ship too";
1926
+ output.line(` ${paint(["bold", "yellow"], "!")} ${paint("bold", `${listed(names)} ${verb}:`)}`);
1927
+ companions.forEach(({ app, version, why }) => {
1928
+ const packageName = release.units.find(({ name }) => name === app)?.packageName;
1929
+ const waiting = split.waits.filter(({ releases }) => releases.some(({ name }) => name === packageName)).length;
1930
+ const own = waiting > 0 ? ` · picking it ships its ${plural$2(waiting, "changeset")} too` : "";
1931
+ output.line(` ${app.padEnd(11)}${version.padEnd(20)}${paint("dim", `${why}${own}`)}`);
1932
+ });
1933
+ output.line();
1934
+ };
1935
+ /** The table a person reads before anything is written: each unit, its move, what ships. */
1936
+ const printSummary = (context, prepared) => {
1937
+ const { output, release } = context;
1938
+ const { bumps, packages, pending, held, unreleased, contributions, companions } = prepared;
1939
+ const dot = paint("dim", "·");
1940
+ const stays = held.filter((app) => !bumps.some((bump) => bump.app === app));
1941
+ const heldLabel = stays.length > 0 ? ` ${dot} ${stays.join(", ")} held` : "";
1942
+ const where = environmentLabel(context, bumps.map(({ app }) => app), "preview");
1943
+ output.line();
1944
+ output.line(` ${paint("bold", "Release")} ${dot} ${where} ${dot} ${plural$2(pending, "changeset")}${heldLabel}`);
1945
+ output.line();
1946
+ const width = Math.max(13, ...release.units.map(({ name }) => name.length)) + 2;
1947
+ output.line(paint("dim", ` ${"Unit".padEnd(width)}${"Version".padEnd(20)}${where === "live" ? "Ships live" : "Ships to preview"}`));
1948
+ release.units.forEach((unit) => {
1949
+ const bump = bumps.find(({ app }) => app === unit.name);
1950
+ const version = bump ? `${bump.from} → ${bump.to}` : unit.version;
1951
+ const left = unreleased.find(({ app }) => app === unit.name);
1952
+ const ships = (() => {
1953
+ if (held.includes(unit.name) && !bump) return paint("yellow", "⏸ held, its changesets stay pending");
1954
+ if (left && !bump) return paint("yellow", `! ${plural$2(left.commits.length, "commit")} since ${left.version}, no changeset: not in this release`);
1955
+ const contributed = contributions[unit.name]?.summary;
1956
+ if (contributed && contributed.length > 0) return contributed.join(`\n ${" ".repeat(width + 20)}`);
1957
+ if (!bump) return paint("dim", "– nothing changed");
1958
+ const along = companions.some(({ app }) => app === unit.name) ? paint("yellow", " not picked, goes along") : "";
1959
+ return `${paint("green", "↑ ship")} ${paint("dim", moduleOf(context, unit)?.provider ?? "")}${along}`;
1960
+ })();
1961
+ output.line(` ${unit.name.padEnd(width)}${version.padEnd(20)}${ships}`);
1962
+ });
1963
+ if (packages > 0) output.line(` ${"packages".padEnd(width)}${`${packages} bumped`.padEnd(20)}${paint("dim", "changelogs only, nothing published")}`);
1964
+ output.line();
1965
+ printCompanions(context, prepared);
1966
+ };
1967
+ /**
1968
+ * Versions what `prepared` covers on one branch from main, opens its PR, and goes back to main.
1969
+ * Null, with what to do, when it must not run.
1970
+ */
1971
+ const openReleasePr = async (context, prepared, replaces = []) => {
1972
+ const { output, services, clock } = context;
1973
+ printSummary(context, prepared);
1974
+ const blocked = Object.values(prepared.contributions).find((entry) => entry.blocked)?.blocked;
1975
+ if (blocked) {
1976
+ fail(context, blocked.title, blocked.detail, blocked.commands);
1977
+ return null;
1978
+ }
1979
+ const source = releaseSource("build", "preview", await services.sourceControl.position());
1980
+ if (!source.allowed) {
1981
+ fail(context, source.why === "not-main" ? "Not from main" : "main is behind origin", "a release versions what is merged.", [
1982
+ "git switch main",
1983
+ "git pull",
1984
+ "shiplane"
1985
+ ]);
1986
+ return null;
1987
+ }
1988
+ if (!await services.sourceControl.isClean()) {
1989
+ fail(context, "Uncommitted changes", "commit or stash them first, the release PR commits every change.");
1990
+ return null;
1991
+ }
1992
+ const kindOf = (app) => {
1993
+ const unit = context.release.units.find(({ name }) => name === app);
1994
+ return unit && moduleOf(context, unit)?.kind;
1995
+ };
1996
+ const groups = prGroupsOf(context, prepared);
1997
+ const titles = groups.map((group) => releaseTitle(group, kindOf));
1641
1998
  const planned = [
1642
- "Open the release PR, then wait for you to squash merge it",
1999
+ groups.length > 1 ? `Open ${groups.length} release PRs from main, one per app, then wait for you to squash merge each:\n${titles.map((title) => ` ${title}`).join("\n")}` : "Open the release PR, then wait for you to squash merge it",
1643
2000
  "Tag each version and publish its release notes",
1644
2001
  ...Object.values(prepared.contributions).flatMap(({ step }) => step ? [step] : [])
1645
2002
  ];
@@ -1650,9 +2007,40 @@ const openReleasePr = async (context, prepared) => {
1650
2007
  output.line(paint("dim", "Nothing ran."));
1651
2008
  return null;
1652
2009
  }
1653
- const branch = releaseBranchName(clock.now());
1654
- const title = releaseTitle(prepared.bumps);
2010
+ const now = clock.now();
1655
2011
  const prs = [];
2012
+ for (const group of groups) {
2013
+ const apps = new Set(group.map(({ app }) => app));
2014
+ const scoped = groups.length > 1 ? await prepareRelease(context, apps, prepared.contributions) : prepared;
2015
+ const [first] = group;
2016
+ const pr = await openOne(context, scoped, kindOf, `${releaseBranchName(now)}${groups.length > 1 && first ? `-${first.app}` : ""}`, replaces);
2017
+ if (!pr) {
2018
+ if (prs.length > 0) output.line(paint("dim", ` ${listed(prs.map(({ number }) => `#${number}`))} stay open: merge them, then run shiplane for the rest.`));
2019
+ return null;
2020
+ }
2021
+ prs.push(pr);
2022
+ }
2023
+ return prs;
2024
+ };
2025
+ /**
2026
+ * The apps each release PR takes: one PR per app, a family as one. Apps one changeset names or
2027
+ * one moving with the other share a PR. A release moving internal packages stays one PR: their
2028
+ * changelog lines have no app to go with.
2029
+ */
2030
+ const prGroupsOf = ({ release }, prepared) => {
2031
+ if (prepared.packages > 0) return [prepared.bumps];
2032
+ const appOf = (packageName) => release.units.find((unit) => unit.packageName === packageName)?.name;
2033
+ const linked = [...prepared.shipped.map(({ releases }) => releases.map(({ name }) => appOf(name) ?? name)), ...prepared.bumps.map(({ app, movedWith }) => [app, ...movedWith.map((name) => appOf(name) ?? name)])];
2034
+ return releasePrGroups(prepared.bumps, linked);
2035
+ };
2036
+ /** The line a release PR opens with when it takes the place of release PRs main moved past. */
2037
+ const replacedLine = (replaces) => replaces.length === 0 ? "" : `Replaces ${listed(replaces.map(({ number }) => `#${number}`))}, which went out of date when main moved.\n\n`;
2038
+ /** Versions `prepared` on `branch` from main, opens its PR, and goes back to main. */
2039
+ const openOne = async (context, prepared, kindOf, branch, replaces) => {
2040
+ const { services } = context;
2041
+ const title = releaseTitle(prepared.bumps, kindOf);
2042
+ const skipHooks = !titleFits(title);
2043
+ const created = {};
1656
2044
  return await runSteps(context, [
1657
2045
  branchStep(context, branch),
1658
2046
  {
@@ -1662,38 +2050,37 @@ const openReleasePr = async (context, prepared) => {
1662
2050
  ...Object.values(prepared.contributions).flatMap(({ writes }) => writes),
1663
2051
  {
1664
2052
  label: `commit "${title}"`,
1665
- run: async () => services.sourceControl.commit(await services.sourceControl.changedFiles(), title, releaseCommitBody(prepared.bumps) || void 0)
2053
+ run: async () => services.sourceControl.commit(await services.sourceControl.changedFiles(), title, releaseCommitBody(prepared.bumps) || void 0, { skipHooks })
1666
2054
  },
1667
2055
  pushStep(context, branch),
1668
2056
  openPrStep(context, "open the release pull request", async () => {
1669
- const pr = await services.codeHost.createPr({
2057
+ created.pr = await services.codeHost.createPr({
1670
2058
  base: "main",
1671
2059
  head: branch,
1672
2060
  title,
1673
- body: releasePrBody(prepared.bumps, shipsOnMerge(context, prepared)),
2061
+ body: replacedLine(replaces) + releasePrBody(prepared.bumps, shipsOnMerge(context, prepared)),
1674
2062
  label: "type: chore"
1675
2063
  });
1676
- prs.push(pr);
1677
- return pr;
2064
+ return created.pr;
1678
2065
  }),
1679
2066
  {
1680
2067
  label: "back to main",
1681
2068
  run: () => services.sourceControl.switchTo("main")
1682
2069
  }
1683
- ]) ? prs : null;
2070
+ ]) && created.pr ? created.pr : null;
1684
2071
  };
1685
2072
  //#endregion
1686
2073
  //#region src/domain/scope.ts
1687
- const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
2074
+ const plural$1 = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
1688
2075
  const previewChoice = ({ version, changesets, commits, tagged, versioned, firstRelease, onChannel, decidedBy, releaseOnly }) => {
1689
2076
  const later = decidedBy ? ` · ${decidedBy.platform} decides ${decidedBy.choice} once picked` : "";
1690
2077
  if (changesets > 0) return {
1691
2078
  pending: true,
1692
- hint: `${plural(changesets, "changeset")}${later}`
2079
+ hint: `${plural$1(changesets, "changeset")}${later}`
1693
2080
  };
1694
2081
  if (commits > 0) return {
1695
2082
  pending: true,
1696
- hint: `${plural(commits, "commit")} since ${version}, changelog from its commits${later}`
2083
+ hint: `${plural$1(commits, "commit")} since ${version}, changelog from its commits${later}`
1697
2084
  };
1698
2085
  if (!tagged) {
1699
2086
  if (versioned) return {
@@ -1755,80 +2142,6 @@ const scopeChoices = (apps, channel) => apps.map((info) => ({
1755
2142
  ...channel === "production" ? productionChoice(info) : previewChoice(info)
1756
2143
  }));
1757
2144
  //#endregion
1758
- //#region src/application/readScope.ts
1759
- const MANIFEST = "package.json";
1760
- const unitRefs = (units) => units.map(({ name, packageName }) => ({
1761
- name,
1762
- packageName
1763
- }));
1764
- /** The units the pending changesets name. */
1765
- const namedUnits = async ({ release, services }) => new Set((await services.versioning.pending()).flatMap(({ text }) => changesetApps(text, unitRefs(release.units))));
1766
- /** Units whose folder moved since their current version, that no changeset or bump ships. */
1767
- const findUnreleased = async ({ release, services: { sourceControl: source } }, named) => {
1768
- if (!release.releasesCommits) return [];
1769
- return unreleasedApps((await Promise.all(release.units.map(async ({ name, dir, version }) => {
1770
- const since = await source.tagCommit(tagName(name, version, release.tagFormat)) ?? (await source.versionCommit(dir, "package.json", version))?.sha;
1771
- if (!since) return [];
1772
- return [{
1773
- app: name,
1774
- version,
1775
- commits: await source.subjectsSince(since, dir, UNIT_FILES)
1776
- }];
1777
- }))).flat(), named);
1778
- };
1779
- /** A tag's deploy on an environment, from every record the host keeps. */
1780
- const deployedOn = (history, tag, environment) => {
1781
- const states = history.filter(({ title }) => title === deployRunTitle(tag, environment)).map(({ state }) => state);
1782
- if (states.includes("done")) return "done";
1783
- return states.includes("running") ? "running" : "none";
1784
- };
1785
- /**
1786
- * Each unit as the first question sees it: git for what is new, the host's deploy records for what
1787
- * each environment runs (offline, nothing counts as deployed).
1788
- */
1789
- const readScope = async (context, environment) => {
1790
- const { release, services } = context;
1791
- const pending = await services.versioning.pending();
1792
- const refs = unitRefs(release.units);
1793
- const named = pending.map(({ text }) => changesetApps(text, refs));
1794
- const unreleased = await findUnreleased(context, new Set(named.flat()));
1795
- const [deployed, tags] = await Promise.all([services.codeHost.deployments().catch(() => []), services.sourceControl.tags()]);
1796
- return Promise.all(release.units.map(async (unit) => {
1797
- const tag = tagName(unit.name, unit.version, context.release.tagFormat);
1798
- const target = moduleOf(context, unit);
1799
- const decidedBy = target?.decidedBy;
1800
- const commit = await services.sourceControl.versionCommit(unit.dir, MANIFEST, unit.version);
1801
- const tagged = await services.sourceControl.tagCommit(tag) !== null;
1802
- const live = async (on) => {
1803
- if (!target?.live || !tagged) return deployedOn(deployed, tag, on) === "done";
1804
- const { head } = await services.sourceControl.position();
1805
- const input = jobInput(context, target, unit, {
1806
- tag,
1807
- environment: on,
1808
- commit: head
1809
- });
1810
- return target.live(decideContext(context), input).catch(() => false);
1811
- };
1812
- return {
1813
- app: unit.name,
1814
- version: unit.version,
1815
- changesets: named.filter((apps) => apps.includes(unit.name)).length,
1816
- commits: unreleased.find((entry) => entry.app === unit.name)?.commits.length ?? 0,
1817
- tagged,
1818
- versioned: commit !== null && cameWithRelease({
1819
- app: unit.name,
1820
- version: unit.version,
1821
- commit
1822
- }),
1823
- firstRelease: !tagged && commit !== null && firstRelease(unit.name, unit.version, tags, context.release.tagFormat),
1824
- onChannel: await live(environment),
1825
- onPreview: await live("preview"),
1826
- ...decidedBy ? { decidedBy } : {},
1827
- ...target?.releaseOnly ? { releaseOnly: true } : {}
1828
- };
1829
- }));
1830
- };
1831
- //#endregion
1832
2145
  //#region src/application/pickScope.ts
1833
2146
  /** Every unit with something to release here: what --yes and a run without a terminal cover. */
1834
2147
  const defaultScope = (info, environment) => new Set(scopeChoices(info, environment).filter(({ pending }) => pending).map(({ app }) => app));
@@ -1920,196 +2233,26 @@ const planShips = async (context, environment) => {
1920
2233
  tag,
1921
2234
  environment
1922
2235
  });
1923
- const plan = shipPlanOf(context, module, jobInput(context, module, unit, {
1924
- tag,
1925
- environment,
1926
- commit: head
1927
- }));
1928
- output.line();
1929
- output.line(` ${paint("bold", tag)} → ${plan.where}${tagged ? "" : paint("yellow", " (not tagged yet: release first)")}`);
1930
- plan.jobs.forEach((job) => {
1931
- output.line(` ${paint("dim", "this machine")}`);
1932
- job.local.forEach((command) => output.line(` ${commandLine(command)}`));
1933
- if (job.record) output.line(` ${paint("dim", `then record ${tag} on ${environment} in GitHub Deployments`)}`);
1934
- if (job.ci) {
1935
- const workflow = services.ciPipeline.shipWorkflow;
1936
- output.line(` ${paint("dim", "GitHub Actions")}`);
1937
- output.line(` gh workflow run ${workflow} --ref ${job.ci.ref} -f units=${unit.name} -f environment=${environment}`);
1938
- }
1939
- });
1940
- }
1941
- await planFollowUps(context, shipped);
1942
- output.line();
1943
- };
1944
- //#endregion
1945
- //#region src/domain/companions.ts
1946
- /** The shortest chain of moving packages from `from` to one a changeset names, breadth first. */
1947
- const chainTo = (from, dependencies, moving, named) => {
1948
- const seen = /* @__PURE__ */ new Set();
1949
- let paths = [[from]];
1950
- while (paths.length > 0) {
1951
- const next = [];
1952
- for (const path of paths) {
1953
- const last = path[path.length - 1] ?? from;
1954
- for (const dependency of dependencies[last] ?? []) {
1955
- if (!moving.has(dependency) || seen.has(dependency)) continue;
1956
- seen.add(dependency);
1957
- const chain = [...path, dependency];
1958
- if (named.has(dependency)) return chain.slice(1);
1959
- next.push(chain);
1960
- }
1961
- }
1962
- paths = next;
1963
- }
1964
- return [];
1965
- };
1966
- /**
1967
- * Preview: the units a release moves that the person did not pick. changesets moves a unit whenever
1968
- * a workspace package it uses moves, so it cannot stay behind; this says through which package.
1969
- */
1970
- const draggedUnits = (plan, dependencies, units, scope) => {
1971
- const moving = new Set(plan.releases.map(({ name }) => name));
1972
- const named = new Set(plan.releases.filter(({ changesets }) => changesets.length > 0).map(({ name }) => name));
1973
- const picked = units.filter(({ name }) => scope.has(name));
1974
- return units.flatMap(({ name: app, packageName }) => {
1975
- const release = plan.releases.find(({ name }) => name === packageName);
1976
- if (scope.has(app) || !release) return [];
1977
- const chain = chainTo(packageName, dependencies, moving, named);
1978
- const source = chain[chain.length - 1];
1979
- const movers = picked.filter((unit) => plan.changesets.some(({ releases }) => releases.some(({ name }) => name === source) && releases.some(({ name }) => name === unit.packageName))).map(({ name }) => name);
1980
- const whose = movers.length > 0 ? `${movers.join(", ")}'s changes move` : "this release moves";
1981
- return [{
1982
- app,
1983
- version: release.newVersion,
1984
- with: movers,
1985
- why: chain.length > 0 ? `uses ${chain.join(" → ")}, which ${whose}` : "moves with this release"
1986
- }];
1987
- });
1988
- };
1989
- const OWN_CHANGE = /^- ([0-9a-f]{7,40}): /gm;
1990
- const DEPENDENCY_CHANGES = /^- Updated dependencies \[([^\]]+)\]/gm;
1991
- /** The changes a version carries: its own, and those a package it uses moved for. */
1992
- const changeIds = (notes) => new Set([...[...notes.matchAll(OWN_CHANGE)].flatMap(([, id]) => id ? [id] : []), ...[...notes.matchAll(DEPENDENCY_CHANGES)].flatMap(([, ids]) => (ids ?? "").split(",").map((id) => id.trim()))]);
1993
- /** A change's first line in these notes, with an ellipsis when it goes on. */
1994
- const summaryOf = (notes, id) => {
1995
- const lines = notes.split("\n");
1996
- const index = lines.findIndex((line) => line.startsWith(`- ${id}: `));
1997
- const first = lines[index]?.slice(`- ${id}: `.length).trim();
1998
- if (index < 0 || !first) return null;
1999
- return /^ {2}\S/.test(lines[index + 1] ?? "") ? `${first}…` : first;
2000
- };
2001
- /** The packages listed under the `Updated dependencies` line that names this change. */
2002
- const packagesMovedFor = (notes, id) => {
2003
- const lines = notes.split("\n");
2004
- const start = lines.findIndex((line) => line.startsWith("- Updated dependencies [") && line.includes(id));
2005
- if (start < 0) return [];
2006
- const listed = lines.slice(start + 1);
2007
- const end = listed.findIndex((line) => !/^ {2}- \S+@/.test(line));
2008
- return (end < 0 ? listed : listed.slice(0, end)).map((line) => line.trim().slice(2).replace(/@[^@]*$/, ""));
2009
- };
2010
- /** Why two versions went out together: the change they share, or the package both moved for. */
2011
- const sharedReason = (partner, other, id) => {
2012
- const summary = summaryOf(partner.notes, id) ?? summaryOf(other.notes, id);
2013
- if (summary) return ` for: ${summary}`;
2014
- const theirs = new Set(packagesMovedFor(partner.notes, id));
2015
- const both = packagesMovedFor(other.notes, id).filter((name) => theirs.has(name));
2016
- return both.length > 0 ? `: both use ${both.join(", ")}, which moved` : "";
2017
- };
2018
- /**
2019
- * Production: the units preview runs with the picked ones that are not picked. Two versions went to
2020
- * preview together when their notes share a change, their own or one a package they use moved for.
2021
- */
2022
- const releasedTogether = (picked, others) => others.flatMap((other) => {
2023
- const ids = changeIds(other.notes);
2024
- const partners = picked.flatMap((partner) => {
2025
- const shared = [...changeIds(partner.notes)].find((id) => ids.has(id));
2026
- return shared ? [{
2027
- partner,
2028
- shared
2029
- }] : [];
2030
- });
2031
- const [first] = partners;
2032
- if (!first) return [];
2033
- const names = partners.map(({ partner }) => `${partner.app} ${partner.version}`).join(", ");
2034
- return [{
2035
- app: other.app,
2036
- version: other.version,
2037
- with: partners.map(({ partner }) => partner.app),
2038
- why: `went to preview with ${names}${sharedReason(first.partner, other, first.shared)}`
2039
- }];
2040
- });
2041
- //#endregion
2042
- //#region src/application/prepareRelease.ts
2043
- const NOTHING_HELD = {
2044
- ships: [],
2045
- waits: []
2046
- };
2047
- /** The person's answer to a plugin's choice; the suggestion without a terminal or with --yes. */
2048
- const choose = async ({ prompter, options }, choice) => {
2049
- if (!choice) return null;
2050
- if (options.yes || !prompter.interactive) return choice.suggested;
2051
- return prompter.select(choice.question, choice.options, choice.suggested);
2052
- };
2053
- /** What each picked unit's plugin adds, given the unit's bump so far. One at a time: it may ask. */
2054
- const contributionsOf = async (context, scope, bumps) => {
2055
- const { head } = await context.services.sourceControl.position();
2056
- const contributions = {};
2057
- for (const unit of context.release.units.filter(({ name }) => scope.has(name))) {
2058
- const module = moduleOf(context, unit);
2059
- const version = module?.version?.bind(module);
2060
- if (!module || !version) continue;
2061
- const input = jobInput(context, module, unit, {
2062
- tag: tagName(unit.name, unit.version, context.release.tagFormat),
2063
- environment: "preview",
2064
- commit: head
2065
- });
2066
- const bump = bumps.find(({ app }) => app === unit.name);
2067
- const contribute = (chosen) => version(decideContext(context), {
2068
- ...input,
2069
- bump,
2070
- chosen
2071
- });
2072
- const suggested = await contribute();
2073
- const chosen = await choose(context, suggested.choice);
2074
- contributions[unit.name] = chosen && chosen !== suggested.choice?.suggested ? await contribute(chosen) : suggested;
2236
+ const plan = shipPlanOf(context, module, jobInput(context, module, unit, {
2237
+ tag,
2238
+ environment,
2239
+ commit: head
2240
+ }));
2241
+ output.line();
2242
+ output.line(` ${paint("bold", tag)} → ${plan.where}${tagged ? "" : paint("yellow", " (not tagged yet: release first)")}`);
2243
+ plan.jobs.forEach((job) => {
2244
+ output.line(` ${paint("dim", "this machine")}`);
2245
+ job.local.forEach((command) => output.line(` ${commandLine(command)}`));
2246
+ if (job.record) output.line(` ${paint("dim", `then record ${tag} on ${environment} in GitHub Deployments`)}`);
2247
+ if (job.ci) {
2248
+ const workflow = services.ciPipeline.shipWorkflow;
2249
+ output.line(` ${paint("dim", "GitHub Actions")}`);
2250
+ output.line(` gh workflow run ${workflow} --ref ${job.ci.ref} -f units=${unit.name} -f environment=${environment}`);
2251
+ }
2252
+ });
2075
2253
  }
2076
- return contributions;
2077
- };
2078
- /** What a release PR covering `scope` would version, computed without writing anything. */
2079
- const prepareRelease = async (context, scope) => {
2080
- const { release, services } = context;
2081
- const refs = unitRefs(release.units);
2082
- const [dependencies, named, base, pendingFiles] = await Promise.all([
2083
- services.versioning.dependencies(),
2084
- namedUnits(context),
2085
- services.versioning.plan([], []),
2086
- services.versioning.pending()
2087
- ]);
2088
- const baseBumps = appBumps(base, dependencies, refs);
2089
- const unreleased = await findUnreleased(context, new Set([...named, ...baseBumps.map(({ app }) => app)]));
2090
- const held = [...named].filter((app) => !scope.has(app));
2091
- const adopted = unreleased.filter(({ app }) => scope.has(app)).flatMap(({ app, version, commits }) => {
2092
- const ref = refs.find(({ name }) => name === app);
2093
- return ref ? unreleasedChangesets(ref, version, commits) : [];
2094
- });
2095
- const split = held.length > 0 ? splitChangesets(base.changesets, held, refs) : NOTHING_HELD;
2096
- const picked = held.length > 0 || adopted.length > 0 ? await services.versioning.plan(adopted, split.waits) : base;
2097
- const contributions = await contributionsOf(context, scope, appBumps(picked, dependencies, refs));
2098
- const contributed = Object.values(contributions).flatMap(({ added }) => added);
2099
- const added = [...adopted, ...contributed];
2100
- const plan = contributed.length > 0 ? await services.versioning.plan(added, split.waits) : picked;
2101
- return {
2102
- pending: (held.length > 0 ? split.ships.length : pendingFiles.length) + added.length,
2103
- held,
2104
- unreleased: unreleased.filter(({ app }) => !scope.has(app)),
2105
- split,
2106
- bumps: appBumps(plan, dependencies, refs),
2107
- companions: draggedUnits(plan, dependencies, refs, scope),
2108
- packages: packageBumps(plan, refs),
2109
- added,
2110
- shipped: plan.changesets,
2111
- contributions
2112
- };
2254
+ await planFollowUps(context, shipped);
2255
+ output.line();
2113
2256
  };
2114
2257
  //#endregion
2115
2258
  //#region src/application/askPath.ts
@@ -2167,11 +2310,6 @@ const askPaths = async (context, environment, shipments) => {
2167
2310
  //#endregion
2168
2311
  //#region src/application/waitForMerge.ts
2169
2312
  const POLL_MS = 15e3;
2170
- const KEYS = [
2171
- "d",
2172
- "m",
2173
- "o"
2174
- ];
2175
2313
  /** Merges the pull request with the method the person picks. GitHub refuses approving your own PR. */
2176
2314
  const mergeHere = async (context, pr) => {
2177
2315
  const { choices, initial } = mergeChoices(await context.services.codeHost.mergeMethods());
@@ -2194,20 +2332,55 @@ const ACTIONS = {
2194
2332
  merge: mergeHere,
2195
2333
  open: (context, pr) => context.services.codeHost.openInBrowser(pr)
2196
2334
  };
2335
+ /** The keys a wait offers. Someone else approves a release that requires it: no merge from here. */
2336
+ const hintsFor = (approvalRequired) => [
2337
+ {
2338
+ key: "d",
2339
+ label: "see the diff"
2340
+ },
2341
+ ...approvalRequired ? [] : [{
2342
+ key: "m",
2343
+ label: "merge it from here"
2344
+ }],
2345
+ {
2346
+ key: "o",
2347
+ label: "open it on GitHub"
2348
+ },
2349
+ {
2350
+ key: "Ctrl-C",
2351
+ label: "leave, continue later"
2352
+ }
2353
+ ];
2197
2354
  /**
2198
- * True once merged, false when closed without a merge. It polls the host; in a terminal the person
2199
- * can also read the diff (d), merge from here (m) or open it in the browser (o).
2355
+ * Polls the host until the PR merges or closes; in a terminal the person can also read the diff
2356
+ * (d), merge from here (m, unless approval is required) or open it in the browser (o). Without a
2357
+ * terminal, a release waiting on someone's approval is left for a later run instead.
2200
2358
  */
2201
2359
  const waitForMerge = async (context, pr) => {
2202
2360
  const { output, prompter, services } = context;
2361
+ const approvalRequired = context.release.flow.approval === "required";
2203
2362
  output.line(` ${paint("green", "✓")} Release PR ${paint("cyan", pr.url)}`);
2204
- output.line(paint("dim", " Review and merge it here or on GitHub; this carries on by itself once merged."));
2205
- if (prompter.interactive) output.line(` ${paint("cyan", "d")} ${paint("dim", "see the diff")} ${paint("cyan", "m")} ${paint("dim", "merge it from here")} ${paint("cyan", "o")} ${paint("dim", "open it on GitHub")} ${paint("cyan", "Ctrl-C")} ${paint("dim", "stop, release picks up here")}`);
2363
+ if (approvalRequired) {
2364
+ output.line(` Waiting for approval on #${pr.number}. This can take a while.`);
2365
+ output.line(paint("dim", " It's safe to leave: run shiplane later and it picks up here."));
2366
+ } else output.line(paint("dim", " Review and merge it here or on GitHub; this carries on by itself once merged."));
2367
+ if (approvalRequired && !prompter.interactive) {
2368
+ const state = await services.codeHost.prState(pr).catch(() => "OPEN");
2369
+ if (state === "OPEN") return "left";
2370
+ return state === "MERGED" ? "merged" : "closed";
2371
+ }
2372
+ const hints = hintsFor(approvalRequired);
2373
+ if (prompter.interactive) {
2374
+ output.line();
2375
+ output.line(` ${keyHints(hints)}`);
2376
+ }
2206
2377
  output.line();
2378
+ const keys = prompter.interactive ? hints.map(({ key }) => key).filter((key) => key.length === 1) : [];
2207
2379
  for (;;) {
2208
2380
  const state = await services.codeHost.prState(pr).catch(() => "OPEN");
2209
- if (state !== "OPEN") return state === "MERGED";
2210
- const action = waitKey(await prompter.waitForKey(`Waiting for #${pr.number} to merge`, POLL_MS, prompter.interactive ? KEYS : []) ?? void 0);
2381
+ if (state !== "OPEN") return state === "MERGED" ? "merged" : "closed";
2382
+ const key = await prompter.waitForKey(approvalRequired ? `Waiting for #${pr.number} to be approved and merged` : `Waiting for #${pr.number} to merge`, POLL_MS, keys);
2383
+ const action = key && keys.includes(key) ? waitKey(key) : null;
2211
2384
  if (action) await ACTIONS[action](context, pr);
2212
2385
  }
2213
2386
  };
@@ -2559,7 +2732,7 @@ const shipTo = async (context, environment, { scope, via }) => {
2559
2732
  environment
2560
2733
  })));
2561
2734
  if (runs.length > 0) output.line(` ${paint("cyan", "gh run list --limit 5")}`);
2562
- output.line(` ${paint("cyan", `shiplane status --channel ${environment}`)}`);
2735
+ if (going.some(({ module }) => module.kind !== "published-package")) output.line(` ${paint("cyan", `shiplane status --channel ${environment}`)}`);
2563
2736
  output.line();
2564
2737
  return !stuck;
2565
2738
  };
@@ -2703,6 +2876,38 @@ const tagRelease = async (context, tags) => {
2703
2876
  };
2704
2877
  //#endregion
2705
2878
  //#region src/application/releaseToPreview.ts
2879
+ const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
2880
+ /** The commits main gained since a release PR's branch, or none when the host did not say. */
2881
+ const movedPast = async (context, pr, originMain) => {
2882
+ if (!pr.head) return [];
2883
+ return context.services.sourceControl.commitsBetween(pr.head, originMain).catch(() => []);
2884
+ };
2885
+ /** Why a stale release PR closed, said on it, so a reviewer landing there knows where to go. */
2886
+ const closedComment = (replacement, subjects) => [
2887
+ `Closed by shiplane: ${plural(subjects.length, "commit")} ${subjects.length === 1 ? "was" : "were"} merged into main after this release PR was opened, so its changelog no longer matched what would ship.`,
2888
+ `Replaced by ${listed(replacement.map(({ number }) => `#${number}`))}, which versions everything merged so far. Please review that one.`,
2889
+ "",
2890
+ ...subjects.map((subject) => `- ${subject}`)
2891
+ ].join("\n");
2892
+ /**
2893
+ * Release PRs main moved past are replaced: a fresh one versions everything merged, then each
2894
+ * stale one closes with a comment pointing to it. The open ones, or null when that failed.
2895
+ */
2896
+ const refreshStale = async (context, prs, scope) => {
2897
+ const { originMain } = await context.services.sourceControl.position();
2898
+ const moved = await Promise.all(prs.map((pr) => movedPast(context, pr, originMain)));
2899
+ const subjects = [...new Set(moved.flat().map(({ subject }) => subject))];
2900
+ if (subjects.length === 0) return prs;
2901
+ const { output, progress } = context;
2902
+ const names = listed(prs.map(({ number }) => `#${number}`));
2903
+ progress.say("thinking", `↻ Release ${names} is out of date: ${plural(subjects.length, "commit")} landed on main since.`);
2904
+ output.line(paint("dim", " Replacing it so the changelog matches what ships."));
2905
+ const opened = await openReleasePr(context, await prepareRelease(context, scope), prs);
2906
+ if (!opened) return null;
2907
+ for (const pr of prs) await context.services.codeHost.closePr(pr, closedComment(opened, subjects));
2908
+ output.line(` ${paint("green", "✓")} Opened ${listed(opened.map(({ number }) => `#${number}`))}${context.release.flow.approval === "required" ? " (needs approval again)" : ""} ${paint("green", "✓")} Closed ${names}, with a comment pointing to it`);
2909
+ return opened;
2910
+ };
2706
2911
  const STAGES = [
2707
2912
  "What to release",
2708
2913
  "Versions",
@@ -2747,13 +2952,31 @@ const releaseToPreview = async (context) => {
2747
2952
  const opened = await openReleasePr(context, prepared);
2748
2953
  if (!opened) return false;
2749
2954
  prs = opened;
2750
- } else if (step.step === "wait-merge") prs = step.prs;
2955
+ } else if (step.step === "wait-merge") {
2956
+ const fresh = await refreshStale(context, step.prs, picked.scope);
2957
+ if (!fresh) return false;
2958
+ if (fresh === step.prs) {
2959
+ const waiting = context.release.flow.approval === "required" ? "approval" : "a merge";
2960
+ progress.say("thinking", `↻ Picking up release ${listed(fresh.map(({ number }) => `#${number}`))}: still waiting for ${waiting}`);
2961
+ output.line(paint("dim", " To cancel it, close it on GitHub."));
2962
+ }
2963
+ prs = fresh;
2964
+ } else if (missing.length > 0) {
2965
+ progress.say("thinking", `↻ Picking up a merged release`);
2966
+ output.line(paint("dim", ` Left to do: tag ${plural(missing.length, "version")} → ship to preview`));
2967
+ }
2751
2968
  if (prs.length > 0) stage("Merge");
2752
2969
  for (const pr of prs) {
2753
2970
  output.line();
2754
- if (!await waitForMerge(context, pr)) {
2755
- fail(context, `#${pr.number} was closed without a merge`, "nothing shipped.", ["shiplane"]);
2756
- return false;
2971
+ const outcome = await waitForMerge(context, pr);
2972
+ if (outcome === "closed") {
2973
+ progress.say("resting", `○ Release #${pr.number} was closed: nothing shipped.`);
2974
+ output.line(paint("dim", " Run shiplane to open a new release with everything pending."));
2975
+ return true;
2976
+ }
2977
+ if (outcome === "left") {
2978
+ output.line(paint("dim", ` Left #${pr.number} waiting. Run shiplane once it's approved.`));
2979
+ return true;
2757
2980
  }
2758
2981
  progress.say("happy", `${paint("green", "✓")} Release PR #${pr.number} merged`);
2759
2982
  }
@@ -2777,56 +3000,710 @@ const releaseToPreview = async (context) => {
2777
3000
  return shipTo(current, "preview", { scope: new Set([...picked.scope, ...tags.map(({ app }) => app)]) });
2778
3001
  };
2779
3002
  //#endregion
3003
+ //#region src/application/customAdapter.ts
3004
+ const CUSTOM_PORTS = {
3005
+ sourceControl: {
3006
+ key: "sourceControl",
3007
+ type: "SourceControlPort",
3008
+ label: "source control",
3009
+ kind: "flow",
3010
+ subject: `head: async () => (await port.position()).head,
3011
+ // TODO: write a file the repository does not track yet.
3012
+ change: () => Promise.resolve(),`
3013
+ },
3014
+ codeHost: {
3015
+ key: "codeHost",
3016
+ type: "CodeHostPort",
3017
+ label: "code host",
3018
+ kind: "flow",
3019
+ subject: `// TODO: a branch pushed with one commit, a tag, an issue comments can go on.
3020
+ branch: (name) => Promise.resolve(name),
3021
+ tag: () => Promise.resolve("app@1.0.0"),
3022
+ issue: { repository: "acme/repo", number: 1 },`
3023
+ },
3024
+ ciPipeline: {
3025
+ key: "ciPipeline",
3026
+ type: "CiPipelinePort",
3027
+ label: "CI pipeline",
3028
+ kind: "flow",
3029
+ subject: `// TODO: a workflow that exists and has never run.
3030
+ idle: "ship.yml",`
3031
+ },
3032
+ versioning: {
3033
+ key: "versioning",
3034
+ type: "VersioningPort",
3035
+ label: "versioning",
3036
+ kind: "flow",
3037
+ subject: `// TODO: a package this workspace holds, and its folder.
3038
+ workspace: { name: "@acme/api", folder: "apps/api" },`
3039
+ },
3040
+ serverHosting: {
3041
+ key: "serverHosting",
3042
+ type: "ServerHostingPort",
3043
+ label: "server hosting",
3044
+ kind: "delivery",
3045
+ subject: `{}`
3046
+ },
3047
+ staticHosting: {
3048
+ key: "staticHosting",
3049
+ type: "StaticHostingPort",
3050
+ label: "static hosting",
3051
+ kind: "delivery",
3052
+ subject: `{}`
3053
+ },
3054
+ mobileDistribution: {
3055
+ key: "mobileDistribution",
3056
+ type: "MobileDistributionPort",
3057
+ label: "mobile distribution",
3058
+ kind: "delivery",
3059
+ subject: `{}`
3060
+ },
3061
+ packageRegistry: {
3062
+ key: "packageRegistry",
3063
+ type: "PackageRegistryPort",
3064
+ label: "package registry",
3065
+ kind: "delivery",
3066
+ subject: `{}`
3067
+ }
3068
+ };
3069
+ /** `jenkinsCiPipeline` → `jenkins-ci-pipeline`. */
3070
+ const kebab = (name) => name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
3071
+ /** A factory name a person can type: a letter, then letters and digits. */
3072
+ const isFactoryName = (name) => /^[a-z][a-zA-Z0-9]*$/.test(name);
3073
+ /** The name offered first: `customCiPipeline`. */
3074
+ const suggestedName = (port) => `custom${port.charAt(0).toUpperCase()}${port.slice(1)}`;
3075
+ /** Where a custom adapter lives, and what the config imports it from. */
3076
+ const customFiles = (name) => ({
3077
+ file: `shiplane/adapters/${kebab(name)}.ts`,
3078
+ test: `shiplane/adapters/${kebab(name)}.test.ts`,
3079
+ from: `./shiplane/adapters/${kebab(name)}`
3080
+ });
3081
+ const share = (name) => ` * Works? Share it: publish it as shiplane-${kebab(name)}, or open a pull request at
3082
+ * https://github.com/arnaud-zg/packages so everyone gets it.`;
3083
+ /** The adapter's file: shiplane's in-memory one under your name, ready to be replaced. */
3084
+ const renderCustomAdapter = (port, name, pkg) => {
3085
+ const { type, label, kind } = CUSTOM_PORTS[port];
3086
+ const memory = `${port}Memory`;
3087
+ if (kind === "delivery") return `import type { DeliveryAdapter, ${type} } from "${pkg}";
3088
+ import { z } from "${pkg}";
3089
+ import { ${memory} } from "${pkg}/memory";
3090
+
3091
+ /**
3092
+ * ${name}: your own ${label}. It starts in memory: it records each delivery it is asked for and
3093
+ * ships nothing, so the release runs end to end while you write it. To make it real, replace the
3094
+ * spread with define${type.replace(/Port$/, "")}({ ... }) from "${pkg}" (see: shiplane docs ${port}).
3095
+ * ${kebab(name)}.test.ts runs the contract every ${label} passes.
3096
+ ${share(name)}
3097
+ */
3098
+ export const ${name} = (): DeliveryAdapter<${type}> => ({
3099
+ ...${memory}(),
3100
+ name: "${name}",
3101
+ // The keys an app's unit file gives it: add yours, such as z.object({ service: z.string() }).
3102
+ settings: z.object({}),
3103
+ });
3104
+ `;
3105
+ return `import type { ${type}, ServiceAdapter } from "${pkg}";
3106
+ import { ${memory} } from "${pkg}/memory";
3107
+
3108
+ /**
3109
+ * ${name}: your own ${label}. It starts in memory: it records each call and does nothing real, so
3110
+ * the release runs end to end while you write it. Replace its methods one at a time;
3111
+ * ${kebab(name)}.test.ts runs the contract every ${label} passes.
3112
+ ${share(name)}
3113
+ */
3114
+ export const ${name} = (): ServiceAdapter<${type}> => ({
3115
+ name: "${name}",
3116
+ create: (context) => {
3117
+ const port: ${type} = ${memory}().create(context);
3118
+ // TODO: replace what it does with your own calls, for example:
3119
+ // port.someMethod = async (...args) => { ... };
3120
+ return port;
3121
+ },
3122
+ });
3123
+ `;
3124
+ };
3125
+ /** Its test: the port's contract, run on it. */
3126
+ const renderCustomTest = (port, name, pkg) => {
3127
+ const { kind, subject } = CUSTOM_PORTS[port];
3128
+ const contract = `${port}Contract`;
3129
+ const file = `./${kebab(name)}`;
3130
+ if (kind === "delivery") return `import { ${contract} } from "${pkg}/testing";
3131
+
3132
+ import { ${name} } from "${file}";
3133
+
3134
+ // The contract every ${CUSTOM_PORTS[port].label} passes. TODO: the settings an app gives it.
3135
+ ${contract}([{ adapter: ${name}(), settings: ${subject} }]);
3136
+ `;
3137
+ return `import { ${contract}, systemShell } from "${pkg}/testing";
3138
+
3139
+ import { ${name} } from "${file}";
3140
+
3141
+ // The contract every ${CUSTOM_PORTS[port].label} passes: green means ${name} is done.
3142
+ ${contract}("${name}", () => {
3143
+ const port = ${name}().create({ root: process.cwd(), shell: systemShell });
3144
+ return Promise.resolve({
3145
+ port,
3146
+ ${subject}
3147
+ });
3148
+ });
3149
+ `;
3150
+ };
3151
+ //#endregion
3152
+ //#region src/application/rehearse.ts
3153
+ var StepFailed = class extends Error {};
3154
+ /** One rehearsal check under a spinner when there is one: true when `work` says it passed. */
3155
+ const check = async (context, label, work) => {
3156
+ const run = async () => {
3157
+ if (!await work()) throw new StepFailed();
3158
+ };
3159
+ try {
3160
+ if (context.progress) await context.progress.during(label, "working", run);
3161
+ else {
3162
+ await run();
3163
+ context.output.line(` ${paint("green", "✓")} ${label}`);
3164
+ }
3165
+ return true;
3166
+ } catch (error) {
3167
+ if (!(error instanceof StepFailed)) {
3168
+ context.output.line(` ${paint("red", "✗")} ${label}`);
3169
+ context.output.line(` ${paint("dim", error instanceof Error ? error.message : String(error))}`);
3170
+ } else if (!context.progress) context.output.line(` ${paint("red", "✗")} ${label}`);
3171
+ return false;
3172
+ }
3173
+ };
3174
+ /** The package manager this repository runs scripts with. */
3175
+ const runner = (context) => context.files.exists("pnpm-lock.yaml") ? "pnpm" : context.files.exists("yarn.lock") ? "yarn" : context.files.exists("bun.lock") || context.files.exists("bun.lockb") ? "bun" : "npm";
3176
+ /** How a unit builds: its `buildCommand:`, else its package.json "build" script, else nothing. */
3177
+ const buildCommandOf = (context, unit) => {
3178
+ if (unit.buildCommand) return {
3179
+ command: "sh",
3180
+ args: ["-c", unit.buildCommand],
3181
+ shown: unit.buildCommand
3182
+ };
3183
+ if (!JSON.parse(context.files.read(path.posix.join(unit.dir, "package.json")) ?? "{}").scripts?.build) return null;
3184
+ const pm = runner(context);
3185
+ return {
3186
+ command: pm,
3187
+ args: ["run", "build"],
3188
+ shown: `${pm} run build`
3189
+ };
3190
+ };
3191
+ /**
3192
+ * A release played through with nothing pushed, published or deployed: the config loads, every app
3193
+ * builds, every ship plan resolves, every sign-in is there. Each failure says how to fix it.
3194
+ */
3195
+ const rehearse = async (context) => {
3196
+ const { output, shell, root } = context;
3197
+ output.line();
3198
+ output.line(` ${paint("bold", "Rehearsal")} ${paint("dim", "· nothing is pushed, published or deployed")}`);
3199
+ const release = await context.load();
3200
+ if (release.problems.length > 0) {
3201
+ release.problems.forEach(({ file, line, message, hint }) => {
3202
+ output.line(` ${paint("red", "✗")} ${line === void 0 ? file : `${file}:${line}`} ${message}`);
3203
+ if (hint) output.line(` ${paint("dim", hint)}`);
3204
+ });
3205
+ return false;
3206
+ }
3207
+ const builds = release.units.flatMap((unit) => {
3208
+ const build = buildCommandOf(context, unit);
3209
+ return build ? [{
3210
+ unit,
3211
+ build
3212
+ }] : [];
3213
+ });
3214
+ const results = [];
3215
+ const built = builds.length === 0 || await check(context, `build ${builds.length} app${builds.length === 1 ? "" : "s"}`, async () => {
3216
+ results.push(...await Promise.all(builds.map(async ({ unit, build }) => {
3217
+ const started = Date.now();
3218
+ const result = await shell.capture(build.command, build.args, { cwd: path.join(root, unit.dir) });
3219
+ return {
3220
+ unit,
3221
+ shown: build.shown,
3222
+ failed: result.status !== 0,
3223
+ seconds: `${((Date.now() - started) / 1e3).toFixed(1)}s`,
3224
+ tail: `${result.stderr}${result.stdout}`.trim().split("\n").slice(-3)
3225
+ };
3226
+ })));
3227
+ return results.every(({ failed }) => !failed);
3228
+ });
3229
+ for (const { unit, shown, failed, seconds, tail } of results) {
3230
+ output.line(` ${failed ? paint("red", "✗") : paint("green", "✓")} ${unit.dir.padEnd(18)}${paint("dim", `${shown} ${seconds}`)}`);
3231
+ if (!failed) continue;
3232
+ tail.forEach((line) => output.line(` ${paint("dim", line)}`));
3233
+ output.line(` ${paint("dim", `fix the build, or set buildCommand: in ${unit.file}`)}`);
3234
+ }
3235
+ const releaseContext = context.compose?.(release);
3236
+ const planned = !releaseContext || await check(context, `plan ${release.units.length} apps, nothing runs`, async () => {
3237
+ const { head } = await releaseContext.services.sourceControl.position();
3238
+ for (const unit of release.units) {
3239
+ const module = moduleOf(releaseContext, unit);
3240
+ if (!module) continue;
3241
+ shipPlanOf(releaseContext, module, jobInput(releaseContext, module, unit, {
3242
+ tag: tagName(unit.name, unit.version, release.tagFormat),
3243
+ environment: "preview",
3244
+ commit: head
3245
+ }));
3246
+ }
3247
+ return true;
3248
+ });
3249
+ let signedIn = true;
3250
+ for (const requirement of requirementsOf(release)) {
3251
+ const status = await checkStatus(shell, root, requirement);
3252
+ if (await check(context, requirement.label, () => Promise.resolve(status === 0))) continue;
3253
+ signedIn = false;
3254
+ const fix = status === 127 ? `not installed: ${requirement.check.command}` : requirement.fix ? `run ${commandLine(requirement.fix)}, then shiplane setup` : "not available here";
3255
+ output.line(` ${paint("dim", fix)}`);
3256
+ }
3257
+ return built && planned && signedIn;
3258
+ };
3259
+ //#endregion
3260
+ //#region src/application/setup.ts
3261
+ const ok = paint("green", "✓");
3262
+ const unsure = paint("yellow", "?");
3263
+ /** What a flow port is called, and what proves the ready-made adapter fits. */
3264
+ const FLOW_LABEL = {
3265
+ sourceControl: {
3266
+ label: "Source control",
3267
+ ready: "git"
3268
+ },
3269
+ codeHost: {
3270
+ label: "Code host",
3271
+ ready: "GitHub"
3272
+ },
3273
+ ciPipeline: {
3274
+ label: "CI pipeline",
3275
+ ready: "GitHub Actions"
3276
+ },
3277
+ versioning: {
3278
+ label: "Versioning",
3279
+ ready: "Changesets"
3280
+ }
3281
+ };
3282
+ /** The kinds of app a person picks from, in their words, and the delivery each one needs. */
3283
+ const APP_KINDS = [
3284
+ {
3285
+ value: "server-hosting",
3286
+ label: "Backend service",
3287
+ hint: "a server that runs"
3288
+ },
3289
+ {
3290
+ value: "static-hosting",
3291
+ label: "Web application",
3292
+ hint: "static files on a CDN"
3293
+ },
3294
+ {
3295
+ value: "mobile-distribution",
3296
+ label: "Mobile application",
3297
+ hint: "store builds and updates"
3298
+ },
3299
+ {
3300
+ value: "package-registry",
3301
+ label: "Published package",
3302
+ hint: "a library others install"
3303
+ },
3304
+ {
3305
+ value: "skip",
3306
+ label: "Internal tool",
3307
+ hint: "versioned, never deployed"
3308
+ }
3309
+ ];
3310
+ const CUSTOM_PORT_OF = {
3311
+ "server-hosting": "serverHosting",
3312
+ "static-hosting": "staticHosting",
3313
+ "mobile-distribution": "mobileDistribution",
3314
+ "package-registry": "packageRegistry"
3315
+ };
3316
+ const MODULE_OF = {
3317
+ sourceControl: "",
3318
+ codeHost: "",
3319
+ ciPipeline: "",
3320
+ versioning: "",
3321
+ serverHosting: "backendService",
3322
+ staticHosting: "webApp",
3323
+ mobileDistribution: "mobileApp",
3324
+ packageRegistry: "publishedPackage"
3325
+ };
3326
+ /** What proves each ready-made flow adapter fits this repository: hard evidence only. */
3327
+ const flowEvidence = async (context) => {
3328
+ const { files, shell, root } = context;
3329
+ const remote = files.exists(".git") ? (await shell.capture("git", [
3330
+ "remote",
3331
+ "get-url",
3332
+ "origin"
3333
+ ], { cwd: root })).stdout.trim() : "";
3334
+ const github = /github\.com[:/]([^/]+\/[^/.]+)/.exec(remote)?.[1];
3335
+ const workflows = files.list(".github/workflows").filter((file) => /\.ya?ml$/.test(file));
3336
+ return {
3337
+ sourceControl: files.exists(".git") ? ".git" : null,
3338
+ codeHost: github ? `remote github.com/${github}` : null,
3339
+ ciPipeline: workflows[0] ? `.github/workflows/${workflows[0]}` : null,
3340
+ versioning: files.exists(".changeset/config.json") ? ".changeset/config.json" : null
3341
+ };
3342
+ };
3343
+ /** A name for a custom adapter: asked, checked, unused. Null when cancelled. */
3344
+ const askName = async (context, port, initial) => {
3345
+ const { prompter, output, files } = context;
3346
+ for (;;) {
3347
+ const name = await prompter.text("Name it (you can rename it later)", initial);
3348
+ if (name === null) return null;
3349
+ if (!isFactoryName(name)) {
3350
+ output.line(` ${paint("red", "✗")} ${name}: a name like ${suggestedName(port)}`);
3351
+ continue;
3352
+ }
3353
+ if (files.exists(customFiles(name).file)) {
3354
+ output.line(` ${paint("red", "✗")} ${customFiles(name).file} already exists`);
3355
+ continue;
3356
+ }
3357
+ return name;
3358
+ }
3359
+ };
3360
+ /** The custom adapter's two files. */
3361
+ const customWrites = (port, name, pkg) => [{
3362
+ file: customFiles(name).file,
3363
+ text: renderCustomAdapter(port, name, pkg),
3364
+ created: true
3365
+ }, {
3366
+ file: customFiles(name).test,
3367
+ text: renderCustomTest(port, name, pkg),
3368
+ created: true
3369
+ }];
3370
+ /** The flow, from what the repository proves; asked part by part when unsure or when asked to. */
3371
+ const chooseFlow = async (context, yes, needsPerson, writes, pkg) => {
3372
+ const { output, prompter } = context;
3373
+ const evidence = await flowEvidence(context);
3374
+ output.line(paint("bold", " Flow"));
3375
+ FLOW_PORTS.forEach((port) => {
3376
+ const proof = evidence[port];
3377
+ const { label, ready } = FLOW_LABEL[port];
3378
+ output.line(proof ? ` ${ok} ${ready.padEnd(16)}${paint("dim", proof)}` : ` ${unsure} ${label.padEnd(16)}${paint("dim", "not sure: nothing here proves one")}`);
3379
+ });
3380
+ if (FLOW_PORTS.every((port) => evidence[port] !== null)) return DEFAULT_FLOW;
3381
+ if (yes) {
3382
+ needsPerson.push(...FLOW_PORTS.filter((port) => !evidence[port]).map((port) => `the ${FLOW_LABEL[port].label.toLowerCase()} (nothing proves one)`));
3383
+ return null;
3384
+ }
3385
+ const flow = { ...DEFAULT_FLOW };
3386
+ for (const port of FLOW_PORTS) {
3387
+ const { label, ready } = FLOW_LABEL[port];
3388
+ const picked = await prompter.select(`${label}?`, [{
3389
+ value: "ready",
3390
+ label: ready,
3391
+ hint: `${DEFAULT_FLOW[port].from}${evidence[port] ? "" : ", not found here"}`
3392
+ }, {
3393
+ value: "custom",
3394
+ label: "Custom",
3395
+ hint: "a no-op in memory you implement"
3396
+ }], evidence[port] ? "ready" : "custom");
3397
+ if (picked === null) return null;
3398
+ if (picked === "custom") {
3399
+ const name = await askName(context, port, suggestedName(port));
3400
+ if (name === null) return null;
3401
+ flow[port] = {
3402
+ factory: name,
3403
+ from: customFiles(name).from
3404
+ };
3405
+ writes.push(...customWrites(port, name, pkg));
3406
+ }
3407
+ }
3408
+ return flow;
3409
+ };
3410
+ /** Where the apps live: prefilled from the workspace when those folders exist, else typed. */
3411
+ const chooseFolders = async (context, yes, needsPerson) => {
3412
+ const { prompter, output, files } = context;
3413
+ const known = workspacePatterns(files).filter((pattern) => pattern.startsWith("!") || expandPatterns(files, [pattern]).length > 0);
3414
+ const found = expandPatterns(files, known).filter((dir) => dir !== ".");
3415
+ output.line();
3416
+ output.line(paint("bold", " Apps"));
3417
+ if (found.length > 0) {
3418
+ const patterns = known.filter((pattern) => !pattern.startsWith("!")).join(", ");
3419
+ if (yes || await prompter.confirm(`Your apps and packages are in ${patterns} (${found.length} folders)?`, true)) return known;
3420
+ } else if (yes) {
3421
+ needsPerson.push("where the apps are (no workspace folders found)");
3422
+ return null;
3423
+ }
3424
+ for (;;) {
3425
+ const typed = await prompter.text("Where are your apps and packages? (e.g. apps/*, web)");
3426
+ if (typed === null) return null;
3427
+ const patterns = typed.split(",").map((part) => part.trim()).filter(Boolean);
3428
+ const empty = patterns.filter((pattern) => expandPatterns(files, [pattern]).length === 0);
3429
+ if (patterns.length > 0 && empty.length === 0) return patterns;
3430
+ output.line(` ${paint("red", "✗")} ${empty.join(", ") || "nothing typed"} matches no folder: try again`);
3431
+ }
3432
+ };
3433
+ /** Folders under these patterns with a manifest and no unit file yet. */
3434
+ const newFolders = (context, patterns) => expandPatterns(context.files, patterns).filter((dir) => dir !== "." && context.files.exists(path.posix.join(dir, "package.json"))).filter((dir) => !UNIT_FILES.some((name) => context.files.exists(path.posix.join(dir, name)))).map((dir) => folderView(context.files, dir));
3435
+ /** How a folder ships: taken when an adapter is sure, asked otherwise. Null: not shipped. */
3436
+ const placeFolder = async (context, folder, state) => {
3437
+ const { prompter, output, adapters } = context;
3438
+ const sure = adapters.map((adapter) => ({
3439
+ adapter,
3440
+ detection: adapter.detect?.(folder) ?? null
3441
+ })).find(({ detection }) => detection?.certainty === "found");
3442
+ const place = (adapter) => {
3443
+ const { name, entry } = placeModule(adapter, state.modules, state.pkg);
3444
+ if (entry) {
3445
+ state.entries.push(entry);
3446
+ state.modules.push(moduleFor(adapter, name));
3447
+ }
3448
+ return name;
3449
+ };
3450
+ if (sure?.detection) {
3451
+ const kind = APP_KINDS.find(({ value }) => value === sure.adapter.capability)?.label ?? "";
3452
+ output.line(` ${ok} ${folder.dir.padEnd(18)}${kind} → ${sure.adapter.name} ${paint("dim", `proof: ${sure.detection.reason}`)}`);
3453
+ const options = await askOptions(context, folder, sure.adapter, sure.detection.options, state.yes);
3454
+ return {
3455
+ folder,
3456
+ module: place(sure.adapter),
3457
+ options,
3458
+ reason: sure.detection.reason
3459
+ };
3460
+ }
3461
+ if (state.yes) {
3462
+ state.needsPerson.push(`${folder.dir} (no adapter is sure what it is)`);
3463
+ return null;
3464
+ }
3465
+ output.line(` ${unsure} ${folder.dir.padEnd(18)}${paint("dim", "not sure what this is")}`);
3466
+ const answer = await prompter.select(`What is ${folder.dir}?`, [...state.modules.map((module) => ({
3467
+ value: `module:${module.name}`,
3468
+ label: `Like ${module.name}`,
3469
+ hint: `${module.kind} on ${module.provider}, already in your config`
3470
+ })), ...APP_KINDS.map(({ value, label, hint }) => ({
3471
+ value,
3472
+ label,
3473
+ hint
3474
+ }))]);
3475
+ if (answer === null) return null;
3476
+ if (answer.startsWith("module:")) return {
3477
+ folder,
3478
+ module: answer.slice(7),
3479
+ options: {}
3480
+ };
3481
+ const kind = answer;
3482
+ if (kind === "skip") return "skip";
3483
+ const fitting = adapters.filter((a) => a.capability === kind);
3484
+ const picked = fitting.length === 0 ? "custom" : await prompter.select(`Where does ${folder.dir} go?`, [...fitting.map((adapter) => ({
3485
+ value: adapter.name,
3486
+ label: adapter.name
3487
+ })), {
3488
+ value: "custom",
3489
+ label: "Custom",
3490
+ hint: "a no-op adapter you implement"
3491
+ }], fitting[0]?.name);
3492
+ if (picked === null) return null;
3493
+ const adapter = fitting.find(({ name }) => name === picked);
3494
+ if (adapter) {
3495
+ const options = await askOptions(context, folder, adapter, {}, false);
3496
+ return {
3497
+ folder,
3498
+ module: place(adapter),
3499
+ options
3500
+ };
3501
+ }
3502
+ const port = CUSTOM_PORT_OF[kind];
3503
+ const name = await askName(context, port, `${path.posix.basename(folder.dir)}Delivery`.replace(/-([a-z])/g, (_m, c) => c.toUpperCase()));
3504
+ if (name === null) return null;
3505
+ const module = kebab(name);
3506
+ state.entries.push({
3507
+ factory: MODULE_OF[port],
3508
+ port,
3509
+ adapter: name,
3510
+ name: module,
3511
+ from: customFiles(name).from
3512
+ });
3513
+ state.writes.push(...customWrites(port, name, state.pkg));
3514
+ return {
3515
+ folder,
3516
+ module,
3517
+ options: {}
3518
+ };
3519
+ };
3520
+ /** The command that builds a folder: its unit's, its package.json script's, or one asked once. */
3521
+ const buildFor = async (context, folder, yes) => {
3522
+ if (JSON.parse(context.files.read(path.posix.join(folder.dir, "package.json")) ?? "{}").scripts?.build) return null;
3523
+ if (yes) return null;
3524
+ const typed = await context.prompter.text(`${folder.dir} has no "build" script. Command to build it? (empty: nothing to build)`);
3525
+ return typed?.trim() ? typed.trim() : null;
3526
+ };
3527
+ /**
3528
+ * `shiplane setup`: the one command to set releases up and keep them right. It reads the
3529
+ * repository, takes what it can prove, asks only the rest, then rehearses a release (builds, plan,
3530
+ * sign-ins) with nothing pushed or deployed. Files are kept only when the rehearsal passes. Run
3531
+ * again, it says all is set or offers what changed.
3532
+ */
3533
+ const setup = async (context, { yes }) => {
3534
+ const { output, prompter, files } = context;
3535
+ const pkg = releasePackage(files);
3536
+ const needsPerson = [];
3537
+ const writes = [];
3538
+ output.line();
3539
+ output.line(` ${paint("bold", "shiplane setup")} ${paint("dim", path.basename(context.root))}`);
3540
+ output.line();
3541
+ const existing = files.exists("shiplane.config.ts") ? await context.load() : null;
3542
+ if (existing && existing.problems.length > 0) {
3543
+ existing.problems.forEach(({ file, line, message, hint }) => {
3544
+ output.line(` ${paint("red", "✗")} ${paint("bold", line === void 0 ? file : `${file}:${line}`)} ${message}`);
3545
+ if (hint) output.line(` ${paint("dim", hint)}`);
3546
+ });
3547
+ output.line(` ${paint("dim", "Fix these, then run shiplane setup again. Nothing written.")}`);
3548
+ return false;
3549
+ }
3550
+ const flow = existing ? null : await chooseFlow(context, yes, needsPerson, writes, pkg);
3551
+ if (existing) output.line(` ${ok} flow ${paint("dim", CONFIG_FILE)}`);
3552
+ else if (!flow && needsPerson.length === 0) return cancelled(context);
3553
+ const patterns = existing ? existing.units.length > 0 ? workspacePatterns(files) : await chooseFolders(context, yes, needsPerson) : await chooseFolders(context, yes, needsPerson);
3554
+ if (!patterns && needsPerson.length === 0) return cancelled(context);
3555
+ if (existing && existing.units.length > 0) output.line(` ${ok} ${existing.units.length} apps ${paint("dim", "unchanged, your edits kept")}`);
3556
+ const modules = [...existing?.modules ?? []];
3557
+ const entries = [];
3558
+ const placed = [];
3559
+ for (const folder of patterns ? newFolders(context, patterns) : []) {
3560
+ const result = await placeFolder(context, folder, {
3561
+ yes,
3562
+ needsPerson,
3563
+ modules,
3564
+ entries,
3565
+ writes,
3566
+ pkg
3567
+ });
3568
+ if (result === null && needsPerson.length === 0) return cancelled(context);
3569
+ if (result && result !== "skip") {
3570
+ const buildCommand = await buildFor(context, folder, yes);
3571
+ placed.push(buildCommand ? {
3572
+ ...result,
3573
+ options: {
3574
+ buildCommand,
3575
+ ...result.options
3576
+ }
3577
+ } : result);
3578
+ }
3579
+ }
3580
+ if (needsPerson.length > 0) {
3581
+ output.line();
3582
+ output.line(` ${paint("red", "✗")} ${needsPerson.length} thing${needsPerson.length === 1 ? "" : "s"} need${needsPerson.length === 1 ? "s" : ""} a person:`);
3583
+ needsPerson.forEach((item) => output.line(` ${item}`));
3584
+ output.line(` ${paint("dim", "Run shiplane setup without --yes. Nothing written.")}`);
3585
+ return false;
3586
+ }
3587
+ if (!existing) {
3588
+ const units = patterns && patterns.join() !== workspacePatterns(files).join() ? patterns : void 0;
3589
+ writes.unshift({
3590
+ file: CONFIG_FILE,
3591
+ text: renderConfig(entries, pkg, flow ?? DEFAULT_FLOW, units),
3592
+ created: true
3593
+ });
3594
+ } else if (entries.length > 0) {
3595
+ let config = files.read("shiplane.config.ts") ?? "";
3596
+ for (const entry of entries) config = addToConfig(config, entry, pkg) ?? config;
3597
+ writes.unshift({
3598
+ file: CONFIG_FILE,
3599
+ text: config,
3600
+ created: false
3601
+ });
3602
+ }
3603
+ placed.forEach(({ folder, module, options, reason }) => writes.push({
3604
+ file: path.posix.join(folder.dir, UNIT_FILE),
3605
+ text: renderUnit(module, options, {
3606
+ reason,
3607
+ schemaLine: schemaLineFor(folder.dir)
3608
+ }),
3609
+ created: true
3610
+ }));
3611
+ if (writes.length === 0) {
3612
+ const passed = await rehearse(context);
3613
+ if (passed) output.line(` ${ok} all set`);
3614
+ return passed;
3615
+ }
3616
+ const before = [...writes.map(({ file }) => file), SCHEMA_FILE].map((file) => ({
3617
+ file,
3618
+ text: files.read(file)
3619
+ }));
3620
+ writes.forEach(({ file, text }) => files.write(file, text));
3621
+ if (existing === null || entries.length > 0) {
3622
+ const release = await context.load();
3623
+ if (release.modules.length > 0) files.write(SCHEMA_FILE, schemaText(release.modules));
3624
+ }
3625
+ const passed = await rehearse(context);
3626
+ if (!(passed && (yes || await prompter.confirm("Releasable. Write it?", true)))) {
3627
+ before.forEach(({ file, text }) => text === null ? files.remove(file) : files.write(file, text));
3628
+ output.line(` ${paint("dim", passed ? "Nothing written." : "Fix it, then run shiplane setup again. Nothing written.")}`);
3629
+ return false;
3630
+ }
3631
+ writes.forEach(({ file, created }) => output.line(` ${created ? paint("green", "+") : paint("yellow", "~")} ${file}`));
3632
+ if (writes.some(({ file }) => file.startsWith("shiplane/adapters/"))) {
3633
+ output.line(` ${paint("dim", "Custom adapters start in memory: fill them in until their contract test passes.")}`);
3634
+ output.line(` ${paint("dim", "Works? Share it as shiplane-<name>, or open a pull request at github.com/arnaud-zg/packages.")}`);
3635
+ }
3636
+ output.line();
3637
+ output.line(` ${ok} ${paint("bold", "Ready.")} Add a changeset, merge, and run ${paint("cyan", "shiplane")}`);
3638
+ return true;
3639
+ };
3640
+ const cancelled = (context) => {
3641
+ context.output.line(` ${paint("dim", "Nothing written.")}`);
3642
+ return false;
3643
+ };
3644
+ //#endregion
2780
3645
  //#region src/adapters/terminal/live-line.ts
2781
- const CLEAR = "\r\x1B[2K";
2782
3646
  const TICK_MS = 140;
2783
3647
  /**
2784
- * The one line the release redraws in place: the mascot and what runs. Anything else printed goes
2785
- * above it, and a prompt or a child process holds it so the terminal is theirs meanwhile.
3648
+ * The one line the release redraws in place, an ora spinner. Anything else printed goes above it,
3649
+ * and a prompt or a child process holds it so the terminal is theirs meanwhile.
2786
3650
  */
2787
3651
  var LiveLine = class {
2788
- render = null;
2789
- timer = null;
2790
- tick = 0;
3652
+ spinner = null;
2791
3653
  held = 0;
2792
3654
  get busy() {
2793
- return this.render !== null;
2794
- }
2795
- show(render, animate) {
2796
- this.render = render;
2797
- this.tick = 0;
2798
- this.draw();
2799
- if (animate) this.timer = setInterval(() => {
2800
- this.tick += 1;
2801
- this.draw();
2802
- }, TICK_MS);
3655
+ return this.spinner !== null;
3656
+ }
3657
+ show({ frames, text, suffix }, animate) {
3658
+ this.spinner = ora({
3659
+ text,
3660
+ suffixText: suffix,
3661
+ stream: process.stdout,
3662
+ discardStdin: false,
3663
+ isEnabled: animate,
3664
+ ...frames && frames.length > 0 ? { spinner: {
3665
+ interval: TICK_MS,
3666
+ frames: [...frames]
3667
+ } } : { spinner: "dots" }
3668
+ });
3669
+ if (this.held === 0) this.spinner.start();
3670
+ }
3671
+ /** Ends the live line with a symbol kept on screen: ✓, ✗ or !. */
3672
+ finish(symbol, text) {
3673
+ const spinner = this.spinner;
3674
+ this.spinner = null;
3675
+ if (!spinner) return;
3676
+ if (this.held > 0) {
3677
+ process.stdout.write(`${symbol} ${text ?? spinner.text}\n`);
3678
+ return;
3679
+ }
3680
+ spinner.stopAndPersist({
3681
+ symbol,
3682
+ ...text === void 0 ? {} : { text }
3683
+ });
2803
3684
  }
2804
3685
  clear() {
2805
- if (this.timer) clearInterval(this.timer);
2806
- this.timer = null;
2807
- if (this.render && this.held === 0) process.stdout.write(CLEAR);
2808
- this.render = null;
3686
+ this.spinner?.stop();
3687
+ this.spinner = null;
2809
3688
  }
2810
3689
  /** Prints a line above the live one. */
2811
3690
  above(text) {
2812
- if (this.render && this.held === 0) process.stdout.write(CLEAR);
3691
+ const live = this.spinner && this.held === 0 ? this.spinner : null;
3692
+ live?.clear();
2813
3693
  process.stdout.write(`${text}\n`);
2814
- this.draw();
3694
+ live?.render();
2815
3695
  }
2816
3696
  /** Gives the terminal to `work`, a prompt or a child process, then draws the live line again. */
2817
3697
  async hold(work) {
2818
- if (this.render && this.held === 0) process.stdout.write(CLEAR);
3698
+ if (this.spinner && this.held === 0) this.spinner.stop();
2819
3699
  this.held += 1;
2820
3700
  try {
2821
3701
  return await work();
2822
3702
  } finally {
2823
3703
  this.held -= 1;
2824
- this.draw();
3704
+ if (this.spinner && this.held === 0) this.spinner.start();
2825
3705
  }
2826
3706
  }
2827
- draw() {
2828
- if (this.render && this.held === 0) process.stdout.write(`${CLEAR}${this.render(this.tick)}`);
2829
- }
2830
3707
  };
2831
3708
  const liveLine = new LiveLine();
2832
3709
  //#endregion
@@ -2916,6 +3793,6 @@ const readStatus = async (context, environment) => {
2916
3793
  };
2917
3794
  };
2918
3795
  //#endregion
2919
- export { ENVIRONMENTS as C, optionsFor as S, nodeFiles as T, addUnit as _, missingTags as a, doctor as b, shipTo as c, pickScope as d, openReleasePr as f, loadRelease as g, findConfig as h, releaseToPreview as i, prepareRelease as l, docsFor as m, systemShell as n, tagRelease as o, newAdapter as p, liveLine as r, promote as s, readStatus as t, planShips as u, removeUnit as v, keysAt as w, refreshEditorSchema as x, initRelease as y };
3796
+ export { refreshEditorSchema as C, nodeFiles as D, keysAt as E, CONFIG_FILE as S, ENVIRONMENTS as T, loadRelease as _, releaseToPreview as a, initRelease as b, promote as c, pickScope as d, openReleasePr as f, findConfig as g, docsFor as h, setup as i, shipTo as l, newAdapter as m, systemShell as n, missingTags as o, prepareRelease as p, liveLine as r, tagRelease as s, readStatus as t, planShips as u, addUnit as v, optionsFor as w, doctor as x, removeUnit as y };
2920
3797
 
2921
- //# sourceMappingURL=readStatus-D5YVR5ZC.js.map
3798
+ //# sourceMappingURL=readStatus-Bo7hpUT3.js.map