shiplane 0.0.0 → 0.1.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.
package/dist/cli.js ADDED
@@ -0,0 +1,503 @@
1
+ #!/usr/bin/env node
2
+ import { t as shellServerHosting } from "./shell-server-hosting.adapter-Bgl6-IWw.js";
3
+ import { C as ENVIRONMENTS, T as nodeFiles, _ as addUnit, a as missingTags, b as doctor, c as shipTo, d as pickScope, f as openReleasePr, g as loadRelease, h as findConfig, i as releaseToPreview, l as prepareRelease, m as docsFor, n as systemShell, o as tagRelease, p as newAdapter, r as liveLine, s as promote, t as readStatus, u as planShips, v as removeUnit, w as keysAt, x as refreshEditorSchema, y as initRelease } from "./readStatus-D5YVR5ZC.js";
4
+ import { n as progressBar, r as resolveDisplay, t as mascotFrame } from "./display-DM0xtQbT.js";
5
+ import { createRequire } from "node:module";
6
+ import { z } from "zod";
7
+ import { parseArgs, styleText } from "node:util";
8
+ import fs from "node:fs";
9
+ import path from "node:path";
10
+ import { pathToFileURL } from "node:url";
11
+ import { emitKeypressEvents } from "node:readline";
12
+ import { createInterface } from "node:readline/promises";
13
+ import { setTimeout as setTimeout$1 } from "node:timers/promises";
14
+ import { confirm, isCancel, multiselect, select, text } from "@clack/prompts";
15
+ //#region src/adapters/terminal/terminal-progress.adapter.ts
16
+ const MASCOT_WIDTH = 13;
17
+ /** The mascot in colour: spines, face, then what he holds; red when worried, green when happy. */
18
+ const paintMascot = (mood, tick) => {
19
+ const frame = [...mascotFrame(mood, tick)];
20
+ if (mood === "worried") return styleText("red", frame.join(""));
21
+ const face = frame.slice(5, 10).join("");
22
+ return `${styleText("yellow", frame.slice(0, 5).join(""))}${styleText(mood === "happy" ? ["bold", "green"] : "bold", face)}${styleText("cyan", frame.slice(10).join(""))}`;
23
+ };
24
+ const elapsed = (since) => {
25
+ const seconds = Math.round((Date.now() - since) / 1e3);
26
+ return seconds < 60 ? `${seconds}s` : `${Math.floor(seconds / 60)}m ${String(seconds % 60).padStart(2, "0")}s`;
27
+ };
28
+ /** Cuts `text` to what the terminal shows on one line, so redrawing it in place stays clean. */
29
+ const fit = (text, taken) => {
30
+ const room = Math.max(20, (process.stdout.columns || 100) - taken);
31
+ return text.length > room ? `${text.slice(0, room - 1)}…` : text;
32
+ };
33
+ const counterOf = (step) => step ? `${step.index + 1}/${step.total} ` : "";
34
+ /**
35
+ * Progress in a terminal. Verbose: the journey bar, what it reads, each step redrawn in place with
36
+ * its time, the mascot beside it. Not verbose: only each step's name, as before. A CI log or a pipe
37
+ * gets plain lines, never a redraw.
38
+ */
39
+ const terminalProgress = (display, inPlace) => {
40
+ const mascot = (mood, tick) => display.mascot ? `${paintMascot(mood, display.motion ? tick : 0)} ` : "";
41
+ const taken = (step) => 2 + (display.mascot ? MASCOT_WIDTH + 1 : 0) + counterOf(step).length + 8;
42
+ const during = async (label, mood, work, step) => {
43
+ const counter = styleText("dim", counterOf(step));
44
+ if (!display.verbose) {
45
+ if (step) {
46
+ liveLine.above("");
47
+ liveLine.above(styleText(["bold", "cyan"], `▶ ${label}`));
48
+ }
49
+ return work();
50
+ }
51
+ const text = fit(label, taken(step));
52
+ if (!inPlace || liveLine.busy) {
53
+ liveLine.above(` ${mascot(mood, 0)}${counter}${text}`);
54
+ return work();
55
+ }
56
+ const started = Date.now();
57
+ liveLine.show((tick) => ` ${mascot(mood, tick)}${counter}${text} ${styleText("dim", elapsed(started))}`, true);
58
+ try {
59
+ const result = await work();
60
+ liveLine.clear();
61
+ liveLine.above(` ${styleText("green", "✓")} ${counter}${text} ${styleText("dim", elapsed(started))}`);
62
+ return result;
63
+ } catch (error) {
64
+ liveLine.clear();
65
+ liveLine.above(` ${styleText("red", "✗")} ${counter}${text} ${styleText("dim", elapsed(started))}`);
66
+ throw error;
67
+ }
68
+ };
69
+ return {
70
+ stage: (stages, index) => {
71
+ if (!display.verbose) return;
72
+ const bar = styleText("green", progressBar(index + 1, stages.length, 18));
73
+ liveLine.above("");
74
+ liveLine.above(` ${bar} ${styleText("dim", `${index + 1}/${stages.length}`)} ${styleText("bold", stages[index] ?? "")}`);
75
+ },
76
+ during,
77
+ say: (mood, text) => liveLine.above(display.mascot ? ` ${mascot(mood, 0)}${text}` : text)
78
+ };
79
+ };
80
+ //#endregion
81
+ //#region src/adapters/terminal/terminal.adapter.ts
82
+ const terminalOutput = { line: (line = "") => liveLine.above(line) };
83
+ /** Whether this process runs inside a GitHub Actions job. */
84
+ const onGitHubActions = () => process.env.GITHUB_ACTIONS === "true";
85
+ const systemClock = {
86
+ now: () => /* @__PURE__ */ new Date(),
87
+ sleep: async (ms) => {
88
+ await setTimeout$1(ms);
89
+ }
90
+ };
91
+ const FRAMES = [
92
+ "⠋",
93
+ "⠙",
94
+ "⠹",
95
+ "⠸",
96
+ "⠼",
97
+ "⠴",
98
+ "⠦",
99
+ "⠧",
100
+ "⠇",
101
+ "⠏"
102
+ ];
103
+ /** A spinner, or the mascot waiting, on one line until a listed key is pressed or `ms` pass. Ctrl-C ends the process. */
104
+ const waitForKey = (display, label, ms, keys) => new Promise((resolve) => {
105
+ const startedAt = Date.now();
106
+ let frame = 0;
107
+ const draw = () => {
108
+ const seconds = Math.round((Date.now() - startedAt) / 1e3);
109
+ const tick = frame++;
110
+ const glyph = display.mascot ? paintMascot("waiting", display.motion ? Math.floor(tick / 5) : 0) : styleText("cyan", FRAMES[tick % FRAMES.length] ?? "");
111
+ process.stdout.write(`\r ${glyph} ${label} ${styleText("dim", `${seconds}s`)}`);
112
+ };
113
+ const timer = setInterval(draw, 80);
114
+ const finish = (key) => {
115
+ clearInterval(timer);
116
+ clearTimeout(timeout);
117
+ process.stdin.off("keypress", onKey);
118
+ process.stdin.setRawMode(false);
119
+ process.stdin.pause();
120
+ process.stdout.write("\r\x1B[2K");
121
+ resolve(key);
122
+ };
123
+ const onKey = (_text, key) => {
124
+ if (key?.ctrl && key.name === "c") {
125
+ finish(null);
126
+ process.stdout.write(`${styleText("dim", " Stopped waiting. release picks up right here.")}\n`);
127
+ process.exit(130);
128
+ }
129
+ if (key?.name && keys.includes(key.name)) finish(key.name);
130
+ };
131
+ const timeout = setTimeout(() => finish(null), ms);
132
+ emitKeypressEvents(process.stdin);
133
+ process.stdin.setRawMode(true);
134
+ process.stdin.resume();
135
+ process.stdin.on("keypress", onKey);
136
+ });
137
+ const asOptions = (choices) => choices;
138
+ const orNull = (answer) => isCancel(answer) ? null : answer;
139
+ const NO_MASCOT = {
140
+ verbose: false,
141
+ mascot: false,
142
+ motion: false
143
+ };
144
+ /** Questions through @clack/prompts, each owning the terminal; without one, every answer is no. */
145
+ const terminalPrompter = (display = NO_MASCOT) => {
146
+ const interactive = Boolean(process.stdin.isTTY);
147
+ const hold = (work) => liveLine.hold(work);
148
+ return {
149
+ interactive,
150
+ confirm: (question, initial = false) => hold(async () => interactive && orNull(await confirm({
151
+ message: question,
152
+ initialValue: initial
153
+ })) === true),
154
+ typed: (question, word) => hold(async () => {
155
+ if (!interactive) return false;
156
+ const prompt = createInterface({
157
+ input: process.stdin,
158
+ output: process.stdout
159
+ });
160
+ const answer = await prompt.question(`${styleText("bold", question)} `);
161
+ prompt.close();
162
+ return answer.trim() === word;
163
+ }),
164
+ select: (message, choices, initial) => hold(async () => interactive ? orNull(await select({
165
+ message,
166
+ options: asOptions(choices),
167
+ initialValue: initial
168
+ })) : null),
169
+ multiselect: (message, choices, initial) => hold(async () => interactive ? orNull(await multiselect({
170
+ message,
171
+ options: asOptions(choices),
172
+ initialValues: initial,
173
+ required: false
174
+ })) : null),
175
+ text: (message, initial) => hold(async () => interactive ? orNull(await text({
176
+ message,
177
+ initialValue: initial
178
+ })) : null),
179
+ waitForKey: (label, ms, keys) => hold(async () => {
180
+ if (interactive) return waitForKey(display, label, ms, keys);
181
+ await setTimeout$1(ms);
182
+ return null;
183
+ })
184
+ };
185
+ };
186
+ //#endregion
187
+ //#region src/cli/plugins.ts
188
+ const readJson = (file) => JSON.parse(fs.readFileSync(file, "utf8"));
189
+ const isRecord = (value) => typeof value === "object" && value !== null;
190
+ /**
191
+ * The delivery adapters init can offer: the built-in shell adapter, then each one a plugin this
192
+ * repository depends on names in its package.json. A plugin that does not load is skipped.
193
+ */
194
+ const installedAdapters = async (root) => {
195
+ const manifestFile = path.join(root, "package.json");
196
+ if (!fs.existsSync(manifestFile)) return [shellServerHosting()];
197
+ const manifest = readJson(manifestFile);
198
+ const names = Object.keys({
199
+ ...manifest.dependencies,
200
+ ...manifest.devDependencies
201
+ });
202
+ const require = createRequire(manifestFile);
203
+ return [...(await Promise.all(names.map(async (name) => {
204
+ try {
205
+ const factories = readJson(require.resolve(`${name}/package.json`)).shiplane?.adapters ?? [];
206
+ if (factories.length === 0) return [];
207
+ const loaded = await import(pathToFileURL(require.resolve(name)).href);
208
+ if (!isRecord(loaded)) return [];
209
+ return factories.flatMap((factory) => {
210
+ const make = loaded[factory];
211
+ return typeof make === "function" ? [make()] : [];
212
+ });
213
+ } catch {
214
+ return [];
215
+ }
216
+ }))).flat(), shellServerHosting()];
217
+ };
218
+ //#endregion
219
+ //#region src/cli/compose.ts
220
+ /** Creates each port the flow runs on, for this repository. */
221
+ const composeServices = (release, open) => ({
222
+ sourceControl: open(release.flow.sourceControl),
223
+ codeHost: open(release.flow.codeHost),
224
+ ciPipeline: open(release.flow.ciPipeline),
225
+ versioning: open(release.flow.versioning)
226
+ });
227
+ /** Ports created on demand, in this repository, through this shell. */
228
+ const opener = (root, shell) => (adapter) => adapter.create({
229
+ root,
230
+ shell
231
+ });
232
+ /** A context wired to this machine: its shell, its terminal, its clock, unless `io` says otherwise. */
233
+ const composeContext = (release, { yes, display: flags }, io = {}) => {
234
+ const ci = onGitHubActions() || systemShell.env("CI") === "true";
235
+ const tty = Boolean(process.stdout.isTTY);
236
+ const display = resolveDisplay(release.display ?? {}, flags, {
237
+ tty,
238
+ ci,
239
+ noMotion: Boolean(systemShell.env("NO_MOTION"))
240
+ });
241
+ const shell = io.shell ?? systemShell;
242
+ const output = io.output ?? terminalOutput;
243
+ const open = opener(release.root, shell);
244
+ return {
245
+ release,
246
+ load: () => loadRelease(release.root, { aliases: io.aliases }),
247
+ services: composeServices(release, open),
248
+ open,
249
+ prompter: io.prompter ?? terminalPrompter(display),
250
+ output,
251
+ progress: io.progress ?? terminalProgress(display, tty && !ci),
252
+ clock: systemClock,
253
+ shell,
254
+ options: {
255
+ yes,
256
+ ci: onGitHubActions()
257
+ }
258
+ };
259
+ };
260
+ /** What init, add, doctor and the rest need: the repository on disk and the adapters installed. */
261
+ const composeSetup = async (root) => ({
262
+ root,
263
+ files: nodeFiles(root),
264
+ shell: systemShell,
265
+ prompter: terminalPrompter(),
266
+ output: terminalOutput,
267
+ adapters: await installedAdapters(root),
268
+ load: () => loadRelease(root)
269
+ });
270
+ //#endregion
271
+ //#region src/cli/findRoot.ts
272
+ /** The nearest folder up from here with a release config, else the git root, else here. */
273
+ const findRoot = (from) => {
274
+ const ancestors = (dir) => {
275
+ const parent = path.dirname(dir);
276
+ return parent === dir ? [dir] : [dir, ...ancestors(parent)];
277
+ };
278
+ const chain = ancestors(path.resolve(from));
279
+ return chain.find((dir) => findConfig(dir)) ?? chain.find((dir) => fs.existsSync(path.join(dir, ".git"))) ?? path.resolve(from);
280
+ };
281
+ //#endregion
282
+ //#region src/cli/output.ts
283
+ const paint = (style, text) => styleText(style, text);
284
+ const out = (line = "") => process.stdout.write(`${line}\n`);
285
+ /** Problems as `file:line message`, each hint on the line below. */
286
+ const printProblems = (problems) => {
287
+ problems.forEach(({ file, line, message, hint }) => {
288
+ const where = line === void 0 ? file : `${file}:${line}`;
289
+ out(`${paint("red", "✗")} ${paint("bold", where)} ${message}`);
290
+ if (hint) out(` ${paint("dim", hint)}`);
291
+ });
292
+ };
293
+ //#endregion
294
+ //#region src/cli/pluginsCommand.ts
295
+ /** `shiplane plugins`: the flow's adapters, the modules in release order with their apps, the features. */
296
+ const pluginsCommand = (release, { json }) => {
297
+ const { flow } = release;
298
+ const ports = {
299
+ sourceControl: flow.sourceControl.name,
300
+ codeHost: flow.codeHost.name,
301
+ ciPipeline: flow.ciPipeline.name,
302
+ versioning: flow.versioning.name
303
+ };
304
+ const modules = release.modules.map(({ name, kind, provider, settings }) => ({
305
+ name,
306
+ kind,
307
+ provider,
308
+ keys: keysAt(settings, []),
309
+ apps: release.units.filter(({ module }) => module === name).map(({ name: app }) => app)
310
+ }));
311
+ const features = release.features.map(({ name, adapters }) => ({
312
+ name,
313
+ uses: adapters.map((adapter) => adapter.name)
314
+ }));
315
+ if (json) {
316
+ out(JSON.stringify({
317
+ flow: ports,
318
+ modules,
319
+ features
320
+ }, null, 2));
321
+ return;
322
+ }
323
+ const width = Math.max(14, ...modules.map(({ name }) => name.length), ...features.map(({ name }) => name.length)) + 2;
324
+ const section = (title) => {
325
+ out();
326
+ out(paint("bold", title));
327
+ out();
328
+ };
329
+ section("Flow in shiplane.config.ts");
330
+ Object.entries(ports).forEach(([port, name]) => out(` ${port.padEnd(width)}${name}`));
331
+ section("Modules, in release order");
332
+ modules.forEach(({ name, provider, keys, apps }) => {
333
+ const used = apps.length > 0 ? `used by ${apps.join(", ")}` : paint("dim", "no app names it");
334
+ out(` ${name.padEnd(width)}${provider} ${paint("dim", keys.join(", ") || "no options")}`);
335
+ out(` ${" ".repeat(width)}${used}`);
336
+ });
337
+ section("Features, after the ship");
338
+ if (features.length === 0) out(` ${paint("dim", "none")}`);
339
+ features.forEach(({ name, uses }) => out(` ${name.padEnd(width)}${paint("dim", `uses ${uses.join(", ")}`)}`));
340
+ out();
341
+ };
342
+ //#endregion
343
+ //#region src/cli/statusCommand.ts
344
+ const NEXT = {
345
+ "release-pr": "open the release PR: shiplane",
346
+ "wait-merge": "merge the release PR, then: shiplane",
347
+ ship: "tag what was versioned and ship it: shiplane"
348
+ };
349
+ /** The next step as a person reads it; a ship with nothing pending anywhere is nothing to do. */
350
+ const nextLabel = ({ next, units, untagged }) => next.step === "ship" && untagged.length === 0 && !units.some(({ pending }) => pending) ? "nothing to release: queue a change with pnpm changeset" : NEXT[next.step] ?? "";
351
+ /** `shiplane status`: where every unit stands on an environment, and what to run next. Reads only. */
352
+ const statusCommand = async (context, { environment, json }) => {
353
+ const status = await readStatus(context, environment);
354
+ if (json) {
355
+ out(JSON.stringify(status, null, 2));
356
+ return;
357
+ }
358
+ const dot = paint("dim", "·");
359
+ out();
360
+ out(` ${paint("bold", "Release status")} ${dot} ${environment}`);
361
+ out();
362
+ const width = Math.max(8, ...status.units.map(({ unit }) => unit.length)) + 2;
363
+ out(paint("dim", ` ${"Unit".padEnd(width)}${"Version".padEnd(12)}${"Target".padEnd(18)}Where it stands`));
364
+ status.units.forEach(({ unit, version, target, pending, hint }) => {
365
+ const mark = pending ? paint("yellow", "↑") : paint("dim", "·");
366
+ out(` ${unit.padEnd(width)}${version.padEnd(12)}${target.padEnd(18)}${mark} ${hint}`);
367
+ });
368
+ status.releasePrs.forEach(({ url }) => out(`\n ${paint("cyan", "Release PR")} ${url}`));
369
+ if (status.untagged.length > 0) out(` ${paint("yellow", "Untagged")} ${status.untagged.map(({ tag }) => tag).join(", ")}`);
370
+ out();
371
+ out(`${paint(["bold", "green"], "→ Next:")} ${nextLabel(status)}`);
372
+ out();
373
+ };
374
+ //#endregion
375
+ //#region src/cli/main.ts
376
+ const HELP = `${paint("bold", "shiplane")}: detect what changed, version it, trigger each app's deploy.
377
+
378
+ shiplane the next step to preview: release PR, merge, tags, ship
379
+ shiplane promote production, from what preview runs (--channel production too)
380
+ shiplane status [--json] where every unit stands, and what to run next
381
+ shiplane version open the release PR for what is pending
382
+ shiplane tag tag merged versions and publish their release notes
383
+ shiplane ship [unit...] trigger each tagged unit's deploy, then return
384
+ shiplane plan every command a ship would run, run nothing
385
+ shiplane plugins [--json] the flow, the modules in release order and who uses each, the features
386
+
387
+ shiplane init [--yes|--blank] find what ships, write a unit file per app, then doctor
388
+ shiplane add <folder> init's questions for one folder
389
+ shiplane remove <unit> stop shipping a unit; it stays versioned
390
+ shiplane doctor check the config, tools and sign-ins, offer each fix
391
+ shiplane adapter new <name> scaffold a server hosting adapter, its contract test and its module
392
+ shiplane docs <name> every key a module's or an adapter's unit files take
393
+ shiplane help this
394
+
395
+ --channel preview|production where status reads (preview by default)
396
+ --via github|local ship through GitHub Actions or this machine, without asking
397
+ --yes answer yes to every question (never on production)
398
+ --verbose / --no-verbose say each thing it reads and runs, with a progress bar (on by default)
399
+ --mascot / --no-mascot the mascot beside it, still in CI or under NO_MOTION=1 (on by default)
400
+ Both defaults live in shiplane.config.ts: display: { verbose, mascot }
401
+ `;
402
+ /** The CLI as a person runs it, from its arguments and folder; resolves to its exit code. */
403
+ const runCli = async (argv, cwd, io = {}) => {
404
+ const { values, positionals } = parseArgs({
405
+ args: argv,
406
+ allowPositionals: true,
407
+ allowNegative: true,
408
+ options: {
409
+ verbose: { type: "boolean" },
410
+ mascot: { type: "boolean" },
411
+ json: {
412
+ type: "boolean",
413
+ default: false
414
+ },
415
+ yes: {
416
+ type: "boolean",
417
+ short: "y",
418
+ default: false
419
+ },
420
+ channel: {
421
+ type: "string",
422
+ default: "preview"
423
+ },
424
+ via: { type: "string" },
425
+ blank: {
426
+ type: "boolean",
427
+ default: false
428
+ }
429
+ }
430
+ });
431
+ const [command = "next", ...units] = positionals;
432
+ const environment = z.enum(ENVIRONMENTS).parse(values.channel);
433
+ const via = values.via === void 0 ? void 0 : z.enum(["github", "local"]).parse(values.via);
434
+ const commands = {
435
+ next: (context) => environment === "preview" ? releaseToPreview(context) : promote(context, via),
436
+ promote: (context) => promote(context, via),
437
+ status: (context) => statusCommand(context, {
438
+ environment,
439
+ json: values.json
440
+ }),
441
+ version: async (context) => {
442
+ const picked = await pickScope(context, "preview");
443
+ if (!picked || picked.scope.size === 0) return true;
444
+ return await openReleasePr(context, await prepareRelease(context, picked.scope)) !== null;
445
+ },
446
+ tag: async (context) => tagRelease(context, await missingTags(context)),
447
+ ship: (context) => shipTo(context, environment, {
448
+ via,
449
+ ...units.length > 0 ? { scope: new Set(units) } : {}
450
+ }),
451
+ plan: (context) => planShips(context, environment),
452
+ plugins: (context) => Promise.resolve(pluginsCommand(context.release, { json: values.json }))
453
+ };
454
+ const [first = ""] = units;
455
+ const setupCommands = {
456
+ init: (context) => initRelease(context, {
457
+ yes: values.yes,
458
+ blank: values.blank
459
+ }),
460
+ add: (context) => addUnit(context, first),
461
+ remove: (context) => removeUnit(context, first),
462
+ doctor: (context) => doctor(context),
463
+ adapter: (context) => {
464
+ if (first === "new" && units[1]) return newAdapter(context, units[1]);
465
+ out(`${paint("red", "✗")} shiplane adapter new <name>`);
466
+ return Promise.resolve(false);
467
+ },
468
+ docs: (context) => docsFor(context, first)
469
+ };
470
+ const run = commands[command];
471
+ const setup = setupCommands[command];
472
+ if (setup) return await setup(await composeSetup(findRoot(cwd))) ? 0 : 1;
473
+ if (command === "help") {
474
+ out(HELP);
475
+ return 0;
476
+ }
477
+ if (!run) {
478
+ out(`${paint("red", "✗")} no command "${command}"`);
479
+ out(HELP);
480
+ return 1;
481
+ }
482
+ const release = await loadRelease(findRoot(cwd), { aliases: io.aliases });
483
+ if (release.problems.length > 0) {
484
+ printProblems(release.problems);
485
+ return 2;
486
+ }
487
+ (release.renames ?? []).forEach(({ from, to }) => out(`${paint("yellow", "!")} rename ${from} to ${to}: the old name still works for now`));
488
+ refreshEditorSchema(nodeFiles(release.root), release);
489
+ return await run(composeContext(release, {
490
+ yes: values.yes,
491
+ display: {
492
+ verbose: values.verbose,
493
+ mascot: values.mascot
494
+ }
495
+ }, io)) === false ? 1 : 0;
496
+ };
497
+ //#endregion
498
+ //#region src/cli.ts
499
+ process.exitCode = await runCli(process.argv.slice(2), process.cwd());
500
+ //#endregion
501
+ export {};
502
+
503
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","names":["sleep"],"sources":["../src/adapters/terminal/terminal-progress.adapter.ts","../src/adapters/terminal/terminal.adapter.ts","../src/cli/plugins.ts","../src/cli/compose.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 { styleText } from \"node:util\";\n\nimport type { Display, Mood } from \"../../domain/display\";\nimport type { Progress, StepPlace } from \"../../ports/terminal.port\";\nimport { mascotFrame, progressBar } from \"../../domain/display\";\nimport { liveLine } from \"./live-line\";\n\nconst MASCOT_WIDTH = 13;\n\n/** The mascot in colour: spines, face, then what he holds; red when worried, green when happy. */\nexport const paintMascot = (mood: Mood, tick: number) => {\n const frame = [...mascotFrame(mood, tick)];\n if (mood === \"worried\") return styleText(\"red\", frame.join(\"\"));\n const face = frame.slice(5, 10).join(\"\");\n return `${styleText(\"yellow\", frame.slice(0, 5).join(\"\"))}${styleText(mood === \"happy\" ? [\"bold\", \"green\"] : \"bold\", face)}${styleText(\"cyan\", frame.slice(10).join(\"\"))}`;\n};\n\nconst elapsed = (since: number) => {\n const seconds = Math.round((Date.now() - since) / 1000);\n return seconds < 60\n ? `${seconds}s`\n : `${Math.floor(seconds / 60)}m ${String(seconds % 60).padStart(2, \"0\")}s`;\n};\n\n/** Cuts `text` to what the terminal shows on one line, so redrawing it in place stays clean. */\nconst fit = (text: string, taken: number) => {\n const room = Math.max(20, (process.stdout.columns || 100) - taken);\n return text.length > room ? `${text.slice(0, room - 1)}…` : text;\n};\n\nconst counterOf = (step?: StepPlace) => (step ? `${step.index + 1}/${step.total} ` : \"\");\n\n/**\n * Progress in a terminal. Verbose: the journey bar, what it reads, each step redrawn in place with\n * its time, the mascot beside it. Not verbose: only each step's name, as before. A CI log or a pipe\n * gets plain lines, never a redraw.\n */\nexport const terminalProgress = (display: Display, inPlace: boolean): Progress => {\n const mascot = (mood: Mood, tick: number) =>\n display.mascot ? `${paintMascot(mood, display.motion ? tick : 0)} ` : \"\";\n const taken = (step?: StepPlace) =>\n 2 + (display.mascot ? MASCOT_WIDTH + 1 : 0) + counterOf(step).length + 8;\n\n const during = async <T>(\n label: string,\n mood: Mood,\n work: () => Promise<T>,\n step?: StepPlace,\n ): Promise<T> => {\n const counter = styleText(\"dim\", counterOf(step));\n if (!display.verbose) {\n if (step) {\n liveLine.above(\"\");\n liveLine.above(styleText([\"bold\", \"cyan\"], `▶ ${label}`));\n }\n return work();\n }\n const text = fit(label, taken(step));\n if (!inPlace || liveLine.busy) {\n liveLine.above(` ${mascot(mood, 0)}${counter}${text}`);\n return work();\n }\n const started = Date.now();\n liveLine.show(\n (tick) => ` ${mascot(mood, tick)}${counter}${text} ${styleText(\"dim\", elapsed(started))}`,\n true,\n );\n try {\n const result = await work();\n liveLine.clear();\n liveLine.above(\n ` ${styleText(\"green\", \"✓\")} ${counter}${text} ${styleText(\"dim\", elapsed(started))}`,\n );\n return result;\n } catch (error) {\n liveLine.clear();\n liveLine.above(\n ` ${styleText(\"red\", \"✗\")} ${counter}${text} ${styleText(\"dim\", elapsed(started))}`,\n );\n throw error;\n }\n };\n\n return {\n stage: (stages, index) => {\n if (!display.verbose) return;\n const bar = styleText(\"green\", progressBar(index + 1, stages.length, 18));\n liveLine.above(\"\");\n liveLine.above(\n ` ${bar} ${styleText(\"dim\", `${index + 1}/${stages.length}`)} ${styleText(\"bold\", stages[index] ?? \"\")}`,\n );\n },\n during,\n say: (mood, text) => liveLine.above(display.mascot ? ` ${mascot(mood, 0)}${text}` : text),\n };\n};\n","import { emitKeypressEvents } from \"node:readline\";\nimport { createInterface } from \"node:readline/promises\";\nimport { setTimeout as sleep } from \"node:timers/promises\";\nimport { styleText } from \"node:util\";\nimport type { Option } from \"@clack/prompts\";\nimport { confirm, isCancel, multiselect, select, text } from \"@clack/prompts\";\n\nimport type { Display } from \"../../domain/display\";\nimport type { Choice, Clock, Output, Prompter } from \"../../ports/terminal.port\";\nimport { liveLine } from \"./live-line\";\nimport { paintMascot } from \"./terminal-progress.adapter\";\n\nexport const terminalOutput: Output = {\n line: (line = \"\") => liveLine.above(line),\n};\n\n/** Whether this process runs inside a GitHub Actions job. */\n\nexport const onGitHubActions = () => process.env.GITHUB_ACTIONS === \"true\";\n\nexport const systemClock: Clock = {\n now: () => new Date(),\n sleep: async (ms) => {\n await sleep(ms);\n },\n};\n\nconst FRAMES = [\"⠋\", \"⠙\", \"⠹\", \"⠸\", \"⠼\", \"⠴\", \"⠦\", \"⠧\", \"⠇\", \"⠏\"];\n\n/** A spinner, or the mascot waiting, on one line until a listed key is pressed or `ms` pass. Ctrl-C ends the process. */\nconst waitForKey = (display: Display, label: string, ms: number, keys: readonly string[]) =>\n new Promise<string | null>((resolve) => {\n const startedAt = Date.now();\n let frame = 0;\n const draw = () => {\n const seconds = Math.round((Date.now() - startedAt) / 1000);\n const tick = frame++;\n const glyph = display.mascot\n ? paintMascot(\"waiting\", display.motion ? Math.floor(tick / 5) : 0)\n : styleText(\"cyan\", FRAMES[tick % FRAMES.length] ?? \"\");\n process.stdout.write(`\\r ${glyph} ${label} ${styleText(\"dim\", `${seconds}s`)}`);\n };\n const timer = setInterval(draw, 80);\n const finish = (key: string | null) => {\n clearInterval(timer);\n clearTimeout(timeout);\n process.stdin.off(\"keypress\", onKey);\n process.stdin.setRawMode(false);\n process.stdin.pause();\n process.stdout.write(\"\\r\\u001B[2K\");\n resolve(key);\n };\n const onKey = (_text: string, key: { name?: string; ctrl?: boolean } | undefined) => {\n if (key?.ctrl && key.name === \"c\") {\n finish(null);\n process.stdout.write(\n `${styleText(\"dim\", \" Stopped waiting. release picks up right here.\")}\\n`,\n );\n process.exit(130);\n }\n if (key?.name && keys.includes(key.name)) finish(key.name);\n };\n const timeout = setTimeout(() => finish(null), ms);\n emitKeypressEvents(process.stdin);\n process.stdin.setRawMode(true);\n process.stdin.resume();\n process.stdin.on(\"keypress\", onKey);\n });\n\n// clack types an option per primitive value; a Choice has the same fields.\nconst asOptions = <Value extends string>(choices: Choice<Value>[]) =>\n choices as unknown as Option<Value>[];\n\nconst orNull = <Value>(answer: Value | symbol): Value | null => (isCancel(answer) ? null : answer);\n\nconst NO_MASCOT: Display = { verbose: false, mascot: false, motion: false };\n\n/** Questions through @clack/prompts, each owning the terminal; without one, every answer is no. */\nexport const terminalPrompter = (display: Display = NO_MASCOT): Prompter => {\n const interactive = Boolean(process.stdin.isTTY);\n const hold = <T>(work: () => Promise<T>) => liveLine.hold(work);\n return {\n interactive,\n confirm: (question, initial = false) =>\n hold(\n async () =>\n interactive &&\n orNull(await confirm({ message: question, initialValue: initial })) === true,\n ),\n typed: (question, word) =>\n hold(async () => {\n if (!interactive) return false;\n const prompt = createInterface({ input: process.stdin, output: process.stdout });\n const answer = await prompt.question(`${styleText(\"bold\", question)} `);\n prompt.close();\n return answer.trim() === word;\n }),\n select: (message, choices, initial) =>\n hold(async () =>\n interactive\n ? orNull(await select({ message, options: asOptions(choices), initialValue: initial }))\n : null,\n ),\n multiselect: (message, choices, initial) =>\n hold(async () =>\n interactive\n ? orNull(\n await multiselect({\n message,\n options: asOptions(choices),\n initialValues: initial,\n required: false,\n }),\n )\n : null,\n ),\n text: (message, initial) =>\n hold(async () =>\n interactive ? orNull(await text({ message, initialValue: initial })) : null,\n ),\n waitForKey: (label, ms, keys) =>\n hold(async () => {\n if (interactive) return waitForKey(display, label, ms, keys);\n await sleep(ms);\n return null;\n }),\n };\n};\n","import fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport type { AnyDeliveryAdapter } from \"../modules/suggest\";\nimport { shellServerHosting } from \"../adapters/server-hosting/shell-server-hosting.adapter\";\n\n/** A plugin's own word on what init may offer: `\"shiplane\": { \"adapters\": [\"flyServerHosting\"] }`. */\ninterface PluginManifest {\n shiplane?: { adapters?: string[] };\n}\n\nconst readJson = (file: string): unknown => JSON.parse(fs.readFileSync(file, \"utf8\"));\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\n/**\n * The delivery adapters init can offer: the built-in shell adapter, then each one a plugin this\n * repository depends on names in its package.json. A plugin that does not load is skipped.\n */\nexport const installedAdapters = async (root: string): Promise<AnyDeliveryAdapter[]> => {\n const manifestFile = path.join(root, \"package.json\");\n if (!fs.existsSync(manifestFile)) return [shellServerHosting()];\n const manifest = readJson(manifestFile) as Record<string, Record<string, string> | undefined>;\n const names = Object.keys({ ...manifest.dependencies, ...manifest.devDependencies });\n const require = createRequire(manifestFile);\n const found = await Promise.all(\n names.map(async (name): Promise<AnyDeliveryAdapter[]> => {\n try {\n const own = readJson(require.resolve(`${name}/package.json`)) as PluginManifest;\n const factories = own.shiplane?.adapters ?? [];\n if (factories.length === 0) return [];\n const loaded: unknown = await import(pathToFileURL(require.resolve(name)).href);\n if (!isRecord(loaded)) return [];\n return factories.flatMap((factory) => {\n const make = loaded[factory];\n return typeof make === \"function\" ? [make() as AnyDeliveryAdapter] : [];\n });\n } catch {\n return [];\n }\n }),\n );\n return [...found.flat(), shellServerHosting()];\n};\n","import type { Release } from \"../application/config/loadRelease\";\nimport type { ReleaseContext, Services } from \"../application/context\";\nimport type { SetupContext } from \"../application/setupContext\";\nimport type { DisplayChoice } from \"../domain/display\";\nimport type { Open } from \"../modules/module\";\nimport type { Shell } from \"../ports/shell.port\";\nimport type { Output, Progress, Prompter } from \"../ports/terminal.port\";\nimport { nodeFiles } from \"../adapters/files/node-files.adapter\";\nimport { systemShell } from \"../adapters/shell/system-shell.adapter\";\nimport { terminalProgress } from \"../adapters/terminal/terminal-progress.adapter\";\nimport {\n onGitHubActions,\n systemClock,\n terminalOutput,\n terminalPrompter,\n} from \"../adapters/terminal/terminal.adapter\";\nimport { loadRelease } from \"../application/config/loadRelease\";\nimport { resolveDisplay } from \"../domain/display\";\nimport { installedAdapters } from \"./plugins\";\n\n/** Creates each port the flow runs on, for this repository. */\nexport const composeServices = (release: Release, open: Open): Services => ({\n sourceControl: open(release.flow.sourceControl),\n codeHost: open(release.flow.codeHost),\n ciPipeline: open(release.flow.ciPipeline),\n versioning: open(release.flow.versioning),\n});\n\n/** Ports created on demand, in this repository, through this shell. */\nexport const opener =\n (root: string, shell: Shell): Open =>\n (adapter) =>\n adapter.create({ root, shell });\n\n/** What a run may take instead of this machine's: a scripted person, a recorded terminal or shell. */\nexport interface ContextIo {\n prompter?: Prompter;\n output?: Output;\n progress?: Progress;\n shell?: Shell;\n /** Where `shiplane` resolves from inside the config. */\n aliases?: Record<string, string>;\n}\n\n/** A context wired to this machine: its shell, its terminal, its clock, unless `io` says otherwise. */\nexport const composeContext = (\n release: Release,\n { yes, display: flags }: { yes: boolean; display: DisplayChoice },\n io: ContextIo = {},\n): ReleaseContext => {\n const ci = onGitHubActions() || systemShell.env(\"CI\") === \"true\";\n const tty = Boolean(process.stdout.isTTY);\n const display = resolveDisplay(release.display ?? {}, flags, {\n tty,\n ci,\n noMotion: Boolean(systemShell.env(\"NO_MOTION\")),\n });\n const shell = io.shell ?? systemShell;\n const output = io.output ?? terminalOutput;\n const open = opener(release.root, shell);\n return {\n release,\n load: () => loadRelease(release.root, { aliases: io.aliases }),\n services: composeServices(release, open),\n open,\n prompter: io.prompter ?? terminalPrompter(display),\n output,\n progress: io.progress ?? terminalProgress(display, tty && !ci),\n clock: systemClock,\n shell,\n options: { yes, ci: onGitHubActions() },\n };\n};\n\n/** What init, add, doctor and the rest need: the repository on disk and the adapters installed. */\nexport const composeSetup = async (root: string): Promise<SetupContext> => ({\n root,\n files: nodeFiles(root),\n shell: systemShell,\n prompter: terminalPrompter(),\n output: terminalOutput,\n adapters: await installedAdapters(root),\n load: () => loadRelease(root),\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 { styleText } from \"node:util\";\n\nimport type { ConfigProblem } from \"../application/config/problem\";\n\ntype Style = Parameters<typeof styleText>[0];\n\nexport const paint = (style: Style, text: string) => styleText(style, text);\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 { out, paint } 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 { out, paint } 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 next,\n units,\n untagged,\n}: {\n next: { step: string };\n units: readonly { pending: boolean }[];\n untagged: readonly unknown[];\n}) =>\n next.step === \"ship\" && untagged.length === 0 && !units.some(({ pending }) => pending)\n ? \"nothing to release: queue a change with pnpm changeset\"\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 out(` ${paint(\"bold\", \"Release status\")} ${dot} ${environment}`);\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(`${paint([\"bold\", \"green\"], \"→ Next:\")} ${nextLabel(status)}`);\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 { loadRelease } from \"../application/config/loadRelease\";\nimport { docsFor } from \"../application/docsFor\";\nimport { doctor } from \"../application/doctor\";\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 { releaseToPreview } from \"../application/releaseToPreview\";\nimport { refreshEditorSchema } from \"../application/setupFiles\";\nimport { shipTo } from \"../application/ship\";\nimport { missingTags, tagRelease } from \"../application/tagRelease\";\nimport { ENVIRONMENTS } from \"../domain/environment\";\nimport { composeContext, composeSetup } from \"./compose\";\nimport { findRoot } from \"./findRoot\";\nimport { out, paint, printProblems } from \"./output\";\nimport { pluginsCommand } from \"./pluginsCommand\";\nimport { statusCommand } from \"./statusCommand\";\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 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 plan every command a ship would run, run nothing\n shiplane plugins [--json] the flow, the modules in release order and who uses each, the features\n\n shiplane init [--yes|--blank] find what ships, write a unit file per app, then doctor\n shiplane add <folder> init's questions for one folder\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 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 this\n\n --channel preview|production where status reads (preview by default)\n --via github|local ship through GitHub Actions or this machine, without asking\n --yes answer yes to every question (never on production)\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 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 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 },\n });\n\n const [command = \"next\", ...units] = positionals;\n const environment = z.enum(ENVIRONMENTS).parse(values.channel);\n const via = values.via === undefined ? undefined : z.enum([\"github\", \"local\"]).parse(values.via);\n\n const commands: Record<string, (context: ReleaseContext) => Promise<boolean | void>> = {\n next: (context) =>\n environment === \"preview\" ? releaseToPreview(context) : promote(context, via),\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 plan: (context) => planShips(context, environment),\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 init: (context) => initRelease(context, { yes: values.yes, blank: values.blank }),\n add: (context) => addUnit(context, first),\n remove: (context) => removeUnit(context, first),\n doctor: (context) => doctor(context),\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 run = commands[command];\n const setup = setupCommands[command];\n if (setup) return (await setup(await composeSetup(findRoot(cwd)))) ? 0 : 1;\n if (command === \"help\") {\n out(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 loadRelease(findRoot(cwd), { 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":";;;;;;;;;;;;;;;AAOA,MAAM,eAAe;;AAGrB,MAAa,eAAe,MAAY,SAAiB;CACvD,MAAM,QAAQ,CAAC,GAAG,YAAY,MAAM,KAAK,CAAC;AAC1C,KAAI,SAAS,UAAW,QAAO,UAAU,OAAO,MAAM,KAAK,GAAG,CAAC;CAC/D,MAAM,OAAO,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,GAAG;AACxC,QAAO,GAAG,UAAU,UAAU,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,UA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AY,QAAQ,SAAS,MAAM;EAC3C;CAED,MAAM,MAAM,SAAS;CACrB,MAAM,QAAQ,cAAc;AAC5B,KAAI,MAAO,QAAQ,MAAM,MAAM,MAAM,aAAa,SAAS,IAAI,CAAC,CAAC,GAAI,IAAI;AACzE,KAAI,YAAY,QAAQ;AACtB,MAAI,KAAK;AACT,SAAO;;AAET,KAAI,CAAC,KAAK;AACR,MAAI,GAAG,MAAM,OAAO,IAAI,CAAC,gBAAgB,QAAQ,GAAG;AACpD,MAAI,KAAK;AACT,SAAO;;CAET,MAAM,UAAU,MAAM,YAAY,SAAS,IAAI,EAAE,EAAE,SAAS,GAAG,SAAS,CAAC;AACzE,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;;;;ACrI9C,QAAQ,WAAW,MAAM,OAAO,QAAQ,KAAK,MAAM,EAAE,EAAE,QAAQ,KAAK,CAAC"}
@@ -0,0 +1,55 @@
1
+ //#region src/domain/display.ts
2
+ const UP = "/\\/\\/";
3
+ const DOWN = "\\/\\/\\";
4
+ const FRAMES = {
5
+ thinking: [
6
+ `${UP}(•ω•) ? `,
7
+ `${UP}(•ω•) ?`,
8
+ `${DOWN}(•ω•) ? `,
9
+ `${DOWN}(•ω•) `
10
+ ],
11
+ working: [
12
+ `${UP}(•ω•)/ `,
13
+ `${UP}(•ω•)- `,
14
+ `${DOWN}(•ω•)\\ `,
15
+ `${DOWN}(•ω•)| `
16
+ ],
17
+ waiting: [
18
+ `${UP}(-ω-) z `,
19
+ `${UP}(-ω-) zz`,
20
+ `${UP}(•ω•) `,
21
+ `${UP}(-ω-) zZ`
22
+ ],
23
+ happy: [
24
+ `${UP}(^ω^) ✦ `,
25
+ `${DOWN}(^ω^) ✧ `,
26
+ `${UP}(^ω^)✦ ✧`,
27
+ `${DOWN}(^ω^) ✧ `
28
+ ],
29
+ worried: [`${UP}(°ω°) ; `, `${DOWN}(°ω°) ;;`],
30
+ resting: [`${UP}(-ω-) zZ`, `${UP}(-ω-) z`]
31
+ };
32
+ /** The mascot at a tick of his animation, looping. */
33
+ const mascotFrame = (mood, tick) => {
34
+ const frames = FRAMES[mood];
35
+ return frames[tick % frames.length] ?? "";
36
+ };
37
+ /** `done` of `total` as a bar `width` characters wide. */
38
+ const progressBar = (done, total, width) => {
39
+ const filled = total <= 0 ? width : Math.round(width * Math.min(done, total) / total);
40
+ return `${"█".repeat(filled)}${"░".repeat(width - filled)}`;
41
+ };
42
+ /** A flag wins over the config, which wins over the default: verbose, with the mascot. */
43
+ const resolveDisplay = (config, flags, terminal) => {
44
+ const verbose = flags.verbose ?? config.verbose ?? true;
45
+ const mascot = flags.mascot ?? config.mascot ?? true;
46
+ return {
47
+ verbose,
48
+ mascot,
49
+ motion: mascot && terminal.tty && !terminal.ci && !terminal.noMotion
50
+ };
51
+ };
52
+ //#endregion
53
+ export { progressBar as n, resolveDisplay as r, mascotFrame as t };
54
+
55
+ //# sourceMappingURL=display-DM0xtQbT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display-DM0xtQbT.js","names":[],"sources":["../src/domain/display.ts"],"sourcesContent":["export const MOODS = [\"thinking\", \"working\", \"waiting\", \"happy\", \"worried\", \"resting\"] as const;\n\n/** What the mascot shows beside the release: reading, running, waiting on a person, done, failed, idle. */\nexport type Mood = (typeof MOODS)[number];\n\n// Spines that rise and fall, a face, then what he holds: every frame is 13 characters wide.\nconst UP = \"/\\\\/\\\\/\";\nconst DOWN = \"\\\\/\\\\/\\\\\";\n\nconst FRAMES: Record<Mood, readonly string[]> = {\n thinking: [`${UP}(•ω•) ? `, `${UP}(•ω•) ?`, `${DOWN}(•ω•) ? `, `${DOWN}(•ω•) `],\n working: [`${UP}(•ω•)/ `, `${UP}(•ω•)- `, `${DOWN}(•ω•)\\\\ `, `${DOWN}(•ω•)| `],\n waiting: [`${UP}(-ω-) z `, `${UP}(-ω-) zz`, `${UP}(•ω•) `, `${UP}(-ω-) zZ`],\n happy: [`${UP}(^ω^) ✦ `, `${DOWN}(^ω^) ✧ `, `${UP}(^ω^)✦ ✧`, `${DOWN}(^ω^) ✧ `],\n worried: [`${UP}(°ω°) ; `, `${DOWN}(°ω°) ;;`],\n resting: [`${UP}(-ω-) zZ`, `${UP}(-ω-) z`],\n};\n\nexport const mascotFrames = (mood: Mood) => FRAMES[mood];\n\n/** The mascot at a tick of his animation, looping. */\nexport const mascotFrame = (mood: Mood, tick: number) => {\n const frames = FRAMES[mood];\n return frames[tick % frames.length] ?? \"\";\n};\n\n/** `done` of `total` as a bar `width` characters wide. */\nexport const progressBar = (done: number, total: number, width: number) => {\n const filled = total <= 0 ? width : Math.round((width * Math.min(done, total)) / total);\n return `${\"█\".repeat(filled)}${\"░\".repeat(width - filled)}`;\n};\n\n/** How much the release says while it runs, as `shiplane.config.ts` or a flag asks. */\nexport interface DisplayChoice {\n /** Says each thing it reads and runs, with a progress bar. */\n verbose?: boolean;\n /** The mascot beside what is happening. */\n mascot?: boolean;\n}\n\nexport interface Display {\n verbose: boolean;\n mascot: boolean;\n /** The mascot animates: only in a terminal, never in a CI log or under NO_MOTION. */\n motion: boolean;\n}\n\n/** A flag wins over the config, which wins over the default: verbose, with the mascot. */\nexport const resolveDisplay = (\n config: DisplayChoice,\n flags: DisplayChoice,\n terminal: { tty: boolean; ci: boolean; noMotion: boolean },\n): Display => {\n const verbose = flags.verbose ?? config.verbose ?? true;\n const mascot = flags.mascot ?? config.mascot ?? true;\n return { verbose, mascot, motion: mascot && terminal.tty && !terminal.ci && !terminal.noMotion };\n};\n"],"mappings":";AAMA,MAAM,KAAK;AACX,MAAM,OAAO;AAEb,MAAM,SAA0C;CAC9C,UAAU;EAAC,GAAG,GAAG;EAAW,GAAG,GAAG;EAAW,GAAG,KAAK;EAAW,GAAG,KAAK;EAAU;CAClF,SAAS;EAAC,GAAG,GAAG;EAAW,GAAG,GAAG;EAAW,GAAG,KAAK;EAAY,GAAG,KAAK;EAAU;CAClF,SAAS;EAAC,GAAG,GAAG;EAAW,GAAG,GAAG;EAAW,GAAG,GAAG;EAAW,GAAG,GAAG;EAAU;CAC7E,OAAO;EAAC,GAAG,GAAG;EAAW,GAAG,KAAK;EAAW,GAAG,GAAG;EAAW,GAAG,KAAK;EAAU;CAC/E,SAAS,CAAC,GAAG,GAAG,WAAW,GAAG,KAAK,UAAU;CAC7C,SAAS,CAAC,GAAG,GAAG,WAAW,GAAG,GAAG,UAAU;CAC5C;;AAKD,MAAa,eAAe,MAAY,SAAiB;CACvD,MAAM,SAAS,OAAO;AACtB,QAAO,OAAO,OAAO,OAAO,WAAW;;;AAIzC,MAAa,eAAe,MAAc,OAAe,UAAkB;CACzE,MAAM,SAAS,SAAS,IAAI,QAAQ,KAAK,MAAO,QAAQ,KAAK,IAAI,MAAM,MAAM,GAAI,MAAM;AACvF,QAAO,GAAG,IAAI,OAAO,OAAO,GAAG,IAAI,OAAO,QAAQ,OAAO;;;AAmB3D,MAAa,kBACX,QACA,OACA,aACY;CACZ,MAAM,UAAU,MAAM,WAAW,OAAO,WAAW;CACnD,MAAM,SAAS,MAAM,UAAU,OAAO,UAAU;AAChD,QAAO;EAAE;EAAS;EAAQ,QAAQ,UAAU,SAAS,OAAO,CAAC,SAAS,MAAM,CAAC,SAAS;EAAU"}