shiplane 0.1.0 → 0.3.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-CTjB1v-Z.js} +70 -27
- package/dist/budget-CTjB1v-Z.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-oKnmZ8qV.d.ts +245 -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 +12 -5
- package/dist/plugin.js +8 -7
- package/dist/{readStatus-D5YVR5ZC.js → readStatus-Bo7hpUT3.js} +1397 -520
- package/dist/readStatus-Bo7hpUT3.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-CGASfBy2.js.map +1 -0
- package/dist/{index-QneBUiDD.d.ts → static-hosting.port-mknLsxwR.d.ts} +61 -244
- package/dist/testing.d.ts +60 -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/src-Dlr2Sgs8.js.map +0 -1
- package/dist/tags-DL74ni09.d.ts +0 -19
- package/dist/web-app.module-Bw-npC4Z.js.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as releaseFlow
|
|
2
|
-
import { C as
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
1
|
+
import { a as releaseFlow } from "./web-app.module-6KrXIU7j.js";
|
|
2
|
+
import { C as refreshEditorSchema, D as nodeFiles, T as ENVIRONMENTS, _ as loadRelease, a as releaseToPreview, b as initRelease, c as promote, f as openReleasePr, h as docsFor, i as setup, l as shipTo, m as newAdapter, n as systemShell, p as prepareRelease, t as readStatus, u as planShips, v as addUnit, w as optionsFor, x as doctor, y as removeUnit } from "./readStatus-Bo7hpUT3.js";
|
|
3
|
+
import { v as nextPatch, x as DEFAULT_TAG_FORMAT } from "./budget-CTjB1v-Z.js";
|
|
4
|
+
import { a as versioningFake, c as sourceControlFake, i as serverHostingFake, n as mobileDistributionFake, o as ciPipelineFake, r as staticHostingFake, s as codeHostFake, t as packageRegistryFake } from "./package-registry.fake-Ciqc4ujx.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
@@ -60,324 +60,6 @@ var RecordingShell = class {
|
|
|
60
60
|
attach = (command, args, options = {}) => Promise.resolve(this.answer(command, args, options).status);
|
|
61
61
|
};
|
|
62
62
|
//#endregion
|
|
63
|
-
//#region src/adapters/ci-pipeline/__fakes__/ci-pipeline.fake.ts
|
|
64
|
-
/** A CI pipeline held in memory: seed its runs and minutes, read back what was dispatched. */
|
|
65
|
-
var CiPipelineFake = class {
|
|
66
|
-
state = {
|
|
67
|
-
workflowRuns: {},
|
|
68
|
-
minutes: null,
|
|
69
|
-
measured: {}
|
|
70
|
-
};
|
|
71
|
-
received = [];
|
|
72
|
-
constructor(shipWorkflow = "ship.yml") {
|
|
73
|
-
this.shipWorkflow = shipWorkflow;
|
|
74
|
-
}
|
|
75
|
-
seed(state) {
|
|
76
|
-
this.state = {
|
|
77
|
-
...this.state,
|
|
78
|
-
...state
|
|
79
|
-
};
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
workflowRuns = (workflow) => Promise.resolve(this.state.workflowRuns[workflow] ?? []);
|
|
83
|
-
dispatch = (workflow, ref, inputs) => {
|
|
84
|
-
this.received.push({
|
|
85
|
-
type: "dispatch",
|
|
86
|
-
workflow,
|
|
87
|
-
ref,
|
|
88
|
-
inputs
|
|
89
|
-
});
|
|
90
|
-
return Promise.resolve();
|
|
91
|
-
};
|
|
92
|
-
minutes = () => Promise.resolve(this.state.minutes);
|
|
93
|
-
measuredMinutes = (workflow) => Promise.resolve(this.state.measured[workflow] ?? []);
|
|
94
|
-
};
|
|
95
|
-
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
96
|
-
const ciPipelineFake = (fake = new CiPipelineFake()) => ({
|
|
97
|
-
name: "fake",
|
|
98
|
-
create: () => fake,
|
|
99
|
-
fake
|
|
100
|
-
});
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/adapters/code-host/__fakes__/code-host.fake.ts
|
|
103
|
-
/** A code host held in memory: seed its pull requests and deploys, read back what it received. */
|
|
104
|
-
var CodeHostFake = class {
|
|
105
|
-
state = {
|
|
106
|
-
openPrs: [],
|
|
107
|
-
prStates: {},
|
|
108
|
-
merges: {
|
|
109
|
-
allowed: [
|
|
110
|
-
"--squash",
|
|
111
|
-
"--merge",
|
|
112
|
-
"--rebase"
|
|
113
|
-
],
|
|
114
|
-
preselected: "--squash"
|
|
115
|
-
},
|
|
116
|
-
releasedTags: [],
|
|
117
|
-
deployments: [],
|
|
118
|
-
nextPrNumber: 1800,
|
|
119
|
-
pullRequests: {},
|
|
120
|
-
comments: {}
|
|
121
|
-
};
|
|
122
|
-
received = [];
|
|
123
|
-
/** Each pull request number, once per state check. */
|
|
124
|
-
polled = [];
|
|
125
|
-
/** Each batched read of pull requests or comments, in order. */
|
|
126
|
-
reads = [];
|
|
127
|
-
seed(state) {
|
|
128
|
-
this.state = {
|
|
129
|
-
...this.state,
|
|
130
|
-
...state
|
|
131
|
-
};
|
|
132
|
-
return this;
|
|
133
|
-
}
|
|
134
|
-
openPrsFrom = (branchPrefix) => Promise.resolve(this.state.openPrs.filter(({ branch }) => branch.startsWith(branchPrefix)).map(({ pr }) => pr));
|
|
135
|
-
createPr = (pr) => {
|
|
136
|
-
const number = this.state.nextPrNumber++;
|
|
137
|
-
const created = {
|
|
138
|
-
number,
|
|
139
|
-
url: `https://github.com/acme/repo/pull/${number}`
|
|
140
|
-
};
|
|
141
|
-
this.received.push({
|
|
142
|
-
type: "pr",
|
|
143
|
-
pr: created,
|
|
144
|
-
...pr
|
|
145
|
-
});
|
|
146
|
-
this.state.openPrs.push({
|
|
147
|
-
branch: pr.head,
|
|
148
|
-
pr: created
|
|
149
|
-
});
|
|
150
|
-
return Promise.resolve(created);
|
|
151
|
-
};
|
|
152
|
-
closeError = null;
|
|
153
|
-
/** Every pull request close throws `error`. */
|
|
154
|
-
failClose(error) {
|
|
155
|
-
this.closeError = error;
|
|
156
|
-
return this;
|
|
157
|
-
}
|
|
158
|
-
closePr = (pr, comment) => {
|
|
159
|
-
if (this.closeError) return Promise.reject(this.closeError);
|
|
160
|
-
this.received.push({
|
|
161
|
-
type: "close",
|
|
162
|
-
pr,
|
|
163
|
-
comment
|
|
164
|
-
});
|
|
165
|
-
this.state.openPrs = this.state.openPrs.filter((open) => open.pr.number !== pr.number);
|
|
166
|
-
this.state.prStates[pr.number] = ["CLOSED"];
|
|
167
|
-
return Promise.resolve();
|
|
168
|
-
};
|
|
169
|
-
prState = (pr) => {
|
|
170
|
-
this.polled.push(pr.number);
|
|
171
|
-
const [state = "OPEN", ...rest] = this.state.prStates[pr.number] ?? ["OPEN"];
|
|
172
|
-
if (rest.length > 0) this.state.prStates[pr.number] = rest;
|
|
173
|
-
return Promise.resolve(state);
|
|
174
|
-
};
|
|
175
|
-
mergeMethods = () => Promise.resolve(this.state.merges);
|
|
176
|
-
merge = (pr, method) => {
|
|
177
|
-
this.received.push({
|
|
178
|
-
type: "merge",
|
|
179
|
-
pr,
|
|
180
|
-
method
|
|
181
|
-
});
|
|
182
|
-
this.state.prStates[pr.number] = ["MERGED"];
|
|
183
|
-
return Promise.resolve();
|
|
184
|
-
};
|
|
185
|
-
showDiff = () => Promise.resolve();
|
|
186
|
-
openInBrowser = () => Promise.resolve();
|
|
187
|
-
releasedTags = () => Promise.resolve(new Set(this.state.releasedTags));
|
|
188
|
-
releaseError = null;
|
|
189
|
-
/** Every release notes publish throws `error`. */
|
|
190
|
-
failRelease(error) {
|
|
191
|
-
this.releaseError = error;
|
|
192
|
-
return this;
|
|
193
|
-
}
|
|
194
|
-
createRelease = (tag, notes, latest) => {
|
|
195
|
-
if (this.releaseError) return Promise.reject(this.releaseError);
|
|
196
|
-
this.received.push({
|
|
197
|
-
type: "release",
|
|
198
|
-
tag,
|
|
199
|
-
notes,
|
|
200
|
-
latest
|
|
201
|
-
});
|
|
202
|
-
this.state.releasedTags.push(tag);
|
|
203
|
-
return Promise.resolve();
|
|
204
|
-
};
|
|
205
|
-
deployments = () => Promise.resolve(this.state.deployments);
|
|
206
|
-
recordDeployment = (ref, environment) => {
|
|
207
|
-
this.received.push({
|
|
208
|
-
type: "record",
|
|
209
|
-
ref,
|
|
210
|
-
environment
|
|
211
|
-
});
|
|
212
|
-
this.state.deployments.push({
|
|
213
|
-
title: `Deploy ${ref} to ${environment}`,
|
|
214
|
-
state: "done"
|
|
215
|
-
});
|
|
216
|
-
return Promise.resolve();
|
|
217
|
-
};
|
|
218
|
-
pullRequests = (numbers) => {
|
|
219
|
-
this.reads.push("pull-requests");
|
|
220
|
-
const missing = numbers.find((number) => !this.state.pullRequests[number]);
|
|
221
|
-
if (missing !== void 0) return Promise.reject(/* @__PURE__ */ new Error(`no pull request #${missing}`));
|
|
222
|
-
return Promise.resolve(numbers.flatMap((number) => this.state.pullRequests[number] ?? []));
|
|
223
|
-
};
|
|
224
|
-
comments = (on) => {
|
|
225
|
-
this.reads.push("comments");
|
|
226
|
-
return Promise.resolve(on.map((ref) => this.state.comments[issueName(ref)] ?? []));
|
|
227
|
-
};
|
|
228
|
-
commentError = null;
|
|
229
|
-
/** Every comment throws `error`. */
|
|
230
|
-
failComment(error) {
|
|
231
|
-
this.commentError = error;
|
|
232
|
-
return this;
|
|
233
|
-
}
|
|
234
|
-
comment = (on, body) => {
|
|
235
|
-
if (this.commentError) return Promise.reject(this.commentError);
|
|
236
|
-
this.received.push({
|
|
237
|
-
type: "comment",
|
|
238
|
-
issue: issueName(on),
|
|
239
|
-
body
|
|
240
|
-
});
|
|
241
|
-
this.state.comments[issueName(on)] = [...this.state.comments[issueName(on)] ?? [], body];
|
|
242
|
-
return Promise.resolve();
|
|
243
|
-
};
|
|
244
|
-
};
|
|
245
|
-
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
246
|
-
const codeHostFake = (fake = new CodeHostFake()) => ({
|
|
247
|
-
name: "fake",
|
|
248
|
-
create: () => fake,
|
|
249
|
-
fake
|
|
250
|
-
});
|
|
251
|
-
//#endregion
|
|
252
|
-
//#region src/adapters/source-control/__fakes__/source-control.fake.ts
|
|
253
|
-
/** A repository held in memory: seed what it contains, read back what it received. */
|
|
254
|
-
var SourceControlFake = class {
|
|
255
|
-
state = {
|
|
256
|
-
position: {
|
|
257
|
-
branch: "main",
|
|
258
|
-
head: "head",
|
|
259
|
-
originMain: "head"
|
|
260
|
-
},
|
|
261
|
-
clean: true,
|
|
262
|
-
tags: {},
|
|
263
|
-
versionCommits: {},
|
|
264
|
-
subjects: {},
|
|
265
|
-
files: {},
|
|
266
|
-
diffs: {},
|
|
267
|
-
commits: {},
|
|
268
|
-
changed: []
|
|
269
|
-
};
|
|
270
|
-
received = [];
|
|
271
|
-
failures = [];
|
|
272
|
-
seed(state) {
|
|
273
|
-
this.state = {
|
|
274
|
-
...this.state,
|
|
275
|
-
...state
|
|
276
|
-
};
|
|
277
|
-
return this;
|
|
278
|
-
}
|
|
279
|
-
/** The `nth` call of this kind throws `error`, after it is recorded. */
|
|
280
|
-
failAt(type, nth, error) {
|
|
281
|
-
this.failures.push({
|
|
282
|
-
type,
|
|
283
|
-
nth,
|
|
284
|
-
error
|
|
285
|
-
});
|
|
286
|
-
return this;
|
|
287
|
-
}
|
|
288
|
-
record(event) {
|
|
289
|
-
this.received.push(event);
|
|
290
|
-
const count = this.received.filter(({ type }) => type === event.type).length;
|
|
291
|
-
const failure = this.failures.find(({ type, nth }) => type === event.type && nth === count);
|
|
292
|
-
return failure ? Promise.reject(failure.error) : Promise.resolve();
|
|
293
|
-
}
|
|
294
|
-
position = () => Promise.resolve(this.state.position);
|
|
295
|
-
isClean = () => Promise.resolve(this.state.clean);
|
|
296
|
-
tagCommit = (tag) => Promise.resolve(this.state.tags[tag] ?? null);
|
|
297
|
-
versionCommit = (dir, _manifest, version) => Promise.resolve(this.state.versionCommits[`${dir}@${version}`] ?? null);
|
|
298
|
-
subjectsSince = (sha, dir) => Promise.resolve(this.state.subjects[`${sha}:${dir}`] ?? []);
|
|
299
|
-
changedFiles = () => Promise.resolve(this.state.changed);
|
|
300
|
-
diffNames = (from, to) => Promise.resolve(this.state.diffs[`${from}..${to}`] ?? []);
|
|
301
|
-
commitsBetween = (from, to) => Promise.resolve(this.state.commits[`${from}..${to}`] ?? []);
|
|
302
|
-
fileAt = (ref, file) => Promise.resolve(this.state.files[`${ref}:${file}`] ?? null);
|
|
303
|
-
tags = () => Promise.resolve(new Set(Object.keys(this.state.tags)));
|
|
304
|
-
createBranch = async (name) => {
|
|
305
|
-
await this.record({
|
|
306
|
-
type: "branch",
|
|
307
|
-
name
|
|
308
|
-
});
|
|
309
|
-
this.state.position = {
|
|
310
|
-
...this.state.position,
|
|
311
|
-
branch: name
|
|
312
|
-
};
|
|
313
|
-
};
|
|
314
|
-
switchTo = async (branch) => {
|
|
315
|
-
await this.record({
|
|
316
|
-
type: "switch",
|
|
317
|
-
branch
|
|
318
|
-
});
|
|
319
|
-
this.state.position = {
|
|
320
|
-
...this.state.position,
|
|
321
|
-
branch
|
|
322
|
-
};
|
|
323
|
-
};
|
|
324
|
-
commit = async (files, title, body) => {
|
|
325
|
-
await this.record({
|
|
326
|
-
type: "commit",
|
|
327
|
-
files,
|
|
328
|
-
title,
|
|
329
|
-
body
|
|
330
|
-
});
|
|
331
|
-
this.state.changed = this.state.changed.filter((file) => !files.includes(file));
|
|
332
|
-
};
|
|
333
|
-
push = (branch) => this.record({
|
|
334
|
-
type: "push",
|
|
335
|
-
branch
|
|
336
|
-
});
|
|
337
|
-
pull = () => this.record({ type: "pull" });
|
|
338
|
-
tag = async (name, sha, message) => {
|
|
339
|
-
await this.record({
|
|
340
|
-
type: "tag",
|
|
341
|
-
name,
|
|
342
|
-
sha,
|
|
343
|
-
message
|
|
344
|
-
});
|
|
345
|
-
this.state.tags[name] = sha;
|
|
346
|
-
};
|
|
347
|
-
pushTags = (names) => this.record({
|
|
348
|
-
type: "push-tags",
|
|
349
|
-
names
|
|
350
|
-
});
|
|
351
|
-
discard = async (files) => {
|
|
352
|
-
await this.record({
|
|
353
|
-
type: "discard",
|
|
354
|
-
files
|
|
355
|
-
});
|
|
356
|
-
this.state.changed = this.state.changed.filter((file) => !files.includes(file));
|
|
357
|
-
};
|
|
358
|
-
deleteBranch = (name) => this.record({
|
|
359
|
-
type: "delete-branch",
|
|
360
|
-
name
|
|
361
|
-
});
|
|
362
|
-
deleteRemoteBranch = (branch) => this.record({
|
|
363
|
-
type: "delete-remote",
|
|
364
|
-
branch
|
|
365
|
-
});
|
|
366
|
-
deleteTag = async (name) => {
|
|
367
|
-
await this.record({
|
|
368
|
-
type: "delete-tag",
|
|
369
|
-
name
|
|
370
|
-
});
|
|
371
|
-
this.state.tags = Object.fromEntries(Object.entries(this.state.tags).filter(([tag]) => tag !== name));
|
|
372
|
-
};
|
|
373
|
-
};
|
|
374
|
-
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
375
|
-
const sourceControlFake = (fake = new SourceControlFake()) => ({
|
|
376
|
-
name: "fake",
|
|
377
|
-
create: () => fake,
|
|
378
|
-
fake
|
|
379
|
-
});
|
|
380
|
-
//#endregion
|
|
381
63
|
//#region src/adapters/terminal/__fakes__/progress.fake.ts
|
|
382
64
|
/** Progress kept as events; what it says also goes to the output, as a terminal would print it. */
|
|
383
65
|
var RecordingProgress = class {
|
|
@@ -474,58 +156,6 @@ var FixedClock = class {
|
|
|
474
156
|
sleep = () => Promise.resolve();
|
|
475
157
|
};
|
|
476
158
|
//#endregion
|
|
477
|
-
//#region src/adapters/versioning/__fakes__/versioning.fake.ts
|
|
478
|
-
/** A changeset as its file reads: one `"package": bump` line each, then the summary. */
|
|
479
|
-
const changesetText$1 = ({ releases, summary }) => `---\n${releases.map(({ name, type }) => `"${name}": ${type}`).join("\n")}\n---\n\n${summary}\n`;
|
|
480
|
-
/** Versioning held in memory: seed the pending changes and the plan, read back what it received. */
|
|
481
|
-
var VersioningFake = class {
|
|
482
|
-
state = {
|
|
483
|
-
pending: [],
|
|
484
|
-
plan: () => ({
|
|
485
|
-
changesets: [],
|
|
486
|
-
releases: []
|
|
487
|
-
}),
|
|
488
|
-
dependencies: {},
|
|
489
|
-
folders: {}
|
|
490
|
-
};
|
|
491
|
-
applied = [];
|
|
492
|
-
written = [];
|
|
493
|
-
seed(state) {
|
|
494
|
-
this.state = {
|
|
495
|
-
...this.state,
|
|
496
|
-
...state
|
|
497
|
-
};
|
|
498
|
-
return this;
|
|
499
|
-
}
|
|
500
|
-
pending = () => Promise.resolve(this.state.pending);
|
|
501
|
-
plan = (added, held) => Promise.resolve(this.state.plan(added, held));
|
|
502
|
-
dependencies = () => Promise.resolve(this.state.dependencies);
|
|
503
|
-
folders = () => Promise.resolve(this.state.folders);
|
|
504
|
-
apply = (added, held) => {
|
|
505
|
-
this.applied.push({
|
|
506
|
-
added,
|
|
507
|
-
held
|
|
508
|
-
});
|
|
509
|
-
return Promise.resolve();
|
|
510
|
-
};
|
|
511
|
-
write = (changeset) => {
|
|
512
|
-
this.written.push(changeset);
|
|
513
|
-
this.state.pending = [...this.state.pending.filter(({ id }) => id !== changeset.id), {
|
|
514
|
-
id: changeset.id,
|
|
515
|
-
text: changesetText$1(changeset)
|
|
516
|
-
}];
|
|
517
|
-
return Promise.resolve();
|
|
518
|
-
};
|
|
519
|
-
changesetFile = (id) => `.changeset/${id}.md`;
|
|
520
|
-
changelogFile = (dir) => `${dir}/CHANGELOG.md`;
|
|
521
|
-
};
|
|
522
|
-
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
523
|
-
const versioningFake = (fake = new VersioningFake()) => ({
|
|
524
|
-
name: "fake",
|
|
525
|
-
create: () => fake,
|
|
526
|
-
fake
|
|
527
|
-
});
|
|
528
|
-
//#endregion
|
|
529
159
|
//#region src/testing/releaseContext.ts
|
|
530
160
|
const testUnit = (name, overrides = {}) => ({
|
|
531
161
|
name,
|
|
@@ -542,7 +172,7 @@ const testUnit = (name, overrides = {}) => ({
|
|
|
542
172
|
* A release over a Fake of every port the flow runs on, answered by a scripted person. The apps are
|
|
543
173
|
* in release order as given: the first is the Latest release.
|
|
544
174
|
*/
|
|
545
|
-
const testContext = ({ units, modules = [], features = [], yes = false, interactive = true, root = "/repo", tagFormat = DEFAULT_TAG_FORMAT, commitsWithoutChangeset = "release" }) => {
|
|
175
|
+
const testContext = ({ units, modules = [], features = [], yes = false, interactive = true, root = "/repo", tagFormat = DEFAULT_TAG_FORMAT, commitsWithoutChangeset = "release", approval }) => {
|
|
546
176
|
const sourceControl = sourceControlFake();
|
|
547
177
|
const codeHost = codeHostFake();
|
|
548
178
|
const ciPipeline = ciPipelineFake();
|
|
@@ -559,7 +189,10 @@ const testContext = ({ units, modules = [], features = [], yes = false, interact
|
|
|
559
189
|
};
|
|
560
190
|
const release = {
|
|
561
191
|
root,
|
|
562
|
-
flow: releaseFlow(
|
|
192
|
+
flow: releaseFlow({
|
|
193
|
+
...fakes,
|
|
194
|
+
approval
|
|
195
|
+
}),
|
|
563
196
|
modules,
|
|
564
197
|
features: typeof features === "function" ? features(fakes) : features,
|
|
565
198
|
units,
|
|
@@ -757,6 +390,7 @@ const codeHostContract = (name, subject) => describe(`${name}, as a code host`,
|
|
|
757
390
|
body: "Opened by the contract suite.",
|
|
758
391
|
label: "release"
|
|
759
392
|
});
|
|
393
|
+
expect(pr.head).toEqual(expect.any(String));
|
|
760
394
|
expect(await port.openPrsFrom("release/contract-open")).toContainEqual(pr);
|
|
761
395
|
expect(await port.prState(pr)).toBe("OPEN");
|
|
762
396
|
});
|
|
@@ -844,254 +478,6 @@ const versioningContract = (name, subject) => describe(`${name}, as versioning`,
|
|
|
844
478
|
});
|
|
845
479
|
});
|
|
846
480
|
//#endregion
|
|
847
|
-
//#region src/adapters/server-hosting/__fakes__/server-hosting.fake.ts
|
|
848
|
-
const ServerSettings = z.object({
|
|
849
|
-
service: z.string().describe("The service it deploys"),
|
|
850
|
-
url: perEnv(z.string()).optional().describe("Where it answers, for other apps to read")
|
|
851
|
-
});
|
|
852
|
-
const Resolved = z.object({ service: z.string() });
|
|
853
|
-
/** A server host held in memory: it deploys nothing, and records each deploy it was asked for. */
|
|
854
|
-
var ServerHostingFake = class {
|
|
855
|
-
capability = "server-hosting";
|
|
856
|
-
needs = [];
|
|
857
|
-
received = [];
|
|
858
|
-
/** What doctor checks for each app it ships. */
|
|
859
|
-
seed({ requirements }) {
|
|
860
|
-
this.needs = requirements;
|
|
861
|
-
return this;
|
|
862
|
-
}
|
|
863
|
-
describe = ({ options }) => `${Resolved.parse(options).service} (fake)`;
|
|
864
|
-
jobs = ({ tag, environment, options }) => {
|
|
865
|
-
const { service } = Resolved.parse(options);
|
|
866
|
-
this.received.push({
|
|
867
|
-
tag,
|
|
868
|
-
environment,
|
|
869
|
-
service
|
|
870
|
-
});
|
|
871
|
-
return [{
|
|
872
|
-
label: `deploy ${tag} to ${service} (fake)`,
|
|
873
|
-
local: [{
|
|
874
|
-
command: "echo",
|
|
875
|
-
args: [
|
|
876
|
-
"deploy",
|
|
877
|
-
service,
|
|
878
|
-
tag
|
|
879
|
-
]
|
|
880
|
-
}],
|
|
881
|
-
ci: { ref: tag },
|
|
882
|
-
record: true
|
|
883
|
-
}];
|
|
884
|
-
};
|
|
885
|
-
requirements = () => this.needs;
|
|
886
|
-
};
|
|
887
|
-
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
888
|
-
const serverHostingFake = (fake = new ServerHostingFake()) => ({
|
|
889
|
-
name: "fake",
|
|
890
|
-
capability: "server-hosting",
|
|
891
|
-
settings: ServerSettings,
|
|
892
|
-
typicalMinutes: 1,
|
|
893
|
-
requirements: () => fake.requirements(),
|
|
894
|
-
create: () => fake,
|
|
895
|
-
fake
|
|
896
|
-
});
|
|
897
|
-
//#endregion
|
|
898
|
-
//#region src/adapters/static-hosting/__fakes__/static-hosting.fake.ts
|
|
899
|
-
const StaticSettings = z.object({ site: z.string().describe("The site it uploads to") });
|
|
900
|
-
/** A static host held in memory: it uploads nothing, and records each upload it was asked for. */
|
|
901
|
-
var StaticHostingFake = class {
|
|
902
|
-
capability = "static-hosting";
|
|
903
|
-
needs = [];
|
|
904
|
-
received = [];
|
|
905
|
-
/** What doctor checks for each app it ships. */
|
|
906
|
-
seed({ requirements }) {
|
|
907
|
-
this.needs = requirements;
|
|
908
|
-
return this;
|
|
909
|
-
}
|
|
910
|
-
describe = ({ options, environment }) => `${StaticSettings.parse(options).site} (fake, ${environment})`;
|
|
911
|
-
jobs = ({ tag, environment, options }) => {
|
|
912
|
-
const { site } = StaticSettings.parse(options);
|
|
913
|
-
this.received.push({
|
|
914
|
-
tag,
|
|
915
|
-
environment,
|
|
916
|
-
site
|
|
917
|
-
});
|
|
918
|
-
return [{
|
|
919
|
-
label: `build ${tag} and upload it to ${site} (fake)`,
|
|
920
|
-
local: [{
|
|
921
|
-
command: "echo",
|
|
922
|
-
args: [
|
|
923
|
-
"upload",
|
|
924
|
-
site,
|
|
925
|
-
tag
|
|
926
|
-
]
|
|
927
|
-
}],
|
|
928
|
-
ci: { ref: tag },
|
|
929
|
-
record: true
|
|
930
|
-
}];
|
|
931
|
-
};
|
|
932
|
-
requirements = () => this.needs;
|
|
933
|
-
};
|
|
934
|
-
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
935
|
-
const staticHostingFake = (fake = new StaticHostingFake()) => ({
|
|
936
|
-
name: "fake",
|
|
937
|
-
capability: "static-hosting",
|
|
938
|
-
settings: StaticSettings,
|
|
939
|
-
typicalMinutes: 1,
|
|
940
|
-
requirements: () => fake.requirements(),
|
|
941
|
-
create: () => fake,
|
|
942
|
-
fake
|
|
943
|
-
});
|
|
944
|
-
//#endregion
|
|
945
|
-
//#region src/adapters/mobile-distribution/__fakes__/mobile-distribution.fake.ts
|
|
946
|
-
const MobileSettings = z.object({ app: z.string().describe("The app it ships to the stores and over the air") });
|
|
947
|
-
const DECIDED_BY = {
|
|
948
|
-
platform: "the fake platform",
|
|
949
|
-
choice: "update or nothing",
|
|
950
|
-
check: "shiplane status"
|
|
951
|
-
};
|
|
952
|
-
/**
|
|
953
|
-
* A mobile platform held in memory: seed what each environment runs and how a tag does; a version
|
|
954
|
-
* not live yet ships as an update.
|
|
955
|
-
*/
|
|
956
|
-
var MobileDistributionFake = class {
|
|
957
|
-
capability = "mobile-distribution";
|
|
958
|
-
state = {
|
|
959
|
-
live: {},
|
|
960
|
-
health: {},
|
|
961
|
-
requirements: []
|
|
962
|
-
};
|
|
963
|
-
received = [];
|
|
964
|
-
seed(state) {
|
|
965
|
-
this.state = {
|
|
966
|
-
...this.state,
|
|
967
|
-
...state
|
|
968
|
-
};
|
|
969
|
-
return this;
|
|
970
|
-
}
|
|
971
|
-
ask(stage, { tag, environment }) {
|
|
972
|
-
this.received.push({
|
|
973
|
-
stage,
|
|
974
|
-
tag,
|
|
975
|
-
environment
|
|
976
|
-
});
|
|
977
|
-
}
|
|
978
|
-
describe = ({ options, environment }) => `${MobileSettings.parse(options).app} on ${environment} (fake)`;
|
|
979
|
-
jobs = (input) => {
|
|
980
|
-
this.ask("jobs", input);
|
|
981
|
-
const { tag, environment, options } = input;
|
|
982
|
-
const { app } = MobileSettings.parse(options);
|
|
983
|
-
return [{
|
|
984
|
-
label: `publish ${tag} to ${app} on ${environment} (fake)`,
|
|
985
|
-
local: [{
|
|
986
|
-
command: "echo",
|
|
987
|
-
args: [
|
|
988
|
-
"update",
|
|
989
|
-
app,
|
|
990
|
-
tag
|
|
991
|
-
]
|
|
992
|
-
}],
|
|
993
|
-
ci: { ref: tag }
|
|
994
|
-
}];
|
|
995
|
-
};
|
|
996
|
-
decide = (_context, input) => {
|
|
997
|
-
this.ask("decide", input);
|
|
998
|
-
const { unit, environment } = input;
|
|
999
|
-
const decision = this.state.live[environment] === unit.version ? {
|
|
1000
|
-
action: "none",
|
|
1001
|
-
status: `${unit.name} ${unit.version} is on ${environment}`
|
|
1002
|
-
} : {
|
|
1003
|
-
action: "ship",
|
|
1004
|
-
kind: "update",
|
|
1005
|
-
jobs: this.jobs(input)
|
|
1006
|
-
};
|
|
1007
|
-
return Promise.resolve(decision);
|
|
1008
|
-
};
|
|
1009
|
-
health = (_context, input) => {
|
|
1010
|
-
this.ask("health", input);
|
|
1011
|
-
return Promise.resolve(this.state.health[input.tag] ?? null);
|
|
1012
|
-
};
|
|
1013
|
-
inspect = (_context, input) => {
|
|
1014
|
-
this.ask("inspect", input);
|
|
1015
|
-
return Promise.resolve({ live: this.state.live[input.environment] ?? null });
|
|
1016
|
-
};
|
|
1017
|
-
requirements = () => this.state.requirements;
|
|
1018
|
-
};
|
|
1019
|
-
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
1020
|
-
const mobileDistributionFake = (fake = new MobileDistributionFake()) => ({
|
|
1021
|
-
name: "fake",
|
|
1022
|
-
capability: "mobile-distribution",
|
|
1023
|
-
settings: MobileSettings,
|
|
1024
|
-
typicalMinutes: 1,
|
|
1025
|
-
decidedBy: DECIDED_BY,
|
|
1026
|
-
requirements: () => fake.requirements(),
|
|
1027
|
-
create: () => fake,
|
|
1028
|
-
fake
|
|
1029
|
-
});
|
|
1030
|
-
//#endregion
|
|
1031
|
-
//#region src/adapters/package-registry/__fakes__/package-registry.fake.ts
|
|
1032
|
-
const PackageSettings = z.object({ tag: z.string().default("latest").describe("The dist-tag a release moves") });
|
|
1033
|
-
/** A package registry held in memory: seed what is published, a version not there yet publishes. */
|
|
1034
|
-
var PackageRegistryFake = class {
|
|
1035
|
-
capability = "package-registry";
|
|
1036
|
-
/** `<package>@<version>` already published. */
|
|
1037
|
-
published = /* @__PURE__ */ new Set();
|
|
1038
|
-
needs = [];
|
|
1039
|
-
received = [];
|
|
1040
|
-
seed({ published = [], requirements = [] }) {
|
|
1041
|
-
this.published = new Set(published);
|
|
1042
|
-
this.needs = requirements;
|
|
1043
|
-
return this;
|
|
1044
|
-
}
|
|
1045
|
-
describe = ({ unit, options }) => `${unit.packageName} (fake, ${PackageSettings.parse(options).tag})`;
|
|
1046
|
-
jobs = ({ unit, tag, environment, options }) => {
|
|
1047
|
-
this.received.push({
|
|
1048
|
-
stage: "jobs",
|
|
1049
|
-
tag,
|
|
1050
|
-
environment
|
|
1051
|
-
});
|
|
1052
|
-
return [{
|
|
1053
|
-
label: `publish ${unit.packageName}@${unit.version} under ${PackageSettings.parse(options).tag} (fake)`,
|
|
1054
|
-
local: [{
|
|
1055
|
-
command: "echo",
|
|
1056
|
-
args: [
|
|
1057
|
-
"publish",
|
|
1058
|
-
unit.packageName,
|
|
1059
|
-
unit.version
|
|
1060
|
-
]
|
|
1061
|
-
}]
|
|
1062
|
-
}];
|
|
1063
|
-
};
|
|
1064
|
-
decide = (_context, input) => {
|
|
1065
|
-
const { unit, tag, environment } = input;
|
|
1066
|
-
this.received.push({
|
|
1067
|
-
stage: "decide",
|
|
1068
|
-
tag,
|
|
1069
|
-
environment
|
|
1070
|
-
});
|
|
1071
|
-
const decision = this.published.has(`${unit.packageName}@${unit.version}`) ? {
|
|
1072
|
-
action: "none",
|
|
1073
|
-
status: `${unit.packageName}@${unit.version} is published`
|
|
1074
|
-
} : {
|
|
1075
|
-
action: "ship",
|
|
1076
|
-
kind: "publish",
|
|
1077
|
-
jobs: this.jobs(input)
|
|
1078
|
-
};
|
|
1079
|
-
return Promise.resolve(decision);
|
|
1080
|
-
};
|
|
1081
|
-
live = (_context, { unit }) => Promise.resolve(this.published.has(`${unit.packageName}@${unit.version}`));
|
|
1082
|
-
requirements = () => this.needs;
|
|
1083
|
-
};
|
|
1084
|
-
/** The Fake as a config holds an adapter; `.fake` is what a test seeds and reads. */
|
|
1085
|
-
const packageRegistryFake = (fake = new PackageRegistryFake()) => ({
|
|
1086
|
-
name: "fake",
|
|
1087
|
-
capability: "package-registry",
|
|
1088
|
-
settings: PackageSettings,
|
|
1089
|
-
typicalMinutes: 1,
|
|
1090
|
-
requirements: () => fake.requirements(),
|
|
1091
|
-
create: () => fake,
|
|
1092
|
-
fake
|
|
1093
|
-
});
|
|
1094
|
-
//#endregion
|
|
1095
481
|
//#region src/testing/sample.ts
|
|
1096
482
|
/** This repository's four shipping units, as the rule tests were written against them. */
|
|
1097
483
|
const SAMPLE_UNITS = [
|
|
@@ -1344,6 +730,6 @@ const packageJson = (name, version = "1.0.0", extra = {}) => JSON.stringify({
|
|
|
1344
730
|
...extra
|
|
1345
731
|
}, null, 2);
|
|
1346
732
|
//#endregion
|
|
1347
|
-
export { LIVE, MemoryOutput, RecordingShell, SAMPLE_UNITS, SAMPLE_VERSION_FILES, SOURCE_ALIASES, ScriptedPrompter, addUnit, builtCli, changesetText, ciPipelineContract, ciPipelineFake, codeHostContract, codeHostFake, consumerRepository, createWorkspace, docsFor, doctor, inSandbox, initRelease, loadRelease, mobileDistributionContract, mobileDistributionFake, newAdapter, nodeFiles, openReleasePr, packageJson, packageRegistryContract, packageRegistryFake, planFrom, planShips, prepareRelease, promote, readStatus, refreshEditorSchema, releaseToPreview, removeUnit, sandbox, serverHostingContract, serverHostingFake, shipTo, sourceControlContract, sourceControlFake, staticHostingContract, staticHostingFake, systemShell, testContext, testUnit, versioningContract, versioningFake };
|
|
733
|
+
export { LIVE, MemoryOutput, RecordingShell, SAMPLE_UNITS, SAMPLE_VERSION_FILES, SOURCE_ALIASES, ScriptedPrompter, addUnit, builtCli, changesetText, ciPipelineContract, ciPipelineFake, codeHostContract, codeHostFake, consumerRepository, createWorkspace, docsFor, doctor, inSandbox, initRelease, loadRelease, mobileDistributionContract, mobileDistributionFake, newAdapter, nodeFiles, openReleasePr, packageJson, packageRegistryContract, packageRegistryFake, planFrom, planShips, prepareRelease, promote, readStatus, refreshEditorSchema, releaseToPreview, removeUnit, sandbox, serverHostingContract, serverHostingFake, setup, shipTo, sourceControlContract, sourceControlFake, staticHostingContract, staticHostingFake, systemShell, testContext, testUnit, versioningContract, versioningFake };
|
|
1348
734
|
|
|
1349
735
|
//# sourceMappingURL=testing.js.map
|