@git.zone/cli 12.1.1 → 12.3.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/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/helpers.tssea.d.ts +2 -7
- package/dist_ts/helpers.tssea.js +20 -10
- package/dist_ts/helpers.versionsource.d.ts +23 -5
- package/dist_ts/helpers.versionsource.js +115 -37
- package/dist_ts/helpers.workflow.d.ts +60 -17
- package/dist_ts/helpers.workflow.js +156 -51
- package/dist_ts/mod_config/index.js +98 -31
- package/dist_ts/mod_release/classes.releasejournal.d.ts +63 -8
- package/dist_ts/mod_release/classes.releasejournal.js +283 -124
- package/dist_ts/mod_release/helpers.cargorelease.d.ts +4 -3
- package/dist_ts/mod_release/helpers.cargorelease.js +5 -4
- package/dist_ts/mod_release/helpers.fossglobalassets.d.ts +61 -0
- package/dist_ts/mod_release/helpers.fossglobalassets.js +580 -0
- package/dist_ts/mod_release/helpers.giteaassets.d.ts +15 -51
- package/dist_ts/mod_release/helpers.giteaassets.js +40 -507
- package/dist_ts/mod_release/helpers.releaseassets.d.ts +40 -0
- package/dist_ts/mod_release/helpers.releaseassets.js +349 -0
- package/dist_ts/mod_release/helpers.releaseassettransfer.d.ts +67 -0
- package/dist_ts/mod_release/helpers.releaseassettransfer.js +239 -0
- package/dist_ts/mod_release/helpers.releasecheck.js +3 -2
- package/dist_ts/mod_release/helpers.releasepreparation.d.ts +7 -6
- package/dist_ts/mod_release/helpers.releasepreparation.js +34 -7
- package/dist_ts/mod_release/helpers.releasepublication.d.ts +8 -2
- package/dist_ts/mod_release/helpers.releasepublication.js +218 -54
- package/dist_ts/mod_release/helpers.releaseversionsource.d.ts +7 -5
- package/dist_ts/mod_release/helpers.releaseversionsource.js +9 -7
- package/dist_ts/mod_release/index.d.ts +1 -1
- package/dist_ts/mod_release/index.js +109 -68
- package/dist_ts/mod_release/interfaces.fossglobalassets.d.ts +108 -0
- package/dist_ts/mod_release/interfaces.fossglobalassets.js +2 -0
- package/dist_ts/mod_release/interfaces.giteaassets.d.ts +9 -43
- package/dist_ts/mod_release/interfaces.releaseassets.d.ts +68 -0
- package/dist_ts/mod_release/interfaces.releaseassets.js +2 -0
- package/dist_ts/plugins.d.ts +1 -0
- package/dist_ts/plugins.js +1 -1
- package/package.json +3 -2
- package/readme.md +339 -41
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/helpers.tssea.ts +31 -10
- package/ts/helpers.versionsource.ts +176 -45
- package/ts/helpers.workflow.ts +288 -78
- package/ts/mod_config/index.ts +130 -38
- package/ts/mod_release/classes.releasejournal.ts +499 -180
- package/ts/mod_release/helpers.cargorelease.ts +8 -3
- package/ts/mod_release/helpers.fossglobalassets.ts +886 -0
- package/ts/mod_release/helpers.giteaassets.ts +127 -694
- package/ts/mod_release/helpers.releaseassets.ts +516 -0
- package/ts/mod_release/helpers.releaseassettransfer.ts +339 -0
- package/ts/mod_release/helpers.releasecheck.ts +3 -1
- package/ts/mod_release/helpers.releasepreparation.ts +55 -12
- package/ts/mod_release/helpers.releasepublication.ts +351 -69
- package/ts/mod_release/helpers.releaseversionsource.ts +11 -7
- package/ts/mod_release/index.ts +151 -90
- package/ts/mod_release/interfaces.fossglobalassets.ts +127 -0
- package/ts/mod_release/interfaces.giteaassets.ts +14 -47
- package/ts/mod_release/interfaces.releaseassets.ts +96 -0
- package/ts/plugins.ts +3 -0
|
@@ -6,10 +6,18 @@ import type { IRsrepoEngineClient } from "./mod_release/helpers.rsrepoengine.js"
|
|
|
6
6
|
* - `npm`: package.json.
|
|
7
7
|
* - `npm+internal-rust`: package.json; the crates of its `rust/` or `ts_rust/`
|
|
8
8
|
* workspace keep their own versions.
|
|
9
|
+
* - `npm+cargo`: package.json and the `rust/` or `ts_rust/` workspace share
|
|
10
|
+
* the version; a TypeScript project gets it by configuring
|
|
11
|
+
* `release.targets.cargo`. The workspace is read and written only through
|
|
12
|
+
* the rsrepo engine (`plan` and `set-version`).
|
|
9
13
|
* - `cargo`: the Cargo workspace (`projectType: "rust"`), read and written
|
|
10
14
|
* only through the rsrepo engine (`plan` and `set-version`).
|
|
11
15
|
*/
|
|
12
|
-
export type TVersionSourceKind =
|
|
16
|
+
export type TVersionSourceKind =
|
|
17
|
+
| "npm"
|
|
18
|
+
| "npm+internal-rust"
|
|
19
|
+
| "npm+cargo"
|
|
20
|
+
| "cargo";
|
|
13
21
|
|
|
14
22
|
export interface IVersionSource {
|
|
15
23
|
kind: TVersionSourceKind;
|
|
@@ -20,7 +28,12 @@ export interface IVersionSource {
|
|
|
20
28
|
/** `00_commitinfo_data.ts` is baked only into TypeScript projects. */
|
|
21
29
|
bakesCommitInfo: boolean;
|
|
22
30
|
readCurrentVersion: () => Promise<string>;
|
|
23
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* The current version of every carrier, for the release plan: package.json
|
|
33
|
+
* and the Cargo workspace can differ before their first shared release.
|
|
34
|
+
*/
|
|
35
|
+
describeCurrentVersions: () => Promise<string>;
|
|
36
|
+
/** Writes the version and returns the changed files, relative to the project directory. */
|
|
24
37
|
writeVersion: (versionArg: string) => Promise<string[]>;
|
|
25
38
|
}
|
|
26
39
|
|
|
@@ -36,14 +49,36 @@ const fileExists = async (pathArg: string): Promise<boolean> => {
|
|
|
36
49
|
/** Internal Rust workspaces of a TypeScript package, as tsrust lays them out. */
|
|
37
50
|
export const internalRustWorkspaceDirectories = ["rust", "ts_rust"] as const;
|
|
38
51
|
|
|
52
|
+
export type TInternalRustWorkspaceDirectory =
|
|
53
|
+
(typeof internalRustWorkspaceDirectories)[number];
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The internal Rust workspace of a TypeScript project in `cwdArg`: the first
|
|
57
|
+
* of `rust/` and `ts_rust/` that carries a Cargo.toml, the order rsrepo
|
|
58
|
+
* discovers them in.
|
|
59
|
+
*/
|
|
60
|
+
export const findInternalRustWorkspaceDirectory = async (
|
|
61
|
+
cwdArg: string,
|
|
62
|
+
): Promise<TInternalRustWorkspaceDirectory | undefined> => {
|
|
63
|
+
for (const directory of internalRustWorkspaceDirectories) {
|
|
64
|
+
if (await fileExists(plugins.path.join(cwdArg, directory, "Cargo.toml"))) {
|
|
65
|
+
return directory;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
};
|
|
70
|
+
|
|
39
71
|
/**
|
|
40
72
|
* The version source of a project: Cargo for `projectType: "rust"`, otherwise
|
|
41
|
-
* package.json
|
|
42
|
-
*
|
|
73
|
+
* package.json. A TypeScript project with an internal Rust workspace shares
|
|
74
|
+
* the version with it only when it configures `release.targets.cargo`
|
|
75
|
+
* (`cargoTargetConfiguredArg`), because published crates must carry the
|
|
76
|
+
* version gitzone releases; otherwise its crates keep their own versions.
|
|
43
77
|
*/
|
|
44
78
|
export const detectVersionSourceKind = async (
|
|
45
79
|
cwdArg: string,
|
|
46
80
|
projectTypeArg: unknown,
|
|
81
|
+
cargoTargetConfiguredArg = false,
|
|
47
82
|
): Promise<TVersionSourceKind> => {
|
|
48
83
|
if (projectTypeArg === "rust") return "cargo";
|
|
49
84
|
if (!(await fileExists(plugins.path.join(cwdArg, "package.json")))) {
|
|
@@ -56,12 +91,16 @@ export const detectVersionSourceKind = async (
|
|
|
56
91
|
`No package.json found in ${cwdArg}: gitzone commit and release version the package.json, or the Cargo workspace of projectType "rust".`,
|
|
57
92
|
);
|
|
58
93
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
94
|
+
const internal = await findInternalRustWorkspaceDirectory(cwdArg);
|
|
95
|
+
if (cargoTargetConfiguredArg) {
|
|
96
|
+
if (!internal) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
`release.targets.cargo publishes a Cargo workspace, but ${cwdArg} has none in rust/ or ts_rust/. A TypeScript project publishes the crates of its internal workspace; a Rust repository sets @git.zone/cli.projectType to "rust".`,
|
|
99
|
+
);
|
|
62
100
|
}
|
|
101
|
+
return "npm+cargo";
|
|
63
102
|
}
|
|
64
|
-
return "npm";
|
|
103
|
+
return internal ? "npm+internal-rust" : "npm";
|
|
65
104
|
};
|
|
66
105
|
|
|
67
106
|
/** The project's projectType, read from the `.smartconfig.json` in `cwdArg`. */
|
|
@@ -74,10 +113,12 @@ export const readProjectType = (cwdArg: string): unknown => {
|
|
|
74
113
|
return cliConfig?.projectType;
|
|
75
114
|
};
|
|
76
115
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
116
|
+
interface IPackageJsonVersion {
|
|
117
|
+
read: () => Promise<string>;
|
|
118
|
+
write: (versionArg: string) => Promise<void>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const packageJsonVersion = (cwdArg: string): IPackageJsonVersion => {
|
|
81
122
|
const packageJsonPath = plugins.path.join(cwdArg, "package.json");
|
|
82
123
|
const readPackageJson = async (): Promise<Record<string, unknown>> => {
|
|
83
124
|
let content: string;
|
|
@@ -98,21 +139,14 @@ const packageJsonVersionSource = (
|
|
|
98
139
|
return parsed as Record<string, unknown>;
|
|
99
140
|
};
|
|
100
141
|
return {
|
|
101
|
-
|
|
102
|
-
cwd: cwdArg,
|
|
103
|
-
description:
|
|
104
|
-
kindArg === "npm"
|
|
105
|
-
? "package.json"
|
|
106
|
-
: "package.json (internal crates keep their own versions)",
|
|
107
|
-
bakesCommitInfo: true,
|
|
108
|
-
readCurrentVersion: async () => {
|
|
142
|
+
read: async () => {
|
|
109
143
|
const version = (await readPackageJson()).version;
|
|
110
144
|
if (typeof version !== "string" || !version) {
|
|
111
145
|
throw new Error("package.json does not contain a version field");
|
|
112
146
|
}
|
|
113
147
|
return version;
|
|
114
148
|
},
|
|
115
|
-
|
|
149
|
+
write: async (versionArg) => {
|
|
116
150
|
const packageJson = await readPackageJson();
|
|
117
151
|
packageJson.version = versionArg;
|
|
118
152
|
await plugins.fs.writeFile(
|
|
@@ -120,37 +154,131 @@ const packageJsonVersionSource = (
|
|
|
120
154
|
`${JSON.stringify(packageJson, null, 2)}\n`,
|
|
121
155
|
"utf8",
|
|
122
156
|
);
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const packageJsonVersionSource = (
|
|
162
|
+
kindArg: "npm" | "npm+internal-rust",
|
|
163
|
+
cwdArg: string,
|
|
164
|
+
): IVersionSource => {
|
|
165
|
+
const packageJson = packageJsonVersion(cwdArg);
|
|
166
|
+
const description =
|
|
167
|
+
kindArg === "npm"
|
|
168
|
+
? "package.json"
|
|
169
|
+
: "package.json (internal crates keep their own versions)";
|
|
170
|
+
return {
|
|
171
|
+
kind: kindArg,
|
|
172
|
+
cwd: cwdArg,
|
|
173
|
+
description,
|
|
174
|
+
bakesCommitInfo: true,
|
|
175
|
+
readCurrentVersion: packageJson.read,
|
|
176
|
+
describeCurrentVersions: async () =>
|
|
177
|
+
`package.json ${await packageJson.read()}${kindArg === "npm" ? "" : " (internal crates keep their own versions)"}`,
|
|
178
|
+
writeVersion: async (versionArg) => {
|
|
179
|
+
await packageJson.write(versionArg);
|
|
123
180
|
return ["package.json"];
|
|
124
181
|
},
|
|
125
182
|
};
|
|
126
183
|
};
|
|
127
184
|
|
|
185
|
+
/**
|
|
186
|
+
* The shared version of the Cargo workspace rsrepo finds in `cwdArg`, which
|
|
187
|
+
* must have the layout the source versions: the repository root for
|
|
188
|
+
* projectType "rust", `rust/` or `ts_rust/` beside a package.json.
|
|
189
|
+
*/
|
|
190
|
+
const readCargoWorkspace = async (
|
|
191
|
+
engineArg: IRsrepoEngineClient,
|
|
192
|
+
cwdArg: string,
|
|
193
|
+
kindArg: "cargo" | "npm+cargo",
|
|
194
|
+
): Promise<{ version: string; directory: string }> => {
|
|
195
|
+
const plan = await engineArg.plan({ cwd: cwdArg, registries: [] });
|
|
196
|
+
if (kindArg === "cargo" && plan.layout !== "root") {
|
|
197
|
+
throw new Error(
|
|
198
|
+
`projectType "rust" versions a Cargo workspace at the repository root; rsrepo found the ${plan.layout}/ layout.`,
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
if (kindArg === "npm+cargo" && plan.layout === "root") {
|
|
202
|
+
throw new Error(
|
|
203
|
+
'A TypeScript project shares its version with its rust/ or ts_rust/ Cargo workspace, but rsrepo found a Cargo workspace at the repository root. Move it into rust/, or set @git.zone/cli.projectType to "rust" for a Rust repository.',
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
if (plan.version === null) {
|
|
207
|
+
throw new Error(
|
|
208
|
+
"The Cargo workspace versions its crates independently. gitzone releases one shared version: move the members to [workspace.package] version and `version.workspace = true`.",
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
version: plan.version,
|
|
213
|
+
directory: plan.layout === "root" ? "" : `${plan.layout}/`,
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/** Cargo answers paths relative to the workspace root; the source answers project paths. */
|
|
218
|
+
const writeCargoWorkspaceVersion = async (
|
|
219
|
+
engineArg: IRsrepoEngineClient,
|
|
220
|
+
cwdArg: string,
|
|
221
|
+
kindArg: "cargo" | "npm+cargo",
|
|
222
|
+
versionArg: string,
|
|
223
|
+
): Promise<string[]> => {
|
|
224
|
+
const { directory } = await readCargoWorkspace(engineArg, cwdArg, kindArg);
|
|
225
|
+
const result = await engineArg.setVersion({ cwd: cwdArg, version: versionArg });
|
|
226
|
+
return result.changedFiles.map((fileArg) => `${directory}${fileArg}`);
|
|
227
|
+
};
|
|
228
|
+
|
|
128
229
|
const cargoVersionSource = (
|
|
129
230
|
cwdArg: string,
|
|
130
231
|
engineArg: IRsrepoEngineClient,
|
|
131
|
-
): IVersionSource =>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
232
|
+
): IVersionSource => {
|
|
233
|
+
const read = async () =>
|
|
234
|
+
(await readCargoWorkspace(engineArg, cwdArg, "cargo")).version;
|
|
235
|
+
return {
|
|
236
|
+
kind: "cargo",
|
|
237
|
+
cwd: cwdArg,
|
|
238
|
+
description: "the Cargo workspace version",
|
|
239
|
+
bakesCommitInfo: false,
|
|
240
|
+
readCurrentVersion: read,
|
|
241
|
+
describeCurrentVersions: async () => `Cargo workspace ${await read()}`,
|
|
242
|
+
writeVersion: (versionArg) =>
|
|
243
|
+
writeCargoWorkspaceVersion(engineArg, cwdArg, "cargo", versionArg),
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* package.json carries the current version; the internal workspace takes the
|
|
249
|
+
* release version with it, whatever version it had before.
|
|
250
|
+
*/
|
|
251
|
+
const npmCargoVersionSource = (
|
|
252
|
+
cwdArg: string,
|
|
253
|
+
engineArg: IRsrepoEngineClient,
|
|
254
|
+
): IVersionSource => {
|
|
255
|
+
const packageJson = packageJsonVersion(cwdArg);
|
|
256
|
+
return {
|
|
257
|
+
kind: "npm+cargo",
|
|
258
|
+
cwd: cwdArg,
|
|
259
|
+
description: "package.json and the internal Cargo workspace",
|
|
260
|
+
bakesCommitInfo: true,
|
|
261
|
+
readCurrentVersion: async () => {
|
|
262
|
+
// The workspace must be releasable before anything is created.
|
|
263
|
+
await readCargoWorkspace(engineArg, cwdArg, "npm+cargo");
|
|
264
|
+
return packageJson.read();
|
|
265
|
+
},
|
|
266
|
+
describeCurrentVersions: async () => {
|
|
267
|
+
const workspace = await readCargoWorkspace(engineArg, cwdArg, "npm+cargo");
|
|
268
|
+
return `package.json ${await packageJson.read()} and the ${workspace.directory} Cargo workspace ${workspace.version}; both take the release version`;
|
|
269
|
+
},
|
|
270
|
+
writeVersion: async (versionArg) => {
|
|
271
|
+
const cargoFiles = await writeCargoWorkspaceVersion(
|
|
272
|
+
engineArg,
|
|
273
|
+
cwdArg,
|
|
274
|
+
"npm+cargo",
|
|
275
|
+
versionArg,
|
|
146
276
|
);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
.changedFiles,
|
|
153
|
-
});
|
|
277
|
+
await packageJson.write(versionArg);
|
|
278
|
+
return ["package.json", ...cargoFiles];
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
};
|
|
154
282
|
|
|
155
283
|
/**
|
|
156
284
|
* Opens the version source of `kindArg`. A Cargo source needs the project's
|
|
@@ -161,9 +289,12 @@ export const openVersionSource = (
|
|
|
161
289
|
cwdArg: string,
|
|
162
290
|
engineArg?: IRsrepoEngineClient,
|
|
163
291
|
): IVersionSource => {
|
|
164
|
-
if (kindArg
|
|
292
|
+
if (kindArg === "npm" || kindArg === "npm+internal-rust")
|
|
293
|
+
return packageJsonVersionSource(kindArg, cwdArg);
|
|
165
294
|
if (!engineArg) {
|
|
166
295
|
throw new Error("The Cargo version source requires the rsrepo engine.");
|
|
167
296
|
}
|
|
168
|
-
return
|
|
297
|
+
return kindArg === "cargo"
|
|
298
|
+
? cargoVersionSource(cwdArg, engineArg)
|
|
299
|
+
: npmCargoVersionSource(cwdArg, engineArg);
|
|
169
300
|
};
|