tegami 1.1.3 → 1.2.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.
@@ -1,4 +1,4 @@
1
- import { f as Tegami, j as Draft, t as Awaitable, v as PublishPlan } from "../types-DEyZ2r-2.js";
1
+ import { f as Tegami, j as Draft, t as Awaitable, v as PublishPlan } from "../types-BbwOrNZ2.js";
2
2
 
3
3
  //#region src/cli/index.d.ts
4
4
  interface TegamiCLIOptions {
package/dist/cli/index.js CHANGED
@@ -561,7 +561,7 @@ async function publishPackages(tegami, options) {
561
561
  s.start(dryRun ? "Validating publish lock" : "Publishing packages");
562
562
  const plan = customPublish ? await customPublish() : await tegami.publish({
563
563
  dryRun,
564
- packages: options.packages
564
+ packages: options.packages && options.packages.length > 0 ? options.packages : void 0
565
565
  });
566
566
  if (plan === "skipped") {
567
567
  s.stop(dryRun ? "No publish lock to validate" : "Nothing to publish");
@@ -1,4 +1,4 @@
1
- import { r as LogGenerator } from "../types-DEyZ2r-2.js";
1
+ import { r as LogGenerator } from "../types-BbwOrNZ2.js";
2
2
 
3
3
  //#region src/generators/simple.d.ts
4
4
  declare function simpleGenerator(): LogGenerator;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as WorkspacePackage, M as DraftPolicy, N as PackageDraft, O as PackageGraph, P as BumpType, _ as PublishOptions, a as PublishPreflight, b as TegamiContext, c as TegamiPluginOption, d as GenerateChangelogOptions, f as Tegami, g as PackagePublishResult, h as PackagePublishPlan, i as PackageOptions, j as Draft, k as PackageGroup, m as PublishLock, n as GroupOptions, o as TegamiOptions, p as tegami, r as LogGenerator, s as TegamiPlugin, v as PublishPlan, y as CommitChangelog } from "./types-DEyZ2r-2.js";
1
+ import { A as WorkspacePackage, M as DraftPolicy, N as PackageDraft, O as PackageGraph, P as BumpType, _ as PublishOptions, a as PublishPreflight, b as TegamiContext, c as TegamiPluginOption, d as GenerateChangelogOptions, f as Tegami, g as PackagePublishResult, h as PackagePublishPlan, i as PackageOptions, j as Draft, k as PackageGroup, m as PublishLock, n as GroupOptions, o as TegamiOptions, p as tegami, r as LogGenerator, s as TegamiPlugin, v as PublishPlan, y as CommitChangelog } from "./types-BbwOrNZ2.js";
2
2
  export { type BumpType, type CommitChangelog, type Draft, type DraftPolicy, GenerateChangelogOptions, type GroupOptions, type LogGenerator, type PackageDraft, PackageGraph, type PackageGroup, type PackageOptions, type PackagePublishPlan, type PackagePublishResult, type PublishLock, type PublishOptions, type PublishPlan, type PublishPreflight, Tegami, type TegamiContext, type TegamiOptions, type TegamiPlugin, type TegamiPluginOption, WorkspacePackage, tegami };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { n as generateFromCommits } from "./generate-Bg86OJP4.js";
2
2
  import { r as handlePluginError } from "./error-BhMYq9iW.js";
3
- import { a as parseChangelogFile, o as readChangelogEntries, t as createDraft } from "./draft-CzUiQasJ.js";
4
- import { a as runPreflights, i as publishPlanStatus, o as runPublishPlan, r as initPublishPlan, t as npm } from "./npm-CaBYeOeV.js";
3
+ import { a as createDraft, c as parseChangelogFile, i as runPublishPlan, l as readChangelogEntries, n as publishPlanStatus, r as runPreflights, t as initPublishPlan } from "./publish-v30y8Lwq.js";
4
+ import { t as npm } from "./npm-DaUHTtlV.js";
5
5
  import { n as WorkspacePackage, t as PackageGraph } from "./graph-BmXTJZxx.js";
6
6
  import { mkdir, rm, writeFile } from "node:fs/promises";
7
7
  import path, { join } from "node:path";
@@ -1,7 +1,7 @@
1
- import { c as somePromise, i as isNodeError, n as execFailure, r as handlePluginError, s as joinPath } from "./error-BhMYq9iW.js";
1
+ import { i as isNodeError, n as execFailure, s as joinPath } from "./error-BhMYq9iW.js";
2
2
  import { t as _accessExpressionAsString } from "./_accessExpressionAsString-QhbUZzwv.js";
3
3
  import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-BGQyz-uA.js";
4
- import { a as parseChangelogFile, i as parsePublishLock, n as validateChangelogStore, r as validatePackageStore } from "./draft-CzUiQasJ.js";
4
+ import { r as runPreflights, s as parsePublishLock, t as initPublishPlan } from "./publish-v30y8Lwq.js";
5
5
  import { t as _assertGuard } from "./_assertGuard-BBn2NbSz.js";
6
6
  import { n as WorkspacePackage } from "./graph-BmXTJZxx.js";
7
7
  import fs, { readFile, writeFile } from "node:fs/promises";
@@ -13,172 +13,6 @@ import { detect } from "package-manager-detector";
13
13
  import { tmpdir } from "node:os";
14
14
  import { intro, note, outro } from "@clack/prompts";
15
15
  import { glob } from "tinyglobby";
16
- //#region src/plans/publish.ts
17
- async function initPublishPlan(context, options) {
18
- let lock;
19
- try {
20
- lock = parsePublishLock(await fs.readFile(context.lockPath, "utf8"));
21
- } catch {
22
- return;
23
- }
24
- let data;
25
- const packages = /* @__PURE__ */ new Map();
26
- const changelogs = /* @__PURE__ */ new Map();
27
- while (data = lock.read("core:changelogs")) {
28
- const validated = validateChangelogStore(data);
29
- if (!validated.success) continue;
30
- const entry = validated.data;
31
- const parsed = parseChangelogFile(entry.filename, entry.content);
32
- if (!parsed) continue;
33
- changelogs.set(parsed.id, parsed);
34
- }
35
- while (data = lock.read("core:packages")) {
36
- const validated = validatePackageStore(data);
37
- if (!validated.success) continue;
38
- const parsed = validated.data;
39
- if (!context.graph.get(parsed.id)) continue;
40
- const pkgChangelogs = [];
41
- for (const id of parsed.changelogIds ?? []) {
42
- const entry = changelogs.get(id);
43
- if (entry) pkgChangelogs.push(entry);
44
- }
45
- packages.set(parsed.id, {
46
- changelogs: pkgChangelogs,
47
- updated: parsed.updated
48
- });
49
- }
50
- const plan = {
51
- options,
52
- changelogs,
53
- packages
54
- };
55
- for (const plugin of context.plugins) await handlePluginError(plugin, "initPublishPlan", () => plugin.initPublishPlan?.call(context, {
56
- lock,
57
- plan
58
- }));
59
- return plan;
60
- }
61
- function resolvePublishTargets(plan) {
62
- /** the iteration order = publish order */
63
- const orderedMap = /* @__PURE__ */ new Map();
64
- /** package id -> true while scanning hard wait, false while scanning optional wait */
65
- const stack = /* @__PURE__ */ new Map();
66
- function scan(id) {
67
- const preflight = plan.packages.get(id)?.preflight;
68
- if (!preflight || !preflight.shouldPublish) return;
69
- switch (stack.get(id)) {
70
- case true: throw new Error(`circular reference of deps: ${[...stack.keys(), id].join(" -> ")}`);
71
- case false: return;
72
- }
73
- if (orderedMap.has(id)) return;
74
- let split = false;
75
- if (preflight.wait) {
76
- stack.set(id, true);
77
- split ||= preflight.wait.length > 0;
78
- for (const dep of preflight.wait) scan(dep);
79
- }
80
- if (preflight.optionalWait) {
81
- stack.set(id, false);
82
- split ||= preflight.optionalWait.length > 0;
83
- for (const dep of preflight.optionalWait) scan(dep);
84
- }
85
- stack.delete(id);
86
- orderedMap.set(id, { split });
87
- }
88
- for (const id of plan.packages.keys()) scan(id);
89
- return orderedMap;
90
- }
91
- async function runPublishPlan(context, plan) {
92
- const { dryRun = false, unstable_maxChunk = 5 } = plan.options;
93
- for (const plugin of context.plugins) await handlePluginError(plugin, "beforePublishAll", () => plugin.beforePublishAll?.call(context, { plan }));
94
- async function publish(pkg) {
95
- if (dryRun) return { type: "published" };
96
- try {
97
- for (const plugin of context.plugins) if (await handlePluginError(plugin, "willPublish", () => plugin.willPublish?.call(context, { pkg })) === false) return { type: "skipped" };
98
- for (const plugin of context.plugins) {
99
- const publishResult = await handlePluginError(plugin, "publish", () => plugin.publish?.call(context, {
100
- pkg,
101
- plan
102
- }));
103
- if (publishResult) return publishResult;
104
- }
105
- } catch (e) {
106
- return {
107
- type: "failed",
108
- error: e instanceof Error ? e.message : String(e)
109
- };
110
- }
111
- return {
112
- type: "failed",
113
- error: `There is no plugin to publish package "${pkg.id}", please make sure the package has a supported provider plugin.`
114
- };
115
- }
116
- let promises = [];
117
- for (const [id, { split }] of resolvePublishTargets(plan)) {
118
- const pkg = context.graph.get(id);
119
- const packagePlan = plan.packages.get(pkg.id);
120
- if (!pkg || !packagePlan) continue;
121
- if (split || promises.length >= unstable_maxChunk) {
122
- await Promise.all(promises);
123
- promises = [];
124
- }
125
- promises.push(publish(pkg).then(async (result) => {
126
- packagePlan.publishResult = result;
127
- if (result.type === "skipped") return;
128
- for (const plugin of context.plugins) await handlePluginError(plugin, "afterPublish", () => plugin.afterPublish?.call(context, {
129
- pkg,
130
- plan
131
- }));
132
- }));
133
- }
134
- await Promise.all(promises);
135
- for (const packagePlan of plan.packages.values()) packagePlan.publishResult ??= { type: "skipped" };
136
- for (const plugin of context.plugins) await handlePluginError(plugin, "afterPublishAll", () => plugin.afterPublishAll?.call(context, { plan }));
137
- }
138
- async function runPreflights(context, plan) {
139
- const { graph } = context;
140
- await Promise.all(Array.from(plan.packages, async ([id, packagePlan]) => {
141
- const pkg = graph.get(id);
142
- packagePlan.preflight = { shouldPublish: false };
143
- if (!packagePlan.updated) return;
144
- for (const plugin of context.plugins) {
145
- const res = await handlePluginError(plugin, "publishPreflight", () => plugin.publishPreflight?.call(context, {
146
- pkg,
147
- plan
148
- }));
149
- if (res) {
150
- packagePlan.preflight = res;
151
- break;
152
- }
153
- }
154
- }));
155
- if (plan.options.packages?.length) {
156
- const only = /* @__PURE__ */ new Set();
157
- function addOnly(id) {
158
- if (only.has(id)) return;
159
- const preflight = plan.packages.get(id)?.preflight;
160
- if (!preflight) return;
161
- only.add(id);
162
- if (preflight.wait) for (const dep of preflight.wait) addOnly(dep);
163
- if (preflight.optionalWait) for (const dep of preflight.optionalWait) addOnly(dep);
164
- }
165
- for (const name of plan.options.packages) for (const pkg of graph.getByName(name)) addOnly(pkg.id);
166
- for (const [id, packagePlan] of plan.packages) {
167
- if (only.has(id)) continue;
168
- packagePlan.preflight.shouldPublish = false;
169
- }
170
- }
171
- for (const plugin of context.plugins) await handlePluginError(plugin, "afterPreflight", () => plugin.afterPreflight?.call(context, { plan }));
172
- }
173
- async function publishPlanStatus(plan, context) {
174
- for (const plugin of context.plugins) {
175
- const status = await handlePluginError(plugin, "resolvePlanStatus", () => plugin.resolvePlanStatus?.call(context, { plan }));
176
- if (Array.isArray(status) && await somePromise(status, (v) => v === "pending")) return "pending";
177
- if (status === "pending") return "pending";
178
- }
179
- return "success";
180
- }
181
- //#endregion
182
16
  //#region src/providers/npm/cli.ts
183
17
  const PLACEHOLDER_VERSION = "0.0.0-tegami-trusted-publish-setup";
184
18
  const PLACEHOLDER_DIST_TAG = "temp";
@@ -1151,8 +985,8 @@ function npm({ client: defaultClient, onBreakPeerDep = "set", updateLockFile = t
1151
985
  }
1152
986
  for (const pkg of npmGraph.packages.values()) {
1153
987
  for (const dep of pkg.listDependencies(npmGraph)) {
1154
- if (!dep.linked || !dep.range || !dep.setRange) continue;
1155
- if (!dep.linked.version || semver$1.satisfies(dep.linked.version, dep.range)) continue;
988
+ if (!dep.linked?.version || !dep.range || !dep.setRange) continue;
989
+ if (semver$1.satisfies(dep.linked.version, dep.range, { includePrerelease: dep.spec.protocol === "workspace" })) continue;
1156
990
  const isPeer = dep.field === "peerDependencies";
1157
991
  if (isPeer && onBreakPeerDep === "ignore") continue;
1158
992
  let updatedRange;
@@ -1205,7 +1039,7 @@ function depsPolicy(context, getBumpDepType) {
1205
1039
  case "":
1206
1040
  case "*": return true;
1207
1041
  case "^":
1208
- case "~": return !semver$1.satisfies(target, `${resolved.spec.range}${resolved.linked.version ?? "0.0.0"}`);
1042
+ case "~": return !semver$1.satisfies(target, `${resolved.spec.range}${resolved.linked.version ?? "0.0.0"}`, { includePrerelease: true });
1209
1043
  }
1210
1044
  }
1211
1045
  if (!resolved.range || !semver$1.validRange(resolved.range)) return false;
@@ -1290,4 +1124,4 @@ async function isPackagePublished(name, version, registry) {
1290
1124
  return true;
1291
1125
  }
1292
1126
  //#endregion
1293
- export { runPreflights as a, publishPlanStatus as i, NpmPackage as n, runPublishPlan as o, initPublishPlan as r, npm as t };
1127
+ export { NpmPackage as n, npm as t };
@@ -1,2 +1,2 @@
1
- import { D as cargo, E as CargoPluginOptions, T as CargoPackage, w as CargoGraph } from "../types-DEyZ2r-2.js";
1
+ import { D as cargo, E as CargoPluginOptions, T as CargoPackage, w as CargoGraph } from "../types-BbwOrNZ2.js";
2
2
  export { CargoGraph, CargoPackage, CargoPluginOptions, cargo };
@@ -1,4 +1,4 @@
1
- import { s as TegamiPlugin } from "../types-DEyZ2r-2.js";
1
+ import { s as TegamiPlugin } from "../types-BbwOrNZ2.js";
2
2
 
3
3
  //#region src/plugins/git.d.ts
4
4
  interface GitPluginOptions {
@@ -1,5 +1,6 @@
1
- import { A as WorkspacePackage, b as TegamiContext, j as Draft, s as TegamiPlugin, t as Awaitable, v as PublishPlan } from "../types-DEyZ2r-2.js";
1
+ import { A as WorkspacePackage, b as TegamiContext, s as TegamiPlugin, t as Awaitable, v as PublishPlan } from "../types-BbwOrNZ2.js";
2
2
  import { GitPluginOptions } from "./git.js";
3
+ import { t as VersionRequestOptions } from "../version-request-C24d9RIW.js";
3
4
 
4
5
  //#region src/plugins/github.d.ts
5
6
  interface GithubRelease {
@@ -10,51 +11,6 @@ interface GithubRelease {
10
11
  /** Whether to mark release as prerelease */
11
12
  prerelease?: boolean;
12
13
  }
13
- interface VersionPullRequest {
14
- /** Pull request title. */
15
- title?: string;
16
- /** Pull request body. */
17
- body?: string;
18
- }
19
- interface VersionPullRequestOptions {
20
- /**
21
- * Create the PR even outside of CI.
22
- *
23
- * @default false
24
- */
25
- forceCreate?: boolean;
26
- /**
27
- * Pull request branch. Publish group PRs are created under `<branch>/`.
28
- *
29
- * @default "tegami/version-packages"
30
- */
31
- branch?: string;
32
- /**
33
- * Pull request base branch.
34
- *
35
- * @default "main"
36
- */
37
- base?: string;
38
- /**
39
- * Publish groups to split into separate version PRs, each entry is a package (or a list of
40
- * packages) to version & publish together. Packages not covered by any group are collected
41
- * into an extra "unlisted packages" PR.
42
- *
43
- * Merging a group PR publishes only its members, the remaining PRs are re-synced on every
44
- * publish run until all of them are merged & published.
45
- */
46
- groups?: (string | string[])[];
47
- /**
48
- * Override details for a version PR.
49
- *
50
- * Only called at version-time: publish group PRs re-synced at publish-time keep the stored
51
- * title and use a default body.
52
- */
53
- create?: (this: TegamiContext, opts: {
54
- draft: Draft;
55
- publishGroup?: string[];
56
- }) => Awaitable<VersionPullRequest>;
57
- }
58
14
  /** Options for creating GitHub releases after a successful publish. */
59
15
  interface GitHubPluginOptions extends GitPluginOptions {
60
16
  /** GitHub repository. */
@@ -89,7 +45,7 @@ interface GitHubPluginOptions extends GitPluginOptions {
89
45
  *
90
46
  * Defaults to enabled in CI and disabled locally.
91
47
  */
92
- versionPr?: VersionPullRequestOptions | false;
48
+ versionPr?: VersionRequestOptions | false;
93
49
  }
94
50
  /** Create GitHub releases for successfully published packages after the whole plan succeeds. */
95
51
  declare function github(options?: GitHubPluginOptions): TegamiPlugin[];
@@ -1,9 +1,9 @@
1
1
  import { i as formatPackageVersion, r as formatNpmDistTag } from "../semver-EKJ8yK5U.js";
2
2
  import { t as changelogFilename } from "../generate-Bg86OJP4.js";
3
3
  import { a as cached, n as execFailure, o as isCI } from "../error-BhMYq9iW.js";
4
- import { o as readChangelogEntries, t as createDraft } from "../draft-CzUiQasJ.js";
4
+ import { a as createDraft, l as readChangelogEntries } from "../publish-v30y8Lwq.js";
5
5
  import { git } from "./git.js";
6
- import { t as onVersionRequest } from "../version-request-DlLpLLK3.js";
6
+ import { t as onVersionRequest } from "../version-request-l6IJdFM6.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";
@@ -348,36 +348,30 @@ function github(options = {}) {
348
348
  }
349
349
  const versionRequests = onVersionRequest({
350
350
  name: "github",
351
- summary: "Merge this PR to publish the versioned packages.",
352
351
  options: options.versionPr,
353
- enabled(context) {
352
+ canCreate(context) {
354
353
  const { repo, token } = context.github ?? {};
355
354
  return Boolean(repo && token);
356
355
  },
357
- find(context, { head }) {
356
+ async upsert(context, request, update) {
358
357
  const { repo, token } = context.github;
359
- return findOpenPullRequest(repo, head, token);
360
- },
361
- create(context, request) {
362
- const { repo, token } = context.github;
363
- return createPullRequest(repo, {
358
+ const openPr = await findOpenPullRequest(repo, request.head, token);
359
+ if (openPr === void 0) await createPullRequest(repo, {
364
360
  title: request.title,
365
361
  body: request.body,
366
362
  head: request.head,
367
363
  base: request.base,
368
364
  token
369
365
  });
370
- },
371
- update(context, number, request) {
372
- const { repo, token } = context.github;
373
- return updatePullRequest(repo, number, {
366
+ else if (update) await updatePullRequest(repo, openPr, {
374
367
  title: request.title,
375
368
  body: request.body,
376
369
  token
377
370
  });
378
371
  }
379
372
  });
380
- return [git(options), {
373
+ const plugin = {
374
+ ...versionRequests,
381
375
  name: "github",
382
376
  init() {
383
377
  this.github = {
@@ -386,7 +380,7 @@ function github(options = {}) {
386
380
  };
387
381
  },
388
382
  async resolvePlanStatus({ plan }) {
389
- if (versionRequests.resolvePlanStatus() === "pending") return "pending";
383
+ if (versionRequests.resolvePlanStatus.call(this, { plan }) === "pending") return "pending";
390
384
  const { repo, token } = this.github;
391
385
  if (!repo || !token || releaseOptions === false) return;
392
386
  const requiredTags = /* @__PURE__ */ new Set();
@@ -459,20 +453,9 @@ function github(options = {}) {
459
453
  `https://x-access-token:${token}@github.com/${repo}.git`
460
454
  ], { nodeOptions: { cwd: this.cwd } });
461
455
  if (result.exitCode !== 0) throw execFailure("Failed to configure git remote for GitHub Actions.", result);
462
- },
463
- initCliDraft() {
464
- versionRequests.initCliDraft.call(this);
465
- },
466
- applyCliDraft(draft) {
467
- return versionRequests.applyCliDraft.call(this, draft);
468
- },
469
- initPublishPlan(opts) {
470
- versionRequests.initPublishPlan.call(this, opts);
471
- },
472
- beforePublishAll(opts) {
473
- return versionRequests.beforePublishAll.call(this, opts);
474
456
  }
475
- }];
457
+ };
458
+ return [git(options), plugin];
476
459
  }
477
460
  function createChangelogRenderer(context) {
478
461
  const { repo, token } = context.github;
@@ -1,5 +1,6 @@
1
- import { A as WorkspacePackage, b as TegamiContext, j as Draft, s as TegamiPlugin, t as Awaitable, v as PublishPlan } from "../types-DEyZ2r-2.js";
1
+ import { A as WorkspacePackage, b as TegamiContext, s as TegamiPlugin, t as Awaitable, v as PublishPlan } from "../types-BbwOrNZ2.js";
2
2
  import { GitPluginOptions } from "./git.js";
3
+ import { t as VersionRequestOptions } from "../version-request-C24d9RIW.js";
3
4
 
4
5
  //#region src/plugins/gitlab.d.ts
5
6
  interface GitlabRelease {
@@ -8,51 +9,6 @@ interface GitlabRelease {
8
9
  /** Release notes */
9
10
  notes?: string;
10
11
  }
11
- interface VersionMergeRequest {
12
- /** Merge request title. */
13
- title?: string;
14
- /** Merge request body. */
15
- body?: string;
16
- }
17
- interface VersionMergeRequestOptions {
18
- /**
19
- * Create the MR even outside of CI.
20
- *
21
- * @default false
22
- */
23
- forceCreate?: boolean;
24
- /**
25
- * Merge request branch. Publish group MRs are created under `<branch>/`.
26
- *
27
- * @default "tegami/version-packages"
28
- */
29
- branch?: string;
30
- /**
31
- * Merge request base branch.
32
- *
33
- * @default "main"
34
- */
35
- base?: string;
36
- /**
37
- * Publish groups to split into separate version MRs, each entry is a package (or a list of
38
- * packages) to version & publish together. Packages not covered by any group are collected
39
- * into an extra "unlisted packages" MR.
40
- *
41
- * Merging a group MR publishes only its members, the remaining MRs are re-synced on every
42
- * publish run until all of them are merged & published.
43
- */
44
- groups?: (string | string[])[];
45
- /**
46
- * Override details for a version MR.
47
- *
48
- * Only called at version-time: publish group MRs re-synced at publish-time keep the stored
49
- * title and use a default body.
50
- */
51
- create?: (this: TegamiContext, opts: {
52
- draft: Draft;
53
- publishGroup?: string[];
54
- }) => Awaitable<VersionMergeRequest>;
55
- }
56
12
  /** Options for creating GitLab releases after a successful publish. */
57
13
  interface GitLabPluginOptions extends GitPluginOptions {
58
14
  /** GitLab repository. */
@@ -91,7 +47,7 @@ interface GitLabPluginOptions extends GitPluginOptions {
91
47
  *
92
48
  * Defaults to enabled in CI and disabled locally.
93
49
  */
94
- versionMr?: VersionMergeRequestOptions | false;
50
+ versionMr?: VersionRequestOptions | false;
95
51
  }
96
52
  /** Create GitLab releases for successfully published packages after the whole plan succeeds. */
97
53
  declare function gitlab(options?: GitLabPluginOptions): TegamiPlugin[];
@@ -1,9 +1,9 @@
1
1
  import { i as formatPackageVersion, r as formatNpmDistTag } from "../semver-EKJ8yK5U.js";
2
2
  import { t as changelogFilename } from "../generate-Bg86OJP4.js";
3
3
  import { a as cached, n as execFailure, o as isCI, s as joinPath } from "../error-BhMYq9iW.js";
4
- import { o as readChangelogEntries, t as createDraft } from "../draft-CzUiQasJ.js";
4
+ import { a as createDraft, l as readChangelogEntries } from "../publish-v30y8Lwq.js";
5
5
  import { git } from "./git.js";
6
- import { t as onVersionRequest } from "../version-request-DlLpLLK3.js";
6
+ import { t as onVersionRequest } from "../version-request-l6IJdFM6.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";
@@ -311,38 +311,36 @@ function gitlab(options = {}) {
311
311
  }
312
312
  const versionRequests = onVersionRequest({
313
313
  name: "gitlab",
314
- summary: "Merge this MR to publish the versioned packages.",
315
314
  options: options.versionMr,
316
- enabled(context) {
315
+ canCreate(context) {
317
316
  const { repo, token } = context.gitlab ?? {};
318
317
  return Boolean(repo && token);
319
318
  },
320
- find(context, { head, base }) {
321
- return findOpenMergeRequest(context.gitlab.repo, {
322
- head,
323
- base,
324
- ...gitLabApiOptions(context.gitlab)
319
+ async upsert(context, request, update) {
320
+ const repo = context.gitlab.repo;
321
+ const api = gitLabApiOptions(context.gitlab);
322
+ const openMr = await findOpenMergeRequest(repo, {
323
+ head: request.head,
324
+ base: request.base,
325
+ ...api
325
326
  });
326
- },
327
- create(context, request) {
328
- return createMergeRequest(context.gitlab.repo, {
327
+ if (openMr === void 0) await createMergeRequest(repo, {
329
328
  title: request.title,
330
329
  body: request.body,
331
330
  head: request.head,
332
331
  base: request.base,
333
- ...gitLabApiOptions(context.gitlab)
332
+ ...api
334
333
  });
335
- },
336
- update(context, number, request) {
337
- return updateMergeRequest(context.gitlab.repo, number, {
334
+ else if (update) await updateMergeRequest(repo, openMr, {
338
335
  title: request.title,
339
336
  body: request.body,
340
337
  base: request.base,
341
- ...gitLabApiOptions(context.gitlab)
338
+ ...api
342
339
  });
343
340
  }
344
341
  });
345
- return [git(options), {
342
+ const plugin = {
343
+ ...versionRequests,
346
344
  name: "gitlab",
347
345
  init() {
348
346
  this.gitlab = {
@@ -353,7 +351,7 @@ function gitlab(options = {}) {
353
351
  };
354
352
  },
355
353
  async resolvePlanStatus({ plan }) {
356
- if (versionRequests.resolvePlanStatus() === "pending") return "pending";
354
+ if (versionRequests.resolvePlanStatus.call(this, { plan }) === "pending") return "pending";
357
355
  const { repo, token } = this.gitlab;
358
356
  if (!repo || !token || releaseOptions === false) return;
359
357
  const requiredTags = /* @__PURE__ */ new Set();
@@ -425,20 +423,9 @@ function gitlab(options = {}) {
425
423
  gitlabRemoteUrl(repo, token, webUrl)
426
424
  ], { nodeOptions: { cwd: this.cwd } });
427
425
  if (result.exitCode !== 0) throw execFailure("Failed to configure git remote for GitLab CI.", result);
428
- },
429
- initCliDraft() {
430
- versionRequests.initCliDraft.call(this);
431
- },
432
- applyCliDraft(draft) {
433
- return versionRequests.applyCliDraft.call(this, draft);
434
- },
435
- initPublishPlan(opts) {
436
- versionRequests.initPublishPlan.call(this, opts);
437
- },
438
- beforePublishAll(opts) {
439
- return versionRequests.beforePublishAll.call(this, opts);
440
426
  }
441
- }];
427
+ };
428
+ return [git(options), plugin];
442
429
  }
443
430
  function createChangelogRenderer(context) {
444
431
  const { repo, webUrl } = context.gitlab;
@@ -1,4 +1,4 @@
1
- import { A as WorkspacePackage, P as BumpType, s as TegamiPlugin } from "../types-DEyZ2r-2.js";
1
+ import { A as WorkspacePackage, P as BumpType, s as TegamiPlugin } from "../types-BbwOrNZ2.js";
2
2
 
3
3
  //#region src/plugins/go.d.ts
4
4
  interface GoModFile {
@@ -1,2 +1,2 @@
1
- import { C as NpmPackage, S as NpmGraph, l as NpmPluginOptions, u as npm, x as DependencySpec } from "../types-DEyZ2r-2.js";
1
+ import { C as NpmPackage, S as NpmGraph, l as NpmPluginOptions, u as npm, x as DependencySpec } from "../types-BbwOrNZ2.js";
2
2
  export { type DependencySpec, type NpmGraph, NpmPackage, NpmPluginOptions, npm };
@@ -1,2 +1,2 @@
1
- import { n as NpmPackage, t as npm } from "../npm-CaBYeOeV.js";
1
+ import { n as NpmPackage, t as npm } from "../npm-DaUHTtlV.js";
2
2
  export { NpmPackage, npm };