@git.zone/cli 6.9.0 → 6.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/dist_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/helpers.workflow.d.ts +23 -1
- package/dist_ts/helpers.workflow.js +93 -3
- package/dist_ts/mod_config/index.js +49 -7
- package/dist_ts/mod_release/classes.releasejournal.d.ts +20 -1
- package/dist_ts/mod_release/classes.releasejournal.js +191 -9
- package/dist_ts/mod_release/helpers.giteaassets.d.ts +36 -0
- package/dist_ts/mod_release/helpers.giteaassets.js +661 -0
- package/dist_ts/mod_release/helpers.npmartifact.d.ts +1 -3
- package/dist_ts/mod_release/helpers.npmartifact.js +88 -66
- package/dist_ts/mod_release/helpers.releasepublication.d.ts +2 -0
- package/dist_ts/mod_release/helpers.releasepublication.js +147 -6
- package/dist_ts/mod_release/index.js +86 -11
- package/dist_ts/mod_release/interfaces.giteaassets.d.ts +50 -0
- package/dist_ts/mod_release/interfaces.giteaassets.js +2 -0
- package/dist_ts/mod_tools/classes.packagemanager.d.ts +2 -0
- package/dist_ts/mod_tools/classes.packagemanager.js +3 -3
- package/package.json +3 -3
- package/readme.md +94 -5
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/helpers.workflow.ts +154 -3
- package/ts/mod_config/index.ts +61 -6
- package/ts/mod_release/classes.releasejournal.ts +298 -14
- package/ts/mod_release/helpers.giteaassets.ts +932 -0
- package/ts/mod_release/helpers.npmartifact.ts +156 -77
- package/ts/mod_release/helpers.releasepublication.ts +224 -4
- package/ts/mod_release/index.ts +111 -8
- package/ts/mod_release/interfaces.giteaassets.ts +67 -0
- package/ts/mod_tools/classes.packagemanager.ts +2 -2
package/ts/mod_release/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
resolveReleaseDockerConfiguration,
|
|
13
13
|
resolveReleaseWorkflow,
|
|
14
14
|
resolveReleaseResumeConfiguration,
|
|
15
|
+
assertGiteaAssetsGitDestination,
|
|
15
16
|
type IResolvedReleaseResumeConfiguration,
|
|
16
17
|
type IResolvedReleaseWorkflow,
|
|
17
18
|
} from "../helpers.workflow.js";
|
|
@@ -35,6 +36,7 @@ import {
|
|
|
35
36
|
normalizeReleaseVersion,
|
|
36
37
|
resolveGitCommonDirectory,
|
|
37
38
|
getReleaseArtifacts,
|
|
39
|
+
hasReleasePackages,
|
|
38
40
|
releasePackageArtifactFile,
|
|
39
41
|
type IReleasePackage,
|
|
40
42
|
type IReleaseArtifact,
|
|
@@ -42,6 +44,10 @@ import {
|
|
|
42
44
|
type IReleaseJournalV1,
|
|
43
45
|
type IReleaseJournalV2,
|
|
44
46
|
} from "./classes.releasejournal.js";
|
|
47
|
+
import {
|
|
48
|
+
GiteaAssetsClient,
|
|
49
|
+
prepareGiteaAssets,
|
|
50
|
+
} from "./helpers.giteaassets.js";
|
|
45
51
|
import {
|
|
46
52
|
assertNoLegacyNpmPublisher,
|
|
47
53
|
assertPnpmReleaseCapability,
|
|
@@ -127,6 +133,11 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
127
133
|
mergeRequested,
|
|
128
134
|
planMode: workflow.confirmation === "plan",
|
|
129
135
|
});
|
|
136
|
+
if (workflow.giteaAssets)
|
|
137
|
+
assertGiteaAssetsGitDestination(
|
|
138
|
+
workflow.giteaAssets,
|
|
139
|
+
branchContext.pushUrl || "",
|
|
140
|
+
);
|
|
130
141
|
printReleasePlan(workflow, branchContext);
|
|
131
142
|
if (
|
|
132
143
|
workflow.targets.includes("npm") &&
|
|
@@ -172,6 +183,20 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
172
183
|
currentVersion,
|
|
173
184
|
versionType,
|
|
174
185
|
);
|
|
186
|
+
if (workflow.giteaAssets) {
|
|
187
|
+
const { tokenEnv, manifestPath, ...destination } = workflow.giteaAssets;
|
|
188
|
+
const token = process.env[tokenEnv];
|
|
189
|
+
if (!token)
|
|
190
|
+
throw new Error(
|
|
191
|
+
`Gitea assets require the configured credential in ${tokenEnv}.`,
|
|
192
|
+
);
|
|
193
|
+
await new GiteaAssetsClient({
|
|
194
|
+
destination,
|
|
195
|
+
tag: `v${plannedVersion}`,
|
|
196
|
+
commit: branchContext.sourceOid,
|
|
197
|
+
token,
|
|
198
|
+
}).preflight();
|
|
199
|
+
}
|
|
175
200
|
if (preflightTsdocker) {
|
|
176
201
|
await preflightTsdocker.validate(
|
|
177
202
|
createDockerQualificationRequest(
|
|
@@ -352,6 +377,18 @@ const assertReleaseConfiguration = (
|
|
|
352
377
|
workflowArg: IResolvedReleaseWorkflow,
|
|
353
378
|
mergeRequestedArg: boolean,
|
|
354
379
|
): void => {
|
|
380
|
+
if (
|
|
381
|
+
workflowArg.targets.includes("giteaAssets") &&
|
|
382
|
+
(!workflowArg.giteaAssets ||
|
|
383
|
+
!workflowArg.targets.includes("git") ||
|
|
384
|
+
!workflowArg.pushBranch ||
|
|
385
|
+
!workflowArg.pushTags ||
|
|
386
|
+
workflowArg.targets.includes("docker") ||
|
|
387
|
+
mergeRequestedArg)
|
|
388
|
+
)
|
|
389
|
+
throw new Error(
|
|
390
|
+
"Gitea asset releases require integrated main and Git branch/tag publication without Docker.",
|
|
391
|
+
);
|
|
355
392
|
if (workflowArg.targets.includes("docker")) {
|
|
356
393
|
if (mergeRequestedArg) {
|
|
357
394
|
throw new Error(
|
|
@@ -549,10 +586,47 @@ export const createReleaseJournal = async (
|
|
|
549
586
|
}
|
|
550
587
|
const now = new Date().toISOString();
|
|
551
588
|
const gitStatus = createInitialTargetStatus(gitEnabled);
|
|
589
|
+
const assetConfiguration = optionsArg.workflow.giteaAssets;
|
|
590
|
+
let giteaAssets:
|
|
591
|
+
| import("./classes.releasejournal.js").IReleaseGiteaAssetsJournal
|
|
592
|
+
| undefined;
|
|
593
|
+
if (optionsArg.workflow.targets.includes("giteaAssets")) {
|
|
594
|
+
if (!assetConfiguration || !gitEnabled || optionsArg.dockerRequest)
|
|
595
|
+
throw new Error("Invalid Gitea asset target combination.");
|
|
596
|
+
assertGiteaAssetsGitDestination(
|
|
597
|
+
assetConfiguration,
|
|
598
|
+
optionsArg.releasePushUrl!,
|
|
599
|
+
);
|
|
600
|
+
const { tokenEnv, manifestPath, ...destination } = assetConfiguration;
|
|
601
|
+
const assets = await prepareGiteaAssets({
|
|
602
|
+
repositoryRoot: npmSourceCwd,
|
|
603
|
+
manifestPath,
|
|
604
|
+
version: optionsArg.version,
|
|
605
|
+
tag: `v${optionsArg.version}`,
|
|
606
|
+
artifactDirectory: temporaryDirectory,
|
|
607
|
+
destination,
|
|
608
|
+
});
|
|
609
|
+
giteaAssets = {
|
|
610
|
+
destination,
|
|
611
|
+
tokenEnv,
|
|
612
|
+
manifestPath,
|
|
613
|
+
release: { ...createInitialTargetStatus(true), id: null },
|
|
614
|
+
assets: assets.map((asset) => ({
|
|
615
|
+
...createInitialTargetStatus(true),
|
|
616
|
+
asset,
|
|
617
|
+
})),
|
|
618
|
+
};
|
|
619
|
+
}
|
|
552
620
|
const journal = finalizeJournalCompletion(
|
|
553
621
|
{
|
|
554
622
|
kind: "gitzone-release-journal",
|
|
555
|
-
schemaVersion:
|
|
623
|
+
schemaVersion: giteaAssets
|
|
624
|
+
? 4
|
|
625
|
+
: packages.length
|
|
626
|
+
? 3
|
|
627
|
+
: optionsArg.dockerRequest
|
|
628
|
+
? 2
|
|
629
|
+
: 1,
|
|
556
630
|
revision: 1,
|
|
557
631
|
release: {
|
|
558
632
|
version: optionsArg.version,
|
|
@@ -561,7 +635,7 @@ export const createReleaseJournal = async (
|
|
|
561
635
|
tagOid: optionsArg.refs.tagOid,
|
|
562
636
|
},
|
|
563
637
|
artifact,
|
|
564
|
-
...(packages.length ? { packages } : {}),
|
|
638
|
+
...(packages.length || giteaAssets ? { packages } : {}),
|
|
565
639
|
git: {
|
|
566
640
|
state: gitStatus.state,
|
|
567
641
|
attempts: gitStatus.attempts,
|
|
@@ -602,6 +676,7 @@ export const createReleaseJournal = async (
|
|
|
602
676
|
})
|
|
603
677
|
: [],
|
|
604
678
|
},
|
|
679
|
+
...(giteaAssets ? { giteaAssets } : {}),
|
|
605
680
|
...(optionsArg.dockerRequest
|
|
606
681
|
? {
|
|
607
682
|
docker: createInitialReleaseDockerJournal(
|
|
@@ -887,6 +962,7 @@ const runReleaseResume = async (
|
|
|
887
962
|
const resumeConfiguration = await resolveReleaseResumeConfiguration({
|
|
888
963
|
git: gitEnabled,
|
|
889
964
|
npm: journal.npm.registries.length > 0,
|
|
965
|
+
giteaAssets: journal.schemaVersion === 4,
|
|
890
966
|
});
|
|
891
967
|
await assertResumeConfiguration(resumeConfiguration, journal, paths.cwd);
|
|
892
968
|
let tsdocker: ITsdockerReleaseClient | undefined;
|
|
@@ -1033,13 +1109,24 @@ const assertResumeConfiguration = async (
|
|
|
1033
1109
|
]) ||
|
|
1034
1110
|
workflowArg.npmAccessLevel !== journalArg.npm.access ||
|
|
1035
1111
|
workflowArg.npmPackageSource !==
|
|
1036
|
-
(journalArg
|
|
1112
|
+
(hasReleasePackages(journalArg) ? "tspublish" : "root") ||
|
|
1037
1113
|
workflowArg.npmAlreadyPublished !== journalArg.npm.alreadyPublished)
|
|
1038
1114
|
) {
|
|
1039
1115
|
throw new Error(
|
|
1040
1116
|
"Current npm release configuration does not match the journal.",
|
|
1041
1117
|
);
|
|
1042
1118
|
}
|
|
1119
|
+
if (journalArg.schemaVersion === 4) {
|
|
1120
|
+
const { destination, tokenEnv, manifestPath } = journalArg.giteaAssets;
|
|
1121
|
+
if (
|
|
1122
|
+
JSON.stringify(workflowArg.giteaAssets) !==
|
|
1123
|
+
JSON.stringify({ ...destination, tokenEnv, manifestPath })
|
|
1124
|
+
) {
|
|
1125
|
+
throw new Error(
|
|
1126
|
+
"Current Gitea asset configuration does not match the journal.",
|
|
1127
|
+
);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1043
1130
|
if (
|
|
1044
1131
|
journalArg.git.state !== "skipped" ||
|
|
1045
1132
|
getReleaseArtifacts(journalArg).length
|
|
@@ -1061,12 +1148,19 @@ const printReleaseJournalSummary = (journalArg: TReleaseJournal): void => {
|
|
|
1061
1148
|
`npm ${registry.packageName ? `${registry.packageName} ` : ""}${registry.registry}: ${registry.state}`,
|
|
1062
1149
|
);
|
|
1063
1150
|
}
|
|
1064
|
-
if (journalArg
|
|
1151
|
+
if (hasReleasePackages(journalArg)) {
|
|
1065
1152
|
for (const { artifact } of journalArg.packages)
|
|
1066
1153
|
console.log(
|
|
1067
1154
|
`artifact ${artifact.packageName}: ${artifact.integrity} (${artifact.sha256})`,
|
|
1068
1155
|
);
|
|
1069
1156
|
}
|
|
1157
|
+
if (journalArg.schemaVersion === 4) {
|
|
1158
|
+
console.log(`Gitea release: ${journalArg.giteaAssets.release.state}`);
|
|
1159
|
+
for (const entry of journalArg.giteaAssets.assets)
|
|
1160
|
+
console.log(
|
|
1161
|
+
`asset ${entry.asset.name}: ${entry.state} (${entry.asset.sha256})`,
|
|
1162
|
+
);
|
|
1163
|
+
}
|
|
1070
1164
|
if (journalArg.schemaVersion === 2) {
|
|
1071
1165
|
console.log(
|
|
1072
1166
|
`docker qualification ${journalArg.docker.request.candidateId}: ${journalArg.docker.qualification.state}`,
|
|
@@ -1416,6 +1510,14 @@ function printReleasePlan(
|
|
|
1416
1510
|
`npm registries: ${workflow.npmRegistries.length > 0 ? workflow.npmRegistries.join(", ") : "none"}`,
|
|
1417
1511
|
);
|
|
1418
1512
|
}
|
|
1513
|
+
if (workflow.giteaAssets) {
|
|
1514
|
+
const assets = workflow.giteaAssets;
|
|
1515
|
+
console.log(
|
|
1516
|
+
`Gitea assets: ${assets.apiOrigin}/${assets.owner}/${assets.repository}`,
|
|
1517
|
+
);
|
|
1518
|
+
console.log(`asset manifest: ${assets.manifestPath}`);
|
|
1519
|
+
console.log(`asset credential variable: ${assets.tokenEnv}`);
|
|
1520
|
+
}
|
|
1419
1521
|
if (workflow.targets.includes("docker")) {
|
|
1420
1522
|
console.log(`docker engine: ${workflow.dockerEngine}`);
|
|
1421
1523
|
console.log(
|
|
@@ -1479,7 +1581,7 @@ export function showHelp(mode?: ICliMode): void {
|
|
|
1479
1581
|
{
|
|
1480
1582
|
flag: "--target <names>",
|
|
1481
1583
|
description:
|
|
1482
|
-
"Replace configured targets with a non-empty subset of git,npm,docker",
|
|
1584
|
+
"Replace configured targets with a non-empty subset of git,giteaAssets,npm,docker",
|
|
1483
1585
|
},
|
|
1484
1586
|
{ flag: "--npm", description: "Explicitly select the npm target" },
|
|
1485
1587
|
{
|
|
@@ -1489,7 +1591,8 @@ export function showHelp(mode?: ICliMode): void {
|
|
|
1489
1591
|
},
|
|
1490
1592
|
{
|
|
1491
1593
|
flag: "--no-publish",
|
|
1492
|
-
description:
|
|
1594
|
+
description:
|
|
1595
|
+
"Remove Gitea assets, npm and Docker without implicitly enabling Git",
|
|
1493
1596
|
},
|
|
1494
1597
|
{
|
|
1495
1598
|
flag: "--merge",
|
|
@@ -1542,14 +1645,14 @@ export function showHelp(mode?: ICliMode): void {
|
|
|
1542
1645
|
console.log(" --no-build Disable the post-metadata release build");
|
|
1543
1646
|
console.log(" -p, --push Explicitly select the git target");
|
|
1544
1647
|
console.log(
|
|
1545
|
-
" --target <names> Replace configured targets with a non-empty subset of git,npm,docker",
|
|
1648
|
+
" --target <names> Replace configured targets with a non-empty subset of git,giteaAssets,npm,docker",
|
|
1546
1649
|
);
|
|
1547
1650
|
console.log(" --npm Explicitly select the npm target");
|
|
1548
1651
|
console.log(
|
|
1549
1652
|
" --docker Select digest-qualified Docker publication through project-local tSDocker >= 3.5.1",
|
|
1550
1653
|
);
|
|
1551
1654
|
console.log(
|
|
1552
|
-
" --no-publish Remove npm and Docker without implicitly enabling Git",
|
|
1655
|
+
" --no-publish Remove Gitea assets, npm and Docker without implicitly enabling Git",
|
|
1553
1656
|
);
|
|
1554
1657
|
console.log(
|
|
1555
1658
|
" --merge Fast-forward and lease-push a cleanly rebased feature branch before release metadata",
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface IGiteaAssetDestination {
|
|
2
|
+
apiOrigin: string;
|
|
3
|
+
owner: string;
|
|
4
|
+
repository: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface IGiteaFrozenAsset {
|
|
8
|
+
name: string;
|
|
9
|
+
size: number;
|
|
10
|
+
sha256: string;
|
|
11
|
+
fileName: string;
|
|
12
|
+
publicUrl: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IPrepareGiteaAssetsOptions {
|
|
16
|
+
repositoryRoot: string;
|
|
17
|
+
manifestPath: string;
|
|
18
|
+
version: string;
|
|
19
|
+
tag: string;
|
|
20
|
+
artifactDirectory: string;
|
|
21
|
+
destination: IGiteaAssetDestination;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface IGiteaRelease {
|
|
25
|
+
id: number;
|
|
26
|
+
tag: string;
|
|
27
|
+
publicUrl: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface IGiteaAssetInspection {
|
|
31
|
+
present: IGiteaFrozenAsset[];
|
|
32
|
+
missing: IGiteaFrozenAsset[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface IGiteaAssetsClientOptions {
|
|
36
|
+
destination: IGiteaAssetDestination;
|
|
37
|
+
tag: string;
|
|
38
|
+
commit: string;
|
|
39
|
+
token: string;
|
|
40
|
+
fetchImplementation?: typeof fetch;
|
|
41
|
+
timeoutMs?: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface IGiteaAssetPreflight {
|
|
45
|
+
repositoryId: number;
|
|
46
|
+
/** Issue-attachment setting; Gitea's release FILE_MAX_SIZE is separate. */
|
|
47
|
+
generalAttachmentMaximumBytes: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface IGiteaAssetsClient {
|
|
51
|
+
preflight(): Promise<IGiteaAssetPreflight>;
|
|
52
|
+
inspectRelease(): Promise<IGiteaRelease | null>;
|
|
53
|
+
createRelease(): Promise<IGiteaRelease>;
|
|
54
|
+
inspectAssets(
|
|
55
|
+
releaseId: number,
|
|
56
|
+
expected: IGiteaFrozenAsset[],
|
|
57
|
+
): Promise<IGiteaAssetInspection>;
|
|
58
|
+
uploadAsset(
|
|
59
|
+
releaseId: number,
|
|
60
|
+
asset: IGiteaFrozenAsset,
|
|
61
|
+
artifactDirectory: string,
|
|
62
|
+
): Promise<void>;
|
|
63
|
+
verifyComplete(
|
|
64
|
+
releaseId: number,
|
|
65
|
+
expected: IGiteaFrozenAsset[],
|
|
66
|
+
): Promise<void>;
|
|
67
|
+
}
|
|
@@ -992,7 +992,7 @@ function getLatestVersionFromMetadata(metadata: any): string | null {
|
|
|
992
992
|
return typeof latest === "string" && latest.length > 0 ? latest : null;
|
|
993
993
|
}
|
|
994
994
|
|
|
995
|
-
function getDefaultMinimumReleaseAgeMinutes(currentPnpmVersion: string): number {
|
|
995
|
+
export function getDefaultMinimumReleaseAgeMinutes(currentPnpmVersion: string): number {
|
|
996
996
|
const majorVersion = normalizeSemver(currentPnpmVersion)[0] || 0;
|
|
997
997
|
return majorVersion >= 11 ? 1440 : 0;
|
|
998
998
|
}
|
|
@@ -1086,7 +1086,7 @@ function normalizePnpmConfigListItem(rawItem: string): string {
|
|
|
1086
1086
|
.trim();
|
|
1087
1087
|
}
|
|
1088
1088
|
|
|
1089
|
-
function packageSelectorMatches(
|
|
1089
|
+
export function packageSelectorMatches(
|
|
1090
1090
|
packageName: string,
|
|
1091
1091
|
version: string,
|
|
1092
1092
|
pattern: string,
|