shiplane 0.5.2 → 0.6.0-fix-shiplane-ship-node-cache.3dccda9
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/README.md +1 -1
- package/dist/cli.js +157 -312
- package/dist/cli.js.map +1 -1
- package/dist/{readStatus-DypM0faL.js → compose-BTQXZqHM.js} +2758 -1448
- package/dist/compose-BTQXZqHM.js.map +1 -0
- package/dist/{budget-BTnKtGF6.js → display-CfV4G1TR.js} +155 -52
- package/dist/display-CfV4G1TR.js.map +1 -0
- package/dist/{static-hosting.port-B5i6W7eD.d.ts → index-B1Rd22nM.d.ts} +482 -21
- package/dist/index.d.ts +2 -3
- package/dist/index.js +3 -4
- package/dist/{issues-TcWtMTv5.js → issues-DCRpXUBW.js} +1 -1
- package/dist/{issues-TcWtMTv5.js.map → issues-DCRpXUBW.js.map} +1 -1
- package/dist/memory.d.ts +1 -1
- package/dist/memory.js +1 -1
- package/dist/{package-registry.fake-BLBdd7IQ.d.ts → package-registry.fake-CjoePEzE.d.ts} +53 -6
- package/dist/{package-registry.fake-CN6M1-Gi.js → package-registry.fake-ykiSBd8M.js} +58 -6
- package/dist/package-registry.fake-ykiSBd8M.js.map +1 -0
- package/dist/plugin-D-JQhwVd.d.ts +118 -0
- package/dist/plugin.d.ts +3 -23
- package/dist/plugin.js +84 -7
- package/dist/plugin.js.map +1 -0
- package/dist/shell-server-hosting.adapter-CvOcC6Wh.js +369 -0
- package/dist/shell-server-hosting.adapter-CvOcC6Wh.js.map +1 -0
- package/dist/{src-DO7WyrfV.js → src-8BbKTQBb.js} +2 -2
- package/dist/src-8BbKTQBb.js.map +1 -0
- package/dist/testing.d.ts +103 -18
- package/dist/testing.js +235 -22
- package/dist/testing.js.map +1 -1
- package/package.json +2 -1
- package/dist/budget-BTnKtGF6.js.map +0 -1
- package/dist/display-IqkJ6uCw.js +0 -96
- package/dist/display-IqkJ6uCw.js.map +0 -1
- package/dist/index-C_urG4yY.d.ts +0 -252
- package/dist/package-registry.fake-CN6M1-Gi.js.map +0 -1
- package/dist/readStatus-DypM0faL.js.map +0 -1
- package/dist/shell-server-hosting.adapter-C7_5MWrl.js +0 -50
- package/dist/shell-server-hosting.adapter-C7_5MWrl.js.map +0 -1
- package/dist/src-DO7WyrfV.js.map +0 -1
- package/dist/web-app.module-BB1fY1Kd.js +0 -125
- package/dist/web-app.module-BB1fY1Kd.js.map +0 -1
package/dist/plugin.js
CHANGED
|
@@ -1,8 +1,85 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { O as isEnvVarName, S as comments, a as backendService, c as definePackageRegistry, g as testReleases, i as mobileApp, l as defineServerHosting, n as webApp, o as releaseFlow, p as channels, r as publishedPackage, s as defineMobileDistribution, t as shellServerHosting, u as defineStaticHosting } from "./shell-server-hosting.adapter-CvOcC6Wh.js";
|
|
2
2
|
import { t as perEnv } from "./perEnv-n2qFRplP.js";
|
|
3
|
-
import { i as defineRelease, n as internalTool, r as agentPlugin, t as z } from "./src-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { i as defineRelease, n as internalTool, r as agentPlugin, t as z } from "./src-8BbKTQBb.js";
|
|
4
|
+
import { A as nextPatch, M as expandPatterns, N as workspacePatterns, O as tagName, T as previousTag, b as TAG_FORMATS, c as yesAllowed, d as deployState, f as onlyVersionFiles, h as appBumps, i as billedMinutes, k as compareVersions, l as CommandFailed, r as actionsMinutes, s as releaseSource, t as progressBar, u as deployRunTitle, w as isReleaseSubject, y as DEFAULT_TAG_FORMAT } from "./display-CfV4G1TR.js";
|
|
5
|
+
import { t as issueName } from "./issues-DCRpXUBW.js";
|
|
6
|
+
import { setTimeout } from "node:timers/promises";
|
|
7
|
+
//#region src/adapters/shell/must-capture.ts
|
|
8
|
+
/** The first line of a command's output that has text on it, trimmed. */
|
|
9
|
+
const firstLine = (text) => text.split("\n").find((line) => line.trim())?.trim();
|
|
10
|
+
/** Everything a failed command printed, its errors first. */
|
|
11
|
+
const printed = ({ stdout, stderr }) => [stderr, stdout].map((text) => text.trim()).filter(Boolean).join("\n");
|
|
12
|
+
/** A command that exited non-zero, named by `label` and its first error line. */
|
|
13
|
+
const commandFailed = ({ label, result }) => {
|
|
14
|
+
const reason = firstLine(result.stderr);
|
|
15
|
+
return new CommandFailed(`${label} exited with ${result.status}${reason ? `: ${reason}` : ""}`, printed(result));
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Runs a command and returns what it printed; a non-zero exit throws `CommandFailed`, which a
|
|
19
|
+
* failed release step shows in full.
|
|
20
|
+
*/
|
|
21
|
+
const mustCapture = async ({ shell, command, args, cwd, env, input, label }) => {
|
|
22
|
+
const result = await shell.capture(command, args, {
|
|
23
|
+
cwd,
|
|
24
|
+
env,
|
|
25
|
+
input
|
|
26
|
+
});
|
|
27
|
+
if (result.status === 0) return result.stdout;
|
|
28
|
+
throw commandFailed({
|
|
29
|
+
label: label ?? `${command} ${args[0] ?? ""}`.trim(),
|
|
30
|
+
result
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/adapters/shell/retrying.ts
|
|
35
|
+
/**
|
|
36
|
+
* Runs `run`, then again after each of `delays` while its result is `retryable`; returns the last
|
|
37
|
+
* result, whatever it is.
|
|
38
|
+
*/
|
|
39
|
+
const retrying = async ({ run, retryable, delays, wait = setTimeout }) => {
|
|
40
|
+
let result = await run();
|
|
41
|
+
for (const delay of delays) {
|
|
42
|
+
if (!retryable(result)) return result;
|
|
43
|
+
await wait(delay);
|
|
44
|
+
result = await run();
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/adapters/parse-json.ts
|
|
50
|
+
/** Text a tool printed, read as JSON and checked against `schema`; never throws. */
|
|
51
|
+
const parseJson = ({ text, schema }) => {
|
|
52
|
+
let value;
|
|
53
|
+
try {
|
|
54
|
+
value = JSON.parse(text);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
return {
|
|
57
|
+
success: false,
|
|
58
|
+
error: error instanceof Error ? error.message : String(error)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const parsed = schema.safeParse(value);
|
|
62
|
+
return parsed.success ? {
|
|
63
|
+
success: true,
|
|
64
|
+
data: parsed.data
|
|
65
|
+
} : {
|
|
66
|
+
success: false,
|
|
67
|
+
error: parsed.error.message
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/domain/registry.ts
|
|
72
|
+
/**
|
|
73
|
+
* What one tagged package version still needs on an environment. Production only moves its tag to
|
|
74
|
+
* what preview published, and a publish ships this checkout, so only while it is the tagged code.
|
|
75
|
+
*/
|
|
76
|
+
const registryDecision = async ({ environment, facts }) => {
|
|
77
|
+
if (!await facts.tagged()) return "not-released";
|
|
78
|
+
if (await facts.published()) return await facts.onDistTag() ? "on-tag" : "move-tag";
|
|
79
|
+
if (environment === "production") return "not-on-preview";
|
|
80
|
+
return await facts.sinceTagOnlyVersionFiles() ? "publish" : "moved-past";
|
|
81
|
+
};
|
|
82
|
+
//#endregion
|
|
83
|
+
export { CommandFailed, DEFAULT_TAG_FORMAT, TAG_FORMATS, actionsMinutes, agentPlugin, appBumps, backendService, billedMinutes, channels, commandFailed, comments, compareVersions, defineMobileDistribution, definePackageRegistry, defineRelease, defineServerHosting, defineStaticHosting, deployRunTitle, deployState, expandPatterns, firstLine, internalTool, isEnvVarName, isReleaseSubject, issueName, mobileApp, mustCapture, nextPatch, onlyVersionFiles, parseJson, perEnv, previousTag, progressBar, publishedPackage, registryDecision, releaseFlow, releaseSource, retrying, shellServerHosting, tagName, testReleases, webApp, workspacePatterns, yesAllowed, z };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","names":["sleep"],"sources":["../src/adapters/shell/must-capture.ts","../src/adapters/shell/retrying.ts","../src/adapters/parse-json.ts","../src/domain/registry.ts"],"sourcesContent":["import type { Shell, ShellResult } from \"../../ports/shell.port\";\nimport { CommandFailed } from \"../../ports/shell.port\";\n\n/** The first line of a command's output that has text on it, trimmed. */\nexport const firstLine = (text: string): string | undefined =>\n text\n .split(\"\\n\")\n .find((line) => line.trim())\n ?.trim();\n\n/** Everything a failed command printed, its errors first. */\nconst printed = ({ stdout, stderr }: ShellResult) =>\n [stderr, stdout]\n .map((text) => text.trim())\n .filter(Boolean)\n .join(\"\\n\");\n\n/** A command that exited non-zero, named by `label` and its first error line. */\nexport const commandFailed = ({ label, result }: { label: string; result: ShellResult }) => {\n const reason = firstLine(result.stderr);\n return new CommandFailed(\n `${label} exited with ${result.status}${reason ? `: ${reason}` : \"\"}`,\n printed(result),\n );\n};\n\n/**\n * Runs a command and returns what it printed; a non-zero exit throws `CommandFailed`, which a\n * failed release step shows in full.\n */\nexport const mustCapture = async ({\n shell,\n command,\n args,\n cwd,\n env,\n input,\n label,\n}: {\n shell: Shell;\n command: string;\n args: readonly string[];\n cwd?: string;\n env?: Record<string, string>;\n input?: string;\n /** How the failure names the command, `git push` by default the command and its first argument. */\n label?: string;\n}): Promise<string> => {\n const result = await shell.capture(command, args, { cwd, env, input });\n if (result.status === 0) return result.stdout;\n throw commandFailed({ label: label ?? `${command} ${args[0] ?? \"\"}`.trim(), result });\n};\n","import { setTimeout as sleep } from \"node:timers/promises\";\n\n/**\n * Runs `run`, then again after each of `delays` while its result is `retryable`; returns the last\n * result, whatever it is.\n */\nexport const retrying = async <Result>({\n run,\n retryable,\n delays,\n wait = sleep,\n}: {\n run: () => Promise<Result>;\n retryable: (result: Result) => boolean;\n /** How long to wait before each new try, in ms: one try per delay. */\n delays: readonly number[];\n wait?: (ms: number) => Promise<unknown>;\n}): Promise<Result> => {\n let result = await run();\n for (const delay of delays) {\n if (!retryable(result)) return result;\n await wait(delay);\n result = await run();\n }\n return result;\n};\n","import type { z } from \"zod\";\n\nexport type ParsedJson<Value> = { success: true; data: Value } | { success: false; error: string };\n\n/** Text a tool printed, read as JSON and checked against `schema`; never throws. */\nexport const parseJson = <Schema extends z.ZodType>({\n text,\n schema,\n}: {\n text: string;\n schema: Schema;\n}): ParsedJson<z.output<Schema>> => {\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch (error) {\n return { success: false, error: error instanceof Error ? error.message : String(error) };\n }\n const parsed = schema.safeParse(value);\n return parsed.success\n ? { success: true, data: parsed.data }\n : { success: false, error: parsed.error.message };\n};\n","import type { Environment } from \"./environment\";\n\nexport type RegistryShip =\n \"not-released\" | \"not-on-preview\" | \"moved-past\" | \"publish\" | \"on-tag\" | \"move-tag\";\n\n/**\n * What a package registry reads, each fact only once the decision needs it: a read costs a call to\n * the registry or to git.\n */\nexport interface RegistryFacts {\n /** The release tag exists. */\n tagged: () => Promise<boolean>;\n /** The registry holds this version. */\n published: () => Promise<boolean>;\n /** The checkout differs from the tag by version files at most. */\n sinceTagOnlyVersionFiles: () => Promise<boolean>;\n /** The environment's dist-tag already names this version. */\n onDistTag: () => Promise<boolean>;\n}\n\n/**\n * What one tagged package version still needs on an environment. Production only moves its tag to\n * what preview published, and a publish ships this checkout, so only while it is the tagged code.\n */\nexport const registryDecision = async ({\n environment,\n facts,\n}: {\n environment: Environment;\n facts: RegistryFacts;\n}): Promise<RegistryShip> => {\n if (!(await facts.tagged())) return \"not-released\";\n if (await facts.published()) return (await facts.onDistTag()) ? \"on-tag\" : \"move-tag\";\n if (environment === \"production\") return \"not-on-preview\";\n return (await facts.sinceTagOnlyVersionFiles()) ? \"publish\" : \"moved-past\";\n};\n"],"mappings":";;;;;;;;AAIA,MAAa,aAAa,SACxB,KACG,MAAM,KAAK,CACX,MAAM,SAAS,KAAK,MAAM,CAAC,EAC1B,MAAM;;AAGZ,MAAM,WAAW,EAAE,QAAQ,aACzB,CAAC,QAAQ,OAAO,CACb,KAAK,SAAS,KAAK,MAAM,CAAC,C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AAM,WAAW,GAAI,WAAW;AAC3E,KAAI,gBAAgB,aAAc,QAAO;AACzC,QAAQ,MAAM,MAAM,0BAA0B,GAAI,YAAY"}
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { t as perEnv } from "./perEnv-n2qFRplP.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/domain/checkEnvBeforeDeploy.ts
|
|
4
|
+
/** UPPER_SNAKE: a capital letter, then capitals, digits or underscores. */
|
|
5
|
+
const ENV_VAR_NAME = /^[A-Z][A-Z0-9_]*$/;
|
|
6
|
+
const isEnvVarName = (text) => ENV_VAR_NAME.test(text);
|
|
7
|
+
/** The names a deploy checks on the platform before it ships, per environment. */
|
|
8
|
+
var EnvToCheck = class {
|
|
9
|
+
#all;
|
|
10
|
+
#perEnvironment;
|
|
11
|
+
constructor(input) {
|
|
12
|
+
if (isList(input)) {
|
|
13
|
+
this.#all = input;
|
|
14
|
+
this.#perEnvironment = {};
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const { all = [], ...perEnvironment } = input;
|
|
18
|
+
this.#all = all;
|
|
19
|
+
this.#perEnvironment = perEnvironment;
|
|
20
|
+
}
|
|
21
|
+
/** `all`, then that environment's own names. */
|
|
22
|
+
for(environment) {
|
|
23
|
+
return new Set([...this.#all, ...this.#perEnvironment[environment] ?? []]);
|
|
24
|
+
}
|
|
25
|
+
/** Names in `all` that an environment lists again. */
|
|
26
|
+
listedTwice() {
|
|
27
|
+
const extras = new Set(Object.values(this.#perEnvironment).flat());
|
|
28
|
+
return [...new Set(this.#all)].filter((name) => extras.has(name));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const isList = (input) => Array.isArray(input);
|
|
32
|
+
/** Names a deploy checks that the platform does not hold. */
|
|
33
|
+
var UnsetEnvVars = class {
|
|
34
|
+
#names;
|
|
35
|
+
constructor(names) {
|
|
36
|
+
this.#names = names;
|
|
37
|
+
}
|
|
38
|
+
isEmpty() {
|
|
39
|
+
return this.#names.length === 0;
|
|
40
|
+
}
|
|
41
|
+
names() {
|
|
42
|
+
return this.#names;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const findUnset = ({ expected, setOnPlatform }) => new UnsetEnvVars([...expected].filter((name) => !setOnPlatform.has(name)));
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/domain/branchRelease.ts
|
|
48
|
+
const MAX_SLUG = 40;
|
|
49
|
+
const SHORT_SHA = 7;
|
|
50
|
+
const SEMVER_RANGE$1 = /^v?(\d+|x)$/;
|
|
51
|
+
const LEADING_ZERO_NUMBER = /^0\d+$/;
|
|
52
|
+
/** The marker a branch release's pull request comment opens with, to find it again. */
|
|
53
|
+
const BRANCH_COMMENT_MARKER = "<!-- shiplane:branch-release -->";
|
|
54
|
+
/** A branch name as a version and a tag take it: `feat/X_y` reads `feat-x-y`. */
|
|
55
|
+
const branchSlug = (branch) => branch.toLowerCase().replace(/[^a-z0-9]+/g, "-").slice(0, MAX_SLUG).replace(/^-+|-+$/g, "") || "branch";
|
|
56
|
+
const identifier = (text) => LEADING_ZERO_NUMBER.test(text) ? `g${text}` : text;
|
|
57
|
+
/** `<current>-<slug>.<short sha>`: the version testers install, never one a release takes. */
|
|
58
|
+
const branchVersion = ({ current, branch, sha }) => `${current}-${identifier(branchSlug(branch))}.${identifier(sha.slice(0, SHORT_SHA))}`;
|
|
59
|
+
/** The npm dist-tag a branch publishes under: its slug, unless npm would refuse it or it is latest. */
|
|
60
|
+
const branchTag = (slug) => SEMVER_RANGE$1.test(slug) || slug === "latest" ? `branch-${slug}` : slug;
|
|
61
|
+
/**
|
|
62
|
+
* What `shiplane` does where it runs. On the default branch: the real release, or a test version
|
|
63
|
+
* without asking, since you are there on purpose. Elsewhere: a test version, asked in a terminal
|
|
64
|
+
* unless --yes. A pull request is never required.
|
|
65
|
+
*/
|
|
66
|
+
const branchChoice = ({ onDefaultBranch, onDefault, yes, interactive }) => {
|
|
67
|
+
if (onDefaultBranch) return onDefault;
|
|
68
|
+
return yes || !interactive ? "publish" : "ask";
|
|
69
|
+
};
|
|
70
|
+
const NPMJS = "https://www.npmjs.com/package";
|
|
71
|
+
const FENCE = "```";
|
|
72
|
+
/** The install line a tester copies. */
|
|
73
|
+
const installLine = ({ name, tag }) => `npm i ${name}@${tag}`;
|
|
74
|
+
/** The repository a pull request address belongs to, such as `https://github.com/o/r`; else null. */
|
|
75
|
+
const repositoryOfPr = (url) => /^(https?:\/\/.+?)\/pull\/\d+$/.exec(url)?.[1] ?? null;
|
|
76
|
+
const link = (text, url, linked) => linked ? `[${text}](${url})` : text;
|
|
77
|
+
const row = (entry) => {
|
|
78
|
+
const page = `${NPMJS}/${entry.name}`;
|
|
79
|
+
return `| ${link(entry.name, page, entry.onNpmjs)} | ${link(entry.version, `${page}/v/${entry.version}`, entry.onNpmjs)} | \`${installLine(entry)}\` |`;
|
|
80
|
+
};
|
|
81
|
+
const notPublished = (others) => {
|
|
82
|
+
if (others.length === 0) return [];
|
|
83
|
+
return ["", `Test release not available yet: ${others.map((name) => `\`${name}\``).join(", ")} (npm packages only for now).`];
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* The pull request comment presets: `table`, the install table with its notes (the default), and
|
|
87
|
+
* `compact`, one line. Each is a template, as is any text of your own.
|
|
88
|
+
*/
|
|
89
|
+
const comments = {
|
|
90
|
+
table: [
|
|
91
|
+
"### 📦 Published on npm for testing",
|
|
92
|
+
"Built from {commit} on `{branch}`. These are test versions on the `{channel}` channel, not a release; pending changesets are untouched.",
|
|
93
|
+
"",
|
|
94
|
+
"{table}",
|
|
95
|
+
"",
|
|
96
|
+
"<sub>Updated by shiplane on each run, same comment.</sub>",
|
|
97
|
+
""
|
|
98
|
+
].join("\n"),
|
|
99
|
+
compact: "📦 Test version of `{branch}` ({commit}): {install}\n"
|
|
100
|
+
};
|
|
101
|
+
/** Where `@<tag>` points: this branch's latest snapshot, or the channel's newest version. */
|
|
102
|
+
const tagPoints = (tag, channel) => channel === "snapshot" ? `\`@${tag}\` always points at this branch's latest publish.` : `\`@${tag}\` moves to each new ${channel}.`;
|
|
103
|
+
/** The install table, the pin line, the pnpm and yarn lines, and the pending units left out. */
|
|
104
|
+
const installTable = (published, others, channel) => {
|
|
105
|
+
const [first] = published;
|
|
106
|
+
const tags = published.map(({ name, tag }) => `${name}@${tag}`).join(" ");
|
|
107
|
+
return [
|
|
108
|
+
"| Package | Version | Install |",
|
|
109
|
+
"| --- | --- | --- |",
|
|
110
|
+
...published.map(row),
|
|
111
|
+
"",
|
|
112
|
+
...first ? [`${tagPoints(first.tag, channel)} To stay on this exact build, install the version instead: \`npm i ${first.name}@${first.version}\`.`, ""] : [],
|
|
113
|
+
"<details><summary>pnpm / yarn</summary>",
|
|
114
|
+
"",
|
|
115
|
+
FENCE,
|
|
116
|
+
`pnpm add ${tags}`,
|
|
117
|
+
`yarn add ${tags}`,
|
|
118
|
+
FENCE,
|
|
119
|
+
"</details>",
|
|
120
|
+
...notPublished(others)
|
|
121
|
+
].join("\n");
|
|
122
|
+
};
|
|
123
|
+
const PLACEHOLDER = /\{(branch|commit|table|install|channel)\}/g;
|
|
124
|
+
/**
|
|
125
|
+
* The comment a test version keeps on its pull request, one per pull request: the template with
|
|
126
|
+
* `{branch}`, `{commit}`, `{table}`, `{install}` and `{channel}` filled in, always under the marker that finds
|
|
127
|
+
* it again.
|
|
128
|
+
*/
|
|
129
|
+
const branchComment = ({ sha, branch, repository, published, others, channel = "snapshot", template = comments.table }) => {
|
|
130
|
+
const short = `\`${sha.slice(0, SHORT_SHA)}\``;
|
|
131
|
+
const values = {
|
|
132
|
+
branch,
|
|
133
|
+
commit: repository ? `[${short}](${repository}/commit/${sha})` : short,
|
|
134
|
+
table: installTable(published, others, channel),
|
|
135
|
+
channel,
|
|
136
|
+
install: `\`npm i ${published.map(({ name, tag }) => `${name}@${tag}`).join(" ")}\``
|
|
137
|
+
};
|
|
138
|
+
return `${BRANCH_COMMENT_MARKER}\n${template.replace(PLACEHOLDER, (_, key) => values[key] ?? "")}`;
|
|
139
|
+
};
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/domain/testChannel.ts
|
|
142
|
+
/**
|
|
143
|
+
* Where a test release publishes. `snapshot` is one temporary version per commit; any other word is
|
|
144
|
+
* a numbered prerelease channel: `<next>-<word>.<n>` under the npm tag `<word>`.
|
|
145
|
+
*/
|
|
146
|
+
const channels = {
|
|
147
|
+
/**
|
|
148
|
+
* `<next>-<branch>.<sha>` under the branch's npm tag, such as `0.6.0-feat-x.ae08284` on `feat-x`.
|
|
149
|
+
* One per commit, temporary: what every branch publishes unless `testRelease` says otherwise.
|
|
150
|
+
*/
|
|
151
|
+
snapshot: "snapshot",
|
|
152
|
+
/**
|
|
153
|
+
* `<next>-nightly.<n>` under the npm tag `nightly`, such as `0.6.0-nightly.4`; `<n>` goes up by
|
|
154
|
+
* one each publish. `npm i <package>@nightly` installs the newest.
|
|
155
|
+
*/
|
|
156
|
+
nightly: "nightly",
|
|
157
|
+
/**
|
|
158
|
+
* `<next>-alpha.<n>` under the npm tag `alpha`, such as `0.6.0-alpha.0`; `<n>` goes up by one each
|
|
159
|
+
* publish. `npm i <package>@alpha` installs the newest.
|
|
160
|
+
*/
|
|
161
|
+
alpha: "alpha",
|
|
162
|
+
/**
|
|
163
|
+
* `<next>-beta.<n>` under the npm tag `beta`, such as `0.6.0-beta.2`; `<n>` goes up by one each
|
|
164
|
+
* publish. `npm i <package>@beta` installs the newest.
|
|
165
|
+
*/
|
|
166
|
+
beta: "beta",
|
|
167
|
+
/**
|
|
168
|
+
* `<next>-rc.<n>` under the npm tag `rc`, such as `0.6.0-rc.1`; `<n>` goes up by one each publish.
|
|
169
|
+
* `npm i <package>@rc` installs the newest.
|
|
170
|
+
*/
|
|
171
|
+
rc: "rc"
|
|
172
|
+
};
|
|
173
|
+
/** Ready branch → channel maps for `testRelease`; each is a plain map, spread it to change it. */
|
|
174
|
+
const testReleases = {
|
|
175
|
+
/**
|
|
176
|
+
* `main` → nightly; every other branch → snapshot.
|
|
177
|
+
* @example main publishes 0.6.0-nightly.4 under the npm tag `nightly`.
|
|
178
|
+
*/
|
|
179
|
+
nightly: { main: "nightly" },
|
|
180
|
+
/**
|
|
181
|
+
* One channel per long-lived branch: `main` → nightly, `next` → alpha, `beta` → beta,
|
|
182
|
+
* `release/*` → rc; every other branch → snapshot.
|
|
183
|
+
* @example release/1.0 publishes 1.0.0-rc.0 under the npm tag `rc`.
|
|
184
|
+
*/
|
|
185
|
+
prerelease: {
|
|
186
|
+
main: "nightly",
|
|
187
|
+
next: "alpha",
|
|
188
|
+
beta: "beta",
|
|
189
|
+
"release/*": "rc"
|
|
190
|
+
},
|
|
191
|
+
/**
|
|
192
|
+
* Git-flow: `develop` → nightly, `release/*` → beta, `hotfix/*` → rc; every other branch → snapshot.
|
|
193
|
+
* @example develop publishes 0.6.0-nightly.4 under the npm tag `nightly`.
|
|
194
|
+
*/
|
|
195
|
+
gitflow: {
|
|
196
|
+
develop: "nightly",
|
|
197
|
+
"release/*": "beta",
|
|
198
|
+
"hotfix/*": "rc"
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
const CHANNEL_NAME = /^[a-z][a-z0-9-]*$/;
|
|
202
|
+
const SEMVER_RANGE = /^v?(\d+|x)$/;
|
|
203
|
+
/** Why a channel name cannot be one, or null when it can. */
|
|
204
|
+
const channelProblem = (name) => {
|
|
205
|
+
if (name === "latest") return "latest is the real release's tag, never a test release's";
|
|
206
|
+
if (!CHANNEL_NAME.test(name) || SEMVER_RANGE.test(name)) return `"${name}" is not a channel: a lowercase word such as beta, [a-z][a-z0-9-]*`;
|
|
207
|
+
return null;
|
|
208
|
+
};
|
|
209
|
+
const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
210
|
+
const patternOf = (key) => new RegExp(`^${key.split("*").map(escape).join(".*")}$`);
|
|
211
|
+
/** The channel a branch publishes on: its exact name, else its longest matching pattern, else snapshot. */
|
|
212
|
+
const channelFor = (branch, branches = {}) => {
|
|
213
|
+
const exact = branches[branch];
|
|
214
|
+
if (exact !== void 0) return exact;
|
|
215
|
+
const [match] = Object.keys(branches).filter((key) => key.includes("*") && patternOf(key).test(branch)).sort((left, right) => right.length - left.length);
|
|
216
|
+
return (match === void 0 ? void 0 : branches[match]) ?? channels.snapshot;
|
|
217
|
+
};
|
|
218
|
+
/** Whether a channel numbers its versions: every one but snapshot. */
|
|
219
|
+
const isNumbered = (channel) => channel !== channels.snapshot;
|
|
220
|
+
/** The next free `<n>` of `<next>-<channel>.<n>`, from the versions the registry already holds. */
|
|
221
|
+
const nextNumber = ({ published, next, channel }) => {
|
|
222
|
+
const numbered = new RegExp(`^${escape(next)}-${escape(channel)}\\.(\\d+)$`);
|
|
223
|
+
return published.reduce((free, version) => {
|
|
224
|
+
const taken = numbered.exec(version)?.[1];
|
|
225
|
+
return taken === void 0 ? free : Math.max(free, Number(taken) + 1);
|
|
226
|
+
}, 0);
|
|
227
|
+
};
|
|
228
|
+
/** The version a test release publishes: a snapshot of the commit, or the channel's numbered one. */
|
|
229
|
+
const testVersion = ({ next, channel, branch, sha, n }) => isNumbered(channel) ? `${next}-${channel}.${n}` : branchVersion({
|
|
230
|
+
current: next,
|
|
231
|
+
branch,
|
|
232
|
+
sha
|
|
233
|
+
});
|
|
234
|
+
/** The npm tag a test release publishes under: the channel, or the branch's for a snapshot. */
|
|
235
|
+
const testTag = (channel, branch) => isNumbered(channel) ? branchTag(channel) : branchTag(branchSlug(branch));
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/adapters/defineDelivery.ts
|
|
238
|
+
const widen = (port) => port;
|
|
239
|
+
const recipe = ({ name, settings, typicalMinutes, decidedBy, detect, questions, requirements, env, ...port }, capability) => ({
|
|
240
|
+
name,
|
|
241
|
+
capability,
|
|
242
|
+
settings,
|
|
243
|
+
typicalMinutes,
|
|
244
|
+
decidedBy,
|
|
245
|
+
detect,
|
|
246
|
+
questions,
|
|
247
|
+
requirements,
|
|
248
|
+
...env ? { env } : {},
|
|
249
|
+
create: () => widen({
|
|
250
|
+
...port,
|
|
251
|
+
capability
|
|
252
|
+
})
|
|
253
|
+
});
|
|
254
|
+
const defineServerHosting = (adapter) => recipe(adapter, "server-hosting");
|
|
255
|
+
const defineStaticHosting = (adapter) => recipe(adapter, "static-hosting");
|
|
256
|
+
const defineMobileDistribution = (adapter) => recipe(adapter, "mobile-distribution");
|
|
257
|
+
const definePackageRegistry = (adapter) => recipe(adapter, "package-registry");
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/application/releaseFlow.ts
|
|
260
|
+
/** How the release itself runs, given an adapter for each port it runs on. */
|
|
261
|
+
const releaseFlow = (ports) => ({
|
|
262
|
+
type: "flow",
|
|
263
|
+
...ports,
|
|
264
|
+
approval: ports.approval ?? "none"
|
|
265
|
+
});
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/modules/deliveryModule.ts
|
|
268
|
+
/** The stages every delivery adapter answers: its settings, where a tag lands and its jobs. */
|
|
269
|
+
const deliveryModule = (kind, adapter, name = kind) => ({
|
|
270
|
+
type: "module",
|
|
271
|
+
name,
|
|
272
|
+
kind,
|
|
273
|
+
provider: adapter.name,
|
|
274
|
+
settings: adapter.settings,
|
|
275
|
+
adapters: [adapter],
|
|
276
|
+
capability: adapter.capability,
|
|
277
|
+
decidedBy: adapter.decidedBy,
|
|
278
|
+
typicalMinutes: adapter.typicalMinutes,
|
|
279
|
+
...adapter.env ? { env: adapter.env } : {},
|
|
280
|
+
requirements: (apps) => apps.flatMap((unit) => adapter.requirements?.(unit) ?? []),
|
|
281
|
+
ship: ({ open }, input) => {
|
|
282
|
+
const port = open(adapter);
|
|
283
|
+
return {
|
|
284
|
+
where: port.describe(input),
|
|
285
|
+
jobs: port.jobs(input)
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region src/modules/backend-service/backend-service.module.ts
|
|
291
|
+
/** A long-lived service, such as an API: deployed from its tag, recorded with the code host. */
|
|
292
|
+
const backendService = ({ name, serverHosting }) => deliveryModule("backend-service", serverHosting, name);
|
|
293
|
+
//#endregion
|
|
294
|
+
//#region src/modules/mobile-app/mobile-app.module.ts
|
|
295
|
+
/**
|
|
296
|
+
* A mobile app: its distribution decides between a store build and an over-the-air update, adds to
|
|
297
|
+
* the release PR, and says how a version does before it is promoted.
|
|
298
|
+
*/
|
|
299
|
+
const mobileApp = ({ name, mobileDistribution }) => ({
|
|
300
|
+
...deliveryModule("mobile-app", mobileDistribution, name),
|
|
301
|
+
versionFiles: (unit, units, open) => open(mobileDistribution).versionFiles?.(unit, units) ?? [],
|
|
302
|
+
version: async (context, input) => {
|
|
303
|
+
const port = context.open(mobileDistribution);
|
|
304
|
+
return port.beforeVersion ? port.beforeVersion(context, input) : {
|
|
305
|
+
added: [],
|
|
306
|
+
writes: [],
|
|
307
|
+
summary: [],
|
|
308
|
+
onMerge: ""
|
|
309
|
+
};
|
|
310
|
+
},
|
|
311
|
+
decide: (context, input) => context.open(mobileDistribution).decide(context, input),
|
|
312
|
+
live: async (context, input) => {
|
|
313
|
+
const port = context.open(mobileDistribution);
|
|
314
|
+
return port.live ? port.live(context, input) : true;
|
|
315
|
+
},
|
|
316
|
+
health: async (context, input) => {
|
|
317
|
+
const port = context.open(mobileDistribution);
|
|
318
|
+
return port.health ? port.health(context, input) : null;
|
|
319
|
+
},
|
|
320
|
+
inspect: async (context, input) => {
|
|
321
|
+
const port = context.open(mobileDistribution);
|
|
322
|
+
return port.inspect ? port.inspect(context, input) : void 0;
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region src/modules/published-package/published-package.module.ts
|
|
327
|
+
/** A package others install: its registry, not deploy records, knows what is out. */
|
|
328
|
+
const publishedPackage = ({ name, packageRegistry }) => ({
|
|
329
|
+
...deliveryModule("published-package", packageRegistry, name),
|
|
330
|
+
decide: (context, input) => context.open(packageRegistry).decide(context, input),
|
|
331
|
+
live: (context, input) => context.open(packageRegistry).live(context, input),
|
|
332
|
+
publishedName: (context, input) => context.open(packageRegistry).publishedName?.(input) ?? input.unit.packageName,
|
|
333
|
+
publishedVersions: async (context, input) => {
|
|
334
|
+
const registry = context.open(packageRegistry);
|
|
335
|
+
if (!registry.publishedVersions) throw new Error(`the ${packageRegistry.name} registry cannot list its versions: publish a snapshot instead`);
|
|
336
|
+
return registry.publishedVersions(context, input);
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
//#endregion
|
|
340
|
+
//#region src/modules/web-app/web-app.module.ts
|
|
341
|
+
/** A static site, built against the environment it ships to. */
|
|
342
|
+
const webApp = ({ name, staticHosting }) => deliveryModule("web-app", staticHosting, name);
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/adapters/server-hosting/shell-server-hosting.adapter.ts
|
|
345
|
+
const ShellOptions = z.object({
|
|
346
|
+
deploy: perEnv(z.array(z.string()).min(1)).describe("The command that ships it, run from the root, as a list: [npx, my-tool, deploy]"),
|
|
347
|
+
url: perEnv(z.string()).optional().describe("Where it answers, for other units to read")
|
|
348
|
+
});
|
|
349
|
+
const shellServerHosting = () => defineServerHosting({
|
|
350
|
+
name: "shell",
|
|
351
|
+
settings: ShellOptions,
|
|
352
|
+
describe: ({ options }) => options.deploy.join(" "),
|
|
353
|
+
jobs: ({ tag, environment, options }) => {
|
|
354
|
+
const [command = "true", ...args] = options.deploy;
|
|
355
|
+
return [{
|
|
356
|
+
label: `ship ${tag}: ${options.deploy.join(" ")}`,
|
|
357
|
+
local: [{
|
|
358
|
+
command,
|
|
359
|
+
args
|
|
360
|
+
}],
|
|
361
|
+
ci: { ref: tag },
|
|
362
|
+
record: true
|
|
363
|
+
}];
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
//#endregion
|
|
367
|
+
export { installLine as C, findUnset as D, EnvToCheck as E, isEnvVarName as O, comments as S, ENV_VAR_NAME as T, testTag as _, backendService as a, branchChoice as b, definePackageRegistry as c, channelFor as d, channelProblem as f, testReleases as g, nextNumber as h, mobileApp as i, defineServerHosting as l, isNumbered as m, webApp as n, releaseFlow as o, channels as p, publishedPackage as r, defineMobileDistribution as s, shellServerHosting as t, defineStaticHosting as u, testVersion as v, repositoryOfPr as w, branchComment as x, BRANCH_COMMENT_MARKER as y };
|
|
368
|
+
|
|
369
|
+
//# sourceMappingURL=shell-server-hosting.adapter-CvOcC6Wh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-server-hosting.adapter-CvOcC6Wh.js","names":["#all","#perEnvironment","#names","SEMVER_RANGE"],"sources":["../src/domain/checkEnvBeforeDeploy.ts","../src/domain/branchRelease.ts","../src/domain/testChannel.ts","../src/adapters/defineDelivery.ts","../src/application/releaseFlow.ts","../src/modules/deliveryModule.ts","../src/modules/backend-service/backend-service.module.ts","../src/modules/mobile-app/mobile-app.module.ts","../src/modules/published-package/published-package.module.ts","../src/modules/web-app/web-app.module.ts","../src/adapters/server-hosting/shell-server-hosting.adapter.ts"],"sourcesContent":["import type { Environment } from \"./environment\";\n\n/** A name an app reads from its environment, as platforms store it: `SENTRY_DSN`. */\nexport type EnvVarName = string & { readonly brand: \"EnvVarName\" };\n\n/** UPPER_SNAKE: a capital letter, then capitals, digits or underscores. */\nexport const ENV_VAR_NAME = /^[A-Z][A-Z0-9_]*$/;\n\nexport const isEnvVarName = (text: string): text is EnvVarName => ENV_VAR_NAME.test(text);\n\n/** As a unit file writes it: one list for every environment, or `all` plus a list per environment. */\nexport type EnvToCheckInput =\n | readonly EnvVarName[]\n | ({ all?: readonly EnvVarName[] } & Partial<Record<Environment, readonly EnvVarName[]>>);\n\n/** The names a deploy checks on the platform before it ships, per environment. */\nexport class EnvToCheck {\n readonly #all: readonly EnvVarName[];\n readonly #perEnvironment: Partial<Record<Environment, readonly EnvVarName[]>>;\n\n constructor(input: EnvToCheckInput) {\n if (isList(input)) {\n this.#all = input;\n this.#perEnvironment = {};\n return;\n }\n const { all = [], ...perEnvironment } = input;\n this.#all = all;\n this.#perEnvironment = perEnvironment;\n }\n\n /** `all`, then that environment's own names. */\n for(environment: Environment): ReadonlySet<EnvVarName> {\n return new Set([...this.#all, ...(this.#perEnvironment[environment] ?? [])]);\n }\n\n /** Names in `all` that an environment lists again. */\n listedTwice(): EnvVarName[] {\n const extras = new Set(Object.values(this.#perEnvironment).flat());\n return [...new Set(this.#all)].filter((name) => extras.has(name));\n }\n}\n\nconst isList = (input: EnvToCheckInput): input is readonly EnvVarName[] => Array.isArray(input);\n\n/** Names a deploy checks that the platform does not hold. */\nexport class UnsetEnvVars {\n readonly #names: readonly EnvVarName[];\n\n constructor(names: readonly EnvVarName[]) {\n this.#names = names;\n }\n\n isEmpty(): boolean {\n return this.#names.length === 0;\n }\n\n names(): readonly EnvVarName[] {\n return this.#names;\n }\n}\n\nexport const findUnset = ({\n expected,\n setOnPlatform,\n}: {\n expected: ReadonlySet<EnvVarName>;\n setOnPlatform: ReadonlySet<EnvVarName>;\n}): UnsetEnvVars => new UnsetEnvVars([...expected].filter((name) => !setOnPlatform.has(name)));\n","const MAX_SLUG = 40;\nconst SHORT_SHA = 7;\n// npm refuses a dist-tag it can read as a semver range; from [a-z0-9-] only these parse as one.\nconst SEMVER_RANGE = /^v?(\\d+|x)$/;\n// A numeric prerelease identifier with a leading zero is not valid semver.\nconst LEADING_ZERO_NUMBER = /^0\\d+$/;\n\n/** The marker a branch release's pull request comment opens with, to find it again. */\nexport const BRANCH_COMMENT_MARKER = \"<!-- shiplane:branch-release -->\";\n\n/** A branch name as a version and a tag take it: `feat/X_y` reads `feat-x-y`. */\nexport const branchSlug = (branch: string) =>\n branch\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .slice(0, MAX_SLUG)\n .replace(/^-+|-+$/g, \"\") || \"branch\";\n\nconst identifier = (text: string) => (LEADING_ZERO_NUMBER.test(text) ? `g${text}` : text);\n\n/** `<current>-<slug>.<short sha>`: the version testers install, never one a release takes. */\nexport const branchVersion = ({\n current,\n branch,\n sha,\n}: {\n current: string;\n branch: string;\n sha: string;\n}) => `${current}-${identifier(branchSlug(branch))}.${identifier(sha.slice(0, SHORT_SHA))}`;\n\n/** The npm dist-tag a branch publishes under: its slug, unless npm would refuse it or it is latest. */\nexport const branchTag = (slug: string) =>\n SEMVER_RANGE.test(slug) || slug === \"latest\" ? `branch-${slug}` : slug;\n\n/** What `shiplane` does on the default branch: the real release, or (`shiplane branch`) a test version. */\nexport type OnDefault = \"release\" | \"publish\";\n\nexport type BranchChoice = \"release\" | \"ask\" | \"publish\";\n\n/**\n * What `shiplane` does where it runs. On the default branch: the real release, or a test version\n * without asking, since you are there on purpose. Elsewhere: a test version, asked in a terminal\n * unless --yes. A pull request is never required.\n */\nexport const branchChoice = ({\n onDefaultBranch,\n onDefault,\n yes,\n interactive,\n}: {\n onDefaultBranch: boolean;\n onDefault: OnDefault;\n yes: boolean;\n interactive: boolean;\n}): BranchChoice => {\n if (onDefaultBranch) return onDefault;\n return yes || !interactive ? \"publish\" : \"ask\";\n};\n\n/** One package a branch release published. */\nexport interface BranchPublished {\n name: string;\n version: string;\n tag: string;\n /** Published to the public npm registry, so npmjs.com shows it. */\n onNpmjs: boolean;\n}\n\nconst NPMJS = \"https://www.npmjs.com/package\";\nconst FENCE = \"```\";\n\n/** The install line a tester copies. */\nexport const installLine = ({ name, tag }: BranchPublished) => `npm i ${name}@${tag}`;\n\n/** The repository a pull request address belongs to, such as `https://github.com/o/r`; else null. */\nexport const repositoryOfPr = (url: string) =>\n /^(https?:\\/\\/.+?)\\/pull\\/\\d+$/.exec(url)?.[1] ?? null;\n\nconst link = (text: string, url: string, linked: boolean) => (linked ? `[${text}](${url})` : text);\n\nconst row = (entry: BranchPublished) => {\n const page = `${NPMJS}/${entry.name}`;\n const name = link(entry.name, page, entry.onNpmjs);\n const version = link(entry.version, `${page}/v/${entry.version}`, entry.onNpmjs);\n return `| ${name} | ${version} | \\`${installLine(entry)}\\` |`;\n};\n\nconst notPublished = (others: readonly string[]) => {\n if (others.length === 0) return [];\n const names = others.map((name) => `\\`${name}\\``).join(\", \");\n return [\"\", `Test release not available yet: ${names} (npm packages only for now).`];\n};\n\n/**\n * The pull request comment presets: `table`, the install table with its notes (the default), and\n * `compact`, one line. Each is a template, as is any text of your own.\n */\nexport const comments = {\n table: [\n \"### 📦 Published on npm for testing\",\n \"Built from {commit} on `{branch}`. These are test versions on the `{channel}` channel, not a release; pending changesets are untouched.\",\n \"\",\n \"{table}\",\n \"\",\n \"<sub>Updated by shiplane on each run, same comment.</sub>\",\n \"\",\n ].join(\"\\n\"),\n compact: \"📦 Test version of `{branch}` ({commit}): {install}\\n\",\n} as const;\n\n/** Where `@<tag>` points: this branch's latest snapshot, or the channel's newest version. */\nconst tagPoints = (tag: string, channel: string) =>\n channel === \"snapshot\"\n ? `\\`@${tag}\\` always points at this branch's latest publish.`\n : `\\`@${tag}\\` moves to each new ${channel}.`;\n\n/** The install table, the pin line, the pnpm and yarn lines, and the pending units left out. */\nconst installTable = (\n published: readonly BranchPublished[],\n others: readonly string[],\n channel: string,\n) => {\n const [first] = published;\n const tags = published.map(({ name, tag }) => `${name}@${tag}`).join(\" \");\n return [\n \"| Package | Version | Install |\",\n \"| --- | --- | --- |\",\n ...published.map(row),\n \"\",\n ...(first\n ? [\n `${tagPoints(first.tag, channel)} To stay on this exact build, install the version instead: \\`npm i ${first.name}@${first.version}\\`.`,\n \"\",\n ]\n : []),\n \"<details><summary>pnpm / yarn</summary>\",\n \"\",\n FENCE,\n `pnpm add ${tags}`,\n `yarn add ${tags}`,\n FENCE,\n \"</details>\",\n ...notPublished(others),\n ].join(\"\\n\");\n};\n\nconst PLACEHOLDER = /\\{(branch|commit|table|install|channel)\\}/g;\n\n/**\n * The comment a test version keeps on its pull request, one per pull request: the template with\n * `{branch}`, `{commit}`, `{table}`, `{install}` and `{channel}` filled in, always under the marker that finds\n * it again.\n */\nexport const branchComment = ({\n sha,\n branch,\n repository,\n published,\n others,\n channel = \"snapshot\",\n template = comments.table,\n}: {\n sha: string;\n branch: string;\n /** The repository's web address, to link the commit; null names it plainly. */\n repository: string | null;\n published: readonly BranchPublished[];\n /** The pending units that are not npm packages. */\n others: readonly string[];\n /** The channel it published on: `snapshot` (the default) or a numbered one such as `beta`. */\n channel?: string;\n /** A preset from `comments`, or text of your own. */\n template?: string;\n}) => {\n const short = `\\`${sha.slice(0, SHORT_SHA)}\\``;\n const values: Record<string, string> = {\n branch,\n commit: repository ? `[${short}](${repository}/commit/${sha})` : short,\n table: installTable(published, others, channel),\n channel,\n install: `\\`npm i ${published.map(({ name, tag }) => `${name}@${tag}`).join(\" \")}\\``,\n };\n const body = template.replace(PLACEHOLDER, (_, key: string) => values[key] ?? \"\");\n return `${BRANCH_COMMENT_MARKER}\\n${body}`;\n};\n","import { branchSlug, branchTag, branchVersion } from \"./branchRelease\";\n\n/**\n * Where a test release publishes. `snapshot` is one temporary version per commit; any other word is\n * a numbered prerelease channel: `<next>-<word>.<n>` under the npm tag `<word>`.\n */\nexport const channels = {\n /**\n * `<next>-<branch>.<sha>` under the branch's npm tag, such as `0.6.0-feat-x.ae08284` on `feat-x`.\n * One per commit, temporary: what every branch publishes unless `testRelease` says otherwise.\n */\n snapshot: \"snapshot\",\n /**\n * `<next>-nightly.<n>` under the npm tag `nightly`, such as `0.6.0-nightly.4`; `<n>` goes up by\n * one each publish. `npm i <package>@nightly` installs the newest.\n */\n nightly: \"nightly\",\n /**\n * `<next>-alpha.<n>` under the npm tag `alpha`, such as `0.6.0-alpha.0`; `<n>` goes up by one each\n * publish. `npm i <package>@alpha` installs the newest.\n */\n alpha: \"alpha\",\n /**\n * `<next>-beta.<n>` under the npm tag `beta`, such as `0.6.0-beta.2`; `<n>` goes up by one each\n * publish. `npm i <package>@beta` installs the newest.\n */\n beta: \"beta\",\n /**\n * `<next>-rc.<n>` under the npm tag `rc`, such as `0.6.0-rc.1`; `<n>` goes up by one each publish.\n * `npm i <package>@rc` installs the newest.\n */\n rc: \"rc\",\n} as const;\n\n/**\n * A test release channel: `snapshot`, one of the numbered `channels`, or any word of your own\n * (`[a-z][a-z0-9-]*`, never `latest`), which publishes `<next>-<word>.<n>` under the npm tag `<word>`.\n */\nexport type Channel = (typeof channels)[keyof typeof channels] | (string & {});\n\n/**\n * Which channel each branch's test release publishes on. A key is a branch name, or a pattern such\n * as `release/*`: the exact name wins, then the longest pattern. A branch not listed publishes a\n * `snapshot`.\n */\nexport type TestReleaseBranches = Readonly<Record<string, Channel>>;\n\n/** Ready branch → channel maps for `testRelease`; each is a plain map, spread it to change it. */\nexport const testReleases = {\n /**\n * `main` → nightly; every other branch → snapshot.\n * @example main publishes 0.6.0-nightly.4 under the npm tag `nightly`.\n */\n nightly: { main: \"nightly\" },\n /**\n * One channel per long-lived branch: `main` → nightly, `next` → alpha, `beta` → beta,\n * `release/*` → rc; every other branch → snapshot.\n * @example release/1.0 publishes 1.0.0-rc.0 under the npm tag `rc`.\n */\n prerelease: { main: \"nightly\", next: \"alpha\", beta: \"beta\", \"release/*\": \"rc\" },\n /**\n * Git-flow: `develop` → nightly, `release/*` → beta, `hotfix/*` → rc; every other branch → snapshot.\n * @example develop publishes 0.6.0-nightly.4 under the npm tag `nightly`.\n */\n gitflow: { develop: \"nightly\", \"release/*\": \"beta\", \"hotfix/*\": \"rc\" },\n} as const satisfies Record<string, TestReleaseBranches>;\n\nconst CHANNEL_NAME = /^[a-z][a-z0-9-]*$/;\n// npm refuses a dist-tag it can read as a semver range.\nconst SEMVER_RANGE = /^v?(\\d+|x)$/;\n\n/** Why a channel name cannot be one, or null when it can. */\nexport const channelProblem = (name: string): string | null => {\n if (name === \"latest\") return \"latest is the real release's tag, never a test release's\";\n if (!CHANNEL_NAME.test(name) || SEMVER_RANGE.test(name)) {\n return `\"${name}\" is not a channel: a lowercase word such as beta, [a-z][a-z0-9-]*`;\n }\n return null;\n};\n\nconst escape = (text: string) => text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\nconst patternOf = (key: string) => new RegExp(`^${key.split(\"*\").map(escape).join(\".*\")}$`);\n\n/** The channel a branch publishes on: its exact name, else its longest matching pattern, else snapshot. */\nexport const channelFor = (branch: string, branches: TestReleaseBranches = {}): Channel => {\n const exact = branches[branch];\n if (exact !== undefined) return exact;\n const [match] = Object.keys(branches)\n .filter((key) => key.includes(\"*\") && patternOf(key).test(branch))\n .sort((left, right) => right.length - left.length);\n return (match === undefined ? undefined : branches[match]) ?? channels.snapshot;\n};\n\n/** Whether a channel numbers its versions: every one but snapshot. */\nexport const isNumbered = (channel: Channel) => channel !== channels.snapshot;\n\n/** The next free `<n>` of `<next>-<channel>.<n>`, from the versions the registry already holds. */\nexport const nextNumber = ({\n published,\n next,\n channel,\n}: {\n published: readonly string[];\n next: string;\n channel: Channel;\n}) => {\n const numbered = new RegExp(`^${escape(next)}-${escape(channel)}\\\\.(\\\\d+)$`);\n return published.reduce((free, version) => {\n const taken = numbered.exec(version)?.[1];\n return taken === undefined ? free : Math.max(free, Number(taken) + 1);\n }, 0);\n};\n\n/** The version a test release publishes: a snapshot of the commit, or the channel's numbered one. */\nexport const testVersion = ({\n next,\n channel,\n branch,\n sha,\n n,\n}: {\n next: string;\n channel: Channel;\n branch: string;\n sha: string;\n n: number;\n}) =>\n isNumbered(channel) ? `${next}-${channel}.${n}` : branchVersion({ current: next, branch, sha });\n\n/** The npm tag a test release publishes under: the channel, or the branch's for a snapshot. */\nexport const testTag = (channel: Channel, branch: string) =>\n isNumbered(channel) ? branchTag(channel) : branchTag(branchSlug(branch));\n","import type { z } from \"zod\";\n\nimport type { DeliveryAdapter } from \"../ports/adapter.port\";\nimport type { Resolved } from \"../ports/delivery.port\";\nimport type { MobileDistributionPort } from \"../ports/mobile-distribution.port\";\nimport type { PackageRegistryPort } from \"../ports/package-registry.port\";\nimport type { ServerHostingPort } from \"../ports/server-hosting.port\";\nimport type { StaticHostingPort } from \"../ports/static-hosting.port\";\n\n/**\n * What an adapter author writes in one object: the recipe's static parts (name, settings, what setup\n * and doctor ask) and the port's members, which read the settings typed.\n */\ntype Authored<Port extends { capability: string }, Schema extends z.ZodObject> = Omit<\n Port,\n \"capability\"\n> &\n Omit<DeliveryAdapter<Port>, \"create\" | \"settings\" | \"capability\"> & {\n readonly settings: Schema;\n };\n\ntype Typed<Schema extends z.ZodObject> = Resolved<z.output<Schema>>;\n\n// Its members take the settings its schema parses; the release flow only ever passes those.\nconst widen = <Port>(port: object): Port => port as Port;\n\nconst recipe = <Port extends { capability: string }>(\n {\n name,\n settings,\n typicalMinutes,\n decidedBy,\n detect,\n questions,\n requirements,\n env,\n ...port\n }: Omit<DeliveryAdapter<Port>, \"create\" | \"capability\">,\n capability: Port[\"capability\"],\n): DeliveryAdapter<Port> => ({\n name,\n capability,\n settings,\n typicalMinutes,\n decidedBy,\n detect,\n questions,\n requirements,\n ...(env ? { env } : {}),\n create: () => widen({ ...port, capability }),\n});\n\nexport const defineServerHosting = <const Schema extends z.ZodObject>(\n adapter: Authored<ServerHostingPort<Typed<Schema>>, Schema>,\n): DeliveryAdapter<ServerHostingPort> => recipe<ServerHostingPort>(adapter, \"server-hosting\");\n\nexport const defineStaticHosting = <const Schema extends z.ZodObject>(\n adapter: Authored<StaticHostingPort<Typed<Schema>>, Schema>,\n): DeliveryAdapter<StaticHostingPort> => recipe<StaticHostingPort>(adapter, \"static-hosting\");\n\nexport const defineMobileDistribution = <const Schema extends z.ZodObject>(\n adapter: Authored<MobileDistributionPort<Typed<Schema>>, Schema> &\n Required<Pick<DeliveryAdapter<MobileDistributionPort>, \"decidedBy\">>,\n): DeliveryAdapter<MobileDistributionPort> =>\n recipe<MobileDistributionPort>(adapter, \"mobile-distribution\");\n\nexport const definePackageRegistry = <const Schema extends z.ZodObject>(\n adapter: Authored<PackageRegistryPort<Typed<Schema>>, Schema>,\n): DeliveryAdapter<PackageRegistryPort> => recipe<PackageRegistryPort>(adapter, \"package-registry\");\n","import type { Approval } from \"../domain/releasePr\";\nimport type { ReleaseFlow } from \"../modules/module\";\nimport type { ServiceAdapter } from \"../ports/adapter.port\";\nimport type { CiPipelinePort } from \"../ports/ci-pipeline.port\";\nimport type { CodeHostPort } from \"../ports/code-host.port\";\nimport type { SourceControlPort } from \"../ports/source-control.port\";\nimport type { VersioningPort } from \"../ports/versioning.port\";\n\n/** How the release itself runs, given an adapter for each port it runs on. */\nexport const releaseFlow = (ports: {\n sourceControl: ServiceAdapter<SourceControlPort>;\n codeHost: ServiceAdapter<CodeHostPort>;\n ciPipeline: ServiceAdapter<CiPipelinePort>;\n versioning: ServiceAdapter<VersioningPort>;\n /** \"required\" when someone else approves the release PR; \"none\", the default, merges it here. */\n approval?: Approval;\n}): ReleaseFlow => ({ type: \"flow\", ...ports, approval: ports.approval ?? \"none\" });\n","import type { DeliveryAdapter } from \"../ports/adapter.port\";\nimport type { Delivery } from \"../ports/delivery.port\";\nimport type { ReleaseModule } from \"./module\";\n\n/** What every module of apps takes besides its adapter: a name, when two of a kind sit side by side. */\nexport interface Named {\n /** What an app's unit file names; the module's kind by default. */\n name?: string;\n}\n\n/** The stages every delivery adapter answers: its settings, where a tag lands and its jobs. */\nexport const deliveryModule = <Port extends Delivery & { capability: string }>(\n kind: string,\n adapter: DeliveryAdapter<Port>,\n name = kind,\n): ReleaseModule => ({\n type: \"module\",\n name,\n kind,\n provider: adapter.name,\n settings: adapter.settings,\n adapters: [adapter],\n capability: adapter.capability,\n decidedBy: adapter.decidedBy,\n typicalMinutes: adapter.typicalMinutes,\n ...(adapter.env ? { env: adapter.env } : {}),\n requirements: (apps) => apps.flatMap((unit) => adapter.requirements?.(unit) ?? []),\n ship: ({ open }, input) => {\n const port = open(adapter);\n return { where: port.describe(input), jobs: port.jobs(input) };\n },\n});\n","import type { DeliveryAdapter } from \"../../ports/adapter.port\";\nimport type { ServerHostingPort } from \"../../ports/server-hosting.port\";\nimport type { Named } from \"../deliveryModule\";\nimport type { ReleaseModule } from \"../module\";\nimport { deliveryModule } from \"../deliveryModule\";\n\n/** A long-lived service, such as an API: deployed from its tag, recorded with the code host. */\nexport const backendService = ({\n name,\n serverHosting,\n}: Named & { serverHosting: DeliveryAdapter<ServerHostingPort> }): ReleaseModule =>\n deliveryModule(\"backend-service\", serverHosting, name);\n","import type { DeliveryAdapter } from \"../../ports/adapter.port\";\nimport type { MobileDistributionPort } from \"../../ports/mobile-distribution.port\";\nimport type { Named } from \"../deliveryModule\";\nimport type { ReleaseModule } from \"../module\";\nimport { deliveryModule } from \"../deliveryModule\";\n\n/**\n * A mobile app: its distribution decides between a store build and an over-the-air update, adds to\n * the release PR, and says how a version does before it is promoted.\n */\nexport const mobileApp = ({\n name,\n mobileDistribution,\n}: Named & { mobileDistribution: DeliveryAdapter<MobileDistributionPort> }): ReleaseModule => ({\n ...deliveryModule(\"mobile-app\", mobileDistribution, name),\n versionFiles: (unit, units, open) => open(mobileDistribution).versionFiles?.(unit, units) ?? [],\n version: async (context, input) => {\n const port = context.open(mobileDistribution);\n return port.beforeVersion\n ? port.beforeVersion(context, input)\n : { added: [], writes: [], summary: [], onMerge: \"\" };\n },\n decide: (context, input) => context.open(mobileDistribution).decide(context, input),\n // A platform that cannot tell keeps the unit greyed, as before.\n live: async (context, input) => {\n const port = context.open(mobileDistribution);\n return port.live ? port.live(context, input) : true;\n },\n health: async (context, input) => {\n const port = context.open(mobileDistribution);\n return port.health ? port.health(context, input) : null;\n },\n inspect: async (context, input) => {\n const port = context.open(mobileDistribution);\n return port.inspect ? port.inspect(context, input) : undefined;\n },\n});\n","import type { DeliveryAdapter } from \"../../ports/adapter.port\";\nimport type { PackageRegistryPort } from \"../../ports/package-registry.port\";\nimport type { Named } from \"../deliveryModule\";\nimport type { ReleaseModule } from \"../module\";\nimport { deliveryModule } from \"../deliveryModule\";\n\n/** A package others install: its registry, not deploy records, knows what is out. */\nexport const publishedPackage = ({\n name,\n packageRegistry,\n}: Named & { packageRegistry: DeliveryAdapter<PackageRegistryPort> }): ReleaseModule => ({\n ...deliveryModule(\"published-package\", packageRegistry, name),\n decide: (context, input) => context.open(packageRegistry).decide(context, input),\n live: (context, input) => context.open(packageRegistry).live(context, input),\n publishedName: (context, input) =>\n context.open(packageRegistry).publishedName?.(input) ?? input.unit.packageName,\n publishedVersions: async (context, input) => {\n const registry = context.open(packageRegistry);\n if (!registry.publishedVersions) {\n throw new Error(\n `the ${packageRegistry.name} registry cannot list its versions: publish a snapshot instead`,\n );\n }\n return registry.publishedVersions(context, input);\n },\n});\n","import type { DeliveryAdapter } from \"../../ports/adapter.port\";\nimport type { StaticHostingPort } from \"../../ports/static-hosting.port\";\nimport type { Named } from \"../deliveryModule\";\nimport type { ReleaseModule } from \"../module\";\nimport { deliveryModule } from \"../deliveryModule\";\n\n/** A static site, built against the environment it ships to. */\nexport const webApp = ({\n name,\n staticHosting,\n}: Named & { staticHosting: DeliveryAdapter<StaticHostingPort> }): ReleaseModule =>\n deliveryModule(\"web-app\", staticHosting, name);\n","import { z } from \"zod\";\n\nimport type { DeliveryAdapter } from \"../../ports/adapter.port\";\nimport type { ServerHostingPort } from \"../../ports/server-hosting.port\";\nimport { perEnv } from \"../../application/config/perEnv\";\nimport { defineServerHosting } from \"../defineDelivery\";\n\nconst ShellOptions = z.object({\n deploy: perEnv(z.array(z.string()).min(1)).describe(\n \"The command that ships it, run from the root, as a list: [npx, my-tool, deploy]\",\n ),\n url: perEnv(z.string()).optional().describe(\"Where it answers, for other units to read\"),\n});\n\n/** Anything a command ships: the escape hatch until a host has its own adapter. */\nexport type ShellServerHostingAdapter = DeliveryAdapter<ServerHostingPort>;\n\nexport const shellServerHosting = (): ShellServerHostingAdapter =>\n defineServerHosting({\n name: \"shell\",\n settings: ShellOptions,\n describe: ({ options }) => options.deploy.join(\" \"),\n jobs: ({ tag, environment, options }) => {\n const [command = \"true\", ...args] = options.deploy;\n return [\n {\n label: `ship ${tag}: ${options.deploy.join(\" \")}`,\n local: [{ command, args }],\n ci: { ref: tag },\n record: true,\n },\n ];\n },\n });\n"],"mappings":";;;;AAMA,MAAa,eAAe;AAE5B,MA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AAE,MAAM,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,SACzC,kFACD;CACD,KAAK,OAAO,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,SAAS,4CAA4C;CACzF,CAAC;AAKF,MAAa,2BACX,oBAAoB;CAClB,MAAM;CACN,UAAU;CACV,WAAW,EAAE,cAAc,QAAQ,OAAO,KAAK,IAAI;CACnD,OAAO,EAAE,KAAK,aAAa,cAAc;EACvC,MAAM,CAAC,UAAU,QAAQ,GAAG,QAAQ,QAAQ;AAC5C,SAAO,CACL;GACE,OAAO,QAAQ,IAAI,IAAI,QAAQ,OAAO,KAAK,IAAI;GAC/C,OAAO,CAAC;IAAE;IAAS;IAAM,CAAC;GAC1B,IAAI,EAAE,KAAK,KAAK;GAChB,QAAQ;GACT,CACF;;CAEJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import "./shell-server-hosting.adapter-CvOcC6Wh.js";
|
|
1
2
|
import "./perEnv-n2qFRplP.js";
|
|
2
|
-
import "./shell-server-hosting.adapter-C7_5MWrl.js";
|
|
3
3
|
import { z, z as z$1 } from "zod";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
@@ -111,4 +111,4 @@ const internalTool = ({ name = "internal-tool" } = {}) => ({
|
|
|
111
111
|
//#endregion
|
|
112
112
|
export { defineRelease as i, internalTool as n, agentPlugin as r, z$1 as t };
|
|
113
113
|
|
|
114
|
-
//# sourceMappingURL=src-
|
|
114
|
+
//# sourceMappingURL=src-8BbKTQBb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-8BbKTQBb.js","names":[],"sources":["../src/application/config/defineRelease.ts","../src/modules/agent-plugin/agent-plugin.module.ts","../src/modules/internal-tool/internal-tool.module.ts"],"sourcesContent":["import type { DisplayChoice } from \"../../domain/display\";\nimport type { TagFormatName } from \"../../domain/tags\";\nimport type { TestReleaseBranches } from \"../../domain/testChannel\";\nimport type { Feature, ReleaseFlow, ReleaseModule } from \"../../modules/module\";\n\n/** How a repository releases: the flow, what gets released in order, and what happens around it. */\nexport interface ReleaseConfig {\n /** Folders to look in, `dir/*` or exact. Without it, the workspace file decides. */\n units?: string[];\n /** How the release itself runs: an adapter per port, each from its plugin. */\n flow: ReleaseFlow;\n /** What gets released, in this order. The first app is the repository's Latest release. */\n modules: ReleaseModule[];\n /** What happens around a release, after the ship, in this order. */\n features?: Feature[];\n /**\n * How a tag names a version: `\"package\"` (`{name}@{version}`, the default), `\"plugin\"` (`{name}--v{version}`), `\"single\"` (`v{version}`, one unit only), `\"module\"` (`{name}/v{version}`), or a format of your own.\n */\n tag?: TagFormatName | (string & {});\n /** How much the release says while it runs; `--verbose` and `--mascot` (or `--no-…`) override. */\n display?: DisplayChoice;\n /**\n * The pull request comment of a test version (`shiplane test-release`): `comments.table` (the default),\n * `comments.compact`, or text of your own with `{branch}`, `{commit}`, `{table}` and `{install}`.\n */\n testComment?: string;\n /**\n * Which channel each branch's test release (`shiplane test-release`) publishes on: a preset such\n * as `testReleases.gitflow`, or a map such as `{ main: channels.nightly, \"release/*\": channels.beta }`.\n * A key is a branch or a `*` pattern; a branch not listed publishes a snapshot. Without it, every\n * branch does. `shiplane test-release <channel>` picks another for one run.\n */\n testRelease?: TestReleaseBranches;\n /**\n * How a unit ships when both ways can: `\"ci\"` (the flow's CI pipeline, such as GitHub Actions) or\n * `\"local\"` (this machine). Without it, each ship asks. `--via` still wins for one run; a way that\n * cannot ship takes the other.\n */\n via?: \"ci\" | \"local\";\n /**\n * A shell command run from the root before each unit ships from this machine (a laptop or a\n * runner), never before a CI dispatch: `{unit}` is the unit's name, `{dir}` its folder from the\n * root, such as `\"pnpm --filter {unit}... build\"`. A failure fails that unit.\n */\n prepare?: string;\n}\n\nexport const defineRelease = (config: ReleaseConfig): ReleaseConfig => config;\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { z } from \"zod\";\n\nimport type { Named } from \"../deliveryModule\";\nimport type { ReleaseModule } from \"../module\";\n\n/**\n * Where each agent reads a plugin's version, relative to the plugin's folder: Claude Code and\n * Copilot CLI, Codex, Cursor, then Gemini CLI.\n */\nexport const AGENT_MANIFESTS = [\n \".claude-plugin/plugin.json\",\n \".codex-plugin/plugin.json\",\n \".cursor-plugin/plugin.json\",\n \"gemini-extension.json\",\n] as const;\n\nconst Versioned = z.object({ version: z.string() });\n\n/** A manifest's version, or null when the file is missing or holds no top-level version. */\nconst versionIn = (file: string) => {\n if (!fs.existsSync(file)) return null;\n const parsed = Versioned.safeParse(JSON.parse(fs.readFileSync(file, \"utf8\")));\n return parsed.success ? parsed.data.version : null;\n};\n\nconst literal = (text: string) => text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/** Moves only the version's value, so the release PR shows one changed line per manifest. */\nconst setVersion = (file: string, from: string, to: string) => {\n const text = fs.readFileSync(file, \"utf8\");\n const moved = text.replace(\n new RegExp(`(\"version\"\\\\s*:\\\\s*)\"${literal(from)}\"`),\n `$1${JSON.stringify(to)}`,\n );\n // The first such value may sit under another key: then the file is written whole instead.\n const top = Versioned.safeParse(JSON.parse(moved));\n const json = JSON.parse(text) as Record<string, unknown>;\n fs.writeFileSync(\n file,\n top.success && top.data.version === to\n ? moved\n : `${JSON.stringify({ ...json, version: to }, null, 2)}\\n`,\n );\n};\n\n/**\n * A plugin for coding agents, such as a Claude Code, Codex or Cursor plugin: a release versions it,\n * writes the version into each agent's manifest in the release PR, tags it and publishes its notes.\n * Nothing deploys it: agents install it from the repository, so merging the release PR ships it.\n */\nexport const agentPlugin = ({ name = \"agent-plugin\" }: Named = {}): ReleaseModule => ({\n type: \"module\",\n name,\n kind: \"agent-plugin\",\n provider: \"marketplace\",\n settings: z.object({}),\n adapters: [],\n releaseOnly: true,\n version: ({ root }, { unit, bump }) => {\n if (!bump) return Promise.resolve({ added: [], writes: [], summary: [], onMerge: \"\" });\n const manifests = AGENT_MANIFESTS.map((file) => path.posix.join(unit.dir, file)).flatMap(\n (file) => {\n const from = versionIn(path.join(root, file));\n return from === null ? [] : [{ file, from }];\n },\n );\n return Promise.resolve({\n added: [],\n writes: manifests.map(({ file, from }) => ({\n label: `${file} → ${bump.to}`,\n run: () => {\n setVersion(path.join(root, file), from, bump.to);\n return Promise.resolve();\n },\n })),\n summary: [],\n onMerge: \"Agents update to it: merging ships it\",\n });\n },\n ship: () => ({\n where: \"its tag and release notes; agents install it from the repository\",\n jobs: [],\n }),\n decide: () =>\n Promise.resolve({ action: \"none\", status: \"released, agents install it from the repository\" }),\n});\n","import { z } from \"zod\";\n\nimport type { Named } from \"../deliveryModule\";\nimport type { ReleaseModule } from \"../module\";\n\n/**\n * An app nothing deploys, such as a CLI run from the repository: a release versions it, tags it and\n * publishes its notes, and every environment counts it as shipped once tagged.\n */\nexport const internalTool = ({ name = \"internal-tool\" }: Named = {}): ReleaseModule => ({\n type: \"module\",\n name,\n kind: \"internal-tool\",\n // What output named it before modules: the release PR and status keep saying it.\n provider: \"release-only\",\n settings: z.object({}),\n adapters: [],\n releaseOnly: true,\n ship: () => ({ where: \"its tag and release notes, nothing deploys it\", jobs: [] }),\n decide: () => Promise.resolve({ action: \"none\", status: \"released, nothing deploys it\" }),\n});\n"],"mappings":";;;;;;AA+CA,MAAa,iBAAiB,WAAyC;;;;;;;ACpCvE,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACD;AAED,MAAM,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;;AAGnD,MAAM,aAAa,SAAiB;AAClC,KAAI,CAAC,GAAG,WAAW,KAAK,CAAE,QAAO;CACjC,MAAM,SAAS,UAAU,UAAU,KAAK,MAAM,GAAG,aAAa,MAAM,OAAO,CAAC,CAAC;AAC7E,QAAO,OAAO,UAAU,OAAO,KAAK,UAAU;;AAGhD,MAAM,WAAW,SAAiB,KAAK,QAAQ,uBAAuB,OAAO;;AAG7E,MAAM,cAAc,MAAc,MAAc,OAAe;CAC7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