tegami 0.1.1 → 0.1.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-Smwtq_Li.js +279 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +207 -201
- package/dist/{error-BaOQJtvf.js → error-qpTCB2ld.js} +6 -1
- package/dist/generators/simple.d.ts +1 -1
- package/dist/generators/simple.js +1 -1
- package/dist/{graph-CUgwuRW5.js → graph-hBQUWKQA.js} +15 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +238 -294
- package/dist/plugins/git.d.ts +1 -1
- package/dist/plugins/git.js +4 -4
- package/dist/plugins/github.d.ts +7 -1
- package/dist/plugins/github.js +24 -23
- package/dist/providers/cargo.d.ts +1 -1
- package/dist/providers/cargo.js +6 -6
- package/dist/providers/npm.d.ts +1 -1
- package/dist/providers/npm.js +32 -16
- package/dist/{semver-mWK2Khi2.js → semver-cnZp9koa.js} +16 -5
- package/dist/{types-Diwnh8Tn.d.ts → types-Di--A9X1.d.ts} +40 -19
- package/package.json +1 -1
- package/dist/checks-Bz3Rf2OX.js +0 -98
package/dist/cli/index.js
CHANGED
|
@@ -1,15 +1,206 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as
|
|
1
|
+
import { r as formatNpmDistTag } from "../semver-cnZp9koa.js";
|
|
2
|
+
import { c as renderChangelog, l as changelogFilename, o as generateReplays, t as assertPublishPlanFinished } from "../checks-Smwtq_Li.js";
|
|
3
|
+
import { n as execFailure, r as handlePluginError, t as CancelledError } from "../error-qpTCB2ld.js";
|
|
4
4
|
import { t as isCI } from "../constants-B9qjNfvr.js";
|
|
5
5
|
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
6
|
-
import path, { basename, isAbsolute, join, normalize, relative
|
|
6
|
+
import path, { basename, isAbsolute, join, normalize, relative } from "node:path";
|
|
7
7
|
import { x } from "tinyexec";
|
|
8
|
-
import { dump } from "js-yaml";
|
|
9
8
|
import { detect, resolveCommand } from "package-manager-detector";
|
|
10
9
|
import { autocompleteMultiselect, confirm, intro, isCancel, multiline, note, outro, select, spinner } from "@clack/prompts";
|
|
11
10
|
import { Command, InvalidArgumentError } from "commander";
|
|
12
11
|
import { tmpdir } from "node:os";
|
|
12
|
+
//#region src/utils/git-changes.ts
|
|
13
|
+
async function getChangedPackages(graph, cwd) {
|
|
14
|
+
return resolveChangedPackages(graph, await getChangedFilePaths(cwd), cwd);
|
|
15
|
+
}
|
|
16
|
+
async function getChangedFilePaths(cwd) {
|
|
17
|
+
const files = /* @__PURE__ */ new Set();
|
|
18
|
+
for (const args of [["diff", "--name-only"], [
|
|
19
|
+
"diff",
|
|
20
|
+
"--cached",
|
|
21
|
+
"--name-only"
|
|
22
|
+
]]) await addGitOutput(files, cwd, args);
|
|
23
|
+
return Array.from(files);
|
|
24
|
+
}
|
|
25
|
+
function resolveChangedPackages(graph, files, cwd) {
|
|
26
|
+
const packages = [...graph.getPackages()].sort((a, b) => b.path.length - a.path.length);
|
|
27
|
+
const matched = /* @__PURE__ */ new Map();
|
|
28
|
+
for (const file of files) for (const pkg of packages) if (isUnderDir(file, pkg.path, cwd)) {
|
|
29
|
+
matched.set(pkg.id, pkg);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
return [...matched.values()];
|
|
33
|
+
}
|
|
34
|
+
function isUnderDir(file, dir, cwd) {
|
|
35
|
+
const absolute = join(cwd, file);
|
|
36
|
+
const rel = relative(normalize(dir), absolute);
|
|
37
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
|
|
38
|
+
}
|
|
39
|
+
async function addGitOutput(files, cwd, args) {
|
|
40
|
+
const result = await x("git", args, { nodeOptions: { cwd } });
|
|
41
|
+
if (result.exitCode !== 0) return;
|
|
42
|
+
for (const line of result.stdout.split("\n")) {
|
|
43
|
+
const trimmed = line.trim();
|
|
44
|
+
if (trimmed) files.add(trimmed);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/cli/changelog.ts
|
|
49
|
+
async function runChangelogTui(tegami) {
|
|
50
|
+
const context = await tegami._internal.context();
|
|
51
|
+
await assertPublishPlanFinished(context);
|
|
52
|
+
intro("Create changelogs");
|
|
53
|
+
let selectedPackages = [];
|
|
54
|
+
if (!isCI()) selectedPackages = await promptPackageSelection(context.graph, context.cwd);
|
|
55
|
+
if (selectedPackages.length === 0) {
|
|
56
|
+
if (!isCI()) {
|
|
57
|
+
const confirmed = await confirm({
|
|
58
|
+
message: "Auto-generate changelog files from commits?",
|
|
59
|
+
initialValue: true
|
|
60
|
+
});
|
|
61
|
+
if (isCancel(confirmed)) throw new CancelledError();
|
|
62
|
+
if (!confirmed) {
|
|
63
|
+
outro("No changelogs created.");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
await persistChangelogs(context, (await tegami.generateChangelog({ write: false })).map(({ filename, content, packages }) => ({
|
|
68
|
+
filename,
|
|
69
|
+
content,
|
|
70
|
+
packages
|
|
71
|
+
})), "No matching conventional commits were found.");
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const packageBumpMap = await promptPackageBumpTypes(selectedPackages);
|
|
75
|
+
const message = await multiline({
|
|
76
|
+
message: "Describe change (Markdown supported, press tab then enter to exit)",
|
|
77
|
+
placeholder: "The first line is heading\n\nAdditional description.",
|
|
78
|
+
showSubmit: true,
|
|
79
|
+
validate(value) {
|
|
80
|
+
if (!value?.trim()) return "Enter a message.";
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
if (isCancel(message)) throw new CancelledError();
|
|
84
|
+
const packages = generateReplays(context.graph, packageBumpMap);
|
|
85
|
+
await persistChangelogs(context, [{
|
|
86
|
+
filename: changelogFilename(),
|
|
87
|
+
content: renderChangelog({ packages }, `## ${message.trim()}`),
|
|
88
|
+
packages
|
|
89
|
+
}]);
|
|
90
|
+
}
|
|
91
|
+
async function persistChangelogs(context, entries, emptyMessage = "No changelogs created.") {
|
|
92
|
+
const s = spinner();
|
|
93
|
+
s.start("Creating changelog");
|
|
94
|
+
await mkdir(context.changelogDir, { recursive: true });
|
|
95
|
+
await Promise.all(entries.map(({ filename, content }) => writeFile(join(context.changelogDir, filename), content)));
|
|
96
|
+
s.stop(entries.length === 1 ? "Created 1 changelog file" : entries.length > 0 ? `Created ${entries.length} changelog files` : "No changelogs created");
|
|
97
|
+
if (entries.length === 0) note(emptyMessage, "No changelogs created");
|
|
98
|
+
else {
|
|
99
|
+
const lines = [];
|
|
100
|
+
for (const { filename, packages } of entries) {
|
|
101
|
+
lines.push(filename);
|
|
102
|
+
for (const [name, config] of Object.entries(packages)) {
|
|
103
|
+
if (typeof config === "string") {
|
|
104
|
+
lines.push(`${name}: ${config}`);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (config.replay?.length) {
|
|
108
|
+
lines.push(`${name}: ${config.type} (replay on ${config.replay.join(" or ")})`);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
lines.push(`${name}: ${config.type}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
note(lines.join("\n"), "Created changelogs");
|
|
115
|
+
}
|
|
116
|
+
outro(entries.length === 1 ? "Changelog ready." : "Changelogs ready.");
|
|
117
|
+
}
|
|
118
|
+
async function promptPackageSelection(graph, cwd) {
|
|
119
|
+
const useShortname = /* @__PURE__ */ new Map();
|
|
120
|
+
for (const pkg of graph.getPackages()) if (useShortname.has(pkg.name)) useShortname.set(pkg.name, false);
|
|
121
|
+
else useShortname.set(pkg.name, true);
|
|
122
|
+
const getPackageLabel = (pkg) => {
|
|
123
|
+
return useShortname.get(pkg.name) ? pkg.name : pkg.id;
|
|
124
|
+
};
|
|
125
|
+
const changedPackages = new Set(await getChangedPackages(graph, cwd));
|
|
126
|
+
const selectOptions = [];
|
|
127
|
+
const groups = [];
|
|
128
|
+
for (const group of graph.getGroups()) {
|
|
129
|
+
const changed = group.packages.some((pkg) => changedPackages.has(pkg));
|
|
130
|
+
groups.push([group, changed]);
|
|
131
|
+
}
|
|
132
|
+
groups.sort((a, b) => (a[1] ? 0 : 1) - (b[1] ? 0 : 1));
|
|
133
|
+
for (const [group, changed] of groups) {
|
|
134
|
+
const members = group.packages.map(getPackageLabel).join(", ");
|
|
135
|
+
selectOptions.push({
|
|
136
|
+
label: `(Group) ${group.name}`,
|
|
137
|
+
value: `group:${group.name}`,
|
|
138
|
+
hint: changed ? `changed · ${members}` : members
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
const packages = graph.getPackages().toSorted((a, b) => (changedPackages.has(a) ? 0 : 1) - (changedPackages.has(b) ? 0 : 1));
|
|
142
|
+
for (const pkg of packages) selectOptions.push({
|
|
143
|
+
label: getPackageLabel(pkg),
|
|
144
|
+
value: pkg.id,
|
|
145
|
+
hint: changedPackages.has(pkg) ? "changed" : void 0
|
|
146
|
+
});
|
|
147
|
+
const selected = await autocompleteMultiselect({
|
|
148
|
+
message: "Select packages (leave empty to auto-generate from commits)",
|
|
149
|
+
required: false,
|
|
150
|
+
options: selectOptions
|
|
151
|
+
});
|
|
152
|
+
if (isCancel(selected)) throw new CancelledError();
|
|
153
|
+
return selected;
|
|
154
|
+
}
|
|
155
|
+
async function promptPackageBumpTypes(selectedPackages) {
|
|
156
|
+
const packageBumpMap = {};
|
|
157
|
+
const bumpType = await select({
|
|
158
|
+
message: "Select release type",
|
|
159
|
+
options: [
|
|
160
|
+
{
|
|
161
|
+
value: "patch",
|
|
162
|
+
label: "patch"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
value: "minor",
|
|
166
|
+
label: "minor"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
value: "major",
|
|
170
|
+
label: "major"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
value: "per-package",
|
|
174
|
+
label: "choose per-package"
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
});
|
|
178
|
+
if (isCancel(bumpType)) throw new CancelledError();
|
|
179
|
+
if (bumpType === "per-package") for (const pkg of selectedPackages) {
|
|
180
|
+
const selectedBump = await select({
|
|
181
|
+
message: `Select release type for "${pkg}"`,
|
|
182
|
+
options: [
|
|
183
|
+
{
|
|
184
|
+
value: "patch",
|
|
185
|
+
label: "patch"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
value: "minor",
|
|
189
|
+
label: "minor"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
value: "major",
|
|
193
|
+
label: "major"
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
});
|
|
197
|
+
if (isCancel(selectedBump)) throw new CancelledError();
|
|
198
|
+
packageBumpMap[pkg] = selectedBump;
|
|
199
|
+
}
|
|
200
|
+
else for (const pkg of selectedPackages) packageBumpMap[pkg] = bumpType;
|
|
201
|
+
return packageBumpMap;
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
13
204
|
//#region src/cli/init-agent.ts
|
|
14
205
|
const CHANGELOG_DOCS_URL$1 = "https://tegami.fuma-nama.dev/changelog";
|
|
15
206
|
async function initAgent(context, options = {}) {
|
|
@@ -101,10 +292,10 @@ async function buildPrPreview(context, draft, options = {}) {
|
|
|
101
292
|
const pendingPackages = [];
|
|
102
293
|
for (const pkg of context.graph.getPackages()) {
|
|
103
294
|
const plan = draft.getPackagePlan(pkg.id);
|
|
104
|
-
if (!plan
|
|
295
|
+
if (!plan || plan.bumpVersion(pkg) === pkg.version) continue;
|
|
105
296
|
pendingPackages.push({
|
|
106
297
|
name: pkg.name,
|
|
107
|
-
type: plan.type,
|
|
298
|
+
type: plan.type ?? "—",
|
|
108
299
|
from: pkg.version,
|
|
109
300
|
to: plan.bumpVersion(pkg),
|
|
110
301
|
distTag: plan.npm?.distTag,
|
|
@@ -271,59 +462,12 @@ function createChangelogUrl(context, repo, branch, filename) {
|
|
|
271
462
|
return `https://github.com/${repo}/new/${branch.split("/").map(encodeURIComponent).join("/")}?${new URLSearchParams({ filename: filePath })}`;
|
|
272
463
|
}
|
|
273
464
|
//#endregion
|
|
274
|
-
//#region src/utils/git-changes.ts
|
|
275
|
-
async function getChangedPackages(graph, cwd) {
|
|
276
|
-
return resolveChangedPackages(graph, await getChangedFilePaths(cwd), cwd);
|
|
277
|
-
}
|
|
278
|
-
async function getChangedFilePaths(cwd) {
|
|
279
|
-
const files = /* @__PURE__ */ new Set();
|
|
280
|
-
for (const args of [["diff", "--name-only"], [
|
|
281
|
-
"diff",
|
|
282
|
-
"--cached",
|
|
283
|
-
"--name-only"
|
|
284
|
-
]]) await addGitOutput(files, cwd, args);
|
|
285
|
-
return Array.from(files);
|
|
286
|
-
}
|
|
287
|
-
function resolveChangedPackages(graph, files, cwd) {
|
|
288
|
-
const packages = [...graph.getPackages()].sort((a, b) => b.path.length - a.path.length);
|
|
289
|
-
const matched = /* @__PURE__ */ new Map();
|
|
290
|
-
for (const file of files) for (const pkg of packages) if (isUnderDir(file, pkg.path, cwd)) {
|
|
291
|
-
matched.set(pkg.id, pkg);
|
|
292
|
-
break;
|
|
293
|
-
}
|
|
294
|
-
return [...matched.values()];
|
|
295
|
-
}
|
|
296
|
-
function isUnderDir(file, dir, cwd) {
|
|
297
|
-
const absolute = join(cwd, file);
|
|
298
|
-
const rel = relative(normalize(dir), absolute);
|
|
299
|
-
return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
|
|
300
|
-
}
|
|
301
|
-
async function addGitOutput(files, cwd, args) {
|
|
302
|
-
const result = await x("git", args, { nodeOptions: { cwd } });
|
|
303
|
-
if (result.exitCode !== 0) return;
|
|
304
|
-
for (const line of result.stdout.split("\n")) {
|
|
305
|
-
const trimmed = line.trim();
|
|
306
|
-
if (trimmed) files.add(trimmed);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
//#endregion
|
|
310
465
|
//#region src/cli/index.ts
|
|
311
|
-
var CancelledError = class extends Error {
|
|
312
|
-
constructor() {
|
|
313
|
-
super("Cancelled.");
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
466
|
function createCli(tegami, options = {}) {
|
|
317
467
|
const program = new Command();
|
|
318
|
-
program.name("tegami").description("create changelogs").action((
|
|
319
|
-
|
|
320
|
-
cli: options
|
|
321
|
-
})));
|
|
322
|
-
program.command("version").description("draft and apply a publish plan").action((commandOptions) => runAction(tegami, async () => {
|
|
323
|
-
await versionPackages(tegami, {
|
|
324
|
-
...commandOptions,
|
|
325
|
-
cli: options
|
|
326
|
-
});
|
|
468
|
+
program.name("tegami").description("create changelogs").action(() => runAction(tegami, () => runChangelogTui(tegami)));
|
|
469
|
+
program.command("version").description("draft and apply a publish plan").action(() => runAction(tegami, async () => {
|
|
470
|
+
await versionPackages(tegami, { cli: options });
|
|
327
471
|
}));
|
|
328
472
|
program.command("ci").description("version and publish packages").action(() => runAction(tegami, async () => {
|
|
329
473
|
if (await versionPackages(tegami, { cli: options })) return;
|
|
@@ -338,10 +482,10 @@ function createCli(tegami, options = {}) {
|
|
|
338
482
|
const context = await tegami._internal.context();
|
|
339
483
|
const body = await buildPrPreview(context, await tegami.draft(), commandOptions);
|
|
340
484
|
if (commandOptions.artifact) {
|
|
341
|
-
const artifactPath = resolve(context.cwd, commandOptions.artifact);
|
|
485
|
+
const artifactPath = path.resolve(context.cwd, commandOptions.artifact);
|
|
342
486
|
await writeFile(artifactPath, body);
|
|
343
487
|
if (!isCI()) {
|
|
344
|
-
note(relative(context.cwd, artifactPath) || commandOptions.artifact, "Release preview");
|
|
488
|
+
note(path.relative(context.cwd, artifactPath) || commandOptions.artifact, "Release preview");
|
|
345
489
|
outro("Release preview ready.");
|
|
346
490
|
}
|
|
347
491
|
return;
|
|
@@ -373,134 +517,6 @@ function createCli(tegami, options = {}) {
|
|
|
373
517
|
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)));
|
|
374
518
|
return program;
|
|
375
519
|
}
|
|
376
|
-
async function createChangelogs(tegami, _options) {
|
|
377
|
-
const context = await tegami._internal.context();
|
|
378
|
-
await assertPublishPlanFinished(context);
|
|
379
|
-
intro("Create changelogs");
|
|
380
|
-
let selectedPackages = [];
|
|
381
|
-
if (!isCI()) {
|
|
382
|
-
const useShortname = /* @__PURE__ */ new Map();
|
|
383
|
-
for (const pkg of context.graph.getPackages()) if (useShortname.has(pkg.name)) useShortname.set(pkg.name, false);
|
|
384
|
-
else useShortname.set(pkg.name, true);
|
|
385
|
-
const getPackageLabel = (pkg) => {
|
|
386
|
-
return useShortname.get(pkg.name) ? pkg.name : pkg.id;
|
|
387
|
-
};
|
|
388
|
-
const changedPackages = new Set(await getChangedPackages(context.graph, context.cwd));
|
|
389
|
-
const selectOptions = [];
|
|
390
|
-
const groups = [];
|
|
391
|
-
for (const group of context.graph.getGroups()) {
|
|
392
|
-
const changed = group.packages.some((pkg) => changedPackages.has(pkg));
|
|
393
|
-
groups.push([group, changed]);
|
|
394
|
-
}
|
|
395
|
-
groups.sort((a, b) => (a[1] ? 0 : 1) - (b[1] ? 0 : 1));
|
|
396
|
-
for (const [group, changed] of groups) {
|
|
397
|
-
const members = group.packages.map(getPackageLabel).join(", ");
|
|
398
|
-
selectOptions.push({
|
|
399
|
-
label: `(Group) ${group.name}`,
|
|
400
|
-
value: `group:${group.name}`,
|
|
401
|
-
hint: changed ? `changed · ${members}` : members
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
const packages = context.graph.getPackages().toSorted((a, b) => (changedPackages.has(a) ? 0 : 1) - (changedPackages.has(b) ? 0 : 1));
|
|
405
|
-
for (const pkg of packages) selectOptions.push({
|
|
406
|
-
label: getPackageLabel(pkg),
|
|
407
|
-
value: pkg.id,
|
|
408
|
-
hint: changedPackages.has(pkg) ? "changed" : void 0
|
|
409
|
-
});
|
|
410
|
-
const selected = await autocompleteMultiselect({
|
|
411
|
-
message: "Select packages (leave empty to auto-generate from commits)",
|
|
412
|
-
required: false,
|
|
413
|
-
options: selectOptions
|
|
414
|
-
});
|
|
415
|
-
if (isCancel(selected)) throw new CancelledError();
|
|
416
|
-
selectedPackages = selected;
|
|
417
|
-
}
|
|
418
|
-
if (selectedPackages.length === 0) {
|
|
419
|
-
if (!isCI()) {
|
|
420
|
-
const confirmed = await confirm({
|
|
421
|
-
message: "Auto-generate changelog files from commits?",
|
|
422
|
-
initialValue: true
|
|
423
|
-
});
|
|
424
|
-
if (isCancel(confirmed)) throw new CancelledError();
|
|
425
|
-
if (!confirmed) {
|
|
426
|
-
outro("No changelogs created.");
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
const s = spinner();
|
|
431
|
-
s.start("Reading commits and creating changelogs");
|
|
432
|
-
const created = await tegami.generateChangelog();
|
|
433
|
-
s.stop(created.length === 1 ? "Created 1 changelog file" : `Created ${created.length} changelog files`);
|
|
434
|
-
if (created.length === 0) note("No matching conventional commits were found.", "No changelogs created");
|
|
435
|
-
else note(created.map((entry) => `${entry.filename} (${entry.changes} changes)`).join("\n"), "Created changelogs");
|
|
436
|
-
outro("Changelogs ready.");
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
const packageBumpMap = {};
|
|
440
|
-
const bumpType = await select({
|
|
441
|
-
message: "Select release type",
|
|
442
|
-
options: [
|
|
443
|
-
{
|
|
444
|
-
value: "patch",
|
|
445
|
-
label: "patch"
|
|
446
|
-
},
|
|
447
|
-
{
|
|
448
|
-
value: "minor",
|
|
449
|
-
label: "minor"
|
|
450
|
-
},
|
|
451
|
-
{
|
|
452
|
-
value: "major",
|
|
453
|
-
label: "major"
|
|
454
|
-
},
|
|
455
|
-
{
|
|
456
|
-
value: "per-package",
|
|
457
|
-
label: "choose per-package"
|
|
458
|
-
}
|
|
459
|
-
]
|
|
460
|
-
});
|
|
461
|
-
if (isCancel(bumpType)) throw new CancelledError();
|
|
462
|
-
if (bumpType === "per-package") for (const pkg of selectedPackages) {
|
|
463
|
-
const bumpType = await select({
|
|
464
|
-
message: `Select release type for "${pkg}"`,
|
|
465
|
-
options: [
|
|
466
|
-
{
|
|
467
|
-
value: "patch",
|
|
468
|
-
label: "patch"
|
|
469
|
-
},
|
|
470
|
-
{
|
|
471
|
-
value: "minor",
|
|
472
|
-
label: "minor"
|
|
473
|
-
},
|
|
474
|
-
{
|
|
475
|
-
value: "major",
|
|
476
|
-
label: "major"
|
|
477
|
-
}
|
|
478
|
-
]
|
|
479
|
-
});
|
|
480
|
-
if (isCancel(bumpType)) throw new CancelledError();
|
|
481
|
-
packageBumpMap[pkg] = bumpType;
|
|
482
|
-
}
|
|
483
|
-
else for (const pkg of selectedPackages) packageBumpMap[pkg] = bumpType;
|
|
484
|
-
const message = await multiline({
|
|
485
|
-
message: "Describe change (Markdown supported, press tab then enter to exit)",
|
|
486
|
-
placeholder: "The first line is heading\n\nAdditional description.",
|
|
487
|
-
showSubmit: true,
|
|
488
|
-
validate(value) {
|
|
489
|
-
if (!value?.trim()) return "Enter a message.";
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
if (isCancel(message)) throw new CancelledError();
|
|
493
|
-
const filename = changelogFilename();
|
|
494
|
-
const s = spinner();
|
|
495
|
-
s.start("Creating changelog");
|
|
496
|
-
await mkdir(context.changelogDir, { recursive: true });
|
|
497
|
-
await writeFile(join(context.changelogDir, filename), renderManualChangelog(packageBumpMap, message.trim()));
|
|
498
|
-
s.stop("Created changelog file");
|
|
499
|
-
const notes = [filename];
|
|
500
|
-
for (const pkg of selectedPackages) notes.push(`${pkg}: ${packageBumpMap[pkg]}`);
|
|
501
|
-
note(notes.join("\n"), "Created changelog");
|
|
502
|
-
outro("Changelog ready.");
|
|
503
|
-
}
|
|
504
520
|
async function versionPackages(tegami, options) {
|
|
505
521
|
intro("Version Packages");
|
|
506
522
|
const { version: customVersion } = options.cli;
|
|
@@ -509,15 +525,15 @@ async function versionPackages(tegami, options) {
|
|
|
509
525
|
if (!draft.canApply()) throw new Error(`The draft plan from custom "version" hook must not be applied`);
|
|
510
526
|
for (const plugin of context.plugins) await handlePluginError(plugin, "cli.publishPlanCreated", () => plugin.cli?.publishPlanCreated?.call(context, draft));
|
|
511
527
|
if (!draft.hasPending()) {
|
|
512
|
-
note("No pending
|
|
528
|
+
note("No pending version changes matched workspace packages.", "Nothing to version");
|
|
513
529
|
outro("No versions changed.");
|
|
514
530
|
return false;
|
|
515
531
|
}
|
|
516
532
|
const planEntries = [];
|
|
517
533
|
for (const pkg of context.graph.getPackages()) {
|
|
518
534
|
const plan = draft.getPackagePlan(pkg.id);
|
|
519
|
-
if (!plan
|
|
520
|
-
planEntries.push(`${pkg.id}: ${plan.
|
|
535
|
+
if (!plan || plan.bumpVersion(pkg) === pkg.version) continue;
|
|
536
|
+
planEntries.push(`${pkg.id}: ${pkg.version} → ${plan.bumpVersion(pkg)} (${plan.changelogs?.length ?? 0} changelogs)`);
|
|
521
537
|
if (plan.bumpReasons) for (const reason of plan.bumpReasons) planEntries.push(` - ${reason}`);
|
|
522
538
|
}
|
|
523
539
|
note(planEntries.join("\n"), "Release plan");
|
|
@@ -568,7 +584,7 @@ async function runInitAgent(tegami, options) {
|
|
|
568
584
|
s.start("Writing AGENTS.md");
|
|
569
585
|
const result = await initAgent(context, options);
|
|
570
586
|
s.stop(result.created ? "Created AGENTS.md" : "Appended to AGENTS.md");
|
|
571
|
-
note(relative(context.cwd, result.path) || "AGENTS.md", "Agent instructions");
|
|
587
|
+
note(path.relative(context.cwd, result.path) || "AGENTS.md", "Agent instructions");
|
|
572
588
|
outro("Agents can follow AGENTS.md to write changelogs.");
|
|
573
589
|
}
|
|
574
590
|
async function runCleanup(tegami) {
|
|
@@ -588,16 +604,6 @@ async function runCleanup(tegami) {
|
|
|
588
604
|
}
|
|
589
605
|
outro(`Publish plan at ${planPath} is still pending. Publish it before cleanup.`);
|
|
590
606
|
}
|
|
591
|
-
function renderManualChangelog(packageBumpMap, message) {
|
|
592
|
-
return [
|
|
593
|
-
"---",
|
|
594
|
-
dump({ packages: packageBumpMap }).trim(),
|
|
595
|
-
"---",
|
|
596
|
-
"",
|
|
597
|
-
`## ${message}`,
|
|
598
|
-
""
|
|
599
|
-
].join("\n");
|
|
600
|
-
}
|
|
601
607
|
async function runAction(tegami, action) {
|
|
602
608
|
try {
|
|
603
609
|
const context = await tegami._internal.context();
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
//#region src/utils/error.ts
|
|
2
|
+
var CancelledError = class extends Error {
|
|
3
|
+
constructor() {
|
|
4
|
+
super("Cancelled.");
|
|
5
|
+
}
|
|
6
|
+
};
|
|
2
7
|
function execFailure(context, result) {
|
|
3
8
|
const lines = [context, `(exit ${result.exitCode})`];
|
|
4
9
|
const out = result.stdout.trim();
|
|
@@ -19,4 +24,4 @@ async function handlePluginError(plugin, hookName, callback) {
|
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
//#endregion
|
|
22
|
-
export {
|
|
27
|
+
export { isNodeError as i, execFailure as n, handlePluginError as r, CancelledError as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as bumpVersion } from "./semver-cnZp9koa.js";
|
|
2
2
|
//#region src/graph.ts
|
|
3
3
|
/** Package discovered in the workspace. */
|
|
4
4
|
var WorkspacePackage = class {
|
|
@@ -13,17 +13,21 @@ var WorkspacePackage = class {
|
|
|
13
13
|
setPackageOptions(options) {
|
|
14
14
|
this.opts = options;
|
|
15
15
|
}
|
|
16
|
-
/** create
|
|
17
|
-
|
|
16
|
+
/** create the initial draft plan. */
|
|
17
|
+
initPlan() {
|
|
18
|
+
return { bumpVersion(pkg) {
|
|
19
|
+
return bumpVersion(pkg.version, this.type, this.prerelease);
|
|
20
|
+
} };
|
|
21
|
+
}
|
|
22
|
+
/** configure an initial draft plan to match script-level configs. */
|
|
23
|
+
configurePlan(plan) {
|
|
18
24
|
const { publish, prerelease, npm } = this.opts;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
npm
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
};
|
|
25
|
+
if (publish !== void 0) plan.publish = publish;
|
|
26
|
+
if (prerelease !== void 0) plan.prerelease = prerelease;
|
|
27
|
+
if (npm?.distTag) {
|
|
28
|
+
plan.npm ??= {};
|
|
29
|
+
plan.npm.distTag = npm.distTag;
|
|
30
|
+
}
|
|
27
31
|
}
|
|
28
32
|
};
|
|
29
33
|
/** Dependency graph for discovered workspace packages. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as PackagePlan, C as PublishOptions, D as PackageGroup, E as PackageGraph, O as WorkspacePackage, S as PackagePublishResult, a as PublishPreflight, b as CreateChangelogOptions, c as TegamiPlugin, i as PackageOptions, k as DraftPlan, l as TegamiPluginOption, n as GroupOptions, o as RegistryClient, r as LogGenerator, s as TegamiOptions, v as Tegami, w as PublishResult, x as CreatedChangelog, y as tegami } from "./types-
|
|
1
|
+
import { A as PackagePlan, C as PublishOptions, D as PackageGroup, E as PackageGraph, O as WorkspacePackage, S as PackagePublishResult, a as PublishPreflight, b as CreateChangelogOptions, c as TegamiPlugin, i as PackageOptions, k as DraftPlan, l as TegamiPluginOption, n as GroupOptions, o as RegistryClient, r as LogGenerator, s as TegamiOptions, v as Tegami, w as PublishResult, x as CreatedChangelog, y as tegami } from "./types-Di--A9X1.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 PublishPreflight, type PublishResult, type RegistryClient, Tegami, type TegamiOptions, type TegamiPlugin, type TegamiPluginOption, type WorkspacePackage, tegami };
|