@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,217 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test"
|
|
2
|
+
|
|
3
|
+
import { checkDeployConfig } from "./deploy-config"
|
|
4
|
+
import { placeholderIds, type WranglerConfig } from "./wrangler"
|
|
5
|
+
|
|
6
|
+
const LOCAL: WranglerConfig = {
|
|
7
|
+
name: "adv-admin-local",
|
|
8
|
+
d1_databases: [
|
|
9
|
+
{
|
|
10
|
+
binding: "DB",
|
|
11
|
+
database_name: "adv-d1-local",
|
|
12
|
+
database_id: "adv-d1-local",
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
kv_namespaces: [{ binding: "KV", id: "adv-kv-local" }],
|
|
16
|
+
ratelimits: [{ name: "AUTH_RATE_LIMITER", namespace_id: "1001" }],
|
|
17
|
+
vars: {
|
|
18
|
+
APP_ENVIRONMENT: "local",
|
|
19
|
+
BETTER_AUTH_URL: "http://localhost:3000",
|
|
20
|
+
TURNSTILE_SECRET_KEY: "",
|
|
21
|
+
WHATSAPP_ACCESS_TOKEN: "",
|
|
22
|
+
},
|
|
23
|
+
secrets: { required: ["BETTER_AUTH_SECRET"] },
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const PRODUCTION = {
|
|
27
|
+
name: "adv-admin-prod",
|
|
28
|
+
d1_databases: [
|
|
29
|
+
{
|
|
30
|
+
binding: "DB",
|
|
31
|
+
database_name: "adv-d1-prod",
|
|
32
|
+
database_id: "44444444-4444-4444-8444-444444444444",
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
kv_namespaces: [{ binding: "KV", id: "5555555555555555aaaaaaaaaaaaaaaa" }],
|
|
36
|
+
ratelimits: [{ name: "AUTH_RATE_LIMITER", namespace_id: "1001" }],
|
|
37
|
+
vars: {
|
|
38
|
+
APP_ENVIRONMENT: "production",
|
|
39
|
+
BETTER_AUTH_URL: "https://admin.example.com",
|
|
40
|
+
},
|
|
41
|
+
secrets: { required: ["BETTER_AUTH_SECRET", "TURNSTILE_SECRET_KEY"] },
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
describe("checkDeployConfig", () => {
|
|
45
|
+
test("accepts an env that redeclares the local vars, secrets and bindings", () => {
|
|
46
|
+
const report = checkDeployConfig(
|
|
47
|
+
{ ...LOCAL, env: { production: PRODUCTION } },
|
|
48
|
+
{ optionalSecrets: ["WHATSAPP_ACCESS_TOKEN"] }
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
expect(report).toEqual({ errors: [], warnings: [] })
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test("fails on a non-empty local var the env forgot", () => {
|
|
55
|
+
const { BETTER_AUTH_URL: _, ...vars } = PRODUCTION.vars
|
|
56
|
+
const report = checkDeployConfig({
|
|
57
|
+
...LOCAL,
|
|
58
|
+
env: { production: { ...PRODUCTION, vars } },
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
expect(report.errors).toEqual([
|
|
62
|
+
"wrangler.jsonc [env.production] : BETTER_AUTH_URL déclaré(s) au niveau local mais absent(s) des vars et de secrets.required (un environnement n'hérite pas des vars).",
|
|
63
|
+
])
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
test("only warns about an empty local slot that is neither a var, a secret nor optional", () => {
|
|
67
|
+
const report = checkDeployConfig({
|
|
68
|
+
...LOCAL,
|
|
69
|
+
env: { production: PRODUCTION },
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
expect(report.errors).toEqual([])
|
|
73
|
+
expect(report.warnings[0]).toContain(
|
|
74
|
+
"WHATSAPP_ACCESS_TOKEN vide(s) en local"
|
|
75
|
+
)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
test("fails on a binding the env does not redeclare, warns on one only the env has", () => {
|
|
79
|
+
const report = checkDeployConfig(
|
|
80
|
+
{
|
|
81
|
+
...LOCAL,
|
|
82
|
+
env: {
|
|
83
|
+
production: {
|
|
84
|
+
...PRODUCTION,
|
|
85
|
+
ratelimits: [],
|
|
86
|
+
send_email: [{ name: "EMAIL" }],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{ optionalSecrets: ["WHATSAPP_ACCESS_TOKEN"] }
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
expect(report.errors).toEqual([
|
|
94
|
+
"wrangler.jsonc [env.production] : binding(s) AUTH_RATE_LIMITER (ratelimit) absent(s) (un environnement n'hérite pas des bindings).",
|
|
95
|
+
])
|
|
96
|
+
expect(report.warnings).toEqual([
|
|
97
|
+
"wrangler.jsonc [env.production] : binding(s) EMAIL absent(s) du niveau local.",
|
|
98
|
+
])
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
test("warns about vars only a deployment declares", () => {
|
|
102
|
+
const report = checkDeployConfig(
|
|
103
|
+
{
|
|
104
|
+
...LOCAL,
|
|
105
|
+
env: {
|
|
106
|
+
production: {
|
|
107
|
+
...PRODUCTION,
|
|
108
|
+
vars: { ...PRODUCTION.vars, MEDIA_PUBLIC_URL: "https://media" },
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{ optionalSecrets: ["WHATSAPP_ACCESS_TOKEN"] }
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
expect(report.warnings).toEqual([
|
|
116
|
+
"wrangler.jsonc [env.production] : MEDIA_PUBLIC_URL absent(s) du niveau local (à déclarer, vide si optionnel, pour que le local les lise).",
|
|
117
|
+
])
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
test("leaves local-only bindings out of deployments, refuses them there", () => {
|
|
121
|
+
const local = {
|
|
122
|
+
...LOCAL,
|
|
123
|
+
d1_databases: [
|
|
124
|
+
...(LOCAL.d1_databases ?? []),
|
|
125
|
+
{
|
|
126
|
+
binding: "SITE_DB_DEMO",
|
|
127
|
+
database_name: "adv-d1-site-demo-local",
|
|
128
|
+
database_id: "adv-d1-site-demo-local",
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
}
|
|
132
|
+
const options = {
|
|
133
|
+
optionalSecrets: ["WHATSAPP_ACCESS_TOKEN"],
|
|
134
|
+
localOnlyBindings: ["SITE_DB_DEMO"],
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
expect(
|
|
138
|
+
checkDeployConfig({ ...local, env: { production: PRODUCTION } }, options)
|
|
139
|
+
.errors
|
|
140
|
+
).toEqual([])
|
|
141
|
+
|
|
142
|
+
const deployed = {
|
|
143
|
+
...PRODUCTION,
|
|
144
|
+
d1_databases: [
|
|
145
|
+
...PRODUCTION.d1_databases,
|
|
146
|
+
{
|
|
147
|
+
binding: "SITE_DB_DEMO",
|
|
148
|
+
database_name: "adv-d1-site-demo-prod",
|
|
149
|
+
database_id: "66666666-6666-4666-8666-666666666666",
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
expect(
|
|
155
|
+
checkDeployConfig({ ...local, env: { production: deployed } }, options)
|
|
156
|
+
.errors
|
|
157
|
+
).toEqual([
|
|
158
|
+
"wrangler.jsonc [env.production] : binding(s) SITE_DB_DEMO réservé(s) au local par localOnlyBindings, mais déclaré(s) dans ce déploiement.",
|
|
159
|
+
])
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
test("warns about placeholder ids, fails on them with --strict", () => {
|
|
163
|
+
const placeholder = {
|
|
164
|
+
...PRODUCTION,
|
|
165
|
+
d1_databases: [
|
|
166
|
+
{
|
|
167
|
+
binding: "DB",
|
|
168
|
+
database_name: "adv-d1-prod",
|
|
169
|
+
database_id: "00000000-0000-0000-0000-000000000000",
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
kv_namespaces: [
|
|
173
|
+
{ binding: "KV", id: "00000000000000000000000000000000" },
|
|
174
|
+
],
|
|
175
|
+
}
|
|
176
|
+
const config = { ...LOCAL, env: { production: placeholder } }
|
|
177
|
+
const options = { optionalSecrets: ["WHATSAPP_ACCESS_TOKEN"] }
|
|
178
|
+
|
|
179
|
+
expect(checkDeployConfig(config, options).warnings).toEqual([
|
|
180
|
+
"wrangler.jsonc [env.production] : identifiants factices pour D1 adv-d1-prod, KV KV (crée les ressources et colle leurs ids).",
|
|
181
|
+
])
|
|
182
|
+
expect(
|
|
183
|
+
checkDeployConfig(config, { ...options, strict: true }).errors
|
|
184
|
+
).toHaveLength(1)
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
test("fails on an env without name and warns about a config without env", () => {
|
|
188
|
+
expect(checkDeployConfig({ name: "adv-web-prod" }).warnings[0]).toContain(
|
|
189
|
+
"aucun bloc env"
|
|
190
|
+
)
|
|
191
|
+
expect(
|
|
192
|
+
checkDeployConfig({ name: "x", env: { production: {} } }).errors
|
|
193
|
+
).toEqual(["wrangler.jsonc [env.production] : pas de name."])
|
|
194
|
+
})
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
describe("placeholderIds", () => {
|
|
198
|
+
test("names the resources that were never created", () => {
|
|
199
|
+
expect(
|
|
200
|
+
placeholderIds({
|
|
201
|
+
d1_databases: [
|
|
202
|
+
{
|
|
203
|
+
database_id: "00000000-0000-0000-0000-000000000000",
|
|
204
|
+
database_name: "adv-d1-prod",
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
kv_namespaces: [
|
|
208
|
+
{ binding: "KV", id: "00000000000000000000000000000000" },
|
|
209
|
+
],
|
|
210
|
+
hyperdrive: [{ binding: "HYPERDRIVE", id: "0000" }],
|
|
211
|
+
})
|
|
212
|
+
).toEqual(["D1 adv-d1-prod", "KV KV", "Hyperdrive HYPERDRIVE"])
|
|
213
|
+
expect(
|
|
214
|
+
placeholderIds({ d1_databases: [{ database_id: "4f0c2a7e" }] })
|
|
215
|
+
).toEqual([])
|
|
216
|
+
})
|
|
217
|
+
})
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bindingsOf,
|
|
3
|
+
placeholderIds,
|
|
4
|
+
requiredSecrets,
|
|
5
|
+
type WranglerConfig,
|
|
6
|
+
type WranglerLevel,
|
|
7
|
+
} from "./wrangler"
|
|
8
|
+
|
|
9
|
+
export interface DeployConfigOptions {
|
|
10
|
+
strict?: boolean
|
|
11
|
+
file?: string
|
|
12
|
+
optionalSecrets?: readonly string[]
|
|
13
|
+
localOnlyBindings?: readonly string[]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface DeployConfigReport {
|
|
17
|
+
errors: string[]
|
|
18
|
+
warnings: string[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function list(keys: string[]): string {
|
|
22
|
+
return keys.join(", ")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function declaredKeys(level: WranglerLevel): Set<string> {
|
|
26
|
+
return new Set([...Object.keys(level.vars ?? {}), ...requiredSecrets(level)])
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function isEmptyVar(value: unknown): boolean {
|
|
30
|
+
return typeof value === "string" && value.trim() === ""
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function checkDeployConfig(
|
|
34
|
+
config: WranglerConfig,
|
|
35
|
+
options: DeployConfigOptions = {}
|
|
36
|
+
): DeployConfigReport {
|
|
37
|
+
const file = options.file ?? "wrangler.jsonc"
|
|
38
|
+
const optional = new Set(options.optionalSecrets ?? [])
|
|
39
|
+
const localOnly = new Set(options.localOnlyBindings ?? [])
|
|
40
|
+
const errors: string[] = []
|
|
41
|
+
const warnings: string[] = []
|
|
42
|
+
const environments = Object.entries(config.env ?? {})
|
|
43
|
+
|
|
44
|
+
if (environments.length === 0) {
|
|
45
|
+
warnings.push(
|
|
46
|
+
`${file} : aucun bloc env, le niveau haut est déployé tel quel. La convention veut le local au niveau haut et la prod dans env.production.`
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const localVars = config.vars ?? {}
|
|
51
|
+
const localKeys = declaredKeys(config)
|
|
52
|
+
const localBindings = new Map(
|
|
53
|
+
bindingsOf(config).map((binding) => [binding.name, binding.kind])
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
for (const [target, level] of environments) {
|
|
57
|
+
const where = `${file} [env.${target}]`
|
|
58
|
+
const keys = declaredKeys(level)
|
|
59
|
+
const bindings = new Set(bindingsOf(level).map((binding) => binding.name))
|
|
60
|
+
|
|
61
|
+
if (!level.name) {
|
|
62
|
+
errors.push(`${where} : pas de name.`)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const missingVars = [...localKeys].filter((key) => !keys.has(key))
|
|
66
|
+
const missingRequired = missingVars.filter(
|
|
67
|
+
(key) => !(isEmptyVar(localVars[key]) || optional.has(key))
|
|
68
|
+
)
|
|
69
|
+
const missingOptional = missingVars.filter(
|
|
70
|
+
(key) => isEmptyVar(localVars[key]) && !optional.has(key)
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
if (missingRequired.length > 0) {
|
|
74
|
+
errors.push(
|
|
75
|
+
`${where} : ${list(missingRequired)} déclaré(s) au niveau local mais absent(s) des vars et de secrets.required (un environnement n'hérite pas des vars).`
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (missingOptional.length > 0) {
|
|
80
|
+
warnings.push(
|
|
81
|
+
`${where} : ${list(missingOptional)} vide(s) en local mais ni dans les vars, ni dans secrets.required, ni dans optionalSecrets de l'app.`
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const extraVars = [...keys].filter((key) => !localKeys.has(key))
|
|
86
|
+
|
|
87
|
+
if (extraVars.length > 0) {
|
|
88
|
+
warnings.push(
|
|
89
|
+
`${where} : ${list(extraVars)} absent(s) du niveau local (à déclarer, vide si optionnel, pour que le local les lise).`
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const missingBindings = [...localBindings.keys()].filter(
|
|
94
|
+
(name) => !bindings.has(name) && !localOnly.has(name)
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
if (missingBindings.length > 0) {
|
|
98
|
+
errors.push(
|
|
99
|
+
`${where} : binding(s) ${list(missingBindings.map((name) => `${name} (${localBindings.get(name)})`))} absent(s) (un environnement n'hérite pas des bindings).`
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const extraBindings = [...bindings].filter(
|
|
104
|
+
(name) => !localBindings.has(name)
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
if (extraBindings.length > 0) {
|
|
108
|
+
warnings.push(
|
|
109
|
+
`${where} : binding(s) ${list(extraBindings)} absent(s) du niveau local.`
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const deployedLocalOnly = [...bindings].filter((name) =>
|
|
114
|
+
localOnly.has(name)
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
if (deployedLocalOnly.length > 0) {
|
|
118
|
+
errors.push(
|
|
119
|
+
`${where} : binding(s) ${list(deployedLocalOnly)} réservé(s) au local par localOnlyBindings, mais déclaré(s) dans ce déploiement.`
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const placeholders = placeholderIds(level)
|
|
124
|
+
|
|
125
|
+
if (placeholders.length > 0) {
|
|
126
|
+
;(options.strict ? errors : warnings).push(
|
|
127
|
+
`${where} : identifiants factices pour ${list(placeholders)} (crée les ressources et colle leurs ids).`
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return { errors, warnings }
|
|
133
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { afterAll, describe, expect, test } from "bun:test"
|
|
2
|
+
import { utimesSync } from "node:fs"
|
|
3
|
+
import { join } from "node:path"
|
|
4
|
+
|
|
5
|
+
import { assertBuiltFor, deployApp } from "./deploy"
|
|
6
|
+
import type { Runner } from "./process"
|
|
7
|
+
import { cleanupTempDirs, fakeRunner, tempDir, writeTree } from "./test-utils"
|
|
8
|
+
import type { Deployment } from "./wrangler"
|
|
9
|
+
|
|
10
|
+
afterAll(cleanupTempDirs)
|
|
11
|
+
|
|
12
|
+
const PRODUCTION: Deployment = {
|
|
13
|
+
environment: "production",
|
|
14
|
+
name: "adv-admin-prod",
|
|
15
|
+
usesEnv: true,
|
|
16
|
+
level: {},
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const WRANGLER = `{
|
|
20
|
+
// local
|
|
21
|
+
"name": "gio-admin-local",
|
|
22
|
+
"env": {
|
|
23
|
+
"production": {
|
|
24
|
+
"name": "gio-admin-prod",
|
|
25
|
+
"d1_databases": [{ "binding": "DB", "database_name": "gio-d1-prod", "database_id": "4f0c2a7e-1111-2222-3333-444455556666" }],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
}`
|
|
29
|
+
|
|
30
|
+
function viteApp(): string {
|
|
31
|
+
return writeTree(tempDir(), {
|
|
32
|
+
"wrangler.jsonc": WRANGLER,
|
|
33
|
+
"package.json": { scripts: { build: "vp build" } },
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function buildWriting(
|
|
38
|
+
dir: string,
|
|
39
|
+
built: object,
|
|
40
|
+
redirect = "../../dist/server/wrangler.json"
|
|
41
|
+
) {
|
|
42
|
+
return fakeRunner((command) => {
|
|
43
|
+
if (command.join(" ") === "bun run build") {
|
|
44
|
+
writeTree(dir, {
|
|
45
|
+
"dist/server/wrangler.json": built,
|
|
46
|
+
".wrangler/deploy/config.json": { configPath: redirect },
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return {}
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const quiet = { log: () => {} }
|
|
55
|
+
|
|
56
|
+
describe("assertBuiltFor", () => {
|
|
57
|
+
test("refuses a build made for another Worker or environment", () => {
|
|
58
|
+
expect(() =>
|
|
59
|
+
assertBuiltFor({ name: "adv-admin-local" }, PRODUCTION)
|
|
60
|
+
).toThrow("Rien n'a été déployé")
|
|
61
|
+
expect(() =>
|
|
62
|
+
assertBuiltFor(
|
|
63
|
+
{ name: "adv-admin-prod", targetEnvironment: "staging" },
|
|
64
|
+
PRODUCTION
|
|
65
|
+
)
|
|
66
|
+
).toThrow("staging")
|
|
67
|
+
expect(() =>
|
|
68
|
+
assertBuiltFor(
|
|
69
|
+
{ name: "adv-admin-prod", targetEnvironment: "production" },
|
|
70
|
+
PRODUCTION
|
|
71
|
+
)
|
|
72
|
+
).not.toThrow()
|
|
73
|
+
expect(() =>
|
|
74
|
+
assertBuiltFor({ name: "adv-admin-prod" }, PRODUCTION)
|
|
75
|
+
).not.toThrow()
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
describe("deployApp", () => {
|
|
80
|
+
test("builds with CLOUDFLARE_ENV, checks the built Worker, then deploys the build", () => {
|
|
81
|
+
const dir = viteApp()
|
|
82
|
+
const { runner, calls } = buildWriting(dir, {
|
|
83
|
+
name: "gio-admin-prod",
|
|
84
|
+
targetEnvironment: "production",
|
|
85
|
+
})
|
|
86
|
+
const outcome = deployApp({
|
|
87
|
+
app: "admin",
|
|
88
|
+
appDir: dir,
|
|
89
|
+
environment: "production",
|
|
90
|
+
dryRun: false,
|
|
91
|
+
runner,
|
|
92
|
+
...quiet,
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
expect(outcome.mode).toBe("built")
|
|
96
|
+
expect(
|
|
97
|
+
calls.map((call) => [call.command.join(" "), call.options.env])
|
|
98
|
+
).toEqual([
|
|
99
|
+
["bun run build", { CLOUDFLARE_ENV: "production" }],
|
|
100
|
+
["bun x wrangler deploy", undefined],
|
|
101
|
+
])
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
test("never deploys a local build", () => {
|
|
105
|
+
const dir = viteApp()
|
|
106
|
+
const { runner, calls } = buildWriting(dir, { name: "gio-admin-local" })
|
|
107
|
+
|
|
108
|
+
expect(() =>
|
|
109
|
+
deployApp({
|
|
110
|
+
app: "admin",
|
|
111
|
+
appDir: dir,
|
|
112
|
+
environment: "production",
|
|
113
|
+
dryRun: false,
|
|
114
|
+
runner,
|
|
115
|
+
...quiet,
|
|
116
|
+
})
|
|
117
|
+
).toThrow("gio-admin-local")
|
|
118
|
+
expect(calls).toHaveLength(1)
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
test("never deploys a stale build output", () => {
|
|
122
|
+
const dir = viteApp()
|
|
123
|
+
|
|
124
|
+
writeTree(dir, { "dist/server/wrangler.json": { name: "gio-admin-prod" } })
|
|
125
|
+
utimesSync(
|
|
126
|
+
join(dir, "dist/server/wrangler.json"),
|
|
127
|
+
new Date(2020, 0, 1),
|
|
128
|
+
new Date(2020, 0, 1)
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
expect(() =>
|
|
132
|
+
deployApp({
|
|
133
|
+
app: "admin",
|
|
134
|
+
appDir: dir,
|
|
135
|
+
environment: "production",
|
|
136
|
+
dryRun: false,
|
|
137
|
+
runner: fakeRunner(() => ({})).runner,
|
|
138
|
+
...quiet,
|
|
139
|
+
})
|
|
140
|
+
).toThrow("build précédent")
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
test("refuses a deploy redirect that points elsewhere", () => {
|
|
144
|
+
const dir = viteApp()
|
|
145
|
+
const { runner } = buildWriting(
|
|
146
|
+
dir,
|
|
147
|
+
{ name: "gio-admin-prod" },
|
|
148
|
+
"../../wrangler.jsonc"
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
expect(() =>
|
|
152
|
+
deployApp({
|
|
153
|
+
app: "admin",
|
|
154
|
+
appDir: dir,
|
|
155
|
+
environment: "production",
|
|
156
|
+
dryRun: false,
|
|
157
|
+
runner,
|
|
158
|
+
...quiet,
|
|
159
|
+
})
|
|
160
|
+
).toThrow("ne pointe pas")
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
test("deploys a plain Worker from its wrangler.jsonc with --env", () => {
|
|
164
|
+
const dir = writeTree(tempDir(), { "wrangler.jsonc": WRANGLER })
|
|
165
|
+
const { runner, calls } = fakeRunner(() => ({}))
|
|
166
|
+
const outcome = deployApp({
|
|
167
|
+
app: "admin",
|
|
168
|
+
appDir: dir,
|
|
169
|
+
environment: "production",
|
|
170
|
+
dryRun: true,
|
|
171
|
+
runner,
|
|
172
|
+
...quiet,
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
expect(outcome.mode).toBe("source")
|
|
176
|
+
expect(calls.map((call) => call.command)).toEqual([
|
|
177
|
+
[
|
|
178
|
+
"bun",
|
|
179
|
+
"x",
|
|
180
|
+
"wrangler",
|
|
181
|
+
"deploy",
|
|
182
|
+
"--config",
|
|
183
|
+
join(dir, "wrangler.jsonc"),
|
|
184
|
+
"--env",
|
|
185
|
+
"production",
|
|
186
|
+
"--dry-run",
|
|
187
|
+
],
|
|
188
|
+
])
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
test("deploys the top level of a config without env, without CLOUDFLARE_ENV", () => {
|
|
192
|
+
const dir = writeTree(tempDir(), {
|
|
193
|
+
"wrangler.jsonc": '{ "name": "adv-web-prod" }',
|
|
194
|
+
"package.json": { scripts: { build: "astro build" } },
|
|
195
|
+
})
|
|
196
|
+
const { runner, calls } = fakeRunner(() => ({}))
|
|
197
|
+
|
|
198
|
+
deployApp({
|
|
199
|
+
app: "web",
|
|
200
|
+
appDir: dir,
|
|
201
|
+
environment: "production",
|
|
202
|
+
dryRun: false,
|
|
203
|
+
runner,
|
|
204
|
+
...quiet,
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
expect(
|
|
208
|
+
calls.map((call) => [call.command.join(" "), call.options.env])
|
|
209
|
+
).toEqual([
|
|
210
|
+
["bun run build", undefined],
|
|
211
|
+
[
|
|
212
|
+
`bun x wrangler deploy --config ${join(dir, "wrangler.jsonc")}`,
|
|
213
|
+
undefined,
|
|
214
|
+
],
|
|
215
|
+
])
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
test("refuses placeholder ids unless it is a dry run, and unknown environments", () => {
|
|
219
|
+
const dir = writeTree(tempDir(), {
|
|
220
|
+
"wrangler.jsonc": WRANGLER.replace(
|
|
221
|
+
"4f0c2a7e-1111-2222-3333-444455556666",
|
|
222
|
+
"00000000-0000-0000-0000-000000000000"
|
|
223
|
+
),
|
|
224
|
+
})
|
|
225
|
+
const runner: Runner = fakeRunner(() => ({})).runner
|
|
226
|
+
|
|
227
|
+
expect(() =>
|
|
228
|
+
deployApp({
|
|
229
|
+
app: "admin",
|
|
230
|
+
appDir: dir,
|
|
231
|
+
environment: "production",
|
|
232
|
+
dryRun: false,
|
|
233
|
+
runner,
|
|
234
|
+
...quiet,
|
|
235
|
+
})
|
|
236
|
+
).toThrow("factices")
|
|
237
|
+
expect(() =>
|
|
238
|
+
deployApp({
|
|
239
|
+
app: "admin",
|
|
240
|
+
appDir: dir,
|
|
241
|
+
environment: "production",
|
|
242
|
+
dryRun: true,
|
|
243
|
+
runner,
|
|
244
|
+
...quiet,
|
|
245
|
+
})
|
|
246
|
+
).not.toThrow()
|
|
247
|
+
expect(() =>
|
|
248
|
+
deployApp({
|
|
249
|
+
app: "admin",
|
|
250
|
+
appDir: dir,
|
|
251
|
+
environment: "staging",
|
|
252
|
+
dryRun: true,
|
|
253
|
+
runner,
|
|
254
|
+
...quiet,
|
|
255
|
+
})
|
|
256
|
+
).toThrow("pas d'environnement « staging » (environnements : production)")
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
test("stops when the build fails", () => {
|
|
260
|
+
const dir = viteApp()
|
|
261
|
+
const { runner, calls } = fakeRunner(() => ({ exitCode: 1 }))
|
|
262
|
+
|
|
263
|
+
expect(() =>
|
|
264
|
+
deployApp({
|
|
265
|
+
app: "admin",
|
|
266
|
+
appDir: dir,
|
|
267
|
+
environment: "production",
|
|
268
|
+
dryRun: false,
|
|
269
|
+
runner,
|
|
270
|
+
...quiet,
|
|
271
|
+
})
|
|
272
|
+
).toThrow("bun run build")
|
|
273
|
+
expect(calls).toHaveLength(1)
|
|
274
|
+
})
|
|
275
|
+
})
|