@git.zone/cli 8.10.0 → 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/assets/templates/npm/.package.json +1 -1
- package/assets/templates/service/.package.json +1 -1
- package/assets/templates/wcc/.package.json +1 -1
- package/assets/templates/website/.package.json +1 -1
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.project.js +1 -1
- package/dist_ts/gitzone.cli.js +1 -1
- package/dist_ts/helpers.climode.d.ts +2 -1
- package/dist_ts/helpers.climode.js +1 -1
- package/dist_ts/helpers.ownerscopes.d.ts +1 -1
- package/dist_ts/helpers.ownerscopes.js +2 -1
- package/dist_ts/helpers.smartconfig.js +1 -1
- package/dist_ts/helpers.tsdocker.js +1 -1
- package/dist_ts/helpers.tstest.js +1 -1
- package/dist_ts/helpers.workflow.d.ts +7 -0
- package/dist_ts/helpers.workflow.js +15 -1
- package/dist_ts/mod_commit/index.js +1 -1
- package/dist_ts/mod_config/classes.commitconfig.js +1 -1
- package/dist_ts/mod_config/classes.releaseconfig.js +1 -1
- package/dist_ts/mod_deprecate/helpers.deprecation.js +1 -1
- package/dist_ts/mod_deprecate/index.js +1 -1
- package/dist_ts/mod_format/classes.formatcontext.js +1 -1
- package/dist_ts/mod_format/classes.formatplanner.js +1 -1
- package/dist_ts/mod_format/classes.formatstats.js +1 -1
- package/dist_ts/mod_format/formatters/assets.formatter.js +1 -1
- package/dist_ts/mod_format/formatters/deno.formatter.js +1 -1
- package/dist_ts/mod_format/index.js +1 -1
- package/dist_ts/mod_release/classes.releasejournal.d.ts +70 -0
- package/dist_ts/mod_release/classes.releasejournal.js +273 -5
- package/dist_ts/mod_release/helpers.giteaassets.js +18 -9
- package/dist_ts/mod_release/helpers.gitremote.js +1 -1
- package/dist_ts/mod_release/helpers.npmartifact.js +1 -1
- package/dist_ts/mod_release/helpers.npmartifactcheck.js +1 -1
- package/dist_ts/mod_release/helpers.releasephase.js +1 -1
- package/dist_ts/mod_release/helpers.releaseversion.js +1 -1
- package/dist_ts/mod_release/helpers.tsdockerprotocol.js +1 -1
- package/dist_ts/mod_release/index.js +131 -9
- package/dist_ts/mod_services/classes.dockercontainer.js +1 -1
- package/dist_ts/mod_services/classes.globalregistry.js +1 -1
- package/dist_ts/mod_services/classes.globalregistrystore.js +1 -1
- package/dist_ts/mod_services/classes.legacymongomigration.d.ts +1 -1
- package/dist_ts/mod_services/classes.legacymongomigration.js +1 -1
- package/dist_ts/mod_services/classes.serviceconfiguration.js +1 -1
- package/dist_ts/mod_services/classes.servicemanager.js +1 -1
- package/dist_ts/mod_services/classes.servicenames.js +1 -1
- package/dist_ts/mod_services/classes.serviceoptions.js +1 -1
- package/dist_ts/mod_services/classes.servicepruner.js +1 -1
- package/dist_ts/mod_services/helpers.js +1 -1
- package/dist_ts/mod_services/index.js +1 -1
- package/dist_ts/mod_standard/index.js +1 -1
- package/dist_ts/mod_testing/classes.commands.js +1 -1
- package/dist_ts/mod_testing/classes.runtime.js +1 -1
- package/dist_ts/mod_testing/index.js +1 -1
- package/dist_ts/mod_tools/index.js +1 -1
- package/dist_ts/paths.js +1 -1
- package/dist_ts_migration/001.service-selection.js +1 -1
- package/dist_ts_migration/004.global-registry.js +1 -1
- package/package.json +6 -6
- package/readme.md +106 -3
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/helpers.ownerscopes.ts +1 -0
- package/ts/helpers.workflow.ts +28 -0
- package/ts/mod_release/classes.releasejournal.ts +358 -5
- package/ts/mod_release/helpers.giteaassets.ts +19 -10
- package/ts/mod_release/index.ts +238 -31
|
@@ -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";
|
|
@@ -53,6 +54,54 @@ export const releaseArtifactFileName = "package.tgz" as const;
|
|
|
53
54
|
export const releaseJournalFileName = "journal.json" as const;
|
|
54
55
|
export const releaseIntentKind = "gitzone-release-intent" as const;
|
|
55
56
|
|
|
57
|
+
/** npm tarballs and frozen Gitea assets: the bytes retention may remove. */
|
|
58
|
+
export const isReleasePayloadFileName = (nameArg: string): boolean =>
|
|
59
|
+
nameArg === releaseArtifactFileName ||
|
|
60
|
+
/^package\.[0-9a-f]{64}\.tgz$/.test(nameArg) ||
|
|
61
|
+
/^asset\.[0-9a-f]{64}\.bin$/.test(nameArg);
|
|
62
|
+
|
|
63
|
+
export type TReleaseRecordPruneAction = "kept" | "pruned" | "blocked";
|
|
64
|
+
export type TReleaseRecordPruneReason =
|
|
65
|
+
| "newest-completed"
|
|
66
|
+
| "current-release"
|
|
67
|
+
| "incomplete"
|
|
68
|
+
| "older-completed"
|
|
69
|
+
| "payload-absent"
|
|
70
|
+
| "intent-present"
|
|
71
|
+
| "record-in-use"
|
|
72
|
+
| "invalid-journal";
|
|
73
|
+
|
|
74
|
+
export interface IReleaseRecordPruneEntry {
|
|
75
|
+
version: string;
|
|
76
|
+
state: "completed" | "incomplete" | "invalid";
|
|
77
|
+
createdAt: string | null;
|
|
78
|
+
completedAt: string | null;
|
|
79
|
+
/** Every regular file of the record directory. */
|
|
80
|
+
bytes: number;
|
|
81
|
+
/** The npm tarballs and Gitea assets among them. */
|
|
82
|
+
payloadBytes: number;
|
|
83
|
+
payloadFiles: number;
|
|
84
|
+
action: TReleaseRecordPruneAction;
|
|
85
|
+
reason: TReleaseRecordPruneReason;
|
|
86
|
+
detail?: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface IReleaseRecordPruneReport {
|
|
90
|
+
dryRun: boolean;
|
|
91
|
+
keep: number;
|
|
92
|
+
root: string;
|
|
93
|
+
records: IReleaseRecordPruneEntry[];
|
|
94
|
+
totals: {
|
|
95
|
+
records: number;
|
|
96
|
+
kept: number;
|
|
97
|
+
pruned: number;
|
|
98
|
+
blocked: number;
|
|
99
|
+
bytes: number;
|
|
100
|
+
wouldFreeBytes: number;
|
|
101
|
+
freedBytes: number;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
56
105
|
/**
|
|
57
106
|
* `accepted` records a destination that took the upload without rejecting it
|
|
58
107
|
* while its read-back is still missing. It is neither a success nor a failure:
|
|
@@ -2140,11 +2189,7 @@ export class ReleaseJournalStore {
|
|
|
2140
2189
|
versionArg: string,
|
|
2141
2190
|
fileArg: string = releaseArtifactFileName,
|
|
2142
2191
|
): string {
|
|
2143
|
-
if (
|
|
2144
|
-
fileArg !== releaseArtifactFileName &&
|
|
2145
|
-
!/^package\.[0-9a-f]{64}\.tgz$/.test(fileArg) &&
|
|
2146
|
-
!/^asset\.[0-9a-f]{64}\.bin$/.test(fileArg)
|
|
2147
|
-
) {
|
|
2192
|
+
if (!isReleasePayloadFileName(fileArg)) {
|
|
2148
2193
|
throw new Error("Invalid release artifact filename.");
|
|
2149
2194
|
}
|
|
2150
2195
|
return plugins.path.join(this.getReleaseDirectory(versionArg), fileArg);
|
|
@@ -2295,6 +2340,314 @@ export class ReleaseJournalStore {
|
|
|
2295
2340
|
);
|
|
2296
2341
|
}
|
|
2297
2342
|
|
|
2343
|
+
/** Pins artifacts for the whole publication or resume, including its reads. */
|
|
2344
|
+
public async withReleaseRecord<T>(
|
|
2345
|
+
versionArg: string,
|
|
2346
|
+
operationArg: () => Promise<T>,
|
|
2347
|
+
): Promise<T> {
|
|
2348
|
+
return this.getRecordLock(versionArg).runExclusive(operationArg);
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
private getRecordLock(versionArg: string): InterProcessLock {
|
|
2352
|
+
const version = normalizeReleaseVersion(versionArg);
|
|
2353
|
+
return new InterProcessLock({
|
|
2354
|
+
lockPath: `${this.getReleaseDirectory(version)}.record.lock`,
|
|
2355
|
+
description: `Release record v${version}`,
|
|
2356
|
+
});
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
/**
|
|
2360
|
+
* Only a completed run trims completed records. The current record, intents,
|
|
2361
|
+
* and records pinned by another publisher/resume keep their payloads.
|
|
2362
|
+
* Invalid journals stop retention before deletion rather than guessing
|
|
2363
|
+
* their state.
|
|
2364
|
+
*/
|
|
2365
|
+
public async pruneCompleted(
|
|
2366
|
+
keepArg: number,
|
|
2367
|
+
currentVersionArg: string,
|
|
2368
|
+
): Promise<string[]> {
|
|
2369
|
+
const keep = resolveReleaseRecordRetention(keepArg);
|
|
2370
|
+
if ((await this.read(currentVersionArg)).completedAt === null) return [];
|
|
2371
|
+
const report = await this.pruneRecords({
|
|
2372
|
+
keep,
|
|
2373
|
+
apply: true,
|
|
2374
|
+
currentVersion: currentVersionArg,
|
|
2375
|
+
});
|
|
2376
|
+
return report.records
|
|
2377
|
+
.filter((entry) => entry.action === "pruned" && entry.payloadFiles > 0)
|
|
2378
|
+
.map((entry) => entry.version);
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
/**
|
|
2382
|
+
* Retention for every caller: the newest `keep` completed records and every
|
|
2383
|
+
* incomplete record keep their payloads; older completed records lose their
|
|
2384
|
+
* npm tarballs and Gitea assets. Journals and all other files stay. A dry run
|
|
2385
|
+
* only reports; `apply` deletes under the same locks a release takes.
|
|
2386
|
+
*/
|
|
2387
|
+
public async pruneRecords(optionsArg: {
|
|
2388
|
+
keep: number;
|
|
2389
|
+
apply: boolean;
|
|
2390
|
+
currentVersion?: string;
|
|
2391
|
+
}): Promise<IReleaseRecordPruneReport> {
|
|
2392
|
+
const keep = resolveReleaseRecordRetention(optionsArg.keep);
|
|
2393
|
+
const currentVersion =
|
|
2394
|
+
optionsArg.currentVersion === undefined
|
|
2395
|
+
? undefined
|
|
2396
|
+
: normalizeReleaseVersion(optionsArg.currentVersion);
|
|
2397
|
+
if (!optionsArg.apply)
|
|
2398
|
+
return this.summarizePrune(
|
|
2399
|
+
keep,
|
|
2400
|
+
true,
|
|
2401
|
+
await this.planPrune(keep, currentVersion),
|
|
2402
|
+
);
|
|
2403
|
+
const retentionLock = new InterProcessLock({
|
|
2404
|
+
lockPath: plugins.path.join(this.rootPath, "retention.lock"),
|
|
2405
|
+
description: "Release record retention",
|
|
2406
|
+
});
|
|
2407
|
+
return retentionLock.runExclusive(async () => {
|
|
2408
|
+
const records = await this.planPrune(keep, currentVersion);
|
|
2409
|
+
const invalid = records.filter((entry) => entry.state === "invalid");
|
|
2410
|
+
if (invalid.length > 0)
|
|
2411
|
+
throw new Error(
|
|
2412
|
+
`Release record retention stopped before deletion: ${invalid.map((entry) => `v${entry.version} (${entry.detail})`).join("; ")}.`,
|
|
2413
|
+
);
|
|
2414
|
+
for (const entry of records) {
|
|
2415
|
+
if (entry.action !== "pruned" || entry.payloadFiles === 0) continue;
|
|
2416
|
+
const blocked = await this.prunePayload(entry.version);
|
|
2417
|
+
if (blocked) {
|
|
2418
|
+
entry.action = blocked === "incomplete" ? "kept" : "blocked";
|
|
2419
|
+
entry.reason = blocked;
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
return this.summarizePrune(keep, false, records);
|
|
2423
|
+
});
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
/**
|
|
2427
|
+
* Paths that show a release of this repository at work: journal, record,
|
|
2428
|
+
* creation and recovery-preparation locks, the detached-run lock, and
|
|
2429
|
+
* temporary preparation directories. Stale entries need the same manual
|
|
2430
|
+
* owner check as every release lock.
|
|
2431
|
+
*/
|
|
2432
|
+
public async findActiveReleaseState(): Promise<string[]> {
|
|
2433
|
+
let names: string[];
|
|
2434
|
+
try {
|
|
2435
|
+
names = await plugins.fs.readdir(this.rootPath);
|
|
2436
|
+
} catch (error) {
|
|
2437
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return [];
|
|
2438
|
+
throw new Error("Release journal directory could not be listed.", {
|
|
2439
|
+
cause: error,
|
|
2440
|
+
});
|
|
2441
|
+
}
|
|
2442
|
+
return names
|
|
2443
|
+
.filter((name) =>
|
|
2444
|
+
/^(?:v.+\.(?:record\.|create\.|prepare\.)?lock|detached\.lock|\.v.+\.tmp-.+)$/.test(
|
|
2445
|
+
name,
|
|
2446
|
+
),
|
|
2447
|
+
)
|
|
2448
|
+
.sort()
|
|
2449
|
+
.map((name) => plugins.path.join(this.rootPath, name));
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
/** True when a journal's npm tarballs or Gitea assets are not stored. */
|
|
2453
|
+
public async isPayloadMissing(journalArg: TReleaseJournal): Promise<boolean> {
|
|
2454
|
+
const files = [
|
|
2455
|
+
...getReleaseArtifacts(journalArg).map((artifact) => artifact.file),
|
|
2456
|
+
...(journalArg.schemaVersion === 4
|
|
2457
|
+
? journalArg.giteaAssets.assets.map((entry) => entry.asset.fileName)
|
|
2458
|
+
: []),
|
|
2459
|
+
];
|
|
2460
|
+
for (const file of files) {
|
|
2461
|
+
try {
|
|
2462
|
+
await plugins.fs.lstat(
|
|
2463
|
+
this.getArtifactPath(journalArg.release.version, file),
|
|
2464
|
+
);
|
|
2465
|
+
} catch (error) {
|
|
2466
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return true;
|
|
2467
|
+
throw error;
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
return false;
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
private async planPrune(
|
|
2474
|
+
keepArg: number,
|
|
2475
|
+
currentVersionArg: string | undefined,
|
|
2476
|
+
): Promise<IReleaseRecordPruneEntry[]> {
|
|
2477
|
+
let directoryEntries: Array<{ name: string; isDirectory: () => boolean }>;
|
|
2478
|
+
try {
|
|
2479
|
+
directoryEntries = await plugins.fs.readdir(this.rootPath, {
|
|
2480
|
+
withFileTypes: true,
|
|
2481
|
+
});
|
|
2482
|
+
} catch (error) {
|
|
2483
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return [];
|
|
2484
|
+
throw new Error("Release journal directory could not be listed.", {
|
|
2485
|
+
cause: error,
|
|
2486
|
+
});
|
|
2487
|
+
}
|
|
2488
|
+
const records: Array<{
|
|
2489
|
+
entry: IReleaseRecordPruneEntry;
|
|
2490
|
+
journal: TReleaseJournal | null;
|
|
2491
|
+
}> = [];
|
|
2492
|
+
for (const directoryEntry of directoryEntries) {
|
|
2493
|
+
if (
|
|
2494
|
+
!directoryEntry.isDirectory() ||
|
|
2495
|
+
!directoryEntry.name.startsWith("v") ||
|
|
2496
|
+
!isSupportedReleaseVersion(directoryEntry.name.slice(1))
|
|
2497
|
+
)
|
|
2498
|
+
continue;
|
|
2499
|
+
const version = directoryEntry.name.slice(1);
|
|
2500
|
+
const usage = await this.measureRecord(version);
|
|
2501
|
+
let journal: TReleaseJournal | null = null;
|
|
2502
|
+
let detail: string | undefined;
|
|
2503
|
+
try {
|
|
2504
|
+
journal = await this.read(version);
|
|
2505
|
+
} catch (error) {
|
|
2506
|
+
detail = error instanceof Error ? error.message : String(error);
|
|
2507
|
+
}
|
|
2508
|
+
records.push({
|
|
2509
|
+
journal,
|
|
2510
|
+
entry: {
|
|
2511
|
+
version,
|
|
2512
|
+
state: !journal
|
|
2513
|
+
? "invalid"
|
|
2514
|
+
: journal.completedAt === null
|
|
2515
|
+
? "incomplete"
|
|
2516
|
+
: "completed",
|
|
2517
|
+
createdAt: journal?.createdAt ?? null,
|
|
2518
|
+
completedAt: journal?.completedAt ?? null,
|
|
2519
|
+
...usage,
|
|
2520
|
+
...(journal
|
|
2521
|
+
? journal.completedAt === null
|
|
2522
|
+
? { action: "kept", reason: "incomplete" }
|
|
2523
|
+
: { action: "pruned", reason: "older-completed" }
|
|
2524
|
+
: { action: "blocked", reason: "invalid-journal", detail }),
|
|
2525
|
+
},
|
|
2526
|
+
});
|
|
2527
|
+
}
|
|
2528
|
+
records.sort(
|
|
2529
|
+
(left, right) =>
|
|
2530
|
+
(right.entry.createdAt ?? "").localeCompare(
|
|
2531
|
+
left.entry.createdAt ?? "",
|
|
2532
|
+
) ||
|
|
2533
|
+
compareSupportedReleaseVersions(
|
|
2534
|
+
right.entry.version,
|
|
2535
|
+
left.entry.version,
|
|
2536
|
+
),
|
|
2537
|
+
);
|
|
2538
|
+
const completed = records
|
|
2539
|
+
.filter((record) => record.entry.state === "completed")
|
|
2540
|
+
.map((record) => record.entry);
|
|
2541
|
+
for (const [index, entry] of completed.entries()) {
|
|
2542
|
+
if (entry.version === currentVersionArg) {
|
|
2543
|
+
entry.action = "kept";
|
|
2544
|
+
entry.reason = "current-release";
|
|
2545
|
+
} else if (index < keepArg) {
|
|
2546
|
+
entry.action = "kept";
|
|
2547
|
+
entry.reason = "newest-completed";
|
|
2548
|
+
} else if (await this.hasIntent(entry.version)) {
|
|
2549
|
+
entry.action = "blocked";
|
|
2550
|
+
entry.reason = "intent-present";
|
|
2551
|
+
} else if (await this.getRecordLock(entry.version).readHolder()) {
|
|
2552
|
+
entry.action = "blocked";
|
|
2553
|
+
entry.reason = "record-in-use";
|
|
2554
|
+
} else if (entry.payloadFiles === 0) {
|
|
2555
|
+
entry.reason = "payload-absent";
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
return records.map((record) => record.entry);
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2561
|
+
private summarizePrune(
|
|
2562
|
+
keepArg: number,
|
|
2563
|
+
dryRunArg: boolean,
|
|
2564
|
+
recordsArg: IReleaseRecordPruneEntry[],
|
|
2565
|
+
): IReleaseRecordPruneReport {
|
|
2566
|
+
const count = (actionArg: TReleaseRecordPruneAction) =>
|
|
2567
|
+
recordsArg.filter((entry) => entry.action === actionArg).length;
|
|
2568
|
+
const wouldFreeBytes = recordsArg
|
|
2569
|
+
.filter((entry) => entry.action === "pruned")
|
|
2570
|
+
.reduce((sum, entry) => sum + entry.payloadBytes, 0);
|
|
2571
|
+
return {
|
|
2572
|
+
dryRun: dryRunArg,
|
|
2573
|
+
keep: keepArg,
|
|
2574
|
+
root: this.rootPath,
|
|
2575
|
+
records: recordsArg,
|
|
2576
|
+
totals: {
|
|
2577
|
+
records: recordsArg.length,
|
|
2578
|
+
kept: count("kept"),
|
|
2579
|
+
pruned: count("pruned"),
|
|
2580
|
+
blocked: count("blocked"),
|
|
2581
|
+
bytes: recordsArg.reduce((sum, entry) => sum + entry.bytes, 0),
|
|
2582
|
+
wouldFreeBytes,
|
|
2583
|
+
freedBytes: dryRunArg ? 0 : wouldFreeBytes,
|
|
2584
|
+
},
|
|
2585
|
+
};
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
private async measureRecord(
|
|
2589
|
+
versionArg: string,
|
|
2590
|
+
): Promise<{ bytes: number; payloadBytes: number; payloadFiles: number }> {
|
|
2591
|
+
const directory = this.getReleaseDirectory(versionArg);
|
|
2592
|
+
const usage = { bytes: 0, payloadBytes: 0, payloadFiles: 0 };
|
|
2593
|
+
for (const name of await plugins.fs.readdir(directory)) {
|
|
2594
|
+
const stat = await plugins.fs.lstat(plugins.path.join(directory, name));
|
|
2595
|
+
if (!stat.isFile()) continue;
|
|
2596
|
+
usage.bytes += stat.size;
|
|
2597
|
+
if (!isReleasePayloadFileName(name)) continue;
|
|
2598
|
+
usage.payloadBytes += stat.size;
|
|
2599
|
+
usage.payloadFiles++;
|
|
2600
|
+
}
|
|
2601
|
+
return usage;
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2604
|
+
/** Even a malformed intent protects the record; it is not interpreted. */
|
|
2605
|
+
private async hasIntent(versionArg: string): Promise<boolean> {
|
|
2606
|
+
try {
|
|
2607
|
+
await plugins.fs.lstat(this.getIntentPath(versionArg));
|
|
2608
|
+
return true;
|
|
2609
|
+
} catch (error) {
|
|
2610
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
|
|
2611
|
+
return false;
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
/** Deletes one record's payload, or names what still protects it. */
|
|
2616
|
+
private async prunePayload(
|
|
2617
|
+
versionArg: string,
|
|
2618
|
+
): Promise<TReleaseRecordPruneReason | null> {
|
|
2619
|
+
const recordLock = this.getRecordLock(versionArg);
|
|
2620
|
+
if (await recordLock.readHolder()) return "record-in-use";
|
|
2621
|
+
return recordLock.runExclusive(async () => {
|
|
2622
|
+
const directory = this.getReleaseDirectory(versionArg);
|
|
2623
|
+
const journalLock = new InterProcessLock({
|
|
2624
|
+
lockPath: `${directory}.lock`,
|
|
2625
|
+
description: `Release journal v${versionArg}`,
|
|
2626
|
+
});
|
|
2627
|
+
return journalLock.runExclusive(async () => {
|
|
2628
|
+
if ((await this.read(versionArg)).completedAt === null)
|
|
2629
|
+
return "incomplete";
|
|
2630
|
+
if (await this.hasIntent(versionArg)) return "intent-present";
|
|
2631
|
+
const stat = await plugins.fs.lstat(directory);
|
|
2632
|
+
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
2633
|
+
throw new Error(
|
|
2634
|
+
`Release record v${versionArg} is not a regular directory.`,
|
|
2635
|
+
);
|
|
2636
|
+
for (const entry of await plugins.fs.readdir(directory, {
|
|
2637
|
+
withFileTypes: true,
|
|
2638
|
+
})) {
|
|
2639
|
+
if (!entry.isFile() || !isReleasePayloadFileName(entry.name))
|
|
2640
|
+
continue;
|
|
2641
|
+
await plugins.fs.rm(plugins.path.join(directory, entry.name), {
|
|
2642
|
+
force: false,
|
|
2643
|
+
});
|
|
2644
|
+
}
|
|
2645
|
+
await syncDirectory(directory);
|
|
2646
|
+
return null;
|
|
2647
|
+
});
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2298
2651
|
public async installPrepared(
|
|
2299
2652
|
temporaryDirectoryArg: string,
|
|
2300
2653
|
journalArg: TReleaseJournal,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
giteaReleasePagePath,
|
|
18
18
|
giteaTagProcessingPollIntervalMs,
|
|
19
19
|
giteaTagProcessingTimeoutMs,
|
|
20
|
+
GiteaReleasePageCheckError,
|
|
20
21
|
} from "../../assets/templates/asset_tspack_release_gitea/scripts/gitzone-gitea-tag.mjs";
|
|
21
22
|
|
|
22
23
|
const maximumManifestBytes = 4 * 1024 * 1024;
|
|
@@ -1111,10 +1112,13 @@ export class GiteaAssetsClient implements IGiteaAssetsClient {
|
|
|
1111
1112
|
* when it processes a pushed tag, and answers 404 for a draft and for a tag
|
|
1112
1113
|
* it has not processed yet. The API never shows a tag-only row.
|
|
1113
1114
|
*/
|
|
1114
|
-
private async publicReleasePageStatus(): Promise<number> {
|
|
1115
|
+
private async publicReleasePageStatus(remainingMs: number): Promise<number> {
|
|
1115
1116
|
const watchdog = new GiteaTransferWatchdog(
|
|
1116
1117
|
"GET",
|
|
1117
|
-
|
|
1118
|
+
{
|
|
1119
|
+
...this.limits,
|
|
1120
|
+
responseTimeoutMs: Math.min(this.limits.responseTimeoutMs, remainingMs),
|
|
1121
|
+
},
|
|
1118
1122
|
maximumMetadataBytes,
|
|
1119
1123
|
);
|
|
1120
1124
|
let response: Response | undefined;
|
|
@@ -1131,12 +1135,14 @@ export class GiteaAssetsClient implements IGiteaAssetsClient {
|
|
|
1131
1135
|
watchdog.progress("received", 0);
|
|
1132
1136
|
return response.status;
|
|
1133
1137
|
} catch (error) {
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1138
|
+
throw new GiteaReleasePageCheckError(
|
|
1139
|
+
error,
|
|
1140
|
+
watchdog.failure
|
|
1141
|
+
? `(${watchdog.failure.name}: ${watchdog.failure.message})`
|
|
1142
|
+
: describeGiteaRequestFailure(error, {
|
|
1143
|
+
status: response?.status,
|
|
1144
|
+
progress: "headers only",
|
|
1145
|
+
}),
|
|
1140
1146
|
);
|
|
1141
1147
|
} finally {
|
|
1142
1148
|
watchdog.close();
|
|
@@ -1153,7 +1159,7 @@ export class GiteaAssetsClient implements IGiteaAssetsClient {
|
|
|
1153
1159
|
onWaiting?: (elapsedMs: number) => void,
|
|
1154
1160
|
): Promise<void> {
|
|
1155
1161
|
const result = await awaitGiteaTagProcessed({
|
|
1156
|
-
pageStatus: () => this.publicReleasePageStatus(),
|
|
1162
|
+
pageStatus: (remainingMs) => this.publicReleasePageStatus(remainingMs),
|
|
1157
1163
|
timeoutMs: this.tagProcessingTimeoutMs,
|
|
1158
1164
|
pollIntervalMs: this.tagProcessingPollIntervalMs,
|
|
1159
1165
|
onWaiting,
|
|
@@ -1164,7 +1170,10 @@ export class GiteaAssetsClient implements IGiteaAssetsClient {
|
|
|
1164
1170
|
);
|
|
1165
1171
|
if (result.outcome === "timeout")
|
|
1166
1172
|
throw new GiteaTagProcessingTimeoutError(
|
|
1167
|
-
`Gitea has not processed the pushed tag ${this.tag} within ${formatSeconds(result.elapsedMs)}; the draft release was not created, because Gitea publishes a draft it finds for the tag once it processes the push. Resume once Gitea shows the tag
|
|
1173
|
+
`Gitea has not processed the pushed tag ${this.tag} within ${formatSeconds(result.elapsedMs)}; the draft release was not created, because Gitea publishes a draft it finds for the tag once it processes the push. Resume once Gitea shows the tag.` +
|
|
1174
|
+
(result.lastError
|
|
1175
|
+
? ` Last page check error: ${result.lastError}`
|
|
1176
|
+
: ""),
|
|
1168
1177
|
);
|
|
1169
1178
|
}
|
|
1170
1179
|
|