@supatype/cli 0.3.4 → 0.3.6
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 +1 -1
- package/.turbo/turbo-test.log +168 -158
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +36 -0
- package/dist/adopt-walkthrough.d.ts +40 -0
- package/dist/adopt-walkthrough.d.ts.map +1 -0
- package/dist/adopt-walkthrough.js +113 -0
- package/dist/adopt-walkthrough.js.map +1 -0
- package/dist/cli-version-embedded.js +1 -1
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +7 -16
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/adopt.d.ts.map +1 -1
- package/dist/commands/adopt.js +5 -6
- package/dist/commands/adopt.js.map +1 -1
- package/dist/commands/db.js +3 -3
- package/dist/commands/db.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +7 -4
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +20 -5
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +5 -7
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +6 -3
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +10 -6
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/seed.js +2 -2
- package/dist/commands/seed.js.map +1 -1
- package/dist/dev-compose.d.ts +42 -0
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +116 -71
- package/dist/dev-compose.js.map +1 -1
- package/dist/dev-db-reset.d.ts +19 -0
- package/dist/dev-db-reset.d.ts.map +1 -0
- package/dist/dev-db-reset.js +75 -0
- package/dist/dev-db-reset.js.map +1 -0
- package/dist/dev-initial-push.d.ts +37 -0
- package/dist/dev-initial-push.d.ts.map +1 -0
- package/dist/dev-initial-push.js +91 -0
- package/dist/dev-initial-push.js.map +1 -0
- package/dist/dev-ports.d.ts.map +1 -1
- package/dist/dev-ports.js +1 -1
- package/dist/dev-ports.js.map +1 -1
- package/dist/diff-output.d.ts +2 -2
- package/dist/diff-output.d.ts.map +1 -1
- package/dist/diff-output.js +1 -1
- package/dist/diff-output.js.map +1 -1
- package/dist/engine-client.d.ts +5 -1
- package/dist/engine-client.d.ts.map +1 -1
- package/dist/engine-client.js +8 -6
- package/dist/engine-client.js.map +1 -1
- package/dist/engine-push-output.d.ts +10 -0
- package/dist/engine-push-output.d.ts.map +1 -1
- package/dist/engine-push-output.js +12 -0
- package/dist/engine-push-output.js.map +1 -1
- package/dist/{seed-connection.d.ts → host-database.d.ts} +20 -10
- package/dist/host-database.d.ts.map +1 -0
- package/dist/{seed-connection.js → host-database.js} +40 -14
- package/dist/host-database.js.map +1 -0
- package/dist/resolve-target.d.ts +2 -2
- package/dist/resolve-target.d.ts.map +1 -1
- package/dist/resolve-target.js +15 -11
- package/dist/resolve-target.js.map +1 -1
- package/dist/retired-no-cache.d.ts +18 -0
- package/dist/retired-no-cache.d.ts.map +1 -0
- package/dist/retired-no-cache.js +21 -0
- package/dist/retired-no-cache.js.map +1 -0
- package/dist/self-host-compose.d.ts +6 -0
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +9 -3
- package/dist/self-host-compose.js.map +1 -1
- package/dist/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +31 -25
- package/dist/type-extractor.js.map +1 -1
- package/package.json +2 -2
- package/src/adopt-walkthrough.ts +142 -0
- package/src/cli-version-embedded.ts +1 -1
- package/src/commands/admin.ts +7 -20
- package/src/commands/adopt.ts +5 -6
- package/src/commands/db.ts +3 -3
- package/src/commands/deploy.ts +7 -4
- package/src/commands/dev.ts +22 -6
- package/src/commands/doctor.ts +5 -7
- package/src/commands/init.ts +1 -1
- package/src/commands/migrate.ts +7 -4
- package/src/commands/push.ts +28 -10
- package/src/commands/seed.ts +2 -2
- package/src/dev-compose.ts +166 -77
- package/src/dev-db-reset.ts +95 -0
- package/src/dev-initial-push.ts +134 -0
- package/src/dev-ports.ts +1 -1
- package/src/diff-output.ts +2 -2
- package/src/engine-client.ts +5 -4
- package/src/engine-push-output.ts +19 -0
- package/src/{seed-connection.ts → host-database.ts} +42 -12
- package/src/resolve-target.ts +20 -14
- package/src/retired-no-cache.ts +27 -0
- package/src/self-host-compose.ts +10 -3
- package/src/type-extractor.ts +39 -42
- package/tests/adopt-result.test.ts +27 -0
- package/tests/adopt-walkthrough.test.ts +129 -0
- package/tests/dev-db-reset.test.ts +162 -0
- package/tests/dev-initial-push.test.ts +142 -0
- package/tests/engine-push-output.test.ts +30 -1
- package/tests/host-connection-targets.test.ts +84 -0
- package/tests/{seed-connection.test.ts → host-database.test.ts} +33 -15
- package/tests/retired-no-cache.test.ts +46 -0
- package/tests/type-extractor.test.ts +80 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/seed-connection.d.ts.map +0 -1
- package/dist/seed-connection.js.map +0 -1
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
// Annotated `string`, not left to inference: once a release stamps a value here, the
|
|
10
10
|
// inferred literal type makes the `!== ""` test in cliPackageVersion() a compile error
|
|
11
11
|
// (TS2367, no overlap), so the build would only fail during a release.
|
|
12
|
-
export const EMBEDDED_CLI_VERSION: string = "0.3.
|
|
12
|
+
export const EMBEDDED_CLI_VERSION: string = "0.3.6"
|
package/src/commands/admin.ts
CHANGED
|
@@ -10,11 +10,8 @@ import { dirname, join, resolve } from "node:path"
|
|
|
10
10
|
import bcrypt from "bcryptjs"
|
|
11
11
|
import type { Pool, QueryResult } from "pg"
|
|
12
12
|
import { loadConfig } from "../config.js"
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
resolveRuntimeProvider,
|
|
16
|
-
type SupatypeProjectConfig,
|
|
17
|
-
} from "../project-config.js"
|
|
13
|
+
import { resolveRuntimeProvider, type SupatypeProjectConfig } from "../project-config.js"
|
|
14
|
+
import { resolveHostDatabaseUrl } from "../host-database.js"
|
|
18
15
|
import { readEnvValue, upsertEnvFile } from "../env-file.js"
|
|
19
16
|
import { hasEngineOverride } from "../binary-cache.js"
|
|
20
17
|
import { readDevSessionLock } from "../dev-session-lock.js"
|
|
@@ -94,9 +91,7 @@ function resolveAdminConnection(
|
|
|
94
91
|
config: SupatypeProjectConfig,
|
|
95
92
|
override?: string,
|
|
96
93
|
): string {
|
|
97
|
-
|
|
98
|
-
if (hasEngineOverride(config)) return hostComposeDbUrlFromEnv(cwd)
|
|
99
|
-
return readEnvValue(cwd, "DATABASE_URL", connectionString(config))
|
|
94
|
+
return resolveHostDatabaseUrl(cwd, config, { connection: override, allowDerived: true }).dsn
|
|
100
95
|
}
|
|
101
96
|
|
|
102
97
|
export function registerAdmin(program: Command): void {
|
|
@@ -343,10 +338,10 @@ export async function ensureFirstAdminUserForProject(
|
|
|
343
338
|
return
|
|
344
339
|
}
|
|
345
340
|
|
|
346
|
-
const connection =
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
341
|
+
const connection = resolveHostDatabaseUrl(root, config, {
|
|
342
|
+
connection: options.connection,
|
|
343
|
+
allowDerived: true,
|
|
344
|
+
}).dsn
|
|
350
345
|
|
|
351
346
|
await ensureFirstAdminUser(connection, merged)
|
|
352
347
|
}
|
|
@@ -814,14 +809,6 @@ function interpolateSql(sql: string, params: unknown[]): string {
|
|
|
814
809
|
})
|
|
815
810
|
}
|
|
816
811
|
|
|
817
|
-
function hostComposeDbUrlFromEnv(cwd: string): string {
|
|
818
|
-
const port = readEnvValue(cwd, "SUPATYPE_DEV_DB_PORT", "54329")
|
|
819
|
-
const user = readEnvValue(cwd, "POSTGRES_USER", "supatype_admin")
|
|
820
|
-
const pass = readEnvValue(cwd, "POSTGRES_PASSWORD", "postgres")
|
|
821
|
-
const db = readEnvValue(cwd, "POSTGRES_DB", "supatype")
|
|
822
|
-
return `postgresql://${user}:${pass}@127.0.0.1:${port}/${db}?sslmode=disable`
|
|
823
|
-
}
|
|
824
|
-
|
|
825
812
|
async function importPg(): Promise<typeof import("pg")> {
|
|
826
813
|
try {
|
|
827
814
|
return await import("pg")
|
package/src/commands/adopt.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { resolveTarget, targetSchemaAdopt, schemaPgSchema } from "../resolve-tar
|
|
|
6
6
|
import { confirm } from "../ui/confirm.js"
|
|
7
7
|
import { info, plain } from "../ui/messages.js"
|
|
8
8
|
import { withSpinner } from "../ui/progress.js"
|
|
9
|
+
import { addRetiredNoCacheOption, warnIfRetiredNoCache } from "../retired-no-cache.js"
|
|
9
10
|
|
|
10
11
|
interface AdoptPreview {
|
|
11
12
|
status: string
|
|
@@ -18,21 +19,21 @@ interface AdoptPreview {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export function registerAdopt(program: Command): void {
|
|
21
|
-
program
|
|
22
|
+
const command = program
|
|
22
23
|
.command("adopt")
|
|
23
24
|
.description("Stamp Supatype-managed comments on DB objects matching the schema (adoption ceremony)")
|
|
24
25
|
.option("--connection <url>", "Database connection URL (overrides config)")
|
|
25
26
|
.option("--env <name>", "Target environment when linked")
|
|
26
27
|
.option("--direct", "Use local engine subprocess")
|
|
27
28
|
.option("--yes", "Apply stamps without interactive confirmation")
|
|
28
|
-
|
|
29
|
-
.action(async (opts: {
|
|
29
|
+
addRetiredNoCacheOption(command).action(async (opts: {
|
|
30
30
|
connection?: string
|
|
31
31
|
env?: string
|
|
32
32
|
direct?: boolean
|
|
33
33
|
yes?: boolean
|
|
34
|
-
|
|
34
|
+
cache?: boolean
|
|
35
35
|
}) => {
|
|
36
|
+
warnIfRetiredNoCache(opts)
|
|
36
37
|
const cwd = process.cwd()
|
|
37
38
|
const config = loadConfig(cwd)
|
|
38
39
|
const pgSchema = schemaPgSchema(cwd)
|
|
@@ -48,7 +49,6 @@ export function registerAdopt(program: Command): void {
|
|
|
48
49
|
|
|
49
50
|
const preview = (await targetSchemaAdopt(target, ast, {
|
|
50
51
|
schema: pgSchema,
|
|
51
|
-
noCache: opts.noCache ?? false,
|
|
52
52
|
yes: false,
|
|
53
53
|
})) as AdoptPreview
|
|
54
54
|
|
|
@@ -73,7 +73,6 @@ export function registerAdopt(program: Command): void {
|
|
|
73
73
|
|
|
74
74
|
const result = (await targetSchemaAdopt(target, ast, {
|
|
75
75
|
schema: pgSchema,
|
|
76
|
-
noCache: opts.noCache ?? false,
|
|
77
76
|
yes: true,
|
|
78
77
|
})) as { status: string; stamped?: number; name?: string }
|
|
79
78
|
|
package/src/commands/db.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import type { Command } from "commander"
|
|
9
9
|
import { loadConfig, rethrowIfConfigBroken } from "../config.js"
|
|
10
|
-
import {
|
|
10
|
+
import { resolveHostDatabaseUrl } from "../host-database.js"
|
|
11
11
|
import { loadProjectLink } from "../link.js"
|
|
12
12
|
import { resolveTarget } from "../resolve-target.js"
|
|
13
13
|
import { targetFetch } from "../target-client.js"
|
|
@@ -36,7 +36,7 @@ export function registerDb(program: Command): void {
|
|
|
36
36
|
const cwd = process.cwd()
|
|
37
37
|
const config = loadConfig(cwd)
|
|
38
38
|
const link = loadProjectLink(cwd)
|
|
39
|
-
const localConn =
|
|
39
|
+
const localConn = resolveHostDatabaseUrl(cwd, config, { allowDerived: true }).dsn
|
|
40
40
|
|
|
41
41
|
if (!link || link.kind !== "cloud") {
|
|
42
42
|
const connStr = opts.transaction ? localConn.replace(/:5432\//, ":6432/") : localConn
|
|
@@ -151,7 +151,7 @@ export function registerDb(program: Command): void {
|
|
|
151
151
|
if (!url || !schema) {
|
|
152
152
|
try {
|
|
153
153
|
const config = loadConfig(cwd)
|
|
154
|
-
url = url ??
|
|
154
|
+
url = url ?? resolveHostDatabaseUrl(cwd, config, { allowDerived: true }).dsn
|
|
155
155
|
schema = schema ?? config.schema?.pg_schema ?? "public"
|
|
156
156
|
} catch (err) {
|
|
157
157
|
rethrowIfConfigBroken(err)
|
package/src/commands/deploy.ts
CHANGED
|
@@ -16,7 +16,8 @@ import type { Command } from "commander"
|
|
|
16
16
|
import { existsSync, readdirSync, statSync, createReadStream, mkdirSync, cpSync } from "node:fs"
|
|
17
17
|
import { join, relative } from "node:path"
|
|
18
18
|
import { loadConfig, loadSchemaAst } from "../config.js"
|
|
19
|
-
import {
|
|
19
|
+
import { schemaPathFromProject } from "../project-config.js"
|
|
20
|
+
import { resolveHostDatabaseUrl } from "../host-database.js"
|
|
20
21
|
import { deploySchemaToLinkedProject, loadCloudConfig, pushSchemaToLinkedProject } from "./cloud.js"
|
|
21
22
|
import { loadProjectLink } from "../link.js"
|
|
22
23
|
import { resolveTarget } from "../resolve-target.js"
|
|
@@ -27,6 +28,7 @@ import { TIER_LIMITS, type Tier } from "./deploy-types.js"
|
|
|
27
28
|
import { spawnSync } from "node:child_process"
|
|
28
29
|
import { error, info, plain, step, warn } from "../ui/messages.js"
|
|
29
30
|
import { withSpinner } from "../ui/progress.js"
|
|
31
|
+
import { printPushWarnings, type EnginePushResult } from "../engine-push-output.js"
|
|
30
32
|
|
|
31
33
|
export function registerDeploy(program: Command): void {
|
|
32
34
|
const deploy = program
|
|
@@ -83,7 +85,7 @@ export function registerDeploy(program: Command): void {
|
|
|
83
85
|
|
|
84
86
|
const diff = await engineRequest<DiffResult>("/diff", {
|
|
85
87
|
ast,
|
|
86
|
-
database_url:
|
|
88
|
+
database_url: resolveHostDatabaseUrl(cwd, config, { allowDerived: true }).dsn,
|
|
87
89
|
schema: "public",
|
|
88
90
|
})
|
|
89
91
|
|
|
@@ -91,13 +93,14 @@ export function registerDeploy(program: Command): void {
|
|
|
91
93
|
|
|
92
94
|
if (ops.length > 0) {
|
|
93
95
|
info(`${ops.length} schema change(s) to apply.`)
|
|
94
|
-
await engineRequest("/push", {
|
|
96
|
+
const result = await engineRequest<EnginePushResult>("/push", {
|
|
95
97
|
ast,
|
|
96
|
-
database_url:
|
|
98
|
+
database_url: resolveHostDatabaseUrl(cwd, config, { allowDerived: true }).dsn,
|
|
97
99
|
schema: "public",
|
|
98
100
|
force: true,
|
|
99
101
|
})
|
|
100
102
|
info("Schema changes applied.")
|
|
103
|
+
printPushWarnings(result)
|
|
101
104
|
} else {
|
|
102
105
|
info("Schema is up to date.")
|
|
103
106
|
}
|
package/src/commands/dev.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { keyspaceInPostgres } from "../cache-provider.js"
|
|
14
|
+
import { printPushWarnings, type EnginePushResult } from "../engine-push-output.js"
|
|
14
15
|
import type { Command } from "commander"
|
|
15
16
|
import { spawnSync } from "node:child_process"
|
|
16
17
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"
|
|
@@ -130,13 +131,23 @@ export function registerDev(program: Command): void {
|
|
|
130
131
|
.option("--no-watch", "Start services but do not watch for schema changes")
|
|
131
132
|
.option("--stream", "Print interleaved logs instead of the interactive TUI")
|
|
132
133
|
.option("--port <port>", "Port for supatype-server (overrides config)", String)
|
|
133
|
-
.
|
|
134
|
+
.option("--reset-db", "Remove the local Postgres data volume before starting (asks first; storage is kept)")
|
|
135
|
+
.option("--yes", "Skip the --reset-db confirmation")
|
|
136
|
+
.action(async (opts: { watch: boolean; stream?: boolean; port?: string; resetDb?: boolean; yes?: boolean }) => {
|
|
134
137
|
const cwd = process.cwd()
|
|
135
138
|
|
|
136
139
|
// ── 1. Load project config (before TUI, fatal errors must hit real stderr) ──
|
|
137
140
|
const config = loadConfig(cwd)
|
|
138
141
|
const provider = resolveRuntimeProvider(config)
|
|
139
142
|
|
|
143
|
+
// The native provider keeps Postgres in a data directory, not a compose volume, and has
|
|
144
|
+
// nothing for this flag to remove. Saying so beats silently starting on the old data.
|
|
145
|
+
if (opts.resetDb === true && provider !== "docker") {
|
|
146
|
+
fatalError("--reset-db applies to the Docker provider only.", [
|
|
147
|
+
"This project runs Postgres natively, so there is no compose volume to remove.",
|
|
148
|
+
])
|
|
149
|
+
}
|
|
150
|
+
|
|
140
151
|
if (provider === "docker") {
|
|
141
152
|
const probe = probeDockerDaemon()
|
|
142
153
|
if (!probe.ok) {
|
|
@@ -164,7 +175,11 @@ export function registerDev(program: Command): void {
|
|
|
164
175
|
|
|
165
176
|
if (provider === "docker") {
|
|
166
177
|
const { runDevCompose } = await import("../dev-compose.js")
|
|
167
|
-
await runDevCompose(cwd, config, {
|
|
178
|
+
await runDevCompose(cwd, config, {
|
|
179
|
+
watch: opts.watch !== false,
|
|
180
|
+
resetDb: opts.resetDb === true,
|
|
181
|
+
yes: opts.yes === true,
|
|
182
|
+
})
|
|
168
183
|
return
|
|
169
184
|
}
|
|
170
185
|
|
|
@@ -226,7 +241,7 @@ export function registerDev(program: Command): void {
|
|
|
226
241
|
if (wantsPgKeyspace && nativeKeyspaceLibraryPresent(pgBinDir) && keyspacePort === null) {
|
|
227
242
|
console.warn(
|
|
228
243
|
`[supatype] ⚠ No free port in ${KEYSPACE_PORT_BASE}-${KEYSPACE_PORT_BASE + KEYSPACE_PORT_SPAN - 1} ` +
|
|
229
|
-
"for the Postgres keyspace
|
|
244
|
+
"for the Postgres keyspace, starting without it.",
|
|
230
245
|
)
|
|
231
246
|
}
|
|
232
247
|
|
|
@@ -449,8 +464,8 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticate
|
|
|
449
464
|
: null
|
|
450
465
|
if (keyspacePort !== null && nativeKeyspaceAddr === null) {
|
|
451
466
|
console.warn(
|
|
452
|
-
`[supatype] ⚠ Postgres has pg_keyspace but is not serving RESP on :${keyspacePort}
|
|
453
|
-
"
|
|
467
|
+
`[supatype] ⚠ Postgres has pg_keyspace but is not serving RESP on :${keyspacePort}. ` +
|
|
468
|
+
"See logs/postgres.log. Falling back to the Valkey sidecar.",
|
|
454
469
|
)
|
|
455
470
|
}
|
|
456
471
|
if (nativeKeyspaceAddr) {
|
|
@@ -757,7 +772,7 @@ async function runSchemaPush(
|
|
|
757
772
|
const pgSchema = config?.schema?.pg_schema ?? "public"
|
|
758
773
|
const sources = writeSchemaSourcePushArtifacts(cwd)
|
|
759
774
|
try {
|
|
760
|
-
await engineRequest("/push", {
|
|
775
|
+
const result = await engineRequest<EnginePushResult>("/push", {
|
|
761
776
|
ast,
|
|
762
777
|
database_url: dbURL,
|
|
763
778
|
schema: pgSchema,
|
|
@@ -769,6 +784,7 @@ async function runSchemaPush(
|
|
|
769
784
|
}
|
|
770
785
|
: {}),
|
|
771
786
|
})
|
|
787
|
+
printPushWarnings(result)
|
|
772
788
|
} catch (err) {
|
|
773
789
|
_lastFailedAst = astJson
|
|
774
790
|
throw err
|
package/src/commands/doctor.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { loadProjectLink } from "../link.js"
|
|
|
7
7
|
import { resolveHostEngineDatabaseUrl } from "../dev-compose.js"
|
|
8
8
|
import { hooksReport, type HooksReport } from "../model-hooks.js"
|
|
9
9
|
import { checkServiceRoleRoutes, type ServiceRoleProblems } from "../service-role-check.js"
|
|
10
|
+
import { addRetiredNoCacheOption, warnIfRetiredNoCache } from "../retired-no-cache.js"
|
|
10
11
|
|
|
11
12
|
interface DoctorItem {
|
|
12
13
|
kind: string
|
|
@@ -36,21 +37,21 @@ export function printSection(title: string, items: DoctorItem[]): void {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
export function registerDoctor(program: Command): void {
|
|
39
|
-
program
|
|
40
|
+
const command = program
|
|
40
41
|
.command("doctor")
|
|
41
42
|
.description("Report schema drift between schema/index.ts and the live database")
|
|
42
43
|
.option("--connection <url>", "Database connection URL (overrides config)")
|
|
43
44
|
.option("--env <name>", "Target environment when linked")
|
|
44
45
|
.option("--strict", "Exit non-zero when missing or stale managed drift exists")
|
|
45
|
-
.option("--no-cache", "Force full database introspection")
|
|
46
46
|
.option("--direct", "Use local engine subprocess")
|
|
47
|
-
|
|
47
|
+
addRetiredNoCacheOption(command).action(async (opts: {
|
|
48
48
|
connection?: string
|
|
49
49
|
env?: string
|
|
50
50
|
strict?: boolean
|
|
51
|
-
|
|
51
|
+
cache?: boolean
|
|
52
52
|
direct?: boolean
|
|
53
53
|
}) => {
|
|
54
|
+
warnIfRetiredNoCache(opts)
|
|
54
55
|
const cwd = process.cwd()
|
|
55
56
|
const config = loadConfig(cwd)
|
|
56
57
|
const pgSchema = schemaPgSchema(cwd)
|
|
@@ -64,14 +65,12 @@ export function registerDoctor(program: Command): void {
|
|
|
64
65
|
if (linked && !opts.direct && !opts.connection) {
|
|
65
66
|
const target = resolveTarget(cwd, { env: opts.env })
|
|
66
67
|
report = (await targetSchemaDoctor(target, ast, {
|
|
67
|
-
noCache: opts.noCache,
|
|
68
68
|
schema: pgSchema,
|
|
69
69
|
})) as DoctorReport
|
|
70
70
|
} else if (!opts.direct && !opts.connection) {
|
|
71
71
|
const connection = await resolveHostEngineDatabaseUrl(cwd, config, opts.connection)
|
|
72
72
|
const target = resolveTarget(cwd, { direct: true, connection })
|
|
73
73
|
report = (await targetSchemaDoctor(target, ast, {
|
|
74
|
-
noCache: opts.noCache,
|
|
75
74
|
schema: pgSchema,
|
|
76
75
|
})) as DoctorReport
|
|
77
76
|
void connection
|
|
@@ -82,7 +81,6 @@ export function registerDoctor(program: Command): void {
|
|
|
82
81
|
connection: opts.connection,
|
|
83
82
|
})
|
|
84
83
|
report = (await targetSchemaDoctor(target, ast, {
|
|
85
|
-
noCache: opts.noCache,
|
|
86
84
|
schema: pgSchema,
|
|
87
85
|
})) as DoctorReport
|
|
88
86
|
}
|
package/src/commands/init.ts
CHANGED
|
@@ -1000,7 +1000,7 @@ function appConfigLines(app: ScaffoldAppOptions, productionTarget: ProductionTar
|
|
|
1000
1000
|
const HOLDING_PAGE_LOGO_URL = "https://supatype.github.io/supatype/supatype.svg"
|
|
1001
1001
|
const HOLDING_PAGE_DOCS_URL = "https://supatype.github.io/supatype/"
|
|
1002
1002
|
const HOLDING_PAGE_GITHUB_URL = "https://github.com/supatype"
|
|
1003
|
-
const HOLDING_PAGE_DISCORD_URL = "https://discord.gg/
|
|
1003
|
+
const HOLDING_PAGE_DISCORD_URL = "https://discord.gg/TzMtynufEH"
|
|
1004
1004
|
|
|
1005
1005
|
function escapeHtml(text: string): string {
|
|
1006
1006
|
return text
|
package/src/commands/migrate.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { withPublishing } from "../model-versioning.js"
|
|
2
2
|
import type { Command } from "commander"
|
|
3
3
|
import { join } from "node:path"
|
|
4
|
+
import { printPushWarnings, type EnginePushResult } from "../engine-push-output.js"
|
|
4
5
|
import { loadConfig, loadSchemaAst } from "../config.js"
|
|
5
|
-
import {
|
|
6
|
+
import { projectRootFromConfig, schemaPathFromProject } from "../project-config.js"
|
|
7
|
+
import { resolveHostDatabaseUrl } from "../host-database.js"
|
|
6
8
|
import { ensureEngine, engineRequest } from "../engine-client.js"
|
|
7
9
|
import { loadProjectLink } from "../link.js"
|
|
8
10
|
import {
|
|
@@ -75,7 +77,7 @@ export function registerMigrate(program: Command): void {
|
|
|
75
77
|
.option("--connection <url>", "Database connection URL (overrides config)")
|
|
76
78
|
.action(async (opts: { connection?: string }) => {
|
|
77
79
|
const config = loadConfig()
|
|
78
|
-
const connection = opts.connection
|
|
80
|
+
const connection = resolveHostDatabaseUrl(process.cwd(), config, { connection: opts.connection, allowDerived: true }).dsn
|
|
79
81
|
|
|
80
82
|
await ensureEngine()
|
|
81
83
|
const result = await engineRequest<{ message?: string }>("/migrations", {
|
|
@@ -146,18 +148,19 @@ export function registerMigrate(program: Command): void {
|
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
const config = loadConfig()
|
|
149
|
-
const connection = opts.connection
|
|
151
|
+
const connection = resolveHostDatabaseUrl(process.cwd(), config, { connection: opts.connection, allowDerived: true }).dsn
|
|
150
152
|
const cwd = process.cwd()
|
|
151
153
|
|
|
152
154
|
await ensureEngine()
|
|
153
155
|
const ast = withPublishing(loadSchemaAst(schemaPathFromProject(config, cwd), cwd), config)
|
|
154
|
-
const result = await engineRequest<
|
|
156
|
+
const result = await engineRequest<EnginePushResult>("/push", {
|
|
155
157
|
ast,
|
|
156
158
|
database_url: connection,
|
|
157
159
|
schema: "public",
|
|
158
160
|
force: true,
|
|
159
161
|
})
|
|
160
162
|
info(result.message ?? "Reset complete.")
|
|
163
|
+
printPushWarnings(result)
|
|
161
164
|
})
|
|
162
165
|
}
|
|
163
166
|
|
package/src/commands/push.ts
CHANGED
|
@@ -27,6 +27,8 @@ import {
|
|
|
27
27
|
} from "../preview-config-check.js"
|
|
28
28
|
import { pinnedVersion } from "../binary-cache.js"
|
|
29
29
|
import { printDiffOperations, printDiffWarnings } from "../diff-output.js"
|
|
30
|
+
import { printPushWarnings } from "../engine-push-output.js"
|
|
31
|
+
import { pushOfferingAdoption, targetAdoptionSteps } from "../adopt-walkthrough.js"
|
|
30
32
|
import { signJwt } from "../jwt.js"
|
|
31
33
|
import { provisionBucketsFromAst } from "../storage-provision.js"
|
|
32
34
|
import type { ExtractedSchemaAstV2 } from "../schema-ast-v2.js"
|
|
@@ -38,6 +40,7 @@ import { refreshFunctionsContext } from "../functions-context-refresh.js"
|
|
|
38
40
|
import type { SupatypeProjectConfig } from "../project-config.js"
|
|
39
41
|
import {
|
|
40
42
|
resolveTarget,
|
|
43
|
+
targetSchemaAdopt,
|
|
41
44
|
targetSchemaDiff,
|
|
42
45
|
targetSchemaPush,
|
|
43
46
|
schemaPgSchema,
|
|
@@ -100,8 +103,12 @@ export function registerPush(program: Command): void {
|
|
|
100
103
|
await pushViaTarget(cwd, config, localTarget, ast, pgSchema, opts.yes ?? false)
|
|
101
104
|
return
|
|
102
105
|
}
|
|
103
|
-
const { pushSchemaDocker } = await import("../dev-compose.js")
|
|
104
|
-
await
|
|
106
|
+
const { dockerAdoptionSteps, pushSchemaDocker } = await import("../dev-compose.js")
|
|
107
|
+
await pushOfferingAdoption(
|
|
108
|
+
() => withSpinner("Applying schema via Docker Compose", () => pushSchemaDocker(cwd, config)),
|
|
109
|
+
dockerAdoptionSteps(cwd, config),
|
|
110
|
+
{ yes: opts.yes ?? false, retry: "supatype push" },
|
|
111
|
+
)
|
|
105
112
|
return
|
|
106
113
|
}
|
|
107
114
|
|
|
@@ -152,14 +159,23 @@ async function pushViaTarget(
|
|
|
152
159
|
}
|
|
153
160
|
}
|
|
154
161
|
|
|
155
|
-
const pushResult = await
|
|
156
|
-
ops.length > 0 ? "Applying migration" : "Syncing with engine",
|
|
162
|
+
const pushResult = await pushOfferingAdoption(
|
|
157
163
|
() =>
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
164
|
+
withSpinner(ops.length > 0 ? "Applying migration" : "Syncing with engine", () =>
|
|
165
|
+
targetSchemaPush(target, ast, {
|
|
166
|
+
force: true,
|
|
167
|
+
schema: pgSchema,
|
|
168
|
+
schemaSources: buildSchemaSourcesPayload(cwd, resolvePushedBy()),
|
|
169
|
+
}),
|
|
170
|
+
),
|
|
171
|
+
targetAdoptionSteps(
|
|
172
|
+
async (yes) =>
|
|
173
|
+
(await targetSchemaAdopt(target, ast, { schema: pgSchema, yes })) as {
|
|
174
|
+
stampStatements?: string[]
|
|
175
|
+
stamped?: number
|
|
176
|
+
},
|
|
177
|
+
),
|
|
178
|
+
{ yes: skipConfirm, retry: "supatype push" },
|
|
163
179
|
)
|
|
164
180
|
|
|
165
181
|
if ((pushResult as { status?: string }).status === "up_to_date") {
|
|
@@ -172,6 +188,8 @@ async function pushViaTarget(
|
|
|
172
188
|
cacheSchemaSourcesLocally(cwd, migrationName, schemaSources.gz)
|
|
173
189
|
}
|
|
174
190
|
}
|
|
191
|
+
// The diff's were printed before applying; what is left is what the push found once applied.
|
|
192
|
+
printPushWarnings(pushResult, diff.warnings ?? [])
|
|
175
193
|
|
|
176
194
|
if (target.mode === "cloud" || target.mode === "self-host") {
|
|
177
195
|
await deployHooksToTarget(cwd, config, target, ast)
|
|
@@ -260,7 +278,7 @@ async function deployHooksToTarget(
|
|
|
260
278
|
*
|
|
261
279
|
* Two things have to be true for a local `.cache({ server: true })` to be served: the schema
|
|
262
280
|
* declares the table, and the runtime allowlist has it on. A push writes the first, so without
|
|
263
|
-
* this the second is a trip to Studio that nothing in the output asks for
|
|
281
|
+
* this the second is a trip to Studio that nothing in the output asks for, the symptom being a
|
|
264
282
|
* BYPASS header and a declaration that appears to do nothing.
|
|
265
283
|
*
|
|
266
284
|
* Never an error, and never a rewrite of an entry that already exists. See `seedApiConfigCache`.
|
package/src/commands/seed.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { loadConfig, loadSchemaAst, type SupatypeConfig } from "../config.js"
|
|
|
19
19
|
import { engineRequest, ensureEngine } from "../engine-client.js"
|
|
20
20
|
import { seedUnsupportedByPinnedEngine } from "../engine-floor.js"
|
|
21
21
|
import { pgSchema, projectRootFromConfig, schemaPathFromProject } from "../project-config.js"
|
|
22
|
-
import { DsnNotFound, redact,
|
|
22
|
+
import { DsnNotFound, redact, resolveHostDatabaseUrl } from "../host-database.js"
|
|
23
23
|
import { collectSeed, SeedCollectionFailed } from "../seed-runner.js"
|
|
24
24
|
import { seedBuilderPathWithDefaults } from "../type-generation.js"
|
|
25
25
|
import type { SeedConfig, SeedIr } from "../seed.js"
|
|
@@ -99,7 +99,7 @@ export async function runSeed(file: string | undefined, opts: SeedFlags): Promis
|
|
|
99
99
|
|
|
100
100
|
let dsn: string
|
|
101
101
|
try {
|
|
102
|
-
dsn =
|
|
102
|
+
dsn = resolveHostDatabaseUrl(cwd, config, {
|
|
103
103
|
connection: opts.connection,
|
|
104
104
|
allowDerived: true,
|
|
105
105
|
}).dsn
|