feat(generators): wire events entry + e2e test

Add EVENTS_RULE_BLOCK constant, events entry in CORE_PACKAGE_GENERATORS
dispatch table, events choice in prompts, and printEventsNextSteps helper.
Events entry emits 15 template files + transpilePackages splice + ESLint
no-restricted-syntax splice (E1 + J blocks). Add byte-identical e2e test
that strips @repo/core-events deps before pnpm install, scaffolds via
gen core-package events, and diffs against the snapshot.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-09 13:55:49 +02:00
parent 60961f73d0
commit 681fe6ada1
3 changed files with 177 additions and 2 deletions

View File

@@ -3,7 +3,7 @@ import type { PlopTypes } from "@turbo/gen";
import generator from "./config";
describe("core-package generator", () => {
it("is registered with realtime in choices list", () => {
it("is registered with realtime and events in choices list", () => {
const captured: Array<{ name: string; def: PlopTypes.PlopGeneratorConfig }> = [];
const plopMock = {
setHelper: () => {},
@@ -16,6 +16,7 @@ describe("core-package generator", () => {
const prompts = corePkg!.def.prompts as Array<{ name: string; choices: unknown[] }>;
expect(prompts[0]!.name).toBe("name");
expect(prompts[0]!.choices).toContain("realtime");
expect(prompts[0]!.choices).toContain("events");
});
});
@@ -36,3 +37,20 @@ describe("core-package realtime", () => {
expect(actions.length).toBeGreaterThan(20); // 28 files + extras
});
});
describe("core-package events", () => {
it("emits actions covering package files, transpilePackages, and ESLint rule splice", () => {
const captured: Array<{ name: string; def: PlopTypes.PlopGeneratorConfig }> = [];
const plop = {
setHelper: () => {},
setGenerator: (n: string, d: unknown) => captured.push({ name: n, def: d as PlopTypes.PlopGeneratorConfig }),
} as unknown as PlopTypes.NodePlopAPI;
generator(plop);
const corePkg = captured.find((c) => c.name === "core-package")!.def;
const actions = (corePkg.actions as (a: { name: string }) => PlopTypes.ActionType[])(
{ name: "events" },
);
// 1 guard + 15 template files + transpilePackages + ESLint splice + printNextSteps = 19
expect(actions.length).toBeGreaterThanOrEqual(18);
});
});