shiplane 0.1.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/dist/{budget-C8_aayQk.js → budget-BqtW-Ekk.js} +53 -26
- package/dist/budget-BqtW-Ekk.js.map +1 -0
- package/dist/cli.js +81 -36
- package/dist/cli.js.map +1 -1
- 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 -2
- package/dist/index.js +4 -3
- package/dist/{issues-C5fKq1Jv.js → issues-TcWtMTv5.js} +1 -1
- package/dist/{issues-C5fKq1Jv.js.map → issues-TcWtMTv5.js.map} +1 -1
- 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 +13 -5
- package/dist/plugin.js +7 -6
- package/dist/{readStatus-D5YVR5ZC.js → readStatus-YTZXH_Hh.js} +1387 -519
- package/dist/readStatus-YTZXH_Hh.js.map +1 -0
- package/dist/{shell-server-hosting.adapter-Bgl6-IWw.js → shell-server-hosting.adapter-DobfDqFm.js} +2 -2
- package/dist/{shell-server-hosting.adapter-Bgl6-IWw.js.map → shell-server-hosting.adapter-DobfDqFm.js.map} +1 -1
- package/dist/{src-Dlr2Sgs8.js → src-CGASfBy2.js} +3 -3
- package/dist/{src-Dlr2Sgs8.js.map → src-CGASfBy2.js.map} +1 -1
- package/dist/{index-QneBUiDD.d.ts → static-hosting.port-mknLsxwR.d.ts} +61 -244
- package/dist/{tags-DL74ni09.d.ts → tags-Bn3JrgPI.d.ts} +1 -1
- package/dist/testing.d.ts +61 -468
- package/dist/testing.js +11 -625
- package/dist/testing.js.map +1 -1
- package/dist/{web-app.module-Bw-npC4Z.js → web-app.module-6KrXIU7j.js} +4 -11
- package/dist/web-app.module-6KrXIU7j.js.map +1 -0
- package/package.json +6 -1
- package/dist/budget-C8_aayQk.js.map +0 -1
- package/dist/display-DM0xtQbT.js +0 -55
- package/dist/display-DM0xtQbT.js.map +0 -1
- package/dist/readStatus-D5YVR5ZC.js.map +0 -1
- package/dist/web-app.module-Bw-npC4Z.js.map +0 -1
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
import { t as perEnv } from "./perEnv-B7AiYnW_.js";
|
|
2
|
+
import { t as issueName } from "./issues-TcWtMTv5.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/adapters/source-control/__fakes__/source-control.fake.ts
|
|
5
|
+
/** A repository held in memory: seed what it contains, read back what it received. */
|
|
6
|
+
var SourceControlFake = class {
|
|
7
|
+
state = {
|
|
8
|
+
position: {
|
|
9
|
+
branch: "main",
|
|
10
|
+
head: "head",
|
|
11
|
+
originMain: "head"
|
|
12
|
+
},
|
|
13
|
+
clean: true,
|
|
14
|
+
tags: {},
|
|
15
|
+
versionCommits: {},
|
|
16
|
+
subjects: {},
|
|
17
|
+
files: {},
|
|
18
|
+
diffs: {},
|
|
19
|
+
commits: {},
|
|
20
|
+
changed: []
|
|
21
|
+
};
|
|
22
|
+
received = [];
|
|
23
|
+
failures = [];
|
|
24
|
+
seed(state) {
|
|
25
|
+
this.state = {
|
|
26
|
+
...this.state,
|
|
27
|
+
...state
|
|
28
|
+
};
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
/** The `nth` call of this kind throws `error`, after it is recorded. */
|
|
32
|
+
failAt(type, nth, error) {
|
|
33
|
+
this.failures.push({
|
|
34
|
+
type,
|
|
35
|
+
nth,
|
|
36
|
+
error
|
|
37
|
+
});
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
record(event) {
|
|
41
|
+
this.received.push(event);
|
|
42
|
+
const count = this.received.filter(({ type }) => type === event.type).length;
|
|
43
|
+
const failure = this.failures.find(({ type, nth }) => type === event.type && nth === count);
|
|
44
|
+
return failure ? Promise.reject(failure.error) : Promise.resolve();
|
|
45
|
+
}
|
|
46
|
+
position = () => Promise.resolve(this.state.position);
|
|
47
|
+
isClean = () => Promise.resolve(this.state.clean);
|
|
48
|
+
tagCommit = (tag) => Promise.resolve(this.state.tags[tag] ?? null);
|
|
49
|
+
versionCommit = (dir, _manifest, version) => Promise.resolve(this.state.versionCommits[`${dir}@${version}`] ?? null);
|
|
50
|
+
subjectsSince = (sha, dir) => Promise.resolve(this.state.subjects[`${sha}:${dir}`] ?? []);
|
|
51
|
+
changedFiles = () => Promise.resolve(this.state.changed);
|
|
52
|
+
diffNames = (from, to) => Promise.resolve(this.state.diffs[`${from}..${to}`] ?? []);
|
|
53
|
+
commitsBetween = (from, to) => Promise.resolve(this.state.commits[`${from}..${to}`] ?? []);
|
|
54
|
+
fileAt = (ref, file) => Promise.resolve(this.state.files[`${ref}:${file}`] ?? null);
|
|
55
|
+
tags = () => Promise.resolve(new Set(Object.keys(this.state.tags)));
|
|
56
|
+
createBranch = async (name) => {
|
|
57
|
+
await this.record({
|
|
58
|
+
type: "branch",
|
|
59
|
+
name
|
|
60
|
+
});
|
|
61
|
+
this.state.position = {
|
|
62
|
+
...this.state.position,
|
|
63
|
+
branch: name
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
switchTo = async (branch) => {
|
|
67
|
+
await this.record({
|
|
68
|
+
type: "switch",
|
|
69
|
+
branch
|
|
70
|
+
});
|
|
71
|
+
this.state.position = {
|
|
72
|
+
...this.state.position,
|
|
73
|
+
branch
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
commit = async (files, title, body, { skipHooks = false } = {}) => {
|
|
77
|
+
await this.record({
|
|
78
|
+
type: "commit",
|
|
79
|
+
files,
|
|
80
|
+
title,
|
|
81
|
+
body,
|
|
82
|
+
...skipHooks ? { skipHooks } : {}
|
|
83
|
+
});
|
|
84
|
+
this.state.changed = this.state.changed.filter((file) => !files.includes(file));
|
|
85
|
+
};
|
|
86
|
+
push = (branch) => this.record({
|
|
87
|
+
type: "push",
|
|
88
|
+
branch
|
|
89
|
+
});
|
|
90
|
+
pull = () => this.record({ type: "pull" });
|
|
91
|
+
tag = async (name, sha, message) => {
|
|
92
|
+
await this.record({
|
|
93
|
+
type: "tag",
|
|
94
|
+
name,
|
|
95
|
+
sha,
|
|
96
|
+
message
|
|
97
|
+
});
|
|
98
|
+
this.state.tags[name] = sha;
|
|
99
|
+
};
|
|
100
|
+
pushTags = (names) => this.record({
|
|
101
|
+
type: "push-tags",
|
|
102
|
+
names
|
|
103
|
+
});
|
|
104
|
+
discard = async (files) => {
|
|
105
|
+
await this.record({
|
|
106
|
+
type: "discard",
|
|
107
|
+
files
|
|
108
|
+
});
|
|
109
|
+
this.state.changed = this.state.changed.filter((file) => !files.includes(file));
|
|
110
|
+
};
|
|
111
|
+
deleteBranch = (name) => this.record({
|
|
112
|
+
type: "delete-branch",
|
|
113
|
+
name
|
|
114
|
+
});
|
|
115
|
+
deleteRemoteBranch = (branch) => this.record({
|
|
116
|
+
type: "delete-remote",
|
|
117
|
+
branch
|
|
118
|
+
});
|
|
119
|
+
deleteTag = async (name) => {
|
|
120
|
+
await this.record({
|
|
121
|
+
type: "delete-tag",
|
|
122
|
+
name
|
|
123
|
+
});
|
|
124
|
+
this.state.tags = Object.fromEntries(Object.entries(this.state.tags).filter(([tag]) => tag !== name));
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
128
|
+
const sourceControlFake = (fake = new SourceControlFake()) => ({
|
|
129
|
+
name: "fake",
|
|
130
|
+
create: () => fake,
|
|
131
|
+
fake
|
|
132
|
+
});
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/adapters/code-host/__fakes__/code-host.fake.ts
|
|
135
|
+
/** A code host held in memory: seed its pull requests and deploys, read back what it received. */
|
|
136
|
+
var CodeHostFake = class {
|
|
137
|
+
state = {
|
|
138
|
+
openPrs: [],
|
|
139
|
+
prStates: {},
|
|
140
|
+
merges: {
|
|
141
|
+
allowed: [
|
|
142
|
+
"--squash",
|
|
143
|
+
"--merge",
|
|
144
|
+
"--rebase"
|
|
145
|
+
],
|
|
146
|
+
preselected: "--squash"
|
|
147
|
+
},
|
|
148
|
+
releasedTags: [],
|
|
149
|
+
deployments: [],
|
|
150
|
+
nextPrNumber: 1800,
|
|
151
|
+
pullRequests: {},
|
|
152
|
+
comments: {}
|
|
153
|
+
};
|
|
154
|
+
received = [];
|
|
155
|
+
/** Each pull request number, once per state check. */
|
|
156
|
+
polled = [];
|
|
157
|
+
/** Each batched read of pull requests or comments, in order. */
|
|
158
|
+
reads = [];
|
|
159
|
+
seed(state) {
|
|
160
|
+
this.state = {
|
|
161
|
+
...this.state,
|
|
162
|
+
...state
|
|
163
|
+
};
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
openPrsFrom = (branchPrefix) => Promise.resolve(this.state.openPrs.filter(({ branch }) => branch.startsWith(branchPrefix)).map(({ pr }) => pr));
|
|
167
|
+
createError = null;
|
|
168
|
+
/** Every pull request open throws `error`. */
|
|
169
|
+
failCreate(error) {
|
|
170
|
+
this.createError = error;
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
createPr = (pr) => {
|
|
174
|
+
if (this.createError) return Promise.reject(this.createError);
|
|
175
|
+
const number = this.state.nextPrNumber++;
|
|
176
|
+
const created = {
|
|
177
|
+
number,
|
|
178
|
+
url: `https://github.com/acme/repo/pull/${number}`,
|
|
179
|
+
head: `sha-${number}`
|
|
180
|
+
};
|
|
181
|
+
this.received.push({
|
|
182
|
+
type: "pr",
|
|
183
|
+
pr: created,
|
|
184
|
+
...pr
|
|
185
|
+
});
|
|
186
|
+
this.state.openPrs.push({
|
|
187
|
+
branch: pr.head,
|
|
188
|
+
pr: created
|
|
189
|
+
});
|
|
190
|
+
return Promise.resolve(created);
|
|
191
|
+
};
|
|
192
|
+
closeError = null;
|
|
193
|
+
/** Every pull request close throws `error`. */
|
|
194
|
+
failClose(error) {
|
|
195
|
+
this.closeError = error;
|
|
196
|
+
return this;
|
|
197
|
+
}
|
|
198
|
+
closePr = (pr, comment) => {
|
|
199
|
+
if (this.closeError) return Promise.reject(this.closeError);
|
|
200
|
+
this.received.push({
|
|
201
|
+
type: "close",
|
|
202
|
+
pr,
|
|
203
|
+
comment
|
|
204
|
+
});
|
|
205
|
+
this.state.openPrs = this.state.openPrs.filter((open) => open.pr.number !== pr.number);
|
|
206
|
+
this.state.prStates[pr.number] = ["CLOSED"];
|
|
207
|
+
return Promise.resolve();
|
|
208
|
+
};
|
|
209
|
+
prState = (pr) => {
|
|
210
|
+
this.polled.push(pr.number);
|
|
211
|
+
const [state = "OPEN", ...rest] = this.state.prStates[pr.number] ?? ["OPEN"];
|
|
212
|
+
if (rest.length > 0) this.state.prStates[pr.number] = rest;
|
|
213
|
+
return Promise.resolve(state);
|
|
214
|
+
};
|
|
215
|
+
mergeMethods = () => Promise.resolve(this.state.merges);
|
|
216
|
+
merge = (pr, method) => {
|
|
217
|
+
this.received.push({
|
|
218
|
+
type: "merge",
|
|
219
|
+
pr,
|
|
220
|
+
method
|
|
221
|
+
});
|
|
222
|
+
this.state.prStates[pr.number] = ["MERGED"];
|
|
223
|
+
return Promise.resolve();
|
|
224
|
+
};
|
|
225
|
+
showDiff = () => Promise.resolve();
|
|
226
|
+
openInBrowser = () => Promise.resolve();
|
|
227
|
+
releasedTags = () => Promise.resolve(new Set(this.state.releasedTags));
|
|
228
|
+
releaseError = null;
|
|
229
|
+
/** Every release notes publish throws `error`. */
|
|
230
|
+
failRelease(error) {
|
|
231
|
+
this.releaseError = error;
|
|
232
|
+
return this;
|
|
233
|
+
}
|
|
234
|
+
createRelease = (tag, notes, latest) => {
|
|
235
|
+
if (this.releaseError) return Promise.reject(this.releaseError);
|
|
236
|
+
this.received.push({
|
|
237
|
+
type: "release",
|
|
238
|
+
tag,
|
|
239
|
+
notes,
|
|
240
|
+
latest
|
|
241
|
+
});
|
|
242
|
+
this.state.releasedTags.push(tag);
|
|
243
|
+
return Promise.resolve();
|
|
244
|
+
};
|
|
245
|
+
deployments = () => Promise.resolve(this.state.deployments);
|
|
246
|
+
recordDeployment = (ref, environment) => {
|
|
247
|
+
this.received.push({
|
|
248
|
+
type: "record",
|
|
249
|
+
ref,
|
|
250
|
+
environment
|
|
251
|
+
});
|
|
252
|
+
this.state.deployments.push({
|
|
253
|
+
title: `Deploy ${ref} to ${environment}`,
|
|
254
|
+
state: "done"
|
|
255
|
+
});
|
|
256
|
+
return Promise.resolve();
|
|
257
|
+
};
|
|
258
|
+
pullRequests = (numbers) => {
|
|
259
|
+
this.reads.push("pull-requests");
|
|
260
|
+
const missing = numbers.find((number) => !this.state.pullRequests[number]);
|
|
261
|
+
if (missing !== void 0) return Promise.reject(/* @__PURE__ */ new Error(`no pull request #${missing}`));
|
|
262
|
+
return Promise.resolve(numbers.flatMap((number) => this.state.pullRequests[number] ?? []));
|
|
263
|
+
};
|
|
264
|
+
comments = (on) => {
|
|
265
|
+
this.reads.push("comments");
|
|
266
|
+
return Promise.resolve(on.map((ref) => this.state.comments[issueName(ref)] ?? []));
|
|
267
|
+
};
|
|
268
|
+
commentError = null;
|
|
269
|
+
/** Every comment throws `error`. */
|
|
270
|
+
failComment(error) {
|
|
271
|
+
this.commentError = error;
|
|
272
|
+
return this;
|
|
273
|
+
}
|
|
274
|
+
comment = (on, body) => {
|
|
275
|
+
if (this.commentError) return Promise.reject(this.commentError);
|
|
276
|
+
this.received.push({
|
|
277
|
+
type: "comment",
|
|
278
|
+
issue: issueName(on),
|
|
279
|
+
body
|
|
280
|
+
});
|
|
281
|
+
this.state.comments[issueName(on)] = [...this.state.comments[issueName(on)] ?? [], body];
|
|
282
|
+
return Promise.resolve();
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
286
|
+
const codeHostFake = (fake = new CodeHostFake()) => ({
|
|
287
|
+
name: "fake",
|
|
288
|
+
create: () => fake,
|
|
289
|
+
fake
|
|
290
|
+
});
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/adapters/ci-pipeline/__fakes__/ci-pipeline.fake.ts
|
|
293
|
+
/** A CI pipeline held in memory: seed its runs and minutes, read back what was dispatched. */
|
|
294
|
+
var CiPipelineFake = class {
|
|
295
|
+
state = {
|
|
296
|
+
workflowRuns: {},
|
|
297
|
+
minutes: null,
|
|
298
|
+
measured: {}
|
|
299
|
+
};
|
|
300
|
+
received = [];
|
|
301
|
+
constructor(shipWorkflow = "ship.yml") {
|
|
302
|
+
this.shipWorkflow = shipWorkflow;
|
|
303
|
+
}
|
|
304
|
+
seed(state) {
|
|
305
|
+
this.state = {
|
|
306
|
+
...this.state,
|
|
307
|
+
...state
|
|
308
|
+
};
|
|
309
|
+
return this;
|
|
310
|
+
}
|
|
311
|
+
workflowRuns = (workflow) => Promise.resolve(this.state.workflowRuns[workflow] ?? []);
|
|
312
|
+
dispatch = (workflow, ref, inputs) => {
|
|
313
|
+
this.received.push({
|
|
314
|
+
type: "dispatch",
|
|
315
|
+
workflow,
|
|
316
|
+
ref,
|
|
317
|
+
inputs
|
|
318
|
+
});
|
|
319
|
+
return Promise.resolve();
|
|
320
|
+
};
|
|
321
|
+
minutes = () => Promise.resolve(this.state.minutes);
|
|
322
|
+
measuredMinutes = (workflow) => Promise.resolve(this.state.measured[workflow] ?? []);
|
|
323
|
+
};
|
|
324
|
+
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
325
|
+
const ciPipelineFake = (fake = new CiPipelineFake()) => ({
|
|
326
|
+
name: "fake",
|
|
327
|
+
create: () => fake,
|
|
328
|
+
fake
|
|
329
|
+
});
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region src/adapters/versioning/__fakes__/versioning.fake.ts
|
|
332
|
+
/** A changeset as its file reads: one `"package": bump` line each, then the summary. */
|
|
333
|
+
const changesetText = ({ releases, summary }) => `---\n${releases.map(({ name, type }) => `"${name}": ${type}`).join("\n")}\n---\n\n${summary}\n`;
|
|
334
|
+
/** Versioning held in memory: seed the pending changes and the plan, read back what it received. */
|
|
335
|
+
var VersioningFake = class {
|
|
336
|
+
state = {
|
|
337
|
+
pending: [],
|
|
338
|
+
plan: () => ({
|
|
339
|
+
changesets: [],
|
|
340
|
+
releases: []
|
|
341
|
+
}),
|
|
342
|
+
dependencies: {},
|
|
343
|
+
folders: {}
|
|
344
|
+
};
|
|
345
|
+
applied = [];
|
|
346
|
+
written = [];
|
|
347
|
+
seed(state) {
|
|
348
|
+
this.state = {
|
|
349
|
+
...this.state,
|
|
350
|
+
...state
|
|
351
|
+
};
|
|
352
|
+
return this;
|
|
353
|
+
}
|
|
354
|
+
pending = () => Promise.resolve(this.state.pending);
|
|
355
|
+
plan = (added, held) => Promise.resolve(this.state.plan(added, held));
|
|
356
|
+
dependencies = () => Promise.resolve(this.state.dependencies);
|
|
357
|
+
folders = () => Promise.resolve(this.state.folders);
|
|
358
|
+
apply = (added, held) => {
|
|
359
|
+
this.applied.push({
|
|
360
|
+
added,
|
|
361
|
+
held
|
|
362
|
+
});
|
|
363
|
+
return Promise.resolve();
|
|
364
|
+
};
|
|
365
|
+
write = (changeset) => {
|
|
366
|
+
this.written.push(changeset);
|
|
367
|
+
this.state.pending = [...this.state.pending.filter(({ id }) => id !== changeset.id), {
|
|
368
|
+
id: changeset.id,
|
|
369
|
+
text: changesetText(changeset)
|
|
370
|
+
}];
|
|
371
|
+
return Promise.resolve();
|
|
372
|
+
};
|
|
373
|
+
changesetFile = (id) => `.changeset/${id}.md`;
|
|
374
|
+
changelogFile = (dir) => `${dir}/CHANGELOG.md`;
|
|
375
|
+
};
|
|
376
|
+
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
377
|
+
const versioningFake = (fake = new VersioningFake()) => ({
|
|
378
|
+
name: "fake",
|
|
379
|
+
create: () => fake,
|
|
380
|
+
fake
|
|
381
|
+
});
|
|
382
|
+
//#endregion
|
|
383
|
+
//#region src/adapters/server-hosting/__fakes__/server-hosting.fake.ts
|
|
384
|
+
const ServerSettings = z.object({
|
|
385
|
+
service: z.string().describe("The service it deploys"),
|
|
386
|
+
url: perEnv(z.string()).optional().describe("Where it answers, for other apps to read")
|
|
387
|
+
});
|
|
388
|
+
const Resolved = z.object({ service: z.string() });
|
|
389
|
+
/** A server host held in memory: it deploys nothing, and records each deploy it was asked for. */
|
|
390
|
+
var ServerHostingFake = class {
|
|
391
|
+
capability = "server-hosting";
|
|
392
|
+
needs = [];
|
|
393
|
+
received = [];
|
|
394
|
+
/** What doctor checks for each app it ships. */
|
|
395
|
+
seed({ requirements }) {
|
|
396
|
+
this.needs = requirements;
|
|
397
|
+
return this;
|
|
398
|
+
}
|
|
399
|
+
describe = ({ options }) => `${Resolved.parse(options).service} (fake)`;
|
|
400
|
+
jobs = ({ tag, environment, options }) => {
|
|
401
|
+
const { service } = Resolved.parse(options);
|
|
402
|
+
this.received.push({
|
|
403
|
+
tag,
|
|
404
|
+
environment,
|
|
405
|
+
service
|
|
406
|
+
});
|
|
407
|
+
return [{
|
|
408
|
+
label: `deploy ${tag} to ${service} (fake)`,
|
|
409
|
+
local: [{
|
|
410
|
+
command: "echo",
|
|
411
|
+
args: [
|
|
412
|
+
"deploy",
|
|
413
|
+
service,
|
|
414
|
+
tag
|
|
415
|
+
]
|
|
416
|
+
}],
|
|
417
|
+
ci: { ref: tag },
|
|
418
|
+
record: true
|
|
419
|
+
}];
|
|
420
|
+
};
|
|
421
|
+
requirements = () => this.needs;
|
|
422
|
+
};
|
|
423
|
+
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
424
|
+
const serverHostingFake = (fake = new ServerHostingFake()) => ({
|
|
425
|
+
name: "fake",
|
|
426
|
+
capability: "server-hosting",
|
|
427
|
+
settings: ServerSettings,
|
|
428
|
+
typicalMinutes: 1,
|
|
429
|
+
requirements: () => fake.requirements(),
|
|
430
|
+
create: () => fake,
|
|
431
|
+
fake
|
|
432
|
+
});
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/adapters/static-hosting/__fakes__/static-hosting.fake.ts
|
|
435
|
+
const StaticSettings = z.object({ site: z.string().describe("The site it uploads to") });
|
|
436
|
+
/** A static host held in memory: it uploads nothing, and records each upload it was asked for. */
|
|
437
|
+
var StaticHostingFake = class {
|
|
438
|
+
capability = "static-hosting";
|
|
439
|
+
needs = [];
|
|
440
|
+
received = [];
|
|
441
|
+
/** What doctor checks for each app it ships. */
|
|
442
|
+
seed({ requirements }) {
|
|
443
|
+
this.needs = requirements;
|
|
444
|
+
return this;
|
|
445
|
+
}
|
|
446
|
+
describe = ({ options, environment }) => `${StaticSettings.parse(options).site} (fake, ${environment})`;
|
|
447
|
+
jobs = ({ tag, environment, options }) => {
|
|
448
|
+
const { site } = StaticSettings.parse(options);
|
|
449
|
+
this.received.push({
|
|
450
|
+
tag,
|
|
451
|
+
environment,
|
|
452
|
+
site
|
|
453
|
+
});
|
|
454
|
+
return [{
|
|
455
|
+
label: `build ${tag} and upload it to ${site} (fake)`,
|
|
456
|
+
local: [{
|
|
457
|
+
command: "echo",
|
|
458
|
+
args: [
|
|
459
|
+
"upload",
|
|
460
|
+
site,
|
|
461
|
+
tag
|
|
462
|
+
]
|
|
463
|
+
}],
|
|
464
|
+
ci: { ref: tag },
|
|
465
|
+
record: true
|
|
466
|
+
}];
|
|
467
|
+
};
|
|
468
|
+
requirements = () => this.needs;
|
|
469
|
+
};
|
|
470
|
+
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
471
|
+
const staticHostingFake = (fake = new StaticHostingFake()) => ({
|
|
472
|
+
name: "fake",
|
|
473
|
+
capability: "static-hosting",
|
|
474
|
+
settings: StaticSettings,
|
|
475
|
+
typicalMinutes: 1,
|
|
476
|
+
requirements: () => fake.requirements(),
|
|
477
|
+
create: () => fake,
|
|
478
|
+
fake
|
|
479
|
+
});
|
|
480
|
+
//#endregion
|
|
481
|
+
//#region src/adapters/mobile-distribution/__fakes__/mobile-distribution.fake.ts
|
|
482
|
+
const MobileSettings = z.object({ app: z.string().describe("The app it ships to the stores and over the air") });
|
|
483
|
+
const DECIDED_BY = {
|
|
484
|
+
platform: "the fake platform",
|
|
485
|
+
choice: "update or nothing",
|
|
486
|
+
check: "shiplane status"
|
|
487
|
+
};
|
|
488
|
+
/**
|
|
489
|
+
* A mobile platform held in memory: seed what each environment runs and how a tag does; a version
|
|
490
|
+
* not live yet ships as an update.
|
|
491
|
+
*/
|
|
492
|
+
var MobileDistributionFake = class {
|
|
493
|
+
capability = "mobile-distribution";
|
|
494
|
+
state = {
|
|
495
|
+
live: {},
|
|
496
|
+
health: {},
|
|
497
|
+
requirements: []
|
|
498
|
+
};
|
|
499
|
+
received = [];
|
|
500
|
+
seed(state) {
|
|
501
|
+
this.state = {
|
|
502
|
+
...this.state,
|
|
503
|
+
...state
|
|
504
|
+
};
|
|
505
|
+
return this;
|
|
506
|
+
}
|
|
507
|
+
ask(stage, { tag, environment }) {
|
|
508
|
+
this.received.push({
|
|
509
|
+
stage,
|
|
510
|
+
tag,
|
|
511
|
+
environment
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
describe = ({ options, environment }) => `${MobileSettings.parse(options).app} on ${environment} (fake)`;
|
|
515
|
+
jobs = (input) => {
|
|
516
|
+
this.ask("jobs", input);
|
|
517
|
+
const { tag, environment, options } = input;
|
|
518
|
+
const { app } = MobileSettings.parse(options);
|
|
519
|
+
return [{
|
|
520
|
+
label: `publish ${tag} to ${app} on ${environment} (fake)`,
|
|
521
|
+
local: [{
|
|
522
|
+
command: "echo",
|
|
523
|
+
args: [
|
|
524
|
+
"update",
|
|
525
|
+
app,
|
|
526
|
+
tag
|
|
527
|
+
]
|
|
528
|
+
}],
|
|
529
|
+
ci: { ref: tag }
|
|
530
|
+
}];
|
|
531
|
+
};
|
|
532
|
+
decide = (_context, input) => {
|
|
533
|
+
this.ask("decide", input);
|
|
534
|
+
const { unit, environment } = input;
|
|
535
|
+
const decision = this.state.live[environment] === unit.version ? {
|
|
536
|
+
action: "none",
|
|
537
|
+
status: `${unit.name} ${unit.version} is on ${environment}`
|
|
538
|
+
} : {
|
|
539
|
+
action: "ship",
|
|
540
|
+
kind: "update",
|
|
541
|
+
jobs: this.jobs(input)
|
|
542
|
+
};
|
|
543
|
+
return Promise.resolve(decision);
|
|
544
|
+
};
|
|
545
|
+
health = (_context, input) => {
|
|
546
|
+
this.ask("health", input);
|
|
547
|
+
return Promise.resolve(this.state.health[input.tag] ?? null);
|
|
548
|
+
};
|
|
549
|
+
inspect = (_context, input) => {
|
|
550
|
+
this.ask("inspect", input);
|
|
551
|
+
return Promise.resolve({ live: this.state.live[input.environment] ?? null });
|
|
552
|
+
};
|
|
553
|
+
requirements = () => this.state.requirements;
|
|
554
|
+
};
|
|
555
|
+
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
556
|
+
const mobileDistributionFake = (fake = new MobileDistributionFake()) => ({
|
|
557
|
+
name: "fake",
|
|
558
|
+
capability: "mobile-distribution",
|
|
559
|
+
settings: MobileSettings,
|
|
560
|
+
typicalMinutes: 1,
|
|
561
|
+
decidedBy: DECIDED_BY,
|
|
562
|
+
requirements: () => fake.requirements(),
|
|
563
|
+
create: () => fake,
|
|
564
|
+
fake
|
|
565
|
+
});
|
|
566
|
+
//#endregion
|
|
567
|
+
//#region src/adapters/package-registry/__fakes__/package-registry.fake.ts
|
|
568
|
+
const PackageSettings = z.object({ tag: z.string().default("latest").describe("The dist-tag a release moves") });
|
|
569
|
+
/** A package registry held in memory: seed what is published, a version not there yet publishes. */
|
|
570
|
+
var PackageRegistryFake = class {
|
|
571
|
+
capability = "package-registry";
|
|
572
|
+
/** `<package>@<version>` already published. */
|
|
573
|
+
published = /* @__PURE__ */ new Set();
|
|
574
|
+
needs = [];
|
|
575
|
+
received = [];
|
|
576
|
+
seed({ published = [], requirements = [] }) {
|
|
577
|
+
this.published = new Set(published);
|
|
578
|
+
this.needs = requirements;
|
|
579
|
+
return this;
|
|
580
|
+
}
|
|
581
|
+
describe = ({ unit, options }) => `${unit.packageName} (fake, ${PackageSettings.parse(options).tag})`;
|
|
582
|
+
jobs = ({ unit, tag, environment, options }) => {
|
|
583
|
+
this.received.push({
|
|
584
|
+
stage: "jobs",
|
|
585
|
+
tag,
|
|
586
|
+
environment
|
|
587
|
+
});
|
|
588
|
+
return [{
|
|
589
|
+
label: `publish ${unit.packageName}@${unit.version} under ${PackageSettings.parse(options).tag} (fake)`,
|
|
590
|
+
local: [{
|
|
591
|
+
command: "echo",
|
|
592
|
+
args: [
|
|
593
|
+
"publish",
|
|
594
|
+
unit.packageName,
|
|
595
|
+
unit.version
|
|
596
|
+
]
|
|
597
|
+
}]
|
|
598
|
+
}];
|
|
599
|
+
};
|
|
600
|
+
decide = (_context, input) => {
|
|
601
|
+
const { unit, tag, environment } = input;
|
|
602
|
+
this.received.push({
|
|
603
|
+
stage: "decide",
|
|
604
|
+
tag,
|
|
605
|
+
environment
|
|
606
|
+
});
|
|
607
|
+
const decision = this.published.has(`${unit.packageName}@${unit.version}`) ? {
|
|
608
|
+
action: "none",
|
|
609
|
+
status: `${unit.packageName}@${unit.version} is published`
|
|
610
|
+
} : {
|
|
611
|
+
action: "ship",
|
|
612
|
+
kind: "publish",
|
|
613
|
+
jobs: this.jobs(input)
|
|
614
|
+
};
|
|
615
|
+
return Promise.resolve(decision);
|
|
616
|
+
};
|
|
617
|
+
live = (_context, { unit }) => Promise.resolve(this.published.has(`${unit.packageName}@${unit.version}`));
|
|
618
|
+
requirements = () => this.needs;
|
|
619
|
+
};
|
|
620
|
+
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
621
|
+
const packageRegistryFake = (fake = new PackageRegistryFake()) => ({
|
|
622
|
+
name: "fake",
|
|
623
|
+
capability: "package-registry",
|
|
624
|
+
settings: PackageSettings,
|
|
625
|
+
typicalMinutes: 1,
|
|
626
|
+
requirements: () => fake.requirements(),
|
|
627
|
+
create: () => fake,
|
|
628
|
+
fake
|
|
629
|
+
});
|
|
630
|
+
//#endregion
|
|
631
|
+
export { versioningFake as a, sourceControlFake as c, serverHostingFake as i, mobileDistributionFake as n, ciPipelineFake as o, staticHostingFake as r, codeHostFake as s, packageRegistryFake as t };
|
|
632
|
+
|
|
633
|
+
//# sourceMappingURL=package-registry.fake-Ciqc4ujx.js.map
|