tegami 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +8 -5
- package/dist/generators/simple.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -6
- package/dist/{npm-uJA8deYA.js → npm-CyC2Rk11.js} +8 -10
- package/dist/plugins/cargo.d.ts +1 -1
- package/dist/plugins/cargo.js +34 -31
- package/dist/plugins/git.d.ts +1 -1
- package/dist/plugins/git.js +2 -4
- package/dist/plugins/github.d.ts +7 -7
- package/dist/plugins/github.js +108 -198
- package/dist/plugins/gitlab.d.ts +6 -6
- package/dist/plugins/gitlab.js +113 -203
- package/dist/plugins/go.d.ts +1 -1
- package/dist/plugins/go.js +8 -8
- package/dist/providers/npm.d.ts +1 -1
- package/dist/providers/npm.js +1 -1
- package/dist/{publish-BEYIILK5.js → publish-DAMkayLs.js} +5 -3
- package/dist/{types-Kj7Nxbjz.d.ts → types-BMYzG4dR.d.ts} +16 -3
- package/dist/{version-request-C5vtakPE.d.ts → version-request-BorZZ98V.d.ts} +1 -1
- package/dist/{version-request-C89RO85i.js → version-request-CQ4cJHtP.js} +133 -43
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { i as formatNpmDistTag, r as diffWeight } from "./semver-DrtaCCZK.js";
|
|
2
|
-
import { n as execFailure, s as isCI } from "./error-CAsrGb6e.js";
|
|
1
|
+
import { a as formatPackageVersion, i as formatNpmDistTag, r as diffWeight } from "./semver-DrtaCCZK.js";
|
|
2
|
+
import { l as somePromise, n as execFailure, s as isCI } from "./error-CAsrGb6e.js";
|
|
3
3
|
import { t as _accessExpressionAsString } from "./_accessExpressionAsString-DW_6Xqcp.js";
|
|
4
4
|
import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-CrRqJgaE.js";
|
|
5
5
|
import { t as getPackageBumps } from "./shared-pTOZU5UZ.js";
|
|
6
|
-
import { o as PublishLock, r as runPreflights, s as parsePublishLock, t as initPublishPlan } from "./publish-
|
|
6
|
+
import { o as PublishLock, r as runPreflights, s as parsePublishLock, t as initPublishPlan } from "./publish-DAMkayLs.js";
|
|
7
7
|
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
8
8
|
import { join, relative } from "node:path";
|
|
9
9
|
import { x } from "tinyexec";
|
|
@@ -66,8 +66,8 @@ const validatePublishGroupStore = (() => {
|
|
|
66
66
|
};
|
|
67
67
|
});
|
|
68
68
|
})();
|
|
69
|
-
function
|
|
70
|
-
const
|
|
69
|
+
function versionRequestPlugin(provider) {
|
|
70
|
+
const NamespacePublishGroup = `${provider.name}:publish-group`;
|
|
71
71
|
/** package id -> version before applying the CLI draft */
|
|
72
72
|
const snapshots = /* @__PURE__ */ new Map();
|
|
73
73
|
function resolveConfig(graph) {
|
|
@@ -94,6 +94,19 @@ function onVersionRequest(provider) {
|
|
|
94
94
|
...rest
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
+
/** commit the working tree changes onto a detached HEAD */
|
|
98
|
+
async function createVersionCommit(ctx, config) {
|
|
99
|
+
const { title = "Version Packages", body } = await config.commit?.call(ctx, { type: "version-packages" }) ?? {};
|
|
100
|
+
await run(ctx.cwd, ["checkout", "--detach"], "Failed to detach HEAD for version branches.");
|
|
101
|
+
await run(ctx.cwd, ["add", "-A"], "Failed to stage version changes.");
|
|
102
|
+
const args = [
|
|
103
|
+
"commit",
|
|
104
|
+
"-m",
|
|
105
|
+
title
|
|
106
|
+
];
|
|
107
|
+
if (body) args.push("-m", body);
|
|
108
|
+
await run(ctx.cwd, args, "Failed to commit version changes.");
|
|
109
|
+
}
|
|
97
110
|
/**
|
|
98
111
|
* Commit the group's lock state on top of `parent` and force-push its branch.
|
|
99
112
|
*
|
|
@@ -101,8 +114,8 @@ function onVersionRequest(provider) {
|
|
|
101
114
|
*/
|
|
102
115
|
async function syncGroupBranch(context, opts) {
|
|
103
116
|
const lock = new PublishLock(opts.baseLock);
|
|
104
|
-
while (lock.read(
|
|
105
|
-
lock.write(
|
|
117
|
+
while (lock.read(NamespacePublishGroup));
|
|
118
|
+
lock.write(NamespacePublishGroup, opts.store);
|
|
106
119
|
const commit = await createLockCommit(context, opts.parent, lock.serialize(), await opts.config.commit?.call(context, {
|
|
107
120
|
type: "update-lock",
|
|
108
121
|
store: opts.store,
|
|
@@ -118,15 +131,16 @@ function onVersionRequest(provider) {
|
|
|
118
131
|
return false;
|
|
119
132
|
}
|
|
120
133
|
return {
|
|
121
|
-
|
|
134
|
+
name: `${provider.name}:version-request`,
|
|
135
|
+
/** snapshot package versions */
|
|
122
136
|
initCliDraft() {
|
|
123
137
|
for (const pkg of this.graph.getPackages()) snapshots.set(pkg.id, pkg.version);
|
|
124
138
|
},
|
|
125
|
-
/** commit & push version branches, then upsert their requests
|
|
139
|
+
/** commit & push version branches, then upsert their requests */
|
|
126
140
|
async applyCliDraft(draft) {
|
|
141
|
+
if (!provider.canCreate(this)) return;
|
|
127
142
|
const config = resolveConfig(this.graph);
|
|
128
|
-
if (!config || !
|
|
129
|
-
if (!(config.forceCreate || isCI()) || !await hasGitChanges(this.cwd)) return;
|
|
143
|
+
if (!config || !(config.forceCreate || isCI()) || !await hasGitChanges(this.cwd)) return;
|
|
130
144
|
const requests = [];
|
|
131
145
|
const updatedPackages = /* @__PURE__ */ new Map();
|
|
132
146
|
for (const id of draft.getPackageDrafts().keys()) {
|
|
@@ -152,7 +166,7 @@ function onVersionRequest(provider) {
|
|
|
152
166
|
packages: Array.from(updatedPackages.values())
|
|
153
167
|
});
|
|
154
168
|
if (requests.length === 0) return;
|
|
155
|
-
await createVersionCommit(this
|
|
169
|
+
await createVersionCommit(this, config);
|
|
156
170
|
let baseLock;
|
|
157
171
|
let parent;
|
|
158
172
|
const tasks = [];
|
|
@@ -189,19 +203,30 @@ function onVersionRequest(provider) {
|
|
|
189
203
|
tasks.push(provider.upsert(this, resolved, !inSync));
|
|
190
204
|
continue;
|
|
191
205
|
}
|
|
192
|
-
await
|
|
206
|
+
await run(this.cwd, [
|
|
207
|
+
"checkout",
|
|
208
|
+
"-B",
|
|
209
|
+
branch
|
|
210
|
+
], "Failed to create the version branch.");
|
|
211
|
+
await run(this.cwd, [
|
|
212
|
+
"push",
|
|
213
|
+
"--force",
|
|
214
|
+
"-u",
|
|
215
|
+
"origin",
|
|
216
|
+
branch
|
|
217
|
+
], "Failed to push the version branch to origin. Ensure `origin` is configured and you have push access.");
|
|
193
218
|
await provider.upsert(this, resolved, true);
|
|
194
219
|
}
|
|
195
220
|
await Promise.all(tasks);
|
|
196
221
|
},
|
|
197
|
-
/** restore publish groups from the lock into the plan
|
|
222
|
+
/** restore publish groups from the lock into the plan */
|
|
198
223
|
initPublishPlan({ lock, plan }) {
|
|
199
224
|
const config = resolveConfig(this.graph);
|
|
200
225
|
if (!config) return;
|
|
201
226
|
let data;
|
|
202
227
|
const publishGroups = /* @__PURE__ */ new Map();
|
|
203
228
|
plan.$versionRequest = { publishGroups };
|
|
204
|
-
while (data = lock.read(
|
|
229
|
+
while (data = lock.read(NamespacePublishGroup)) {
|
|
205
230
|
const validated = validatePublishGroupStore(data);
|
|
206
231
|
if (!validated.success) continue;
|
|
207
232
|
const store = validated.data;
|
|
@@ -228,7 +253,7 @@ function onVersionRequest(provider) {
|
|
|
228
253
|
if (!publishGroups) return;
|
|
229
254
|
for (const s of publishGroups.values()) if (s === "pending") return "pending";
|
|
230
255
|
},
|
|
231
|
-
/** re-sync the version requests of pending publish groups
|
|
256
|
+
/** re-sync the version requests of pending publish groups */
|
|
232
257
|
async beforePublishAll({ plan }) {
|
|
233
258
|
if (plan.options.dryRun || !provider.canCreate(this)) return;
|
|
234
259
|
const config = resolveConfig(this.graph);
|
|
@@ -388,32 +413,6 @@ async function resolveRemoteBranches(cwd, branches) {
|
|
|
388
413
|
async function hasGitChanges(cwd) {
|
|
389
414
|
return (await run(cwd, ["status", "--porcelain"], "Failed to check git status.")).length > 0;
|
|
390
415
|
}
|
|
391
|
-
/** commit the working tree changes onto a detached HEAD */
|
|
392
|
-
async function createVersionCommit(cwd, { title = "Version Packages", body } = {}) {
|
|
393
|
-
await run(cwd, ["checkout", "--detach"], "Failed to detach HEAD for version branches.");
|
|
394
|
-
await run(cwd, ["add", "-A"], "Failed to stage version changes.");
|
|
395
|
-
const args = [
|
|
396
|
-
"commit",
|
|
397
|
-
"-m",
|
|
398
|
-
title
|
|
399
|
-
];
|
|
400
|
-
if (body) args.push("-m", body);
|
|
401
|
-
await run(cwd, args, "Failed to commit version changes.");
|
|
402
|
-
}
|
|
403
|
-
async function pushBranch(cwd, branch) {
|
|
404
|
-
await run(cwd, [
|
|
405
|
-
"checkout",
|
|
406
|
-
"-B",
|
|
407
|
-
branch
|
|
408
|
-
], "Failed to create the version branch.");
|
|
409
|
-
await run(cwd, [
|
|
410
|
-
"push",
|
|
411
|
-
"--force",
|
|
412
|
-
"-u",
|
|
413
|
-
"origin",
|
|
414
|
-
branch
|
|
415
|
-
], "Failed to push the version branch to origin. Ensure `origin` is configured and you have push access.");
|
|
416
|
-
}
|
|
417
416
|
async function run(cwd, args, message, env) {
|
|
418
417
|
const result = await x("git", args, { nodeOptions: {
|
|
419
418
|
cwd,
|
|
@@ -469,5 +468,96 @@ function formatPreview({ graph, npm }, draft, newChangelogNames, labels) {
|
|
|
469
468
|
lines.push(`Run \`${npm?.client ?? "npm"} run tegami\` locally to create a changelog interactively.`, "", `<sub>Managed by [Tegami](https://tegami.fuma-nama.dev).</sub>`, "");
|
|
470
469
|
return lines.join("\n");
|
|
471
470
|
}
|
|
471
|
+
async function resolveFileCommit(ctx, filename) {
|
|
472
|
+
const result = await x("git", [
|
|
473
|
+
"log",
|
|
474
|
+
"--diff-filter=A",
|
|
475
|
+
"-1",
|
|
476
|
+
"--format=%H",
|
|
477
|
+
"--",
|
|
478
|
+
relative(ctx.cwd, join(ctx.changelogDir, filename))
|
|
479
|
+
], { nodeOptions: { cwd: ctx.cwd } });
|
|
480
|
+
if (result.exitCode !== 0) return;
|
|
481
|
+
return result.stdout.trim() || void 0;
|
|
482
|
+
}
|
|
483
|
+
function createAutoRelease({ eager, create, override, overrideGroup, releaseExistsByTag, formatChangelog }) {
|
|
484
|
+
async function defaultNotes(ctx, pkg, packagePlan) {
|
|
485
|
+
if (packagePlan && packagePlan.changelogs.length > 0) return (await Promise.all(packagePlan.changelogs.map(formatChangelog.bind(ctx)))).join("\n\n");
|
|
486
|
+
return `Published ${formatPackageVersion(pkg.name, pkg.version, packagePlan?.npm?.distTag)}.`;
|
|
487
|
+
}
|
|
488
|
+
async function defaultGroupedNotes(ctx, plan, packages) {
|
|
489
|
+
const changelogs = /* @__PURE__ */ new Map();
|
|
490
|
+
for (const pkg of packages) {
|
|
491
|
+
const packagePlan = plan.packages.get(pkg.id);
|
|
492
|
+
if (!packagePlan) continue;
|
|
493
|
+
for (const entry of packagePlan.changelogs) changelogs.set(entry.id, entry);
|
|
494
|
+
}
|
|
495
|
+
const sections = [packages.map((pkg) => {
|
|
496
|
+
const packagePlan = plan.packages.get(pkg.id);
|
|
497
|
+
return `- ${formatPackageVersion(pkg.name, pkg.version, packagePlan?.npm?.distTag)}`;
|
|
498
|
+
}).join("\n")];
|
|
499
|
+
if (changelogs.size > 0) {
|
|
500
|
+
const notes = await Promise.all(Array.from(changelogs.values(), formatChangelog.bind(ctx)));
|
|
501
|
+
sections.push("", notes.join("\n\n"));
|
|
502
|
+
}
|
|
503
|
+
return sections.join("\n");
|
|
504
|
+
}
|
|
505
|
+
return {
|
|
506
|
+
async hasPending(plan) {
|
|
507
|
+
const requiredTags = /* @__PURE__ */ new Set();
|
|
508
|
+
for (const pkg of plan.packages.values()) if (pkg.preflight.shouldPublish && pkg.git?.tag) requiredTags.add(pkg.git.tag);
|
|
509
|
+
return somePromise(Array.from(requiredTags, (tag) => releaseExistsByTag.call(this, tag)), (exists) => !exists);
|
|
510
|
+
},
|
|
511
|
+
async create(plan) {
|
|
512
|
+
const groups = /* @__PURE__ */ new Map();
|
|
513
|
+
for (const [id, { preflight, publishResult, git }] of plan.packages) {
|
|
514
|
+
if (!eager && publishResult.type === "failed") return;
|
|
515
|
+
const tag = git?.tag;
|
|
516
|
+
if (!tag || !preflight.shouldPublish) continue;
|
|
517
|
+
const pkg = this.graph.get(id);
|
|
518
|
+
const group = groups.get(tag);
|
|
519
|
+
if (group) group.push(pkg);
|
|
520
|
+
else groups.set(tag, [pkg]);
|
|
521
|
+
}
|
|
522
|
+
await Promise.all(Array.from(groups, async ([tag, packages]) => {
|
|
523
|
+
for (const member of packages) if (plan.packages.get(member.id).publishResult.type === "failed") return;
|
|
524
|
+
if (await releaseExistsByTag.call(this, tag)) return;
|
|
525
|
+
if (packages.length > 1) {
|
|
526
|
+
const { title = tag, notes = await defaultGroupedNotes(this, plan, packages), ...rest } = await overrideGroup?.call(this, {
|
|
527
|
+
tag,
|
|
528
|
+
packages,
|
|
529
|
+
plan
|
|
530
|
+
}) ?? {};
|
|
531
|
+
await create({
|
|
532
|
+
input: {
|
|
533
|
+
title,
|
|
534
|
+
notes,
|
|
535
|
+
...rest
|
|
536
|
+
},
|
|
537
|
+
tag,
|
|
538
|
+
packages
|
|
539
|
+
});
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
const pkg = packages[0];
|
|
543
|
+
const packagePlan = plan.packages.get(pkg.id);
|
|
544
|
+
const { title = formatPackageVersion(pkg.name, pkg.version, packagePlan?.npm?.distTag), notes = await defaultNotes(this, pkg, packagePlan), ...rest } = await override?.call(this, {
|
|
545
|
+
tag,
|
|
546
|
+
pkg,
|
|
547
|
+
plan
|
|
548
|
+
}) ?? {};
|
|
549
|
+
await create({
|
|
550
|
+
input: {
|
|
551
|
+
title,
|
|
552
|
+
notes,
|
|
553
|
+
...rest
|
|
554
|
+
},
|
|
555
|
+
tag,
|
|
556
|
+
packages
|
|
557
|
+
});
|
|
558
|
+
}));
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
}
|
|
472
562
|
//#endregion
|
|
473
|
-
export {
|
|
563
|
+
export { versionRequestPlugin as i, formatPreview as n, resolveFileCommit as r, createAutoRelease as t };
|