tegami 0.1.0 → 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 +212 -209
- package/dist/{error-DBK-9uBa.js → error-qpTCB2ld.js} +10 -6
- 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 +2 -2
- package/dist/index.js +272 -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 +32 -14
- package/dist/providers/npm.d.ts +1 -1
- package/dist/providers/npm.js +33 -18
- package/dist/{semver-mWK2Khi2.js → semver-cnZp9koa.js} +16 -5
- package/dist/{types-UjsZkz42.d.ts → types-Di--A9X1.d.ts} +68 -23
- package/package.json +1 -1
- package/dist/checks-BQISvt_o.js +0 -98
package/dist/checks-BQISvt_o.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { n as handlePluginError } from "./error-DBK-9uBa.js";
|
|
2
|
-
import { n as jsonCodec, t as bumpTypeSchema } from "./schemas-CurBAaW5.js";
|
|
3
|
-
import z$1 from "zod";
|
|
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
|
|
11
|
-
//#region src/plans/store.ts
|
|
12
|
-
const packagePlanStoreSchema = z$1.object({
|
|
13
|
-
type: bumpTypeSchema.optional(),
|
|
14
|
-
changelogIds: z$1.array(z$1.string()).optional(),
|
|
15
|
-
bumpReasons: z$1.array(z$1.string()).optional(),
|
|
16
|
-
npm: z$1.object({ distTag: z$1.string().optional() }).optional(),
|
|
17
|
-
publish: z$1.boolean()
|
|
18
|
-
});
|
|
19
|
-
/** the persisted plan data for actual publishing */
|
|
20
|
-
const planStoreSchema = jsonCodec(z$1.object({
|
|
21
|
-
id: z$1.string(),
|
|
22
|
-
createdAt: z$1.iso.datetime(),
|
|
23
|
-
version: z$1.literal("0.0.0").default("0.0.0"),
|
|
24
|
-
/** release note entries */
|
|
25
|
-
changelogs: z$1.record(z$1.string(), z$1.object({
|
|
26
|
-
filename: z$1.string(),
|
|
27
|
-
subject: z$1.string().optional(),
|
|
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
|
-
})),
|
|
35
|
-
/** package id -> package info */
|
|
36
|
-
packages: z$1.record(z$1.string(), packagePlanStoreSchema)
|
|
37
|
-
}));
|
|
38
|
-
function createPlanStore(draft, context) {
|
|
39
|
-
const store = {
|
|
40
|
-
version: "0.0.0",
|
|
41
|
-
id: `tegami-${Date.now().toString(36)}`,
|
|
42
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
43
|
-
changelogs: {},
|
|
44
|
-
packages: {}
|
|
45
|
-
};
|
|
46
|
-
for (const entry of draft.getChangelogs()) store.changelogs[entry.id] = {
|
|
47
|
-
filename: entry.filename,
|
|
48
|
-
subject: entry.subject,
|
|
49
|
-
packages: Object.fromEntries(entry.packages.entries()),
|
|
50
|
-
sections: entry.sections
|
|
51
|
-
};
|
|
52
|
-
for (const pkg of context.graph.getPackages()) {
|
|
53
|
-
const plan = draft.getPackagePlan(pkg.id);
|
|
54
|
-
if (plan) store.packages[pkg.id] = {
|
|
55
|
-
publish: plan.publish ?? false,
|
|
56
|
-
type: plan.type,
|
|
57
|
-
npm: plan.npm,
|
|
58
|
-
changelogIds: plan.changelogs?.map((entry) => entry.id),
|
|
59
|
-
bumpReasons: plan.bumpReasons ? Array.from(plan.bumpReasons) : void 0
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
return planStoreSchema.encode(store);
|
|
63
|
-
}
|
|
64
|
-
async function readPlanStore(context) {
|
|
65
|
-
try {
|
|
66
|
-
return planStoreSchema.decode(await readFile(context.planPath, "utf8"));
|
|
67
|
-
} catch {}
|
|
68
|
-
}
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/plans/checks.ts
|
|
71
|
-
async function publishPlanStatus(store, context) {
|
|
72
|
-
async function defaultStatus() {
|
|
73
|
-
try {
|
|
74
|
-
await Promise.all(Object.entries(store.packages).map(async ([id, plan]) => {
|
|
75
|
-
const pkg = context.graph.get(id);
|
|
76
|
-
if (!pkg || !plan.publish) return;
|
|
77
|
-
if (!await context.getRegistryClient(pkg).isPackagePublished(pkg)) throw "pending";
|
|
78
|
-
}));
|
|
79
|
-
return { state: "success" };
|
|
80
|
-
} catch (err) {
|
|
81
|
-
if (err === "pending") return { state: "pending" };
|
|
82
|
-
throw err;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
let status = await defaultStatus();
|
|
86
|
-
for (const plugin of context.plugins) {
|
|
87
|
-
const resolved = await handlePluginError(plugin, "resolvePlanStatus", () => plugin.resolvePlanStatus?.call(context, status, { plan: store }));
|
|
88
|
-
if (resolved) status = resolved;
|
|
89
|
-
}
|
|
90
|
-
return status;
|
|
91
|
-
}
|
|
92
|
-
async function assertPublishPlanFinished(context) {
|
|
93
|
-
const store = await readPlanStore(context);
|
|
94
|
-
if (!store) return;
|
|
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.`);
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
|
-
export { changelogFilename as a, readPlanStore as i, publishPlanStatus as n, createPlanStore as r, assertPublishPlanFinished as t };
|