shiplane 0.0.0 → 0.2.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/LICENSE +21 -0
- package/README.md +133 -0
- package/dist/budget-BqtW-Ekk.js +355 -0
- package/dist/budget-BqtW-Ekk.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +548 -0
- package/dist/cli.js.map +1 -0
- package/dist/display-IqkJ6uCw.js +96 -0
- package/dist/display-IqkJ6uCw.js.map +1 -0
- package/dist/index-D4qsXAis.d.ts +214 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/issues-TcWtMTv5.js +6 -0
- package/dist/issues-TcWtMTv5.js.map +1 -0
- package/dist/memory.d.ts +2 -0
- package/dist/memory.js +2 -0
- package/dist/package-registry.fake-CC37ptzf.d.ts +444 -0
- package/dist/package-registry.fake-Ciqc4ujx.js +633 -0
- package/dist/package-registry.fake-Ciqc4ujx.js.map +1 -0
- package/dist/perEnv-B7AiYnW_.js +11 -0
- package/dist/perEnv-B7AiYnW_.js.map +1 -0
- package/dist/plugin.d.ts +24 -0
- package/dist/plugin.js +8 -0
- package/dist/readStatus-YTZXH_Hh.js +3789 -0
- package/dist/readStatus-YTZXH_Hh.js.map +1 -0
- package/dist/shell-server-hosting.adapter-DobfDqFm.js +49 -0
- package/dist/shell-server-hosting.adapter-DobfDqFm.js.map +1 -0
- package/dist/src-CGASfBy2.js +32 -0
- package/dist/src-CGASfBy2.js.map +1 -0
- package/dist/static-hosting.port-mknLsxwR.d.ts +684 -0
- package/dist/tags-Bn3JrgPI.d.ts +19 -0
- package/dist/testing.d.ts +585 -0
- package/dist/testing.js +735 -0
- package/dist/testing.js.map +1 -0
- package/dist/web-app.module-6KrXIU7j.js +76 -0
- package/dist/web-app.module-6KrXIU7j.js.map +1 -0
- package/package.json +63 -9
|
@@ -0,0 +1,684 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/domain/environment.d.ts
|
|
4
|
+
/** Where a unit runs, in promotion order: production ships what preview validated. */
|
|
5
|
+
declare const ENVIRONMENTS: readonly ["preview", "production"];
|
|
6
|
+
type Environment = (typeof ENVIRONMENTS)[number];
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/domain/display.d.ts
|
|
9
|
+
declare const MOODS: readonly ["thinking", "working", "waiting", "happy", "worried", "resting"];
|
|
10
|
+
/** What the mascot shows beside the release: reading, running, waiting on a person, done, failed, idle. */
|
|
11
|
+
type Mood = (typeof MOODS)[number];
|
|
12
|
+
/** `done` of `total` as a bar `width` characters wide. */
|
|
13
|
+
declare const progressBar: (done: number, total: number, width: number) => string;
|
|
14
|
+
/** What is happening when the mascot is drawn. */
|
|
15
|
+
interface MascotMoment {
|
|
16
|
+
mood: Mood;
|
|
17
|
+
/** Its animation frame, from 0; always 0 when motion is off. */
|
|
18
|
+
tick: number;
|
|
19
|
+
/** What runs right now, such as "build 3 apps" or "deploy api@1.2.0 to production". */
|
|
20
|
+
label: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A mascot of your own: frames per mood, looped as it animates, or a function drawing each moment.
|
|
24
|
+
* Plain text: shiplane colours it by mood, pads it to one width, and takes any mood a set of frames
|
|
25
|
+
* leaves out from the hedgehog.
|
|
26
|
+
*/
|
|
27
|
+
type Mascot = Partial<Record<Mood, readonly string[]>> | ((moment: MascotMoment) => string);
|
|
28
|
+
/** How much the release says while it runs, as `shiplane.config.ts` or a flag asks. */
|
|
29
|
+
interface DisplayChoice {
|
|
30
|
+
/** Says each thing it reads and runs, with a progress bar. */
|
|
31
|
+
verbose?: boolean;
|
|
32
|
+
/** The mascot beside what is happening: the hedgehog (true), none (false), or your own. */
|
|
33
|
+
mascot?: boolean | Mascot;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/domain/unit.d.ts
|
|
37
|
+
/** Something with a version that ships somewhere: an app, a published package, this CLI. */
|
|
38
|
+
interface ReleaseUnit {
|
|
39
|
+
/** Its folder's name, the name every command and `${units.<name>}` uses. */
|
|
40
|
+
name: string;
|
|
41
|
+
/** Its folder, relative to the repository root. */
|
|
42
|
+
dir: string;
|
|
43
|
+
/** Its `shiplane.unit.yml`, relative to the repository root. */
|
|
44
|
+
file: string;
|
|
45
|
+
packageName: string;
|
|
46
|
+
version: string;
|
|
47
|
+
/** The module that ships it, as its unit file names it. */
|
|
48
|
+
module: string;
|
|
49
|
+
/** Its `buildCommand:`, when its unit file says one; else its package.json "build" script. */
|
|
50
|
+
buildCommand?: string;
|
|
51
|
+
/** As written: per-environment maps and references are resolved by `optionsFor`. */
|
|
52
|
+
options: Record<string, unknown>;
|
|
53
|
+
/** Units whose values it reads: they are dispatched before it. */
|
|
54
|
+
after: string[];
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/domain/changes.d.ts
|
|
58
|
+
/** A unit as changesets know it: its name here, its package name there. */
|
|
59
|
+
interface UnitRef {
|
|
60
|
+
name: string;
|
|
61
|
+
packageName: string;
|
|
62
|
+
}
|
|
63
|
+
type BumpType = "major" | "minor" | "patch" | "none";
|
|
64
|
+
/** One changeset, as `changeset status --output` lists it. */
|
|
65
|
+
interface PlannedChangeset {
|
|
66
|
+
id: string;
|
|
67
|
+
summary: string;
|
|
68
|
+
releases: {
|
|
69
|
+
name: string;
|
|
70
|
+
type: BumpType;
|
|
71
|
+
}[];
|
|
72
|
+
}
|
|
73
|
+
/** One package's version move, as `changeset status --output` lists it. */
|
|
74
|
+
interface PlannedRelease {
|
|
75
|
+
name: string;
|
|
76
|
+
type: BumpType;
|
|
77
|
+
oldVersion: string;
|
|
78
|
+
newVersion: string;
|
|
79
|
+
/** Empty when the package only moves because a workspace dependency did. */
|
|
80
|
+
changesets: string[];
|
|
81
|
+
}
|
|
82
|
+
interface StatusPlan {
|
|
83
|
+
changesets: PlannedChangeset[];
|
|
84
|
+
releases: PlannedRelease[];
|
|
85
|
+
}
|
|
86
|
+
interface AppBump {
|
|
87
|
+
/** The unit's name. */
|
|
88
|
+
app: string;
|
|
89
|
+
from: string;
|
|
90
|
+
to: string;
|
|
91
|
+
/** What the app's users get: the summaries of the changesets naming it. */
|
|
92
|
+
notes: string[];
|
|
93
|
+
/** The workspace packages it moves with, when no changeset names it. */
|
|
94
|
+
movedWith: string[];
|
|
95
|
+
}
|
|
96
|
+
/** The units a release moves, in `units` order, each with its notes or the packages it moves with. */
|
|
97
|
+
declare const appBumps: ({
|
|
98
|
+
changesets,
|
|
99
|
+
releases
|
|
100
|
+
}: StatusPlan, dependencies: Record<string, string[]>, units: readonly UnitRef[]) => AppBump[];
|
|
101
|
+
/**
|
|
102
|
+
* Holding an app back keeps its lines pending, with any package line they came with so the package
|
|
103
|
+
* does not drag the held app along. The picked apps' lines ship under the same summary.
|
|
104
|
+
*/
|
|
105
|
+
declare const splitChangesets: (changesets: PlannedChangeset[], held: readonly string[], units: readonly UnitRef[]) => {
|
|
106
|
+
ships: PlannedChangeset[];
|
|
107
|
+
waits: PlannedChangeset[];
|
|
108
|
+
};
|
|
109
|
+
interface UnreleasedApp {
|
|
110
|
+
/** The unit's name. */
|
|
111
|
+
app: string;
|
|
112
|
+
version: string;
|
|
113
|
+
/** Subjects of the commits that touched it since its current version, newest first. */
|
|
114
|
+
commits: string[];
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/domain/releasePr.d.ts
|
|
118
|
+
interface OpenPr {
|
|
119
|
+
number: number;
|
|
120
|
+
url: string;
|
|
121
|
+
/** The commit the PR's branch stands on, when the host says: main moving past it makes the PR stale. */
|
|
122
|
+
head?: string;
|
|
123
|
+
}
|
|
124
|
+
/** Whether a release PR merges from the terminal, or waits for someone else to approve it. */
|
|
125
|
+
type Approval = "none" | "required";
|
|
126
|
+
type MergeMethod = "--squash" | "--merge" | "--rebase";
|
|
127
|
+
/** What the pull request page offers: the methods the repository allows, and the one it preselects. */
|
|
128
|
+
interface MergeMethods {
|
|
129
|
+
allowed: MergeMethod[];
|
|
130
|
+
preselected: MergeMethod | null;
|
|
131
|
+
}
|
|
132
|
+
type ReleaseStep = {
|
|
133
|
+
step: "wait-merge";
|
|
134
|
+
prs: OpenPr[];
|
|
135
|
+
} | {
|
|
136
|
+
step: "release-pr";
|
|
137
|
+
} | {
|
|
138
|
+
step: "ship";
|
|
139
|
+
};
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/domain/scope.d.ts
|
|
142
|
+
/** A unit whose live state its own platform knows, not GitHub Deployments: EAS for a mobile app. */
|
|
143
|
+
interface DecidedBy {
|
|
144
|
+
/** Who decides, as a person reads it: "EAS". */
|
|
145
|
+
platform: string;
|
|
146
|
+
/** What it decides between: "build or update". */
|
|
147
|
+
choice: string;
|
|
148
|
+
/** The command that shows its state: "shiplane status". */
|
|
149
|
+
check: string;
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/domain/deploys.d.ts
|
|
153
|
+
/** The run name the deploy workflows set, so the Actions list says which version went where. */
|
|
154
|
+
declare const deployRunTitle: (tag: string, environment: Environment) => string;
|
|
155
|
+
type DeployState = "none" | "running" | "done";
|
|
156
|
+
/** One version on one environment, from the states of its GitHub deployments. */
|
|
157
|
+
declare const deployState: (states: string[]) => DeployState;
|
|
158
|
+
/** Whether a diff only moves version files: the code is still the code a release named. */
|
|
159
|
+
declare const onlyVersionFiles: (files: string[], versionFiles: ReadonlySet<string>) => boolean;
|
|
160
|
+
type DeployPath = "github" | "local";
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/domain/budget.d.ts
|
|
163
|
+
interface ActionsMinutes {
|
|
164
|
+
used: number;
|
|
165
|
+
included: number;
|
|
166
|
+
left: number;
|
|
167
|
+
}
|
|
168
|
+
/** This month's Actions minutes against the plan's allowance, from GitHub's usage summary. */
|
|
169
|
+
declare const actionsMinutes: (plan: string, usage: {
|
|
170
|
+
sku: string;
|
|
171
|
+
grossQuantity: number;
|
|
172
|
+
unitType: string;
|
|
173
|
+
}[]) => ActionsMinutes | null;
|
|
174
|
+
/** Minutes GitHub bills for a run: each job rounds up to the minute; unfinished jobs are skipped. */
|
|
175
|
+
declare const billedMinutes: (jobs: {
|
|
176
|
+
startedAt: string | null;
|
|
177
|
+
completedAt: string | null;
|
|
178
|
+
}[]) => number;
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/domain/issues.d.ts
|
|
181
|
+
/** An issue or pull request, by repository: `owner/name` and its number. */
|
|
182
|
+
interface IssueRef {
|
|
183
|
+
repository: string;
|
|
184
|
+
number: number;
|
|
185
|
+
}
|
|
186
|
+
/** A merged pull request, as a release reads which issues it relates to. */
|
|
187
|
+
interface LinkedPr extends IssueRef {
|
|
188
|
+
body: string;
|
|
189
|
+
/** The issues GitHub says it closes. */
|
|
190
|
+
closes: IssueRef[];
|
|
191
|
+
}
|
|
192
|
+
declare const issueName: ({
|
|
193
|
+
repository,
|
|
194
|
+
number
|
|
195
|
+
}: IssueRef) => string;
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/ports/code-host.port.d.ts
|
|
198
|
+
interface Deploy {
|
|
199
|
+
/** The run title every deploy records: `Deploy <tag> to <environment>`. */
|
|
200
|
+
title: string;
|
|
201
|
+
state: DeployState;
|
|
202
|
+
}
|
|
203
|
+
/** Where pull requests, comments, release notes and deploy records live. */
|
|
204
|
+
interface CodeHostPort {
|
|
205
|
+
/** Open pull requests whose branch starts with the prefix, oldest first. */
|
|
206
|
+
openPrsFrom: (branchPrefix: string) => Promise<OpenPr[]>;
|
|
207
|
+
createPr: (pr: {
|
|
208
|
+
base: string;
|
|
209
|
+
head: string;
|
|
210
|
+
title: string;
|
|
211
|
+
body: string;
|
|
212
|
+
label: string;
|
|
213
|
+
}) => Promise<OpenPr>;
|
|
214
|
+
prState: (pr: OpenPr) => Promise<"OPEN" | "MERGED" | "CLOSED">;
|
|
215
|
+
closePr: (pr: OpenPr, comment: string) => Promise<void>;
|
|
216
|
+
mergeMethods: () => Promise<MergeMethods>;
|
|
217
|
+
merge: (pr: OpenPr, method: MergeMethod) => Promise<void>;
|
|
218
|
+
showDiff: (pr: OpenPr) => Promise<void>;
|
|
219
|
+
openInBrowser: (pr: OpenPr) => Promise<void>;
|
|
220
|
+
/** Tags that already have release notes. */
|
|
221
|
+
releasedTags: () => Promise<Set<string>>;
|
|
222
|
+
createRelease: (tag: string, notes: string, latest: boolean) => Promise<void>;
|
|
223
|
+
/** Every deploy recorded for a tag, by a workflow or by this machine. */
|
|
224
|
+
deployments: () => Promise<Deploy[]>;
|
|
225
|
+
recordDeployment: (ref: string, environment: Environment) => Promise<void>;
|
|
226
|
+
/** Each pull request's body and the issues it closes, in the order asked, read in one go. */
|
|
227
|
+
pullRequests: (numbers: readonly number[]) => Promise<LinkedPr[]>;
|
|
228
|
+
/** The recent comments of each issue or pull request, in the order asked, read in one go. */
|
|
229
|
+
comments: (on: readonly IssueRef[]) => Promise<string[][]>;
|
|
230
|
+
/** Posts a comment on an issue or a pull request, paced so a burst stays under the host's limits. */
|
|
231
|
+
comment: (on: IssueRef, body: string) => Promise<void>;
|
|
232
|
+
}
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/ports/ci-pipeline.port.d.ts
|
|
235
|
+
/** Where workflows run: dispatched on a ref, their runs read back, the minutes they cost. */
|
|
236
|
+
interface CiPipelinePort {
|
|
237
|
+
/** The one workflow that ships on CI: `shiplane ship` on a runner, given units and an environment. */
|
|
238
|
+
readonly shipWorkflow: string;
|
|
239
|
+
/** A workflow's runs, each titled `Deploy <tag> to <environment>` when it deploys. */
|
|
240
|
+
workflowRuns: (workflow: string) => Promise<Deploy[]>;
|
|
241
|
+
dispatch: (workflow: string, ref: string, inputs: Record<string, string>) => Promise<void>;
|
|
242
|
+
/** This month's minutes, or null when the pipeline won't say. */
|
|
243
|
+
minutes: () => Promise<ActionsMinutes | null>;
|
|
244
|
+
/** Billed minutes of a workflow's last successful runs. */
|
|
245
|
+
measuredMinutes: (workflow: string) => Promise<number[]>;
|
|
246
|
+
}
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region src/ports/shell.port.d.ts
|
|
249
|
+
interface RunOptions {
|
|
250
|
+
cwd?: string;
|
|
251
|
+
env?: Record<string, string>;
|
|
252
|
+
input?: string;
|
|
253
|
+
}
|
|
254
|
+
interface ShellResult {
|
|
255
|
+
status: number;
|
|
256
|
+
stdout: string;
|
|
257
|
+
stderr: string;
|
|
258
|
+
}
|
|
259
|
+
/** Every vendor tool this CLI drives (git, gh, eas, flyctl, wrangler) goes through here. */
|
|
260
|
+
interface Shell {
|
|
261
|
+
/** Runs and captures its output; a non-zero exit is a result, never an error. */
|
|
262
|
+
capture: (command: string, args: readonly string[], options?: RunOptions) => Promise<ShellResult>;
|
|
263
|
+
/** Runs in the person's terminal with its output shown; resolves with the exit status. */
|
|
264
|
+
attach: (command: string, args: readonly string[], options?: RunOptions) => Promise<number>;
|
|
265
|
+
/** A variable of this process's environment, such as a token a command needs. */
|
|
266
|
+
env: (name: string) => string | undefined;
|
|
267
|
+
}
|
|
268
|
+
/** A command that exited non-zero, carrying all it printed so a failure can show why. */
|
|
269
|
+
declare class CommandFailed extends Error {
|
|
270
|
+
readonly output: string;
|
|
271
|
+
constructor(message: string, output: string);
|
|
272
|
+
}
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/domain/governance.d.ts
|
|
275
|
+
type ReleaseIntent = "build" | "update" | "submit";
|
|
276
|
+
interface GitPosition {
|
|
277
|
+
branch: string;
|
|
278
|
+
head: string;
|
|
279
|
+
/** origin/main after a fetch. */
|
|
280
|
+
originMain: string;
|
|
281
|
+
}
|
|
282
|
+
type SourceResult = {
|
|
283
|
+
allowed: true;
|
|
284
|
+
} | {
|
|
285
|
+
allowed: false;
|
|
286
|
+
why: "not-main" | "behind-main";
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* A binary ships what it was built from, so builds start from main as it is on origin. Preview
|
|
290
|
+
* updates may come from a branch for testers; production updates only from main.
|
|
291
|
+
*/
|
|
292
|
+
declare const releaseSource: (intent: ReleaseIntent, channel: Environment, {
|
|
293
|
+
branch,
|
|
294
|
+
head,
|
|
295
|
+
originMain
|
|
296
|
+
}: GitPosition) => SourceResult;
|
|
297
|
+
/** Production never runs a step nobody confirmed. */
|
|
298
|
+
declare const yesAllowed: (channel: Environment, yes: boolean) => boolean;
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region src/ports/source-control.port.d.ts
|
|
301
|
+
/** The repository's history, as a release reads and writes it. */
|
|
302
|
+
interface SourceControlPort {
|
|
303
|
+
/** After fetching main: the branch, its head and origin/main. */
|
|
304
|
+
position: () => Promise<GitPosition>;
|
|
305
|
+
/** No tracked file changed. */
|
|
306
|
+
isClean: () => Promise<boolean>;
|
|
307
|
+
tagCommit: (tag: string) => Promise<string | null>;
|
|
308
|
+
/** The commit that brought a version into a folder's manifest. */
|
|
309
|
+
versionCommit: (dir: string, manifest: string, version: string) => Promise<{
|
|
310
|
+
sha: string;
|
|
311
|
+
subject: string;
|
|
312
|
+
} | null>;
|
|
313
|
+
/** Subjects of the commits that touched a folder since a commit, newest first, `ignore` aside. */
|
|
314
|
+
subjectsSince: (sha: string, dir: string, ignore?: readonly string[]) => Promise<string[]>;
|
|
315
|
+
/** The commits after `from` up to `to`, newest first: each subject and the files it touched. */
|
|
316
|
+
commitsBetween: (from: string, to: string) => Promise<{
|
|
317
|
+
subject: string;
|
|
318
|
+
files: string[];
|
|
319
|
+
}[]>;
|
|
320
|
+
/** Modified and untracked files, relative to the root. */
|
|
321
|
+
changedFiles: () => Promise<string[]>;
|
|
322
|
+
diffNames: (from: string, to: string) => Promise<string[]>;
|
|
323
|
+
fileAt: (ref: string, file: string) => Promise<string | null>;
|
|
324
|
+
tags: () => Promise<Set<string>>;
|
|
325
|
+
createBranch: (name: string) => Promise<void>;
|
|
326
|
+
switchTo: (branch: string) => Promise<void>;
|
|
327
|
+
/** `skipHooks` commits without the repository's hooks: a release title longer than they allow. */
|
|
328
|
+
commit: (files: string[], title: string, body?: string, options?: {
|
|
329
|
+
skipHooks?: boolean;
|
|
330
|
+
}) => Promise<void>;
|
|
331
|
+
push: (branch: string) => Promise<void>;
|
|
332
|
+
pull: () => Promise<void>;
|
|
333
|
+
tag: (name: string, sha: string, message: string) => Promise<void>;
|
|
334
|
+
pushTags: (names: string[]) => Promise<void>;
|
|
335
|
+
/** Puts tracked files back as committed and removes `files` this release created. */
|
|
336
|
+
discard: (files: string[]) => Promise<void>;
|
|
337
|
+
deleteBranch: (name: string) => Promise<void>;
|
|
338
|
+
deleteRemoteBranch: (branch: string) => Promise<void>;
|
|
339
|
+
deleteTag: (name: string) => Promise<void>;
|
|
340
|
+
}
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/ports/terminal.port.d.ts
|
|
343
|
+
/** Where the CLI writes for a person to read. */
|
|
344
|
+
interface Output {
|
|
345
|
+
line: (text?: string) => void;
|
|
346
|
+
}
|
|
347
|
+
interface Choice<Value extends string> {
|
|
348
|
+
value: Value;
|
|
349
|
+
label: string;
|
|
350
|
+
hint?: string;
|
|
351
|
+
disabled?: boolean;
|
|
352
|
+
}
|
|
353
|
+
/** Questions to the person. Without a terminal, nothing is asked: each answer is null or false. */
|
|
354
|
+
interface Prompter {
|
|
355
|
+
readonly interactive: boolean;
|
|
356
|
+
/** `initial` is the answer offered first: No unless said. */
|
|
357
|
+
confirm: (question: string, initial?: boolean) => Promise<boolean>;
|
|
358
|
+
/** The typed confirmation production asks for: true only when the word is typed exactly. */
|
|
359
|
+
typed: (question: string, word: string) => Promise<boolean>;
|
|
360
|
+
select: <Value extends string>(message: string, choices: Choice<Value>[], initial?: Value) => Promise<Value | null>;
|
|
361
|
+
multiselect: <Value extends string>(message: string, choices: Choice<Value>[], initial: Value[]) => Promise<Value[] | null>;
|
|
362
|
+
text: (message: string, initial?: string) => Promise<string | null>;
|
|
363
|
+
/** Shows `label` as waiting for up to `ms`; resolves with a key from `keys`, or null on timeout. */
|
|
364
|
+
waitForKey: (label: string, ms: number, keys: readonly string[]) => Promise<string | null>;
|
|
365
|
+
}
|
|
366
|
+
interface Clock {
|
|
367
|
+
now: () => Date;
|
|
368
|
+
/** Waits, unless something wakes it first. */
|
|
369
|
+
sleep: (ms: number) => Promise<void>;
|
|
370
|
+
}
|
|
371
|
+
/** A step's place in its run, for the counter and the bar. */
|
|
372
|
+
interface StepPlace {
|
|
373
|
+
index: number;
|
|
374
|
+
total: number;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Where the release is, for a person to follow: the stage of its journey, what it is reading or
|
|
378
|
+
* running right now, and the mascot's mood. How much of it shows is the adapter's choice.
|
|
379
|
+
*/
|
|
380
|
+
interface Progress {
|
|
381
|
+
/** The release reached `stages[index]`. */
|
|
382
|
+
stage: (stages: readonly string[], index: number) => void;
|
|
383
|
+
/** Runs `work` while showing `label`; a step also shows its place in its run. */
|
|
384
|
+
during: <T>(label: string, mood: Mood, work: () => Promise<T>, step?: StepPlace) => Promise<T>;
|
|
385
|
+
/** One line, said in a mood: done, failed, nothing to do. */
|
|
386
|
+
say: (mood: Mood, text: string) => void;
|
|
387
|
+
}
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/ports/delivery.port.d.ts
|
|
390
|
+
/** One command, as data: run here, printed by a dry run, mirrored by a CI workflow. */
|
|
391
|
+
interface Command {
|
|
392
|
+
command: string;
|
|
393
|
+
args: string[];
|
|
394
|
+
/** Relative to the repository root; the root itself when absent. */
|
|
395
|
+
cwd?: string;
|
|
396
|
+
env?: Record<string, string>;
|
|
397
|
+
/** Variables passed as `<flag> NAME=value` when set; a plan shows only `NAME=$NAME`. */
|
|
398
|
+
secrets?: {
|
|
399
|
+
flag: string;
|
|
400
|
+
name: string;
|
|
401
|
+
}[];
|
|
402
|
+
}
|
|
403
|
+
/** What shipping one tag to one environment takes. Built, never run, by an adapter. */
|
|
404
|
+
interface Job {
|
|
405
|
+
/** What a person reads: "deploy api@0.4.2 to acme-api-preview (Fly)". */
|
|
406
|
+
label: string;
|
|
407
|
+
/** The commands this machine runs, in order. */
|
|
408
|
+
local: Command[];
|
|
409
|
+
/** The ref the CI pipeline's ship workflow runs these commands from; absent when only here can. */
|
|
410
|
+
ci?: {
|
|
411
|
+
ref: string;
|
|
412
|
+
};
|
|
413
|
+
/** Record the deploy in the host's deploy records once it ran from this machine. */
|
|
414
|
+
record?: boolean;
|
|
415
|
+
/** Runs after `local` whether it failed or not, such as putting a manifest back. */
|
|
416
|
+
cleanup?: Command[];
|
|
417
|
+
}
|
|
418
|
+
/** What an adapter is told when asked for its jobs. */
|
|
419
|
+
interface JobInput<Options> {
|
|
420
|
+
unit: ReleaseUnit;
|
|
421
|
+
/** The tag being shipped: `<unit>@<version>`. */
|
|
422
|
+
tag: string;
|
|
423
|
+
environment: Environment;
|
|
424
|
+
/** The unit's options for that environment, per-environment values picked, references filled. */
|
|
425
|
+
options: Options;
|
|
426
|
+
/** The commit this machine is on. */
|
|
427
|
+
commit: string;
|
|
428
|
+
}
|
|
429
|
+
/** What a module's per-app stages may read and run. */
|
|
430
|
+
interface DecideContext {
|
|
431
|
+
root: string;
|
|
432
|
+
shell: Shell;
|
|
433
|
+
sourceControl: SourceControlPort;
|
|
434
|
+
codeHost: CodeHostPort;
|
|
435
|
+
ciPipeline: CiPipelinePort;
|
|
436
|
+
units: readonly ReleaseUnit[];
|
|
437
|
+
/** How a tag names a version, such as `{name}@{version}`. */
|
|
438
|
+
tagFormat: string;
|
|
439
|
+
/** Every file a release may move after a tag without changing what ships. */
|
|
440
|
+
versionFiles: ReadonlySet<string>;
|
|
441
|
+
/** The files changed between two commits that can reach what a unit ships. */
|
|
442
|
+
changedCode: (unit: ReleaseUnit, from: string, to: string) => Promise<string[]>;
|
|
443
|
+
now: () => Date;
|
|
444
|
+
/** The port an adapter gives, created for this repository. */
|
|
445
|
+
open: <Port>(adapter: Adapter<Port>) => Port;
|
|
446
|
+
}
|
|
447
|
+
/** How a version does where it runs, as its platform reports it. */
|
|
448
|
+
interface Health {
|
|
449
|
+
ok: boolean;
|
|
450
|
+
/** What was measured, as a person reads it: "iOS 3 launches, 0 crashes". */
|
|
451
|
+
summary: string;
|
|
452
|
+
/** Why it looks unwell, when it does. */
|
|
453
|
+
why?: string;
|
|
454
|
+
}
|
|
455
|
+
/** What a failure says, and what to run next. */
|
|
456
|
+
interface Refusal {
|
|
457
|
+
title: string;
|
|
458
|
+
detail: string;
|
|
459
|
+
commands: string[];
|
|
460
|
+
}
|
|
461
|
+
/** What a unit needs on an environment, as its adapter decides. */
|
|
462
|
+
type Decision =
|
|
463
|
+
/**
|
|
464
|
+
* Ship: a build, a submit or a publish runs from here; an update or a deploy asks how.
|
|
465
|
+
* `notLocal` says why this machine cannot ship it, leaving GitHub Actions.
|
|
466
|
+
*/
|
|
467
|
+
{
|
|
468
|
+
action: "ship";
|
|
469
|
+
kind: "build" | "submit" | "publish" | "update" | "deploy";
|
|
470
|
+
jobs: Job[];
|
|
471
|
+
notLocal?: string;
|
|
472
|
+
} /** Nothing to do; the status says why. */ | {
|
|
473
|
+
action: "none";
|
|
474
|
+
status: string;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* A move only a person picks, such as how far a rollout goes: `lines` say where it stands, then
|
|
478
|
+
* the question; an option with no jobs ships nothing and says `held`.
|
|
479
|
+
*/
|
|
480
|
+
| {
|
|
481
|
+
action: "choose";
|
|
482
|
+
lines: string[];
|
|
483
|
+
question: string;
|
|
484
|
+
suggested: string;
|
|
485
|
+
options: (Choice<string> & {
|
|
486
|
+
jobs: Job[];
|
|
487
|
+
})[];
|
|
488
|
+
held: string;
|
|
489
|
+
} | ({
|
|
490
|
+
action: "fail";
|
|
491
|
+
} & Refusal) /** A small PR has to merge first, such as moving a version; the adapter decides again after it. */ | {
|
|
492
|
+
action: "pull-request";
|
|
493
|
+
question: string;
|
|
494
|
+
branch: string;
|
|
495
|
+
title: string;
|
|
496
|
+
body: string;
|
|
497
|
+
changesets: PlannedChangeset[]; /** Writes its files and returns them, relative to the root. */
|
|
498
|
+
write: () => Promise<string[]>;
|
|
499
|
+
};
|
|
500
|
+
/** A question its detection answers first: the person sees why and may pick another option. */
|
|
501
|
+
interface VersionChoice {
|
|
502
|
+
question: string;
|
|
503
|
+
options: Choice<string>[];
|
|
504
|
+
suggested: string;
|
|
505
|
+
}
|
|
506
|
+
/** What an adapter adds to a release PR: changesets it writes, files it moves, what a person reads. */
|
|
507
|
+
interface VersionContribution {
|
|
508
|
+
blocked?: Refusal;
|
|
509
|
+
/** Asked before the summary; the adapter runs again with the answer when it differs. */
|
|
510
|
+
choice?: VersionChoice;
|
|
511
|
+
added: PlannedChangeset[];
|
|
512
|
+
writes: {
|
|
513
|
+
label: string;
|
|
514
|
+
run: () => Promise<void>;
|
|
515
|
+
}[];
|
|
516
|
+
/** Lines under the unit in the summary. */
|
|
517
|
+
summary: string[];
|
|
518
|
+
/** The "On merge" cell of the release PR. */
|
|
519
|
+
onMerge: string;
|
|
520
|
+
/** A numbered step the release announces before anything runs. */
|
|
521
|
+
step?: string;
|
|
522
|
+
}
|
|
523
|
+
/** A folder as `init` shows it to an adapter, to recognise what ships from it. */
|
|
524
|
+
interface FolderView {
|
|
525
|
+
/** Relative to the root. */
|
|
526
|
+
dir: string;
|
|
527
|
+
name: string;
|
|
528
|
+
/** Entries directly in it. */
|
|
529
|
+
files: string[];
|
|
530
|
+
has: (file: string) => boolean;
|
|
531
|
+
read: (file: string) => string | null;
|
|
532
|
+
}
|
|
533
|
+
/** What an adapter recognised in a folder. */
|
|
534
|
+
interface Detection {
|
|
535
|
+
/**
|
|
536
|
+
* `found`: a file only this target uses. `likely`: a strong sign, such as a static build's
|
|
537
|
+
* config. `possible`: a weak one, such as a Dockerfile. The strongest is suggested.
|
|
538
|
+
*/
|
|
539
|
+
certainty: "found" | "likely" | "possible";
|
|
540
|
+
/** What was seen, as a person reads it: "fly-preview.toml". */
|
|
541
|
+
reason: string;
|
|
542
|
+
/** Options read from what was seen; `questions` asks for the rest. */
|
|
543
|
+
options: Record<string, unknown>;
|
|
544
|
+
}
|
|
545
|
+
/** An option `init` asks for when nothing in the folder said it. */
|
|
546
|
+
interface Question {
|
|
547
|
+
key: string;
|
|
548
|
+
message: string;
|
|
549
|
+
initial?: string;
|
|
550
|
+
}
|
|
551
|
+
/** A tool or sign-in an adapter needs, checked by `shiplane doctor`. */
|
|
552
|
+
interface Requirement {
|
|
553
|
+
label: string;
|
|
554
|
+
/** Exits 0 when the requirement is met. */
|
|
555
|
+
check: Command;
|
|
556
|
+
/** What fixes it, offered to run. */
|
|
557
|
+
fix?: Command;
|
|
558
|
+
}
|
|
559
|
+
/** A value per environment becomes the value itself, at any depth. */
|
|
560
|
+
type Resolved<Value> = Value extends {
|
|
561
|
+
preview: infer Inner;
|
|
562
|
+
production: infer Inner;
|
|
563
|
+
} ? Resolved<Inner> : Value extends readonly (infer Item)[] ? Resolved<Item>[] : Value extends object ? { [Key in keyof Value]: Resolved<Value[Key]> } : Value;
|
|
564
|
+
/** What every delivery port does: say where a tag lands, and build the jobs that ship it. */
|
|
565
|
+
interface Delivery<Options = Record<string, unknown>> {
|
|
566
|
+
/** Where a tag lands, as a person reads it. */
|
|
567
|
+
describe(input: JobInput<Options>): string;
|
|
568
|
+
/** What shipping a tag runs: commands as data, never run by the adapter itself. */
|
|
569
|
+
jobs(input: JobInput<Options>): Job[];
|
|
570
|
+
}
|
|
571
|
+
//#endregion
|
|
572
|
+
//#region src/ports/adapter.port.d.ts
|
|
573
|
+
/** What an adapter is given when the CLI creates its port: the repository and a shell. */
|
|
574
|
+
interface AdapterContext {
|
|
575
|
+
root: string;
|
|
576
|
+
shell: Shell;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* An adapter as shiplane.config.ts holds it: a recipe, not a live object. The CLI creates the port
|
|
580
|
+
* when a module runs, so reloading the config creates fresh ports.
|
|
581
|
+
*/
|
|
582
|
+
interface Adapter<Port> {
|
|
583
|
+
/** The provider: "git", "fly". */
|
|
584
|
+
readonly name: string;
|
|
585
|
+
readonly create: (context: AdapterContext) => Port;
|
|
586
|
+
}
|
|
587
|
+
/** An adapter of a port the release flow runs on: source control, code host, CI, versioning. */
|
|
588
|
+
interface ServiceAdapter<Port> extends Adapter<Port> {
|
|
589
|
+
/** Tools and sign-ins it needs, checked by `shiplane doctor`. */
|
|
590
|
+
readonly requirements?: () => Requirement[];
|
|
591
|
+
}
|
|
592
|
+
/** An adapter of a delivery port: what its apps' unit files hold, and what `init` recognises. */
|
|
593
|
+
interface DeliveryAdapter<Port extends {
|
|
594
|
+
capability: string;
|
|
595
|
+
}> extends Adapter<Port> {
|
|
596
|
+
/** The kind of delivery its port does, the one `init` picks a module by. */
|
|
597
|
+
readonly capability: Port["capability"];
|
|
598
|
+
/** The keys an app's unit file holds for it besides `module`. */
|
|
599
|
+
readonly settings: z.ZodObject;
|
|
600
|
+
/** Billed minutes of its CI deploy, used until a run has been measured. */
|
|
601
|
+
readonly typicalMinutes?: number;
|
|
602
|
+
/** Set when its own platform, not deploy records, knows what is live. */
|
|
603
|
+
readonly decidedBy?: DecidedBy;
|
|
604
|
+
/** What `init` recognises in a folder it ships. */
|
|
605
|
+
readonly detect?: (folder: FolderView) => Detection | null;
|
|
606
|
+
/** Settings `init` asks for that `detect` could not read. */
|
|
607
|
+
readonly questions?: (folder: FolderView, found: Record<string, unknown>, repository: string) => Question[];
|
|
608
|
+
/** Tools and sign-ins it needs for an app. */
|
|
609
|
+
readonly requirements?: (unit: ReleaseUnit) => Requirement[];
|
|
610
|
+
}
|
|
611
|
+
//#endregion
|
|
612
|
+
//#region src/ports/versioning.port.d.ts
|
|
613
|
+
/** The intent to release: changesets today. */
|
|
614
|
+
interface VersioningPort {
|
|
615
|
+
/** Pending change files, by id, with their raw text. */
|
|
616
|
+
pending: () => Promise<{
|
|
617
|
+
id: string;
|
|
618
|
+
text: string;
|
|
619
|
+
}[]>;
|
|
620
|
+
/** What versioning would move, with these added and the `waits` held back, writing nothing. */
|
|
621
|
+
plan: (added: PlannedChangeset[], held: PlannedChangeset[]) => Promise<StatusPlan>;
|
|
622
|
+
/** Writes `added`, versions everything but `held`, and leaves `held` pending. */
|
|
623
|
+
apply: (added: PlannedChangeset[], held: PlannedChangeset[]) => Promise<void>;
|
|
624
|
+
/** Adds one pending changeset, as a person would with `pnpm changeset`. */
|
|
625
|
+
write: (changeset: PlannedChangeset) => Promise<void>;
|
|
626
|
+
/** Each workspace package's runtime workspace dependencies, by package name. */
|
|
627
|
+
dependencies: () => Promise<Record<string, string[]>>;
|
|
628
|
+
/** Each workspace package's folder, relative to the root, by package name. */
|
|
629
|
+
folders: () => Promise<Record<string, string>>;
|
|
630
|
+
/** A pending changeset's file, relative to the root. */
|
|
631
|
+
changesetFile: (id: string) => string;
|
|
632
|
+
/** The changelog a unit keeps, to read release notes from. */
|
|
633
|
+
changelogFile: (dir: string) => string;
|
|
634
|
+
}
|
|
635
|
+
//#endregion
|
|
636
|
+
//#region src/ports/mobile-distribution.port.d.ts
|
|
637
|
+
/**
|
|
638
|
+
* Ships a mobile app to the stores or over the air: EAS today. Its own platform knows what is live,
|
|
639
|
+
* decides between a binary and an update, and reports how a version does.
|
|
640
|
+
*/
|
|
641
|
+
interface MobileDistributionPort<Options = Record<string, unknown>> extends Delivery<Options> {
|
|
642
|
+
readonly capability: "mobile-distribution";
|
|
643
|
+
/** A store build, an over-the-air update, a choice for the person, or nothing. */
|
|
644
|
+
decide(context: DecideContext, input: JobInput<Options>): Promise<Decision>;
|
|
645
|
+
/**
|
|
646
|
+
* Files a release may change after the tag without changing what ships, such as the binary's
|
|
647
|
+
* version file. Relative to the root.
|
|
648
|
+
*/
|
|
649
|
+
versionFiles?(unit: ReleaseUnit, units: readonly ReleaseUnit[]): string[];
|
|
650
|
+
/** Adds to the release PR, given the app's bump in it when there is one. */
|
|
651
|
+
beforeVersion?(context: DecideContext, input: JobInput<Options> & {
|
|
652
|
+
bump: AppBump | undefined; /** The person's answer to its `choice`, once asked. */
|
|
653
|
+
chosen?: string;
|
|
654
|
+
}): Promise<VersionContribution>;
|
|
655
|
+
/** What `status --json` shows for the app, read from its platform. */
|
|
656
|
+
inspect?(context: DecideContext, input: JobInput<Options>): Promise<unknown>;
|
|
657
|
+
/** How the tagged version does on preview, read before promoting it. Null when nothing says. */
|
|
658
|
+
health?(context: DecideContext, input: JobInput<Options>): Promise<Health | null>;
|
|
659
|
+
}
|
|
660
|
+
//#endregion
|
|
661
|
+
//#region src/ports/package-registry.port.d.ts
|
|
662
|
+
/** Publishes a package and points a dist-tag at it: npm today. */
|
|
663
|
+
interface PackageRegistryPort<Options = Record<string, unknown>> extends Delivery<Options> {
|
|
664
|
+
readonly capability: "package-registry";
|
|
665
|
+
/** Publish, move a tag, or nothing: the registry, not GitHub Deployments, knows what is out. */
|
|
666
|
+
decide(context: DecideContext, input: JobInput<Options>): Promise<Decision>;
|
|
667
|
+
/** The version is out on the environment: published, and its dist-tag points at it. */
|
|
668
|
+
live(context: DecideContext, input: JobInput<Options>): Promise<boolean>;
|
|
669
|
+
}
|
|
670
|
+
//#endregion
|
|
671
|
+
//#region src/ports/server-hosting.port.d.ts
|
|
672
|
+
/** Runs a long-lived service, such as an API, from a tag: Fly.io today. */
|
|
673
|
+
interface ServerHostingPort<Options = Record<string, unknown>> extends Delivery<Options> {
|
|
674
|
+
readonly capability: "server-hosting";
|
|
675
|
+
}
|
|
676
|
+
//#endregion
|
|
677
|
+
//#region src/ports/static-hosting.port.d.ts
|
|
678
|
+
/** Serves a static build, built against its environment: Cloudflare Pages today. */
|
|
679
|
+
interface StaticHostingPort<Options = Record<string, unknown>> extends Delivery<Options> {
|
|
680
|
+
readonly capability: "static-hosting";
|
|
681
|
+
}
|
|
682
|
+
//#endregion
|
|
683
|
+
export { OpenPr as $, releaseSource as A, LinkedPr as B, Clock as C, StepPlace as D, Prompter as E, ShellResult as F, DeployPath as G, ActionsMinutes as H, CiPipelinePort as I, onlyVersionFiles as J, deployRunTitle as K, CodeHostPort as L, CommandFailed as M, RunOptions as N, SourceControlPort as O, Shell as P, MergeMethods as Q, Deploy as R, Choice as S, Progress as T, actionsMinutes as U, issueName as V, billedMinutes as W, Approval as X, DecidedBy as Y, MergeMethod as Z, Refusal as _, VersioningPort as a, UnreleasedApp as at, VersionChoice as b, DeliveryAdapter as c, ReleaseUnit as ct, DecideContext as d, MascotMoment as dt, ReleaseStep as et, Decision as f, Mood as ft, JobInput as g, Job as h, MobileDistributionPort as i, UnitRef as it, yesAllowed as j, GitPosition as k, ServiceAdapter as l, DisplayChoice as lt, Health as m, Environment as mt, ServerHostingPort as n, PlannedChangeset as nt, Adapter as o, appBumps as ot, Delivery as p, progressBar as pt, deployState as q, PackageRegistryPort as r, StatusPlan as rt, AdapterContext as s, splitChangesets as st, StaticHostingPort as t, AppBump as tt, Command as u, Mascot as ut, Requirement as v, Output as w, VersionContribution as x, Resolved as y, IssueRef as z };
|
|
684
|
+
//# sourceMappingURL=static-hosting.port-mknLsxwR.d.ts.map
|