tegami 1.0.0-beta.4 → 1.0.1

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.
@@ -0,0 +1,97 @@
1
+ import { O as BumpType, s as TegamiPlugin, w as WorkspacePackage } from "../types-DItu_YCc.js";
2
+ import z from "zod";
3
+
4
+ //#region src/plugins/cargo/schema.d.ts
5
+ declare const cargoManifestSchema: z.ZodObject<{
6
+ package: z.ZodObject<{
7
+ name: z.ZodString;
8
+ version: z.ZodOptional<z.ZodString>;
9
+ publish: z.ZodOptional<z.ZodBoolean>;
10
+ }, z.core.$strip>;
11
+ workspace: z.ZodOptional<z.ZodObject<{
12
+ members: z.ZodOptional<z.ZodArray<z.ZodString>>;
13
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
14
+ package: z.ZodOptional<z.ZodObject<{
15
+ version: z.ZodOptional<z.ZodString>;
16
+ }, z.core.$strip>>;
17
+ }, z.core.$strip>>;
18
+ dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
19
+ version: z.ZodString;
20
+ package: z.ZodOptional<z.ZodString>;
21
+ path: z.ZodOptional<z.ZodString>;
22
+ }, z.core.$strip>]>>>;
23
+ "dev-dependencies": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
24
+ version: z.ZodString;
25
+ package: z.ZodOptional<z.ZodString>;
26
+ path: z.ZodOptional<z.ZodString>;
27
+ }, z.core.$strip>]>>>;
28
+ "build-dependencies": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
29
+ version: z.ZodString;
30
+ package: z.ZodOptional<z.ZodString>;
31
+ path: z.ZodOptional<z.ZodString>;
32
+ }, z.core.$strip>]>>>;
33
+ target: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
34
+ dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
35
+ version: z.ZodString;
36
+ package: z.ZodOptional<z.ZodString>;
37
+ path: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$strip>]>>>;
39
+ "dev-dependencies": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
40
+ version: z.ZodString;
41
+ package: z.ZodOptional<z.ZodString>;
42
+ path: z.ZodOptional<z.ZodString>;
43
+ }, z.core.$strip>]>>>;
44
+ "build-dependencies": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
45
+ version: z.ZodString;
46
+ package: z.ZodOptional<z.ZodString>;
47
+ path: z.ZodOptional<z.ZodString>;
48
+ }, z.core.$strip>]>>>;
49
+ }, z.core.$strip>>>;
50
+ }, z.core.$strip>;
51
+ type CargoManifest = z.infer<typeof cargoManifestSchema>;
52
+ //#endregion
53
+ //#region src/plugins/cargo.d.ts
54
+ declare const DEP_FIELDS: readonly ["dependencies", "dev-dependencies", "build-dependencies"];
55
+ declare class CargoPackage extends WorkspacePackage {
56
+ readonly path: string;
57
+ readonly manifest: CargoManifest;
58
+ private content;
59
+ private readonly workspaceManifest?;
60
+ readonly manager = "cargo";
61
+ constructor(path: string, manifest: CargoManifest, content: string, workspaceManifest?: CargoManifest | undefined);
62
+ get name(): string;
63
+ get version(): string | undefined;
64
+ setVersion(version: string): void;
65
+ write(): Promise<void>;
66
+ patch(path: string, value: unknown): void;
67
+ get packageInfo(): {
68
+ name: string;
69
+ version?: string | undefined;
70
+ publish?: boolean | undefined;
71
+ };
72
+ private get workspaceVersion();
73
+ }
74
+ interface DependentRef {
75
+ dependent: CargoPackage;
76
+ kind: (typeof DEP_FIELDS)[number];
77
+ name: string;
78
+ version: string;
79
+ }
80
+ interface CargoPluginOptions {
81
+ /**
82
+ * Update lock file after versioning.
83
+ *
84
+ * @default true
85
+ */
86
+ updateLockFile?: boolean;
87
+ /**
88
+ * Decide how to bump the dependents of a bumped package.
89
+ */
90
+ bumpDep?: (opts: DependentRef) => BumpType | false;
91
+ }
92
+ declare function cargo({
93
+ updateLockFile,
94
+ bumpDep: getBumpDepType
95
+ }?: CargoPluginOptions): TegamiPlugin;
96
+ //#endregion
97
+ export { CargoPackage, CargoPluginOptions, cargo };
@@ -1,12 +1,43 @@
1
- import { i as isNodeError, n as execFailure } from "../error-We7chQVJ.js";
1
+ import { n as execFailure } from "../error-BhMYq9iW.js";
2
2
  import { n as WorkspacePackage } from "../graph-gThXu8Cz.js";
3
3
  import { readFile, writeFile } from "node:fs/promises";
4
4
  import { join, normalize } from "node:path";
5
5
  import { x } from "tinyexec";
6
6
  import * as semver$1 from "semver";
7
- import initToml, { edit, parse as parse$1 } from "@rainbowatcher/toml-edit-js";
7
+ import z from "zod";
8
8
  import { glob } from "tinyglobby";
9
- //#region src/providers/cargo.ts
9
+ import initToml, { edit, parse as parse$1 } from "@rainbowatcher/toml-edit-js";
10
+ //#region src/plugins/cargo/schema.ts
11
+ const cargoDependencySchema = z.union([z.string(), z.object({
12
+ version: z.string(),
13
+ package: z.string().optional(),
14
+ path: z.string().optional()
15
+ })]);
16
+ const cargoTargetConfigSchema = z.object({
17
+ dependencies: z.record(z.string(), cargoDependencySchema).optional(),
18
+ "dev-dependencies": z.record(z.string(), cargoDependencySchema).optional(),
19
+ "build-dependencies": z.record(z.string(), cargoDependencySchema).optional()
20
+ });
21
+ const cargoPackageSchema = z.object({
22
+ name: z.string(),
23
+ version: z.string().optional(),
24
+ publish: z.boolean().optional()
25
+ });
26
+ const cargoWorkspaceSchema = z.object({
27
+ members: z.array(z.string()).optional(),
28
+ exclude: z.array(z.string()).optional(),
29
+ package: z.object({ version: z.string().optional() }).optional()
30
+ });
31
+ const cargoManifestSchema = z.object({
32
+ package: cargoPackageSchema,
33
+ workspace: cargoWorkspaceSchema.optional(),
34
+ dependencies: z.record(z.string(), cargoDependencySchema).optional(),
35
+ "dev-dependencies": z.record(z.string(), cargoDependencySchema).optional(),
36
+ "build-dependencies": z.record(z.string(), cargoDependencySchema).optional(),
37
+ target: z.record(z.string(), cargoTargetConfigSchema).optional()
38
+ });
39
+ //#endregion
40
+ //#region src/plugins/cargo.ts
10
41
  const DEP_FIELDS = [
11
42
  "dependencies",
12
43
  "dev-dependencies",
@@ -29,7 +60,7 @@ var CargoPackage = class extends WorkspacePackage {
29
60
  return this.packageInfo.name;
30
61
  }
31
62
  get version() {
32
- return stringValue(this.packageInfo.version) ?? this.workspaceVersion;
63
+ return this.packageInfo.version ?? this.workspaceVersion;
33
64
  }
34
65
  setVersion(version) {
35
66
  this.packageInfo.version = version;
@@ -42,11 +73,10 @@ var CargoPackage = class extends WorkspacePackage {
42
73
  this.content = edit(this.content, path, value);
43
74
  }
44
75
  get packageInfo() {
45
- this.manifest.package ??= {};
46
76
  return this.manifest.package;
47
77
  }
48
78
  get workspaceVersion() {
49
- return stringValue(tableValue(tableValue(this.workspaceManifest?.workspace)?.package)?.version);
79
+ return this.workspaceManifest?.workspace?.package?.version;
50
80
  }
51
81
  };
52
82
  function cargo({ updateLockFile = true, bumpDep: getBumpDepType } = {}) {
@@ -68,9 +98,9 @@ function cargo({ updateLockFile = true, bumpDep: getBumpDepType } = {}) {
68
98
  async publishPreflight({ pkg }) {
69
99
  if (!(pkg instanceof CargoPackage)) return;
70
100
  const wait = [];
71
- for (const { table } of dependencyTables(pkg.manifest, "")) for (const [rawName, rawSpec] of Object.entries(table)) {
72
- if (!isTableValue(rawSpec) || typeof rawSpec.path !== "string") continue;
73
- const id = `cargo:${stringValue(rawSpec.package) ?? rawName}`;
101
+ for (const { table } of dependencyTables(pkg.manifest, "")) for (const [rawName, dep] of Object.entries(table)) {
102
+ if (!dep || typeof dep === "string" || !dep.path) continue;
103
+ const id = `cargo:${dep.package ?? rawName}`;
74
104
  const linked = this.graph.get(id);
75
105
  if (!linked || !(linked instanceof CargoPackage)) continue;
76
106
  wait.push(id);
@@ -81,6 +111,7 @@ function cargo({ updateLockFile = true, bumpDep: getBumpDepType } = {}) {
81
111
  };
82
112
  },
83
113
  resolvePlanStatus({ plan }) {
114
+ if (!active) return;
84
115
  return Array.from(plan.packages, async ([id, { preflight }]) => {
85
116
  if (!preflight.shouldPublish) return;
86
117
  const pkg = this.graph.get(id);
@@ -143,32 +174,47 @@ function depsPolicy({ graph }, getBumpDepType = ({ kind }) => {
143
174
  case "dev-dependencies": return false;
144
175
  }
145
176
  }) {
177
+ const dependentMap = /* @__PURE__ */ new Map();
178
+ for (const pkg of graph.getPackages()) {
179
+ if (!(pkg instanceof CargoPackage)) continue;
180
+ for (const { table, kind } of dependencyTables(pkg.manifest, "")) for (const [rawName, rawSpec] of Object.entries(table)) {
181
+ const spec = parseSpec(rawSpec);
182
+ if (!spec || !semver$1.validRange(spec.version)) continue;
183
+ const name = spec.package ?? rawName;
184
+ const id = `cargo:${name}`;
185
+ const refs = dependentMap.get(id);
186
+ if (refs) refs.push({
187
+ dependent: pkg,
188
+ kind,
189
+ name,
190
+ version: spec.version
191
+ });
192
+ else dependentMap.set(id, [{
193
+ dependent: pkg,
194
+ kind,
195
+ name,
196
+ version: spec.version
197
+ }]);
198
+ }
199
+ }
146
200
  return {
147
201
  id: "cargo:deps",
148
202
  onUpdate({ pkg, packageDraft: plan }) {
149
203
  if (!(pkg instanceof CargoPackage)) return;
204
+ const deps = dependentMap.get(pkg.id);
205
+ if (!deps) return;
150
206
  const group = graph.getPackageGroup(pkg.id);
151
- for (const dependent of graph.getPackages()) {
152
- if (!(dependent instanceof CargoPackage)) continue;
153
- for (const { table, kind } of dependencyTables(dependent.manifest, "")) for (const [rawName, rawSpec] of Object.entries(table)) {
154
- const spec = parseSpec(rawSpec);
155
- if (!spec || !semver$1.validRange(spec.version)) continue;
156
- if (pkg.id !== `cargo:${spec.package ?? rawName}`) continue;
157
- if (group?.options.syncBump && graph.getPackageGroup(dependent.id) === group) continue;
158
- const bumped = plan.bumpVersion(pkg);
159
- if (!bumped || semver$1.satisfies(bumped, spec.version)) continue;
160
- const bumpType = getBumpDepType({
161
- kind,
162
- dependent,
163
- name: pkg.name,
164
- version: spec.version
165
- });
166
- if (bumpType === false) continue;
167
- this.bumpPackage(dependent, {
168
- type: bumpType,
169
- reason: `update dependency "${rawName}"`
170
- });
171
- }
207
+ const bumped = plan.bumpVersion(pkg);
208
+ if (!bumped) return;
209
+ for (const dep of deps) {
210
+ if (group?.options.syncBump && graph.getPackageGroup(dep.dependent.id) === group) continue;
211
+ if (semver$1.satisfies(bumped, dep.version)) continue;
212
+ const bumpType = getBumpDepType(dep);
213
+ if (bumpType === false) continue;
214
+ this.bumpPackage(dep.dependent, {
215
+ type: bumpType,
216
+ reason: `update dependency "${dep.name}"`
217
+ });
172
218
  }
173
219
  }
174
220
  };
@@ -179,29 +225,29 @@ async function isPackagePublished(name, version) {
179
225
  if (response.status === 404) return false;
180
226
  throw new Error(`Unable to validate ${name}@${version} against crates.io: ${await response.text()}`);
181
227
  }
228
+ async function buildEntry(path) {
229
+ try {
230
+ const content = await readFile(join(path, "Cargo.toml"), "utf8");
231
+ return {
232
+ manifest: cargoManifestSchema.parse(parse$1(content)),
233
+ content,
234
+ path
235
+ };
236
+ } catch {
237
+ return;
238
+ }
239
+ }
182
240
  async function discoverCargoPackages(cwd, add) {
183
- const root = await readCargoManifest(cwd).catch((error) => {
184
- if (isNodeError(error) && error.code === "ENOENT") return void 0;
185
- throw error;
186
- });
241
+ const root = await buildEntry(cwd);
187
242
  if (!root) return;
188
- addCargoPackage(cwd, root.manifest, root.content, root.manifest, add);
189
- const workspace = tableValue(root.manifest.workspace);
190
- const members = workspace?.members;
191
- if (!workspace || !Array.isArray(members)) return;
192
- const exclude = Array.isArray(workspace.exclude) ? workspace.exclude.filter((member) => typeof member === "string") : [];
193
- const paths = await expandWorkspaceMembers(cwd, members.filter((member) => typeof member === "string"), exclude);
194
- const manifests = await Promise.all(paths.map((path) => readCargoManifest(path).then((manifest) => ({
195
- path,
196
- manifest
197
- })).catch(() => void 0)));
198
- for (const entry of manifests) if (entry) addCargoPackage(entry.path, entry.manifest.manifest, entry.manifest.content, root.manifest, add);
199
- }
200
- function addCargoPackage(path, manifest, content, workspaceManifest, add) {
201
- if (!tableValue(manifest.package)?.name) return;
202
- add(new CargoPackage(path, manifest, content, workspaceManifest));
243
+ if (root.manifest.package?.name) add(new CargoPackage(cwd, root.manifest, root.content, root.manifest));
244
+ const workspace = root.manifest.workspace;
245
+ if (!workspace?.members) return;
246
+ const paths = await expandWorkspaceMembers(cwd, workspace.members, workspace.exclude);
247
+ const manifests = await Promise.all(paths.map(buildEntry));
248
+ for (const entry of manifests) if (entry?.manifest.package?.name) add(new CargoPackage(entry.path, entry.manifest, entry.content, root.manifest));
203
249
  }
204
- async function expandWorkspaceMembers(cwd, members, exclude) {
250
+ async function expandWorkspaceMembers(cwd, members, exclude = []) {
205
251
  const paths = members.includes(".") ? [cwd] : [];
206
252
  const patterns = members.filter((member) => member !== ".");
207
253
  if (patterns.length > 0) paths.push(...await glob(patterns, {
@@ -216,7 +262,7 @@ async function expandWorkspaceMembers(cwd, members, exclude) {
216
262
  function dependencyTables(manifest, prefix) {
217
263
  const tables = [];
218
264
  for (const field of DEP_FIELDS) {
219
- const table = tableValue(manifest[field]);
265
+ const table = manifest[field];
220
266
  if (table) {
221
267
  const path = prefix ? `${prefix}.${field}` : field;
222
268
  tables.push({
@@ -226,13 +272,11 @@ function dependencyTables(manifest, prefix) {
226
272
  });
227
273
  }
228
274
  }
229
- const target = tableValue(manifest.target);
275
+ const target = manifest.target;
230
276
  if (target) for (const [targetKey, targetConfig] of Object.entries(target)) {
231
- const targetTable = tableValue(targetConfig);
232
- if (!targetTable) continue;
233
277
  const targetPath = prefix ? `${prefix}.target.${targetKey}` : `target.${targetKey}`;
234
278
  for (const field of DEP_FIELDS) {
235
- const table = tableValue(targetTable[field]);
279
+ const table = targetConfig[field];
236
280
  if (table) tables.push({
237
281
  kind: field,
238
282
  table,
@@ -249,8 +293,8 @@ function parseSpec(v) {
249
293
  return version;
250
294
  }
251
295
  };
252
- if (isTableValue(v)) return {
253
- package: stringValue(v.package),
296
+ return {
297
+ package: v.package,
254
298
  version: v.version,
255
299
  setVersion(version) {
256
300
  return {
@@ -260,22 +304,5 @@ function parseSpec(v) {
260
304
  }
261
305
  };
262
306
  }
263
- async function readCargoManifest(path) {
264
- const content = await readFile(join(path, "Cargo.toml"), "utf8");
265
- return {
266
- manifest: parse$1(content),
267
- content
268
- };
269
- }
270
- function isTableValue(value) {
271
- return value !== null && typeof value === "object" && !Array.isArray(value);
272
- }
273
- function tableValue(value) {
274
- if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
275
- return value;
276
- }
277
- function stringValue(value) {
278
- return typeof value === "string" ? value : void 0;
279
- }
280
307
  //#endregion
281
308
  export { CargoPackage, cargo };
@@ -1,4 +1,4 @@
1
- import { s as TegamiPlugin } from "../types-DKZsadC8.js";
1
+ import { s as TegamiPlugin } from "../types-DItu_YCc.js";
2
2
 
3
3
  //#region src/plugins/git.d.ts
4
4
  interface GitPluginOptions {
@@ -1,4 +1,4 @@
1
- import { n as execFailure, o as isCI } from "../error-We7chQVJ.js";
1
+ import { n as execFailure, o as isCI } from "../error-BhMYq9iW.js";
2
2
  import { x } from "tinyexec";
3
3
  //#region src/plugins/git.ts
4
4
  /**
@@ -52,7 +52,20 @@ function git(options = {}) {
52
52
  async resolvePlanStatus({ plan }) {
53
53
  const pendingTags = getPendingTags(plan);
54
54
  return Array.from(pendingTags, async (tag) => {
55
- if (!await gitTagExists(this.cwd, tag)) return "pending";
55
+ if ((await x("git", [
56
+ "rev-parse",
57
+ "-q",
58
+ "--verify",
59
+ `refs/tags/${tag}`
60
+ ], { nodeOptions: { cwd: this.cwd } })).exitCode === 0) return;
61
+ if ((await x("git", [
62
+ "ls-remote",
63
+ "--exit-code",
64
+ "--tags",
65
+ "origin",
66
+ `refs/tags/${tag}`
67
+ ], { nodeOptions: { cwd: this.cwd } })).exitCode === 0) return;
68
+ return "pending";
56
69
  });
57
70
  },
58
71
  async afterPublishAll({ plan }) {
@@ -74,18 +87,13 @@ function git(options = {}) {
74
87
  "origin",
75
88
  ...createdTags
76
89
  ], { nodeOptions: { cwd } });
77
- if (gitOut.exitCode !== 0) throw execFailure(`Failed to push Git tags to origin: ${createdTags.join(", ")}`, gitOut);
90
+ if (gitOut.exitCode !== 0) {
91
+ if (/already exists/i.test(`${gitOut.stdout}\n${gitOut.stderr}`)) return;
92
+ throw execFailure(`Failed to push Git tags to origin: ${createdTags.join(", ")}`, gitOut);
93
+ }
78
94
  }
79
95
  }
80
96
  };
81
97
  }
82
- async function gitTagExists(cwd, tag) {
83
- return (await x("git", [
84
- "rev-parse",
85
- "-q",
86
- "--verify",
87
- `refs/tags/${tag}`
88
- ], { nodeOptions: { cwd } })).exitCode === 0;
89
- }
90
98
  //#endregion
91
99
  export { git };
@@ -1,4 +1,4 @@
1
- import { D as WorkspacePackage, O as Draft, _ as PublishPlan, s as TegamiPlugin, t as Awaitable, w as TegamiContext } from "../types-DKZsadC8.js";
1
+ import { T as Draft, s as TegamiPlugin, t as Awaitable, w as WorkspacePackage, x as TegamiContext, y as PublishPlan } from "../types-DItu_YCc.js";
2
2
  import { GitPluginOptions } from "./git.js";
3
3
 
4
4
  //#region src/plugins/github.d.ts
@@ -1,9 +1,9 @@
1
1
  import { i as formatPackageVersion, r as formatNpmDistTag } from "../semver-EKJ8yK5U.js";
2
- import { t as changelogFilename } from "../generate-BfYdNTFi.js";
3
- import { a as cached, n as execFailure, o as isCI } from "../error-We7chQVJ.js";
4
- import { n as createDraft, o as readChangelogEntries } from "../draft-DtFyGxe8.js";
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-cFS0Suzd.js";
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";
@@ -1,4 +1,4 @@
1
- import { D as WorkspacePackage, O as Draft, _ as PublishPlan, s as TegamiPlugin, t as Awaitable, w as TegamiContext } from "../types-DKZsadC8.js";
1
+ import { T as Draft, s as TegamiPlugin, t as Awaitable, w as WorkspacePackage, x as TegamiContext, y as PublishPlan } from "../types-DItu_YCc.js";
2
2
  import { GitPluginOptions } from "./git.js";
3
3
 
4
4
  //#region src/plugins/gitlab.d.ts
@@ -1,9 +1,9 @@
1
1
  import { i as formatPackageVersion, r as formatNpmDistTag } from "../semver-EKJ8yK5U.js";
2
- import { t as changelogFilename } from "../generate-BfYdNTFi.js";
3
- import { a as cached, n as execFailure, o as isCI } from "../error-We7chQVJ.js";
4
- import { n as createDraft, o as readChangelogEntries } from "../draft-DtFyGxe8.js";
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-cFS0Suzd.js";
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(`${gitlabApiUrl(options.apiUrl)}${path}`, {
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: context.gitlab?.apiUrl,
242
- token: context.gitlab?.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: context.gitlab?.apiUrl,
257
- token: context.gitlab?.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 `${gitlabWebUrl(context.gitlab?.webUrl)}/${repo}/-/new/${branchPath}?${params}`;
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}](${baseUrl}/${repo}/-/merge_requests/${mr.number})` : `- #${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}](${baseUrl}/${repo}/-/commit/${meta.commit})` : `\`${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 `${gitlabWebUrl(webUrl).replace(/^https?:\/\//, `https://${username}:${token.value}@`)}/${repo}.git`;
544
+ return joinPath(webUrl.replace(/^https?:\/\//, `https://${username}:${token.value}@`), `${repo}.git`);
552
545
  }
553
546
  //#endregion
554
547
  export { gitlab };
@@ -1,4 +1,4 @@
1
- import { D as WorkspacePackage, j as BumpType, s as TegamiPlugin } from "../types-DKZsadC8.js";
1
+ import { O as BumpType, s as TegamiPlugin, w as WorkspacePackage } from "../types-DItu_YCc.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
- * Experimental plugin for Golang, the release flow of Golang is pretty special, there's some exceptions for it:
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.