@git.zone/cli 8.4.0 → 8.5.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.
@@ -85,6 +85,10 @@ import {
85
85
  } from "./helpers.releaseline.js";
86
86
  import { executeReleasePublication } from "./helpers.releasepublication.js";
87
87
  import { formatCommandFailure } from "./helpers.commandfailure.js";
88
+ import {
89
+ formatReleaseDuration,
90
+ printReleasePhase,
91
+ } from "./helpers.releasephase.js";
88
92
  import { runTstestCleanup } from "../helpers.tstest.js";
89
93
  import {
90
94
  assertPackageReleaseRecovery,
@@ -335,10 +339,9 @@ const runInternal = async (argvArg: any): Promise<void> => {
335
339
  branchContext,
336
340
  );
337
341
  if (workflow.runTests) {
338
- await runCommandStep(
342
+ await runReleaseTests(
339
343
  smartshellInstance,
340
344
  branchContext.sourceCwd,
341
- "Running tests",
342
345
  workflow.testCommand,
343
346
  );
344
347
  }
@@ -437,6 +440,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
437
440
  pushUrl: releasePushUrl,
438
441
  npmVerificationWindowMs: workflow.npmVerificationWindowMinutes * 60_000,
439
442
  giteaAssetTransfer: workflow.giteaAssetTransfer,
443
+ giteaAssetConcurrency: workflow.giteaAssetConcurrency,
440
444
  gitRemotePolicy: branchContext.gitRemotePolicy,
441
445
  tsdocker: journalContext.tsdocker,
442
446
  ensurePublicationState,
@@ -850,8 +854,8 @@ const prepareRecordedRelease = async (
850
854
  : undefined,
851
855
  `run \`gitzone release resume ${version} -y\``,
852
856
  );
853
- console.log(
854
- `\nPreparing the journal of recorded release v${version} from ${refs.mainOid}`,
857
+ printReleasePhase(
858
+ `Preparing the journal of recorded release v${version} from ${refs.mainOid}`,
855
859
  );
856
860
  await prepareTaggedRelease({
857
861
  pnpmCapability,
@@ -1428,6 +1432,7 @@ const runReleaseRecover = async (
1428
1432
  pushUrl: branch.pushUrl,
1429
1433
  npmVerificationWindowMs: workflow.npmVerificationWindowMinutes * 60_000,
1430
1434
  giteaAssetTransfer: workflow.giteaAssetTransfer,
1435
+ giteaAssetConcurrency: workflow.giteaAssetConcurrency,
1431
1436
  gitRemotePolicy: branch.gitRemotePolicy,
1432
1437
  tsdocker,
1433
1438
  ensurePublicationState: ensureState,
@@ -1677,6 +1682,7 @@ const runReleaseResume = async (
1677
1682
  npmVerificationWindowMs:
1678
1683
  resumeConfiguration.npmVerificationWindowMinutes * 60_000,
1679
1684
  giteaAssetTransfer: resumeConfiguration.giteaAssetTransfer,
1685
+ giteaAssetConcurrency: resumeConfiguration.giteaAssetConcurrency,
1680
1686
  gitRemotePolicy: branchContext.gitRemotePolicy,
1681
1687
  tsdocker,
1682
1688
  ensurePublicationState,
@@ -1827,13 +1833,34 @@ function readReleaseLevelOverride(
1827
1833
  return undefined;
1828
1834
  }
1829
1835
 
1836
+ /**
1837
+ * The release preflight tests: the configured test command against the
1838
+ * release source. This is the one seam where a release will ask tstest's run
1839
+ * ledger whether the configured full test set already passed for this exact
1840
+ * tree, and skip the run when it did; until tstest publishes that ledger, the
1841
+ * release always runs the tests.
1842
+ */
1843
+ async function runReleaseTests(
1844
+ smartshellInstance: plugins.smartshell.Smartshell,
1845
+ cwdArg: string,
1846
+ testCommandArg: string,
1847
+ ): Promise<void> {
1848
+ await runCommandStep(
1849
+ smartshellInstance,
1850
+ cwdArg,
1851
+ "Running tests",
1852
+ testCommandArg,
1853
+ );
1854
+ }
1855
+
1830
1856
  async function runCommandStep(
1831
1857
  smartshellInstance: plugins.smartshell.Smartshell,
1832
1858
  cwdArg: string,
1833
1859
  label: string,
1834
1860
  command: string,
1835
1861
  ): Promise<void> {
1836
- console.log(`\n${label}`);
1862
+ printReleasePhase(label);
1863
+ const startedAt = Date.now();
1837
1864
  const result = await smartshellInstance.exec(command, { cwd: cwdArg });
1838
1865
  if (result.exitCode !== 0) {
1839
1866
  throw new Error(
@@ -1843,7 +1870,10 @@ async function runCommandStep(
1843
1870
  }),
1844
1871
  );
1845
1872
  }
1846
- logger.log("success", `${label} passed.`);
1873
+ logger.log(
1874
+ "success",
1875
+ `${label} passed in ${formatReleaseDuration(Date.now() - startedAt)}.`,
1876
+ );
1847
1877
  }
1848
1878
 
1849
1879
  async function verifyCleanTree(
@@ -25,6 +25,8 @@ export interface IGiteaRelease {
25
25
  id: number;
26
26
  tag: string;
27
27
  publicUrl: string;
28
+ /** A draft is visible to repository writers only, its attachments too. */
29
+ draft: boolean;
28
30
  }
29
31
 
30
32
  export interface IGiteaAssetInspection {
@@ -55,6 +57,13 @@ export interface IGiteaAssetsClientOptions
55
57
  commit: string;
56
58
  token: string;
57
59
  fetchImplementation?: typeof fetch;
60
+ /**
61
+ * Longest wait for Gitea to process the pushed release tag before the draft
62
+ * is created; default 15 minutes.
63
+ */
64
+ tagProcessingTimeoutMs?: number;
65
+ /** Pause between two checks whether Gitea processed the tag; default 5 s. */
66
+ tagProcessingPollIntervalMs?: number;
58
67
  }
59
68
 
60
69
  export interface IGiteaAssetPreflight {
@@ -66,20 +75,55 @@ export interface IGiteaAssetPreflight {
66
75
  export interface IGiteaAssetsClient {
67
76
  preflight(): Promise<IGiteaAssetPreflight>;
68
77
  inspectRelease(): Promise<IGiteaRelease | null>;
69
- createRelease(): Promise<IGiteaRelease>;
78
+ /**
79
+ * Waits until Gitea has processed the pushed tag, then creates the draft.
80
+ * Gitea processes a tag push asynchronously and publishes any draft it then
81
+ * finds for the tag, so a draft created earlier would turn public on its own.
82
+ * `onWaiting` is called when the wait starts and about once a minute after.
83
+ */
84
+ createRelease(
85
+ onWaiting?: (elapsedMs: number) => void,
86
+ ): Promise<IGiteaRelease>;
70
87
  /** Downloads and hashes only the present attachments named in `verify`. */
71
88
  inspectAssets(
72
89
  releaseId: number,
73
90
  expected: IGiteaFrozenAsset[],
74
91
  verify?: readonly IGiteaFrozenAsset[],
75
92
  ): Promise<IGiteaAssetInspection>;
93
+ /**
94
+ * Uploads one attachment, only while the release is still a draft exactly
95
+ * when `expectedDraft` says so; otherwise a GiteaReleaseStateChangedError
96
+ * stops before any byte is sent.
97
+ */
76
98
  uploadAsset(
77
99
  releaseId: number,
78
100
  asset: IGiteaFrozenAsset,
79
101
  artifactDirectory: string,
102
+ expectedDraft: boolean,
80
103
  ): Promise<void>;
104
+ /**
105
+ * The complete set, nothing extra, every frozen identity unchanged. Downloads
106
+ * and hashes every attachment except one this client itself downloaded and
107
+ * hashed whose attachment id and UUID are unchanged since. A draft's
108
+ * attachments are listed and downloaded with the token.
109
+ */
81
110
  verifyComplete(
82
111
  releaseId: number,
83
112
  expected: IGiteaFrozenAsset[],
84
113
  ): Promise<void>;
114
+ /**
115
+ * Publishes a draft release (`draft: false`), then proves the release, its
116
+ * attachment identities and every attachment's anonymous download. Every
117
+ * listed attachment must be the one this client hashed (id and UUID; the id
118
+ * alone on a server without UUIDs), otherwise a destination conflict leaves
119
+ * the release a draft. An already published release is only verified.
120
+ * `expectedDraft` is the state the attachments were uploaded for: a draft
121
+ * that something else published meanwhile stops with a
122
+ * GiteaReleaseStateChangedError instead of passing as already published.
123
+ */
124
+ publishRelease(
125
+ releaseId: number,
126
+ expected: IGiteaFrozenAsset[],
127
+ expectedDraft: boolean,
128
+ ): Promise<void>;
85
129
  }