tegami 1.0.0-beta.5 → 1.0.2
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/cli/index.d.ts +1 -1
- package/dist/cli/index.js +8 -10
- package/dist/{draft-DtFyGxe8.js → draft-BqHcSCeX.js} +32 -23
- package/dist/{error-We7chQVJ.js → error-BhMYq9iW.js} +14 -1
- package/dist/{generate-BfYdNTFi.js → generate-Rvz4Lu98.js} +3 -33
- package/dist/generators/simple.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -141
- package/dist/npm-5cG02krT.js +682 -0
- package/dist/plugins/cargo.d.ts +2 -0
- package/dist/plugins/cargo.js +405 -0
- package/dist/plugins/git.d.ts +1 -1
- package/dist/plugins/git.js +1 -1
- package/dist/plugins/github.d.ts +1 -1
- package/dist/plugins/github.js +4 -4
- package/dist/plugins/gitlab.d.ts +1 -1
- package/dist/plugins/gitlab.js +18 -25
- package/dist/plugins/go.d.ts +8 -7
- package/dist/plugins/go.js +34 -20
- package/dist/providers/npm.d.ts +1 -1
- package/dist/providers/npm.js +1 -1
- package/dist/shared-C92toqVI.js +32 -0
- package/dist/{types-C1rEqeM4.d.ts → types-DHddSAez.d.ts} +497 -178
- package/dist/utils/index.js +1 -1
- package/dist/{version-request-DKvR3_xb.js → version-request-oxy16TJ1.js} +1 -1
- package/package.json +2 -2
- package/dist/cargo-hlZX2akE.js +0 -292
- package/dist/npm-CMOyacwf.js +0 -371
- package/dist/providers/cargo.d.ts +0 -2
- package/dist/providers/cargo.js +0 -2
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
import { n as execFailure } from "../error-BhMYq9iW.js";
|
|
2
|
+
import { n as WorkspacePackage } from "../graph-gThXu8Cz.js";
|
|
3
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { x } from "tinyexec";
|
|
6
|
+
import * as semver$1 from "semver";
|
|
7
|
+
import z from "zod";
|
|
8
|
+
import { glob } from "tinyglobby";
|
|
9
|
+
import initToml, { edit, parse as parse$1 } from "@rainbowatcher/toml-edit-js";
|
|
10
|
+
//#region src/plugins/cargo/schema.ts
|
|
11
|
+
const baseDepSchema = z.object({
|
|
12
|
+
package: z.string().optional(),
|
|
13
|
+
features: z.array(z.string()).optional(),
|
|
14
|
+
optional: z.boolean().optional(),
|
|
15
|
+
"default-features": z.boolean().optional()
|
|
16
|
+
});
|
|
17
|
+
/** `{ workspace = true }` — inherit from `[workspace.dependencies]` */
|
|
18
|
+
const workspaceDependencySchema = baseDepSchema.extend({ workspace: z.literal(true) });
|
|
19
|
+
/** `{ path = "../lib" }` — optional `version` for publishing */
|
|
20
|
+
const pathDependencySchema = baseDepSchema.extend({
|
|
21
|
+
path: z.string(),
|
|
22
|
+
version: z.string().optional()
|
|
23
|
+
});
|
|
24
|
+
/** `{ git = "…" }` — exactly one of `branch`, `tag`, or `rev` in practice */
|
|
25
|
+
const gitDependencySchema = baseDepSchema.extend({
|
|
26
|
+
git: z.string(),
|
|
27
|
+
branch: z.string().optional(),
|
|
28
|
+
tag: z.string().optional(),
|
|
29
|
+
rev: z.string().optional(),
|
|
30
|
+
version: z.string().optional()
|
|
31
|
+
});
|
|
32
|
+
/** `{ version = "1.0" }` — crates.io or `[registries]` */
|
|
33
|
+
const registryDependencySchema = baseDepSchema.extend({
|
|
34
|
+
version: z.string(),
|
|
35
|
+
registry: z.string().optional()
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* @see https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html
|
|
39
|
+
*/
|
|
40
|
+
const cargoDependencySchema = z.union([
|
|
41
|
+
z.string(),
|
|
42
|
+
workspaceDependencySchema,
|
|
43
|
+
pathDependencySchema,
|
|
44
|
+
gitDependencySchema,
|
|
45
|
+
registryDependencySchema
|
|
46
|
+
]);
|
|
47
|
+
const cargoInheritSchema = z.looseObject({ workspace: z.literal(true) });
|
|
48
|
+
const cargoWorkspaceSchema = z.looseObject({
|
|
49
|
+
members: z.array(z.string()).optional(),
|
|
50
|
+
exclude: z.array(z.string()).optional(),
|
|
51
|
+
package: z.looseObject({
|
|
52
|
+
version: z.string().optional(),
|
|
53
|
+
publish: z.boolean().optional()
|
|
54
|
+
}).optional(),
|
|
55
|
+
dependencies: z.record(z.string(), cargoDependencySchema).optional(),
|
|
56
|
+
"dev-dependencies": z.record(z.string(), cargoDependencySchema).optional(),
|
|
57
|
+
"build-dependencies": z.record(z.string(), cargoDependencySchema).optional()
|
|
58
|
+
});
|
|
59
|
+
const cargoManifestSchema = z.looseObject({
|
|
60
|
+
package: z.looseObject({
|
|
61
|
+
name: z.string(),
|
|
62
|
+
version: z.string().or(cargoInheritSchema),
|
|
63
|
+
publish: z.boolean().or(cargoInheritSchema).optional()
|
|
64
|
+
}).optional(),
|
|
65
|
+
workspace: cargoWorkspaceSchema.optional(),
|
|
66
|
+
dependencies: z.record(z.string(), cargoDependencySchema).optional(),
|
|
67
|
+
"dev-dependencies": z.record(z.string(), cargoDependencySchema).optional(),
|
|
68
|
+
"build-dependencies": z.record(z.string(), cargoDependencySchema).optional(),
|
|
69
|
+
target: z.record(z.string(), z.looseObject({
|
|
70
|
+
dependencies: z.record(z.string(), cargoDependencySchema).optional(),
|
|
71
|
+
"dev-dependencies": z.record(z.string(), cargoDependencySchema).optional(),
|
|
72
|
+
"build-dependencies": z.record(z.string(), cargoDependencySchema).optional()
|
|
73
|
+
})).optional()
|
|
74
|
+
});
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/plugins/cargo.ts
|
|
77
|
+
const DEP_FIELDS = [
|
|
78
|
+
"dependencies",
|
|
79
|
+
"dev-dependencies",
|
|
80
|
+
"build-dependencies"
|
|
81
|
+
];
|
|
82
|
+
var CargoPackage = class extends WorkspacePackage {
|
|
83
|
+
path;
|
|
84
|
+
file;
|
|
85
|
+
workspaceFile;
|
|
86
|
+
manager = "cargo";
|
|
87
|
+
manifest;
|
|
88
|
+
constructor(path, file, workspaceFile) {
|
|
89
|
+
super();
|
|
90
|
+
this.path = path;
|
|
91
|
+
this.file = file;
|
|
92
|
+
this.workspaceFile = workspaceFile;
|
|
93
|
+
this.manifest = file.data;
|
|
94
|
+
}
|
|
95
|
+
get name() {
|
|
96
|
+
return this.manifest.package.name;
|
|
97
|
+
}
|
|
98
|
+
get version() {
|
|
99
|
+
const packageVersion = this.manifest.package.version;
|
|
100
|
+
if (typeof packageVersion === "string") return packageVersion;
|
|
101
|
+
const inherited = this.workspaceFile?.data.workspace.package;
|
|
102
|
+
if (packageVersion.workspace && inherited?.version) return inherited.version;
|
|
103
|
+
throw new Error(`Invalid Cargo.toml in "${this.path}".`);
|
|
104
|
+
}
|
|
105
|
+
setVersion(version) {
|
|
106
|
+
const packageInfo = this.manifest.package;
|
|
107
|
+
if (typeof packageInfo.version === "string") {
|
|
108
|
+
packageInfo.version = version;
|
|
109
|
+
patchFile(this.file, "package.version", version);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (packageInfo.version.workspace && this.workspaceFile?.data.workspace.package) {
|
|
113
|
+
this.workspaceFile.data.workspace.package.version = version;
|
|
114
|
+
patchFile(this.workspaceFile, "workspace.package.version", version);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
throw new Error(`Invalid Cargo.toml in "${this.path}".`);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
function patchFile(file, path, value) {
|
|
121
|
+
file.content = edit(file.content, path, value);
|
|
122
|
+
}
|
|
123
|
+
function cargo({ updateLockFile = true, bumpDep: getBumpDepType } = {}) {
|
|
124
|
+
return {
|
|
125
|
+
name: "cargo",
|
|
126
|
+
enforce: "pre",
|
|
127
|
+
async init() {
|
|
128
|
+
await initToml();
|
|
129
|
+
},
|
|
130
|
+
async resolve() {
|
|
131
|
+
const graph = await resolveCargoGraph(this.cwd);
|
|
132
|
+
if (graph.packages.size === 0) return;
|
|
133
|
+
this.cargo = { graph };
|
|
134
|
+
for (const pkg of graph.packages.values()) this.graph.add(pkg);
|
|
135
|
+
},
|
|
136
|
+
initDraft(plan) {
|
|
137
|
+
if (!this.cargo) return;
|
|
138
|
+
plan.addPolicy(depsPolicy(this, getBumpDepType));
|
|
139
|
+
},
|
|
140
|
+
async publishPreflight({ pkg }) {
|
|
141
|
+
if (!(pkg instanceof CargoPackage) || !this.cargo) return;
|
|
142
|
+
let shouldPublish = true;
|
|
143
|
+
if (typeof pkg.manifest.package.publish === "boolean") shouldPublish = pkg.manifest.package.publish;
|
|
144
|
+
else if (pkg.manifest.package.publish?.workspace) shouldPublish = pkg.workspaceFile?.data.workspace?.package?.publish ?? shouldPublish;
|
|
145
|
+
const wait = [];
|
|
146
|
+
for (const { table, tablePath } of dependencyTables(pkg.manifest)) for (const [rawName, spec] of Object.entries(table)) {
|
|
147
|
+
const resolved = resolveLinkedDep(pkg.workspaceFile, pkg.file, this.cargo.graph, tablePath, rawName, spec);
|
|
148
|
+
if (!resolved) continue;
|
|
149
|
+
wait.push(resolved.linked.id);
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
shouldPublish,
|
|
153
|
+
wait
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
resolvePlanStatus({ plan }) {
|
|
157
|
+
if (!this.cargo) return;
|
|
158
|
+
return Array.from(plan.packages, async ([id, { preflight }]) => {
|
|
159
|
+
if (!preflight.shouldPublish) return;
|
|
160
|
+
const pkg = this.graph.get(id);
|
|
161
|
+
if (!(pkg instanceof CargoPackage)) return;
|
|
162
|
+
if (!await isPackagePublished(pkg.name, pkg.version)) return "pending";
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
async publish({ pkg }) {
|
|
166
|
+
if (!(pkg instanceof CargoPackage)) return;
|
|
167
|
+
const result = await x("cargo", ["publish"], { nodeOptions: { cwd: pkg.path } });
|
|
168
|
+
if (result.exitCode !== 0) {
|
|
169
|
+
if (/already exists|already published/i.test(`${result.stdout}\n${result.stderr}`)) return { type: "skipped" };
|
|
170
|
+
return {
|
|
171
|
+
type: "failed",
|
|
172
|
+
error: execFailure(`Failed to publish ${pkg.name}@${pkg.version}.`, result).message
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
return { type: "published" };
|
|
176
|
+
},
|
|
177
|
+
async applyDraft(draft) {
|
|
178
|
+
if (!this.cargo) return;
|
|
179
|
+
const graph = this.cargo.graph;
|
|
180
|
+
for (const pkg of graph.packages.values()) {
|
|
181
|
+
const bumped = draft.getPackageDraft(pkg.id)?.bumpVersion(pkg);
|
|
182
|
+
if (bumped) pkg.setVersion(bumped);
|
|
183
|
+
}
|
|
184
|
+
for (const pkg of graph.packages.values()) for (const { table, tablePath } of dependencyTables(pkg.manifest)) for (const [rawName, spec] of Object.entries(table)) {
|
|
185
|
+
const resolved = resolveLinkedDep(pkg.workspaceFile, pkg.file, graph, tablePath, rawName, spec);
|
|
186
|
+
if (!resolved || !resolved.range || !resolved.setRange || semver$1.satisfies(resolved.linked.version, resolved.range)) continue;
|
|
187
|
+
let updatedRange;
|
|
188
|
+
if (resolved.range.startsWith("^")) updatedRange = `^${resolved.linked.version}`;
|
|
189
|
+
else if (resolved.range.startsWith("~")) updatedRange = `~${resolved.linked.version}`;
|
|
190
|
+
else updatedRange = resolved.linked.version;
|
|
191
|
+
table[rawName] = resolved.setRange(updatedRange);
|
|
192
|
+
}
|
|
193
|
+
await Promise.all(Array.from(graph.files.values(), (file) => writeFile(file.path, file.content + "\n")));
|
|
194
|
+
},
|
|
195
|
+
async applyCliDraft() {
|
|
196
|
+
if (!this.cargo || !updateLockFile) return;
|
|
197
|
+
const result = await x("cargo", ["update", "--workspace"], { nodeOptions: { cwd: this.cwd } });
|
|
198
|
+
if (result.exitCode !== 0) throw execFailure("Failed to update Cargo lock file", result);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function depsPolicy({ graph, cargo }, getBumpDepType = ({ kind }) => {
|
|
203
|
+
switch (kind) {
|
|
204
|
+
case "dependencies": return "patch";
|
|
205
|
+
case "build-dependencies":
|
|
206
|
+
case "dev-dependencies": return false;
|
|
207
|
+
}
|
|
208
|
+
}) {
|
|
209
|
+
const cargoGraph = cargo.graph;
|
|
210
|
+
const dependentMap = /* @__PURE__ */ new Map();
|
|
211
|
+
for (const pkg of cargoGraph.packages.values()) for (const { table, tablePath } of dependencyTables(pkg.manifest)) for (const [name, spec] of Object.entries(table)) {
|
|
212
|
+
const resolved = resolveLinkedDep(pkg.workspaceFile, pkg.file, cargoGraph, tablePath, name, spec);
|
|
213
|
+
if (!resolved) continue;
|
|
214
|
+
const id = resolved.linked.id;
|
|
215
|
+
const refs = dependentMap.get(id);
|
|
216
|
+
const kind = tablePath.at(-1);
|
|
217
|
+
if (refs) refs.push({
|
|
218
|
+
dependent: pkg,
|
|
219
|
+
kind,
|
|
220
|
+
name,
|
|
221
|
+
spec,
|
|
222
|
+
version: resolved.range
|
|
223
|
+
});
|
|
224
|
+
else dependentMap.set(id, [{
|
|
225
|
+
dependent: pkg,
|
|
226
|
+
kind,
|
|
227
|
+
name,
|
|
228
|
+
spec,
|
|
229
|
+
version: resolved.range
|
|
230
|
+
}]);
|
|
231
|
+
}
|
|
232
|
+
return {
|
|
233
|
+
id: "cargo:deps",
|
|
234
|
+
onUpdate({ pkg, packageDraft: plan }) {
|
|
235
|
+
if (!(pkg instanceof CargoPackage)) return;
|
|
236
|
+
const deps = dependentMap.get(pkg.id);
|
|
237
|
+
if (!deps) return;
|
|
238
|
+
const group = graph.getPackageGroup(pkg.id);
|
|
239
|
+
const bumped = plan.bumpVersion(pkg);
|
|
240
|
+
if (!bumped) return;
|
|
241
|
+
for (const dep of deps) {
|
|
242
|
+
if (group?.options.syncBump && graph.getPackageGroup(dep.dependent.id) === group) continue;
|
|
243
|
+
if (dep.version && semver$1.satisfies(bumped, dep.version)) continue;
|
|
244
|
+
const bumpType = getBumpDepType(dep);
|
|
245
|
+
if (bumpType === false) continue;
|
|
246
|
+
this.bumpPackage(dep.dependent, {
|
|
247
|
+
type: bumpType,
|
|
248
|
+
reason: `update dependency "${pkg.name}"`
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
async function isPackagePublished(name, version) {
|
|
255
|
+
const response = await fetch(`https://crates.io/api/v1/crates/${encodeURIComponent(name)}/${version}`);
|
|
256
|
+
if (response.status === 200) return true;
|
|
257
|
+
if (response.status === 404) return false;
|
|
258
|
+
throw new Error(`Unable to validate ${name}@${version} against crates.io: ${await response.text()}`);
|
|
259
|
+
}
|
|
260
|
+
async function buildEntry(dir) {
|
|
261
|
+
try {
|
|
262
|
+
const filePath = path.join(dir, "Cargo.toml");
|
|
263
|
+
const content = await readFile(filePath, "utf8");
|
|
264
|
+
return {
|
|
265
|
+
path: filePath,
|
|
266
|
+
data: cargoManifestSchema.parse(parse$1(content)),
|
|
267
|
+
content
|
|
268
|
+
};
|
|
269
|
+
} catch {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
async function resolveCargoGraph(cwd) {
|
|
274
|
+
const out = {
|
|
275
|
+
packages: /* @__PURE__ */ new Map(),
|
|
276
|
+
files: /* @__PURE__ */ new Map()
|
|
277
|
+
};
|
|
278
|
+
const root = await buildEntry(cwd);
|
|
279
|
+
if (!root) return out;
|
|
280
|
+
const rootWorkspace = root.data.workspace;
|
|
281
|
+
out.files.set(root.path, root);
|
|
282
|
+
if (root.data.package) {
|
|
283
|
+
const pkg = new CargoPackage(cwd, root, rootWorkspace ? root : void 0);
|
|
284
|
+
out.packages.set(pkg.name, pkg);
|
|
285
|
+
}
|
|
286
|
+
if (!rootWorkspace || !rootWorkspace.members) return out;
|
|
287
|
+
const dirs = await expandWorkspaceMembers(cwd, rootWorkspace.members, rootWorkspace.exclude);
|
|
288
|
+
await Promise.all(dirs.map(async (dir) => {
|
|
289
|
+
const entry = await buildEntry(dir);
|
|
290
|
+
if (!entry || !entry.data.package) return;
|
|
291
|
+
const pkg = new CargoPackage(dir, entry, root);
|
|
292
|
+
out.files.set(entry.path, entry);
|
|
293
|
+
out.packages.set(pkg.name, pkg);
|
|
294
|
+
}));
|
|
295
|
+
return out;
|
|
296
|
+
}
|
|
297
|
+
async function expandWorkspaceMembers(cwd, members, exclude = []) {
|
|
298
|
+
const patterns = members.filter((member) => member !== ".");
|
|
299
|
+
if (patterns.length === 0) return [];
|
|
300
|
+
return (await glob(patterns, {
|
|
301
|
+
absolute: true,
|
|
302
|
+
cwd,
|
|
303
|
+
ignore: ["**/target/**", ...exclude],
|
|
304
|
+
onlyDirectories: true,
|
|
305
|
+
onlyFiles: false
|
|
306
|
+
})).map((item) => {
|
|
307
|
+
return item.endsWith(path.sep) ? item.slice(0, -1) : item;
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function dependencyTables(manifest, prefix = []) {
|
|
311
|
+
const tables = [];
|
|
312
|
+
for (const field of DEP_FIELDS) {
|
|
313
|
+
const table = manifest[field];
|
|
314
|
+
if (!table) continue;
|
|
315
|
+
tables.push({
|
|
316
|
+
table,
|
|
317
|
+
tablePath: [...prefix, field]
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
const target = manifest.target;
|
|
321
|
+
if (target) for (const [targetKey, targetConfig] of Object.entries(target)) for (const field of DEP_FIELDS) {
|
|
322
|
+
const table = targetConfig[field];
|
|
323
|
+
if (!table) continue;
|
|
324
|
+
tables.push({
|
|
325
|
+
table,
|
|
326
|
+
tablePath: [
|
|
327
|
+
...prefix,
|
|
328
|
+
"target",
|
|
329
|
+
targetKey,
|
|
330
|
+
field
|
|
331
|
+
]
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
return tables;
|
|
335
|
+
}
|
|
336
|
+
function resolveLinkedDep(workspaceFile, file, graph, tablePath, rawName, spec) {
|
|
337
|
+
if (typeof spec === "string") {
|
|
338
|
+
const linked = graph.packages.get(rawName);
|
|
339
|
+
if (!linked) return;
|
|
340
|
+
return {
|
|
341
|
+
linked,
|
|
342
|
+
range: spec,
|
|
343
|
+
setRange(v) {
|
|
344
|
+
patchFile(file, [...tablePath, rawName].join("."), v);
|
|
345
|
+
return v;
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
if ("git" in spec) return;
|
|
350
|
+
if ("workspace" in spec) {
|
|
351
|
+
const kind = tablePath[tablePath.length - 1];
|
|
352
|
+
const entry = workspaceFile?.data.workspace?.[kind]?.[rawName];
|
|
353
|
+
if (!entry) return;
|
|
354
|
+
const resolved = resolveLinkedDep(void 0, workspaceFile, graph, ["workspace", kind], rawName, entry);
|
|
355
|
+
if (!resolved || !resolved.setRange) return resolved;
|
|
356
|
+
return {
|
|
357
|
+
...resolved,
|
|
358
|
+
setRange(v) {
|
|
359
|
+
workspaceFile.data.workspace[kind][rawName] = resolved.setRange(v);
|
|
360
|
+
return spec;
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
if ("path" in spec) {
|
|
365
|
+
const pkgPath = path.resolve(path.dirname(file.path), spec.path);
|
|
366
|
+
for (const pkg of graph.packages.values()) {
|
|
367
|
+
if (pkg.path !== pkgPath) continue;
|
|
368
|
+
return {
|
|
369
|
+
linked: pkg,
|
|
370
|
+
range: spec.version,
|
|
371
|
+
setRange(v) {
|
|
372
|
+
patchFile(file, [
|
|
373
|
+
...tablePath,
|
|
374
|
+
rawName,
|
|
375
|
+
"version"
|
|
376
|
+
].join("."), v);
|
|
377
|
+
return {
|
|
378
|
+
...spec,
|
|
379
|
+
version: v
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
const linked = graph.packages.get(spec.package ?? rawName);
|
|
387
|
+
if (!linked) return;
|
|
388
|
+
return {
|
|
389
|
+
linked,
|
|
390
|
+
range: spec.version,
|
|
391
|
+
setRange(v) {
|
|
392
|
+
patchFile(file, [
|
|
393
|
+
...tablePath,
|
|
394
|
+
rawName,
|
|
395
|
+
"version"
|
|
396
|
+
].join("."), v);
|
|
397
|
+
return {
|
|
398
|
+
...spec,
|
|
399
|
+
version: v
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
//#endregion
|
|
405
|
+
export { CargoPackage, cargo };
|
package/dist/plugins/git.d.ts
CHANGED
package/dist/plugins/git.js
CHANGED
package/dist/plugins/github.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { O as WorkspacePackage, k as Draft, s as TegamiPlugin, t as Awaitable, x as TegamiContext, y as PublishPlan } from "../types-DHddSAez.js";
|
|
2
2
|
import { GitPluginOptions } from "./git.js";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins/github.d.ts
|
package/dist/plugins/github.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { i as formatPackageVersion, r as formatNpmDistTag } from "../semver-EKJ8yK5U.js";
|
|
2
|
-
import { t as changelogFilename } from "../generate-
|
|
3
|
-
import { a as cached, n as execFailure, o as isCI } from "../error-
|
|
4
|
-
import { n as createDraft, o as readChangelogEntries } from "../draft-
|
|
2
|
+
import { t as changelogFilename } from "../generate-Rvz4Lu98.js";
|
|
3
|
+
import { a as cached, n as execFailure, o as isCI } from "../error-BhMYq9iW.js";
|
|
4
|
+
import { n as createDraft, o as readChangelogEntries } from "../draft-BqHcSCeX.js";
|
|
5
5
|
import { git } from "./git.js";
|
|
6
|
-
import { n as createVersionRequestBody, r as hasGitChanges, t as commitVersionBranchChanges } from "../version-request-
|
|
6
|
+
import { n as createVersionRequestBody, r as hasGitChanges, t as commitVersionBranchChanges } from "../version-request-oxy16TJ1.js";
|
|
7
7
|
import { readFile, writeFile } from "node:fs/promises";
|
|
8
8
|
import { basename, join, relative, resolve } from "node:path";
|
|
9
9
|
import { x } from "tinyexec";
|
package/dist/plugins/gitlab.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { O as WorkspacePackage, k as Draft, s as TegamiPlugin, t as Awaitable, x as TegamiContext, y as PublishPlan } from "../types-DHddSAez.js";
|
|
2
2
|
import { GitPluginOptions } from "./git.js";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins/gitlab.d.ts
|
package/dist/plugins/gitlab.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { i as formatPackageVersion, r as formatNpmDistTag } from "../semver-EKJ8yK5U.js";
|
|
2
|
-
import { t as changelogFilename } from "../generate-
|
|
3
|
-
import { a as cached, n as execFailure, o as isCI } from "../error-
|
|
4
|
-
import { n as createDraft, o as readChangelogEntries } from "../draft-
|
|
2
|
+
import { t as changelogFilename } from "../generate-Rvz4Lu98.js";
|
|
3
|
+
import { a as cached, n as execFailure, o as isCI, s as joinPath } from "../error-BhMYq9iW.js";
|
|
4
|
+
import { n as createDraft, o as readChangelogEntries } from "../draft-BqHcSCeX.js";
|
|
5
5
|
import { git } from "./git.js";
|
|
6
|
-
import { n as createVersionRequestBody, r as hasGitChanges, t as commitVersionBranchChanges } from "../version-request-
|
|
6
|
+
import { n as createVersionRequestBody, r as hasGitChanges, t as commitVersionBranchChanges } from "../version-request-oxy16TJ1.js";
|
|
7
7
|
import { readFile, writeFile } from "node:fs/promises";
|
|
8
8
|
import { basename, join, relative, resolve } from "node:path";
|
|
9
9
|
import { x } from "tinyexec";
|
|
@@ -18,17 +18,11 @@ function parseGitLabRepo(repo) {
|
|
|
18
18
|
encodedProjectPath: encodeURIComponent(projectPath)
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
function gitlabApiUrl(apiUrl = "https://gitlab.com/api/v4") {
|
|
22
|
-
return apiUrl.replace(/\/+$/, "");
|
|
23
|
-
}
|
|
24
|
-
function gitlabWebUrl(webUrl = "https://gitlab.com") {
|
|
25
|
-
return webUrl.replace(/\/+$/, "");
|
|
26
|
-
}
|
|
27
21
|
async function gitlabRequest(options, path, init = {}) {
|
|
28
22
|
const headers = new Headers(init.headers);
|
|
29
23
|
headers.set("Accept", "application/json");
|
|
30
24
|
if (options.token) headers.set(options.token.type === "job-token" ? "JOB-TOKEN" : "PRIVATE-TOKEN", options.token.value);
|
|
31
|
-
return fetch(
|
|
25
|
+
return fetch(joinPath(options.apiUrl ?? "https://gitlab.com/api/v4", path), {
|
|
32
26
|
...init,
|
|
33
27
|
headers
|
|
34
28
|
});
|
|
@@ -227,7 +221,7 @@ async function buildMrPreview(context, draft, options = {}) {
|
|
|
227
221
|
return lines.join("\n");
|
|
228
222
|
}
|
|
229
223
|
async function postMrComment(context, body, options = {}) {
|
|
230
|
-
const { repo } = context.gitlab
|
|
224
|
+
const { repo, apiUrl, token } = context.gitlab;
|
|
231
225
|
if (!repo) {
|
|
232
226
|
outro("GITLAB_REPOSITORY or CI_PROJECT_PATH is required.");
|
|
233
227
|
return;
|
|
@@ -238,8 +232,8 @@ async function postMrComment(context, body, options = {}) {
|
|
|
238
232
|
return;
|
|
239
233
|
}
|
|
240
234
|
const api = {
|
|
241
|
-
apiUrl
|
|
242
|
-
token
|
|
235
|
+
apiUrl,
|
|
236
|
+
token
|
|
243
237
|
};
|
|
244
238
|
const markedBody = `${COMMENT_MARKER}\n${body}`;
|
|
245
239
|
const existingId = await findMergeRequestCommentByPrefix(repo, number, COMMENT_MARKER, api);
|
|
@@ -250,11 +244,11 @@ async function postMrComment(context, body, options = {}) {
|
|
|
250
244
|
await createMergeRequestComment(repo, number, markedBody, api);
|
|
251
245
|
}
|
|
252
246
|
async function resolveMergeRequest(context, options) {
|
|
253
|
-
const { repo } = context.gitlab
|
|
247
|
+
const { repo, apiUrl, token } = context.gitlab;
|
|
254
248
|
if (!repo) throw new Error("GITLAB_REPOSITORY or CI_PROJECT_PATH is required.");
|
|
255
249
|
const api = {
|
|
256
|
-
apiUrl
|
|
257
|
-
token
|
|
250
|
+
apiUrl,
|
|
251
|
+
token
|
|
258
252
|
};
|
|
259
253
|
if (options.number !== void 0) {
|
|
260
254
|
const data = await getMergeRequest(repo, options.number, api);
|
|
@@ -299,7 +293,7 @@ function createChangelogUrl(context, repo, branch, filename) {
|
|
|
299
293
|
const filePath = join(relative(context.cwd, context.changelogDir), filename).replaceAll("\\", "/");
|
|
300
294
|
const branchPath = branch.split("/").map(encodeURIComponent).join("/");
|
|
301
295
|
const params = new URLSearchParams({ file_name: filePath });
|
|
302
|
-
return
|
|
296
|
+
return joinPath(context.gitlab.webUrl, repo, "-/new", branchPath) + `?${params}`;
|
|
303
297
|
}
|
|
304
298
|
function parsePositiveInt(value, option) {
|
|
305
299
|
const number = Number(value);
|
|
@@ -322,8 +316,8 @@ function gitlab(options = {}) {
|
|
|
322
316
|
this.gitlab = {
|
|
323
317
|
repo: options.repo ?? process.env.GITLAB_REPOSITORY ?? process.env.CI_PROJECT_PATH,
|
|
324
318
|
token: resolveGitLabToken(options.token),
|
|
325
|
-
apiUrl: options.apiUrl ?? process.env.GITLAB_API_URL ?? process.env.CI_API_V4_URL,
|
|
326
|
-
webUrl: options.webUrl ?? process.env.GITLAB_SERVER_URL ?? process.env.CI_SERVER_URL
|
|
319
|
+
apiUrl: options.apiUrl ?? process.env.GITLAB_API_URL ?? process.env.CI_API_V4_URL ?? "https://gitlab.com/api/v4",
|
|
320
|
+
webUrl: options.webUrl ?? process.env.GITLAB_SERVER_URL ?? process.env.CI_SERVER_URL ?? "https://gitlab.com"
|
|
327
321
|
};
|
|
328
322
|
},
|
|
329
323
|
async resolvePlanStatus({ plan }) {
|
|
@@ -389,7 +383,7 @@ function gitlab(options = {}) {
|
|
|
389
383
|
async initCli(cli) {
|
|
390
384
|
registerMrCli(cli);
|
|
391
385
|
if (!isCI()) return;
|
|
392
|
-
const { repo, token, webUrl } = this.gitlab
|
|
386
|
+
const { repo, token, webUrl } = this.gitlab;
|
|
393
387
|
if (!token || !repo) return;
|
|
394
388
|
const result = await x("git", [
|
|
395
389
|
"remote",
|
|
@@ -442,7 +436,6 @@ function gitlab(options = {}) {
|
|
|
442
436
|
function createChangelogRenderer(context) {
|
|
443
437
|
const { repo, webUrl } = context.gitlab;
|
|
444
438
|
const api = gitLabApiOptions(context.gitlab);
|
|
445
|
-
const baseUrl = gitlabWebUrl(webUrl);
|
|
446
439
|
const resolveFileCommit = cached((filename) => filename, async (filename) => {
|
|
447
440
|
const result = await x("git", [
|
|
448
441
|
"log",
|
|
@@ -470,7 +463,7 @@ function createChangelogRenderer(context) {
|
|
|
470
463
|
if (meta.mergeRequests.length === 0) return;
|
|
471
464
|
const lines = [];
|
|
472
465
|
for (const mr of meta.mergeRequests) {
|
|
473
|
-
let line = repo ? `- [!${mr.number} ${mr.title}](${
|
|
466
|
+
let line = repo ? `- [!${mr.number} ${mr.title}](${joinPath(webUrl, repo, "-/merge_requests", String(mr.number))})` : `- #${mr.number} ${mr.title}`;
|
|
474
467
|
if (mr.user) line += ` by @${mr.user.login}`;
|
|
475
468
|
lines.push(line);
|
|
476
469
|
}
|
|
@@ -488,7 +481,7 @@ function createChangelogRenderer(context) {
|
|
|
488
481
|
let commitSuffix = "";
|
|
489
482
|
if (meta.commit) {
|
|
490
483
|
const short = meta.commit.slice(0, 7);
|
|
491
|
-
const link = repo ? `[${short}](${
|
|
484
|
+
const link = repo ? `[${short}](${joinPath(webUrl, repo, "-/commit", meta.commit)})` : `\`${short}\``;
|
|
492
485
|
commitSuffix += ` (${link})`;
|
|
493
486
|
}
|
|
494
487
|
const lines = [];
|
|
@@ -548,7 +541,7 @@ function resolveGitLabToken(optionToken) {
|
|
|
548
541
|
}
|
|
549
542
|
function gitlabRemoteUrl(repo, token, webUrl) {
|
|
550
543
|
const username = token.type === "job-token" ? "gitlab-ci-token" : "oauth2";
|
|
551
|
-
return
|
|
544
|
+
return joinPath(webUrl.replace(/^https?:\/\//, `https://${username}:${token.value}@`), `${repo}.git`);
|
|
552
545
|
}
|
|
553
546
|
//#endregion
|
|
554
547
|
export { gitlab };
|
package/dist/plugins/go.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M as BumpType, O as WorkspacePackage, s as TegamiPlugin } from "../types-DHddSAez.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugins/go.d.ts
|
|
4
4
|
interface GoModFile {
|
|
@@ -24,6 +24,11 @@ declare class GoPackage extends WorkspacePackage {
|
|
|
24
24
|
setRequire(module: string, version: string): void;
|
|
25
25
|
write(): Promise<void>;
|
|
26
26
|
}
|
|
27
|
+
interface DependentRef {
|
|
28
|
+
dependent: GoPackage;
|
|
29
|
+
name: string;
|
|
30
|
+
version: string;
|
|
31
|
+
}
|
|
27
32
|
interface GoPluginOptions {
|
|
28
33
|
/**
|
|
29
34
|
* Run `go work sync` or `go mod tidy` after versioning.
|
|
@@ -31,14 +36,10 @@ interface GoPluginOptions {
|
|
|
31
36
|
* @default true
|
|
32
37
|
*/
|
|
33
38
|
updateLockFile?: boolean;
|
|
34
|
-
bumpDep?: (opts:
|
|
35
|
-
dependent: GoPackage;
|
|
36
|
-
name: string;
|
|
37
|
-
version: string;
|
|
38
|
-
}) => BumpType | false;
|
|
39
|
+
bumpDep?: (opts: DependentRef) => BumpType | false;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
+
* Plugin for Golang, the release flow of Golang is pretty special, there's some exceptions for it:
|
|
42
43
|
*
|
|
43
44
|
* - Version is stored in lock file, normally, it should prefer to store versions in a file like `package.json` & `Cargo.toml`, but for Golang, there is no such file.
|
|
44
45
|
* - Publishing is handed to Git plugin, because Golang uses Git tag for publishing.
|