tegami 0.1.0-beta.3 → 0.1.0-beta.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.
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +173 -58
- package/dist/generators/simple.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +47 -23
- package/dist/plugins/git.d.ts +1 -1
- package/dist/plugins/git.js +1 -1
- package/dist/plugins/github.d.ts +1 -1
- package/dist/plugins/github.js +1 -1
- package/dist/providers/cargo.d.ts +1 -1
- package/dist/providers/npm.d.ts +1 -1
- package/dist/{types-CrA7ZKxb.d.ts → types-Cx-uvEWw.d.ts} +8 -3
- package/package.json +1 -1
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as PublishResult, O as DraftPlan, _ as Tegami, t as Awaitable } from "../types-
|
|
1
|
+
import { C as PublishResult, O as DraftPlan, _ as Tegami, t as Awaitable } from "../types-Cx-uvEWw.js";
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
|
|
4
4
|
//#region src/cli/index.d.ts
|
package/dist/cli/index.js
CHANGED
|
@@ -2,13 +2,14 @@ import { a as changelogFilename, t as assertPublishPlanFinished } from "../check
|
|
|
2
2
|
import { n as handlePluginError } from "../error-DBK-9uBa.js";
|
|
3
3
|
import { r as formatNpmDistTag, t as bumpDepth } from "../semver-CPtl0XNq.js";
|
|
4
4
|
import { t as isCI } from "../constants-B9qjNfvr.js";
|
|
5
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
6
|
-
import path, { basename, isAbsolute, join, normalize, relative } from "node:path";
|
|
5
|
+
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
6
|
+
import path, { basename, isAbsolute, join, normalize, relative, resolve } from "node:path";
|
|
7
7
|
import { x } from "tinyexec";
|
|
8
8
|
import { dump } from "js-yaml";
|
|
9
9
|
import { detect, resolveCommand } from "package-manager-detector";
|
|
10
10
|
import { autocompleteMultiselect, confirm, intro, isCancel, multiline, note, outro, select, spinner } from "@clack/prompts";
|
|
11
|
-
import { Command } from "commander";
|
|
11
|
+
import { Command, InvalidArgumentError } from "commander";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
12
13
|
//#region src/cli/init-agent.ts
|
|
13
14
|
const CHANGELOG_DOCS_URL$1 = "https://tegami.fuma-nama.dev/changelog";
|
|
14
15
|
async function initAgent(context, options = {}) {
|
|
@@ -80,32 +81,38 @@ async function formatRunScriptCommand(cwd, script, agent) {
|
|
|
80
81
|
return [resolved.command, ...resolved.args].join(" ");
|
|
81
82
|
}
|
|
82
83
|
//#endregion
|
|
83
|
-
//#region src/cli/
|
|
84
|
+
//#region src/cli/pr.ts
|
|
84
85
|
const TEGAMI_DOCS_URL = "https://tegami.fuma-nama.dev";
|
|
85
86
|
const CHANGELOG_DOCS_URL = `${TEGAMI_DOCS_URL}/changelog`;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
prChangelogFiles: event && !options.branch ? await getPullRequestChangelogFiles(context, event.baseSha, event.headSha) : [],
|
|
92
|
-
tegamiCommand: await formatRunScriptCommand(context.cwd, "tegami", context.options.npm?.client)
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
function renderCiPrPreview(context, draft, options = {}) {
|
|
87
|
+
const COMMENT_MARKER = "<!-- tegami -->";
|
|
88
|
+
async function buildPrPreview(context, draft, options = {}) {
|
|
89
|
+
const pullRequest = await resolvePullRequest(context, options);
|
|
90
|
+
const tegamiCommand = await formatRunScriptCommand(context.cwd, "tegami", context.options.npm?.client);
|
|
91
|
+
const prChangelogFiles = await listPullRequestChangelogFiles(context, pullRequest.baseSha, pullRequest.headSha);
|
|
96
92
|
const changelogDir = relative(context.cwd, context.changelogDir) || ".tegami";
|
|
97
|
-
const
|
|
98
|
-
const createLink = options.repo && options.branch ? createChangelogUrl(options.repo, options.branch, changelogDir, changelogFilename()) : void 0;
|
|
93
|
+
const createLink = createChangelogUrl(pullRequest.headRepo, pullRequest.headRef, changelogDir, changelogFilename());
|
|
99
94
|
const lines = [
|
|
100
95
|
"### Tegami",
|
|
101
96
|
"",
|
|
102
97
|
`This repository uses [Tegami](${TEGAMI_DOCS_URL}) to manage releases. When your changes affect published packages, add a changelog file under \`.tegami/\` before merging.`,
|
|
98
|
+
"",
|
|
99
|
+
`[**Create a changelog →**](${createLink}) · [Changelog format](${CHANGELOG_DOCS_URL})`,
|
|
103
100
|
""
|
|
104
101
|
];
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
102
|
+
const pendingPackages = [];
|
|
103
|
+
for (const pkg of context.graph.getPackages()) {
|
|
104
|
+
const plan = draft.getPackagePlan(pkg.id);
|
|
105
|
+
if (!plan?.type) continue;
|
|
106
|
+
pendingPackages.push({
|
|
107
|
+
name: pkg.name,
|
|
108
|
+
type: plan.type,
|
|
109
|
+
from: pkg.version,
|
|
110
|
+
to: plan.bumpVersion(pkg),
|
|
111
|
+
distTag: plan.npm?.distTag,
|
|
112
|
+
publish: plan.publish ?? false
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const prChangelogs = draft.getChangelogs().filter((entry) => prChangelogFiles.has(entry.filename));
|
|
109
116
|
if (pendingPackages.length > 0) {
|
|
110
117
|
lines.push("#### Release preview", "", "| Package | Bump | Version |", "| --- | --- | --- |");
|
|
111
118
|
for (const { name, type, from, to, distTag, publish } of pendingPackages) {
|
|
@@ -122,11 +129,109 @@ function renderCiPrPreview(context, draft, options = {}) {
|
|
|
122
129
|
}
|
|
123
130
|
lines.push("");
|
|
124
131
|
} else if (pendingPackages.length === 0) lines.push("#### No changelogs yet", "", "This PR has no pending changelog files. If your changes require a release, add a changelog before merging.", "");
|
|
125
|
-
else if (
|
|
132
|
+
else if (prChangelogFiles.size === 0) lines.push("This PR does not add changelog files. Pending changelogs from other branches are included in the preview above.", "");
|
|
126
133
|
lines.push(`Run \`${tegamiCommand}\` locally to create a changelog interactively.`, "", `<sub>Managed by [Tegami](${TEGAMI_DOCS_URL}).</sub>`, "");
|
|
127
134
|
return lines.join("\n");
|
|
128
135
|
}
|
|
129
|
-
async function
|
|
136
|
+
async function postPrComment(body) {
|
|
137
|
+
const repo = process.env.GITHUB_REPOSITORY;
|
|
138
|
+
if (!repo) throw new Error("GITHUB_REPOSITORY is required.");
|
|
139
|
+
const number = await readPullRequestNumberFromWorkflowRunEvent();
|
|
140
|
+
const markedBody = `${COMMENT_MARKER}\n${body}`;
|
|
141
|
+
const listResult = await x("gh", [
|
|
142
|
+
"api",
|
|
143
|
+
`repos/${repo}/issues/${number}/comments`,
|
|
144
|
+
"--paginate",
|
|
145
|
+
"--jq",
|
|
146
|
+
`[.[] | select(.body | startswith("${COMMENT_MARKER}")) | .id][0] // empty`
|
|
147
|
+
]);
|
|
148
|
+
if (listResult.exitCode !== 0) throw new Error(listResult.stderr || "Failed to list pull request comments.");
|
|
149
|
+
const existingId = listResult.stdout.trim();
|
|
150
|
+
if (existingId) {
|
|
151
|
+
const dir = await mkdtemp(join(tmpdir(), "tegami-pr-comment-"));
|
|
152
|
+
const inputPath = join(dir, "body.json");
|
|
153
|
+
try {
|
|
154
|
+
await writeFile(inputPath, JSON.stringify({ body: markedBody }));
|
|
155
|
+
const updateResult = await x("gh", [
|
|
156
|
+
"api",
|
|
157
|
+
"-X",
|
|
158
|
+
"PATCH",
|
|
159
|
+
`repos/${repo}/issues/comments/${existingId}`,
|
|
160
|
+
"--input",
|
|
161
|
+
inputPath
|
|
162
|
+
]);
|
|
163
|
+
if (updateResult.exitCode !== 0) throw new Error(updateResult.stderr || "Failed to update pull request comment.");
|
|
164
|
+
} finally {
|
|
165
|
+
await rm(dir, {
|
|
166
|
+
recursive: true,
|
|
167
|
+
force: true
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const createResult = await x("gh", [
|
|
173
|
+
"pr",
|
|
174
|
+
"comment",
|
|
175
|
+
String(number),
|
|
176
|
+
"--body",
|
|
177
|
+
markedBody,
|
|
178
|
+
"--repo",
|
|
179
|
+
repo
|
|
180
|
+
]);
|
|
181
|
+
if (createResult.exitCode !== 0) throw new Error(createResult.stderr || "Failed to create pull request comment.");
|
|
182
|
+
}
|
|
183
|
+
async function readPullRequestNumberFromWorkflowRunEvent() {
|
|
184
|
+
const eventPath = process.env.GITHUB_EVENT_PATH;
|
|
185
|
+
if (!eventPath) throw new Error("GITHUB_EVENT_PATH is required.");
|
|
186
|
+
let event;
|
|
187
|
+
try {
|
|
188
|
+
event = JSON.parse(await readFile(eventPath, "utf8"));
|
|
189
|
+
} catch {
|
|
190
|
+
throw new Error("Failed to read workflow_run event.");
|
|
191
|
+
}
|
|
192
|
+
const workflowRun = event.workflow_run;
|
|
193
|
+
if (!workflowRun) throw new Error("A workflow_run event is required.");
|
|
194
|
+
if (workflowRun.event !== "pull_request") throw new Error("The preview workflow was not triggered by a pull request.");
|
|
195
|
+
if (workflowRun.conclusion !== "success") throw new Error("The preview workflow did not complete successfully.");
|
|
196
|
+
const number = workflowRun.pull_requests?.[0]?.number;
|
|
197
|
+
if (!Number.isInteger(number) || !number || number <= 0) throw new Error("The preview workflow is not associated with a pull request.");
|
|
198
|
+
return number;
|
|
199
|
+
}
|
|
200
|
+
async function resolvePullRequest(context, options) {
|
|
201
|
+
const repo = context.github?.repo ?? process.env.GITHUB_REPOSITORY;
|
|
202
|
+
if (!repo) throw new Error("GITHUB_REPOSITORY is required.");
|
|
203
|
+
if (options.number !== void 0) {
|
|
204
|
+
if (!Number.isInteger(options.number) || options.number <= 0) throw new Error("--number must be a positive integer.");
|
|
205
|
+
return readPullRequestFromGh(repo, options.number);
|
|
206
|
+
}
|
|
207
|
+
const event = await readPullRequestEvent();
|
|
208
|
+
if (event) return {
|
|
209
|
+
repo,
|
|
210
|
+
...event
|
|
211
|
+
};
|
|
212
|
+
throw new Error("A pull request event or --number is required.");
|
|
213
|
+
}
|
|
214
|
+
async function readPullRequestFromGh(repo, number) {
|
|
215
|
+
const result = await x("gh", [
|
|
216
|
+
"pr",
|
|
217
|
+
"view",
|
|
218
|
+
String(number),
|
|
219
|
+
"--repo",
|
|
220
|
+
repo,
|
|
221
|
+
"--json",
|
|
222
|
+
"headRefName,baseRefOid,headRefOid,headRepository"
|
|
223
|
+
]);
|
|
224
|
+
if (result.exitCode !== 0) throw new Error(result.stderr || `Failed to resolve pull request #${number}.`);
|
|
225
|
+
const data = JSON.parse(result.stdout);
|
|
226
|
+
return {
|
|
227
|
+
repo,
|
|
228
|
+
headRepo: data.headRepository ? `${data.headRepository.owner.login}/${data.headRepository.name}` : repo,
|
|
229
|
+
headRef: data.headRefName,
|
|
230
|
+
baseSha: data.baseRefOid,
|
|
231
|
+
headSha: data.headRefOid
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
async function readPullRequestEvent() {
|
|
130
235
|
const eventPath = process.env.GITHUB_EVENT_PATH;
|
|
131
236
|
if (!eventPath) return;
|
|
132
237
|
let event;
|
|
@@ -138,45 +243,32 @@ async function resolvePullRequestEvent() {
|
|
|
138
243
|
const pullRequest = event.pull_request;
|
|
139
244
|
if (!pullRequest) return;
|
|
140
245
|
return {
|
|
141
|
-
|
|
246
|
+
headRepo: pullRequest.head.repo.full_name,
|
|
142
247
|
headRef: pullRequest.head.ref,
|
|
143
248
|
baseSha: pullRequest.base.sha,
|
|
144
249
|
headSha: pullRequest.head.sha
|
|
145
250
|
};
|
|
146
251
|
}
|
|
147
|
-
async function
|
|
252
|
+
async function listPullRequestChangelogFiles(context, baseSha, headSha) {
|
|
148
253
|
const dir = relative(context.cwd, context.changelogDir);
|
|
149
254
|
const result = await x("git", [
|
|
150
255
|
"diff",
|
|
151
256
|
"--name-only",
|
|
152
|
-
"--diff-filter=
|
|
257
|
+
"--diff-filter=ACMRD",
|
|
153
258
|
`${baseSha}...${headSha}`,
|
|
154
259
|
"--",
|
|
155
260
|
`${dir}/`
|
|
156
261
|
], { nodeOptions: { cwd: context.cwd } });
|
|
157
|
-
if (result.exitCode !== 0)
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
function getPendingPackages(context, draft) {
|
|
161
|
-
const packages = [];
|
|
162
|
-
for (const pkg of context.graph.getPackages()) {
|
|
163
|
-
const plan = draft.getPackagePlan(pkg.id);
|
|
164
|
-
if (!plan?.type) continue;
|
|
165
|
-
packages.push({
|
|
166
|
-
name: pkg.name,
|
|
167
|
-
type: plan.type,
|
|
168
|
-
from: pkg.version,
|
|
169
|
-
to: plan.bumpVersion(pkg),
|
|
170
|
-
distTag: plan.npm?.distTag,
|
|
171
|
-
publish: plan.publish ?? false
|
|
172
|
-
});
|
|
262
|
+
if (result.exitCode !== 0) {
|
|
263
|
+
const detail = result.stderr.trim();
|
|
264
|
+
throw new Error(detail ? `Failed to list pull request changelog files: ${detail}` : "Failed to list pull request changelog files.");
|
|
173
265
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return
|
|
266
|
+
const files = /* @__PURE__ */ new Set();
|
|
267
|
+
for (const line of result.stdout.split("\n")) {
|
|
268
|
+
const trimmed = line.trim();
|
|
269
|
+
if (trimmed.endsWith(".md")) files.add(basename(trimmed));
|
|
270
|
+
}
|
|
271
|
+
return files;
|
|
180
272
|
}
|
|
181
273
|
function createChangelogUrl(repo, branch, changelogDir, filename) {
|
|
182
274
|
const segments = [...changelogDir.split("/").filter(Boolean), filename].map((part) => encodeURIComponent(part));
|
|
@@ -241,7 +333,40 @@ function createCli(tegami, options = {}) {
|
|
|
241
333
|
if (await versionPackages(tegami, { cli: options })) return;
|
|
242
334
|
await publishPackages(tegami, { cli: options });
|
|
243
335
|
}));
|
|
244
|
-
program.command("
|
|
336
|
+
const programPr = program.command("pr");
|
|
337
|
+
programPr.command("preview").description("(should be executed in a GitHub action) show a pull request release preview and changelog guidance").option("--artifact <path>", "write preview markdown to a file").option("--number <number>", "pull request number", (value) => {
|
|
338
|
+
const number = Number(value);
|
|
339
|
+
if (!Number.isInteger(number) || number <= 0) throw new InvalidArgumentError("--number must be a positive integer.");
|
|
340
|
+
return number;
|
|
341
|
+
}).action((commandOptions) => runAction(tegami, async () => {
|
|
342
|
+
const context = await tegami._internal.context();
|
|
343
|
+
const body = await buildPrPreview(context, await tegami.draft(), commandOptions);
|
|
344
|
+
if (commandOptions.artifact) {
|
|
345
|
+
const artifactPath = resolve(context.cwd, commandOptions.artifact);
|
|
346
|
+
await writeFile(artifactPath, body);
|
|
347
|
+
if (!isCI()) {
|
|
348
|
+
note(relative(context.cwd, artifactPath) || commandOptions.artifact, "Release preview");
|
|
349
|
+
outro("Release preview ready.");
|
|
350
|
+
}
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (isCI()) {
|
|
354
|
+
process.stdout.write(`${body}\n`);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
note(body, "Release preview");
|
|
358
|
+
outro("Release preview ready.");
|
|
359
|
+
}));
|
|
360
|
+
programPr.command("comment").description("(should be used with 'pr preview') post the pull request release preview as a comment").argument("<artifact>", "the file path of GitHub artifact").action(async (artifact) => {
|
|
361
|
+
try {
|
|
362
|
+
await postPrComment(await readFile(artifact, "utf8"));
|
|
363
|
+
outro("Pull request comment updated.");
|
|
364
|
+
} catch (error) {
|
|
365
|
+
note(error instanceof Error ? error.message : String(error), "Error");
|
|
366
|
+
outro("Command failed.");
|
|
367
|
+
process.exit(1);
|
|
368
|
+
}
|
|
369
|
+
});
|
|
245
370
|
program.command("publish").description("publish packages from the applied publish plan").option("--dry-run", "validate the publish plan without publishing packages").action((commandOptions) => runAction(tegami, async () => {
|
|
246
371
|
await publishPackages(tegami, {
|
|
247
372
|
...commandOptions,
|
|
@@ -411,16 +536,6 @@ async function publishPackages(tegami, options) {
|
|
|
411
536
|
outro(dryRun ? "Publish plan is valid." : "Packages published.");
|
|
412
537
|
return true;
|
|
413
538
|
}
|
|
414
|
-
async function runCiPrCommand(tegami, options) {
|
|
415
|
-
const body = await runCiPr(await tegami._internal.context(), await tegami.draft(), options);
|
|
416
|
-
if (options.print) {
|
|
417
|
-
process.stdout.write(`${body}\n`);
|
|
418
|
-
if (!isCI()) outro("Release preview ready.");
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
note(body, "Release preview");
|
|
422
|
-
outro("Release preview ready.");
|
|
423
|
-
}
|
|
424
539
|
async function runInitAgent(tegami, options) {
|
|
425
540
|
intro("Init agent instructions");
|
|
426
541
|
const context = await tegami._internal.context();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as PublishResult, D as WorkspacePackage, E as PackageGroup, O as DraftPlan, S as PublishOptions, T as PackageGraph, _ as Tegami, a as RegistryClient, b as CreatedChangelog, c as TegamiPluginOption, i as PackageOptions, k as PackagePlan, n as GroupOptions, o as TegamiOptions, r as LogGenerator, s as TegamiPlugin, v as tegami, x as PackagePublishResult, y as CreateChangelogOptions } from "./types-
|
|
1
|
+
import { C as PublishResult, D as WorkspacePackage, E as PackageGroup, O as DraftPlan, S as PublishOptions, T as PackageGraph, _ as Tegami, a as RegistryClient, b as CreatedChangelog, c as TegamiPluginOption, i as PackageOptions, k as PackagePlan, n as GroupOptions, o as TegamiOptions, r as LogGenerator, s as TegamiPlugin, v as tegami, x as PackagePublishResult, y as CreateChangelogOptions } from "./types-Cx-uvEWw.js";
|
|
2
2
|
export { type CreateChangelogOptions, type CreatedChangelog, type DraftPlan, type GroupOptions, type LogGenerator, type PackageGraph, type PackageGroup, type PackageOptions, type PackagePlan, type PackagePublishResult, type PublishOptions, type PublishResult, type RegistryClient, Tegami, type TegamiOptions, type TegamiPlugin, type TegamiPluginOption, type WorkspacePackage, tegami };
|
package/dist/index.js
CHANGED
|
@@ -440,7 +440,7 @@ function parseChangelogFile(file, content) {
|
|
|
440
440
|
if (sectionBumpType) bumpType = bumpType ? maxBump(bumpType, sectionBumpType) : sectionBumpType;
|
|
441
441
|
sections.push({
|
|
442
442
|
depth: section.heading.depth,
|
|
443
|
-
title:
|
|
443
|
+
title: sectionToMarkdown(section.heading.children),
|
|
444
444
|
content: sectionToMarkdown(section.children)
|
|
445
445
|
});
|
|
446
446
|
}
|
|
@@ -471,14 +471,6 @@ function getHeadingSections(tree) {
|
|
|
471
471
|
}
|
|
472
472
|
return sections;
|
|
473
473
|
}
|
|
474
|
-
function headingText(heading) {
|
|
475
|
-
return heading.children.map((child) => nodeText(child)).join("").trim();
|
|
476
|
-
}
|
|
477
|
-
function nodeText(node) {
|
|
478
|
-
if ("value" in node && typeof node.value === "string") return node.value;
|
|
479
|
-
if ("children" in node && Array.isArray(node.children)) return node.children.map((child) => nodeText(child)).join("");
|
|
480
|
-
return "";
|
|
481
|
-
}
|
|
482
474
|
function sectionToMarkdown(children) {
|
|
483
475
|
if (children.length === 0) return "";
|
|
484
476
|
return toMarkdown({
|
|
@@ -490,9 +482,11 @@ function sectionToMarkdown(children) {
|
|
|
490
482
|
}).trim();
|
|
491
483
|
}
|
|
492
484
|
function headingToBump(depth) {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
485
|
+
switch (depth) {
|
|
486
|
+
case 1: return "major";
|
|
487
|
+
case 2: return "minor";
|
|
488
|
+
case 3: return "patch";
|
|
489
|
+
}
|
|
496
490
|
}
|
|
497
491
|
//#endregion
|
|
498
492
|
//#region src/publish.ts
|
|
@@ -504,6 +498,7 @@ async function publishFromPlan(context, store, options) {
|
|
|
504
498
|
if (!plan.publish) continue;
|
|
505
499
|
const pkg = context.graph.get(id);
|
|
506
500
|
if (!pkg) continue;
|
|
501
|
+
const registryClient = context.getRegistryClient(pkg);
|
|
507
502
|
const changelogs = [];
|
|
508
503
|
for (const id of plan.changelogIds ?? []) {
|
|
509
504
|
const entry = store.changelogs[id];
|
|
@@ -514,7 +509,7 @@ async function publishFromPlan(context, store, options) {
|
|
|
514
509
|
});
|
|
515
510
|
}
|
|
516
511
|
if (!dryRun) {
|
|
517
|
-
if (await
|
|
512
|
+
if (await registryClient.isPackagePublished(pkg)) {
|
|
518
513
|
packages.push({
|
|
519
514
|
id: pkg.id,
|
|
520
515
|
name: pkg.name,
|
|
@@ -525,15 +520,7 @@ async function publishFromPlan(context, store, options) {
|
|
|
525
520
|
});
|
|
526
521
|
continue;
|
|
527
522
|
}
|
|
528
|
-
}
|
|
529
|
-
try {
|
|
530
|
-
if (!dryRun) {
|
|
531
|
-
for (const plugin of context.plugins) await handlePluginError(plugin, "willPublish", () => plugin.willPublish?.call(context, { pkg }));
|
|
532
|
-
await context.getRegistryClient(pkg).publish(pkg, {
|
|
533
|
-
packageStore: plan,
|
|
534
|
-
store
|
|
535
|
-
});
|
|
536
|
-
}
|
|
523
|
+
} else {
|
|
537
524
|
packages.push({
|
|
538
525
|
id: pkg.id,
|
|
539
526
|
name: pkg.name,
|
|
@@ -542,6 +529,40 @@ async function publishFromPlan(context, store, options) {
|
|
|
542
529
|
state: "success",
|
|
543
530
|
changelogs
|
|
544
531
|
});
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
534
|
+
try {
|
|
535
|
+
let result;
|
|
536
|
+
for (const plugin of context.plugins) {
|
|
537
|
+
const next = await handlePluginError(plugin, "willPublish", () => plugin.willPublish?.call(context, { pkg }));
|
|
538
|
+
if (next !== void 0) {
|
|
539
|
+
result = next;
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
if (result === void 0) {
|
|
544
|
+
await registryClient.publish(pkg, {
|
|
545
|
+
packageStore: plan,
|
|
546
|
+
store
|
|
547
|
+
});
|
|
548
|
+
result = {
|
|
549
|
+
id: pkg.id,
|
|
550
|
+
name: pkg.name,
|
|
551
|
+
version: pkg.version,
|
|
552
|
+
npm: plan.npm,
|
|
553
|
+
state: "success",
|
|
554
|
+
changelogs
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
if (result === false) continue;
|
|
558
|
+
for (const plugin of context.plugins) {
|
|
559
|
+
const next = await handlePluginError(plugin, "afterPublish", () => plugin.afterPublish?.call(context, {
|
|
560
|
+
pkg,
|
|
561
|
+
result
|
|
562
|
+
}));
|
|
563
|
+
if (next) result = next;
|
|
564
|
+
}
|
|
565
|
+
packages.push(result);
|
|
545
566
|
} catch (error) {
|
|
546
567
|
packages.push({
|
|
547
568
|
id: pkg.id,
|
|
@@ -596,7 +617,10 @@ function tegami(options = {}) {
|
|
|
596
617
|
...context,
|
|
597
618
|
publishOptions
|
|
598
619
|
};
|
|
599
|
-
for (const plugin of context.plugins)
|
|
620
|
+
for (const plugin of context.plugins) {
|
|
621
|
+
const next = await handlePluginError(plugin, "afterPublishAll", () => plugin.afterPublishAll?.call(publishCtx, result));
|
|
622
|
+
if (next) result = next;
|
|
623
|
+
}
|
|
600
624
|
return result;
|
|
601
625
|
},
|
|
602
626
|
async cleanup() {
|
package/dist/plugins/git.d.ts
CHANGED
package/dist/plugins/git.js
CHANGED
|
@@ -37,7 +37,7 @@ function git(options = {}) {
|
|
|
37
37
|
if (result.exitCode !== 0) throw execFailure("Failed to configure git user for GitHub Actions.", result);
|
|
38
38
|
}
|
|
39
39
|
} },
|
|
40
|
-
async
|
|
40
|
+
async afterPublishAll(result) {
|
|
41
41
|
const { cwd, publishOptions: { dryRun = false } } = this;
|
|
42
42
|
if (dryRun || !createTags || result.state !== "created") return result;
|
|
43
43
|
const pendingTags = /* @__PURE__ */ new Set();
|
package/dist/plugins/github.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as DraftPlan, s as TegamiPlugin, t as Awaitable, w as TegamiContext, x as PackagePublishResult } from "../types-
|
|
1
|
+
import { O as DraftPlan, s as TegamiPlugin, t as Awaitable, w as TegamiContext, x as PackagePublishResult } from "../types-Cx-uvEWw.js";
|
|
2
2
|
import { GitPluginOptions } from "./git.js";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins/github.d.ts
|
package/dist/plugins/github.js
CHANGED
|
@@ -168,7 +168,7 @@ function github(options = {}) {
|
|
|
168
168
|
if (prResult.exitCode !== 0) throw execFailure("Failed to create the version pull request.", prResult);
|
|
169
169
|
}
|
|
170
170
|
},
|
|
171
|
-
async
|
|
171
|
+
async afterPublishAll(result) {
|
|
172
172
|
if (result.state !== "created") return;
|
|
173
173
|
for (const packages of groupPackagesByGitTag(result.packages).values()) if (packages.length > 1) await createGroupedRelease(this, packages);
|
|
174
174
|
else await createRelease(this, packages[0]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as CargoRegistryClient, f as cargo, l as CargoPackage, u as CargoPluginOptions } from "../types-
|
|
1
|
+
import { d as CargoRegistryClient, f as cargo, l as CargoPackage, u as CargoPluginOptions } from "../types-Cx-uvEWw.js";
|
|
2
2
|
export { CargoPackage, CargoPluginOptions, CargoRegistryClient, cargo };
|
package/dist/providers/npm.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { g as npm, h as NpmRegistryClient, m as NpmPluginOptions, p as NpmPackage } from "../types-
|
|
1
|
+
import { g as npm, h as NpmRegistryClient, m as NpmPluginOptions, p as NpmPackage } from "../types-Cx-uvEWw.js";
|
|
2
2
|
export { NpmPackage, NpmPluginOptions, NpmRegistryClient, npm };
|
|
@@ -456,12 +456,17 @@ interface TegamiPlugin {
|
|
|
456
456
|
resolvePlanStatus?(this: TegamiContext, status: PublishPlanStatus, env: {
|
|
457
457
|
plan: PlanStore;
|
|
458
458
|
}): Awaitable<PublishPlanStatus>;
|
|
459
|
-
/** Called before a package will be published. */
|
|
459
|
+
/** Called before a package will be published, return `false` to prevent from publishing. */
|
|
460
460
|
willPublish?(this: TegamiContext, opts: {
|
|
461
461
|
pkg: WorkspacePackage;
|
|
462
|
-
}): Awaitable<
|
|
462
|
+
}): Awaitable<PackagePublishResult | false | void | undefined>;
|
|
463
|
+
/** Called after a package is published. */
|
|
464
|
+
afterPublish?(this: TegamiContext, opts: {
|
|
465
|
+
pkg: WorkspacePackage;
|
|
466
|
+
result: PackagePublishResult;
|
|
467
|
+
}): Awaitable<PackagePublishResult | void | undefined>;
|
|
463
468
|
/** Called after publishing finishes. */
|
|
464
|
-
|
|
469
|
+
afterPublishAll?(this: TegamiContext & {
|
|
465
470
|
publishOptions: PublishOptions;
|
|
466
471
|
}, result: PublishResult): Awaitable<PublishResult | void | undefined>;
|
|
467
472
|
/** CLI lifecycle hooks. */
|