tegami 0.1.0-beta.1 → 0.1.0-beta.3
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/{checks-CKBRRjgQ.js → checks-BQISvt_o.js} +17 -19
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +280 -23
- package/dist/generators/simple.d.ts +1 -1
- package/dist/generators/simple.js +12 -11
- package/dist/{graph-CUgwuRW5.js → graph-B22NBRUG.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +125 -84
- package/dist/plugins/git.d.ts +1 -1
- package/dist/plugins/github.d.ts +12 -4
- package/dist/plugins/github.js +97 -26
- package/dist/providers/cargo.d.ts +1 -1
- package/dist/providers/cargo.js +1 -1
- package/dist/providers/npm.d.ts +1 -1
- package/dist/providers/npm.js +26 -13
- package/dist/{schemas-Cc4h6bq5.js → schemas-CurBAaW5.js} +6 -5
- package/dist/{semver-mWK2Khi2.js → semver-CPtl0XNq.js} +9 -1
- package/dist/{index-Da6P6gSc.d.ts → types-CrA7ZKxb.d.ts} +120 -99
- package/package.json +1 -1
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { n as handlePluginError } from "./error-DBK-9uBa.js";
|
|
2
|
-
import { n as jsonCodec } from "./schemas-
|
|
2
|
+
import { n as jsonCodec, t as bumpTypeSchema } from "./schemas-CurBAaW5.js";
|
|
3
3
|
import z$1 from "zod";
|
|
4
4
|
import { readFile } from "fs/promises";
|
|
5
|
+
//#region src/utils/changelog.ts
|
|
6
|
+
function changelogFilename(disambiguator = 0) {
|
|
7
|
+
const date = /* @__PURE__ */ new Date();
|
|
8
|
+
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}-${(Date.now() + disambiguator).toString(36)}.md`;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
5
11
|
//#region src/plans/store.ts
|
|
6
12
|
const packagePlanStoreSchema = z$1.object({
|
|
7
|
-
type:
|
|
8
|
-
"major",
|
|
9
|
-
"minor",
|
|
10
|
-
"patch"
|
|
11
|
-
]).optional(),
|
|
13
|
+
type: bumpTypeSchema.optional(),
|
|
12
14
|
changelogIds: z$1.array(z$1.string()).optional(),
|
|
13
15
|
bumpReasons: z$1.array(z$1.string()).optional(),
|
|
14
16
|
npm: z$1.object({ distTag: z$1.string().optional() }).optional(),
|
|
@@ -23,14 +25,12 @@ const planStoreSchema = jsonCodec(z$1.object({
|
|
|
23
25
|
changelogs: z$1.record(z$1.string(), z$1.object({
|
|
24
26
|
filename: z$1.string(),
|
|
25
27
|
subject: z$1.string().optional(),
|
|
26
|
-
packages: z$1.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
title: z$1.string(),
|
|
33
|
-
content: z$1.string()
|
|
28
|
+
packages: z$1.record(z$1.string(), bumpTypeSchema),
|
|
29
|
+
sections: z$1.array(z$1.object({
|
|
30
|
+
depth: z$1.number(),
|
|
31
|
+
title: z$1.string(),
|
|
32
|
+
content: z$1.string()
|
|
33
|
+
}))
|
|
34
34
|
})),
|
|
35
35
|
/** package id -> package info */
|
|
36
36
|
packages: z$1.record(z$1.string(), packagePlanStoreSchema)
|
|
@@ -46,10 +46,8 @@ function createPlanStore(draft, context) {
|
|
|
46
46
|
for (const entry of draft.getChangelogs()) store.changelogs[entry.id] = {
|
|
47
47
|
filename: entry.filename,
|
|
48
48
|
subject: entry.subject,
|
|
49
|
-
packages:
|
|
50
|
-
|
|
51
|
-
title: entry.title,
|
|
52
|
-
content: entry.content
|
|
49
|
+
packages: Object.fromEntries(entry.packages.entries()),
|
|
50
|
+
sections: entry.sections
|
|
53
51
|
};
|
|
54
52
|
for (const pkg of context.graph.getPackages()) {
|
|
55
53
|
const plan = draft.getPackagePlan(pkg.id);
|
|
@@ -97,4 +95,4 @@ async function assertPublishPlanFinished(context) {
|
|
|
97
95
|
if ((await publishPlanStatus(store, context)).state === "pending") throw new Error(`Publish plan already exists at ${context.planPath} and is pending. Publish it before applying a new plan.`);
|
|
98
96
|
}
|
|
99
97
|
//#endregion
|
|
100
|
-
export { readPlanStore as i, publishPlanStatus as n, createPlanStore as r, assertPublishPlanFinished as t };
|
|
98
|
+
export { changelogFilename as a, readPlanStore as i, publishPlanStatus as n, createPlanStore as r, assertPublishPlanFinished as t };
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as PublishResult,
|
|
1
|
+
import { C as PublishResult, O as DraftPlan, _ as Tegami, t as Awaitable } from "../types-CrA7ZKxb.js";
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
|
|
4
4
|
//#region src/cli/index.d.ts
|
package/dist/cli/index.js
CHANGED
|
@@ -1,10 +1,224 @@
|
|
|
1
|
+
import { a as changelogFilename, t as assertPublishPlanFinished } from "../checks-BQISvt_o.js";
|
|
1
2
|
import { n as handlePluginError } from "../error-DBK-9uBa.js";
|
|
2
|
-
import { t as
|
|
3
|
+
import { r as formatNpmDistTag, t as bumpDepth } from "../semver-CPtl0XNq.js";
|
|
3
4
|
import { t as isCI } from "../constants-B9qjNfvr.js";
|
|
4
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
import {
|
|
5
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
6
|
+
import path, { basename, isAbsolute, join, normalize, relative } from "node:path";
|
|
7
|
+
import { x } from "tinyexec";
|
|
8
|
+
import { dump } from "js-yaml";
|
|
9
|
+
import { detect, resolveCommand } from "package-manager-detector";
|
|
10
|
+
import { autocompleteMultiselect, confirm, intro, isCancel, multiline, note, outro, select, spinner } from "@clack/prompts";
|
|
7
11
|
import { Command } from "commander";
|
|
12
|
+
//#region src/cli/init-agent.ts
|
|
13
|
+
const CHANGELOG_DOCS_URL$1 = "https://tegami.fuma-nama.dev/changelog";
|
|
14
|
+
async function initAgent(context, options = {}) {
|
|
15
|
+
const output = path.resolve(context.cwd, options.output ?? "AGENTS.md");
|
|
16
|
+
const content = renderAgentsMd(context);
|
|
17
|
+
try {
|
|
18
|
+
await writeFile(output, (await readFile(output, "utf8")).trimEnd() + "\n\n" + content);
|
|
19
|
+
return {
|
|
20
|
+
path: output,
|
|
21
|
+
created: false
|
|
22
|
+
};
|
|
23
|
+
} catch {
|
|
24
|
+
await writeFile(output, content);
|
|
25
|
+
return {
|
|
26
|
+
path: output,
|
|
27
|
+
created: true
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function renderAgentsMd(context) {
|
|
32
|
+
const changelogDir = path.relative(context.cwd, context.changelogDir) || "project root";
|
|
33
|
+
const planPath = path.relative(context.cwd, context.planPath) || "project root";
|
|
34
|
+
return [
|
|
35
|
+
"# Release workflow",
|
|
36
|
+
"",
|
|
37
|
+
"This repository uses [Tegami](https://tegami.fuma-nama.dev) for versioning and publishing.",
|
|
38
|
+
"",
|
|
39
|
+
"## Write changelog files",
|
|
40
|
+
"",
|
|
41
|
+
`Create pending changelog files under \`${changelogDir}/\` as \`YYYY-MM-DD-{hash}.md\`.`,
|
|
42
|
+
"",
|
|
43
|
+
`See the [changelog format docs](${CHANGELOG_DOCS_URL$1}) for details.`,
|
|
44
|
+
"",
|
|
45
|
+
"### Example",
|
|
46
|
+
"",
|
|
47
|
+
"```md",
|
|
48
|
+
"---",
|
|
49
|
+
"packages:",
|
|
50
|
+
` "npm:@acme/ui": patch`,
|
|
51
|
+
"---",
|
|
52
|
+
"",
|
|
53
|
+
"### Fix button hover state",
|
|
54
|
+
"",
|
|
55
|
+
"The hover color now matches the design system.",
|
|
56
|
+
"```",
|
|
57
|
+
"",
|
|
58
|
+
"### Package references",
|
|
59
|
+
"",
|
|
60
|
+
"Use package names, ids, or groups in frontmatter. For example:",
|
|
61
|
+
"",
|
|
62
|
+
"- `\"@acme/ui\"` — package name",
|
|
63
|
+
"- `\"npm:@acme/ui\"` — package id",
|
|
64
|
+
"- `\"group:acme\"` — every package in a group",
|
|
65
|
+
"",
|
|
66
|
+
"Rules:",
|
|
67
|
+
"",
|
|
68
|
+
"- Include YAML frontmatter with `packages`",
|
|
69
|
+
"- Include at least one `#`, `##`, or `###` heading in the body",
|
|
70
|
+
"- Write user-facing release notes under each heading",
|
|
71
|
+
`- Do not edit \`${planPath}\` or package \`CHANGELOG.md\` files directly`,
|
|
72
|
+
""
|
|
73
|
+
].join("\n");
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/utils/package-manager.ts
|
|
77
|
+
async function formatRunScriptCommand(cwd, script, agent) {
|
|
78
|
+
const resolved = resolveCommand(agent ?? (await detect({ cwd }))?.agent ?? "npm", "run", [script]);
|
|
79
|
+
if (!resolved) return `npm run ${script}`;
|
|
80
|
+
return [resolved.command, ...resolved.args].join(" ");
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/cli/ci-pr.ts
|
|
84
|
+
const TEGAMI_DOCS_URL = "https://tegami.fuma-nama.dev";
|
|
85
|
+
const CHANGELOG_DOCS_URL = `${TEGAMI_DOCS_URL}/changelog`;
|
|
86
|
+
async function runCiPr(context, draft, options = {}) {
|
|
87
|
+
const event = await resolvePullRequestEvent();
|
|
88
|
+
return renderCiPrPreview(context, draft, {
|
|
89
|
+
repo: options.repo ?? context.github?.repo ?? process.env.GITHUB_REPOSITORY,
|
|
90
|
+
branch: options.branch ?? event?.headRef,
|
|
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 = {}) {
|
|
96
|
+
const changelogDir = relative(context.cwd, context.changelogDir) || ".tegami";
|
|
97
|
+
const tegamiCommand = options.tegamiCommand ?? "npm run tegami";
|
|
98
|
+
const createLink = options.repo && options.branch ? createChangelogUrl(options.repo, options.branch, changelogDir, changelogFilename()) : void 0;
|
|
99
|
+
const lines = [
|
|
100
|
+
"### Tegami",
|
|
101
|
+
"",
|
|
102
|
+
`This repository uses [Tegami](${TEGAMI_DOCS_URL}) to manage releases. When your changes affect published packages, add a changelog file under \`.tegami/\` before merging.`,
|
|
103
|
+
""
|
|
104
|
+
];
|
|
105
|
+
if (createLink) lines.push(`[**Create a changelog →**](${createLink}) · [Changelog format](${CHANGELOG_DOCS_URL})`, "");
|
|
106
|
+
else lines.push(`Run \`${tegamiCommand}\` locally or see the [changelog format](${CHANGELOG_DOCS_URL}).`, "");
|
|
107
|
+
const pendingPackages = getPendingPackages(context, draft);
|
|
108
|
+
const prChangelogs = filterChangelogsInPullRequest(draft, options.prChangelogFiles);
|
|
109
|
+
if (pendingPackages.length > 0) {
|
|
110
|
+
lines.push("#### Release preview", "", "| Package | Bump | Version |", "| --- | --- | --- |");
|
|
111
|
+
for (const { name, type, from, to, distTag, publish } of pendingPackages) {
|
|
112
|
+
const publishNote = publish ? "" : " (no publish)";
|
|
113
|
+
lines.push(`| \`${name}\` | ${type} | \`${from}\` → \`${to}\`${formatNpmDistTag(distTag)}${publishNote} |`);
|
|
114
|
+
}
|
|
115
|
+
lines.push("");
|
|
116
|
+
}
|
|
117
|
+
if (prChangelogs.length > 0) {
|
|
118
|
+
lines.push("#### Changelogs in this PR", "");
|
|
119
|
+
for (const entry of prChangelogs) {
|
|
120
|
+
const title = entry.sections[0]?.title ?? entry.filename;
|
|
121
|
+
lines.push(`- \`${entry.filename}\` — ${title}`);
|
|
122
|
+
}
|
|
123
|
+
lines.push("");
|
|
124
|
+
} 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 (options.prChangelogFiles?.length === 0) lines.push("This PR does not add changelog files. Pending changelogs from other branches are included in the preview above.", "");
|
|
126
|
+
lines.push(`Run \`${tegamiCommand}\` locally to create a changelog interactively.`, "", `<sub>Managed by [Tegami](${TEGAMI_DOCS_URL}).</sub>`, "");
|
|
127
|
+
return lines.join("\n");
|
|
128
|
+
}
|
|
129
|
+
async function resolvePullRequestEvent() {
|
|
130
|
+
const eventPath = process.env.GITHUB_EVENT_PATH;
|
|
131
|
+
if (!eventPath) return;
|
|
132
|
+
let event;
|
|
133
|
+
try {
|
|
134
|
+
event = JSON.parse(await readFile(eventPath, "utf8"));
|
|
135
|
+
} catch {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const pullRequest = event.pull_request;
|
|
139
|
+
if (!pullRequest) return;
|
|
140
|
+
return {
|
|
141
|
+
number: pullRequest.number,
|
|
142
|
+
headRef: pullRequest.head.ref,
|
|
143
|
+
baseSha: pullRequest.base.sha,
|
|
144
|
+
headSha: pullRequest.head.sha
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
async function getPullRequestChangelogFiles(context, baseSha, headSha) {
|
|
148
|
+
const dir = relative(context.cwd, context.changelogDir);
|
|
149
|
+
const result = await x("git", [
|
|
150
|
+
"diff",
|
|
151
|
+
"--name-only",
|
|
152
|
+
"--diff-filter=AM",
|
|
153
|
+
`${baseSha}...${headSha}`,
|
|
154
|
+
"--",
|
|
155
|
+
`${dir}/`
|
|
156
|
+
], { nodeOptions: { cwd: context.cwd } });
|
|
157
|
+
if (result.exitCode !== 0) return [];
|
|
158
|
+
return result.stdout.split("\n").map((line) => line.trim()).filter((line) => line.endsWith(".md")).map((line) => basename(line));
|
|
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
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return packages;
|
|
175
|
+
}
|
|
176
|
+
function filterChangelogsInPullRequest(draft, filenames) {
|
|
177
|
+
if (!filenames) return draft.getChangelogs();
|
|
178
|
+
const names = new Set(filenames);
|
|
179
|
+
return draft.getChangelogs().filter((entry) => names.has(entry.filename));
|
|
180
|
+
}
|
|
181
|
+
function createChangelogUrl(repo, branch, changelogDir, filename) {
|
|
182
|
+
const segments = [...changelogDir.split("/").filter(Boolean), filename].map((part) => encodeURIComponent(part));
|
|
183
|
+
return `https://github.com/${repo}/new/${branch.split("/").map(encodeURIComponent).join("/")}/${segments.join("/")}`;
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/utils/git-changes.ts
|
|
187
|
+
async function getChangedPackages(graph, cwd) {
|
|
188
|
+
return resolveChangedPackages(graph, await getChangedFilePaths(cwd), cwd);
|
|
189
|
+
}
|
|
190
|
+
async function getChangedFilePaths(cwd) {
|
|
191
|
+
const files = /* @__PURE__ */ new Set();
|
|
192
|
+
for (const args of [["diff", "--name-only"], [
|
|
193
|
+
"diff",
|
|
194
|
+
"--cached",
|
|
195
|
+
"--name-only"
|
|
196
|
+
]]) await addGitOutput(files, cwd, args);
|
|
197
|
+
return Array.from(files);
|
|
198
|
+
}
|
|
199
|
+
function resolveChangedPackages(graph, files, cwd) {
|
|
200
|
+
const packages = [...graph.getPackages()].sort((a, b) => b.path.length - a.path.length);
|
|
201
|
+
const matched = /* @__PURE__ */ new Map();
|
|
202
|
+
for (const file of files) for (const pkg of packages) if (isUnderDir(file, pkg.path, cwd)) {
|
|
203
|
+
matched.set(pkg.id, pkg);
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
return [...matched.values()];
|
|
207
|
+
}
|
|
208
|
+
function isUnderDir(file, dir, cwd) {
|
|
209
|
+
const absolute = join(cwd, file);
|
|
210
|
+
const rel = relative(normalize(dir), absolute);
|
|
211
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
|
|
212
|
+
}
|
|
213
|
+
async function addGitOutput(files, cwd, args) {
|
|
214
|
+
const result = await x("git", args, { nodeOptions: { cwd } });
|
|
215
|
+
if (result.exitCode !== 0) return;
|
|
216
|
+
for (const line of result.stdout.split("\n")) {
|
|
217
|
+
const trimmed = line.trim();
|
|
218
|
+
if (trimmed) files.add(trimmed);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
//#endregion
|
|
8
222
|
//#region src/cli/index.ts
|
|
9
223
|
var CancelledError = class extends Error {
|
|
10
224
|
constructor() {
|
|
@@ -27,6 +241,7 @@ function createCli(tegami, options = {}) {
|
|
|
27
241
|
if (await versionPackages(tegami, { cli: options })) return;
|
|
28
242
|
await publishPackages(tegami, { cli: options });
|
|
29
243
|
}));
|
|
244
|
+
program.command("ci-pr").description("show a pull request release preview and changelog guidance").option("--repo <repo>", "GitHub repository (owner/name)").option("--branch <branch>", "PR head branch for the create-changelog link").option("--print", "print the preview markdown to stdout").action((commandOptions) => runAction(tegami, () => runCiPrCommand(tegami, commandOptions)));
|
|
30
245
|
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 () => {
|
|
31
246
|
await publishPackages(tegami, {
|
|
32
247
|
...commandOptions,
|
|
@@ -34,24 +249,47 @@ function createCli(tegami, options = {}) {
|
|
|
34
249
|
});
|
|
35
250
|
}));
|
|
36
251
|
program.command("cleanup").description("remove the publish plan after all packages have been published").action(() => runAction(tegami, () => runCleanup(tegami)));
|
|
252
|
+
program.command("init-agent").description("write AGENTS.md with changelog instructions for AI agents").option("-o, --output <path>", "output path", "AGENTS.md").action((commandOptions) => runAction(tegami, () => runInitAgent(tegami, commandOptions)));
|
|
37
253
|
return program;
|
|
38
254
|
}
|
|
39
255
|
async function createChangelogs(tegami, _options) {
|
|
40
256
|
const context = await tegami._internal.context();
|
|
41
257
|
await assertPublishPlanFinished(context);
|
|
42
258
|
intro("Create changelogs");
|
|
43
|
-
const packages = context.graph.getPackages();
|
|
44
259
|
let selectedPackages = [];
|
|
45
|
-
if (isCI())
|
|
46
|
-
|
|
47
|
-
const
|
|
260
|
+
if (!isCI()) {
|
|
261
|
+
const useShortname = /* @__PURE__ */ new Map();
|
|
262
|
+
for (const pkg of context.graph.getPackages()) if (useShortname.has(pkg.name)) useShortname.set(pkg.name, false);
|
|
263
|
+
else useShortname.set(pkg.name, true);
|
|
264
|
+
const getPackageLabel = (pkg) => {
|
|
265
|
+
return useShortname.get(pkg.name) ? pkg.name : pkg.id;
|
|
266
|
+
};
|
|
267
|
+
const changedPackages = new Set(await getChangedPackages(context.graph, context.cwd));
|
|
268
|
+
const selectOptions = [];
|
|
269
|
+
const groups = [];
|
|
270
|
+
for (const group of context.graph.getGroups()) {
|
|
271
|
+
const changed = group.packages.some((pkg) => changedPackages.has(pkg));
|
|
272
|
+
groups.push([group, changed]);
|
|
273
|
+
}
|
|
274
|
+
groups.sort((a, b) => (a[1] ? 0 : 1) - (b[1] ? 0 : 1));
|
|
275
|
+
for (const [group, changed] of groups) {
|
|
276
|
+
const members = group.packages.map(getPackageLabel).join(", ");
|
|
277
|
+
selectOptions.push({
|
|
278
|
+
label: `Group ${group.name}`,
|
|
279
|
+
value: `group:${group.name}`,
|
|
280
|
+
hint: changed ? `changed · ${members}` : members
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
const packages = context.graph.getPackages().toSorted((a, b) => (changedPackages.has(a) ? 0 : 1) - (changedPackages.has(b) ? 0 : 1));
|
|
284
|
+
for (const pkg of packages) selectOptions.push({
|
|
285
|
+
label: getPackageLabel(pkg),
|
|
286
|
+
value: pkg.id,
|
|
287
|
+
hint: changedPackages.has(pkg) ? "changed" : void 0
|
|
288
|
+
});
|
|
289
|
+
const selected = await autocompleteMultiselect({
|
|
48
290
|
message: "Select packages (leave empty to auto-generate from commits)",
|
|
49
291
|
required: false,
|
|
50
|
-
options:
|
|
51
|
-
value: pkg.id,
|
|
52
|
-
label: pkg.id,
|
|
53
|
-
hint: pkg.version
|
|
54
|
-
}))
|
|
292
|
+
options: selectOptions
|
|
55
293
|
});
|
|
56
294
|
if (isCancel(selected)) throw new CancelledError();
|
|
57
295
|
selectedPackages = selected;
|
|
@@ -95,9 +333,10 @@ async function createChangelogs(tegami, _options) {
|
|
|
95
333
|
]
|
|
96
334
|
});
|
|
97
335
|
if (isCancel(type)) throw new CancelledError();
|
|
98
|
-
const message = await
|
|
99
|
-
message: "
|
|
100
|
-
placeholder: "
|
|
336
|
+
const message = await multiline({
|
|
337
|
+
message: "Describe change (Markdown supported, press tab then enter to exit)",
|
|
338
|
+
placeholder: "The first line is heading\n\nAdditional description.",
|
|
339
|
+
showSubmit: true,
|
|
101
340
|
validate(value) {
|
|
102
341
|
if (!value?.trim()) return "Enter a message.";
|
|
103
342
|
}
|
|
@@ -172,6 +411,26 @@ async function publishPackages(tegami, options) {
|
|
|
172
411
|
outro(dryRun ? "Publish plan is valid." : "Packages published.");
|
|
173
412
|
return true;
|
|
174
413
|
}
|
|
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
|
+
async function runInitAgent(tegami, options) {
|
|
425
|
+
intro("Init agent instructions");
|
|
426
|
+
const context = await tegami._internal.context();
|
|
427
|
+
const s = spinner();
|
|
428
|
+
s.start("Writing AGENTS.md");
|
|
429
|
+
const result = await initAgent(context, options);
|
|
430
|
+
s.stop(result.created ? "Created AGENTS.md" : "Appended to AGENTS.md");
|
|
431
|
+
note(relative(context.cwd, result.path) || "AGENTS.md", "Agent instructions");
|
|
432
|
+
outro("Agents can follow AGENTS.md to write changelogs.");
|
|
433
|
+
}
|
|
175
434
|
async function runCleanup(tegami) {
|
|
176
435
|
intro("Cleanup publish plan");
|
|
177
436
|
const s = spinner();
|
|
@@ -190,20 +449,18 @@ async function runCleanup(tegami) {
|
|
|
190
449
|
outro(`Publish plan at ${planPath} is still pending. Publish it before cleanup.`);
|
|
191
450
|
}
|
|
192
451
|
function renderManualChangelog(packages, type, message) {
|
|
193
|
-
const
|
|
452
|
+
const prefix = "#".repeat(bumpDepth(type));
|
|
453
|
+
const packageMap = {};
|
|
454
|
+
for (const name of packages) packageMap[name] = type;
|
|
194
455
|
return [
|
|
195
456
|
"---",
|
|
196
|
-
|
|
457
|
+
dump({ packages: packageMap }).trim(),
|
|
197
458
|
"---",
|
|
198
459
|
"",
|
|
199
|
-
`${
|
|
460
|
+
`${prefix} ${message}`,
|
|
200
461
|
""
|
|
201
462
|
].join("\n");
|
|
202
463
|
}
|
|
203
|
-
function changelogFilename() {
|
|
204
|
-
const date = /* @__PURE__ */ new Date();
|
|
205
|
-
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}-${Date.now().toString(36)}.md`;
|
|
206
|
-
}
|
|
207
464
|
async function runAction(tegami, action) {
|
|
208
465
|
try {
|
|
209
466
|
const context = await tegami._internal.context();
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as formatPackageVersion } from "../semver-CPtl0XNq.js";
|
|
2
2
|
//#region src/generators/simple.ts
|
|
3
3
|
function simpleGenerator() {
|
|
4
4
|
return { generate({ changelogs, version, packageName, plan }) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
""
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
const lines = [`## ${formatPackageVersion(packageName, version, plan.npm?.distTag)}`, ""];
|
|
6
|
+
for (const entry of changelogs) {
|
|
7
|
+
let sectionDepth = 4;
|
|
8
|
+
if (entry.subject) lines.push(`### ${entry.subject}`, "");
|
|
9
|
+
else sectionDepth--;
|
|
10
|
+
for (const section of entry.sections) {
|
|
11
|
+
const prefix = "#".repeat(sectionDepth);
|
|
12
|
+
lines.push(`${prefix} ${section.title}`, "", section.content, "");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return lines.join("\n").trim();
|
|
15
16
|
} };
|
|
16
17
|
}
|
|
17
18
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as PublishResult, D as
|
|
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-CrA7ZKxb.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 };
|