@git.zone/cli 9.2.2 → 11.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/.smartconfig.json +5 -3
- package/assets/templates/asset_binary_installer/install.sh +109 -34
- package/assets/templates/asset_binary_release_gitea/.gitea/workflows/release.yml +17 -4
- 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/cli/cli.ts.js +1 -1
- 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/npm/.package.json +4 -6
- package/assets/templates/npm/test/test.ts +1 -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/assets/templates/service/.package.json +3 -6
- package/assets/templates/wcc/.package.json +3 -6
- package/assets/templates/wcc_update/html/index.html +2 -2
- package/assets/templates/website/.package.json +3 -6
- package/assets/templates/website/npmextra.json +3 -1
- package/assets/templates/website_update/html/index.html +4 -4
- 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.packagefiles.js +2 -2
- 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 +11 -4
- 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_commit/mod.plugins.d.ts +1 -1
- package/dist_ts/mod_commit/mod.plugins.js +2 -2
- package/dist_ts/mod_config/index.js +131 -18
- package/dist_ts/mod_format/formatters/assets.formatter.js +30 -28
- 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/formatters/templates.formatter.d.ts +3 -2
- package/dist_ts/mod_format/formatters/templates.formatter.js +61 -14
- package/dist_ts/mod_format/formatters/tsconfig.formatter.js +2 -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/dist_ts/mod_tools/index.js +3 -8
- package/dist_ts/plugins.d.ts +1 -1
- package/dist_ts/plugins.js +2 -2
- package/package.json +6 -11
- package/readme.md +244 -26
- 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.packagefiles.ts +1 -1
- 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 +62 -19
- 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_commit/mod.plugins.ts +1 -1
- package/ts/mod_config/index.ts +169 -19
- package/ts/mod_format/formatters/assets.formatter.ts +29 -28
- 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/formatters/templates.formatter.ts +80 -14
- package/ts/mod_format/formatters/tsconfig.formatter.ts +1 -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_tools/index.ts +2 -7
- package/ts/plugins.ts +1 -1
package/ts/helpers.workflow.ts
CHANGED
|
@@ -33,7 +33,7 @@ export type TConfirmationMode = "prompt" | "auto" | "plan";
|
|
|
33
33
|
export type TCommitStep =
|
|
34
34
|
"format" | "analyze" | "test" | "build" | "changelog" | "commit" | "push";
|
|
35
35
|
|
|
36
|
-
export type TReleaseTarget = "git" | "giteaAssets" | "npm" | "docker";
|
|
36
|
+
export type TReleaseTarget = "git" | "giteaAssets" | "npm" | "cargo" | "docker";
|
|
37
37
|
|
|
38
38
|
export interface ICommitWorkflowConfig {
|
|
39
39
|
confirmation?: TConfirmationMode;
|
|
@@ -264,6 +264,122 @@ export interface IReleaseDockerTargetConfig {
|
|
|
264
264
|
noBuild?: boolean;
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
+
/**
|
|
268
|
+
* Cargo publication through the rsrepo engine. No configured cargo target
|
|
269
|
+
* means no Cargo publication.
|
|
270
|
+
*/
|
|
271
|
+
export interface IReleaseCargoTargetConfig {
|
|
272
|
+
enabled?: boolean;
|
|
273
|
+
/** `crates-io` or registry names defined in cargo config. */
|
|
274
|
+
registries?: string[];
|
|
275
|
+
/** Crates to publish; default every member whose Cargo `publish` admits each registry. */
|
|
276
|
+
members?: string[];
|
|
277
|
+
/** Minutes one accepted crate may stay unindexed before resume takes over. */
|
|
278
|
+
verificationWindowMinutes?: number;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface IResolvedReleaseCargoConfiguration {
|
|
282
|
+
registries: string[];
|
|
283
|
+
members?: string[];
|
|
284
|
+
verificationWindowMinutes: number;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** The keys `release.targets` accepts; anything else is a typo or a target this gitzone lacks. */
|
|
288
|
+
export const releaseTargetConfigKeys = [
|
|
289
|
+
"git",
|
|
290
|
+
"giteaAssets",
|
|
291
|
+
"npm",
|
|
292
|
+
"docker",
|
|
293
|
+
"cargo",
|
|
294
|
+
] as const;
|
|
295
|
+
|
|
296
|
+
const cargoTargetConfigKeys = [
|
|
297
|
+
"enabled",
|
|
298
|
+
"registries",
|
|
299
|
+
"members",
|
|
300
|
+
"verificationWindowMinutes",
|
|
301
|
+
];
|
|
302
|
+
|
|
303
|
+
export const defaultCargoVerificationWindowMinutes = 15;
|
|
304
|
+
|
|
305
|
+
/** An enabled flag or registries switch the cargo target on, as for npm. */
|
|
306
|
+
export const isCargoTargetEnabled = (configArg: unknown): boolean => {
|
|
307
|
+
if (configArg === undefined) return false;
|
|
308
|
+
if (typeof configArg !== "object" || configArg === null || Array.isArray(configArg))
|
|
309
|
+
throw new Error("release.targets.cargo must be an object.");
|
|
310
|
+
const config = configArg as IReleaseCargoTargetConfig;
|
|
311
|
+
if (config.enabled !== undefined && typeof config.enabled !== "boolean")
|
|
312
|
+
throw new Error("release.targets.cargo.enabled must be true or false.");
|
|
313
|
+
return (
|
|
314
|
+
config.enabled ??
|
|
315
|
+
(Array.isArray(config.registries)
|
|
316
|
+
? config.registries.length > 0
|
|
317
|
+
: config.registries !== undefined)
|
|
318
|
+
);
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
/** The active cargo target's settings; every key is checked. */
|
|
322
|
+
export const resolveCargoTargetConfiguration = (
|
|
323
|
+
configArg: unknown,
|
|
324
|
+
): IResolvedReleaseCargoConfiguration => {
|
|
325
|
+
if (typeof configArg !== "object" || configArg === null || Array.isArray(configArg))
|
|
326
|
+
throw new Error("release.targets.cargo must be an object.");
|
|
327
|
+
const config = configArg as Record<string, unknown>;
|
|
328
|
+
const unknownKeys = Object.keys(config).filter(
|
|
329
|
+
(keyArg) => !cargoTargetConfigKeys.includes(keyArg),
|
|
330
|
+
);
|
|
331
|
+
if (unknownKeys.length > 0)
|
|
332
|
+
throw new Error(
|
|
333
|
+
`release.targets.cargo has unknown keys: ${unknownKeys.join(", ")}. Use ${cargoTargetConfigKeys.join(", ")}.`,
|
|
334
|
+
);
|
|
335
|
+
const registries = config.registries;
|
|
336
|
+
if (
|
|
337
|
+
!Array.isArray(registries) ||
|
|
338
|
+
registries.length === 0 ||
|
|
339
|
+
registries.some(
|
|
340
|
+
(registryArg) =>
|
|
341
|
+
typeof registryArg !== "string" ||
|
|
342
|
+
!/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(registryArg),
|
|
343
|
+
) ||
|
|
344
|
+
new Set(registries).size !== registries.length
|
|
345
|
+
)
|
|
346
|
+
throw new Error(
|
|
347
|
+
'release.targets.cargo.registries must list unique registry names: "crates-io" or registries defined in cargo config.',
|
|
348
|
+
);
|
|
349
|
+
const members = config.members;
|
|
350
|
+
if (
|
|
351
|
+
members !== undefined &&
|
|
352
|
+
(!Array.isArray(members) ||
|
|
353
|
+
members.length === 0 ||
|
|
354
|
+
members.some(
|
|
355
|
+
(memberArg) =>
|
|
356
|
+
typeof memberArg !== "string" ||
|
|
357
|
+
!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(memberArg),
|
|
358
|
+
) ||
|
|
359
|
+
new Set(members).size !== members.length)
|
|
360
|
+
)
|
|
361
|
+
throw new Error(
|
|
362
|
+
"release.targets.cargo.members must list unique crate names, or be absent to publish every publishable member.",
|
|
363
|
+
);
|
|
364
|
+
const window = config.verificationWindowMinutes;
|
|
365
|
+
if (
|
|
366
|
+
window !== undefined &&
|
|
367
|
+
(typeof window !== "number" ||
|
|
368
|
+
!Number.isSafeInteger(window) ||
|
|
369
|
+
window < 1 ||
|
|
370
|
+
window > 720)
|
|
371
|
+
)
|
|
372
|
+
throw new Error(
|
|
373
|
+
"release.targets.cargo.verificationWindowMinutes must be a whole number of minutes between 1 and 720",
|
|
374
|
+
);
|
|
375
|
+
return {
|
|
376
|
+
registries: registries as string[],
|
|
377
|
+
...(members !== undefined ? { members: members as string[] } : {}),
|
|
378
|
+
verificationWindowMinutes:
|
|
379
|
+
(window as number | undefined) ?? defaultCargoVerificationWindowMinutes,
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
|
|
267
383
|
export interface IReleaseWorkflowConfig {
|
|
268
384
|
confirmation?: TConfirmationMode;
|
|
269
385
|
/** Newest completed local release records to keep; default 3. */
|
|
@@ -295,6 +411,7 @@ export interface IReleaseWorkflowConfig {
|
|
|
295
411
|
npm?: IReleaseNpmTargetConfig;
|
|
296
412
|
giteaAssets?: IReleaseGiteaAssetsTargetConfig;
|
|
297
413
|
docker?: IReleaseDockerTargetConfig;
|
|
414
|
+
cargo?: IReleaseCargoTargetConfig;
|
|
298
415
|
};
|
|
299
416
|
}
|
|
300
417
|
|
|
@@ -323,6 +440,12 @@ export interface IResolvedReleaseWorkflow {
|
|
|
323
440
|
cleanTestArtifacts: boolean;
|
|
324
441
|
testCommand: string;
|
|
325
442
|
buildCommand: string;
|
|
443
|
+
/**
|
|
444
|
+
* projectType "rust": the Cargo workspace carries the version, read and
|
|
445
|
+
* written through the rsrepo engine, and the release checkout fetches its
|
|
446
|
+
* locked Cargo dependencies.
|
|
447
|
+
*/
|
|
448
|
+
cargoVersioned: boolean;
|
|
326
449
|
changelogFile: "changelog.md";
|
|
327
450
|
changelogPendingSection: "Pending";
|
|
328
451
|
changelogVersionHeading: "## {{date}} - {{version}}";
|
|
@@ -353,6 +476,8 @@ export interface IResolvedReleaseWorkflow {
|
|
|
353
476
|
giteaAssetTransfer?: IGiteaAssetTransferLimits;
|
|
354
477
|
/** Attachments of a draft in progress at the same time. */
|
|
355
478
|
giteaAssetConcurrency?: number;
|
|
479
|
+
/** The cargo target's registries, member filter and verification window, when active. */
|
|
480
|
+
cargo?: IResolvedReleaseCargoConfiguration;
|
|
356
481
|
dockerEnabled: boolean;
|
|
357
482
|
dockerEngine: "tsdocker";
|
|
358
483
|
dockerRegistry?: string;
|
|
@@ -389,6 +514,7 @@ export interface IResolvedReleaseResumeConfiguration {
|
|
|
389
514
|
giteaAssets?: IResolvedReleaseGiteaAssetsConfiguration;
|
|
390
515
|
giteaAssetTransfer?: IGiteaAssetTransferLimits;
|
|
391
516
|
giteaAssetConcurrency?: number;
|
|
517
|
+
cargo?: IResolvedReleaseCargoConfiguration;
|
|
392
518
|
}
|
|
393
519
|
|
|
394
520
|
export type TResolvedReleaseDockerConfiguration = Pick<
|
|
@@ -404,11 +530,23 @@ export type TResolvedReleaseDockerConfiguration = Pick<
|
|
|
404
530
|
>;
|
|
405
531
|
|
|
406
532
|
interface ICliWorkflowConfig {
|
|
533
|
+
projectType?: unknown;
|
|
407
534
|
commit?: ICommitWorkflowConfig;
|
|
408
535
|
release?: IReleaseWorkflowConfig;
|
|
409
536
|
packageFiles?: unknown;
|
|
410
537
|
}
|
|
411
538
|
|
|
539
|
+
/**
|
|
540
|
+
* The test and build commands a project runs when its configuration names
|
|
541
|
+
* none: pnpm scripts, or rsrepo for a Rust project, which has no package.json.
|
|
542
|
+
*/
|
|
543
|
+
export const getDefaultProjectCommands = (
|
|
544
|
+
projectTypeArg: unknown,
|
|
545
|
+
): { test: string; build: string } =>
|
|
546
|
+
projectTypeArg === "rust"
|
|
547
|
+
? { test: "rsrepo test", build: "rsrepo build" }
|
|
548
|
+
: { test: "pnpm test", build: "pnpm build" };
|
|
549
|
+
|
|
412
550
|
const commitFlagToStep: Record<string, TCommitStep | undefined> = {
|
|
413
551
|
f: "format",
|
|
414
552
|
t: "test",
|
|
@@ -742,6 +880,7 @@ const getTargetOverride = (argvArg: any): TReleaseTarget[] | undefined => {
|
|
|
742
880
|
"git",
|
|
743
881
|
"giteaAssets",
|
|
744
882
|
"npm",
|
|
883
|
+
"cargo",
|
|
745
884
|
"docker",
|
|
746
885
|
];
|
|
747
886
|
const targetKey = ["target", "targets"].find((keyArg) =>
|
|
@@ -774,6 +913,7 @@ const getTargetOverride = (argvArg: any): TReleaseTarget[] | undefined => {
|
|
|
774
913
|
const targets: TReleaseTarget[] = [];
|
|
775
914
|
if (argvArg.git || argvArg.p || argvArg.push) targets.push("git");
|
|
776
915
|
if (argvArg.npm) targets.push("npm");
|
|
916
|
+
if (argvArg.cargo) targets.push("cargo");
|
|
777
917
|
if (argvArg.docker) targets.push("docker");
|
|
778
918
|
return targets.length > 0 ? targets : undefined;
|
|
779
919
|
};
|
|
@@ -782,6 +922,7 @@ const releaseTargetOrder: TReleaseTarget[] = [
|
|
|
782
922
|
"git",
|
|
783
923
|
"giteaAssets",
|
|
784
924
|
"npm",
|
|
925
|
+
"cargo",
|
|
785
926
|
"docker",
|
|
786
927
|
];
|
|
787
928
|
|
|
@@ -796,6 +937,7 @@ export const releaseNeedsIsolatedCheckout = (
|
|
|
796
937
|
): boolean =>
|
|
797
938
|
workflowArg.runBuild ||
|
|
798
939
|
workflowArg.targets.includes("npm") ||
|
|
940
|
+
workflowArg.targets.includes("cargo") ||
|
|
799
941
|
workflowArg.targets.includes("giteaAssets");
|
|
800
942
|
|
|
801
943
|
const buildReleasePlan = (options: {
|
|
@@ -818,6 +960,9 @@ const buildReleasePlan = (options: {
|
|
|
818
960
|
// anything: `latest` never moves downwards, and a line takes it only when
|
|
819
961
|
// its dist-tag is `latest` and every higher major is a prerelease.
|
|
820
962
|
if (options.targets.includes("npm")) plan.push("preflight.npmDistTags");
|
|
963
|
+
// Every crate's new version must be absent from every cargo registry, and
|
|
964
|
+
// the workspace plan must hold no blocking problem.
|
|
965
|
+
if (options.targets.includes("cargo")) plan.push("preflight.cargoRegistries");
|
|
821
966
|
if (options.runTests) plan.push("preflight.test");
|
|
822
967
|
if (options.mergeRequested) {
|
|
823
968
|
plan.push("integration.main", "integration.pushMain");
|
|
@@ -840,6 +985,7 @@ const buildReleasePlan = (options: {
|
|
|
840
985
|
if (options.npmPublishSizeLimit)
|
|
841
986
|
plan.push("core.packNpmArtifact.publishSize");
|
|
842
987
|
}
|
|
988
|
+
if (options.targets.includes("cargo")) plan.push("core.packageCrates");
|
|
843
989
|
if (options.targets.includes("giteaAssets"))
|
|
844
990
|
plan.push("core.freezeGiteaAssets");
|
|
845
991
|
plan.push("core.writeReleaseJournal");
|
|
@@ -905,6 +1051,7 @@ export const resolveCommitWorkflow = async (
|
|
|
905
1051
|
}
|
|
906
1052
|
const cliConfig = await readCliWorkflowConfig();
|
|
907
1053
|
const commitConfig = cliConfig.commit || {};
|
|
1054
|
+
const defaultCommands = getDefaultProjectCommands(cliConfig.projectType);
|
|
908
1055
|
const releaseFlagRequested = Boolean(argvArg.r || argvArg.release);
|
|
909
1056
|
|
|
910
1057
|
let confirmation = normalizeConfirmation(commitConfig.confirmation, "prompt");
|
|
@@ -950,8 +1097,8 @@ export const resolveCommitWorkflow = async (
|
|
|
950
1097
|
inputMode === "manual" && step === "analyze" ? "manual" : step,
|
|
951
1098
|
),
|
|
952
1099
|
staging: commitConfig.staging || "all",
|
|
953
|
-
testCommand: commitConfig.test?.command ||
|
|
954
|
-
buildCommand: commitConfig.build?.command ||
|
|
1100
|
+
testCommand: commitConfig.test?.command || defaultCommands.test,
|
|
1101
|
+
buildCommand: commitConfig.build?.command || defaultCommands.build,
|
|
955
1102
|
changelogFile: "changelog.md",
|
|
956
1103
|
changelogSection: "Pending",
|
|
957
1104
|
pushRemote: commitConfig.push?.remote || "origin",
|
|
@@ -1074,6 +1221,32 @@ const assertReleaseLineTargets = (
|
|
|
1074
1221
|
}
|
|
1075
1222
|
};
|
|
1076
1223
|
|
|
1224
|
+
/**
|
|
1225
|
+
* The cargo target publishes a Cargo workspace that gitzone versions
|
|
1226
|
+
* (projectType "rust"), which carries no package.json version for npm.
|
|
1227
|
+
* Docker and Gitea assets cannot join a cargo release yet.
|
|
1228
|
+
*/
|
|
1229
|
+
const assertCargoReleaseTargets = (
|
|
1230
|
+
targetsArg: TReleaseTarget[],
|
|
1231
|
+
cargoVersionedArg: boolean,
|
|
1232
|
+
): void => {
|
|
1233
|
+
if (targetsArg.includes("cargo") && !cargoVersionedArg)
|
|
1234
|
+
throw new Error(
|
|
1235
|
+
'The cargo release target publishes a Cargo workspace versioned by gitzone, which needs projectType "rust".',
|
|
1236
|
+
);
|
|
1237
|
+
if (
|
|
1238
|
+
targetsArg.includes("cargo") &&
|
|
1239
|
+
(targetsArg.includes("docker") || targetsArg.includes("giteaAssets"))
|
|
1240
|
+
)
|
|
1241
|
+
throw new Error(
|
|
1242
|
+
"The cargo release target cannot combine Docker or Gitea assets yet.",
|
|
1243
|
+
);
|
|
1244
|
+
if (cargoVersionedArg && targetsArg.includes("npm"))
|
|
1245
|
+
throw new Error(
|
|
1246
|
+
'projectType "rust" versions its Cargo workspace, so the npm release target has no package.json version to publish.',
|
|
1247
|
+
);
|
|
1248
|
+
};
|
|
1249
|
+
|
|
1077
1250
|
/**
|
|
1078
1251
|
* Resolves the release from its configuration and command line. A resume of
|
|
1079
1252
|
* a recorded release passes `recordedPlanArg`, which replaces every command
|
|
@@ -1149,6 +1322,7 @@ export const resolveReleaseWorkflow = async (
|
|
|
1149
1322
|
if (targetConfig.giteaAssets?.enabled === true)
|
|
1150
1323
|
configuredTargets.push("giteaAssets");
|
|
1151
1324
|
if (npmEnabled) configuredTargets.push("npm");
|
|
1325
|
+
if (isCargoTargetEnabled(targetConfig.cargo)) configuredTargets.push("cargo");
|
|
1152
1326
|
if (dockerEnabled) configuredTargets.push("docker");
|
|
1153
1327
|
let targets = getTargetOverride(argvArg) || configuredTargets;
|
|
1154
1328
|
if (isDisabled(argvArg, "git", "push")) {
|
|
@@ -1185,6 +1359,8 @@ export const resolveReleaseWorkflow = async (
|
|
|
1185
1359
|
);
|
|
1186
1360
|
}
|
|
1187
1361
|
assertReleaseLineTargets(line, targets, argvArg.merge === true);
|
|
1362
|
+
const cargoVersioned = cliConfig.projectType === "rust";
|
|
1363
|
+
assertCargoReleaseTargets(targets, cargoVersioned);
|
|
1188
1364
|
if (
|
|
1189
1365
|
prerelease &&
|
|
1190
1366
|
(targets.includes("docker") || targets.includes("giteaAssets"))
|
|
@@ -1243,6 +1419,9 @@ export const resolveReleaseWorkflow = async (
|
|
|
1243
1419
|
? resolveNpmMaxPublishBytes(npmConfig.maxPublishBytes, npmRegistries)
|
|
1244
1420
|
: {};
|
|
1245
1421
|
const packageFilesConfigured = cliConfig.packageFiles !== undefined;
|
|
1422
|
+
const cargo = targets.includes("cargo")
|
|
1423
|
+
? resolveCargoTargetConfiguration(targetConfig.cargo)
|
|
1424
|
+
: undefined;
|
|
1246
1425
|
|
|
1247
1426
|
return {
|
|
1248
1427
|
confirmation,
|
|
@@ -1263,8 +1442,13 @@ export const resolveReleaseWorkflow = async (
|
|
|
1263
1442
|
runTests,
|
|
1264
1443
|
runBuild,
|
|
1265
1444
|
cleanTestArtifacts,
|
|
1266
|
-
testCommand:
|
|
1267
|
-
|
|
1445
|
+
testCommand:
|
|
1446
|
+
releaseConfig.preflight?.testCommand ||
|
|
1447
|
+
getDefaultProjectCommands(cliConfig.projectType).test,
|
|
1448
|
+
buildCommand:
|
|
1449
|
+
releaseConfig.preflight?.buildCommand ||
|
|
1450
|
+
getDefaultProjectCommands(cliConfig.projectType).build,
|
|
1451
|
+
cargoVersioned,
|
|
1268
1452
|
changelogFile: "changelog.md",
|
|
1269
1453
|
changelogPendingSection: "Pending",
|
|
1270
1454
|
changelogVersionHeading: "## {{date}} - {{version}}",
|
|
@@ -1301,6 +1485,7 @@ export const resolveReleaseWorkflow = async (
|
|
|
1301
1485
|
),
|
|
1302
1486
|
}
|
|
1303
1487
|
: {}),
|
|
1488
|
+
...(cargo ? { cargo } : {}),
|
|
1304
1489
|
dockerEnabled,
|
|
1305
1490
|
dockerEngine: "tsdocker",
|
|
1306
1491
|
...dockerConfiguration,
|
|
@@ -1311,6 +1496,7 @@ export const resolveReleaseResumeConfiguration = async (optionsArg: {
|
|
|
1311
1496
|
git: boolean;
|
|
1312
1497
|
npm: boolean;
|
|
1313
1498
|
giteaAssets?: boolean;
|
|
1499
|
+
cargo?: boolean;
|
|
1314
1500
|
}): Promise<IResolvedReleaseResumeConfiguration> => {
|
|
1315
1501
|
const cliConfig = await readCliWorkflowConfig();
|
|
1316
1502
|
const releaseConfig = cliConfig.release || {};
|
|
@@ -1332,6 +1518,9 @@ export const resolveReleaseResumeConfiguration = async (optionsArg: {
|
|
|
1332
1518
|
"The journaled Gitea asset target must remain enabled for resume.",
|
|
1333
1519
|
);
|
|
1334
1520
|
}
|
|
1521
|
+
if (optionsArg.cargo && !isCargoTargetEnabled(targetConfig.cargo)) {
|
|
1522
|
+
throw new Error("The journaled cargo target must remain enabled for resume.");
|
|
1523
|
+
}
|
|
1335
1524
|
|
|
1336
1525
|
const gitRemote = optionsArg.git ? gitConfig.remote || "origin" : "origin";
|
|
1337
1526
|
if (typeof gitRemote !== "string" || !gitRemote.trim()) {
|
|
@@ -1413,6 +1602,9 @@ export const resolveReleaseResumeConfiguration = async (optionsArg: {
|
|
|
1413
1602
|
),
|
|
1414
1603
|
}
|
|
1415
1604
|
: {}),
|
|
1605
|
+
...(optionsArg.cargo
|
|
1606
|
+
? { cargo: resolveCargoTargetConfiguration(targetConfig.cargo) }
|
|
1607
|
+
: {}),
|
|
1416
1608
|
};
|
|
1417
1609
|
};
|
|
1418
1610
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as plugins from './mod.plugins.js';
|
|
2
|
-
import * as paths from '../paths.js';
|
|
3
2
|
import { logger } from '../gitzone.logging.js';
|
|
4
|
-
import * as ui from './mod.ui.js';
|
|
5
3
|
|
|
6
4
|
export type VersionType = 'patch' | 'minor' | 'major';
|
|
7
5
|
|
|
@@ -64,120 +62,3 @@ export function calculateNewVersion(currentVersion: string, versionType: Version
|
|
|
64
62
|
|
|
65
63
|
return `${major}.${minor}.${patch}`;
|
|
66
64
|
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* The project's package.json, which carries the version gitzone commit and release own.
|
|
70
|
-
*/
|
|
71
|
-
const packageJsonPathIn = async (cwdArg: string): Promise<string> => {
|
|
72
|
-
const packageJsonPath = plugins.path.join(cwdArg, 'package.json');
|
|
73
|
-
if (!(await plugins.smartfs.file(packageJsonPath).exists())) {
|
|
74
|
-
throw new Error(
|
|
75
|
-
`No package.json found in ${cwdArg}: gitzone commit and release version the package.json.`,
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
return packageJsonPath;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Reads the current version from package.json
|
|
83
|
-
* @returns The current version string
|
|
84
|
-
*/
|
|
85
|
-
export async function readCurrentVersion(cwdArg = paths.cwd): Promise<string> {
|
|
86
|
-
const content = (await plugins.smartfs
|
|
87
|
-
.file(await packageJsonPathIn(cwdArg))
|
|
88
|
-
.encoding('utf8')
|
|
89
|
-
.read()) as string;
|
|
90
|
-
const packageJson = JSON.parse(content) as { version?: string };
|
|
91
|
-
|
|
92
|
-
if (!packageJson.version) {
|
|
93
|
-
throw new Error('package.json does not contain a version field');
|
|
94
|
-
}
|
|
95
|
-
return packageJson.version;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Updates the version field in a JSON file
|
|
100
|
-
* @param filePath Path to the JSON file
|
|
101
|
-
* @param newVersion The new version to write
|
|
102
|
-
*/
|
|
103
|
-
export async function updateVersionFile(filePath: string, newVersion: string): Promise<void> {
|
|
104
|
-
const content = (await plugins.smartfs
|
|
105
|
-
.file(filePath)
|
|
106
|
-
.encoding('utf8')
|
|
107
|
-
.read()) as string;
|
|
108
|
-
const config = JSON.parse(content) as { version?: string };
|
|
109
|
-
config.version = newVersion;
|
|
110
|
-
await plugins.smartfs
|
|
111
|
-
.file(filePath)
|
|
112
|
-
.encoding('utf8')
|
|
113
|
-
.write(JSON.stringify(config, null, 2) + '\n');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Updates the package.json version without creating commits or tags.
|
|
118
|
-
* @returns The updated files, relative to `cwdArg`
|
|
119
|
-
*/
|
|
120
|
-
export async function updateProjectVersionFiles(
|
|
121
|
-
newVersion: string,
|
|
122
|
-
cwdArg = paths.cwd,
|
|
123
|
-
): Promise<string[]> {
|
|
124
|
-
await updateVersionFile(await packageJsonPathIn(cwdArg), newVersion);
|
|
125
|
-
return ['package.json'];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Bumps the package.json version, then commits and tags it
|
|
130
|
-
* @param versionType The type of version bump
|
|
131
|
-
* @param currentStep The current step number for progress display
|
|
132
|
-
* @param totalSteps The total number of steps for progress display
|
|
133
|
-
* @returns The new version string
|
|
134
|
-
*/
|
|
135
|
-
export async function bumpProjectVersion(
|
|
136
|
-
versionType: VersionType,
|
|
137
|
-
currentStep?: number,
|
|
138
|
-
totalSteps?: number
|
|
139
|
-
): Promise<string> {
|
|
140
|
-
const description = '🏷️ Bumping version (📦 package.json)';
|
|
141
|
-
|
|
142
|
-
if (currentStep && totalSteps) {
|
|
143
|
-
ui.printStep(currentStep, totalSteps, description, 'in-progress');
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const smartshellInstance = new plugins.smartshell.Smartshell({
|
|
147
|
-
executor: 'bash',
|
|
148
|
-
sourceFilePaths: [],
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
// 1. Read current version
|
|
153
|
-
const currentVersion = await readCurrentVersion();
|
|
154
|
-
|
|
155
|
-
// 2. Calculate new version (reuse existing function!)
|
|
156
|
-
const newVersion = calculateNewVersion(currentVersion, versionType);
|
|
157
|
-
|
|
158
|
-
logger.log('info', `Bumping version: ${currentVersion} → ${newVersion}`);
|
|
159
|
-
|
|
160
|
-
// 3. Determine which files to update
|
|
161
|
-
const filesToUpdate = await updateProjectVersionFiles(newVersion);
|
|
162
|
-
|
|
163
|
-
// 4. Stage all updated files
|
|
164
|
-
await smartshellInstance.exec(`git add ${filesToUpdate.join(' ')}`);
|
|
165
|
-
|
|
166
|
-
// 5. Create version commit
|
|
167
|
-
await smartshellInstance.exec(`git commit -m "v${newVersion}"`);
|
|
168
|
-
|
|
169
|
-
// 6. Create version tag
|
|
170
|
-
await smartshellInstance.exec(`git tag v${newVersion} -m "v${newVersion}"`);
|
|
171
|
-
|
|
172
|
-
logger.log('info', `Created commit and tag v${newVersion}`);
|
|
173
|
-
|
|
174
|
-
if (currentStep && totalSteps) {
|
|
175
|
-
ui.printStep(currentStep, totalSteps, description, 'done');
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return newVersion;
|
|
179
|
-
} catch (error) {
|
|
180
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
181
|
-
throw new Error(`Failed to bump project version: ${errorMessage}`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
@@ -4,6 +4,6 @@ import * as smartfile from "@push.rocks/smartfile";
|
|
|
4
4
|
import * as smartshell from "@push.rocks/smartshell";
|
|
5
5
|
|
|
6
6
|
// Manual commits must not load or initialize the AI dependency chain.
|
|
7
|
-
export const loadTsdoc = () => import("@git.zone/
|
|
7
|
+
export const loadTsdoc = () => import("@git.zone/tsrepo/docs");
|
|
8
8
|
|
|
9
9
|
export { smartfile, smartshell };
|