tegami 0.1.5 → 0.2.0
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/api-D-jf_8xY.js +116 -0
- package/dist/cli/index.d.ts +4 -4
- package/dist/cli/index.js +124 -133
- package/dist/{checks-Cwz-Ezkq.js → generate-BMlrn-2e.js} +18 -106
- package/dist/generators/simple.d.ts +1 -1
- package/dist/generators/simple.js +3 -3
- package/dist/{graph-DLKPUXSD.js → graph-DrzluXw8.js} +17 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.js +317 -210
- package/dist/plugins/git.d.ts +1 -1
- package/dist/plugins/git.js +47 -35
- package/dist/plugins/github.d.ts +28 -15
- package/dist/plugins/github.js +158 -142
- package/dist/providers/cargo.d.ts +2 -2
- package/dist/providers/cargo.js +86 -100
- package/dist/providers/npm.d.ts +2 -2
- package/dist/providers/npm.js +132 -129
- package/dist/schemas-B7N6EE2k.js +26 -0
- package/dist/{types-BXk2fMqa.d.ts → types-CurHqnWl.d.ts} +199 -226
- package/package.json +6 -7
- package/dist/schemas-CurBAaW5.js +0 -42
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { a as maxBump, t as bumpDepth } from "./semver-C4vJ4SK8.js";
|
|
2
|
-
import { n as execFailure
|
|
3
|
-
import {
|
|
4
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
|
-
import { join } from "node:path";
|
|
2
|
+
import { n as execFailure } from "./error-DNy8R5ue.js";
|
|
3
|
+
import { t as bumpTypeSchema } from "./schemas-B7N6EE2k.js";
|
|
6
4
|
import { x } from "tinyexec";
|
|
7
5
|
import * as semver from "semver";
|
|
8
|
-
import z
|
|
6
|
+
import z from "zod";
|
|
9
7
|
import { dump } from "js-yaml";
|
|
10
|
-
import { readFile as readFile$1 } from "fs/promises";
|
|
11
8
|
//#region src/utils/conventional-commit.ts
|
|
12
9
|
/**
|
|
13
10
|
* Conventional commit header per conventionalcommits.org and semantic-release defaults.
|
|
@@ -74,15 +71,15 @@ function conventionalCommitToBump(type, breaking) {
|
|
|
74
71
|
}
|
|
75
72
|
//#endregion
|
|
76
73
|
//#region src/changelog/shared.ts
|
|
77
|
-
const changelogPackageConfigSchema = z
|
|
74
|
+
const changelogPackageConfigSchema = z.object({
|
|
78
75
|
type: bumpTypeSchema.optional(),
|
|
79
|
-
replay: z
|
|
76
|
+
replay: z.array(z.string().min(1)).optional()
|
|
80
77
|
});
|
|
81
|
-
const changelogFrontmatterSchema = z
|
|
82
|
-
subject: z
|
|
83
|
-
packages: z
|
|
78
|
+
const changelogFrontmatterSchema = z.object({
|
|
79
|
+
subject: z.string().optional(),
|
|
80
|
+
packages: z.union([z.array(z.string()), z.record(z.string(), z.union([
|
|
84
81
|
bumpTypeSchema,
|
|
85
|
-
z
|
|
82
|
+
z.null(),
|
|
86
83
|
changelogPackageConfigSchema
|
|
87
84
|
]))]).optional()
|
|
88
85
|
});
|
|
@@ -98,9 +95,8 @@ function renderChangelog(frontmatter, body) {
|
|
|
98
95
|
}
|
|
99
96
|
//#endregion
|
|
100
97
|
//#region src/changelog/generate.ts
|
|
101
|
-
async function
|
|
102
|
-
const
|
|
103
|
-
const commits = await readConventionalCommits(context, options);
|
|
98
|
+
async function generateFromCommits(context, { from, to } = {}) {
|
|
99
|
+
const commits = await readConventionalCommits(context, from, to);
|
|
104
100
|
const groups = /* @__PURE__ */ new Map();
|
|
105
101
|
for (const commit of commits) {
|
|
106
102
|
const key = commit.packages.join("\0");
|
|
@@ -108,7 +104,7 @@ async function generateChangelog(context, options = {}) {
|
|
|
108
104
|
if (group) group.push(commit);
|
|
109
105
|
else groups.set(key, [commit]);
|
|
110
106
|
}
|
|
111
|
-
|
|
107
|
+
return Array.from(groups, ([key, changes], index) => {
|
|
112
108
|
const packageNames = key ? key.split("\0") : [];
|
|
113
109
|
let bumpType = "patch";
|
|
114
110
|
for (const change of changes) bumpType = maxBump(change.type, bumpType);
|
|
@@ -126,15 +122,10 @@ async function generateChangelog(context, options = {}) {
|
|
|
126
122
|
changes
|
|
127
123
|
};
|
|
128
124
|
});
|
|
129
|
-
if (write && changelogs.length > 0) {
|
|
130
|
-
await mkdir(context.changelogDir, { recursive: true });
|
|
131
|
-
await Promise.all(changelogs.map((entry) => writeFile(join(context.changelogDir, entry.filename), entry.content)));
|
|
132
|
-
}
|
|
133
|
-
return changelogs;
|
|
134
125
|
}
|
|
135
|
-
async function readConventionalCommits(context,
|
|
136
|
-
|
|
137
|
-
|
|
126
|
+
async function readConventionalCommits(context, from, to) {
|
|
127
|
+
from ??= await latestTag(context.cwd);
|
|
128
|
+
to ??= "HEAD";
|
|
138
129
|
const args = [
|
|
139
130
|
"log",
|
|
140
131
|
"--no-merges",
|
|
@@ -178,8 +169,8 @@ function generateReplays(graph, base) {
|
|
|
178
169
|
for (const [ref, type] of Object.entries(base)) {
|
|
179
170
|
const resolved = graph.getByName(ref);
|
|
180
171
|
for (const pkg of resolved) {
|
|
181
|
-
const plan = pkg.
|
|
182
|
-
pkg.
|
|
172
|
+
const plan = pkg.initDraft();
|
|
173
|
+
pkg.configureDraft(plan, graph.getPackageGroup(pkg.id));
|
|
183
174
|
const prerelease = semver.prerelease(pkg.version)?.[0];
|
|
184
175
|
const targetPrerelease = plan.prerelease;
|
|
185
176
|
if (targetPrerelease && !prerelease || targetPrerelease && prerelease && targetPrerelease === prerelease) packages[pkg.id] = {
|
|
@@ -195,83 +186,4 @@ function changelogFilename(disambiguator = 0) {
|
|
|
195
186
|
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}-${(Date.now() + disambiguator).toString(36)}.md`;
|
|
196
187
|
}
|
|
197
188
|
//#endregion
|
|
198
|
-
|
|
199
|
-
const packagePlanStoreSchema = z$1.object({
|
|
200
|
-
type: bumpTypeSchema.optional(),
|
|
201
|
-
changelogIds: z$1.array(z$1.string()).optional(),
|
|
202
|
-
bumpReasons: z$1.array(z$1.string()).optional(),
|
|
203
|
-
npm: z$1.object({ distTag: z$1.string().optional() }).optional(),
|
|
204
|
-
publish: z$1.boolean()
|
|
205
|
-
});
|
|
206
|
-
/** the persisted plan data for actual publishing */
|
|
207
|
-
const planStoreSchema = jsonCodec(z$1.object({
|
|
208
|
-
id: z$1.string(),
|
|
209
|
-
createdAt: z$1.iso.datetime(),
|
|
210
|
-
version: z$1.literal("0.0.0").default("0.0.0"),
|
|
211
|
-
/** release note entries */
|
|
212
|
-
changelogs: z$1.record(z$1.string(), z$1.object({
|
|
213
|
-
filename: z$1.string(),
|
|
214
|
-
content: z$1.string()
|
|
215
|
-
})),
|
|
216
|
-
/** package id -> package info */
|
|
217
|
-
packages: z$1.record(z$1.string(), packagePlanStoreSchema)
|
|
218
|
-
}));
|
|
219
|
-
function createPlanStore(draft, context) {
|
|
220
|
-
const store = {
|
|
221
|
-
version: "0.0.0",
|
|
222
|
-
id: `tegami-${Date.now().toString(36)}`,
|
|
223
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
224
|
-
changelogs: {},
|
|
225
|
-
packages: {}
|
|
226
|
-
};
|
|
227
|
-
for (const entry of draft.getChangelogs()) store.changelogs[entry.id] = {
|
|
228
|
-
filename: entry.filename,
|
|
229
|
-
content: entry.getRawContent()
|
|
230
|
-
};
|
|
231
|
-
for (const pkg of context.graph.getPackages()) {
|
|
232
|
-
const plan = draft.getPackagePlan(pkg.id);
|
|
233
|
-
if (plan) store.packages[pkg.id] = {
|
|
234
|
-
publish: plan.publish ?? false,
|
|
235
|
-
type: plan.type,
|
|
236
|
-
npm: plan.npm,
|
|
237
|
-
changelogIds: plan.changelogs?.map((entry) => entry.id),
|
|
238
|
-
bumpReasons: plan.bumpReasons ? Array.from(plan.bumpReasons) : void 0
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
return planStoreSchema.encode(store);
|
|
242
|
-
}
|
|
243
|
-
async function readPlanStore(context) {
|
|
244
|
-
try {
|
|
245
|
-
return planStoreSchema.decode(await readFile$1(context.planPath, "utf8"));
|
|
246
|
-
} catch {}
|
|
247
|
-
}
|
|
248
|
-
//#endregion
|
|
249
|
-
//#region src/plans/checks.ts
|
|
250
|
-
async function publishPlanStatus(store, context) {
|
|
251
|
-
async function defaultStatus() {
|
|
252
|
-
try {
|
|
253
|
-
await Promise.all(Object.entries(store.packages).map(async ([id, plan]) => {
|
|
254
|
-
const pkg = context.graph.get(id);
|
|
255
|
-
if (!pkg || !plan.publish) return;
|
|
256
|
-
if (!await context.getRegistryClient(pkg).isPackagePublished(pkg)) throw "pending";
|
|
257
|
-
}));
|
|
258
|
-
return { state: "success" };
|
|
259
|
-
} catch (err) {
|
|
260
|
-
if (err === "pending") return { state: "pending" };
|
|
261
|
-
throw err;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
let status = await defaultStatus();
|
|
265
|
-
for (const plugin of context.plugins) {
|
|
266
|
-
const resolved = await handlePluginError(plugin, "resolvePlanStatus", () => plugin.resolvePlanStatus?.call(context, status, { plan: store }));
|
|
267
|
-
if (resolved) status = resolved;
|
|
268
|
-
}
|
|
269
|
-
return status;
|
|
270
|
-
}
|
|
271
|
-
async function assertPublishPlanFinished(context) {
|
|
272
|
-
const store = await readPlanStore(context);
|
|
273
|
-
if (!store) return;
|
|
274
|
-
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.`);
|
|
275
|
-
}
|
|
276
|
-
//#endregion
|
|
277
|
-
export { changelogFilename as a, changelogFrontmatterSchema as c, readPlanStore as i, renderChangelog as l, publishPlanStatus as n, generateChangelog as o, createPlanStore as r, generateReplays as s, assertPublishPlanFinished as t };
|
|
189
|
+
export { renderChangelog as a, changelogFrontmatterSchema as i, generateFromCommits as n, generateReplays as r, changelogFilename as t };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { i as formatPackageVersion } from "../semver-C4vJ4SK8.js";
|
|
2
2
|
//#region src/generators/simple.ts
|
|
3
3
|
function simpleGenerator() {
|
|
4
|
-
return { generate({
|
|
5
|
-
const lines = [`## ${formatPackageVersion(
|
|
6
|
-
for (const entry of changelogs) {
|
|
4
|
+
return { generate({ pkg, packageDraft }) {
|
|
5
|
+
const lines = [`## ${formatPackageVersion(pkg.name, pkg.version, packageDraft.npm?.distTag)}`, ""];
|
|
6
|
+
for (const entry of packageDraft.changelogs ?? []) {
|
|
7
7
|
let sectionDepth = 4;
|
|
8
8
|
if (entry.subject) lines.push(`### ${entry.subject}`, "");
|
|
9
9
|
else sectionDepth--;
|
|
@@ -13,21 +13,20 @@ var WorkspacePackage = class {
|
|
|
13
13
|
setPackageOptions(options) {
|
|
14
14
|
this.opts = options;
|
|
15
15
|
}
|
|
16
|
-
/** create the initial draft
|
|
17
|
-
|
|
16
|
+
/** create the initial draft. */
|
|
17
|
+
initDraft() {
|
|
18
18
|
return { bumpVersion(pkg) {
|
|
19
19
|
return bumpVersion(pkg.version, this.type, this.prerelease);
|
|
20
20
|
} };
|
|
21
21
|
}
|
|
22
|
-
/** configure an initial draft
|
|
23
|
-
|
|
22
|
+
/** configure an initial draft to match script-level configs. */
|
|
23
|
+
configureDraft(draft, group) {
|
|
24
24
|
const groupOptions = group?.options;
|
|
25
|
-
const {
|
|
26
|
-
if (
|
|
27
|
-
if (prerelease !== void 0) plan.prerelease = prerelease;
|
|
25
|
+
const { prerelease = groupOptions?.prerelease, npm: { distTag = groupOptions?.npm?.distTag } = {} } = this.opts;
|
|
26
|
+
if (prerelease !== void 0) draft.prerelease = prerelease;
|
|
28
27
|
if (distTag) {
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
draft.npm ??= {};
|
|
29
|
+
draft.npm.distTag = distTag;
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
};
|
|
@@ -100,11 +99,19 @@ var PackageGraph = class {
|
|
|
100
99
|
}
|
|
101
100
|
removeGroupMember(group, id) {
|
|
102
101
|
const entry = this.groups.get(group);
|
|
103
|
-
|
|
102
|
+
const pkg = this.packages.get(id);
|
|
103
|
+
if (!entry || !pkg || pkg.group !== entry) return;
|
|
104
104
|
const index = entry.packages.findIndex((pkg) => pkg.id === id);
|
|
105
105
|
if (index >= 0) entry.packages.splice(index, 1);
|
|
106
|
+
pkg.group = void 0;
|
|
106
107
|
}
|
|
107
108
|
unregisterGroup(name) {
|
|
109
|
+
const group = this.groups.get(name);
|
|
110
|
+
if (!group) return;
|
|
111
|
+
for (const pkg of group.packages) {
|
|
112
|
+
const entry = this.packages.get(pkg.id);
|
|
113
|
+
if (entry?.group === group) entry.group = void 0;
|
|
114
|
+
}
|
|
108
115
|
this.groups.delete(name);
|
|
109
116
|
}
|
|
110
117
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { type
|
|
1
|
+
import { A as PackageDraft, C as CommitChangelog, D as WorkspacePackage, E as PackageGroup, O as Draft, S as PublishPlan, T as PackageGraph, _ as tegami, a as PublishPreflight, b as PackagePublishResult, c as TegamiPluginOption, g as Tegami, h as GenerateChangelogOptions, i as PackageOptions, k as DraftPolicy, n as GroupOptions, o as TegamiOptions, r as LogGenerator, s as TegamiPlugin, v as PublishLock, x as PublishOptions, y as PackagePublishPlan } from "./types-CurHqnWl.js";
|
|
2
|
+
export { type CommitChangelog, type Draft, type DraftPolicy, GenerateChangelogOptions, type GroupOptions, type LogGenerator, type PackageDraft, type PackageGraph, type PackageGroup, type PackageOptions, type PackagePublishPlan, type PackagePublishResult, type PublishLock, type PublishOptions, type PublishPlan, type PublishPreflight, Tegami, type TegamiOptions, type TegamiPlugin, type TegamiPluginOption, type WorkspacePackage, tegami };
|