@supatype/cli 0.1.0-alpha.8 → 0.1.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/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-test.log +274 -69
- package/.turbo/turbo-typecheck.log +1 -1
- package/assets/supatype-logo-wordmark.ascii.txt +6 -0
- package/bin/dev-entry.ts +2 -1
- package/dist/app/framework.js +1 -3
- package/dist/app/framework.js.map +1 -1
- package/dist/app/proxy-dev-app.d.ts +14 -0
- package/dist/app/proxy-dev-app.d.ts.map +1 -1
- package/dist/app/proxy-dev-app.js +110 -6
- package/dist/app/proxy-dev-app.js.map +1 -1
- package/dist/app-config.d.ts +10 -0
- package/dist/app-config.d.ts.map +1 -1
- package/dist/app-config.js +72 -0
- package/dist/app-config.js.map +1 -1
- package/dist/assets/supatype-logo-wordmark.ascii.txt +6 -0
- package/dist/binary-cache.d.ts +19 -7
- package/dist/binary-cache.d.ts.map +1 -1
- package/dist/binary-cache.js +92 -46
- package/dist/binary-cache.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +17 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/add.d.ts +3 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +86 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +39 -53
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/adopt.d.ts +3 -0
- package/dist/commands/adopt.d.ts.map +1 -0
- package/dist/commands/adopt.js +55 -0
- package/dist/commands/adopt.js.map +1 -0
- package/dist/commands/app.d.ts.map +1 -1
- package/dist/commands/app.js +20 -17
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/cache.d.ts.map +1 -1
- package/dist/commands/cache.js +11 -10
- package/dist/commands/cache.js.map +1 -1
- package/dist/commands/cloud.d.ts +4 -9
- package/dist/commands/cloud.d.ts.map +1 -1
- package/dist/commands/cloud.js +75 -125
- package/dist/commands/cloud.js.map +1 -1
- package/dist/commands/db.d.ts.map +1 -1
- package/dist/commands/db.js +37 -58
- package/dist/commands/db.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +140 -96
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +72 -39
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +39 -39
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +78 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/engine.d.ts.map +1 -1
- package/dist/commands/engine.js +5 -4
- package/dist/commands/engine.js.map +1 -1
- package/dist/commands/functions.d.ts.map +1 -1
- package/dist/commands/functions.js +172 -119
- package/dist/commands/functions.js.map +1 -1
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +5 -4
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/init.d.ts +30 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +814 -107
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/introspect.d.ts +3 -0
- package/dist/commands/introspect.d.ts.map +1 -0
- package/dist/commands/introspect.js +35 -0
- package/dist/commands/introspect.js.map +1 -0
- package/dist/commands/keys.d.ts +15 -1
- package/dist/commands/keys.d.ts.map +1 -1
- package/dist/commands/keys.js +46 -10
- package/dist/commands/keys.js.map +1 -1
- package/dist/commands/link-helpers.d.ts +15 -0
- package/dist/commands/link-helpers.d.ts.map +1 -0
- package/dist/commands/link-helpers.js +225 -0
- package/dist/commands/link-helpers.js.map +1 -0
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +5 -4
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/migrate-from-v1.d.ts.map +1 -1
- package/dist/commands/migrate-from-v1.js +3 -2
- package/dist/commands/migrate-from-v1.js.map +1 -1
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +119 -26
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/pg.d.ts.map +1 -1
- package/dist/commands/pg.js +11 -12
- package/dist/commands/pg.js.map +1 -1
- package/dist/commands/plugins.d.ts.map +1 -1
- package/dist/commands/plugins.js +55 -46
- package/dist/commands/plugins.js.map +1 -1
- package/dist/commands/pull.d.ts.map +1 -1
- package/dist/commands/pull.js +33 -5
- package/dist/commands/pull.js.map +1 -1
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +110 -137
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/seed.d.ts.map +1 -1
- package/dist/commands/seed.js +4 -3
- package/dist/commands/seed.js.map +1 -1
- package/dist/commands/self-host.d.ts +2 -2
- package/dist/commands/self-host.d.ts.map +1 -1
- package/dist/commands/self-host.js +65 -50
- package/dist/commands/self-host.js.map +1 -1
- package/dist/commands/self-update.d.ts.map +1 -1
- package/dist/commands/self-update.js +3 -2
- package/dist/commands/self-update.js.map +1 -1
- package/dist/commands/status.d.ts +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +95 -29
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/types.js +3 -2
- package/dist/commands/types.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +54 -21
- package/dist/commands/update.js.map +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/dev-compose.d.ts +26 -0
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +328 -34
- package/dist/dev-compose.js.map +1 -1
- package/dist/dev-log-bus.d.ts +30 -0
- package/dist/dev-log-bus.d.ts.map +1 -0
- package/dist/dev-log-bus.js +87 -0
- package/dist/dev-log-bus.js.map +1 -0
- package/dist/dev-log-filter.d.ts +10 -0
- package/dist/dev-log-filter.d.ts.map +1 -0
- package/dist/dev-log-filter.js +36 -0
- package/dist/dev-log-filter.js.map +1 -0
- package/dist/dev-logo.d.ts +12 -0
- package/dist/dev-logo.d.ts.map +1 -0
- package/dist/dev-logo.js +56 -0
- package/dist/dev-logo.js.map +1 -0
- package/dist/dev-session.d.ts +26 -0
- package/dist/dev-session.d.ts.map +1 -0
- package/dist/dev-session.js +106 -0
- package/dist/dev-session.js.map +1 -0
- package/dist/dev-shutdown.d.ts +9 -0
- package/dist/dev-shutdown.d.ts.map +1 -0
- package/dist/dev-shutdown.js +50 -0
- package/dist/dev-shutdown.js.map +1 -0
- package/dist/dev-task-colors.d.ts +13 -0
- package/dist/dev-task-colors.d.ts.map +1 -0
- package/dist/dev-task-colors.js +43 -0
- package/dist/dev-task-colors.js.map +1 -0
- package/dist/dev-tui.d.ts +24 -0
- package/dist/dev-tui.d.ts.map +1 -0
- package/dist/dev-tui.js +188 -0
- package/dist/dev-tui.js.map +1 -0
- package/dist/diff-output.d.ts +5 -1
- package/dist/diff-output.d.ts.map +1 -1
- package/dist/diff-output.js +69 -0
- package/dist/diff-output.js.map +1 -1
- package/dist/docker-runtime.d.ts +30 -0
- package/dist/docker-runtime.d.ts.map +1 -0
- package/dist/docker-runtime.js +118 -0
- package/dist/docker-runtime.js.map +1 -0
- package/dist/engine-client.d.ts +10 -1
- package/dist/engine-client.d.ts.map +1 -1
- package/dist/engine-client.js +76 -17
- package/dist/engine-client.js.map +1 -1
- package/dist/engine-push-output.d.ts +17 -0
- package/dist/engine-push-output.d.ts.map +1 -0
- package/dist/engine-push-output.js +64 -0
- package/dist/engine-push-output.js.map +1 -0
- package/dist/ensure-binary.js +2 -2
- package/dist/ensure-binary.js.map +1 -1
- package/dist/gitignore.d.ts +8 -0
- package/dist/gitignore.d.ts.map +1 -0
- package/dist/gitignore.js +41 -0
- package/dist/gitignore.js.map +1 -0
- package/dist/kong-config.d.ts +9 -0
- package/dist/kong-config.d.ts.map +1 -1
- package/dist/kong-config.js +18 -1
- package/dist/kong-config.js.map +1 -1
- package/dist/link.d.ts +66 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +160 -0
- package/dist/link.js.map +1 -0
- package/dist/process-manager.d.ts +8 -0
- package/dist/process-manager.d.ts.map +1 -1
- package/dist/process-manager.js +53 -9
- package/dist/process-manager.js.map +1 -1
- package/dist/project-config.d.ts +30 -3
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +37 -4
- package/dist/project-config.js.map +1 -1
- package/dist/prompts.d.ts +3 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +3 -0
- package/dist/prompts.js.map +1 -0
- package/dist/pull-utils.d.ts +50 -14
- package/dist/pull-utils.d.ts.map +1 -1
- package/dist/pull-utils.js +152 -12
- package/dist/pull-utils.js.map +1 -1
- package/dist/resolve-target.d.ts +86 -0
- package/dist/resolve-target.d.ts.map +1 -0
- package/dist/resolve-target.js +291 -0
- package/dist/resolve-target.js.map +1 -0
- package/dist/restore-system-relation-targets.d.ts +3 -0
- package/dist/restore-system-relation-targets.d.ts.map +1 -0
- package/dist/restore-system-relation-targets.js +45 -0
- package/dist/restore-system-relation-targets.js.map +1 -0
- package/dist/runtime-routes.d.ts.map +1 -1
- package/dist/runtime-routes.js +7 -0
- package/dist/runtime-routes.js.map +1 -1
- package/dist/schema-ast-v2.d.ts +1 -1
- package/dist/schema-ast-v2.d.ts.map +1 -1
- package/dist/schema-ast-v2.js +2 -2
- package/dist/schema-ast-v2.js.map +1 -1
- package/dist/schema-sources.d.ts +40 -0
- package/dist/schema-sources.d.ts.map +1 -0
- package/dist/schema-sources.js +183 -0
- package/dist/schema-sources.js.map +1 -0
- package/dist/scripts/postinstall.js +5 -1
- package/dist/scripts/postinstall.js.map +1 -1
- package/dist/seed.d.ts +8 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +32 -0
- package/dist/seed.js.map +1 -0
- package/dist/self-host-compose.d.ts +37 -1
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +233 -43
- package/dist/self-host-compose.js.map +1 -1
- package/dist/storage-provision.d.ts +4 -0
- package/dist/storage-provision.d.ts.map +1 -1
- package/dist/storage-provision.js +24 -2
- package/dist/storage-provision.js.map +1 -1
- package/dist/supatype-eval-1781522769253.d.mts +2 -0
- package/dist/supatype-eval-1781522769253.d.mts.map +1 -0
- package/dist/supatype-eval-1781522769253.mjs +3 -0
- package/dist/supatype-eval-1781522769253.mjs.map +1 -0
- package/dist/systemd.js +2 -2
- package/dist/systemd.js.map +1 -1
- package/dist/target-client.d.ts +10 -0
- package/dist/target-client.d.ts.map +1 -0
- package/dist/target-client.js +22 -0
- package/dist/target-client.js.map +1 -0
- package/dist/type-extractor.d.ts +11 -0
- package/dist/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +95 -8
- package/dist/type-extractor.js.map +1 -1
- package/dist/ui/brand.d.ts +9 -0
- package/dist/ui/brand.d.ts.map +1 -0
- package/dist/ui/brand.js +11 -0
- package/dist/ui/brand.js.map +1 -0
- package/dist/ui/confirm.d.ts +12 -0
- package/dist/ui/confirm.d.ts.map +1 -0
- package/dist/ui/confirm.js +28 -0
- package/dist/ui/confirm.js.map +1 -0
- package/dist/ui/fatal.d.ts +10 -0
- package/dist/ui/fatal.d.ts.map +1 -0
- package/dist/ui/fatal.js +34 -0
- package/dist/ui/fatal.js.map +1 -0
- package/dist/ui/index.d.ts +9 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +9 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/interactive.d.ts +3 -0
- package/dist/ui/interactive.d.ts.map +1 -0
- package/dist/ui/interactive.js +5 -0
- package/dist/ui/interactive.js.map +1 -0
- package/dist/ui/messages.d.ts +10 -0
- package/dist/ui/messages.d.ts.map +1 -0
- package/dist/ui/messages.js +35 -0
- package/dist/ui/messages.js.map +1 -0
- package/dist/ui/next-steps.d.ts +3 -0
- package/dist/ui/next-steps.d.ts.map +1 -0
- package/dist/ui/next-steps.js +10 -0
- package/dist/ui/next-steps.js.map +1 -0
- package/dist/ui/progress.d.ts +5 -0
- package/dist/ui/progress.d.ts.map +1 -0
- package/dist/ui/progress.js +24 -0
- package/dist/ui/progress.js.map +1 -0
- package/dist/ui/prompts.d.ts +14 -0
- package/dist/ui/prompts.d.ts.map +1 -0
- package/dist/ui/prompts.js +34 -0
- package/dist/ui/prompts.js.map +1 -0
- package/package.json +9 -4
- package/src/app/framework.ts +1 -3
- package/src/app/proxy-dev-app.ts +114 -6
- package/src/app-config.ts +80 -0
- package/src/binary-cache.ts +102 -52
- package/src/cli.ts +16 -2
- package/src/commands/add.ts +97 -0
- package/src/commands/admin.ts +39 -73
- package/src/commands/adopt.ts +82 -0
- package/src/commands/app.ts +20 -17
- package/src/commands/cache.ts +11 -10
- package/src/commands/cloud.ts +91 -142
- package/src/commands/db.ts +40 -63
- package/src/commands/deploy.ts +186 -126
- package/src/commands/dev.ts +95 -55
- package/src/commands/diff.ts +52 -43
- package/src/commands/doctor.ts +103 -0
- package/src/commands/engine.ts +5 -4
- package/src/commands/functions.ts +187 -123
- package/src/commands/generate.ts +5 -4
- package/src/commands/init.ts +996 -105
- package/src/commands/introspect.ts +48 -0
- package/src/commands/keys.ts +56 -14
- package/src/commands/link-helpers.ts +273 -0
- package/src/commands/logs.ts +5 -4
- package/src/commands/migrate-from-v1.ts +3 -2
- package/src/commands/migrate.ts +167 -27
- package/src/commands/pg.ts +13 -18
- package/src/commands/plugins.ts +55 -46
- package/src/commands/pull.ts +38 -9
- package/src/commands/push.ts +147 -174
- package/src/commands/seed.ts +5 -4
- package/src/commands/self-host.ts +85 -54
- package/src/commands/self-update.ts +3 -2
- package/src/commands/status.ts +102 -33
- package/src/commands/types.ts +3 -2
- package/src/commands/update.ts +59 -23
- package/src/config.ts +2 -1
- package/src/dev-compose.ts +426 -34
- package/src/dev-log-bus.ts +101 -0
- package/src/dev-log-filter.ts +32 -0
- package/src/dev-logo.ts +61 -0
- package/src/dev-session.ts +130 -0
- package/src/dev-shutdown.ts +54 -0
- package/src/dev-task-colors.ts +47 -0
- package/src/dev-tui.ts +232 -0
- package/src/diff-output.ts +79 -1
- package/src/docker-runtime.ts +151 -0
- package/src/engine-client.ts +81 -17
- package/src/engine-push-output.ts +75 -0
- package/src/ensure-binary.ts +2 -2
- package/src/gitignore.ts +48 -0
- package/src/kong-config.ts +24 -1
- package/src/link.ts +243 -0
- package/src/process-manager.ts +66 -10
- package/src/project-config.ts +62 -7
- package/src/prompts.ts +2 -0
- package/src/pull-utils.ts +217 -23
- package/src/resolve-target.ts +419 -0
- package/src/restore-system-relation-targets.ts +45 -0
- package/src/runtime-routes.ts +7 -0
- package/src/schema-ast-v2.ts +2 -1
- package/src/schema-sources.ts +248 -0
- package/src/scripts/postinstall.ts +7 -1
- package/src/seed.ts +43 -0
- package/src/self-host-compose.ts +261 -46
- package/src/storage-provision.ts +33 -1
- package/src/supatype-eval-1781522769253.mts +1 -0
- package/src/systemd.ts +2 -2
- package/src/target-client.ts +40 -0
- package/src/type-extractor.ts +124 -11
- package/src/ui/README.md +17 -0
- package/src/ui/brand.ts +12 -0
- package/src/ui/confirm.ts +38 -0
- package/src/ui/fatal.ts +43 -0
- package/src/ui/index.ts +8 -0
- package/src/ui/interactive.ts +4 -0
- package/src/ui/messages.ts +43 -0
- package/src/ui/next-steps.ts +10 -0
- package/src/ui/progress.ts +28 -0
- package/src/ui/prompts.ts +40 -0
- package/tests/cli-help.test.ts +27 -2
- package/tests/config.test.ts +29 -2
- package/tests/dev-ui.test.ts +139 -0
- package/tests/docker-runtime.test.ts +236 -0
- package/tests/engine-push-output.test.ts +67 -0
- package/tests/init.test.ts +197 -18
- package/tests/link.test.ts +148 -0
- package/tests/minisign.test.ts +102 -0
- package/tests/proxy-dev-app.test.ts +45 -1
- package/tests/pull-utils.test.ts +5 -4
- package/tests/runtime-contract.test.ts +186 -2
- package/tests/schema-sources.test.ts +119 -0
- package/tests/storage-provision.test.ts +100 -0
- package/tests/ui-confirm.test.ts +41 -0
- package/tests/ui-messages.test.ts +66 -0
- package/tsconfig.tsbuildinfo +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { resolve, join, dirname } from "node:path";
|
|
2
|
+
import { resolve, join, dirname, basename } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import {
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
import * as p from "@clack/prompts";
|
|
6
|
+
import { ensureNotCancelled, printLogo } from "../ui/prompts.js";
|
|
7
|
+
import { generateAndWriteKeys } from "./keys.js";
|
|
8
|
+
import { file, error, info, plain, warn } from "../ui/messages.js";
|
|
9
|
+
import { nextSteps } from "../ui/next-steps.js";
|
|
10
|
+
import { probeDockerDaemon, reportDockerUnavailable } from "../docker-runtime.js";
|
|
5
11
|
export { scaffold };
|
|
6
12
|
// ─── Markers used by `supatype app add / remove` (app.ts) ────────────────────
|
|
7
13
|
export const APP_COMPOSE_MARKER = " # ─── App service (run: supatype app add) ───";
|
|
@@ -16,145 +22,684 @@ function cliPackageVersion() {
|
|
|
16
22
|
return "0.1.0";
|
|
17
23
|
}
|
|
18
24
|
}
|
|
25
|
+
const STORAGE_PROVIDER_OPTIONS = [
|
|
26
|
+
{ value: "local", label: "Local", hint: "storage you host yourself (MinIO)" },
|
|
27
|
+
{ value: "s3", label: "S3", hint: "external bucket (AWS S3 or compatible)" },
|
|
28
|
+
];
|
|
29
|
+
/** `--mode dev|standalone` is mapped onto a production target for back-compat. */
|
|
30
|
+
function productionTargetFromMode(mode) {
|
|
31
|
+
return mode === "standalone" ? "self-host" : "later";
|
|
32
|
+
}
|
|
33
|
+
/** supatype-server mode written to the committed config for a production target. */
|
|
34
|
+
function serverModeForTarget(target) {
|
|
35
|
+
switch (target) {
|
|
36
|
+
case "cloud":
|
|
37
|
+
return "managed";
|
|
38
|
+
case "self-host":
|
|
39
|
+
return "standalone";
|
|
40
|
+
case "later":
|
|
41
|
+
return "dev";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function defaultScaffoldOptions(projectName, productionTarget = "later") {
|
|
45
|
+
return {
|
|
46
|
+
projectName,
|
|
47
|
+
provider: "docker",
|
|
48
|
+
productionTarget,
|
|
49
|
+
...(productionTarget === "self-host" ? { domain: "" } : {}),
|
|
50
|
+
schemaPath: "schema/index.ts",
|
|
51
|
+
app: { mode: "none" },
|
|
52
|
+
email: "console",
|
|
53
|
+
storageLocal: "local",
|
|
54
|
+
storageProduction: "local",
|
|
55
|
+
helloFunction: false,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
19
58
|
export function registerInit(program) {
|
|
20
59
|
program
|
|
21
60
|
.command("init [name]")
|
|
22
61
|
.description("Scaffold a new Supatype project")
|
|
23
|
-
.option("--mode <mode>", "
|
|
24
|
-
.
|
|
25
|
-
|
|
62
|
+
.option("--mode <mode>", "Back-compat: dev (default, local only) | standalone (self-host production target)", "dev")
|
|
63
|
+
.option("-y, --defaults", "Skip all prompts and use sensible defaults")
|
|
64
|
+
.option("--no-install", "Do not run the package manager install step")
|
|
65
|
+
.option("--no-keys", "Do not generate ANON_KEY / SERVICE_ROLE_KEY")
|
|
66
|
+
.action(async (name, opts) => {
|
|
26
67
|
const dir = name ? resolve(process.cwd(), name) : process.cwd();
|
|
27
68
|
if (name && existsSync(dir)) {
|
|
28
|
-
|
|
69
|
+
error(`Directory already exists: ${dir}`);
|
|
29
70
|
process.exit(1);
|
|
30
71
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
72
|
+
const defaultName = name ?? basename(dir) ?? "my-project";
|
|
73
|
+
const interactive = !opts.defaults && Boolean(process.stdin.isTTY);
|
|
74
|
+
const modeTarget = productionTargetFromMode(opts.mode);
|
|
75
|
+
let result;
|
|
76
|
+
if (interactive) {
|
|
77
|
+
printLogo();
|
|
78
|
+
result = await runWizard(defaultName, modeTarget);
|
|
37
79
|
}
|
|
38
|
-
|
|
39
|
-
|
|
80
|
+
else {
|
|
81
|
+
result = {
|
|
82
|
+
...defaultScaffoldOptions(defaultName, modeTarget),
|
|
83
|
+
packageManager: detectInvokingPackageManager(),
|
|
84
|
+
install: true,
|
|
85
|
+
generateKeys: true,
|
|
86
|
+
};
|
|
40
87
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
88
|
+
// CLI flags override wizard / default action choices.
|
|
89
|
+
const doInstall = opts.install !== false && result.install;
|
|
90
|
+
const doKeys = opts.keys !== false && result.generateKeys;
|
|
44
91
|
if (name)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
92
|
+
mkdirSync(dir, { recursive: true });
|
|
93
|
+
scaffold(dir, result);
|
|
94
|
+
if (doInstall)
|
|
95
|
+
runInstall(dir, result.packageManager);
|
|
96
|
+
const keysGenerated = doKeys ? writeKeys(dir) : false;
|
|
97
|
+
warnDockerUnavailableForProvider(result.provider);
|
|
98
|
+
printNextSteps({
|
|
99
|
+
name,
|
|
100
|
+
result,
|
|
101
|
+
installed: doInstall,
|
|
102
|
+
keysGenerated,
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// ─── Wizard ──────────────────────────────────────────────────────────────────
|
|
107
|
+
async function runWizard(defaultName, defaultTarget) {
|
|
108
|
+
p.intro("Create a new Supatype project");
|
|
109
|
+
const projectName = ensureNotCancelled(await p.text({
|
|
110
|
+
message: "Project name",
|
|
111
|
+
defaultValue: defaultName,
|
|
112
|
+
placeholder: defaultName,
|
|
113
|
+
})).trim() || defaultName;
|
|
114
|
+
const packageManager = ensureNotCancelled(await p.select({
|
|
115
|
+
message: "Package manager",
|
|
116
|
+
initialValue: detectInvokingPackageManager(),
|
|
117
|
+
options: [
|
|
118
|
+
{ value: "npm", label: "npm" },
|
|
119
|
+
{ value: "pnpm", label: "pnpm" },
|
|
120
|
+
{ value: "yarn", label: "yarn" },
|
|
121
|
+
{ value: "bun", label: "bun" },
|
|
122
|
+
],
|
|
123
|
+
}));
|
|
124
|
+
const productionTarget = ensureNotCancelled(await p.select({
|
|
125
|
+
message: "Where will this run in production?",
|
|
126
|
+
initialValue: defaultTarget,
|
|
127
|
+
options: [
|
|
128
|
+
{ value: "cloud", label: "Supatype Cloud", hint: "managed; deploy via supatype link" },
|
|
129
|
+
{ value: "self-host", label: "Self-host", hint: "your own server with TLS" },
|
|
130
|
+
{ value: "later", label: "Decide later", hint: "local development only for now" },
|
|
131
|
+
],
|
|
132
|
+
}));
|
|
133
|
+
let domain;
|
|
134
|
+
let tlsEmail;
|
|
135
|
+
if (productionTarget === "self-host") {
|
|
136
|
+
domain = ensureNotCancelled(await p.text({
|
|
137
|
+
message: "Production domain for ACME TLS (optional, can set later)",
|
|
138
|
+
placeholder: "api.example.com",
|
|
139
|
+
defaultValue: "",
|
|
140
|
+
})).trim();
|
|
141
|
+
if (domain) {
|
|
142
|
+
tlsEmail =
|
|
143
|
+
ensureNotCancelled(await p.text({
|
|
144
|
+
message: "Email for Let's Encrypt (HTTPS) certificates",
|
|
145
|
+
placeholder: "you@example.com",
|
|
146
|
+
defaultValue: "",
|
|
147
|
+
})).trim() || undefined;
|
|
58
148
|
}
|
|
59
|
-
|
|
149
|
+
}
|
|
150
|
+
const provider = ensureNotCancelled(await p.select({
|
|
151
|
+
message: "How should Postgres and the server run for local development?",
|
|
152
|
+
initialValue: "docker",
|
|
153
|
+
options: [
|
|
154
|
+
{ value: "docker", label: "Docker", hint: "Docker Compose stack (recommended)" },
|
|
155
|
+
{ value: "native", label: "Native", hint: "host Postgres + server binaries, no Docker" },
|
|
156
|
+
],
|
|
157
|
+
}));
|
|
158
|
+
const schemaPath = ensureNotCancelled(await p.text({
|
|
159
|
+
message: "Where should your schema live?",
|
|
160
|
+
defaultValue: "schema/index.ts",
|
|
161
|
+
placeholder: "schema/index.ts",
|
|
162
|
+
})).trim() || "schema/index.ts";
|
|
163
|
+
const app = await promptApp();
|
|
164
|
+
const email = ensureNotCancelled(await p.select({
|
|
165
|
+
message: "Email provider",
|
|
166
|
+
initialValue: "console",
|
|
167
|
+
options: [
|
|
168
|
+
{ value: "console", label: "console", hint: "log emails to the terminal (dev)" },
|
|
169
|
+
{ value: "smtp", label: "SMTP" },
|
|
170
|
+
{ value: "resend", label: "Resend" },
|
|
171
|
+
{ value: "ses", label: "Amazon SES" },
|
|
172
|
+
],
|
|
173
|
+
}));
|
|
174
|
+
const storageLocal = ensureNotCancelled(await p.select({
|
|
175
|
+
message: "Local storage (for development)?",
|
|
176
|
+
initialValue: "local",
|
|
177
|
+
options: STORAGE_PROVIDER_OPTIONS,
|
|
178
|
+
}));
|
|
179
|
+
const storageProduction = ensureNotCancelled(await p.select({
|
|
180
|
+
message: "Production storage?",
|
|
181
|
+
initialValue: "local",
|
|
182
|
+
options: STORAGE_PROVIDER_OPTIONS,
|
|
183
|
+
}));
|
|
184
|
+
const helloFunction = ensureNotCancelled(await p.confirm({
|
|
185
|
+
message: "Create a hello-world edge function?",
|
|
186
|
+
initialValue: false,
|
|
187
|
+
}));
|
|
188
|
+
const install = ensureNotCancelled(await p.confirm({
|
|
189
|
+
message: `Install dependencies with ${packageManager} now?`,
|
|
190
|
+
initialValue: true,
|
|
191
|
+
}));
|
|
192
|
+
const generateKeys = ensureNotCancelled(await p.confirm({
|
|
193
|
+
message: "Generate ANON_KEY and SERVICE_ROLE_KEY now?",
|
|
194
|
+
initialValue: true,
|
|
195
|
+
}));
|
|
196
|
+
p.outro("Setting up your project...");
|
|
197
|
+
return {
|
|
198
|
+
projectName,
|
|
199
|
+
provider,
|
|
200
|
+
productionTarget,
|
|
201
|
+
...(domain !== undefined ? { domain } : {}),
|
|
202
|
+
...(tlsEmail !== undefined ? { tlsEmail } : {}),
|
|
203
|
+
schemaPath,
|
|
204
|
+
app,
|
|
205
|
+
email,
|
|
206
|
+
storageLocal,
|
|
207
|
+
storageProduction,
|
|
208
|
+
helloFunction,
|
|
209
|
+
packageManager,
|
|
210
|
+
install,
|
|
211
|
+
generateKeys,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
async function promptApp() {
|
|
215
|
+
const mode = ensureNotCancelled(await p.select({
|
|
216
|
+
message: "Host a frontend app at /?",
|
|
217
|
+
initialValue: "none",
|
|
218
|
+
options: [
|
|
219
|
+
{ value: "none", label: "No app", hint: "API only" },
|
|
220
|
+
{ value: "static", label: "Static site", hint: "serve a built directory" },
|
|
221
|
+
{ value: "proxy", label: "Local dev server", hint: "forward requests to a dev server you run" },
|
|
222
|
+
],
|
|
223
|
+
}));
|
|
224
|
+
if (mode === "static") {
|
|
225
|
+
const staticDir = ensureNotCancelled(await p.text({
|
|
226
|
+
message: "Directory to serve",
|
|
227
|
+
defaultValue: "./public",
|
|
228
|
+
placeholder: "./public",
|
|
229
|
+
})).trim() || "./public";
|
|
230
|
+
const viteDevUrl = await promptViteDevUrl();
|
|
231
|
+
return { mode, staticDir, ...(viteDevUrl ? { viteDevUrl } : {}) };
|
|
232
|
+
}
|
|
233
|
+
if (mode === "proxy") {
|
|
234
|
+
const upstream = ensureNotCancelled(await p.text({
|
|
235
|
+
message: "URL of your running dev server",
|
|
236
|
+
defaultValue: "http://localhost:3000",
|
|
237
|
+
placeholder: "http://localhost:3000",
|
|
238
|
+
})).trim() || "http://localhost:3000";
|
|
239
|
+
const start = ensureNotCancelled(await p.text({
|
|
240
|
+
message: "package.json script that starts your dev server",
|
|
241
|
+
defaultValue: "dev",
|
|
242
|
+
placeholder: "dev",
|
|
243
|
+
})).trim() || "dev";
|
|
244
|
+
const viteDevUrl = await promptViteDevUrl();
|
|
245
|
+
return { mode, upstream, start, ...(viteDevUrl ? { viteDevUrl } : {}) };
|
|
246
|
+
}
|
|
247
|
+
return { mode: "none" };
|
|
248
|
+
}
|
|
249
|
+
async function promptViteDevUrl() {
|
|
250
|
+
const useVite = ensureNotCancelled(await p.confirm({
|
|
251
|
+
message: "Enable live reload from a separate Vite dev server?",
|
|
252
|
+
initialValue: false,
|
|
253
|
+
}));
|
|
254
|
+
if (!useVite)
|
|
255
|
+
return undefined;
|
|
256
|
+
return (ensureNotCancelled(await p.text({
|
|
257
|
+
message: "Vite dev server URL",
|
|
258
|
+
defaultValue: "http://127.0.0.1:5173",
|
|
259
|
+
placeholder: "http://127.0.0.1:5173",
|
|
260
|
+
})).trim() || "http://127.0.0.1:5173");
|
|
261
|
+
}
|
|
262
|
+
// ─── Package manager ───────────────────────────────────────────────────────--
|
|
263
|
+
function detectInvokingPackageManager() {
|
|
264
|
+
const ua = process.env["npm_config_user_agent"] ?? "";
|
|
265
|
+
if (ua.startsWith("pnpm"))
|
|
266
|
+
return "pnpm";
|
|
267
|
+
if (ua.startsWith("yarn"))
|
|
268
|
+
return "yarn";
|
|
269
|
+
if (ua.startsWith("bun"))
|
|
270
|
+
return "bun";
|
|
271
|
+
return "npm";
|
|
272
|
+
}
|
|
273
|
+
function runInstall(dir, pm) {
|
|
274
|
+
info(`Installing dependencies with ${pm}...`);
|
|
275
|
+
const res = spawnSync(pm, ["install"], {
|
|
276
|
+
cwd: dir,
|
|
277
|
+
stdio: "inherit",
|
|
278
|
+
shell: process.platform === "win32",
|
|
60
279
|
});
|
|
280
|
+
if (res.status !== 0 || res.error) {
|
|
281
|
+
warn(`Dependency install did not complete (run "${pm} install" manually).`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function writeKeys(dir) {
|
|
285
|
+
const keys = generateAndWriteKeys(dir);
|
|
286
|
+
if (!keys) {
|
|
287
|
+
warn("Could not generate keys (JWT_SECRET missing). Run `supatype keys` manually.");
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
return true;
|
|
61
291
|
}
|
|
62
|
-
|
|
292
|
+
// ─── Scaffold ──────────────────────────────────────────────────────────────--
|
|
293
|
+
function scaffold(dir, optsOrName) {
|
|
294
|
+
const opts = typeof optsOrName === "string" ? defaultScaffoldOptions(optsOrName) : optsOrName;
|
|
63
295
|
const write = (rel, content) => {
|
|
64
296
|
const full = join(dir, rel);
|
|
65
297
|
mkdirSync(resolve(full, ".."), { recursive: true });
|
|
66
298
|
writeFileSync(full, content, "utf8");
|
|
67
|
-
|
|
299
|
+
file("created", rel);
|
|
68
300
|
};
|
|
69
301
|
const pkgPath = join(dir, "package.json");
|
|
70
302
|
if (!existsSync(pkgPath)) {
|
|
71
|
-
write("package.json", packageJsonTemplate(
|
|
303
|
+
write("package.json", packageJsonTemplate(opts, cliPackageVersion()));
|
|
72
304
|
}
|
|
73
305
|
else {
|
|
74
|
-
|
|
306
|
+
file("skipped", "package.json (already exists)");
|
|
75
307
|
}
|
|
76
|
-
write("supatype.config.ts", tsConfigTemplate(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
308
|
+
write("supatype.config.ts", tsConfigTemplate(opts));
|
|
309
|
+
if (opts.productionTarget !== "later") {
|
|
310
|
+
write("supatype.local.config.ts", localConfigTemplate(opts.app));
|
|
311
|
+
}
|
|
312
|
+
write(opts.schemaPath, schemaTemplate());
|
|
313
|
+
write(".env", envTemplate(opts));
|
|
314
|
+
write("seed.ts", seedTemplate(opts.projectName));
|
|
80
315
|
write("seeds/.gitkeep", "");
|
|
316
|
+
scaffoldAppAssets(opts, write);
|
|
317
|
+
if (opts.helloFunction)
|
|
318
|
+
scaffoldHelloFunction(dir, write);
|
|
319
|
+
const gitignorePath = join(dir, ".gitignore");
|
|
320
|
+
if (existsSync(gitignorePath)) {
|
|
321
|
+
const merged = mergeGitignoreTemplate(readFileSync(gitignorePath, "utf8"));
|
|
322
|
+
if (merged !== readFileSync(gitignorePath, "utf8")) {
|
|
323
|
+
writeFileSync(gitignorePath, merged, "utf8");
|
|
324
|
+
file("updated", ".gitignore (added .supatype/)");
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
file("skipped", ".gitignore (already exists)");
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
write(".gitignore", gitignoreTemplate());
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function staticDirRelative(staticDir) {
|
|
335
|
+
const raw = (staticDir ?? "./public").trim();
|
|
336
|
+
return raw.replace(/^\.\//, "").replace(/\/+$/, "") || "public";
|
|
337
|
+
}
|
|
338
|
+
function scaffoldAppAssets(opts, write) {
|
|
339
|
+
const holding = holdingPageTemplate(opts.projectName);
|
|
340
|
+
const hasVite = Boolean(opts.app.viteDevUrl);
|
|
341
|
+
if (opts.app.mode === "static") {
|
|
342
|
+
const staticRel = staticDirRelative(opts.app.staticDir);
|
|
343
|
+
write(`${staticRel}/index.html`, holding);
|
|
344
|
+
if (hasVite)
|
|
345
|
+
scaffoldVite(opts, write, holding);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (opts.app.mode === "proxy" && opts.productionTarget !== "later") {
|
|
349
|
+
write("dist/index.html", holding);
|
|
350
|
+
if (hasVite)
|
|
351
|
+
scaffoldVite(opts, write, holding);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (opts.app.mode === "proxy" && hasVite) {
|
|
355
|
+
scaffoldVite(opts, write, holding);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
81
358
|
write("public/.gitkeep", "");
|
|
82
|
-
|
|
359
|
+
}
|
|
360
|
+
function scaffoldVite(opts, write, holding) {
|
|
361
|
+
if (!opts.app.viteDevUrl)
|
|
362
|
+
return;
|
|
363
|
+
write("index.html", holding);
|
|
364
|
+
write("vite.config.ts", viteConfigTemplate(opts.app.viteDevUrl));
|
|
365
|
+
}
|
|
366
|
+
function scaffoldHelloFunction(dir, write) {
|
|
367
|
+
write("functions/hello/index.ts", helloFunctionTemplate());
|
|
368
|
+
if (!existsSync(join(dir, "functions/_shared/README.md"))) {
|
|
369
|
+
write("functions/_shared/README.md", sharedFunctionsReadme());
|
|
370
|
+
}
|
|
371
|
+
if (!existsSync(join(dir, "functions/.env.local"))) {
|
|
372
|
+
write("functions/.env.local", functionsEnvLocalTemplate());
|
|
373
|
+
}
|
|
83
374
|
}
|
|
84
375
|
// ─── Templates ───────────────────────────────────────────────────────────────
|
|
85
|
-
function packageJsonTemplate(
|
|
376
|
+
function packageJsonTemplate(opts, cliVersion) {
|
|
377
|
+
const scripts = [
|
|
378
|
+
` "dev": "supatype dev"`,
|
|
379
|
+
` "push": "supatype push"`,
|
|
380
|
+
` "seed": "tsx seed.ts"`,
|
|
381
|
+
];
|
|
382
|
+
if (opts.app.viteDevUrl) {
|
|
383
|
+
scripts.push(` "vite": "vite"`);
|
|
384
|
+
}
|
|
385
|
+
if (opts.helloFunction) {
|
|
386
|
+
scripts.push(` "functions": "supatype functions serve"`);
|
|
387
|
+
}
|
|
388
|
+
const devDeps = [` "tsx": "^4.19.2"`, ` "typescript": "^5"`];
|
|
389
|
+
if (opts.app.viteDevUrl) {
|
|
390
|
+
devDeps.push(` "vite": "^6"`);
|
|
391
|
+
}
|
|
86
392
|
return `{
|
|
87
|
-
"name": "${projectName}",
|
|
393
|
+
"name": "${opts.projectName}",
|
|
88
394
|
"private": true,
|
|
89
395
|
"type": "module",
|
|
90
396
|
"scripts": {
|
|
91
|
-
|
|
92
|
-
"push": "supatype push",
|
|
93
|
-
"seed": "tsx seed.ts"
|
|
397
|
+
${scripts.join(",\n")}
|
|
94
398
|
},
|
|
95
399
|
"dependencies": {
|
|
96
400
|
"@supatype/cli": "^${cliVersion}",
|
|
97
401
|
"@supatype/types": "^${cliVersion}"
|
|
98
402
|
},
|
|
99
403
|
"devDependencies": {
|
|
100
|
-
|
|
101
|
-
"typescript": "^5"
|
|
404
|
+
${devDeps.join(",\n")}
|
|
102
405
|
}
|
|
103
406
|
}
|
|
104
407
|
`;
|
|
105
408
|
}
|
|
106
|
-
function tsConfigTemplate(
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
409
|
+
function tsConfigTemplate(opts) {
|
|
410
|
+
const serverMode = serverModeForTarget(opts.productionTarget);
|
|
411
|
+
const hasLocalOverride = opts.productionTarget !== "later";
|
|
412
|
+
const lines = [];
|
|
413
|
+
lines.push(`import { defineConfig } from "@supatype/cli"`);
|
|
414
|
+
lines.push("");
|
|
415
|
+
if (hasLocalOverride) {
|
|
416
|
+
lines.push(`// Committed config = ${opts.productionTarget} production target.`);
|
|
417
|
+
lines.push(`// Local development overrides live in supatype.local.config.ts (gitignored).`);
|
|
418
|
+
}
|
|
419
|
+
lines.push(`export default defineConfig({`);
|
|
420
|
+
lines.push(` project: { name: "${opts.projectName}" },`);
|
|
421
|
+
lines.push(` provider: "${opts.provider}",`);
|
|
422
|
+
if (opts.provider === "docker") {
|
|
423
|
+
lines.push(` // provider: "native" // host Postgres + supatype-server binaries (no Docker)`);
|
|
424
|
+
}
|
|
425
|
+
lines.push(` database: {`);
|
|
426
|
+
lines.push(` provider: "${opts.provider}",`);
|
|
427
|
+
lines.push(` },`);
|
|
428
|
+
lines.push(` server: {`);
|
|
429
|
+
lines.push(` mode: "${serverMode}",`);
|
|
430
|
+
lines.push(` port: 54321,`);
|
|
431
|
+
if (serverMode === "standalone") {
|
|
432
|
+
lines.push(` domain: "${opts.domain ?? ""}", // e.g. "api.example.com" for ACME TLS`);
|
|
433
|
+
if (opts.tlsEmail) {
|
|
434
|
+
lines.push(` tls: { email: "${opts.tlsEmail}" }, // automatic HTTPS via Let's Encrypt`);
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
lines.push(` // tls: { email: "you@example.com" }, // set to enable automatic HTTPS (Let's Encrypt)`);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
lines.push(` },`);
|
|
441
|
+
lines.push(...appConfigLines(opts.app, opts.productionTarget));
|
|
442
|
+
if (opts.productionTarget !== "later") {
|
|
443
|
+
lines.push(` environments: { default: "production" }, // supatype link --env production ...`);
|
|
444
|
+
}
|
|
445
|
+
lines.push(` // Optional: pin component versions (native cache + Docker images synced to .env on dev/push)`);
|
|
446
|
+
lines.push(` // versions: { engine: "0.1.2", server: "1.0.5", postgres: "17.2", deno: "2.2.0" },`);
|
|
447
|
+
lines.push(` email: { provider: "${opts.email}" },`);
|
|
448
|
+
lines.push(...storageConfigLines(opts.storageLocal, opts.storageProduction));
|
|
449
|
+
lines.push(` schema: { path: "${opts.schemaPath}", pg_schema: "public" },`);
|
|
450
|
+
lines.push(` // Self-host production: supatype self-host compose (Docker only). Standalone + domain = native ACME dev.`);
|
|
451
|
+
lines.push(`})`);
|
|
452
|
+
return lines.join("\n") + "\n";
|
|
453
|
+
}
|
|
454
|
+
function localConfigTemplate(app) {
|
|
455
|
+
const lines = [
|
|
456
|
+
`import type { SupatypeConfig } from "@supatype/cli"`,
|
|
457
|
+
``,
|
|
458
|
+
`// Local development overrides — gitignored, deep-merged over supatype.config.ts.`,
|
|
459
|
+
`// Keeps \`supatype dev\` in local mode while the committed config targets production.`,
|
|
460
|
+
`const localConfig: Partial<SupatypeConfig> = {`,
|
|
461
|
+
` server: { mode: "dev" },`,
|
|
462
|
+
];
|
|
463
|
+
if (app.mode === "proxy") {
|
|
464
|
+
lines.push(` app: {`);
|
|
465
|
+
lines.push(` mode: "proxy",`);
|
|
466
|
+
lines.push(` upstream: "${app.upstream ?? "http://localhost:3000"}",`);
|
|
467
|
+
lines.push(` start: "${app.start ?? "dev"}",`);
|
|
468
|
+
if (app.viteDevUrl)
|
|
469
|
+
lines.push(` vite_dev_url: "${app.viteDevUrl}",`);
|
|
470
|
+
lines.push(` },`);
|
|
471
|
+
}
|
|
472
|
+
lines.push(`}`, ``, `export default localConfig`, ``);
|
|
473
|
+
return lines.join("\n");
|
|
474
|
+
}
|
|
475
|
+
function appConfigLines(app, productionTarget) {
|
|
476
|
+
if (app.mode === "static") {
|
|
477
|
+
const out = [
|
|
478
|
+
` app: {`,
|
|
479
|
+
` mode: "static",`,
|
|
480
|
+
` static_dir: "${app.staticDir ?? "./public"}",`,
|
|
481
|
+
];
|
|
482
|
+
if (app.viteDevUrl)
|
|
483
|
+
out.push(` vite_dev_url: "${app.viteDevUrl}",`);
|
|
484
|
+
out.push(` },`);
|
|
485
|
+
return out;
|
|
486
|
+
}
|
|
487
|
+
if (app.mode === "proxy") {
|
|
488
|
+
if (productionTarget !== "later") {
|
|
489
|
+
return [
|
|
490
|
+
` app: {`,
|
|
491
|
+
` mode: "static",`,
|
|
492
|
+
` static_dir: "./dist", // production build output`,
|
|
493
|
+
` },`,
|
|
494
|
+
];
|
|
495
|
+
}
|
|
496
|
+
const out = [
|
|
497
|
+
` app: {`,
|
|
498
|
+
` mode: "proxy",`,
|
|
499
|
+
` upstream: "${app.upstream ?? "http://localhost:3000"}",`,
|
|
500
|
+
` start: "${app.start ?? "dev"}",`,
|
|
501
|
+
];
|
|
502
|
+
if (app.viteDevUrl)
|
|
503
|
+
out.push(` vite_dev_url: "${app.viteDevUrl}",`);
|
|
504
|
+
out.push(` },`);
|
|
505
|
+
return out;
|
|
506
|
+
}
|
|
507
|
+
return [
|
|
508
|
+
` app: {`,
|
|
509
|
+
` mode: "none",`,
|
|
510
|
+
` // mode: "static", static_dir: "./public", // supatype app add --static ./public`,
|
|
511
|
+
` // mode: "proxy", upstream: "http://localhost:3000", start: "dev",`,
|
|
512
|
+
` // vite_dev_url: "http://127.0.0.1:5173", // live reload from a separate Vite dev server`,
|
|
513
|
+
` },`,
|
|
514
|
+
];
|
|
515
|
+
}
|
|
516
|
+
const HOLDING_PAGE_LOGO_URL = "https://supatype.github.io/supatype/supatype.svg";
|
|
517
|
+
const HOLDING_PAGE_DOCS_URL = "https://supatype.github.io/supatype/";
|
|
518
|
+
const HOLDING_PAGE_GITHUB_URL = "https://github.com/supatype";
|
|
519
|
+
const HOLDING_PAGE_DISCORD_URL = "https://discord.gg/yaQrjQD4";
|
|
520
|
+
function escapeHtml(text) {
|
|
521
|
+
return text
|
|
522
|
+
.replace(/&/g, "&")
|
|
523
|
+
.replace(/</g, "<")
|
|
524
|
+
.replace(/>/g, ">")
|
|
525
|
+
.replace(/"/g, """);
|
|
526
|
+
}
|
|
527
|
+
function holdingPageTemplate(projectName) {
|
|
528
|
+
const name = escapeHtml(projectName);
|
|
529
|
+
return `<!doctype html>
|
|
530
|
+
<html lang="en">
|
|
531
|
+
<head>
|
|
532
|
+
<meta charset="UTF-8" />
|
|
533
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
534
|
+
<title>${name} — Supatype</title>
|
|
535
|
+
<meta name="description" content="A Supatype project. Define your types — we generate your backend." />
|
|
536
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
537
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
538
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
|
|
539
|
+
<style>
|
|
540
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
541
|
+
:root {
|
|
542
|
+
--bg: #0a0a0f;
|
|
543
|
+
--border: rgba(255, 255, 255, 0.08);
|
|
544
|
+
--text: #e8e8f0;
|
|
545
|
+
--text-muted: #8888a8;
|
|
546
|
+
--purple: #7c3aed;
|
|
547
|
+
--purple-light: #a855f7;
|
|
548
|
+
}
|
|
549
|
+
body {
|
|
550
|
+
min-height: 100vh;
|
|
551
|
+
font-family: Inter, system-ui, sans-serif;
|
|
552
|
+
background: var(--bg);
|
|
553
|
+
color: var(--text);
|
|
554
|
+
line-height: 1.6;
|
|
555
|
+
display: flex;
|
|
556
|
+
align-items: center;
|
|
557
|
+
justify-content: center;
|
|
558
|
+
padding: 2rem;
|
|
559
|
+
}
|
|
560
|
+
body::before {
|
|
561
|
+
content: "";
|
|
562
|
+
position: fixed;
|
|
563
|
+
inset: 0;
|
|
564
|
+
background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(124, 58, 237, 0.18), transparent);
|
|
565
|
+
pointer-events: none;
|
|
566
|
+
}
|
|
567
|
+
main {
|
|
568
|
+
position: relative;
|
|
569
|
+
max-width: 32rem;
|
|
570
|
+
width: 100%;
|
|
571
|
+
text-align: center;
|
|
572
|
+
}
|
|
573
|
+
.logo {
|
|
574
|
+
display: block;
|
|
575
|
+
height: 2rem;
|
|
576
|
+
width: auto;
|
|
577
|
+
margin: 0 auto 2rem;
|
|
578
|
+
}
|
|
579
|
+
h1 {
|
|
580
|
+
font-size: 1.5rem;
|
|
581
|
+
font-weight: 700;
|
|
582
|
+
letter-spacing: -0.02em;
|
|
583
|
+
margin-bottom: 0.75rem;
|
|
584
|
+
}
|
|
585
|
+
.tagline {
|
|
586
|
+
color: var(--text-muted);
|
|
587
|
+
font-size: 1rem;
|
|
588
|
+
margin-bottom: 2rem;
|
|
589
|
+
}
|
|
590
|
+
.links {
|
|
591
|
+
display: flex;
|
|
592
|
+
flex-wrap: wrap;
|
|
593
|
+
gap: 0.75rem;
|
|
594
|
+
justify-content: center;
|
|
595
|
+
margin-bottom: 2.5rem;
|
|
596
|
+
}
|
|
597
|
+
.links a {
|
|
598
|
+
display: inline-flex;
|
|
599
|
+
align-items: center;
|
|
600
|
+
padding: 0.6rem 1.1rem;
|
|
601
|
+
border-radius: 10px;
|
|
602
|
+
border: 1px solid var(--border);
|
|
603
|
+
color: var(--text);
|
|
604
|
+
text-decoration: none;
|
|
605
|
+
font-size: 0.9rem;
|
|
606
|
+
font-weight: 500;
|
|
607
|
+
transition: border-color 0.15s, background 0.15s;
|
|
608
|
+
}
|
|
609
|
+
.links a:hover {
|
|
610
|
+
border-color: rgba(168, 85, 247, 0.45);
|
|
611
|
+
background: rgba(124, 58, 237, 0.08);
|
|
612
|
+
}
|
|
613
|
+
.links a.primary {
|
|
614
|
+
background: linear-gradient(135deg, var(--purple), var(--purple-light));
|
|
615
|
+
border-color: transparent;
|
|
616
|
+
color: #fff;
|
|
617
|
+
}
|
|
618
|
+
.links a.primary:hover {
|
|
619
|
+
opacity: 0.92;
|
|
620
|
+
}
|
|
621
|
+
.hint {
|
|
622
|
+
font-size: 0.85rem;
|
|
623
|
+
color: var(--text-muted);
|
|
624
|
+
}
|
|
625
|
+
.hint code {
|
|
626
|
+
font-family: ui-monospace, "JetBrains Mono", monospace;
|
|
627
|
+
font-size: 0.8rem;
|
|
628
|
+
background: rgba(255, 255, 255, 0.06);
|
|
629
|
+
padding: 0.15rem 0.4rem;
|
|
630
|
+
border-radius: 4px;
|
|
631
|
+
}
|
|
632
|
+
</style>
|
|
633
|
+
</head>
|
|
634
|
+
<body>
|
|
635
|
+
<main>
|
|
636
|
+
<img class="logo" src="${HOLDING_PAGE_LOGO_URL}" alt="Supatype" width="160" height="30" />
|
|
637
|
+
<h1>${name}</h1>
|
|
638
|
+
<p class="tagline">Your Supatype project is ready. Replace this page when you build your app.</p>
|
|
639
|
+
<nav class="links" aria-label="Supatype resources">
|
|
640
|
+
<a class="primary" href="${HOLDING_PAGE_DOCS_URL}" target="_blank" rel="noopener noreferrer">Documentation</a>
|
|
641
|
+
<a href="${HOLDING_PAGE_GITHUB_URL}" target="_blank" rel="noopener noreferrer">GitHub</a>
|
|
642
|
+
<a href="${HOLDING_PAGE_DISCORD_URL}" target="_blank" rel="noopener noreferrer">Discord</a>
|
|
643
|
+
</nav>
|
|
644
|
+
<p class="hint">Run <code>supatype dev</code> then open <code>http://localhost:18473/</code></p>
|
|
645
|
+
</main>
|
|
646
|
+
</body>
|
|
647
|
+
</html>
|
|
648
|
+
`;
|
|
649
|
+
}
|
|
650
|
+
function vitePortFromDevUrl(viteDevUrl) {
|
|
651
|
+
try {
|
|
652
|
+
const url = new URL(viteDevUrl);
|
|
653
|
+
if (url.port)
|
|
654
|
+
return Number.parseInt(url.port, 10);
|
|
655
|
+
return url.protocol === "https:" ? 443 : 80;
|
|
656
|
+
}
|
|
657
|
+
catch {
|
|
658
|
+
return 5173;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
function viteConfigTemplate(viteDevUrl) {
|
|
662
|
+
const port = vitePortFromDevUrl(viteDevUrl);
|
|
663
|
+
return `import { defineConfig } from "vite"
|
|
112
664
|
|
|
113
665
|
export default defineConfig({
|
|
114
|
-
project: { name: "${projectName}" },
|
|
115
|
-
provider: "native",
|
|
116
|
-
// provider: "docker" // full self-host Compose stack (Kong :18473)
|
|
117
|
-
database: {
|
|
118
|
-
provider: "native",
|
|
119
|
-
},
|
|
120
666
|
server: {
|
|
121
|
-
|
|
122
|
-
port:
|
|
123
|
-
|
|
124
|
-
app: {
|
|
125
|
-
mode: "none",
|
|
126
|
-
// mode: "static", static_dir: "./public", // supatype app add --static ./public
|
|
127
|
-
// mode: "proxy", upstream: "http://localhost:3000", start: "dev",
|
|
128
|
-
// vite_dev_url: "http://127.0.0.1:5173", // dev HMR at /_vite (when using a separate Vite server)
|
|
129
|
-
},
|
|
130
|
-
versions: {
|
|
131
|
-
engine: "${v("engine", "latest")}",
|
|
132
|
-
server: "${v("server", "latest")}",
|
|
133
|
-
postgres: "${v("postgres", "latest")}",
|
|
134
|
-
deno: "${v("deno", "latest")}",
|
|
667
|
+
host: "127.0.0.1",
|
|
668
|
+
port: ${port},
|
|
669
|
+
strictPort: true,
|
|
135
670
|
},
|
|
136
|
-
email: { provider: "console" },
|
|
137
|
-
storage: { provider: "local", local_path: ".supatype/storage" },
|
|
138
|
-
schema: { path: "schema/index.ts", pg_schema: "public" },
|
|
139
|
-
// Self-host production: supatype self-host compose (Docker only). Standalone + domain = native ACME dev.
|
|
140
671
|
})
|
|
141
672
|
`;
|
|
142
673
|
}
|
|
674
|
+
function storageConfigLines(storageLocal, storageProduction) {
|
|
675
|
+
const lines = [];
|
|
676
|
+
if (storageLocal === "s3") {
|
|
677
|
+
lines.push(` storage: { provider: "s3" }, // dev — configure S3_* in .env`);
|
|
678
|
+
}
|
|
679
|
+
else {
|
|
680
|
+
lines.push(` storage: { provider: "local", local_path: ".supatype/storage" },`);
|
|
681
|
+
}
|
|
682
|
+
if (storageProduction === "s3" && storageLocal !== "s3") {
|
|
683
|
+
lines.push(` // Production storage: external S3 bucket — set production S3_* in .env`);
|
|
684
|
+
}
|
|
685
|
+
else if (storageProduction === "local" && storageLocal === "s3") {
|
|
686
|
+
lines.push(` // Production storage: MinIO on your server (included in self-host compose)`);
|
|
687
|
+
}
|
|
688
|
+
return lines;
|
|
689
|
+
}
|
|
143
690
|
function schemaTemplate() {
|
|
144
|
-
return `import type { Model,
|
|
691
|
+
return `import type { Model, LoggedIn, Owner, Public, Role, SupatypeAuthUserId, UUID } from "@supatype/types"
|
|
145
692
|
|
|
146
|
-
|
|
693
|
+
/** App profile for a signed-in user. \`id\` matches the Supatype auth user id. */
|
|
694
|
+
export type Profile = Model<{
|
|
147
695
|
id: SupatypeAuthUserId
|
|
148
|
-
|
|
149
|
-
name: string
|
|
150
|
-
created_at: string
|
|
151
|
-
updated_at: string
|
|
696
|
+
display_name: string
|
|
152
697
|
}, {
|
|
153
698
|
access: {
|
|
154
|
-
read:
|
|
155
|
-
create:
|
|
699
|
+
read: LoggedIn
|
|
700
|
+
create: Owner<"id">
|
|
156
701
|
update: Owner<"id">
|
|
157
|
-
delete:
|
|
702
|
+
delete: Owner<"id">
|
|
158
703
|
}
|
|
159
704
|
}>
|
|
160
705
|
|
|
@@ -171,34 +716,95 @@ export type SiteSettings = Model<{
|
|
|
171
716
|
}>
|
|
172
717
|
`;
|
|
173
718
|
}
|
|
174
|
-
function envTemplate(
|
|
175
|
-
|
|
719
|
+
function envTemplate(opts) {
|
|
720
|
+
const sections = [];
|
|
721
|
+
sections.push(`DATABASE_URL=postgresql://supatype_admin:postgres@localhost:5432/${opts.projectName}
|
|
176
722
|
POSTGRES_USER=supatype_admin
|
|
177
723
|
POSTGRES_PASSWORD=postgres
|
|
178
|
-
POSTGRES_DB=${projectName}
|
|
179
|
-
|
|
180
|
-
# JWT — run \`supatype keys\` to generate ANON_KEY and SERVICE_ROLE_KEY
|
|
724
|
+
POSTGRES_DB=${opts.projectName}`);
|
|
725
|
+
sections.push(`# JWT — run \`supatype keys\` to generate ANON_KEY and SERVICE_ROLE_KEY
|
|
181
726
|
JWT_SECRET=super-secret-jwt-token-change-in-production
|
|
182
727
|
ANON_KEY=
|
|
183
|
-
SERVICE_ROLE_KEY
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
728
|
+
SERVICE_ROLE_KEY=`);
|
|
729
|
+
sections.push(`# Site URL (used by GoTrue for email redirects)
|
|
730
|
+
SITE_URL=http://localhost:3000`);
|
|
731
|
+
sections.push(emailEnvSection(opts.email, opts.projectName));
|
|
732
|
+
sections.push(storageEnvSections(opts.storageLocal, opts.storageProduction));
|
|
733
|
+
sections.push(`# Self-host compose uses the same DATABASE_URL when Postgres is published on localhost:5432`);
|
|
734
|
+
return sections.join("\n\n") + "\n";
|
|
735
|
+
}
|
|
736
|
+
function emailEnvSection(email, projectName) {
|
|
737
|
+
switch (email) {
|
|
738
|
+
case "resend":
|
|
739
|
+
return `# Email (Resend)
|
|
740
|
+
RESEND_API_KEY=
|
|
741
|
+
RESEND_FROM=onboarding@resend.dev`;
|
|
742
|
+
case "ses":
|
|
743
|
+
return `# Email (Amazon SES)
|
|
744
|
+
SES_FROM=
|
|
745
|
+
AWS_REGION=us-east-1
|
|
746
|
+
AWS_ACCESS_KEY_ID=
|
|
747
|
+
AWS_SECRET_ACCESS_KEY=`;
|
|
748
|
+
case "smtp":
|
|
749
|
+
return `# Email (SMTP)
|
|
750
|
+
SMTP_HOST=
|
|
751
|
+
SMTP_PORT=587
|
|
752
|
+
SMTP_USER=
|
|
753
|
+
SMTP_PASS=
|
|
754
|
+
SMTP_SENDER_NAME=${projectName}`;
|
|
755
|
+
case "console":
|
|
756
|
+
default:
|
|
757
|
+
return `# SMTP — leave empty to use email autoconfirm in dev (no emails sent)
|
|
189
758
|
SMTP_HOST=
|
|
190
759
|
SMTP_PORT=
|
|
191
760
|
SMTP_USER=
|
|
192
761
|
SMTP_PASS=
|
|
193
|
-
SMTP_SENDER_NAME=${projectName}
|
|
762
|
+
SMTP_SENDER_NAME=${projectName}`;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
function storageEnvSections(storageLocal, storageProduction) {
|
|
766
|
+
if (storageLocal === storageProduction) {
|
|
767
|
+
if (storageLocal === "s3") {
|
|
768
|
+
return `# Storage (local development and production — external bucket)
|
|
769
|
+
# Use separate buckets for dev and production in your provider.
|
|
770
|
+
S3_ENDPOINT=
|
|
771
|
+
S3_REGION=us-east-1
|
|
772
|
+
S3_BUCKET=
|
|
773
|
+
S3_ACCESS_KEY=
|
|
774
|
+
S3_SECRET_KEY=`;
|
|
775
|
+
}
|
|
776
|
+
return `${localStorageEnvSection("local")}
|
|
194
777
|
|
|
195
|
-
#
|
|
778
|
+
# Production storage (MinIO on your server)
|
|
779
|
+
# Included in the self-host compose stack — no extra configuration needed.`;
|
|
780
|
+
}
|
|
781
|
+
return [localStorageEnvSection(storageLocal), productionStorageEnvSection(storageProduction)].join("\n\n");
|
|
782
|
+
}
|
|
783
|
+
function localStorageEnvSection(storage) {
|
|
784
|
+
if (storage === "s3") {
|
|
785
|
+
return `# Storage (local development — external bucket)
|
|
786
|
+
S3_ENDPOINT=
|
|
787
|
+
S3_REGION=us-east-1
|
|
788
|
+
S3_BUCKET=
|
|
789
|
+
S3_ACCESS_KEY=
|
|
790
|
+
S3_SECRET_KEY=`;
|
|
791
|
+
}
|
|
792
|
+
return `# Storage (local development — MinIO)
|
|
196
793
|
S3_ENDPOINT=http://localhost:9000
|
|
197
794
|
S3_ACCESS_KEY=supatype
|
|
198
|
-
S3_SECRET_KEY=supatype-secret
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
795
|
+
S3_SECRET_KEY=supatype-secret`;
|
|
796
|
+
}
|
|
797
|
+
function productionStorageEnvSection(storage) {
|
|
798
|
+
if (storage === "s3") {
|
|
799
|
+
return `# Storage (production — external bucket)
|
|
800
|
+
S3_ENDPOINT=
|
|
801
|
+
S3_REGION=us-east-1
|
|
802
|
+
S3_BUCKET=
|
|
803
|
+
S3_ACCESS_KEY=
|
|
804
|
+
S3_SECRET_KEY=`;
|
|
805
|
+
}
|
|
806
|
+
return `# Storage (production — MinIO on your server)
|
|
807
|
+
# Included in the self-host compose stack — no extra configuration needed.`;
|
|
202
808
|
}
|
|
203
809
|
function seedTemplate(projectName) {
|
|
204
810
|
return `import { sql } from "@supatype/cli/seed"
|
|
@@ -213,7 +819,7 @@ async function seed() {
|
|
|
213
819
|
console.log("Seeding ${projectName}...")
|
|
214
820
|
|
|
215
821
|
// TODO: insert seed data
|
|
216
|
-
// await db\`INSERT INTO
|
|
822
|
+
// await db\`INSERT INTO profile (id, display_name) VALUES ('...', 'Admin')\`
|
|
217
823
|
|
|
218
824
|
await db.end()
|
|
219
825
|
console.log("Done.")
|
|
@@ -225,18 +831,119 @@ seed().catch((e) => {
|
|
|
225
831
|
})
|
|
226
832
|
`;
|
|
227
833
|
}
|
|
834
|
+
function helloFunctionTemplate() {
|
|
835
|
+
return `// hello — Supatype Edge Function
|
|
836
|
+
// Docs: https://supatype.com/docs/edge-functions
|
|
837
|
+
|
|
838
|
+
export default async function handler(req: Request): Promise<Response> {
|
|
839
|
+
const { method } = req
|
|
840
|
+
|
|
841
|
+
if (method === "POST") {
|
|
842
|
+
const body = await req.json()
|
|
843
|
+
return new Response(JSON.stringify({ message: "Hello from hello!", received: body }), {
|
|
844
|
+
status: 200,
|
|
845
|
+
headers: { "Content-Type": "application/json" },
|
|
846
|
+
})
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
return new Response(JSON.stringify({ message: "Hello from hello!" }), {
|
|
850
|
+
status: 200,
|
|
851
|
+
headers: { "Content-Type": "application/json" },
|
|
852
|
+
})
|
|
853
|
+
}
|
|
854
|
+
`;
|
|
855
|
+
}
|
|
856
|
+
function sharedFunctionsReadme() {
|
|
857
|
+
return "# Shared Code\n\nFiles in `_shared/` are available to all functions via relative imports.\nThis directory is not deployed as a function.\n\nExample: `import { sendEmail } from '../_shared/email.ts'`\n";
|
|
858
|
+
}
|
|
859
|
+
function functionsEnvLocalTemplate() {
|
|
860
|
+
return "# Local environment variables for edge functions\n# These are NOT committed to git\n# Set production env vars via: npx supatype functions env set KEY=value\n";
|
|
861
|
+
}
|
|
228
862
|
function gitignoreTemplate() {
|
|
229
863
|
return `.env
|
|
230
864
|
node_modules/
|
|
231
865
|
dist/
|
|
232
|
-
.supatype/
|
|
233
|
-
# Local overrides — never commit
|
|
866
|
+
.supatype/
|
|
234
867
|
supatype.local.config.ts
|
|
235
868
|
supatype.local.config.js
|
|
236
869
|
supatype.local.config.mjs
|
|
237
|
-
# Generated by supatype push
|
|
870
|
+
# Generated by supatype push (legacy paths — prefer output.types in config)
|
|
238
871
|
src/types/supatype.d.ts
|
|
239
872
|
src/lib/supatype.ts
|
|
240
873
|
`;
|
|
241
874
|
}
|
|
875
|
+
export function mergeGitignoreTemplate(existingContent) {
|
|
876
|
+
if (existingContent.includes(".supatype/") || existingContent.includes(".supatype\n")) {
|
|
877
|
+
return existingContent;
|
|
878
|
+
}
|
|
879
|
+
const block = `
|
|
880
|
+
# Supatype — local runtime (contains secrets in link.json)
|
|
881
|
+
.supatype/
|
|
882
|
+
`;
|
|
883
|
+
return existingContent.endsWith("\n") ? `${existingContent}${block}` : `${existingContent}\n${block}`;
|
|
884
|
+
}
|
|
885
|
+
// ─── Next steps ────────────────────────────────────────────────────────────--
|
|
886
|
+
function warnDockerUnavailableForProvider(provider) {
|
|
887
|
+
if (provider !== "docker")
|
|
888
|
+
return;
|
|
889
|
+
const probe = probeDockerDaemon();
|
|
890
|
+
if (probe.ok)
|
|
891
|
+
return;
|
|
892
|
+
reportDockerUnavailable(probe);
|
|
893
|
+
plain();
|
|
894
|
+
}
|
|
895
|
+
function printNextSteps(args) {
|
|
896
|
+
const { name, result, installed, keysGenerated } = args;
|
|
897
|
+
const steps = [];
|
|
898
|
+
if (name)
|
|
899
|
+
steps.push(`cd ${name}`);
|
|
900
|
+
if (!installed)
|
|
901
|
+
steps.push(`${result.packageManager} install`);
|
|
902
|
+
if (!keysGenerated)
|
|
903
|
+
steps.push("supatype keys");
|
|
904
|
+
steps.push("supatype dev # Docker Compose stack (Kong :18473)");
|
|
905
|
+
steps.push("supatype push # apply schema + generate types");
|
|
906
|
+
if (result.helloFunction) {
|
|
907
|
+
steps.push("supatype functions serve # run edge functions locally");
|
|
908
|
+
}
|
|
909
|
+
info(`Supatype project ready${name ? ` in ${name}/` : ""}.`);
|
|
910
|
+
nextSteps("Next steps:", steps);
|
|
911
|
+
if (result.app.mode === "none") {
|
|
912
|
+
nextSteps("Static frontend (self-host):", [
|
|
913
|
+
"supatype app add --static ./public",
|
|
914
|
+
"npm run build # write files into public/",
|
|
915
|
+
"supatype self-host compose up -d",
|
|
916
|
+
]);
|
|
917
|
+
}
|
|
918
|
+
if (result.productionTarget === "cloud") {
|
|
919
|
+
nextSteps("Deploy to Supatype Cloud:", [
|
|
920
|
+
"supatype login",
|
|
921
|
+
"supatype link --env production --project <ref>",
|
|
922
|
+
"supatype push --env production",
|
|
923
|
+
]);
|
|
924
|
+
info("supatype.local.config.ts keeps `supatype dev` local while the committed config targets cloud.");
|
|
925
|
+
}
|
|
926
|
+
else if (result.productionTarget === "self-host") {
|
|
927
|
+
const selfHostSteps = [];
|
|
928
|
+
const domain = result.domain?.trim();
|
|
929
|
+
if (domain) {
|
|
930
|
+
selfHostSteps.push(`1. Point DNS: an A record for ${domain} -> your server's public IP`);
|
|
931
|
+
selfHostSteps.push("2. Open ports 80 and 443 on the server firewall");
|
|
932
|
+
if (!result.tlsEmail) {
|
|
933
|
+
selfHostSteps.push("3. Set server.tls.email in supatype.config.ts (required for HTTPS)");
|
|
934
|
+
}
|
|
935
|
+
selfHostSteps.push("supatype self-host compose up -d # Kong provisions HTTPS automatically");
|
|
936
|
+
selfHostSteps.push(`Your Supatype platform goes live at https://${domain}`);
|
|
937
|
+
selfHostSteps.push("Your app, REST, Auth, Storage, Realtime, Functions, and Studio — all behind one HTTPS domain (certs persist in valkey-data)");
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
selfHostSteps.push("Set server.domain + server.tls.email in supatype.config.ts to enable automatic HTTPS");
|
|
941
|
+
selfHostSteps.push("supatype self-host compose up -d # Docker stack");
|
|
942
|
+
}
|
|
943
|
+
selfHostSteps.push("supatype link --env production ... # then: supatype push --env production");
|
|
944
|
+
nextSteps("Self-host production (your own server):", selfHostSteps);
|
|
945
|
+
info("supatype.local.config.ts keeps `supatype dev` local while the committed config targets self-host.");
|
|
946
|
+
}
|
|
947
|
+
plain();
|
|
948
|
+
}
|
|
242
949
|
//# sourceMappingURL=init.js.map
|