@react-consulting/rc-kit 0.0.0-stage → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +94 -2
- package/devkit/README.md +301 -0
- package/devkit/cli.test.ts +211 -0
- package/devkit/cli.ts +120 -0
- package/devkit/commands/build.ts +127 -0
- package/devkit/commands/checks.ts +123 -0
- package/devkit/commands/context.ts +47 -0
- package/devkit/commands/db.ts +154 -0
- package/devkit/commands/deploy.ts +46 -0
- package/devkit/commands/dev.ts +191 -0
- package/devkit/commands/doctor.ts +25 -0
- package/devkit/commands/kit.ts +45 -0
- package/devkit/commands/new.ts +81 -0
- package/devkit/commands/registry.ts +20 -0
- package/devkit/commands/secrets.ts +254 -0
- package/devkit/lib/args.ts +65 -0
- package/devkit/lib/audit.test.ts +405 -0
- package/devkit/lib/audit.ts +813 -0
- package/devkit/lib/config.test.ts +203 -0
- package/devkit/lib/config.ts +417 -0
- package/devkit/lib/database/index.test.ts +223 -0
- package/devkit/lib/database/index.ts +314 -0
- package/devkit/lib/database/neon.test.ts +233 -0
- package/devkit/lib/database/neon.ts +357 -0
- package/devkit/lib/database/prepare.ts +54 -0
- package/devkit/lib/deploy-config.test.ts +217 -0
- package/devkit/lib/deploy-config.ts +133 -0
- package/devkit/lib/deploy.test.ts +275 -0
- package/devkit/lib/deploy.ts +177 -0
- package/devkit/lib/dev-gateway.test.ts +128 -0
- package/devkit/lib/dev-gateway.ts +162 -0
- package/devkit/lib/dev-menu.test.ts +114 -0
- package/devkit/lib/dev-menu.ts +332 -0
- package/devkit/lib/dev-secrets.test.ts +156 -0
- package/devkit/lib/dev-secrets.ts +97 -0
- package/devkit/lib/dev.test.ts +194 -0
- package/devkit/lib/dev.ts +119 -0
- package/devkit/lib/doctor.test.ts +144 -0
- package/devkit/lib/doctor.ts +264 -0
- package/devkit/lib/env-file.test.ts +102 -0
- package/devkit/lib/env-file.ts +96 -0
- package/devkit/lib/glob.ts +31 -0
- package/devkit/lib/infisical.test.ts +208 -0
- package/devkit/lib/infisical.ts +139 -0
- package/devkit/lib/json-schema.ts +220 -0
- package/devkit/lib/jsonc.test.ts +53 -0
- package/devkit/lib/jsonc.ts +93 -0
- package/devkit/lib/kit-migrate.test.ts +212 -0
- package/devkit/lib/kit-migrate.ts +617 -0
- package/devkit/lib/kit-package.test.ts +83 -0
- package/devkit/lib/kit-package.ts +57 -0
- package/devkit/lib/kit-version.ts +22 -0
- package/devkit/lib/naming.test.ts +547 -0
- package/devkit/lib/naming.ts +796 -0
- package/devkit/lib/paths.ts +7 -0
- package/devkit/lib/process.ts +78 -0
- package/devkit/lib/project-checks.ts +86 -0
- package/devkit/lib/scaffold.test.ts +302 -0
- package/devkit/lib/scaffold.ts +315 -0
- package/devkit/lib/secrets.test.ts +101 -0
- package/devkit/lib/secrets.ts +125 -0
- package/devkit/lib/sourcemaps.test.ts +86 -0
- package/devkit/lib/sourcemaps.ts +98 -0
- package/devkit/lib/test-utils.ts +68 -0
- package/devkit/lib/workspace.ts +87 -0
- package/devkit/lib/wrangler.ts +231 -0
- package/docs/rc-config.md +93 -0
- package/package.json +86 -4
- package/presets/build.d.ts +15 -0
- package/presets/build.js +53 -0
- package/presets/vite-plus.d.ts +28 -0
- package/presets/vite-plus.js +153 -0
- package/registry/README.md +294 -0
- package/registry/public/r/avatar-stack.json +18 -0
- package/registry/public/r/avatar.json +20 -0
- package/registry/public/r/back-link.json +21 -0
- package/registry/public/r/badge.json +17 -0
- package/registry/public/r/button.json +18 -0
- package/registry/public/r/calendar-days.json +14 -0
- package/registry/public/r/calendar-popover.json +24 -0
- package/registry/public/r/calendar.json +23 -0
- package/registry/public/r/callout.json +20 -0
- package/registry/public/r/card.json +18 -0
- package/registry/public/r/character-counter.json +17 -0
- package/registry/public/r/checkbox.json +22 -0
- package/registry/public/r/choice-cards.json +22 -0
- package/registry/public/r/color-tag.json +17 -0
- package/registry/public/r/combobox.json +24 -0
- package/registry/public/r/confirm-button.json +24 -0
- package/registry/public/r/confirm-dialog.json +23 -0
- package/registry/public/r/copy-button.json +24 -0
- package/registry/public/r/date-picker.json +24 -0
- package/registry/public/r/date-range-picker.json +28 -0
- package/registry/public/r/detail-header.json +17 -0
- package/registry/public/r/detail-row.json +17 -0
- package/registry/public/r/dev-inbox-api.json +33 -0
- package/registry/public/r/dev-toolbar.json +109 -0
- package/registry/public/r/dev-tools-contract.json +15 -0
- package/registry/public/r/dialog.json +23 -0
- package/registry/public/r/empty-state.json +20 -0
- package/registry/public/r/error-state.json +23 -0
- package/registry/public/r/eyebrow.json +17 -0
- package/registry/public/r/fab.json +20 -0
- package/registry/public/r/field-error.json +17 -0
- package/registry/public/r/field-grid.json +17 -0
- package/registry/public/r/field.json +19 -0
- package/registry/public/r/file-picker.json +22 -0
- package/registry/public/r/filter-chips.json +17 -0
- package/registry/public/r/form-section.json +17 -0
- package/registry/public/r/form-sheet.json +22 -0
- package/registry/public/r/icon-button.json +23 -0
- package/registry/public/r/input.json +18 -0
- package/registry/public/r/label.json +18 -0
- package/registry/public/r/list-row.json +17 -0
- package/registry/public/r/loading-state.json +18 -0
- package/registry/public/r/localized-field.json +23 -0
- package/registry/public/r/markdown-text.json +17 -0
- package/registry/public/r/menu.json +21 -0
- package/registry/public/r/money-input.json +17 -0
- package/registry/public/r/month-day-select.json +18 -0
- package/registry/public/r/numbered-step.json +20 -0
- package/registry/public/r/page-actions.json +14 -0
- package/registry/public/r/page-header.json +17 -0
- package/registry/public/r/pending.json +17 -0
- package/registry/public/r/person-option.json +21 -0
- package/registry/public/r/popover.json +20 -0
- package/registry/public/r/progress-bar.json +17 -0
- package/registry/public/r/query-view.json +22 -0
- package/registry/public/r/registry.json +1352 -0
- package/registry/public/r/retry-button.json +21 -0
- package/registry/public/r/rich-text-editor.json +32 -0
- package/registry/public/r/save-bar.json +22 -0
- package/registry/public/r/search-input.json +23 -0
- package/registry/public/r/search-select.json +24 -0
- package/registry/public/r/section-tabs.json +17 -0
- package/registry/public/r/segmented.json +18 -0
- package/registry/public/r/select.json +23 -0
- package/registry/public/r/sheet.json +24 -0
- package/registry/public/r/skeleton.json +17 -0
- package/registry/public/r/spinner.json +20 -0
- package/registry/public/r/stale-notice.json +23 -0
- package/registry/public/r/stat-tile.json +23 -0
- package/registry/public/r/stepper.json +23 -0
- package/registry/public/r/suggestion-strip.json +21 -0
- package/registry/public/r/swatch-picker.json +22 -0
- package/registry/public/r/switch.json +21 -0
- package/registry/public/r/tabs.json +20 -0
- package/registry/public/r/textarea.json +18 -0
- package/registry/public/r/theme.json +15 -0
- package/registry/public/r/timezone-select.json +19 -0
- package/registry/public/r/toaster.json +21 -0
- package/registry/public/r/tooltip.json +17 -0
- package/registry/public/r/ui-labels.json +14 -0
- package/registry/public/r/use-copy-to-clipboard.json +20 -0
- package/registry/public/r/use-online.json +14 -0
- package/registry/public/r/use-stale-queries.json +17 -0
- package/registry/public/r/utils.json +18 -0
- package/registry/public/r/weekday-picker.json +19 -0
- package/registry/public/r/yes-no.json +20 -0
- package/registry/serve.ts +29 -0
- package/rules/architecture.md +47 -0
- package/rules/cloudflare.md +74 -0
- package/rules/code.md +12 -0
- package/rules/git.md +10 -0
- package/rules/index.md +14 -0
- package/rules/observability.md +13 -0
- package/rules/performance.md +39 -0
- package/rules/runtime.md +9 -0
- package/rules/secrets.md +11 -0
- package/rules/stack.md +33 -0
- package/rules/ui.md +23 -0
- package/runtime/ai.test.ts +106 -0
- package/runtime/ai.ts +125 -0
- package/runtime/observability/allowlists.ts +42 -0
- package/runtime/observability/anonymize.test.ts +111 -0
- package/runtime/observability/anonymize.ts +249 -0
- package/runtime/observability/browser.test.ts +46 -0
- package/runtime/observability/browser.ts +126 -0
- package/runtime/observability/server.test.ts +84 -0
- package/runtime/observability/server.ts +152 -0
- package/runtime/observability/tunnel.test.ts +276 -0
- package/runtime/observability/tunnel.ts +360 -0
- package/runtime/observability/user-agent.ts +51 -0
- package/schema/rc.config.schema.json +333 -0
- package/template/.gitattributes +1 -0
- package/template/.github/workflows/ci.yml +64 -0
- package/template/CLAUDE.md +48 -0
- package/template/README.md +50 -0
- package/template/apps/admin/.dev.vars.example +5 -0
- package/template/apps/admin/components.json +24 -0
- package/template/apps/admin/package.json +48 -0
- package/template/apps/admin/public/favicon.svg +1 -0
- package/template/apps/admin/src/components/app-shell.tsx +41 -0
- package/template/apps/admin/src/components/dev-sign-in-links.tsx +57 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-context.ts +13 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-environment-panel.tsx +105 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-inbox-list.tsx +54 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-inbox-message.tsx +104 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-inbox-panel.tsx +130 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-launcher.tsx +45 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-panel.tsx +90 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-types.ts +11 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar.tsx +61 -0
- package/template/apps/admin/src/components/dev-toolbar/development-devtools.tsx +32 -0
- package/template/apps/admin/src/components/login-form.tsx +115 -0
- package/template/apps/admin/src/components/login-sent.tsx +23 -0
- package/template/apps/admin/src/components/message-list.tsx +44 -0
- package/template/apps/admin/src/components/turnstile-challenge.tsx +140 -0
- package/template/apps/admin/src/components/ui/button.tsx +87 -0
- package/template/apps/admin/src/components/ui/callout.tsx +84 -0
- package/template/apps/admin/src/components/ui/card.tsx +48 -0
- package/template/apps/admin/src/components/ui/eyebrow.tsx +33 -0
- package/template/apps/admin/src/components/ui/field-error.tsx +24 -0
- package/template/apps/admin/src/components/ui/field.tsx +100 -0
- package/template/apps/admin/src/components/ui/input.tsx +73 -0
- package/template/apps/admin/src/components/ui/label.tsx +39 -0
- package/template/apps/admin/src/components/ui/skeleton.tsx +225 -0
- package/template/apps/admin/src/components/ui/spinner.tsx +12 -0
- package/template/apps/admin/src/components/ui/toaster.tsx +33 -0
- package/template/apps/admin/src/components/ui/tooltip.tsx +51 -0
- package/template/apps/admin/src/hooks/use-dev-inbox.ts +25 -0
- package/template/apps/admin/src/hooks/use-dev-toolbar-state.ts +48 -0
- package/template/apps/admin/src/lib/api.ts +39 -0
- package/template/apps/admin/src/lib/auth-client.ts +7 -0
- package/template/apps/admin/src/lib/dev-inbox-links.ts +66 -0
- package/template/apps/admin/src/lib/dev-tools-client.ts +54 -0
- package/template/apps/admin/src/lib/dev-tools-contract.ts +52 -0
- package/template/apps/admin/src/lib/messages.ts +5 -0
- package/template/apps/admin/src/lib/query-keys.ts +3 -0
- package/template/apps/admin/src/lib/security-headers.ts +18 -0
- package/template/apps/admin/src/lib/session.ts +27 -0
- package/template/apps/admin/src/lib/site-url.ts +7 -0
- package/template/apps/admin/src/lib/turnstile.ts +70 -0
- package/template/apps/admin/src/lib/ui-labels.tsx +182 -0
- package/template/apps/admin/src/lib/utils.ts +6 -0
- package/template/apps/admin/src/routeTree.gen.ts +109 -0
- package/template/apps/admin/src/router.tsx +29 -0
- package/template/apps/admin/src/routes/__root.tsx +56 -0
- package/template/apps/admin/src/routes/_app/index.tsx +38 -0
- package/template/apps/admin/src/routes/_app.tsx +26 -0
- package/template/apps/admin/src/routes/login.tsx +48 -0
- package/template/apps/admin/src/styles/app.css +11 -0
- package/template/apps/admin/src/worker.ts +88 -0
- package/template/apps/admin/tsconfig.json +19 -0
- package/template/apps/admin/vite.config.ts +69 -0
- package/template/apps/admin/wrangler.jsonc +92 -0
- package/template/apps/web/.env.example +1 -0
- package/template/apps/web/astro.config.ts +46 -0
- package/template/apps/web/package.json +33 -0
- package/template/apps/web/public/favicon.svg +1 -0
- package/template/apps/web/src/components/ContactForm.astro +78 -0
- package/template/apps/web/src/env.d.ts +11 -0
- package/template/apps/web/src/layouts/BaseLayout.astro +32 -0
- package/template/apps/web/src/lib/api.ts +8 -0
- package/template/apps/web/src/pages/api/messages.ts +32 -0
- package/template/apps/web/src/pages/index.astro +26 -0
- package/template/apps/web/src/pages/media/[...key].ts +4 -0
- package/template/apps/web/src/scripts/contact-form.ts +105 -0
- package/template/apps/web/src/scripts/error-reporting.ts +4 -0
- package/template/apps/web/src/scripts/turnstile.ts +177 -0
- package/template/apps/web/src/styles/global.css +11 -0
- package/template/apps/web/src/worker.ts +34 -0
- package/template/apps/web/tsconfig.json +11 -0
- package/template/apps/web/wrangler.jsonc +45 -0
- package/template/bun.lock +1925 -0
- package/template/bunfig.toml +2 -0
- package/template/gitignore +23 -0
- package/template/package.json +74 -0
- package/template/packages/api/components.json +21 -0
- package/template/packages/api/package.json +30 -0
- package/template/packages/api/src/client.ts +13 -0
- package/template/packages/api/src/cloudflare-env.d.ts +26 -0
- package/template/packages/api/src/emails/escape-html.ts +13 -0
- package/template/packages/api/src/emails/layout.ts +22 -0
- package/template/packages/api/src/emails/magic-link.ts +32 -0
- package/template/packages/api/src/emails/new-message.ts +32 -0
- package/template/packages/api/src/emails/send.ts +14 -0
- package/template/packages/api/src/lib/auth-guard.ts +16 -0
- package/template/packages/api/src/lib/auth.ts +108 -0
- package/template/packages/api/src/lib/context.ts +7 -0
- package/template/packages/api/src/lib/dev-inbox/routes.ts +77 -0
- package/template/packages/api/src/lib/dev-inbox/send.ts +57 -0
- package/template/packages/api/src/lib/dev-inbox/store.ts +185 -0
- package/template/packages/api/src/lib/dev-inbox.ts +6 -0
- package/template/packages/api/src/lib/dev-tools-contract.ts +52 -0
- package/template/packages/api/src/lib/environment.ts +17 -0
- package/template/packages/api/src/lib/turnstile.ts +33 -0
- package/template/packages/api/src/media.ts +45 -0
- package/template/packages/api/src/routes/admin-messages.ts +21 -0
- package/template/packages/api/src/routes/dev.ts +31 -0
- package/template/packages/api/src/routes/health.ts +7 -0
- package/template/packages/api/src/routes/messages.ts +58 -0
- package/template/packages/api/src/schemas.ts +18 -0
- package/template/packages/api/src/server.ts +29 -0
- package/template/packages/api/tsconfig.json +10 -0
- package/template/packages/db/migrations/0001_init.sql +79 -0
- package/template/packages/db/package.json +34 -0
- package/template/packages/db/prisma/schema.prisma +95 -0
- package/template/packages/db/prisma.config.ts +9 -0
- package/template/packages/db/scripts/migrate.ts +15 -0
- package/template/packages/db/scripts/new-migration.ts +185 -0
- package/template/packages/db/scripts/reset.ts +54 -0
- package/template/packages/db/scripts/seed.ts +44 -0
- package/template/packages/db/scripts/wrangler.ts +35 -0
- package/template/packages/db/src/d1.ts +7 -0
- package/template/packages/db/src/migration-guard.test.ts +43 -0
- package/template/packages/db/src/migration-guard.ts +51 -0
- package/template/packages/db/src/new-migration.test.ts +16 -0
- package/template/packages/db/src/scope.ts +38 -0
- package/template/packages/db/src/seed.ts +30 -0
- package/template/packages/db/src/sql.ts +42 -0
- package/template/packages/db/tsconfig.json +8 -0
- package/template/packages/shared/components.json +21 -0
- package/template/packages/shared/package.json +33 -0
- package/template/packages/shared/src/edge/origins.ts +20 -0
- package/template/packages/shared/src/edge/turnstile.ts +11 -0
- package/template/packages/shared/src/locales.ts +13 -0
- package/template/packages/shared/src/message-rules.ts +16 -0
- package/template/packages/shared/src/messages.test.ts +26 -0
- package/template/packages/shared/src/messages.ts +30 -0
- package/template/packages/shared/src/observability/build-release.ts +9 -0
- package/template/packages/shared/src/observability/error-reporting.ts +31 -0
- package/template/packages/shared/src/observability/error-tunnel.ts +20 -0
- package/template/packages/shared/src/observability/sentry-browser.ts +1 -0
- package/template/packages/shared/src/observability/server-errors.ts +74 -0
- package/template/packages/shared/src/project.ts +1 -0
- package/template/packages/shared/src/styles/rc-theme.css +138 -0
- package/template/packages/shared/src/styles/theme.css +9 -0
- package/template/packages/shared/tsconfig.json +10 -0
- package/template/rc.config.json +25 -0
- package/template/scripts/bootstrap-local.ts +42 -0
- package/template/tsconfig.base.json +20 -0
- package/template/tsconfig.json +8 -0
- package/template/tsconfig.worker.json +7 -0
- package/template/turbo.json +40 -0
- package/template/vite.config.ts +8 -0
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
import { afterAll, describe, expect, test } from "bun:test"
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type AuditCheck,
|
|
5
|
+
auditFailed,
|
|
6
|
+
formatAuditMarkdown,
|
|
7
|
+
formatAuditText,
|
|
8
|
+
RULES_IMPORT,
|
|
9
|
+
runAudit,
|
|
10
|
+
} from "./audit"
|
|
11
|
+
import { cleanupTempDirs, tempDir, writeTree } from "./test-utils"
|
|
12
|
+
|
|
13
|
+
afterAll(cleanupTempDirs)
|
|
14
|
+
|
|
15
|
+
const RC = "0123456789abcdef0123456789abcdef"
|
|
16
|
+
|
|
17
|
+
const RC_CONFIG = {
|
|
18
|
+
project: "contoso-mode",
|
|
19
|
+
kit: ">=0.1.0",
|
|
20
|
+
prefix: "gfa",
|
|
21
|
+
account: "contoso",
|
|
22
|
+
apps: { admin: { path: "apps/admin" } },
|
|
23
|
+
infisical: { projectId: "11111111-1111-4111-8111-111111111111" },
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const ADMIN_WRANGLER = {
|
|
27
|
+
name: "gfa-admin-local",
|
|
28
|
+
account_id: RC,
|
|
29
|
+
d1_databases: [
|
|
30
|
+
{
|
|
31
|
+
binding: "DB",
|
|
32
|
+
database_name: "gfa-d1-local",
|
|
33
|
+
database_id: "gfa-d1-local",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
vars: { ENVIRONMENT: "local" },
|
|
37
|
+
env: {
|
|
38
|
+
production: {
|
|
39
|
+
name: "gfa-admin-prod",
|
|
40
|
+
d1_databases: [
|
|
41
|
+
{
|
|
42
|
+
binding: "DB",
|
|
43
|
+
database_name: "gfa-d1-prod",
|
|
44
|
+
database_id: "4f0c2a7e-1111-2222-3333-444455556666",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
vars: { ENVIRONMENT: "production" },
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function conformingProject(): string {
|
|
53
|
+
return writeTree(tempDir(), {
|
|
54
|
+
"rc.config.json": RC_CONFIG,
|
|
55
|
+
"CLAUDE.md": `${RULES_IMPORT}\n\n# Contoso Mode\n`,
|
|
56
|
+
".gitattributes": "* text=auto eol=lf\n",
|
|
57
|
+
".gitignore": "node_modules/\n.env*\n.infisical-token\n",
|
|
58
|
+
"package.json": {
|
|
59
|
+
name: "contoso-mode",
|
|
60
|
+
workspaces: {
|
|
61
|
+
packages: ["apps/*", "packages/*"],
|
|
62
|
+
catalog: { "vite-plus": "1.4.0" },
|
|
63
|
+
},
|
|
64
|
+
devDependencies: {
|
|
65
|
+
"@react-consulting/rc-kit": "^0.1.0",
|
|
66
|
+
"vite-plus": "catalog:",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
"vite.config.ts":
|
|
70
|
+
'import { rcFmt, rcLint } from "@react-consulting/rc-kit/vite-plus"\n',
|
|
71
|
+
"apps/admin/package.json": {
|
|
72
|
+
name: "@gfa/admin",
|
|
73
|
+
scripts: {
|
|
74
|
+
"build:cloudflare": "vp build",
|
|
75
|
+
"deploy:cloudflare": "wrangler deploy",
|
|
76
|
+
"upload:cloudflare": "wrangler versions upload",
|
|
77
|
+
},
|
|
78
|
+
dependencies: { "@base-ui/react": "^1.0.0" },
|
|
79
|
+
},
|
|
80
|
+
"apps/admin/src/components/ui/button.tsx": "export {}\n",
|
|
81
|
+
"apps/admin/components.json": {
|
|
82
|
+
registries: { "@rc": "https://rc.example/r/{name}.json" },
|
|
83
|
+
},
|
|
84
|
+
"apps/admin/wrangler.jsonc": ADMIN_WRANGLER,
|
|
85
|
+
"packages/db/package.json": {
|
|
86
|
+
name: "@gfa/db",
|
|
87
|
+
dependencies: { "@prisma/client": "^7.0.0" },
|
|
88
|
+
devDependencies: { prisma: "^7.0.0" },
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function byTitle(checks: AuditCheck[]): Record<string, AuditCheck> {
|
|
94
|
+
return Object.fromEntries(checks.map((entry) => [entry.title, entry]))
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
describe("runAudit", () => {
|
|
98
|
+
test("asks every app for the standard Workers Builds scripts", () => {
|
|
99
|
+
const root = conformingProject()
|
|
100
|
+
|
|
101
|
+
writeTree(root, {
|
|
102
|
+
"apps/admin/package.json": { name: "@gfa/admin", scripts: {} },
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const entry = runAudit({ root }).find((item) =>
|
|
106
|
+
item.title.startsWith("scripts Workers Builds")
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
expect(entry?.status).toBe("warn")
|
|
110
|
+
expect(entry?.details).toEqual([
|
|
111
|
+
"apps/admin/package.json : build:cloudflare, deploy:cloudflare, upload:cloudflare manquant(s)",
|
|
112
|
+
])
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
test("asks to ignore the Infisical token file", () => {
|
|
116
|
+
const root = conformingProject()
|
|
117
|
+
|
|
118
|
+
writeTree(root, { ".gitignore": "node_modules/\n" })
|
|
119
|
+
|
|
120
|
+
const entry = runAudit({ root }).find(
|
|
121
|
+
(item) => item.title === ".infisical-token ignoré par .gitignore"
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
expect(entry?.status).toBe("fail")
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
test("passes a project that follows every rule", () => {
|
|
128
|
+
const checks = runAudit({ root: conformingProject() })
|
|
129
|
+
|
|
130
|
+
expect(
|
|
131
|
+
checks.filter(
|
|
132
|
+
(entry) => entry.status === "fail" || entry.status === "warn"
|
|
133
|
+
)
|
|
134
|
+
).toEqual([])
|
|
135
|
+
expect(auditFailed(checks)).toBe(false)
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
test("accepts the rules import through AGENTS.md", () => {
|
|
139
|
+
const root = conformingProject()
|
|
140
|
+
|
|
141
|
+
writeTree(root, {
|
|
142
|
+
"CLAUDE.md": "@AGENTS.md\n",
|
|
143
|
+
"AGENTS.md": `${RULES_IMPORT}\n`,
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
expect(
|
|
147
|
+
byTitle(runAudit({ root }))["CLAUDE.md importe les règles communes"]
|
|
148
|
+
?.status
|
|
149
|
+
).toBe("pass")
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
test("flags every deviation with a fix hint", () => {
|
|
153
|
+
const root = writeTree(tempDir(), {
|
|
154
|
+
"CLAUDE.md": "# Legacy\n",
|
|
155
|
+
"biome.jsonc": "{}",
|
|
156
|
+
"package.json": {
|
|
157
|
+
name: "legacy",
|
|
158
|
+
workspaces: ["apps/*", "packages/*"],
|
|
159
|
+
devDependencies: { "@biomejs/biome": "^2.0.0", ultracite: "^7.0.0" },
|
|
160
|
+
},
|
|
161
|
+
"scripts/upload-sourcemaps.ts": "",
|
|
162
|
+
"scripts/deploy-admin.ts": "",
|
|
163
|
+
"scripts/check-deploy-config.ts": "",
|
|
164
|
+
"scripts/morocco-borders.ts": "",
|
|
165
|
+
"apps/admin/package.json": {
|
|
166
|
+
name: "@legacy/admin",
|
|
167
|
+
dependencies: {
|
|
168
|
+
"@radix-ui/react-dialog": "1",
|
|
169
|
+
"@floating-ui/react": "1",
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
"apps/admin/src/components/ui/button.tsx": "",
|
|
173
|
+
"packages/db/package.json": {
|
|
174
|
+
name: "@legacy/db",
|
|
175
|
+
dependencies: { "drizzle-orm": "1" },
|
|
176
|
+
devDependencies: { "drizzle-kit": "1" },
|
|
177
|
+
},
|
|
178
|
+
})
|
|
179
|
+
const checks = byTitle(runAudit({ root }))
|
|
180
|
+
const failed = Object.values(checks)
|
|
181
|
+
.filter((entry) => entry.status === "fail")
|
|
182
|
+
.map((entry) => entry.title)
|
|
183
|
+
|
|
184
|
+
expect(failed).toEqual([
|
|
185
|
+
"rc.config.json présent et valide",
|
|
186
|
+
"@react-consulting/rc-kit à la racine",
|
|
187
|
+
"CLAUDE.md importe les règles communes",
|
|
188
|
+
".gitattributes impose les fins de ligne LF",
|
|
189
|
+
"pas de Biome ni d'Ultracite",
|
|
190
|
+
"Vite+ avec le preset @react-consulting/rc-kit/vite-plus",
|
|
191
|
+
"pas de Drizzle",
|
|
192
|
+
"Prisma dans packages/db",
|
|
193
|
+
"@base-ui/react dans les workspaces avec components/ui",
|
|
194
|
+
"pas de Radix ni de Floating UI",
|
|
195
|
+
"components.json déclare le registre @rc",
|
|
196
|
+
".infisical-token ignoré par .gitignore",
|
|
197
|
+
"pas de script local qui doublonne rc",
|
|
198
|
+
])
|
|
199
|
+
expect(checks["pas de script local qui doublonne rc"]?.details).toEqual([
|
|
200
|
+
"scripts/check-deploy-config.ts → rc check:deploy-config",
|
|
201
|
+
"scripts/deploy-admin.ts → rc deploy <app|all> [env]",
|
|
202
|
+
"scripts/upload-sourcemaps.ts → rc sentry:sourcemaps --app <app> --directory <sortie>",
|
|
203
|
+
])
|
|
204
|
+
expect(checks["pas de Drizzle"]?.details).toEqual([
|
|
205
|
+
"packages/db/package.json : drizzle-kit, drizzle-orm",
|
|
206
|
+
])
|
|
207
|
+
expect(checks["nommage Cloudflare (rc check:naming)"]?.status).toBe("skip")
|
|
208
|
+
expect(
|
|
209
|
+
Object.values(checks).every(
|
|
210
|
+
(entry) => entry.status !== "fail" || Boolean(entry.fix)
|
|
211
|
+
)
|
|
212
|
+
).toBe(true)
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
test("skips the Infisical check while rc.config.json is invalid", () => {
|
|
216
|
+
const root = conformingProject()
|
|
217
|
+
|
|
218
|
+
writeTree(root, {
|
|
219
|
+
"rc.config.json": {
|
|
220
|
+
...RC_CONFIG,
|
|
221
|
+
infisical: { projectId: "00000000-0000-0000-0000-000000000000" },
|
|
222
|
+
vault: {},
|
|
223
|
+
},
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
const checks = byTitle(runAudit({ root }))
|
|
227
|
+
|
|
228
|
+
expect(checks["rc.config.json présent et valide"]?.details).toEqual(
|
|
229
|
+
expect.arrayContaining([
|
|
230
|
+
expect.stringContaining("/vault : propriété inconnue"),
|
|
231
|
+
])
|
|
232
|
+
)
|
|
233
|
+
expect(checks["infisical.projectId renseigné"]).toMatchObject({
|
|
234
|
+
status: "skip",
|
|
235
|
+
})
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
test("flags a placeholder Infisical project on a valid config", () => {
|
|
239
|
+
const root = conformingProject()
|
|
240
|
+
|
|
241
|
+
writeTree(root, {
|
|
242
|
+
"rc.config.json": {
|
|
243
|
+
...RC_CONFIG,
|
|
244
|
+
infisical: { projectId: "00000000-0000-0000-0000-000000000000" },
|
|
245
|
+
},
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
expect(
|
|
249
|
+
byTitle(runAudit({ root }))["infisical.projectId renseigné"]
|
|
250
|
+
).toMatchObject({
|
|
251
|
+
status: "fail",
|
|
252
|
+
details: [expect.stringContaining("identifiant factice")],
|
|
253
|
+
})
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
test("flags a legacy, local or outdated kit", () => {
|
|
257
|
+
const root = conformingProject()
|
|
258
|
+
|
|
259
|
+
writeTree(root, {
|
|
260
|
+
"CLAUDE.md": "@~/Projets/_rc-kit/rules/index.md\n",
|
|
261
|
+
"rc.config.json": { ...RC_CONFIG, kit: ">=99.0.0" },
|
|
262
|
+
"package.json": {
|
|
263
|
+
name: "contoso-mode",
|
|
264
|
+
workspaces: { catalog: { "vite-plus": "1.4.0" } },
|
|
265
|
+
devDependencies: {
|
|
266
|
+
"@rc/kit": "link:../_rc-kit",
|
|
267
|
+
"@react-consulting/rc-kit": "file:../kit",
|
|
268
|
+
"vite-plus": "catalog:",
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
const checks = byTitle(runAudit({ root }))
|
|
274
|
+
|
|
275
|
+
expect(checks["pas d'ancienne dépendance @rc/kit"]?.details).toEqual([
|
|
276
|
+
"package.json : @rc/kit",
|
|
277
|
+
])
|
|
278
|
+
expect(
|
|
279
|
+
checks["@react-consulting/rc-kit installé depuis le registre npm"]
|
|
280
|
+
?.details
|
|
281
|
+
).toEqual([
|
|
282
|
+
"package.json racine : @react-consulting/rc-kit vaut « file:../kit »",
|
|
283
|
+
])
|
|
284
|
+
expect(checks["version installée du kit suffisante"]?.status).toBe("fail")
|
|
285
|
+
expect(checks["import des règles par un chemin relatif"]?.details).toEqual([
|
|
286
|
+
"@~/Projets/_rc-kit/rules/index.md dépend du poste",
|
|
287
|
+
])
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
test("flags the leftovers of the sibling clone", () => {
|
|
291
|
+
const root = conformingProject()
|
|
292
|
+
|
|
293
|
+
writeTree(root, {
|
|
294
|
+
"scripts/ensure-rc-kit.ts": "",
|
|
295
|
+
".github/workflows/ci.yml": "run: bun install --cwd ../_rc-kit\n",
|
|
296
|
+
"package.json": {
|
|
297
|
+
name: "contoso-mode",
|
|
298
|
+
scripts: { preinstall: "bun scripts/ensure-rc-kit.ts" },
|
|
299
|
+
workspaces: { catalog: { "vite-plus": "1.4.0" } },
|
|
300
|
+
devDependencies: {
|
|
301
|
+
"@react-consulting/rc-kit": "^0.1.0",
|
|
302
|
+
"vite-plus": "catalog:",
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
expect(
|
|
308
|
+
byTitle(runAudit({ root }))["plus de clone du kit à côté du projet"]
|
|
309
|
+
?.details
|
|
310
|
+
).toEqual([
|
|
311
|
+
"scripts/ensure-rc-kit.ts existe encore",
|
|
312
|
+
"package.json : le script « preinstall » lance ensure-rc-kit",
|
|
313
|
+
".github/workflows/ci.yml clone encore le kit",
|
|
314
|
+
])
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
test("reports naming and deploy-config failures", () => {
|
|
318
|
+
const root = conformingProject()
|
|
319
|
+
const { production } = ADMIN_WRANGLER.env
|
|
320
|
+
|
|
321
|
+
writeTree(root, {
|
|
322
|
+
"apps/admin/wrangler.jsonc": {
|
|
323
|
+
...ADMIN_WRANGLER,
|
|
324
|
+
name: "contoso-mode-admin",
|
|
325
|
+
env: {
|
|
326
|
+
production: {
|
|
327
|
+
...production,
|
|
328
|
+
vars: {},
|
|
329
|
+
d1_databases: [
|
|
330
|
+
{
|
|
331
|
+
...production.d1_databases[0],
|
|
332
|
+
database_id: "00000000-0000-0000-0000-000000000000",
|
|
333
|
+
},
|
|
334
|
+
],
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
const checks = byTitle(runAudit({ root }))
|
|
341
|
+
|
|
342
|
+
expect(checks["nommage Cloudflare (rc check:naming)"]?.details).toEqual([
|
|
343
|
+
"apps/admin/wrangler.jsonc [niveau haut] Worker « contoso-mode-admin » : attendu gfa-admin-local (<pfx>-<rôle>-<env>) → gfa-admin-local",
|
|
344
|
+
])
|
|
345
|
+
expect(
|
|
346
|
+
checks["environnements Wrangler complets (rc check:deploy-config)"]
|
|
347
|
+
?.details
|
|
348
|
+
).toEqual([
|
|
349
|
+
"apps/admin/wrangler.jsonc [env.production] : ENVIRONMENT déclaré(s) au niveau local mais absent(s) des vars et de secrets.required (un environnement n'hérite pas des vars).",
|
|
350
|
+
])
|
|
351
|
+
expect(
|
|
352
|
+
checks["cohérence local / déploiements (avertissements)"]?.details?.[0]
|
|
353
|
+
).toContain("identifiants factices")
|
|
354
|
+
})
|
|
355
|
+
})
|
|
356
|
+
|
|
357
|
+
describe("audit formats", () => {
|
|
358
|
+
const checks: AuditCheck[] = [
|
|
359
|
+
{ theme: "Cloudflare", title: "nommage", status: "pass" },
|
|
360
|
+
{
|
|
361
|
+
theme: "Cloudflare",
|
|
362
|
+
title: "environnements",
|
|
363
|
+
status: "fail",
|
|
364
|
+
details: ["env.production : X absent"],
|
|
365
|
+
fix: "Déclare X.",
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
theme: "Stack",
|
|
369
|
+
title: "Prisma",
|
|
370
|
+
status: "skip",
|
|
371
|
+
details: ["pas de packages/db"],
|
|
372
|
+
},
|
|
373
|
+
]
|
|
374
|
+
|
|
375
|
+
test("renders a markdown checklist grouped by theme", () => {
|
|
376
|
+
expect(formatAuditMarkdown(checks, { project: "demo", root: "/p" })).toBe(
|
|
377
|
+
[
|
|
378
|
+
"# Audit de conformité @react-consulting/rc-kit : demo",
|
|
379
|
+
"",
|
|
380
|
+
"Projet : `/p`",
|
|
381
|
+
"",
|
|
382
|
+
"**Résultat : 1 en échec, 0 avertissement(s), 1 conforme(s), 1 sans objet.**",
|
|
383
|
+
"",
|
|
384
|
+
"## Cloudflare",
|
|
385
|
+
"",
|
|
386
|
+
"- [x] nommage",
|
|
387
|
+
"- [ ] environnements",
|
|
388
|
+
" - env.production : X absent",
|
|
389
|
+
" - **Correctif :** Déclare X.",
|
|
390
|
+
"",
|
|
391
|
+
"## Stack",
|
|
392
|
+
"",
|
|
393
|
+
"- [x] (sans objet) Prisma",
|
|
394
|
+
" - pas de packages/db",
|
|
395
|
+
"",
|
|
396
|
+
].join("\n")
|
|
397
|
+
)
|
|
398
|
+
})
|
|
399
|
+
|
|
400
|
+
test("renders plain text", () => {
|
|
401
|
+
expect(formatAuditText(checks, { project: "demo" })).toContain(
|
|
402
|
+
"FAIL environnements"
|
|
403
|
+
)
|
|
404
|
+
})
|
|
405
|
+
})
|