@cosmicdrift/kumiko-framework 0.276.0 → 0.277.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-framework",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.277.0",
|
|
4
4
|
"description": "Framework core — engine, pipeline, API, DB, and every other bit that makes Kumiko go.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
"./package.json": "./package.json"
|
|
199
199
|
},
|
|
200
200
|
"dependencies": {
|
|
201
|
-
"@cosmicdrift/kumiko-types": "0.
|
|
201
|
+
"@cosmicdrift/kumiko-types": "0.277.0",
|
|
202
202
|
"bullmq": "^5.76.7",
|
|
203
203
|
"bun-types": "^1.3.13",
|
|
204
204
|
"hono": "^4.13.1",
|
|
@@ -214,7 +214,7 @@
|
|
|
214
214
|
"zod": "^4.4.3"
|
|
215
215
|
},
|
|
216
216
|
"devDependencies": {
|
|
217
|
-
"@cosmicdrift/kumiko-dispatcher-live": "0.
|
|
217
|
+
"@cosmicdrift/kumiko-dispatcher-live": "0.277.0",
|
|
218
218
|
"bun-types": "^1.3.13",
|
|
219
219
|
"pino-pretty": "^13.1.3"
|
|
220
220
|
},
|
package/src/changes.json
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.277.0",
|
|
4
|
+
"type": "improvement",
|
|
5
|
+
"title": "Changesets are the single source for upgrade changelog entries",
|
|
6
|
+
"detail": "The release step folds structured Changeset metadata into changes.json with the actual published version."
|
|
7
|
+
},
|
|
2
8
|
{
|
|
3
9
|
"version": "0.276.0",
|
|
4
10
|
"type": "improvement",
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { parseChangesetChanges } from "../changeset-changes";
|
|
3
|
+
|
|
4
|
+
describe("parseChangesetChanges", () => {
|
|
5
|
+
test("parses a structured change and derives detail from the body", () => {
|
|
6
|
+
const changes = parseChangesetChanges(
|
|
7
|
+
`---\n"@cosmicdrift/kumiko-framework": minor\n---\n\nAdds the new upgrade flow.\n\nMore detail.\n\n<!-- kumiko-changes\nfeature: framework\ntype: improvement\ntitle: Adds the new upgrade flow\n-->`,
|
|
8
|
+
".changeset/upgrade-flow.md",
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
expect(changes).toEqual([
|
|
12
|
+
{
|
|
13
|
+
feature: "framework",
|
|
14
|
+
type: "improvement",
|
|
15
|
+
title: "Adds the new upgrade flow",
|
|
16
|
+
detail: "More detail.",
|
|
17
|
+
source: ".changeset/upgrade-flow.md",
|
|
18
|
+
},
|
|
19
|
+
]);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("parses multiple blocks with multiline migration", () => {
|
|
23
|
+
const changes = parseChangesetChanges(
|
|
24
|
+
`---\n"@cosmicdrift/kumiko-framework": minor\n---\n\n<!-- kumiko-changes\nfeature: framework\ntype: breaking\ntitle: Removes the old flow\nmigration: |\n Replace the old call.\n Then run the migration.\n-->\n\n<!-- kumiko-changes\nfeature: sessions\ntype: fix\ntitle: Fixes session cleanup\n-->`,
|
|
25
|
+
".changeset/two-features.md",
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(changes.map(({ feature, type, migration }) => ({ feature, type, migration }))).toEqual([
|
|
29
|
+
{
|
|
30
|
+
feature: "framework",
|
|
31
|
+
type: "breaking",
|
|
32
|
+
migration: "Replace the old call.\nThen run the migration.",
|
|
33
|
+
},
|
|
34
|
+
{ feature: "sessions", type: "fix", migration: undefined },
|
|
35
|
+
]);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("rejects a breaking change without migration", () => {
|
|
39
|
+
expect(() =>
|
|
40
|
+
parseChangesetChanges(
|
|
41
|
+
`---\n"@cosmicdrift/kumiko-framework": minor\n---\n\n<!-- kumiko-changes\nfeature: framework\ntype: breaking\ntitle: Removes the old flow\n-->`,
|
|
42
|
+
".changeset/breaking.md",
|
|
43
|
+
),
|
|
44
|
+
).toThrow('breaking change "Removes the old flow" missing migration field');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("rejects an unknown type", () => {
|
|
48
|
+
expect(() =>
|
|
49
|
+
parseChangesetChanges(
|
|
50
|
+
`---\n"@cosmicdrift/kumiko-framework": patch\n---\n\n<!-- kumiko-changes\nfeature: framework\ntype: feature\ntitle: Invalid\n-->`,
|
|
51
|
+
".changeset/invalid.md",
|
|
52
|
+
),
|
|
53
|
+
).toThrow("type must be breaking, improvement, or fix");
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { type ChangelogType, validateChangelog } from "./feature-changelog";
|
|
2
|
+
|
|
3
|
+
export type PendingChange = {
|
|
4
|
+
readonly feature: string;
|
|
5
|
+
readonly type: ChangelogType;
|
|
6
|
+
readonly title: string;
|
|
7
|
+
readonly detail?: string;
|
|
8
|
+
readonly migration?: string;
|
|
9
|
+
readonly codemod?: string;
|
|
10
|
+
readonly source: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const BLOCK_RE = /<!--\s*kumiko-changes\s*\n([\s\S]*?)\n\s*-->/g;
|
|
14
|
+
const TYPE_VALUES = new Set<ChangelogType>(["breaking", "improvement", "fix"]);
|
|
15
|
+
const KEY_RE = /^(feature|type|title|detail|migration|codemod):(?:\s(.*))?$/;
|
|
16
|
+
|
|
17
|
+
function requiredField(fields: ReadonlyMap<string, string>, field: string, source: string): string {
|
|
18
|
+
const value = fields.get(field)?.trim();
|
|
19
|
+
if (!value) throw new Error(`${source}: kumiko-changes ${field} is required`);
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function parseBlock(raw: string, source: string): ReadonlyMap<string, string> {
|
|
24
|
+
const fields = new Map<string, string>();
|
|
25
|
+
const lines = raw.split("\n");
|
|
26
|
+
|
|
27
|
+
for (let index = 0; index < lines.length; index++) {
|
|
28
|
+
const line = lines[index] ?? "";
|
|
29
|
+
if (line.trim() === "") continue;
|
|
30
|
+
const match = KEY_RE.exec(line.trim());
|
|
31
|
+
if (!match) throw new Error(`${source}: invalid kumiko-changes line "${line.trim()}"`);
|
|
32
|
+
|
|
33
|
+
const key = match[1];
|
|
34
|
+
if (!key) throw new Error(`${source}: invalid kumiko-changes field`);
|
|
35
|
+
if (fields.has(key)) throw new Error(`${source}: duplicate kumiko-changes field "${key}"`);
|
|
36
|
+
const value = match[2];
|
|
37
|
+
if (value === "|") {
|
|
38
|
+
const continuation: string[] = [];
|
|
39
|
+
while (index + 1 < lines.length && (lines[index + 1]?.startsWith(" ") ?? false)) {
|
|
40
|
+
index++;
|
|
41
|
+
const continuationLine = lines[index];
|
|
42
|
+
if (continuationLine) continuation.push(continuationLine.slice(2));
|
|
43
|
+
}
|
|
44
|
+
fields.set(key, continuation.join("\n").trim());
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
fields.set(key, value ?? "");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return fields;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function proseWithoutMetadata(markdown: string): string[] {
|
|
54
|
+
const withoutFrontmatter = markdown.replace(/^\s*---\n[\s\S]*?\n---\s*/, "");
|
|
55
|
+
return withoutFrontmatter
|
|
56
|
+
.replace(BLOCK_RE, "")
|
|
57
|
+
.split("\n")
|
|
58
|
+
.map((line) => line.trim())
|
|
59
|
+
.filter((line) => line !== "");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Parse structured upgrade metadata embedded in a Changeset body. */
|
|
63
|
+
export function parseChangesetChanges(markdown: string, source: string): readonly PendingChange[] {
|
|
64
|
+
const changes: PendingChange[] = [];
|
|
65
|
+
const prose = proseWithoutMetadata(markdown);
|
|
66
|
+
BLOCK_RE.lastIndex = 0;
|
|
67
|
+
let match = BLOCK_RE.exec(markdown);
|
|
68
|
+
while (match !== null) {
|
|
69
|
+
const block = match[1];
|
|
70
|
+
if (!block) throw new Error(`${source}: empty kumiko-changes block`);
|
|
71
|
+
const fields = parseBlock(block, source);
|
|
72
|
+
const feature = requiredField(fields, "feature", source);
|
|
73
|
+
const rawType = requiredField(fields, "type", source);
|
|
74
|
+
if (!TYPE_VALUES.has(rawType as ChangelogType)) {
|
|
75
|
+
throw new Error(`${source}: kumiko-changes type must be breaking, improvement, or fix`);
|
|
76
|
+
}
|
|
77
|
+
const title = fields.get("title")?.trim() || prose[0];
|
|
78
|
+
if (!title) throw new Error(`${source}: kumiko-changes title is required`);
|
|
79
|
+
|
|
80
|
+
const detail =
|
|
81
|
+
fields.get("detail")?.trim() ||
|
|
82
|
+
prose
|
|
83
|
+
.slice(prose.length > 0 ? 1 : 0)
|
|
84
|
+
.join("\n")
|
|
85
|
+
.trim();
|
|
86
|
+
const migration = fields.get("migration")?.trim();
|
|
87
|
+
const codemod = fields.get("codemod")?.trim();
|
|
88
|
+
const change: PendingChange = {
|
|
89
|
+
feature,
|
|
90
|
+
type: rawType as ChangelogType,
|
|
91
|
+
title,
|
|
92
|
+
...(detail ? { detail } : {}),
|
|
93
|
+
...(migration ? { migration } : {}),
|
|
94
|
+
...(codemod ? { codemod } : {}),
|
|
95
|
+
source,
|
|
96
|
+
};
|
|
97
|
+
const validation = validateChangelog({ version: "0.0.0", ...change });
|
|
98
|
+
if (validation.length > 0) throw new Error(`${source}: ${validation.join("; ")}`);
|
|
99
|
+
changes.push(change);
|
|
100
|
+
match = BLOCK_RE.exec(markdown);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return changes;
|
|
104
|
+
}
|
package/src/engine/index.ts
CHANGED
|
@@ -13,6 +13,9 @@ const ALLOWED_FILES = new Set([
|
|
|
13
13
|
"packages/bundled-features/src/tenant/seeding.ts",
|
|
14
14
|
"packages/bundled-features/src/tier-engine/feature.ts",
|
|
15
15
|
"packages/framework/src/event-store/__tests__/unscoped-stream-primitives.guard.test.ts",
|
|
16
|
+
// Fixtures of the AST guard that enforces this same restriction.
|
|
17
|
+
"packages/guards/src/__tests__/guard-fires.test.ts",
|
|
18
|
+
"packages/guards/src/__tests__/guard-restricted-symbols.test.ts",
|
|
16
19
|
]);
|
|
17
20
|
|
|
18
21
|
const REPO_ROOT = `${import.meta.dir}/../../../../..`;
|