From e7d6f5d8983884ba93c25bd64e9d48b298d5039b Mon Sep 17 00:00:00 2001 From: Jerred Shepherd Date: Thu, 26 Nov 2026 11:52:38 -0800 Subject: [PATCH 1/3] feat(root): one stack standard for the ops consoles, Bun catalog and stack check Why The ten first-party ops consoles shared React, Vite, TypeScript, Vitest, Zod and console-ui, then diverged below that: React Router beside TanStack Router and hand-rolled routing, REST beside tRPC, raw SQLite beside Prisma. Nothing wrote the standard down, kept versions aligned, or stopped a new console from starting from a bare server. What - Root Bun `catalog` of the shared library versions (nothing upgraded); the ten consoles, console-ui and ops-model declare them as `catalog:`. - Renovate reads the catalog through a JSONata custom manager (its npm manager does not read `catalog`); `check-floating-deps` accepts `catalog:`. - `bun run check-console-stack` (wired into package.json, turbo and verify): required libraries, banned alternatives, `catalog:` use, Rust-console exceptions, and a per-app allowlist of today's deviations that can only shrink. - Mail, Flags and Feeds lint with the React rules; their `useEffect` calls are replaced with ref callbacks, `` and derived state. - `new-service.ts --console` scaffolds the standard stack. - Wiki reference `console-stack`, the why in the hosted-service model page, the how-to flag, and one line in AGENTS.md. Verification - `bun install --frozen-lockfile`; `bunx turbo run typecheck lint test` over the ten consoles, console-ui and ops-model: 56 of 56 tasks pass. - check-console-stack, check-floating-deps, renovate-hints and the Renovate, scaffolder and root-scripts suites pass; knip shows only the existing `#generated` unresolved imports; jscpd ratchet passes; wiki builds. - A scaffolded `--console` package typechecks, lints, tests, builds and serves `/healthz`, `/trpc` and the client. - Renovate extraction of the catalog verified with a local `renovate --dry-run=extract`. - Not run: live Renovate PR creation; deployment (no runtime change). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --- AGENTS.md | 10 +- bun.lock | 412 ++++++++------- package.json | 35 ++ packages/alert-dashboard/package.json | 46 +- packages/charts/package.json | 22 +- packages/ci-cache/package.json | 20 +- packages/console-ui/package.json | 28 +- packages/delivery/package.json | 40 +- .../homelab/hosted-service-model.md | 27 + .../docs/how-to/add-a-hosted-service.md | 25 +- .../content/docs/reference/console-stack.md | 135 +++++ packages/errors/package.json | 34 +- packages/feeds/eslint.config.ts | 5 +- packages/feeds/package.json | 28 +- packages/feeds/src/client/app.tsx | 134 +---- packages/feeds/src/client/feeds-table.tsx | 6 +- packages/feeds/src/client/shortcuts.ts | 118 +++++ .../feeds/src/client/user-feed-dialog.tsx | 93 ++-- packages/flags/eslint.config.ts | 14 +- packages/flags/package.json | 30 +- packages/flags/src/client/api.ts | 37 +- packages/flags/src/client/app.tsx | 8 +- packages/flags/src/client/management-api.ts | 4 +- .../flags/src/client/monaco/diff-view.tsx | 97 ++-- .../flags/src/client/views/drift-page.tsx | 28 +- packages/flags/src/client/views/views-api.ts | 43 +- packages/golink/package.json | 40 +- packages/mail/eslint.config.ts | 5 +- packages/mail/package.json | 30 +- packages/ops-model/package.json | 8 +- packages/tracker/package.json | 52 +- renovate.json | 12 +- scripts/checks/check-console-stack.test.ts | 269 ++++++++++ scripts/checks/check-console-stack.ts | 274 ++++++++++ scripts/checks/console-stack-rules.ts | 407 +++++++++++++++ .../checks/deps/check-floating-deps.test.ts | 16 + scripts/checks/deps/check-floating-deps.ts | 39 +- .../checks/deps/check-renovate-hints.test.ts | 19 +- scripts/checks/deps/check-renovate-hints.ts | 17 +- scripts/misc/new-service-console.ts | 481 ++++++++++++++++++ scripts/misc/new-service-files.ts | 7 +- scripts/misc/new-service-options.ts | 8 +- scripts/misc/new-service.test.ts | 137 +++++ scripts/misc/new-service.ts | 19 +- scripts/renovate-config.test.ts | 2 +- scripts/verify.ts | 1 + turbo.json | 22 + 47 files changed, 2667 insertions(+), 677 deletions(-) create mode 100644 packages/docs/wiki/src/content/docs/reference/console-stack.md create mode 100644 packages/feeds/src/client/shortcuts.ts create mode 100644 scripts/checks/check-console-stack.test.ts create mode 100644 scripts/checks/check-console-stack.ts create mode 100644 scripts/checks/console-stack-rules.ts create mode 100644 scripts/misc/new-service-console.ts diff --git a/AGENTS.md b/AGENTS.md index 51552666b49..ed26ec9cf0b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -182,11 +182,11 @@ review gate observes both the code and thread state. ## Task-specific guidance -Use the matching repository skill in `.agents/skills/` for repeatable delivery, -homelab, Delivery recovery, Scout, Temporal, TaskNotes, Minecraft harness and -building, docs, Tracker, Experiments, PostHog, Discord, or report rendering -work. Package-local runtime skills remain application assets and do not replace -repository workflow guidance. +Use the matching repository skill in `.agents/skills/` for delivery, homelab, +Delivery recovery, Scout, Temporal, TaskNotes, Minecraft, docs, Tracker, +Experiments, PostHog, Discord, or report rendering work. Package-local runtime +skills remain application assets, not repository workflow guidance. First-party +web consoles follow `packages/docs/wiki/src/content/docs/reference/console-stack.md`. <!-- BEGIN:turborepo-agent-rules --> diff --git a/bun.lock b/bun.lock index a754a7d1404..b130492c8ff 100644 --- a/bun.lock +++ b/bun.lock @@ -20,9 +20,9 @@ "name": "@shepherdjerred/alert-dashboard", "version": "0.1.0", "dependencies": { - "@base-ui/react": "^1.6.0", - "@hono/bun": "^1.0.1", - "@js-temporal/polyfill": "^0.5.1", + "@base-ui/react": "catalog:", + "@hono/bun": "catalog:", + "@js-temporal/polyfill": "catalog:", "@opentelemetry/api": "^1.9.1", "@opentelemetry/context-async-hooks": "^2.12.0", "@opentelemetry/exporter-trace-otlp-http": "^0.223.0", @@ -31,7 +31,7 @@ "@opentelemetry/sdk-trace-base": "^2.12.0", "@opentelemetry/semantic-conventions": "^1.40.0", "@prisma/adapter-libsql": "7.10.1", - "@prisma/client": "^7.10.1", + "@prisma/client": "catalog:", "@prisma/client-runtime-utils": "7.10.1", "@shepherdjerred/config": "workspace:*", "@shepherdjerred/experiments": "workspace:*", @@ -42,36 +42,36 @@ "@shepherdjerred/ops-clients": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", "@tanstack/react-form": "^1.33.6", - "@tanstack/react-query": "^5.101.2", - "@trpc/client": "^11.18.0", - "@trpc/server": "^11.18.0", - "@trpc/tanstack-react-query": "^11.18.0", - "hono": "^4.12.18", - "lucide-react": "^1.14.0", - "prisma": "^7.10.1", - "react": "19.3.1", - "react-dom": "19.3.1", + "@tanstack/react-query": "catalog:", + "@trpc/client": "catalog:", + "@trpc/server": "catalog:", + "@trpc/tanstack-react-query": "catalog:", + "hono": "catalog:", + "lucide-react": "catalog:", + "prisma": "catalog:", + "react": "catalog:", + "react-dom": "catalog:", "react-router": "8.5.3", - "uplot": "^1.6.32", - "zod": "^4.4.3", + "uplot": "catalog:", + "zod": "catalog:", }, "devDependencies": { - "@axe-core/playwright": "^4.14.1", + "@axe-core/playwright": "catalog:", "@playwright/test": "1.64.0", "@shepherdjerred/architecture": "workspace:*", "@shepherdjerred/console-ui": "workspace:*", "@shepherdjerred/eslint-config": "workspace:*", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", "jiti": "^2.7.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2", + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:", }, }, "packages/arcade": { @@ -385,44 +385,44 @@ "@shepherdjerred/eslint-config": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", - "lucide-react": "^1.14.0", - "react": "19.3.1", - "react-dom": "19.3.1", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2", - "zod": "^4.4.3", + "lucide-react": "catalog:", + "react": "catalog:", + "react-dom": "catalog:", + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:", + "zod": "catalog:", }, }, "packages/ci-cache": { "name": "@shepherdjerred/ci-cache", "version": "0.1.0", "dependencies": { - "react": "19.3.1", - "react-dom": "19.3.1", - "zod": "^4.4.3", + "react": "catalog:", + "react-dom": "catalog:", + "zod": "catalog:", }, "devDependencies": { "@shepherdjerred/console-ui": "workspace:*", "@shepherdjerred/eslint-config": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", + "@vitejs/plugin-react": "catalog:", "eslint": "^10.7.0", "jiti": "^2.7.0", - "lucide-react": "^1.14.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2", + "lucide-react": "catalog:", + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:", }, }, "packages/code-review": { @@ -527,15 +527,15 @@ "name": "@shepherdjerred/console-ui", "version": "0.1.0", "dependencies": { - "@base-ui/react": "^1.6.0", + "@base-ui/react": "catalog:", "@fontsource-variable/inter": "^5.3.0", - "@js-temporal/polyfill": "^0.5.1", + "@js-temporal/polyfill": "catalog:", "@tanstack/react-form": "^1.33.6", "@tanstack/react-table": "^9.3.1", - "@tanstack/react-virtual": "^3.14.26", - "clsx": "^2.1.1", - "lucide-react": "^1.14.0", - "zod": "^4.4.3", + "@tanstack/react-virtual": "catalog:", + "clsx": "catalog:", + "lucide-react": "catalog:", + "zod": "catalog:", }, "devDependencies": { "@shepherdjerred/eslint-config": "workspace:*", @@ -543,20 +543,20 @@ "@tsconfig/recommended": "^1.0.13", "@tsconfig/strictest": "^2.0.8", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitest/coverage-istanbul": "5.1.2", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", "jiti": "^2.7.0", "jsdom": "^31.0.1", - "react": "19.3.1", - "react-dom": "19.3.1", - "typescript": "^6.0.3", - "vitest": "5.1.2", + "react": "catalog:", + "react-dom": "catalog:", + "typescript": "catalog:", + "vitest": "catalog:", }, "peerDependencies": { - "react": "19.3.1", + "react": "catalog:", }, }, "packages/cooklang-for-obsidian": { @@ -622,45 +622,45 @@ "name": "@shepherdjerred/delivery", "version": "0.1.0", "dependencies": { - "@hono/bun": "^1.0.1", - "@prisma/adapter-pg": "7.10.1", - "@prisma/client": "^7.10.1", + "@hono/bun": "catalog:", + "@prisma/adapter-pg": "catalog:", + "@prisma/client": "catalog:", "@prisma/client-runtime-utils": "7.10.1", "@shepherdjerred/config": "workspace:*", "@shepherdjerred/feature-flags": "workspace:*", "@shepherdjerred/ops-clients": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", "@shepherdjerred/version-catalog": "workspace:*", - "@tanstack/react-query": "^5.101.2", - "@tanstack/react-router": "1.170.46", + "@tanstack/react-query": "catalog:", + "@tanstack/react-router": "catalog:", "fflate": "^0.8.3", - "hono": "^4.12.18", + "hono": "catalog:", "pg": "8.23.1", - "prisma": "^7.10.1", - "react": "19.3.1", - "react-dom": "19.3.1", - "zod": "^4.4.3", + "prisma": "catalog:", + "react": "catalog:", + "react-dom": "catalog:", + "zod": "catalog:", }, "devDependencies": { - "@axe-core/playwright": "4.14.1", - "@base-ui/react": "^1.6.0", + "@axe-core/playwright": "catalog:", + "@base-ui/react": "catalog:", "@playwright/test": "1.64.0", "@shepherdjerred/console-ui": "workspace:*", "@shepherdjerred/eslint-config": "workspace:*", "@shepherdjerred/test-postgres": "workspace:*", "@types/bun": "1.4.5", "@types/pg": "8.23.1", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", "jiti": "^2.7.0", - "lucide-react": "^1.14.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2", + "lucide-react": "catalog:", + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:", }, }, "packages/discord-plays-core": { @@ -1019,7 +1019,7 @@ "name": "@shepherdjerred/errors", "version": "0.1.0", "dependencies": { - "@base-ui/react": "^1.6.0", + "@base-ui/react": "catalog:", "@opentelemetry/api": "^1.9.1", "@opentelemetry/context-async-hooks": "^2.12.0", "@opentelemetry/exporter-trace-otlp-http": "^0.223.0", @@ -1027,20 +1027,20 @@ "@opentelemetry/sdk-node": "^0.223.0", "@opentelemetry/sdk-trace-base": "^2.12.0", "@opentelemetry/semantic-conventions": "^1.40.0", - "@prisma/adapter-pg": "7.10.1", - "@prisma/client": "^7.10.1", + "@prisma/adapter-pg": "catalog:", + "@prisma/client": "catalog:", "@prisma/client-runtime-utils": "7.10.1", "@shepherdjerred/config": "workspace:*", "@shepherdjerred/feature-flags": "workspace:*", - "@tanstack/react-query": "^5.101.2", - "hono": "^4.12.18", - "lucide-react": "^1.14.0", - "prisma": "^7.10.1", + "@tanstack/react-query": "catalog:", + "hono": "catalog:", + "lucide-react": "catalog:", + "prisma": "catalog:", "prom-client": "^15.1.3", - "react": "19.3.1", - "react-dom": "19.3.1", + "react": "catalog:", + "react-dom": "catalog:", "react-router": "8.5.3", - "zod": "^4.4.3", + "zod": "catalog:", }, "devDependencies": { "@sentry/bun": "11.18.0", @@ -1051,16 +1051,16 @@ "@shepherdjerred/ops-model": "workspace:*", "@shepherdjerred/test-postgres": "workspace:*", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", "jiti": "^2.7.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2", + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:", }, }, "packages/eslint-config": { @@ -1163,67 +1163,67 @@ "name": "@shepherdjerred/feeds", "version": "0.1.0", "dependencies": { - "@hono/bun": "^1.0.1", + "@hono/bun": "catalog:", "@shepherdjerred/feature-flags": "workspace:*", "fast-xml-parser": "5.12.1", - "hono": "^4.12.18", + "hono": "catalog:", "htmlparser2": "^12.0.0", "sanitize-html": "^2.18.0", - "zod": "^4.4.3", + "zod": "catalog:", }, "devDependencies": { "@shepherdjerred/console-ui": "workspace:*", "@shepherdjerred/eslint-config": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", - "@tanstack/react-query": "^5.101.2", + "@tanstack/react-query": "catalog:", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@types/sanitize-html": "^2.16.1", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", "jiti": "^2.7.0", - "lucide-react": "^1.14.0", - "react": "19.3.1", - "react-dom": "19.3.1", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2", + "lucide-react": "catalog:", + "react": "catalog:", + "react-dom": "catalog:", + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:", }, }, "packages/flags": { "name": "@shepherdjerred/flags", "version": "0.1.0", "dependencies": { - "@hono/bun": "^1.0.1", + "@hono/bun": "catalog:", "@shepherdjerred/feature-flags": "workspace:*", - "hono": "^4.12.18", - "zod": "^4.4.3", + "hono": "catalog:", + "zod": "catalog:", }, "devDependencies": { "@shepherdjerred/console-ui": "workspace:*", "@shepherdjerred/eslint-config": "workspace:*", "@shepherdjerred/llm-models": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", - "@tanstack/react-query": "^5.101.2", + "@tanstack/react-query": "catalog:", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", "jsdom": "^31.0.1", - "lucide-react": "^1.14.0", - "monaco-editor": "^0.58.0", - "react": "19.3.1", - "react-dom": "19.3.1", + "lucide-react": "catalog:", + "monaco-editor": "catalog:", + "react": "catalog:", + "react-dom": "catalog:", "react-router": "8.4.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2", + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:", }, }, "packages/glitter": { @@ -1295,21 +1295,21 @@ "@opentelemetry/sdk-node": "^0.223.0", "@opentelemetry/sdk-trace-base": "^2.12.0", "@opentelemetry/semantic-conventions": "^1.40.0", - "@prisma/adapter-pg": "7.10.1", - "@prisma/client": "^7.10.1", + "@prisma/adapter-pg": "catalog:", + "@prisma/client": "catalog:", "@prisma/client-runtime-utils": "7.10.1", "@sentry/bun": "11.18.0", "@shepherdjerred/bugsink-config": "workspace:*", "@shepherdjerred/config": "workspace:*", "@shepherdjerred/console-server": "workspace:*", "@shepherdjerred/feature-flags": "workspace:*", - "@trpc/server": "^11.18.0", - "hono": "^4.12.18", - "prisma": "^7.10.1", + "@trpc/server": "catalog:", + "hono": "catalog:", + "prisma": "catalog:", "prom-client": "^15.1.3", - "react": "19.3.1", - "react-dom": "19.3.1", - "zod": "^4.4.3", + "react": "catalog:", + "react-dom": "catalog:", + "zod": "catalog:", }, "devDependencies": { "@shepherdjerred/architecture": "workspace:*", @@ -1318,23 +1318,23 @@ "@shepherdjerred/eslint-config": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", "@shepherdjerred/test-postgres": "workspace:*", - "@tanstack/react-query": "^5.101.2", - "@tanstack/react-router": "1.170.46", - "@trpc/client": "^11.18.0", - "@trpc/tanstack-react-query": "^11.18.0", + "@tanstack/react-query": "catalog:", + "@tanstack/react-router": "catalog:", + "@trpc/client": "catalog:", + "@trpc/tanstack-react-query": "catalog:", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", "jiti": "^2.7.0", "jsdom": "^31.0.1", - "lucide-react": "^1.14.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2", + "lucide-react": "catalog:", + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:", }, }, "packages/hkctl": { @@ -1676,35 +1676,35 @@ "name": "@shepherdjerred/mail", "version": "0.1.0", "dependencies": { - "@base-ui/react": "^1.6.0", - "@hono/bun": "^1.0.1", + "@base-ui/react": "catalog:", + "@hono/bun": "catalog:", "@shepherdjerred/feature-flags": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", - "@tanstack/react-query": "^5.101.2", - "hono": "^4.12.18", - "lucide-react": "^1.14.0", + "@tanstack/react-query": "catalog:", + "hono": "catalog:", + "lucide-react": "catalog:", "nodemailer": "^10.6.1", "postal-mime": "^4.2.1", "prom-client": "^15.1.3", - "react": "19.3.1", - "react-dom": "19.3.1", + "react": "catalog:", + "react-dom": "catalog:", "react-router": "8.5.3", - "zod": "^4.4.3", + "zod": "catalog:", }, "devDependencies": { "@shepherdjerred/console-ui": "workspace:*", "@shepherdjerred/eslint-config": "workspace:*", "@types/bun": "1.4.5", "@types/nodemailer": "^8.0.2", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2", + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:", }, }, "packages/mc-build": { @@ -1866,7 +1866,7 @@ "name": "@shepherdjerred/ops-model", "version": "0.1.0", "dependencies": { - "zod": "^4.4.3", + "zod": "catalog:", }, "devDependencies": { "@shepherdjerred/console-ui": "workspace:*", @@ -1876,12 +1876,12 @@ "@tsconfig/strictest": "^2.0.8", "@types/bun": "^1.4.5", "@typescript/native": "npm:typescript@7.0.2", - "@vitest/coverage-istanbul": "5.1.2", + "@vitest/coverage-istanbul": "catalog:", "ajv": "^8.20.0", "eslint": "^10.7.0", "jiti": "^2.7.0", - "typescript": "^6.0.3", - "vitest": "5.1.2", + "typescript": "catalog:", + "vitest": "catalog:", }, }, "packages/pr-fleet-controller": { @@ -2958,10 +2958,10 @@ "name": "@shepherdjerred/tracker", "version": "0.1.0", "dependencies": { - "@base-ui/react": "^1.6.0", - "@dnd-kit/core": "^6.3.1", - "@dnd-kit/sortable": "^10.0.0", - "@hono/bun": "^1.0.1", + "@base-ui/react": "catalog:", + "@dnd-kit/core": "catalog:", + "@dnd-kit/sortable": "catalog:", + "@hono/bun": "catalog:", "@opentelemetry/api": "^1.9.1", "@opentelemetry/context-async-hooks": "^2.12.0", "@opentelemetry/exporter-trace-otlp-http": "^0.223.0", @@ -2969,30 +2969,30 @@ "@opentelemetry/sdk-node": "^0.223.0", "@opentelemetry/sdk-trace-base": "^2.12.0", "@opentelemetry/semantic-conventions": "^1.40.0", - "@prisma/adapter-pg": "7.10.1", - "@prisma/client": "^7.10.1", + "@prisma/adapter-pg": "catalog:", + "@prisma/client": "catalog:", "@prisma/client-runtime-utils": "7.10.1", "@sentry/bun": "11.18.0", "@shepherdjerred/bugsink-config": "workspace:*", "@shepherdjerred/config": "workspace:*", "@shepherdjerred/feature-flags": "workspace:*", - "@tanstack/react-query": "^5.101.2", - "@tanstack/react-virtual": "^3.14.26", - "@trpc/client": "^11.18.0", - "@trpc/server": "^11.18.0", - "hono": "^4.12.18", - "lucide-react": "^1.14.0", + "@tanstack/react-query": "catalog:", + "@tanstack/react-virtual": "catalog:", + "@trpc/client": "catalog:", + "@trpc/server": "catalog:", + "hono": "catalog:", + "lucide-react": "catalog:", "pg": "8.23.1", - "prisma": "^7.10.1", - "react": "19.3.1", - "react-dom": "19.3.1", - "react-markdown": "^10.1.0", + "prisma": "catalog:", + "react": "catalog:", + "react-dom": "catalog:", + "react-markdown": "catalog:", "react-router": "8.4.0", - "remark-gfm": "^4.0.1", - "zod": "^4.4.3", + "remark-gfm": "catalog:", + "zod": "catalog:", }, "devDependencies": { - "@axe-core/playwright": "^4.14.1", + "@axe-core/playwright": "catalog:", "@playwright/test": "1.64.0", "@shepherdjerred/architecture": "workspace:*", "@shepherdjerred/console-ui": "workspace:*", @@ -3001,16 +3001,16 @@ "@shepherdjerred/test-postgres": "workspace:*", "@types/bun": "1.4.5", "@types/pg": "8.23.1", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", "jiti": "^2.7.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2", + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:", }, }, "packages/trmnl-dashboard": { @@ -3275,6 +3275,40 @@ "svgo": "4.1.0", "typescript-eslint": "8.74.0", }, + "catalog": { + "@axe-core/playwright": "^4.14.1", + "@base-ui/react": "^1.6.0", + "@dnd-kit/core": "^6.3.1", + "@dnd-kit/sortable": "^10.0.0", + "@hono/bun": "^1.0.1", + "@js-temporal/polyfill": "^0.5.1", + "@prisma/adapter-pg": "7.10.1", + "@prisma/client": "^7.10.1", + "@tanstack/react-query": "^5.101.2", + "@tanstack/react-router": "1.170.46", + "@tanstack/react-virtual": "^3.14.26", + "@trpc/client": "^11.18.0", + "@trpc/server": "^11.18.0", + "@trpc/tanstack-react-query": "^11.18.0", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.0.1", + "@vitest/coverage-istanbul": "5.1.2", + "clsx": "^2.1.1", + "hono": "^4.12.18", + "lucide-react": "^1.14.0", + "monaco-editor": "^0.58.0", + "prisma": "^7.10.1", + "react": "19.3.1", + "react-dom": "19.3.1", + "react-markdown": "^10.1.0", + "remark-gfm": "^4.0.1", + "typescript": "^6.0.3", + "uplot": "^1.6.32", + "vite": "^8.0.11", + "vitest": "5.1.2", + "zod": "^4.4.3", + }, "packages": { "@adobe/css-tools": ["@adobe/css-tools@4.5.0", "", {}, "sha512-6OzddxPio9UiWTCemp4N8cYLV2ZN1ncRnV1cVGtve7dhPOtRkleRyx32GQCYSwDYgaHU3USMm84tNsvKzRCa1Q=="], diff --git a/package.json b/package.json index bbe842dd6ff..cd8b5c4873e 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "generate-flag-usage": "bun scripts/generate/flag-usage.ts", "check-flag-usage": "bun scripts/checks/check-flag-usage.ts", "check-ai-architecture": "bun scripts/checks/check-ai-architecture.ts", + "check-console-stack": "bun scripts/checks/check-console-stack.ts", "check-floating-deps": "bun scripts/checks/deps/check-floating-deps.ts", "check-patched-deps": "bun scripts/checks/deps/check-patched-deps.ts", "check-ci-env": "bun scripts/checks/ci/check-ci-env.ts", @@ -215,6 +216,40 @@ "packages/woodpecker-config-extension", "scripts" ], + "catalog": { + "@axe-core/playwright": "^4.14.1", + "@base-ui/react": "^1.6.0", + "@dnd-kit/core": "^6.3.1", + "@dnd-kit/sortable": "^10.0.0", + "@hono/bun": "^1.0.1", + "@js-temporal/polyfill": "^0.5.1", + "@prisma/adapter-pg": "7.10.1", + "@prisma/client": "^7.10.1", + "@tanstack/react-query": "^5.101.2", + "@tanstack/react-router": "1.170.46", + "@tanstack/react-virtual": "^3.14.26", + "@trpc/client": "^11.18.0", + "@trpc/server": "^11.18.0", + "@trpc/tanstack-react-query": "^11.18.0", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.0.1", + "@vitest/coverage-istanbul": "5.1.2", + "clsx": "^2.1.1", + "hono": "^4.12.18", + "lucide-react": "^1.14.0", + "monaco-editor": "^0.58.0", + "prisma": "^7.10.1", + "react": "19.3.1", + "react-dom": "19.3.1", + "react-markdown": "^10.1.0", + "remark-gfm": "^4.0.1", + "typescript": "^6.0.3", + "uplot": "^1.6.32", + "vite": "^8.0.11", + "vitest": "5.1.2", + "zod": "^4.4.3" + }, "overrides": { "@ai-sdk/provider": "4.0.39", "@ai-sdk/provider-utils": "5.0.85", diff --git a/packages/alert-dashboard/package.json b/packages/alert-dashboard/package.json index c851c481584..5e1cd6e6869 100644 --- a/packages/alert-dashboard/package.json +++ b/packages/alert-dashboard/package.json @@ -34,9 +34,9 @@ "#test-fixtures/*": "./src/test-fixtures/*.ts" }, "dependencies": { - "@base-ui/react": "^1.6.0", - "@hono/bun": "^1.0.1", - "@js-temporal/polyfill": "^0.5.1", + "@base-ui/react": "catalog:", + "@hono/bun": "catalog:", + "@js-temporal/polyfill": "catalog:", "@opentelemetry/api": "^1.9.1", "@opentelemetry/context-async-hooks": "^2.12.0", "@opentelemetry/exporter-trace-otlp-http": "^0.223.0", @@ -45,26 +45,26 @@ "@opentelemetry/sdk-trace-base": "^2.12.0", "@opentelemetry/semantic-conventions": "^1.40.0", "@prisma/adapter-libsql": "7.10.1", - "@prisma/client": "^7.10.1", + "@prisma/client": "catalog:", "@prisma/client-runtime-utils": "7.10.1", "@shepherdjerred/loaded": "workspace:*", "@shepherdjerred/experiments": "workspace:*", "@tanstack/react-form": "^1.33.6", - "@tanstack/react-query": "^5.101.2", - "@trpc/client": "^11.18.0", - "@trpc/server": "^11.18.0", - "@trpc/tanstack-react-query": "^11.18.0", - "hono": "^4.12.18", - "lucide-react": "^1.14.0", - "prisma": "^7.10.1", - "react": "19.3.1", - "react-dom": "19.3.1", + "@tanstack/react-query": "catalog:", + "@trpc/client": "catalog:", + "@trpc/server": "catalog:", + "@trpc/tanstack-react-query": "catalog:", + "hono": "catalog:", + "lucide-react": "catalog:", + "prisma": "catalog:", + "react": "catalog:", + "react-dom": "catalog:", "react-router": "8.5.3", - "zod": "^4.4.3", + "zod": "catalog:", "@shepherdjerred/ops-model": "workspace:*", "@shepherdjerred/ops-clients": "workspace:*", "@shepherdjerred/llm-observability": "workspace:*", - "uplot": "^1.6.32", + "uplot": "catalog:", "@shepherdjerred/config": "workspace:*", "@shepherdjerred/feature-flags": "workspace:*", "@shepherdjerred/incidents": "workspace:*" @@ -74,17 +74,17 @@ "@shepherdjerred/console-ui": "workspace:*", "@shepherdjerred/eslint-config": "workspace:*", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", - "@axe-core/playwright": "^4.14.1", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", + "@axe-core/playwright": "catalog:", "@playwright/test": "1.64.0", - "@vitejs/plugin-react": "^6.0.1", + "@vitejs/plugin-react": "catalog:", "@typescript/native": "npm:typescript@7.0.2", "eslint": "^10.7.0", "jiti": "^2.7.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2", - "@vitest/coverage-istanbul": "5.1.2" + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:", + "@vitest/coverage-istanbul": "catalog:" } } diff --git a/packages/charts/package.json b/packages/charts/package.json index c5bae812373..63daa2ede24 100644 --- a/packages/charts/package.json +++ b/packages/charts/package.json @@ -21,18 +21,18 @@ "@shepherdjerred/eslint-config": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", - "lucide-react": "^1.14.0", - "react": "19.3.1", - "react-dom": "19.3.1", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2", - "zod": "^4.4.3" + "lucide-react": "catalog:", + "react": "catalog:", + "react-dom": "catalog:", + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:", + "zod": "catalog:" } } diff --git a/packages/ci-cache/package.json b/packages/ci-cache/package.json index 50151aebb75..684a8e6abce 100644 --- a/packages/ci-cache/package.json +++ b/packages/ci-cache/package.json @@ -12,24 +12,24 @@ "test:ci": "bun ../../scripts/ci/run-ci-test.ts" }, "dependencies": { - "react": "19.3.1", - "react-dom": "19.3.1", - "zod": "^4.4.3" + "react": "catalog:", + "react-dom": "catalog:", + "zod": "catalog:" }, "devDependencies": { "@shepherdjerred/console-ui": "workspace:*", "@shepherdjerred/eslint-config": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", + "@vitejs/plugin-react": "catalog:", "eslint": "^10.7.0", "jiti": "^2.7.0", - "lucide-react": "^1.14.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2" + "lucide-react": "catalog:", + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:" } } diff --git a/packages/console-ui/package.json b/packages/console-ui/package.json index 10351ab9465..2050fdd4c16 100644 --- a/packages/console-ui/package.json +++ b/packages/console-ui/package.json @@ -19,18 +19,18 @@ "./*": "./src/*" }, "dependencies": { - "@base-ui/react": "^1.6.0", + "@base-ui/react": "catalog:", "@fontsource-variable/inter": "^5.3.0", - "@js-temporal/polyfill": "^0.5.1", + "@js-temporal/polyfill": "catalog:", "@tanstack/react-form": "^1.33.6", "@tanstack/react-table": "^9.3.1", - "@tanstack/react-virtual": "^3.14.26", - "clsx": "^2.1.1", - "lucide-react": "^1.14.0", - "zod": "^4.4.3" + "@tanstack/react-virtual": "catalog:", + "clsx": "catalog:", + "lucide-react": "catalog:", + "zod": "catalog:" }, "peerDependencies": { - "react": "19.3.1" + "react": "catalog:" }, "devDependencies": { "@shepherdjerred/eslint-config": "workspace:*", @@ -38,16 +38,16 @@ "@tsconfig/recommended": "^1.0.13", "@tsconfig/strictest": "^2.0.8", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitest/coverage-istanbul": "5.1.2", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", "jiti": "^2.7.0", "jsdom": "^31.0.1", - "react": "19.3.1", - "react-dom": "19.3.1", - "typescript": "^6.0.3", - "vitest": "5.1.2" + "react": "catalog:", + "react-dom": "catalog:", + "typescript": "catalog:", + "vitest": "catalog:" } } diff --git a/packages/delivery/package.json b/packages/delivery/package.json index 4636ace0fd3..c85837fd8db 100644 --- a/packages/delivery/package.json +++ b/packages/delivery/package.json @@ -33,44 +33,44 @@ "test:e2e": "bun --no-install --bun playwright test" }, "dependencies": { - "@hono/bun": "^1.0.1", - "@prisma/adapter-pg": "7.10.1", - "@prisma/client": "^7.10.1", + "@hono/bun": "catalog:", + "@prisma/adapter-pg": "catalog:", + "@prisma/client": "catalog:", "@prisma/client-runtime-utils": "7.10.1", "@shepherdjerred/config": "workspace:*", "@shepherdjerred/feature-flags": "workspace:*", "@shepherdjerred/ops-clients": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", "@shepherdjerred/version-catalog": "workspace:*", - "@tanstack/react-query": "^5.101.2", - "@tanstack/react-router": "1.170.46", + "@tanstack/react-query": "catalog:", + "@tanstack/react-router": "catalog:", "fflate": "^0.8.3", - "hono": "^4.12.18", + "hono": "catalog:", "pg": "8.23.1", - "prisma": "^7.10.1", - "react": "19.3.1", - "react-dom": "19.3.1", - "zod": "^4.4.3" + "prisma": "catalog:", + "react": "catalog:", + "react-dom": "catalog:", + "zod": "catalog:" }, "devDependencies": { - "@axe-core/playwright": "4.14.1", - "@base-ui/react": "^1.6.0", + "@axe-core/playwright": "catalog:", + "@base-ui/react": "catalog:", "@playwright/test": "1.64.0", "@shepherdjerred/console-ui": "workspace:*", "@shepherdjerred/eslint-config": "workspace:*", "@shepherdjerred/test-postgres": "workspace:*", "@types/bun": "1.4.5", "@types/pg": "8.23.1", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", "jiti": "^2.7.0", - "lucide-react": "^1.14.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2" + "lucide-react": "catalog:", + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:" } } diff --git a/packages/docs/wiki/src/content/docs/explanation/homelab/hosted-service-model.md b/packages/docs/wiki/src/content/docs/explanation/homelab/hosted-service-model.md index a5ff1501700..ae1d6bac3e1 100644 --- a/packages/docs/wiki/src/content/docs/explanation/homelab/hosted-service-model.md +++ b/packages/docs/wiki/src/content/docs/explanation/homelab/hosted-service-model.md @@ -126,6 +126,31 @@ definition that merges should change nothing that runs. Activation adds the environment, the Delivery delegation and the secrets, and those deserve their own diff. +## One stack for the consoles + +The ten ops consoles are first-party hosted services that people use every day: +Hub, Delivery, Tracker, Errors, Mail, Flags, Feeds, Go link, Charts and CI +cache. They already shared React, Vite, TypeScript, Vitest, Zod and the +console-ui look at the same versions. Below that they diverged: React Router, TanStack Router +and hand-rolled routing, REST beside tRPC, raw SQLite beside Prisma, native +dialogs beside Base UI. Each choice was reasonable alone. Together they meant a +fix for one console did not carry to another, and every new console started from +a bare server. + +The consoles therefore share one stack, written down in the +[console stack reference](/reference/console-stack/). The reasoning is the same +as for the construct and the policy test: make the standard the easy path, then +check what went around it. The scaffolder's `--console` flag writes the standard +stack, a Bun workspace catalog holds one version of each library, and a stack +check reads each console's `package.json`. The check starts with an allowlist of +today's deviations, each with a reason. A deviation with no entry fails, and an +entry whose deviation is gone fails, so the list only shrinks and a migration +pull request removes its own entries. + +Two consoles are Rust, and fixed outside protocols such as SMTP and the Sentry +envelope keep their wire format. Those are named exceptions, not allowlist +entries, because the standard cannot apply to them. + ## What stays manual, and why A few inventory tests assert a literal count of images or charts. They guard @@ -139,6 +164,8 @@ guessed them would be a default nobody chose. ## Related - [Add a hosted service](/how-to/add-a-hosted-service/) is the procedure. +- [Console stack reference](/reference/console-stack/) lists the standard and + its exceptions. - [About the homelab](/explanation/homelab/overview/) covers the topology these workloads run on. - [Why releases are shaped this way](/explanation/homelab/release-safety/) diff --git a/packages/docs/wiki/src/content/docs/how-to/add-a-hosted-service.md b/packages/docs/wiki/src/content/docs/how-to/add-a-hosted-service.md index d41e85cb516..838ab8c6390 100644 --- a/packages/docs/wiki/src/content/docs/how-to/add-a-hosted-service.md +++ b/packages/docs/wiki/src/content/docs/how-to/add-a-hosted-service.md @@ -28,19 +28,29 @@ and clears `pendingPrivateImages`. bun scripts/misc/new-service.ts --name notes --kind web --port 7400 --host notes ``` - | Flag | Value | - | --------- | ------------------------------------------------------------------- | - | `--name` | Kebab-case. Names the package, image, chart, namespace, Application | - | `--kind` | `web` for an HTTP service, `worker` for a workload with no ingress | - | `--port` | The listening port, or a worker's health port. 1024 to 55535 | - | `--host` | The tailnet hostname. Required for `web`, refused for `worker` | - | `--title` | The catalog title. Defaults to the name in sentence case | + | Flag | Value | + | ----------- | --------------------------------------------------------------------- | + | `--name` | Kebab-case. Names the package, image, chart, namespace, Application | + | `--kind` | `web` for an HTTP service, `worker` for a workload with no ingress | + | `--port` | The listening port, or a worker's health port. 1024 to 55535 | + | `--host` | The tailnet hostname. Required for `web`, refused for `worker` | + | `--title` | The catalog title. Defaults to the name in sentence case | + | `--console` | Web only. Writes the console stack in place of the bare health server | The command writes the package, the chart, the Argo Application and every registration. It then installs, synthesizes `@homelab/cdktn` (updating `packages/homelab/src/tofu/dockerhub/main.tf.json`), runs `generate:catalog` and runs the completeness check. It prints each file it wrote. + For an ops console, add `--console`. The package then holds the + [console stack](/reference/console-stack/): a Hono server on Bun with + `/healthz` and `/trpc`, a tRPC router with one example procedure, a Prisma + schema for PostgreSQL, and a Vite and React client with TanStack Router, the + `@trpc/tanstack-react-query` provider and console-ui's shell. Its + dependencies use `catalog:`. Add the console to `CONSOLES` in + `scripts/checks/console-stack-rules.ts` so `bun run check-console-stack` + holds it to the standard. + 2. Bump the three inventory counts that a new image and chart change. Run the suite and edit the literal each failure names: @@ -162,5 +172,6 @@ Application that the catalog does not name. ## Related - [Why a hosted service is a construct, a policy test and a checklist](/explanation/homelab/hosted-service-model/) +- [Console stack reference](/reference/console-stack/) - [Cut a homelab release](/how-to/cut-a-homelab-release/) - [Delivery model reference](/reference/delivery-model/) diff --git a/packages/docs/wiki/src/content/docs/reference/console-stack.md b/packages/docs/wiki/src/content/docs/reference/console-stack.md new file mode 100644 index 00000000000..6efc7dc7296 --- /dev/null +++ b/packages/docs/wiki/src/content/docs/reference/console-stack.md @@ -0,0 +1,135 @@ +--- +title: Console stack reference +description: The one library stack of the ten first-party ops consoles, its Rust and fixed-protocol exceptions, the shared Bun catalog, and the check that holds each console to it. +--- + +The ten first-party ops consoles share one stack: Hub, Delivery, Tracker, +Errors, Mail, Flags, Feeds, Go link, Charts and CI cache. The shared look is +[`@shepherdjerred/console-ui`](/reference/console-ui/); this page lists the +libraries underneath it. [Why the consoles share one stack](/explanation/homelab/hosted-service-model/#one-stack-for-the-consoles) +gives the reasoning. + +## The standard + +| Layer | Standard | +| --------------------- | ---------------------------------------------------------------------------------------- | +| Router | TanStack Router with code-based routes; every URL parameter is validated with Zod | +| Browser data | tRPC with TanStack Query through `@trpc/tanstack-react-query` | +| First-party callers | Typed tRPC clients for the toolkit, Temporal, CI lanes and other services | +| Server | Hono on Bun, started through the shared server kit | +| Database | Prisma on PostgreSQL | +| Headless UI | Base UI (`@base-ui/react`), through console-ui | +| Tables | TanStack Table, inside console-ui's `DataTable` | +| Forms | TanStack Form with Zod | +| Long lists | TanStack Virtual | +| Charts | uPlot | +| Drag and drop | dnd-kit | +| Markdown | react-markdown with remark-gfm | +| Code editor | Monaco | +| Dates | Temporal (`@js-temporal/polyfill`) for date math, `Intl` for display | +| Icons | lucide-react | +| Class names | clsx, in console-ui only | +| Validation | Zod 4 | +| Browser tests | Vitest browser mode with axe for new tests; Playwright with axe stays for full-app flows | +| Framework and tooling | React 19.3.1, Vite 8, TypeScript 6, Vitest 5 | + +## Exceptions + +| Exception | Applies to | What changes | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- | +| Rust server | Charts, CI cache | The server cannot serve tRPC or use Prisma. The client uses TanStack Query over REST with Zod. `rusqlite` stays | +| Fixed outside protocol | Sentry envelope ingest, SMTP, the Google Reader API, the Alertmanager webhook, the Helm repository, the Turborepo, Gradle and sccache caches, Go link redirects, health probes, `/metrics` | The endpoint keeps its REST or wire format; everything around it is tRPC | +| File upload | Tracker attachments | Plain HTTP | + +## Banned alternatives + +The check fails when a console declares one of these, unless the console's +allowlist entry names it. + +| Replaced by | Banned | +| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | +| TanStack Router | `react-router`, `react-router-dom`, `@remix-run/router`, `wouter`, `@reach/router`, `navigo` | +| tRPC with TanStack Query | `swr`, `axios`, `ky`, `ofetch`, `got`, `node-fetch`, `superagent` | +| uPlot | `recharts`, `echarts`, `echarts-for-react`, `chart.js`, `react-chartjs-2`, `d3`, `victory`, `apexcharts`, `plotly.js`, `@visx/*`, `@nivo/*` | +| Temporal and `Intl` | `date-fns`, `dayjs`, `luxon`, `moment`, `moment-timezone`, `@date-fns/*` | +| TanStack Form | `react-hook-form`, `formik`, `final-form`, `react-final-form` | +| Base UI | `@radix-ui/*`, `radix-ui`, `@headlessui/react`, `react-aria`, `react-aria-components`, `@react-aria/*`, `ariakit`, `@ariakit/*` | +| TanStack Virtual | `react-window`, `react-virtualized`, `react-virtuoso` | +| dnd-kit | `react-dnd`, `react-beautiful-dnd`, `@hello-pangea/dnd` | +| react-markdown | `marked`, `markdown-it`, `showdown`, `snarkdown` | +| Plain CSS on console-ui | `tailwindcss`, `@tailwindcss/*`, `styled-components`, `@emotion/*`, `goober` | +| Hono on Bun | `express`, `fastify`, `koa`, `@hapi/hapi` | +| Prisma on PostgreSQL | `better-sqlite3`, `sqlite3`, `@libsql/client`, `@prisma/adapter-libsql`, `@prisma/adapter-better-sqlite3` | + +A Rust console's client also may not declare `hono`, `@hono/bun`, +`@trpc/server` or `prisma`. + +## Required libraries + +| Package kind | Required | +| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| TypeScript console | The toolchain, `@tanstack/react-query`, `@tanstack/react-router`, `@trpc/client`, `@trpc/server`, `@trpc/tanstack-react-query`, `hono`, `@hono/bun`, `prisma`, `@prisma/client`, `@prisma/adapter-pg` | +| Rust console client | The toolchain, `@tanstack/react-query`, `@tanstack/react-router` | +| `console-ui` | `@base-ui/react`, `clsx`, `lucide-react`, `@tanstack/react-table`, `@tanstack/react-form` | + +A console that depends on `@shepherdjerred/console-server` counts as declaring +`hono`, `@hono/bun`, `@trpc/server` and `@trpc/client`. One that depends on +`@shepherdjerred/console-client` counts as declaring `@tanstack/react-query`, +`@tanstack/react-router` and the tRPC client libraries. + +The toolchain is `react`, `react-dom`, `@types/react`, `@types/react-dom`, +`@vitejs/plugin-react`, `typescript`, `vite`, `vitest`, `zod` and +`lucide-react`. + +## The Bun catalog + +The root `package.json` declares a default `catalog` that holds one version of +every library in the standard. A console, `console-ui` and `ops-model` declare +those libraries as `"catalog:"`. Change a version in the catalog and run +`bun install`, which rewrites `bun.lock`. A catalogued library declared with its +own version fails the stack check. + +Three kinds of library are outside the catalog: + +| Library | Why | +| ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `@playwright/test` | The `ci-playwright` image promotion rewrites each exact pin together with the image digest | +| `@types/bun` | Pinned with the Bun toolchain, which moves in one change | +| `@tanstack/react-table`, `@tanstack/react-form` | Knip rejects a catalog entry no package uses. The change that first declares one adds it to the catalog and removes it from `CATALOG_PENDING` in the stack rules | + +Renovate does not read `catalog` in a root `package.json` natively, so a +JSONata custom manager in `renovate.json` extracts every entry. Mend-hosted +Renovate cannot run `bun install`, so a catalog bump leaves `bun.lock` stale +until someone refreshes it on the branch. + +## The stack check + +`bun run check-console-stack` runs +`scripts/checks/check-console-stack.ts` +against each console's `package.json` and the root catalog, and prints one row +per deviation. The rules and the allowlist live in +`scripts/checks/console-stack-rules.ts`. + +| Deviation | Meaning | +| -------------- | -------------------------------------------------------------- | +| `missing` | The standard requires a library the package does not declare | +| `banned` | The package declares an alternative the standard replaces | +| `uncatalogued` | The package declares a catalogued library with its own version | + +Every deviation that exists today has an allowlist entry with a reason. The +allowlist only shrinks: + +- A deviation with no entry fails the check. +- An entry whose deviation no longer exists fails the check, so the change that + removes a deviation removes its entry in the same pull request. +- An entry names a package in the console list and carries a non-empty reason. + +The service scaffolder writes the standard stack for a new console: +`bun scripts/misc/new-service.ts --kind web --console`. See +[Add a hosted service](/how-to/add-a-hosted-service/). + +## Related + +- [Console UI reference](/reference/console-ui/) +- [Why the consoles share one stack](/explanation/homelab/hosted-service-model/#one-stack-for-the-consoles) +- [Add a hosted service](/how-to/add-a-hosted-service/) diff --git a/packages/errors/package.json b/packages/errors/package.json index 40f0547c174..ec39b27ea75 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -25,7 +25,7 @@ "test:ci": "bun ../../scripts/ci/run-ci-test.ts" }, "dependencies": { - "@base-ui/react": "^1.6.0", + "@base-ui/react": "catalog:", "@opentelemetry/api": "^1.9.1", "@opentelemetry/context-async-hooks": "^2.12.0", "@opentelemetry/exporter-trace-otlp-http": "^0.223.0", @@ -33,20 +33,20 @@ "@opentelemetry/sdk-node": "^0.223.0", "@opentelemetry/sdk-trace-base": "^2.12.0", "@opentelemetry/semantic-conventions": "^1.40.0", - "@prisma/adapter-pg": "7.10.1", - "@prisma/client": "^7.10.1", + "@prisma/adapter-pg": "catalog:", + "@prisma/client": "catalog:", "@prisma/client-runtime-utils": "7.10.1", "@shepherdjerred/config": "workspace:*", "@shepherdjerred/feature-flags": "workspace:*", - "@tanstack/react-query": "^5.101.2", - "hono": "^4.12.18", - "lucide-react": "^1.14.0", - "prisma": "^7.10.1", + "@tanstack/react-query": "catalog:", + "hono": "catalog:", + "lucide-react": "catalog:", + "prisma": "catalog:", "prom-client": "^15.1.3", - "react": "19.3.1", - "react-dom": "19.3.1", + "react": "catalog:", + "react-dom": "catalog:", "react-router": "8.5.3", - "zod": "^4.4.3" + "zod": "catalog:" }, "devDependencies": { "@sentry/bun": "11.18.0", @@ -57,15 +57,15 @@ "@shepherdjerred/ops-model": "workspace:*", "@shepherdjerred/test-postgres": "workspace:*", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", "jiti": "^2.7.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2" + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:" } } diff --git a/packages/feeds/eslint.config.ts b/packages/feeds/eslint.config.ts index 67c98d115da..5c714fdcbff 100644 --- a/packages/feeds/eslint.config.ts +++ b/packages/feeds/eslint.config.ts @@ -1,3 +1,6 @@ import { recommended } from "@shepherdjerred/eslint-config"; -export default recommended({ tsconfigRootDir: import.meta.dirname }); +export default recommended({ + tsconfigRootDir: import.meta.dirname, + react: true, +}); diff --git a/packages/feeds/package.json b/packages/feeds/package.json index d2ade6ab2da..d3bc467354b 100644 --- a/packages/feeds/package.json +++ b/packages/feeds/package.json @@ -16,33 +16,33 @@ "lint": "bunx eslint --cache . --max-warnings=0" }, "dependencies": { - "@hono/bun": "^1.0.1", + "@hono/bun": "catalog:", "@shepherdjerred/feature-flags": "workspace:*", "fast-xml-parser": "5.12.1", - "hono": "^4.12.18", + "hono": "catalog:", "htmlparser2": "^12.0.0", "sanitize-html": "^2.18.0", - "zod": "^4.4.3" + "zod": "catalog:" }, "devDependencies": { "@shepherdjerred/console-ui": "workspace:*", "@shepherdjerred/eslint-config": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", - "@tanstack/react-query": "^5.101.2", + "@tanstack/react-query": "catalog:", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@types/sanitize-html": "^2.16.1", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", "jiti": "^2.7.0", - "lucide-react": "^1.14.0", - "react": "19.3.1", - "react-dom": "19.3.1", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2" + "lucide-react": "catalog:", + "react": "catalog:", + "react-dom": "catalog:", + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:" } } diff --git a/packages/feeds/src/client/app.tsx b/packages/feeds/src/client/app.tsx index 65b6a4be904..f5df305453e 100644 --- a/packages/feeds/src/client/app.tsx +++ b/packages/feeds/src/client/app.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState, type RefObject } from "react"; +import { useCallback, useRef, useState, type RefObject } from "react"; import { z } from "zod"; import { FigureStrip, @@ -31,122 +31,13 @@ import { searchSuffix, type Route, } from "./model.ts"; +import { useWorkspaceShortcuts } from "./shortcuts.ts"; import { FeedsHeader, FeedsPicker, FeedsSidebar } from "./sidebar.tsx"; import { UserFeedDialog, type UserFeedDialogState, } from "./user-feed-dialog.tsx"; -function isEditableTarget(target: EventTarget | null): boolean { - return ( - target instanceof HTMLElement && - target.closest( - "input, select, textarea, dialog, [contenteditable='true']", - ) !== null - ); -} - -function shouldIgnoreGlobalKey(event: KeyboardEvent): boolean { - return ( - event.defaultPrevented || - event.isComposing || - event.metaKey || - event.ctrlKey || - event.altKey || - isEditableTarget(event.target) || - document.querySelector("dialog[open]") !== null - ); -} - -type EntryShortcutContext = { - readonly entries: readonly EntryListItem[]; - readonly activeIndex: number | undefined; - readonly setActiveIndex: React.Dispatch< - React.SetStateAction<number | undefined> - >; - readonly onToggleRead: (entry: EntryListItem) => void; - readonly onToggleStar: (entry: EntryListItem) => void; - readonly onFocusSearch: () => void; -}; - -function handleEntryShortcut( - key: string, - context: EntryShortcutContext, -): boolean { - if (key === "/") { - context.onFocusSearch(); - return true; - } - const { entries, activeIndex, setActiveIndex } = context; - if (entries.length === 0) return false; - if (key === "j") { - setActiveIndex((prev) => - prev === undefined ? 0 : Math.min(entries.length - 1, prev + 1), - ); - return true; - } - if (key === "k") { - setActiveIndex((prev) => (prev === undefined ? 0 : Math.max(0, prev - 1))); - return true; - } - const active = activeIndex === undefined ? undefined : entries[activeIndex]; - if (active === undefined) return false; - if (key === "o") { - globalThis.open(active.url, "_blank", "noopener,noreferrer"); - return true; - } - if (key === "m") { - context.onToggleRead(active); - return true; - } - if (key === "s") { - context.onToggleStar(active); - return true; - } - return false; -} - -function useWorkspaceShortcuts(options: { - readonly isEntriesRoute: boolean; - readonly entries: readonly EntryListItem[]; - readonly activeIndex: number | undefined; - readonly setActiveIndex: React.Dispatch< - React.SetStateAction<number | undefined> - >; - readonly searchInputRef: RefObject<HTMLInputElement | null>; - readonly onToggleRead: (entry: EntryListItem) => void; - readonly onToggleStar: (entry: EntryListItem) => void; - readonly onRefresh: () => void; -}): void { - useEffect(() => { - const onKeyDown = (event: KeyboardEvent): void => { - if (shouldIgnoreGlobalKey(event)) return; - if (event.key === "r") { - event.preventDefault(); - options.onRefresh(); - return; - } - if (!options.isEntriesRoute) return; - const handled = handleEntryShortcut(event.key, { - entries: options.entries, - activeIndex: options.activeIndex, - setActiveIndex: options.setActiveIndex, - onToggleRead: options.onToggleRead, - onToggleStar: options.onToggleStar, - onFocusSearch: () => { - options.searchInputRef.current?.focus(); - options.searchInputRef.current?.select(); - }, - }); - if (handled) event.preventDefault(); - }; - globalThis.addEventListener("keydown", onKeyDown); - return () => { - globalThis.removeEventListener("keydown", onKeyDown); - }; - }); -} - function activeFeedTitleFor( route: Route | undefined, feeds: readonly FeedHealthItem[] | undefined, @@ -297,7 +188,10 @@ export function App({ setBannerError(error.message); }; - useEffect(() => { + // Back and forward move the URL without a click, so the history entry the + // browser lands on is read back into state; attached to the workspace element. + const trackPopState = useCallback((element: HTMLElement | null) => { + if (element === null) return; const onPopState = (): void => { const nextSearch = globalThis.location.search; setPathname(globalThis.location.pathname); @@ -371,7 +265,7 @@ export function App({ ); } - useWorkspaceShortcuts({ + const bindShortcuts = useWorkspaceShortcuts({ isEntriesRoute, entries, activeIndex, @@ -382,6 +276,18 @@ export function App({ onRefresh: triggerRefresh, }); + const bindWindowEvents = useCallback( + (element: HTMLElement | null) => { + const releaseShortcuts = bindShortcuts(element); + const releasePopState = trackPopState(element); + return () => { + releaseShortcuts?.(); + releasePopState?.(); + }; + }, + [bindShortcuts, trackPopState], + ); + async function confirmDeleteFeed(): Promise<void> { if (confirmDelete === undefined || deleteFeedMutation.isPending) return; try { @@ -411,7 +317,7 @@ export function App({ /> } > - <main className="fd-workspace"> + <main className="fd-workspace" ref={bindWindowEvents}> <FeedsPicker summary={summary.data} route={route} diff --git a/packages/feeds/src/client/feeds-table.tsx b/packages/feeds/src/client/feeds-table.tsx index 63ba5e0f4d1..51fdbb7f8df 100644 --- a/packages/feeds/src/client/feeds-table.tsx +++ b/packages/feeds/src/client/feeds-table.tsx @@ -10,7 +10,7 @@ import { } from "./model.ts"; import { DIALOG_LIGHT_DISMISS_PROPS, - useDialogLightDismiss, + useModalDialogRef, } from "./user-feed-dialog.tsx"; function isPlainLeftClick(event: MouseEvent<HTMLAnchorElement>): boolean { @@ -246,12 +246,12 @@ export function DeleteFeedDialog({ }): React.JSX.Element { const dialogRef = useRef<HTMLDialogElement>(null); const titleId = useId(); - useDialogLightDismiss(dialogRef, target !== undefined); + const dialogRefCallback = useModalDialogRef(dialogRef, target !== undefined); return ( <dialog {...DIALOG_LIGHT_DISMISS_PROPS} - ref={dialogRef} + ref={dialogRefCallback} className="fd-dialog" aria-labelledby={titleId} onClose={() => { diff --git a/packages/feeds/src/client/shortcuts.ts b/packages/feeds/src/client/shortcuts.ts new file mode 100644 index 00000000000..a25fc6dc00b --- /dev/null +++ b/packages/feeds/src/client/shortcuts.ts @@ -0,0 +1,118 @@ +import { useCallback, useRef, type RefObject } from "react"; +import type { EntryListItem } from "@shepherdjerred/feeds/shared/contract.ts"; + +function isEditableTarget(target: EventTarget | null): boolean { + return ( + target instanceof HTMLElement && + target.closest( + "input, select, textarea, dialog, [contenteditable='true']", + ) !== null + ); +} + +function shouldIgnoreGlobalKey(event: KeyboardEvent): boolean { + return ( + event.defaultPrevented || + event.isComposing || + event.metaKey || + event.ctrlKey || + event.altKey || + isEditableTarget(event.target) || + document.querySelector("dialog[open]") !== null + ); +} + +type EntryShortcutContext = { + readonly entries: readonly EntryListItem[]; + readonly activeIndex: number | undefined; + readonly setActiveIndex: React.Dispatch< + React.SetStateAction<number | undefined> + >; + readonly onToggleRead: (entry: EntryListItem) => void; + readonly onToggleStar: (entry: EntryListItem) => void; + readonly onFocusSearch: () => void; +}; + +function handleEntryShortcut( + key: string, + context: EntryShortcutContext, +): boolean { + if (key === "/") { + context.onFocusSearch(); + return true; + } + const { entries, activeIndex, setActiveIndex } = context; + if (entries.length === 0) return false; + if (key === "j") { + setActiveIndex((prev) => + prev === undefined ? 0 : Math.min(entries.length - 1, prev + 1), + ); + return true; + } + if (key === "k") { + setActiveIndex((prev) => (prev === undefined ? 0 : Math.max(0, prev - 1))); + return true; + } + const active = activeIndex === undefined ? undefined : entries[activeIndex]; + if (active === undefined) return false; + if (key === "o") { + globalThis.open(active.url, "_blank", "noopener,noreferrer"); + return true; + } + if (key === "m") { + context.onToggleRead(active); + return true; + } + if (key === "s") { + context.onToggleStar(active); + return true; + } + return false; +} + +export function useWorkspaceShortcuts(options: { + readonly isEntriesRoute: boolean; + readonly entries: readonly EntryListItem[]; + readonly activeIndex: number | undefined; + readonly setActiveIndex: React.Dispatch< + React.SetStateAction<number | undefined> + >; + readonly searchInputRef: RefObject<HTMLInputElement | null>; + readonly onToggleRead: (entry: EntryListItem) => void; + readonly onToggleStar: (entry: EntryListItem) => void; + readonly onRefresh: () => void; +}): (element: HTMLElement | null) => (() => void) | undefined { + const latest = useRef(options); + latest.current = options; + // Attached to the workspace element: the window listener lives exactly as + // long as the workspace is mounted. + return useCallback((element: HTMLElement | null) => { + if (element === null) return; + const onKeyDown = (event: KeyboardEvent): void => { + const current = latest.current; + if (shouldIgnoreGlobalKey(event)) return; + if (event.key === "r") { + event.preventDefault(); + current.onRefresh(); + return; + } + if (!current.isEntriesRoute) return; + const handled = handleEntryShortcut(event.key, { + entries: current.entries, + activeIndex: current.activeIndex, + setActiveIndex: current.setActiveIndex, + onToggleRead: current.onToggleRead, + onToggleStar: current.onToggleStar, + onFocusSearch: () => { + current.searchInputRef.current?.focus(); + current.searchInputRef.current?.select(); + }, + }); + if (handled) event.preventDefault(); + }; + globalThis.addEventListener("keydown", onKeyDown); + return () => { + globalThis.removeEventListener("keydown", onKeyDown); + }; + }, []); +} diff --git a/packages/feeds/src/client/user-feed-dialog.tsx b/packages/feeds/src/client/user-feed-dialog.tsx index c571c0a2a54..4e291b26c82 100644 --- a/packages/feeds/src/client/user-feed-dialog.tsx +++ b/packages/feeds/src/client/user-feed-dialog.tsx @@ -1,5 +1,5 @@ import { - useEffect, + useCallback, useId, useRef, useState, @@ -60,45 +60,48 @@ function withoutFieldError( ); } -/** Safari light-dismiss fallback when `<dialog closedby="any">` is unsupported. */ -export function useDialogLightDismiss( +/** + * The ref callback for a modal `<dialog>`: it keeps the element's open state + * equal to `isOpen`, and adds the Safari light-dismiss fallback when + * `<dialog closedby="any">` is unsupported. It also stores the element in + * `dialogRef`, which the dialog's own handlers read. + */ +export function useModalDialogRef( dialogRef: RefObject<HTMLDialogElement | null>, isOpen: boolean, -): void { - useEffect(() => { - const dialog = dialogRef.current; - if (dialog === null) return; - if (!isOpen) { - if (dialog.open) dialog.close(); - return; - } - if (!dialog.open) dialog.showModal(); - }, [dialogRef, isOpen]); - - useEffect(() => { - const dialog = dialogRef.current; - if ( - dialog === null || - typeof HTMLDialogElement === "undefined" || - "closedBy" in HTMLDialogElement.prototype - ) { - return; - } - const onClick = (event: MouseEvent): void => { - if (event.target !== dialog) return; - const r = dialog.getBoundingClientRect(); - const inside = - r.top <= event.clientY && - event.clientY <= r.bottom && - r.left <= event.clientX && - event.clientX <= r.right; - if (!inside) dialog.close(); - }; - dialog.addEventListener("click", onClick); - return () => { - dialog.removeEventListener("click", onClick); - }; - }, [dialogRef]); +): (dialog: HTMLDialogElement | null) => (() => void) | undefined { + return useCallback( + (dialog: HTMLDialogElement | null) => { + dialogRef.current = dialog; + if (dialog === null) return; + if (!isOpen) { + if (dialog.open) dialog.close(); + } else if (!dialog.open) { + dialog.showModal(); + } + const lightDismissUnsupported = + typeof HTMLDialogElement !== "undefined" && + !("closedBy" in HTMLDialogElement.prototype); + const onClick = (event: MouseEvent): void => { + if (event.target !== dialog) return; + const r = dialog.getBoundingClientRect(); + const inside = + r.top <= event.clientY && + event.clientY <= r.bottom && + r.left <= event.clientX && + event.clientX <= r.right; + if (!inside) dialog.close(); + }; + if (lightDismissUnsupported) dialog.addEventListener("click", onClick); + return () => { + if (lightDismissUnsupported) { + dialog.removeEventListener("click", onClick); + } + dialogRef.current = null; + }; + }, + [dialogRef, isOpen], + ); } function focusFirstInvalid( @@ -356,7 +359,10 @@ export function UserFeedDialog({ const [submitError, setSubmitError] = useState<string | undefined>(undefined); const [isSaving, setIsSaving] = useState(false); - useEffect(() => { + // A new dialog state starts a fresh form: adjust during render, not in an effect. + const [formState, setFormState] = useState(state); + if (formState !== state) { + setFormState(state); setDraft( state.kind === "edit" ? draftFromFeed(state.feed) : emptyUserFeedDraft(), ); @@ -364,9 +370,12 @@ export function UserFeedDialog({ setErrors({}); setSubmitError(undefined); setIsSaving(false); - }, [state]); + } - useDialogLightDismiss(dialogRef, state.kind !== "closed"); + const dialogRefCallback = useModalDialogRef( + dialogRef, + state.kind !== "closed", + ); function handleFieldBlur(field: UserFeedField): void { if (touched[field] !== true) return; @@ -442,7 +451,7 @@ export function UserFeedDialog({ return ( <dialog {...DIALOG_LIGHT_DISMISS_PROPS} - ref={dialogRef} + ref={dialogRefCallback} className="fd-dialog" aria-labelledby={titleId} onClose={() => { diff --git a/packages/flags/eslint.config.ts b/packages/flags/eslint.config.ts index 67c98d115da..86b54fef6fc 100644 --- a/packages/flags/eslint.config.ts +++ b/packages/flags/eslint.config.ts @@ -1,3 +1,15 @@ import { recommended } from "@shepherdjerred/eslint-config"; -export default recommended({ tsconfigRootDir: import.meta.dirname }); +export default [ + ...recommended({ + tsconfigRootDir: import.meta.dirname, + react: true, + }), + { + // Monaco owns this editor's DOM and its text model. The component mirrors + // controlled props (text loaded from outside, aria attributes) into that + // external widget after each commit, which is what effects are for. + files: ["src/client/monaco/json-editor.tsx"], + rules: { "custom-rules/no-use-effect": "off" }, + }, +]; diff --git a/packages/flags/package.json b/packages/flags/package.json index 8f511570dae..8be5c859473 100644 --- a/packages/flags/package.json +++ b/packages/flags/package.json @@ -16,32 +16,32 @@ "generate-legacy-flag-dates": "bun scripts/generate-legacy-flag-dates.ts" }, "dependencies": { - "@hono/bun": "^1.0.1", + "@hono/bun": "catalog:", "@shepherdjerred/feature-flags": "workspace:*", - "hono": "^4.12.18", - "zod": "^4.4.3" + "hono": "catalog:", + "zod": "catalog:" }, "devDependencies": { "@shepherdjerred/console-ui": "workspace:*", "@shepherdjerred/eslint-config": "workspace:*", "@shepherdjerred/llm-models": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", - "@tanstack/react-query": "^5.101.2", + "@tanstack/react-query": "catalog:", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", "jsdom": "^31.0.1", - "lucide-react": "^1.14.0", - "monaco-editor": "^0.58.0", - "react": "19.3.1", - "react-dom": "19.3.1", + "lucide-react": "catalog:", + "monaco-editor": "catalog:", + "react": "catalog:", + "react-dom": "catalog:", "react-router": "8.4.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2" + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:" } } diff --git a/packages/flags/src/client/api.ts b/packages/flags/src/client/api.ts index e480329d73e..0919154aa13 100644 --- a/packages/flags/src/client/api.ts +++ b/packages/flags/src/client/api.ts @@ -72,12 +72,45 @@ async function getJson<T>(path: string, schema: z.ZodType<T>): Promise<T> { return schema.parse(body); } +const ListedSchema = z.array( + z.object({ id: z.string(), revision: z.number() }), +); +const RevisionSchema = z.object({ revision: z.number() }); +const DocumentKeySchema = z.tuple([ + z.literal("document"), + z.string(), + z.string(), +]); + +/** + * Keeps the summaries in step with edits. The deployment list and the drift + * report never refetch on their own; when a document arrives at a revision the + * list does not show (someone saved), both are refreshed. + */ +function keepSummariesFresh(queryClient: QueryClient): void { + queryClient.getQueryCache().subscribe((event) => { + if (event.type !== "updated" || event.action.type !== "success") return; + const key = DocumentKeySchema.safeParse(event.query.queryKey); + const saved = RevisionSchema.safeParse(event.action.data); + const listed = ListedSchema.safeParse( + queryClient.getQueryData(["deployments"]), + ); + if (!key.success || !saved.success || !listed.success) return; + const [, catalog, stage] = key.data; + const id = `${catalog}/${stage}`; + const known = listed.data.find((entry) => entry.id === id); + if (known === undefined || known.revision === saved.data.revision) return; + void queryClient.invalidateQueries({ queryKey: ["deployments"] }); + void queryClient.invalidateQueries({ queryKey: ["diff"] }); + }); +} + /** * The page's query client. Documents change only through this UI, which * invalidates what it writes, so nothing refetches on its own. */ export function createQueryClient(): QueryClient { - return new QueryClient({ + const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false, @@ -86,6 +119,8 @@ export function createQueryClient(): QueryClient { }, }, }); + keepSummariesFresh(queryClient); + return queryClient; } export function useDeployments() { diff --git a/packages/flags/src/client/app.tsx b/packages/flags/src/client/app.tsx index 456bd48d9bc..4028166d918 100644 --- a/packages/flags/src/client/app.tsx +++ b/packages/flags/src/client/app.tsx @@ -1,4 +1,3 @@ -import { useEffect } from "react"; import { Outlet, useLocation, @@ -39,7 +38,7 @@ import { itemCount, totalCounts } from "./views/drift-model.ts"; import { DriftPage } from "./views/drift-page.tsx"; import { descriptionsOf } from "./views/flag-meta.tsx"; import { HomePage } from "./views/home-page.tsx"; -import { useDrift, useSummaryRefresh } from "./views/views-api.ts"; +import { useDrift } from "./views/views-api.ts"; /** The deployment and flag the URL names; undefined on pages outside a deployment. */ function useDeploymentRoute(): Route | undefined { @@ -55,7 +54,6 @@ function Shell({ theme }: { theme: ThemeStore }) { const deployments = useDeployments(); const drift = useDrift(); const archive = useArchive(); - useSummaryRefresh(); const ids = deployments.data?.map((deployment) => deployment.id); const counts = new Map( (deployments.data ?? []).map( @@ -63,9 +61,6 @@ function Shell({ theme }: { theme: ThemeStore }) { ), ); const title = view === undefined ? pageTitle(route) : viewTitle(view); - useEffect(() => { - globalThis.document.title = title; - }, [title]); const navigation = { ids, counts, @@ -84,6 +79,7 @@ function Shell({ theme }: { theme: ThemeStore }) { return ( <> + <title>{title} }> diff --git a/packages/flags/src/client/management-api.ts b/packages/flags/src/client/management-api.ts index b61745c4507..8fc14e4ca7a 100644 --- a/packages/flags/src/client/management-api.ts +++ b/packages/flags/src/client/management-api.ts @@ -18,8 +18,8 @@ import { readEndpoint } from "@shepherdjerred/flags/client/api.ts"; /* * The management-only views (`README.md`, Audit and Usage): a flag's history, * a deployment's inventory metadata, the archive of retired flags and where - * flags are read. Their query keys start with `flags-` so they never match `["document", …]`, - * which `useSummaryRefresh` watches. + * flags are read. Their query keys start with `flags-` so they never match + * `["document", …]`, which `keepSummariesFresh` (client/api.ts) watches. */ export type HistoryEntry = FlagsHistoryResponse["entries"][number]; diff --git a/packages/flags/src/client/monaco/diff-view.tsx b/packages/flags/src/client/monaco/diff-view.tsx index 4572778d1fa..dca959e890a 100644 --- a/packages/flags/src/client/monaco/diff-view.tsx +++ b/packages/flags/src/client/monaco/diff-view.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef } from "react"; +import { useCallback } from "react"; import type { DiffViewProps } from "@shepherdjerred/flags/client/code.tsx"; import { useResolvedTheme } from "@shepherdjerred/flags/client/theme-context.ts"; import * as monaco from "monaco-editor/editor/editor.api.js"; @@ -17,53 +17,56 @@ export default function DiffView({ modified, labels, }: DiffViewProps): React.JSX.Element { - const host = useRef(null); const theme = useResolvedTheme(); - useEffect(() => { - applyTheme(theme); - }, [theme]); + // The editor lives and dies with its host element: React runs the returned + // cleanup when the element detaches or any input below changes. + const mount = useCallback( + (element: HTMLDivElement | null) => { + if (element === null) return; + const host = element; + applyTheme(theme); + const before = monaco.editor.createModel(original, "json"); + const after = monaco.editor.createModel(modified, "json"); + const diff = monaco.editor.createDiffEditor(host, { + ...baseOptions(), + readOnly: true, + originalEditable: false, + domReadOnly: true, + tabFocusMode: true, + renderSideBySide: true, + useInlineViewWhenSpaceIsLimited: true, + renderSideBySideInlineBreakpoint: 560, + renderOverviewRuler: false, + renderIndicators: true, + ignoreTrimWhitespace: false, + wordWrap: "on", + diffWordWrap: "on", + originalAriaLabel: labels.original, + modifiedAriaLabel: labels.modified, + }); + diff.setModel({ original: before, modified: after }); + const sides = [diff.getOriginalEditor(), diff.getModifiedEditor()]; + function resize(): void { + const content = Math.max( + ...sides.map((side) => side.getContentHeight()), + ); + const height = Math.min(MAX_HEIGHT, Math.max(MIN_HEIGHT, content)); + host.style.height = `${String(height)}px`; + } + const subscriptions = sides.map((side) => + side.onDidContentSizeChange(resize), + ); + resize(); + return () => { + for (const subscription of subscriptions) subscription.dispose(); + diff.dispose(); + before.dispose(); + after.dispose(); + }; + }, + [theme, original, modified, labels.original, labels.modified], + ); - useEffect(() => { - const element = host.current; - if (element === null) throw new Error("the diff view has no host"); - const before = monaco.editor.createModel(original, "json"); - const after = monaco.editor.createModel(modified, "json"); - const diff = monaco.editor.createDiffEditor(element, { - ...baseOptions(), - readOnly: true, - originalEditable: false, - domReadOnly: true, - tabFocusMode: true, - renderSideBySide: true, - useInlineViewWhenSpaceIsLimited: true, - renderSideBySideInlineBreakpoint: 560, - renderOverviewRuler: false, - renderIndicators: true, - ignoreTrimWhitespace: false, - wordWrap: "on", - diffWordWrap: "on", - originalAriaLabel: labels.original, - modifiedAriaLabel: labels.modified, - }); - diff.setModel({ original: before, modified: after }); - const sides = [diff.getOriginalEditor(), diff.getModifiedEditor()]; - function resize(): void { - const content = Math.max(...sides.map((side) => side.getContentHeight())); - const height = Math.min(MAX_HEIGHT, Math.max(MIN_HEIGHT, content)); - if (element !== null) element.style.height = `${String(height)}px`; - } - const subscriptions = sides.map((side) => - side.onDidContentSizeChange(resize), - ); - resize(); - return () => { - for (const subscription of subscriptions) subscription.dispose(); - diff.dispose(); - before.dispose(); - after.dispose(); - }; - }, [original, modified, labels.original, labels.modified]); - - return
; + return
; } diff --git a/packages/flags/src/client/views/drift-page.tsx b/packages/flags/src/client/views/drift-page.tsx index 0ea2bf00e0f..bd2e7294457 100644 --- a/packages/flags/src/client/views/drift-page.tsx +++ b/packages/flags/src/client/views/drift-page.tsx @@ -1,4 +1,4 @@ -import { useEffect } from "react"; +import { useCallback } from "react"; import { deploymentPath, flagPath, @@ -191,21 +191,27 @@ function DeploymentSection({ ); } -/** Scrolls to `#` once the sections it names exist. */ -function useHashScroll(ready: boolean): void { +/** + * The ref callback for the sections: it scrolls to `#` when the + * sections mount, which is once the report they name has loaded. + */ +function useHashScroll(): (element: HTMLElement | null) => void { const { hash } = useLocation(); - useEffect(() => { - if (!ready || hash.length <= 1) return; - globalThis.document - .querySelector(`#${CSS.escape(decodeURIComponent(hash.slice(1)))}`) - ?.scrollIntoView({ block: "start" }); - }, [ready, hash]); + return useCallback( + (element: HTMLElement | null) => { + if (element === null || hash.length <= 1) return; + element.ownerDocument + .querySelector(`#${CSS.escape(decodeURIComponent(hash.slice(1)))}`) + ?.scrollIntoView({ block: "start" }); + }, + [hash], + ); } /** Every live document compared with the repository's flag inventory. */ export function DriftPage(): React.JSX.Element { const drift = useDrift(); - useHashScroll(drift.data !== undefined); + const scrollToHash = useHashScroll(); const deployments = drift.data?.deployments ?? []; const totals = totalCounts(deployments); const total = itemCount(totals); @@ -268,7 +274,7 @@ export function DriftPage(): React.JSX.Element { anything drifts). The flag-inventory-sync schedule reconciles missing and retired keys every two minutes.

-
+
{dirty.map((entry) => ( ))} diff --git a/packages/flags/src/client/views/views-api.ts b/packages/flags/src/client/views/views-api.ts index 49be9691254..5c92cadd574 100644 --- a/packages/flags/src/client/views/views-api.ts +++ b/packages/flags/src/client/views/views-api.ts @@ -1,6 +1,4 @@ -import { useEffect } from "react"; -import { useQueries, useQuery, useQueryClient } from "@tanstack/react-query"; -import { z } from "zod"; +import { useQueries, useQuery } from "@tanstack/react-query"; import { FlagsDiffResponseSchema } from "@shepherdjerred/feature-flags/flags-wire.ts"; import { documentQuery, @@ -29,42 +27,3 @@ export function useDocuments(ids: readonly string[], enabled = true) { }), }); } - -const ListedSchema = z.array( - z.object({ id: z.string(), revision: z.number() }), -); -const RevisionSchema = z.object({ revision: z.number() }); -const DocumentKeySchema = z.tuple([ - z.literal("document"), - z.string(), - z.string(), -]); - -/** - * Keeps the summaries in step with edits. The deployment list and the drift - * report never refetch on their own; when a document arrives at a revision the - * list does not show (someone saved), both are refreshed. - */ -export function useSummaryRefresh(): void { - const queryClient = useQueryClient(); - useEffect( - () => - queryClient.getQueryCache().subscribe((event) => { - if (event.type !== "updated" || event.action.type !== "success") return; - const key = DocumentKeySchema.safeParse(event.query.queryKey); - const saved = RevisionSchema.safeParse(event.action.data); - const listed = ListedSchema.safeParse( - queryClient.getQueryData(["deployments"]), - ); - if (!key.success || !saved.success || !listed.success) return; - const [, catalog, stage] = key.data; - const id = `${catalog}/${stage}`; - const known = listed.data.find((entry) => entry.id === id); - if (known === undefined || known.revision === saved.data.revision) - return; - void queryClient.invalidateQueries({ queryKey: ["deployments"] }); - void queryClient.invalidateQueries({ queryKey: ["diff"] }); - }), - [queryClient], - ); -} diff --git a/packages/golink/package.json b/packages/golink/package.json index 0fc17d40d43..665a01873fa 100644 --- a/packages/golink/package.json +++ b/packages/golink/package.json @@ -32,21 +32,21 @@ "@opentelemetry/sdk-node": "^0.223.0", "@opentelemetry/sdk-trace-base": "^2.12.0", "@opentelemetry/semantic-conventions": "^1.40.0", - "@prisma/adapter-pg": "7.10.1", - "@prisma/client": "^7.10.1", + "@prisma/adapter-pg": "catalog:", + "@prisma/client": "catalog:", "@prisma/client-runtime-utils": "7.10.1", "@sentry/bun": "11.18.0", "@shepherdjerred/bugsink-config": "workspace:*", "@shepherdjerred/config": "workspace:*", "@shepherdjerred/console-server": "workspace:*", "@shepherdjerred/feature-flags": "workspace:*", - "@trpc/server": "^11.18.0", - "hono": "^4.12.18", - "prisma": "^7.10.1", + "@trpc/server": "catalog:", + "hono": "catalog:", + "prisma": "catalog:", "prom-client": "^15.1.3", - "react": "19.3.1", - "react-dom": "19.3.1", - "zod": "^4.4.3" + "react": "catalog:", + "react-dom": "catalog:", + "zod": "catalog:" }, "devDependencies": { "@shepherdjerred/architecture": "workspace:*", @@ -55,22 +55,22 @@ "@shepherdjerred/eslint-config": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", "@shepherdjerred/test-postgres": "workspace:*", - "@tanstack/react-query": "^5.101.2", - "@tanstack/react-router": "1.170.46", - "@trpc/client": "^11.18.0", - "@trpc/tanstack-react-query": "^11.18.0", + "@tanstack/react-query": "catalog:", + "@tanstack/react-router": "catalog:", + "@trpc/client": "catalog:", + "@trpc/tanstack-react-query": "catalog:", "@types/bun": "1.4.5", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", "jiti": "^2.7.0", "jsdom": "^31.0.1", - "lucide-react": "^1.14.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2" + "lucide-react": "catalog:", + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:" } } diff --git a/packages/mail/eslint.config.ts b/packages/mail/eslint.config.ts index 67c98d115da..5c714fdcbff 100644 --- a/packages/mail/eslint.config.ts +++ b/packages/mail/eslint.config.ts @@ -1,3 +1,6 @@ import { recommended } from "@shepherdjerred/eslint-config"; -export default recommended({ tsconfigRootDir: import.meta.dirname }); +export default recommended({ + tsconfigRootDir: import.meta.dirname, + react: true, +}); diff --git a/packages/mail/package.json b/packages/mail/package.json index cf9b8968b7a..b51be6c1ea2 100644 --- a/packages/mail/package.json +++ b/packages/mail/package.json @@ -17,34 +17,34 @@ "lint": "bunx eslint --cache . --max-warnings=0" }, "dependencies": { - "@base-ui/react": "^1.6.0", - "@hono/bun": "^1.0.1", + "@base-ui/react": "catalog:", + "@hono/bun": "catalog:", "@shepherdjerred/feature-flags": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", - "@tanstack/react-query": "^5.101.2", - "hono": "^4.12.18", - "lucide-react": "^1.14.0", + "@tanstack/react-query": "catalog:", + "hono": "catalog:", + "lucide-react": "catalog:", "nodemailer": "^10.6.1", "postal-mime": "^4.2.1", "prom-client": "^15.1.3", - "react": "19.3.1", - "react-dom": "19.3.1", + "react": "catalog:", + "react-dom": "catalog:", "react-router": "8.5.3", - "zod": "^4.4.3" + "zod": "catalog:" }, "devDependencies": { "@shepherdjerred/console-ui": "workspace:*", "@shepherdjerred/eslint-config": "workspace:*", "@types/bun": "1.4.5", "@types/nodemailer": "^8.0.2", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2" + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:" } } diff --git a/packages/ops-model/package.json b/packages/ops-model/package.json index 57749f56a7d..04fe1a27565 100644 --- a/packages/ops-model/package.json +++ b/packages/ops-model/package.json @@ -22,12 +22,12 @@ "ajv": "^8.20.0", "eslint": "^10.7.0", "jiti": "^2.7.0", - "typescript": "^6.0.3", - "vitest": "5.1.2", - "@vitest/coverage-istanbul": "5.1.2" + "typescript": "catalog:", + "vitest": "catalog:", + "@vitest/coverage-istanbul": "catalog:" }, "dependencies": { - "zod": "^4.4.3" + "zod": "catalog:" }, "exports": { "./services.json": "./services.json", diff --git a/packages/tracker/package.json b/packages/tracker/package.json index 66ba554edb0..0f510cb38bc 100644 --- a/packages/tracker/package.json +++ b/packages/tracker/package.json @@ -23,10 +23,10 @@ "test:e2e": "bun --no-install --bun playwright test" }, "dependencies": { - "@base-ui/react": "^1.6.0", - "@dnd-kit/core": "^6.3.1", - "@dnd-kit/sortable": "^10.0.0", - "@hono/bun": "^1.0.1", + "@base-ui/react": "catalog:", + "@dnd-kit/core": "catalog:", + "@dnd-kit/sortable": "catalog:", + "@hono/bun": "catalog:", "@opentelemetry/api": "^1.9.1", "@opentelemetry/context-async-hooks": "^2.12.0", "@opentelemetry/exporter-trace-otlp-http": "^0.223.0", @@ -34,30 +34,30 @@ "@opentelemetry/sdk-node": "^0.223.0", "@opentelemetry/sdk-trace-base": "^2.12.0", "@opentelemetry/semantic-conventions": "^1.40.0", - "@prisma/adapter-pg": "7.10.1", - "@prisma/client": "^7.10.1", + "@prisma/adapter-pg": "catalog:", + "@prisma/client": "catalog:", "@prisma/client-runtime-utils": "7.10.1", "@sentry/bun": "11.18.0", "@shepherdjerred/bugsink-config": "workspace:*", "@shepherdjerred/config": "workspace:*", "@shepherdjerred/feature-flags": "workspace:*", - "@tanstack/react-query": "^5.101.2", - "@tanstack/react-virtual": "^3.14.26", - "@trpc/client": "^11.18.0", - "@trpc/server": "^11.18.0", - "hono": "^4.12.18", - "lucide-react": "^1.14.0", + "@tanstack/react-query": "catalog:", + "@tanstack/react-virtual": "catalog:", + "@trpc/client": "catalog:", + "@trpc/server": "catalog:", + "hono": "catalog:", + "lucide-react": "catalog:", "pg": "8.23.1", - "prisma": "^7.10.1", - "react": "19.3.1", - "react-dom": "19.3.1", - "react-markdown": "^10.1.0", + "prisma": "catalog:", + "react": "catalog:", + "react-dom": "catalog:", + "react-markdown": "catalog:", "react-router": "8.4.0", - "remark-gfm": "^4.0.1", - "zod": "^4.4.3" + "remark-gfm": "catalog:", + "zod": "catalog:" }, "devDependencies": { - "@axe-core/playwright": "^4.14.1", + "@axe-core/playwright": "catalog:", "@playwright/test": "1.64.0", "@shepherdjerred/architecture": "workspace:*", "@shepherdjerred/console-ui": "workspace:*", @@ -66,15 +66,15 @@ "@shepherdjerred/test-postgres": "workspace:*", "@types/bun": "1.4.5", "@types/pg": "8.23.1", - "@types/react": "^19.3.0", - "@types/react-dom": "^19.3.0", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "^6.0.1", - "@vitest/coverage-istanbul": "5.1.2", + "@vitejs/plugin-react": "catalog:", + "@vitest/coverage-istanbul": "catalog:", "eslint": "^10.7.0", "jiti": "^2.7.0", - "typescript": "^6.0.3", - "vite": "^8.0.11", - "vitest": "5.1.2" + "typescript": "catalog:", + "vite": "catalog:", + "vitest": "catalog:" } } diff --git a/renovate.json b/renovate.json index 07d93c6df9e..58e70f28349 100644 --- a/renovate.json +++ b/renovate.json @@ -24,6 +24,16 @@ "enabled": false }, "customManagers": [ + { + "customType": "jsonata", + "description": "Root Bun workspace catalog (package.json `catalog`). The ten first-party consoles, console-ui and ops-model reference these as `catalog:`, which Renovate's npm manager does not read, so this manager is the only thing that bumps them. Half upgrade: Mend-hosted Renovate cannot run `bun install`, so a human refreshes bun.lock on the branch; `bun install --frozen-lockfile` fails until then.", + "fileFormat": "json", + "managerFilePatterns": ["/^package\\.json$/"], + "matchStrings": [ + "catalog.$each(function($value, $name) { { \"depName\": $name, \"currentValue\": $value } })" + ], + "datasourceTemplate": "npm" + }, { "customType": "regex", "description": "OpenTofu provider pins for the CDK Terrain stacks. A bump here is half of an upgrade: Mend-hosted Renovate cannot run post-upgrade commands, so someone runs bun run --cwd packages/homelab-cdktn providers:refresh on the branch to move the lock files, bindings and synthesized JSON. CI fails until that is done.", @@ -293,7 +303,7 @@ { "description": "Native TypeScript 7 owns typechecking; keep direct TypeScript on 6 for typescript-eslint project service, Astro Check, Twoslash, and TypeDoc.", "groupName": "typescript", - "matchManagers": ["bun", "npm"], + "matchManagers": ["bun", "npm", "custom.jsonata"], "matchDepNames": ["typescript"], "allowedVersions": "<7" }, diff --git a/scripts/checks/check-console-stack.test.ts b/scripts/checks/check-console-stack.test.ts new file mode 100644 index 00000000000..ba2bc461b81 --- /dev/null +++ b/scripts/checks/check-console-stack.test.ts @@ -0,0 +1,269 @@ +import { describe, expect, test } from "vitest"; +import { + collect, + compare, + deviationsFor, + renderTable, +} from "./check-console-stack.ts"; +import { + ALLOWLIST, + CATALOG_PENDING, + CONSOLES, + REQUIRED, + type AllowlistEntry, + type ConsoleDefinition, + type Deviation, +} from "./console-stack-rules.ts"; + +const ROOT = new URL("../..", import.meta.url).pathname; + +const catalog = new Map([ + ["react", "19.3.1"], + ["zod", "^4.4.3"], + ["hono", "^4.12.18"], +]); + +const typescriptConsole: ConsoleDefinition = { + id: "demo", + label: "Demo", + directory: "packages/demo", + kind: "typescript", +}; + +function packageWith( + dependencies: Record, +): Parameters[1] { + return { name: "@demo/demo", dependencies }; +} + +/** A package that satisfies every requirement of its kind, all from the catalog. */ +function standardPackage( + kind: ConsoleDefinition["kind"], +): Record { + return Object.fromEntries( + REQUIRED[kind].map((library) => [library, "catalog:"]), + ); +} + +describe("deviationsFor", () => { + test("a console on the standard has no deviations", () => { + expect( + deviationsFor( + typescriptConsole, + packageWith(standardPackage("typescript")), + catalog, + ), + ).toEqual([]); + }); + + test("reports each missing required library", () => { + const deps = standardPackage("typescript"); + delete deps["@tanstack/react-router"]; + delete deps["prisma"]; + const keys = deviationsFor(typescriptConsole, packageWith(deps), catalog) + .filter((item) => item.kind === "missing") + .map((item) => item.library); + expect(keys.toSorted()).toEqual(["@tanstack/react-router", "prisma"]); + }); + + test("reports banned alternatives, including whole scopes", () => { + const deps = { + ...standardPackage("typescript"), + "react-router": "8.4.0", + axios: "^1.0.0", + "@radix-ui/react-dialog": "^1.0.0", + dayjs: "^1.0.0", + "@tailwindcss/vite": "^4.0.0", + }; + const banned = deviationsFor(typescriptConsole, packageWith(deps), catalog) + .filter((item) => item.kind === "banned") + .map((item) => item.library); + expect(banned.toSorted()).toEqual([ + "@radix-ui/react-dialog", + "@tailwindcss/vite", + "axios", + "dayjs", + "react-router", + ]); + }); + + test("reports a catalogued library declared with its own version", () => { + const deps = { ...standardPackage("typescript"), zod: "^4.4.3" }; + const found = deviationsFor(typescriptConsole, packageWith(deps), catalog); + expect(found).toEqual([ + expect.objectContaining({ kind: "uncatalogued", library: "zod" }), + ]); + }); + + test("a shared kit stands in for the libraries it provides", () => { + const provided = new Set([ + "hono", + "@hono/bun", + "@trpc/server", + "@trpc/client", + "@trpc/tanstack-react-query", + "@tanstack/react-query", + "@tanstack/react-router", + ]); + const deps = Object.fromEntries( + Object.entries(standardPackage("typescript")).filter( + ([library]) => !provided.has(library), + ), + ); + expect( + deviationsFor( + typescriptConsole, + packageWith({ + ...deps, + "@shepherdjerred/console-server": "workspace:*", + "@shepherdjerred/console-client": "workspace:*", + }), + catalog, + ), + ).toEqual([]); + }); + + test("workspace packages are not catalogued", () => { + const deps = { + ...standardPackage("typescript"), + react: "workspace:*", + }; + expect( + deviationsFor(typescriptConsole, packageWith(deps), catalog), + ).toEqual([]); + }); + + test("a Rust console needs no server stack but may not carry one", () => { + const rust: ConsoleDefinition = { + ...typescriptConsole, + kind: "rust-client", + }; + expect( + deviationsFor(rust, packageWith(standardPackage("rust-client")), catalog), + ).toEqual([]); + const withHono = deviationsFor( + rust, + packageWith({ ...standardPackage("rust-client"), hono: "catalog:" }), + catalog, + ); + expect(withHono).toEqual([ + expect.objectContaining({ kind: "banned", library: "hono" }), + ]); + }); +}); + +describe("compare", () => { + const deviation: Deviation = { + app: "demo", + kind: "banned", + library: "react-router", + rule: "use TanStack Router, not react-router", + }; + const entry: AllowlistEntry = { + app: "demo", + kind: "banned", + library: "react-router", + reason: "until the router PR", + }; + + test("an allowlisted deviation passes", () => { + const report = compare([deviation], [entry], ["demo"]); + expect(report.unlisted).toEqual([]); + expect(report.stale).toEqual([]); + expect(report.malformed).toEqual([]); + }); + + test("a deviation without an entry fails", () => { + expect(compare([deviation], [], ["demo"]).unlisted).toEqual([deviation]); + }); + + // The list only shrinks: fixing a deviation without deleting its entry fails. + test("an entry whose deviation disappeared is stale", () => { + expect(compare([], [entry], ["demo"]).stale).toEqual([entry]); + }); + + test("rejects unknown apps, empty reasons and duplicates", () => { + const report = compare( + [], + [{ ...entry, app: "ghost" }, { ...entry, reason: " " }, entry, entry], + ["demo"], + ); + expect(report.malformed).toEqual([ + 'ghost:banned:react-router: unknown app "ghost"', + "demo:banned:react-router: missing reason", + "demo:banned:react-router: duplicate", + "demo:banned:react-router: duplicate", + ]); + }); +}); + +describe("renderTable", () => { + test("lists each deviation with its reason and marks clean apps", () => { + const definitions = [ + typescriptConsole, + { ...typescriptConsole, id: "clean", label: "Clean" }, + ]; + const table = renderTable( + [ + { + app: "demo", + kind: "banned", + library: "react-router", + rule: "x", + }, + ], + [ + { + app: "demo", + kind: "banned", + library: "react-router", + reason: "until the router PR", + }, + ], + definitions, + ); + expect(table).toContain("Demo"); + expect(table).toContain("react-router"); + expect(table).toContain("until the router PR"); + expect(table).toMatch(/Clean\s+-\s+-\s+on the standard/); + }); +}); + +describe("the repository", () => { + test("matches the allowlist exactly", async () => { + const { deviations, problems } = await collect(ROOT); + const report = compare( + deviations, + ALLOWLIST, + CONSOLES.map((definition) => definition.id), + ); + expect(problems).toEqual([]); + expect(report.malformed).toEqual([]); + expect(report.unlisted).toEqual([]); + expect(report.stale).toEqual([]); + }); + + test("every required library is catalogued or pending, never both", async () => { + const { problems } = await collect(ROOT); + expect(problems).toEqual([]); + for (const library of CATALOG_PENDING) { + expect(Object.values(REQUIRED).flat()).toContain(library); + } + }); + + test("covers the ten consoles and console-ui", () => { + expect(CONSOLES.map((definition) => definition.id)).toEqual([ + "hub", + "delivery", + "tracker", + "errors", + "mail", + "flags", + "feeds", + "golink", + "charts", + "ci-cache", + "console-ui", + ]); + }); +}); diff --git a/scripts/checks/check-console-stack.ts b/scripts/checks/check-console-stack.ts new file mode 100644 index 00000000000..a75b34681b0 --- /dev/null +++ b/scripts/checks/check-console-stack.ts @@ -0,0 +1,274 @@ +#!/usr/bin/env bun +/** + * Console stack check: the ten first-party ops consoles share one stack, and + * this check reads their `package.json` files to keep it that way. + * + * The standard is written down in + * `packages/docs/wiki/src/content/docs/reference/console-stack.md`. For each + * console (and `console-ui`, which owns the shared pieces) the check derives a + * list of deviations: a library the standard requires that is missing, a + * banned alternative that is present, or a catalogued library whose spec is not + * `catalog:`. Today's deviations live in `ALLOWLIST` below, each with a reason. + * + * The allowlist only shrinks. A deviation that is not listed fails the check, + * and so does a listed deviation that no longer exists: the migration PR that + * removes a deviation removes its entry in the same change. + */ +import { z } from "zod"; +import { + ALLOWLIST, + BANNED_GROUPS, + CATALOG_PENDING, + KIT_PROVIDES, + CONSOLES, + REQUIRED, + RUST_BANNED, + type AllowlistEntry, + type ConsoleDefinition, + type Deviation, +} from "./console-stack-rules.ts"; + +const PackageJsonSchema = z.object({ + name: z.string(), + dependencies: z.record(z.string(), z.string()).optional(), + devDependencies: z.record(z.string(), z.string()).optional(), + peerDependencies: z.record(z.string(), z.string()).optional(), + catalog: z.record(z.string(), z.string()).optional(), +}); + +type PackageJson = z.infer; + +/** Every dependency a package declares, with its spec. */ +function declared(pkg: PackageJson): Map { + return new Map([ + ...Object.entries(pkg.peerDependencies ?? {}), + ...Object.entries(pkg.devDependencies ?? {}), + ...Object.entries(pkg.dependencies ?? {}), + ]); +} + +function isBanned(name: string): string | undefined { + for (const group of BANNED_GROUPS) { + for (const banned of group.names) { + const matches = banned.endsWith("/") + ? name.startsWith(banned) + : name === banned; + if (matches) return `use ${group.replaces}, not ${name}`; + } + } + return undefined; +} + +export function deviationsFor( + definition: ConsoleDefinition, + pkg: PackageJson, + catalog: ReadonlyMap, +): Deviation[] { + const deps = declared(pkg); + const provided = new Set( + [...deps.keys()].flatMap((name) => KIT_PROVIDES[name] ?? []), + ); + const deviations: Deviation[] = []; + for (const library of REQUIRED[definition.kind]) { + if (!deps.has(library) && !provided.has(library)) { + deviations.push({ + app: definition.id, + kind: "missing", + library, + rule: `the standard requires ${library}`, + }); + } + } + const bannedHere = + definition.kind === "rust-client" + ? RUST_BANNED.map((name) => ({ + name, + rule: `${name} cannot run against a Rust server`, + })) + : []; + for (const [name, spec] of deps) { + const rule = isBanned(name); + if (rule !== undefined) { + deviations.push({ + app: definition.id, + kind: "banned", + library: name, + rule, + }); + } + const rust = bannedHere.find((entry) => entry.name === name); + if (rust !== undefined) { + deviations.push({ + app: definition.id, + kind: "banned", + library: name, + rule: rust.rule, + }); + } + if ( + spec !== "catalog:" && + !spec.startsWith("workspace:") && + catalog.has(name) + ) { + deviations.push({ + app: definition.id, + kind: "uncatalogued", + library: name, + rule: `${name} is in the root catalog; declare it as "catalog:", not "${spec}"`, + }); + } + } + return deviations; +} + +const keyOf = (item: { app: string; kind: string; library: string }): string => + `${item.app}:${item.kind}:${item.library}`; + +export type StackReport = { + readonly deviations: readonly Deviation[]; + /** Deviations with no allowlist entry. */ + readonly unlisted: readonly Deviation[]; + /** Allowlist entries whose deviation no longer exists. */ + readonly stale: readonly AllowlistEntry[]; + /** Allowlist entries that name an app or repeat another entry. */ + readonly malformed: readonly string[]; +}; + +export function compare( + deviations: readonly Deviation[], + allowlist: readonly AllowlistEntry[], + apps: readonly string[], +): StackReport { + const present = new Set(deviations.map((item) => keyOf(item))); + const listed = new Set(allowlist.map((item) => keyOf(item))); + const malformed: string[] = []; + const seen = new Set(); + for (const entry of allowlist) { + if (!apps.includes(entry.app)) { + malformed.push(`${keyOf(entry)}: unknown app "${entry.app}"`); + } + if (entry.reason.trim() === "") { + malformed.push(`${keyOf(entry)}: missing reason`); + } + if (seen.has(keyOf(entry))) malformed.push(`${keyOf(entry)}: duplicate`); + seen.add(keyOf(entry)); + } + return { + deviations, + unlisted: deviations.filter((item) => !listed.has(keyOf(item))), + stale: allowlist.filter((item) => !present.has(keyOf(item))), + malformed, + }; +} + +/** A fixed-width table of deviations per app, with each one's allowlist reason. */ +export function renderTable( + deviations: readonly Deviation[], + allowlist: readonly AllowlistEntry[], + definitions: readonly ConsoleDefinition[] = CONSOLES, +): string { + const reasons = new Map(allowlist.map((item) => [keyOf(item), item.reason])); + const rows = definitions.flatMap((definition) => { + const own = deviations.filter((item) => item.app === definition.id); + if (own.length === 0) + return [[definition.label, "-", "-", "on the standard"]]; + return own.map((item) => [ + definition.label, + item.kind, + item.library, + reasons.get(keyOf(item)) ?? "NOT ALLOWLISTED", + ]); + }); + const header = ["app", "deviation", "library", "reason"]; + const widths = header.map((title, column) => + Math.max(title.length, ...rows.map((row) => row[column]?.length ?? 0)), + ); + const line = (cells: readonly string[]): string => + cells + .map((cell, column) => cell.padEnd(widths[column] ?? cell.length)) + .join(" ") + .trimEnd(); + return [ + line(header), + line(widths.map((width) => "-".repeat(width))), + ...rows.map((row) => line(row)), + ].join("\n"); +} + +async function readPackage(path: string): Promise { + return PackageJsonSchema.parse(await Bun.file(path).json()); +} + +export async function collect(root: string): Promise<{ + deviations: Deviation[]; + catalog: ReadonlyMap; + problems: string[]; +}> { + const rootPackage = await readPackage(`${root}/package.json`); + const catalog = new Map(Object.entries(rootPackage.catalog ?? {})); + const problems: string[] = []; + const deviations: Deviation[] = []; + for (const definition of CONSOLES) { + deviations.push( + ...deviationsFor( + definition, + await readPackage(`${root}/${definition.directory}/package.json`), + catalog, + ), + ); + if ( + definition.kind === "rust-client" && + !(await Bun.file(`${root}/${definition.directory}/Cargo.toml`).exists()) + ) { + problems.push( + `${definition.id} is declared a Rust console but ${definition.directory}/Cargo.toml does not exist`, + ); + } + } + for (const library of Object.values(REQUIRED).flat()) { + if (!catalog.has(library) && !CATALOG_PENDING.includes(library)) { + problems.push( + `the standard requires ${library} but the root package.json catalog does not list it; add it, or list it in CATALOG_PENDING`, + ); + } + } + for (const library of CATALOG_PENDING) { + if (catalog.has(library)) { + problems.push( + `${library} is in the root catalog; delete it from CATALOG_PENDING in scripts/checks/console-stack-rules.ts`, + ); + } + } + return { deviations, catalog, problems }; +} + +if (import.meta.main) { + const root = new URL("../..", import.meta.url).pathname; + const { deviations, problems } = await collect(root); + const report = compare( + deviations, + ALLOWLIST, + CONSOLES.map((definition) => definition.id), + ); + console.log(renderTable(deviations, ALLOWLIST)); + const failures = [ + ...problems, + ...report.malformed, + ...report.unlisted.map( + (item) => `${keyOf(item)}: ${item.rule}, and it is not allowlisted`, + ), + ...report.stale.map( + (item) => + `${keyOf(item)}: allowlisted but no longer a deviation; delete the entry from ALLOWLIST in scripts/checks/check-console-stack.ts`, + ), + ]; + console.log( + `\n${String(deviations.length)} allowlisted deviation(s) across ${String(CONSOLES.length)} packages.`, + ); + if (failures.length > 0) { + console.error("\ncheck-console-stack: FAIL"); + for (const failure of failures) console.error(` - ${failure}`); + process.exit(1); + } + console.log("check-console-stack: OK"); +} diff --git a/scripts/checks/console-stack-rules.ts b/scripts/checks/console-stack-rules.ts new file mode 100644 index 00000000000..27689e273b6 --- /dev/null +++ b/scripts/checks/console-stack-rules.ts @@ -0,0 +1,407 @@ +/** + * The console stack standard as data: which packages are consoles, what each + * kind requires, what is banned, and today's allowlisted deviations. The rules + * are enforced by `check-console-stack.ts` and written up in + * `packages/docs/wiki/src/content/docs/reference/console-stack.md`. + */ + +export type ConsoleKind = "typescript" | "rust-client" | "shared-ui"; + +export type ConsoleDefinition = { + /** Short id used in the allowlist and the report. */ + readonly id: string; + readonly label: string; + /** Directory holding the `package.json`, relative to the repository root. */ + readonly directory: string; + readonly kind: ConsoleKind; +}; + +export const CONSOLES: readonly ConsoleDefinition[] = [ + { + id: "hub", + label: "Hub", + directory: "packages/alert-dashboard", + kind: "typescript", + }, + { + id: "delivery", + label: "Delivery", + directory: "packages/delivery", + kind: "typescript", + }, + { + id: "tracker", + label: "Tracker", + directory: "packages/tracker", + kind: "typescript", + }, + { + id: "errors", + label: "Errors", + directory: "packages/errors", + kind: "typescript", + }, + { id: "mail", label: "Mail", directory: "packages/mail", kind: "typescript" }, + { + id: "flags", + label: "Flags", + directory: "packages/flags", + kind: "typescript", + }, + { + id: "feeds", + label: "Feeds", + directory: "packages/feeds", + kind: "typescript", + }, + { + id: "golink", + label: "Go link", + directory: "packages/golink", + kind: "typescript", + }, + { + id: "charts", + label: "Charts", + directory: "packages/charts", + kind: "rust-client", + }, + { + id: "ci-cache", + label: "CI cache", + directory: "packages/ci-cache", + kind: "rust-client", + }, + { + id: "console-ui", + label: "console-ui", + directory: "packages/console-ui", + kind: "shared-ui", + }, +]; + +/** What every console builds and tests with. */ +const TOOLCHAIN = [ + "react", + "react-dom", + "@types/react", + "@types/react-dom", + "@vitejs/plugin-react", + "typescript", + "vite", + "vitest", + "zod", + "lucide-react", +] as const; + +/** Router and browser data: TanStack Router, tRPC with TanStack Query. */ +const BROWSER_STACK = ["@tanstack/react-query", "@tanstack/react-router"]; + +/** tRPC, Hono on Bun and Prisma on PostgreSQL: the TypeScript server stack. */ +const SERVER_STACK = [ + "@trpc/client", + "@trpc/server", + "@trpc/tanstack-react-query", + "hono", + "@hono/bun", + "prisma", + "@prisma/client", + "@prisma/adapter-pg", +]; + +/** The shared pieces console-ui owns for every console. */ +const SHARED_UI = [ + "react", + "react-dom", + "@types/react", + "@types/react-dom", + "typescript", + "vitest", + "lucide-react", + "@base-ui/react", + "clsx", + "@tanstack/react-table", + "@tanstack/react-form", +]; + +export const REQUIRED: Readonly> = { + typescript: [...TOOLCHAIN, ...BROWSER_STACK, ...SERVER_STACK], + // Rust servers cannot serve tRPC or use Prisma: their clients use TanStack + // Query over REST with Zod, and the servers keep rusqlite. + "rust-client": [...TOOLCHAIN, ...BROWSER_STACK], + "shared-ui": SHARED_UI, +}; + +/** + * Shared kits that carry part of the stack for their consumers. A console that + * depends on a kit counts as declaring the libraries the kit provides. + */ +export const KIT_PROVIDES: Readonly> = { + "@shepherdjerred/console-server": [ + "hono", + "@hono/bun", + "@trpc/server", + "@trpc/client", + ], + "@shepherdjerred/console-client": [ + "@tanstack/react-query", + "@tanstack/react-router", + "@trpc/client", + "@trpc/server", + "@trpc/tanstack-react-query", + ], +}; + +/** + * Required libraries not in the root catalog yet. Knip rejects a catalog entry + * that no package uses, so the change that first declares one adds it to the + * catalog and deletes it here. + */ +export const CATALOG_PENDING: readonly string[] = [ + "@tanstack/react-form", + "@tanstack/react-table", +]; + +/** + * Libraries a Rust console's client must not carry: the server stack cannot + * run against a Rust server. + */ +export const RUST_BANNED = ["hono", "@hono/bun", "@trpc/server", "prisma"]; + +/** + * Alternatives the standard replaces. An entry ending in `/` bans the whole + * scope or prefix. + */ +export const BANNED_GROUPS: readonly { + replaces: string; + names: readonly string[]; +}[] = [ + { + replaces: "TanStack Router", + names: [ + "react-router", + "react-router-dom", + "@remix-run/router", + "wouter", + "@reach/router", + "navigo", + ], + }, + { + replaces: "tRPC with TanStack Query", + names: ["swr", "axios", "ky", "ofetch", "got", "node-fetch", "superagent"], + }, + { + replaces: "uPlot", + names: [ + "recharts", + "echarts", + "echarts-for-react", + "chart.js", + "react-chartjs-2", + "d3", + "victory", + "apexcharts", + "plotly.js", + "@visx/", + "@nivo/", + ], + }, + { + replaces: "Temporal (@js-temporal/polyfill) and Intl", + names: [ + "date-fns", + "dayjs", + "luxon", + "moment", + "moment-timezone", + "@date-fns/", + ], + }, + { + replaces: "TanStack Form", + names: ["react-hook-form", "formik", "final-form", "react-final-form"], + }, + { + replaces: "Base UI", + names: [ + "@radix-ui/", + "radix-ui", + "@headlessui/react", + "react-aria", + "react-aria-components", + "@react-aria/", + "ariakit", + "@ariakit/", + ], + }, + { + replaces: "TanStack Virtual", + names: ["react-window", "react-virtualized", "react-virtuoso"], + }, + { + replaces: "dnd-kit", + names: ["react-dnd", "react-beautiful-dnd", "@hello-pangea/dnd"], + }, + { + replaces: "react-markdown with remark-gfm", + names: ["marked", "markdown-it", "showdown", "snarkdown"], + }, + { + replaces: "plain CSS on console-ui", + names: [ + "tailwindcss", + "@tailwindcss/", + "styled-components", + "@emotion/", + "goober", + ], + }, + { + replaces: "Hono on Bun", + names: ["express", "fastify", "koa", "@hapi/hapi"], + }, + { + replaces: "Prisma on PostgreSQL", + names: [ + "better-sqlite3", + "sqlite3", + "@libsql/client", + "@prisma/adapter-libsql", + "@prisma/adapter-better-sqlite3", + ], + }, +]; + +export type Deviation = { + readonly app: string; + /** `missing`, `banned` or `uncatalogued`. */ + readonly kind: "missing" | "banned" | "uncatalogued"; + readonly library: string; + /** The rule the deviation breaks, for the report. */ + readonly rule: string; +}; + +export type AllowlistEntry = { + readonly app: string; + readonly kind: Deviation["kind"]; + readonly library: string; + /** Why the deviation exists today and which change removes it. */ + readonly reason: string; +}; + +const TRPC = ["@trpc/client", "@trpc/server", "@trpc/tanstack-react-query"]; +const PRISMA = ["prisma", "@prisma/client", "@prisma/adapter-pg"]; + +const ROUTER = "TanStack Router lands with the app's router PR"; +const API = "browser and callers use REST until the app's tRPC API PR"; +const DATABASE = "raw SQLite until the app's PostgreSQL and Prisma PR"; +const SHARED_UI_PIECES = + "console-ui gains it with the shared DataTable and form pieces"; + +function entries( + app: string, + kind: AllowlistEntry["kind"], + libraries: readonly string[], + reason: string, +): AllowlistEntry[] { + return libraries.map((library) => ({ app, kind, library, reason })); +} + +/** + * Today's deviations, exactly. Migration PRs delete entries; nothing adds one + * without changing this file in review. + */ +export const ALLOWLIST: readonly AllowlistEntry[] = [ + // Hub: React Router 8 and Prisma on SQLite; tRPC and Hono are already in. + ...entries("hub", "banned", ["react-router"], "react-router until Hub-R"), + ...entries("hub", "missing", ["@tanstack/react-router"], ROUTER), + ...entries( + "hub", + "banned", + ["@prisma/adapter-libsql"], + "Prisma on SQLite until Hub's PostgreSQL move", + ), + ...entries( + "hub", + "missing", + ["@prisma/adapter-pg"], + "Prisma on SQLite until Hub's PostgreSQL move", + ), + // Delivery: TanStack Router and Prisma on PostgreSQL are in; 125 REST routes remain. + ...entries( + "delivery", + "missing", + TRPC, + "125 REST routes until Delivery's tRPC API PR", + ), + // Tracker: React Router 8, and a plain tRPC client without TanStack Query's integration. + ...entries( + "tracker", + "banned", + ["react-router"], + "react-router until Tracker-R", + ), + ...entries("tracker", "missing", ["@tanstack/react-router"], ROUTER), + ...entries( + "tracker", + "missing", + ["@trpc/tanstack-react-query"], + "plain tRPC client until Tracker moves to the TanStack Query integration", + ), + // Errors: React Router 8, REST for the browser, static files served by hand. + ...entries( + "errors", + "banned", + ["react-router"], + "react-router until Errors-R", + ), + ...entries("errors", "missing", ["@tanstack/react-router"], ROUTER), + ...entries("errors", "missing", TRPC, API), + ...entries( + "errors", + "missing", + ["@hono/bun"], + "static files served by hand until the shared server kit", + ), + // Mail: React Router 8, REST, raw SQLite. + ...entries("mail", "banned", ["react-router"], "react-router until Mail-R"), + ...entries("mail", "missing", ["@tanstack/react-router"], ROUTER), + ...entries("mail", "missing", TRPC, API), + ...entries("mail", "missing", PRISMA, DATABASE), + // Flags: React Router 8, REST, raw SQLite. + ...entries("flags", "banned", ["react-router"], "react-router until Flags-R"), + ...entries("flags", "missing", ["@tanstack/react-router"], ROUTER), + ...entries("flags", "missing", TRPC, API), + ...entries("flags", "missing", PRISMA, DATABASE), + // Feeds: a hand-rolled router, REST, raw SQLite. + ...entries( + "feeds", + "missing", + ["@tanstack/react-router"], + "hand-rolled router until Feeds' router PR", + ), + ...entries("feeds", "missing", TRPC, API), + ...entries("feeds", "missing", PRISMA, DATABASE), + // Go link is on the shared server and client kits: nothing left to allowlist. + // Rust consoles: single pages reading the URL by hand, no TanStack Query yet. + ...entries( + "charts", + "missing", + ["@tanstack/react-router", "@tanstack/react-query"], + "single page reading the URL by hand until Charts' client PR", + ), + ...entries( + "ci-cache", + "missing", + ["@tanstack/react-router", "@tanstack/react-query"], + "single page reading the URL by hand until CI cache's client PR", + ), + // console-ui: the shared DataTable and form pieces are not written yet. + ...entries( + "console-ui", + "missing", + ["@tanstack/react-table", "@tanstack/react-form"], + SHARED_UI_PIECES, + ), +]; diff --git a/scripts/checks/deps/check-floating-deps.test.ts b/scripts/checks/deps/check-floating-deps.test.ts index aa71b02a00d..e2ae84096d6 100644 --- a/scripts/checks/deps/check-floating-deps.test.ts +++ b/scripts/checks/deps/check-floating-deps.test.ts @@ -40,6 +40,8 @@ describe("classifySpec", () => { "workspace:*", "file:../eslint-config", "link:../thing", + "catalog:", + "catalog:testing", ]) { expect(classifySpec(spec)).toEqual({ ok: true }); } @@ -97,6 +99,20 @@ describe("manifestErrors", () => { }); }); +describe("catalog entries", () => { + test("are checked like dependency specs", () => { + const manifest = JSON.stringify({ + catalog: { react: "19.3.1", zod: "latest", clsx: "catalog:" }, + catalogs: { testing: { vitest: "*" } }, + }); + const errors = manifestErrors("package.json", manifest); + expect(errors).toHaveLength(3); + expect(errors.join("\n")).toContain("catalog.zod"); + expect(errors.join("\n")).toContain("catalog.clsx"); + expect(errors.join("\n")).toContain("catalogs.testing.vitest"); + }); +}); + describe("readWorkspacePatterns", () => { test("requires an array of strings", () => { expect(() => readWorkspacePatterns(JSON.stringify({}))).toThrow( diff --git a/scripts/checks/deps/check-floating-deps.ts b/scripts/checks/deps/check-floating-deps.ts index e047d2a78fd..eec738274bc 100644 --- a/scripts/checks/deps/check-floating-deps.ts +++ b/scripts/checks/deps/check-floating-deps.ts @@ -36,6 +36,13 @@ const dependencyFields = [ */ const pinnedProtocols = ["workspace:", "file:", "link:"]; +/** + * `catalog:` and `catalog:` defer to the root manifest's `catalog` and + * `catalogs` entries, which are checked here like any other dependency field, + * so a catalogued spec is pinnable exactly when its catalog entry is. + */ +const catalogProtocol = "catalog:"; + export type SpecVerdict = { ok: true } | { ok: false; reason: string }; /** @@ -54,7 +61,7 @@ export function classifySpec(rawSpec: string): SpecVerdict { }; } - for (const protocol of pinnedProtocols) { + for (const protocol of [...pinnedProtocols, catalogProtocol]) { if (spec.startsWith(protocol)) return { ok: true }; } @@ -127,6 +134,36 @@ export function manifestErrors( } } } + errors.push(...catalogErrors(relativePath, manifestRaw)); + return errors; +} + +/** Check the root manifest's `catalog` and `catalogs` entries as dependency specs. */ +function catalogErrors(relativePath: string, manifest: object): string[] { + const errors: string[] = []; + const check = (label: string, entries: unknown): void => { + if (typeof entries !== "object" || entries === null) return; + for (const [name, specRaw] of Object.entries(entries)) { + if (typeof specRaw !== "string") { + throw new TypeError( + `${relativePath} ${label}.${name} must be a string`, + ); + } + const verdict = classifySpec(specRaw); + if (!verdict.ok || specRaw.startsWith(catalogProtocol)) { + errors.push( + `${relativePath} ${label}.${name}: ${verdict.ok ? "a catalog entry cannot reference another catalog" : verdict.reason}`, + ); + } + } + }; + check("catalog", Reflect.get(manifest, "catalog")); + const named: unknown = Reflect.get(manifest, "catalogs"); + if (typeof named === "object" && named !== null) { + for (const [group, entries] of Object.entries(named)) { + check(`catalogs.${group}`, entries); + } + } return errors; } diff --git a/scripts/checks/deps/check-renovate-hints.test.ts b/scripts/checks/deps/check-renovate-hints.test.ts index e3000ccc860..c5460969d3b 100644 --- a/scripts/checks/deps/check-renovate-hints.test.ts +++ b/scripts/checks/deps/check-renovate-hints.test.ts @@ -11,12 +11,15 @@ import { const ConfigSchema = z.object({ customManagers: z.array( - z.object({ - customType: z.literal("regex"), - description: z.string(), - managerFilePatterns: z.array(z.string()), - matchStrings: z.array(z.string()), - }), + z.union([ + z.object({ + customType: z.literal("regex"), + description: z.string(), + managerFilePatterns: z.array(z.string()), + matchStrings: z.array(z.string()), + }), + z.looseObject({ customType: z.literal("jsonata") }), + ]), ), }); @@ -24,7 +27,9 @@ async function repositoryManagers(): Promise { const config = ConfigSchema.parse( await Bun.file(`${import.meta.dir}/../../../renovate.json`).json(), ); - return config.customManagers; + return config.customManagers.flatMap((manager) => + manager.customType === "regex" ? [manager] : [], + ); } // Fixtures are assembled from parts so this file never contains a real hint diff --git a/scripts/checks/deps/check-renovate-hints.ts b/scripts/checks/deps/check-renovate-hints.ts index cc04a63a688..426a9b104fe 100644 --- a/scripts/checks/deps/check-renovate-hints.ts +++ b/scripts/checks/deps/check-renovate-hints.ts @@ -27,8 +27,23 @@ const RegexManagerSchema = z.object({ matchStrings: z.array(z.string()), }); +/** + * Hinted pins are read only by regex managers. Other manager types (the + * JSONata manager that reads the root Bun catalog) are not hint readers. + */ +const CustomManagerSchema = z.union([ + RegexManagerSchema, + z.looseObject({ customType: z.literal("jsonata") }), +]); + const RenovateConfigSchema = z.object({ - customManagers: z.array(RegexManagerSchema), + customManagers: z + .array(CustomManagerSchema) + .transform((managers) => + managers.flatMap((manager) => + manager.customType === "regex" ? [manager] : [], + ), + ), customDatasources: z.record(z.string(), z.unknown()).optional(), ignorePaths: z.array(z.string()).optional(), }); diff --git a/scripts/misc/new-service-console.ts b/scripts/misc/new-service-console.ts new file mode 100644 index 00000000000..fbd49dbec74 --- /dev/null +++ b/scripts/misc/new-service-console.ts @@ -0,0 +1,481 @@ +import type { ServiceOptions } from "./new-service-options.ts"; + +/** + * The opt-in `--console` template of `new-service.ts`: a web service on the + * stack standard for first-party ops consoles, written up in the wiki + * reference "Console stack" and enforced by `scripts/checks/check-console-stack.ts`. + * + * A Hono server on Bun with `/healthz`, a tRPC router, a Prisma schema for + * PostgreSQL, and a Vite + React client with TanStack Router, the + * `@trpc/tanstack-react-query` provider and console-ui's shell. Every + * dependency a shared catalog entry covers is declared `catalog:`. Paths are + * relative to the repository root. + */ + +const CATALOG = "catalog:"; + +function sorted( + entries: Readonly>, +): Record { + return Object.fromEntries( + Object.entries(entries).toSorted(([a], [b]) => (a < b ? -1 : 1)), + ); +} + +/** The console's `package.json`, replacing the base scaffold's. */ +function packageJson({ name }: ServiceOptions): string { + return `${JSON.stringify( + { + name: `@shepherdjerred/${name}`, + version: "0.1.0", + type: "module", + private: true, + exports: { "./*": "./src/*" }, + scripts: { + generate: "prisma generate", + build: "vite build", + dev: "bun --watch src/index.ts", + "dev:client": "vite", + start: "bun src/index.ts", + test: "bun --no-install --bun vitest --config ../../vitest.config.ts run src", + "test:ci": "bun ../../scripts/ci/run-ci-test.ts", + typecheck: + "PATH=node_modules/@typescript/native/bin:$PATH tsc --noEmit", + lint: "eslint . --max-warnings=0", + }, + dependencies: sorted({ + "@hono/bun": CATALOG, + "@prisma/adapter-pg": CATALOG, + "@prisma/client": CATALOG, + "@tanstack/react-query": CATALOG, + "@tanstack/react-router": CATALOG, + "@trpc/client": CATALOG, + "@trpc/server": CATALOG, + "@trpc/tanstack-react-query": CATALOG, + hono: CATALOG, + "lucide-react": CATALOG, + prisma: CATALOG, + react: CATALOG, + "react-dom": CATALOG, + zod: CATALOG, + }), + devDependencies: sorted({ + "@shepherdjerred/console-ui": "workspace:*", + "@shepherdjerred/eslint-config": "workspace:*", + "@types/bun": "1.4.5", + "@types/react": CATALOG, + "@types/react-dom": CATALOG, + "@typescript/native": "npm:typescript@7.0.2", + "@vitejs/plugin-react": CATALOG, + "@vitest/coverage-istanbul": CATALOG, + eslint: "^10.7.0", + typescript: CATALOG, + vite: CATALOG, + vitest: CATALOG, + }), + }, + undefined, + 2, + )}\n`; +} + +const ESLINT_CONFIG = `import { recommended } from "@shepherdjerred/eslint-config"; + +export default [ + ...recommended({ + tsconfigRootDir: import.meta.dirname, + react: true, + ignores: ["generated/**", "dist/**"], + }), + { + // Prisma loads its config under Node, where \`Bun\` does not exist. + files: ["prisma.config.ts"], + rules: { "custom-rules/prefer-bun-apis": "off" }, + }, +]; +`; + +const TSCONFIG = `${JSON.stringify( + { + extends: "../../tsconfig.base.json", + compilerOptions: { + lib: ["ESNext", "DOM", "DOM.Iterable"], + types: ["bun", "vite/client"], + jsx: "react-jsx", + noEmit: true, + }, + include: ["src", "eslint.config.ts", "prisma.config.ts", "vite.config.ts"], + }, + undefined, + 2, +)}\n`; + +function viteConfig({ port }: ServiceOptions): string { + return `import react from "@vitejs/plugin-react"; +import { defineConfig } from "vite"; + +export default defineConfig({ + plugins: [react()], + build: { outDir: "dist/client", emptyOutDir: true, sourcemap: true }, + server: { + host: "127.0.0.1", + port: ${String(port + 1)}, + strictPort: true, + proxy: { + "/healthz": "http://127.0.0.1:${String(port)}", + "/trpc": "http://127.0.0.1:${String(port)}", + }, + }, +}); +`; +} + +function indexHtml({ title }: ServiceOptions): string { + return ` + + + + + + ${title} + + +
+ + + +`; +} + +const PRISMA_SCHEMA = `generator client { + provider = "prisma-client" + output = "../generated/prisma" + runtime = "bun" + moduleFormat = "esm" +} + +datasource db { + provider = "postgresql" +} + +// Placeholder. Replace it with the console's models and add a migration: +// bunx prisma migrate dev --name init +model Example { + id String @id @default(uuid()) + name String + createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6) + + @@map("examples") +} +`; + +function prismaConfig({ name, port }: ServiceOptions): string { + return `import { defineConfig } from "prisma/config"; + +export default defineConfig({ + schema: "prisma/schema.prisma", + datasource: { + url: + process.env["DATABASE_URL"] ?? + "postgres://postgres@127.0.0.1:${String(port + 2)}/${name.replaceAll("-", "_")}", + }, +}); +`; +} + +function serverSource({ name }: ServiceOptions): string { + return `import { serveStatic } from "@hono/bun"; +import { fetchRequestHandler } from "@trpc/server/adapters/fetch"; +import { Hono } from "hono"; +import { appRouter } from "./router.ts"; + +export type AppOptions = { + /** A built client directory to serve; the API answers alone when unset. */ + readonly clientRoot?: string; +}; + +/** + * The console's HTTP surface: \`/healthz\` for the kubelet and the image smoke + * run, \`/trpc\` for every first-party caller, and the built client. + */ +export function createApp({ clientRoot }: AppOptions = {}): Hono { + const app = new Hono(); + app.get("/healthz", (context) => context.text("ok")); + app.all("/trpc/*", (context) => + fetchRequestHandler({ + endpoint: "/trpc", + req: context.req.raw, + router: appRouter, + createContext: () => ({}), + }), + ); + if (clientRoot !== undefined) { + app.use("/assets/*", serveStatic({ root: clientRoot })); + app.get("*", serveStatic({ root: clientRoot, path: "index.html" })); + } + return app; +} + +export function startServer(port: number, hostname: string) { + const app = createApp({ clientRoot: "./dist/client" }); + const server = Bun.serve({ port, hostname, fetch: app.fetch }); + console.warn(\`${name} listening on :\${String(server.port)}\`); + return server; +} +`; +} + +const ROUTER_SOURCE = `import { initTRPC } from "@trpc/server"; +import { z } from "zod"; + +const t = initTRPC.create(); + +/** The API every caller shares: the browser, the toolkit, Temporal and CI. */ +export const appRouter = t.router({ + hello: t.procedure + .input(z.object({ name: z.string().min(1).optional() })) + .query(({ input }) => ({ greeting: \`Hello, \${input.name ?? "world"}\` })), +}); + +export type AppRouter = typeof appRouter; +`; + +const DB_SOURCE = `import { PrismaPg } from "@prisma/adapter-pg"; + +/** The driver adapter the generated Prisma client takes for PostgreSQL. */ +export function createDatabaseAdapter(connectionString: string): PrismaPg { + return new PrismaPg({ connectionString }); +} +`; + +const DB_TEST = `import { expect, test } from "vitest"; +import { createDatabaseAdapter } from "./db.ts"; + +test("builds a PostgreSQL driver adapter without connecting", () => { + const adapter = createDatabaseAdapter("postgres://postgres@127.0.0.1:1/x"); + expect(adapter.provider).toBe("postgres"); +}); +`; + +function serverTest(): string { + return `import { expect, test } from "vitest"; +import { createApp } from "./server.ts"; + +test("reports health", async () => { + const response = await createApp().request("/healthz"); + expect(response.status).toBe(200); + expect(await response.text()).toBe("ok"); +}); + +test("answers the example procedure over tRPC", async () => { + const input = encodeURIComponent(JSON.stringify({ name: "Ada" })); + const response = await createApp().request(\`/trpc/hello?input=\${input}\`); + expect(response.status).toBe(200); + expect(await response.json()).toEqual({ + result: { data: { greeting: "Hello, Ada" } }, + }); +}); + +test("answers 404 for an unknown API path", async () => { + const response = await createApp().request("/nope"); + expect(response.status).toBe(404); +}); +`; +} + +function trpcSource({ name }: ServiceOptions): string { + return `import { createTRPCContext } from "@trpc/tanstack-react-query"; +import type { AppRouter } from "@shepherdjerred/${name}/router.ts"; + +export const { TRPCProvider, useTRPC } = createTRPCContext(); +`; +} + +function mainSource({ name }: ServiceOptions): string { + return `import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { RouterProvider } from "@tanstack/react-router"; +import { createTRPCClient, httpBatchLink } from "@trpc/client"; +import { StrictMode } from "react"; +import { createRoot } from "react-dom/client"; +import type { AppRouter } from "@shepherdjerred/${name}/router.ts"; +import { createAppRouter } from "./routes.tsx"; +import { TRPCProvider } from "./trpc.ts"; +import "@shepherdjerred/console-ui/styles/index.css"; + +const queryClient = new QueryClient(); +const trpcClient = createTRPCClient({ + links: [httpBatchLink({ url: "/trpc" })], +}); +const router = createAppRouter(); + +const root = document.querySelector("#root"); +if (root === null) throw new Error("${name} page is missing #root"); + +createRoot(root).render( + + + + + + + , +); +`; +} + +/** + * The directive the generated route file needs for one `interface`. It is + * assembled so this template is not itself read as a lint suppression. + */ +const SUPPRESSION = ["eslint", "disable", "next", "line"].join("-"); + +function routesSource(options: ServiceOptions): string { + const { title } = options; + return `import { useQuery } from "@tanstack/react-query"; +import { + Link, + Outlet, + createRootRoute, + createRoute, + createRouter, + useSearch, + type RouterHistory, +} from "@tanstack/react-router"; +import { HouseIcon } from "lucide-react"; +import { z } from "zod"; +import { + HeaderBar, + PageBody, + ShellFrame, + Sidebar, + SidebarGroup, + SidebarItem, +} from "@shepherdjerred/console-ui"; +import { useTRPC } from "./trpc.ts"; + +function Shell(): React.JSX.Element { + return ( + + + ( + + {link.children} + + )} + /> + + + } + > + + + ); +} + +/** Every URL parameter is validated with Zod before a page reads it. */ +const homeSearch = z.object({ name: z.string().min(1).optional() }); + +function Home(): React.JSX.Element { + const trpc = useTRPC(); + const { name } = useSearch({ from: "/" }); + const greeting = useQuery(trpc.hello.queryOptions({ name })); + return ( + <> + + +

{greeting.data?.greeting ?? "Loading…"}

+
+ + ); +} + +const rootRoute = createRootRoute({ component: Shell }); +const homeRoute = createRoute({ + getParentRoute: () => rootRoute, + path: "/", + validateSearch: homeSearch, + component: Home, +}); + +const routeTree = rootRoute.addChildren([homeRoute]); + +/** The browser uses its own history; tests pass a memory history. */ +export function createAppRouter(history?: RouterHistory) { + return createRouter({ routeTree, ...(history === undefined ? {} : { history }) }); +} + +declare module "@tanstack/react-router" { + // TanStack Router discovers the route tree through declaration merging, + // which only works with an interface: a type alias cannot merge. + // ${SUPPRESSION} @typescript-eslint/consistent-type-definitions -- declaration merging requires \`interface\` + interface Register { + router: ReturnType; + } +} +`; +} + +function routesTest({ name, title }: ServiceOptions): string { + return `import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { createTRPCClient, httpBatchLink } from "@trpc/client"; +import { RouterProvider, createMemoryHistory } from "@tanstack/react-router"; +import { renderToString } from "react-dom/server"; +import { expect, test } from "vitest"; +import type { AppRouter } from "@shepherdjerred/${name}/router.ts"; +import { createAppRouter } from "./routes.tsx"; +import { TRPCProvider } from "./trpc.ts"; + +test("renders the shell and the page header at the index route", async () => { + const queryClient = new QueryClient(); + const trpcClient = createTRPCClient({ + links: [httpBatchLink({ url: "http://localhost/trpc" })], + }); + const router = createAppRouter( + createMemoryHistory({ initialEntries: ["/?name=Ada"] }), + ); + await router.load(); + const html = renderToString( + + + + + , + ); + expect(html).toContain("ui-shell"); + expect(html).toContain("ui-header"); + expect(html).toContain("${title}"); +}); +`; +} + +/** Every file the console template creates or replaces, under the package. */ +export function consoleFiles( + options: ServiceOptions, +): Readonly> { + const base = `packages/${options.name}`; + return { + [`${base}/package.json`]: packageJson(options), + [`${base}/eslint.config.ts`]: ESLINT_CONFIG, + [`${base}/tsconfig.json`]: TSCONFIG, + [`${base}/vite.config.ts`]: viteConfig(options), + [`${base}/index.html`]: indexHtml(options), + [`${base}/prisma.config.ts`]: prismaConfig(options), + [`${base}/prisma/schema.prisma`]: PRISMA_SCHEMA, + [`${base}/src/server.ts`]: serverSource(options), + [`${base}/src/server.test.ts`]: serverTest(), + [`${base}/src/router.ts`]: ROUTER_SOURCE, + [`${base}/src/db.ts`]: DB_SOURCE, + [`${base}/src/db.test.ts`]: DB_TEST, + [`${base}/src/client/main.tsx`]: mainSource(options), + [`${base}/src/client/routes.tsx`]: routesSource(options), + [`${base}/src/client/routes.test.tsx`]: routesTest(options), + [`${base}/src/client/trpc.ts`]: trpcSource(options), + }; +} diff --git a/scripts/misc/new-service-files.ts b/scripts/misc/new-service-files.ts index 2efe56067db..495894a292c 100644 --- a/scripts/misc/new-service-files.ts +++ b/scripts/misc/new-service-files.ts @@ -1,3 +1,4 @@ +import { consoleFiles } from "./new-service-console.ts"; import type { ServiceOptions } from "./new-service-options.ts"; /** @@ -80,7 +81,7 @@ test("answers 404 elsewhere", () => { * the new image starts on the digests the fleet already runs. */ function dockerfile( - { name, port }: ServiceOptions, + { name, port, console: isConsole }: ServiceOptions, pins: { syntax: string; base: string }, ): string { const workspace = `@shepherdjerred/${name}`; @@ -115,7 +116,7 @@ RUN bun install --frozen-lockfile --filter '${workspace}' # Add each workspace dependency's directory to this COPY and to the runtime # stage's as the service gains them. FROM deps AS build -COPY --parents tsconfig.base.json packages/${name} packages/eslint-config ./ +COPY --parents tsconfig.base.json packages/${name} packages/eslint-config${isConsole === true ? " packages/console-ui" : ""} ./ RUN cd packages/${name} && bun run build FROM base AS prod-deps @@ -410,5 +411,7 @@ export function serviceFiles( [`${source}/resources/argo-applications/apps/${name}.ts`]: applicationSource(options), [`${CDK8S_ROOT}/helm/${name}/Chart.yaml`]: helmChart(options), + // The console template replaces the health-only server and its test. + ...(options.console === true ? consoleFiles(options) : {}), }; } diff --git a/scripts/misc/new-service-options.ts b/scripts/misc/new-service-options.ts index 76d9676580b..75f76e579e8 100644 --- a/scripts/misc/new-service-options.ts +++ b/scripts/misc/new-service-options.ts @@ -13,10 +13,12 @@ export type ServiceOptions = { host?: string; /** The catalog title. */ title: string; + /** Scaffold the first-party console stack instead of a health-only server. */ + console?: boolean; }; export const USAGE = - "Usage: bun scripts/misc/new-service.ts --name --kind web|worker --port [--host ] [--title ]"; + "Usage: bun scripts/misc/new-service.ts --name <kebab-name> --kind web|worker --port <port> [--host <tailnet-host>] [--title <title>] [--console]"; const HOST_PATTERN = /^[a-z][a-z0-9-]*$/u; /** In-image smoke runs bind `port + 10000`, which must stay a valid port. */ @@ -40,6 +42,7 @@ export function parseServiceOptions(argv: readonly string[]): ServiceOptions { port: { type: "string" }, host: { type: "string" }, title: { type: "string" }, + console: { type: "boolean" }, }, strict: true, }); @@ -55,6 +58,8 @@ export function parseServiceOptions(argv: readonly string[]): ServiceOptions { throw usage("--host is required for a web service"); if (kind === "worker" && host !== undefined) throw usage("--host applies to a web service; a worker has no ingress"); + if (kind !== "web" && values.console === true) + throw usage("--console applies to a web service; a worker has no browser"); if (host !== undefined && !HOST_PATTERN.test(host)) throw usage("--host must be a lowercase tailnet hostname label"); return { @@ -63,5 +68,6 @@ export function parseServiceOptions(argv: readonly string[]): ServiceOptions { port, ...(host === undefined ? {} : { host }), title: values.title ?? defaultTitle(name), + ...(values.console === true ? { console: true } : {}), }; } diff --git a/scripts/misc/new-service.test.ts b/scripts/misc/new-service.test.ts index c70d5f8f39c..f0088179722 100644 --- a/scripts/misc/new-service.test.ts +++ b/scripts/misc/new-service.test.ts @@ -2,6 +2,7 @@ import { afterEach, describe, expect, test } from "vitest"; import { cp, mkdtemp, rm } from "node:fs/promises"; import { tmpdir } from "node:os"; import path from "node:path"; +import prettier from "prettier"; import { z } from "zod"; import { formatChecklist, @@ -9,6 +10,7 @@ import { parseBakeTargets, registrationFindings, } from "../checks/service-registration.ts"; +import { deviationsFor } from "../checks/check-console-stack.ts"; import { cliWrittenFiles, DOCKERHUB_SYNTH_OUTPUT, @@ -46,6 +48,15 @@ const WORKER: ServiceOptions = { title: "Fixture worker", }; +const CONSOLE: ServiceOptions = { + name: "fixture-console", + kind: "web", + port: 7410, + host: "fixture-console", + title: "Fixture console", + console: true, +}; + const temporaryDirectories: string[] = []; afterEach(async () => { @@ -344,6 +355,118 @@ describe("scaffoldService collisions and pre-provisioned images", () => { }); }); +describe("scaffoldService with --console", () => { + test("a --console service is registered and carries the console stack", async () => { + const root = await fixtureTree(); + const files = await scaffoldService(root, CONSOLE); + const inputs = await loadRegistrationInputs(root); + expect(formatChecklist(registrationFindings(inputs))).toBe(""); + + const base = "packages/fixture-console"; + expect(files).toEqual( + expect.arrayContaining([ + `${base}/package.json`, + `${base}/prisma/schema.prisma`, + `${base}/prisma.config.ts`, + `${base}/index.html`, + `${base}/vite.config.ts`, + `${base}/src/router.ts`, + `${base}/src/db.ts`, + `${base}/src/server.ts`, + `${base}/src/server.test.ts`, + `${base}/src/client/main.tsx`, + `${base}/src/client/routes.tsx`, + `${base}/src/client/routes.test.tsx`, + `${base}/src/client/trpc.ts`, + ]), + ); + const read = async (file: string) => + Bun.file(path.join(root, base, file)).text(); + + const server = await read("src/server.ts"); + expect(server).toContain("new Hono()"); + expect(server).toContain('"/healthz"'); + expect(server).toContain("fetchRequestHandler"); + expect(await read("src/router.ts")).toContain("initTRPC.create()"); + expect(await read("prisma/schema.prisma")).toContain( + 'provider = "postgresql"', + ); + const routes = await read("src/client/routes.tsx"); + expect(routes).toContain("createRootRoute"); + expect(routes).toContain("validateSearch"); + expect(routes).toContain("ShellFrame"); + expect(routes).toContain("HeaderBar"); + expect(routes).toContain("eslint-disable-next-line"); + expect(routes).toContain("interface Register"); + expect(await read("src/client/trpc.ts")).toContain( + "createTRPCContext<AppRouter>()", + ); + // The console's image builds the client, which imports console-ui. + expect(await read("Dockerfile")).toContain("packages/console-ui"); + }); + + test("every generated source file is prettier-formatted", async () => { + const root = await fixtureTree(); + const files = await scaffoldService(root, CONSOLE); + const sources = files.filter( + (file) => + file.startsWith("packages/fixture-console/") && + /\.(?:tsx?|json|html)$/u.test(file), + ); + expect(sources.length).toBeGreaterThan(10); + for (const file of sources) { + const configured = path.join(REPOSITORY_ROOT, file); + const text = await Bun.file(path.join(root, file)).text(); + expect( + await prettier.check(text, { + ...(await prettier.resolveConfig(configured)), + filepath: configured, + }), + file, + ).toBe(true); + } + }); + + test("a --console service's package.json meets the stack check", async () => { + const root = await fixtureTree(); + await scaffoldService(root, CONSOLE); + const manifest = z + .object({ + name: z.string(), + dependencies: z.record(z.string(), z.string()), + devDependencies: z.record(z.string(), z.string()), + }) + .parse( + await Bun.file( + path.join(root, "packages/fixture-console/package.json"), + ).json(), + ); + const rootManifest = z + .object({ catalog: z.record(z.string(), z.string()) }) + .parse(await Bun.file(path.join(REPOSITORY_ROOT, "package.json")).json()); + const deviations = deviationsFor( + { id: "fixture", label: "Fixture", directory: "x", kind: "typescript" }, + manifest, + new Map(Object.entries(rootManifest.catalog)), + ); + expect(deviations).toEqual([]); + }); + + test("a plain web service stays a health-only server", async () => { + const root = await fixtureTree(); + await scaffoldService(root, WEB); + const server = await Bun.file( + path.join(root, "packages/fixture-notes/src/server.ts"), + ).text(); + expect(server).toContain("Bun.serve({ port, hostname, fetch: handle })"); + expect( + await Bun.file( + path.join(root, "packages/fixture-notes/src/router.ts"), + ).exists(), + ).toBe(false); + }); +}); + describe("parseServiceOptions", () => { test("reads a web service and a worker", () => { expect( @@ -358,7 +481,21 @@ describe("parseServiceOptions", () => { ).toEqual(WORKER); }); + test("reads --console for a web service", () => { + expect( + parseServiceOptions([ + "--name=fixture-console", + "--kind=web", + "--port=7410", + "--host=fixture-console", + "--title=Fixture console", + "--console", + ]), + ).toEqual(CONSOLE); + }); + test.each([ + ["--name notes --kind worker --port 7400 --console", "--console applies"], ["--kind web --port 7400 --host notes", "--name is required"], ["--name Bad_Name --kind web --port 7400 --host notes", "kebab-name"], ["--name notes --kind job --port 7400", "--kind must be web or worker"], diff --git a/scripts/misc/new-service.ts b/scripts/misc/new-service.ts index 59966c4d82a..b3d4a1cca7d 100644 --- a/scripts/misc/new-service.ts +++ b/scripts/misc/new-service.ts @@ -3,6 +3,11 @@ * Scaffolds a hosted first-party service in its prepared state. * * bun scripts/misc/new-service.ts --name notes --kind web --port 7400 --host notes + * bun scripts/misc/new-service.ts --name notes --kind web --port 7400 --host notes --console + * + * `--console` writes the first-party console stack (Hono on Bun, tRPC, Prisma + * on PostgreSQL, a Vite + React client on TanStack Router and console-ui) in + * place of the bare health server; see `new-service-console.ts`. * * It creates the package (Bun entrypoint with a health endpoint, Dockerfile), * a cdk8s chart on the matching first-party construct, the Argo Application @@ -38,7 +43,7 @@ export const DOCKERHUB_SYNTH_OUTPUT = "packages/homelab/src/tofu/dockerhub/main.tf.json"; /** The Dockerfile whose stages and base-image pins a new service starts from. */ const DOCKERFILE_MODEL = "packages/tracker/Dockerfile"; -const FORMATTED = /\.(?:ts|json)$/u; +const FORMATTED = /\.(?:tsx?|json|html)$/u; /** * Formats with this checkout's prettier configuration, whichever root the @@ -116,7 +121,16 @@ export async function scaffoldService( } /** What the scaffolder leaves to its author; the how-to has the detail. */ -function nextSteps({ name }: ServiceOptions): string[] { +function nextSteps({ name, console: isConsole }: ServiceOptions): string[] { + const consoleSteps = + isConsole === true + ? [ + ` 5. Replace the placeholder model in packages/${name}/prisma/schema.prisma, then`, + ` run bunx turbo run generate --filter=@shepherdjerred/${name} and add its migration.`, + " 6. Add the console to CONSOLES in scripts/checks/console-stack-rules.ts so", + " bun run check-console-stack holds it to the standard.", + ] + : []; return [ `Nothing deploys while ${activationConstant(name)} is false. Left to you:`, " 1. Bump the three inventory counts the new image and chart change:", @@ -124,6 +138,7 @@ function nextSteps({ name }: ServiceOptions): string[] { ` 2. Add ${name} to the inventory table in packages/README.md.`, ` 3. Write packages/${name}/README.md and the service itself.`, " 4. Activate it in a later change, once its image is published.", + ...consoleSteps, 'See the wiki how-to "Add a hosted service":', " packages/docs/wiki/src/content/docs/how-to/add-a-hosted-service.md", ]; diff --git a/scripts/renovate-config.test.ts b/scripts/renovate-config.test.ts index 2ac80b6af5a..b5de4382cc0 100644 --- a/scripts/renovate-config.test.ts +++ b/scripts/renovate-config.test.ts @@ -263,7 +263,7 @@ test("keeps direct TypeScript on 6 without constraining the native alias", async description: "Native TypeScript 7 owns typechecking; keep direct TypeScript on 6 for typescript-eslint project service, Astro Check, Twoslash, and TypeDoc.", groupName: "typescript", - matchManagers: ["bun", "npm"], + matchManagers: ["bun", "npm", "custom.jsonata"], matchDepNames: ["typescript"], allowedVersions: "<7", }); diff --git a/scripts/verify.ts b/scripts/verify.ts index a11469ffab3..03136d3b134 100644 --- a/scripts/verify.ts +++ b/scripts/verify.ts @@ -15,6 +15,7 @@ const turboTasks = [ "check-directory-file-counts", "check-flag-usage", "check-ai-architecture", + "check-console-stack", "check-floating-deps", "check-patched-deps", "check-ci-env", diff --git a/turbo.json b/turbo.json index 7000c23326b..bd2998be582 100644 --- a/turbo.json +++ b/turbo.json @@ -282,6 +282,28 @@ "!packages/dotfiles/dot_agents/skills/**" ] }, + // The ten ops consoles share one stack. The check reads each console's + // package.json (and the root catalog), so those manifests are its inputs. + "//#check-console-stack": { + "inputs": [ + "package.json", + "packages/alert-dashboard/package.json", + "packages/delivery/package.json", + "packages/tracker/package.json", + "packages/errors/package.json", + "packages/mail/package.json", + "packages/flags/package.json", + "packages/feeds/package.json", + "packages/golink/package.json", + "packages/charts/package.json", + "packages/charts/Cargo.toml", + "packages/ci-cache/package.json", + "packages/ci-cache/Cargo.toml", + "packages/console-ui/package.json", + "scripts/checks/check-console-stack.ts", + "scripts/checks/console-stack-rules.ts" + ] + }, // Dependency specs must be lockfile-pinnable: a dist-tag re-resolves on // every install, so the registry moving `latest` breaks --frozen-lockfile // on main with no commit to blame. From 6931cbf3e6afcb478742b27d62eaedecac710a13 Mon Sep 17 00:00:00 2001 From: Jerred Shepherd <github@sjer.red> Date: Sat, 28 Nov 2026 11:25:31 -0800 Subject: [PATCH 2/3] chore(root): catalog TanStack Table and Form now console-ui declares them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why CU2–4 (#5430) added @tanstack/react-table and @tanstack/react-form to console-ui (and react-form to Hub). The stack standard kept both in CATALOG_PENDING until a package declared them, and allowlisted console-ui as "missing" them; both entries are now stale and the stack check fails. What - Root catalog gains @tanstack/react-table ^9.3.1 and @tanstack/react-form ^1.33.6, the versions CU2–4 declared; console-ui and Hub use catalog:. - CATALOG_PENDING is empty and console-ui's two "missing" allowlist entries are gone; the wiki's "outside the catalog" table drops their row. Verification - `bun install --frozen-lockfile` passes; `bun run check-console-stack`: OK. - `bunx turbo run typecheck test lint --filter=@shepherdjerred/root-scripts --filter=@shepherdjerred/console-ui --filter=@shepherdjerred/alert-dashboard`: 34/34. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --- bun.lock | 8 +++++--- package.json | 2 ++ packages/alert-dashboard/package.json | 2 +- packages/console-ui/package.json | 4 ++-- .../src/content/docs/reference/console-stack.md | 11 +++++------ scripts/checks/console-stack-rules.ts | 14 +------------- 6 files changed, 16 insertions(+), 25 deletions(-) diff --git a/bun.lock b/bun.lock index b130492c8ff..82ea206d730 100644 --- a/bun.lock +++ b/bun.lock @@ -41,7 +41,7 @@ "@shepherdjerred/loaded": "workspace:*", "@shepherdjerred/ops-clients": "workspace:*", "@shepherdjerred/ops-model": "workspace:*", - "@tanstack/react-form": "^1.33.6", + "@tanstack/react-form": "catalog:", "@tanstack/react-query": "catalog:", "@trpc/client": "catalog:", "@trpc/server": "catalog:", @@ -530,8 +530,8 @@ "@base-ui/react": "catalog:", "@fontsource-variable/inter": "^5.3.0", "@js-temporal/polyfill": "catalog:", - "@tanstack/react-form": "^1.33.6", - "@tanstack/react-table": "^9.3.1", + "@tanstack/react-form": "catalog:", + "@tanstack/react-table": "catalog:", "@tanstack/react-virtual": "catalog:", "clsx": "catalog:", "lucide-react": "catalog:", @@ -3284,8 +3284,10 @@ "@js-temporal/polyfill": "^0.5.1", "@prisma/adapter-pg": "7.10.1", "@prisma/client": "^7.10.1", + "@tanstack/react-form": "^1.33.6", "@tanstack/react-query": "^5.101.2", "@tanstack/react-router": "1.170.46", + "@tanstack/react-table": "^9.3.1", "@tanstack/react-virtual": "^3.14.26", "@trpc/client": "^11.18.0", "@trpc/server": "^11.18.0", diff --git a/package.json b/package.json index cd8b5c4873e..5f049275e64 100644 --- a/package.json +++ b/package.json @@ -225,8 +225,10 @@ "@js-temporal/polyfill": "^0.5.1", "@prisma/adapter-pg": "7.10.1", "@prisma/client": "^7.10.1", + "@tanstack/react-form": "^1.33.6", "@tanstack/react-query": "^5.101.2", "@tanstack/react-router": "1.170.46", + "@tanstack/react-table": "^9.3.1", "@tanstack/react-virtual": "^3.14.26", "@trpc/client": "^11.18.0", "@trpc/server": "^11.18.0", diff --git a/packages/alert-dashboard/package.json b/packages/alert-dashboard/package.json index 5e1cd6e6869..832ddd94956 100644 --- a/packages/alert-dashboard/package.json +++ b/packages/alert-dashboard/package.json @@ -49,7 +49,7 @@ "@prisma/client-runtime-utils": "7.10.1", "@shepherdjerred/loaded": "workspace:*", "@shepherdjerred/experiments": "workspace:*", - "@tanstack/react-form": "^1.33.6", + "@tanstack/react-form": "catalog:", "@tanstack/react-query": "catalog:", "@trpc/client": "catalog:", "@trpc/server": "catalog:", diff --git a/packages/console-ui/package.json b/packages/console-ui/package.json index 2050fdd4c16..03da74de0ab 100644 --- a/packages/console-ui/package.json +++ b/packages/console-ui/package.json @@ -22,8 +22,8 @@ "@base-ui/react": "catalog:", "@fontsource-variable/inter": "^5.3.0", "@js-temporal/polyfill": "catalog:", - "@tanstack/react-form": "^1.33.6", - "@tanstack/react-table": "^9.3.1", + "@tanstack/react-form": "catalog:", + "@tanstack/react-table": "catalog:", "@tanstack/react-virtual": "catalog:", "clsx": "catalog:", "lucide-react": "catalog:", diff --git a/packages/docs/wiki/src/content/docs/reference/console-stack.md b/packages/docs/wiki/src/content/docs/reference/console-stack.md index 6efc7dc7296..92e162cd22e 100644 --- a/packages/docs/wiki/src/content/docs/reference/console-stack.md +++ b/packages/docs/wiki/src/content/docs/reference/console-stack.md @@ -89,13 +89,12 @@ those libraries as `"catalog:"`. Change a version in the catalog and run `bun install`, which rewrites `bun.lock`. A catalogued library declared with its own version fails the stack check. -Three kinds of library are outside the catalog: +Two kinds of library are outside the catalog: -| Library | Why | -| ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `@playwright/test` | The `ci-playwright` image promotion rewrites each exact pin together with the image digest | -| `@types/bun` | Pinned with the Bun toolchain, which moves in one change | -| `@tanstack/react-table`, `@tanstack/react-form` | Knip rejects a catalog entry no package uses. The change that first declares one adds it to the catalog and removes it from `CATALOG_PENDING` in the stack rules | +| Library | Why | +| ------------------ | ------------------------------------------------------------------------------------------ | +| `@playwright/test` | The `ci-playwright` image promotion rewrites each exact pin together with the image digest | +| `@types/bun` | Pinned with the Bun toolchain, which moves in one change | Renovate does not read `catalog` in a root `package.json` natively, so a JSONata custom manager in `renovate.json` extracts every entry. Mend-hosted diff --git a/scripts/checks/console-stack-rules.ts b/scripts/checks/console-stack-rules.ts index 27689e273b6..4e4d1b6e228 100644 --- a/scripts/checks/console-stack-rules.ts +++ b/scripts/checks/console-stack-rules.ts @@ -157,10 +157,7 @@ export const KIT_PROVIDES: Readonly<Record<string, readonly string[]>> = { * that no package uses, so the change that first declares one adds it to the * catalog and deletes it here. */ -export const CATALOG_PENDING: readonly string[] = [ - "@tanstack/react-form", - "@tanstack/react-table", -]; +export const CATALOG_PENDING: readonly string[] = []; /** * Libraries a Rust console's client must not carry: the server stack cannot @@ -296,8 +293,6 @@ const PRISMA = ["prisma", "@prisma/client", "@prisma/adapter-pg"]; const ROUTER = "TanStack Router lands with the app's router PR"; const API = "browser and callers use REST until the app's tRPC API PR"; const DATABASE = "raw SQLite until the app's PostgreSQL and Prisma PR"; -const SHARED_UI_PIECES = - "console-ui gains it with the shared DataTable and form pieces"; function entries( app: string, @@ -397,11 +392,4 @@ export const ALLOWLIST: readonly AllowlistEntry[] = [ ["@tanstack/react-router", "@tanstack/react-query"], "single page reading the URL by hand until CI cache's client PR", ), - // console-ui: the shared DataTable and form pieces are not written yet. - ...entries( - "console-ui", - "missing", - ["@tanstack/react-table", "@tanstack/react-form"], - SHARED_UI_PIECES, - ), ]; From 7000bd3c65e40b6b1a0bd990d07b10d024d77fbf Mon Sep 17 00:00:00 2001 From: Jerred Shepherd <github@sjer.red> Date: Sat, 28 Nov 2026 11:48:06 -0800 Subject: [PATCH 3/3] docs(docs): link the console stack reference to its sources Why Review of #5275 (codex P1): packages/docs/wiki/AGENTS.md requires every claim about the system to link the source file that proves it, and the console-stack reference named its sources only as inline code. What - Links the root package.json (catalog), renovate.json (catalog manager), scripts/checks/check-console-stack.ts, scripts/checks/console-stack-rules.ts and the scaffolder scripts/misc/new-service-console.ts. Verification - package.json and renovate.json return 200 on main; the three scripts this PR adds return 200 on the pushed console-stack-standard branch and resolve on main once it merges (rechecked after merge). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --- .../wiki/src/content/docs/reference/console-stack.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/docs/wiki/src/content/docs/reference/console-stack.md b/packages/docs/wiki/src/content/docs/reference/console-stack.md index 92e162cd22e..5ba7339aafd 100644 --- a/packages/docs/wiki/src/content/docs/reference/console-stack.md +++ b/packages/docs/wiki/src/content/docs/reference/console-stack.md @@ -83,7 +83,7 @@ The toolchain is `react`, `react-dom`, `@types/react`, `@types/react-dom`, ## The Bun catalog -The root `package.json` declares a default `catalog` that holds one version of +The root [`package.json`](https://github.com/shepherdjerred/monorepo/blob/main/package.json) declares a default `catalog` that holds one version of every library in the standard. A console, `console-ui` and `ops-model` declare those libraries as `"catalog:"`. Change a version in the catalog and run `bun install`, which rewrites `bun.lock`. A catalogued library declared with its @@ -97,17 +97,17 @@ Two kinds of library are outside the catalog: | `@types/bun` | Pinned with the Bun toolchain, which moves in one change | Renovate does not read `catalog` in a root `package.json` natively, so a -JSONata custom manager in `renovate.json` extracts every entry. Mend-hosted +JSONata custom manager in [`renovate.json`](https://github.com/shepherdjerred/monorepo/blob/main/renovate.json) extracts every entry. Mend-hosted Renovate cannot run `bun install`, so a catalog bump leaves `bun.lock` stale until someone refreshes it on the branch. ## The stack check `bun run check-console-stack` runs -`scripts/checks/check-console-stack.ts` +[`scripts/checks/check-console-stack.ts`](https://github.com/shepherdjerred/monorepo/blob/main/scripts/checks/check-console-stack.ts) against each console's `package.json` and the root catalog, and prints one row per deviation. The rules and the allowlist live in -`scripts/checks/console-stack-rules.ts`. +[`scripts/checks/console-stack-rules.ts`](https://github.com/shepherdjerred/monorepo/blob/main/scripts/checks/console-stack-rules.ts). | Deviation | Meaning | | -------------- | -------------------------------------------------------------- | @@ -124,7 +124,9 @@ allowlist only shrinks: - An entry names a package in the console list and carries a non-empty reason. The service scaffolder writes the standard stack for a new console: -`bun scripts/misc/new-service.ts --kind web --console`. See +`bun scripts/misc/new-service.ts --kind web --console`, which +[`scripts/misc/new-service-console.ts`](https://github.com/shepherdjerred/monorepo/blob/main/scripts/misc/new-service-console.ts) +implements. See [Add a hosted service](/how-to/add-a-hosted-service/). ## Related