feat(core-analytics): scaffold @repo/core-analytics via generator

Add the `pnpm turbo gen core-package analytics` generator template and
run it to scaffold the @repo/core-analytics workspace package. The
package lands in placeholder state (empty barrel export) ready for the
IAnalytics + NoopAnalytics implementation in the next commit.

Includes:
- turbo/generators/templates/core-package/analytics/ templates
- turbo/generators/config.ts analytics generator registration
- packages/core-analytics/ placeholder scaffold
- apps/web-next/next.config.mjs transpilePackages entry

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-18 11:26:24 +00:00
parent b8d4cfe907
commit ea384c67c4
17 changed files with 236 additions and 2 deletions

View File

@@ -764,17 +764,35 @@ import noRealtimeHandlerReexport from "./rules/no-realtime-handler-reexport.js";
},
printAuditNextSteps,
],
analytics: () => [
() => {
assertOptionalPackageNotPresent("core-analytics");
return "Guard passed — packages/core-analytics does not exist yet.";
},
...emitTemplateTree(
"core-package/analytics",
"packages/core-analytics",
),
() => {
addToTranspilePackages(
"apps/web-next/next.config.mjs",
"@repo/core-analytics",
);
return "Added @repo/core-analytics to transpilePackages.";
},
printAnalyticsNextSteps,
],
};
plop.setGenerator("core-package", {
description:
"Scaffold an optional core package (realtime, events, trpc, ui, audit)",
"Scaffold an optional core package (realtime, events, trpc, ui, audit, analytics)",
prompts: [
{
type: "list",
name: "name",
message: "Which optional core package?",
choices: ["realtime", "events", "trpc", "ui", "audit"],
choices: ["analytics", "audit", "events", "realtime", "trpc", "ui"],
},
],
actions: (answers) => {
@@ -1475,6 +1493,30 @@ function printAuditNextSteps(): string {
].join("\n");
}
function printAnalyticsNextSteps(): string {
return [
"─────────────────────────────────────────────────────────────",
"@repo/core-analytics scaffolded into packages/core-analytics/.",
"",
"Next steps:",
"",
" 1. pnpm install # link the new workspace package",
"",
" 2. Implement IAnalytics + NoopAnalytics in packages/core-analytics/src/",
" (see story 01-scaffold-core-analytics-package bullet 2)",
"",
" 3. Add @repo/core-analytics to feature package.json files that need analytics",
"",
" 4. Wire IAnalytics into apps/web-next/src/server/bind-production.ts:",
' - import { NoopAnalytics, type IAnalytics } from "@repo/core-analytics";',
" - add analytics field to BindAllDeps and BindProductionContext",
" - pass NoopAnalytics (or a vendor adapter) into each feature binder",
"",
" 5. pnpm typecheck && pnpm lint && pnpm test",
"─────────────────────────────────────────────────────────────",
].join("\n");
}
function coreUiComponentActions(a: {
tier: "atom" | "molecule" | "organism";
name: string;