@git.zone/cli 8.10.1 → 8.11.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/assets/templates/asset_tspack_release_gitea/scripts/gitzone-gitea-tag.d.mts +9 -3
- package/assets/templates/asset_tspack_release_gitea/scripts/gitzone-gitea-tag.mjs +50 -6
- package/assets/templates/asset_tspack_release_gitea/scripts/gitzone-release-api.mjs +7 -6
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/helpers.ownerscopes.d.ts +1 -1
- package/dist_ts/helpers.ownerscopes.js +2 -1
- package/dist_ts/helpers.workflow.d.ts +2 -0
- package/dist_ts/helpers.workflow.js +3 -1
- package/dist_ts/mod_release/classes.releasejournal.d.ts +63 -2
- package/dist_ts/mod_release/classes.releasejournal.js +247 -48
- package/dist_ts/mod_release/helpers.giteaassets.js +18 -9
- package/dist_ts/mod_release/index.js +100 -4
- package/package.json +2 -2
- package/readme.md +99 -11
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/helpers.ownerscopes.ts +1 -0
- package/ts/helpers.workflow.ts +6 -0
- package/ts/mod_release/classes.releasejournal.ts +323 -52
- package/ts/mod_release/helpers.giteaassets.ts +19 -10
- package/ts/mod_release/index.ts +132 -2
package/ts/mod_release/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
resolveReleaseDockerConfiguration,
|
|
14
14
|
resolveReleaseWorkflow,
|
|
15
15
|
resolveReleaseResumeConfiguration,
|
|
16
|
+
readReleaseRecordRetention,
|
|
16
17
|
assertGiteaAssetsGitDestination,
|
|
17
18
|
type IResolvedReleaseResumeConfiguration,
|
|
18
19
|
type IResolvedReleaseWorkflow,
|
|
@@ -50,7 +51,9 @@ import {
|
|
|
50
51
|
type IReleaseJournalV2,
|
|
51
52
|
releaseIntentKind,
|
|
52
53
|
type IReleaseIntent,
|
|
54
|
+
type IReleaseRecordPruneReport,
|
|
53
55
|
} from "./classes.releasejournal.js";
|
|
56
|
+
import { formatBytes } from "../mod_services/helpers.js";
|
|
54
57
|
import { createReleaseGitRemotePolicy } from "./helpers.gitremote.js";
|
|
55
58
|
import {
|
|
56
59
|
GiteaAssetsClient,
|
|
@@ -175,6 +178,10 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
175
178
|
await runReleaseRecover(argvArg, mode);
|
|
176
179
|
return;
|
|
177
180
|
}
|
|
181
|
+
if (subcommand === "prune") {
|
|
182
|
+
await runReleasePrune(argvArg, mode);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
178
185
|
if (subcommand !== undefined) {
|
|
179
186
|
throw new Error(`Unknown release subcommand: ${subcommand}`);
|
|
180
187
|
}
|
|
@@ -1384,6 +1391,117 @@ const runReleaseInspect = async (
|
|
|
1384
1391
|
}
|
|
1385
1392
|
};
|
|
1386
1393
|
|
|
1394
|
+
/**
|
|
1395
|
+
* Applies record retention on demand, through the same store method a
|
|
1396
|
+
* completed release uses. Without `--apply` it only reports.
|
|
1397
|
+
*/
|
|
1398
|
+
const runReleasePrune = async (
|
|
1399
|
+
argvArg: any,
|
|
1400
|
+
modeArg: ICliMode,
|
|
1401
|
+
): Promise<void> => {
|
|
1402
|
+
try {
|
|
1403
|
+
const report = await pruneReleaseRecordsOnDemand(argvArg);
|
|
1404
|
+
if (modeArg.json) {
|
|
1405
|
+
printJson({ ok: true, ...report });
|
|
1406
|
+
return;
|
|
1407
|
+
}
|
|
1408
|
+
printReleasePruneReport(report);
|
|
1409
|
+
} catch (error) {
|
|
1410
|
+
if (!modeArg.json) throw error;
|
|
1411
|
+
printJson({
|
|
1412
|
+
ok: false,
|
|
1413
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1414
|
+
});
|
|
1415
|
+
process.exitCode = 1;
|
|
1416
|
+
}
|
|
1417
|
+
};
|
|
1418
|
+
|
|
1419
|
+
const pruneReleaseRecordsOnDemand = async (
|
|
1420
|
+
argvArg: any,
|
|
1421
|
+
): Promise<IReleaseRecordPruneReport> => {
|
|
1422
|
+
const allowed = new Set([
|
|
1423
|
+
"_",
|
|
1424
|
+
"$0",
|
|
1425
|
+
"apply",
|
|
1426
|
+
"keep",
|
|
1427
|
+
"json",
|
|
1428
|
+
"output",
|
|
1429
|
+
"plain",
|
|
1430
|
+
"quiet",
|
|
1431
|
+
"q",
|
|
1432
|
+
"agent",
|
|
1433
|
+
"interactive",
|
|
1434
|
+
"check-updates",
|
|
1435
|
+
"checkUpdates",
|
|
1436
|
+
]);
|
|
1437
|
+
if (
|
|
1438
|
+
argvArg._?.length !== 2 ||
|
|
1439
|
+
Object.keys(argvArg).some((key) => !allowed.has(key)) ||
|
|
1440
|
+
(argvArg.apply !== undefined && argvArg.apply !== true)
|
|
1441
|
+
) {
|
|
1442
|
+
throw new Error(
|
|
1443
|
+
"Usage: gitzone release prune [--apply] [--keep <n>] [--json]",
|
|
1444
|
+
);
|
|
1445
|
+
}
|
|
1446
|
+
let keep: number;
|
|
1447
|
+
if (argvArg.keep === undefined) {
|
|
1448
|
+
keep = await readReleaseRecordRetention();
|
|
1449
|
+
} else if (
|
|
1450
|
+
typeof argvArg.keep === "string" &&
|
|
1451
|
+
/^[1-9][0-9]*$/.test(argvArg.keep) &&
|
|
1452
|
+
Number.isSafeInteger(Number(argvArg.keep))
|
|
1453
|
+
) {
|
|
1454
|
+
keep = Number(argvArg.keep);
|
|
1455
|
+
} else {
|
|
1456
|
+
throw new Error("--keep must be a positive integer.");
|
|
1457
|
+
}
|
|
1458
|
+
const store = new ReleaseJournalStore(
|
|
1459
|
+
await resolveGitCommonDirectory(
|
|
1460
|
+
new plugins.smartshell.Smartshell({
|
|
1461
|
+
executor: "bash",
|
|
1462
|
+
sourceFilePaths: [],
|
|
1463
|
+
}),
|
|
1464
|
+
paths.cwd,
|
|
1465
|
+
),
|
|
1466
|
+
);
|
|
1467
|
+
const active = await store.findActiveReleaseState();
|
|
1468
|
+
if (active.length > 0) {
|
|
1469
|
+
throw new Error(
|
|
1470
|
+
`A release of this repository is in progress; prune refuses to run until it ends. ` +
|
|
1471
|
+
`If no release process is left, inspect and remove: ${active.join(", ")}`,
|
|
1472
|
+
);
|
|
1473
|
+
}
|
|
1474
|
+
return store.pruneRecords({ keep, apply: argvArg.apply === true });
|
|
1475
|
+
};
|
|
1476
|
+
|
|
1477
|
+
const printReleasePruneReport = (reportArg: IReleaseRecordPruneReport) => {
|
|
1478
|
+
console.log(
|
|
1479
|
+
`gitzone release prune - ${reportArg.dryRun ? "dry run" : "applied"}: newest ${reportArg.keep} completed records keep their payloads`,
|
|
1480
|
+
);
|
|
1481
|
+
if (reportArg.records.length === 0) {
|
|
1482
|
+
console.log("No release records found.");
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1485
|
+
for (const entry of reportArg.records) {
|
|
1486
|
+
console.log(
|
|
1487
|
+
` v${entry.version} ${entry.state} ${formatBytes(entry.bytes)} ${entry.action}: ${entry.reason}${entry.payloadBytes > 0 ? ` (payload ${formatBytes(entry.payloadBytes)})` : ""}${entry.detail ? ` - ${entry.detail}` : ""}`,
|
|
1488
|
+
);
|
|
1489
|
+
}
|
|
1490
|
+
const { totals } = reportArg;
|
|
1491
|
+
console.log(
|
|
1492
|
+
`Records: ${totals.records} (kept ${totals.kept}, pruned ${totals.pruned}, blocked ${totals.blocked}); on disk ${formatBytes(totals.bytes)}`,
|
|
1493
|
+
);
|
|
1494
|
+
if (reportArg.records.some((entry) => entry.state === "invalid"))
|
|
1495
|
+
console.log(
|
|
1496
|
+
"An invalid journal stops --apply before anything is deleted; repair or remove that record first.",
|
|
1497
|
+
);
|
|
1498
|
+
console.log(
|
|
1499
|
+
reportArg.dryRun
|
|
1500
|
+
? `Would free ${formatBytes(totals.wouldFreeBytes)}. Run \`gitzone release prune --apply\` to delete it.`
|
|
1501
|
+
: `Freed ${formatBytes(totals.freedBytes)}.`,
|
|
1502
|
+
);
|
|
1503
|
+
};
|
|
1504
|
+
|
|
1387
1505
|
const describeDetachedReleaseRun = (runArg: IDetachedReleaseRun): string => {
|
|
1388
1506
|
const release = `gitzone ${runArg.command.join(" ")} (v${runArg.version})`;
|
|
1389
1507
|
const outcome =
|
|
@@ -1738,6 +1856,10 @@ const runReleaseResumeFromStore = async (optionsArg: {
|
|
|
1738
1856
|
await prepareRecordedRelease(smartshellInstance, intent);
|
|
1739
1857
|
}
|
|
1740
1858
|
const journal = await store.read(version);
|
|
1859
|
+
if (journal.completedAt !== null && (await store.isPayloadMissing(journal)))
|
|
1860
|
+
throw new Error(
|
|
1861
|
+
`Release v${version} is complete and record retention removed its local artifacts; there is nothing left to resume. \`gitzone release inspect ${version}\` shows its journal.`,
|
|
1862
|
+
);
|
|
1741
1863
|
const gitEnabled = journal.git.state !== "skipped";
|
|
1742
1864
|
const resumeConfiguration = await resolveReleaseResumeConfiguration({
|
|
1743
1865
|
git: gitEnabled,
|
|
@@ -2713,7 +2835,7 @@ export function showHelp(mode?: ICliMode): void {
|
|
|
2713
2835
|
printJson({
|
|
2714
2836
|
command: "release",
|
|
2715
2837
|
usage:
|
|
2716
|
-
"gitzone release [inspect [version]|resume <version>|recover <version
|
|
2838
|
+
"gitzone release [inspect [version]|resume <version>|recover <version>|prune] [options]",
|
|
2717
2839
|
description:
|
|
2718
2840
|
"Creates a versioned release from pending changelog entries and publishes configured artifacts.",
|
|
2719
2841
|
flags: [
|
|
@@ -2773,6 +2895,11 @@ export function showHelp(mode?: ICliMode): void {
|
|
|
2773
2895
|
description:
|
|
2774
2896
|
"Recover a local npm and/or Docker release tag created without a recorded intent after build or pack failure before journal creation",
|
|
2775
2897
|
},
|
|
2898
|
+
{
|
|
2899
|
+
flag: "prune [--apply] [--keep <n>]",
|
|
2900
|
+
description:
|
|
2901
|
+
"Report, and with --apply delete, the npm tarballs and Gitea assets of completed release records beyond the newest release.recordRetention (or --keep); journals, incomplete and in-use records stay",
|
|
2902
|
+
},
|
|
2776
2903
|
{
|
|
2777
2904
|
flag: "--recover-attempt <id>",
|
|
2778
2905
|
description:
|
|
@@ -2790,7 +2917,7 @@ export function showHelp(mode?: ICliMode): void {
|
|
|
2790
2917
|
|
|
2791
2918
|
console.log("");
|
|
2792
2919
|
console.log(
|
|
2793
|
-
"Usage: gitzone release [inspect [version]|resume <version>|recover <version
|
|
2920
|
+
"Usage: gitzone release [inspect [version]|resume <version>|recover <version>|prune] [options]",
|
|
2794
2921
|
);
|
|
2795
2922
|
console.log("");
|
|
2796
2923
|
console.log("Creates a versioned release from changelog Pending entries.");
|
|
@@ -2831,6 +2958,9 @@ export function showHelp(mode?: ICliMode): void {
|
|
|
2831
2958
|
console.log(
|
|
2832
2959
|
" recover <version> Recover an unpublished npm and/or Docker release tag created without a recorded intent",
|
|
2833
2960
|
);
|
|
2961
|
+
console.log(
|
|
2962
|
+
" prune Report payloads of completed records beyond release.recordRetention; --apply deletes them, --keep <n> overrides the count",
|
|
2963
|
+
);
|
|
2834
2964
|
console.log(
|
|
2835
2965
|
" --recover-attempt Recover one exact 32-character hexadecimal attempt ID after proving its publisher stopped",
|
|
2836
2966
|
);
|