@git.zone/cli 8.9.2 → 8.10.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.
Files changed (71) hide show
  1. package/assets/templates/npm/.package.json +1 -1
  2. package/assets/templates/service/.package.json +1 -1
  3. package/assets/templates/wcc/.package.json +1 -1
  4. package/assets/templates/website/.package.json +1 -1
  5. package/dist_ts/00_commitinfo_data.js +2 -2
  6. package/dist_ts/classes.project.js +1 -1
  7. package/dist_ts/gitzone.cli.js +1 -1
  8. package/dist_ts/helpers.climode.d.ts +2 -1
  9. package/dist_ts/helpers.climode.js +1 -1
  10. package/dist_ts/helpers.ownerscopes.d.ts +1 -1
  11. package/dist_ts/helpers.smartconfig.js +1 -1
  12. package/dist_ts/helpers.tsdocker.js +1 -1
  13. package/dist_ts/helpers.tstest.js +1 -1
  14. package/dist_ts/helpers.workflow.d.ts +7 -1
  15. package/dist_ts/helpers.workflow.js +15 -2
  16. package/dist_ts/mod_commit/index.js +1 -1
  17. package/dist_ts/mod_config/classes.commitconfig.js +1 -1
  18. package/dist_ts/mod_config/classes.releaseconfig.js +1 -1
  19. package/dist_ts/mod_config/index.js +7 -4
  20. package/dist_ts/mod_deprecate/helpers.deprecation.js +1 -1
  21. package/dist_ts/mod_deprecate/index.js +1 -1
  22. package/dist_ts/mod_format/classes.formatcontext.js +1 -1
  23. package/dist_ts/mod_format/classes.formatplanner.js +1 -1
  24. package/dist_ts/mod_format/classes.formatstats.js +1 -1
  25. package/dist_ts/mod_format/formatters/assets.formatter.js +1 -1
  26. package/dist_ts/mod_format/formatters/deno.formatter.js +1 -1
  27. package/dist_ts/mod_format/index.js +1 -1
  28. package/dist_ts/mod_release/classes.releasejournal.d.ts +9 -0
  29. package/dist_ts/mod_release/classes.releasejournal.js +76 -5
  30. package/dist_ts/mod_release/helpers.giteaassets.js +1 -1
  31. package/dist_ts/mod_release/helpers.gitremote.js +1 -1
  32. package/dist_ts/mod_release/helpers.npmartifact.d.ts +10 -6
  33. package/dist_ts/mod_release/helpers.npmartifact.js +10 -7
  34. package/dist_ts/mod_release/helpers.npmartifactcheck.js +1 -1
  35. package/dist_ts/mod_release/helpers.releaseline.d.ts +14 -5
  36. package/dist_ts/mod_release/helpers.releaseline.js +63 -6
  37. package/dist_ts/mod_release/helpers.releasephase.js +1 -1
  38. package/dist_ts/mod_release/helpers.releasepublication.js +4 -3
  39. package/dist_ts/mod_release/helpers.releaseversion.js +1 -1
  40. package/dist_ts/mod_release/helpers.tsdockerprotocol.js +1 -1
  41. package/dist_ts/mod_release/index.js +42 -7
  42. package/dist_ts/mod_services/classes.dockercontainer.js +1 -1
  43. package/dist_ts/mod_services/classes.globalregistry.js +1 -1
  44. package/dist_ts/mod_services/classes.globalregistrystore.js +1 -1
  45. package/dist_ts/mod_services/classes.legacymongomigration.d.ts +1 -1
  46. package/dist_ts/mod_services/classes.legacymongomigration.js +1 -1
  47. package/dist_ts/mod_services/classes.serviceconfiguration.js +1 -1
  48. package/dist_ts/mod_services/classes.servicemanager.js +1 -1
  49. package/dist_ts/mod_services/classes.servicenames.js +1 -1
  50. package/dist_ts/mod_services/classes.serviceoptions.js +1 -1
  51. package/dist_ts/mod_services/classes.servicepruner.js +1 -1
  52. package/dist_ts/mod_services/helpers.js +1 -1
  53. package/dist_ts/mod_services/index.js +1 -1
  54. package/dist_ts/mod_standard/index.js +1 -1
  55. package/dist_ts/mod_testing/classes.commands.js +1 -1
  56. package/dist_ts/mod_testing/classes.runtime.js +1 -1
  57. package/dist_ts/mod_testing/index.js +1 -1
  58. package/dist_ts/mod_tools/index.js +1 -1
  59. package/dist_ts/paths.js +1 -1
  60. package/dist_ts_migration/001.service-selection.js +1 -1
  61. package/dist_ts_migration/004.global-registry.js +1 -1
  62. package/package.json +5 -5
  63. package/readme.md +87 -9
  64. package/ts/00_commitinfo_data.ts +1 -1
  65. package/ts/helpers.workflow.ts +26 -2
  66. package/ts/mod_config/index.ts +7 -2
  67. package/ts/mod_release/classes.releasejournal.ts +87 -2
  68. package/ts/mod_release/helpers.npmartifact.ts +11 -6
  69. package/ts/mod_release/helpers.releaseline.ts +90 -7
  70. package/ts/mod_release/helpers.releasepublication.ts +3 -2
  71. package/ts/mod_release/index.ts +118 -30
@@ -3,6 +3,7 @@ import { formatCommandFailure } from "./helpers.commandfailure.js";
3
3
  import { InterProcessLock } from "../mod_services/classes.interprocesslock.js";
4
4
  import {
5
5
  resolveGiteaAssetsConfiguration,
6
+ resolveReleaseRecordRetention,
6
7
  type TReleaseRecordedPlan,
7
8
  type TReleaseTarget,
8
9
  } from "../helpers.workflow.js";
@@ -41,6 +42,7 @@ import {
41
42
  import {
42
43
  getReleaseDistTag,
43
44
  getReleaseDockerAliasPolicy,
45
+ latestDistTag,
44
46
  parseReleaseLine,
45
47
  type IReleaseLine,
46
48
  } from "./helpers.releaseline.js";
@@ -655,8 +657,9 @@ const assertReleaseLineRecord = (valueArg: unknown): IReleaseLine => {
655
657
 
656
658
  /**
657
659
  * Only a line release claims a publication with the `latest` version it found,
658
- * and the guard admitted it only with a higher major than the release. The
659
- * record exists once the publication was claimed.
660
+ * and the guard admitted it only with a higher major than the release. A line
661
+ * that takes `latest` itself records none. The record exists once the
662
+ * publication was claimed.
660
663
  */
661
664
  const assertPreviousLatest = (
662
665
  registryArg: Record<string, unknown>,
@@ -667,6 +670,7 @@ const assertPreviousLatest = (
667
670
  const prerelease = parsePrereleaseVersion(releaseArg.version);
668
671
  if (
669
672
  (!releaseArg.line && !releaseArg.prerelease) ||
673
+ releaseArg.line?.distTag === latestDistTag ||
670
674
  typeof previousLatest !== "string" ||
671
675
  !isCanonicalReleaseVersion(previousLatest) ||
672
676
  (prerelease
@@ -2292,6 +2296,87 @@ export class ReleaseJournalStore {
2292
2296
  );
2293
2297
  }
2294
2298
 
2299
+ /** Pins artifacts for the whole publication or resume, including its reads. */
2300
+ public async withReleaseRecord<T>(
2301
+ versionArg: string,
2302
+ operationArg: () => Promise<T>,
2303
+ ): Promise<T> {
2304
+ return this.getRecordLock(versionArg).runExclusive(operationArg);
2305
+ }
2306
+
2307
+ private getRecordLock(versionArg: string): InterProcessLock {
2308
+ const version = normalizeReleaseVersion(versionArg);
2309
+ return new InterProcessLock({
2310
+ lockPath: `${this.getReleaseDirectory(version)}.record.lock`,
2311
+ description: `Release record v${version}`,
2312
+ });
2313
+ }
2314
+
2315
+ /**
2316
+ * Only a completed run trims completed records. The current record, intents,
2317
+ * and records pinned by another publisher/resume remain available. Invalid
2318
+ * journals stop retention before deletion rather than guessing their state.
2319
+ */
2320
+ public async pruneCompleted(
2321
+ keepArg: number,
2322
+ currentVersionArg: string,
2323
+ ): Promise<string[]> {
2324
+ const keep = resolveReleaseRecordRetention(keepArg);
2325
+ const currentVersion = normalizeReleaseVersion(currentVersionArg);
2326
+ const retentionLock = new InterProcessLock({
2327
+ lockPath: plugins.path.join(this.rootPath, "retention.lock"),
2328
+ description: "Release record retention",
2329
+ });
2330
+ return retentionLock.runExclusive(async () => {
2331
+ if ((await this.read(currentVersion)).completedAt === null) return [];
2332
+ const completed = (await this.list())
2333
+ .filter((journal) => journal.completedAt !== null)
2334
+ .sort(
2335
+ (left, right) =>
2336
+ right.createdAt.localeCompare(left.createdAt) ||
2337
+ compareSupportedReleaseVersions(
2338
+ right.release.version,
2339
+ left.release.version,
2340
+ ),
2341
+ );
2342
+ const pruned: string[] = [];
2343
+ for (const journal of completed.slice(keep)) {
2344
+ const version = journal.release.version;
2345
+ if (version === currentVersion) continue;
2346
+ const recordLock = this.getRecordLock(version);
2347
+ if (await recordLock.readHolder()) continue;
2348
+ await recordLock.runExclusive(async () => {
2349
+ const directory = this.getReleaseDirectory(version);
2350
+ const journalLock = new InterProcessLock({
2351
+ lockPath: `${directory}.lock`,
2352
+ description: `Release journal v${version}`,
2353
+ });
2354
+ await journalLock.runExclusive(async () => {
2355
+ const current = await this.read(version);
2356
+ if (current.completedAt === null) return;
2357
+ // Even a malformed intent protects the record; do not interpret it.
2358
+ try {
2359
+ await plugins.fs.lstat(this.getIntentPath(version));
2360
+ return;
2361
+ } catch (error) {
2362
+ if ((error as NodeJS.ErrnoException).code !== "ENOENT")
2363
+ throw error;
2364
+ }
2365
+ const stat = await plugins.fs.lstat(directory);
2366
+ if (!stat.isDirectory() || stat.isSymbolicLink())
2367
+ throw new Error(
2368
+ `Release record v${version} is not a regular directory.`,
2369
+ );
2370
+ await plugins.fs.rm(directory, { recursive: true, force: false });
2371
+ await syncDirectory(this.rootPath);
2372
+ pruned.push(version);
2373
+ });
2374
+ });
2375
+ }
2376
+ return pruned;
2377
+ });
2378
+ }
2379
+
2295
2380
  public async installPrepared(
2296
2381
  temporaryDirectoryArg: string,
2297
2382
  journalArg: TReleaseJournal,
@@ -1259,11 +1259,11 @@ const tagSupersedesVersion = (
1259
1259
  /**
1260
1260
  * Reads the dist-tags of a published version. A prerelease needs stable latest
1261
1261
  * below its core and an exact or later sequence of its own channel and core.
1262
- * `latest` follows the rule
1263
- * above. A maintenance line's tag is superseded only by a later version of
1264
- * its own major, and a line release additionally requires `latest` to still
1265
- * carry a higher major: a line whose version took `latest` is a terminal
1266
- * conflict, because the registry now serves it as the newest release.
1262
+ * `latest`, of `main` or of a line that takes it, follows the rule above. A
1263
+ * maintenance line's own tag is superseded only by a later version of its
1264
+ * own major, and such a line additionally requires `latest` to still carry a
1265
+ * higher major: a line whose version took `latest` is a terminal conflict,
1266
+ * because the registry now serves it as the newest release.
1267
1267
  */
1268
1268
  export const assessPublishedDistTags = (
1269
1269
  distTagsArg: Record<string, unknown> | undefined,
@@ -1834,6 +1834,8 @@ export interface INpmDistTagPreflightOptions {
1834
1834
  packageNames: readonly string[];
1835
1835
  version: string;
1836
1836
  distTag: string;
1837
+ /** The release publishes from a release line. */
1838
+ line: boolean;
1837
1839
  /** What the operator runs once an authentication failure is fixed. */
1838
1840
  nextStep: string;
1839
1841
  probeOptions?: INpmArtifactProbeOptions;
@@ -1842,7 +1844,9 @@ export interface INpmDistTagPreflightOptions {
1842
1844
  /**
1843
1845
  * Before anything is committed or tagged, every package at every registry
1844
1846
  * must allow `version` under `distTag`: a `main` release never moves `latest`
1845
- * downwards, and a line never takes `latest` or moves its own tag backwards.
1847
+ * downwards, a line under its own tag never takes `latest` or moves its tag
1848
+ * backwards, and a line under `latest` takes it only while every higher major
1849
+ * is a prerelease.
1846
1850
  * A registry that cannot be read stops the release as well, because nothing
1847
1851
  * else proves the dist-tags it would change. A private read needs the
1848
1852
  * capability the release qualified with {@link assertPnpmDistTagReadCapability}.
@@ -1880,6 +1884,7 @@ export const assertNpmDistTagsAllowPublication = async (
1880
1884
  registry,
1881
1885
  version: optionsArg.version,
1882
1886
  distTag: optionsArg.distTag,
1887
+ line: optionsArg.line,
1883
1888
  },
1884
1889
  );
1885
1890
  if (refusal) refusals.push(refusal);
@@ -14,8 +14,10 @@ export const latestDistTag = "latest";
14
14
 
15
15
  /**
16
16
  * A maintenance line: an older major released from its own branch under its
17
- * own npm dist-tag, so that `latest` never moves. Its Docker images carry only
18
- * tags bound to the release version, so no floating image tag moves either.
17
+ * own npm dist-tag, so that `latest` never moves. A line whose dist-tag is
18
+ * `latest` takes it only while every higher major is a prerelease, see
19
+ * {@link findDistTagPublicationRefusal}. Its Docker images carry only tags
20
+ * bound to the release version, so no floating image tag moves either.
19
21
  * The block is committed on the maintenance branch itself, which makes that
20
22
  * branch, and only that branch, a release source.
21
23
  */
@@ -60,7 +62,10 @@ export const isReleaseLineDistTag = (valueArg: unknown): boolean =>
60
62
  !/^v*(?:\d+|x)$/.test(valueArg) &&
61
63
  valueArg !== latestDistTag;
62
64
 
63
- /** Validates `release.line`; absent means the release runs from `main`. */
65
+ /**
66
+ * Validates `release.line`; absent means the release runs from `main`. The
67
+ * dist-tag is a {@link isReleaseLineDistTag} tag of its own, or `latest`.
68
+ */
64
69
  export const parseReleaseLine = (
65
70
  valueArg: unknown,
66
71
  contextArg = "release.line",
@@ -86,9 +91,12 @@ export const parseReleaseLine = (
86
91
  `${contextArg}.branch must be a canonical Git branch name other than main, found ${JSON.stringify(valueArg.branch)}.`,
87
92
  );
88
93
  }
89
- if (!isReleaseLineDistTag(valueArg.distTag)) {
94
+ if (
95
+ valueArg.distTag !== latestDistTag &&
96
+ !isReleaseLineDistTag(valueArg.distTag)
97
+ ) {
90
98
  throw new Error(
91
- `${contextArg}.distTag must be lowercase letters and digits joined by hyphens, start with a letter, and be neither "latest" nor a semver range such as "v4", found ${JSON.stringify(valueArg.distTag)}.`,
99
+ `${contextArg}.distTag must be "latest" or lowercase letters and digits joined by hyphens that start with a letter and are not a semver range such as "v4", found ${JSON.stringify(valueArg.distTag)}.`,
92
100
  );
93
101
  }
94
102
  return {
@@ -158,6 +166,8 @@ export interface IDistTagSubject {
158
166
  registry: string;
159
167
  version: string;
160
168
  distTag: string;
169
+ /** The release publishes from a release line; required for a line that takes `latest`. */
170
+ line?: boolean;
161
171
  }
162
172
 
163
173
  const describeDistTagValue = (valueArg: unknown): string =>
@@ -170,8 +180,10 @@ const describeDistTagValue = (valueArg: unknown): string =>
170
180
  *
171
181
  * - `main` (`latest`): a canonical `latest` above the version would move
172
182
  * `latest` downwards, so it refuses.
173
- * - A line: `latest` must already carry a higher major, so the line can never
174
- * take `latest`, and the line's own tag must not be ahead of the version.
183
+ * - A line under its own tag: `latest` must already carry a higher major, so
184
+ * the line never takes `latest`, and the line's own tag must not be ahead
185
+ * of the version.
186
+ * - A line under `latest`: see {@link findLatestLineRefusal}.
175
187
  */
176
188
  export const findDistTagPublicationRefusal = (
177
189
  distTagsArg: Record<string, unknown> | undefined,
@@ -202,6 +214,7 @@ export const findDistTagPublicationRefusal = (
202
214
  return `${packageName} at ${registry}: prerelease dist-tag ${distTag} points at ${describeDistTagValue(tagged)}, which is not a prior release of the configured identifier; publishing would overwrite a different channel or move it backwards.`;
203
215
  }
204
216
  if (distTag === latestDistTag) {
217
+ if (subjectArg.line) return findLatestLineRefusal(distTagsArg, subjectArg);
205
218
  if (
206
219
  typeof latest === "string" &&
207
220
  isCanonicalReleaseVersion(latest) &&
@@ -239,6 +252,76 @@ export const findDistTagPublicationRefusal = (
239
252
  );
240
253
  };
241
254
 
255
+ /** The major of an npm version and whether it is a prerelease; `undefined` for anything else. */
256
+ const parseNpmVersion = (
257
+ valueArg: unknown,
258
+ ): { major: bigint; prerelease: boolean } | undefined => {
259
+ const match =
260
+ typeof valueArg === "string"
261
+ ? /^(0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.exec(
262
+ valueArg,
263
+ )
264
+ : null;
265
+ return match
266
+ ? { major: BigInt(match[1]), prerelease: match[2] !== undefined }
267
+ : undefined;
268
+ };
269
+
270
+ /**
271
+ * A line whose dist-tag is `latest` releases the stable major while `main`
272
+ * has published the next major only as a prerelease. It may move `latest`
273
+ * only upwards within its own major, and only while the dist-tags show that
274
+ * the higher major is a prerelease: `latest` is a canonical version of the
275
+ * line's major not above the release, some dist-tag carries a prerelease of a
276
+ * higher major, and no dist-tag carries a stable version of a higher major.
277
+ * Once the higher major is stable the line needs a dist-tag of its own.
278
+ */
279
+ const findLatestLineRefusal = (
280
+ distTagsArg: Record<string, unknown> | undefined,
281
+ subjectArg: IDistTagSubject,
282
+ ): string | undefined => {
283
+ const { packageName, registry, version } = subjectArg;
284
+ const major = releaseVersionMajor(version);
285
+ const latest = distTagsArg?.[latestDistTag];
286
+ const ownTag = `Give the line a dist-tag of its own in release.line.distTag (see "Maintenance lines" in the gitzone readme).`;
287
+ const higherMajor = (prereleaseArg: boolean) =>
288
+ Object.entries(distTagsArg ?? {}).filter(([, valueArg]) => {
289
+ const parsed = parseNpmVersion(valueArg);
290
+ return (
291
+ parsed !== undefined &&
292
+ parsed.prerelease === prereleaseArg &&
293
+ parsed.major > major
294
+ );
295
+ });
296
+ const higherStable = higherMajor(false);
297
+ if (higherStable.length > 0) {
298
+ return (
299
+ `${packageName} at ${registry}: release line latest takes latest only while every higher major is a prerelease, but ${higherStable.map(([tagArg, valueArg]) => `${tagArg} carries ${describeDistTagValue(valueArg)}`).join(", ")}. ` +
300
+ ownTag
301
+ );
302
+ }
303
+ if (
304
+ typeof latest !== "string" ||
305
+ !isCanonicalReleaseVersion(latest) ||
306
+ releaseVersionMajor(latest) !== major
307
+ ) {
308
+ return (
309
+ `${packageName} at ${registry}: release line latest requires the latest dist-tag to carry a stable version of major ${major}, but latest is ${describeDistTagValue(latest)}. ` +
310
+ ownTag
311
+ );
312
+ }
313
+ if (compareReleaseVersions(latest, version) > 0) {
314
+ return `${packageName} at ${registry}: the latest dist-tag points at ${latest}, above ${version}. A release line never moves latest downwards.`;
315
+ }
316
+ if (higherMajor(true).length === 0) {
317
+ return (
318
+ `${packageName} at ${registry}: release line latest takes latest only while a higher major is published as a prerelease, but no dist-tag carries a prerelease above major ${major}. ` +
319
+ "Release this major from main instead."
320
+ );
321
+ }
322
+ return undefined;
323
+ };
324
+
242
325
  /**
243
326
  * gitzone never writes dist-tags. When a line release finds `latest` on its
244
327
  * own version, it names the command that restores the version `latest`
@@ -780,8 +780,8 @@ const markNpmProbeFailure = async (
780
780
  * Right before a version is published, the registry's dist-tags must still
781
781
  * allow it: the guard the release ran in preflight, repeated per package and
782
782
  * registry, because a registry can change between the two. A refusal is a
783
- * terminal dist-tag conflict and nothing is published. A line returns the
784
- * `latest` version it found, which its claim records.
783
+ * terminal dist-tag conflict and nothing is published. A line under its own
784
+ * tag returns the `latest` version it found, which its claim records.
785
785
  */
786
786
  const assertNpmDistTagsBeforePublication = async (
787
787
  optionsArg: IReleasePublicationOptions,
@@ -821,6 +821,7 @@ const assertNpmDistTagsBeforePublication = async (
821
821
  registry: selectorArg.registry,
822
822
  version: journalArg.release.version,
823
823
  distTag: journalArg.npm.tag,
824
+ line: journalArg.release.line !== undefined,
824
825
  });
825
826
  if (refusal) {
826
827
  await markUnclaimedTarget(
@@ -83,7 +83,10 @@ import {
83
83
  latestDistTag,
84
84
  type IReleaseLine,
85
85
  } from "./helpers.releaseline.js";
86
- import { executeReleasePublication } from "./helpers.releasepublication.js";
86
+ import {
87
+ executeReleasePublication,
88
+ type IReleasePublicationOptions,
89
+ } from "./helpers.releasepublication.js";
87
90
  import {
88
91
  findNpmArtifactCheckError,
89
92
  verifyPackedNpmArtifacts,
@@ -296,6 +299,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
296
299
  packageNames: getReleaseNpmPublicationOrder(workflow.npmPackages),
297
300
  version: newVersion,
298
301
  distTag: workflow.npmDistTag,
302
+ line: workflow.line !== undefined,
299
303
  nextStep: "release again",
300
304
  });
301
305
  }
@@ -458,20 +462,23 @@ const runInternal = async (argvArg: any): Promise<void> => {
458
462
  { cause: error },
459
463
  );
460
464
  }
461
- const finalJournal = await executeReleasePublication({
462
- pnpmCapability,
463
- smartshell: smartshellInstance,
464
- cwd: releaseCwd,
465
- store: journalContext.store,
466
- journal: journalContext.journal,
467
- pushUrl: releasePushUrl,
468
- npmVerificationWindowMs: workflow.npmVerificationWindowMinutes * 60_000,
469
- giteaAssetTransfer: workflow.giteaAssetTransfer,
470
- giteaAssetConcurrency: workflow.giteaAssetConcurrency,
471
- gitRemotePolicy: branchContext.gitRemotePolicy,
472
- tsdocker: journalContext.tsdocker,
473
- ensurePublicationState,
474
- });
465
+ const finalJournal = await publishReleaseWithRetention(
466
+ {
467
+ pnpmCapability,
468
+ smartshell: smartshellInstance,
469
+ cwd: releaseCwd,
470
+ store: journalContext.store,
471
+ journal: journalContext.journal,
472
+ pushUrl: releasePushUrl,
473
+ npmVerificationWindowMs: workflow.npmVerificationWindowMinutes * 60_000,
474
+ giteaAssetTransfer: workflow.giteaAssetTransfer,
475
+ giteaAssetConcurrency: workflow.giteaAssetConcurrency,
476
+ gitRemotePolicy: branchContext.gitRemotePolicy,
477
+ tsdocker: journalContext.tsdocker,
478
+ ensurePublicationState,
479
+ },
480
+ workflow.recordRetention,
481
+ );
475
482
  await cleanTestArtifactsForCompletedRelease(
476
483
  smartshellInstance,
477
484
  releaseCwd,
@@ -481,6 +488,35 @@ const runInternal = async (argvArg: any): Promise<void> => {
481
488
  printReleaseJournalSummary(finalJournal);
482
489
  };
483
490
 
491
+ const publishReleaseWithRetention = async (
492
+ optionsArg: IReleasePublicationOptions,
493
+ keepArg: number,
494
+ ): Promise<TReleaseJournal> =>
495
+ optionsArg.store.withReleaseRecord(
496
+ optionsArg.journal.release.version,
497
+ async () => {
498
+ const journal = await executeReleasePublication(optionsArg);
499
+ await pruneCompletedReleaseRecords(optionsArg.store, journal, keepArg);
500
+ return journal;
501
+ },
502
+ );
503
+
504
+ const pruneCompletedReleaseRecords = async (
505
+ storeArg: ReleaseJournalStore,
506
+ journalArg: TReleaseJournal,
507
+ keepArg: number,
508
+ ): Promise<void> => {
509
+ if (journalArg.completedAt === null) return;
510
+ const versions = await storeArg.pruneCompleted(
511
+ keepArg,
512
+ journalArg.release.version,
513
+ );
514
+ if (versions.length > 0)
515
+ console.log(
516
+ `Pruned completed release records: ${versions.map((version) => `v${version}`).join(", ")}`,
517
+ );
518
+ };
519
+
484
520
  /**
485
521
  * What an operator does after the release failed between its tag and its
486
522
  * journal. Most such failures are environmental, and resuming the recorded
@@ -1550,20 +1586,23 @@ const runReleaseRecover = async (
1550
1586
  },
1551
1587
  }),
1552
1588
  );
1553
- const result = await executeReleasePublication({
1554
- pnpmCapability,
1555
- smartshell: shell,
1556
- cwd: paths.cwd,
1557
- store: context.store,
1558
- journal: context.journal,
1559
- pushUrl: branch.pushUrl,
1560
- npmVerificationWindowMs: workflow.npmVerificationWindowMinutes * 60_000,
1561
- giteaAssetTransfer: workflow.giteaAssetTransfer,
1562
- giteaAssetConcurrency: workflow.giteaAssetConcurrency,
1563
- gitRemotePolicy: branch.gitRemotePolicy,
1564
- tsdocker,
1565
- ensurePublicationState: ensureState,
1566
- });
1589
+ const result = await publishReleaseWithRetention(
1590
+ {
1591
+ pnpmCapability,
1592
+ smartshell: shell,
1593
+ cwd: paths.cwd,
1594
+ store: context.store,
1595
+ journal: context.journal,
1596
+ pushUrl: branch.pushUrl,
1597
+ npmVerificationWindowMs: workflow.npmVerificationWindowMinutes * 60_000,
1598
+ giteaAssetTransfer: workflow.giteaAssetTransfer,
1599
+ giteaAssetConcurrency: workflow.giteaAssetConcurrency,
1600
+ gitRemotePolicy: branch.gitRemotePolicy,
1601
+ tsdocker,
1602
+ ensurePublicationState: ensureState,
1603
+ },
1604
+ workflow.recordRetention,
1605
+ );
1567
1606
  printReleaseJournalSummary(result);
1568
1607
  };
1569
1608
 
@@ -1638,6 +1677,37 @@ const runReleaseResume = async (
1638
1677
  const store = new ReleaseJournalStore(
1639
1678
  await resolveGitCommonDirectory(smartshellInstance, paths.cwd),
1640
1679
  );
1680
+ return store.withReleaseRecord(version, () =>
1681
+ runReleaseResumeFromStore({
1682
+ argv: argvArg,
1683
+ mode: modeArg,
1684
+ smartshell: smartshellInstance,
1685
+ store,
1686
+ version,
1687
+ detach,
1688
+ recoveryAttemptId,
1689
+ }),
1690
+ );
1691
+ };
1692
+
1693
+ const runReleaseResumeFromStore = async (optionsArg: {
1694
+ argv: any;
1695
+ mode: ICliMode;
1696
+ smartshell: plugins.smartshell.Smartshell;
1697
+ store: ReleaseJournalStore;
1698
+ version: string;
1699
+ detach: boolean;
1700
+ recoveryAttemptId?: string;
1701
+ }): Promise<void> => {
1702
+ const {
1703
+ argv: argvArg,
1704
+ mode: modeArg,
1705
+ smartshell: smartshellInstance,
1706
+ store,
1707
+ version,
1708
+ detach,
1709
+ recoveryAttemptId,
1710
+ } = optionsArg;
1641
1711
  const detachedRuns = await openDetachedReleaseRuns(paths.cwd);
1642
1712
  await detachedRuns.assertNoForeignRun();
1643
1713
  if (detach) {
@@ -1817,6 +1887,11 @@ const runReleaseResume = async (
1817
1887
  tsdocker,
1818
1888
  ensurePublicationState,
1819
1889
  });
1890
+ await pruneCompletedReleaseRecords(
1891
+ store,
1892
+ finalJournal,
1893
+ resumeConfiguration.recordRetention,
1894
+ );
1820
1895
  await cleanTestArtifactsForCompletedRelease(
1821
1896
  smartshellInstance,
1822
1897
  paths.cwd,
@@ -2443,11 +2518,21 @@ const describeReleaseLineDistTags = async (
2443
2518
  registry,
2444
2519
  version: versionArg,
2445
2520
  distTag: workflowArg.npmDistTag,
2521
+ line: workflowArg.line !== undefined,
2446
2522
  });
2447
2523
  if (refusal) {
2448
2524
  lines.push(`${prefix} refused: ${refusal}`);
2449
2525
  continue;
2450
2526
  }
2527
+ if (workflowArg.npmDistTag === latestDistTag) {
2528
+ const otherTags = Object.entries(distTags ?? {})
2529
+ .filter(([tagArg]) => tagArg !== latestDistTag)
2530
+ .map(([tagArg, valueArg]) => `${tagArg} ${String(valueArg)}`);
2531
+ lines.push(
2532
+ `${prefix} ${latestDistTag} ${String(distTags?.[latestDistTag])} -> ${versionArg}, ${otherTags.join(", ")} unchanged`,
2533
+ );
2534
+ continue;
2535
+ }
2451
2536
  const lineVersion = distTags?.[workflowArg.npmDistTag];
2452
2537
  lines.push(
2453
2538
  `${prefix} ${workflowArg.npmDistTag} ${typeof lineVersion === "string" ? lineVersion : "(new)"} -> ${versionArg}, ${latestDistTag} ${String(distTags?.[latestDistTag])} unchanged`,
@@ -2520,6 +2605,9 @@ async function printReleasePlan(
2520
2605
  console.log("gitzone release - resolved workflow");
2521
2606
  console.log(`confirmation: ${workflow.confirmation}`);
2522
2607
  console.log(`plan: ${workflow.plan.join(" -> ")}`);
2608
+ console.log(
2609
+ `record retention: newest ${workflow.recordRetention} completed records (incomplete and active records are retained)`,
2610
+ );
2523
2611
  console.log(`source branch: ${branchContextArg.sourceBranch}`);
2524
2612
  if (workflow.prerelease)
2525
2613
  console.log(
@@ -2527,7 +2615,7 @@ async function printReleasePlan(
2527
2615
  );
2528
2616
  if (workflow.line) {
2529
2617
  console.log(
2530
- `release line: ${workflow.line.branch} -> npm dist-tag ${workflow.line.distTag} (major ${releaseVersionMajor(versionResolutionArg.currentVersion)}; latest is never moved)`,
2618
+ `release line: ${workflow.line.branch} -> npm dist-tag ${workflow.line.distTag} (major ${releaseVersionMajor(versionResolutionArg.currentVersion)}; ${workflow.line.distTag === latestDistTag ? "latest moves only while every higher major is a prerelease" : "latest is never moved"})`,
2531
2619
  );
2532
2620
  }
2533
2621
  if (branchContextArg.sourceBranch !== branchContextArg.releaseBranch) {