@git.zone/cli 8.3.1 → 8.4.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_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/helpers.workflow.d.ts +14 -0
- package/dist_ts/helpers.workflow.js +29 -1
- package/dist_ts/mod_config/index.js +42 -1
- package/dist_ts/mod_release/classes.releasejournal.d.ts +19 -3
- package/dist_ts/mod_release/classes.releasejournal.js +95 -9
- package/dist_ts/mod_release/helpers.npmartifact.d.ts +80 -7
- package/dist_ts/mod_release/helpers.npmartifact.js +276 -41
- package/dist_ts/mod_release/helpers.releasebranch.d.ts +11 -0
- package/dist_ts/mod_release/helpers.releasebranch.js +88 -61
- package/dist_ts/mod_release/helpers.releaseline.d.ts +60 -0
- package/dist_ts/mod_release/helpers.releaseline.js +129 -0
- package/dist_ts/mod_release/helpers.releasepublication.d.ts +2 -0
- package/dist_ts/mod_release/helpers.releasepublication.js +86 -19
- package/dist_ts/mod_release/helpers.releaseversion.d.ts +2 -0
- package/dist_ts/mod_release/helpers.releaseversion.js +4 -2
- package/dist_ts/mod_release/index.js +130 -40
- package/package.json +3 -3
- package/readme.md +123 -7
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/helpers.workflow.ts +54 -0
- package/ts/mod_config/index.ts +47 -0
- package/ts/mod_release/classes.releasejournal.ts +149 -10
- package/ts/mod_release/helpers.npmartifact.ts +450 -37
- package/ts/mod_release/helpers.releasebranch.ts +120 -45
- package/ts/mod_release/helpers.releaseline.ts +214 -0
- package/ts/mod_release/helpers.releasepublication.ts +168 -16
- package/ts/mod_release/helpers.releaseversion.ts +5 -1
- package/ts/mod_release/index.ts +177 -26
package/ts/mod_release/index.ts
CHANGED
|
@@ -59,18 +59,30 @@ import {
|
|
|
59
59
|
import {
|
|
60
60
|
assertNoLegacyNpmPublisher,
|
|
61
61
|
assertNoStandaloneTspublishPublisher,
|
|
62
|
+
assertNpmDistTagsAllowPublication,
|
|
62
63
|
assertNpmRegistryAuthentication,
|
|
64
|
+
assertPnpmDistTagReadCapability,
|
|
63
65
|
assertPnpmReleaseCapability,
|
|
64
66
|
hashReleaseDestination,
|
|
65
67
|
normalizeNpmRegistryUrl,
|
|
66
68
|
packNpmArtifact,
|
|
69
|
+
readAnonymousNpmDistTags,
|
|
67
70
|
verifyStoredNpmArtifact,
|
|
68
71
|
type IPnpmReleaseCapability,
|
|
69
72
|
} from "./helpers.npmartifact.js";
|
|
70
73
|
import {
|
|
71
74
|
describeReleaseNpmPackages,
|
|
75
|
+
getReleaseNpmPublicationOrder,
|
|
72
76
|
planReleaseNpmPackages,
|
|
73
77
|
} from "./helpers.npmpackages.js";
|
|
78
|
+
import {
|
|
79
|
+
assertReleaseLineVersion,
|
|
80
|
+
findDistTagPublicationRefusal,
|
|
81
|
+
getReleaseDistTag,
|
|
82
|
+
isSameReleaseLine,
|
|
83
|
+
latestDistTag,
|
|
84
|
+
type IReleaseLine,
|
|
85
|
+
} from "./helpers.releaseline.js";
|
|
74
86
|
import { executeReleasePublication } from "./helpers.releasepublication.js";
|
|
75
87
|
import { formatCommandFailure } from "./helpers.commandfailure.js";
|
|
76
88
|
import { runTstestCleanup } from "../helpers.tstest.js";
|
|
@@ -92,6 +104,7 @@ import {
|
|
|
92
104
|
assertResolvedCurrentVersion,
|
|
93
105
|
describeAppliedVersionFloor,
|
|
94
106
|
describeReleaseVersion,
|
|
107
|
+
releaseVersionMajor,
|
|
95
108
|
resolveReleaseVersion,
|
|
96
109
|
toReleaseVersionFloorRecord,
|
|
97
110
|
type IReleaseVersionFloorRecord,
|
|
@@ -192,6 +205,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
192
205
|
// A detached launch checks in the foreground what the plan checks, and
|
|
193
206
|
// leaves every mutation to the release it starts.
|
|
194
207
|
planMode: workflow.confirmation === "plan" || detach,
|
|
208
|
+
releaseLine: workflow.line,
|
|
195
209
|
gitRemotePolicy: createReleaseGitRemotePolicy(
|
|
196
210
|
workflow.gitRemoteTimeoutSeconds,
|
|
197
211
|
),
|
|
@@ -214,7 +228,12 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
214
228
|
levelOverride: readReleaseLevelOverride(argvArg),
|
|
215
229
|
versionFloor: workflow.versionFloor,
|
|
216
230
|
});
|
|
217
|
-
|
|
231
|
+
assertReleaseLineVersion(
|
|
232
|
+
workflow.line,
|
|
233
|
+
versionResolution.currentVersion,
|
|
234
|
+
versionResolution.version,
|
|
235
|
+
);
|
|
236
|
+
await printReleasePlan(workflow, branchContext, versionResolution);
|
|
218
237
|
if (workflow.confirmation === "plan") {
|
|
219
238
|
return;
|
|
220
239
|
}
|
|
@@ -242,6 +261,21 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
242
261
|
}
|
|
243
262
|
|
|
244
263
|
const newVersion = versionResolution.version;
|
|
264
|
+
if (workflow.targets.includes("npm") && workflow.npmPackages) {
|
|
265
|
+
await assertNpmDistTagsAllowPublication({
|
|
266
|
+
reader: {
|
|
267
|
+
smartshell: smartshellInstance,
|
|
268
|
+
cwd: branchContext.sourceCwd,
|
|
269
|
+
capability: pnpmCapability,
|
|
270
|
+
},
|
|
271
|
+
access: workflow.npmAccessLevel,
|
|
272
|
+
registries: workflow.npmRegistries,
|
|
273
|
+
packageNames: getReleaseNpmPublicationOrder(workflow.npmPackages),
|
|
274
|
+
version: newVersion,
|
|
275
|
+
distTag: workflow.npmDistTag,
|
|
276
|
+
nextStep: "release again",
|
|
277
|
+
});
|
|
278
|
+
}
|
|
245
279
|
if (workflow.giteaAssets) {
|
|
246
280
|
const { tokenEnv, manifestPath, ...destination } = workflow.giteaAssets;
|
|
247
281
|
const token = process.env[tokenEnv];
|
|
@@ -312,7 +346,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
312
346
|
let releaseCwd = branchContext.sourceCwd;
|
|
313
347
|
let releasePushUrl = branchContext.pushUrl;
|
|
314
348
|
let expectedRemoteMainOid = branchContext.remoteMainOid;
|
|
315
|
-
if (branchContext.sourceBranch ===
|
|
349
|
+
if (branchContext.sourceBranch === branchContext.releaseBranch) {
|
|
316
350
|
await revalidatePreparedReleaseBranch(smartshellInstance, branchContext);
|
|
317
351
|
} else {
|
|
318
352
|
const integration = await integrateReleaseBranch(
|
|
@@ -328,6 +362,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
328
362
|
await runChangelogStep(workflow, newVersion, releaseCwd);
|
|
329
363
|
const releaseCommitOid = await runReleaseCommitStep(
|
|
330
364
|
smartshellInstance,
|
|
365
|
+
branchContext.releaseBranch,
|
|
331
366
|
newVersion,
|
|
332
367
|
releaseCwd,
|
|
333
368
|
);
|
|
@@ -340,6 +375,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
340
375
|
const releaseRefs = await captureReleaseRefs(
|
|
341
376
|
smartshellInstance,
|
|
342
377
|
releaseCwd,
|
|
378
|
+
branchContext.releaseBranch,
|
|
343
379
|
newVersion,
|
|
344
380
|
releaseCommitOid,
|
|
345
381
|
);
|
|
@@ -350,6 +386,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
350
386
|
await verifyReleaseRefs(
|
|
351
387
|
smartshellInstance,
|
|
352
388
|
releaseCwd,
|
|
389
|
+
branchContext.releaseBranch,
|
|
353
390
|
newVersion,
|
|
354
391
|
releaseRefs,
|
|
355
392
|
);
|
|
@@ -457,7 +494,7 @@ const assertFreshReleaseCapabilities = async (
|
|
|
457
494
|
if (workflowArg.targets.includes("npm")) {
|
|
458
495
|
await assertNoStandaloneTspublishPublisher(cwdArg);
|
|
459
496
|
const capability = await assertPnpmReleaseCapability(smartshellArg, cwdArg);
|
|
460
|
-
await
|
|
497
|
+
await assertPrivateNpmReleaseCapabilities(
|
|
461
498
|
smartshellArg,
|
|
462
499
|
cwdArg,
|
|
463
500
|
capability,
|
|
@@ -470,11 +507,14 @@ const assertFreshReleaseCapabilities = async (
|
|
|
470
507
|
};
|
|
471
508
|
|
|
472
509
|
/**
|
|
473
|
-
* A private package is verified
|
|
474
|
-
* authentication
|
|
475
|
-
*
|
|
510
|
+
* A private package is read and verified through the qualified pnpm with the
|
|
511
|
+
* registry's configured authentication. Every path that assembles a pnpm
|
|
512
|
+
* capability for a release (fresh, recorded-intent preparation, recover and
|
|
513
|
+
* resume) runs this before anything is committed, tagged or published: the
|
|
514
|
+
* `pnpm view <name> dist-tags --json` read joins the qualified contract, then
|
|
515
|
+
* every destination must confirm its authentication.
|
|
476
516
|
*/
|
|
477
|
-
const
|
|
517
|
+
const assertPrivateNpmReleaseCapabilities = async (
|
|
478
518
|
smartshellArg: plugins.smartshell.Smartshell,
|
|
479
519
|
cwdArg: string,
|
|
480
520
|
capabilityArg: IPnpmReleaseCapability,
|
|
@@ -483,6 +523,7 @@ const assertPrivateNpmAuthentication = async (
|
|
|
483
523
|
nextStepArg: string,
|
|
484
524
|
): Promise<void> => {
|
|
485
525
|
if (accessArg !== "private") return;
|
|
526
|
+
await assertPnpmDistTagReadCapability(smartshellArg, cwdArg, capabilityArg);
|
|
486
527
|
for (const registry of registriesArg) {
|
|
487
528
|
await assertNpmRegistryAuthentication(
|
|
488
529
|
{ smartshell: smartshellArg, cwd: cwdArg, capability: capabilityArg },
|
|
@@ -632,6 +673,7 @@ const recordReleaseIntent = async (
|
|
|
632
673
|
...(optionsArg.versionFloor
|
|
633
674
|
? { versionFloor: optionsArg.versionFloor }
|
|
634
675
|
: {}),
|
|
676
|
+
...(optionsArg.workflow.line ? { line: optionsArg.workflow.line } : {}),
|
|
635
677
|
},
|
|
636
678
|
plan: {
|
|
637
679
|
targets: optionsArg.workflow.targets,
|
|
@@ -746,6 +788,11 @@ const prepareRecordedRelease = async (
|
|
|
746
788
|
const { version } = intentArg.release;
|
|
747
789
|
const workflow = await resolveReleaseWorkflow({ yes: true }, intentArg.plan);
|
|
748
790
|
assertReleaseConfiguration(workflow, false);
|
|
791
|
+
if (!isSameReleaseLine(workflow.line, intentArg.release.line)) {
|
|
792
|
+
throw new Error(
|
|
793
|
+
`Current release.line (${describeReleaseLine(workflow.line)}) does not match the recorded release (${describeReleaseLine(intentArg.release.line)}).`,
|
|
794
|
+
);
|
|
795
|
+
}
|
|
749
796
|
const gitEnabled = workflow.targets.includes("git");
|
|
750
797
|
if (gitEnabled && intentArg.git?.remote !== workflow.gitRemote) {
|
|
751
798
|
throw new Error(
|
|
@@ -761,18 +808,20 @@ const prepareRecordedRelease = async (
|
|
|
761
808
|
pushTags: workflow.pushTags,
|
|
762
809
|
mergeRequested: false,
|
|
763
810
|
planMode: false,
|
|
811
|
+
releaseLine: intentArg.release.line,
|
|
764
812
|
gitRemotePolicy: createReleaseGitRemotePolicy(
|
|
765
813
|
workflow.gitRemoteTimeoutSeconds,
|
|
766
814
|
),
|
|
767
815
|
});
|
|
768
816
|
if (branch.sourceOid !== intentArg.release.mainOid) {
|
|
769
817
|
throw new Error(
|
|
770
|
-
|
|
818
|
+
`Resume must run from the recorded release commit on ${branch.releaseBranch}.`,
|
|
771
819
|
);
|
|
772
820
|
}
|
|
773
821
|
const refs = await captureReleaseRefs(
|
|
774
822
|
smartshellArg,
|
|
775
823
|
paths.cwd,
|
|
824
|
+
branch.releaseBranch,
|
|
776
825
|
version,
|
|
777
826
|
intentArg.release.mainOid,
|
|
778
827
|
);
|
|
@@ -815,7 +864,13 @@ const prepareRecordedRelease = async (
|
|
|
815
864
|
versionFloor: intentArg.release.versionFloor,
|
|
816
865
|
refs,
|
|
817
866
|
ensurePublicationState: async () => {
|
|
818
|
-
await verifyReleaseRefs(
|
|
867
|
+
await verifyReleaseRefs(
|
|
868
|
+
smartshellArg,
|
|
869
|
+
paths.cwd,
|
|
870
|
+
branch.releaseBranch,
|
|
871
|
+
version,
|
|
872
|
+
refs,
|
|
873
|
+
);
|
|
819
874
|
await revalidateReleasePublicationState(
|
|
820
875
|
smartshellArg,
|
|
821
876
|
branch,
|
|
@@ -1013,6 +1068,9 @@ export const createReleaseJournal = async (
|
|
|
1013
1068
|
...(optionsArg.versionFloor
|
|
1014
1069
|
? { versionFloor: optionsArg.versionFloor }
|
|
1015
1070
|
: {}),
|
|
1071
|
+
...(optionsArg.workflow.line
|
|
1072
|
+
? { line: optionsArg.workflow.line }
|
|
1073
|
+
: {}),
|
|
1016
1074
|
},
|
|
1017
1075
|
artifact,
|
|
1018
1076
|
...(packages.length || giteaAssets ? { packages } : {}),
|
|
@@ -1033,7 +1091,7 @@ export const createReleaseJournal = async (
|
|
|
1033
1091
|
access: optionsArg.workflow.targets.includes("npm")
|
|
1034
1092
|
? optionsArg.workflow.npmAccessLevel
|
|
1035
1093
|
: "public",
|
|
1036
|
-
tag:
|
|
1094
|
+
tag: getReleaseDistTag(optionsArg.workflow.line),
|
|
1037
1095
|
alreadyPublished: optionsArg.workflow.targets.includes("npm")
|
|
1038
1096
|
? optionsArg.workflow.npmAlreadyPublished
|
|
1039
1097
|
: "success",
|
|
@@ -1239,6 +1297,11 @@ const runReleaseRecover = async (
|
|
|
1239
1297
|
}
|
|
1240
1298
|
const workflow = await resolveReleaseWorkflow({ yes: true });
|
|
1241
1299
|
assertReleaseConfiguration(workflow, false);
|
|
1300
|
+
if (workflow.line) {
|
|
1301
|
+
throw new Error(
|
|
1302
|
+
`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\`.`,
|
|
1303
|
+
);
|
|
1304
|
+
}
|
|
1242
1305
|
let branch = await inspectReleaseBranch({
|
|
1243
1306
|
smartshell: shell,
|
|
1244
1307
|
cwd: paths.cwd,
|
|
@@ -1255,6 +1318,7 @@ const runReleaseRecover = async (
|
|
|
1255
1318
|
const refs = await captureReleaseRefs(
|
|
1256
1319
|
shell,
|
|
1257
1320
|
paths.cwd,
|
|
1321
|
+
branch.releaseBranch,
|
|
1258
1322
|
version,
|
|
1259
1323
|
branch.sourceOid,
|
|
1260
1324
|
);
|
|
@@ -1317,7 +1381,7 @@ const runReleaseRecover = async (
|
|
|
1317
1381
|
branch = await prepareReleaseIntegration(shell, branch);
|
|
1318
1382
|
options.branch = branch;
|
|
1319
1383
|
const ensureState = async (remote = branch.remoteMainOid) => {
|
|
1320
|
-
await verifyReleaseRefs(shell, paths.cwd, version, refs);
|
|
1384
|
+
await verifyReleaseRefs(shell, paths.cwd, branch.releaseBranch, version, refs);
|
|
1321
1385
|
await revalidateReleasePublicationState(
|
|
1322
1386
|
shell,
|
|
1323
1387
|
branch,
|
|
@@ -1519,7 +1583,7 @@ const runReleaseResume = async (
|
|
|
1519
1583
|
);
|
|
1520
1584
|
await assertNoLegacyNpmPublisher(paths.cwd);
|
|
1521
1585
|
await assertNoStandaloneTspublishPublisher(paths.cwd);
|
|
1522
|
-
await
|
|
1586
|
+
await assertPrivateNpmReleaseCapabilities(
|
|
1523
1587
|
smartshellInstance,
|
|
1524
1588
|
paths.cwd,
|
|
1525
1589
|
pnpmCapability,
|
|
@@ -1548,6 +1612,7 @@ const runReleaseResume = async (
|
|
|
1548
1612
|
pushTags: true,
|
|
1549
1613
|
mergeRequested: false,
|
|
1550
1614
|
planMode: false,
|
|
1615
|
+
releaseLine: journal.release.line,
|
|
1551
1616
|
gitRemotePolicy: createReleaseGitRemotePolicy(
|
|
1552
1617
|
resumeConfiguration.gitRemoteTimeoutSeconds,
|
|
1553
1618
|
),
|
|
@@ -1580,6 +1645,7 @@ const runReleaseResume = async (
|
|
|
1580
1645
|
await verifyReleaseRefs(
|
|
1581
1646
|
smartshellInstance,
|
|
1582
1647
|
paths.cwd,
|
|
1648
|
+
branchContext.releaseBranch,
|
|
1583
1649
|
version,
|
|
1584
1650
|
refs,
|
|
1585
1651
|
verificationOnly,
|
|
@@ -1647,6 +1713,11 @@ const assertResumeConfiguration = async (
|
|
|
1647
1713
|
journalArg: TReleaseJournal,
|
|
1648
1714
|
cwdArg: string,
|
|
1649
1715
|
): Promise<void> => {
|
|
1716
|
+
if (!isSameReleaseLine(workflowArg.line, journalArg.release.line)) {
|
|
1717
|
+
throw new Error(
|
|
1718
|
+
`Current release.line (${describeReleaseLine(workflowArg.line)}) does not match the journal (${describeReleaseLine(journalArg.release.line)}).`,
|
|
1719
|
+
);
|
|
1720
|
+
}
|
|
1650
1721
|
if (
|
|
1651
1722
|
journalArg.git.state !== "skipped" &&
|
|
1652
1723
|
workflowArg.gitRemote !== journalArg.git.remote
|
|
@@ -1701,6 +1772,14 @@ const printReleaseJournalSummary = (journalArg: TReleaseJournal): void => {
|
|
|
1701
1772
|
),
|
|
1702
1773
|
);
|
|
1703
1774
|
}
|
|
1775
|
+
if (journalArg.release.line) {
|
|
1776
|
+
console.log(
|
|
1777
|
+
`release line: ${journalArg.release.line.branch} (npm dist-tag ${journalArg.release.line.distTag})`,
|
|
1778
|
+
);
|
|
1779
|
+
}
|
|
1780
|
+
if (journalArg.npm.registries.length > 0) {
|
|
1781
|
+
console.log(`npm dist-tag: ${journalArg.npm.tag}`);
|
|
1782
|
+
}
|
|
1704
1783
|
console.log(`journal revision: ${journalArg.revision}`);
|
|
1705
1784
|
console.log(
|
|
1706
1785
|
`artifact: ${journalArg.artifact ? `${journalArg.artifact.integrity} (${journalArg.artifact.sha256})` : "none"}`,
|
|
@@ -1836,6 +1915,7 @@ async function runChangelogStep(
|
|
|
1836
1915
|
|
|
1837
1916
|
async function runReleaseCommitStep(
|
|
1838
1917
|
smartshellInstance: plugins.smartshell.Smartshell,
|
|
1918
|
+
releaseBranchArg: string,
|
|
1839
1919
|
newVersion: string,
|
|
1840
1920
|
cwdArg: string,
|
|
1841
1921
|
): Promise<string> {
|
|
@@ -1886,14 +1966,16 @@ async function runReleaseCommitStep(
|
|
|
1886
1966
|
if (branchResult.exitCode !== 0) {
|
|
1887
1967
|
throw new Error(
|
|
1888
1968
|
formatCommandFailure(
|
|
1889
|
-
|
|
1969
|
+
`The release commit was not created on ${releaseBranchArg}.`,
|
|
1890
1970
|
branchResult,
|
|
1891
1971
|
{ command: "git symbolic-ref", timeoutMs: 60_000 },
|
|
1892
1972
|
),
|
|
1893
1973
|
);
|
|
1894
1974
|
}
|
|
1895
|
-
if (branchResult.stdout.trim() !==
|
|
1896
|
-
throw new Error(
|
|
1975
|
+
if (branchResult.stdout.trim() !== `refs/heads/${releaseBranchArg}`) {
|
|
1976
|
+
throw new Error(
|
|
1977
|
+
`The release commit was not created on ${releaseBranchArg}.`,
|
|
1978
|
+
);
|
|
1897
1979
|
}
|
|
1898
1980
|
const headOid = await resolveGitObjectOid(
|
|
1899
1981
|
smartshellInstance,
|
|
@@ -1903,11 +1985,11 @@ async function runReleaseCommitStep(
|
|
|
1903
1985
|
const mainOid = await resolveGitObjectOid(
|
|
1904
1986
|
smartshellInstance,
|
|
1905
1987
|
cwdArg,
|
|
1906
|
-
|
|
1988
|
+
`refs/heads/${releaseBranchArg}^{commit}`,
|
|
1907
1989
|
);
|
|
1908
1990
|
if (headOid !== mainOid) {
|
|
1909
1991
|
throw new Error(
|
|
1910
|
-
|
|
1992
|
+
`HEAD and ${releaseBranchArg} diverged after creating the release commit.`,
|
|
1911
1993
|
);
|
|
1912
1994
|
}
|
|
1913
1995
|
return mainOid;
|
|
@@ -1986,16 +2068,17 @@ const resolveGitObjectOid = async (
|
|
|
1986
2068
|
const captureReleaseRefs = async (
|
|
1987
2069
|
smartshellInstanceArg: plugins.smartshell.Smartshell,
|
|
1988
2070
|
cwdArg: string,
|
|
2071
|
+
releaseBranchArg: string,
|
|
1989
2072
|
newVersionArg: string,
|
|
1990
2073
|
expectedMainOidArg?: string,
|
|
1991
|
-
// Verification reads the release commit through its tag, so
|
|
1992
|
-
// to carry later commits.
|
|
2074
|
+
// Verification reads the release commit through its tag, so the release
|
|
2075
|
+
// branch is allowed to carry later commits.
|
|
1993
2076
|
mainMayBeAheadArg = false,
|
|
1994
2077
|
): Promise<IReleaseRefs> => {
|
|
1995
2078
|
const mainOid = await resolveGitObjectOid(
|
|
1996
2079
|
smartshellInstanceArg,
|
|
1997
2080
|
cwdArg,
|
|
1998
|
-
|
|
2081
|
+
`refs/heads/${releaseBranchArg}^{commit}`,
|
|
1999
2082
|
);
|
|
2000
2083
|
const tagOid = await resolveGitObjectOid(
|
|
2001
2084
|
smartshellInstanceArg,
|
|
@@ -2014,7 +2097,7 @@ const captureReleaseRefs = async (
|
|
|
2014
2097
|
tagCommitOid !== releaseOid
|
|
2015
2098
|
) {
|
|
2016
2099
|
throw new Error(
|
|
2017
|
-
|
|
2100
|
+
`The release tag is not bound to the captured ${releaseBranchArg} release commit.`,
|
|
2018
2101
|
);
|
|
2019
2102
|
}
|
|
2020
2103
|
return { mainOid: releaseOid, tagOid };
|
|
@@ -2023,6 +2106,7 @@ const captureReleaseRefs = async (
|
|
|
2023
2106
|
const verifyReleaseRefs = async (
|
|
2024
2107
|
smartshellInstanceArg: plugins.smartshell.Smartshell,
|
|
2025
2108
|
cwdArg: string,
|
|
2109
|
+
releaseBranchArg: string,
|
|
2026
2110
|
newVersionArg: string,
|
|
2027
2111
|
expectedRefsArg: IReleaseRefs,
|
|
2028
2112
|
mainMayBeAheadArg = false,
|
|
@@ -2030,6 +2114,7 @@ const verifyReleaseRefs = async (
|
|
|
2030
2114
|
const currentRefs = await captureReleaseRefs(
|
|
2031
2115
|
smartshellInstanceArg,
|
|
2032
2116
|
cwdArg,
|
|
2117
|
+
releaseBranchArg,
|
|
2033
2118
|
newVersionArg,
|
|
2034
2119
|
expectedRefsArg.mainOid,
|
|
2035
2120
|
mainMayBeAheadArg,
|
|
@@ -2039,7 +2124,7 @@ const verifyReleaseRefs = async (
|
|
|
2039
2124
|
currentRefs.tagOid !== expectedRefsArg.tagOid
|
|
2040
2125
|
) {
|
|
2041
2126
|
throw new Error(
|
|
2042
|
-
|
|
2127
|
+
`Local release refs changed before publication. Inspect ${releaseBranchArg} and the release tag before retrying.`,
|
|
2043
2128
|
);
|
|
2044
2129
|
}
|
|
2045
2130
|
};
|
|
@@ -2059,7 +2144,7 @@ export const resolveResumeReleaseRefs = async (
|
|
|
2059
2144
|
if (branchContextArg.sourceOid !== journalArg.release.mainOid) {
|
|
2060
2145
|
if (!verificationOnly) {
|
|
2061
2146
|
throw new Error(
|
|
2062
|
-
|
|
2147
|
+
`Resume must run from the journaled release commit on ${branchContextArg.releaseBranch}.`,
|
|
2063
2148
|
);
|
|
2064
2149
|
}
|
|
2065
2150
|
await verifyReleaseHistoryRetained(
|
|
@@ -2071,6 +2156,7 @@ export const resolveResumeReleaseRefs = async (
|
|
|
2071
2156
|
const refs = await captureReleaseRefs(
|
|
2072
2157
|
smartshellInstanceArg,
|
|
2073
2158
|
cwdArg,
|
|
2159
|
+
branchContextArg.releaseBranch,
|
|
2074
2160
|
journalArg.release.version,
|
|
2075
2161
|
journalArg.release.mainOid,
|
|
2076
2162
|
verificationOnly,
|
|
@@ -2132,17 +2218,76 @@ function shellQuote(value: string): string {
|
|
|
2132
2218
|
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
2133
2219
|
}
|
|
2134
2220
|
|
|
2135
|
-
|
|
2221
|
+
const describeReleaseLine = (lineArg: IReleaseLine | undefined): string =>
|
|
2222
|
+
lineArg
|
|
2223
|
+
? `branch ${lineArg.branch}, npm dist-tag ${lineArg.distTag}`
|
|
2224
|
+
: "none, releasing main";
|
|
2225
|
+
|
|
2226
|
+
/**
|
|
2227
|
+
* What a line release would do to each public package's dist-tags, read the
|
|
2228
|
+
* way the release reads them. A private package is read with the registry's
|
|
2229
|
+
* authentication, which the plan does not use.
|
|
2230
|
+
*/
|
|
2231
|
+
const describeReleaseLineDistTags = async (
|
|
2232
|
+
workflowArg: IResolvedReleaseWorkflow,
|
|
2233
|
+
versionArg: string,
|
|
2234
|
+
): Promise<string[]> => {
|
|
2235
|
+
if (!workflowArg.line || !workflowArg.npmPackages) return [];
|
|
2236
|
+
const lines: string[] = [];
|
|
2237
|
+
for (const packageName of getReleaseNpmPublicationOrder(
|
|
2238
|
+
workflowArg.npmPackages,
|
|
2239
|
+
)) {
|
|
2240
|
+
for (const registry of workflowArg.npmRegistries) {
|
|
2241
|
+
const prefix = `npm dist-tags of ${packageName} at ${registry}:`;
|
|
2242
|
+
if (workflowArg.npmAccessLevel === "private") {
|
|
2243
|
+
lines.push(
|
|
2244
|
+
`${prefix} read with the registry's authentication when the release runs`,
|
|
2245
|
+
);
|
|
2246
|
+
continue;
|
|
2247
|
+
}
|
|
2248
|
+
const read = await readAnonymousNpmDistTags(registry, packageName);
|
|
2249
|
+
if (read.status === "inconclusive") {
|
|
2250
|
+
lines.push(
|
|
2251
|
+
`${prefix} unreadable (${read.code}); the release stops until the registry answers`,
|
|
2252
|
+
);
|
|
2253
|
+
continue;
|
|
2254
|
+
}
|
|
2255
|
+
const distTags = read.status === "present" ? read.distTags : undefined;
|
|
2256
|
+
const refusal = findDistTagPublicationRefusal(distTags, {
|
|
2257
|
+
packageName,
|
|
2258
|
+
registry,
|
|
2259
|
+
version: versionArg,
|
|
2260
|
+
distTag: workflowArg.npmDistTag,
|
|
2261
|
+
});
|
|
2262
|
+
if (refusal) {
|
|
2263
|
+
lines.push(`${prefix} refused: ${refusal}`);
|
|
2264
|
+
continue;
|
|
2265
|
+
}
|
|
2266
|
+
const lineVersion = distTags?.[workflowArg.npmDistTag];
|
|
2267
|
+
lines.push(
|
|
2268
|
+
`${prefix} ${workflowArg.npmDistTag} ${typeof lineVersion === "string" ? lineVersion : "(new)"} -> ${versionArg}, ${latestDistTag} ${String(distTags?.[latestDistTag])} unchanged`,
|
|
2269
|
+
);
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
return lines;
|
|
2273
|
+
};
|
|
2274
|
+
|
|
2275
|
+
async function printReleasePlan(
|
|
2136
2276
|
workflow: IResolvedReleaseWorkflow,
|
|
2137
2277
|
branchContextArg: IReleaseBranchContext,
|
|
2138
2278
|
versionResolutionArg: IReleaseVersionResolution,
|
|
2139
|
-
): void {
|
|
2279
|
+
): Promise<void> {
|
|
2140
2280
|
console.log("");
|
|
2141
2281
|
console.log("gitzone release - resolved workflow");
|
|
2142
2282
|
console.log(`confirmation: ${workflow.confirmation}`);
|
|
2143
2283
|
console.log(`plan: ${workflow.plan.join(" -> ")}`);
|
|
2144
2284
|
console.log(`source branch: ${branchContextArg.sourceBranch}`);
|
|
2145
|
-
if (
|
|
2285
|
+
if (workflow.line) {
|
|
2286
|
+
console.log(
|
|
2287
|
+
`release line: ${workflow.line.branch} -> npm dist-tag ${workflow.line.distTag} (major ${releaseVersionMajor(versionResolutionArg.currentVersion)}; latest is never moved)`,
|
|
2288
|
+
);
|
|
2289
|
+
}
|
|
2290
|
+
if (branchContextArg.sourceBranch !== branchContextArg.releaseBranch) {
|
|
2146
2291
|
console.log("release branch: main (fast-forward integration requested)");
|
|
2147
2292
|
console.log(
|
|
2148
2293
|
`remote main ancestry: ${branchContextArg.planAncestryVerified ? "verified" : "deferred until execution"}`,
|
|
@@ -2161,6 +2306,12 @@ function printReleasePlan(
|
|
|
2161
2306
|
console.log(
|
|
2162
2307
|
`npm registries: ${workflow.npmRegistries.length > 0 ? workflow.npmRegistries.join(", ") : "none"}`,
|
|
2163
2308
|
);
|
|
2309
|
+
console.log(`npm dist-tag: ${workflow.npmDistTag}`);
|
|
2310
|
+
for (const line of await describeReleaseLineDistTags(
|
|
2311
|
+
workflow,
|
|
2312
|
+
versionResolutionArg.version,
|
|
2313
|
+
))
|
|
2314
|
+
console.log(line);
|
|
2164
2315
|
}
|
|
2165
2316
|
if (workflow.npmPackages) {
|
|
2166
2317
|
for (const line of describeReleaseNpmPackages(workflow.npmPackages))
|