@git.zone/cli 7.2.3 → 7.2.4
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/mod_release/classes.releasejournal.js +6 -4
- package/dist_ts/mod_release/helpers.commandfailure.d.ts +44 -0
- package/dist_ts/mod_release/helpers.commandfailure.js +177 -0
- package/dist_ts/mod_release/helpers.npmartifact.d.ts +1 -0
- package/dist_ts/mod_release/helpers.npmartifact.js +43 -9
- package/dist_ts/mod_release/helpers.releasebranch.js +46 -16
- package/dist_ts/mod_release/helpers.releasepreparation.js +12 -4
- package/dist_ts/mod_release/helpers.releasepublication.js +24 -7
- package/dist_ts/mod_release/helpers.tsdockerprotocol.js +25 -11
- package/dist_ts/mod_release/index.js +30 -8
- package/package.json +1 -1
- package/readme.md +18 -0
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/mod_release/classes.releasejournal.ts +11 -5
- package/ts/mod_release/helpers.commandfailure.ts +258 -0
- package/ts/mod_release/helpers.npmartifact.ts +68 -11
- package/ts/mod_release/helpers.releasebranch.ts +72 -17
- package/ts/mod_release/helpers.releasepreparation.ts +29 -3
- package/ts/mod_release/helpers.releasepublication.ts +51 -6
- package/ts/mod_release/helpers.tsdockerprotocol.ts +35 -10
- package/ts/mod_release/index.ts +55 -9
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
type INpmArtifactProbeResult,
|
|
36
36
|
} from "./helpers.npmartifact.js";
|
|
37
37
|
import { isAbsentGitOid, releaseGitEnv } from "./helpers.releasebranch.js";
|
|
38
|
+
import { describeCommandFailure } from "./helpers.commandfailure.js";
|
|
38
39
|
import {
|
|
39
40
|
TsdockerReleaseCommandError,
|
|
40
41
|
TsdockerReleaseRequestCleanupError,
|
|
@@ -97,8 +98,17 @@ type TGitProbeStatus = "pending" | "exact" | "conflict" | "inconclusive";
|
|
|
97
98
|
|
|
98
99
|
interface IGitProbeResult {
|
|
99
100
|
status: TGitProbeStatus;
|
|
101
|
+
/** Why an inconclusive probe could not read the remote refs. */
|
|
102
|
+
failure?: string;
|
|
100
103
|
}
|
|
101
104
|
|
|
105
|
+
/** Appends why a probe could not read the remote refs, when it knows. */
|
|
106
|
+
const withGitProbeFailure = (
|
|
107
|
+
messageArg: string,
|
|
108
|
+
probeArg: IGitProbeResult,
|
|
109
|
+
): string =>
|
|
110
|
+
probeArg.failure ? `${messageArg} ${probeArg.failure}` : messageArg;
|
|
111
|
+
|
|
102
112
|
export interface IReleasePublicationOptions {
|
|
103
113
|
pnpmCapability?: IPnpmReleaseCapability;
|
|
104
114
|
smartshell: plugins.smartshell.Smartshell;
|
|
@@ -319,7 +329,13 @@ const inspectRemoteRelease = async (
|
|
|
319
329
|
},
|
|
320
330
|
);
|
|
321
331
|
if (result.exitCode !== 0) {
|
|
322
|
-
return {
|
|
332
|
+
return {
|
|
333
|
+
status: "inconclusive",
|
|
334
|
+
failure: describeCommandFailure(result, {
|
|
335
|
+
command: "git ls-remote",
|
|
336
|
+
timeoutMs: gitProbeTimeoutMs,
|
|
337
|
+
}),
|
|
338
|
+
};
|
|
323
339
|
}
|
|
324
340
|
const refs = new Map<string, string>();
|
|
325
341
|
for (const line of result.stdout.split("\n")) {
|
|
@@ -388,7 +404,10 @@ const executeGitTarget = async (
|
|
|
388
404
|
throw new Error("Previously verified Git release refs no longer match.");
|
|
389
405
|
}
|
|
390
406
|
throw new Error(
|
|
391
|
-
|
|
407
|
+
withGitProbeFailure(
|
|
408
|
+
"Previously verified Git release refs cannot currently be verified.",
|
|
409
|
+
probe,
|
|
410
|
+
),
|
|
392
411
|
);
|
|
393
412
|
}
|
|
394
413
|
|
|
@@ -415,7 +434,12 @@ const executeGitTarget = async (
|
|
|
415
434
|
throw new Error("Remote Git refs conflict with the release journal.");
|
|
416
435
|
}
|
|
417
436
|
if (probe.status === "inconclusive") {
|
|
418
|
-
throw new Error(
|
|
437
|
+
throw new Error(
|
|
438
|
+
withGitProbeFailure(
|
|
439
|
+
"Remote Git publication state is inconclusive.",
|
|
440
|
+
probe,
|
|
441
|
+
),
|
|
442
|
+
);
|
|
419
443
|
}
|
|
420
444
|
journal = await recoverPublishingTarget(
|
|
421
445
|
optionsArg.store,
|
|
@@ -468,7 +492,12 @@ const executeGitTarget = async (
|
|
|
468
492
|
"failed",
|
|
469
493
|
"verification-inconclusive",
|
|
470
494
|
);
|
|
471
|
-
throw new Error(
|
|
495
|
+
throw new Error(
|
|
496
|
+
withGitProbeFailure(
|
|
497
|
+
"Remote Git publication state is inconclusive.",
|
|
498
|
+
probe,
|
|
499
|
+
),
|
|
500
|
+
);
|
|
472
501
|
}
|
|
473
502
|
|
|
474
503
|
await optionsArg.ensurePublicationState(expectedRemoteMainOid);
|
|
@@ -525,7 +554,19 @@ const executeGitTarget = async (
|
|
|
525
554
|
"failed",
|
|
526
555
|
pushResult.exitCode === 0 ? "verification-inconclusive" : "command-failed",
|
|
527
556
|
);
|
|
528
|
-
|
|
557
|
+
const pushFailure =
|
|
558
|
+
pushResult.exitCode === 0
|
|
559
|
+
? ""
|
|
560
|
+
: ` ${describeCommandFailure(pushResult, {
|
|
561
|
+
command: "git push",
|
|
562
|
+
timeoutMs: gitPushTimeoutMs,
|
|
563
|
+
})}`;
|
|
564
|
+
throw new Error(
|
|
565
|
+
withGitProbeFailure(
|
|
566
|
+
`Git publication did not produce verifiable remote refs.${pushFailure}`,
|
|
567
|
+
probe,
|
|
568
|
+
),
|
|
569
|
+
);
|
|
529
570
|
};
|
|
530
571
|
|
|
531
572
|
const probeNpm = async (
|
|
@@ -842,7 +883,11 @@ const executeNpmRegistry = async (
|
|
|
842
883
|
"failed",
|
|
843
884
|
"command-failed",
|
|
844
885
|
);
|
|
845
|
-
throw new Error(
|
|
886
|
+
throw new Error(
|
|
887
|
+
publishResult.failure
|
|
888
|
+
? `npm publication was rejected: ${registryArg} ${publishResult.failure}`
|
|
889
|
+
: `npm publication was rejected: ${registryArg}`,
|
|
890
|
+
);
|
|
846
891
|
};
|
|
847
892
|
|
|
848
893
|
const requireTsdocker = (
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as plugins from "./mod.plugins.js";
|
|
2
2
|
import { getProjectTsdockerBinPath } from "../helpers.tsdocker.js";
|
|
3
|
+
import { formatCommandFailure } from "./helpers.commandfailure.js";
|
|
3
4
|
import { supportsTsdockerMinimumVersion } from "../helpers.workflow.js";
|
|
4
5
|
import type {
|
|
5
6
|
IReleaseCapabilitiesResult,
|
|
@@ -143,27 +144,40 @@ const parseProtocolOutput = (
|
|
|
143
144
|
resultArg: plugins.smartshell.IExecResult,
|
|
144
145
|
commandArg: TReleaseProtocolCommand,
|
|
145
146
|
): unknown => {
|
|
147
|
+
const withFailure = (messageArg: string): string =>
|
|
148
|
+
formatCommandFailure(messageArg, resultArg, {
|
|
149
|
+
command: `tsdocker ${commandArg}`,
|
|
150
|
+
timeoutMs: commandTimeouts[commandArg],
|
|
151
|
+
});
|
|
146
152
|
if (resultArg.timedOut) {
|
|
147
153
|
throw new TsdockerReleaseCommandError(
|
|
148
154
|
commandArg,
|
|
149
155
|
"COMMAND_TIMEOUT",
|
|
150
|
-
|
|
156
|
+
withFailure(
|
|
157
|
+
`tSDocker ${commandArg} timed out with an unresolved outcome.`,
|
|
158
|
+
),
|
|
151
159
|
);
|
|
152
160
|
}
|
|
153
161
|
if (resultArg.signal) {
|
|
154
162
|
throw new TsdockerReleaseCommandError(
|
|
155
163
|
commandArg,
|
|
156
164
|
"COMMAND_SIGNALLED",
|
|
157
|
-
|
|
165
|
+
withFailure(
|
|
166
|
+
`tSDocker ${commandArg} was terminated with an unresolved outcome.`,
|
|
167
|
+
),
|
|
158
168
|
);
|
|
159
169
|
}
|
|
160
170
|
if (resultArg.stderr !== "") {
|
|
161
171
|
throw new TsdockerReleaseCommandError(
|
|
162
172
|
commandArg,
|
|
163
173
|
"INVALID_PROTOCOL_OUTPUT",
|
|
164
|
-
`tSDocker ${commandArg} wrote non-protocol stderr output
|
|
174
|
+
withFailure(`tSDocker ${commandArg} wrote non-protocol stderr output.`),
|
|
165
175
|
);
|
|
166
176
|
}
|
|
177
|
+
// Past this point stderr is empty, so a failure detail names only the exit
|
|
178
|
+
// code, which is worth naming whenever the protocol output is unusable.
|
|
179
|
+
const withExitCode = (messageArg: string): string =>
|
|
180
|
+
resultArg.exitCode === 0 ? messageArg : withFailure(messageArg);
|
|
167
181
|
if (
|
|
168
182
|
Buffer.byteLength(resultArg.stdout) > responseByteLimit ||
|
|
169
183
|
!resultArg.stdout.endsWith("\n")
|
|
@@ -171,7 +185,9 @@ const parseProtocolOutput = (
|
|
|
171
185
|
throw new TsdockerReleaseCommandError(
|
|
172
186
|
commandArg,
|
|
173
187
|
"INVALID_PROTOCOL_OUTPUT",
|
|
174
|
-
|
|
188
|
+
withExitCode(
|
|
189
|
+
`tSDocker ${commandArg} returned an invalid response envelope.`,
|
|
190
|
+
),
|
|
175
191
|
);
|
|
176
192
|
}
|
|
177
193
|
|
|
@@ -182,14 +198,14 @@ const parseProtocolOutput = (
|
|
|
182
198
|
throw new TsdockerReleaseCommandError(
|
|
183
199
|
commandArg,
|
|
184
200
|
"INVALID_PROTOCOL_OUTPUT",
|
|
185
|
-
`tSDocker ${commandArg} returned invalid JSON
|
|
201
|
+
withExitCode(`tSDocker ${commandArg} returned invalid JSON.`),
|
|
186
202
|
);
|
|
187
203
|
}
|
|
188
204
|
if (canonicalReleaseJsonDocument(parsed) !== resultArg.stdout) {
|
|
189
205
|
throw new TsdockerReleaseCommandError(
|
|
190
206
|
commandArg,
|
|
191
207
|
"INVALID_PROTOCOL_OUTPUT",
|
|
192
|
-
`tSDocker ${commandArg} returned noncanonical JSON
|
|
208
|
+
withExitCode(`tSDocker ${commandArg} returned noncanonical JSON.`),
|
|
193
209
|
);
|
|
194
210
|
}
|
|
195
211
|
if (resultArg.exitCode !== 0) {
|
|
@@ -209,7 +225,9 @@ const parseProtocolOutput = (
|
|
|
209
225
|
throw new TsdockerReleaseCommandError(
|
|
210
226
|
commandArg,
|
|
211
227
|
"INVALID_PROTOCOL_OUTPUT",
|
|
212
|
-
|
|
228
|
+
withFailure(
|
|
229
|
+
`tSDocker ${commandArg} failed without a valid protocol error.`,
|
|
230
|
+
),
|
|
213
231
|
);
|
|
214
232
|
}
|
|
215
233
|
}
|
|
@@ -260,17 +278,24 @@ export class TsdockerReleaseClient implements ITsdockerReleaseClient {
|
|
|
260
278
|
timeoutKillGraceMs: 5_000,
|
|
261
279
|
},
|
|
262
280
|
);
|
|
281
|
+
const versionMessage =
|
|
282
|
+
"Docker release journal schema 2 requires one matching project-local @git.zone/tsdocker package and binary.";
|
|
263
283
|
if (
|
|
264
284
|
versionResult.exitCode !== 0 ||
|
|
265
285
|
versionResult.timedOut ||
|
|
266
286
|
versionResult.signal ||
|
|
267
|
-
versionResult.stderr !== ""
|
|
268
|
-
versionResult.stdout.trim() !== installedVersion
|
|
287
|
+
versionResult.stderr !== ""
|
|
269
288
|
) {
|
|
270
289
|
throw new Error(
|
|
271
|
-
|
|
290
|
+
formatCommandFailure(versionMessage, versionResult, {
|
|
291
|
+
command: "tsdocker --version",
|
|
292
|
+
timeoutMs: 30_000,
|
|
293
|
+
}),
|
|
272
294
|
);
|
|
273
295
|
}
|
|
296
|
+
if (versionResult.stdout.trim() !== installedVersion) {
|
|
297
|
+
throw new Error(versionMessage);
|
|
298
|
+
}
|
|
274
299
|
|
|
275
300
|
const parsed = await this.run("release-capabilities");
|
|
276
301
|
return plugins.tsdockerReleaseProtocol.assertReleaseCapabilitiesResult(
|
package/ts/mod_release/index.ts
CHANGED
|
@@ -65,6 +65,7 @@ import {
|
|
|
65
65
|
planReleaseNpmPackages,
|
|
66
66
|
} from "./helpers.npmpackages.js";
|
|
67
67
|
import { executeReleasePublication } from "./helpers.releasepublication.js";
|
|
68
|
+
import { formatCommandFailure } from "./helpers.commandfailure.js";
|
|
68
69
|
import { runTstestCleanup } from "../helpers.tstest.js";
|
|
69
70
|
import {
|
|
70
71
|
assertPackageReleaseRecovery,
|
|
@@ -1356,7 +1357,12 @@ async function runCommandStep(
|
|
|
1356
1357
|
console.log(`\n${label}`);
|
|
1357
1358
|
const result = await smartshellInstance.exec(command, { cwd: cwdArg });
|
|
1358
1359
|
if (result.exitCode !== 0) {
|
|
1359
|
-
throw new Error(
|
|
1360
|
+
throw new Error(
|
|
1361
|
+
formatCommandFailure(`${label} failed. Aborting release.`, result, {
|
|
1362
|
+
command,
|
|
1363
|
+
output: "combined",
|
|
1364
|
+
}),
|
|
1365
|
+
);
|
|
1360
1366
|
}
|
|
1361
1367
|
logger.log("success", `${label} passed.`);
|
|
1362
1368
|
}
|
|
@@ -1376,6 +1382,15 @@ async function verifyCleanTree(
|
|
|
1376
1382
|
timeoutKillGraceMs: 5_000,
|
|
1377
1383
|
},
|
|
1378
1384
|
);
|
|
1385
|
+
if (statusResult.exitCode !== 0) {
|
|
1386
|
+
throw new Error(
|
|
1387
|
+
formatCommandFailure(
|
|
1388
|
+
"Unable to inspect the release worktree.",
|
|
1389
|
+
statusResult,
|
|
1390
|
+
{ command: "git status", timeoutMs: 60_000 },
|
|
1391
|
+
),
|
|
1392
|
+
);
|
|
1393
|
+
}
|
|
1379
1394
|
if (statusResult.stdout.trim() !== "") {
|
|
1380
1395
|
throw new Error(errorMessage);
|
|
1381
1396
|
}
|
|
@@ -1434,7 +1449,12 @@ async function runReleaseCommitStep(
|
|
|
1434
1449
|
timeoutKillGraceMs: 5_000,
|
|
1435
1450
|
});
|
|
1436
1451
|
if (addResult.exitCode !== 0) {
|
|
1437
|
-
throw new Error(
|
|
1452
|
+
throw new Error(
|
|
1453
|
+
formatCommandFailure("Staging release metadata failed.", addResult, {
|
|
1454
|
+
command: "git add",
|
|
1455
|
+
timeoutMs: 60_000,
|
|
1456
|
+
}),
|
|
1457
|
+
);
|
|
1438
1458
|
}
|
|
1439
1459
|
const result = await smartshellInstance.execSpawn(
|
|
1440
1460
|
"git",
|
|
@@ -1447,7 +1467,13 @@ async function runReleaseCommitStep(
|
|
|
1447
1467
|
},
|
|
1448
1468
|
);
|
|
1449
1469
|
if (result.exitCode !== 0) {
|
|
1450
|
-
throw new Error(
|
|
1470
|
+
throw new Error(
|
|
1471
|
+
formatCommandFailure("Release commit failed.", result, {
|
|
1472
|
+
command: "git commit",
|
|
1473
|
+
timeoutMs: 60_000,
|
|
1474
|
+
output: "combined",
|
|
1475
|
+
}),
|
|
1476
|
+
);
|
|
1451
1477
|
}
|
|
1452
1478
|
const branchResult = await smartshellInstance.execSpawn(
|
|
1453
1479
|
"git",
|
|
@@ -1460,10 +1486,16 @@ async function runReleaseCommitStep(
|
|
|
1460
1486
|
timeoutKillGraceMs: 5_000,
|
|
1461
1487
|
},
|
|
1462
1488
|
);
|
|
1463
|
-
if (
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1489
|
+
if (branchResult.exitCode !== 0) {
|
|
1490
|
+
throw new Error(
|
|
1491
|
+
formatCommandFailure(
|
|
1492
|
+
"The release commit was not created on main.",
|
|
1493
|
+
branchResult,
|
|
1494
|
+
{ command: "git symbolic-ref", timeoutMs: 60_000 },
|
|
1495
|
+
),
|
|
1496
|
+
);
|
|
1497
|
+
}
|
|
1498
|
+
if (branchResult.stdout.trim() !== "refs/heads/main") {
|
|
1467
1499
|
throw new Error("The release commit was not created on main.");
|
|
1468
1500
|
}
|
|
1469
1501
|
const headOid = await resolveGitObjectOid(
|
|
@@ -1508,7 +1540,12 @@ async function runTagStep(
|
|
|
1508
1540
|
},
|
|
1509
1541
|
);
|
|
1510
1542
|
if (result.exitCode !== 0) {
|
|
1511
|
-
throw new Error(
|
|
1543
|
+
throw new Error(
|
|
1544
|
+
formatCommandFailure("Release tag failed.", result, {
|
|
1545
|
+
command: "git tag",
|
|
1546
|
+
timeoutMs: 60_000,
|
|
1547
|
+
}),
|
|
1548
|
+
);
|
|
1512
1549
|
}
|
|
1513
1550
|
}
|
|
1514
1551
|
|
|
@@ -1534,7 +1571,16 @@ const resolveGitObjectOid = async (
|
|
|
1534
1571
|
},
|
|
1535
1572
|
);
|
|
1536
1573
|
const oid = result.stdout.trim();
|
|
1537
|
-
if (result.exitCode !== 0
|
|
1574
|
+
if (result.exitCode !== 0) {
|
|
1575
|
+
throw new Error(
|
|
1576
|
+
formatCommandFailure(
|
|
1577
|
+
`Unable to resolve release Git object ${revisionArg}.`,
|
|
1578
|
+
result,
|
|
1579
|
+
{ command: "git rev-parse", timeoutMs: 60_000 },
|
|
1580
|
+
),
|
|
1581
|
+
);
|
|
1582
|
+
}
|
|
1583
|
+
if (!/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i.test(oid)) {
|
|
1538
1584
|
throw new Error(`Unable to resolve release Git object ${revisionArg}.`);
|
|
1539
1585
|
}
|
|
1540
1586
|
return oid;
|