@git.zone/cli 9.2.1 → 10.0.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_binary_installer/install.sh +109 -34
- package/assets/templates/asset_binary_release_gitea/.gitea/workflows/release.yml +20 -6
- package/assets/templates/ci_rust/.gitea/workflows/rust_nottags.yaml +29 -0
- package/assets/templates/ci_rust/.gitea/workflows/rust_tags.yaml +32 -0
- package/assets/templates/gitignore/_gitignore +1 -1
- package/assets/templates/gitignore_rust/_gitignore +31 -0
- package/assets/templates/license_mit/license +4 -1
- package/assets/templates/rust/.smartscaf.yml +16 -0
- package/assets/templates/rust/_Cargo.toml +12 -0
- package/assets/templates/rust/_crate_Cargo.toml +10 -0
- package/assets/templates/rust/_crate_lib.rs +19 -0
- package/assets/templates/rust/_smartconfig.json +27 -0
- package/assets/templates/rust/readme.md +23 -0
- package/dist_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/classes.gitzoneconfig.d.ts +3 -1
- package/dist_ts/classes.gitzoneconfig.js +9 -1
- package/dist_ts/helpers.managedassets.d.ts +1 -1
- package/dist_ts/helpers.managedassets.js +58 -14
- package/dist_ts/helpers.releasetargets.d.ts +6 -0
- package/dist_ts/helpers.releasetargets.js +13 -0
- package/dist_ts/helpers.smartconfigmigrations.js +42 -1
- package/dist_ts/helpers.toolconfig.d.ts +50 -0
- package/dist_ts/helpers.toolconfig.js +212 -0
- package/dist_ts/helpers.tssea.d.ts +9 -2
- package/dist_ts/helpers.tssea.js +47 -17
- package/dist_ts/helpers.tstest.d.ts +27 -8
- package/dist_ts/helpers.tstest.js +64 -26
- package/dist_ts/helpers.versionsource.d.ts +37 -0
- package/dist_ts/helpers.versionsource.js +112 -0
- package/dist_ts/helpers.workflow.d.ts +45 -1
- package/dist_ts/helpers.workflow.js +120 -5
- package/dist_ts/mod_commit/mod.helpers.d.ts +0 -24
- package/dist_ts/mod_commit/mod.helpers.js +1 -94
- package/dist_ts/mod_config/index.js +131 -18
- package/dist_ts/mod_format/formatters/assets.formatter.js +29 -27
- package/dist_ts/mod_format/formatters/gitignore.formatter.d.ts +4 -2
- package/dist_ts/mod_format/formatters/gitignore.formatter.js +10 -7
- package/dist_ts/mod_format/formatters/license.formatter.d.ts +8 -0
- package/dist_ts/mod_format/formatters/license.formatter.js +25 -2
- package/dist_ts/mod_format/formatters/packagejson.formatter.js +14 -3
- package/dist_ts/mod_format/formatters/rustfmt.formatter.d.ts +19 -0
- package/dist_ts/mod_format/formatters/rustfmt.formatter.js +97 -0
- package/dist_ts/mod_format/formatters/smartconfig.formatter.js +5 -2
- package/dist_ts/mod_format/index.js +3 -1
- package/dist_ts/mod_format/interfaces.format.js +2 -1
- package/dist_ts/mod_release/classes.releasejournal.d.ts +38 -2
- package/dist_ts/mod_release/classes.releasejournal.js +238 -66
- package/dist_ts/mod_release/helpers.cargorelease.d.ts +52 -0
- package/dist_ts/mod_release/helpers.cargorelease.js +195 -0
- package/dist_ts/mod_release/helpers.npmpackages.d.ts +18 -0
- package/dist_ts/mod_release/helpers.npmpackages.js +40 -2
- package/dist_ts/mod_release/helpers.releasecheck.d.ts +73 -0
- package/dist_ts/mod_release/helpers.releasecheck.js +269 -0
- package/dist_ts/mod_release/helpers.releasepreparation.d.ts +22 -8
- package/dist_ts/mod_release/helpers.releasepreparation.js +74 -26
- package/dist_ts/mod_release/helpers.releasepublication.d.ts +21 -1
- package/dist_ts/mod_release/helpers.releasepublication.js +249 -4
- package/dist_ts/mod_release/helpers.releaseversionsource.d.ts +10 -0
- package/dist_ts/mod_release/helpers.releaseversionsource.js +18 -0
- package/dist_ts/mod_release/helpers.rsrepoengine.d.ts +192 -0
- package/dist_ts/mod_release/helpers.rsrepoengine.js +457 -0
- package/dist_ts/mod_release/index.d.ts +3 -0
- package/dist_ts/mod_release/index.js +177 -65
- package/dist_ts/mod_template/index.js +6 -2
- package/package.json +1 -1
- package/readme.md +237 -21
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.gitzoneconfig.ts +10 -1
- package/ts/helpers.managedassets.ts +64 -14
- package/ts/helpers.releasetargets.ts +13 -0
- package/ts/helpers.smartconfigmigrations.ts +48 -0
- package/ts/helpers.toolconfig.ts +280 -0
- package/ts/helpers.tssea.ts +59 -16
- package/ts/helpers.tstest.ts +105 -35
- package/ts/helpers.versionsource.ts +169 -0
- package/ts/helpers.workflow.ts +197 -5
- package/ts/mod_commit/mod.helpers.ts +0 -119
- package/ts/mod_config/index.ts +169 -19
- package/ts/mod_format/formatters/assets.formatter.ts +28 -27
- package/ts/mod_format/formatters/gitignore.formatter.ts +10 -6
- package/ts/mod_format/formatters/license.formatter.ts +26 -1
- package/ts/mod_format/formatters/packagejson.formatter.ts +14 -2
- package/ts/mod_format/formatters/rustfmt.formatter.ts +107 -0
- package/ts/mod_format/formatters/smartconfig.formatter.ts +8 -1
- package/ts/mod_format/index.ts +2 -0
- package/ts/mod_format/interfaces.format.ts +1 -0
- package/ts/mod_release/classes.releasejournal.ts +312 -39
- package/ts/mod_release/helpers.cargorelease.ts +289 -0
- package/ts/mod_release/helpers.npmpackages.ts +76 -1
- package/ts/mod_release/helpers.releasecheck.ts +409 -0
- package/ts/mod_release/helpers.releasepreparation.ts +116 -36
- package/ts/mod_release/helpers.releasepublication.ts +462 -1
- package/ts/mod_release/helpers.releaseversionsource.ts +29 -0
- package/ts/mod_release/helpers.rsrepoengine.ts +790 -0
- package/ts/mod_release/index.ts +277 -84
- package/ts/mod_template/index.ts +5 -1
package/ts/mod_format/index.ts
CHANGED
|
@@ -28,6 +28,7 @@ import { TsconfigFormatter } from "./formatters/tsconfig.formatter.js";
|
|
|
28
28
|
import { PrettierFormatter } from "./formatters/prettier.formatter.js";
|
|
29
29
|
import { ReadmeFormatter } from "./formatters/readme.formatter.js";
|
|
30
30
|
import { CopyFormatter } from "./formatters/copy.formatter.js";
|
|
31
|
+
import { RustfmtFormatter } from "./formatters/rustfmt.formatter.js";
|
|
31
32
|
import type { ICheckResult, IFormatPlan } from "./interfaces.format.js";
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -73,6 +74,7 @@ const formatterMap: Record<
|
|
|
73
74
|
prettier: PrettierFormatter,
|
|
74
75
|
readme: ReadmeFormatter,
|
|
75
76
|
copy: CopyFormatter,
|
|
77
|
+
rustfmt: RustfmtFormatter,
|
|
76
78
|
};
|
|
77
79
|
|
|
78
80
|
// Formatters that don't require projectType to be set
|
|
@@ -46,6 +46,10 @@ import {
|
|
|
46
46
|
parseReleaseLine,
|
|
47
47
|
type IReleaseLine,
|
|
48
48
|
} from "./helpers.releaseline.js";
|
|
49
|
+
import {
|
|
50
|
+
isCargoCrateName,
|
|
51
|
+
isCargoRegistryName,
|
|
52
|
+
} from "./helpers.rsrepoengine.js";
|
|
49
53
|
|
|
50
54
|
export const releaseJournalStorageVersion = 1 as const;
|
|
51
55
|
export const legacyReleaseJournalSchemaVersion = 1 as const;
|
|
@@ -54,10 +58,11 @@ export const releaseArtifactFileName = "package.tgz" as const;
|
|
|
54
58
|
export const releaseJournalFileName = "journal.json" as const;
|
|
55
59
|
export const releaseIntentKind = "gitzone-release-intent" as const;
|
|
56
60
|
|
|
57
|
-
/** npm tarballs and frozen Gitea assets: the bytes retention may remove. */
|
|
61
|
+
/** npm tarballs, packed crates and frozen Gitea assets: the bytes retention may remove. */
|
|
58
62
|
export const isReleasePayloadFileName = (nameArg: string): boolean =>
|
|
59
63
|
nameArg === releaseArtifactFileName ||
|
|
60
64
|
/^package\.[0-9a-f]{64}\.tgz$/.test(nameArg) ||
|
|
65
|
+
/^crate\.[0-9a-f]{64}\.crate$/.test(nameArg) ||
|
|
61
66
|
/^asset\.[0-9a-f]{64}\.bin$/.test(nameArg);
|
|
62
67
|
|
|
63
68
|
export type TReleaseRecordPruneAction = "kept" | "pruned" | "blocked";
|
|
@@ -191,6 +196,38 @@ export interface IReleaseIdentity {
|
|
|
191
196
|
prerelease?: IReleasePrereleaseRecord;
|
|
192
197
|
}
|
|
193
198
|
|
|
199
|
+
/** One crate packed by the rsrepo engine in the release checkout. */
|
|
200
|
+
export interface IReleaseCrateArtifact {
|
|
201
|
+
kind: "cargo-crate";
|
|
202
|
+
/** `crate.<sha256(name)>.crate` beside the journal. */
|
|
203
|
+
file: string;
|
|
204
|
+
crateName: string;
|
|
205
|
+
version: string;
|
|
206
|
+
size: number;
|
|
207
|
+
/** The sha256 a sparse index serves as the crate's `cksum`. */
|
|
208
|
+
sha256: string;
|
|
209
|
+
/** Crates of this release it needs (normal and build); they publish first. */
|
|
210
|
+
dependencies: string[];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** One crate in one cargo registry. */
|
|
214
|
+
export interface IReleaseCargoRegistryJournal extends IReleaseTargetStatus {
|
|
215
|
+
registry: string;
|
|
216
|
+
crate: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The composable Cargo section of a Git and npm journal (schema 1 or 3).
|
|
221
|
+
* Crates are in publication order, dependencies first; the cells are one per
|
|
222
|
+
* crate and registry, crate by crate in that order.
|
|
223
|
+
*/
|
|
224
|
+
export interface IReleaseCargoJournal {
|
|
225
|
+
engine: "rsrepo";
|
|
226
|
+
protocolVersion: 1;
|
|
227
|
+
crates: IReleaseCrateArtifact[];
|
|
228
|
+
registries: IReleaseCargoRegistryJournal[];
|
|
229
|
+
}
|
|
230
|
+
|
|
194
231
|
export interface IReleaseJournalV1 {
|
|
195
232
|
kind: "gitzone-release-journal";
|
|
196
233
|
schemaVersion: typeof legacyReleaseJournalSchemaVersion;
|
|
@@ -205,6 +242,8 @@ export interface IReleaseJournalV1 {
|
|
|
205
242
|
alreadyPublished: "success" | "error";
|
|
206
243
|
registries: IReleaseNpmRegistryJournal[];
|
|
207
244
|
};
|
|
245
|
+
/** Present only when the release publishes crates. */
|
|
246
|
+
cargo?: IReleaseCargoJournal;
|
|
208
247
|
createdAt: string;
|
|
209
248
|
updatedAt: string;
|
|
210
249
|
completedAt: string | null;
|
|
@@ -283,7 +322,7 @@ export interface IReleaseGiteaAssetsJournal {
|
|
|
283
322
|
|
|
284
323
|
export interface IReleaseJournalV4 extends Omit<
|
|
285
324
|
IReleaseJournalV1,
|
|
286
|
-
"schemaVersion"
|
|
325
|
+
"schemaVersion" | "cargo"
|
|
287
326
|
> {
|
|
288
327
|
schemaVersion: 4;
|
|
289
328
|
packages: IReleasePackage[];
|
|
@@ -308,6 +347,24 @@ export const hasReleasePackages = (
|
|
|
308
347
|
export const releasePackageArtifactFile = (packageNameArg: string): string =>
|
|
309
348
|
`package.${plugins.crypto.createHash("sha256").update(packageNameArg).digest("hex")}.tgz`;
|
|
310
349
|
|
|
350
|
+
export const releaseCrateArtifactFile = (crateNameArg: string): string =>
|
|
351
|
+
`crate.${plugins.crypto.createHash("sha256").update(crateNameArg).digest("hex")}.crate`;
|
|
352
|
+
|
|
353
|
+
/** The Cargo section of a Git and npm journal, when the release publishes crates. */
|
|
354
|
+
export const getReleaseCargo = (
|
|
355
|
+
journalArg: TReleaseJournal,
|
|
356
|
+
): IReleaseCargoJournal | undefined =>
|
|
357
|
+
journalArg.schemaVersion === 1 || journalArg.schemaVersion === 3
|
|
358
|
+
? journalArg.cargo
|
|
359
|
+
: undefined;
|
|
360
|
+
|
|
361
|
+
/** The cargo registries in journal order. */
|
|
362
|
+
export const getReleaseCargoRegistries = (
|
|
363
|
+
cargoArg: IReleaseCargoJournal,
|
|
364
|
+
): string[] => [
|
|
365
|
+
...new Set(cargoArg.registries.map((cellArg) => cellArg.registry)),
|
|
366
|
+
];
|
|
367
|
+
|
|
311
368
|
/** Every stored npm artifact in publication order: the modules, then the root package. */
|
|
312
369
|
export const getReleaseArtifacts = (
|
|
313
370
|
journalArg: TReleaseJournal,
|
|
@@ -556,6 +613,8 @@ const isComplete = (journalArg: TReleaseJournal): boolean => {
|
|
|
556
613
|
const commonComplete = [
|
|
557
614
|
journalArg.git.state,
|
|
558
615
|
...journalArg.npm.registries.map((registryArg) => registryArg.state),
|
|
616
|
+
...(getReleaseCargo(journalArg)?.registries.map((cellArg) => cellArg.state) ??
|
|
617
|
+
[]),
|
|
559
618
|
...(journalArg.schemaVersion === 4
|
|
560
619
|
? [
|
|
561
620
|
journalArg.giteaAssets.release.state,
|
|
@@ -590,6 +649,7 @@ export const isVerificationOnlyResume = (
|
|
|
590
649
|
const targets: IReleaseTargetStatus[] = [
|
|
591
650
|
journalArg.git,
|
|
592
651
|
...journalArg.npm.registries,
|
|
652
|
+
...(getReleaseCargo(journalArg)?.registries ?? []),
|
|
593
653
|
...(journalArg.schemaVersion === 4
|
|
594
654
|
? [
|
|
595
655
|
journalArg.giteaAssets.release,
|
|
@@ -612,8 +672,9 @@ export const isVerificationOnlyResume = (
|
|
|
612
672
|
);
|
|
613
673
|
};
|
|
614
674
|
|
|
615
|
-
const immutableJournalIdentity = (journalArg: TReleaseJournal): string =>
|
|
616
|
-
|
|
675
|
+
const immutableJournalIdentity = (journalArg: TReleaseJournal): string => {
|
|
676
|
+
const cargo = getReleaseCargo(journalArg);
|
|
677
|
+
return JSON.stringify({
|
|
617
678
|
schemaVersion: journalArg.schemaVersion,
|
|
618
679
|
release: journalArg.release,
|
|
619
680
|
artifact: journalArg.artifact,
|
|
@@ -635,6 +696,17 @@ const immutableJournalIdentity = (journalArg: TReleaseJournal): string =>
|
|
|
635
696
|
: registryArg.registry,
|
|
636
697
|
),
|
|
637
698
|
},
|
|
699
|
+
cargo: cargo
|
|
700
|
+
? {
|
|
701
|
+
engine: cargo.engine,
|
|
702
|
+
protocolVersion: cargo.protocolVersion,
|
|
703
|
+
crates: cargo.crates,
|
|
704
|
+
registries: cargo.registries.map((cellArg) => [
|
|
705
|
+
cellArg.crate,
|
|
706
|
+
cellArg.registry,
|
|
707
|
+
]),
|
|
708
|
+
}
|
|
709
|
+
: undefined,
|
|
638
710
|
giteaAssets:
|
|
639
711
|
journalArg.schemaVersion === 4
|
|
640
712
|
? {
|
|
@@ -653,6 +725,7 @@ const immutableJournalIdentity = (journalArg: TReleaseJournal): string =>
|
|
|
653
725
|
}
|
|
654
726
|
: undefined,
|
|
655
727
|
});
|
|
728
|
+
};
|
|
656
729
|
|
|
657
730
|
const releaseIdentityKeys = ["version", "tag", "mainOid", "tagOid"] as const;
|
|
658
731
|
|
|
@@ -831,10 +904,134 @@ const assertReleaseIdentity = (valueArg: unknown): IReleaseIdentity => {
|
|
|
831
904
|
return valueArg as unknown as IReleaseIdentity;
|
|
832
905
|
};
|
|
833
906
|
|
|
907
|
+
/**
|
|
908
|
+
* The Cargo section: crates in dependency order with payload names derived
|
|
909
|
+
* from their names, and one cell per crate and registry. A cell leaves
|
|
910
|
+
* pending only after every dependency verified in the same registry, because
|
|
911
|
+
* a registry refuses a crate whose dependency it does not index yet.
|
|
912
|
+
*/
|
|
913
|
+
const assertReleaseCargoJournal = (
|
|
914
|
+
valueArg: unknown,
|
|
915
|
+
releaseArg: IReleaseIdentity,
|
|
916
|
+
): IReleaseCargoJournal => {
|
|
917
|
+
if (!isPlainObject(valueArg)) {
|
|
918
|
+
throw new Error("Release journal cargo target must be an object.");
|
|
919
|
+
}
|
|
920
|
+
assertExactKeys(
|
|
921
|
+
valueArg,
|
|
922
|
+
["engine", "protocolVersion", "crates", "registries"],
|
|
923
|
+
"Release journal cargo target",
|
|
924
|
+
);
|
|
925
|
+
if (
|
|
926
|
+
valueArg.engine !== "rsrepo" ||
|
|
927
|
+
valueArg.protocolVersion !== 1 ||
|
|
928
|
+
!Array.isArray(valueArg.crates) ||
|
|
929
|
+
valueArg.crates.length === 0 ||
|
|
930
|
+
valueArg.crates.length > 1000 ||
|
|
931
|
+
!Array.isArray(valueArg.registries)
|
|
932
|
+
) {
|
|
933
|
+
throw new Error("Release journal cargo target is invalid.");
|
|
934
|
+
}
|
|
935
|
+
const names: string[] = [];
|
|
936
|
+
for (const [index, crate] of valueArg.crates.entries()) {
|
|
937
|
+
const context = `Release journal crate ${index}`;
|
|
938
|
+
if (!isPlainObject(crate)) throw new Error(`${context} must be an object.`);
|
|
939
|
+
assertExactKeys(
|
|
940
|
+
crate,
|
|
941
|
+
["kind", "file", "crateName", "version", "size", "sha256", "dependencies"],
|
|
942
|
+
context,
|
|
943
|
+
);
|
|
944
|
+
if (
|
|
945
|
+
crate.kind !== "cargo-crate" ||
|
|
946
|
+
!isCargoCrateName(crate.crateName) ||
|
|
947
|
+
names.includes(crate.crateName) ||
|
|
948
|
+
crate.file !== releaseCrateArtifactFile(crate.crateName) ||
|
|
949
|
+
crate.version !== releaseArg.version ||
|
|
950
|
+
!Number.isSafeInteger(crate.size) ||
|
|
951
|
+
(crate.size as number) <= 0 ||
|
|
952
|
+
typeof crate.sha256 !== "string" ||
|
|
953
|
+
!sha256Regex.test(crate.sha256) ||
|
|
954
|
+
!Array.isArray(crate.dependencies) ||
|
|
955
|
+
new Set(crate.dependencies).size !== crate.dependencies.length ||
|
|
956
|
+
// Dependencies are crates of this release that publish earlier.
|
|
957
|
+
crate.dependencies.some(
|
|
958
|
+
(dependencyArg) =>
|
|
959
|
+
typeof dependencyArg !== "string" || !names.includes(dependencyArg),
|
|
960
|
+
)
|
|
961
|
+
) {
|
|
962
|
+
throw new Error(`${context} identity or publication order is invalid.`);
|
|
963
|
+
}
|
|
964
|
+
names.push(crate.crateName);
|
|
965
|
+
}
|
|
966
|
+
const crates = valueArg.crates as unknown as IReleaseCrateArtifact[];
|
|
967
|
+
const cells = valueArg.registries;
|
|
968
|
+
if (cells.length === 0 || cells.length % crates.length !== 0) {
|
|
969
|
+
throw new Error(
|
|
970
|
+
"Release journal cargo cells must cover every crate in every registry.",
|
|
971
|
+
);
|
|
972
|
+
}
|
|
973
|
+
const registryCount = cells.length / crates.length;
|
|
974
|
+
const registries: string[] = [];
|
|
975
|
+
for (const [index, cell] of cells.entries()) {
|
|
976
|
+
const context = `Release journal cargo cell ${index}`;
|
|
977
|
+
if (!isPlainObject(cell)) throw new Error(`${context} must be an object.`);
|
|
978
|
+
assertExactKeys(
|
|
979
|
+
cell,
|
|
980
|
+
["state", "attempts", "attempt", "error", "registry", "crate"],
|
|
981
|
+
context,
|
|
982
|
+
);
|
|
983
|
+
assertTargetStatus(cell, context);
|
|
984
|
+
const crate = crates[Math.floor(index / registryCount)];
|
|
985
|
+
if (index < registryCount) {
|
|
986
|
+
if (!isCargoRegistryName(cell.registry) || registries.includes(cell.registry))
|
|
987
|
+
throw new Error(`${context} registry is invalid.`);
|
|
988
|
+
registries.push(cell.registry);
|
|
989
|
+
}
|
|
990
|
+
if (
|
|
991
|
+
cell.state === "skipped" ||
|
|
992
|
+
cell.crate !== crate.crateName ||
|
|
993
|
+
cell.registry !== registries[index % registryCount]
|
|
994
|
+
) {
|
|
995
|
+
throw new Error(
|
|
996
|
+
"Release journal cargo cells must list every registry per crate, in crate order.",
|
|
997
|
+
);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
const cargo = valueArg as unknown as IReleaseCargoJournal;
|
|
1001
|
+
for (const cell of cargo.registries) {
|
|
1002
|
+
if (cell.state === "pending") continue;
|
|
1003
|
+
const crate = crates.find((entryArg) => entryArg.crateName === cell.crate)!;
|
|
1004
|
+
for (const dependency of crate.dependencies) {
|
|
1005
|
+
const dependencyCell = cargo.registries.find(
|
|
1006
|
+
(entryArg) =>
|
|
1007
|
+
entryArg.crate === dependency && entryArg.registry === cell.registry,
|
|
1008
|
+
)!;
|
|
1009
|
+
if (!["verified", "conflict"].includes(dependencyCell.state)) {
|
|
1010
|
+
throw new Error(
|
|
1011
|
+
`Release journal cargo cell ${cell.crate} in ${cell.registry} left pending before its dependency ${dependency} verified.`,
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
return cargo;
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
/** At most one target of a journal with crates publishes at a time. */
|
|
1020
|
+
const assertSingleCargoPublisher = (
|
|
1021
|
+
statusesArg: IReleaseTargetStatus[],
|
|
1022
|
+
): void => {
|
|
1023
|
+
if (statusesArg.filter((statusArg) => statusArg.state === "publishing").length > 1) {
|
|
1024
|
+
throw new Error(
|
|
1025
|
+
"A release journal with crates permits at most one active publication owner.",
|
|
1026
|
+
);
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
|
|
834
1030
|
const assertReleaseJournalV1 = (valueArg: unknown): IReleaseJournalV1 => {
|
|
835
1031
|
if (!isPlainObject(valueArg)) {
|
|
836
1032
|
throw new Error("Release journal root must be a JSON object.");
|
|
837
1033
|
}
|
|
1034
|
+
const hasCargo = Object.hasOwn(valueArg, "cargo");
|
|
838
1035
|
assertExactKeys(
|
|
839
1036
|
valueArg,
|
|
840
1037
|
[
|
|
@@ -845,6 +1042,7 @@ const assertReleaseJournalV1 = (valueArg: unknown): IReleaseJournalV1 => {
|
|
|
845
1042
|
"artifact",
|
|
846
1043
|
"git",
|
|
847
1044
|
"npm",
|
|
1045
|
+
...(hasCargo ? ["cargo"] : []),
|
|
848
1046
|
"createdAt",
|
|
849
1047
|
"updatedAt",
|
|
850
1048
|
"completedAt",
|
|
@@ -972,6 +1170,14 @@ const assertReleaseJournalV1 = (valueArg: unknown): IReleaseJournalV1 => {
|
|
|
972
1170
|
"Release journal npm targets and artifact must exist together.",
|
|
973
1171
|
);
|
|
974
1172
|
}
|
|
1173
|
+
if (hasCargo) {
|
|
1174
|
+
const cargo = assertReleaseCargoJournal(valueArg.cargo, release);
|
|
1175
|
+
assertSingleCargoPublisher([
|
|
1176
|
+
valueArg.git as unknown as IReleaseTargetStatus,
|
|
1177
|
+
...(valueArg.npm.registries as IReleaseTargetStatus[]),
|
|
1178
|
+
...cargo.registries,
|
|
1179
|
+
]);
|
|
1180
|
+
}
|
|
975
1181
|
|
|
976
1182
|
const createdAt = assertIsoTimestamp(
|
|
977
1183
|
valueArg.createdAt,
|
|
@@ -1333,6 +1539,7 @@ const assertReleaseJournalV2 = (valueArg: unknown): IReleaseJournalV2 => {
|
|
|
1333
1539
|
const assertReleaseJournalV3 = (
|
|
1334
1540
|
valueArg: Record<string, unknown>,
|
|
1335
1541
|
): IReleaseJournalV3 => {
|
|
1542
|
+
const hasCargo = Object.hasOwn(valueArg, "cargo");
|
|
1336
1543
|
assertExactKeys(
|
|
1337
1544
|
valueArg,
|
|
1338
1545
|
[
|
|
@@ -1344,6 +1551,7 @@ const assertReleaseJournalV3 = (
|
|
|
1344
1551
|
"packages",
|
|
1345
1552
|
"git",
|
|
1346
1553
|
"npm",
|
|
1554
|
+
...(hasCargo ? ["cargo"] : []),
|
|
1347
1555
|
"createdAt",
|
|
1348
1556
|
"updatedAt",
|
|
1349
1557
|
"completedAt",
|
|
@@ -1365,7 +1573,8 @@ const assertReleaseJournalV3 = (
|
|
|
1365
1573
|
const targets = valueArg.npm.registries;
|
|
1366
1574
|
let expectedRegistries: string[] | undefined;
|
|
1367
1575
|
let targetOffset = 0;
|
|
1368
|
-
|
|
1576
|
+
// The Cargo section is validated once below, not in each package projection.
|
|
1577
|
+
const { packages, cargo: rawCargo, ...common } = valueArg;
|
|
1369
1578
|
// Each package owns the next run of targets. Reuse the established identity,
|
|
1370
1579
|
// destination, state and timestamp validators through a schema 1 projection
|
|
1371
1580
|
// per package; the projection is validation-only and never rewrites data.
|
|
@@ -1456,9 +1665,16 @@ const assertReleaseJournalV3 = (
|
|
|
1456
1665
|
if (rootArtifact) assertPackageTargets(rootArtifact);
|
|
1457
1666
|
if (targetOffset !== targets.length)
|
|
1458
1667
|
throw new Error("Unexpected or out-of-order release package target.");
|
|
1668
|
+
const cargo = hasCargo
|
|
1669
|
+
? assertReleaseCargoJournal(
|
|
1670
|
+
rawCargo,
|
|
1671
|
+
valueArg.release as unknown as IReleaseIdentity,
|
|
1672
|
+
)
|
|
1673
|
+
: undefined;
|
|
1459
1674
|
const statuses = [
|
|
1460
1675
|
valueArg.git as IReleaseTargetStatus,
|
|
1461
1676
|
...(targets as IReleaseTargetStatus[]),
|
|
1677
|
+
...(cargo?.registries ?? []),
|
|
1462
1678
|
];
|
|
1463
1679
|
if (statuses.filter((target) => target.state === "publishing").length > 1) {
|
|
1464
1680
|
throw new Error("Schema 3 permits at most one active publication owner.");
|
|
@@ -1945,42 +2161,52 @@ const assertSchema4AppendOnlyTransition = (
|
|
|
1945
2161
|
];
|
|
1946
2162
|
const nextStatuses = statuses(next);
|
|
1947
2163
|
for (const [index, before] of statuses(current).entries()) {
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
if (after.attempts !== before.attempts + 1)
|
|
1962
|
-
throw new Error(
|
|
1963
|
-
"Publication claims must increment the attempt counter once.",
|
|
1964
|
-
);
|
|
1965
|
-
continue;
|
|
1966
|
-
}
|
|
2164
|
+
assertStatusAppendOnly(before, nextStatuses[index]);
|
|
2165
|
+
}
|
|
2166
|
+
};
|
|
2167
|
+
|
|
2168
|
+
/**
|
|
2169
|
+
* One target's transition: a claim increments its attempts once, an owned
|
|
2170
|
+
* attempt keeps its owner, and no state regresses or rewrites its history.
|
|
2171
|
+
*/
|
|
2172
|
+
const assertStatusAppendOnly = (
|
|
2173
|
+
before: IReleaseTargetStatus,
|
|
2174
|
+
after: IReleaseTargetStatus,
|
|
2175
|
+
): void => {
|
|
2176
|
+
if (before.state === "publishing" && after.state === "publishing") {
|
|
1967
2177
|
if (
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
) {
|
|
2178
|
+
JSON.stringify(before.attempt) !== JSON.stringify(after.attempt) ||
|
|
2179
|
+
before.attempts !== after.attempts
|
|
2180
|
+
)
|
|
2181
|
+
throw new Error("Publication attempt ownership cannot change.");
|
|
2182
|
+
return;
|
|
2183
|
+
}
|
|
2184
|
+
if (
|
|
2185
|
+
(before.state === "pending" || before.state === "failed") &&
|
|
2186
|
+
after.state === "publishing"
|
|
2187
|
+
) {
|
|
2188
|
+
if (after.attempts !== before.attempts + 1)
|
|
1980
2189
|
throw new Error(
|
|
1981
|
-
"
|
|
2190
|
+
"Publication claims must increment the attempt counter once.",
|
|
1982
2191
|
);
|
|
1983
|
-
|
|
2192
|
+
return;
|
|
2193
|
+
}
|
|
2194
|
+
if (
|
|
2195
|
+
after.attempts !== before.attempts ||
|
|
2196
|
+
(after.state === "pending" && before.state !== "pending") ||
|
|
2197
|
+
(after.state === "accepted" &&
|
|
2198
|
+
!["publishing", "accepted"].includes(before.state)) ||
|
|
2199
|
+
(before.state === "conflict" && after.state !== "conflict") ||
|
|
2200
|
+
(before.state === "verified" &&
|
|
2201
|
+
!["verified", "conflict"].includes(after.state)) ||
|
|
2202
|
+
(before.state === "accepted" &&
|
|
2203
|
+
!["accepted", "verified", "conflict"].includes(after.state)) ||
|
|
2204
|
+
(before.state === "publishing" &&
|
|
2205
|
+
!["accepted", "verified", "failed", "conflict"].includes(after.state))
|
|
2206
|
+
) {
|
|
2207
|
+
throw new Error(
|
|
2208
|
+
"Release publication status cannot regress or rewrite attempt history.",
|
|
2209
|
+
);
|
|
1984
2210
|
}
|
|
1985
2211
|
};
|
|
1986
2212
|
|
|
@@ -2032,6 +2258,7 @@ const releaseTargets: readonly TReleaseTarget[] = [
|
|
|
2032
2258
|
"git",
|
|
2033
2259
|
"giteaAssets",
|
|
2034
2260
|
"npm",
|
|
2261
|
+
"cargo",
|
|
2035
2262
|
"docker",
|
|
2036
2263
|
];
|
|
2037
2264
|
|
|
@@ -2101,7 +2328,12 @@ export const assertReleaseIntent = (valueArg: unknown): IReleaseIntent => {
|
|
|
2101
2328
|
release.prerelease &&
|
|
2102
2329
|
(plan.targets.includes("docker") || plan.targets.includes("giteaAssets"))
|
|
2103
2330
|
)
|
|
2104
|
-
throw new Error("Prerelease intents support Git and
|
|
2331
|
+
throw new Error("Prerelease intents support Git, npm and cargo targets only.");
|
|
2332
|
+
if (
|
|
2333
|
+
plan.targets.includes("cargo") &&
|
|
2334
|
+
(plan.targets.includes("docker") || plan.targets.includes("giteaAssets"))
|
|
2335
|
+
)
|
|
2336
|
+
throw new Error("A cargo release intent cannot name Docker or Gitea assets.");
|
|
2105
2337
|
if (release.line && plan.targets.includes("giteaAssets")) {
|
|
2106
2338
|
throw new Error(
|
|
2107
2339
|
"A release line never publishes Gitea assets; its intent cannot name them.",
|
|
@@ -2453,6 +2685,7 @@ export class ReleaseJournalStore {
|
|
|
2453
2685
|
public async isPayloadMissing(journalArg: TReleaseJournal): Promise<boolean> {
|
|
2454
2686
|
const files = [
|
|
2455
2687
|
...getReleaseArtifacts(journalArg).map((artifact) => artifact.file),
|
|
2688
|
+
...(getReleaseCargo(journalArg)?.crates.map((crate) => crate.file) ?? []),
|
|
2456
2689
|
...(journalArg.schemaVersion === 4
|
|
2457
2690
|
? journalArg.giteaAssets.assets.map((entry) => entry.asset.fileName)
|
|
2458
2691
|
: []),
|
|
@@ -2677,6 +2910,22 @@ export class ReleaseJournalStore {
|
|
|
2677
2910
|
"New package and asset journals require unclaimed publication targets.",
|
|
2678
2911
|
);
|
|
2679
2912
|
}
|
|
2913
|
+
const cargo = getReleaseCargo(journal);
|
|
2914
|
+
if (
|
|
2915
|
+
cargo &&
|
|
2916
|
+
(journal.completedAt !== null ||
|
|
2917
|
+
cargo.registries.some(
|
|
2918
|
+
(cell) =>
|
|
2919
|
+
cell.state !== "pending" ||
|
|
2920
|
+
cell.attempts !== 0 ||
|
|
2921
|
+
cell.attempt !== null ||
|
|
2922
|
+
cell.error !== null,
|
|
2923
|
+
))
|
|
2924
|
+
) {
|
|
2925
|
+
throw new Error(
|
|
2926
|
+
"New cargo release journals require unclaimed publication targets.",
|
|
2927
|
+
);
|
|
2928
|
+
}
|
|
2680
2929
|
if (journal.schemaVersion === releaseJournalSchemaVersion) {
|
|
2681
2930
|
const commonTargets = [journal.git, ...journal.npm.registries];
|
|
2682
2931
|
const commonTargetsUnclaimed = commonTargets.every(
|
|
@@ -2742,6 +2991,23 @@ export class ReleaseJournalStore {
|
|
|
2742
2991
|
);
|
|
2743
2992
|
}
|
|
2744
2993
|
}
|
|
2994
|
+
for (const crate of cargo?.crates ?? []) {
|
|
2995
|
+
const cratePath = plugins.path.join(temporaryDirectory, crate.file);
|
|
2996
|
+
const crateStat = await plugins.fs.lstat(cratePath);
|
|
2997
|
+
if (!crateStat.isFile() || crateStat.isSymbolicLink()) {
|
|
2998
|
+
throw new Error("Prepared release crate must be a regular file.");
|
|
2999
|
+
}
|
|
3000
|
+
const crateBytes = await plugins.fs.readFile(cratePath);
|
|
3001
|
+
if (
|
|
3002
|
+
crateBytes.byteLength !== crate.size ||
|
|
3003
|
+
plugins.crypto.createHash("sha256").update(crateBytes).digest("hex") !==
|
|
3004
|
+
crate.sha256
|
|
3005
|
+
) {
|
|
3006
|
+
throw new Error(
|
|
3007
|
+
"Prepared release crate does not match its journal identity.",
|
|
3008
|
+
);
|
|
3009
|
+
}
|
|
3010
|
+
}
|
|
2745
3011
|
if (journal.schemaVersion === 4) {
|
|
2746
3012
|
if (journal.giteaAssets.release.id !== null)
|
|
2747
3013
|
throw new Error(
|
|
@@ -2833,6 +3099,13 @@ export class ReleaseJournalStore {
|
|
|
2833
3099
|
}
|
|
2834
3100
|
if (current.schemaVersion === 4 && next.schemaVersion === 4)
|
|
2835
3101
|
assertSchema4AppendOnlyTransition(current, next);
|
|
3102
|
+
const currentCargo = getReleaseCargo(current);
|
|
3103
|
+
const nextCargo = getReleaseCargo(next);
|
|
3104
|
+
if (currentCargo && nextCargo) {
|
|
3105
|
+
for (const [index, before] of currentCargo.registries.entries()) {
|
|
3106
|
+
assertStatusAppendOnly(before, nextCargo.registries[index]);
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
2836
3109
|
assertPreviousLatestTransition(current, next);
|
|
2837
3110
|
await this.writeAtomic(version, next);
|
|
2838
3111
|
return next;
|