@supatype/cli 0.9.1 → 0.9.2
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 +303 -91
- package/bin/node-version.js +28 -0
- package/bin/supatype.js +8 -4
- 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 +21 -3
- package/dist/app/proxy-dev-app.d.ts.map +1 -1
- package/dist/app/proxy-dev-app.js +84 -46
- package/dist/app/proxy-dev-app.js.map +1 -1
- package/dist/app/vite-dev-args.d.ts +20 -0
- package/dist/app/vite-dev-args.d.ts.map +1 -0
- package/dist/app/vite-dev-args.js +65 -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/augmentation-generator.d.ts +2 -0
- package/dist/augmentation-generator.d.ts.map +1 -1
- package/dist/augmentation-generator.js +7 -3
- package/dist/augmentation-generator.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/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/cli-version-embedded.js +1 -1
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +10 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/admin.js +5 -11
- 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/dev.d.ts +21 -4
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +222 -68
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/doctor.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/init.d.ts +6 -8
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +193 -114
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/link-helpers.js +1 -1
- package/dist/commands/link-helpers.js.map +1 -1
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +3 -1
- package/dist/commands/push.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 +68 -269
- package/dist/commands/self-host.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +156 -63
- package/dist/commands/update.js.map +1 -1
- package/dist/compose-db-roles.d.ts.map +1 -1
- package/dist/compose-db-roles.js +3 -0
- package/dist/compose-db-roles.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 +13 -5
- 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 +9 -11
- 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 +4 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -2
- package/dist/config.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 +87 -53
- package/dist/dev-compose.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-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 +66 -2
- package/dist/dev-session-lock.d.ts.map +1 -1
- package/dist/dev-session-lock.js +104 -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/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-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/env-file.d.ts +18 -3
- package/dist/env-file.d.ts.map +1 -1
- package/dist/env-file.js +23 -7
- package/dist/env-file.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 +1 -1
- package/dist/frontend-env.js.map +1 -1
- package/dist/functions-deno-types.d.ts.map +1 -1
- package/dist/functions-deno-types.js +5 -5
- package/dist/functions-deno-types.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/release-images.d.ts +6 -6
- package/dist/generated/release-images.js +3 -3
- 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 +4 -2
- package/dist/hooks-generator.js.map +1 -1
- 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/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 +11 -3
- package/dist/init-package-json.d.ts.map +1 -1
- package/dist/init-package-json.js +20 -13
- 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-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/kong-config.d.ts +1 -0
- package/dist/kong-config.d.ts.map +1 -1
- package/dist/kong-config.js +64 -20
- package/dist/kong-config.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 +10 -0
- package/dist/local-secrets.d.ts.map +1 -1
- package/dist/local-secrets.js +13 -0
- package/dist/local-secrets.js.map +1 -1
- package/dist/local-stack-guard.d.ts.map +1 -1
- package/dist/local-stack-guard.js +3 -2
- package/dist/local-stack-guard.js.map +1 -1
- package/dist/local-stack.d.ts.map +1 -1
- package/dist/local-stack.js +7 -6
- 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/model-hooks.d.ts +4 -4
- package/dist/model-hooks.d.ts.map +1 -1
- package/dist/model-hooks.js +13 -7
- package/dist/model-hooks.js.map +1 -1
- package/dist/native-dev-env.d.ts +25 -2
- package/dist/native-dev-env.d.ts.map +1 -1
- package/dist/native-dev-env.js +39 -4
- package/dist/native-dev-env.js.map +1 -1
- package/dist/native-keyspace.d.ts +21 -6
- package/dist/native-keyspace.d.ts.map +1 -1
- package/dist/native-keyspace.js +48 -14
- 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-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/parent-watch.d.ts.map +1 -1
- package/dist/parent-watch.js +4 -8
- package/dist/parent-watch.js.map +1 -1
- package/dist/postgres-ctl.d.ts +31 -5
- package/dist/postgres-ctl.d.ts.map +1 -1
- package/dist/postgres-ctl.js +49 -11
- package/dist/postgres-ctl.js.map +1 -1
- package/dist/postgres-image.d.ts +16 -0
- package/dist/postgres-image.d.ts.map +1 -1
- package/dist/postgres-image.js +34 -11
- package/dist/postgres-image.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 +73 -4
- package/dist/process-manager.d.ts.map +1 -1
- package/dist/process-manager.js +121 -45
- 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 +33 -4
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +5 -1
- package/dist/project-config.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/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 +5 -1
- package/dist/runtime-routes.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-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.d.ts +15 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/self-host-compose.d.ts +15 -1
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +216 -51
- package/dist/self-host-compose.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-setting-warnings.d.ts +2 -1
- package/dist/stack-setting-warnings.d.ts.map +1 -1
- package/dist/stack-setting-warnings.js +6 -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/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +27 -3
- package/dist/type-extractor.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 +24 -11
- package/dist/valkey-sidecar.d.ts.map +1 -1
- package/dist/valkey-sidecar.js +45 -25
- 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 +6 -4
- 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
|
@@ -9,7 +9,8 @@ import { adminEmailProblem, answerProblem, askText, smtpHostProblem, smtpPortPro
|
|
|
9
9
|
import { assertEnvValues } from "../env-value.js";
|
|
10
10
|
import { ensureFunctionsEnvLocal, FUNCTIONS_ENV_LOCAL } from "../functions-env-local.js";
|
|
11
11
|
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";
|
|
12
|
+
import { BUNDLED_DB_USER, CONTROL_PLANE_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";
|
|
13
|
+
import { KEYSPACE_PASSWORD_FILE_ENV, shellNamesKeyspacePasswordFile } from "../keyspace-password-file.js";
|
|
13
14
|
import { file, error, info, plain, warn } from "../ui/messages.js";
|
|
14
15
|
import { nextSteps } from "../ui/next-steps.js";
|
|
15
16
|
import { probeDockerDaemonAsync, reportDockerUnavailable } from "../docker-runtime.js";
|
|
@@ -17,19 +18,25 @@ import { loadConfig } from "../config.js";
|
|
|
17
18
|
import { ensureComponentBinaries, reportComponentBinaryFailures, } from "../ensure-component-binaries.js";
|
|
18
19
|
import { ensureFunctionsDenoTypes, sharedFunctionsReadmeSource, } from "../functions-deno-types.js";
|
|
19
20
|
import { functionTemplateSource } from "../functions-template.js";
|
|
20
|
-
import { mergeSupatypePackageJson, PREPARE_COMMAND, scaffoldPackageJson,
|
|
21
|
+
import { mergeSupatypePackageJson, mergeSupatypeScripts, PREPARE_COMMAND, scaffoldPackageJson, } from "../init-package-json.js";
|
|
22
|
+
import { runsSupatypeDev } from "../dev-self-start.js";
|
|
23
|
+
import { DEFAULT_PROXY_DEV_SCRIPT } from "../app/proxy-dev-app.js";
|
|
21
24
|
import { downloadRelease, initFromExample } from "../init-example.js";
|
|
22
25
|
import { errorMessage } from "../error-message.js";
|
|
23
26
|
import { isJsonObject, parseJsonObject } from "@supatype/shared";
|
|
24
27
|
import { cliPackageVersion } from "../cli-package-version.js";
|
|
25
28
|
import { initDependencyVersionsFallback, resolveInitDependencyVersions, } from "../init-dependency-versions.js";
|
|
26
|
-
import { detectProjectSetup } from "../init-project-detect.js";
|
|
27
|
-
import { SUPATYPE_GITIGNORE_PATHS } from "../gitignore.js";
|
|
29
|
+
import { detectProjectSetup, readPackageJson, VITE_CONFIG_NAMES, withFreeVitePort, } from "../init-project-detect.js";
|
|
30
|
+
import { missingSupatypeIgnores, negationOverrideNotice, SUPATYPE_GITIGNORE_PATHS, withSupatypeIgnores, } from "../gitignore.js";
|
|
28
31
|
import { DEV_FRONTEND_ENV_FILE, writeFrontendEnv } from "../frontend-env.js";
|
|
29
32
|
import { DEFAULT_CLIENT_PATH, DEFAULT_TYPES_PATH } from "../type-generation.js";
|
|
30
33
|
import { COMPOSE_DEV_KONG_PORT, defaultAppStaticDir, NATIVE_DB_PORT, NATIVE_SERVER_PORT, nativeDatabaseUrl, VITE_BUILD_DIR, } from "../project-config.js";
|
|
31
34
|
import { cliDatabaseUrlLines } from "../database-url-owner.js";
|
|
32
35
|
import { scaffoldNextRuntimeEnv } from "../init-next-runtime-env.js";
|
|
36
|
+
import { scaffoldExpoRuntimeEnv } from "../init-expo-runtime-env.js";
|
|
37
|
+
import { refuseAddingViteOnOldNode, refuseViteOnOldNode } from "../init-vite-node.js";
|
|
38
|
+
import { recordInitKongPort } from "../init-port-registry.js";
|
|
39
|
+
import { MAILER_AUTOCONFIRM_NOTE } from "../mailer-autoconfirm.js";
|
|
33
40
|
const STORAGE_PROVIDER_OPTIONS = [
|
|
34
41
|
{ value: "local", label: "Local", hint: "storage you host yourself (SeaweedFS)" },
|
|
35
42
|
{ value: "s3", label: "S3", hint: "external bucket (AWS S3 or compatible)" },
|
|
@@ -140,6 +147,7 @@ async function createProject(args) {
|
|
|
140
147
|
if (name)
|
|
141
148
|
mkdirSync(dir, { recursive: true });
|
|
142
149
|
scaffold(dir, result, await args.deps);
|
|
150
|
+
recordScaffoldedKongPort(dir, result);
|
|
143
151
|
const outcome = await withStepView((view) => runSetupSteps(dir, result.packageManager, wants, view));
|
|
144
152
|
exitOnFailedSetup(outcome, wants, result.packageManager);
|
|
145
153
|
await warnDockerUnavailableForProvider(result.provider, args.daemon);
|
|
@@ -149,7 +157,6 @@ async function createProject(args) {
|
|
|
149
157
|
installed: wants.install && outcome.installOk,
|
|
150
158
|
keysGenerated: outcome.keysGenerated,
|
|
151
159
|
binariesReady: outcome.binariesReady,
|
|
152
|
-
devScript: projectDevScript(dir),
|
|
153
160
|
});
|
|
154
161
|
}
|
|
155
162
|
/** `--no-admin`, or `--admin-email` with `--admin-password`, over the answers. */
|
|
@@ -180,7 +187,7 @@ async function runInteractiveInit(args) {
|
|
|
180
187
|
const { name, dir, defaultName, modeTarget, opts } = args;
|
|
181
188
|
await runClackFlow(async () => {
|
|
182
189
|
p.intro("Create a new Supatype project");
|
|
183
|
-
const detected = detectProjectSetup(dir);
|
|
190
|
+
const detected = await withFreeVitePort(detectProjectSetup(dir));
|
|
184
191
|
if (detected.hasExistingFiles && detected.summaryLines.length > 0) {
|
|
185
192
|
p.note(["Existing project detected:", ...detected.summaryLines.map((line) => ` • ${line}`)].join("\n"));
|
|
186
193
|
}
|
|
@@ -353,14 +360,44 @@ async function promptApp(detected, productionTarget) {
|
|
|
353
360
|
const viteDevUrl = await promptViteDevUrl(detected, productionTarget);
|
|
354
361
|
return { mode, staticDir: await promptStaticDir(detected, viteDevUrl !== undefined), ...(viteDevUrl ? { viteDevUrl } : {}) };
|
|
355
362
|
}
|
|
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
|
-
}
|
|
363
|
+
if (mode === "proxy")
|
|
364
|
+
return promptDevServer(detected, productionTarget);
|
|
362
365
|
return { mode: "none" };
|
|
363
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* The dev server "Local dev server" forwards to, with Vite asked first. The script was asked before
|
|
369
|
+
* Vite and offered `dev`, which in a new folder is init's own `supatype dev`, so dev ran itself as
|
|
370
|
+
* the app. A Vite app runs the `vite` script init adds, at Vite's URL. Any other app runs a script
|
|
371
|
+
* of the project's own: its `dev` or `start` is offered, but never one that runs `supatype dev`.
|
|
372
|
+
*/
|
|
373
|
+
async function promptDevServer(detected, productionTarget) {
|
|
374
|
+
const viteDevUrl = await promptViteDevUrl(detected, productionTarget);
|
|
375
|
+
if (viteDevUrl !== undefined)
|
|
376
|
+
return { mode: "proxy", upstream: viteDevUrl, start: "vite", viteDevUrl };
|
|
377
|
+
const upstream = await askWithDefault("URL of your running dev server", "http://localhost:3000");
|
|
378
|
+
const scripts = mergeSupatypeScripts(detected.packageScripts, { app: { mode: "proxy" }, helloFunction: false });
|
|
379
|
+
const offered = ["dev", DEFAULT_PROXY_DEV_SCRIPT].find((name) => {
|
|
380
|
+
const body = scripts[name];
|
|
381
|
+
return body !== undefined && !runsSupatypeDev(body);
|
|
382
|
+
});
|
|
383
|
+
const chosen = (answer) => answer.trim() || offered;
|
|
384
|
+
const start = chosen(await askText({
|
|
385
|
+
message: "package.json script that starts your dev server",
|
|
386
|
+
...(offered !== undefined && { defaultValue: offered, placeholder: offered }),
|
|
387
|
+
validate: (answer) => devServerScriptProblem(chosen(answer), scripts),
|
|
388
|
+
}));
|
|
389
|
+
return { mode: "proxy", upstream, ...(start !== undefined && { start }) };
|
|
390
|
+
}
|
|
391
|
+
/** Why `script` cannot start the app's dev server, or undefined when it can. */
|
|
392
|
+
function devServerScriptProblem(script, scripts) {
|
|
393
|
+
if (script === undefined)
|
|
394
|
+
return `Enter the package.json script that starts your dev server, like ${DEFAULT_PROXY_DEV_SCRIPT}.`;
|
|
395
|
+
const body = scripts[script];
|
|
396
|
+
if (body !== undefined && runsSupatypeDev(body)) {
|
|
397
|
+
return `"${script}" runs supatype dev, so dev would start itself. Enter the script that starts your frontend's dev server.`;
|
|
398
|
+
}
|
|
399
|
+
return undefined;
|
|
400
|
+
}
|
|
364
401
|
/**
|
|
365
402
|
* The directory a static site is served from, asked after Vite: it was asked before, so a new Vite
|
|
366
403
|
* project was offered ./public. A Vite project is offered its build output, ./dist; a site with no
|
|
@@ -385,6 +422,10 @@ async function promptViteDevUrl(detected, productionTarget) {
|
|
|
385
422
|
}));
|
|
386
423
|
if (!useVite)
|
|
387
424
|
return undefined;
|
|
425
|
+
// Refused here on an old Node, not after every other question (pm N2). An app that lists its
|
|
426
|
+
// own Vite keeps it, so its Node is its own business.
|
|
427
|
+
if (!detected.declaresVite)
|
|
428
|
+
refuseAddingViteOnOldNode();
|
|
388
429
|
return askWithDefault("Vite dev server URL", detected.viteDevUrl);
|
|
389
430
|
}
|
|
390
431
|
// ─── Package manager ───────────────────────────────────────────────────────--
|
|
@@ -496,6 +537,7 @@ export function scaffold(dir, optsOrName, deps = initDependencyVersionsFallback(
|
|
|
496
537
|
};
|
|
497
538
|
// First, so a value .env cannot hold is refused before any file is written.
|
|
498
539
|
const env = envTemplate(opts);
|
|
540
|
+
refuseViteOnOldNode(dir, opts.app.viteDevUrl);
|
|
499
541
|
const pkgPath = join(dir, "package.json");
|
|
500
542
|
if (!existsSync(pkgPath)) {
|
|
501
543
|
write("package.json", scaffoldPackageJson(opts, deps));
|
|
@@ -516,10 +558,21 @@ export function scaffold(dir, optsOrName, deps = initDependencyVersionsFallback(
|
|
|
516
558
|
// The Next.js counterpart of the static page's script tag: the client and @supatype/ssr ship
|
|
517
559
|
// together, so the route's package is added at the client's range.
|
|
518
560
|
scaffoldNextRuntimeEnv(dir, write, `^${deps.client}`);
|
|
561
|
+
// An Expo Router app has neither an index.html nor a root layout: its page is +html.tsx.
|
|
562
|
+
scaffoldExpoRuntimeEnv(dir, write);
|
|
519
563
|
if (opts.helloFunction)
|
|
520
564
|
scaffoldHelloFunction(dir, write);
|
|
521
565
|
scaffoldGitignore(dir, write);
|
|
522
566
|
}
|
|
567
|
+
/**
|
|
568
|
+
* Record the Kong port the project in `dir` was given, so the next init skips it before this project
|
|
569
|
+
* ever starts (FF26, init-port-registry.ts). Outside `scaffold`, which tests call by the hundred and
|
|
570
|
+
* which writes only inside `dir`; this writes under the home folder.
|
|
571
|
+
*/
|
|
572
|
+
export function recordScaffoldedKongPort(dir, opts) {
|
|
573
|
+
if (opts.provider === "docker" && opts.kongPort !== undefined)
|
|
574
|
+
recordInitKongPort(resolve(dir), opts.kongPort);
|
|
575
|
+
}
|
|
523
576
|
/**
|
|
524
577
|
* Supatype's scripts and packages merged into the project's own package.json, saying so when its
|
|
525
578
|
* `prepare` changed: a project's own (husky, say) gets `supatype-prepare` after it, and the one
|
|
@@ -569,13 +622,16 @@ function scaffoldGitignore(dir, write) {
|
|
|
569
622
|
return;
|
|
570
623
|
}
|
|
571
624
|
const existing = readFileSync(gitignorePath, "utf8");
|
|
572
|
-
const
|
|
573
|
-
if (
|
|
625
|
+
const missing = missingSupatypeIgnores(existing);
|
|
626
|
+
if (missing.length === 0) {
|
|
574
627
|
file("skipped", ".gitignore (already exists)");
|
|
575
628
|
return;
|
|
576
629
|
}
|
|
577
|
-
writeFileSync(gitignorePath,
|
|
630
|
+
writeFileSync(gitignorePath, withSupatypeIgnores(existing, missing), "utf8");
|
|
578
631
|
file("updated", ".gitignore (added Supatype's local files)");
|
|
632
|
+
const notice = negationOverrideNotice(existing, missing);
|
|
633
|
+
if (notice !== undefined)
|
|
634
|
+
warn(notice);
|
|
579
635
|
}
|
|
580
636
|
/**
|
|
581
637
|
* The directory a static app is served from: the one typed at init, else the stack's own default
|
|
@@ -597,16 +653,20 @@ function servedStatically(opts) {
|
|
|
597
653
|
return opts.app.mode === "static" || (opts.app.mode === "proxy" && opts.productionTarget !== "later");
|
|
598
654
|
}
|
|
599
655
|
function scaffoldAppAssets(dir, opts, write) {
|
|
656
|
+
const hasVite = Boolean(opts.app.viteDevUrl);
|
|
657
|
+
// 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.
|
|
658
|
+
const appPage = (rel) => (hasVite ? rel === "index.html" : rel.endsWith("index.html"));
|
|
600
659
|
const writeUnlessExists = (rel, content) => {
|
|
601
660
|
const full = join(dir, rel);
|
|
602
661
|
if (existsSync(full)) {
|
|
603
662
|
file("skipped", `${rel} (already exists)`);
|
|
663
|
+
if (servedStatically(opts) && appPage(rel))
|
|
664
|
+
adviseRuntimeEnvScript(full);
|
|
604
665
|
return;
|
|
605
666
|
}
|
|
606
667
|
write(rel, content);
|
|
607
668
|
};
|
|
608
669
|
const holding = holdingPageTemplate(opts.projectName, initLocalApiUrl(opts), servedStatically(opts));
|
|
609
|
-
const hasVite = Boolean(opts.app.viteDevUrl);
|
|
610
670
|
if (opts.app.mode === "static") {
|
|
611
671
|
writeUnlessExists(`${staticDirRelative(staticDirOf(opts.app))}/index.html`, holding);
|
|
612
672
|
if (hasVite)
|
|
@@ -629,12 +689,19 @@ function scaffoldVite(dir, opts, write, holding) {
|
|
|
629
689
|
if (!opts.app.viteDevUrl)
|
|
630
690
|
return;
|
|
631
691
|
write("index.html", holding);
|
|
632
|
-
const viteConfigRel =
|
|
692
|
+
const viteConfigRel = VITE_CONFIG_NAMES.find((name) => existsSync(join(dir, name)));
|
|
633
693
|
if (viteConfigRel) {
|
|
634
694
|
file("skipped", `${viteConfigRel} (already exists)`);
|
|
635
695
|
return;
|
|
636
696
|
}
|
|
637
|
-
write(
|
|
697
|
+
write(newViteConfigName(dir), viteConfigTemplate(opts.app.viteDevUrl, viteBuildOutDir(opts)));
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* `vite.config.ts` in an ESM package, else `vite.config.mts`, which Vite loads as ESM by its
|
|
701
|
+
* extension: init no longer makes an existing app's package ESM (FF24), and the config imports `vite`.
|
|
702
|
+
*/
|
|
703
|
+
function newViteConfigName(dir) {
|
|
704
|
+
return readPackageJson(dir)?.raw["type"] === "module" ? "vite.config.ts" : "vite.config.mts";
|
|
638
705
|
}
|
|
639
706
|
/**
|
|
640
707
|
* Where `vite build` writes, when it is not Vite's own `dist`: the static directory a static app is
|
|
@@ -753,18 +820,24 @@ function localConfigTemplate(app) {
|
|
|
753
820
|
lines.push(`}`, ``, `export default localConfig`, ``);
|
|
754
821
|
return lines.join("\n");
|
|
755
822
|
}
|
|
823
|
+
/**
|
|
824
|
+
* The app block for a dev server. A missing `start` is left out, and dev then runs `start`: it was
|
|
825
|
+
* written as `dev`, which in a new project is init's own `supatype dev`.
|
|
826
|
+
*/
|
|
827
|
+
function proxyAppLines(app) {
|
|
828
|
+
return [
|
|
829
|
+
` app: {`,
|
|
830
|
+
` mode: "proxy",`,
|
|
831
|
+
` upstream: "${app.upstream ?? "http://localhost:3000"}",`,
|
|
832
|
+
...(app.start ? [` start: "${app.start}",`] : []),
|
|
833
|
+
...(app.viteDevUrl ? [` vite_dev_url: "${app.viteDevUrl}",`] : []),
|
|
834
|
+
` },`,
|
|
835
|
+
];
|
|
836
|
+
}
|
|
756
837
|
/** App block for supatype.local.config.ts (proxy + Vite during local dev). */
|
|
757
838
|
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
|
-
}
|
|
839
|
+
if (app.mode === "proxy")
|
|
840
|
+
return proxyAppLines(app);
|
|
768
841
|
if (app.viteDevUrl) {
|
|
769
842
|
return [
|
|
770
843
|
` app: {`,
|
|
@@ -792,16 +865,7 @@ function appConfigLines(app, productionTarget) {
|
|
|
792
865
|
` },`,
|
|
793
866
|
];
|
|
794
867
|
}
|
|
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;
|
|
868
|
+
return proxyAppLines(app);
|
|
805
869
|
}
|
|
806
870
|
return [
|
|
807
871
|
` app: {`,
|
|
@@ -851,10 +915,21 @@ function initSiteUrl(opts) {
|
|
|
851
915
|
* bundle a script the project does not have. Vite drops the attribute from the page it builds, and
|
|
852
916
|
* a browser ignores it in a page nothing builds.
|
|
853
917
|
*/
|
|
918
|
+
const RUNTIME_ENV_TAG = '<script src="/supatype-env.js" vite-ignore></script>';
|
|
854
919
|
const RUNTIME_ENV_SCRIPT = `
|
|
855
920
|
<!-- The deployment's API address and anon key, from the server that serves this page.
|
|
856
921
|
vite-ignore tells Vite to leave it out of the bundle, so the build does not warn. -->
|
|
857
|
-
|
|
922
|
+
${RUNTIME_ENV_TAG}`;
|
|
923
|
+
/**
|
|
924
|
+
* The tag for an app's own page, which init keeps. It used to print only "skipped index.html", and
|
|
925
|
+
* a production build of the page then threw MissingClientValuesError (0.9.2 release test round 2,
|
|
926
|
+
* N-S15).
|
|
927
|
+
*/
|
|
928
|
+
function adviseRuntimeEnvScript(page) {
|
|
929
|
+
if (readFileSync(page, "utf8").includes("/supatype-env.js"))
|
|
930
|
+
return;
|
|
931
|
+
plain(` add ${RUNTIME_ENV_TAG} to its <head>, so a build Supatype serves gets its API URL and anon key`);
|
|
932
|
+
}
|
|
858
933
|
function holdingPageTemplate(projectName, apiUrl, runtimeEnv) {
|
|
859
934
|
const name = escapeHtml(projectName);
|
|
860
935
|
return `<!doctype html>
|
|
@@ -1006,20 +1081,10 @@ ${build} server: {
|
|
|
1006
1081
|
`;
|
|
1007
1082
|
}
|
|
1008
1083
|
function storageConfigLines(storageLocal, storageProduction) {
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
}
|
|
1013
|
-
else {
|
|
1014
|
-
lines.push(` storage: { provider: "local", local_path: ".supatype/storage" },`);
|
|
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;
|
|
1084
|
+
// provider is dev's, production the self-host stack's; S3_* in .env name the bucket for either.
|
|
1085
|
+
const dev = storageLocal === "s3" ? `provider: "s3"` : `provider: "local", local_path: ".supatype/storage"`;
|
|
1086
|
+
const production = storageLocal === "local" && storageProduction === "local" ? "" : `, production: "${storageProduction}"`;
|
|
1087
|
+
return [` storage: { ${dev}${production} },`];
|
|
1023
1088
|
}
|
|
1024
1089
|
function schemaTemplate() {
|
|
1025
1090
|
return `import type { Model, LoggedIn, Owner, Public, Role, SupatypeAuthUserId, UUID } from "@supatype/types"
|
|
@@ -1061,6 +1126,16 @@ function envAnswers(opts) {
|
|
|
1061
1126
|
...(opts.adminPassword !== undefined && { SUPATYPE_ADMIN_PASSWORD: opts.adminPassword }),
|
|
1062
1127
|
};
|
|
1063
1128
|
}
|
|
1129
|
+
/**
|
|
1130
|
+
* The keyspace password's line in the new .env: a generated password, or, when the shell names a
|
|
1131
|
+
* file for it, a note saying so. A password beside the file stops the stack at start (R2-S16).
|
|
1132
|
+
*/
|
|
1133
|
+
function keyspacePasswordLine() {
|
|
1134
|
+
if (!shellNamesKeyspacePasswordFile())
|
|
1135
|
+
return `${KEYSPACE_PASSWORD_ENV}=${randomBytes(24).toString("base64url")}`;
|
|
1136
|
+
return `# Read from the file ${KEYSPACE_PASSWORD_FILE_ENV} names in your shell, so none is written here.
|
|
1137
|
+
# Do not set ${KEYSPACE_PASSWORD_ENV} as well: dev and self-host refuse to start with both.`;
|
|
1138
|
+
}
|
|
1064
1139
|
function envTemplate(opts) {
|
|
1065
1140
|
assertEnvValues(envAnswers(opts), ".env");
|
|
1066
1141
|
const sections = [];
|
|
@@ -1100,6 +1175,11 @@ SERVICE_ROLE_KEY=`);
|
|
|
1100
1175
|
sections.push(`# Shared by the API server and the control plane only. The control plane refuses any
|
|
1101
1176
|
# request without it, so code running in the functions worker cannot call it directly.
|
|
1102
1177
|
${CONTROL_PLANE_SECRET_ENV}=${generateControlPlaneSecret()}`);
|
|
1178
|
+
// Dev wrote it on first start, appended with no comment (0.9.2 release test round 2, R2-S14).
|
|
1179
|
+
sections.push(`# The cache's password when the cache runs in Postgres (pg_keyspace): the keyspace user
|
|
1180
|
+
# \`${KEYSPACE_USERNAME}\`'s, which the API server logs in with, and the gateway when HTTPS is on.
|
|
1181
|
+
# It reads and writes every cached value.
|
|
1182
|
+
${keyspacePasswordLine()}`);
|
|
1103
1183
|
sections.push(`# Site URL (used for email redirects)
|
|
1104
1184
|
SITE_URL=${initSiteUrl(opts)}`);
|
|
1105
1185
|
if (opts.provider === "docker" && opts.kongPort !== undefined) {
|
|
@@ -1110,27 +1190,33 @@ SUPATYPE_KONG_PORT=${opts.kongPort}
|
|
|
1110
1190
|
API_EXTERNAL_URL=${initLocalApiUrl(opts)}`);
|
|
1111
1191
|
}
|
|
1112
1192
|
sections.push(emailEnvSection(opts));
|
|
1193
|
+
// Where the CLI would leave it after taking out a SUPATYPE_MAILER_AUTOCONFIRM an earlier CLI wrote.
|
|
1194
|
+
// Written here, a new project never has that done to a line of the developer's own (FF7).
|
|
1195
|
+
sections.push(MAILER_AUTOCONFIRM_NOTE);
|
|
1113
1196
|
sections.push(storageEnvSections(opts.storageLocal, opts.storageProduction));
|
|
1114
1197
|
if (opts.adminEmail && opts.adminPassword) {
|
|
1115
1198
|
sections.push(`# First Studio admin (/studio/), consumed on first supatype dev or push (password removed after use)
|
|
1116
1199
|
SUPATYPE_ADMIN_EMAIL=${opts.adminEmail}
|
|
1117
1200
|
SUPATYPE_ADMIN_PASSWORD=${opts.adminPassword}`);
|
|
1118
1201
|
}
|
|
1119
|
-
sections.push(
|
|
1202
|
+
sections.push(selfHostPortsEnvSection(opts.storageProduction));
|
|
1120
1203
|
return sections.join("\n\n") + "\n";
|
|
1121
1204
|
}
|
|
1122
1205
|
/**
|
|
1123
1206
|
* 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.
|
|
1207
|
+
* defaults apply; the first anyone heard of these used to be a clash on 5432. A stack on the
|
|
1208
|
+
* project's own S3 bucket runs no SeaweedFS, so it is not named there (0.9.2 release test round 2, N-S26).
|
|
1125
1209
|
*/
|
|
1126
|
-
|
|
1127
|
-
|
|
1210
|
+
function selfHostPortsEnvSection(storageProduction) {
|
|
1211
|
+
const seaweedfs = storageProduction !== "s3";
|
|
1212
|
+
return `# Self-host stack ports (supatype self-host compose). Kong, at SUPATYPE_KONG_PORT, is the way in.
|
|
1213
|
+
# Postgres${seaweedfs ? ", the API server and SeaweedFS" : " and the API server"} bind 127.0.0.1 only. To reach them from other machines,
|
|
1128
1214
|
# set SUPATYPE_PUBLISH_ADDRESS=0.0.0.0 (put a firewall in front of the server first).
|
|
1129
1215
|
# Self-host commands reach Postgres at SUPATYPE_DB_PORT for their own run; DATABASE_URL above stays dev's.
|
|
1130
1216
|
# SUPATYPE_PUBLISH_ADDRESS=127.0.0.1
|
|
1131
1217
|
# SUPATYPE_DB_PORT=5432
|
|
1132
|
-
# SUPATYPE_SERVER_PORT=9999
|
|
1133
|
-
|
|
1218
|
+
# SUPATYPE_SERVER_PORT=9999${seaweedfs ? "\n# SUPATYPE_SEAWEEDFS_PORT=8333" : ""}`;
|
|
1219
|
+
}
|
|
1134
1220
|
/**
|
|
1135
1221
|
* The scaffolded `.env`'s email settings, under the names the auth server reads. They used to be
|
|
1136
1222
|
* written unprefixed (RESEND_API_KEY, SES_FROM, SMTP_HOST), which nothing reads, so a developer who
|
|
@@ -1158,7 +1244,6 @@ SUPATYPE_SMTP_SENDER_NAME=${projectName}`;
|
|
|
1158
1244
|
case "console":
|
|
1159
1245
|
default:
|
|
1160
1246
|
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
1247
|
# SUPATYPE_SMTP_HOST=
|
|
1163
1248
|
# SUPATYPE_SMTP_PORT=587
|
|
1164
1249
|
# SUPATYPE_SMTP_USER=
|
|
@@ -1169,13 +1254,7 @@ SUPATYPE_SMTP_SENDER_NAME=${projectName}`;
|
|
|
1169
1254
|
function storageEnvSections(storageLocal, storageProduction) {
|
|
1170
1255
|
if (storageLocal === storageProduction) {
|
|
1171
1256
|
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=`;
|
|
1257
|
+
return s3EnvSection("local development and production", "Use a separate bucket for dev and production.");
|
|
1179
1258
|
}
|
|
1180
1259
|
return `${localStorageEnvSection("local")}
|
|
1181
1260
|
|
|
@@ -1184,36 +1263,50 @@ S3_SECRET_KEY=`;
|
|
|
1184
1263
|
}
|
|
1185
1264
|
return [localStorageEnvSection(storageLocal), productionStorageEnvSection(storageProduction)].join("\n\n");
|
|
1186
1265
|
}
|
|
1187
|
-
/**
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
function
|
|
1192
|
-
|
|
1193
|
-
|
|
1266
|
+
/**
|
|
1267
|
+
* The settings for a bucket of your own (storage.provider "s3"), described as the storage service
|
|
1268
|
+
* uses them: one S3 bucket, every Supatype bucket a key prefix in it, as Supabase Storage keeps them.
|
|
1269
|
+
*/
|
|
1270
|
+
function s3EnvSection(use, note) {
|
|
1271
|
+
return `# Storage (${use}, your own S3 bucket)
|
|
1272
|
+
# Every Supatype bucket is a folder (key prefix) in S3_BUCKET, and the storage service serves every
|
|
1273
|
+
# file, public ones included, so the bucket itself stays private. The keys need only read, write,
|
|
1274
|
+
# list and delete on that one bucket.${note === undefined ? "" : ` ${note}`}
|
|
1275
|
+
# AWS: set S3_REGION and leave S3_ENDPOINT blank. Another S3-compatible store (Cloudflare R2,
|
|
1276
|
+
# SeaweedFS, and the like): set S3_ENDPOINT too. On AWS, leave both keys blank to use the AWS SDK's
|
|
1277
|
+
# own credentials (an instance or task role, AWS_PROFILE).
|
|
1278
|
+
# In the self-host stack the storage service runs in a container, where localhost is that container.
|
|
1279
|
+
# For a store on the same machine use http://host.docker.internal:<port> with Docker Desktop, or on
|
|
1280
|
+
# Linux the host's Docker bridge address (usually 172.17.0.1). Native supatype dev can use localhost.
|
|
1194
1281
|
S3_ENDPOINT=
|
|
1195
1282
|
S3_REGION=us-east-1
|
|
1196
1283
|
S3_BUCKET=
|
|
1197
1284
|
S3_ACCESS_KEY=
|
|
1198
1285
|
S3_SECRET_KEY=`;
|
|
1199
|
-
|
|
1286
|
+
}
|
|
1287
|
+
/** Whether init generates the object store's login: for the local SeaweedFS, not a bucket of your own. */
|
|
1288
|
+
function generatesObjectStoreLogin(storage) {
|
|
1289
|
+
return storage !== "s3";
|
|
1290
|
+
}
|
|
1291
|
+
/**
|
|
1292
|
+
* Dev's storage settings. Local SeaweedFS takes no S3_* names: the compose file hands the storage
|
|
1293
|
+
* service its address itself. The S3_ENDPOINT=http://localhost:8333 written here was read by
|
|
1294
|
+
* nothing, named the storage container itself from inside it, and stayed behind when a project
|
|
1295
|
+
* moved to its own bucket (0.9.2 release test round 2, N-S26).
|
|
1296
|
+
*/
|
|
1297
|
+
function localStorageEnvSection(storage) {
|
|
1298
|
+
if (!generatesObjectStoreLogin(storage))
|
|
1299
|
+
return s3EnvSection("local development");
|
|
1200
1300
|
const login = generateObjectStoreCredentials();
|
|
1201
1301
|
return `# Storage (local development, SeaweedFS)
|
|
1202
1302
|
# The object store's login, generated for this project. It opens every file in every bucket, so
|
|
1203
1303
|
# keep it as private as the database password.
|
|
1204
|
-
S3_ENDPOINT=http://localhost:8333
|
|
1205
1304
|
${OBJECT_STORE_ACCESS_KEY_ENV}=${login.accessKey}
|
|
1206
1305
|
${OBJECT_STORE_SECRET_KEY_ENV}=${login.secretKey}`;
|
|
1207
1306
|
}
|
|
1208
1307
|
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
|
-
}
|
|
1308
|
+
if (storage === "s3")
|
|
1309
|
+
return s3EnvSection("production");
|
|
1217
1310
|
return `# Storage (production, SeaweedFS on your server)
|
|
1218
1311
|
# Included in the self-host compose stack, no extra configuration needed.`;
|
|
1219
1312
|
}
|
|
@@ -1266,22 +1359,6 @@ node_modules/
|
|
|
1266
1359
|
dist/
|
|
1267
1360
|
`;
|
|
1268
1361
|
}
|
|
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
1362
|
// ─── Next steps ────────────────────────────────────────────────────────────--
|
|
1286
1363
|
/** Say so when a Docker project's Docker is not running: from `started` when init already asked. */
|
|
1287
1364
|
async function warnDockerUnavailableForProvider(provider, started) {
|
|
@@ -1305,16 +1382,6 @@ function startInitQuestions(provider) {
|
|
|
1305
1382
|
const kongPort = import("../dev-ports.js").then(({ chooseInitKongPort }) => chooseInitKongPort());
|
|
1306
1383
|
return { kongPort, daemon: probeDockerDaemonAsync(), deps };
|
|
1307
1384
|
}
|
|
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
1385
|
/** True when nothing is left to set up, only to run. */
|
|
1319
1386
|
function initSetupComplete(args) {
|
|
1320
1387
|
return args.installed && args.keysGenerated && args.binariesReady;
|
|
@@ -1375,9 +1442,11 @@ function commented(command, comments) {
|
|
|
1375
1442
|
return comments.map((comment, index) => `${(index === 0 ? command : "").padEnd(column)}# ${comment}`);
|
|
1376
1443
|
}
|
|
1377
1444
|
/**
|
|
1378
|
-
*
|
|
1445
|
+
* `supatype dev`, which applies the schema and generates the types, then watches both; then where
|
|
1379
1446
|
* to open the project. `push` is for another database (`push --env <name>`), and listing it here
|
|
1380
|
-
* sent people to it anyway.
|
|
1447
|
+
* sent people to it anyway. The command as the docs give it: init printed the package.json script
|
|
1448
|
+
* (`npm run supatype:dev` beside a framework's own dev), which no page of the docs names
|
|
1449
|
+
* (0.9.2 release test round 2, N-S15).
|
|
1381
1450
|
*/
|
|
1382
1451
|
function initDevSteps(args) {
|
|
1383
1452
|
const { result } = args;
|
|
@@ -1387,7 +1456,7 @@ function initDevSteps(args) {
|
|
|
1387
1456
|
];
|
|
1388
1457
|
if (result.adminEmail)
|
|
1389
1458
|
comments.push("first admin user is created on dev");
|
|
1390
|
-
const steps = commented(
|
|
1459
|
+
const steps = commented("supatype dev", comments);
|
|
1391
1460
|
steps.push(`Open ${initLocalApiUrl(result)}`);
|
|
1392
1461
|
if (result.helloFunction) {
|
|
1393
1462
|
steps.push(...commented(runScriptCommand(result.packageManager, "functions"), ["run edge functions locally"]));
|
|
@@ -1404,6 +1473,7 @@ const INIT_SECRETS = [
|
|
|
1404
1473
|
["AUTHENTICATOR_PASSWORD", "PostgREST's own login; rotating the one above does not affect it"],
|
|
1405
1474
|
["SUPATYPE_SQL_EDITOR_PASSWORD", "Studio's SQL editor login, a role that is not a superuser"],
|
|
1406
1475
|
["JWT_SECRET", "signs ANON_KEY and SERVICE_ROLE_KEY; changing it invalidates every token"],
|
|
1476
|
+
[KEYSPACE_PASSWORD_ENV, "the cache's login, which reads and writes every cached value"],
|
|
1407
1477
|
];
|
|
1408
1478
|
/** The object store's login, when init generates one ({@link generatesObjectStoreLogin}). */
|
|
1409
1479
|
const OBJECT_STORE_SECRETS = [
|
|
@@ -1416,7 +1486,8 @@ const SECRETS_CLOSING = "Keep .env out of version control, and use different val
|
|
|
1416
1486
|
* development storage in an S3 bucket of your own, init generates no object-store login.
|
|
1417
1487
|
*/
|
|
1418
1488
|
export function initSecretLines(storageLocal = "local") {
|
|
1419
|
-
const
|
|
1489
|
+
const generated = shellNamesKeyspacePasswordFile() ? INIT_SECRETS.filter(([name]) => name !== KEYSPACE_PASSWORD_ENV) : INIT_SECRETS;
|
|
1490
|
+
const secrets = generatesObjectStoreLogin(storageLocal) ? [...generated, ...OBJECT_STORE_SECRETS] : generated;
|
|
1420
1491
|
const width = Math.max(...secrets.map(([name]) => name.length)) + 2;
|
|
1421
1492
|
return secrets.map(([name, description]) => `${name.padEnd(width)}${description}`);
|
|
1422
1493
|
}
|
|
@@ -1438,6 +1509,11 @@ function deployBlock(result) {
|
|
|
1438
1509
|
}
|
|
1439
1510
|
return undefined;
|
|
1440
1511
|
}
|
|
1512
|
+
/**
|
|
1513
|
+
* The server's bucket, for production storage on S3: compose refuses to start without S3_BUCKET,
|
|
1514
|
+
* and init's steps never named it (0.9.2 release test round 2, N-S26).
|
|
1515
|
+
*/
|
|
1516
|
+
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
1517
|
/**
|
|
1442
1518
|
* Taking a self-host project to its own server. With a domain, DNS and the firewall come first;
|
|
1443
1519
|
* without one, HTTPS is the last step and an optional one, since the person just said they had none.
|
|
@@ -1445,8 +1521,10 @@ function deployBlock(result) {
|
|
|
1445
1521
|
export function selfHostDeploySteps(result) {
|
|
1446
1522
|
const domain = result.domain?.trim();
|
|
1447
1523
|
const link = "supatype link --env production ... # then: supatype push --env production";
|
|
1524
|
+
const bucket = result.storageProduction === "s3" ? [S3_BUCKET_STEP] : [];
|
|
1448
1525
|
if (!domain) {
|
|
1449
1526
|
return [
|
|
1527
|
+
...bucket,
|
|
1450
1528
|
"supatype self-host compose up -d # on your server: the Docker stack",
|
|
1451
1529
|
link,
|
|
1452
1530
|
BUILD_STEP,
|
|
@@ -1457,6 +1535,7 @@ export function selfHostDeploySteps(result) {
|
|
|
1457
1535
|
`1. Point DNS: an A record for ${domain} -> your server's public IP`,
|
|
1458
1536
|
"2. Open ports 80 and 443 on the server firewall",
|
|
1459
1537
|
...(result.tlsEmail ? [] : ["3. Set server.tls.email in supatype.config.ts (required for HTTPS)"]),
|
|
1538
|
+
...bucket,
|
|
1460
1539
|
"supatype self-host compose up -d # Kong provisions HTTPS automatically",
|
|
1461
1540
|
link,
|
|
1462
1541
|
BUILD_STEP,
|