tegami 1.2.0 → 1.2.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.
@@ -1,4 +1,4 @@
1
- import { f as Tegami, j as Draft, t as Awaitable, v as PublishPlan } from "../types-BbwOrNZ2.js";
1
+ import { f as Tegami, j as Draft, t as Awaitable, v as PublishPlan } from "../types-C_vz41r2.js";
2
2
 
3
3
  //#region src/cli/index.d.ts
4
4
  interface TegamiCLIOptions {
package/dist/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { n as generateFromCommits, t as changelogFilename } from "../generate-Bg86OJP4.js";
2
- import { o as isCI, r as handlePluginError, t as CancelledError } from "../error-BhMYq9iW.js";
1
+ import { n as generateFromCommits, t as changelogFilename } from "../generate-Cnd8RiKO.js";
2
+ import { i as handlePluginError, s as isCI, t as CancelledError } from "../error-CAsrGb6e.js";
3
3
  import { t as renderChangelog } from "../shared-C_iSTp_s.js";
4
4
  import { mkdir, readFile, writeFile } from "node:fs/promises";
5
5
  import path, { join, relative } from "node:path";
@@ -59,6 +59,11 @@ function execFailure(context, result) {
59
59
  if (err) lines.push(err);
60
60
  return new Error(redactSensitiveTokens(lines.join("\n")));
61
61
  }
62
+ async function fetchFailure(context, response) {
63
+ const body = (await response.text()).trim();
64
+ const message = body ? `${context}: ${body}` : context;
65
+ return new Error(redactSensitiveTokens(message));
66
+ }
62
67
  function isNodeError(error) {
63
68
  return error instanceof Error && "code" in error;
64
69
  }
@@ -86,4 +91,4 @@ async function handlePluginError(plugin, hookName, callback) {
86
91
  }
87
92
  }
88
93
  //#endregion
89
- export { cached as a, somePromise as c, isNodeError as i, execFailure as n, isCI as o, handlePluginError as r, joinPath as s, CancelledError as t };
94
+ export { isNodeError as a, joinPath as c, handlePluginError as i, somePromise as l, execFailure as n, cached as o, fetchFailure as r, isCI as s, CancelledError as t };
@@ -1,5 +1,5 @@
1
1
  import { a as maxBump, t as bumpDepth } from "./semver-EKJ8yK5U.js";
2
- import { n as execFailure } from "./error-BhMYq9iW.js";
2
+ import { n as execFailure } from "./error-CAsrGb6e.js";
3
3
  import { t as renderChangelog } from "./shared-C_iSTp_s.js";
4
4
  import { x } from "tinyexec";
5
5
  //#region src/utils/conventional-commit.ts
@@ -1,4 +1,4 @@
1
- import { r as LogGenerator } from "../types-BbwOrNZ2.js";
1
+ import { r as LogGenerator } from "../types-C_vz41r2.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-BbwOrNZ2.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-C_vz41r2.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
- import { n as generateFromCommits } from "./generate-Bg86OJP4.js";
2
- import { r as handlePluginError } from "./error-BhMYq9iW.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";
1
+ import { n as generateFromCommits } from "./generate-Cnd8RiKO.js";
2
+ import { i as handlePluginError } from "./error-CAsrGb6e.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-Bt3e1RPs.js";
4
+ import { t as npm } from "./npm-cS-D2xGI.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 { i as isNodeError, n as execFailure, s as joinPath } from "./error-BhMYq9iW.js";
1
+ import { a as isNodeError, c as joinPath, n as execFailure, r as fetchFailure } from "./error-CAsrGb6e.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 { r as runPreflights, s as parsePublishLock, t as initPublishPlan } from "./publish-v30y8Lwq.js";
4
+ import { r as runPreflights, s as parsePublishLock, t as initPublishPlan } from "./publish-Bt3e1RPs.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";
@@ -79,7 +79,7 @@ async function resolvePretrustTargets(context) {
79
79
  async function isPackageOnRegistry(name, registry = "https://registry.npmjs.org") {
80
80
  const response = await fetch(joinPath(registry, name), { headers: { Accept: "application/json" } });
81
81
  if (response.status === 404) return false;
82
- if (!response.ok) throw new Error(`Unable to check whether ${name} exists on the npm registry${registry ? ` "${registry}"` : ""}.`);
82
+ if (!response.ok) throw await fetchFailure(`Unable to check whether ${name} exists on the npm registry${registry ? ` "${registry}"` : ""}`, response);
83
83
  return true;
84
84
  }
85
85
  async function publishPlaceholder(pkg) {
@@ -887,14 +887,21 @@ function npm({ client: defaultClient, onBreakPeerDep = "set", updateLockFile = t
887
887
  }
888
888
  } } = {}) {
889
889
  let active = false;
890
- let client;
891
890
  return {
892
891
  name: "npm",
893
892
  enforce: "pre",
894
893
  async init() {
895
- if (defaultClient) client = defaultClient;
896
- else client = (await detect({ cwd: this.cwd }))?.name ?? "npm";
897
- this.npm = { client };
894
+ if (defaultClient) this.npm = {
895
+ client: defaultClient,
896
+ agent: defaultClient
897
+ };
898
+ else {
899
+ const result = await detect({ cwd: this.cwd });
900
+ this.npm = {
901
+ client: result?.name ?? "npm",
902
+ agent: result?.agent ?? "npm"
903
+ };
904
+ }
898
905
  },
899
906
  async resolve() {
900
907
  if (!this.npm) return;
@@ -952,9 +959,9 @@ function npm({ client: defaultClient, onBreakPeerDep = "set", updateLockFile = t
952
959
  }
953
960
  },
954
961
  async publish({ pkg, plan }) {
955
- if (!(pkg instanceof NpmPackage)) return;
962
+ if (!(pkg instanceof NpmPackage) || !this.npm) return;
956
963
  const { distTag, markLatest } = plan.packages.get(pkg.id)?.npm ?? {};
957
- const result = await publish(client, pkg, distTag);
964
+ const result = await publish(this.npm.client, pkg, distTag);
958
965
  if (result.type === "published" && markLatest) {
959
966
  const tagResult = await x("npm", [
960
967
  "dist-tag",
@@ -1003,8 +1010,33 @@ function npm({ client: defaultClient, onBreakPeerDep = "set", updateLockFile = t
1003
1010
  await Promise.all(writes);
1004
1011
  },
1005
1012
  async applyCliDraft() {
1006
- if (!active || !updateLockFile) return;
1007
- const result = await x(client, ["install"], { nodeOptions: { cwd: this.cwd } });
1013
+ if (!this.npm || !active || !updateLockFile) return;
1014
+ let args;
1015
+ switch (this.npm.agent) {
1016
+ case "pnpm":
1017
+ case "pnpm@6":
1018
+ args = [
1019
+ "install",
1020
+ "--lockfile-only",
1021
+ "--no-frozen-lockfile"
1022
+ ];
1023
+ break;
1024
+ case "npm":
1025
+ args = ["install", "--package-lock-only"];
1026
+ break;
1027
+ case "bun":
1028
+ args = ["install", "--lockfile-only"];
1029
+ break;
1030
+ case "yarn@berry":
1031
+ args = [
1032
+ "install",
1033
+ "--mode=update-lockfile",
1034
+ "--no-immutable"
1035
+ ];
1036
+ break;
1037
+ default: args = ["install"];
1038
+ }
1039
+ const result = await x(this.npm.client, args, { nodeOptions: { cwd: this.cwd } });
1008
1040
  if (result.exitCode !== 0) throw execFailure("Failed to update lockfile.", result);
1009
1041
  },
1010
1042
  initCli(cli) {
@@ -1120,7 +1152,7 @@ async function publish(client, pkg, distTag) {
1120
1152
  async function isPackagePublished(name, version, registry) {
1121
1153
  const response = await fetch(joinPath(registry, name, version), { headers: { Accept: "application/json" } });
1122
1154
  if (response.status === 404) return false;
1123
- if (!response.ok) throw new Error(`Unable to validate ${name}@${version} against the npm registry${registry ? ` "${registry}"` : ""}.`);
1155
+ if (!response.ok) throw await fetchFailure(`Unable to validate ${name}@${version} against the npm registry${registry ? ` "${registry}"` : ""}`, response);
1124
1156
  return true;
1125
1157
  }
1126
1158
  //#endregion
@@ -1,2 +1,2 @@
1
- import { D as cargo, E as CargoPluginOptions, T as CargoPackage, w as CargoGraph } from "../types-BbwOrNZ2.js";
1
+ import { D as cargo, E as CargoPluginOptions, T as CargoPackage, w as CargoGraph } from "../types-C_vz41r2.js";
2
2
  export { CargoGraph, CargoPackage, CargoPluginOptions, cargo };
@@ -1,4 +1,4 @@
1
- import { n as execFailure } from "../error-BhMYq9iW.js";
1
+ import { n as execFailure, r as fetchFailure } from "../error-CAsrGb6e.js";
2
2
  import { t as _accessExpressionAsString } from "../_accessExpressionAsString-QhbUZzwv.js";
3
3
  import { t as _assertGuard } from "../_assertGuard-BBn2NbSz.js";
4
4
  import { n as WorkspacePackage } from "../graph-BmXTJZxx.js";
@@ -686,7 +686,7 @@ async function isPackagePublished(name, version) {
686
686
  const response = await fetch(`https://crates.io/api/v1/crates/${encodeURIComponent(name)}/${version}`);
687
687
  if (response.status === 200) return true;
688
688
  if (response.status === 404) return false;
689
- throw new Error(`Unable to validate ${name}@${version} against crates.io: ${await response.text()}`);
689
+ throw await fetchFailure(`Unable to validate ${name}@${version} against crates.io`, response);
690
690
  }
691
691
  async function buildEntry(dir) {
692
692
  try {
@@ -1,4 +1,4 @@
1
- import { s as TegamiPlugin } from "../types-BbwOrNZ2.js";
1
+ import { s as TegamiPlugin } from "../types-C_vz41r2.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-BhMYq9iW.js";
1
+ import { n as execFailure, s as isCI } from "../error-CAsrGb6e.js";
2
2
  import { x } from "tinyexec";
3
3
  //#region src/plugins/git.ts
4
4
  /**
@@ -1,6 +1,6 @@
1
- import { A as WorkspacePackage, b as TegamiContext, s as TegamiPlugin, t as Awaitable, v as PublishPlan } from "../types-BbwOrNZ2.js";
1
+ import { A as WorkspacePackage, b as TegamiContext, s as TegamiPlugin, t as Awaitable, v as PublishPlan } from "../types-C_vz41r2.js";
2
2
  import { GitPluginOptions } from "./git.js";
3
- import { t as VersionRequestOptions } from "../version-request-C24d9RIW.js";
3
+ import { t as VersionRequestOptions } from "../version-request-DXk_B7O_.js";
4
4
 
5
5
  //#region src/plugins/github.d.ts
6
6
  interface GithubRelease {
@@ -1,9 +1,9 @@
1
1
  import { i as formatPackageVersion, r as formatNpmDistTag } from "../semver-EKJ8yK5U.js";
2
- import { t as changelogFilename } from "../generate-Bg86OJP4.js";
3
- import { a as cached, n as execFailure, o as isCI } from "../error-BhMYq9iW.js";
4
- import { a as createDraft, l as readChangelogEntries } from "../publish-v30y8Lwq.js";
2
+ import { t as changelogFilename } from "../generate-Cnd8RiKO.js";
3
+ import { 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";
5
5
  import { git } from "./git.js";
6
- import { t as onVersionRequest } from "../version-request-l6IJdFM6.js";
6
+ import { t as onVersionRequest } from "../version-request-DvWVAYj2.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";
@@ -33,12 +33,12 @@ async function releaseExistsByTag(repo, tag, token) {
33
33
  const { owner, repo: name } = parseGitHubRepo(repo);
34
34
  const response = await githubRequest(`/repos/${owner}/${name}/releases/tags/${encodeURIComponent(tag)}`, token, { method: "HEAD" });
35
35
  if (response.status === 404) return false;
36
- if (!response.ok) throw new Error(`Failed to get GitHub release for ${tag}.`);
36
+ if (!response.ok) throw await fetchFailure(`Failed to get GitHub release for ${tag}`, response);
37
37
  return true;
38
38
  }
39
39
  async function createRelease(repo, options) {
40
40
  const { owner, repo: name } = parseGitHubRepo(repo);
41
- if (!(await githubRequest(`/repos/${owner}/${name}/releases`, options.token, {
41
+ const response = await githubRequest(`/repos/${owner}/${name}/releases`, options.token, {
42
42
  method: "POST",
43
43
  headers: { "Content-Type": "application/json" },
44
44
  body: JSON.stringify({
@@ -47,7 +47,8 @@ async function createRelease(repo, options) {
47
47
  body: options.notes,
48
48
  prerelease: options.prerelease ?? false
49
49
  })
50
- })).ok) throw new Error(`Failed to create GitHub release for ${options.tag}.`);
50
+ });
51
+ if (!response.ok) throw await fetchFailure(`Failed to create GitHub release for ${options.tag}`, response);
51
52
  }
52
53
  async function findOpenPullRequest(repo, headBranch, token) {
53
54
  const { owner, repo: name } = parseGitHubRepo(repo);
@@ -55,23 +56,24 @@ async function findOpenPullRequest(repo, headBranch, token) {
55
56
  head: `${owner}:${headBranch}`,
56
57
  state: "open"
57
58
  })}`, token);
58
- if (!response.ok) throw new Error("Failed to check for an existing version pull request.");
59
+ if (!response.ok) throw await fetchFailure("Failed to check for an existing version pull request", response);
59
60
  return (await response.json())[0]?.number;
60
61
  }
61
62
  async function updatePullRequest(repo, number, options) {
62
63
  const { owner, repo: name } = parseGitHubRepo(repo);
63
- if (!(await githubRequest(`/repos/${owner}/${name}/pulls/${number}`, options.token, {
64
+ const response = await githubRequest(`/repos/${owner}/${name}/pulls/${number}`, options.token, {
64
65
  method: "PATCH",
65
66
  headers: { "Content-Type": "application/json" },
66
67
  body: JSON.stringify({
67
68
  title: options.title,
68
69
  body: options.body
69
70
  })
70
- })).ok) throw new Error("Failed to update the version pull request.");
71
+ });
72
+ if (!response.ok) throw await fetchFailure("Failed to update the version pull request", response);
71
73
  }
72
74
  async function createPullRequest(repo, options) {
73
75
  const { owner, repo: name } = parseGitHubRepo(repo);
74
- if (!(await githubRequest(`/repos/${owner}/${name}/pulls`, options.token, {
76
+ const response = await githubRequest(`/repos/${owner}/${name}/pulls`, options.token, {
75
77
  method: "POST",
76
78
  headers: { "Content-Type": "application/json" },
77
79
  body: JSON.stringify({
@@ -80,18 +82,19 @@ async function createPullRequest(repo, options) {
80
82
  head: options.head,
81
83
  base: options.base
82
84
  })
83
- })).ok) throw new Error("Failed to create the version pull request.");
85
+ });
86
+ if (!response.ok) throw await fetchFailure("Failed to create the version pull request", response);
84
87
  }
85
88
  async function listPullRequestsForCommit(repo, commitSha, token) {
86
89
  const { owner, repo: name } = parseGitHubRepo(repo);
87
90
  const response = await githubRequest(`/repos/${owner}/${name}/commits/${commitSha}/pulls`, token);
88
- if (!response.ok) throw new Error(`Failed to list pull requests for commit ${commitSha.slice(0, 7)}.`);
91
+ if (!response.ok) throw await fetchFailure(`Failed to list pull requests for commit ${commitSha.slice(0, 7)}`, response);
89
92
  return await response.json();
90
93
  }
91
94
  async function getPullRequest(repo, number, token) {
92
95
  const { owner, repo: name } = parseGitHubRepo(repo);
93
96
  const response = await githubRequest(`/repos/${owner}/${name}/pulls/${number}`, token);
94
- if (!response.ok) throw new Error(`Failed to resolve pull request #${number}.`);
97
+ if (!response.ok) throw await fetchFailure(`Failed to resolve pull request #${number}`, response);
95
98
  const data = await response.json();
96
99
  return {
97
100
  headRefName: data.head.ref,
@@ -105,7 +108,7 @@ async function findIssueCommentByPrefix(repo, issueNumber, prefix, token) {
105
108
  let page = 1;
106
109
  while (true) {
107
110
  const response = await githubRequest(`/repos/${owner}/${name}/issues/${issueNumber}/comments?per_page=100&page=${page}`, token);
108
- if (!response.ok) throw new Error("Failed to list pull request comments.");
111
+ if (!response.ok) throw await fetchFailure("Failed to list pull request comments", response);
109
112
  const batch = await response.json();
110
113
  if (batch.length === 0) break;
111
114
  const comment = batch.find((comment) => comment.body.startsWith(prefix));
@@ -116,19 +119,21 @@ async function findIssueCommentByPrefix(repo, issueNumber, prefix, token) {
116
119
  }
117
120
  async function updateIssueComment(repo, commentId, body, token) {
118
121
  const { owner, repo: name } = parseGitHubRepo(repo);
119
- if (!(await githubRequest(`/repos/${owner}/${name}/issues/comments/${commentId}`, token, {
122
+ const response = await githubRequest(`/repos/${owner}/${name}/issues/comments/${commentId}`, token, {
120
123
  method: "PATCH",
121
124
  headers: { "Content-Type": "application/json" },
122
125
  body: JSON.stringify({ body })
123
- })).ok) throw new Error("Failed to update pull request comment.");
126
+ });
127
+ if (!response.ok) throw await fetchFailure("Failed to update pull request comment", response);
124
128
  }
125
129
  async function createIssueComment(repo, issueNumber, body, token) {
126
130
  const { owner, repo: name } = parseGitHubRepo(repo);
127
- if (!(await githubRequest(`/repos/${owner}/${name}/issues/${issueNumber}/comments`, token, {
131
+ const response = await githubRequest(`/repos/${owner}/${name}/issues/${issueNumber}/comments`, token, {
128
132
  method: "POST",
129
133
  headers: { "Content-Type": "application/json" },
130
134
  body: JSON.stringify({ body })
131
- })).ok) throw new Error("Failed to create pull request comment.");
135
+ });
136
+ if (!response.ok) throw await fetchFailure("Failed to create pull request comment", response);
132
137
  }
133
138
  //#endregion
134
139
  //#region src/plugins/github/cli.ts
@@ -1,6 +1,6 @@
1
- import { A as WorkspacePackage, b as TegamiContext, s as TegamiPlugin, t as Awaitable, v as PublishPlan } from "../types-BbwOrNZ2.js";
1
+ import { A as WorkspacePackage, b as TegamiContext, s as TegamiPlugin, t as Awaitable, v as PublishPlan } from "../types-C_vz41r2.js";
2
2
  import { GitPluginOptions } from "./git.js";
3
- import { t as VersionRequestOptions } from "../version-request-C24d9RIW.js";
3
+ import { t as VersionRequestOptions } from "../version-request-DXk_B7O_.js";
4
4
 
5
5
  //#region src/plugins/gitlab.d.ts
6
6
  interface GitlabRelease {
@@ -1,9 +1,9 @@
1
1
  import { i as formatPackageVersion, r as formatNpmDistTag } from "../semver-EKJ8yK5U.js";
2
- import { t as changelogFilename } from "../generate-Bg86OJP4.js";
3
- import { a as cached, n as execFailure, o as isCI, s as joinPath } from "../error-BhMYq9iW.js";
4
- import { a as createDraft, l as readChangelogEntries } from "../publish-v30y8Lwq.js";
2
+ import { t as changelogFilename } from "../generate-Cnd8RiKO.js";
3
+ 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";
5
5
  import { git } from "./git.js";
6
- import { t as onVersionRequest } from "../version-request-l6IJdFM6.js";
6
+ import { t as onVersionRequest } from "../version-request-DvWVAYj2.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";
@@ -31,12 +31,12 @@ async function releaseExistsByTag(repo, tag, options = {}) {
31
31
  const { encodedProjectPath } = parseGitLabRepo(repo);
32
32
  const response = await gitlabRequest(options, `/projects/${encodedProjectPath}/releases/${encodeURIComponent(tag)}`, { method: "HEAD" });
33
33
  if (response.status === 404) return false;
34
- if (!response.ok) throw new Error(`Failed to get GitLab release for ${tag}.`);
34
+ if (!response.ok) throw await fetchFailure(`Failed to get GitLab release for ${tag}`, response);
35
35
  return true;
36
36
  }
37
37
  async function createRelease(repo, options) {
38
38
  const { encodedProjectPath } = parseGitLabRepo(repo);
39
- if (!(await gitlabRequest(options, `/projects/${encodedProjectPath}/releases`, {
39
+ const response = await gitlabRequest(options, `/projects/${encodedProjectPath}/releases`, {
40
40
  method: "POST",
41
41
  headers: { "Content-Type": "application/json" },
42
42
  body: JSON.stringify({
@@ -44,7 +44,8 @@ async function createRelease(repo, options) {
44
44
  name: options.title,
45
45
  description: options.notes
46
46
  })
47
- })).ok) throw new Error(`Failed to create GitLab release for ${options.tag}.`);
47
+ });
48
+ if (!response.ok) throw await fetchFailure(`Failed to create GitLab release for ${options.tag}`, response);
48
49
  }
49
50
  async function findOpenMergeRequest(repo, options) {
50
51
  const { encodedProjectPath } = parseGitLabRepo(repo);
@@ -54,12 +55,12 @@ async function findOpenMergeRequest(repo, options) {
54
55
  });
55
56
  if (options.base) params.set("target_branch", options.base);
56
57
  const response = await gitlabRequest(options, `/projects/${encodedProjectPath}/merge_requests?${params}`);
57
- if (!response.ok) throw new Error("Failed to check for an existing version merge request.");
58
+ if (!response.ok) throw await fetchFailure("Failed to check for an existing version merge request", response);
58
59
  return (await response.json())[0]?.iid;
59
60
  }
60
61
  async function updateMergeRequest(repo, number, options) {
61
62
  const { encodedProjectPath } = parseGitLabRepo(repo);
62
- if (!(await gitlabRequest(options, `/projects/${encodedProjectPath}/merge_requests/${number}`, {
63
+ const response = await gitlabRequest(options, `/projects/${encodedProjectPath}/merge_requests/${number}`, {
63
64
  method: "PUT",
64
65
  headers: { "Content-Type": "application/json" },
65
66
  body: JSON.stringify({
@@ -67,11 +68,12 @@ async function updateMergeRequest(repo, number, options) {
67
68
  description: options.body,
68
69
  target_branch: options.base
69
70
  })
70
- })).ok) throw new Error("Failed to update the version merge request.");
71
+ });
72
+ if (!response.ok) throw await fetchFailure("Failed to update the version merge request", response);
71
73
  }
72
74
  async function createMergeRequest(repo, options) {
73
75
  const { encodedProjectPath } = parseGitLabRepo(repo);
74
- if (!(await gitlabRequest(options, `/projects/${encodedProjectPath}/merge_requests`, {
76
+ const response = await gitlabRequest(options, `/projects/${encodedProjectPath}/merge_requests`, {
75
77
  method: "POST",
76
78
  headers: { "Content-Type": "application/json" },
77
79
  body: JSON.stringify({
@@ -80,12 +82,13 @@ async function createMergeRequest(repo, options) {
80
82
  source_branch: options.head,
81
83
  target_branch: options.base
82
84
  })
83
- })).ok) throw new Error("Failed to create the version merge request.");
85
+ });
86
+ if (!response.ok) throw await fetchFailure("Failed to create the version merge request", response);
84
87
  }
85
88
  async function getMergeRequest(repo, number, options = {}) {
86
89
  const { encodedProjectPath } = parseGitLabRepo(repo);
87
90
  const response = await gitlabRequest(options, `/projects/${encodedProjectPath}/merge_requests/${number}`);
88
- if (!response.ok) throw new Error(`Failed to resolve merge request !${number}.`);
91
+ if (!response.ok) throw await fetchFailure(`Failed to resolve merge request !${number}`, response);
89
92
  const data = await response.json();
90
93
  let sourceProjectPath;
91
94
  if (data.source_project_id !== void 0) {
@@ -102,7 +105,7 @@ async function getMergeRequest(repo, number, options = {}) {
102
105
  async function listMergeRequestsForCommit(repo, commitSha, options = {}) {
103
106
  const { encodedProjectPath } = parseGitLabRepo(repo);
104
107
  const response = await gitlabRequest(options, `/projects/${encodedProjectPath}/repository/commits/${commitSha}/merge_requests`);
105
- if (!response.ok) throw new Error(`Failed to list merge requests for commit ${commitSha.slice(0, 7)}.`);
108
+ if (!response.ok) throw await fetchFailure(`Failed to list merge requests for commit ${commitSha.slice(0, 7)}`, response);
106
109
  return (await response.json()).map((mergeRequest) => ({
107
110
  number: mergeRequest.iid,
108
111
  title: mergeRequest.title,
@@ -114,7 +117,7 @@ async function findMergeRequestCommentByPrefix(repo, mergeRequestNumber, prefix,
114
117
  let page = 1;
115
118
  while (true) {
116
119
  const response = await gitlabRequest(options, `/projects/${encodedProjectPath}/merge_requests/${mergeRequestNumber}/notes?per_page=100&page=${page}`);
117
- if (!response.ok) throw new Error("Failed to list merge request comments.");
120
+ if (!response.ok) throw await fetchFailure("Failed to list merge request comments", response);
118
121
  const batch = await response.json();
119
122
  if (batch.length === 0) break;
120
123
  const comment = batch.find((comment) => comment.body.startsWith(prefix));
@@ -125,19 +128,21 @@ async function findMergeRequestCommentByPrefix(repo, mergeRequestNumber, prefix,
125
128
  }
126
129
  async function updateMergeRequestComment(repo, mergeRequestNumber, commentId, body, options = {}) {
127
130
  const { encodedProjectPath } = parseGitLabRepo(repo);
128
- if (!(await gitlabRequest(options, `/projects/${encodedProjectPath}/merge_requests/${mergeRequestNumber}/notes/${commentId}`, {
131
+ const response = await gitlabRequest(options, `/projects/${encodedProjectPath}/merge_requests/${mergeRequestNumber}/notes/${commentId}`, {
129
132
  method: "PUT",
130
133
  headers: { "Content-Type": "application/json" },
131
134
  body: JSON.stringify({ body })
132
- })).ok) throw new Error("Failed to update merge request comment.");
135
+ });
136
+ if (!response.ok) throw await fetchFailure("Failed to update merge request comment", response);
133
137
  }
134
138
  async function createMergeRequestComment(repo, mergeRequestNumber, body, options = {}) {
135
139
  const { encodedProjectPath } = parseGitLabRepo(repo);
136
- if (!(await gitlabRequest(options, `/projects/${encodedProjectPath}/merge_requests/${mergeRequestNumber}/notes`, {
140
+ const response = await gitlabRequest(options, `/projects/${encodedProjectPath}/merge_requests/${mergeRequestNumber}/notes`, {
137
141
  method: "POST",
138
142
  headers: { "Content-Type": "application/json" },
139
143
  body: JSON.stringify({ body })
140
- })).ok) throw new Error("Failed to create merge request comment.");
144
+ });
145
+ if (!response.ok) throw await fetchFailure("Failed to create merge request comment", response);
141
146
  }
142
147
  //#endregion
143
148
  //#region src/plugins/gitlab/cli.ts
@@ -1,4 +1,4 @@
1
- import { A as WorkspacePackage, P as BumpType, s as TegamiPlugin } from "../types-BbwOrNZ2.js";
1
+ import { A as WorkspacePackage, P as BumpType, s as TegamiPlugin } from "../types-C_vz41r2.js";
2
2
 
3
3
  //#region src/plugins/go.d.ts
4
4
  interface GoModFile {
@@ -1,4 +1,4 @@
1
- import { i as isNodeError, n as execFailure } from "../error-BhMYq9iW.js";
1
+ import { a as isNodeError, n as execFailure, r as fetchFailure } from "../error-CAsrGb6e.js";
2
2
  import { n as _validateReport, t as _createStandardSchema } from "../_createStandardSchema-BGQyz-uA.js";
3
3
  import { n as WorkspacePackage } from "../graph-BmXTJZxx.js";
4
4
  import { relative, resolve } from "node:path";
@@ -524,7 +524,7 @@ async function isModulePublished(module, version) {
524
524
  const response = await fetch(`https://proxy.golang.org/${encodeURIComponent(module)}/@v/${formatted}.info`);
525
525
  if (response.status === 200) return true;
526
526
  if (response.status === 404) return false;
527
- throw new Error(`Unable to validate ${module}@${formatted} against proxy.golang.org: ${await response.text()}`);
527
+ throw await fetchFailure(`Unable to validate ${module}@${formatted} against proxy.golang.org`, response);
528
528
  }
529
529
  //#endregion
530
530
  export { GoPackage, go };
@@ -1,2 +1,2 @@
1
- import { C as NpmPackage, S as NpmGraph, l as NpmPluginOptions, u as npm, x as DependencySpec } from "../types-BbwOrNZ2.js";
1
+ import { C as NpmPackage, S as NpmGraph, l as NpmPluginOptions, u as npm, x as DependencySpec } from "../types-C_vz41r2.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-DaUHTtlV.js";
1
+ import { n as NpmPackage, t as npm } from "../npm-cS-D2xGI.js";
2
2
  export { NpmPackage, npm };
@@ -1,5 +1,5 @@
1
1
  import { a as maxBump } from "./semver-EKJ8yK5U.js";
2
- import { c as somePromise, r as handlePluginError } from "./error-BhMYq9iW.js";
2
+ import { i as handlePluginError, l as somePromise } from "./error-CAsrGb6e.js";
3
3
  import { t as _accessExpressionAsString } from "./_accessExpressionAsString-QhbUZzwv.js";
4
4
  import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-BGQyz-uA.js";
5
5
  import { n as validateChangelogFrontmatter, t as renderChangelog } from "./shared-C_iSTp_s.js";
@@ -1,4 +1,4 @@
1
- import { AgentName } from "package-manager-detector";
1
+ import { Agent, AgentName } from "package-manager-detector";
2
2
 
3
3
  //#region src/utils/semver.d.ts
4
4
  type BumpType = "major" | "minor" | "patch";
@@ -523,6 +523,7 @@ interface TegamiContext {
523
523
  };
524
524
  /** additional context when npm plugin is configured */
525
525
  npm?: {
526
+ agent: Agent;
526
527
  client: AgentName; /** available after resolve */
527
528
  graph?: NpmGraph;
528
529
  };
@@ -2,9 +2,10 @@ import { Result } from "tinyexec";
2
2
 
3
3
  //#region src/utils/error.d.ts
4
4
  declare function execFailure(context: string, result: Awaited<Result>): Error;
5
+ declare function fetchFailure(context: string, response: Response): Promise<Error>;
5
6
  //#endregion
6
7
  //#region src/utils/common.d.ts
7
8
  declare const isCI: () => boolean;
8
9
  declare function joinPath(...paths: string[]): string;
9
10
  //#endregion
10
- export { execFailure, isCI, joinPath };
11
+ export { execFailure, fetchFailure, isCI, joinPath };
@@ -1,2 +1,2 @@
1
- import { n as execFailure, o as isCI, s as joinPath } from "../error-BhMYq9iW.js";
2
- export { execFailure, isCI, joinPath };
1
+ import { c as joinPath, n as execFailure, r as fetchFailure, s as isCI } from "../error-CAsrGb6e.js";
2
+ export { execFailure, fetchFailure, isCI, joinPath };
@@ -1,4 +1,4 @@
1
- import { b as TegamiContext, j as Draft, t as Awaitable, v as PublishPlan } from "./types-BbwOrNZ2.js";
1
+ import { b as TegamiContext, j as Draft, m as PublishLock, t as Awaitable, v as PublishPlan } from "./types-C_vz41r2.js";
2
2
 
3
3
  //#region src/utils/version-request.d.ts
4
4
  interface VersionRequestOptions {
@@ -27,6 +27,17 @@ interface VersionRequestOptions {
27
27
  title?: string;
28
28
  body?: string;
29
29
  }>;
30
+ /** Override commit summary & message. */
31
+ commit?: (this: TegamiContext, opts: {
32
+ type: "version-packages";
33
+ } | {
34
+ type: "update-lock";
35
+ store: PublishGroupStore;
36
+ updatedLock: PublishLock;
37
+ }) => Awaitable<{
38
+ title?: string;
39
+ body?: string;
40
+ } | undefined>;
30
41
  }
31
42
  interface VersionRequestContext {
32
43
  draft: Draft;
@@ -35,5 +46,12 @@ interface VersionRequestContext {
35
46
  getPreviousVersion(packageId: string): string | undefined;
36
47
  }
37
48
  /** adapter over the version request API of a git provider */
49
+ interface PublishGroupStore {
50
+ /**
51
+ * - active: groups whose version request was merged, they stay listed until the lock is removed
52
+ * - pending: groups still waiting for their version request to be merged
53
+ */
54
+ groups: Record<string, "pending" | "active">;
55
+ }
38
56
  //#endregion
39
57
  export { VersionRequestOptions as t };
@@ -1,8 +1,8 @@
1
1
  import { r as formatNpmDistTag } from "./semver-EKJ8yK5U.js";
2
- import { n as execFailure, o as isCI } from "./error-BhMYq9iW.js";
2
+ import { n as execFailure, s as isCI } from "./error-CAsrGb6e.js";
3
3
  import { t as _accessExpressionAsString } from "./_accessExpressionAsString-QhbUZzwv.js";
4
4
  import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-BGQyz-uA.js";
5
- import { o as PublishLock, r as runPreflights, s as parsePublishLock, t as initPublishPlan } from "./publish-v30y8Lwq.js";
5
+ import { o as PublishLock, r as runPreflights, s as parsePublishLock, t as initPublishPlan } from "./publish-Bt3e1RPs.js";
6
6
  import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
7
7
  import { join, relative } from "node:path";
8
8
  import { x } from "tinyexec";
@@ -71,7 +71,7 @@ function onVersionRequest(provider) {
71
71
  const snapshots = /* @__PURE__ */ new Map();
72
72
  function resolveConfig(graph) {
73
73
  if (provider.options === false) return;
74
- const { forceCreate = false, branch = "tegami/version-packages", base = "main", groups, create } = provider.options ?? {};
74
+ const { forceCreate = false, branch = "tegami/version-packages", base = "main", groups, ...rest } = provider.options ?? {};
75
75
  const groupMap = /* @__PURE__ */ new Map();
76
76
  if (groups?.length) {
77
77
  const unlistedPackages = /* @__PURE__ */ new Set();
@@ -90,7 +90,7 @@ function onVersionRequest(provider) {
90
90
  branch,
91
91
  base,
92
92
  groupMap,
93
- create
93
+ ...rest
94
94
  };
95
95
  }
96
96
  /**
@@ -98,16 +98,16 @@ function onVersionRequest(provider) {
98
98
  *
99
99
  * Returns `true` and skips the push when the branch on `remote` already matches.
100
100
  */
101
- async function syncGroupBranch(context, baseLock, opts) {
102
- const lock = new PublishLock(baseLock);
101
+ async function syncGroupBranch(context, opts) {
102
+ const lock = new PublishLock(opts.baseLock);
103
103
  while (lock.read(namespace));
104
104
  lock.write(namespace, opts.store);
105
- const commit = await createLockCommit(context, {
106
- parent: opts.parent,
107
- content: lock.serialize(),
108
- message: "Update Lock"
109
- });
110
- if (opts.remote?.get(opts.branch) === commit) return true;
105
+ const commit = await createLockCommit(context, opts.parent, lock.serialize(), await opts.config.commit?.call(context, {
106
+ type: "update-lock",
107
+ store: opts.store,
108
+ updatedLock: lock
109
+ }));
110
+ if (opts.remote && opts.remote.get(opts.branch) === commit) return true;
111
111
  await run(context.cwd, [
112
112
  "push",
113
113
  "--force",
@@ -151,7 +151,7 @@ function onVersionRequest(provider) {
151
151
  packages: Array.from(updatedPackages.values())
152
152
  });
153
153
  if (requests.length === 0) return;
154
- await createVersionCommit(this.cwd, "Version Packages");
154
+ await createVersionCommit(this.cwd, await config.commit?.call(this, { type: "version-packages" }));
155
155
  let baseLock;
156
156
  let parent;
157
157
  const tasks = [];
@@ -173,7 +173,9 @@ function onVersionRequest(provider) {
173
173
  if (!req.publishGroup) continue;
174
174
  newGroups[req.publishGroup] = req.publishGroup !== publishGroup ? "pending" : "active";
175
175
  }
176
- const inSync = await syncGroupBranch(this, baseLock, {
176
+ const inSync = await syncGroupBranch(this, {
177
+ baseLock,
178
+ config,
177
179
  branch,
178
180
  parent,
179
181
  store: { groups: newGroups }
@@ -246,10 +248,12 @@ function onVersionRequest(provider) {
246
248
  for (const id of pending) {
247
249
  const newGroups = Object.fromEntries(publishGroups.entries());
248
250
  newGroups[id] = "active";
249
- await syncGroupBranch(this, baseLock, {
251
+ await syncGroupBranch(this, {
250
252
  branch: `${config.branch}/${id}`,
253
+ baseLock,
251
254
  parent,
252
255
  remote,
256
+ config,
253
257
  store: { groups: newGroups }
254
258
  });
255
259
  }
@@ -301,12 +305,12 @@ function renderRequestBody(ctx, { draft, getPreviousVersion, plan }) {
301
305
  * working tree. Commit dates are pinned to the parent, so unchanged content always produces
302
306
  * the exact same commit.
303
307
  */
304
- async function createLockCommit(context, opts) {
308
+ async function createLockCommit(context, parent, content, commit = {}) {
305
309
  const { cwd } = context;
306
310
  const dir = await mkdtemp(join(tmpdir(), "tegami-"));
307
311
  try {
308
312
  const blobFile = join(dir, "lock");
309
- await writeFile(blobFile, opts.content);
313
+ await writeFile(blobFile, content);
310
314
  const blob = await run(cwd, [
311
315
  "hash-object",
312
316
  "-w",
@@ -317,24 +321,26 @@ async function createLockCommit(context, opts) {
317
321
  ...process.env,
318
322
  GIT_INDEX_FILE: join(dir, "index")
319
323
  };
320
- await run(cwd, ["read-tree", opts.parent.commit], "Failed to read the current git tree.", env);
324
+ await run(cwd, ["read-tree", parent.commit], "Failed to read the current git tree.", env);
321
325
  await run(cwd, [
322
326
  "update-index",
323
327
  "--add",
324
328
  "--cacheinfo",
325
329
  `100644,${blob},${path}`
326
330
  ], "Failed to update the lock file entry.", env);
327
- return await run(cwd, [
331
+ const args = [
328
332
  "commit-tree",
329
333
  await run(cwd, ["write-tree"], "Failed to write the updated git tree.", env),
330
334
  "-p",
331
- opts.parent.commit,
335
+ parent.commit,
332
336
  "-m",
333
- opts.message
334
- ], "Failed to commit the lock file update.", {
337
+ commit.title ?? "Update lock file"
338
+ ];
339
+ if (commit.body) args.push("-m", commit.body);
340
+ return await run(cwd, args, "Failed to commit the lock file update.", {
335
341
  ...env,
336
- GIT_AUTHOR_DATE: opts.parent.date,
337
- GIT_COMMITTER_DATE: opts.parent.date
342
+ GIT_AUTHOR_DATE: parent.date,
343
+ GIT_COMMITTER_DATE: parent.date
338
344
  });
339
345
  } finally {
340
346
  await rm(dir, {
@@ -375,14 +381,16 @@ async function hasGitChanges(cwd) {
375
381
  return (await run(cwd, ["status", "--porcelain"], "Failed to check git status.")).length > 0;
376
382
  }
377
383
  /** commit the working tree changes onto a detached HEAD */
378
- async function createVersionCommit(cwd, title) {
384
+ async function createVersionCommit(cwd, { title = "Version Packages", body } = {}) {
379
385
  await run(cwd, ["checkout", "--detach"], "Failed to detach HEAD for version branches.");
380
386
  await run(cwd, ["add", "-A"], "Failed to stage version changes.");
381
- await run(cwd, [
387
+ const args = [
382
388
  "commit",
383
389
  "-m",
384
390
  title
385
- ], "Failed to commit version changes.");
391
+ ];
392
+ if (body) args.push("-m", body);
393
+ await run(cwd, args, "Failed to commit version changes.");
386
394
  }
387
395
  async function pushBranch(cwd, branch) {
388
396
  await run(cwd, [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tegami",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "A tool to manage changelogs, versioning, and publishing in monorepo",
5
5
  "license": "MIT",
6
6
  "author": "Fuma Nama",