tegami 1.2.2 → 1.2.4

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.
Files changed (31) hide show
  1. package/dist/{_accessExpressionAsString-QhbUZzwv.js → _accessExpressionAsString-DW_6Xqcp.js} +1 -1
  2. package/dist/{_assertGuard-BBn2NbSz.js → _assertGuard-CFFC1Up9.js} +2 -2
  3. package/dist/{_createStandardSchema-BGQyz-uA.js → _createStandardSchema-CrRqJgaE.js} +2 -2
  4. package/dist/cli/index.d.ts +1 -1
  5. package/dist/cli/index.js +10 -8
  6. package/dist/{generate-Cnd8RiKO.js → generate-Cgl2G5ea.js} +2 -2
  7. package/dist/generators/simple.d.ts +1 -1
  8. package/dist/generators/simple.js +1 -1
  9. package/dist/{graph-BmXTJZxx.js → graph-DaJ28Y4f.js} +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +14 -8
  12. package/dist/{npm-cS-D2xGI.js → npm-CyC2Rk11.js} +221 -133
  13. package/dist/plugins/cargo.d.ts +1 -1
  14. package/dist/plugins/cargo.js +37 -34
  15. package/dist/plugins/git.d.ts +1 -1
  16. package/dist/plugins/git.js +2 -4
  17. package/dist/plugins/github.d.ts +7 -7
  18. package/dist/plugins/github.js +113 -241
  19. package/dist/plugins/gitlab.d.ts +6 -6
  20. package/dist/plugins/gitlab.js +118 -245
  21. package/dist/plugins/go.d.ts +1 -1
  22. package/dist/plugins/go.js +10 -10
  23. package/dist/providers/npm.d.ts +1 -1
  24. package/dist/providers/npm.js +1 -1
  25. package/dist/{publish-Bt3e1RPs.js → publish-DAMkayLs.js} +11 -15
  26. package/dist/{semver-EKJ8yK5U.js → semver-DrtaCCZK.js} +15 -3
  27. package/dist/{shared-C_iSTp_s.js → shared-pTOZU5UZ.js} +11 -3
  28. package/dist/{types-C_vz41r2.d.ts → types-BMYzG4dR.d.ts} +42 -26
  29. package/dist/{version-request-DXk_B7O_.d.ts → version-request-BorZZ98V.d.ts} +1 -1
  30. package/dist/{version-request-DvWVAYj2.js → version-request-CQ4cJHtP.js} +203 -67
  31. package/package.json +5 -4
@@ -1,13 +1,11 @@
1
- import { i as formatPackageVersion, r as formatNpmDistTag } from "../semver-EKJ8yK5U.js";
2
- import { t as changelogFilename } from "../generate-Cnd8RiKO.js";
1
+ import { t as changelogFilename } from "../generate-Cgl2G5ea.js";
3
2
  import { c as joinPath, n as execFailure, o as cached, r as fetchFailure, s as isCI } from "../error-CAsrGb6e.js";
4
- import { a as createDraft, l as readChangelogEntries } from "../publish-Bt3e1RPs.js";
3
+ import { a as createDraft, l as readChangelogEntries } from "../publish-DAMkayLs.js";
5
4
  import { git } from "./git.js";
6
- import { t as onVersionRequest } from "../version-request-DvWVAYj2.js";
5
+ import { i as versionRequestPlugin, n as formatPreview, r as resolveFileCommit, t as createAutoRelease } from "../version-request-CQ4cJHtP.js";
7
6
  import { readFile, writeFile } from "node:fs/promises";
8
7
  import { basename, join, relative, resolve } from "node:path";
9
8
  import { x } from "tinyexec";
10
- import { resolveCommand } from "package-manager-detector";
11
9
  import { note, outro } from "@clack/prompts";
12
10
  //#region src/plugins/gitlab/api.ts
13
11
  function parseGitLabRepo(repo) {
@@ -184,46 +182,10 @@ function registerMrCli(cli) {
184
182
  }
185
183
  async function buildMrPreview(context, draft, options = {}) {
186
184
  const mergeRequest = await resolveMergeRequest(context, options);
187
- const tegamiCommandRaw = resolveCommand(context.npm?.client ?? "npm", "run", ["tegami"]);
188
- const tegamiCommand = [tegamiCommandRaw.command, ...tegamiCommandRaw.args].join(" ");
189
- const changelogFiles = await listMergeRequestChangelogFiles(context, mergeRequest.baseSha, mergeRequest.headSha);
190
- const createLink = createChangelogUrl(context, mergeRequest.headRepo, mergeRequest.headRef, changelogFilename());
191
- const pendingPackages = [];
192
- const lines = [
193
- "### Tegami",
194
- "",
195
- `This repository uses [Tegami](https://tegami.fuma-nama.dev) to manage releases. When your changes affect published packages, add a changelog file under \`.tegami/\` before merging.`,
196
- "",
197
- `[**Create a changelog →**](${createLink}) · [Changelog format](https://tegami.fuma-nama.dev/changelog)`,
198
- ""
199
- ];
200
- for (const pkg of context.graph.getPackages()) {
201
- const plan = draft.getPackageDraft(pkg.id);
202
- if (!plan) continue;
203
- const bumped = plan.bumpVersion(pkg);
204
- if (!bumped || !pkg.version || bumped === pkg.version) continue;
205
- pendingPackages.push({
206
- name: pkg.name,
207
- type: plan.type ?? "—",
208
- from: pkg.version,
209
- to: bumped,
210
- distTag: plan.npm?.distTag
211
- });
212
- }
213
- const requestChangelogs = draft.getChangelogs().filter((entry) => changelogFiles.has(entry.filename));
214
- if (pendingPackages.length > 0) {
215
- lines.push("#### Release preview", "", "| Package | Bump | Version |", "| --- | --- | --- |");
216
- for (const { name, type, from, to, distTag } of pendingPackages) lines.push(`| \`${name}\` | ${type} | \`${from}\` → \`${to}\`${formatNpmDistTag(distTag)} |`);
217
- lines.push("");
218
- }
219
- if (requestChangelogs.length > 0) {
220
- lines.push("#### Changelogs in this MR", "", "| Changelog | Title |", "| --- | --- |");
221
- for (const entry of requestChangelogs) for (const section of entry.sections) lines.push(`| \`${entry.filename}\` | ${section.title} |`);
222
- lines.push("");
223
- } else if (pendingPackages.length === 0) lines.push("#### No changelogs yet", "", "This MR has no pending changelog files. If your changes require a release, add a changelog before merging.", "");
224
- else if (changelogFiles.size === 0) lines.push("This MR does not add changelog files. Pending changelogs from other branches are included in the preview above.", "");
225
- lines.push(`Run \`${tegamiCommand}\` locally to create a changelog interactively.`, "", `<sub>Managed by [Tegami](https://tegami.fuma-nama.dev).</sub>`, "");
226
- return lines.join("\n");
185
+ return formatPreview(context, draft, await listMergeRequestChangelogFiles(context, mergeRequest.baseSha, mergeRequest.headSha), {
186
+ "create-a-changelog-href": createChangelogUrl(context, mergeRequest.headRepo, mergeRequest.headRef, changelogFilename()),
187
+ pr: "MR"
188
+ });
227
189
  }
228
190
  async function postMrComment(context, body, options = {}) {
229
191
  const { repo, apiUrl, token } = context.gitlab;
@@ -310,209 +272,120 @@ function parsePositiveInt(value, option) {
310
272
  /** Create GitLab releases for successfully published packages after the whole plan succeeds. */
311
273
  function gitlab(options = {}) {
312
274
  const { release: releaseOptions = true } = options;
313
- let renderer;
314
- function getRenderer(context) {
315
- return renderer ??= createChangelogRenderer(context);
316
- }
317
- const versionRequests = onVersionRequest({
318
- name: "gitlab",
319
- options: options.versionMr,
320
- canCreate(context) {
321
- const { repo, token } = context.gitlab ?? {};
322
- return Boolean(repo && token);
323
- },
324
- async upsert(context, request, update) {
325
- const repo = context.gitlab.repo;
326
- const api = gitLabApiOptions(context.gitlab);
327
- const openMr = await findOpenMergeRequest(repo, {
328
- head: request.head,
329
- base: request.base,
330
- ...api
331
- });
332
- if (openMr === void 0) await createMergeRequest(repo, {
333
- title: request.title,
334
- body: request.body,
335
- head: request.head,
336
- base: request.base,
337
- ...api
338
- });
339
- else if (update) await updateMergeRequest(repo, openMr, {
340
- title: request.title,
341
- body: request.body,
342
- base: request.base,
343
- ...api
344
- });
345
- }
346
- });
347
- const plugin = {
348
- ...versionRequests,
349
- name: "gitlab",
350
- init() {
351
- this.gitlab = {
352
- repo: options.repo ?? process.env.GITLAB_REPOSITORY ?? process.env.CI_PROJECT_PATH,
353
- token: resolveGitLabToken(options.token),
354
- apiUrl: options.apiUrl ?? process.env.GITLAB_API_URL ?? process.env.CI_API_V4_URL ?? "https://gitlab.com/api/v4",
355
- webUrl: options.webUrl ?? process.env.GITLAB_SERVER_URL ?? process.env.CI_SERVER_URL ?? "https://gitlab.com"
356
- };
357
- },
358
- async resolvePlanStatus({ plan }) {
359
- if (versionRequests.resolvePlanStatus.call(this, { plan }) === "pending") return "pending";
360
- const { repo, token } = this.gitlab;
361
- if (!repo || !token || releaseOptions === false) return;
362
- const requiredTags = /* @__PURE__ */ new Set();
363
- const api = gitLabApiOptions(this.gitlab);
364
- for (const pkg of plan.packages.values()) if (pkg.preflight.shouldPublish && pkg.git?.tag) requiredTags.add(pkg.git.tag);
365
- return Array.from(requiredTags, async (tag) => {
366
- if (!await releaseExistsByTag(repo, tag, api)) return "pending";
367
- });
368
- },
369
- async afterPublishAll({ plan }) {
370
- const { repo, token } = this.gitlab;
371
- if (!repo || !token || releaseOptions === false) return;
372
- const api = gitLabApiOptions(this.gitlab);
373
- const { eager = false, create, createGrouped } = releaseOptions === true ? {} : releaseOptions;
374
- const groups = /* @__PURE__ */ new Map();
375
- for (const [id, { preflight, publishResult, git }] of plan.packages) {
376
- if (!eager && publishResult.type === "failed") return;
377
- const tag = git?.tag;
378
- if (!tag || !preflight.shouldPublish) continue;
379
- const pkg = this.graph.get(id);
380
- const group = groups.get(tag);
381
- if (group) group.push(pkg);
382
- else groups.set(tag, [pkg]);
383
- }
384
- await Promise.all(Array.from(groups, async ([tag, packages]) => {
385
- for (const member of packages) if (plan.packages.get(member.id).publishResult.type === "failed") return;
386
- if (await releaseExistsByTag(repo, tag, api)) return;
387
- let release;
388
- if (packages.length > 1) {
389
- const overrides = await createGrouped?.call(this, {
390
- tag,
391
- packages,
392
- plan
393
- }) ?? {};
394
- release = {
395
- title: overrides.title ?? tag,
396
- notes: overrides.notes ?? await defaultGroupedNotes(getRenderer(this), plan, packages)
397
- };
398
- } else {
399
- const pkg = packages[0];
400
- const overrides = await create?.call(this, {
401
- tag,
402
- pkg,
403
- plan
404
- }) ?? {};
405
- const packagePlan = plan.packages.get(pkg.id);
406
- release = {
407
- title: overrides.title ?? formatPackageVersion(pkg.name, pkg.version, packagePlan?.npm?.distTag),
408
- notes: overrides.notes ?? await defaultNotes(getRenderer(this), pkg, packagePlan)
409
- };
275
+ let autoRelease;
276
+ return [
277
+ git(options),
278
+ {
279
+ name: "gitlab",
280
+ init() {
281
+ const { repo, token, webUrl } = this.gitlab = {
282
+ repo: options.repo ?? process.env.GITLAB_REPOSITORY ?? process.env.CI_PROJECT_PATH,
283
+ token: resolveGitLabToken(options.token),
284
+ apiUrl: options.apiUrl ?? process.env.GITLAB_API_URL ?? process.env.CI_API_V4_URL ?? "https://gitlab.com/api/v4",
285
+ webUrl: options.webUrl ?? process.env.GITLAB_SERVER_URL ?? process.env.CI_SERVER_URL ?? "https://gitlab.com"
286
+ };
287
+ if (repo && token && releaseOptions !== false) {
288
+ const { eager = false, create, createGrouped } = releaseOptions === true ? {} : releaseOptions;
289
+ const api = gitLabApiOptions(this.gitlab);
290
+ const resolveEntryMeta = cached((entry) => entry.id, async (entry) => {
291
+ const commit = await resolveFileCommit(this, entry.filename);
292
+ if (!commit || !repo) return {
293
+ commit,
294
+ mergeRequests: []
295
+ };
296
+ return {
297
+ commit,
298
+ mergeRequests: await listMergeRequestsForCommit(repo, commit, api).catch(() => [])
299
+ };
300
+ });
301
+ autoRelease = createAutoRelease({
302
+ eager,
303
+ override: create,
304
+ overrideGroup: createGrouped,
305
+ async formatChangelog(entry) {
306
+ const meta = await resolveEntryMeta(entry);
307
+ const commitSuffix = meta.commit ? ` ([${meta.commit.slice(0, 7)}](${joinPath(webUrl, repo, "-/commit", meta.commit)}))` : "";
308
+ const lines = [];
309
+ for (const section of entry.sections) {
310
+ lines.push(`### ${section.title}${commitSuffix}`, "");
311
+ if (section.content) lines.push(section.content, "");
312
+ }
313
+ if (meta.mergeRequests.length > 0) {
314
+ lines.push("<details>", "<summary>Merge request & contributors</summary>", "");
315
+ for (const mr of meta.mergeRequests) {
316
+ let line = `- [!${mr.number} ${mr.title}](${joinPath(webUrl, repo, "-/merge_requests", String(mr.number))})`;
317
+ if (mr.user) line += ` by @${mr.user.login}`;
318
+ lines.push(line);
319
+ }
320
+ lines.push("", "</details>");
321
+ }
322
+ return lines.join("\n").trim();
323
+ },
324
+ create({ input, tag }) {
325
+ return createRelease(repo, {
326
+ tag,
327
+ title: input.title,
328
+ notes: input.notes,
329
+ ...api
330
+ });
331
+ },
332
+ releaseExistsByTag(tag) {
333
+ return releaseExistsByTag(repo, tag, api);
334
+ }
335
+ });
410
336
  }
411
- await createRelease(repo, {
412
- tag,
413
- title: release.title,
414
- notes: release.notes,
337
+ },
338
+ async resolvePlanStatus({ plan }) {
339
+ if (await autoRelease?.hasPending.call(this, plan)) return "pending";
340
+ },
341
+ async afterPublishAll({ plan }) {
342
+ await autoRelease?.create.call(this, plan);
343
+ },
344
+ async initCli(cli) {
345
+ registerMrCli(cli);
346
+ if (!isCI()) return;
347
+ const { repo, token, webUrl } = this.gitlab;
348
+ if (!token || !repo) return;
349
+ const result = await x("git", [
350
+ "remote",
351
+ "set-url",
352
+ "origin",
353
+ gitlabRemoteUrl(repo, token, webUrl)
354
+ ], { nodeOptions: { cwd: this.cwd } });
355
+ if (result.exitCode !== 0) throw execFailure("Failed to configure git remote for GitLab CI.", result);
356
+ }
357
+ },
358
+ versionRequestPlugin({
359
+ name: "gitlab",
360
+ options: options.versionMr,
361
+ canCreate(context) {
362
+ const { repo, token } = context.gitlab ?? {};
363
+ return Boolean(repo && token);
364
+ },
365
+ async upsert(context, request, update) {
366
+ const repo = context.gitlab.repo;
367
+ const api = gitLabApiOptions(context.gitlab);
368
+ const openMr = await findOpenMergeRequest(repo, {
369
+ head: request.head,
370
+ base: request.base,
415
371
  ...api
416
372
  });
417
- }));
418
- },
419
- async initCli(cli) {
420
- registerMrCli(cli);
421
- if (!isCI()) return;
422
- const { repo, token, webUrl } = this.gitlab;
423
- if (!token || !repo) return;
424
- const result = await x("git", [
425
- "remote",
426
- "set-url",
427
- "origin",
428
- gitlabRemoteUrl(repo, token, webUrl)
429
- ], { nodeOptions: { cwd: this.cwd } });
430
- if (result.exitCode !== 0) throw execFailure("Failed to configure git remote for GitLab CI.", result);
431
- }
432
- };
433
- return [git(options), plugin];
434
- }
435
- function createChangelogRenderer(context) {
436
- const { repo, webUrl } = context.gitlab;
437
- const api = gitLabApiOptions(context.gitlab);
438
- const resolveFileCommit = cached((filename) => filename, async (filename) => {
439
- const result = await x("git", [
440
- "log",
441
- "--diff-filter=A",
442
- "-1",
443
- "--format=%H",
444
- "--",
445
- relative(context.cwd, join(context.changelogDir, filename))
446
- ], { nodeOptions: { cwd: context.cwd } });
447
- if (result.exitCode !== 0) return;
448
- return result.stdout.trim() || void 0;
449
- });
450
- const resolveEntryMeta = cached((entry) => entry.id, async (entry) => {
451
- const commit = await resolveFileCommit(entry.filename);
452
- if (!commit || !repo) return {
453
- commit,
454
- mergeRequests: []
455
- };
456
- return {
457
- commit,
458
- mergeRequests: await listMergeRequestsForCommit(repo, commit, api).catch(() => [])
459
- };
460
- });
461
- function formatEntryDetails(meta) {
462
- if (meta.mergeRequests.length === 0) return;
463
- const lines = [];
464
- for (const mr of meta.mergeRequests) {
465
- let line = repo ? `- [!${mr.number} ${mr.title}](${joinPath(webUrl, repo, "-/merge_requests", String(mr.number))})` : `- #${mr.number} ${mr.title}`;
466
- if (mr.user) line += ` by @${mr.user.login}`;
467
- lines.push(line);
468
- }
469
- return [
470
- "<details>",
471
- "<summary>Merge request & contributors</summary>",
472
- "",
473
- ...lines,
474
- "",
475
- "</details>"
476
- ].join("\n");
477
- }
478
- return async (entry) => {
479
- const meta = await resolveEntryMeta(entry);
480
- let commitSuffix = "";
481
- if (meta.commit) {
482
- const short = meta.commit.slice(0, 7);
483
- const link = repo ? `[${short}](${joinPath(webUrl, repo, "-/commit", meta.commit)})` : `\`${short}\``;
484
- commitSuffix += ` (${link})`;
485
- }
486
- const lines = [];
487
- for (const section of entry.sections) {
488
- lines.push(`### ${section.title}${commitSuffix}`, "");
489
- if (section.content) lines.push(section.content, "");
490
- }
491
- const details = formatEntryDetails(meta);
492
- if (details) lines.push(details);
493
- return lines.join("\n").trim();
494
- };
495
- }
496
- async function defaultNotes(renderer, pkg, packagePlan) {
497
- if (packagePlan && packagePlan.changelogs.length > 0) return (await Promise.all(packagePlan.changelogs.map(renderer))).join("\n\n");
498
- return `Published ${formatPackageVersion(pkg.name, pkg.version, packagePlan?.npm?.distTag)}.`;
499
- }
500
- async function defaultGroupedNotes(renderer, plan, packages) {
501
- const changelogs = /* @__PURE__ */ new Map();
502
- for (const pkg of packages) {
503
- const packagePlan = plan.packages.get(pkg.id);
504
- if (!packagePlan) continue;
505
- for (const entry of packagePlan.changelogs) changelogs.set(entry.id, entry);
506
- }
507
- const sections = [packages.map((pkg) => {
508
- const packagePlan = plan.packages.get(pkg.id);
509
- return `- ${formatPackageVersion(pkg.name, pkg.version, packagePlan?.npm?.distTag)}`;
510
- }).join("\n")];
511
- if (changelogs.size > 0) {
512
- const notes = await Promise.all(Array.from(changelogs.values(), renderer));
513
- sections.push("", notes.join("\n\n"));
514
- }
515
- return sections.join("\n");
373
+ if (openMr === void 0) await createMergeRequest(repo, {
374
+ title: request.title,
375
+ body: request.body,
376
+ head: request.head,
377
+ base: request.base,
378
+ ...api
379
+ });
380
+ else if (update) await updateMergeRequest(repo, openMr, {
381
+ title: request.title,
382
+ body: request.body,
383
+ base: request.base,
384
+ ...api
385
+ });
386
+ }
387
+ })
388
+ ];
516
389
  }
517
390
  function gitLabApiOptions(gitlab) {
518
391
  const options = {};
@@ -1,4 +1,4 @@
1
- import { A as WorkspacePackage, P as BumpType, s as TegamiPlugin } from "../types-C_vz41r2.js";
1
+ import { F as BumpType, j as WorkspacePackage, s as TegamiPlugin } from "../types-BMYzG4dR.js";
2
2
 
3
3
  //#region src/plugins/go.d.ts
4
4
  interface GoModFile {
@@ -1,6 +1,6 @@
1
1
  import { a as isNodeError, n as execFailure, r as fetchFailure } from "../error-CAsrGb6e.js";
2
- import { n as _validateReport, t as _createStandardSchema } from "../_createStandardSchema-BGQyz-uA.js";
3
- import { n as WorkspacePackage } from "../graph-BmXTJZxx.js";
2
+ import { n as _validateReport, t as _createStandardSchema } from "../_createStandardSchema-CrRqJgaE.js";
3
+ import { n as WorkspacePackage } from "../graph-DaJ28Y4f.js";
4
4
  import { relative, resolve } from "node:path";
5
5
  import { x } from "tinyexec";
6
6
  import * as semver$1 from "semver";
@@ -287,7 +287,6 @@ function go({ updateLockFile = true, bumpDep: getBumpDepType } = {}) {
287
287
  let active = false;
288
288
  return {
289
289
  name: "go",
290
- enforce: "post",
291
290
  async resolve() {
292
291
  await discoverGoPackages(this.cwd, (pkg) => this.graph.add(pkg));
293
292
  active = this.graph.getPackages().some((pkg) => pkg instanceof GoPackage);
@@ -320,9 +319,9 @@ function go({ updateLockFile = true, bumpDep: getBumpDepType } = {}) {
320
319
  },
321
320
  initPublishLock({ lock, draft }) {
322
321
  if (!active) return;
323
- for (const [id, packageDraft] of draft.getPackageDrafts()) {
322
+ for (const id of draft.getPackageDrafts().keys()) {
324
323
  const pkg = this.graph.get(id);
325
- if (!(pkg instanceof GoPackage) || !packageDraft.type) continue;
324
+ if (!(pkg instanceof GoPackage)) continue;
326
325
  lock.write("go:packages", {
327
326
  id,
328
327
  version: pkg.version
@@ -331,17 +330,18 @@ function go({ updateLockFile = true, bumpDep: getBumpDepType } = {}) {
331
330
  },
332
331
  initPublishPlan({ lock, plan }) {
333
332
  if (!active) return;
333
+ const lockVersions = /* @__PURE__ */ new Map();
334
334
  let data;
335
335
  while (data = lock.read("go:packages")) {
336
- const validated = validateGoPackageLock(data);
337
- if (!validated.success) continue;
338
- const parsed = validated.data;
339
- const pkg = this.graph.get(parsed.id);
340
- if (pkg instanceof GoPackage) pkg.setVersion(parsed.version);
336
+ const { success, data: parsed } = validateGoPackageLock(data);
337
+ if (!success) continue;
338
+ lockVersions.set(parsed.id, parsed.version);
341
339
  }
342
340
  for (const [id, packagePlan] of plan.packages) {
343
341
  const pkg = this.graph.get(id);
344
342
  if (!(pkg instanceof GoPackage)) continue;
343
+ const version = packagePlan.updated && lockVersions.get(id);
344
+ if (version) pkg.setVersion(version);
345
345
  packagePlan.git ??= {};
346
346
  packagePlan.git.tag = formatGoTag(this.cwd, pkg.path, pkg.version);
347
347
  }
@@ -1,2 +1,2 @@
1
- import { C as NpmPackage, S as NpmGraph, l as NpmPluginOptions, u as npm, x as DependencySpec } from "../types-C_vz41r2.js";
1
+ import { C as NpmGraph, S as DependencySpec, l as NpmPluginOptions, u as npm, w as NpmPackage } from "../types-BMYzG4dR.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-cS-D2xGI.js";
1
+ import { n as NpmPackage, t as npm } from "../npm-CyC2Rk11.js";
2
2
  export { NpmPackage, npm };
@@ -1,10 +1,10 @@
1
- import { a as maxBump } from "./semver-EKJ8yK5U.js";
1
+ import { o as maxBump } from "./semver-DrtaCCZK.js";
2
2
  import { i as handlePluginError, l as somePromise } from "./error-CAsrGb6e.js";
3
- import { t as _accessExpressionAsString } from "./_accessExpressionAsString-QhbUZzwv.js";
4
- import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-BGQyz-uA.js";
5
- import { n as validateChangelogFrontmatter, t as renderChangelog } from "./shared-C_iSTp_s.js";
3
+ import { t as _accessExpressionAsString } from "./_accessExpressionAsString-DW_6Xqcp.js";
4
+ import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-CrRqJgaE.js";
5
+ import { n as renderChangelog, r as validateChangelogFrontmatter, t as getPackageBumps } from "./shared-pTOZU5UZ.js";
6
6
  import { simpleGenerator } from "./generators/simple.js";
7
- import { t as _assertGuard } from "./_assertGuard-BBn2NbSz.js";
7
+ import { t as _assertGuard } from "./_assertGuard-CFFC1Up9.js";
8
8
  import fs, { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
9
9
  import path, { basename, dirname, join } from "node:path";
10
10
  import * as semver$1 from "semver";
@@ -450,13 +450,7 @@ var Draft = class {
450
450
  }
451
451
  addChangelog(entry) {
452
452
  this.changelogs.set(entry.id, entry);
453
- const { graph } = this.context;
454
- const groupPackages = /* @__PURE__ */ new Map();
455
- for (const [name, config] of entry.packages) {
456
- if (!config.type) continue;
457
- for (const pkg of graph.getByName(name)) groupPackages.set(pkg, config.type);
458
- }
459
- for (const [pkg, bumpType] of groupPackages) attachChangelog(this.bumpPackage(pkg, { type: bumpType }), entry);
453
+ for (const [pkg, bumpType] of getPackageBumps(this.context.graph, entry)) attachChangelog(this.bumpPackage(pkg, { type: bumpType }), entry);
460
454
  }
461
455
  deleteChangelog(id) {
462
456
  return this.changelogs.delete(id);
@@ -794,10 +788,12 @@ async function runPreflights(context, plan) {
794
788
  async function publishPlanStatus(plan, context) {
795
789
  for (const plugin of context.plugins) {
796
790
  const status = await handlePluginError(plugin, "resolvePlanStatus", () => plugin.resolvePlanStatus?.call(context, { plan }));
797
- if (Array.isArray(status) && await somePromise(status, (v) => v === "pending")) return "pending";
798
- if (status === "pending") return "pending";
791
+ if (Array.isArray(status) && await somePromise(status, (v) => v === "pending") || status === "pending") return {
792
+ status: "pending",
793
+ reason: `Plugin "${plugin.name}" has pending tasks`
794
+ };
799
795
  }
800
- return "success";
796
+ return { status: "success" };
801
797
  }
802
798
  //#endregion
803
799
  export { createDraft as a, parseChangelogFile as c, runPublishPlan as i, readChangelogEntries as l, publishPlanStatus as n, PublishLock as o, runPreflights as r, parsePublishLock as s, initPublishPlan as t };
@@ -1,4 +1,4 @@
1
- import { inc, parse } from "semver";
1
+ import { diff, inc, parse } from "semver";
2
2
  //#region src/utils/semver.ts
3
3
  function formatNpmDistTag(distTag) {
4
4
  return distTag && distTag !== "latest" ? ` (${distTag})` : "";
@@ -11,8 +11,11 @@ function formatPackageVersion(name, version, distTag) {
11
11
  }
12
12
  const WEIGHTS = {
13
13
  major: 3,
14
+ premajor: 3,
14
15
  minor: 2,
15
- patch: 1
16
+ preminor: 2,
17
+ patch: 1,
18
+ prepatch: 1
16
19
  };
17
20
  const DEPTH = {
18
21
  major: 1,
@@ -24,6 +27,15 @@ const PRE = {
24
27
  minor: "preminor",
25
28
  patch: "prepatch"
26
29
  };
30
+ function diffWeight(from, to) {
31
+ const d = diff(from, to);
32
+ if (!d) return 0;
33
+ switch (d) {
34
+ case "release":
35
+ case "prerelease": return 4;
36
+ default: return WEIGHTS[d];
37
+ }
38
+ }
27
39
  function maxBump(a, b) {
28
40
  if (WEIGHTS[a] > WEIGHTS[b]) return a;
29
41
  return b;
@@ -45,4 +57,4 @@ function bumpVersion(version, type, prerelease) {
45
57
  return next;
46
58
  }
47
59
  //#endregion
48
- export { maxBump as a, formatPackageVersion as i, bumpVersion as n, formatNpmDistTag as r, bumpDepth as t };
60
+ export { formatPackageVersion as a, formatNpmDistTag as i, bumpVersion as n, maxBump as o, diffWeight as r, bumpDepth as t };
@@ -1,5 +1,5 @@
1
- import { t as _accessExpressionAsString } from "./_accessExpressionAsString-QhbUZzwv.js";
2
- import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-BGQyz-uA.js";
1
+ import { t as _accessExpressionAsString } from "./_accessExpressionAsString-DW_6Xqcp.js";
2
+ import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-CrRqJgaE.js";
3
3
  import { stringify } from "yaml";
4
4
  //#region src/changelog/shared.ts
5
5
  const validateChangelogFrontmatter = (() => {
@@ -111,5 +111,13 @@ function renderChangelog(frontmatter, body) {
111
111
  ""
112
112
  ].join("\n");
113
113
  }
114
+ function getPackageBumps(graph, entry) {
115
+ const packageBumps = /* @__PURE__ */ new Map();
116
+ for (const [name, config] of entry.packages) {
117
+ if (!config.type) continue;
118
+ for (const pkg of graph.getByName(name)) packageBumps.set(pkg, config.type);
119
+ }
120
+ return packageBumps;
121
+ }
114
122
  //#endregion
115
- export { validateChangelogFrontmatter as n, renderChangelog as t };
123
+ export { renderChangelog as n, validateChangelogFrontmatter as r, getPackageBumps as t };