@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
package/devkit/cli.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { resolve } from "node:path"
|
|
3
|
+
|
|
4
|
+
import { ciOnly, sentrySourcemaps } from "./commands/build"
|
|
5
|
+
import { audit, checkDeployConfig, checkNaming } from "./commands/checks"
|
|
6
|
+
import type { Command } from "./commands/context"
|
|
7
|
+
import { dbBranch, dbEnv, dbGuard, dbMigrate, dbSeed } from "./commands/db"
|
|
8
|
+
import { deploy } from "./commands/deploy"
|
|
9
|
+
import { dev } from "./commands/dev"
|
|
10
|
+
import { doctor } from "./commands/doctor"
|
|
11
|
+
import { kitMigrate } from "./commands/kit"
|
|
12
|
+
import { newProject } from "./commands/new"
|
|
13
|
+
import { registry } from "./commands/registry"
|
|
14
|
+
import { secretsCheck, secretsPull, secretsPush } from "./commands/secrets"
|
|
15
|
+
import { booleanFlag, parseArgs, stringFlag } from "./lib/args"
|
|
16
|
+
import { ConfigError, findProjectRoot } from "./lib/config"
|
|
17
|
+
|
|
18
|
+
const COMMANDS: Record<string, Command> = {
|
|
19
|
+
"secrets:pull": secretsPull,
|
|
20
|
+
"secrets:push": secretsPush,
|
|
21
|
+
"secrets:check": secretsCheck,
|
|
22
|
+
"db:env": dbEnv,
|
|
23
|
+
"db:migrate": dbMigrate,
|
|
24
|
+
"db:seed": dbSeed,
|
|
25
|
+
"db:guard": dbGuard,
|
|
26
|
+
"db:branch": dbBranch,
|
|
27
|
+
deploy,
|
|
28
|
+
"ci:only": ciOnly,
|
|
29
|
+
"sentry:sourcemaps": sentrySourcemaps,
|
|
30
|
+
dev,
|
|
31
|
+
"check:naming": checkNaming,
|
|
32
|
+
"check:deploy-config": checkDeployConfig,
|
|
33
|
+
audit,
|
|
34
|
+
doctor,
|
|
35
|
+
"kit:migrate": kitMigrate,
|
|
36
|
+
registry,
|
|
37
|
+
new: newProject,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const GLOBAL_VALUE_FLAGS = ["config", "root"]
|
|
41
|
+
|
|
42
|
+
function help(): string {
|
|
43
|
+
const width = Math.max(...Object.keys(COMMANDS).map((name) => name.length))
|
|
44
|
+
|
|
45
|
+
return [
|
|
46
|
+
"rc : outillage commun des projets Cloudflare Workers (@react-consulting/rc-kit)",
|
|
47
|
+
"",
|
|
48
|
+
"Usage : rc <commande> [arguments] [--config <rc.config.json>] [--root <dossier>]",
|
|
49
|
+
"",
|
|
50
|
+
"Commandes :",
|
|
51
|
+
...Object.entries(COMMANDS).map(
|
|
52
|
+
([name, command]) => ` ${name.padEnd(width)} ${command.summary}`
|
|
53
|
+
),
|
|
54
|
+
"",
|
|
55
|
+
"Options globales :",
|
|
56
|
+
" --config <chemin> rc.config.json à lire (défaut : <root>/rc.config.json)",
|
|
57
|
+
" --root <dossier> racine du projet (défaut : dossier courant)",
|
|
58
|
+
" -h, --help aide générale, ou d'une commande : rc <commande> --help",
|
|
59
|
+
].join("\n")
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function commandHelp(command: Command): string {
|
|
63
|
+
return [
|
|
64
|
+
`Usage : ${command.usage}`,
|
|
65
|
+
"",
|
|
66
|
+
command.summary,
|
|
67
|
+
...(command.details ? ["", command.details] : []),
|
|
68
|
+
].join("\n")
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export async function main(argv: string[]): Promise<number> {
|
|
72
|
+
const [name, ...rest] = argv
|
|
73
|
+
|
|
74
|
+
if (!name || name === "--help" || name === "-h" || name === "help") {
|
|
75
|
+
console.log(help())
|
|
76
|
+
return 0
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const command = COMMANDS[name]
|
|
80
|
+
|
|
81
|
+
if (!command) {
|
|
82
|
+
console.error(`Commande inconnue « ${name} ».\n\n${help()}`)
|
|
83
|
+
return 1
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
const args = parseArgs(rest, [
|
|
88
|
+
...GLOBAL_VALUE_FLAGS,
|
|
89
|
+
...(command.valueFlags ?? []),
|
|
90
|
+
])
|
|
91
|
+
|
|
92
|
+
if (booleanFlag(args, "help")) {
|
|
93
|
+
console.log(commandHelp(command))
|
|
94
|
+
return 0
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return await command.run({
|
|
98
|
+
args,
|
|
99
|
+
root: command.cwdRoot
|
|
100
|
+
? resolve(stringFlag(args, "root") ?? process.cwd())
|
|
101
|
+
: findProjectRoot(stringFlag(args, "root") ?? process.cwd()),
|
|
102
|
+
})
|
|
103
|
+
} catch (error) {
|
|
104
|
+
if (error instanceof ConfigError) {
|
|
105
|
+
console.error(
|
|
106
|
+
[error.message, ...error.details.map((detail) => ` ${detail}`)].join(
|
|
107
|
+
"\n"
|
|
108
|
+
)
|
|
109
|
+
)
|
|
110
|
+
} else {
|
|
111
|
+
console.error(error instanceof Error ? error.message : String(error))
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return 1
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (import.meta.main) {
|
|
119
|
+
process.exit(await main(process.argv.slice(2)))
|
|
120
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { existsSync } from "node:fs"
|
|
2
|
+
import { delimiter, join, resolve } from "node:path"
|
|
3
|
+
|
|
4
|
+
import { resolveBuildCommitSha } from "../../presets/build.js"
|
|
5
|
+
import { booleanFlag, listFlag, stringFlag } from "../lib/args"
|
|
6
|
+
import { runCommand } from "../lib/process"
|
|
7
|
+
import {
|
|
8
|
+
isWorkersBuild,
|
|
9
|
+
planSourcemaps,
|
|
10
|
+
removeSourceMaps,
|
|
11
|
+
sentryCliCommands,
|
|
12
|
+
} from "../lib/sourcemaps"
|
|
13
|
+
import { type Command, loadProjectConfig } from "./context"
|
|
14
|
+
|
|
15
|
+
function sentryCli(root: string): string | null {
|
|
16
|
+
const bins = [process.cwd(), root].map((dir) =>
|
|
17
|
+
join(dir, "node_modules", ".bin")
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
return Bun.which("sentry-cli", { PATH: bins.join(delimiter) })
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const ciOnly: Command = {
|
|
24
|
+
usage: "rc ci:only <script> [arguments…]",
|
|
25
|
+
summary: "lance un script du package.json seulement dans Workers Builds",
|
|
26
|
+
details:
|
|
27
|
+
"Lance `bun run <script>` dans le dossier courant quand WORKERS_CI=1 (Workers Builds), sinon affiche qu'il est sauté et sort en 0. Sert aux migrations D1 appelées par build:cloudflare : un build local ne migre jamais.",
|
|
28
|
+
cwdRoot: true,
|
|
29
|
+
run(context) {
|
|
30
|
+
const [script, ...rest] = context.args.positionals
|
|
31
|
+
|
|
32
|
+
if (!script) {
|
|
33
|
+
throw new Error("Usage : rc ci:only <script du package.json>")
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!isWorkersBuild(process.env)) {
|
|
37
|
+
console.log(`Hors Workers Builds : « ${script} » n'est pas lancé.`)
|
|
38
|
+
return 0
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return runCommand(["bun", "run", script, ...rest], { inherit: true })
|
|
42
|
+
.exitCode
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const sentrySourcemaps: Command = {
|
|
47
|
+
usage:
|
|
48
|
+
"rc sentry:sourcemaps --app <app> --directory <sortie> [--directory <sortie>] [--delete-maps]",
|
|
49
|
+
summary: "envoie les source maps d'un build à Sentry (release = commit)",
|
|
50
|
+
details:
|
|
51
|
+
"À la fin de build:cloudflare, depuis le dossier de l'app. Lit sentry.org, sentry.url et sentry.projects.<app> de rc.config.json, injecte les identifiants de débogage puis envoie les maps sous la release du commit (WORKERS_CI_COMMIT_SHA, sinon git). Sans SENTRY_AUTH_TOKEN : saute l'envoi en local, échoue dans Workers Builds. --delete-maps supprime ensuite les .map, envoyées ou non (à mettre sur les assets publics). Demande @sentry/cli dans l'app.",
|
|
52
|
+
valueFlags: ["app", "directory"],
|
|
53
|
+
run(context) {
|
|
54
|
+
const loaded = loadProjectConfig(context)
|
|
55
|
+
const app = stringFlag(context.args, "app")
|
|
56
|
+
const directories = listFlag(context.args, "directory").map((dir) =>
|
|
57
|
+
resolve(dir)
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
if (!app || directories.length === 0) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
`Usage : rc sentry:sourcemaps --app <${Object.keys(loaded.config.apps).join("|")}> --directory <sortie>`
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const missing = directories.filter((dir) => !existsSync(dir))
|
|
67
|
+
|
|
68
|
+
if (missing.length > 0) {
|
|
69
|
+
throw new Error(`Sortie de build absente : ${missing.join(", ")}`)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const plan = planSourcemaps({
|
|
73
|
+
sentry: loaded.config.sentry,
|
|
74
|
+
app,
|
|
75
|
+
release: resolveBuildCommitSha(context.root),
|
|
76
|
+
env: process.env,
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
if (plan.action === "fail") {
|
|
80
|
+
throw new Error(`[sourcemaps] ${plan.reason}`)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (plan.action === "skip") {
|
|
84
|
+
console.log(`[sourcemaps] ${plan.reason}`)
|
|
85
|
+
} else {
|
|
86
|
+
const binary = sentryCli(context.root)
|
|
87
|
+
|
|
88
|
+
if (!binary) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
"[sourcemaps] sentry-cli introuvable : déclare @sentry/cli dans l'app construite."
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
for (const args of sentryCliCommands(
|
|
95
|
+
plan,
|
|
96
|
+
loaded.config.sentry?.org ?? "",
|
|
97
|
+
directories
|
|
98
|
+
)) {
|
|
99
|
+
const result = runCommand([binary, ...args], {
|
|
100
|
+
env: { SENTRY_URL: plan.url },
|
|
101
|
+
inherit: true,
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
if (result.exitCode !== 0) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
`[sourcemaps] sentry-cli ${args[0]} ${args[1]} a échoué.`
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
console.log(
|
|
112
|
+
`[sourcemaps] ${plan.project}@${plan.release} envoyé à Sentry.`
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (booleanFlag(context.args, "delete-maps")) {
|
|
117
|
+
const removed = directories.reduce(
|
|
118
|
+
(count, dir) => count + removeSourceMaps(dir),
|
|
119
|
+
0
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
console.log(`[sourcemaps] ${removed} fichier(s) .map supprimé(s).`)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return 0
|
|
126
|
+
},
|
|
127
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { writeFileSync } from "node:fs"
|
|
2
|
+
import { basename, resolve } from "node:path"
|
|
3
|
+
|
|
4
|
+
import { booleanFlag, stringFlag } from "../lib/args"
|
|
5
|
+
import {
|
|
6
|
+
auditFailed,
|
|
7
|
+
formatAuditMarkdown,
|
|
8
|
+
formatAuditText,
|
|
9
|
+
loadProject,
|
|
10
|
+
runAudit,
|
|
11
|
+
} from "../lib/audit"
|
|
12
|
+
import { formatNamingReport } from "../lib/naming"
|
|
13
|
+
import { deployConfigForProject, namingForProject } from "../lib/project-checks"
|
|
14
|
+
import { type Command, loadProjectConfig } from "./context"
|
|
15
|
+
|
|
16
|
+
export const checkNaming: Command = {
|
|
17
|
+
usage: "rc check:naming",
|
|
18
|
+
summary:
|
|
19
|
+
"vérifie le nommage Cloudflare de chaque wrangler.jsonc (rules/cloudflare.md)",
|
|
20
|
+
details:
|
|
21
|
+
"Workers, D1, R2, KV locaux, queues, workflows, Vectorize, AI Gateway et buckets cités dans les vars, cibles des bindings de service, casse des bindings, suffixes _RATE_LIMITER / _WORKFLOW / _QUEUE, account_id. Les noms de naming.legacy sont tolérés.",
|
|
22
|
+
run(context) {
|
|
23
|
+
const loaded = loadProjectConfig(context)
|
|
24
|
+
let failed = false
|
|
25
|
+
|
|
26
|
+
for (const entry of namingForProject(loaded)) {
|
|
27
|
+
if (entry.error) {
|
|
28
|
+
console.error(`${entry.app} : ${entry.error}`)
|
|
29
|
+
failed = true
|
|
30
|
+
continue
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (entry.result) {
|
|
34
|
+
console.log(
|
|
35
|
+
`${entry.file}\n${formatNamingReport(entry.result).replace(/^/gm, " ")}`
|
|
36
|
+
)
|
|
37
|
+
failed ||= entry.result.violations.length > 0
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return failed ? 1 : 0
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const checkDeployConfig: Command = {
|
|
46
|
+
usage: "rc check:deploy-config [--strict]",
|
|
47
|
+
summary:
|
|
48
|
+
"vérifie que chaque env Wrangler redéclare les vars et bindings du local",
|
|
49
|
+
details:
|
|
50
|
+
"Un environnement n'hérite ni des vars ni des bindings. --strict refuse les ids factices (zéros) des déploiements.",
|
|
51
|
+
run(context) {
|
|
52
|
+
const loaded = loadProjectConfig(context)
|
|
53
|
+
const strict = booleanFlag(context.args, "strict")
|
|
54
|
+
let failed = false
|
|
55
|
+
|
|
56
|
+
for (const entry of deployConfigForProject(loaded, strict)) {
|
|
57
|
+
if (entry.error) {
|
|
58
|
+
console.error(`${entry.app} : ${entry.error}`)
|
|
59
|
+
failed = true
|
|
60
|
+
continue
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const { errors = [], warnings = [] } = entry.result ?? {}
|
|
64
|
+
|
|
65
|
+
for (const warning of warnings) {
|
|
66
|
+
console.warn(`avertissement : ${warning}`)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
for (const error of errors) {
|
|
70
|
+
console.error(`erreur : ${error}`)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (errors.length === 0) {
|
|
74
|
+
console.log(
|
|
75
|
+
`${entry.file} : chaque déploiement redéclare ses vars et bindings.`
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
failed ||= errors.length > 0
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return failed ? 1 : 0
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const audit: Command = {
|
|
87
|
+
usage: "rc audit [--format md|text] [--output <fichier>]",
|
|
88
|
+
summary: "rapport de conformité du projet aux règles du kit",
|
|
89
|
+
valueFlags: ["format", "output"],
|
|
90
|
+
run(context) {
|
|
91
|
+
const format = stringFlag(context.args, "format") ?? "md"
|
|
92
|
+
|
|
93
|
+
if (format !== "md" && format !== "text") {
|
|
94
|
+
throw new Error("--format attend md ou text.")
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const input = {
|
|
98
|
+
root: context.root,
|
|
99
|
+
config: stringFlag(context.args, "config"),
|
|
100
|
+
}
|
|
101
|
+
const checks = runAudit(input)
|
|
102
|
+
const project =
|
|
103
|
+
loadProject(input).loaded?.config.project ?? basename(context.root)
|
|
104
|
+
const report =
|
|
105
|
+
format === "md"
|
|
106
|
+
? formatAuditMarkdown(checks, {
|
|
107
|
+
project,
|
|
108
|
+
root: context.root,
|
|
109
|
+
date: new Date().toISOString().slice(0, 10),
|
|
110
|
+
})
|
|
111
|
+
: formatAuditText(checks, { project })
|
|
112
|
+
const output = stringFlag(context.args, "output")
|
|
113
|
+
|
|
114
|
+
if (output) {
|
|
115
|
+
writeFileSync(resolve(output), report)
|
|
116
|
+
console.log(`Rapport écrit dans ${resolve(output)}`)
|
|
117
|
+
} else {
|
|
118
|
+
process.stdout.write(report)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return auditFailed(checks) ? 1 : 0
|
|
122
|
+
},
|
|
123
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ParsedArgs } from "../lib/args"
|
|
2
|
+
import { stringFlag } from "../lib/args"
|
|
3
|
+
import { ConfigError, type LoadedConfig, loadConfig } from "../lib/config"
|
|
4
|
+
import { kitVersionError } from "../lib/kit-version"
|
|
5
|
+
|
|
6
|
+
export interface CommandContext {
|
|
7
|
+
args: ParsedArgs
|
|
8
|
+
root: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Command {
|
|
12
|
+
usage: string
|
|
13
|
+
summary: string
|
|
14
|
+
details?: string
|
|
15
|
+
valueFlags?: string[]
|
|
16
|
+
cwdRoot?: boolean
|
|
17
|
+
run: (context: CommandContext) => number | Promise<number>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function loadProjectConfig(context: CommandContext): LoadedConfig {
|
|
21
|
+
const loaded = loadConfig({
|
|
22
|
+
root: context.root,
|
|
23
|
+
config: stringFlag(context.args, "config"),
|
|
24
|
+
})
|
|
25
|
+
const versionError = kitVersionError(loaded.config.kit)
|
|
26
|
+
|
|
27
|
+
if (versionError) {
|
|
28
|
+
throw new ConfigError(versionError)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return loaded
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function environmentArg(
|
|
35
|
+
value: string | undefined,
|
|
36
|
+
fallback = "production"
|
|
37
|
+
): string {
|
|
38
|
+
const environment = value ?? fallback
|
|
39
|
+
|
|
40
|
+
if (!/^[a-z][a-z0-9-]*$/.test(environment)) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`« ${environment} » n'est pas une clé d'environnement Wrangler valide.`
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return environment
|
|
47
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { createInterface } from "node:readline/promises"
|
|
2
|
+
|
|
3
|
+
import { booleanFlag } from "../lib/args"
|
|
4
|
+
import type { DatabaseCommand, LoadedConfig } from "../lib/config"
|
|
5
|
+
import {
|
|
6
|
+
assertLocalTarget,
|
|
7
|
+
currentGitBranch,
|
|
8
|
+
databaseConfigOf,
|
|
9
|
+
type DatabaseTarget,
|
|
10
|
+
deleteFeatureBranch,
|
|
11
|
+
migrateCommand,
|
|
12
|
+
productionLabel,
|
|
13
|
+
runDatabaseCommand,
|
|
14
|
+
seedCommand,
|
|
15
|
+
targetEnv,
|
|
16
|
+
writeDevEnv,
|
|
17
|
+
} from "../lib/database"
|
|
18
|
+
import { runCommand } from "../lib/process"
|
|
19
|
+
import { type Command, type CommandContext, loadProjectConfig } from "./context"
|
|
20
|
+
|
|
21
|
+
const PRODUCTION_DETAILS =
|
|
22
|
+
"Avec --production, vise la base de production : terminal interactif obligatoire, nom du projet de production à taper, chaîne de connexion lue par neonctl sur la branche main du projet database.neon.production (jamais depuis le fichier env)."
|
|
23
|
+
|
|
24
|
+
async function confirmProduction(
|
|
25
|
+
loaded: LoadedConfig,
|
|
26
|
+
action: string
|
|
27
|
+
): Promise<void> {
|
|
28
|
+
const name = productionLabel(loaded)
|
|
29
|
+
|
|
30
|
+
if (!process.stdin.isTTY) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
`Refus de ${action} la production sans terminal interactif.`
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const prompt = createInterface({
|
|
37
|
+
input: process.stdin,
|
|
38
|
+
output: process.stdout,
|
|
39
|
+
})
|
|
40
|
+
const answer = await prompt.question(
|
|
41
|
+
`Tu vas ${action} la base de PRODUCTION de ${name}.\nTape « ${name} » pour continuer : `
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
prompt.close()
|
|
45
|
+
|
|
46
|
+
if (answer.trim() !== name) {
|
|
47
|
+
throw new Error("Confirmation différente : rien n'a été modifié.")
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function targetOf(context: CommandContext): DatabaseTarget {
|
|
52
|
+
return booleanFlag(context.args, "production") ? "production" : "local"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function runOn(
|
|
56
|
+
context: CommandContext,
|
|
57
|
+
action: string,
|
|
58
|
+
commandFor: (loaded: LoadedConfig, target: DatabaseTarget) => DatabaseCommand
|
|
59
|
+
): Promise<number> {
|
|
60
|
+
const loaded = loadProjectConfig(context)
|
|
61
|
+
const target = targetOf(context)
|
|
62
|
+
|
|
63
|
+
if (target === "production") {
|
|
64
|
+
await confirmProduction(loaded, action)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const env = targetEnv(loaded, target, runCommand)
|
|
68
|
+
|
|
69
|
+
return runDatabaseCommand(loaded, commandFor(loaded, target), env, runCommand)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const dbEnv: Command = {
|
|
73
|
+
usage: "rc db:env [branche-git]",
|
|
74
|
+
summary:
|
|
75
|
+
"écrit dans le fichier env local les chaînes de la branche Neon de dev de la branche git",
|
|
76
|
+
details:
|
|
77
|
+
"Projet Neon de dev (database.neon.devProjectName, défaut <production>-dev) : la branche git main ou master utilise development, toute autre branche feature/<branche>, créée depuis development pour featureBranchTtlDays jours. Une branche archivée est acceptée : elle se réveille à la première connexion. Écrit APP_ENV, DATABASE_URL (poolée), DATABASE_URL_UNPOOLED, NEON_BRANCH, NEON_PROJECT_ID et NEON_PROJECT_NAME. Sans effet avec provider d1.",
|
|
78
|
+
run(context) {
|
|
79
|
+
const loaded = loadProjectConfig(context)
|
|
80
|
+
|
|
81
|
+
if (databaseConfigOf(loaded).provider !== "neon") {
|
|
82
|
+
console.log(
|
|
83
|
+
" · provider d1 : rien à écrire, la base locale vit dans .wrangler."
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
return 0
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const gitBranch =
|
|
90
|
+
context.args.positionals[0] ?? currentGitBranch(loaded.root, runCommand)
|
|
91
|
+
const branch = writeDevEnv(loaded, { gitBranch, runner: runCommand })
|
|
92
|
+
|
|
93
|
+
console.log(` ✓ fichier env écrit pour la branche Neon ${branch}`)
|
|
94
|
+
|
|
95
|
+
return 0
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const dbMigrate: Command = {
|
|
100
|
+
usage: "rc db:migrate [--production]",
|
|
101
|
+
summary: "applique les migrations à la base de dev, ou à la production",
|
|
102
|
+
details: [
|
|
103
|
+
"Lance database.migrate (défaut neon : bun x prisma migrate deploy dans packages/db ; défaut d1 : wrangler d1 migrations apply --local) avec DATABASE_URL et RC_DATABASE_TARGET. Réessaie tant que la base se réveille.",
|
|
104
|
+
PRODUCTION_DETAILS,
|
|
105
|
+
].join("\n"),
|
|
106
|
+
run: (context) => runOn(context, "migrer", migrateCommand),
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export const dbSeed: Command = {
|
|
110
|
+
usage: "rc db:seed [--production]",
|
|
111
|
+
summary: "lance le seed du projet sur la base de dev, ou sur la production",
|
|
112
|
+
details: [
|
|
113
|
+
"Lance database.seed avec DATABASE_URL, APP_ENV et RC_DATABASE_TARGET de la base visée.",
|
|
114
|
+
PRODUCTION_DETAILS,
|
|
115
|
+
].join("\n"),
|
|
116
|
+
run: (context) => runOn(context, "semer", (loaded) => seedCommand(loaded)),
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export const dbGuard: Command = {
|
|
120
|
+
usage: "rc db:guard",
|
|
121
|
+
summary: "refuse une commande de base locale qui viserait la production",
|
|
122
|
+
details:
|
|
123
|
+
"Contrôle le fichier env local : APP_ENV=local, DATABASE_URL présente, ni la branche main de la base de dev, ni le projet ou le compute de production. À placer devant prisma migrate dev ou reset.",
|
|
124
|
+
run(context) {
|
|
125
|
+
assertLocalTarget(loadProjectConfig(context))
|
|
126
|
+
|
|
127
|
+
return 0
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export const dbBranch: Command = {
|
|
132
|
+
usage: "rc db:branch --delete [branche-git]",
|
|
133
|
+
summary: "supprime la branche Neon feature/* d'une branche git",
|
|
134
|
+
details:
|
|
135
|
+
"Seules les branches feature/* du projet de dev sont supprimables ; elles expirent de toute façon au bout de featureBranchTtlDays jours.",
|
|
136
|
+
run(context) {
|
|
137
|
+
if (!booleanFlag(context.args, "delete")) {
|
|
138
|
+
throw new Error("Précise l'action : rc db:branch --delete [branche-git].")
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const loaded = loadProjectConfig(context)
|
|
142
|
+
const gitBranch =
|
|
143
|
+
context.args.positionals[0] ?? currentGitBranch(loaded.root, runCommand)
|
|
144
|
+
const deleted = deleteFeatureBranch(loaded, gitBranch, runCommand)
|
|
145
|
+
|
|
146
|
+
console.log(
|
|
147
|
+
deleted
|
|
148
|
+
? ` ✓ branche Neon ${deleted} supprimée`
|
|
149
|
+
: " · aucune branche Neon à supprimer"
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
return 0
|
|
153
|
+
},
|
|
154
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { booleanFlag } from "../lib/args"
|
|
2
|
+
import { appDir, deployOrder } from "../lib/config"
|
|
3
|
+
import { deployApp } from "../lib/deploy"
|
|
4
|
+
import { runCommand } from "../lib/process"
|
|
5
|
+
import { type Command, environmentArg, loadProjectConfig } from "./context"
|
|
6
|
+
|
|
7
|
+
export const deploy: Command = {
|
|
8
|
+
usage: "rc deploy <app|all> [env=production] [--dry-run]",
|
|
9
|
+
summary:
|
|
10
|
+
"build avec CLOUDFLARE_ENV, vérifie le Worker construit, puis wrangler deploy",
|
|
11
|
+
details:
|
|
12
|
+
"all déploie toutes les apps dans l'ordre de apps.*.dependsOn. Pour un build Vite (TanStack Start, Astro), le nom et l'environnement de dist/server/wrangler.json sont vérifiés avant wrangler deploy ; sinon wrangler deploy part de wrangler.jsonc avec --env. Refuse les ids factices hors --dry-run.",
|
|
13
|
+
run(context) {
|
|
14
|
+
const loaded = loadProjectConfig(context)
|
|
15
|
+
const [selector, envArg] = context.args.positionals
|
|
16
|
+
const environment = environmentArg(envArg)
|
|
17
|
+
const dryRun = booleanFlag(context.args, "dry-run")
|
|
18
|
+
|
|
19
|
+
if (!selector) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
`Précise une app (${Object.keys(loaded.config.apps).join(", ")}) ou all.`
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const apps =
|
|
26
|
+
selector === "all"
|
|
27
|
+
? deployOrder(loaded.config.apps, Object.keys(loaded.config.apps))
|
|
28
|
+
: [selector]
|
|
29
|
+
|
|
30
|
+
for (const app of apps) {
|
|
31
|
+
const outcome = deployApp({
|
|
32
|
+
app,
|
|
33
|
+
appDir: appDir(loaded, app),
|
|
34
|
+
environment,
|
|
35
|
+
dryRun,
|
|
36
|
+
runner: runCommand,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
console.log(
|
|
40
|
+
`${app} : ${outcome.worker} ${dryRun ? "vérifié (dry run)" : "déployé"}.`
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return 0
|
|
45
|
+
},
|
|
46
|
+
}
|