@supatype/cli 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +499 -91
- package/bin/node-version.js +28 -0
- package/bin/supatype.js +8 -4
- package/dist/api-config-cache.d.ts +22 -8
- package/dist/api-config-cache.d.ts.map +1 -1
- package/dist/api-config-cache.js +82 -19
- package/dist/api-config-cache.js.map +1 -1
- package/dist/api-config-stack.d.ts +23 -0
- package/dist/api-config-stack.d.ts.map +1 -0
- package/dist/api-config-stack.js +63 -0
- package/dist/api-config-stack.js.map +1 -0
- package/dist/api-url.d.ts +12 -0
- package/dist/api-url.d.ts.map +1 -0
- package/dist/api-url.js +17 -0
- package/dist/api-url.js.map +1 -0
- package/dist/app/framework.d.ts +18 -2
- package/dist/app/framework.d.ts.map +1 -1
- package/dist/app/framework.js +26 -3
- package/dist/app/framework.js.map +1 -1
- package/dist/app/port-holder.d.ts +33 -0
- package/dist/app/port-holder.d.ts.map +1 -0
- package/dist/app/port-holder.js +66 -0
- package/dist/app/port-holder.js.map +1 -0
- package/dist/app/proxy-dev-app.d.ts +27 -3
- package/dist/app/proxy-dev-app.d.ts.map +1 -1
- package/dist/app/proxy-dev-app.js +100 -46
- package/dist/app/proxy-dev-app.js.map +1 -1
- package/dist/app/vite-dev-args.d.ts +33 -0
- package/dist/app/vite-dev-args.d.ts.map +1 -0
- package/dist/app/vite-dev-args.js +90 -0
- package/dist/app/vite-dev-args.js.map +1 -0
- package/dist/app-config.d.ts +2 -0
- package/dist/app-config.d.ts.map +1 -1
- package/dist/app-config.js +27 -8
- package/dist/app-config.js.map +1 -1
- package/dist/applied-ast-artifacts.d.ts +7 -2
- package/dist/applied-ast-artifacts.d.ts.map +1 -1
- package/dist/applied-ast-artifacts.js +8 -3
- package/dist/applied-ast-artifacts.js.map +1 -1
- package/dist/archive-extract.d.ts +21 -2
- package/dist/archive-extract.d.ts.map +1 -1
- package/dist/archive-extract.js +30 -11
- package/dist/archive-extract.js.map +1 -1
- package/dist/augmentation-generator.d.ts +9 -0
- package/dist/augmentation-generator.d.ts.map +1 -1
- package/dist/augmentation-generator.js +75 -8
- package/dist/augmentation-generator.js.map +1 -1
- package/dist/auth-answer.d.ts +1 -1
- package/dist/auth-answer.js +1 -1
- package/dist/auth-config-validate.d.ts +3 -0
- package/dist/auth-config-validate.d.ts.map +1 -0
- package/dist/auth-config-validate.js +85 -0
- package/dist/auth-config-validate.js.map +1 -0
- package/dist/auth-groups-env.d.ts +14 -0
- package/dist/auth-groups-env.d.ts.map +1 -0
- package/dist/auth-groups-env.js +53 -0
- package/dist/auth-groups-env.js.map +1 -0
- package/dist/auth-providers.d.ts +6 -14
- package/dist/auth-providers.d.ts.map +1 -1
- package/dist/auth-providers.js +6 -36
- package/dist/auth-providers.js.map +1 -1
- package/dist/auth-settings-push.d.ts +29 -0
- package/dist/auth-settings-push.d.ts.map +1 -0
- package/dist/auth-settings-push.js +176 -0
- package/dist/auth-settings-push.js.map +1 -0
- package/dist/binary-cache.d.ts +4 -1
- package/dist/binary-cache.d.ts.map +1 -1
- package/dist/binary-cache.js +33 -63
- package/dist/binary-cache.js.map +1 -1
- package/dist/binary-download-lock.d.ts.map +1 -1
- package/dist/binary-download-lock.js +2 -10
- package/dist/binary-download-lock.js.map +1 -1
- package/dist/browser-login.d.ts +42 -0
- package/dist/browser-login.d.ts.map +1 -0
- package/dist/browser-login.js +111 -0
- package/dist/browser-login.js.map +1 -0
- package/dist/build-public-env.d.ts +29 -0
- package/dist/build-public-env.d.ts.map +1 -0
- package/dist/build-public-env.js +97 -0
- package/dist/build-public-env.js.map +1 -0
- package/dist/build-refused.d.ts +9 -0
- package/dist/build-refused.d.ts.map +1 -0
- package/dist/build-refused.js +9 -0
- package/dist/build-refused.js.map +1 -0
- package/dist/cache-provider.d.ts +17 -2
- package/dist/cache-provider.d.ts.map +1 -1
- package/dist/cache-provider.js +28 -3
- package/dist/cache-provider.js.map +1 -1
- package/dist/cdn-fetch.d.ts +36 -0
- package/dist/cdn-fetch.d.ts.map +1 -0
- package/dist/cdn-fetch.js +175 -0
- package/dist/cdn-fetch.js.map +1 -0
- package/dist/channel-extractor.d.ts +51 -0
- package/dist/channel-extractor.d.ts.map +1 -0
- package/dist/channel-extractor.js +485 -0
- package/dist/channel-extractor.js.map +1 -0
- package/dist/cli-launcher.d.ts.map +1 -1
- package/dist/cli-launcher.js +3 -2
- package/dist/cli-launcher.js.map +1 -1
- package/dist/cli-release-check.d.ts +34 -0
- package/dist/cli-release-check.d.ts.map +1 -0
- package/dist/cli-release-check.js +79 -0
- package/dist/cli-release-check.js.map +1 -0
- package/dist/cli-standalone.d.ts +16 -0
- package/dist/cli-standalone.d.ts.map +1 -1
- package/dist/cli-standalone.js +92 -47
- package/dist/cli-standalone.js.map +1 -1
- package/dist/cli-version-embedded.d.ts.map +1 -1
- package/dist/cli-version-embedded.js +1 -1
- package/dist/cli-version-embedded.js.map +1 -1
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +12 -1
- package/dist/cli.js.map +1 -1
- package/dist/client-generator.d.ts.map +1 -1
- package/dist/client-generator.js +9 -3
- package/dist/client-generator.js.map +1 -1
- package/dist/cloud-admin.d.ts +55 -0
- package/dist/cloud-admin.d.ts.map +1 -0
- package/dist/cloud-admin.js +99 -0
- package/dist/cloud-admin.js.map +1 -0
- package/dist/cloud-credentials.d.ts +24 -9
- package/dist/cloud-credentials.d.ts.map +1 -1
- package/dist/cloud-credentials.js +57 -47
- package/dist/cloud-credentials.js.map +1 -1
- package/dist/cloud-saml-key.d.ts +9 -0
- package/dist/cloud-saml-key.d.ts.map +1 -0
- package/dist/cloud-saml-key.js +44 -0
- package/dist/cloud-saml-key.js.map +1 -0
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +79 -24
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/app.d.ts.map +1 -1
- package/dist/commands/app.js +22 -2
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/build.d.ts +3 -2
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +10 -13
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/cache.d.ts.map +1 -1
- package/dist/commands/cache.js +16 -5
- package/dist/commands/cache.js.map +1 -1
- package/dist/commands/cloud.d.ts +2 -0
- package/dist/commands/cloud.d.ts.map +1 -1
- package/dist/commands/cloud.js +96 -23
- package/dist/commands/cloud.js.map +1 -1
- package/dist/commands/db.d.ts.map +1 -1
- package/dist/commands/db.js +2 -1
- package/dist/commands/db.js.map +1 -1
- package/dist/commands/deploy.d.ts +21 -2
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +97 -97
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +31 -4
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +261 -77
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +16 -4
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/functions.d.ts.map +1 -1
- package/dist/commands/functions.js +163 -54
- package/dist/commands/functions.js.map +1 -1
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +3 -0
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/hooks.d.ts.map +1 -1
- package/dist/commands/hooks.js +40 -9
- package/dist/commands/hooks.js.map +1 -1
- package/dist/commands/init.d.ts +20 -8
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +358 -137
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/keys.d.ts +6 -0
- package/dist/commands/keys.d.ts.map +1 -1
- package/dist/commands/keys.js +17 -10
- package/dist/commands/keys.js.map +1 -1
- package/dist/commands/link-helpers.d.ts +4 -1
- package/dist/commands/link-helpers.d.ts.map +1 -1
- package/dist/commands/link-helpers.js +64 -12
- package/dist/commands/link-helpers.js.map +1 -1
- package/dist/commands/login.d.ts +3 -2
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +99 -57
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/migrate.d.ts +17 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +22 -4
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/push.d.ts +35 -1
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +117 -21
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/seed.d.ts +31 -45
- package/dist/commands/seed.d.ts.map +1 -1
- package/dist/commands/seed.js +93 -215
- package/dist/commands/seed.js.map +1 -1
- package/dist/commands/self-host.d.ts +3 -3
- package/dist/commands/self-host.d.ts.map +1 -1
- package/dist/commands/self-host.js +88 -270
- package/dist/commands/self-host.js.map +1 -1
- package/dist/commands/site.d.ts +42 -0
- package/dist/commands/site.d.ts.map +1 -0
- package/dist/commands/site.js +100 -0
- package/dist/commands/site.js.map +1 -0
- package/dist/commands/sso.d.ts +13 -3
- package/dist/commands/sso.d.ts.map +1 -1
- package/dist/commands/sso.js +58 -16
- package/dist/commands/sso.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +161 -68
- package/dist/commands/update.js.map +1 -1
- package/dist/compose-auth-settings.d.ts +12 -0
- package/dist/compose-auth-settings.d.ts.map +1 -0
- package/dist/compose-auth-settings.js +39 -0
- package/dist/compose-auth-settings.js.map +1 -0
- package/dist/compose-db-roles.d.ts.map +1 -1
- package/dist/compose-db-roles.js +6 -0
- package/dist/compose-db-roles.js.map +1 -1
- package/dist/compose-kong.d.ts +5 -1
- package/dist/compose-kong.d.ts.map +1 -1
- package/dist/compose-kong.js +8 -4
- package/dist/compose-kong.js.map +1 -1
- package/dist/compose-rename.d.ts.map +1 -1
- package/dist/compose-rename.js +5 -0
- package/dist/compose-rename.js.map +1 -1
- package/dist/compose-render-mode.d.ts +8 -3
- package/dist/compose-render-mode.d.ts.map +1 -1
- package/dist/compose-render-mode.js +22 -13
- package/dist/compose-render-mode.js.map +1 -1
- package/dist/compose-services.d.ts.map +1 -1
- package/dist/compose-services.js +3 -2
- package/dist/compose-services.js.map +1 -1
- package/dist/config-mailer-env.d.ts +6 -2
- package/dist/config-mailer-env.d.ts.map +1 -1
- package/dist/config-mailer-env.js +11 -13
- package/dist/config-mailer-env.js.map +1 -1
- package/dist/config-version-pin.d.ts +42 -0
- package/dist/config-version-pin.d.ts.map +1 -0
- package/dist/config-version-pin.js +64 -0
- package/dist/config-version-pin.js.map +1 -0
- package/dist/config.d.ts +5 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -2
- package/dist/config.js.map +1 -1
- package/dist/cors-origins-push.d.ts +16 -0
- package/dist/cors-origins-push.d.ts.map +1 -0
- package/dist/cors-origins-push.js +37 -0
- package/dist/cors-origins-push.js.map +1 -0
- package/dist/database-url-owner.d.ts.map +1 -1
- package/dist/database-url-owner.js +2 -1
- package/dist/database-url-owner.js.map +1 -1
- package/dist/db-port.d.ts +3 -1
- package/dist/db-port.d.ts.map +1 -1
- package/dist/db-port.js +1 -1
- package/dist/db-port.js.map +1 -1
- package/dist/destructive-consent.d.ts.map +1 -1
- package/dist/destructive-consent.js +23 -1
- package/dist/destructive-consent.js.map +1 -1
- package/dist/dev-compose.d.ts +9 -4
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +112 -71
- package/dist/dev-compose.js.map +1 -1
- package/dist/dev-functions-watch.d.ts +25 -4
- package/dist/dev-functions-watch.d.ts.map +1 -1
- package/dist/dev-functions-watch.js +78 -13
- package/dist/dev-functions-watch.js.map +1 -1
- package/dist/dev-initial-push.d.ts.map +1 -1
- package/dist/dev-initial-push.js +6 -0
- package/dist/dev-initial-push.js.map +1 -1
- package/dist/dev-ports.d.ts +7 -2
- package/dist/dev-ports.d.ts.map +1 -1
- package/dist/dev-ports.js +44 -22
- package/dist/dev-ports.js.map +1 -1
- package/dist/dev-ready-panel.d.ts +26 -3
- package/dist/dev-ready-panel.d.ts.map +1 -1
- package/dist/dev-ready-panel.js +37 -5
- package/dist/dev-ready-panel.js.map +1 -1
- package/dist/dev-schema-watch.d.ts +6 -0
- package/dist/dev-schema-watch.d.ts.map +1 -1
- package/dist/dev-schema-watch.js +9 -0
- package/dist/dev-schema-watch.js.map +1 -1
- package/dist/dev-self-start.d.ts +16 -0
- package/dist/dev-self-start.d.ts.map +1 -0
- package/dist/dev-self-start.js +31 -0
- package/dist/dev-self-start.js.map +1 -0
- package/dist/dev-session-lock.d.ts +71 -2
- package/dist/dev-session-lock.d.ts.map +1 -1
- package/dist/dev-session-lock.js +105 -5
- package/dist/dev-session-lock.js.map +1 -1
- package/dist/dev-session.d.ts +6 -1
- package/dist/dev-session.d.ts.map +1 -1
- package/dist/dev-session.js +9 -3
- package/dist/dev-session.js.map +1 -1
- package/dist/dev-shutdown.d.ts +11 -2
- package/dist/dev-shutdown.d.ts.map +1 -1
- package/dist/dev-shutdown.js +23 -9
- package/dist/dev-shutdown.js.map +1 -1
- package/dist/diff-access.d.ts.map +1 -1
- package/dist/diff-access.js +17 -1
- package/dist/diff-access.js.map +1 -1
- package/dist/diff-channels.d.ts +14 -0
- package/dist/diff-channels.d.ts.map +1 -0
- package/dist/diff-channels.js +38 -0
- package/dist/diff-channels.js.map +1 -0
- package/dist/docker-exec.d.ts +25 -4
- package/dist/docker-exec.d.ts.map +1 -1
- package/dist/docker-exec.js +88 -8
- package/dist/docker-exec.js.map +1 -1
- package/dist/docker-postgres.d.ts +11 -0
- package/dist/docker-postgres.d.ts.map +1 -1
- package/dist/docker-postgres.js +9 -1
- package/dist/docker-postgres.js.map +1 -1
- package/dist/docker-runtime.d.ts +31 -7
- package/dist/docker-runtime.d.ts.map +1 -1
- package/dist/docker-runtime.js +104 -36
- package/dist/docker-runtime.js.map +1 -1
- package/dist/engine-answers.d.ts.map +1 -1
- package/dist/engine-answers.js +2 -1
- package/dist/engine-answers.js.map +1 -1
- package/dist/engine-client.d.ts +28 -0
- package/dist/engine-client.d.ts.map +1 -1
- package/dist/engine-client.js +4 -4
- package/dist/engine-client.js.map +1 -1
- package/dist/engine-columns.d.ts +26 -0
- package/dist/engine-columns.d.ts.map +1 -0
- package/dist/engine-columns.js +67 -0
- package/dist/engine-columns.js.map +1 -0
- package/dist/engine-floor.d.ts +35 -0
- package/dist/engine-floor.d.ts.map +1 -1
- package/dist/engine-floor.js +67 -0
- package/dist/engine-floor.js.map +1 -1
- package/dist/engine-ownership-gate.d.ts +11 -1
- package/dist/engine-ownership-gate.d.ts.map +1 -1
- package/dist/engine-ownership-gate.js +32 -0
- package/dist/engine-ownership-gate.js.map +1 -1
- package/dist/engine-push-output.d.ts +12 -4
- package/dist/engine-push-output.d.ts.map +1 -1
- package/dist/engine-push-output.js.map +1 -1
- package/dist/env-file.d.ts +36 -3
- package/dist/env-file.d.ts.map +1 -1
- package/dist/env-file.js +82 -11
- package/dist/env-file.js.map +1 -1
- package/dist/env-lines.d.ts +5 -2
- package/dist/env-lines.d.ts.map +1 -1
- package/dist/env-lines.js +18 -3
- package/dist/env-lines.js.map +1 -1
- package/dist/env-managed-record.d.ts +20 -0
- package/dist/env-managed-record.d.ts.map +1 -0
- package/dist/env-managed-record.js +56 -0
- package/dist/env-managed-record.js.map +1 -0
- package/dist/error-message.d.ts.map +1 -1
- package/dist/error-message.js +7 -3
- package/dist/error-message.js.map +1 -1
- package/dist/frontend-env.d.ts +3 -2
- package/dist/frontend-env.d.ts.map +1 -1
- package/dist/frontend-env.js +4 -5
- package/dist/frontend-env.js.map +1 -1
- package/dist/frontend-values-linked.d.ts +3 -0
- package/dist/frontend-values-linked.d.ts.map +1 -1
- package/dist/frontend-values-linked.js +3 -2
- package/dist/frontend-values-linked.js.map +1 -1
- package/dist/frontend-values.d.ts +2 -1
- package/dist/frontend-values.d.ts.map +1 -1
- package/dist/frontend-values.js +2 -1
- package/dist/frontend-values.js.map +1 -1
- package/dist/functions-context-refresh.d.ts.map +1 -1
- package/dist/functions-context-refresh.js +5 -2
- package/dist/functions-context-refresh.js.map +1 -1
- package/dist/functions-deno-types.d.ts +6 -0
- package/dist/functions-deno-types.d.ts.map +1 -1
- package/dist/functions-deno-types.js +43 -35
- package/dist/functions-deno-types.js.map +1 -1
- package/dist/functions-env-local.d.ts +7 -2
- package/dist/functions-env-local.d.ts.map +1 -1
- package/dist/functions-env-local.js +8 -3
- package/dist/functions-env-local.js.map +1 -1
- package/dist/functions-worker-files.d.ts.map +1 -1
- package/dist/functions-worker-files.js +2 -13
- package/dist/functions-worker-files.js.map +1 -1
- package/dist/generated/functions-worker-source.d.ts.map +1 -1
- package/dist/generated/functions-worker-source.js +6 -3
- package/dist/generated/functions-worker-source.js.map +1 -1
- package/dist/generated/release-images.d.ts +6 -6
- package/dist/generated/release-images.js +3 -3
- package/dist/generated-files-engine.d.ts +9 -0
- package/dist/generated-files-engine.d.ts.map +1 -1
- package/dist/generated-files-engine.js +23 -0
- package/dist/generated-files-engine.js.map +1 -1
- package/dist/gitignore.d.ts +29 -2
- package/dist/gitignore.d.ts.map +1 -1
- package/dist/gitignore.js +86 -21
- package/dist/gitignore.js.map +1 -1
- package/dist/hooks-generator.d.ts.map +1 -1
- package/dist/hooks-generator.js +32 -10
- package/dist/hooks-generator.js.map +1 -1
- package/dist/hooks-worker-reload.d.ts +18 -0
- package/dist/hooks-worker-reload.d.ts.map +1 -0
- package/dist/hooks-worker-reload.js +19 -0
- package/dist/hooks-worker-reload.js.map +1 -0
- package/dist/host-database.d.ts +6 -2
- package/dist/host-database.d.ts.map +1 -1
- package/dist/host-database.js +10 -2
- package/dist/host-database.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/init-dependency-versions.d.ts +2 -3
- package/dist/init-dependency-versions.d.ts.map +1 -1
- package/dist/init-dependency-versions.js +12 -9
- package/dist/init-dependency-versions.js.map +1 -1
- package/dist/init-example.d.ts.map +1 -1
- package/dist/init-example.js +13 -1
- package/dist/init-example.js.map +1 -1
- package/dist/init-expo-runtime-env.d.ts +25 -0
- package/dist/init-expo-runtime-env.d.ts.map +1 -0
- package/dist/init-expo-runtime-env.js +112 -0
- package/dist/init-expo-runtime-env.js.map +1 -0
- package/dist/init-next-runtime-env.d.ts +14 -1
- package/dist/init-next-runtime-env.d.ts.map +1 -1
- package/dist/init-next-runtime-env.js +116 -35
- package/dist/init-next-runtime-env.js.map +1 -1
- package/dist/init-package-json.d.ts +12 -3
- package/dist/init-package-json.d.ts.map +1 -1
- package/dist/init-package-json.js +35 -15
- package/dist/init-package-json.js.map +1 -1
- package/dist/init-port-registry.d.ts +19 -0
- package/dist/init-port-registry.d.ts.map +1 -0
- package/dist/init-port-registry.js +57 -0
- package/dist/init-port-registry.js.map +1 -0
- package/dist/init-project-detect.d.ts +20 -0
- package/dist/init-project-detect.d.ts.map +1 -1
- package/dist/init-project-detect.js +41 -8
- package/dist/init-project-detect.js.map +1 -1
- package/dist/init-setup-steps.d.ts +32 -4
- package/dist/init-setup-steps.d.ts.map +1 -1
- package/dist/init-setup-steps.js +114 -18
- package/dist/init-setup-steps.js.map +1 -1
- package/dist/init-vite-node.d.ts +21 -0
- package/dist/init-vite-node.d.ts.map +1 -0
- package/dist/init-vite-node.js +75 -0
- package/dist/init-vite-node.js.map +1 -0
- package/dist/jsx-first-child.d.ts +18 -0
- package/dist/jsx-first-child.d.ts.map +1 -0
- package/dist/jsx-first-child.js +53 -0
- package/dist/jsx-first-child.js.map +1 -0
- package/dist/keyspace-password-file.d.ts +46 -0
- package/dist/keyspace-password-file.d.ts.map +1 -0
- package/dist/keyspace-password-file.js +128 -0
- package/dist/keyspace-password-file.js.map +1 -0
- package/dist/keyspace-port.d.ts +14 -0
- package/dist/keyspace-port.d.ts.map +1 -0
- package/dist/keyspace-port.js +35 -0
- package/dist/keyspace-port.js.map +1 -0
- package/dist/kong-config.d.ts +6 -0
- package/dist/kong-config.d.ts.map +1 -1
- package/dist/kong-config.js +119 -20
- package/dist/kong-config.js.map +1 -1
- package/dist/link.d.ts +30 -0
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +70 -16
- package/dist/link.js.map +1 -1
- package/dist/local-gateway.d.ts +11 -3
- package/dist/local-gateway.d.ts.map +1 -1
- package/dist/local-gateway.js +16 -7
- package/dist/local-gateway.js.map +1 -1
- package/dist/local-secrets.d.ts +22 -0
- package/dist/local-secrets.d.ts.map +1 -1
- package/dist/local-secrets.js +29 -0
- package/dist/local-secrets.js.map +1 -1
- package/dist/local-stack-guard.d.ts +8 -0
- package/dist/local-stack-guard.d.ts.map +1 -1
- package/dist/local-stack-guard.js +44 -3
- package/dist/local-stack-guard.js.map +1 -1
- package/dist/local-stack.d.ts +2 -0
- package/dist/local-stack.d.ts.map +1 -1
- package/dist/local-stack.js +14 -8
- package/dist/local-stack.js.map +1 -1
- package/dist/local-storage.d.ts +3 -5
- package/dist/local-storage.d.ts.map +1 -1
- package/dist/local-storage.js +10 -10
- package/dist/local-storage.js.map +1 -1
- package/dist/mailer-autoconfirm.d.ts +29 -24
- package/dist/mailer-autoconfirm.d.ts.map +1 -1
- package/dist/mailer-autoconfirm.js +47 -43
- package/dist/mailer-autoconfirm.js.map +1 -1
- package/dist/mailer-env.d.ts +8 -1
- package/dist/mailer-env.d.ts.map +1 -1
- package/dist/mailer-env.js +52 -8
- package/dist/mailer-env.js.map +1 -1
- package/dist/model-hooks.d.ts +6 -4
- package/dist/model-hooks.d.ts.map +1 -1
- package/dist/model-hooks.js +14 -8
- package/dist/model-hooks.js.map +1 -1
- package/dist/model-versioning.d.ts +6 -0
- package/dist/model-versioning.d.ts.map +1 -1
- package/dist/model-versioning.js +12 -0
- package/dist/model-versioning.js.map +1 -1
- package/dist/native-dev-env.d.ts +38 -3
- package/dist/native-dev-env.d.ts.map +1 -1
- package/dist/native-dev-env.js +98 -7
- package/dist/native-dev-env.js.map +1 -1
- package/dist/native-keyspace.d.ts +31 -6
- package/dist/native-keyspace.d.ts.map +1 -1
- package/dist/native-keyspace.js +70 -20
- package/dist/native-keyspace.js.map +1 -1
- package/dist/native-leftover-postgres.d.ts +23 -0
- package/dist/native-leftover-postgres.d.ts.map +1 -0
- package/dist/native-leftover-postgres.js +55 -0
- package/dist/native-leftover-postgres.js.map +1 -0
- package/dist/native-leftover-services.d.ts +17 -0
- package/dist/native-leftover-services.d.ts.map +1 -0
- package/dist/native-leftover-services.js +93 -0
- package/dist/native-leftover-services.js.map +1 -0
- package/dist/native-pg-auth.d.ts.map +1 -1
- package/dist/native-pg-auth.js +2 -1
- package/dist/native-pg-auth.js.map +1 -1
- package/dist/native-port-lock.d.ts +37 -0
- package/dist/native-port-lock.d.ts.map +1 -0
- package/dist/native-port-lock.js +78 -0
- package/dist/native-port-lock.js.map +1 -0
- package/dist/native-realtime.d.ts +6 -3
- package/dist/native-realtime.d.ts.map +1 -1
- package/dist/native-realtime.js +65 -24
- package/dist/native-realtime.js.map +1 -1
- package/dist/native-roles-sql.d.ts.map +1 -1
- package/dist/native-roles-sql.js +2 -1
- package/dist/native-roles-sql.js.map +1 -1
- package/dist/native-stale-session.d.ts +17 -0
- package/dist/native-stale-session.d.ts.map +1 -0
- package/dist/native-stale-session.js +42 -0
- package/dist/native-stale-session.js.map +1 -0
- package/dist/native-storage-import.d.ts.map +1 -1
- package/dist/native-storage-import.js +6 -5
- package/dist/native-storage-import.js.map +1 -1
- package/dist/native-storage.d.ts +42 -7
- package/dist/native-storage.d.ts.map +1 -1
- package/dist/native-storage.js +196 -50
- package/dist/native-storage.js.map +1 -1
- package/dist/native-worker.d.ts +15 -0
- package/dist/native-worker.d.ts.map +1 -1
- package/dist/native-worker.js +26 -0
- package/dist/native-worker.js.map +1 -1
- package/dist/open-browser.d.ts +7 -0
- package/dist/open-browser.d.ts.map +1 -0
- package/dist/open-browser.js +26 -0
- package/dist/open-browser.js.map +1 -0
- package/dist/parent-watch.d.ts.map +1 -1
- package/dist/parent-watch.js +4 -8
- package/dist/parent-watch.js.map +1 -1
- package/dist/personal-access-token.d.ts +7 -0
- package/dist/personal-access-token.d.ts.map +1 -0
- package/dist/personal-access-token.js +11 -0
- package/dist/personal-access-token.js.map +1 -0
- package/dist/plan-sql.d.ts +30 -0
- package/dist/plan-sql.d.ts.map +1 -0
- package/dist/plan-sql.js +65 -0
- package/dist/plan-sql.js.map +1 -0
- package/dist/platform-settings-push.d.ts +15 -0
- package/dist/platform-settings-push.d.ts.map +1 -0
- package/dist/platform-settings-push.js +100 -0
- package/dist/platform-settings-push.js.map +1 -0
- package/dist/platform-settings.d.ts +81 -0
- package/dist/platform-settings.d.ts.map +1 -0
- package/dist/platform-settings.js +164 -0
- package/dist/platform-settings.js.map +1 -0
- package/dist/postgres-ctl.d.ts +45 -5
- package/dist/postgres-ctl.d.ts.map +1 -1
- package/dist/postgres-ctl.js +59 -21
- package/dist/postgres-ctl.js.map +1 -1
- package/dist/postgres-image.d.ts +27 -2
- package/dist/postgres-image.d.ts.map +1 -1
- package/dist/postgres-image.js +58 -13
- package/dist/postgres-image.js.map +1 -1
- package/dist/postgrest-release.d.ts +1 -1
- package/dist/postgrest-release.d.ts.map +1 -1
- package/dist/postgrest-release.js +3 -1
- package/dist/postgrest-release.js.map +1 -1
- package/dist/process-info.d.ts +14 -0
- package/dist/process-info.d.ts.map +1 -0
- package/dist/process-info.js +41 -0
- package/dist/process-info.js.map +1 -0
- package/dist/process-manager.d.ts +78 -4
- package/dist/process-manager.d.ts.map +1 -1
- package/dist/process-manager.js +128 -46
- package/dist/process-manager.js.map +1 -1
- package/dist/process-tree.d.ts +48 -0
- package/dist/process-tree.d.ts.map +1 -0
- package/dist/process-tree.js +141 -0
- package/dist/process-tree.js.map +1 -0
- package/dist/project-config.d.ts +121 -10
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +62 -1
- package/dist/project-config.js.map +1 -1
- package/dist/release-images.d.ts +21 -0
- package/dist/release-images.d.ts.map +1 -1
- package/dist/release-images.js +24 -0
- package/dist/release-images.js.map +1 -1
- package/dist/required-host-components.d.ts.map +1 -1
- package/dist/required-host-components.js +3 -5
- package/dist/required-host-components.js.map +1 -1
- package/dist/resolve-target.d.ts +42 -2
- package/dist/resolve-target.d.ts.map +1 -1
- package/dist/resolve-target.js +115 -21
- package/dist/resolve-target.js.map +1 -1
- package/dist/rest-cache-admin.d.ts +13 -0
- package/dist/rest-cache-admin.d.ts.map +1 -1
- package/dist/rest-cache-admin.js +36 -1
- package/dist/rest-cache-admin.js.map +1 -1
- package/dist/rest-ready.d.ts +6 -0
- package/dist/rest-ready.d.ts.map +1 -1
- package/dist/rest-ready.js +18 -2
- package/dist/rest-ready.js.map +1 -1
- package/dist/route-manifest.d.ts +24 -0
- package/dist/route-manifest.d.ts.map +1 -1
- package/dist/route-manifest.js +60 -2
- package/dist/route-manifest.js.map +1 -1
- package/dist/run-captured.d.ts +3 -1
- package/dist/run-captured.d.ts.map +1 -1
- package/dist/run-captured.js.map +1 -1
- package/dist/run-until-stopped.d.ts +3 -0
- package/dist/run-until-stopped.d.ts.map +1 -1
- package/dist/run-until-stopped.js +25 -11
- package/dist/run-until-stopped.js.map +1 -1
- package/dist/runtime-routes.d.ts +5 -0
- package/dist/runtime-routes.d.ts.map +1 -1
- package/dist/runtime-routes.js +10 -5
- package/dist/runtime-routes.js.map +1 -1
- package/dist/schema-ast-v2.d.ts +38 -0
- package/dist/schema-ast-v2.d.ts.map +1 -1
- package/dist/schema-ast-v2.js +2 -0
- package/dist/schema-ast-v2.js.map +1 -1
- package/dist/schema-reset.d.ts.map +1 -1
- package/dist/schema-reset.js +2 -0
- package/dist/schema-reset.js.map +1 -1
- package/dist/secret-sql.d.ts +13 -0
- package/dist/secret-sql.d.ts.map +1 -0
- package/dist/secret-sql.js +13 -0
- package/dist/secret-sql.js.map +1 -0
- package/dist/seed-default-export.d.ts +12 -0
- package/dist/seed-default-export.d.ts.map +1 -0
- package/dist/seed-default-export.js +44 -0
- package/dist/seed-default-export.js.map +1 -0
- package/dist/seed-ir.d.ts +8 -1
- package/dist/seed-ir.d.ts.map +1 -1
- package/dist/seed-ir.js +92 -6
- package/dist/seed-ir.js.map +1 -1
- package/dist/seed-prepare.d.ts +60 -0
- package/dist/seed-prepare.d.ts.map +1 -0
- package/dist/seed-prepare.js +115 -0
- package/dist/seed-prepare.js.map +1 -0
- package/dist/seed-remote.d.ts +22 -0
- package/dist/seed-remote.d.ts.map +1 -0
- package/dist/seed-remote.js +203 -0
- package/dist/seed-remote.js.map +1 -0
- package/dist/seed-report.d.ts +65 -0
- package/dist/seed-report.d.ts.map +1 -0
- package/dist/seed-report.js +98 -0
- package/dist/seed-report.js.map +1 -0
- package/dist/seed.d.ts +15 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/self-host-compose.d.ts +21 -1
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +349 -78
- package/dist/self-host-compose.js.map +1 -1
- package/dist/site-build-env.d.ts +31 -0
- package/dist/site-build-env.d.ts.map +1 -0
- package/dist/site-build-env.js +29 -0
- package/dist/site-build-env.js.map +1 -0
- package/dist/site-deploy.d.ts +52 -0
- package/dist/site-deploy.d.ts.map +1 -0
- package/dist/site-deploy.js +230 -0
- package/dist/site-deploy.js.map +1 -0
- package/dist/site-public-env.d.ts +67 -0
- package/dist/site-public-env.d.ts.map +1 -0
- package/dist/site-public-env.js +124 -0
- package/dist/site-public-env.js.map +1 -0
- package/dist/sso-admin.d.ts +15 -0
- package/dist/sso-admin.d.ts.map +1 -1
- package/dist/sso-admin.js +32 -9
- package/dist/sso-admin.js.map +1 -1
- package/dist/stack-exit-watch.d.ts +15 -0
- package/dist/stack-exit-watch.d.ts.map +1 -1
- package/dist/stack-exit-watch.js +41 -13
- package/dist/stack-exit-watch.js.map +1 -1
- package/dist/stack-folder.d.ts +28 -0
- package/dist/stack-folder.d.ts.map +1 -0
- package/dist/stack-folder.js +123 -0
- package/dist/stack-folder.js.map +1 -0
- package/dist/stack-running.d.ts +13 -0
- package/dist/stack-running.d.ts.map +1 -0
- package/dist/stack-running.js +44 -0
- package/dist/stack-running.js.map +1 -0
- package/dist/stack-setting-warnings.d.ts +8 -1
- package/dist/stack-setting-warnings.d.ts.map +1 -1
- package/dist/stack-setting-warnings.js +21 -1
- package/dist/stack-setting-warnings.js.map +1 -1
- package/dist/storage-provision.d.ts +12 -2
- package/dist/storage-provision.d.ts.map +1 -1
- package/dist/storage-provision.js +36 -11
- package/dist/storage-provision.js.map +1 -1
- package/dist/studio-admin-roles.d.ts +4 -4
- package/dist/studio-admin-roles.d.ts.map +1 -1
- package/dist/studio-admin-roles.js +6 -4
- package/dist/studio-admin-roles.js.map +1 -1
- package/dist/target-client.d.ts +13 -1
- package/dist/target-client.d.ts.map +1 -1
- package/dist/target-client.js +83 -17
- package/dist/target-client.js.map +1 -1
- package/dist/target-request.d.ts +5 -0
- package/dist/target-request.d.ts.map +1 -1
- package/dist/target-request.js +11 -2
- package/dist/target-request.js.map +1 -1
- package/dist/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +102 -10
- package/dist/type-extractor.js.map +1 -1
- package/dist/ui/clack-api.d.ts +2 -1
- package/dist/ui/clack-api.d.ts.map +1 -1
- package/dist/ui/clack-api.js +4 -4
- package/dist/ui/clack-api.js.map +1 -1
- package/dist/ui/clack.d.ts.map +1 -1
- package/dist/ui/clack.js +5 -2
- package/dist/ui/clack.js.map +1 -1
- package/dist/ui/dev/DevReadyPanelView.js +1 -1
- package/dist/ui/dev/DevReadyPanelView.js.map +1 -1
- package/dist/valkey-sidecar.d.ts +34 -13
- package/dist/valkey-sidecar.d.ts.map +1 -1
- package/dist/valkey-sidecar.js +65 -39
- package/dist/valkey-sidecar.js.map +1 -1
- package/dist/windows-processes.d.ts +7 -0
- package/dist/windows-processes.d.ts.map +1 -0
- package/dist/windows-processes.js +31 -0
- package/dist/windows-processes.js.map +1 -0
- package/dist/write-if-changed.d.ts +12 -0
- package/dist/write-if-changed.d.ts.map +1 -0
- package/dist/write-if-changed.js +32 -0
- package/dist/write-if-changed.js.map +1 -0
- package/package.json +7 -5
- package/releases/deno/VERSION +1 -1
- package/dist/commands/deploy-types.d.ts +0 -14
- package/dist/commands/deploy-types.d.ts.map +0 -1
- package/dist/commands/deploy-types.js +0 -38
- package/dist/commands/deploy-types.js.map +0 -1
- package/dist/systemd.d.ts +0 -26
- package/dist/systemd.d.ts.map +0 -1
- package/dist/systemd.js +0 -117
- package/dist/systemd.js.map +0 -1
package/dist/commands/init.js
CHANGED
|
@@ -3,13 +3,15 @@ import { resolve, join, basename } from "node:path";
|
|
|
3
3
|
import { randomBytes } from "node:crypto";
|
|
4
4
|
import { p, runClackFlow } from "../ui/clack.js";
|
|
5
5
|
import { withProgressView } from "../ui/progress.js";
|
|
6
|
-
import { installCommand, installDependencies, plainStepView, runTimedStep, spinnerStepView, } from "../init-setup-steps.js";
|
|
6
|
+
import { describeInstallFailure, installCommand, installDependencies, plainStepView, runTimedStep, spinnerStepView, } from "../init-setup-steps.js";
|
|
7
|
+
import { devBuildInitNote } from "../release-images.js";
|
|
7
8
|
import { ensureNotCancelled } from "../ui/prompts.js";
|
|
8
9
|
import { adminEmailProblem, answerProblem, askText, smtpHostProblem, smtpPortProblem } from "../init-answers.js";
|
|
9
10
|
import { assertEnvValues } from "../env-value.js";
|
|
10
11
|
import { ensureFunctionsEnvLocal, FUNCTIONS_ENV_LOCAL } from "../functions-env-local.js";
|
|
11
12
|
import { generateAndWriteKeys } from "./keys.js";
|
|
12
|
-
import { BUNDLED_DB_USER, CONTROL_PLANE_SECRET_ENV, generateControlPlaneSecret, generateObjectStoreCredentials, givenJwtSecret, newJwtSecret, OBJECT_STORE_ACCESS_KEY_ENV, OBJECT_STORE_SECRET_KEY_ENV, } from "../local-secrets.js";
|
|
13
|
+
import { BUNDLED_DB_USER, CONTROL_PLANE_SECRET_ENV, FORWARDING_SECRET_ENV, generateControlPlaneSecret, generateObjectStoreCredentials, givenJwtSecret, KEYSPACE_PASSWORD_ENV, KEYSPACE_USERNAME, newJwtSecret, OBJECT_STORE_ACCESS_KEY_ENV, OBJECT_STORE_SECRET_KEY_ENV, } from "../local-secrets.js";
|
|
14
|
+
import { KEYSPACE_PASSWORD_FILE_ENV, shellNamesKeyspacePasswordFile } from "../keyspace-password-file.js";
|
|
13
15
|
import { file, error, info, plain, warn } from "../ui/messages.js";
|
|
14
16
|
import { nextSteps } from "../ui/next-steps.js";
|
|
15
17
|
import { probeDockerDaemonAsync, reportDockerUnavailable } from "../docker-runtime.js";
|
|
@@ -17,19 +19,26 @@ import { loadConfig } from "../config.js";
|
|
|
17
19
|
import { ensureComponentBinaries, reportComponentBinaryFailures, } from "../ensure-component-binaries.js";
|
|
18
20
|
import { ensureFunctionsDenoTypes, sharedFunctionsReadmeSource, } from "../functions-deno-types.js";
|
|
19
21
|
import { functionTemplateSource } from "../functions-template.js";
|
|
20
|
-
import { mergeSupatypePackageJson, PREPARE_COMMAND, scaffoldPackageJson,
|
|
22
|
+
import { mergeSupatypePackageJson, mergeSupatypeScripts, PREPARE_COMMAND, scaffoldPackageJson, } from "../init-package-json.js";
|
|
23
|
+
import { runsSupatypeDev } from "../dev-self-start.js";
|
|
24
|
+
import { DEFAULT_PROXY_DEV_SCRIPT } from "../app/proxy-dev-app.js";
|
|
25
|
+
import { DEV_APP_HOST_ENV } from "../app/vite-dev-args.js";
|
|
21
26
|
import { downloadRelease, initFromExample } from "../init-example.js";
|
|
22
27
|
import { errorMessage } from "../error-message.js";
|
|
23
28
|
import { isJsonObject, parseJsonObject } from "@supatype/shared";
|
|
24
29
|
import { cliPackageVersion } from "../cli-package-version.js";
|
|
25
30
|
import { initDependencyVersionsFallback, resolveInitDependencyVersions, } from "../init-dependency-versions.js";
|
|
26
|
-
import { detectProjectSetup } from "../init-project-detect.js";
|
|
27
|
-
import { SUPATYPE_GITIGNORE_PATHS } from "../gitignore.js";
|
|
31
|
+
import { detectProjectSetup, readPackageJson, VITE_CONFIG_NAMES, withFreeVitePort, } from "../init-project-detect.js";
|
|
32
|
+
import { missingSupatypeIgnores, negationOverrideNotice, SUPATYPE_GITIGNORE_PATHS, withSupatypeIgnores, } from "../gitignore.js";
|
|
28
33
|
import { DEV_FRONTEND_ENV_FILE, writeFrontendEnv } from "../frontend-env.js";
|
|
29
34
|
import { DEFAULT_CLIENT_PATH, DEFAULT_TYPES_PATH } from "../type-generation.js";
|
|
30
35
|
import { COMPOSE_DEV_KONG_PORT, defaultAppStaticDir, NATIVE_DB_PORT, NATIVE_SERVER_PORT, nativeDatabaseUrl, VITE_BUILD_DIR, } from "../project-config.js";
|
|
31
36
|
import { cliDatabaseUrlLines } from "../database-url-owner.js";
|
|
32
37
|
import { scaffoldNextRuntimeEnv } from "../init-next-runtime-env.js";
|
|
38
|
+
import { scaffoldExpoRuntimeEnv } from "../init-expo-runtime-env.js";
|
|
39
|
+
import { refuseAddingViteOnOldNode, refuseViteOnOldNode } from "../init-vite-node.js";
|
|
40
|
+
import { recordInitKongPort } from "../init-port-registry.js";
|
|
41
|
+
import { MAILER_AUTOCONFIRM_NOTE } from "../mailer-autoconfirm.js";
|
|
33
42
|
const STORAGE_PROVIDER_OPTIONS = [
|
|
34
43
|
{ value: "local", label: "Local", hint: "storage you host yourself (SeaweedFS)" },
|
|
35
44
|
{ value: "s3", label: "S3", hint: "external bucket (AWS S3 or compatible)" },
|
|
@@ -139,7 +148,12 @@ async function createProject(args) {
|
|
|
139
148
|
const wants = { install: opts.install !== false && result.install, keys: opts.keys !== false && result.generateKeys };
|
|
140
149
|
if (name)
|
|
141
150
|
mkdirSync(dir, { recursive: true });
|
|
142
|
-
|
|
151
|
+
const deps = await args.deps;
|
|
152
|
+
const devNote = devBuildInitNote(deps);
|
|
153
|
+
if (devNote !== undefined)
|
|
154
|
+
warn(devNote);
|
|
155
|
+
scaffold(dir, result, deps);
|
|
156
|
+
recordScaffoldedKongPort(dir, result);
|
|
143
157
|
const outcome = await withStepView((view) => runSetupSteps(dir, result.packageManager, wants, view));
|
|
144
158
|
exitOnFailedSetup(outcome, wants, result.packageManager);
|
|
145
159
|
await warnDockerUnavailableForProvider(result.provider, args.daemon);
|
|
@@ -149,15 +163,19 @@ async function createProject(args) {
|
|
|
149
163
|
installed: wants.install && outcome.installOk,
|
|
150
164
|
keysGenerated: outcome.keysGenerated,
|
|
151
165
|
binariesReady: outcome.binariesReady,
|
|
152
|
-
devScript: projectDevScript(dir),
|
|
153
166
|
});
|
|
154
167
|
}
|
|
155
168
|
/** `--no-admin`, or `--admin-email` with `--admin-password`, over the answers. */
|
|
156
|
-
function applyAdminFlags(result, opts) {
|
|
169
|
+
export function applyAdminFlags(result, opts) {
|
|
157
170
|
if (opts.admin === false) {
|
|
158
171
|
delete result.adminEmail;
|
|
159
172
|
delete result.adminPassword;
|
|
160
173
|
}
|
|
174
|
+
else if (Boolean(opts.adminEmail) !== Boolean(opts.adminPassword)) {
|
|
175
|
+
// An admin needs both. One alone used to write nothing and say nothing.
|
|
176
|
+
error(`${opts.adminEmail ? "--admin-email" : "--admin-password"} needs ${opts.adminEmail ? "--admin-password" : "--admin-email"} too. Give both, or neither and create the admin later.`);
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
161
179
|
else if (opts.adminEmail && opts.adminPassword) {
|
|
162
180
|
refuseAdminFlags(opts.adminEmail, opts.adminPassword);
|
|
163
181
|
result.adminEmail = opts.adminEmail.trim();
|
|
@@ -180,7 +198,7 @@ async function runInteractiveInit(args) {
|
|
|
180
198
|
const { name, dir, defaultName, modeTarget, opts } = args;
|
|
181
199
|
await runClackFlow(async () => {
|
|
182
200
|
p.intro("Create a new Supatype project");
|
|
183
|
-
const detected = detectProjectSetup(dir);
|
|
201
|
+
const detected = await withFreeVitePort(detectProjectSetup(dir));
|
|
184
202
|
if (detected.hasExistingFiles && detected.summaryLines.length > 0) {
|
|
185
203
|
p.note(["Existing project detected:", ...detected.summaryLines.map((line) => ` • ${line}`)].join("\n"));
|
|
186
204
|
}
|
|
@@ -212,7 +230,7 @@ export async function collectWizardAnswers(context) {
|
|
|
212
230
|
message: "Where will this run in production?",
|
|
213
231
|
initialValue: defaultTarget,
|
|
214
232
|
options: [
|
|
215
|
-
{ value: "cloud", label: "Supatype Cloud", hint: "managed
|
|
233
|
+
{ value: "cloud", label: "Supatype Cloud", hint: "managed, closed beta: request access at supatype.com" },
|
|
216
234
|
{ value: "self-host", label: "Self-host", hint: "your own server with TLS" },
|
|
217
235
|
{ value: "later", label: "Decide later", hint: "local development only for now" },
|
|
218
236
|
],
|
|
@@ -250,8 +268,9 @@ export async function collectWizardAnswers(context) {
|
|
|
250
268
|
initialValue: "local",
|
|
251
269
|
options: STORAGE_PROVIDER_OPTIONS,
|
|
252
270
|
}));
|
|
253
|
-
//
|
|
254
|
-
|
|
271
|
+
// Not asked when there is no production to store for yet, nor on Supatype Cloud, which brings its
|
|
272
|
+
// own storage: an own bucket is set in the config later.
|
|
273
|
+
const storageProduction = productionTarget === "self-host" ? await promptProductionStorage() : storageLocal;
|
|
255
274
|
const helloFunction = ensureNotCancelled(await p.confirm({
|
|
256
275
|
message: "Create a hello-world edge function?",
|
|
257
276
|
initialValue: false,
|
|
@@ -340,27 +359,71 @@ async function promptApp(detected, productionTarget) {
|
|
|
340
359
|
: detected.hasVite
|
|
341
360
|
? "proxy"
|
|
342
361
|
: "none";
|
|
343
|
-
const
|
|
362
|
+
const choice = ensureNotCancelled(await p.select({
|
|
344
363
|
message: "Host a frontend app at /?",
|
|
345
364
|
initialValue: initialMode,
|
|
346
365
|
options: [
|
|
347
366
|
{ value: "none", label: "No app", hint: "API only" },
|
|
348
367
|
{ value: "static", label: "Static site", hint: "serve a built directory" },
|
|
349
368
|
{ value: "proxy", label: "Local dev server", hint: "forward requests to a dev server you run" },
|
|
369
|
+
{ value: "react", label: "React (Vite)", hint: "a React starter on Vite, with @supatype/react" },
|
|
350
370
|
],
|
|
351
371
|
}));
|
|
372
|
+
if (choice === "react")
|
|
373
|
+
return promptReactStarter(detected);
|
|
374
|
+
const mode = choice;
|
|
352
375
|
if (mode === "static") {
|
|
353
376
|
const viteDevUrl = await promptViteDevUrl(detected, productionTarget);
|
|
354
377
|
return { mode, staticDir: await promptStaticDir(detected, viteDevUrl !== undefined), ...(viteDevUrl ? { viteDevUrl } : {}) };
|
|
355
378
|
}
|
|
356
|
-
if (mode === "proxy")
|
|
357
|
-
|
|
358
|
-
const start = await askWithDefault("package.json script that starts your dev server", detected.hasVite ? "vite" : "dev");
|
|
359
|
-
const viteDevUrl = await promptViteDevUrl(detected, productionTarget);
|
|
360
|
-
return { mode, upstream, start, ...(viteDevUrl ? { viteDevUrl } : {}) };
|
|
361
|
-
}
|
|
379
|
+
if (mode === "proxy")
|
|
380
|
+
return promptDevServer(detected, productionTarget);
|
|
362
381
|
return { mode: "none" };
|
|
363
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* The React (Vite) starter: a Vite app served through the dev proxy, like "Local dev server" with Vite
|
|
385
|
+
* chosen, plus the React page, packages and Vite plugin. Vite is the point, so it is not asked.
|
|
386
|
+
*/
|
|
387
|
+
async function promptReactStarter(detected) {
|
|
388
|
+
if (!detected.declaresVite)
|
|
389
|
+
refuseAddingViteOnOldNode();
|
|
390
|
+
const viteDevUrl = await askWithDefault("Vite dev server URL", detected.viteDevUrl);
|
|
391
|
+
return { mode: "proxy", upstream: viteDevUrl, start: "vite", viteDevUrl, react: true };
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* The dev server "Local dev server" forwards to, with Vite asked first. The script was asked before
|
|
395
|
+
* Vite and offered `dev`, which in a new folder is init's own `supatype dev`, so dev ran itself as
|
|
396
|
+
* the app. A Vite app runs the `vite` script init adds, at Vite's URL. Any other app runs a script
|
|
397
|
+
* of the project's own: its `dev` or `start` is offered, but never one that runs `supatype dev`.
|
|
398
|
+
*/
|
|
399
|
+
async function promptDevServer(detected, productionTarget) {
|
|
400
|
+
const viteDevUrl = await promptViteDevUrl(detected, productionTarget);
|
|
401
|
+
if (viteDevUrl !== undefined)
|
|
402
|
+
return { mode: "proxy", upstream: viteDevUrl, start: "vite", viteDevUrl };
|
|
403
|
+
const upstream = await askWithDefault("URL of your running dev server", "http://localhost:3000");
|
|
404
|
+
const scripts = mergeSupatypeScripts(detected.packageScripts, { app: { mode: "proxy" }, helloFunction: false });
|
|
405
|
+
const offered = ["dev", DEFAULT_PROXY_DEV_SCRIPT].find((name) => {
|
|
406
|
+
const body = scripts[name];
|
|
407
|
+
return body !== undefined && !runsSupatypeDev(body);
|
|
408
|
+
});
|
|
409
|
+
const chosen = (answer) => answer.trim() || offered;
|
|
410
|
+
const start = chosen(await askText({
|
|
411
|
+
message: "package.json script that starts your dev server",
|
|
412
|
+
...(offered !== undefined && { defaultValue: offered, placeholder: offered }),
|
|
413
|
+
validate: (answer) => devServerScriptProblem(chosen(answer), scripts),
|
|
414
|
+
}));
|
|
415
|
+
return { mode: "proxy", upstream, ...(start !== undefined && { start }) };
|
|
416
|
+
}
|
|
417
|
+
/** Why `script` cannot start the app's dev server, or undefined when it can. */
|
|
418
|
+
function devServerScriptProblem(script, scripts) {
|
|
419
|
+
if (script === undefined)
|
|
420
|
+
return `Enter the package.json script that starts your dev server, like ${DEFAULT_PROXY_DEV_SCRIPT}.`;
|
|
421
|
+
const body = scripts[script];
|
|
422
|
+
if (body !== undefined && runsSupatypeDev(body)) {
|
|
423
|
+
return `"${script}" runs supatype dev, so dev would start itself. Enter the script that starts your frontend's dev server.`;
|
|
424
|
+
}
|
|
425
|
+
return undefined;
|
|
426
|
+
}
|
|
364
427
|
/**
|
|
365
428
|
* The directory a static site is served from, asked after Vite: it was asked before, so a new Vite
|
|
366
429
|
* project was offered ./public. A Vite project is offered its build output, ./dist; a site with no
|
|
@@ -385,6 +448,10 @@ async function promptViteDevUrl(detected, productionTarget) {
|
|
|
385
448
|
}));
|
|
386
449
|
if (!useVite)
|
|
387
450
|
return undefined;
|
|
451
|
+
// Refused here on an old Node, not after every other question (pm N2). An app that lists its
|
|
452
|
+
// own Vite keeps it, so its Node is its own business.
|
|
453
|
+
if (!detected.declaresVite)
|
|
454
|
+
refuseAddingViteOnOldNode();
|
|
388
455
|
return askWithDefault("Vite dev server URL", detected.viteDevUrl);
|
|
389
456
|
}
|
|
390
457
|
// ─── Package manager ───────────────────────────────────────────────────────--
|
|
@@ -407,7 +474,11 @@ async function withStepView(run) {
|
|
|
407
474
|
}
|
|
408
475
|
/** Install, then keys, then the component binaries an install makes possible, each timed on `view`. */
|
|
409
476
|
async function runSetupSteps(dir, pm, wants, view) {
|
|
410
|
-
|
|
477
|
+
let installFailure;
|
|
478
|
+
const installOk = wants.install &&
|
|
479
|
+
(await runTimedStep(view, installStep(dir, pm, view.live, (failure) => {
|
|
480
|
+
installFailure = failure;
|
|
481
|
+
})));
|
|
411
482
|
const keysGenerated = wants.keys &&
|
|
412
483
|
(await runTimedStep(view, {
|
|
413
484
|
label: "Generating API keys",
|
|
@@ -420,20 +491,30 @@ async function runSetupSteps(dir, pm, wants, view) {
|
|
|
420
491
|
run: () => ensureInitBinaries(dir),
|
|
421
492
|
done: (ok) => (ok ? "Component binaries ready" : "Some binaries are missing"),
|
|
422
493
|
}));
|
|
423
|
-
return { installOk, keysGenerated, binariesReady };
|
|
494
|
+
return { installOk, ...(installFailure !== undefined && { installFailure }), keysGenerated, binariesReady };
|
|
424
495
|
}
|
|
425
496
|
/** The install step: in a terminal its output is read for the spinner, otherwise it passes through. */
|
|
426
|
-
function installStep(dir, pm, live) {
|
|
497
|
+
function installStep(dir, pm, live, onFailure) {
|
|
498
|
+
let script;
|
|
427
499
|
return {
|
|
428
500
|
label: `Installing dependencies with ${pm}`,
|
|
429
|
-
run: (detail) =>
|
|
430
|
-
|
|
501
|
+
run: async (detail) => {
|
|
502
|
+
const result = await installDependencies(dir, installCommand(pm), live ? detail : undefined);
|
|
503
|
+
if (!result.ok) {
|
|
504
|
+
script = result.failure.script;
|
|
505
|
+
onFailure(result.failure);
|
|
506
|
+
}
|
|
507
|
+
return result.ok;
|
|
508
|
+
},
|
|
509
|
+
done: (ok) => (ok ? "Dependencies installed" : `Dependency install failed${script === undefined ? "" : ` in the "${script}" script`}`),
|
|
431
510
|
};
|
|
432
511
|
}
|
|
433
512
|
/** Stop init, naming what to run, when a setup step it was asked for failed. */
|
|
434
513
|
function exitOnFailedSetup(outcome, wants, pm) {
|
|
435
514
|
if (wants.install && !outcome.installOk) {
|
|
436
|
-
error(
|
|
515
|
+
error(outcome.installFailure === undefined
|
|
516
|
+
? `Dependency install failed. Run "${pm} install" in the project directory, then "supatype update".`
|
|
517
|
+
: describeInstallFailure(pm, outcome.installFailure));
|
|
437
518
|
process.exit(1);
|
|
438
519
|
}
|
|
439
520
|
if (wants.keys && !outcome.keysGenerated) {
|
|
@@ -496,6 +577,7 @@ export function scaffold(dir, optsOrName, deps = initDependencyVersionsFallback(
|
|
|
496
577
|
};
|
|
497
578
|
// First, so a value .env cannot hold is refused before any file is written.
|
|
498
579
|
const env = envTemplate(opts);
|
|
580
|
+
refuseViteOnOldNode(dir, opts.app.viteDevUrl);
|
|
499
581
|
const pkgPath = join(dir, "package.json");
|
|
500
582
|
if (!existsSync(pkgPath)) {
|
|
501
583
|
write("package.json", scaffoldPackageJson(opts, deps));
|
|
@@ -509,6 +591,9 @@ export function scaffold(dir, optsOrName, deps = initDependencyVersionsFallback(
|
|
|
509
591
|
}
|
|
510
592
|
write(opts.schemaPath, schemaTemplate());
|
|
511
593
|
write(".env", env);
|
|
594
|
+
if (opts.email === "smtp" && opts.adminEmail) {
|
|
595
|
+
info(`SUPATYPE_SMTP_ADMIN_EMAIL in .env defaults to your admin email (${opts.adminEmail}): change it to the address mail should come from.`);
|
|
596
|
+
}
|
|
512
597
|
scaffoldDevFrontendEnv(dir, opts);
|
|
513
598
|
write("seed.ts", seedTemplate(opts.projectName));
|
|
514
599
|
write("seeds/.gitkeep", "");
|
|
@@ -516,10 +601,21 @@ export function scaffold(dir, optsOrName, deps = initDependencyVersionsFallback(
|
|
|
516
601
|
// The Next.js counterpart of the static page's script tag: the client and @supatype/ssr ship
|
|
517
602
|
// together, so the route's package is added at the client's range.
|
|
518
603
|
scaffoldNextRuntimeEnv(dir, write, `^${deps.client}`);
|
|
604
|
+
// An Expo Router app has neither an index.html nor a root layout: its page is +html.tsx.
|
|
605
|
+
scaffoldExpoRuntimeEnv(dir, write);
|
|
519
606
|
if (opts.helloFunction)
|
|
520
607
|
scaffoldHelloFunction(dir, write);
|
|
521
608
|
scaffoldGitignore(dir, write);
|
|
522
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* Record the Kong port the project in `dir` was given, so the next init skips it before this project
|
|
612
|
+
* ever starts (FF26, init-port-registry.ts). Outside `scaffold`, which tests call by the hundred and
|
|
613
|
+
* which writes only inside `dir`; this writes under the home folder.
|
|
614
|
+
*/
|
|
615
|
+
export function recordScaffoldedKongPort(dir, opts) {
|
|
616
|
+
if (opts.provider === "docker" && opts.kongPort !== undefined)
|
|
617
|
+
recordInitKongPort(resolve(dir), opts.kongPort);
|
|
618
|
+
}
|
|
523
619
|
/**
|
|
524
620
|
* Supatype's scripts and packages merged into the project's own package.json, saying so when its
|
|
525
621
|
* `prepare` changed: a project's own (husky, say) gets `supatype-prepare` after it, and the one
|
|
@@ -569,13 +665,16 @@ function scaffoldGitignore(dir, write) {
|
|
|
569
665
|
return;
|
|
570
666
|
}
|
|
571
667
|
const existing = readFileSync(gitignorePath, "utf8");
|
|
572
|
-
const
|
|
573
|
-
if (
|
|
668
|
+
const missing = missingSupatypeIgnores(existing);
|
|
669
|
+
if (missing.length === 0) {
|
|
574
670
|
file("skipped", ".gitignore (already exists)");
|
|
575
671
|
return;
|
|
576
672
|
}
|
|
577
|
-
writeFileSync(gitignorePath,
|
|
673
|
+
writeFileSync(gitignorePath, withSupatypeIgnores(existing, missing), "utf8");
|
|
578
674
|
file("updated", ".gitignore (added Supatype's local files)");
|
|
675
|
+
const notice = negationOverrideNotice(existing, missing);
|
|
676
|
+
if (notice !== undefined)
|
|
677
|
+
warn(notice);
|
|
579
678
|
}
|
|
580
679
|
/**
|
|
581
680
|
* The directory a static app is served from: the one typed at init, else the stack's own default
|
|
@@ -597,16 +696,20 @@ function servedStatically(opts) {
|
|
|
597
696
|
return opts.app.mode === "static" || (opts.app.mode === "proxy" && opts.productionTarget !== "later");
|
|
598
697
|
}
|
|
599
698
|
function scaffoldAppAssets(dir, opts, write) {
|
|
699
|
+
const hasVite = Boolean(opts.app.viteDevUrl);
|
|
700
|
+
// The app's own page: a Vite app's is the root index.html, and the one in its build output is rebuilt from it.
|
|
701
|
+
const appPage = (rel) => (hasVite ? rel === "index.html" : rel.endsWith("index.html"));
|
|
600
702
|
const writeUnlessExists = (rel, content) => {
|
|
601
703
|
const full = join(dir, rel);
|
|
602
704
|
if (existsSync(full)) {
|
|
603
705
|
file("skipped", `${rel} (already exists)`);
|
|
706
|
+
if (servedStatically(opts) && appPage(rel))
|
|
707
|
+
adviseRuntimeEnvScript(full);
|
|
604
708
|
return;
|
|
605
709
|
}
|
|
606
710
|
write(rel, content);
|
|
607
711
|
};
|
|
608
712
|
const holding = holdingPageTemplate(opts.projectName, initLocalApiUrl(opts), servedStatically(opts));
|
|
609
|
-
const hasVite = Boolean(opts.app.viteDevUrl);
|
|
610
713
|
if (opts.app.mode === "static") {
|
|
611
714
|
writeUnlessExists(`${staticDirRelative(staticDirOf(opts.app))}/index.html`, holding);
|
|
612
715
|
if (hasVite)
|
|
@@ -628,13 +731,92 @@ function scaffoldAppAssets(dir, opts, write) {
|
|
|
628
731
|
function scaffoldVite(dir, opts, write, holding) {
|
|
629
732
|
if (!opts.app.viteDevUrl)
|
|
630
733
|
return;
|
|
631
|
-
write("index.html", holding);
|
|
632
|
-
|
|
734
|
+
write("index.html", opts.app.react ? reactIndexHtml(opts.projectName, servedStatically(opts)) : holding);
|
|
735
|
+
if (opts.app.react)
|
|
736
|
+
scaffoldReactSources(opts.projectName, write);
|
|
737
|
+
const viteConfigRel = VITE_CONFIG_NAMES.find((name) => existsSync(join(dir, name)));
|
|
633
738
|
if (viteConfigRel) {
|
|
634
739
|
file("skipped", `${viteConfigRel} (already exists)`);
|
|
635
740
|
return;
|
|
636
741
|
}
|
|
637
|
-
write(
|
|
742
|
+
write(newViteConfigName(dir), viteConfigTemplate(opts.app.viteDevUrl, viteBuildOutDir(opts), opts.app.react === true));
|
|
743
|
+
}
|
|
744
|
+
/** The React starter's page: a root to mount into and the entry module, with the runtime env tag a served build needs. */
|
|
745
|
+
function reactIndexHtml(projectName, runtimeEnv) {
|
|
746
|
+
return `<!doctype html>
|
|
747
|
+
<html lang="en">
|
|
748
|
+
<head>
|
|
749
|
+
<meta charset="UTF-8" />
|
|
750
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
751
|
+
<title>${escapeHtml(projectName)}: Supatype</title>${runtimeEnv ? RUNTIME_ENV_SCRIPT : ""}
|
|
752
|
+
</head>
|
|
753
|
+
<body>
|
|
754
|
+
<div id="root"></div>
|
|
755
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
756
|
+
</body>
|
|
757
|
+
</html>
|
|
758
|
+
`;
|
|
759
|
+
}
|
|
760
|
+
/** src/supatype.ts, main.tsx and App.tsx of the React starter. */
|
|
761
|
+
function scaffoldReactSources(projectName, write) {
|
|
762
|
+
write("src/supatype.ts", REACT_CLIENT_SOURCE);
|
|
763
|
+
write("src/main.tsx", REACT_MAIN_SOURCE);
|
|
764
|
+
write("src/App.tsx", reactAppSource(projectName));
|
|
765
|
+
}
|
|
766
|
+
const REACT_CLIENT_SOURCE = [
|
|
767
|
+
'import { createClient } from "@supatype/client"',
|
|
768
|
+
"",
|
|
769
|
+
"// The address and anon key: init, supatype dev and supatype keys write them to .env.development.local,",
|
|
770
|
+
"// and a build Supatype serves reads them from /supatype-env.js.",
|
|
771
|
+
"export const supatype = createClient({",
|
|
772
|
+
" url: import.meta.env.VITE_SUPATYPE_URL,",
|
|
773
|
+
" anonKey: import.meta.env.VITE_SUPATYPE_ANON_KEY,",
|
|
774
|
+
"})",
|
|
775
|
+
"",
|
|
776
|
+
].join("\n");
|
|
777
|
+
const REACT_MAIN_SOURCE = [
|
|
778
|
+
'import { StrictMode } from "react"',
|
|
779
|
+
'import { createRoot } from "react-dom/client"',
|
|
780
|
+
'import { SupatypeProvider } from "@supatype/react"',
|
|
781
|
+
'import { App } from "./App"',
|
|
782
|
+
'import { supatype } from "./supatype"',
|
|
783
|
+
"",
|
|
784
|
+
'const root = document.getElementById("root")',
|
|
785
|
+
'if (root === null) throw new Error("index.html has no #root to mount the app into")',
|
|
786
|
+
"",
|
|
787
|
+
"createRoot(root).render(",
|
|
788
|
+
" <StrictMode>",
|
|
789
|
+
" <SupatypeProvider client={supatype}>",
|
|
790
|
+
" <App />",
|
|
791
|
+
" </SupatypeProvider>",
|
|
792
|
+
" </StrictMode>,",
|
|
793
|
+
")",
|
|
794
|
+
"",
|
|
795
|
+
].join("\n");
|
|
796
|
+
/** The starter's page component. The project name is shown as a JSON string, so no name can break the markup. */
|
|
797
|
+
function reactAppSource(projectName) {
|
|
798
|
+
return [
|
|
799
|
+
'import { useAuth } from "@supatype/react"',
|
|
800
|
+
"",
|
|
801
|
+
"export function App() {",
|
|
802
|
+
" const { user, loading } = useAuth()",
|
|
803
|
+
" return (",
|
|
804
|
+
" <main>",
|
|
805
|
+
` <h1>{${JSON.stringify(projectName)}}</h1>`,
|
|
806
|
+
' <p>{loading ? "Checking your session" : user ? "Signed in as " + user.email : "Not signed in"}</p>',
|
|
807
|
+
" <p>Add a model to schema/index.ts, push it, then read it with useQuery from @supatype/react.</p>",
|
|
808
|
+
" </main>",
|
|
809
|
+
" )",
|
|
810
|
+
"}",
|
|
811
|
+
"",
|
|
812
|
+
].join("\n");
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* `vite.config.ts` in an ESM package, else `vite.config.mts`, which Vite loads as ESM by its
|
|
816
|
+
* extension: init no longer makes an existing app's package ESM (FF24), and the config imports `vite`.
|
|
817
|
+
*/
|
|
818
|
+
function newViteConfigName(dir) {
|
|
819
|
+
return readPackageJson(dir)?.raw["type"] === "module" ? "vite.config.ts" : "vite.config.mts";
|
|
638
820
|
}
|
|
639
821
|
/**
|
|
640
822
|
* Where `vite build` writes, when it is not Vite's own `dist`: the static directory a static app is
|
|
@@ -727,10 +909,12 @@ function tsConfigTemplate(opts) {
|
|
|
727
909
|
lines.push(` environments: { default: "production" }, // supatype link --env production ...`);
|
|
728
910
|
}
|
|
729
911
|
lines.push(` // Optional: pin component versions (native cache + Docker images synced to .env on dev/push)`);
|
|
730
|
-
lines.push(` // versions: { engine: "0.1.2", server: "1.0.5", postgres: "17.2", deno: "2.
|
|
912
|
+
lines.push(` // versions: { engine: "0.1.2", server: "1.0.5", postgres: "17.2", deno: "2.9.8" },`);
|
|
731
913
|
lines.push(` email: { provider: "${opts.email}" },`);
|
|
732
|
-
lines.push(...storageConfigLines(opts.storageLocal, opts.storageProduction));
|
|
914
|
+
lines.push(...storageConfigLines(opts.storageLocal, opts.productionTarget === "cloud" ? undefined : opts.storageProduction));
|
|
733
915
|
lines.push(` schema: { path: "${opts.schemaPath}", pg_schema: "public" },`);
|
|
916
|
+
lines.push(` // Broadcast and presence on a channel no Channel<> declares are refused. "open" allows them.`);
|
|
917
|
+
lines.push(` realtime: { channels: "declared" },`);
|
|
734
918
|
lines.push(` // Regenerated by dev, push and generate on every schema change.`);
|
|
735
919
|
lines.push(` output: { types: "${DEFAULT_TYPES_PATH}", client: "${DEFAULT_CLIENT_PATH}" },`);
|
|
736
920
|
lines.push(` // Self-host production: supatype self-host compose (Docker only). Standalone + domain = native ACME dev.`);
|
|
@@ -753,18 +937,24 @@ function localConfigTemplate(app) {
|
|
|
753
937
|
lines.push(`}`, ``, `export default localConfig`, ``);
|
|
754
938
|
return lines.join("\n");
|
|
755
939
|
}
|
|
940
|
+
/**
|
|
941
|
+
* The app block for a dev server. A missing `start` is left out, and dev then runs `start`: it was
|
|
942
|
+
* written as `dev`, which in a new project is init's own `supatype dev`.
|
|
943
|
+
*/
|
|
944
|
+
function proxyAppLines(app) {
|
|
945
|
+
return [
|
|
946
|
+
` app: {`,
|
|
947
|
+
` mode: "proxy",`,
|
|
948
|
+
` upstream: "${app.upstream ?? "http://localhost:3000"}",`,
|
|
949
|
+
...(app.start ? [` start: "${app.start}",`] : []),
|
|
950
|
+
...(app.viteDevUrl ? [` vite_dev_url: "${app.viteDevUrl}",`] : []),
|
|
951
|
+
` },`,
|
|
952
|
+
];
|
|
953
|
+
}
|
|
756
954
|
/** App block for supatype.local.config.ts (proxy + Vite during local dev). */
|
|
757
955
|
function localDevAppConfigLines(app) {
|
|
758
|
-
if (app.mode === "proxy")
|
|
759
|
-
return
|
|
760
|
-
` app: {`,
|
|
761
|
-
` mode: "proxy",`,
|
|
762
|
-
` upstream: "${app.upstream ?? "http://localhost:3000"}",`,
|
|
763
|
-
` start: "${app.start ?? "dev"}",`,
|
|
764
|
-
...(app.viteDevUrl ? [` vite_dev_url: "${app.viteDevUrl}",`] : []),
|
|
765
|
-
` },`,
|
|
766
|
-
];
|
|
767
|
-
}
|
|
956
|
+
if (app.mode === "proxy")
|
|
957
|
+
return proxyAppLines(app);
|
|
768
958
|
if (app.viteDevUrl) {
|
|
769
959
|
return [
|
|
770
960
|
` app: {`,
|
|
@@ -792,16 +982,7 @@ function appConfigLines(app, productionTarget) {
|
|
|
792
982
|
` },`,
|
|
793
983
|
];
|
|
794
984
|
}
|
|
795
|
-
|
|
796
|
-
` app: {`,
|
|
797
|
-
` mode: "proxy",`,
|
|
798
|
-
` upstream: "${app.upstream ?? "http://localhost:3000"}",`,
|
|
799
|
-
` start: "${app.start ?? "dev"}",`,
|
|
800
|
-
];
|
|
801
|
-
if (app.viteDevUrl)
|
|
802
|
-
out.push(` vite_dev_url: "${app.viteDevUrl}",`);
|
|
803
|
-
out.push(` },`);
|
|
804
|
-
return out;
|
|
985
|
+
return proxyAppLines(app);
|
|
805
986
|
}
|
|
806
987
|
return [
|
|
807
988
|
` app: {`,
|
|
@@ -851,10 +1032,21 @@ function initSiteUrl(opts) {
|
|
|
851
1032
|
* bundle a script the project does not have. Vite drops the attribute from the page it builds, and
|
|
852
1033
|
* a browser ignores it in a page nothing builds.
|
|
853
1034
|
*/
|
|
1035
|
+
const RUNTIME_ENV_TAG = '<script src="/supatype-env.js" vite-ignore></script>';
|
|
854
1036
|
const RUNTIME_ENV_SCRIPT = `
|
|
855
1037
|
<!-- The deployment's API address and anon key, from the server that serves this page.
|
|
856
1038
|
vite-ignore tells Vite to leave it out of the bundle, so the build does not warn. -->
|
|
857
|
-
|
|
1039
|
+
${RUNTIME_ENV_TAG}`;
|
|
1040
|
+
/**
|
|
1041
|
+
* The tag for an app's own page, which init keeps. It used to print only "skipped index.html", and
|
|
1042
|
+
* a production build of the page then threw MissingClientValuesError (0.9.2 release test round 2,
|
|
1043
|
+
* N-S15).
|
|
1044
|
+
*/
|
|
1045
|
+
function adviseRuntimeEnvScript(page) {
|
|
1046
|
+
if (readFileSync(page, "utf8").includes("/supatype-env.js"))
|
|
1047
|
+
return;
|
|
1048
|
+
plain(` add ${RUNTIME_ENV_TAG} to its <head>, so a build Supatype serves gets its API URL and anon key`);
|
|
1049
|
+
}
|
|
858
1050
|
function holdingPageTemplate(projectName, apiUrl, runtimeEnv) {
|
|
859
1051
|
const name = escapeHtml(projectName);
|
|
860
1052
|
return `<!doctype html>
|
|
@@ -989,14 +1181,18 @@ function vitePortFromDevUrl(viteDevUrl) {
|
|
|
989
1181
|
return 5173;
|
|
990
1182
|
}
|
|
991
1183
|
}
|
|
992
|
-
function viteConfigTemplate(viteDevUrl, outDir) {
|
|
1184
|
+
function viteConfigTemplate(viteDevUrl, outDir, react = false) {
|
|
993
1185
|
const port = vitePortFromDevUrl(viteDevUrl);
|
|
994
1186
|
const build = outDir === undefined ? "" : ` // Built into the directory supatype.config.ts serves.\n build: { outDir: "${outDir}" },\n`;
|
|
995
|
-
|
|
1187
|
+
const reactImport = react ? '\nimport react from "@vitejs/plugin-react"' : "";
|
|
1188
|
+
const reactPlugin = react ? " plugins: [react()],\n" : "";
|
|
1189
|
+
return `import { defineConfig } from "vite"${reactImport}
|
|
996
1190
|
|
|
997
1191
|
export default defineConfig({
|
|
998
|
-
${build} server: {
|
|
999
|
-
|
|
1192
|
+
${reactPlugin}${build} server: {
|
|
1193
|
+
// supatype dev sets ${DEV_APP_HOST_ENV}: 0.0.0.0 on Linux, where the gateway arrives over
|
|
1194
|
+
// the Docker bridge rather than the loopback.
|
|
1195
|
+
host: process.env.${DEV_APP_HOST_ENV} ?? "127.0.0.1",
|
|
1000
1196
|
port: ${port},
|
|
1001
1197
|
strictPort: true,
|
|
1002
1198
|
// Docker Compose app proxy reaches the host as host.docker.internal.
|
|
@@ -1006,20 +1202,13 @@ ${build} server: {
|
|
|
1006
1202
|
`;
|
|
1007
1203
|
}
|
|
1008
1204
|
function storageConfigLines(storageLocal, storageProduction) {
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
}
|
|
1016
|
-
if (storageProduction === "s3" && storageLocal !== "s3") {
|
|
1017
|
-
lines.push(` // Production storage: external S3 bucket, set production S3_* in .env`);
|
|
1018
|
-
}
|
|
1019
|
-
else if (storageProduction === "local" && storageLocal === "s3") {
|
|
1020
|
-
lines.push(` // Production storage: SeaweedFS on your server (included in self-host compose)`);
|
|
1021
|
-
}
|
|
1022
|
-
return lines;
|
|
1205
|
+
// provider is dev's, production the self-host stack's; S3_* in .env name the bucket for either.
|
|
1206
|
+
// No production entry (undefined) on Supatype Cloud, which brings its own storage.
|
|
1207
|
+
const dev = storageLocal === "s3" ? `provider: "s3"` : `provider: "local", local_path: ".supatype/storage"`;
|
|
1208
|
+
const production = storageProduction === undefined || (storageLocal === "local" && storageProduction === "local")
|
|
1209
|
+
? ""
|
|
1210
|
+
: `, production: "${storageProduction}"`;
|
|
1211
|
+
return [` storage: { ${dev}${production} },`];
|
|
1023
1212
|
}
|
|
1024
1213
|
function schemaTemplate() {
|
|
1025
1214
|
return `import type { Model, LoggedIn, Owner, Public, Role, SupatypeAuthUserId, UUID } from "@supatype/types"
|
|
@@ -1061,6 +1250,16 @@ function envAnswers(opts) {
|
|
|
1061
1250
|
...(opts.adminPassword !== undefined && { SUPATYPE_ADMIN_PASSWORD: opts.adminPassword }),
|
|
1062
1251
|
};
|
|
1063
1252
|
}
|
|
1253
|
+
/**
|
|
1254
|
+
* The keyspace password's line in the new .env: a generated password, or, when the shell names a
|
|
1255
|
+
* file for it, a note saying so. A password beside the file stops the stack at start (R2-S16).
|
|
1256
|
+
*/
|
|
1257
|
+
function keyspacePasswordLine() {
|
|
1258
|
+
if (!shellNamesKeyspacePasswordFile())
|
|
1259
|
+
return `${KEYSPACE_PASSWORD_ENV}=${randomBytes(24).toString("base64url")}`;
|
|
1260
|
+
return `# Read from the file ${KEYSPACE_PASSWORD_FILE_ENV} names in your shell, so none is written here.
|
|
1261
|
+
# Do not set ${KEYSPACE_PASSWORD_ENV} as well: dev and self-host refuse to start with both.`;
|
|
1262
|
+
}
|
|
1064
1263
|
function envTemplate(opts) {
|
|
1065
1264
|
assertEnvValues(envAnswers(opts), ".env");
|
|
1066
1265
|
const sections = [];
|
|
@@ -1100,6 +1299,14 @@ SERVICE_ROLE_KEY=`);
|
|
|
1100
1299
|
sections.push(`# Shared by the API server and the control plane only. The control plane refuses any
|
|
1101
1300
|
# request without it, so code running in the functions worker cannot call it directly.
|
|
1102
1301
|
${CONTROL_PLANE_SECRET_ENV}=${generateControlPlaneSecret()}`);
|
|
1302
|
+
sections.push(`# Held by the API server, the gateway and the functions worker. The server believes a client address
|
|
1303
|
+
# passed on in a header only on a request that carries it; code in a function never sees it.
|
|
1304
|
+
${FORWARDING_SECRET_ENV}=${generateControlPlaneSecret()}`);
|
|
1305
|
+
// Dev wrote it on first start, appended with no comment (0.9.2 release test round 2, R2-S14).
|
|
1306
|
+
sections.push(`# The cache's password when the cache runs in Postgres (pg_keyspace): the keyspace user
|
|
1307
|
+
# \`${KEYSPACE_USERNAME}\`'s, which the API server logs in with, and the gateway when HTTPS is on.
|
|
1308
|
+
# It reads and writes every cached value.
|
|
1309
|
+
${keyspacePasswordLine()}`);
|
|
1103
1310
|
sections.push(`# Site URL (used for email redirects)
|
|
1104
1311
|
SITE_URL=${initSiteUrl(opts)}`);
|
|
1105
1312
|
if (opts.provider === "docker" && opts.kongPort !== undefined) {
|
|
@@ -1110,33 +1317,42 @@ SUPATYPE_KONG_PORT=${opts.kongPort}
|
|
|
1110
1317
|
API_EXTERNAL_URL=${initLocalApiUrl(opts)}`);
|
|
1111
1318
|
}
|
|
1112
1319
|
sections.push(emailEnvSection(opts));
|
|
1113
|
-
|
|
1320
|
+
// Where the CLI would leave it after taking out a SUPATYPE_MAILER_AUTOCONFIRM an earlier CLI wrote.
|
|
1321
|
+
// Written here, a new project never has that done to a line of the developer's own (FF7).
|
|
1322
|
+
sections.push(MAILER_AUTOCONFIRM_NOTE);
|
|
1323
|
+
sections.push(storageEnvSections(opts.storageLocal, opts.storageProduction, opts.productionTarget === "cloud"));
|
|
1114
1324
|
if (opts.adminEmail && opts.adminPassword) {
|
|
1115
1325
|
sections.push(`# First Studio admin (/studio/), consumed on first supatype dev or push (password removed after use)
|
|
1116
1326
|
SUPATYPE_ADMIN_EMAIL=${opts.adminEmail}
|
|
1117
1327
|
SUPATYPE_ADMIN_PASSWORD=${opts.adminPassword}`);
|
|
1118
1328
|
}
|
|
1119
|
-
|
|
1329
|
+
// Those ports belong to the self-host compose stack, which a Cloud project never runs; its local
|
|
1330
|
+
// gateway port is written above.
|
|
1331
|
+
if (opts.productionTarget !== "cloud")
|
|
1332
|
+
sections.push(selfHostPortsEnvSection(opts.storageProduction));
|
|
1120
1333
|
return sections.join("\n\n") + "\n";
|
|
1121
1334
|
}
|
|
1122
1335
|
/**
|
|
1123
1336
|
* The host ports `supatype self-host compose` publishes, with their defaults. Commented out so the
|
|
1124
|
-
* defaults apply; the first anyone heard of these used to be a clash on 5432.
|
|
1337
|
+
* defaults apply; the first anyone heard of these used to be a clash on 5432. A stack on the
|
|
1338
|
+
* project's own S3 bucket runs no SeaweedFS, so it is not named there (0.9.2 release test round 2, N-S26).
|
|
1125
1339
|
*/
|
|
1126
|
-
|
|
1127
|
-
|
|
1340
|
+
function selfHostPortsEnvSection(storageProduction) {
|
|
1341
|
+
const seaweedfs = storageProduction !== "s3";
|
|
1342
|
+
return `# Self-host stack ports (supatype self-host compose). Kong, at SUPATYPE_KONG_PORT, is the way in.
|
|
1343
|
+
# Postgres${seaweedfs ? ", the API server and SeaweedFS" : " and the API server"} bind 127.0.0.1 only. To reach them from other machines,
|
|
1128
1344
|
# set SUPATYPE_PUBLISH_ADDRESS=0.0.0.0 (put a firewall in front of the server first).
|
|
1129
1345
|
# Self-host commands reach Postgres at SUPATYPE_DB_PORT for their own run; DATABASE_URL above stays dev's.
|
|
1130
1346
|
# SUPATYPE_PUBLISH_ADDRESS=127.0.0.1
|
|
1131
1347
|
# SUPATYPE_DB_PORT=5432
|
|
1132
|
-
# SUPATYPE_SERVER_PORT=9999
|
|
1133
|
-
|
|
1348
|
+
# SUPATYPE_SERVER_PORT=9999${seaweedfs ? "\n# SUPATYPE_SEAWEEDFS_PORT=8333" : ""}`;
|
|
1349
|
+
}
|
|
1134
1350
|
/**
|
|
1135
1351
|
* The scaffolded `.env`'s email settings, under the names the auth server reads. They used to be
|
|
1136
1352
|
* written unprefixed (RESEND_API_KEY, SES_FROM, SMTP_HOST), which nothing reads, so a developer who
|
|
1137
1353
|
* filled them in still got no email.
|
|
1138
1354
|
*/
|
|
1139
|
-
function emailEnvSection({ email, projectName, smtp }) {
|
|
1355
|
+
function emailEnvSection({ email, projectName, smtp, adminEmail }) {
|
|
1140
1356
|
switch (email) {
|
|
1141
1357
|
case "resend":
|
|
1142
1358
|
return `# Email (Resend)
|
|
@@ -1154,11 +1370,13 @@ SUPATYPE_SMTP_HOST=${smtp?.host ?? ""}
|
|
|
1154
1370
|
SUPATYPE_SMTP_PORT=${smtp?.port ?? 587}
|
|
1155
1371
|
SUPATYPE_SMTP_USER=
|
|
1156
1372
|
SUPATYPE_SMTP_PASS=
|
|
1373
|
+
# The address mail is sent from. Without it the server builds an empty From and fails every send.
|
|
1374
|
+
# Defaulted to the admin email given at init: change it to a sender your SMTP server accepts.
|
|
1375
|
+
SUPATYPE_SMTP_ADMIN_EMAIL=${adminEmail ?? ""}
|
|
1157
1376
|
SUPATYPE_SMTP_SENDER_NAME=${projectName}`;
|
|
1158
1377
|
case "console":
|
|
1159
1378
|
default:
|
|
1160
1379
|
return `# SMTP: unused while email.provider is console, which logs each email instead of sending it.
|
|
1161
|
-
# Email confirmation is auth.email.enableConfirmations in supatype.config.ts.
|
|
1162
1380
|
# SUPATYPE_SMTP_HOST=
|
|
1163
1381
|
# SUPATYPE_SMTP_PORT=587
|
|
1164
1382
|
# SUPATYPE_SMTP_USER=
|
|
@@ -1166,16 +1384,19 @@ SUPATYPE_SMTP_SENDER_NAME=${projectName}`;
|
|
|
1166
1384
|
# SUPATYPE_SMTP_SENDER_NAME=${projectName}`;
|
|
1167
1385
|
}
|
|
1168
1386
|
}
|
|
1169
|
-
function storageEnvSections(storageLocal, storageProduction) {
|
|
1387
|
+
function storageEnvSections(storageLocal, storageProduction, cloud) {
|
|
1388
|
+
// Supatype Cloud brings its own storage and no production entry is written, so a bucket of your own
|
|
1389
|
+
// here serves local development only.
|
|
1390
|
+
if (cloud) {
|
|
1391
|
+
return storageLocal === "s3"
|
|
1392
|
+
? s3EnvSection("local development only", "Supatype Cloud provides production storage.")
|
|
1393
|
+
: `${localStorageEnvSection(storageLocal)}
|
|
1394
|
+
|
|
1395
|
+
# Production storage: Supatype Cloud provides it, no configuration needed.`;
|
|
1396
|
+
}
|
|
1170
1397
|
if (storageLocal === storageProduction) {
|
|
1171
1398
|
if (storageLocal === "s3") {
|
|
1172
|
-
return
|
|
1173
|
-
# Use separate buckets for dev and production in your provider.
|
|
1174
|
-
S3_ENDPOINT=
|
|
1175
|
-
S3_REGION=us-east-1
|
|
1176
|
-
S3_BUCKET=
|
|
1177
|
-
S3_ACCESS_KEY=
|
|
1178
|
-
S3_SECRET_KEY=`;
|
|
1399
|
+
return s3EnvSection("local development and production", "Use a separate bucket for dev and production.");
|
|
1179
1400
|
}
|
|
1180
1401
|
return `${localStorageEnvSection("local")}
|
|
1181
1402
|
|
|
@@ -1184,36 +1405,50 @@ S3_SECRET_KEY=`;
|
|
|
1184
1405
|
}
|
|
1185
1406
|
return [localStorageEnvSection(storageLocal), productionStorageEnvSection(storageProduction)].join("\n\n");
|
|
1186
1407
|
}
|
|
1187
|
-
/**
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
function
|
|
1192
|
-
|
|
1193
|
-
|
|
1408
|
+
/**
|
|
1409
|
+
* The settings for a bucket of your own (storage.provider "s3"), described as the storage service
|
|
1410
|
+
* uses them: one S3 bucket, every Supatype bucket a key prefix in it, as Supabase Storage keeps them.
|
|
1411
|
+
*/
|
|
1412
|
+
function s3EnvSection(use, note) {
|
|
1413
|
+
return `# Storage (${use}, your own S3 bucket)
|
|
1414
|
+
# Every Supatype bucket is a folder (key prefix) in S3_BUCKET, and the storage service serves every
|
|
1415
|
+
# file, public ones included, so the bucket itself stays private. The keys need only read, write,
|
|
1416
|
+
# list and delete on that one bucket.${note === undefined ? "" : ` ${note}`}
|
|
1417
|
+
# AWS: set S3_REGION and leave S3_ENDPOINT blank. Another S3-compatible store (Cloudflare R2,
|
|
1418
|
+
# SeaweedFS, and the like): set S3_ENDPOINT too. On AWS, leave both keys blank to use the AWS SDK's
|
|
1419
|
+
# own credentials (an instance or task role, AWS_PROFILE).
|
|
1420
|
+
# In the self-host stack the storage service runs in a container, where localhost is that container.
|
|
1421
|
+
# For a store on the same machine use http://host.docker.internal:<port> with Docker Desktop, or on
|
|
1422
|
+
# Linux the host's Docker bridge address (usually 172.17.0.1). Native supatype dev can use localhost.
|
|
1194
1423
|
S3_ENDPOINT=
|
|
1195
1424
|
S3_REGION=us-east-1
|
|
1196
1425
|
S3_BUCKET=
|
|
1197
1426
|
S3_ACCESS_KEY=
|
|
1198
1427
|
S3_SECRET_KEY=`;
|
|
1199
|
-
|
|
1428
|
+
}
|
|
1429
|
+
/** Whether init generates the object store's login: for the local SeaweedFS, not a bucket of your own. */
|
|
1430
|
+
function generatesObjectStoreLogin(storage) {
|
|
1431
|
+
return storage !== "s3";
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* Dev's storage settings. Local SeaweedFS takes no S3_* names: the compose file hands the storage
|
|
1435
|
+
* service its address itself. The S3_ENDPOINT=http://localhost:8333 written here was read by
|
|
1436
|
+
* nothing, named the storage container itself from inside it, and stayed behind when a project
|
|
1437
|
+
* moved to its own bucket (0.9.2 release test round 2, N-S26).
|
|
1438
|
+
*/
|
|
1439
|
+
function localStorageEnvSection(storage) {
|
|
1440
|
+
if (!generatesObjectStoreLogin(storage))
|
|
1441
|
+
return s3EnvSection("local development");
|
|
1200
1442
|
const login = generateObjectStoreCredentials();
|
|
1201
1443
|
return `# Storage (local development, SeaweedFS)
|
|
1202
1444
|
# The object store's login, generated for this project. It opens every file in every bucket, so
|
|
1203
1445
|
# keep it as private as the database password.
|
|
1204
|
-
S3_ENDPOINT=http://localhost:8333
|
|
1205
1446
|
${OBJECT_STORE_ACCESS_KEY_ENV}=${login.accessKey}
|
|
1206
1447
|
${OBJECT_STORE_SECRET_KEY_ENV}=${login.secretKey}`;
|
|
1207
1448
|
}
|
|
1208
1449
|
function productionStorageEnvSection(storage) {
|
|
1209
|
-
if (storage === "s3")
|
|
1210
|
-
return
|
|
1211
|
-
S3_ENDPOINT=
|
|
1212
|
-
S3_REGION=us-east-1
|
|
1213
|
-
S3_BUCKET=
|
|
1214
|
-
S3_ACCESS_KEY=
|
|
1215
|
-
S3_SECRET_KEY=`;
|
|
1216
|
-
}
|
|
1450
|
+
if (storage === "s3")
|
|
1451
|
+
return s3EnvSection("production");
|
|
1217
1452
|
return `# Storage (production, SeaweedFS on your server)
|
|
1218
1453
|
# Included in the self-host compose stack, no extra configuration needed.`;
|
|
1219
1454
|
}
|
|
@@ -1266,22 +1501,6 @@ node_modules/
|
|
|
1266
1501
|
dist/
|
|
1267
1502
|
`;
|
|
1268
1503
|
}
|
|
1269
|
-
/**
|
|
1270
|
-
* An existing `.gitignore` with what init adds to a project: `.supatype/` (link.json holds secrets)
|
|
1271
|
-
* and `.env.*.local`, where init writes the front end's development-only API address. Each is added
|
|
1272
|
-
* only when the file does not already cover it.
|
|
1273
|
-
*/
|
|
1274
|
-
export function mergeGitignoreTemplate(existingContent) {
|
|
1275
|
-
const lines = existingContent.split(/\r?\n/).map((line) => line.trim());
|
|
1276
|
-
const missing = [
|
|
1277
|
-
...(existingContent.includes(".supatype/") || lines.includes(".supatype") ? [] : [".supatype/"]),
|
|
1278
|
-
...(lines.includes(".env.*.local") || lines.includes("*.local") ? [] : [".env.*.local"]),
|
|
1279
|
-
];
|
|
1280
|
-
if (missing.length === 0)
|
|
1281
|
-
return existingContent;
|
|
1282
|
-
const block = `\n# Supatype: local runtime (secrets in .supatype/link.json) and development-only env files\n${missing.join("\n")}\n`;
|
|
1283
|
-
return existingContent.endsWith("\n") ? `${existingContent}${block}` : `${existingContent}\n${block}`;
|
|
1284
|
-
}
|
|
1285
1504
|
// ─── Next steps ────────────────────────────────────────────────────────────--
|
|
1286
1505
|
/** Say so when a Docker project's Docker is not running: from `started` when init already asked. */
|
|
1287
1506
|
async function warnDockerUnavailableForProvider(provider, started) {
|
|
@@ -1305,16 +1524,6 @@ function startInitQuestions(provider) {
|
|
|
1305
1524
|
const kongPort = import("../dev-ports.js").then(({ chooseInitKongPort }) => chooseInitKongPort());
|
|
1306
1525
|
return { kongPort, daemon: probeDockerDaemonAsync(), deps };
|
|
1307
1526
|
}
|
|
1308
|
-
/** The script in `dir`'s package.json that runs `supatype dev`, or `dev` when it cannot be read. */
|
|
1309
|
-
function projectDevScript(dir) {
|
|
1310
|
-
try {
|
|
1311
|
-
const pkg = parseJsonObject(readFileSync(join(dir, "package.json"), "utf8"));
|
|
1312
|
-
return pkg.ok ? supatypeDevScript(pkg.value["scripts"]) : "dev";
|
|
1313
|
-
}
|
|
1314
|
-
catch {
|
|
1315
|
-
return "dev";
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
1527
|
/** True when nothing is left to set up, only to run. */
|
|
1319
1528
|
function initSetupComplete(args) {
|
|
1320
1529
|
return args.installed && args.keysGenerated && args.binariesReady;
|
|
@@ -1375,9 +1584,11 @@ function commented(command, comments) {
|
|
|
1375
1584
|
return comments.map((comment, index) => `${(index === 0 ? command : "").padEnd(column)}# ${comment}`);
|
|
1376
1585
|
}
|
|
1377
1586
|
/**
|
|
1378
|
-
*
|
|
1587
|
+
* `supatype dev`, which applies the schema and generates the types, then watches both; then where
|
|
1379
1588
|
* to open the project. `push` is for another database (`push --env <name>`), and listing it here
|
|
1380
|
-
* sent people to it anyway.
|
|
1589
|
+
* sent people to it anyway. The command as the docs give it: init printed the package.json script
|
|
1590
|
+
* (`npm run supatype:dev` beside a framework's own dev), which no page of the docs names
|
|
1591
|
+
* (0.9.2 release test round 2, N-S15).
|
|
1381
1592
|
*/
|
|
1382
1593
|
function initDevSteps(args) {
|
|
1383
1594
|
const { result } = args;
|
|
@@ -1387,7 +1598,7 @@ function initDevSteps(args) {
|
|
|
1387
1598
|
];
|
|
1388
1599
|
if (result.adminEmail)
|
|
1389
1600
|
comments.push("first admin user is created on dev");
|
|
1390
|
-
const steps = commented(
|
|
1601
|
+
const steps = commented("supatype dev", comments);
|
|
1391
1602
|
steps.push(`Open ${initLocalApiUrl(result)}`);
|
|
1392
1603
|
if (result.helloFunction) {
|
|
1393
1604
|
steps.push(...commented(runScriptCommand(result.packageManager, "functions"), ["run edge functions locally"]));
|
|
@@ -1404,6 +1615,7 @@ const INIT_SECRETS = [
|
|
|
1404
1615
|
["AUTHENTICATOR_PASSWORD", "PostgREST's own login; rotating the one above does not affect it"],
|
|
1405
1616
|
["SUPATYPE_SQL_EDITOR_PASSWORD", "Studio's SQL editor login, a role that is not a superuser"],
|
|
1406
1617
|
["JWT_SECRET", "signs ANON_KEY and SERVICE_ROLE_KEY; changing it invalidates every token"],
|
|
1618
|
+
[KEYSPACE_PASSWORD_ENV, "the cache's login, which reads and writes every cached value"],
|
|
1407
1619
|
];
|
|
1408
1620
|
/** The object store's login, when init generates one ({@link generatesObjectStoreLogin}). */
|
|
1409
1621
|
const OBJECT_STORE_SECRETS = [
|
|
@@ -1416,7 +1628,8 @@ const SECRETS_CLOSING = "Keep .env out of version control, and use different val
|
|
|
1416
1628
|
* development storage in an S3 bucket of your own, init generates no object-store login.
|
|
1417
1629
|
*/
|
|
1418
1630
|
export function initSecretLines(storageLocal = "local") {
|
|
1419
|
-
const
|
|
1631
|
+
const generated = shellNamesKeyspacePasswordFile() ? INIT_SECRETS.filter(([name]) => name !== KEYSPACE_PASSWORD_ENV) : INIT_SECRETS;
|
|
1632
|
+
const secrets = generatesObjectStoreLogin(storageLocal) ? [...generated, ...OBJECT_STORE_SECRETS] : generated;
|
|
1420
1633
|
const width = Math.max(...secrets.map(([name]) => name.length)) + 2;
|
|
1421
1634
|
return secrets.map(([name, description]) => `${name.padEnd(width)}${description}`);
|
|
1422
1635
|
}
|
|
@@ -1438,6 +1651,11 @@ function deployBlock(result) {
|
|
|
1438
1651
|
}
|
|
1439
1652
|
return undefined;
|
|
1440
1653
|
}
|
|
1654
|
+
/**
|
|
1655
|
+
* The server's bucket, for production storage on S3: compose refuses to start without S3_BUCKET,
|
|
1656
|
+
* and init's steps never named it (0.9.2 release test round 2, N-S26).
|
|
1657
|
+
*/
|
|
1658
|
+
const S3_BUCKET_STEP = "Set S3_BUCKET in the server's .env, with S3_REGION for AWS or S3_ENDPOINT for another store # production storage is your own S3 bucket";
|
|
1441
1659
|
/**
|
|
1442
1660
|
* Taking a self-host project to its own server. With a domain, DNS and the firewall come first;
|
|
1443
1661
|
* without one, HTTPS is the last step and an optional one, since the person just said they had none.
|
|
@@ -1445,8 +1663,10 @@ function deployBlock(result) {
|
|
|
1445
1663
|
export function selfHostDeploySteps(result) {
|
|
1446
1664
|
const domain = result.domain?.trim();
|
|
1447
1665
|
const link = "supatype link --env production ... # then: supatype push --env production";
|
|
1666
|
+
const bucket = result.storageProduction === "s3" ? [S3_BUCKET_STEP] : [];
|
|
1448
1667
|
if (!domain) {
|
|
1449
1668
|
return [
|
|
1669
|
+
...bucket,
|
|
1450
1670
|
"supatype self-host compose up -d # on your server: the Docker stack",
|
|
1451
1671
|
link,
|
|
1452
1672
|
BUILD_STEP,
|
|
@@ -1457,6 +1677,7 @@ export function selfHostDeploySteps(result) {
|
|
|
1457
1677
|
`1. Point DNS: an A record for ${domain} -> your server's public IP`,
|
|
1458
1678
|
"2. Open ports 80 and 443 on the server firewall",
|
|
1459
1679
|
...(result.tlsEmail ? [] : ["3. Set server.tls.email in supatype.config.ts (required for HTTPS)"]),
|
|
1680
|
+
...bucket,
|
|
1460
1681
|
"supatype self-host compose up -d # Kong provisions HTTPS automatically",
|
|
1461
1682
|
link,
|
|
1462
1683
|
BUILD_STEP,
|