@supatype/cli 0.1.0-alpha.9 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-test.log +285 -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 +28 -1
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +297 -149
- 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 +74 -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 +35 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +883 -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 +111 -138
- 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/compose-rename.d.ts +10 -0
- package/dist/compose-rename.d.ts.map +1 -0
- package/dist/compose-rename.js +67 -0
- package/dist/compose-rename.js.map +1 -0
- 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 +357 -79
- 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-ports.d.ts +27 -0
- package/dist/dev-ports.d.ts.map +1 -0
- package/dist/dev-ports.js +171 -0
- package/dist/dev-ports.js.map +1 -0
- package/dist/dev-session-lock.d.ts +25 -0
- package/dist/dev-session-lock.d.ts.map +1 -0
- package/dist/dev-session-lock.js +81 -0
- package/dist/dev-session-lock.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 +25 -0
- package/dist/dev-shutdown.d.ts.map +1 -0
- package/dist/dev-shutdown.js +114 -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/env-file.d.ts +5 -0
- package/dist/env-file.d.ts.map +1 -0
- package/dist/env-file.js +33 -0
- package/dist/env-file.js.map +1 -0
- 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/self-host-compose.d.ts +37 -1
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +234 -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 +5 -2
- 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 +381 -190
- 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 +98 -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 +1087 -104
- 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 +148 -175
- 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/compose-rename.ts +76 -0
- package/src/config.ts +2 -1
- package/src/dev-compose.ts +462 -76
- 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-ports.ts +212 -0
- package/src/dev-session-lock.ts +101 -0
- package/src/dev-session.ts +130 -0
- package/src/dev-shutdown.ts +147 -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/env-file.ts +37 -0
- 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/self-host-compose.ts +262 -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/admin-ensure.test.ts +59 -0
- package/tests/cli-help.test.ts +27 -2
- package/tests/config.test.ts +29 -2
- package/tests/dev-ports.test.ts +41 -0
- package/tests/dev-session-lock.test.ts +54 -0
- package/tests/dev-ui.test.ts +162 -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/src/commands/deploy.ts
CHANGED
|
@@ -12,15 +12,20 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import type { Command } from "commander"
|
|
15
|
-
import { existsSync, readdirSync, statSync, createReadStream } from "node:fs"
|
|
16
|
-
import { join } from "node:path"
|
|
15
|
+
import { existsSync, readdirSync, statSync, createReadStream, mkdirSync, cpSync } from "node:fs"
|
|
16
|
+
import { join, relative } from "node:path"
|
|
17
17
|
import { loadConfig, loadSchemaAst } from "../config.js"
|
|
18
18
|
import { connectionString, schemaPathFromProject } from "../project-config.js"
|
|
19
19
|
import { deploySchemaToLinkedProject, loadCloudConfig, pushSchemaToLinkedProject } from "./cloud.js"
|
|
20
|
+
import { loadProjectLink } from "../link.js"
|
|
21
|
+
import { resolveTarget } from "../resolve-target.js"
|
|
22
|
+
import { targetFetch } from "../target-client.js"
|
|
20
23
|
import { ensureEngine, engineRequest, type DiffResult } from "../engine-client.js"
|
|
21
24
|
import { resolveAppConfig, validateStaticMode, validateBuildOutput, detectPackageManager } from "../app/framework.js"
|
|
22
25
|
import { TIER_LIMITS, type Tier } from "./deploy-types.js"
|
|
23
26
|
import { spawnSync } from "node:child_process"
|
|
27
|
+
import { error, info, plain, step, warn } from "../ui/messages.js"
|
|
28
|
+
import { withSpinner } from "../ui/progress.js"
|
|
24
29
|
|
|
25
30
|
export function registerDeploy(program: Command): void {
|
|
26
31
|
const deploy = program
|
|
@@ -29,7 +34,8 @@ export function registerDeploy(program: Command): void {
|
|
|
29
34
|
"Deploy schema and app — Supatype Cloud by default when linked (`supatype link`); pass --local for engine + your database",
|
|
30
35
|
)
|
|
31
36
|
.option("--local", "Use local schema engine and database_url from config (skip cloud control plane)")
|
|
32
|
-
.option("--environment <name>", "
|
|
37
|
+
.option("--environment <name>", "Target environment when linked", "production")
|
|
38
|
+
.option("--env <name>", "Alias for --environment")
|
|
33
39
|
.option("--app-only", "Skip schema push, only deploy the static site")
|
|
34
40
|
.option("--schema-only", "Skip app build, only push schema changes")
|
|
35
41
|
.option("--skip-build", "Deploy existing build output without building")
|
|
@@ -38,6 +44,7 @@ export function registerDeploy(program: Command): void {
|
|
|
38
44
|
.action(async (opts: {
|
|
39
45
|
local?: boolean
|
|
40
46
|
environment?: string
|
|
47
|
+
env?: string
|
|
41
48
|
appOnly?: boolean
|
|
42
49
|
schemaOnly?: boolean
|
|
43
50
|
skipBuild?: boolean
|
|
@@ -46,18 +53,19 @@ export function registerDeploy(program: Command): void {
|
|
|
46
53
|
}) => {
|
|
47
54
|
const cwd = process.cwd()
|
|
48
55
|
const config = loadConfig(cwd)
|
|
56
|
+
const link = loadProjectLink(cwd)
|
|
49
57
|
const cloudCfg = loadCloudConfig(cwd)
|
|
58
|
+
const envName = opts.env ?? opts.environment ?? "production"
|
|
50
59
|
|
|
51
60
|
let schemaDone = false
|
|
52
61
|
|
|
53
|
-
// Default: cloud — .supatype/cloud.json → control plane schema deploy
|
|
54
62
|
if (
|
|
55
63
|
!opts.local &&
|
|
56
|
-
|
|
64
|
+
link &&
|
|
57
65
|
!opts.appOnly &&
|
|
58
66
|
!opts.skipBuild
|
|
59
67
|
) {
|
|
60
|
-
await deploySchemaToLinkedProject(cwd,
|
|
68
|
+
await deploySchemaToLinkedProject(cwd, envName)
|
|
61
69
|
schemaDone = true
|
|
62
70
|
if (opts.schemaOnly) {
|
|
63
71
|
return
|
|
@@ -69,7 +77,7 @@ export function registerDeploy(program: Command): void {
|
|
|
69
77
|
const ast = loadSchemaAst(schemaPathFromProject(config, cwd), cwd)
|
|
70
78
|
|
|
71
79
|
if (opts.local) {
|
|
72
|
-
|
|
80
|
+
step("Schema Push (local)")
|
|
73
81
|
await ensureEngine()
|
|
74
82
|
|
|
75
83
|
const diff = await engineRequest<DiffResult>("/diff", {
|
|
@@ -81,22 +89,22 @@ export function registerDeploy(program: Command): void {
|
|
|
81
89
|
const ops = diff.operations ?? []
|
|
82
90
|
|
|
83
91
|
if (ops.length > 0) {
|
|
84
|
-
|
|
92
|
+
info(`${ops.length} schema change(s) to apply.`)
|
|
85
93
|
await engineRequest("/push", {
|
|
86
94
|
ast,
|
|
87
95
|
database_url: connectionString(config),
|
|
88
96
|
schema: "public",
|
|
89
97
|
force: true,
|
|
90
98
|
})
|
|
91
|
-
|
|
99
|
+
info("Schema changes applied.")
|
|
92
100
|
} else {
|
|
93
|
-
|
|
101
|
+
info("Schema is up to date.")
|
|
94
102
|
}
|
|
95
|
-
} else if (
|
|
96
|
-
|
|
97
|
-
await pushSchemaToLinkedProject(cwd, { force: opts.yes ?? true })
|
|
103
|
+
} else if (link) {
|
|
104
|
+
step("Schema Push (linked)")
|
|
105
|
+
await pushSchemaToLinkedProject(cwd, { force: opts.yes ?? true, env: envName })
|
|
98
106
|
} else {
|
|
99
|
-
|
|
107
|
+
error(
|
|
100
108
|
"Not linked to Supatype Cloud. Run: supatype link\n" +
|
|
101
109
|
"Or deploy against your own database: supatype deploy --local",
|
|
102
110
|
)
|
|
@@ -108,29 +116,29 @@ export function registerDeploy(program: Command): void {
|
|
|
108
116
|
if (!opts.schemaOnly) {
|
|
109
117
|
if (!config.build) {
|
|
110
118
|
if (opts.appOnly) {
|
|
111
|
-
|
|
119
|
+
error("No build section found in supatype.config.ts")
|
|
112
120
|
process.exit(1)
|
|
113
121
|
}
|
|
114
122
|
// No build config — skip app deployment silently
|
|
115
123
|
return
|
|
116
124
|
}
|
|
117
125
|
|
|
118
|
-
|
|
126
|
+
step("App Build & Deploy")
|
|
119
127
|
const appConfig = resolveAppConfig(config.build, cwd)
|
|
120
128
|
|
|
121
129
|
// Validate static mode
|
|
122
130
|
const staticError = validateStaticMode(appConfig.framework, appConfig.directory)
|
|
123
131
|
if (staticError) {
|
|
124
|
-
|
|
132
|
+
error(staticError)
|
|
125
133
|
process.exit(1)
|
|
126
134
|
}
|
|
127
135
|
|
|
128
136
|
// Build step
|
|
129
137
|
if (!opts.skipBuild && appConfig.buildCommand) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
138
|
+
info(`Framework: ${appConfig.framework}`)
|
|
139
|
+
info(`Build command: ${appConfig.buildCommand}`)
|
|
140
|
+
info(`Output directory: ${appConfig.outputDirectory}`)
|
|
141
|
+
plain()
|
|
134
142
|
|
|
135
143
|
// Inject environment variables
|
|
136
144
|
const buildEnv: Record<string, string> = {
|
|
@@ -148,7 +156,7 @@ export function registerDeploy(program: Command): void {
|
|
|
148
156
|
|
|
149
157
|
// Install dependencies
|
|
150
158
|
const pm = detectPackageManager(appConfig.directory)
|
|
151
|
-
|
|
159
|
+
info(`Installing dependencies (${pm})...`)
|
|
152
160
|
const installResult = spawnSync(pm, ["install"], {
|
|
153
161
|
cwd: appConfig.directory,
|
|
154
162
|
stdio: "inherit",
|
|
@@ -156,12 +164,12 @@ export function registerDeploy(program: Command): void {
|
|
|
156
164
|
timeout: 5 * 60 * 1000, // 5 minute timeout
|
|
157
165
|
})
|
|
158
166
|
if (installResult.status !== 0) {
|
|
159
|
-
|
|
167
|
+
error("Dependency installation failed.")
|
|
160
168
|
process.exit(1)
|
|
161
169
|
}
|
|
162
170
|
|
|
163
171
|
// Run build
|
|
164
|
-
|
|
172
|
+
plain("\nBuilding...")
|
|
165
173
|
const [buildCmd, ...buildArgs] = appConfig.buildCommand.split(" ")
|
|
166
174
|
const buildResult = spawnSync(buildCmd!, buildArgs, {
|
|
167
175
|
cwd: appConfig.directory,
|
|
@@ -170,7 +178,7 @@ export function registerDeploy(program: Command): void {
|
|
|
170
178
|
timeout: 10 * 60 * 1000, // 10 minute timeout
|
|
171
179
|
})
|
|
172
180
|
if (buildResult.status !== 0) {
|
|
173
|
-
|
|
181
|
+
error("Build failed.")
|
|
174
182
|
process.exit(1)
|
|
175
183
|
}
|
|
176
184
|
}
|
|
@@ -179,27 +187,27 @@ export function registerDeploy(program: Command): void {
|
|
|
179
187
|
const maxSizeMb = 500 // Default, should be tier-aware in cloud
|
|
180
188
|
const validationError = validateBuildOutput(appConfig.outputDirectory, maxSizeMb)
|
|
181
189
|
if (validationError) {
|
|
182
|
-
|
|
190
|
+
error(validationError)
|
|
183
191
|
process.exit(1)
|
|
184
192
|
}
|
|
185
193
|
|
|
186
194
|
// Deploy (--local never uploads to cloud, even if linked)
|
|
187
|
-
if (
|
|
188
|
-
await
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
)
|
|
195
|
+
if (link && !opts.local) {
|
|
196
|
+
await deployStaticSite(cwd, appConfig.outputDirectory, {
|
|
197
|
+
preview: opts.preview ?? false,
|
|
198
|
+
env: envName,
|
|
199
|
+
})
|
|
193
200
|
} else {
|
|
194
201
|
deploySelfHost(appConfig.outputDirectory, cwd)
|
|
195
202
|
}
|
|
196
203
|
|
|
197
|
-
|
|
198
|
-
if (
|
|
204
|
+
info("Deployment complete!")
|
|
205
|
+
if (link && !opts.local) {
|
|
206
|
+
const target = resolveTarget(cwd, { env: envName })
|
|
199
207
|
const url = opts.preview
|
|
200
|
-
?
|
|
201
|
-
:
|
|
202
|
-
|
|
208
|
+
? `${target.apiBaseUrl}/preview`
|
|
209
|
+
: target.apiBaseUrl
|
|
210
|
+
info(`URL: ${url}`)
|
|
203
211
|
}
|
|
204
212
|
}
|
|
205
213
|
})
|
|
@@ -208,123 +216,174 @@ export function registerDeploy(program: Command): void {
|
|
|
208
216
|
deploy
|
|
209
217
|
.command("rollback")
|
|
210
218
|
.description("Roll back to the previous static site deployment")
|
|
211
|
-
.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const apiUrl = cloudCfg.apiUrl || "https://api.supatype.com"
|
|
219
|
-
const token = cloudCfg.token || process.env["SUPATYPE_ACCESS_TOKEN"] || ""
|
|
220
|
-
|
|
221
|
-
const res = await fetch(`${apiUrl}/platform/v1/projects/${cloudCfg.projectSlug}/deployments/rollback`, {
|
|
222
|
-
method: "POST",
|
|
223
|
-
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
224
|
-
})
|
|
225
|
-
|
|
226
|
-
if (!res.ok) {
|
|
227
|
-
const body = await res.text()
|
|
228
|
-
console.error(`Rollback failed: ${res.status} ${body}`)
|
|
219
|
+
.option("--env <name>", "Target environment when linked")
|
|
220
|
+
.option("--to <id>", "Roll back to a specific deployment id or version")
|
|
221
|
+
.action(async (opts: { env?: string; to?: string }) => {
|
|
222
|
+
const cwd = process.cwd()
|
|
223
|
+
const link = loadProjectLink(cwd)
|
|
224
|
+
if (!link) {
|
|
225
|
+
error("Not linked to a project. Rollback requires a linked target.")
|
|
229
226
|
process.exit(1)
|
|
230
227
|
}
|
|
231
228
|
|
|
232
|
-
const
|
|
233
|
-
|
|
229
|
+
const target = resolveTarget(cwd, { env: opts.env })
|
|
230
|
+
const body = opts.to ? { to: opts.to } : undefined
|
|
231
|
+
const data = await targetFetch<{ version: string; message: string }>(
|
|
232
|
+
target.apiBaseUrl,
|
|
233
|
+
target.apiPrefix,
|
|
234
|
+
{
|
|
235
|
+
method: "POST",
|
|
236
|
+
path: `/projects/${target.projectRef}/deployments/rollback`,
|
|
237
|
+
body,
|
|
238
|
+
token: target.token!,
|
|
239
|
+
orgId: target.orgId,
|
|
240
|
+
environment: target.mode === "cloud" ? target.environment : undefined,
|
|
241
|
+
},
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
info(`Rolled back to deployment ${data.version ?? "previous"}.`)
|
|
234
245
|
})
|
|
235
246
|
|
|
236
247
|
// supatype deploy status
|
|
237
248
|
deploy
|
|
238
249
|
.command("status")
|
|
239
250
|
.description("Show current deployment status")
|
|
240
|
-
.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
251
|
+
.option("--env <name>", "Target environment when linked")
|
|
252
|
+
.action(async (opts: { env?: string }) => {
|
|
253
|
+
const cwd = process.cwd()
|
|
254
|
+
const link = loadProjectLink(cwd)
|
|
255
|
+
if (!link) {
|
|
256
|
+
error("Not linked to a project.")
|
|
244
257
|
process.exit(1)
|
|
245
258
|
}
|
|
246
259
|
|
|
247
|
-
const
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
260
|
+
const target = resolveTarget(cwd, { env: opts.env })
|
|
261
|
+
const data = await targetFetch<{
|
|
262
|
+
version?: string
|
|
263
|
+
id?: string
|
|
264
|
+
timestamp?: string
|
|
265
|
+
createdAt?: string
|
|
266
|
+
size?: number
|
|
267
|
+
buildDuration?: number
|
|
268
|
+
url?: string
|
|
269
|
+
status?: string
|
|
270
|
+
} | null>(
|
|
271
|
+
target.apiBaseUrl,
|
|
272
|
+
target.apiPrefix,
|
|
273
|
+
{
|
|
274
|
+
method: "GET",
|
|
275
|
+
path: `/projects/${target.projectRef}/deployments/current`,
|
|
276
|
+
token: target.token!,
|
|
277
|
+
orgId: target.orgId,
|
|
278
|
+
environment: target.mode === "cloud" ? target.environment : undefined,
|
|
279
|
+
},
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
if (!data) {
|
|
283
|
+
info("No active deployment found.")
|
|
256
284
|
return
|
|
257
285
|
}
|
|
258
286
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
console.log(`Deployment: ${data.version}`)
|
|
269
|
-
console.log(`Status: ${data.status}`)
|
|
270
|
-
console.log(`Deployed: ${data.timestamp}`)
|
|
271
|
-
console.log(`Size: ${(data.size / (1024 * 1024)).toFixed(1)}MB`)
|
|
272
|
-
console.log(`Build duration: ${data.buildDuration}s`)
|
|
273
|
-
console.log(`URL: ${data.url}`)
|
|
287
|
+
info(`Deployment: ${data.version ?? data.id ?? "unknown"}`)
|
|
288
|
+
info(`Status: ${data.status ?? "live"}`)
|
|
289
|
+
if (data.timestamp ?? data.createdAt) {
|
|
290
|
+
info(`Deployed: ${data.timestamp ?? data.createdAt}`)
|
|
291
|
+
}
|
|
292
|
+
if (data.size) info(`Size: ${(data.size / (1024 * 1024)).toFixed(1)}MB`)
|
|
293
|
+
if (data.buildDuration) info(`Build duration: ${data.buildDuration}s`)
|
|
294
|
+
if (data.url) info(`URL: ${data.url}`)
|
|
274
295
|
})
|
|
275
296
|
|
|
276
297
|
// supatype deploy logs <version>
|
|
277
298
|
deploy
|
|
278
299
|
.command("logs [version]")
|
|
279
300
|
.description("Show build logs for a deployment")
|
|
280
|
-
.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
301
|
+
.option("--env <name>", "Target environment when linked")
|
|
302
|
+
.action(async (version: string | undefined, opts: { env?: string }) => {
|
|
303
|
+
const cwd = process.cwd()
|
|
304
|
+
const link = loadProjectLink(cwd)
|
|
305
|
+
if (!link) {
|
|
306
|
+
error("Not linked to a project.")
|
|
284
307
|
process.exit(1)
|
|
285
308
|
}
|
|
286
309
|
|
|
287
|
-
const
|
|
288
|
-
const token = cloudCfg.token || process.env["SUPATYPE_ACCESS_TOKEN"] || ""
|
|
289
|
-
|
|
310
|
+
const target = resolveTarget(cwd, { env: opts.env })
|
|
290
311
|
const versionPath = version ? `/${version}` : "/current"
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
312
|
+
const data = await targetFetch<{ logs: string }>(
|
|
313
|
+
target.apiBaseUrl,
|
|
314
|
+
target.apiPrefix,
|
|
315
|
+
{
|
|
316
|
+
method: "GET",
|
|
317
|
+
path: `/projects/${target.projectRef}/deployments${versionPath}/logs`,
|
|
318
|
+
token: target.token!,
|
|
319
|
+
orgId: target.orgId,
|
|
320
|
+
environment: target.mode === "cloud" ? target.environment : undefined,
|
|
321
|
+
},
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
plain(data.logs ?? "(no logs)")
|
|
302
325
|
})
|
|
303
326
|
}
|
|
304
327
|
|
|
305
|
-
async function
|
|
306
|
-
|
|
328
|
+
async function deployStaticSite(
|
|
329
|
+
cwd: string,
|
|
307
330
|
outputDir: string,
|
|
308
|
-
|
|
331
|
+
opts: { preview?: boolean; env?: string },
|
|
309
332
|
): Promise<void> {
|
|
310
|
-
const
|
|
311
|
-
const token =
|
|
312
|
-
|
|
313
|
-
|
|
333
|
+
const target = resolveTarget(cwd, { env: opts.env })
|
|
334
|
+
const token = target.token
|
|
335
|
+
if (!token) {
|
|
336
|
+
throw new Error("No token for linked target. Re-run supatype link --token ...")
|
|
337
|
+
}
|
|
314
338
|
|
|
315
|
-
|
|
339
|
+
info("Uploading build artifacts...")
|
|
316
340
|
const files = collectFiles(outputDir, outputDir)
|
|
317
|
-
|
|
341
|
+
info(`${files.length} files to upload (${formatSize(files.reduce((s, f) => s + f.size, 0))})`)
|
|
342
|
+
|
|
343
|
+
const { readFileSync } = await import("node:fs")
|
|
344
|
+
|
|
345
|
+
if (target.apiPrefix === "/platform/v1") {
|
|
346
|
+
const filePayload = files.map((f) => ({
|
|
347
|
+
path: f.relativePath,
|
|
348
|
+
content: readFileSync(f.absolutePath).toString("base64"),
|
|
349
|
+
encoding: "base64",
|
|
350
|
+
}))
|
|
351
|
+
|
|
352
|
+
const created = await targetFetch<{ id: string }>(
|
|
353
|
+
target.apiBaseUrl,
|
|
354
|
+
target.apiPrefix,
|
|
355
|
+
{
|
|
356
|
+
method: "POST",
|
|
357
|
+
path: `/projects/${target.projectRef}/deployments`,
|
|
358
|
+
body: { preview: opts.preview ?? false, files: filePayload },
|
|
359
|
+
token,
|
|
360
|
+
orgId: target.orgId,
|
|
361
|
+
},
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
await targetFetch(
|
|
365
|
+
target.apiBaseUrl,
|
|
366
|
+
target.apiPrefix,
|
|
367
|
+
{
|
|
368
|
+
method: "POST",
|
|
369
|
+
path: `/projects/${target.projectRef}/deployments/${created.id}/finalize`,
|
|
370
|
+
token,
|
|
371
|
+
orgId: target.orgId,
|
|
372
|
+
},
|
|
373
|
+
)
|
|
374
|
+
return
|
|
375
|
+
}
|
|
318
376
|
|
|
319
|
-
|
|
320
|
-
const createRes = await fetch(`${apiUrl}/platform/v1/projects/${config.projectRef}/deployments`, {
|
|
377
|
+
const createRes = await fetch(`${target.apiBaseUrl}/api/v1/projects/${target.projectRef}/deployments`, {
|
|
321
378
|
method: "POST",
|
|
322
379
|
headers: {
|
|
323
380
|
Authorization: `Bearer ${token}`,
|
|
324
381
|
"Content-Type": "application/json",
|
|
382
|
+
...(target.orgId ? { "X-Org-Id": target.orgId } : {}),
|
|
383
|
+
...(target.environment ? { "X-Supatype-Environment": target.environment } : {}),
|
|
325
384
|
},
|
|
326
385
|
body: JSON.stringify({
|
|
327
|
-
preview:
|
|
386
|
+
preview: opts.preview ?? false,
|
|
328
387
|
fileCount: files.length,
|
|
329
388
|
totalSize: files.reduce((s, f) => s + f.size, 0),
|
|
330
389
|
files: files.map((f) => ({ path: f.relativePath, size: f.size })),
|
|
@@ -338,9 +397,8 @@ async function deployToCloud(
|
|
|
338
397
|
|
|
339
398
|
const { data } = await createRes.json() as { data: { deploymentId: string; uploadUrl: string } }
|
|
340
399
|
|
|
341
|
-
// Upload files (simplified — in production, use multipart or presigned URLs)
|
|
342
400
|
for (const file of files) {
|
|
343
|
-
const content =
|
|
401
|
+
const content = readFileSync(file.absolutePath)
|
|
344
402
|
await fetch(`${data.uploadUrl}/${file.relativePath}`, {
|
|
345
403
|
method: "PUT",
|
|
346
404
|
headers: {
|
|
@@ -352,19 +410,23 @@ async function deployToCloud(
|
|
|
352
410
|
})
|
|
353
411
|
}
|
|
354
412
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
413
|
+
await fetch(
|
|
414
|
+
`${target.apiBaseUrl}/api/v1/projects/${target.projectRef}/deployments/${data.deploymentId}/finalize`,
|
|
415
|
+
{
|
|
416
|
+
method: "POST",
|
|
417
|
+
headers: {
|
|
418
|
+
Authorization: `Bearer ${token}`,
|
|
419
|
+
...(target.orgId ? { "X-Org-Id": target.orgId } : {}),
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
)
|
|
360
423
|
}
|
|
361
424
|
|
|
362
425
|
function deploySelfHost(outputDir: string, cwd: string): void {
|
|
363
426
|
const servingDir = join(cwd, ".supatype", "static")
|
|
364
|
-
const { mkdirSync, cpSync } = require("node:fs") as typeof import("node:fs")
|
|
365
427
|
mkdirSync(servingDir, { recursive: true })
|
|
366
428
|
cpSync(outputDir, servingDir, { recursive: true })
|
|
367
|
-
|
|
429
|
+
info(`Static files deployed to ${servingDir}`)
|
|
368
430
|
}
|
|
369
431
|
|
|
370
432
|
interface FileEntry {
|
|
@@ -375,8 +437,6 @@ interface FileEntry {
|
|
|
375
437
|
|
|
376
438
|
function collectFiles(dir: string, baseDir: string): FileEntry[] {
|
|
377
439
|
const files: FileEntry[] = []
|
|
378
|
-
const { readdirSync, statSync } = require("node:fs") as typeof import("node:fs")
|
|
379
|
-
const { relative } = require("node:path") as typeof import("node:path")
|
|
380
440
|
|
|
381
441
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
382
442
|
const fullPath = join(dir, entry.name)
|