shiplane 0.5.2 → 0.6.0-fix-shiplane-ship-node-cache.3dccda9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.js +157 -312
- package/dist/cli.js.map +1 -1
- package/dist/{readStatus-DypM0faL.js → compose-BTQXZqHM.js} +2758 -1448
- package/dist/compose-BTQXZqHM.js.map +1 -0
- package/dist/{budget-BTnKtGF6.js → display-CfV4G1TR.js} +155 -52
- package/dist/display-CfV4G1TR.js.map +1 -0
- package/dist/{static-hosting.port-B5i6W7eD.d.ts → index-B1Rd22nM.d.ts} +482 -21
- package/dist/index.d.ts +2 -3
- package/dist/index.js +3 -4
- package/dist/{issues-TcWtMTv5.js → issues-DCRpXUBW.js} +1 -1
- package/dist/{issues-TcWtMTv5.js.map → issues-DCRpXUBW.js.map} +1 -1
- package/dist/memory.d.ts +1 -1
- package/dist/memory.js +1 -1
- package/dist/{package-registry.fake-BLBdd7IQ.d.ts → package-registry.fake-CjoePEzE.d.ts} +53 -6
- package/dist/{package-registry.fake-CN6M1-Gi.js → package-registry.fake-ykiSBd8M.js} +58 -6
- package/dist/package-registry.fake-ykiSBd8M.js.map +1 -0
- package/dist/plugin-D-JQhwVd.d.ts +118 -0
- package/dist/plugin.d.ts +3 -23
- package/dist/plugin.js +84 -7
- package/dist/plugin.js.map +1 -0
- package/dist/shell-server-hosting.adapter-CvOcC6Wh.js +369 -0
- package/dist/shell-server-hosting.adapter-CvOcC6Wh.js.map +1 -0
- package/dist/{src-DO7WyrfV.js → src-8BbKTQBb.js} +2 -2
- package/dist/src-8BbKTQBb.js.map +1 -0
- package/dist/testing.d.ts +103 -18
- package/dist/testing.js +235 -22
- package/dist/testing.js.map +1 -1
- package/package.json +2 -1
- package/dist/budget-BTnKtGF6.js.map +0 -1
- package/dist/display-IqkJ6uCw.js +0 -96
- package/dist/display-IqkJ6uCw.js.map +0 -1
- package/dist/index-C_urG4yY.d.ts +0 -252
- package/dist/package-registry.fake-CN6M1-Gi.js.map +0 -1
- package/dist/readStatus-DypM0faL.js.map +0 -1
- package/dist/shell-server-hosting.adapter-C7_5MWrl.js +0 -50
- package/dist/shell-server-hosting.adapter-C7_5MWrl.js.map +0 -1
- package/dist/src-DO7WyrfV.js.map +0 -1
- package/dist/web-app.module-BB1fY1Kd.js +0 -125
- package/dist/web-app.module-BB1fY1Kd.js.map +0 -1
package/dist/testing.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as VersioningFake, c as ciPipelineFake, d as codeHostFake, f as SourceControlFake, i as serverHostingFake, l as CodeHostFake, n as mobileDistributionFake, o as versioningFake, p as sourceControlFake, r as staticHostingFake, s as CiPipelineFake, t as packageRegistryFake, u as HostEvent } from "./package-registry.fake-BLBdd7IQ.js";
|
|
1
|
+
import { $ as StepPlace, At as StatusPlan, C as Feature, D as ReleaseModule, Dt as AppBump, E as ReleaseFlow, Et as ReleaseStep, Ft as TestReleaseBranches, J as Choice, Jt as ReleaseUnit, K as VersionContribution, L as Delivery, M as DeliveryAdapter, N as ServiceAdapter, Nt as splitChangesets, Ot as BumpLevel, Q as Prompter, St as Approval, T as Open, Tt as OpenPr, X as Output, Y as Clock, Z as Progress, Zt as DisplayChoice, _ as MobileDistributionPort, at as RunOptions, en as Mood, et as SourceControlPort, ft as IssueRef, g as PackageRegistryPort, h as ServerHostingPort, jt as UnitRef, k as VersioningPort, kt as PlannedChangeset, lt as CiPipelinePort, m as StaticHostingPort, nn as Environment, ot as Shell, q as BatchPlace, st as ShellResult, ut as CodeHostPort, v as OnDefault, vt as DeployPath, zt as ReleaseTag } from "./index-B1Rd22nM.js";
|
|
2
|
+
import { a as VersioningFake, c as ciPipelineFake, d as codeHostFake, f as SourceControlFake, i as serverHostingFake, l as CodeHostFake, n as mobileDistributionFake, o as versioningFake, p as sourceControlFake, r as staticHostingFake, s as CiPipelineFake, t as packageRegistryFake, u as HostEvent } from "./package-registry.fake-CjoePEzE.js";
|
|
4
3
|
import { z } from "zod";
|
|
5
4
|
import * as _$vitest from "vitest";
|
|
6
5
|
|
|
@@ -11,6 +10,8 @@ interface ContractCase<Port extends Delivery & {
|
|
|
11
10
|
}> {
|
|
12
11
|
adapter: DeliveryAdapter<Port>;
|
|
13
12
|
settings: Record<string, unknown>;
|
|
13
|
+
/** False when its decision reads a platform the contract's empty fakes cannot answer. */
|
|
14
|
+
decide?: boolean;
|
|
14
15
|
}
|
|
15
16
|
//#endregion
|
|
16
17
|
//#region src/adapters/server-hosting/server-hosting.contract.d.ts
|
|
@@ -92,6 +93,8 @@ declare class RecordingShell implements Shell {
|
|
|
92
93
|
private variables;
|
|
93
94
|
seedEnv(variables: Record<string, string>): this;
|
|
94
95
|
env: (name: string) => string;
|
|
96
|
+
/** Puts a folder first on the seeded PATH, as the system shell does to its process. */
|
|
97
|
+
prependPath: (dir: string) => void;
|
|
95
98
|
/** Answers every call whose `command args` line starts with `prefix`. */
|
|
96
99
|
seed(prefix: string, result: Partial<ShellResult>): this;
|
|
97
100
|
/** Answers the next call starting with `prefix` only, ahead of what `seed` answers. */
|
|
@@ -101,6 +104,25 @@ declare class RecordingShell implements Shell {
|
|
|
101
104
|
attach: (command: string, args: readonly string[], options?: RunOptions) => Promise<number>;
|
|
102
105
|
}
|
|
103
106
|
//#endregion
|
|
107
|
+
//#region src/testing/platformEnvContract.d.ts
|
|
108
|
+
/** One adapter's env, with the shells that answer its listing: one that lists, one that fails. */
|
|
109
|
+
interface PlatformEnvCase {
|
|
110
|
+
adapter: DeliveryAdapter<{
|
|
111
|
+
capability: string;
|
|
112
|
+
}>;
|
|
113
|
+
settings: Record<string, unknown>;
|
|
114
|
+
environment: Environment;
|
|
115
|
+
/** A shell whose listing holds `names`. */
|
|
116
|
+
listing: {
|
|
117
|
+
shell: RecordingShell;
|
|
118
|
+
names: readonly string[];
|
|
119
|
+
};
|
|
120
|
+
/** A shell whose listing fails, signed out or offline. */
|
|
121
|
+
failing: RecordingShell;
|
|
122
|
+
}
|
|
123
|
+
/** What every platform env does, whatever its provider: list names only, and say how to set them. */
|
|
124
|
+
declare const platformEnvContract: (cases: PlatformEnvCase[]) => void;
|
|
125
|
+
//#endregion
|
|
104
126
|
//#region src/adapters/terminal/__fakes__/terminal.fake.d.ts
|
|
105
127
|
/** Everything the CLI printed, in order, without colours. */
|
|
106
128
|
declare class MemoryOutput implements Output {
|
|
@@ -138,6 +160,11 @@ interface Files {
|
|
|
138
160
|
exists: (file: string) => boolean;
|
|
139
161
|
read: (file: string) => string | null;
|
|
140
162
|
write: (file: string, text: string) => void;
|
|
163
|
+
/**
|
|
164
|
+
* Adds text at the end of a file, made when missing. An absolute path may sit outside the
|
|
165
|
+
* repository, such as a runner's `GITHUB_STEP_SUMMARY`.
|
|
166
|
+
*/
|
|
167
|
+
append: (file: string, text: string) => void;
|
|
141
168
|
remove: (file: string) => void;
|
|
142
169
|
/** Entries directly in a folder; empty when it does not exist. */
|
|
143
170
|
list: (dir: string) => string[];
|
|
@@ -145,6 +172,28 @@ interface Files {
|
|
|
145
172
|
folders: (dir: string) => string[];
|
|
146
173
|
}
|
|
147
174
|
//#endregion
|
|
175
|
+
//#region src/adapters/files/__fakes__/memory-files.fake.d.ts
|
|
176
|
+
/** A repository held in memory, one entry per file: nothing touches the disk. */
|
|
177
|
+
declare class MemoryFiles implements Files {
|
|
178
|
+
private readonly texts;
|
|
179
|
+
/** Every write and removal, in order, for a test to read back. */
|
|
180
|
+
readonly changes: {
|
|
181
|
+
kind: "write" | "remove";
|
|
182
|
+
file: string;
|
|
183
|
+
}[];
|
|
184
|
+
constructor(files?: Record<string, string>);
|
|
185
|
+
private entries;
|
|
186
|
+
exists: (file: string) => boolean;
|
|
187
|
+
read: (file: string) => string | null;
|
|
188
|
+
write: (file: string, text: string) => void;
|
|
189
|
+
append: (file: string, text: string) => void;
|
|
190
|
+
remove: (file: string) => void;
|
|
191
|
+
list: (dir: string) => string[];
|
|
192
|
+
folders: (dir: string) => string[];
|
|
193
|
+
/** Every file, as a snapshot a test compares before and after. */
|
|
194
|
+
get all(): Record<string, string>;
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
148
197
|
//#region src/adapters/files/node-files.adapter.d.ts
|
|
149
198
|
/** The repository on disk, under `root`. */
|
|
150
199
|
declare const nodeFiles: (root: string) => Files;
|
|
@@ -153,7 +202,7 @@ declare const nodeFiles: (root: string) => Files;
|
|
|
153
202
|
declare const systemShell: Shell;
|
|
154
203
|
//#endregion
|
|
155
204
|
//#region src/modules/suggest.d.ts
|
|
156
|
-
/** An adapter of any delivery port, as `
|
|
205
|
+
/** An adapter of any delivery port, as `setup` offers them. */
|
|
157
206
|
type AnyDeliveryAdapter = DeliveryAdapter<ServerHostingPort> | DeliveryAdapter<StaticHostingPort> | DeliveryAdapter<MobileDistributionPort> | DeliveryAdapter<PackageRegistryPort>;
|
|
158
207
|
//#endregion
|
|
159
208
|
//#region src/ports/manifest.port.d.ts
|
|
@@ -195,21 +244,25 @@ interface Release {
|
|
|
195
244
|
problems: ConfigProblem[];
|
|
196
245
|
/** How a tag names a version, such as `{name}@{version}`. */
|
|
197
246
|
tagFormat: string;
|
|
247
|
+
/** How a unit ships when both ways can, as the config asks; unset, each ship asks. */
|
|
248
|
+
via?: DeployPath;
|
|
198
249
|
/** How much the release says while it runs, as the config asks. */
|
|
199
250
|
display?: DisplayChoice;
|
|
200
251
|
/** Files still under their name from before shiplane. */
|
|
201
252
|
renames?: Rename[];
|
|
253
|
+
/** The template of a test version's pull request comment; `comments.table` when unset. */
|
|
254
|
+
testComment?: string;
|
|
255
|
+
/** Which channel each branch's test release publishes on; unset, every branch a snapshot. */
|
|
256
|
+
testRelease?: TestReleaseBranches;
|
|
257
|
+
/** Run from the root before each unit ships from this machine, its placeholders filled. */
|
|
258
|
+
prepare?: string;
|
|
202
259
|
}
|
|
203
260
|
interface LoadOptions {
|
|
204
261
|
/** Where `shiplane` resolves from inside the config; by default, this very package. */
|
|
205
262
|
aliases?: Record<string, string>;
|
|
206
|
-
|
|
263
|
+
/** Where each unit's name and version come from: its package.json, as `cli/compose` wires it. */
|
|
264
|
+
manifests: ManifestReader;
|
|
207
265
|
}
|
|
208
|
-
/**
|
|
209
|
-
* The release as written: what `shiplane.config.ts` composes, and one app per folder that holds a
|
|
210
|
-
* `shiplane.unit.yml`, in release order. Every problem is collected, never thrown.
|
|
211
|
-
*/
|
|
212
|
-
declare const loadRelease: (root: string, options?: LoadOptions) => Promise<Release>;
|
|
213
266
|
//#endregion
|
|
214
267
|
//#region src/application/context.d.ts
|
|
215
268
|
/** Everything a use case reads and drives: the release as written, its services, the person. */
|
|
@@ -227,6 +280,8 @@ interface ReleaseContext {
|
|
|
227
280
|
clock: Clock;
|
|
228
281
|
/** Runs the jobs plugins return, when they run from this machine. */
|
|
229
282
|
shell: Shell;
|
|
283
|
+
/** The repository's files, as a branch release writes and puts back its versions. */
|
|
284
|
+
files: Files;
|
|
230
285
|
options: {
|
|
231
286
|
/** Answers yes to every confirmation; production never accepts it. */yes: boolean; /** Running inside GitHub Actions: a ship runs on this runner, never dispatching another. */
|
|
232
287
|
ci: boolean;
|
|
@@ -241,7 +296,7 @@ interface Services {
|
|
|
241
296
|
}
|
|
242
297
|
//#endregion
|
|
243
298
|
//#region src/application/setupContext.d.ts
|
|
244
|
-
/** What setting a release up needs: the repository, the person, the adapters
|
|
299
|
+
/** What setting a release up needs: the repository, the person, the adapters setup can offer. */
|
|
245
300
|
interface SetupContext {
|
|
246
301
|
root: string;
|
|
247
302
|
files: Files;
|
|
@@ -256,6 +311,8 @@ interface SetupContext {
|
|
|
256
311
|
progress?: Progress;
|
|
257
312
|
/** A release's context, for the rehearsal's plan; without it, the plan is not rehearsed. */
|
|
258
313
|
compose?: (release: Release) => ReleaseContext;
|
|
314
|
+
/** The shiplane running, which the caller workflow pins; none is written or checked without it. */
|
|
315
|
+
version?: string;
|
|
259
316
|
}
|
|
260
317
|
//#endregion
|
|
261
318
|
//#region src/application/addUnit.d.ts
|
|
@@ -264,6 +321,27 @@ declare const addUnit: (context: SetupContext, dir: string) => Promise<boolean>;
|
|
|
264
321
|
/** `shiplane remove <unit>`: its unit file goes; changesets still version it. */
|
|
265
322
|
declare const removeUnit: (context: SetupContext, name: string) => Promise<boolean>;
|
|
266
323
|
//#endregion
|
|
324
|
+
//#region src/application/branchRelease.d.ts
|
|
325
|
+
/**
|
|
326
|
+
* `shiplane` where it runs: on the default branch, the real release; elsewhere, or for `shiplane
|
|
327
|
+
* test-release`, a test version of the npm packages the pending changesets release, on the branch's
|
|
328
|
+
* channel (a snapshot unless `testRelease` says otherwise), commented on its pull request when it
|
|
329
|
+
* has one. False when refused or failed.
|
|
330
|
+
*/
|
|
331
|
+
declare const branchRelease: (context: ReleaseContext, {
|
|
332
|
+
onDefault,
|
|
333
|
+
channel: picked,
|
|
334
|
+
dryRun
|
|
335
|
+
}: {
|
|
336
|
+
onDefault: OnDefault; /** The channel for this run, over the one `testRelease` gives the branch. */
|
|
337
|
+
channel?: string; /** Show what would publish, at which versions and tag, and publish nothing. */
|
|
338
|
+
dryRun?: boolean;
|
|
339
|
+
}) => Promise<boolean>;
|
|
340
|
+
//#endregion
|
|
341
|
+
//#region src/cli/compose.d.ts
|
|
342
|
+
/** The release as written on disk, each unit's name and version read from its package.json. */
|
|
343
|
+
declare const loadReleaseOnDisk: (root: string, options?: Partial<LoadOptions>) => Promise<Release>;
|
|
344
|
+
//#endregion
|
|
267
345
|
//#region src/application/docsFor.d.ts
|
|
268
346
|
/**
|
|
269
347
|
* `shiplane docs <module or adapter>`: every key a unit file takes, described, with its default. A
|
|
@@ -275,9 +353,13 @@ declare const docsFor: (context: SetupContext, name: string) => Promise<boolean>
|
|
|
275
353
|
/**
|
|
276
354
|
* `shiplane doctor`: the config as written, the editor schema refreshed, the release order, a warning
|
|
277
355
|
* for each module no app names, then every tool and sign-in the flow, modules and features need, each
|
|
278
|
-
* failure with the command that fixes it, offered to run.
|
|
356
|
+
* failure with the command that fixes it, offered to run, and the workflow that ships on CI.
|
|
279
357
|
*/
|
|
280
|
-
declare const doctor: (context: SetupContext
|
|
358
|
+
declare const doctor: (context: SetupContext, {
|
|
359
|
+
yes
|
|
360
|
+
}?: {
|
|
361
|
+
yes: boolean;
|
|
362
|
+
}) => Promise<boolean>;
|
|
281
363
|
//#endregion
|
|
282
364
|
//#region src/application/initRelease.d.ts
|
|
283
365
|
/**
|
|
@@ -351,7 +433,8 @@ declare const prepareRelease: (context: ReleaseContext, scope: ReadonlySet<strin
|
|
|
351
433
|
//#endregion
|
|
352
434
|
//#region src/application/openReleasePr.d.ts
|
|
353
435
|
/**
|
|
354
|
-
* Versions what `prepared` covers on one branch from
|
|
436
|
+
* Versions what `prepared` covers on one branch from the default branch, opens its PR, and goes
|
|
437
|
+
* back to it.
|
|
355
438
|
* Null, with what to do, when it must not run.
|
|
356
439
|
*/
|
|
357
440
|
declare const openReleasePr: (context: ReleaseContext, prepared: Prepared, /** Release PRs this one takes the place of, named at the top of its description. */
|
|
@@ -360,7 +443,7 @@ replaces?: readonly OpenPr[]) => Promise<OpenPr[] | null>;
|
|
|
360
443
|
//#endregion
|
|
361
444
|
//#region src/application/planShips.d.ts
|
|
362
445
|
/**
|
|
363
|
-
*
|
|
446
|
+
* `--dry-run`: every command shipping the current tags would run, both ways, in release order,
|
|
364
447
|
* then what the features would do. It runs nothing and asks nothing; it reads git, and the code host
|
|
365
448
|
* for features.
|
|
366
449
|
*/
|
|
@@ -501,7 +584,8 @@ declare const testContext: ({
|
|
|
501
584
|
interactive,
|
|
502
585
|
root,
|
|
503
586
|
tagFormat,
|
|
504
|
-
approval
|
|
587
|
+
approval,
|
|
588
|
+
files
|
|
505
589
|
}: {
|
|
506
590
|
units: ReleaseUnit[];
|
|
507
591
|
modules?: ReleaseModule[]; /** The features, or how to make them from the flow's Fakes they share. */
|
|
@@ -510,7 +594,8 @@ declare const testContext: ({
|
|
|
510
594
|
interactive?: boolean;
|
|
511
595
|
root?: string;
|
|
512
596
|
tagFormat?: string; /** Whether someone else approves the release PR; the config default when absent. */
|
|
513
|
-
approval?: Approval;
|
|
597
|
+
approval?: Approval; /** The repository's files; empty when absent. */
|
|
598
|
+
files?: Files;
|
|
514
599
|
}) => {
|
|
515
600
|
context: ReleaseContext;
|
|
516
601
|
flow: {
|
|
@@ -590,5 +675,5 @@ interface Workspace {
|
|
|
590
675
|
declare const createWorkspace: (files: Record<string, string>) => Workspace;
|
|
591
676
|
declare const packageJson: (name: string, version?: string, extra?: object) => string;
|
|
592
677
|
//#endregion
|
|
593
|
-
export { type CliRun, type ConsumerRepository, type HostEvent, LIVE, MemoryOutput, RecordingShell, SAMPLE_UNITS, SAMPLE_VERSION_FILES, SOURCE_ALIASES, ScriptedPrompter, type SetupContext, type Workspace, 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 };
|
|
678
|
+
export { type CliRun, type ConsumerRepository, type HostEvent, LIVE, MemoryFiles, MemoryOutput, type PlatformEnvCase, RecordingShell, SAMPLE_UNITS, SAMPLE_VERSION_FILES, SOURCE_ALIASES, ScriptedPrompter, type SetupContext, type Workspace, addUnit, branchRelease, builtCli, changesetText, ciPipelineContract, ciPipelineFake, codeHostContract, codeHostFake, consumerRepository, createWorkspace, docsFor, doctor, inSandbox, initRelease, loadReleaseOnDisk as loadRelease, mobileDistributionContract, mobileDistributionFake, newAdapter, nodeFiles, openReleasePr, packageJson, packageRegistryContract, packageRegistryFake, planFrom, planShips, platformEnvContract, prepareRelease, promote, readStatus, refreshEditorSchema, releaseToPreview, removeUnit, sandbox, serverHostingContract, serverHostingFake, setup, shipTo, sourceControlContract, sourceControlFake, staticHostingContract, staticHostingFake, systemShell, testContext, testUnit, versioningContract, versioningFake };
|
|
594
679
|
//# sourceMappingURL=testing.d.ts.map
|
package/dist/testing.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as
|
|
3
|
-
import {
|
|
4
|
-
import { a as versioningFake, c as sourceControlFake, i as serverHostingFake, n as mobileDistributionFake, o as
|
|
1
|
+
import { O as isEnvVarName, o as releaseFlow } from "./shell-server-hosting.adapter-CvOcC6Wh.js";
|
|
2
|
+
import { C as initRelease, E as refreshEditorSchema, I as nodeFiles, M as optionsFor, P as ENVIRONMENTS, S as removeUnit, b as prepareRelease, c as promote, d as docsFor, f as branchRelease, h as readStatus, i as coreDir, l as planShips, m as shipTo, o as systemShell, p as releaseToPreview, r as loadReleaseOnDisk, s as setup, u as newAdapter, w as doctor, x as addUnit, y as openReleasePr } from "./compose-BTQXZqHM.js";
|
|
3
|
+
import { j as nextVersion, y as DEFAULT_TAG_FORMAT } from "./display-CfV4G1TR.js";
|
|
4
|
+
import { a as versioningFake, c as CodeHostFake, d as sourceControlFake, i as serverHostingFake, l as codeHostFake, n as mobileDistributionFake, o as CiPipelineFake, r as staticHostingFake, s as ciPipelineFake, t as packageRegistryFake, u as SourceControlFake } from "./package-registry.fake-ykiSBd8M.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
|
+
import os from "node:os";
|
|
8
9
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
9
10
|
import { describe, expect, it } from "vitest";
|
|
10
|
-
import os from "node:os";
|
|
11
11
|
//#region src/adapters/shell/__fakes__/shell.fake.ts
|
|
12
12
|
/** A shell that runs nothing: it keeps every call and answers from what was seeded. */
|
|
13
13
|
var RecordingShell = class {
|
|
@@ -22,6 +22,11 @@ var RecordingShell = class {
|
|
|
22
22
|
return this;
|
|
23
23
|
}
|
|
24
24
|
env = (name) => this.variables[name];
|
|
25
|
+
/** Puts a folder first on the seeded PATH, as the system shell does to its process. */
|
|
26
|
+
prependPath = (dir) => {
|
|
27
|
+
const { PATH } = this.variables;
|
|
28
|
+
this.variables.PATH = PATH ? `${dir}:${PATH}` : dir;
|
|
29
|
+
};
|
|
25
30
|
/** Answers every call whose `command args` line starts with `prefix`. */
|
|
26
31
|
seed(prefix, result) {
|
|
27
32
|
this.answers.push({
|
|
@@ -60,6 +65,87 @@ var RecordingShell = class {
|
|
|
60
65
|
attach = (command, args, options = {}) => Promise.resolve(this.answer(command, args, options).status);
|
|
61
66
|
};
|
|
62
67
|
//#endregion
|
|
68
|
+
//#region src/testing/decideContract.ts
|
|
69
|
+
const ACTIONS = new Set([
|
|
70
|
+
"ship",
|
|
71
|
+
"none",
|
|
72
|
+
"choose",
|
|
73
|
+
"fail",
|
|
74
|
+
"pull-request"
|
|
75
|
+
]);
|
|
76
|
+
const decides = (port) => "decide" in port && typeof port.decide === "function";
|
|
77
|
+
/** A repository with nothing tagged yet, its tools answering empty, on the contract's fakes. */
|
|
78
|
+
const freshContext = (unit) => {
|
|
79
|
+
const shell = new RecordingShell();
|
|
80
|
+
return {
|
|
81
|
+
root: "/repo",
|
|
82
|
+
shell,
|
|
83
|
+
sourceControl: new SourceControlFake(),
|
|
84
|
+
codeHost: new CodeHostFake(),
|
|
85
|
+
ciPipeline: new CiPipelineFake(),
|
|
86
|
+
units: [unit],
|
|
87
|
+
tagFormat: DEFAULT_TAG_FORMAT,
|
|
88
|
+
versionFiles: /* @__PURE__ */ new Set(),
|
|
89
|
+
changedCode: () => Promise.resolve([]),
|
|
90
|
+
now: () => /* @__PURE__ */ new Date("2026-01-01T00:00:00Z"),
|
|
91
|
+
open: (adapter) => adapter.create({
|
|
92
|
+
root: "/repo",
|
|
93
|
+
shell
|
|
94
|
+
})
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
/** What a deciding port does on a repository with nothing tagged: it says so, and nothing is live. */
|
|
98
|
+
const decideContract = ({ port, unit, input }) => {
|
|
99
|
+
it("given a version never tagged, when the adapter decides, then it answers one of the decisions the release flow knows", async () => {
|
|
100
|
+
const decision = await port.decide(freshContext(unit), input);
|
|
101
|
+
expect(ACTIONS.has(decision.action)).toBe(true);
|
|
102
|
+
});
|
|
103
|
+
it("given a version never tagged, when the adapter says whether it is live, then it is not", async () => {
|
|
104
|
+
expect(await (port.live?.(freshContext(unit), input) ?? false)).toBe(false);
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/adapters/files/__fakes__/memory-files.fake.ts
|
|
109
|
+
/** A repository held in memory, one entry per file: nothing touches the disk. */
|
|
110
|
+
var MemoryFiles = class {
|
|
111
|
+
texts = /* @__PURE__ */ new Map();
|
|
112
|
+
/** Every write and removal, in order, for a test to read back. */
|
|
113
|
+
changes = [];
|
|
114
|
+
constructor(files = {}) {
|
|
115
|
+
Object.entries(files).forEach(([file, text]) => this.texts.set(path.posix.normalize(file), text));
|
|
116
|
+
}
|
|
117
|
+
entries(dir) {
|
|
118
|
+
const prefix = dir === "." || dir === "" ? "" : `${path.posix.normalize(dir)}/`;
|
|
119
|
+
return [...this.texts.keys()].filter((file) => file.startsWith(prefix)).map((file) => file.slice(prefix.length).split("/"));
|
|
120
|
+
}
|
|
121
|
+
exists = (file) => {
|
|
122
|
+
const at = path.posix.normalize(file);
|
|
123
|
+
return this.texts.has(at) || [...this.texts.keys()].some((key) => key.startsWith(`${at}/`));
|
|
124
|
+
};
|
|
125
|
+
read = (file) => this.texts.get(path.posix.normalize(file)) ?? null;
|
|
126
|
+
write = (file, text) => {
|
|
127
|
+
this.texts.set(path.posix.normalize(file), text);
|
|
128
|
+
this.changes.push({
|
|
129
|
+
kind: "write",
|
|
130
|
+
file
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
append = (file, text) => this.write(file, `${this.read(file) ?? ""}${text}`);
|
|
134
|
+
remove = (file) => {
|
|
135
|
+
this.texts.delete(path.posix.normalize(file));
|
|
136
|
+
this.changes.push({
|
|
137
|
+
kind: "remove",
|
|
138
|
+
file
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
list = (dir) => [...new Set(this.entries(dir).map(([first = ""]) => first))].sort();
|
|
142
|
+
folders = (dir) => [...new Set(this.entries(dir).filter((parts) => parts.length > 1).map(([first = ""]) => first))].sort();
|
|
143
|
+
/** Every file, as a snapshot a test compares before and after. */
|
|
144
|
+
get all() {
|
|
145
|
+
return Object.fromEntries([...this.texts].sort(([a], [b]) => a.localeCompare(b)));
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
//#endregion
|
|
63
149
|
//#region src/adapters/terminal/__fakes__/progress.fake.ts
|
|
64
150
|
/** Progress kept as events; what it says also goes to the output, as a terminal would print it. */
|
|
65
151
|
var RecordingProgress = class {
|
|
@@ -177,7 +263,7 @@ const testUnit = (name, overrides = {}) => ({
|
|
|
177
263
|
* A release over a Fake of every port the flow runs on, answered by a scripted person. The apps are
|
|
178
264
|
* in release order as given: the first is the Latest release.
|
|
179
265
|
*/
|
|
180
|
-
const testContext = ({ units, modules = [], features = [], yes = false, interactive = true, root = "/repo", tagFormat = DEFAULT_TAG_FORMAT, approval }) => {
|
|
266
|
+
const testContext = ({ units, modules = [], features = [], yes = false, interactive = true, root = "/repo", tagFormat = DEFAULT_TAG_FORMAT, approval, files = new MemoryFiles() }) => {
|
|
181
267
|
const sourceControl = sourceControlFake();
|
|
182
268
|
const codeHost = codeHostFake();
|
|
183
269
|
const ciPipeline = ciPipelineFake();
|
|
@@ -223,6 +309,7 @@ const testContext = ({ units, modules = [], features = [], yes = false, interact
|
|
|
223
309
|
progress,
|
|
224
310
|
clock: new FixedClock(/* @__PURE__ */ new Date("2026-10-12T09:00:00Z")),
|
|
225
311
|
shell,
|
|
312
|
+
files,
|
|
226
313
|
options: {
|
|
227
314
|
yes,
|
|
228
315
|
ci: false
|
|
@@ -250,7 +337,7 @@ const EMPTY_FOLDER = {
|
|
|
250
337
|
read: () => null
|
|
251
338
|
};
|
|
252
339
|
/** What every adapter of a delivery port must do, whatever its provider; `more` adds the port's own. */
|
|
253
|
-
const deliveryContract = (kind, cases, more = () => void 0) => describe.each(cases.map((entry) => [entry.adapter.name, entry]))(`%s, as ${kind}`, (_name, { adapter, settings }) => {
|
|
340
|
+
const deliveryContract = (kind, cases, more = () => void 0) => describe.each(cases.map((entry) => [entry.adapter.name, entry]))(`%s, as ${kind}`, (_name, { adapter, settings, decide = true }) => {
|
|
254
341
|
const port = adapter.create({
|
|
255
342
|
root: "/repo",
|
|
256
343
|
shell: new RecordingShell()
|
|
@@ -267,7 +354,8 @@ const deliveryContract = (kind, cases, more = () => void 0) => describe.each(cas
|
|
|
267
354
|
...unit,
|
|
268
355
|
options: adapter.settings.parse(settings)
|
|
269
356
|
}, environment, [unit]),
|
|
270
|
-
commit: "abc1234"
|
|
357
|
+
commit: "abc1234",
|
|
358
|
+
defaultBranch: "main"
|
|
271
359
|
});
|
|
272
360
|
it("given an app's settings, when its unit file is read, then the adapter's schema takes them", () => {
|
|
273
361
|
expect(adapter.settings.safeParse(settings).success).toBe(true);
|
|
@@ -282,7 +370,7 @@ const deliveryContract = (kind, cases, more = () => void 0) => describe.each(cas
|
|
|
282
370
|
job.local.forEach(({ command }) => expect(command.trim()).not.toBe(""));
|
|
283
371
|
}));
|
|
284
372
|
});
|
|
285
|
-
it("given a folder with nothing in it, when
|
|
373
|
+
it("given a folder with nothing in it, when setup looks at it, then the adapter recognises nothing", () => {
|
|
286
374
|
expect(adapter.detect?.(EMPTY_FOLDER) ?? null).toBeNull();
|
|
287
375
|
});
|
|
288
376
|
it("given an app it ships, when doctor asks what it needs, then each need has a name and a check", () => {
|
|
@@ -291,6 +379,11 @@ const deliveryContract = (kind, cases, more = () => void 0) => describe.each(cas
|
|
|
291
379
|
expect(check.command.trim()).not.toBe("");
|
|
292
380
|
});
|
|
293
381
|
});
|
|
382
|
+
if (decide && decides(port)) decideContract({
|
|
383
|
+
port,
|
|
384
|
+
unit,
|
|
385
|
+
input: inputFor("preview")
|
|
386
|
+
});
|
|
294
387
|
more(adapter, port);
|
|
295
388
|
});
|
|
296
389
|
//#endregion
|
|
@@ -328,6 +421,8 @@ const packageRegistryContract = (cases) => deliveryContract("a package registry"
|
|
|
328
421
|
});
|
|
329
422
|
//#endregion
|
|
330
423
|
//#region src/adapters/source-control/source-control.contract.ts
|
|
424
|
+
let worktrees = 0;
|
|
425
|
+
const tmpWorktree = () => path.join(os.tmpdir(), `shiplane-contract-worktree-${process.pid}-${worktrees += 1}`);
|
|
331
426
|
/** What every source control does, whatever its provider. */
|
|
332
427
|
const sourceControlContract = (name, subject) => describe(`${name}, as source control`, () => {
|
|
333
428
|
it("given a fresh checkout, when its position is read, then it is on main with nothing to commit", async () => {
|
|
@@ -335,6 +430,10 @@ const sourceControlContract = (name, subject) => describe(`${name}, as source co
|
|
|
335
430
|
expect((await port.position()).branch).toBe("main");
|
|
336
431
|
expect(await port.isClean()).toBe(true);
|
|
337
432
|
});
|
|
433
|
+
it("given a fresh checkout of main, when its default branch is read, then it is main", async () => {
|
|
434
|
+
const { port } = await subject();
|
|
435
|
+
expect(await port.defaultBranch()).toBe("main");
|
|
436
|
+
});
|
|
338
437
|
it("given a commit tagged, when the tags are read, then the tag is there and names that commit", async () => {
|
|
339
438
|
const { port, head } = await subject();
|
|
340
439
|
const sha = await head();
|
|
@@ -379,6 +478,35 @@ const sourceControlContract = (name, subject) => describe(`${name}, as source co
|
|
|
379
478
|
expect(before).toContain("notes.md");
|
|
380
479
|
expect(await port.changedFiles()).not.toContain("notes.md");
|
|
381
480
|
});
|
|
481
|
+
it("given a branch and main each one commit ahead, when their merge base is read, then it is where the branch started", async () => {
|
|
482
|
+
const { port, change, head } = await subject();
|
|
483
|
+
const start = await head();
|
|
484
|
+
await port.createBranch("feat/x");
|
|
485
|
+
await change("feature.md", "feature\n");
|
|
486
|
+
await port.commit(["feature.md"], "feat: x");
|
|
487
|
+
const branch = await head();
|
|
488
|
+
await port.switchTo("main");
|
|
489
|
+
await change("main.md", "main\n");
|
|
490
|
+
await port.commit(["main.md"], "chore: main moves");
|
|
491
|
+
expect(await port.mergeBase?.(await head(), branch)).toBe(start);
|
|
492
|
+
});
|
|
493
|
+
it("given an env file git ignores, when the ignored files are listed by pattern, then only it is listed", async () => {
|
|
494
|
+
const { port, change } = await subject();
|
|
495
|
+
await change(".gitignore", ".env*\n");
|
|
496
|
+
await port.commit([".gitignore"], "chore: ignore env files");
|
|
497
|
+
await change(".env.local", "TOKEN=1\n");
|
|
498
|
+
await change("notes.md", "notes\n");
|
|
499
|
+
expect(await port.ignoredFiles([".env*"])).toEqual([".env.local"]);
|
|
500
|
+
});
|
|
501
|
+
it("given a tag, when a worktree is added at it and removed, then it lists nothing more and the checkout stays on main", async () => {
|
|
502
|
+
const { port, head } = await subject();
|
|
503
|
+
await port.tag("app@1.0.0", await head(), "app 1.0.0");
|
|
504
|
+
const dir = tmpWorktree();
|
|
505
|
+
await port.addWorktree(dir, "app@1.0.0");
|
|
506
|
+
await port.removeWorktree(dir);
|
|
507
|
+
expect((await port.position()).branch).toBe("main");
|
|
508
|
+
expect(await port.isClean()).toBe(true);
|
|
509
|
+
});
|
|
382
510
|
});
|
|
383
511
|
//#endregion
|
|
384
512
|
//#region src/adapters/code-host/code-host.contract.ts
|
|
@@ -412,12 +540,62 @@ const codeHostContract = (name, subject) => describe(`${name}, as a code host`,
|
|
|
412
540
|
expect(await port.openPrsFrom("release/contract-close")).not.toContainEqual(pr);
|
|
413
541
|
expect(await port.prState(pr)).toBe("CLOSED");
|
|
414
542
|
});
|
|
543
|
+
it("given a branch with an open pull request, when its pull request is read, then it is that one; another branch has none", async () => {
|
|
544
|
+
const { port, branch } = await subject();
|
|
545
|
+
const head = await branch("release/contract-for-branch");
|
|
546
|
+
const pr = await port.createPr({
|
|
547
|
+
base: "main",
|
|
548
|
+
head,
|
|
549
|
+
title: "chore: contract",
|
|
550
|
+
body: "Opened by the contract suite.",
|
|
551
|
+
label: "release"
|
|
552
|
+
});
|
|
553
|
+
expect(await port.prForBranch(head)).toMatchObject({
|
|
554
|
+
number: pr.number,
|
|
555
|
+
url: pr.url
|
|
556
|
+
});
|
|
557
|
+
expect(await port.prForBranch(`${head}-none`)).toBeNull();
|
|
558
|
+
});
|
|
559
|
+
it("given a comment upserted twice with one marker, when the comments are read, then there is one, holding the second body", async () => {
|
|
560
|
+
const { port, branch } = await subject();
|
|
561
|
+
const head = await branch("release/contract-upsert");
|
|
562
|
+
const pr = await port.createPr({
|
|
563
|
+
base: "main",
|
|
564
|
+
head,
|
|
565
|
+
title: "chore: contract",
|
|
566
|
+
body: "Opened by the contract suite.",
|
|
567
|
+
label: "release"
|
|
568
|
+
});
|
|
569
|
+
const marker = `<!-- contract:${Date.now()} -->`;
|
|
570
|
+
const ref = {
|
|
571
|
+
repository: new URL(pr.url).pathname.split("/").slice(1, 3).join("/"),
|
|
572
|
+
number: pr.number
|
|
573
|
+
};
|
|
574
|
+
await port.upsertComment({
|
|
575
|
+
on: pr,
|
|
576
|
+
marker,
|
|
577
|
+
body: `${marker}\nfirst`
|
|
578
|
+
});
|
|
579
|
+
await port.upsertComment({
|
|
580
|
+
on: pr,
|
|
581
|
+
marker,
|
|
582
|
+
body: `${marker}\nsecond`
|
|
583
|
+
});
|
|
584
|
+
expect((await port.comments([ref])).flat().filter((body) => body.includes(marker))).toEqual([`${marker}\nsecond`]);
|
|
585
|
+
});
|
|
415
586
|
it("given release notes published for a tag, when the released tags are read, then it is among them", async () => {
|
|
416
587
|
const { port, tag } = await subject();
|
|
417
588
|
const name = await tag();
|
|
418
589
|
await port.createRelease(name, "Published by the contract suite.", false);
|
|
419
590
|
expect(await port.releasedTags()).toContain(name);
|
|
420
591
|
});
|
|
592
|
+
it("given release notes published with the tag before, when the released tags are read, then it is among them", async () => {
|
|
593
|
+
const { port, tag } = await subject();
|
|
594
|
+
const before = await tag();
|
|
595
|
+
const name = await tag();
|
|
596
|
+
await port.createRelease(name, "Published by the contract suite.", false, before);
|
|
597
|
+
expect(await port.releasedTags()).toContain(name);
|
|
598
|
+
});
|
|
421
599
|
it("given a deploy recorded, when the deploys are read, then it is there and done", async () => {
|
|
422
600
|
const { port, tag } = await subject();
|
|
423
601
|
const name = await tag();
|
|
@@ -449,8 +627,7 @@ const ciPipelineContract = (name, subject) => describe(`${name}, as a CI pipelin
|
|
|
449
627
|
it("given this month's budget, when it is read, then what is left is never more than included", async () => {
|
|
450
628
|
const { port } = await subject();
|
|
451
629
|
const minutes = await port.minutes();
|
|
452
|
-
|
|
453
|
-
else expect(minutes).toBeNull();
|
|
630
|
+
expect(minutes === null || minutes.left <= minutes.included).toBe(true);
|
|
454
631
|
});
|
|
455
632
|
});
|
|
456
633
|
//#endregion
|
|
@@ -486,6 +663,52 @@ const versioningContract = (name, subject) => describe(`${name}, as versioning`,
|
|
|
486
663
|
});
|
|
487
664
|
});
|
|
488
665
|
//#endregion
|
|
666
|
+
//#region src/testing/platformEnvContract.ts
|
|
667
|
+
/** What every platform env does, whatever its provider: list names only, and say how to set them. */
|
|
668
|
+
const platformEnvContract = (cases) => describe.each(cases.map((entry) => [entry.adapter.name, entry]))("%s, as a platform env", (_name, { adapter, settings, environment, listing, failing }) => {
|
|
669
|
+
const unit = testUnit("app", {
|
|
670
|
+
module: "app",
|
|
671
|
+
options: settings
|
|
672
|
+
});
|
|
673
|
+
const options = optionsFor({
|
|
674
|
+
...unit,
|
|
675
|
+
options: adapter.settings.parse(settings)
|
|
676
|
+
}, environment, [unit]);
|
|
677
|
+
const envOn = (shell) => {
|
|
678
|
+
if (!adapter.env) throw new Error(`${adapter.name} lists no env`);
|
|
679
|
+
return adapter.env({
|
|
680
|
+
root: "/repo",
|
|
681
|
+
shell
|
|
682
|
+
});
|
|
683
|
+
};
|
|
684
|
+
it("given names set on the platform, when they are listed, then each is there as an env var name", async () => {
|
|
685
|
+
const listed = await envOn(listing.shell).listNames({
|
|
686
|
+
unit,
|
|
687
|
+
environment,
|
|
688
|
+
options
|
|
689
|
+
});
|
|
690
|
+
expect([...listed]).toEqual(expect.arrayContaining([...listing.names]));
|
|
691
|
+
expect([...listed].every(isEnvVarName)).toBe(true);
|
|
692
|
+
});
|
|
693
|
+
it("given a listing the platform refuses, when names are listed, then it fails saying why", async () => {
|
|
694
|
+
await expect(envOn(failing).listNames({
|
|
695
|
+
unit,
|
|
696
|
+
environment,
|
|
697
|
+
options
|
|
698
|
+
})).rejects.toThrow(/\S/);
|
|
699
|
+
});
|
|
700
|
+
it("given names to set, when the person is told how, then the command names each of them", () => {
|
|
701
|
+
const names = listing.names.filter(isEnvVarName);
|
|
702
|
+
const command = envOn(listing.shell).setCommand({
|
|
703
|
+
unit,
|
|
704
|
+
environment,
|
|
705
|
+
options,
|
|
706
|
+
names
|
|
707
|
+
});
|
|
708
|
+
names.forEach((name) => expect(command).toContain(name));
|
|
709
|
+
});
|
|
710
|
+
});
|
|
711
|
+
//#endregion
|
|
489
712
|
//#region src/testing/sample.ts
|
|
490
713
|
/** This repository's four shipping units, as the rule tests were written against them. */
|
|
491
714
|
const SAMPLE_UNITS = [
|
|
@@ -555,16 +778,6 @@ const planFrom = (pending, versions) => (added, held, ceiling) => {
|
|
|
555
778
|
//#endregion
|
|
556
779
|
//#region src/testing/consumer.ts
|
|
557
780
|
const CORE = "shiplane";
|
|
558
|
-
const coreDir = (from) => {
|
|
559
|
-
const manifest = path.join(from, "package.json");
|
|
560
|
-
if (fs.existsSync(manifest)) {
|
|
561
|
-
const { name } = JSON.parse(fs.readFileSync(manifest, "utf8"));
|
|
562
|
-
if (name === CORE) return from;
|
|
563
|
-
}
|
|
564
|
-
const parent = path.dirname(from);
|
|
565
|
-
if (parent === from) throw new Error(`${CORE} not found above ${import.meta.dirname}`);
|
|
566
|
-
return coreDir(parent);
|
|
567
|
-
};
|
|
568
781
|
/** The built CLI, as `pnpm add shiplane` installs it. */
|
|
569
782
|
const builtCli = () => {
|
|
570
783
|
const cli = path.join(coreDir(import.meta.dirname), "dist", "cli.js");
|
|
@@ -734,6 +947,6 @@ const packageJson = (name, version = "1.0.0", extra = {}) => JSON.stringify({
|
|
|
734
947
|
...extra
|
|
735
948
|
}, null, 2);
|
|
736
949
|
//#endregion
|
|
737
|
-
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 };
|
|
950
|
+
export { LIVE, MemoryFiles, MemoryOutput, RecordingShell, SAMPLE_UNITS, SAMPLE_VERSION_FILES, SOURCE_ALIASES, ScriptedPrompter, addUnit, branchRelease, builtCli, changesetText, ciPipelineContract, ciPipelineFake, codeHostContract, codeHostFake, consumerRepository, createWorkspace, docsFor, doctor, inSandbox, initRelease, loadReleaseOnDisk as loadRelease, mobileDistributionContract, mobileDistributionFake, newAdapter, nodeFiles, openReleasePr, packageJson, packageRegistryContract, packageRegistryFake, planFrom, planShips, platformEnvContract, prepareRelease, promote, readStatus, refreshEditorSchema, releaseToPreview, removeUnit, sandbox, serverHostingContract, serverHostingFake, setup, shipTo, sourceControlContract, sourceControlFake, staticHostingContract, staticHostingFake, systemShell, testContext, testUnit, versioningContract, versioningFake };
|
|
738
951
|
|
|
739
952
|
//# sourceMappingURL=testing.js.map
|