@react-consulting/rc-kit 0.0.0-stage → 0.13.1
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 +93 -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 +215 -0
- package/devkit/lib/kit-migrate.ts +624 -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,813 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs"
|
|
2
|
+
import { join } from "node:path"
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
ConfigError,
|
|
6
|
+
type LoadedConfig,
|
|
7
|
+
loadConfig,
|
|
8
|
+
PLACEHOLDER_PROJECT_ID,
|
|
9
|
+
} from "./config"
|
|
10
|
+
import { parseJsonc } from "./jsonc"
|
|
11
|
+
import {
|
|
12
|
+
GITATTRIBUTES,
|
|
13
|
+
hasLfAttributes,
|
|
14
|
+
isLocalSpec,
|
|
15
|
+
isPortableImport,
|
|
16
|
+
KIT_PACKAGE,
|
|
17
|
+
LEGACY_KIT_PACKAGE,
|
|
18
|
+
RULES_IMPORT,
|
|
19
|
+
rulesImportsOf,
|
|
20
|
+
} from "./kit-package"
|
|
21
|
+
import { KIT_VERSION, kitVersionError } from "./kit-version"
|
|
22
|
+
import { TOKEN_FILE, isTokenFileTracked } from "./infisical"
|
|
23
|
+
import { formatNamingViolation } from "./naming"
|
|
24
|
+
import { deployConfigForProject, namingForProject } from "./project-checks"
|
|
25
|
+
import {
|
|
26
|
+
catalogOf,
|
|
27
|
+
dependenciesOf,
|
|
28
|
+
listWorkspaces,
|
|
29
|
+
readPackageJson,
|
|
30
|
+
type Workspace,
|
|
31
|
+
} from "./workspace"
|
|
32
|
+
|
|
33
|
+
export type CheckStatus = "pass" | "fail" | "warn" | "skip"
|
|
34
|
+
|
|
35
|
+
export interface AuditCheck {
|
|
36
|
+
theme: string
|
|
37
|
+
title: string
|
|
38
|
+
status: CheckStatus
|
|
39
|
+
details?: string[]
|
|
40
|
+
fix?: string
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface AuditInput {
|
|
44
|
+
root: string
|
|
45
|
+
config?: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { RULES_IMPORT }
|
|
49
|
+
|
|
50
|
+
export const THEMES = {
|
|
51
|
+
config: "Configuration rc",
|
|
52
|
+
agents: "Instructions des agents",
|
|
53
|
+
tooling: "Outillage (lint, format, types)",
|
|
54
|
+
database: "Base de données",
|
|
55
|
+
ui: "Composants UI",
|
|
56
|
+
scripts: "Scripts et secrets",
|
|
57
|
+
cloudflare: "Cloudflare",
|
|
58
|
+
} as const
|
|
59
|
+
|
|
60
|
+
const DUPLICATE_SCRIPTS: { pattern: RegExp; command: string }[] = [
|
|
61
|
+
{ pattern: /^on-workers-ci\.ts$/, command: "rc ci:only <script>" },
|
|
62
|
+
{
|
|
63
|
+
pattern: /^upload-sourcemaps\.ts$/,
|
|
64
|
+
command: "rc sentry:sourcemaps --app <app> --directory <sortie>",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
pattern: /^(?:build-commit-sha|deployed-public-env)\.ts$/,
|
|
68
|
+
command: `${KIT_PACKAGE}/build`,
|
|
69
|
+
},
|
|
70
|
+
{ pattern: /^check-worker-secrets\.ts$/, command: "rc secrets:check [env]" },
|
|
71
|
+
{ pattern: /^deploy.*\.ts$/, command: "rc deploy <app|all> [env]" },
|
|
72
|
+
{ pattern: /^check-deploy-config\.ts$/, command: "rc check:deploy-config" },
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
interface Project {
|
|
76
|
+
root: string
|
|
77
|
+
workspaces: Workspace[]
|
|
78
|
+
loaded?: LoadedConfig
|
|
79
|
+
raw?: Record<string, unknown>
|
|
80
|
+
configError?: string[]
|
|
81
|
+
configPath: string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function check(
|
|
85
|
+
theme: string,
|
|
86
|
+
title: string,
|
|
87
|
+
failures: string[],
|
|
88
|
+
fix: string,
|
|
89
|
+
status: CheckStatus = "fail"
|
|
90
|
+
): AuditCheck {
|
|
91
|
+
return failures.length === 0
|
|
92
|
+
? { theme, title, status: "pass" }
|
|
93
|
+
: { theme, title, status, details: failures, fix }
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function skip(theme: string, title: string, reason: string): AuditCheck {
|
|
97
|
+
return { theme, title, status: "skip", details: [reason] }
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function depsMatching(
|
|
101
|
+
project: Project,
|
|
102
|
+
matches: (name: string) => boolean
|
|
103
|
+
): string[] {
|
|
104
|
+
const found: string[] = []
|
|
105
|
+
|
|
106
|
+
for (const workspace of project.workspaces) {
|
|
107
|
+
const names = Object.keys(dependenciesOf(workspace.pkg)).filter(matches)
|
|
108
|
+
|
|
109
|
+
if (names.length > 0) {
|
|
110
|
+
found.push(
|
|
111
|
+
`${workspace.rel === "." ? "" : `${workspace.rel}/`}package.json : ${names.join(", ")}`
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const rootPkg = project.workspaces[0]?.pkg
|
|
117
|
+
const catalog = rootPkg ? Object.keys(catalogOf(rootPkg)).filter(matches) : []
|
|
118
|
+
|
|
119
|
+
if (catalog.length > 0) {
|
|
120
|
+
found.push(`catalog racine : ${catalog.join(", ")}`)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return found
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function readText(path: string): string | null {
|
|
127
|
+
return existsSync(path) ? readFileSync(path, "utf8") : null
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function configChecks(project: Project): AuditCheck[] {
|
|
131
|
+
const theme = THEMES.config
|
|
132
|
+
const rootPkg = project.workspaces[0]?.pkg
|
|
133
|
+
const kit = rootPkg ? dependenciesOf(rootPkg)[KIT_PACKAGE] : undefined
|
|
134
|
+
const legacy = depsMatching(project, (name) => name === LEGACY_KIT_PACKAGE)
|
|
135
|
+
|
|
136
|
+
return [
|
|
137
|
+
check(
|
|
138
|
+
theme,
|
|
139
|
+
"rc.config.json présent et valide",
|
|
140
|
+
project.configError ?? [],
|
|
141
|
+
"Crée ou corrige rc.config.json à la racine selon docs/rc-config.md du kit (project, prefix, account, apps, infisical, devEnvFiles) ; les erreurs listées nomment la clé en cause."
|
|
142
|
+
),
|
|
143
|
+
check(
|
|
144
|
+
theme,
|
|
145
|
+
"rc.config.json à la racine du projet",
|
|
146
|
+
project.configPath === join(project.root, "rc.config.json") ||
|
|
147
|
+
project.configError
|
|
148
|
+
? []
|
|
149
|
+
: [
|
|
150
|
+
`lu depuis --config ${project.configPath}, absent de la racine du projet`,
|
|
151
|
+
],
|
|
152
|
+
"Place rc.config.json à la racine du projet pour que rc le lise sans --config.",
|
|
153
|
+
"warn"
|
|
154
|
+
),
|
|
155
|
+
infisicalProjectCheck(project),
|
|
156
|
+
check(
|
|
157
|
+
theme,
|
|
158
|
+
`pas d'ancienne dépendance ${LEGACY_KIT_PACKAGE}`,
|
|
159
|
+
legacy,
|
|
160
|
+
`Lance rc kit:migrate (bunx ${KIT_PACKAGE}@latest kit:migrate si rc n'est pas encore installé), puis bun install.`
|
|
161
|
+
),
|
|
162
|
+
check(
|
|
163
|
+
theme,
|
|
164
|
+
`${KIT_PACKAGE} à la racine`,
|
|
165
|
+
kit
|
|
166
|
+
? []
|
|
167
|
+
: [`package.json racine : ${KIT_PACKAGE} absent des dependencies`],
|
|
168
|
+
`Lance bun add -d ${KIT_PACKAGE}.`
|
|
169
|
+
),
|
|
170
|
+
check(
|
|
171
|
+
theme,
|
|
172
|
+
`${KIT_PACKAGE} installé depuis le registre npm`,
|
|
173
|
+
kit && isLocalSpec(kit)
|
|
174
|
+
? [`package.json racine : ${KIT_PACKAGE} vaut « ${kit} »`]
|
|
175
|
+
: [],
|
|
176
|
+
`Remplace la valeur par "^${KIT_VERSION}". Pour développer le kit, bun link dans le clone puis bun link ${KIT_PACKAGE} dans le projet, sans toucher au package.json.`
|
|
177
|
+
),
|
|
178
|
+
...kitVersionChecks(project),
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function infisicalProjectCheck(project: Project): AuditCheck {
|
|
183
|
+
const theme = THEMES.config
|
|
184
|
+
|
|
185
|
+
if (!project.loaded) {
|
|
186
|
+
return skip(
|
|
187
|
+
theme,
|
|
188
|
+
"infisical.projectId renseigné",
|
|
189
|
+
"nécessite un rc.config.json valide"
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return check(
|
|
194
|
+
theme,
|
|
195
|
+
"infisical.projectId renseigné",
|
|
196
|
+
project.loaded.config.infisical.projectId === PLACEHOLDER_PROJECT_ID
|
|
197
|
+
? [
|
|
198
|
+
"identifiant factice (zéros) : le projet Infisical n'est pas encore relié",
|
|
199
|
+
]
|
|
200
|
+
: [],
|
|
201
|
+
"Crée le projet Infisical du projet (environnements dev et prod) ou demande son identifiant à l'utilisateur, puis écris-le dans infisical.projectId de rc.config.json."
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function kitVersionChecks(project: Project): AuditCheck[] {
|
|
206
|
+
const theme = THEMES.config
|
|
207
|
+
|
|
208
|
+
if (!project.loaded) {
|
|
209
|
+
return []
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const range = project.loaded.config.kit
|
|
213
|
+
const error = kitVersionError(range)
|
|
214
|
+
|
|
215
|
+
return [
|
|
216
|
+
check(
|
|
217
|
+
theme,
|
|
218
|
+
"version du kit déclarée",
|
|
219
|
+
range ? [] : ["rc.config.json : clé kit absente"],
|
|
220
|
+
`Ajoute "kit": ">=${KIT_VERSION}" à rc.config.json : rc refusera une version installée plus ancienne.`,
|
|
221
|
+
"warn"
|
|
222
|
+
),
|
|
223
|
+
check(
|
|
224
|
+
theme,
|
|
225
|
+
"version installée du kit suffisante",
|
|
226
|
+
error ? [error] : [],
|
|
227
|
+
`Lance bun add -d ${KIT_PACKAGE}@latest.`
|
|
228
|
+
),
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function agentChecks(project: Project): AuditCheck[] {
|
|
233
|
+
const theme = THEMES.agents
|
|
234
|
+
const claude = readText(join(project.root, "CLAUDE.md"))
|
|
235
|
+
|
|
236
|
+
if (claude === null) {
|
|
237
|
+
return [
|
|
238
|
+
check(
|
|
239
|
+
theme,
|
|
240
|
+
"CLAUDE.md importe les règles communes",
|
|
241
|
+
["CLAUDE.md absent à la racine"],
|
|
242
|
+
`Crée CLAUDE.md avec la ligne \`${RULES_IMPORT}\` puis ce qui est propre au projet.`
|
|
243
|
+
),
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const agents = /@AGENTS\.md\b/.test(claude)
|
|
248
|
+
? readText(join(project.root, "AGENTS.md"))
|
|
249
|
+
: null
|
|
250
|
+
const imports =
|
|
251
|
+
claude.includes(RULES_IMPORT) || Boolean(agents?.includes(RULES_IMPORT))
|
|
252
|
+
const nonPortable = rulesImportsOf(`${claude}\n${agents ?? ""}`).filter(
|
|
253
|
+
(spec) => !isPortableImport(spec)
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
return [
|
|
257
|
+
check(
|
|
258
|
+
theme,
|
|
259
|
+
"CLAUDE.md importe les règles communes",
|
|
260
|
+
imports
|
|
261
|
+
? []
|
|
262
|
+
: [
|
|
263
|
+
agents === null
|
|
264
|
+
? `CLAUDE.md ne contient pas ${RULES_IMPORT}`
|
|
265
|
+
: `ni CLAUDE.md ni AGENTS.md ne contient ${RULES_IMPORT}`,
|
|
266
|
+
],
|
|
267
|
+
`Ajoute la ligne \`${RULES_IMPORT}\` en tête de CLAUDE.md et retire ce qui doublonne les règles communes.`
|
|
268
|
+
),
|
|
269
|
+
check(
|
|
270
|
+
theme,
|
|
271
|
+
"import des règles par un chemin relatif",
|
|
272
|
+
nonPortable.map((spec) => `@${spec} dépend du poste`),
|
|
273
|
+
`Remplace l'import par \`${RULES_IMPORT}\` : il marche sur macOS, Linux et Windows quel que soit le dossier parent.`
|
|
274
|
+
),
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function toolingChecks(project: Project): AuditCheck[] {
|
|
279
|
+
const theme = THEMES.tooling
|
|
280
|
+
const biomeFiles = project.workspaces.flatMap((workspace) =>
|
|
281
|
+
["biome.json", "biome.jsonc"]
|
|
282
|
+
.filter((file) => existsSync(join(workspace.dir, file)))
|
|
283
|
+
.map((file) =>
|
|
284
|
+
workspace.rel === "." ? file : `${workspace.rel}/${file}`
|
|
285
|
+
)
|
|
286
|
+
)
|
|
287
|
+
const biomeDeps = depsMatching(
|
|
288
|
+
project,
|
|
289
|
+
(name) => name === "@biomejs/biome" || name === "ultracite"
|
|
290
|
+
)
|
|
291
|
+
const rootPkg = project.workspaces[0]?.pkg
|
|
292
|
+
const vitePlus = rootPkg
|
|
293
|
+
? Boolean(
|
|
294
|
+
dependenciesOf(rootPkg)["vite-plus"] ?? catalogOf(rootPkg)["vite-plus"]
|
|
295
|
+
)
|
|
296
|
+
: false
|
|
297
|
+
const viteConfig = readText(join(project.root, "vite.config.ts"))
|
|
298
|
+
const vitePlusFailures = [
|
|
299
|
+
...(vitePlus ? [] : ["vite-plus absent des devDependencies racine"]),
|
|
300
|
+
...(viteConfig === null
|
|
301
|
+
? ["vite.config.ts absent à la racine"]
|
|
302
|
+
: viteConfig.includes(`${KIT_PACKAGE}/vite-plus`)
|
|
303
|
+
? []
|
|
304
|
+
: [`vite.config.ts n'utilise pas ${KIT_PACKAGE}/vite-plus`]),
|
|
305
|
+
]
|
|
306
|
+
|
|
307
|
+
return [
|
|
308
|
+
check(
|
|
309
|
+
theme,
|
|
310
|
+
".gitattributes impose les fins de ligne LF",
|
|
311
|
+
hasLfAttributes(readText(join(project.root, ".gitattributes")))
|
|
312
|
+
? []
|
|
313
|
+
: [".gitattributes absent ou sans eol=lf"],
|
|
314
|
+
`Ajoute la ligne \`${GITATTRIBUTES.trim()}\` à .gitattributes, puis git add --renormalize . : Git sous Windows extrait sinon en CRLF et vp fmt --check échoue.`
|
|
315
|
+
),
|
|
316
|
+
check(
|
|
317
|
+
theme,
|
|
318
|
+
"pas de Biome ni d'Ultracite",
|
|
319
|
+
[...biomeDeps, ...biomeFiles],
|
|
320
|
+
"Retire @biomejs/biome et ultracite des package.json, supprime biome.json(c), remplace les scripts lint/format par `vp lint && vp fmt --check` et `vp fmt`."
|
|
321
|
+
),
|
|
322
|
+
check(
|
|
323
|
+
theme,
|
|
324
|
+
`Vite+ avec le preset ${KIT_PACKAGE}/vite-plus`,
|
|
325
|
+
vitePlusFailures,
|
|
326
|
+
`Ajoute vite-plus (et "vite": "npm:@voidzero-dev/vite-plus-core@<même version>" en catalog + overrides) à la racine, puis un vite.config.ts : \`import { rcFmt, rcLint, staged } from "${KIT_PACKAGE}/vite-plus"\` et \`defineConfig({ staged, fmt: rcFmt(), lint: rcLint() })\`.`
|
|
327
|
+
),
|
|
328
|
+
]
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function databaseChecks(project: Project): AuditCheck[] {
|
|
332
|
+
const theme = THEMES.database
|
|
333
|
+
const drizzle = depsMatching(
|
|
334
|
+
project,
|
|
335
|
+
(name) => name === "drizzle-orm" || name === "drizzle-kit"
|
|
336
|
+
)
|
|
337
|
+
const db = project.workspaces.find(
|
|
338
|
+
(workspace) => workspace.rel === "packages/db"
|
|
339
|
+
)
|
|
340
|
+
const prisma = db
|
|
341
|
+
? check(
|
|
342
|
+
theme,
|
|
343
|
+
"Prisma dans packages/db",
|
|
344
|
+
["prisma", "@prisma/client"]
|
|
345
|
+
.filter((name) => !dependenciesOf(db.pkg)[name])
|
|
346
|
+
.map((name) => `packages/db/package.json : ${name} absent`),
|
|
347
|
+
"Ajoute prisma (devDependencies) et @prisma/client (+ @prisma/adapter-d1 pour D1) à packages/db, avec le schéma Prisma et les migrations SQL versionnées."
|
|
348
|
+
)
|
|
349
|
+
: skip(theme, "Prisma dans packages/db", "pas de workspace packages/db")
|
|
350
|
+
|
|
351
|
+
return [
|
|
352
|
+
check(
|
|
353
|
+
theme,
|
|
354
|
+
"pas de Drizzle",
|
|
355
|
+
drizzle,
|
|
356
|
+
"Migre le schéma vers Prisma (packages/db, @prisma/adapter-d1), garde les migrations SQL appliquées par Wrangler, puis retire drizzle-orm et drizzle-kit."
|
|
357
|
+
),
|
|
358
|
+
prisma,
|
|
359
|
+
]
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function uiWorkspaces(project: Project): Workspace[] {
|
|
363
|
+
return project.workspaces.filter((workspace) =>
|
|
364
|
+
existsSync(join(workspace.dir, "src", "components", "ui"))
|
|
365
|
+
)
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function hasRcRegistry(dir: string): boolean {
|
|
369
|
+
const raw = readText(join(dir, "components.json"))
|
|
370
|
+
|
|
371
|
+
if (raw === null) {
|
|
372
|
+
return false
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
try {
|
|
376
|
+
const parsed = JSON.parse(raw) as { registries?: Record<string, unknown> }
|
|
377
|
+
|
|
378
|
+
return Boolean(parsed.registries?.["@rc"])
|
|
379
|
+
} catch {
|
|
380
|
+
return false
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function uiChecks(project: Project): AuditCheck[] {
|
|
385
|
+
const theme = THEMES.ui
|
|
386
|
+
const workspaces = uiWorkspaces(project)
|
|
387
|
+
const forbidden = depsMatching(
|
|
388
|
+
project,
|
|
389
|
+
(name) =>
|
|
390
|
+
name.startsWith("@floating-ui/") ||
|
|
391
|
+
name.startsWith("@radix-ui/") ||
|
|
392
|
+
name === "radix-ui"
|
|
393
|
+
)
|
|
394
|
+
const forbiddenCheck = check(
|
|
395
|
+
theme,
|
|
396
|
+
"pas de Radix ni de Floating UI",
|
|
397
|
+
forbidden,
|
|
398
|
+
"Remplace les primitives Radix / Floating UI par leurs équivalents @base-ui/react (registre @rc), puis retire ces dépendances."
|
|
399
|
+
)
|
|
400
|
+
|
|
401
|
+
if (workspaces.length === 0) {
|
|
402
|
+
return [
|
|
403
|
+
skip(
|
|
404
|
+
theme,
|
|
405
|
+
"@base-ui/react dans les workspaces avec components/ui",
|
|
406
|
+
"aucun workspace n'a de src/components/ui"
|
|
407
|
+
),
|
|
408
|
+
forbiddenCheck,
|
|
409
|
+
skip(
|
|
410
|
+
theme,
|
|
411
|
+
"components.json déclare le registre @rc",
|
|
412
|
+
"aucun workspace n'a de src/components/ui"
|
|
413
|
+
),
|
|
414
|
+
]
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return [
|
|
418
|
+
check(
|
|
419
|
+
theme,
|
|
420
|
+
"@base-ui/react dans les workspaces avec components/ui",
|
|
421
|
+
workspaces
|
|
422
|
+
.filter((workspace) => !dependenciesOf(workspace.pkg)["@base-ui/react"])
|
|
423
|
+
.map(
|
|
424
|
+
(workspace) => `${workspace.rel}/package.json : @base-ui/react absent`
|
|
425
|
+
),
|
|
426
|
+
"Ajoute @base-ui/react aux dependencies du workspace et migre src/components/ui vers les composants du registre @rc."
|
|
427
|
+
),
|
|
428
|
+
forbiddenCheck,
|
|
429
|
+
check(
|
|
430
|
+
theme,
|
|
431
|
+
"components.json déclare le registre @rc",
|
|
432
|
+
workspaces
|
|
433
|
+
.filter((workspace) => !hasRcRegistry(workspace.dir))
|
|
434
|
+
.map((workspace) =>
|
|
435
|
+
existsSync(join(workspace.dir, "components.json"))
|
|
436
|
+
? `${workspace.rel}/components.json : pas de registre @rc`
|
|
437
|
+
: `${workspace.rel}/components.json absent`
|
|
438
|
+
),
|
|
439
|
+
'Ajoute à components.json : "registries": { "@rc": "http://localhost:4873/r/{name}.json" } (registre servi en local par bunx rc registry).'
|
|
440
|
+
),
|
|
441
|
+
]
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function scriptChecks(project: Project): AuditCheck[] {
|
|
445
|
+
const theme = THEMES.scripts
|
|
446
|
+
const scriptsDir = join(project.root, "scripts")
|
|
447
|
+
const files = existsSync(scriptsDir)
|
|
448
|
+
? [
|
|
449
|
+
...new Bun.Glob("*.ts").scanSync({ cwd: scriptsDir, onlyFiles: true }),
|
|
450
|
+
].toSorted()
|
|
451
|
+
: []
|
|
452
|
+
const duplicates = files.flatMap((file) => {
|
|
453
|
+
const match = DUPLICATE_SCRIPTS.find((entry) => entry.pattern.test(file))
|
|
454
|
+
|
|
455
|
+
return match && !file.endsWith(".test.ts")
|
|
456
|
+
? [`scripts/${file} → ${match.command}`]
|
|
457
|
+
: []
|
|
458
|
+
})
|
|
459
|
+
|
|
460
|
+
return [
|
|
461
|
+
...legacyKitChecks(project),
|
|
462
|
+
...tokenFileChecks(project),
|
|
463
|
+
check(
|
|
464
|
+
theme,
|
|
465
|
+
"pas de script local qui doublonne rc",
|
|
466
|
+
duplicates,
|
|
467
|
+
"Supprime ces scripts (et leurs lib/tests) et fais pointer les scripts du package.json vers la commande rc indiquée."
|
|
468
|
+
),
|
|
469
|
+
]
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function gitignoreEntries(root: string): string[] {
|
|
473
|
+
const file = join(root, ".gitignore")
|
|
474
|
+
|
|
475
|
+
return existsSync(file)
|
|
476
|
+
? readFileSync(file, "utf8")
|
|
477
|
+
.split("\n")
|
|
478
|
+
.map((line) => line.trim())
|
|
479
|
+
: []
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
function packageScripts(root: string): Record<string, string> {
|
|
483
|
+
try {
|
|
484
|
+
const manifest = JSON.parse(
|
|
485
|
+
readFileSync(join(root, "package.json"), "utf8")
|
|
486
|
+
) as { scripts?: Record<string, string> }
|
|
487
|
+
|
|
488
|
+
return manifest.scripts ?? {}
|
|
489
|
+
} catch {
|
|
490
|
+
return {}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const LEGACY_BOOTSTRAP = "scripts/ensure-rc-kit.ts"
|
|
495
|
+
const LEGACY_CLONE_RE = /_rc-kit|\.rc-kit|RC_KIT_TOKEN/
|
|
496
|
+
|
|
497
|
+
function workflowFiles(root: string): string[] {
|
|
498
|
+
const dir = join(root, ".github", "workflows")
|
|
499
|
+
|
|
500
|
+
return existsSync(dir)
|
|
501
|
+
? [
|
|
502
|
+
...new Bun.Glob("*.{yml,yaml}").scanSync({ cwd: dir, onlyFiles: true }),
|
|
503
|
+
].toSorted()
|
|
504
|
+
: []
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function legacyKitChecks(project: Project): AuditCheck[] {
|
|
508
|
+
const theme = THEMES.scripts
|
|
509
|
+
const scripts = packageScripts(project.root)
|
|
510
|
+
const failures = [
|
|
511
|
+
...(existsSync(join(project.root, LEGACY_BOOTSTRAP))
|
|
512
|
+
? [`${LEGACY_BOOTSTRAP} existe encore`]
|
|
513
|
+
: []),
|
|
514
|
+
...Object.entries(scripts)
|
|
515
|
+
.filter(([, command]) => command.includes("ensure-rc-kit"))
|
|
516
|
+
.map(
|
|
517
|
+
([name]) => `package.json : le script « ${name} » lance ensure-rc-kit`
|
|
518
|
+
),
|
|
519
|
+
...workflowFiles(project.root)
|
|
520
|
+
.filter((file) =>
|
|
521
|
+
LEGACY_CLONE_RE.test(
|
|
522
|
+
readFileSync(join(project.root, ".github", "workflows", file), "utf8")
|
|
523
|
+
)
|
|
524
|
+
)
|
|
525
|
+
.map((file) => `.github/workflows/${file} clone encore le kit`),
|
|
526
|
+
]
|
|
527
|
+
|
|
528
|
+
return [
|
|
529
|
+
check(
|
|
530
|
+
theme,
|
|
531
|
+
"plus de clone du kit à côté du projet",
|
|
532
|
+
failures,
|
|
533
|
+
`Lance rc kit:migrate : le kit s'installe depuis npm (${KIT_PACKAGE}), sans script d'amorçage ni checkout en CI.`
|
|
534
|
+
),
|
|
535
|
+
]
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
const CLOUDFLARE_SCRIPTS = [
|
|
539
|
+
"build:cloudflare",
|
|
540
|
+
"deploy:cloudflare",
|
|
541
|
+
"upload:cloudflare",
|
|
542
|
+
]
|
|
543
|
+
|
|
544
|
+
function workersBuildsChecks(project: Project): AuditCheck[] {
|
|
545
|
+
const theme = THEMES.cloudflare
|
|
546
|
+
const title =
|
|
547
|
+
"scripts Workers Builds de chaque app (build, deploy, upload:cloudflare)"
|
|
548
|
+
|
|
549
|
+
if (!project.loaded) {
|
|
550
|
+
return [skip(theme, title, "rc.config.json absent ou invalide")]
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
const failures: string[] = []
|
|
554
|
+
|
|
555
|
+
for (const app of Object.values(project.loaded.config.apps)) {
|
|
556
|
+
const scripts = packageScripts(join(project.root, app.path))
|
|
557
|
+
const missing = CLOUDFLARE_SCRIPTS.filter((name) => !scripts[name])
|
|
558
|
+
|
|
559
|
+
if (missing.length > 0) {
|
|
560
|
+
failures.push(
|
|
561
|
+
`${app.path}/package.json : ${missing.join(", ")} manquant(s)`
|
|
562
|
+
)
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
return [
|
|
567
|
+
check(
|
|
568
|
+
theme,
|
|
569
|
+
title,
|
|
570
|
+
failures,
|
|
571
|
+
"Donne à chaque app les scripts build:cloudflare, deploy:cloudflare et upload:cloudflare (modèle : template/apps/admin/package.json du kit) : les commandes Workers Builds sont les mêmes partout (rules/cloudflare.md).",
|
|
572
|
+
"warn"
|
|
573
|
+
),
|
|
574
|
+
]
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
function tokenFileChecks(project: Project): AuditCheck[] {
|
|
578
|
+
const theme = THEMES.scripts
|
|
579
|
+
const ignored = gitignoreEntries(project.root).includes(TOKEN_FILE)
|
|
580
|
+
const tracked = isTokenFileTracked(project.root)
|
|
581
|
+
|
|
582
|
+
return [
|
|
583
|
+
check(
|
|
584
|
+
theme,
|
|
585
|
+
`${TOKEN_FILE} ignoré par .gitignore`,
|
|
586
|
+
ignored ? [] : [`ajoute la ligne ${TOKEN_FILE} à .gitignore`],
|
|
587
|
+
"Le jeton Infisical ne doit jamais être commité : ajoute la ligne à .gitignore."
|
|
588
|
+
),
|
|
589
|
+
check(
|
|
590
|
+
theme,
|
|
591
|
+
`${TOKEN_FILE} non suivi par git`,
|
|
592
|
+
tracked ? [`${TOKEN_FILE} est suivi par git`] : [],
|
|
593
|
+
`Retire-le de l'index (\`git rm --cached ${TOKEN_FILE}\`), puis ajoute-le à .gitignore.`
|
|
594
|
+
),
|
|
595
|
+
]
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function cloudflareChecks(project: Project): AuditCheck[] {
|
|
599
|
+
const theme = THEMES.cloudflare
|
|
600
|
+
|
|
601
|
+
if (!project.loaded) {
|
|
602
|
+
return [
|
|
603
|
+
skip(
|
|
604
|
+
theme,
|
|
605
|
+
"nommage Cloudflare (rc check:naming)",
|
|
606
|
+
"nécessite un rc.config.json valide"
|
|
607
|
+
),
|
|
608
|
+
skip(
|
|
609
|
+
theme,
|
|
610
|
+
"environnements Wrangler complets (rc check:deploy-config)",
|
|
611
|
+
"nécessite un rc.config.json valide"
|
|
612
|
+
),
|
|
613
|
+
]
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
const naming = namingForProject(project.loaded)
|
|
617
|
+
const namingFailures = naming.flatMap((entry) =>
|
|
618
|
+
entry.error
|
|
619
|
+
? [`${entry.file} : ${entry.error}`]
|
|
620
|
+
: (entry.result?.violations ?? []).map(formatNamingViolation)
|
|
621
|
+
)
|
|
622
|
+
const deploy = deployConfigForProject(project.loaded, false)
|
|
623
|
+
const deployFailures = deploy.flatMap((entry) =>
|
|
624
|
+
entry.error
|
|
625
|
+
? [`${entry.file} : ${entry.error}`]
|
|
626
|
+
: (entry.result?.errors ?? [])
|
|
627
|
+
)
|
|
628
|
+
const deployWarnings = deploy.flatMap((entry) => entry.result?.warnings ?? [])
|
|
629
|
+
|
|
630
|
+
return [
|
|
631
|
+
check(
|
|
632
|
+
theme,
|
|
633
|
+
"nommage Cloudflare (rc check:naming)",
|
|
634
|
+
namingFailures,
|
|
635
|
+
"Renomme ce qui peut l'être sans risque (ressources locales, Workers sans état) selon la suggestion ; déclare le reste dans naming.legacy de rc.config.json (skill cloudflare-naming)."
|
|
636
|
+
),
|
|
637
|
+
check(
|
|
638
|
+
theme,
|
|
639
|
+
"environnements Wrangler complets (rc check:deploy-config)",
|
|
640
|
+
deployFailures,
|
|
641
|
+
"Déclare dans chaque env.<nom> les vars et bindings du niveau local (un environnement n'hérite de rien) et remplace les ids factices par ceux des ressources créées."
|
|
642
|
+
),
|
|
643
|
+
check(
|
|
644
|
+
theme,
|
|
645
|
+
"cohérence local / déploiements (avertissements)",
|
|
646
|
+
deployWarnings,
|
|
647
|
+
"Déclare au niveau local (vide si optionnel) ce que les déploiements utilisent, et liste les secrets optionnels dans apps.<app>.optionalSecrets de rc.config.json.",
|
|
648
|
+
"warn"
|
|
649
|
+
),
|
|
650
|
+
]
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
export function loadProject(input: AuditInput): Project {
|
|
654
|
+
const workspaces = listWorkspaces(input.root)
|
|
655
|
+
const fallback: Workspace[] =
|
|
656
|
+
workspaces.length > 0
|
|
657
|
+
? workspaces
|
|
658
|
+
: [{ dir: input.root, rel: ".", pkg: readPackageJson(input.root) ?? {} }]
|
|
659
|
+
|
|
660
|
+
try {
|
|
661
|
+
const loaded = loadConfig(input)
|
|
662
|
+
|
|
663
|
+
return {
|
|
664
|
+
root: input.root,
|
|
665
|
+
workspaces: fallback,
|
|
666
|
+
loaded,
|
|
667
|
+
configPath: loaded.configPath,
|
|
668
|
+
raw: rawConfigOf(loaded.configPath),
|
|
669
|
+
}
|
|
670
|
+
} catch (error) {
|
|
671
|
+
const configError =
|
|
672
|
+
error instanceof ConfigError
|
|
673
|
+
? [error.message, ...error.details]
|
|
674
|
+
: [error instanceof Error ? error.message : String(error)]
|
|
675
|
+
const configPath = input.config ?? join(input.root, "rc.config.json")
|
|
676
|
+
|
|
677
|
+
return {
|
|
678
|
+
root: input.root,
|
|
679
|
+
workspaces: fallback,
|
|
680
|
+
configError,
|
|
681
|
+
configPath,
|
|
682
|
+
raw: rawConfigOf(configPath),
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
function rawConfigOf(path: string): Record<string, unknown> | undefined {
|
|
688
|
+
const text = readText(path)
|
|
689
|
+
|
|
690
|
+
if (text === null) {
|
|
691
|
+
return undefined
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
try {
|
|
695
|
+
return parseJsonc<Record<string, unknown>>(text)
|
|
696
|
+
} catch {
|
|
697
|
+
return undefined
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
export function runAudit(input: AuditInput): AuditCheck[] {
|
|
702
|
+
const project = loadProject(input)
|
|
703
|
+
|
|
704
|
+
return [
|
|
705
|
+
...configChecks(project),
|
|
706
|
+
...agentChecks(project),
|
|
707
|
+
...toolingChecks(project),
|
|
708
|
+
...databaseChecks(project),
|
|
709
|
+
...uiChecks(project),
|
|
710
|
+
...scriptChecks(project),
|
|
711
|
+
...cloudflareChecks(project),
|
|
712
|
+
...workersBuildsChecks(project),
|
|
713
|
+
]
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
export function auditFailed(checks: AuditCheck[]): boolean {
|
|
717
|
+
return checks.some((entry) => entry.status === "fail")
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
function summary(checks: AuditCheck[]): string {
|
|
721
|
+
const count = (status: CheckStatus) =>
|
|
722
|
+
checks.filter((entry) => entry.status === status).length
|
|
723
|
+
|
|
724
|
+
return `${count("fail")} en échec, ${count("warn")} avertissement(s), ${count("pass")} conforme(s), ${count("skip")} sans objet`
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
const MARKS: Record<CheckStatus, string> = {
|
|
728
|
+
pass: "- [x]",
|
|
729
|
+
fail: "- [ ]",
|
|
730
|
+
warn: "- [ ] (avertissement)",
|
|
731
|
+
skip: "- [x] (sans objet)",
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
function grouped(checks: AuditCheck[]): [string, AuditCheck[]][] {
|
|
735
|
+
const groups = new Map<string, AuditCheck[]>()
|
|
736
|
+
|
|
737
|
+
for (const entry of checks) {
|
|
738
|
+
groups.set(entry.theme, [...(groups.get(entry.theme) ?? []), entry])
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
return [...groups]
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
export function formatAuditMarkdown(
|
|
745
|
+
checks: AuditCheck[],
|
|
746
|
+
meta: { project: string; root: string; date?: string }
|
|
747
|
+
): string {
|
|
748
|
+
const lines = [
|
|
749
|
+
`# Audit de conformité ${KIT_PACKAGE} : ${meta.project}`,
|
|
750
|
+
"",
|
|
751
|
+
`Projet : \`${meta.root}\`${meta.date ? ` · ${meta.date}` : ""}`,
|
|
752
|
+
"",
|
|
753
|
+
`**Résultat : ${summary(checks)}.**`,
|
|
754
|
+
]
|
|
755
|
+
|
|
756
|
+
for (const [theme, entries] of grouped(checks)) {
|
|
757
|
+
lines.push("", `## ${theme}`, "")
|
|
758
|
+
|
|
759
|
+
for (const entry of entries) {
|
|
760
|
+
lines.push(`${MARKS[entry.status]} ${entry.title}`)
|
|
761
|
+
|
|
762
|
+
if (entry.status === "pass") {
|
|
763
|
+
continue
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
for (const detail of entry.details ?? []) {
|
|
767
|
+
lines.push(` - ${detail}`)
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
if (entry.fix) {
|
|
771
|
+
lines.push(` - **Correctif :** ${entry.fix}`)
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
return `${lines.join("\n")}\n`
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
const TEXT_MARKS: Record<CheckStatus, string> = {
|
|
780
|
+
pass: "OK ",
|
|
781
|
+
fail: "FAIL",
|
|
782
|
+
warn: "WARN",
|
|
783
|
+
skip: "-- ",
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
export function formatAuditText(
|
|
787
|
+
checks: AuditCheck[],
|
|
788
|
+
meta: { project: string }
|
|
789
|
+
): string {
|
|
790
|
+
const lines = [`Audit ${KIT_PACKAGE} : ${meta.project} (${summary(checks)})`]
|
|
791
|
+
|
|
792
|
+
for (const [theme, entries] of grouped(checks)) {
|
|
793
|
+
lines.push("", theme)
|
|
794
|
+
|
|
795
|
+
for (const entry of entries) {
|
|
796
|
+
lines.push(` ${TEXT_MARKS[entry.status]} ${entry.title}`)
|
|
797
|
+
|
|
798
|
+
if (entry.status === "pass") {
|
|
799
|
+
continue
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
for (const detail of entry.details ?? []) {
|
|
803
|
+
lines.push(` ${detail}`)
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
if (entry.fix) {
|
|
807
|
+
lines.push(` correctif : ${entry.fix}`)
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
return `${lines.join("\n")}\n`
|
|
813
|
+
}
|