shiplane 0.6.0-fix-shiplane-ship-node-cache.3dccda9 → 0.6.0-main.463c3b2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { A as commandLine, C as initRelease, D as checkStatus, E as refreshEditorSchema, F as keysAt, I as nodeFiles, N as paint, O as requirementsOf, P as ENVIRONMENTS, S as removeUnit, _ as tagRelease, a as findConfig, b as prepareRelease, c as promote, d as docsFor, f as branchRelease, g as missingTags, h as readStatus, j as environmentLabel, k as signInsOf, l as planShips, m as shipTo, n as composeSetup, r as loadReleaseOnDisk, s as setup, t as composeContext, u as newAdapter, v as pickScope, w as doctor, x as addUnit, y as openReleasePr } from "./compose-BTQXZqHM.js";
2
+ import { A as checkStatus, B as fail, C as addUnit, E as doctor, F as decideContext, G as nodeFiles, H as reasonOf, I as environmentLabel, L as runHere, M as signInsOf, N as checkout, O as refreshEditorSchema, P as commandLine, R as unitTarget, S as plural, T as initRelease, U as ENVIRONMENTS, V as paint, W as keysAt, _ as tagRelease, a as findConfig, b as prepareRelease, c as promote, d as docsFor, f as branchRelease, g as missingTags, h as readStatus, j as requirementsOf, l as planShips, m as shipTo, n as composeSetup, r as loadReleaseOnDisk, s as setup, t as composeContext, u as newAdapter, v as pickScope, w as removeUnit, x as padded, y as openReleasePr } from "./compose-Jfnl-x4-.js";
3
3
  import { z } from "zod";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
@@ -88,6 +88,155 @@ const doctorCi = async (context, { units, channel }) => {
88
88
  passed("secrets", secrets.length > 0 ? [...new Set(secrets)].join(", ") : "none needed");
89
89
  return true;
90
90
  };
91
+ const DAY_MS = 1440 * 60 * 1e3;
92
+ const SNAPSHOT = /^\d+\.\d+\.\d+-([a-z0-9-]+)\.(g?[0-9a-f]{7})$/;
93
+ /**
94
+ * Whether a tag is one a shiplane snapshot left: its version has a snapshot's shape and the tag is
95
+ * that version's branch slug (as branch snapshots were tagged), `branch-<slug>`, or `snapshot`.
96
+ */
97
+ const isSnapshotTag = ({ tag, version }) => {
98
+ const slug = SNAPSHOT.exec(version)?.[1];
99
+ if (slug === void 0 || tag === "latest") return false;
100
+ return tag === slug || tag === `branch-${slug}` || tag === "snapshot";
101
+ };
102
+ /** Why an age cannot be one, or null when it can. */
103
+ const ageProblem = (days) => Number.isInteger(days) && days >= 7 ? null : `--older-than takes a whole number of days, 7 or more`;
104
+ /** Whole days between a publish time and now; null when the time is missing or unreadable. */
105
+ const ageInDays = (publishedAt, now) => {
106
+ const at = publishedAt === null ? NaN : Date.parse(publishedAt);
107
+ return Number.isNaN(at) ? null : Math.floor((now.getTime() - at) / DAY_MS);
108
+ };
109
+ /**
110
+ * The snapshot tags old enough to remove: a shiplane snapshot's tag, on a version published at
111
+ * least `olderThanDays` ago, never the one `latest` points at. A version with no publish time is
112
+ * kept: old is never guessed.
113
+ */
114
+ const staleSnapshotTags = ({ tags, now, olderThanDays = 30 }) => {
115
+ const latest = tags.find(({ tag }) => tag === "latest")?.version;
116
+ return tags.flatMap((tagged) => {
117
+ const days = ageInDays(tagged.publishedAt, now);
118
+ if (!isSnapshotTag(tagged) || tagged.version === latest) return [];
119
+ return days !== null && days >= olderThanDays ? [{
120
+ ...tagged,
121
+ days
122
+ }] : [];
123
+ });
124
+ };
125
+ //#endregion
126
+ //#region src/application/pruneSnapshots.ts
127
+ /** Every package's snapshot tags at least `olderThanDays` old, as each registry lists them. */
128
+ const staleTags = async (context, olderThanDays) => {
129
+ const at = await checkout(context);
130
+ const decide = decideContext(context);
131
+ const now = context.clock.now();
132
+ return (await Promise.all(context.release.units.map(async (unit) => {
133
+ const target = unitTarget(context, {
134
+ unit,
135
+ environment: "preview",
136
+ ...at
137
+ });
138
+ const read = target?.module.tags;
139
+ if (!target || !read) return [];
140
+ const name = target.module.publishedName?.(decide, target.input) ?? unit.packageName;
141
+ return staleSnapshotTags({
142
+ tags: await read(decide, target.input),
143
+ now,
144
+ olderThanDays
145
+ }).map((stale) => ({
146
+ ...stale,
147
+ name,
148
+ target
149
+ }));
150
+ }))).flat();
151
+ };
152
+ const printTable = ({ output }, stale) => {
153
+ const [header = "", ...rows] = padded([[
154
+ "Package",
155
+ "Tag",
156
+ "Version",
157
+ "Published"
158
+ ], ...stale.map(({ name, tag, version, days }) => [
159
+ name,
160
+ tag,
161
+ version,
162
+ `${days} days ago`
163
+ ])]);
164
+ output.line(paint("dim", ` ${header}`));
165
+ rows.forEach((row) => output.line(` ${row}`));
166
+ };
167
+ /** Yes from the person in a terminal, or --yes anywhere: removing tags is never done unasked. */
168
+ const agreed = async (context, count) => {
169
+ if (context.options.yes) return true;
170
+ if (!context.prompter.interactive) {
171
+ fail(context, "Not removed", "add --yes to remove them without a terminal to ask in.");
172
+ return false;
173
+ }
174
+ return context.prompter.confirm(`Remove ${plural(count, "tag")}? Each version stays installable by its number.`);
175
+ };
176
+ /** The code passed with --otp, or one asked for in a terminal; none when the account needs none. */
177
+ const firstCode = async ({ prompter }, otp) => {
178
+ if (otp !== void 0 || !prompter.interactive) return otp;
179
+ return (await prompter.text("npm one-time code, if your account asks for one (Enter: none)"))?.trim() || void 0;
180
+ };
181
+ /**
182
+ * Removes each tag in turn, with one code for all. A failure in a terminal asks for a fresh code
183
+ * and retries, since a code lasts about 30 seconds; anywhere else it stops, and a rerun picks up
184
+ * the tags still there. False when it stopped.
185
+ */
186
+ const removeAll = async (context, stale, otp) => {
187
+ const decide = decideContext(context);
188
+ let code = otp;
189
+ for (const [index, entry] of stale.entries()) for (;;) {
190
+ const job = entry.target.module.untagJob?.(decide, entry.target.input, entry.tag, code);
191
+ if (!job) break;
192
+ try {
193
+ await context.progress.during(job.label, "working", () => runHere(context, job, {
194
+ tag: entry.target.tag,
195
+ environment: "preview"
196
+ }), {
197
+ index,
198
+ total: stale.length
199
+ });
200
+ break;
201
+ } catch (error) {
202
+ const fresh = context.prompter.interactive ? await context.prompter.text(`${job.label} failed: a fresh npm one-time code to retry (Enter: stop)`) : null;
203
+ if (!fresh?.trim()) {
204
+ fail(context, `${job.label} failed`, `${reasonOf(error)}; ${plural(index, "tag")} of ${stale.length} removed. A one-time code lasts about 30 seconds: run it again with a fresh --otp, it picks up the tags still there.`);
205
+ return false;
206
+ }
207
+ code = fresh.trim();
208
+ }
209
+ }
210
+ return true;
211
+ };
212
+ /**
213
+ * `shiplane prune-snapshots`: removes the npm tags old snapshots left, those of a version published
214
+ * `olderThanDays` ago or more (30 by default, never under 7). Only tags a shiplane snapshot gives
215
+ * are touched, never `latest` nor a numbered channel's; the versions stay installable by their
216
+ * number. False when refused or stopped.
217
+ */
218
+ const pruneSnapshots = async (context, { olderThanDays = 30, otp, dryRun = false }) => {
219
+ const problem = ageProblem(olderThanDays);
220
+ if (problem) {
221
+ fail(context, "Not an age", problem);
222
+ return false;
223
+ }
224
+ const stale = await staleTags(context, olderThanDays);
225
+ if (stale.length === 0) {
226
+ context.progress.say("resting", `No snapshot tag older than ${olderThanDays} days.`);
227
+ return true;
228
+ }
229
+ context.progress.say("resting", `${plural(stale.length, "snapshot tag")} older than ${olderThanDays} days${dryRun ? " (dry run)" : ""}`);
230
+ printTable(context, stale);
231
+ if (dryRun) {
232
+ context.output.line(paint("dim", " Nothing removed."));
233
+ return true;
234
+ }
235
+ if (!await agreed(context, stale.length)) return false;
236
+ if (!await removeAll(context, stale, await firstCode(context, otp))) return false;
237
+ context.progress.say("happy", `${paint("green", "✓")} Removed ${plural(stale.length, "tag")}`);
238
+ return true;
239
+ };
91
240
  //#endregion
92
241
  //#region src/cli/findRoot.ts
93
242
  /** The nearest folder up from here with a release config, else the git root, else here. */
@@ -213,6 +362,8 @@ const HELP = `${paint("bold", "shiplane")}: detect what changed, version it, tri
213
362
  (on a branch: a test release, asked first)
214
363
  shiplane test-release [channel] publish what the changesets release for testers, npm packages only:
215
364
  a snapshot (0.6.0-main.329aafb) or a numbered channel (0.6.0-beta.2)
365
+ shiplane prune-snapshots remove the npm tags of snapshots published 30 days ago or more:
366
+ --older-than <days> (7 or more), --otp <code>, --dry-run, --yes
216
367
  shiplane promote production, from what preview runs (--channel production too)
217
368
  shiplane status [--json] where every unit stands, and what to run next
218
369
  shiplane version open the release PR for what is pending
@@ -288,7 +439,9 @@ const runCli = async (argv, cwd, io = {}) => {
288
439
  ci: {
289
440
  type: "boolean",
290
441
  default: false
291
- }
442
+ },
443
+ "older-than": { type: "string" },
444
+ otp: { type: "string" }
292
445
  }
293
446
  });
294
447
  const [command = "next", ...units] = positionals;
@@ -302,6 +455,11 @@ const runCli = async (argv, cwd, io = {}) => {
302
455
  const commands = {
303
456
  next: (context) => environment === "preview" ? branchRelease(context, { onDefault: "release" }) : promote(context, via),
304
457
  "test-release": (context) => branchRelease(context, testRelease),
458
+ "prune-snapshots": (context) => pruneSnapshots(context, {
459
+ dryRun: values["dry-run"],
460
+ ...values["older-than"] === void 0 ? {} : { olderThanDays: Number(values["older-than"]) },
461
+ ...values.otp === void 0 ? {} : { otp: values.otp }
462
+ }),
305
463
  branch: (context) => branchRelease(context, testRelease),
306
464
  promote: (context) => promote(context, via),
307
465
  status: (context) => statusCommand(context, {
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":[],"sources":["../src/application/doctorCi.ts","../src/cli/findRoot.ts","../src/cli/output.ts","../src/cli/pluginsCommand.ts","../src/cli/statusCommand.ts","../src/cli/main.ts","../src/cli.ts"],"sourcesContent":["import path from \"node:path\";\nimport { z } from \"zod\";\n\nimport type { Requirement } from \"../ports/delivery.port\";\nimport type { Release } from \"./config/loadRelease\";\nimport type { SetupContext } from \"./setupContext\";\nimport { ENVIRONMENTS } from \"../domain/environment\";\nimport { checkStatus, requirementsOf, signInsOf } from \"./requirements\";\nimport { paint } from \"./say\";\nimport { commandLine } from \"./targets\";\n\n/** Where every check a runner makes is listed, with what it supports. */\nexport const WORKFLOW_DOCS =\n \"https://github.com/arnaud-zg/js-packages/blob/main/docs/shiplane/reference.md#github-actions-workflow\";\n\n/** The units a run names, each one the config's. */\nconst unitsSchema = (known: readonly string[]) =>\n z.array(z.string()).superRefine((names, context) => {\n const unknown = names.filter((name) => !known.includes(name));\n if (unknown.length > 0) {\n context.addIssue({\n code: \"custom\",\n message: `unknown units [${unknown.join(\", \")}]: known [${known.join(\", \")}]`,\n });\n }\n });\n\nconst environmentSchema = z.enum(ENVIRONMENTS, {\n error: ({ input }) => `unknown environment \"${String(input)}\": ${ENVIRONMENTS.join(\", \")}`,\n});\n\n/** The first problem a schema found, as said. */\nconst problemOf = (error: z.ZodError) => error.issues[0]?.message ?? \"invalid\";\n\n/** `$NAME` and `${NAME}` read from the environment, such as `$HOME/.fly/bin`. */\nconst expand = (context: SetupContext, text: string) =>\n text.replace(/\\$\\{?(\\w+)\\}?/g, (_, name: string) => context.shell.env(name) ?? \"\");\n\n/**\n * A missing tool installed, its folder put first on PATH for this run and, through `GITHUB_PATH`,\n * for the steps after it. The problem, or null once it answers.\n */\nconst install = async (context: SetupContext, requirement: Requirement) => {\n const { shell, files, root } = context;\n const { label, install: how } = requirement;\n if (!how) return `${label} missing and no install for linux`;\n const { command } = how;\n const status = await shell.attach(command.command, command.args, {\n cwd: path.join(root, command.cwd ?? \"\"),\n env: command.env,\n });\n if (status !== 0) return `${label} install failed: ${commandLine(command)} exited with ${status}`;\n if (how.path !== undefined) {\n const dir = expand(context, how.path);\n shell.prependPath?.(dir);\n const githubPath = shell.env(\"GITHUB_PATH\");\n if (githubPath) files.append(githubPath, `${dir}\\n`);\n }\n return (await checkStatus(shell, root, requirement)) === 127\n ? `${label} still missing after ${commandLine(command)}`\n : null;\n};\n\n/** Each secret a requirement names that this run does not hold, as said. */\nconst missing = (context: SetupContext, who: string, requirements: readonly Requirement[]) =>\n requirements.flatMap(({ label, secrets = [] }) =>\n secrets.filter((name) => !context.shell.env(name)).map((name) => ({ who, label, name })),\n );\n\n/** Every secret the picked units and the flow need that this run does not hold, in release order. */\nconst missingSecrets = (context: SetupContext, release: Release, picked: ReadonlySet<string>) => [\n ...release.units\n .filter(({ name }) => picked.has(name))\n .flatMap((unit) => {\n const provider = release.modules.find(({ name }) => name === unit.module)?.provider;\n return missing(\n context,\n `${unit.name} ships with ${provider ?? unit.module}`,\n signInsOf(release, new Set([unit.name])),\n );\n }),\n ...requirementsOf(release, new Set()).flatMap((requirement) =>\n missing(context, `shiplane needs ${requirement.label}`, [requirement]),\n ),\n];\n\n/**\n * `shiplane doctor --ci`: what a runner checks before it ships, in order, stopping at the first\n * problem: the units, the environment, each tool (installed when missing), each secret.\n */\nexport const doctorCi = async (\n context: SetupContext,\n { units, channel }: { units: readonly string[]; channel: string },\n): Promise<boolean> => {\n const { output, shell, root } = context;\n const passed = (check: string, detail: string) =>\n output.line(`${paint(\"green\", \"✓\")} ${check} ${paint(\"dim\", detail)}`);\n const stop = (problem: string) => {\n output.line(`${paint(\"red\", \"✗\")} ${problem}`);\n output.line(` ${paint(\"dim\", WORKFLOW_DOCS)}`);\n return false;\n };\n const release = await context.load();\n const [problem] = release.problems;\n if (problem) {\n return stop(\n `${problem.line === undefined ? problem.file : `${problem.file}:${problem.line}`}: ${problem.message}`,\n );\n }\n const known = release.units.map(({ name }) => name);\n const named = unitsSchema(known).safeParse(units.length > 0 ? units : known);\n if (!named.success) return stop(problemOf(named.error));\n passed(\"units\", named.data.join(\", \"));\n const environment = environmentSchema.safeParse(channel);\n if (!environment.success) return stop(problemOf(environment.error));\n passed(\"environment\", environment.data);\n const picked = new Set(named.data);\n for (const requirement of requirementsOf(release, picked)) {\n const found = (await checkStatus(shell, root, requirement)) !== 127;\n const problem = found ? null : await install(context, requirement);\n if (problem) return stop(problem);\n passed(requirement.label, found ? \"installed\" : \"installed now\");\n }\n const [absent] = missingSecrets(context, release, picked);\n if (absent) return stop(`${absent.who}: ${absent.name} missing in \"${environment.data}\"`);\n const secrets = requirementsOf(release, picked).flatMap(({ secrets = [] }) => secrets);\n passed(\"secrets\", secrets.length > 0 ? [...new Set(secrets)].join(\", \") : \"none needed\");\n return true;\n};\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { findConfig } from \"../application/config/loadRelease\";\n\n/** The nearest folder up from here with a release config, else the git root, else here. */\nexport const findRoot = (from: string): string => {\n const ancestors = (dir: string): string[] => {\n const parent = path.dirname(dir);\n return parent === dir ? [dir] : [dir, ...ancestors(parent)];\n };\n const chain = ancestors(path.resolve(from));\n return (\n chain.find((dir) => findConfig(dir)) ??\n chain.find((dir) => fs.existsSync(path.join(dir, \".git\"))) ??\n path.resolve(from)\n );\n};\n","import type { ConfigProblem } from \"../application/config/problem\";\nimport { paint } from \"../application/say\";\n\nexport const out = (line = \"\") => process.stdout.write(`${line}\\n`);\n\n/** Problems as `file:line message`, each hint on the line below. */\nexport const printProblems = (problems: readonly ConfigProblem[]) => {\n problems.forEach(({ file, line, message, hint }) => {\n const where = line === undefined ? file : `${file}:${line}`;\n out(`${paint(\"red\", \"✗\")} ${paint(\"bold\", where)} ${message}`);\n if (hint) out(` ${paint(\"dim\", hint)}`);\n });\n};\n","import type { Release } from \"../application/config/loadRelease\";\nimport { keysAt } from \"../application/config/unitSchema\";\nimport { paint } from \"../application/say\";\nimport { out } from \"./output\";\n\n/** `shiplane plugins`: the flow's adapters, the modules in release order with their apps, the features. */\nexport const pluginsCommand = (release: Release, { json }: { json: boolean }) => {\n const { flow } = release;\n const ports = {\n sourceControl: flow.sourceControl.name,\n codeHost: flow.codeHost.name,\n ciPipeline: flow.ciPipeline.name,\n versioning: flow.versioning.name,\n };\n const modules = release.modules.map(({ name, kind, provider, settings }) => ({\n name,\n kind,\n provider,\n keys: keysAt(settings, []),\n apps: release.units.filter(({ module }) => module === name).map(({ name: app }) => app),\n }));\n const features = release.features.map(({ name, adapters }) => ({\n name,\n uses: adapters.map((adapter) => adapter.name),\n }));\n if (json) {\n out(JSON.stringify({ flow: ports, modules, features }, null, 2));\n return;\n }\n const width =\n Math.max(\n 14,\n ...modules.map(({ name }) => name.length),\n ...features.map(({ name }) => name.length),\n ) + 2;\n const section = (title: string) => {\n out();\n out(paint(\"bold\", title));\n out();\n };\n section(\"Flow in shiplane.config.ts\");\n Object.entries(ports).forEach(([port, name]) => out(` ${port.padEnd(width)}${name}`));\n section(\"Modules, in release order\");\n modules.forEach(({ name, provider, keys, apps }) => {\n const used = apps.length > 0 ? `used by ${apps.join(\", \")}` : paint(\"dim\", \"no app names it\");\n out(` ${name.padEnd(width)}${provider} ${paint(\"dim\", keys.join(\", \") || \"no options\")}`);\n out(` ${\" \".repeat(width)}${used}`);\n });\n section(\"Features, after the ship\");\n if (features.length === 0) out(` ${paint(\"dim\", \"none\")}`);\n features.forEach(({ name, uses }) =>\n out(` ${name.padEnd(width)}${paint(\"dim\", `uses ${uses.join(\", \")}`)}`),\n );\n out();\n};\n","import type { ReleaseContext } from \"../application/context\";\nimport type { Environment } from \"../domain/environment\";\nimport { readStatus } from \"../application/readStatus\";\nimport { paint } from \"../application/say\";\nimport { environmentLabel } from \"../application/targets\";\nimport { out } from \"./output\";\n\nconst NEXT: Record<string, string> = {\n \"release-pr\": \"open the release PR: shiplane\",\n \"wait-merge\": \"merge the release PR, then: shiplane\",\n ship: \"tag what was versioned and ship it: shiplane\",\n};\n\n/** The next step as a person reads it; a ship with nothing pending anywhere is nothing to do. */\nexport const nextLabel = (\n {\n next,\n units,\n untagged,\n }: {\n next: { step: string };\n units: readonly { pending: boolean }[];\n untagged: readonly unknown[];\n },\n nextChange: string,\n) =>\n next.step === \"ship\" && untagged.length === 0 && !units.some(({ pending }) => pending)\n ? `nothing to release: queue a change with ${nextChange}`\n : (NEXT[next.step] ?? \"\");\n\n/** `shiplane status`: where every unit stands on an environment, and what to run next. Reads only. */\nexport const statusCommand = async (\n context: ReleaseContext,\n { environment, json }: { environment: Environment; json: boolean },\n) => {\n const status = await readStatus(context, environment);\n if (json) {\n out(JSON.stringify(status, null, 2));\n return;\n }\n const dot = paint(\"dim\", \"·\");\n out();\n const label = environmentLabel(context, [], environment);\n out(` ${paint(\"bold\", \"Release status\")} ${dot} ${label}`);\n out();\n const width = Math.max(8, ...status.units.map(({ unit }) => unit.length)) + 2;\n out(\n paint(\n \"dim\",\n ` ${\"Unit\".padEnd(width)}${\"Version\".padEnd(12)}${\"Target\".padEnd(18)}Where it stands`,\n ),\n );\n status.units.forEach(({ unit, version, target, pending, hint }) => {\n const mark = pending ? paint(\"yellow\", \"↑\") : paint(\"dim\", \"·\");\n out(` ${unit.padEnd(width)}${version.padEnd(12)}${target.padEnd(18)}${mark} ${hint}`);\n });\n status.releasePrs.forEach(({ url }) => out(`\\n ${paint(\"cyan\", \"Release PR\")} ${url}`));\n if (status.untagged.length > 0) {\n out(` ${paint(\"yellow\", \"Untagged\")} ${status.untagged.map(({ tag }) => tag).join(\", \")}`);\n }\n out();\n out(\n `${paint([\"bold\", \"green\"], \"→ Next:\")} ${nextLabel(status, context.services.versioning.nextChange)}`,\n );\n out();\n};\n","import { parseArgs } from \"node:util\";\nimport { z } from \"zod\";\n\nimport type { ReleaseContext } from \"../application/context\";\nimport type { ContextIo } from \"./compose\";\nimport { nodeFiles } from \"../adapters/files/node-files.adapter\";\nimport { addUnit, removeUnit } from \"../application/addUnit\";\nimport { branchRelease } from \"../application/branchRelease\";\nimport { docsFor } from \"../application/docsFor\";\nimport { doctor } from \"../application/doctor\";\nimport { doctorCi } from \"../application/doctorCi\";\nimport { initRelease } from \"../application/initRelease\";\nimport { newAdapter } from \"../application/newAdapter\";\nimport { openReleasePr } from \"../application/openReleasePr\";\nimport { pickScope } from \"../application/pickScope\";\nimport { planShips } from \"../application/planShips\";\nimport { prepareRelease } from \"../application/prepareRelease\";\nimport { promote } from \"../application/promote\";\nimport { paint } from \"../application/say\";\nimport { setup } from \"../application/setup\";\nimport { CONFIG_FILE, refreshEditorSchema } from \"../application/setupFiles\";\nimport { shipTo } from \"../application/ship\";\nimport { missingTags, tagRelease } from \"../application/tagRelease\";\nimport { ENVIRONMENTS } from \"../domain/environment\";\nimport { composeContext, composeSetup, loadReleaseOnDisk } from \"./compose\";\nimport { findRoot } from \"./findRoot\";\nimport { out, printProblems } from \"./output\";\nimport { pluginsCommand } from \"./pluginsCommand\";\nimport { statusCommand } from \"./statusCommand\";\n\n/** What `shiplane help` shows: the commands a person runs day to day, and where the rest are. */\nconst SHORT_HELP = `${paint(\"bold\", \"shiplane\")}: detect what changed, version it, trigger each app's deploy.\n\n shiplane the next step to preview: release PR, merge, tags, ship\n shiplane promote production, from what preview runs\n shiplane test-release [channel] publish what the changesets release for testers: a snapshot, or beta, nightly…\n shiplane status where every unit stands, and what to run next\n shiplane setup set up releases, or add an app\n shiplane doctor check the config, tools and sign-ins, offer each fix\n shiplane docs <name> every key a module's or an adapter's unit files take\n\n shiplane help all every command and flag: version, tag, ship, remove and the rest\n`;\n\nconst HELP = `${paint(\"bold\", \"shiplane\")}: detect what changed, version it, trigger each app's deploy.\n\n shiplane the next step to preview: release PR, merge, tags, ship\n (on a branch: a test release, asked first)\n shiplane test-release [channel] publish what the changesets release for testers, npm packages only:\n a snapshot (0.6.0-main.329aafb) or a numbered channel (0.6.0-beta.2)\n shiplane promote production, from what preview runs (--channel production too)\n shiplane status [--json] where every unit stands, and what to run next\n shiplane version open the release PR for what is pending\n shiplane tag tag merged versions and publish their release notes\n shiplane ship [unit...] trigger each tagged unit's deploy, then return\n shiplane plugins [--json] the flow, the modules in release order and who uses each, the features\n\n shiplane setup [--yes] set up, check, or add an app: asks only what it can't tell, rehearses, then writes\n (shiplane init and shiplane add are now setup; both still run for now)\n shiplane remove <unit> stop shipping a unit; it stays versioned\n shiplane doctor check the config, tools and sign-ins, offer each fix\n shiplane doctor --ci [unit...] on a runner: units, --channel, tools (installed when missing), secrets\n shiplane adapter new <name> scaffold a server hosting adapter, its contract test and its module\n shiplane docs <name> every key a module's or an adapter's unit files take\n shiplane help [all] the main commands; all: this, every command and flag\n\n --channel preview|production where status reads (preview by default)\n --via ci|local ship through the CI pipeline (such as GitHub Actions) or this machine, without asking\n --yes answer yes to every question (never on production)\n --dry-run with shiplane, ship or promote: every command it would run, run nothing;\n with test-release: each package's version and npm tag, publish nothing\n (shiplane plan before)\n --verbose / --no-verbose say each thing it reads and runs, with a progress bar (on by default)\n --mascot / --no-mascot the mascot beside it, still in CI or under NO_MOTION=1 (on by default)\n Both defaults live in shiplane.config.ts: display: { verbose, mascot }\n`;\n\n/** The commands `--dry-run` previews instead of running. */\nconst DRY_RUNS = new Set([\"next\", \"ship\", \"promote\"]);\n\n/** --via ci|local; the older --via github still means the CI pipeline, said once. */\nconst viaFlag = (value: string | undefined) => {\n if (value === undefined) return undefined;\n if (value === \"github\") {\n out(paint(\"dim\", \"--via github is now --via ci: the flow's CI pipeline\"));\n return \"ci\" as const;\n }\n return z.enum([\"ci\", \"local\"]).parse(value);\n};\n\n/** The CLI as a person runs it, from its arguments and folder; resolves to its exit code. */\nexport const runCli = async (argv: string[], cwd: string, io: ContextIo = {}): Promise<number> => {\n const { values, positionals } = parseArgs({\n args: argv,\n allowPositionals: true,\n allowNegative: true,\n options: {\n verbose: { type: \"boolean\" },\n mascot: { type: \"boolean\" },\n \"dry-run\": { type: \"boolean\", default: false },\n json: { type: \"boolean\", default: false },\n yes: { type: \"boolean\", short: \"y\", default: false },\n channel: { type: \"string\", default: \"preview\" },\n via: { type: \"string\" },\n blank: { type: \"boolean\", default: false },\n ci: { type: \"boolean\", default: false },\n },\n });\n\n const [command = \"next\", ...units] = positionals;\n // doctor --ci says an unknown channel itself, with the environments it knows.\n const environment = command === \"doctor\" ? \"preview\" : z.enum(ENVIRONMENTS).parse(values.channel);\n const via = viaFlag(values.via);\n // shiplane test-release [channel] [--dry-run]\n const testRelease = {\n onDefault: \"publish\" as const,\n dryRun: values[\"dry-run\"],\n ...(units[0] === undefined ? {} : { channel: units[0] }),\n };\n\n const commands: Record<string, (context: ReleaseContext) => Promise<boolean | void>> = {\n next: (context) =>\n environment === \"preview\"\n ? branchRelease(context, { onDefault: \"release\" })\n : promote(context, via),\n \"test-release\": (context) => branchRelease(context, testRelease),\n // The command's first name, kept working, left out of the help.\n branch: (context) => branchRelease(context, testRelease),\n promote: (context) => promote(context, via),\n status: (context) => statusCommand(context, { environment, json: values.json }),\n version: async (context) => {\n const picked = await pickScope(context, \"preview\");\n if (!picked || picked.scope.size === 0) return true;\n return (await openReleasePr(context, await prepareRelease(context, picked.scope))) !== null;\n },\n tag: async (context) => tagRelease(context, await missingTags(context)),\n ship: (context) =>\n shipTo(context, environment, { via, ...(units.length > 0 ? { scope: new Set(units) } : {}) }),\n // Deprecated: --dry-run does it. Kept working, left out of the help.\n plan: (context) => {\n out(\n paint(\"dim\", \"plan is now --dry-run: shiplane ship --dry-run, shiplane promote --dry-run\"),\n );\n return planShips(context, environment);\n },\n plugins: (context) => Promise.resolve(pluginsCommand(context.release, { json: values.json })),\n };\n\n const [first = \"\"] = units;\n const setupCommands: Record<\n string,\n (context: Awaited<ReturnType<typeof composeSetup>>) => Promise<boolean>\n > = {\n setup: (context) => setup(context, { yes: values.yes }),\n init: (context) => {\n if (values.blank) return initRelease(context, { yes: values.yes, blank: true });\n out(paint(\"dim\", \"init is now shiplane setup\"));\n return setup(context, { yes: values.yes });\n },\n add: (context) => {\n out(paint(\"dim\", \"add is now shiplane setup: run it again to add an app\"));\n return addUnit(context, first);\n },\n remove: (context) => removeUnit(context, first),\n doctor: (context) =>\n values.ci\n ? doctorCi(context, { units, channel: values.channel })\n : doctor(context, { yes: values.yes }),\n adapter: (context) => {\n if (first === \"new\" && units[1]) return newAdapter(context, units[1]);\n out(`${paint(\"red\", \"✗\")} shiplane adapter new <name>`);\n return Promise.resolve(false);\n },\n docs: (context) => docsFor(context, first),\n };\n\n const root = findRoot(cwd);\n const files = io.setup?.files ?? nodeFiles(root);\n const firstRun = command === \"next\" && !files.exists(CONFIG_FILE);\n // A dry run prints every command a ship would run, the way it would go, and runs none.\n const run =\n values[\"dry-run\"] && DRY_RUNS.has(command)\n ? (context: ReleaseContext) =>\n planShips(context, command === \"promote\" ? \"production\" : environment)\n : commands[command];\n const setUp = setupCommands[firstRun ? \"setup\" : command];\n if (setUp) {\n const load = () => loadReleaseOnDisk(root, { aliases: io.aliases });\n return (await setUp(await composeSetup(root, { load, ...io.setup }))) ? 0 : 1;\n }\n if (command === \"help\") {\n out(first === \"all\" ? HELP : SHORT_HELP);\n return 0;\n }\n if (!run) {\n out(`${paint(\"red\", \"✗\")} no command \"${command}\"`);\n out(HELP);\n return 1;\n }\n const release = await loadReleaseOnDisk(root, { aliases: io.aliases });\n if (release.problems.length > 0) {\n printProblems(release.problems);\n return 2;\n }\n (release.renames ?? []).forEach(({ from, to }) =>\n out(`${paint(\"yellow\", \"!\")} rename ${from} to ${to}: the old name still works for now`),\n );\n refreshEditorSchema(nodeFiles(release.root), release);\n const context = composeContext(\n release,\n { yes: values.yes, display: { verbose: values.verbose, mascot: values.mascot } },\n io,\n );\n return (await run(context)) === false ? 1 : 0;\n};\n","#!/usr/bin/env node\nimport { runCli } from \"./cli/main\";\n\nprocess.exitCode = await runCli(process.argv.slice(2), process.cwd());\n"],"mappings":";;;;;;;;AAYA,MAAa,gBACX;;AAGF,MAAM,eAAe,UACnB,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,aAAa,OAAO,YAAY;CAClD,MAAM,UAAU,MAAM,QAAQ,SAAS,CAAC,MAAM,SAAS,KAAK,CAAC;AAC7D,KAAI,QAAQ,SAAS,EACnB,SAAQ,SAAS;EACf,MAAM;EACN,SAAS,kBAAkB,QAAQ,KAAK,KAAK,CAAC,YAAY,MAAM,KAAK,KAAK,CAAC;EAC5E,CAAC;EAEJ;AAEJ,MAAM,oBAAoB,EAAE,KAAK,cAAc,EAC7C,QAAQ,EAAE,YAAY,wBAAwB,OAAO,MAAM,CAAC,KAAK,aAAa,KAAK,KAAK,IACzF,CAAC;;AAGF,MAAM,aAAa,UAAsB,MAAM,OAAO,IAAI,WAAW;;AAGrE,MAAM,UAAU,SAAuB,SACrC,KAAK,QAAQ,mBAAmB,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G,SAAS,CAAC;AACnE,SAAQ,MAAM,MAAM,MAAM,aAAa,MAAM;GAAE;GAAM,GAAG,GAAG;GAAO,CAAC,CAAC,GAAI,IAAI;;AAE9E,KAAI,YAAY,QAAQ;AACtB,MAAI,UAAU,QAAQ,OAAO,WAAW;AACxC,SAAO;;AAET,KAAI,CAAC,KAAK;AACR,MAAI,GAAG,MAAM,OAAO,IAAI,CAAC,gBAAgB,QAAQ,GAAG;AACpD,MAAI,KAAK;AACT,SAAO;;CAET,MAAM,UAAU,MAAM,kBAAkB,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;AACtE,KAAI,QAAQ,SAAS,SAAS,GAAG;AAC/B,gBAAc,QAAQ,SAAS;AAC/B,SAAO;;AAET,EAAC,QAAQ,WAAW,EAAE,EAAE,SAAS,EAAE,MAAM,SACvC,IAAI,GAAG,MAAM,UAAU,IAAI,CAAC,WAAW,KAAK,MAAM,GAAG,oCAAoC,CAC1F;AACD,qBAAoB,UAAU,QAAQ,KAAK,EAAE,QAAQ;AAMrD,QAAQ,MAAM,IALE,eACd,SACA;EAAE,KAAK,OAAO;EAAK,SAAS;GAAE,SAAS,OAAO;GAAS,QAAQ,OAAO;GAAQ;EAAE,EAChF,GAEuB,CAAC,KAAM,QAAQ,IAAI;;;;AClN9C,QAAQ,WAAW,MAAM,OAAO,QAAQ,KAAK,MAAM,EAAE,EAAE,QAAQ,KAAK,CAAC"}
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../src/application/doctorCi.ts","../src/domain/snapshotTags.ts","../src/application/pruneSnapshots.ts","../src/cli/findRoot.ts","../src/cli/output.ts","../src/cli/pluginsCommand.ts","../src/cli/statusCommand.ts","../src/cli/main.ts","../src/cli.ts"],"sourcesContent":["import path from \"node:path\";\nimport { z } from \"zod\";\n\nimport type { Requirement } from \"../ports/delivery.port\";\nimport type { Release } from \"./config/loadRelease\";\nimport type { SetupContext } from \"./setupContext\";\nimport { ENVIRONMENTS } from \"../domain/environment\";\nimport { checkStatus, requirementsOf, signInsOf } from \"./requirements\";\nimport { paint } from \"./say\";\nimport { commandLine } from \"./targets\";\n\n/** Where every check a runner makes is listed, with what it supports. */\nexport const WORKFLOW_DOCS =\n \"https://github.com/arnaud-zg/js-packages/blob/main/docs/shiplane/reference.md#github-actions-workflow\";\n\n/** The units a run names, each one the config's. */\nconst unitsSchema = (known: readonly string[]) =>\n z.array(z.string()).superRefine((names, context) => {\n const unknown = names.filter((name) => !known.includes(name));\n if (unknown.length > 0) {\n context.addIssue({\n code: \"custom\",\n message: `unknown units [${unknown.join(\", \")}]: known [${known.join(\", \")}]`,\n });\n }\n });\n\nconst environmentSchema = z.enum(ENVIRONMENTS, {\n error: ({ input }) => `unknown environment \"${String(input)}\": ${ENVIRONMENTS.join(\", \")}`,\n});\n\n/** The first problem a schema found, as said. */\nconst problemOf = (error: z.ZodError) => error.issues[0]?.message ?? \"invalid\";\n\n/** `$NAME` and `${NAME}` read from the environment, such as `$HOME/.fly/bin`. */\nconst expand = (context: SetupContext, text: string) =>\n text.replace(/\\$\\{?(\\w+)\\}?/g, (_, name: string) => context.shell.env(name) ?? \"\");\n\n/**\n * A missing tool installed, its folder put first on PATH for this run and, through `GITHUB_PATH`,\n * for the steps after it. The problem, or null once it answers.\n */\nconst install = async (context: SetupContext, requirement: Requirement) => {\n const { shell, files, root } = context;\n const { label, install: how } = requirement;\n if (!how) return `${label} missing and no install for linux`;\n const { command } = how;\n const status = await shell.attach(command.command, command.args, {\n cwd: path.join(root, command.cwd ?? \"\"),\n env: command.env,\n });\n if (status !== 0) return `${label} install failed: ${commandLine(command)} exited with ${status}`;\n if (how.path !== undefined) {\n const dir = expand(context, how.path);\n shell.prependPath?.(dir);\n const githubPath = shell.env(\"GITHUB_PATH\");\n if (githubPath) files.append(githubPath, `${dir}\\n`);\n }\n return (await checkStatus(shell, root, requirement)) === 127\n ? `${label} still missing after ${commandLine(command)}`\n : null;\n};\n\n/** Each secret a requirement names that this run does not hold, as said. */\nconst missing = (context: SetupContext, who: string, requirements: readonly Requirement[]) =>\n requirements.flatMap(({ label, secrets = [] }) =>\n secrets.filter((name) => !context.shell.env(name)).map((name) => ({ who, label, name })),\n );\n\n/** Every secret the picked units and the flow need that this run does not hold, in release order. */\nconst missingSecrets = (context: SetupContext, release: Release, picked: ReadonlySet<string>) => [\n ...release.units\n .filter(({ name }) => picked.has(name))\n .flatMap((unit) => {\n const provider = release.modules.find(({ name }) => name === unit.module)?.provider;\n return missing(\n context,\n `${unit.name} ships with ${provider ?? unit.module}`,\n signInsOf(release, new Set([unit.name])),\n );\n }),\n ...requirementsOf(release, new Set()).flatMap((requirement) =>\n missing(context, `shiplane needs ${requirement.label}`, [requirement]),\n ),\n];\n\n/**\n * `shiplane doctor --ci`: what a runner checks before it ships, in order, stopping at the first\n * problem: the units, the environment, each tool (installed when missing), each secret.\n */\nexport const doctorCi = async (\n context: SetupContext,\n { units, channel }: { units: readonly string[]; channel: string },\n): Promise<boolean> => {\n const { output, shell, root } = context;\n const passed = (check: string, detail: string) =>\n output.line(`${paint(\"green\", \"✓\")} ${check} ${paint(\"dim\", detail)}`);\n const stop = (problem: string) => {\n output.line(`${paint(\"red\", \"✗\")} ${problem}`);\n output.line(` ${paint(\"dim\", WORKFLOW_DOCS)}`);\n return false;\n };\n const release = await context.load();\n const [problem] = release.problems;\n if (problem) {\n return stop(\n `${problem.line === undefined ? problem.file : `${problem.file}:${problem.line}`}: ${problem.message}`,\n );\n }\n const known = release.units.map(({ name }) => name);\n const named = unitsSchema(known).safeParse(units.length > 0 ? units : known);\n if (!named.success) return stop(problemOf(named.error));\n passed(\"units\", named.data.join(\", \"));\n const environment = environmentSchema.safeParse(channel);\n if (!environment.success) return stop(problemOf(environment.error));\n passed(\"environment\", environment.data);\n const picked = new Set(named.data);\n for (const requirement of requirementsOf(release, picked)) {\n const found = (await checkStatus(shell, root, requirement)) !== 127;\n const problem = found ? null : await install(context, requirement);\n if (problem) return stop(problem);\n passed(requirement.label, found ? \"installed\" : \"installed now\");\n }\n const [absent] = missingSecrets(context, release, picked);\n if (absent) return stop(`${absent.who}: ${absent.name} missing in \"${environment.data}\"`);\n const secrets = requirementsOf(release, picked).flatMap(({ secrets = [] }) => secrets);\n passed(\"secrets\", secrets.length > 0 ? [...new Set(secrets)].join(\", \") : \"none needed\");\n return true;\n};\n","/** A dist-tag on a registry, the version it points at, and when that version was published. */\nexport interface TaggedVersion {\n tag: string;\n version: string;\n /** ISO time the registry gives the version; null when it gives none. */\n publishedAt: string | null;\n}\n\n/**\n * How old a snapshot's version must be before its tag is removed: 30 days, long enough that a\n * branch still under test has published a newer snapshot since. Never fewer than `MIN_AGE_DAYS`.\n */\nexport const DEFAULT_AGE_DAYS = 30;\nexport const MIN_AGE_DAYS = 7;\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\n// <x.y.z>-<branch slug>.<short sha>, the shape `branchVersion` gives; a numbered channel's\n// <x.y.z>-beta.<n> never matches, its last identifier being a count, not 7 hex characters.\nconst SNAPSHOT = /^\\d+\\.\\d+\\.\\d+-([a-z0-9-]+)\\.(g?[0-9a-f]{7})$/;\n\n/**\n * Whether a tag is one a shiplane snapshot left: its version has a snapshot's shape and the tag is\n * that version's branch slug (as branch snapshots were tagged), `branch-<slug>`, or `snapshot`.\n */\nexport const isSnapshotTag = ({ tag, version }: Pick<TaggedVersion, \"tag\" | \"version\">) => {\n const slug = SNAPSHOT.exec(version)?.[1];\n if (slug === undefined || tag === \"latest\") return false;\n return tag === slug || tag === `branch-${slug}` || tag === \"snapshot\";\n};\n\n/** Why an age cannot be one, or null when it can. */\nexport const ageProblem = (days: number) =>\n Number.isInteger(days) && days >= MIN_AGE_DAYS\n ? null\n : `--older-than takes a whole number of days, ${MIN_AGE_DAYS} or more`;\n\n/** Whole days between a publish time and now; null when the time is missing or unreadable. */\nexport const ageInDays = (publishedAt: string | null, now: Date) => {\n const at = publishedAt === null ? Number.NaN : Date.parse(publishedAt);\n return Number.isNaN(at) ? null : Math.floor((now.getTime() - at) / DAY_MS);\n};\n\n/**\n * The snapshot tags old enough to remove: a shiplane snapshot's tag, on a version published at\n * least `olderThanDays` ago, never the one `latest` points at. A version with no publish time is\n * kept: old is never guessed.\n */\nexport const staleSnapshotTags = ({\n tags,\n now,\n olderThanDays = DEFAULT_AGE_DAYS,\n}: {\n tags: readonly TaggedVersion[];\n now: Date;\n olderThanDays?: number;\n}) => {\n const latest = tags.find(({ tag }) => tag === \"latest\")?.version;\n return tags.flatMap((tagged) => {\n const days = ageInDays(tagged.publishedAt, now);\n if (!isSnapshotTag(tagged) || tagged.version === latest) return [];\n return days !== null && days >= olderThanDays ? [{ ...tagged, days }] : [];\n });\n};\n","import type { TaggedVersion } from \"../domain/snapshotTags\";\nimport type { ReleaseContext } from \"./context\";\nimport { ageProblem, DEFAULT_AGE_DAYS, staleSnapshotTags } from \"../domain/snapshotTags\";\nimport { plural } from \"../domain/words\";\nimport { padded } from \"./branchPublish\";\nimport { fail, paint, reasonOf } from \"./say\";\nimport { checkout, decideContext, runHere, unitTarget } from \"./targets\";\n\ntype Target = NonNullable<ReturnType<typeof unitTarget>>;\n\n/** One old snapshot tag on one package, and the unit that package ships from. */\ninterface Stale extends TaggedVersion {\n name: string;\n days: number;\n target: Target;\n}\n\n/** Every package's snapshot tags at least `olderThanDays` old, as each registry lists them. */\nconst staleTags = async (context: ReleaseContext, olderThanDays: number): Promise<Stale[]> => {\n const at = await checkout(context);\n const decide = decideContext(context);\n const now = context.clock.now();\n const perUnit = await Promise.all(\n context.release.units.map(async (unit) => {\n const target = unitTarget(context, { unit, environment: \"preview\", ...at });\n const read = target?.module.tags;\n if (!target || !read) return [];\n const name = target.module.publishedName?.(decide, target.input) ?? unit.packageName;\n const tags = await read(decide, target.input);\n return staleSnapshotTags({ tags, now, olderThanDays }).map((stale) => ({\n ...stale,\n name,\n target,\n }));\n }),\n );\n return perUnit.flat();\n};\n\nconst printTable = ({ output }: ReleaseContext, stale: readonly Stale[]) => {\n const [header = \"\", ...rows] = padded([\n [\"Package\", \"Tag\", \"Version\", \"Published\"],\n ...stale.map(({ name, tag, version, days }) => [name, tag, version, `${days} days ago`]),\n ]);\n output.line(paint(\"dim\", ` ${header}`));\n rows.forEach((row) => output.line(` ${row}`));\n};\n\n/** Yes from the person in a terminal, or --yes anywhere: removing tags is never done unasked. */\nconst agreed = async (context: ReleaseContext, count: number) => {\n if (context.options.yes) return true;\n if (!context.prompter.interactive) {\n fail(context, \"Not removed\", \"add --yes to remove them without a terminal to ask in.\");\n return false;\n }\n return context.prompter.confirm(\n `Remove ${plural(count, \"tag\")}? Each version stays installable by its number.`,\n );\n};\n\n/** The code passed with --otp, or one asked for in a terminal; none when the account needs none. */\nconst firstCode = async ({ prompter }: ReleaseContext, otp: string | undefined) => {\n if (otp !== undefined || !prompter.interactive) return otp;\n const typed = await prompter.text(\n \"npm one-time code, if your account asks for one (Enter: none)\",\n );\n return typed?.trim() || undefined;\n};\n\n/**\n * Removes each tag in turn, with one code for all. A failure in a terminal asks for a fresh code\n * and retries, since a code lasts about 30 seconds; anywhere else it stops, and a rerun picks up\n * the tags still there. False when it stopped.\n */\nconst removeAll = async (context: ReleaseContext, stale: readonly Stale[], otp?: string) => {\n const decide = decideContext(context);\n let code = otp;\n for (const [index, entry] of stale.entries()) {\n for (;;) {\n const job = entry.target.module.untagJob?.(decide, entry.target.input, entry.tag, code);\n if (!job) break;\n try {\n await context.progress.during(\n job.label,\n \"working\",\n () => runHere(context, job, { tag: entry.target.tag, environment: \"preview\" }),\n { index, total: stale.length },\n );\n break;\n } catch (error) {\n const fresh = context.prompter.interactive\n ? await context.prompter.text(\n `${job.label} failed: a fresh npm one-time code to retry (Enter: stop)`,\n )\n : null;\n if (!fresh?.trim()) {\n fail(\n context,\n `${job.label} failed`,\n `${reasonOf(error)}; ${plural(index, \"tag\")} of ${stale.length} removed. A one-time code lasts about 30 seconds: run it again with a fresh --otp, it picks up the tags still there.`,\n );\n return false;\n }\n code = fresh.trim();\n }\n }\n }\n return true;\n};\n\n/**\n * `shiplane prune-snapshots`: removes the npm tags old snapshots left, those of a version published\n * `olderThanDays` ago or more (30 by default, never under 7). Only tags a shiplane snapshot gives\n * are touched, never `latest` nor a numbered channel's; the versions stay installable by their\n * number. False when refused or stopped.\n */\nexport const pruneSnapshots = async (\n context: ReleaseContext,\n {\n olderThanDays = DEFAULT_AGE_DAYS,\n otp,\n dryRun = false,\n }: { olderThanDays?: number; otp?: string; dryRun?: boolean },\n): Promise<boolean> => {\n const problem = ageProblem(olderThanDays);\n if (problem) {\n fail(context, \"Not an age\", problem);\n return false;\n }\n const stale = await staleTags(context, olderThanDays);\n if (stale.length === 0) {\n context.progress.say(\"resting\", `No snapshot tag older than ${olderThanDays} days.`);\n return true;\n }\n context.progress.say(\n \"resting\",\n `${plural(stale.length, \"snapshot tag\")} older than ${olderThanDays} days${dryRun ? \" (dry run)\" : \"\"}`,\n );\n printTable(context, stale);\n if (dryRun) {\n context.output.line(paint(\"dim\", \" Nothing removed.\"));\n return true;\n }\n if (!(await agreed(context, stale.length))) return false;\n if (!(await removeAll(context, stale, await firstCode(context, otp)))) return false;\n context.progress.say(\"happy\", `${paint(\"green\", \"✓\")} Removed ${plural(stale.length, \"tag\")}`);\n return true;\n};\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { findConfig } from \"../application/config/loadRelease\";\n\n/** The nearest folder up from here with a release config, else the git root, else here. */\nexport const findRoot = (from: string): string => {\n const ancestors = (dir: string): string[] => {\n const parent = path.dirname(dir);\n return parent === dir ? [dir] : [dir, ...ancestors(parent)];\n };\n const chain = ancestors(path.resolve(from));\n return (\n chain.find((dir) => findConfig(dir)) ??\n chain.find((dir) => fs.existsSync(path.join(dir, \".git\"))) ??\n path.resolve(from)\n );\n};\n","import type { ConfigProblem } from \"../application/config/problem\";\nimport { paint } from \"../application/say\";\n\nexport const out = (line = \"\") => process.stdout.write(`${line}\\n`);\n\n/** Problems as `file:line message`, each hint on the line below. */\nexport const printProblems = (problems: readonly ConfigProblem[]) => {\n problems.forEach(({ file, line, message, hint }) => {\n const where = line === undefined ? file : `${file}:${line}`;\n out(`${paint(\"red\", \"✗\")} ${paint(\"bold\", where)} ${message}`);\n if (hint) out(` ${paint(\"dim\", hint)}`);\n });\n};\n","import type { Release } from \"../application/config/loadRelease\";\nimport { keysAt } from \"../application/config/unitSchema\";\nimport { paint } from \"../application/say\";\nimport { out } from \"./output\";\n\n/** `shiplane plugins`: the flow's adapters, the modules in release order with their apps, the features. */\nexport const pluginsCommand = (release: Release, { json }: { json: boolean }) => {\n const { flow } = release;\n const ports = {\n sourceControl: flow.sourceControl.name,\n codeHost: flow.codeHost.name,\n ciPipeline: flow.ciPipeline.name,\n versioning: flow.versioning.name,\n };\n const modules = release.modules.map(({ name, kind, provider, settings }) => ({\n name,\n kind,\n provider,\n keys: keysAt(settings, []),\n apps: release.units.filter(({ module }) => module === name).map(({ name: app }) => app),\n }));\n const features = release.features.map(({ name, adapters }) => ({\n name,\n uses: adapters.map((adapter) => adapter.name),\n }));\n if (json) {\n out(JSON.stringify({ flow: ports, modules, features }, null, 2));\n return;\n }\n const width =\n Math.max(\n 14,\n ...modules.map(({ name }) => name.length),\n ...features.map(({ name }) => name.length),\n ) + 2;\n const section = (title: string) => {\n out();\n out(paint(\"bold\", title));\n out();\n };\n section(\"Flow in shiplane.config.ts\");\n Object.entries(ports).forEach(([port, name]) => out(` ${port.padEnd(width)}${name}`));\n section(\"Modules, in release order\");\n modules.forEach(({ name, provider, keys, apps }) => {\n const used = apps.length > 0 ? `used by ${apps.join(\", \")}` : paint(\"dim\", \"no app names it\");\n out(` ${name.padEnd(width)}${provider} ${paint(\"dim\", keys.join(\", \") || \"no options\")}`);\n out(` ${\" \".repeat(width)}${used}`);\n });\n section(\"Features, after the ship\");\n if (features.length === 0) out(` ${paint(\"dim\", \"none\")}`);\n features.forEach(({ name, uses }) =>\n out(` ${name.padEnd(width)}${paint(\"dim\", `uses ${uses.join(\", \")}`)}`),\n );\n out();\n};\n","import type { ReleaseContext } from \"../application/context\";\nimport type { Environment } from \"../domain/environment\";\nimport { readStatus } from \"../application/readStatus\";\nimport { paint } from \"../application/say\";\nimport { environmentLabel } from \"../application/targets\";\nimport { out } from \"./output\";\n\nconst NEXT: Record<string, string> = {\n \"release-pr\": \"open the release PR: shiplane\",\n \"wait-merge\": \"merge the release PR, then: shiplane\",\n ship: \"tag what was versioned and ship it: shiplane\",\n};\n\n/** The next step as a person reads it; a ship with nothing pending anywhere is nothing to do. */\nexport const nextLabel = (\n {\n next,\n units,\n untagged,\n }: {\n next: { step: string };\n units: readonly { pending: boolean }[];\n untagged: readonly unknown[];\n },\n nextChange: string,\n) =>\n next.step === \"ship\" && untagged.length === 0 && !units.some(({ pending }) => pending)\n ? `nothing to release: queue a change with ${nextChange}`\n : (NEXT[next.step] ?? \"\");\n\n/** `shiplane status`: where every unit stands on an environment, and what to run next. Reads only. */\nexport const statusCommand = async (\n context: ReleaseContext,\n { environment, json }: { environment: Environment; json: boolean },\n) => {\n const status = await readStatus(context, environment);\n if (json) {\n out(JSON.stringify(status, null, 2));\n return;\n }\n const dot = paint(\"dim\", \"·\");\n out();\n const label = environmentLabel(context, [], environment);\n out(` ${paint(\"bold\", \"Release status\")} ${dot} ${label}`);\n out();\n const width = Math.max(8, ...status.units.map(({ unit }) => unit.length)) + 2;\n out(\n paint(\n \"dim\",\n ` ${\"Unit\".padEnd(width)}${\"Version\".padEnd(12)}${\"Target\".padEnd(18)}Where it stands`,\n ),\n );\n status.units.forEach(({ unit, version, target, pending, hint }) => {\n const mark = pending ? paint(\"yellow\", \"↑\") : paint(\"dim\", \"·\");\n out(` ${unit.padEnd(width)}${version.padEnd(12)}${target.padEnd(18)}${mark} ${hint}`);\n });\n status.releasePrs.forEach(({ url }) => out(`\\n ${paint(\"cyan\", \"Release PR\")} ${url}`));\n if (status.untagged.length > 0) {\n out(` ${paint(\"yellow\", \"Untagged\")} ${status.untagged.map(({ tag }) => tag).join(\", \")}`);\n }\n out();\n out(\n `${paint([\"bold\", \"green\"], \"→ Next:\")} ${nextLabel(status, context.services.versioning.nextChange)}`,\n );\n out();\n};\n","import { parseArgs } from \"node:util\";\nimport { z } from \"zod\";\n\nimport type { ReleaseContext } from \"../application/context\";\nimport type { ContextIo } from \"./compose\";\nimport { nodeFiles } from \"../adapters/files/node-files.adapter\";\nimport { addUnit, removeUnit } from \"../application/addUnit\";\nimport { branchRelease } from \"../application/branchRelease\";\nimport { docsFor } from \"../application/docsFor\";\nimport { doctor } from \"../application/doctor\";\nimport { doctorCi } from \"../application/doctorCi\";\nimport { initRelease } from \"../application/initRelease\";\nimport { newAdapter } from \"../application/newAdapter\";\nimport { openReleasePr } from \"../application/openReleasePr\";\nimport { pickScope } from \"../application/pickScope\";\nimport { planShips } from \"../application/planShips\";\nimport { prepareRelease } from \"../application/prepareRelease\";\nimport { promote } from \"../application/promote\";\nimport { pruneSnapshots } from \"../application/pruneSnapshots\";\nimport { paint } from \"../application/say\";\nimport { setup } from \"../application/setup\";\nimport { CONFIG_FILE, refreshEditorSchema } from \"../application/setupFiles\";\nimport { shipTo } from \"../application/ship\";\nimport { missingTags, tagRelease } from \"../application/tagRelease\";\nimport { ENVIRONMENTS } from \"../domain/environment\";\nimport { composeContext, composeSetup, loadReleaseOnDisk } from \"./compose\";\nimport { findRoot } from \"./findRoot\";\nimport { out, printProblems } from \"./output\";\nimport { pluginsCommand } from \"./pluginsCommand\";\nimport { statusCommand } from \"./statusCommand\";\n\n/** What `shiplane help` shows: the commands a person runs day to day, and where the rest are. */\nconst SHORT_HELP = `${paint(\"bold\", \"shiplane\")}: detect what changed, version it, trigger each app's deploy.\n\n shiplane the next step to preview: release PR, merge, tags, ship\n shiplane promote production, from what preview runs\n shiplane test-release [channel] publish what the changesets release for testers: a snapshot, or beta, nightly…\n shiplane status where every unit stands, and what to run next\n shiplane setup set up releases, or add an app\n shiplane doctor check the config, tools and sign-ins, offer each fix\n shiplane docs <name> every key a module's or an adapter's unit files take\n\n shiplane help all every command and flag: version, tag, ship, remove and the rest\n`;\n\nconst HELP = `${paint(\"bold\", \"shiplane\")}: detect what changed, version it, trigger each app's deploy.\n\n shiplane the next step to preview: release PR, merge, tags, ship\n (on a branch: a test release, asked first)\n shiplane test-release [channel] publish what the changesets release for testers, npm packages only:\n a snapshot (0.6.0-main.329aafb) or a numbered channel (0.6.0-beta.2)\n shiplane prune-snapshots remove the npm tags of snapshots published 30 days ago or more:\n --older-than <days> (7 or more), --otp <code>, --dry-run, --yes\n shiplane promote production, from what preview runs (--channel production too)\n shiplane status [--json] where every unit stands, and what to run next\n shiplane version open the release PR for what is pending\n shiplane tag tag merged versions and publish their release notes\n shiplane ship [unit...] trigger each tagged unit's deploy, then return\n shiplane plugins [--json] the flow, the modules in release order and who uses each, the features\n\n shiplane setup [--yes] set up, check, or add an app: asks only what it can't tell, rehearses, then writes\n (shiplane init and shiplane add are now setup; both still run for now)\n shiplane remove <unit> stop shipping a unit; it stays versioned\n shiplane doctor check the config, tools and sign-ins, offer each fix\n shiplane doctor --ci [unit...] on a runner: units, --channel, tools (installed when missing), secrets\n shiplane adapter new <name> scaffold a server hosting adapter, its contract test and its module\n shiplane docs <name> every key a module's or an adapter's unit files take\n shiplane help [all] the main commands; all: this, every command and flag\n\n --channel preview|production where status reads (preview by default)\n --via ci|local ship through the CI pipeline (such as GitHub Actions) or this machine, without asking\n --yes answer yes to every question (never on production)\n --dry-run with shiplane, ship or promote: every command it would run, run nothing;\n with test-release: each package's version and npm tag, publish nothing\n (shiplane plan before)\n --verbose / --no-verbose say each thing it reads and runs, with a progress bar (on by default)\n --mascot / --no-mascot the mascot beside it, still in CI or under NO_MOTION=1 (on by default)\n Both defaults live in shiplane.config.ts: display: { verbose, mascot }\n`;\n\n/** The commands `--dry-run` previews instead of running. */\nconst DRY_RUNS = new Set([\"next\", \"ship\", \"promote\"]);\n\n/** --via ci|local; the older --via github still means the CI pipeline, said once. */\nconst viaFlag = (value: string | undefined) => {\n if (value === undefined) return undefined;\n if (value === \"github\") {\n out(paint(\"dim\", \"--via github is now --via ci: the flow's CI pipeline\"));\n return \"ci\" as const;\n }\n return z.enum([\"ci\", \"local\"]).parse(value);\n};\n\n/** The CLI as a person runs it, from its arguments and folder; resolves to its exit code. */\nexport const runCli = async (argv: string[], cwd: string, io: ContextIo = {}): Promise<number> => {\n const { values, positionals } = parseArgs({\n args: argv,\n allowPositionals: true,\n allowNegative: true,\n options: {\n verbose: { type: \"boolean\" },\n mascot: { type: \"boolean\" },\n \"dry-run\": { type: \"boolean\", default: false },\n json: { type: \"boolean\", default: false },\n yes: { type: \"boolean\", short: \"y\", default: false },\n channel: { type: \"string\", default: \"preview\" },\n via: { type: \"string\" },\n blank: { type: \"boolean\", default: false },\n ci: { type: \"boolean\", default: false },\n \"older-than\": { type: \"string\" },\n otp: { type: \"string\" },\n },\n });\n\n const [command = \"next\", ...units] = positionals;\n // doctor --ci says an unknown channel itself, with the environments it knows.\n const environment = command === \"doctor\" ? \"preview\" : z.enum(ENVIRONMENTS).parse(values.channel);\n const via = viaFlag(values.via);\n // shiplane test-release [channel] [--dry-run]\n const testRelease = {\n onDefault: \"publish\" as const,\n dryRun: values[\"dry-run\"],\n ...(units[0] === undefined ? {} : { channel: units[0] }),\n };\n\n const commands: Record<string, (context: ReleaseContext) => Promise<boolean | void>> = {\n next: (context) =>\n environment === \"preview\"\n ? branchRelease(context, { onDefault: \"release\" })\n : promote(context, via),\n \"test-release\": (context) => branchRelease(context, testRelease),\n \"prune-snapshots\": (context) =>\n pruneSnapshots(context, {\n dryRun: values[\"dry-run\"],\n ...(values[\"older-than\"] === undefined\n ? {}\n : { olderThanDays: Number(values[\"older-than\"]) }),\n ...(values.otp === undefined ? {} : { otp: values.otp }),\n }),\n // The command's first name, kept working, left out of the help.\n branch: (context) => branchRelease(context, testRelease),\n promote: (context) => promote(context, via),\n status: (context) => statusCommand(context, { environment, json: values.json }),\n version: async (context) => {\n const picked = await pickScope(context, \"preview\");\n if (!picked || picked.scope.size === 0) return true;\n return (await openReleasePr(context, await prepareRelease(context, picked.scope))) !== null;\n },\n tag: async (context) => tagRelease(context, await missingTags(context)),\n ship: (context) =>\n shipTo(context, environment, { via, ...(units.length > 0 ? { scope: new Set(units) } : {}) }),\n // Deprecated: --dry-run does it. Kept working, left out of the help.\n plan: (context) => {\n out(\n paint(\"dim\", \"plan is now --dry-run: shiplane ship --dry-run, shiplane promote --dry-run\"),\n );\n return planShips(context, environment);\n },\n plugins: (context) => Promise.resolve(pluginsCommand(context.release, { json: values.json })),\n };\n\n const [first = \"\"] = units;\n const setupCommands: Record<\n string,\n (context: Awaited<ReturnType<typeof composeSetup>>) => Promise<boolean>\n > = {\n setup: (context) => setup(context, { yes: values.yes }),\n init: (context) => {\n if (values.blank) return initRelease(context, { yes: values.yes, blank: true });\n out(paint(\"dim\", \"init is now shiplane setup\"));\n return setup(context, { yes: values.yes });\n },\n add: (context) => {\n out(paint(\"dim\", \"add is now shiplane setup: run it again to add an app\"));\n return addUnit(context, first);\n },\n remove: (context) => removeUnit(context, first),\n doctor: (context) =>\n values.ci\n ? doctorCi(context, { units, channel: values.channel })\n : doctor(context, { yes: values.yes }),\n adapter: (context) => {\n if (first === \"new\" && units[1]) return newAdapter(context, units[1]);\n out(`${paint(\"red\", \"✗\")} shiplane adapter new <name>`);\n return Promise.resolve(false);\n },\n docs: (context) => docsFor(context, first),\n };\n\n const root = findRoot(cwd);\n const files = io.setup?.files ?? nodeFiles(root);\n const firstRun = command === \"next\" && !files.exists(CONFIG_FILE);\n // A dry run prints every command a ship would run, the way it would go, and runs none.\n const run =\n values[\"dry-run\"] && DRY_RUNS.has(command)\n ? (context: ReleaseContext) =>\n planShips(context, command === \"promote\" ? \"production\" : environment)\n : commands[command];\n const setUp = setupCommands[firstRun ? \"setup\" : command];\n if (setUp) {\n const load = () => loadReleaseOnDisk(root, { aliases: io.aliases });\n return (await setUp(await composeSetup(root, { load, ...io.setup }))) ? 0 : 1;\n }\n if (command === \"help\") {\n out(first === \"all\" ? HELP : SHORT_HELP);\n return 0;\n }\n if (!run) {\n out(`${paint(\"red\", \"✗\")} no command \"${command}\"`);\n out(HELP);\n return 1;\n }\n const release = await loadReleaseOnDisk(root, { aliases: io.aliases });\n if (release.problems.length > 0) {\n printProblems(release.problems);\n return 2;\n }\n (release.renames ?? []).forEach(({ from, to }) =>\n out(`${paint(\"yellow\", \"!\")} rename ${from} to ${to}: the old name still works for now`),\n );\n refreshEditorSchema(nodeFiles(release.root), release);\n const context = composeContext(\n release,\n { yes: values.yes, display: { verbose: values.verbose, mascot: values.mascot } },\n io,\n );\n return (await run(context)) === false ? 1 : 0;\n};\n","#!/usr/bin/env node\nimport { runCli } from \"./cli/main\";\n\nprocess.exitCode = await runCli(process.argv.slice(2), process.cwd());\n"],"mappings":";;;;;;;;AAYA,MAAa,gBACX;;AAGF,MAAM,eAAe,UACnB,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,aAAa,OAAO,YAAY;CAClD,MAAM,UAAU,MAAM,QAAQ,SAAS,CAAC,MAAM,SAAS,KAAK,CAAC;AAC7D,KAAI,QAAQ,SAAS,EACnB,SAAQ,SAAS;EACf,MAAM;EACN,SAAS,kBAAkB,QAAQ,KAAK,KAAK,CAAC,YAAY,MAAM,KAAK,KAAK,CAAC;EAC5E,CAAC;EAEJ;AAEJ,MAAM,oBAAoB,EAAE,KAAK,cAAc,EAC7C,QAAQ,EAAE,YAAY,wBAAwB,OAAO,MAAM,CAAC,KAAK,aAAa,KAAK,KAAK,IACzF,CAAC;;AAGF,MAAM,aAAa,UAAsB,MAAM,OAAO,IAAI,WAAW;;AAGrE,MAAM,UAAU,SAAuB,SACrC,KAAK,QAAQ,mBAAmB,GAAG,SAAiB,QAAQ,MAAM,IAAI,KAAK,IAAI,GAAG;;;;;AAMpF,MAAM,UAAU,OAAO,SAAuB,gBAA6B;CACzE,MAAM,EAAE,OAAO,OAAO,SAAS;CAC/B,MAAM,EAAE,OAAO,SAAS,QAAQ;AAChC,KAAI,CAAC,IAAK,QAAO,GAAG,MAAM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