@git.zone/cli 8.8.2 → 8.9.1
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_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/helpers.workflow.d.ts +6 -2
- package/dist_ts/helpers.workflow.js +17 -4
- package/dist_ts/mod_config/index.js +39 -9
- package/dist_ts/mod_release/classes.releasejournal.d.ts +7 -5
- package/dist_ts/mod_release/classes.releasejournal.js +53 -13
- package/dist_ts/mod_release/helpers.npmartifact.d.ts +3 -1
- package/dist_ts/mod_release/helpers.npmartifact.js +29 -3
- package/dist_ts/mod_release/helpers.releaseline.js +23 -4
- package/dist_ts/mod_release/helpers.releasepreparation.d.ts +2 -0
- package/dist_ts/mod_release/helpers.releasepreparation.js +46 -7
- package/dist_ts/mod_release/helpers.releaseversion.d.ts +26 -2
- package/dist_ts/mod_release/helpers.releaseversion.js +126 -6
- package/dist_ts/mod_release/index.js +39 -12
- package/package.json +1 -1
- package/readme.md +68 -2
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/helpers.workflow.ts +43 -5
- package/ts/mod_config/index.ts +49 -5
- package/ts/mod_release/classes.releasejournal.ts +88 -15
- package/ts/mod_release/helpers.npmartifact.ts +33 -1
- package/ts/mod_release/helpers.releaseline.ts +30 -3
- package/ts/mod_release/helpers.releasepreparation.ts +65 -5
- package/ts/mod_release/helpers.releaseversion.ts +225 -4
- package/ts/mod_release/index.ts +67 -4
|
@@ -311,6 +311,32 @@ const commitCarriesBlob = async (
|
|
|
311
311
|
return result.exitCode === 0 && result.stdout.trim() === "blob";
|
|
312
312
|
};
|
|
313
313
|
|
|
314
|
+
/** Keep nested pnpm commands inside the scope the release commit carries. */
|
|
315
|
+
export const getReleaseCommandEnvironment = async (
|
|
316
|
+
options: IReleaseSourceCommit,
|
|
317
|
+
): Promise<NodeJS.ProcessEnv> => {
|
|
318
|
+
const ownsWorkspace = await commitCarriesBlob(options, "pnpm-workspace.yaml");
|
|
319
|
+
const env = Object.fromEntries(
|
|
320
|
+
Object.entries(process.env).filter(
|
|
321
|
+
([key]) =>
|
|
322
|
+
![
|
|
323
|
+
"pnpm_config_ignore_workspace",
|
|
324
|
+
"pnpm_config_workspace_dir",
|
|
325
|
+
"npm_config_workspace_dir",
|
|
326
|
+
].includes(key.toLowerCase()),
|
|
327
|
+
),
|
|
328
|
+
);
|
|
329
|
+
// Configured test/build commands can start further pnpm processes. The
|
|
330
|
+
// environment carries the same boundary through those subprocesses without
|
|
331
|
+
// rewriting project commands or inheriting an unrelated ancestor workspace.
|
|
332
|
+
return {
|
|
333
|
+
...env,
|
|
334
|
+
PNPM_CONFIG_WORKSPACE_DIR: options.cwd,
|
|
335
|
+
NPM_CONFIG_WORKSPACE_DIR: options.cwd,
|
|
336
|
+
PNPM_CONFIG_IGNORE_WORKSPACE: String(!ownsWorkspace),
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
|
|
314
340
|
/**
|
|
315
341
|
* The release checkout holds the release commit, so what it needs is decided by
|
|
316
342
|
* what that commit tracks rather than by what the working folder happens to
|
|
@@ -368,11 +394,20 @@ export const assertReleaseCheckoutInstallable = async (
|
|
|
368
394
|
// lockfile or node_modules, a stale one exits 1 with ERR_PNPM_OUTDATED_LOCKFILE
|
|
369
395
|
// before resolving anything. `--dry-run` cannot replace it: it prints the
|
|
370
396
|
// difference and still exits 0.
|
|
397
|
+
const env = await getReleaseCommandEnvironment(options);
|
|
371
398
|
const frozen = await options.smartshell.execSpawn(
|
|
372
399
|
"pnpm",
|
|
373
|
-
[
|
|
400
|
+
[
|
|
401
|
+
"install",
|
|
402
|
+
"--frozen-lockfile",
|
|
403
|
+
"--lockfile-only",
|
|
404
|
+
...(env.PNPM_CONFIG_IGNORE_WORKSPACE === "true"
|
|
405
|
+
? ["--ignore-workspace"]
|
|
406
|
+
: []),
|
|
407
|
+
],
|
|
374
408
|
{
|
|
375
409
|
cwd: options.cwd,
|
|
410
|
+
env,
|
|
376
411
|
silent: true,
|
|
377
412
|
timeout: 5 * 60_000,
|
|
378
413
|
timeoutKillGraceMs: 5_000,
|
|
@@ -454,6 +489,11 @@ export const withIsolatedReleaseCheckout = async <T>(
|
|
|
454
489
|
options.repositoryCwd,
|
|
455
490
|
);
|
|
456
491
|
added = true;
|
|
492
|
+
const env = await getReleaseCommandEnvironment({
|
|
493
|
+
smartshell: options.smartshell,
|
|
494
|
+
cwd: checkout,
|
|
495
|
+
sourceOid: options.mainOid,
|
|
496
|
+
});
|
|
457
497
|
// The checkout is the release commit, so its own tree decides whether npm
|
|
458
498
|
// dependencies are installed. A Deno-only commit carries no package.json
|
|
459
499
|
// and no pnpm lockfile: its configured commands run against the committed
|
|
@@ -461,9 +501,16 @@ export const withIsolatedReleaseCheckout = async <T>(
|
|
|
461
501
|
if (projectTypeHasPackageJson(await detectProjectType(checkout))) {
|
|
462
502
|
const install = await options.smartshell.execSpawn(
|
|
463
503
|
"pnpm",
|
|
464
|
-
[
|
|
504
|
+
[
|
|
505
|
+
"install",
|
|
506
|
+
"--frozen-lockfile",
|
|
507
|
+
...(env.PNPM_CONFIG_IGNORE_WORKSPACE === "true"
|
|
508
|
+
? ["--ignore-workspace"]
|
|
509
|
+
: []),
|
|
510
|
+
],
|
|
465
511
|
{
|
|
466
512
|
cwd: checkout,
|
|
513
|
+
env,
|
|
467
514
|
timeout: 10 * 60_000,
|
|
468
515
|
timeoutKillGraceMs: 5_000,
|
|
469
516
|
},
|
|
@@ -482,9 +529,21 @@ export const withIsolatedReleaseCheckout = async <T>(
|
|
|
482
529
|
);
|
|
483
530
|
}
|
|
484
531
|
if (options.testCommand)
|
|
485
|
-
await run(
|
|
532
|
+
await run(
|
|
533
|
+
options.smartshell,
|
|
534
|
+
checkout,
|
|
535
|
+
options.testCommand,
|
|
536
|
+
"tests",
|
|
537
|
+
env,
|
|
538
|
+
);
|
|
486
539
|
if (options.buildCommand)
|
|
487
|
-
await run(
|
|
540
|
+
await run(
|
|
541
|
+
options.smartshell,
|
|
542
|
+
checkout,
|
|
543
|
+
options.buildCommand,
|
|
544
|
+
"build",
|
|
545
|
+
env,
|
|
546
|
+
);
|
|
488
547
|
await assertExact();
|
|
489
548
|
// tspublish only prepares into an output whose parent path is canonical.
|
|
490
549
|
const preparationPath = plugins.path.join(
|
|
@@ -563,10 +622,11 @@ const run = async (
|
|
|
563
622
|
cwd: string,
|
|
564
623
|
command: string,
|
|
565
624
|
phase: string,
|
|
625
|
+
env: NodeJS.ProcessEnv,
|
|
566
626
|
) => {
|
|
567
627
|
printReleasePhase(`Running the release ${phase} in the release checkout`);
|
|
568
628
|
const startedAt = Date.now();
|
|
569
|
-
const result = await smartshell.exec(command, { cwd });
|
|
629
|
+
const result = await smartshell.exec(command, { cwd, env });
|
|
570
630
|
if (result.exitCode !== 0)
|
|
571
631
|
throw new Error(
|
|
572
632
|
formatCommandFailure(
|
|
@@ -8,6 +8,7 @@ export type TReleaseVersionErrorCode =
|
|
|
8
8
|
| "malformed-version-floor"
|
|
9
9
|
| "unsupported-prerelease-floor"
|
|
10
10
|
| "noncanonical-version"
|
|
11
|
+
| "invalid-prerelease-config"
|
|
11
12
|
| "current-version-changed";
|
|
12
13
|
|
|
13
14
|
export class ReleaseVersionError extends Error {
|
|
@@ -36,6 +37,24 @@ export interface IReleaseVersionRequest {
|
|
|
36
37
|
levelOverride?: VersionType;
|
|
37
38
|
/** The raw `release.versionFloor` configuration value. */
|
|
38
39
|
versionFloor?: unknown;
|
|
40
|
+
prerelease?: IReleasePrerelease;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** A committed main-branch publication channel; it never selects latest. */
|
|
44
|
+
export interface IReleasePrerelease {
|
|
45
|
+
identifier: string;
|
|
46
|
+
distTag: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The channel and its floor are immutable across interrupted releases. */
|
|
50
|
+
export interface IReleasePrereleaseRecord extends IReleasePrerelease {
|
|
51
|
+
versionFloor: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface IParsedPrereleaseVersion {
|
|
55
|
+
core: string;
|
|
56
|
+
identifier: string;
|
|
57
|
+
sequence: number;
|
|
39
58
|
}
|
|
40
59
|
|
|
41
60
|
export interface IReleaseVersionResolution {
|
|
@@ -47,6 +66,7 @@ export interface IReleaseVersionResolution {
|
|
|
47
66
|
versionFloor: { floor: string; outcome: TReleaseVersionFloorOutcome } | null;
|
|
48
67
|
/** The floor raised the major version above the inferred version, and Pending has no Breaking Changes section. */
|
|
49
68
|
floorRaisesMajorWithoutBreakingChanges: boolean;
|
|
69
|
+
prerelease?: IReleasePrerelease;
|
|
50
70
|
}
|
|
51
71
|
|
|
52
72
|
/** Journaled only when the floor, not the changelog, decided the release version. */
|
|
@@ -56,6 +76,111 @@ export interface IReleaseVersionFloorRecord {
|
|
|
56
76
|
}
|
|
57
77
|
|
|
58
78
|
const canonicalVersionPattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
|
79
|
+
const prereleaseVersionPattern =
|
|
80
|
+
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)-([a-z][a-z0-9]*(?:-[a-z0-9]+)*)\.(0|[1-9]\d*)$/;
|
|
81
|
+
|
|
82
|
+
export const parsePrereleaseVersion = (
|
|
83
|
+
valueArg: string,
|
|
84
|
+
): IParsedPrereleaseVersion | undefined => {
|
|
85
|
+
const match = prereleaseVersionPattern.exec(valueArg);
|
|
86
|
+
if (
|
|
87
|
+
!match ||
|
|
88
|
+
![match[1], match[2], match[3], match[5]].every((componentArg) =>
|
|
89
|
+
Number.isSafeInteger(Number(componentArg)),
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
return undefined;
|
|
93
|
+
return {
|
|
94
|
+
core: `${match[1]}.${match[2]}.${match[3]}`,
|
|
95
|
+
identifier: match[4],
|
|
96
|
+
sequence: Number(match[5]),
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const isSupportedReleaseVersion = (valueArg: string): boolean =>
|
|
101
|
+
(isCanonicalReleaseVersion(valueArg) && hasSafeIntegerComponents(valueArg)) ||
|
|
102
|
+
parsePrereleaseVersion(valueArg) !== undefined;
|
|
103
|
+
|
|
104
|
+
export const releaseVersionCore = (valueArg: string): string =>
|
|
105
|
+
parsePrereleaseVersion(valueArg)?.core ?? valueArg;
|
|
106
|
+
|
|
107
|
+
/** Semver ordering for stable versions and the supported identifier.N form. */
|
|
108
|
+
export const compareSupportedReleaseVersions = (
|
|
109
|
+
leftArg: string,
|
|
110
|
+
rightArg: string,
|
|
111
|
+
): number => {
|
|
112
|
+
const coreOrder = compareReleaseVersions(
|
|
113
|
+
releaseVersionCore(leftArg),
|
|
114
|
+
releaseVersionCore(rightArg),
|
|
115
|
+
);
|
|
116
|
+
if (coreOrder !== 0) return coreOrder;
|
|
117
|
+
const left = parsePrereleaseVersion(leftArg);
|
|
118
|
+
const right = parsePrereleaseVersion(rightArg);
|
|
119
|
+
if (!left && !right) return 0;
|
|
120
|
+
if (!left) return 1;
|
|
121
|
+
if (!right) return -1;
|
|
122
|
+
if (left.identifier !== right.identifier)
|
|
123
|
+
return left.identifier < right.identifier ? -1 : 1;
|
|
124
|
+
return Math.sign(left.sequence - right.sequence);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const parseReleasePrerelease = (
|
|
128
|
+
valueArg: unknown,
|
|
129
|
+
contextArg = "release.prerelease",
|
|
130
|
+
): IReleasePrerelease | undefined => {
|
|
131
|
+
if (valueArg === undefined) return undefined;
|
|
132
|
+
const fail = (): never => {
|
|
133
|
+
throw new ReleaseVersionError(
|
|
134
|
+
"invalid-prerelease-config",
|
|
135
|
+
`${contextArg} must contain exactly identifier and distTag: lowercase letters and digits joined by hyphens, starting with a letter; distTag must not be latest or a semver range.`,
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
if (
|
|
139
|
+
typeof valueArg !== "object" ||
|
|
140
|
+
valueArg === null ||
|
|
141
|
+
Array.isArray(valueArg)
|
|
142
|
+
)
|
|
143
|
+
return fail();
|
|
144
|
+
const config = valueArg as Record<string, unknown>;
|
|
145
|
+
if (
|
|
146
|
+
Object.keys(config).length !== 2 ||
|
|
147
|
+
typeof config.identifier !== "string" ||
|
|
148
|
+
typeof config.distTag !== "string"
|
|
149
|
+
)
|
|
150
|
+
return fail();
|
|
151
|
+
const identifierPattern = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
152
|
+
if (
|
|
153
|
+
![config.identifier, config.distTag].every(
|
|
154
|
+
(partArg) => partArg.length <= 64 && identifierPattern.test(partArg),
|
|
155
|
+
) ||
|
|
156
|
+
config.distTag === "latest" ||
|
|
157
|
+
/^v*(?:\d+|x)$/.test(config.distTag)
|
|
158
|
+
)
|
|
159
|
+
return fail();
|
|
160
|
+
return { identifier: config.identifier, distTag: config.distTag };
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export const toReleasePrereleaseRecord = (
|
|
164
|
+
prereleaseArg: IReleasePrerelease | undefined,
|
|
165
|
+
floorArg: string | undefined,
|
|
166
|
+
): IReleasePrereleaseRecord | undefined => {
|
|
167
|
+
if (!prereleaseArg) return undefined;
|
|
168
|
+
const versionFloor = parseReleaseVersionFloor(floorArg, prereleaseArg);
|
|
169
|
+
if (!versionFloor)
|
|
170
|
+
throw new ReleaseVersionError(
|
|
171
|
+
"invalid-prerelease-config",
|
|
172
|
+
"release.prerelease requires a matching prerelease release.versionFloor.",
|
|
173
|
+
);
|
|
174
|
+
return { ...prereleaseArg, versionFloor };
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export const isSameReleasePrerelease = (
|
|
178
|
+
leftArg: IReleasePrereleaseRecord | undefined,
|
|
179
|
+
rightArg: IReleasePrereleaseRecord | undefined,
|
|
180
|
+
): boolean =>
|
|
181
|
+
leftArg?.identifier === rightArg?.identifier &&
|
|
182
|
+
leftArg?.distTag === rightArg?.distTag &&
|
|
183
|
+
leftArg?.versionFloor === rightArg?.versionFloor;
|
|
59
184
|
// The semver.org 2.0.0 grammar. It is consulted only after the canonical form
|
|
60
185
|
// failed, so a match here means prerelease or build metadata.
|
|
61
186
|
const decoratedSemverPattern =
|
|
@@ -91,7 +216,7 @@ export const compareReleaseVersions = (
|
|
|
91
216
|
|
|
92
217
|
/** The major component of a canonical x.y.z version. */
|
|
93
218
|
export const releaseVersionMajor = (versionArg: string): bigint =>
|
|
94
|
-
parseVersionCore(versionArg)[0];
|
|
219
|
+
parseVersionCore(releaseVersionCore(versionArg))[0];
|
|
95
220
|
|
|
96
221
|
const majorOf = releaseVersionMajor;
|
|
97
222
|
|
|
@@ -104,7 +229,20 @@ const hasSafeIntegerComponents = (versionArg: string): boolean =>
|
|
|
104
229
|
/** Validates `release.versionFloor`; absent means no floor. */
|
|
105
230
|
export const parseReleaseVersionFloor = (
|
|
106
231
|
valueArg: unknown,
|
|
232
|
+
prereleaseArg?: IReleasePrerelease,
|
|
107
233
|
): string | undefined => {
|
|
234
|
+
if (prereleaseArg) {
|
|
235
|
+
const parsed =
|
|
236
|
+
typeof valueArg === "string"
|
|
237
|
+
? parsePrereleaseVersion(valueArg)
|
|
238
|
+
: undefined;
|
|
239
|
+
if (!parsed || parsed.identifier !== prereleaseArg.identifier)
|
|
240
|
+
throw new ReleaseVersionError(
|
|
241
|
+
"invalid-prerelease-config",
|
|
242
|
+
"release.prerelease requires release.versionFloor in the matching x.y.z-identifier.N form; keep this floor to make older CLIs fail closed.",
|
|
243
|
+
);
|
|
244
|
+
return valueArg as string;
|
|
245
|
+
}
|
|
108
246
|
if (valueArg === undefined) return undefined;
|
|
109
247
|
if (typeof valueArg === "string" && isCanonicalReleaseVersion(valueArg)) {
|
|
110
248
|
if (hasSafeIntegerComponents(valueArg)) return valueArg;
|
|
@@ -137,6 +275,66 @@ const decideFloorOutcome = (
|
|
|
137
275
|
return "applied";
|
|
138
276
|
};
|
|
139
277
|
|
|
278
|
+
const resolvePrereleaseVersion = (
|
|
279
|
+
requestArg: IReleaseVersionRequest,
|
|
280
|
+
prereleaseArg: IReleasePrerelease,
|
|
281
|
+
floorArg: string,
|
|
282
|
+
pendingLevelArg: VersionType,
|
|
283
|
+
): IReleaseVersionResolution => {
|
|
284
|
+
if (requestArg.levelOverride)
|
|
285
|
+
throw new ReleaseVersionError(
|
|
286
|
+
"invalid-prerelease-config",
|
|
287
|
+
"Prerelease numbering is controlled by release.versionFloor; --major, --minor and --patch are not allowed while release.prerelease is configured.",
|
|
288
|
+
);
|
|
289
|
+
const current = parsePrereleaseVersion(requestArg.currentVersion);
|
|
290
|
+
const floor = parsePrereleaseVersion(floorArg)!;
|
|
291
|
+
if (
|
|
292
|
+
!isSupportedReleaseVersion(requestArg.currentVersion) ||
|
|
293
|
+
(current && current.identifier !== prereleaseArg.identifier)
|
|
294
|
+
)
|
|
295
|
+
throw new ReleaseVersionError(
|
|
296
|
+
"noncanonical-version",
|
|
297
|
+
"The current version must be stable or belong to the configured prerelease identifier.",
|
|
298
|
+
);
|
|
299
|
+
const coreOrder = compareReleaseVersions(
|
|
300
|
+
floor.core,
|
|
301
|
+
releaseVersionCore(requestArg.currentVersion),
|
|
302
|
+
);
|
|
303
|
+
if (!current && coreOrder <= 0)
|
|
304
|
+
throw new ReleaseVersionError(
|
|
305
|
+
"invalid-prerelease-config",
|
|
306
|
+
"A prerelease floor must target a version above the current stable version.",
|
|
307
|
+
);
|
|
308
|
+
if (current && coreOrder < 0)
|
|
309
|
+
throw new ReleaseVersionError(
|
|
310
|
+
"invalid-prerelease-config",
|
|
311
|
+
"A prerelease floor cannot move its version core backwards.",
|
|
312
|
+
);
|
|
313
|
+
if (current?.sequence === Number.MAX_SAFE_INTEGER)
|
|
314
|
+
throw new ReleaseVersionError(
|
|
315
|
+
"invalid-prerelease-config",
|
|
316
|
+
"The prerelease sequence cannot exceed Number.MAX_SAFE_INTEGER.",
|
|
317
|
+
);
|
|
318
|
+
const inferredVersion = current
|
|
319
|
+
? `${current.core}-${prereleaseArg.identifier}.${current.sequence + 1}`
|
|
320
|
+
: requestArg.currentVersion;
|
|
321
|
+
const applied =
|
|
322
|
+
compareSupportedReleaseVersions(floorArg, inferredVersion) > 0;
|
|
323
|
+
return {
|
|
324
|
+
currentVersion: requestArg.currentVersion,
|
|
325
|
+
level: pendingLevelArg,
|
|
326
|
+
levelSource: "pending-changelog",
|
|
327
|
+
inferredVersion,
|
|
328
|
+
version: applied ? floorArg : inferredVersion,
|
|
329
|
+
versionFloor: { floor: floorArg, outcome: applied ? "applied" : "inert" },
|
|
330
|
+
floorRaisesMajorWithoutBreakingChanges:
|
|
331
|
+
applied &&
|
|
332
|
+
majorOf(floorArg) > majorOf(inferredVersion) &&
|
|
333
|
+
pendingLevelArg !== "major",
|
|
334
|
+
prerelease: prereleaseArg,
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
|
|
140
338
|
/**
|
|
141
339
|
* The only place that decides the next release version: the level-inferred
|
|
142
340
|
* version, raised to `release.versionFloor` when the floor is higher.
|
|
@@ -146,7 +344,25 @@ export const resolveReleaseVersion = (
|
|
|
146
344
|
): IReleaseVersionResolution => {
|
|
147
345
|
const pendingLevel = inferVersionTypeFromPending(requestArg.pendingChangelog);
|
|
148
346
|
const level = requestArg.levelOverride ?? pendingLevel;
|
|
149
|
-
const
|
|
347
|
+
const currentPrerelease = parsePrereleaseVersion(requestArg.currentVersion);
|
|
348
|
+
const prerelease = parseReleasePrerelease(requestArg.prerelease);
|
|
349
|
+
const floor = parseReleaseVersionFloor(requestArg.versionFloor, prerelease);
|
|
350
|
+
if (prerelease)
|
|
351
|
+
return resolvePrereleaseVersion(
|
|
352
|
+
requestArg,
|
|
353
|
+
prerelease,
|
|
354
|
+
floor!,
|
|
355
|
+
pendingLevel,
|
|
356
|
+
);
|
|
357
|
+
// Removing both channel settings explicitly promotes the exact prerelease core.
|
|
358
|
+
const inferredVersion = currentPrerelease
|
|
359
|
+
? currentPrerelease.core
|
|
360
|
+
: calculateNewVersion(requestArg.currentVersion, level);
|
|
361
|
+
if (currentPrerelease && requestArg.levelOverride)
|
|
362
|
+
throw new ReleaseVersionError(
|
|
363
|
+
"invalid-prerelease-config",
|
|
364
|
+
"Promote a prerelease by removing release.prerelease and its floor, without a version-level flag.",
|
|
365
|
+
);
|
|
150
366
|
const levelSource: TReleaseVersionLevelSource = requestArg.levelOverride
|
|
151
367
|
? "flag"
|
|
152
368
|
: "pending-changelog";
|
|
@@ -156,7 +372,6 @@ export const resolveReleaseVersion = (
|
|
|
156
372
|
levelSource,
|
|
157
373
|
inferredVersion,
|
|
158
374
|
};
|
|
159
|
-
const floor = parseReleaseVersionFloor(requestArg.versionFloor);
|
|
160
375
|
if (floor === undefined) {
|
|
161
376
|
return {
|
|
162
377
|
...unfloored,
|
|
@@ -234,7 +449,13 @@ const describeVersionFloor = (
|
|
|
234
449
|
switch (decision.outcome) {
|
|
235
450
|
case "inert":
|
|
236
451
|
return [
|
|
237
|
-
|
|
452
|
+
...(resolutionArg.prerelease
|
|
453
|
+
? [
|
|
454
|
+
`prerelease floor: ${decision.floor} retained (older CLIs refuse this channel)`,
|
|
455
|
+
]
|
|
456
|
+
: [
|
|
457
|
+
`version floor: ${decision.floor} inert (current ${resolutionArg.currentVersion} already meets it); remove release.versionFloor`,
|
|
458
|
+
]),
|
|
238
459
|
];
|
|
239
460
|
case "satisfied":
|
|
240
461
|
return [
|
package/ts/mod_release/index.ts
CHANGED
|
@@ -78,7 +78,6 @@ import {
|
|
|
78
78
|
import {
|
|
79
79
|
assertReleaseLineVersion,
|
|
80
80
|
findDistTagPublicationRefusal,
|
|
81
|
-
getReleaseDistTag,
|
|
82
81
|
getReleaseDockerAliasPolicy,
|
|
83
82
|
isSameReleaseLine,
|
|
84
83
|
latestDistTag,
|
|
@@ -100,6 +99,7 @@ import {
|
|
|
100
99
|
assertPackageReleaseRecovery,
|
|
101
100
|
assertRecoveryUnpublished,
|
|
102
101
|
assertReleaseCheckoutInstallable,
|
|
102
|
+
getReleaseCommandEnvironment,
|
|
103
103
|
withIsolatedReleaseCheckout,
|
|
104
104
|
withReleasePreparationRecovery,
|
|
105
105
|
} from "./helpers.releasepreparation.js";
|
|
@@ -114,6 +114,8 @@ import {
|
|
|
114
114
|
} from "./helpers.tsdockerprotocol.js";
|
|
115
115
|
import {
|
|
116
116
|
assertResolvedCurrentVersion,
|
|
117
|
+
isSameReleasePrerelease,
|
|
118
|
+
toReleasePrereleaseRecord,
|
|
117
119
|
describeAppliedVersionFloor,
|
|
118
120
|
describeReleaseVersion,
|
|
119
121
|
releaseVersionMajor,
|
|
@@ -239,6 +241,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
239
241
|
pendingChangelog: pending.block,
|
|
240
242
|
levelOverride: readReleaseLevelOverride(argvArg),
|
|
241
243
|
versionFloor: workflow.versionFloor,
|
|
244
|
+
prerelease: workflow.prerelease,
|
|
242
245
|
});
|
|
243
246
|
assertReleaseLineVersion(
|
|
244
247
|
workflow.line,
|
|
@@ -359,6 +362,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
359
362
|
smartshellInstance,
|
|
360
363
|
branchContext.sourceCwd,
|
|
361
364
|
workflow.testCommand,
|
|
365
|
+
branchContext.sourceOid,
|
|
362
366
|
);
|
|
363
367
|
}
|
|
364
368
|
|
|
@@ -743,6 +747,14 @@ const recordReleaseIntent = async (
|
|
|
743
747
|
? { versionFloor: optionsArg.versionFloor }
|
|
744
748
|
: {}),
|
|
745
749
|
...(optionsArg.workflow.line ? { line: optionsArg.workflow.line } : {}),
|
|
750
|
+
...(optionsArg.workflow.prerelease
|
|
751
|
+
? {
|
|
752
|
+
prerelease: toReleasePrereleaseRecord(
|
|
753
|
+
optionsArg.workflow.prerelease,
|
|
754
|
+
optionsArg.workflow.versionFloor,
|
|
755
|
+
),
|
|
756
|
+
}
|
|
757
|
+
: {}),
|
|
746
758
|
},
|
|
747
759
|
plan: {
|
|
748
760
|
targets: optionsArg.workflow.targets,
|
|
@@ -793,6 +805,7 @@ const prepareTaggedRelease = async (
|
|
|
793
805
|
releaseCwd,
|
|
794
806
|
"Running release build",
|
|
795
807
|
workflow.buildCommand,
|
|
808
|
+
optionsArg.refs.mainOid,
|
|
796
809
|
);
|
|
797
810
|
await verifyCleanTree(
|
|
798
811
|
smartshell,
|
|
@@ -859,6 +872,15 @@ const prepareRecordedRelease = async (
|
|
|
859
872
|
const { version } = intentArg.release;
|
|
860
873
|
const workflow = await resolveReleaseWorkflow({ yes: true }, intentArg.plan);
|
|
861
874
|
assertReleaseConfiguration(workflow, false);
|
|
875
|
+
if (
|
|
876
|
+
!isSameReleasePrerelease(
|
|
877
|
+
toReleasePrereleaseRecord(workflow.prerelease, workflow.versionFloor),
|
|
878
|
+
intentArg.release.prerelease,
|
|
879
|
+
)
|
|
880
|
+
)
|
|
881
|
+
throw new Error(
|
|
882
|
+
"Current release.prerelease or versionFloor does not match the recorded release.",
|
|
883
|
+
);
|
|
862
884
|
if (!isSameReleaseLine(workflow.line, intentArg.release.line)) {
|
|
863
885
|
throw new Error(
|
|
864
886
|
`Current release.line (${describeReleaseLine(workflow.line)}) does not match the recorded release (${describeReleaseLine(intentArg.release.line)}).`,
|
|
@@ -1168,6 +1190,14 @@ export const createReleaseJournal = async (
|
|
|
1168
1190
|
...(optionsArg.workflow.line
|
|
1169
1191
|
? { line: optionsArg.workflow.line }
|
|
1170
1192
|
: {}),
|
|
1193
|
+
...(optionsArg.workflow.prerelease
|
|
1194
|
+
? {
|
|
1195
|
+
prerelease: toReleasePrereleaseRecord(
|
|
1196
|
+
optionsArg.workflow.prerelease,
|
|
1197
|
+
optionsArg.workflow.versionFloor,
|
|
1198
|
+
),
|
|
1199
|
+
}
|
|
1200
|
+
: {}),
|
|
1171
1201
|
},
|
|
1172
1202
|
artifact,
|
|
1173
1203
|
...(packages.length || giteaAssets ? { packages } : {}),
|
|
@@ -1188,7 +1218,7 @@ export const createReleaseJournal = async (
|
|
|
1188
1218
|
access: optionsArg.workflow.targets.includes("npm")
|
|
1189
1219
|
? optionsArg.workflow.npmAccessLevel
|
|
1190
1220
|
: "public",
|
|
1191
|
-
tag:
|
|
1221
|
+
tag: optionsArg.workflow.npmDistTag,
|
|
1192
1222
|
alreadyPublished: optionsArg.workflow.targets.includes("npm")
|
|
1193
1223
|
? optionsArg.workflow.npmAlreadyPublished
|
|
1194
1224
|
: "success",
|
|
@@ -1394,6 +1424,10 @@ const runReleaseRecover = async (
|
|
|
1394
1424
|
}
|
|
1395
1425
|
const workflow = await resolveReleaseWorkflow({ yes: true });
|
|
1396
1426
|
assertReleaseConfiguration(workflow, false);
|
|
1427
|
+
if (workflow.prerelease)
|
|
1428
|
+
throw new Error(
|
|
1429
|
+
"gitzone release recover does not support prereleases; continue the recorded intent with gitzone release resume <version> -y.",
|
|
1430
|
+
);
|
|
1397
1431
|
if (workflow.line) {
|
|
1398
1432
|
throw new Error(
|
|
1399
1433
|
`gitzone release recover does not support release lines: a ${workflow.line.distTag} release records its intent, so continue it with \`gitzone release resume <version> -y\`.`,
|
|
@@ -1815,6 +1849,15 @@ const assertResumeConfiguration = async (
|
|
|
1815
1849
|
journalArg: TReleaseJournal,
|
|
1816
1850
|
cwdArg: string,
|
|
1817
1851
|
): Promise<void> => {
|
|
1852
|
+
if (
|
|
1853
|
+
!isSameReleasePrerelease(
|
|
1854
|
+
workflowArg.prerelease,
|
|
1855
|
+
journalArg.release.prerelease,
|
|
1856
|
+
)
|
|
1857
|
+
)
|
|
1858
|
+
throw new Error(
|
|
1859
|
+
"Current release.prerelease or versionFloor does not match the journal.",
|
|
1860
|
+
);
|
|
1818
1861
|
if (!isSameReleaseLine(workflowArg.line, journalArg.release.line)) {
|
|
1819
1862
|
throw new Error(
|
|
1820
1863
|
`Current release.line (${describeReleaseLine(workflowArg.line)}) does not match the journal (${describeReleaseLine(journalArg.release.line)}).`,
|
|
@@ -1866,6 +1909,10 @@ const assertResumeConfiguration = async (
|
|
|
1866
1909
|
const printReleaseJournalSummary = (journalArg: TReleaseJournal): void => {
|
|
1867
1910
|
console.log("");
|
|
1868
1911
|
console.log(`Release v${journalArg.release.version}`);
|
|
1912
|
+
if (journalArg.release.prerelease)
|
|
1913
|
+
console.log(
|
|
1914
|
+
`prerelease channel: ${journalArg.release.prerelease.identifier} -> npm dist-tag ${journalArg.release.prerelease.distTag} (latest is never moved)`,
|
|
1915
|
+
);
|
|
1869
1916
|
if (journalArg.release.versionFloor) {
|
|
1870
1917
|
console.log(
|
|
1871
1918
|
describeAppliedVersionFloor(
|
|
@@ -1940,12 +1987,14 @@ async function runReleaseTests(
|
|
|
1940
1987
|
smartshellInstance: plugins.smartshell.Smartshell,
|
|
1941
1988
|
cwdArg: string,
|
|
1942
1989
|
testCommandArg: string,
|
|
1990
|
+
sourceOidArg: string,
|
|
1943
1991
|
): Promise<void> {
|
|
1944
1992
|
await runCommandStep(
|
|
1945
1993
|
smartshellInstance,
|
|
1946
1994
|
cwdArg,
|
|
1947
1995
|
"Running tests",
|
|
1948
1996
|
testCommandArg,
|
|
1997
|
+
sourceOidArg,
|
|
1949
1998
|
);
|
|
1950
1999
|
}
|
|
1951
2000
|
|
|
@@ -1954,10 +2003,16 @@ async function runCommandStep(
|
|
|
1954
2003
|
cwdArg: string,
|
|
1955
2004
|
label: string,
|
|
1956
2005
|
command: string,
|
|
2006
|
+
sourceOid: string,
|
|
1957
2007
|
): Promise<void> {
|
|
1958
2008
|
printReleasePhase(label);
|
|
1959
2009
|
const startedAt = Date.now();
|
|
1960
|
-
const
|
|
2010
|
+
const env = await getReleaseCommandEnvironment({
|
|
2011
|
+
smartshell: smartshellInstance,
|
|
2012
|
+
cwd: cwdArg,
|
|
2013
|
+
sourceOid,
|
|
2014
|
+
});
|
|
2015
|
+
const result = await smartshellInstance.exec(command, { cwd: cwdArg, env });
|
|
1961
2016
|
if (result.exitCode !== 0) {
|
|
1962
2017
|
throw new Error(
|
|
1963
2018
|
formatCommandFailure(`${label} failed. Aborting release.`, result, {
|
|
@@ -2358,7 +2413,11 @@ const describeReleaseLineDistTags = async (
|
|
|
2358
2413
|
workflowArg: IResolvedReleaseWorkflow,
|
|
2359
2414
|
versionArg: string,
|
|
2360
2415
|
): Promise<string[]> => {
|
|
2361
|
-
if (
|
|
2416
|
+
if (
|
|
2417
|
+
(!workflowArg.line && !workflowArg.prerelease) ||
|
|
2418
|
+
!workflowArg.npmPackages
|
|
2419
|
+
)
|
|
2420
|
+
return [];
|
|
2362
2421
|
const lines: string[] = [];
|
|
2363
2422
|
for (const packageName of getReleaseNpmPublicationOrder(
|
|
2364
2423
|
workflowArg.npmPackages,
|
|
@@ -2462,6 +2521,10 @@ async function printReleasePlan(
|
|
|
2462
2521
|
console.log(`confirmation: ${workflow.confirmation}`);
|
|
2463
2522
|
console.log(`plan: ${workflow.plan.join(" -> ")}`);
|
|
2464
2523
|
console.log(`source branch: ${branchContextArg.sourceBranch}`);
|
|
2524
|
+
if (workflow.prerelease)
|
|
2525
|
+
console.log(
|
|
2526
|
+
`prerelease channel: ${workflow.prerelease.identifier} -> npm dist-tag ${workflow.prerelease.distTag} (latest is never moved)`,
|
|
2527
|
+
);
|
|
2465
2528
|
if (workflow.line) {
|
|
2466
2529
|
console.log(
|
|
2467
2530
|
`release line: ${workflow.line.branch} -> npm dist-tag ${workflow.line.distTag} (major ${releaseVersionMajor(versionResolutionArg.currentVersion)}; latest is never moved)`,
|