spfn 0.2.0-beta.34 → 0.2.0-beta.36
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/dist/index.js +29 -10
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -755,7 +755,7 @@ var init_deployment_config = __esm({
|
|
|
755
755
|
|
|
756
756
|
// src/utils/version.ts
|
|
757
757
|
function getCliVersion() {
|
|
758
|
-
return "0.2.0-beta.
|
|
758
|
+
return "0.2.0-beta.36";
|
|
759
759
|
}
|
|
760
760
|
function getTagFromVersion(version) {
|
|
761
761
|
const match = version.match(/-([a-z]+)\./i);
|
|
@@ -2322,6 +2322,7 @@ import prompts3 from "prompts";
|
|
|
2322
2322
|
import "@spfn/core/config";
|
|
2323
2323
|
import { loadEnv as loadEnv3 } from "@spfn/core/server";
|
|
2324
2324
|
import { sql } from "drizzle-orm";
|
|
2325
|
+
import { getTableConfig } from "drizzle-orm/pg-core";
|
|
2325
2326
|
|
|
2326
2327
|
// src/commands/db/utils/sql-classifier.ts
|
|
2327
2328
|
var DESTRUCTIVE_PATTERNS = [
|
|
@@ -2430,20 +2431,34 @@ async function dbPush(options = {}) {
|
|
|
2430
2431
|
console.log(chalk13.dim(`Found ${schemaFiles.length} schema file(s)
|
|
2431
2432
|
`));
|
|
2432
2433
|
const imports = await loadSchemaImports(schemaFiles);
|
|
2434
|
+
const detectedSchemas = new Set(config.schemaFilter ?? ["public"]);
|
|
2435
|
+
for (const value of Object.values(imports)) {
|
|
2436
|
+
try {
|
|
2437
|
+
const cfg = getTableConfig(value);
|
|
2438
|
+
if (cfg.schema) {
|
|
2439
|
+
detectedSchemas.add(cfg.schema);
|
|
2440
|
+
}
|
|
2441
|
+
} catch {
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
const schemaFilter = Array.from(detectedSchemas);
|
|
2433
2445
|
const { db, close } = await createPushConnection();
|
|
2434
2446
|
try {
|
|
2435
2447
|
const { pushSchema } = await import("drizzle-kit/api");
|
|
2436
|
-
const { statementsToExecute
|
|
2448
|
+
const { statementsToExecute } = await pushSchema(
|
|
2437
2449
|
imports,
|
|
2438
2450
|
db,
|
|
2439
|
-
|
|
2451
|
+
schemaFilter
|
|
2452
|
+
);
|
|
2453
|
+
const statements = statementsToExecute.map(
|
|
2454
|
+
(s) => s.replace(/^CREATE SCHEMA(?!\s+IF\s+NOT\s+EXISTS)/i, "CREATE SCHEMA IF NOT EXISTS")
|
|
2440
2455
|
);
|
|
2441
|
-
if (
|
|
2456
|
+
if (statements.length === 0) {
|
|
2442
2457
|
console.log(chalk13.green("\u2705 No changes detected \u2014 database is up to date\n"));
|
|
2443
2458
|
await applyFunctionMigrations();
|
|
2444
2459
|
return;
|
|
2445
2460
|
}
|
|
2446
|
-
const result = classifyStatements(
|
|
2461
|
+
const result = classifyStatements(statements);
|
|
2447
2462
|
if (options.dryRun) {
|
|
2448
2463
|
displayDryRunSummary(result);
|
|
2449
2464
|
return;
|
|
@@ -2451,11 +2466,15 @@ async function dbPush(options = {}) {
|
|
|
2451
2466
|
displayClassifiedStatements(result);
|
|
2452
2467
|
if (options.force) {
|
|
2453
2468
|
console.log(chalk13.dim("\n--force: applying all changes..."));
|
|
2454
|
-
|
|
2455
|
-
|
|
2469
|
+
for (const stmt of statements) {
|
|
2470
|
+
await db.execute(sql.raw(stmt));
|
|
2471
|
+
}
|
|
2472
|
+
displayApplySummary(statements.length, 0);
|
|
2456
2473
|
} else if (result.destructive.length === 0) {
|
|
2457
|
-
|
|
2458
|
-
|
|
2474
|
+
for (const stmt of statements) {
|
|
2475
|
+
await db.execute(sql.raw(stmt));
|
|
2476
|
+
}
|
|
2477
|
+
displayApplySummary(statements.length, 0);
|
|
2459
2478
|
} else {
|
|
2460
2479
|
const safeCount = result.safe.length + result.warning.length;
|
|
2461
2480
|
if (safeCount > 0) {
|
|
@@ -2481,7 +2500,7 @@ async function dbPush(options = {}) {
|
|
|
2481
2500
|
for (const stmt of result.destructive) {
|
|
2482
2501
|
await db.execute(sql.raw(stmt.sql));
|
|
2483
2502
|
}
|
|
2484
|
-
displayApplySummary(
|
|
2503
|
+
displayApplySummary(statements.length, 0);
|
|
2485
2504
|
} else {
|
|
2486
2505
|
displayApplySummary(safeCount, result.destructive.length);
|
|
2487
2506
|
console.log(chalk13.dim("Tip: Use --force to apply all changes without prompting.\n"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spfn",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.36",
|
|
4
4
|
"description": "Superfunction CLI - Add SPFN to your Next.js project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"postgres": "^3.4.0",
|
|
69
69
|
"prompts": "^2.4.2",
|
|
70
70
|
"tsup": "^8.5.0",
|
|
71
|
-
"@spfn/core": "0.2.0-beta.
|
|
71
|
+
"@spfn/core": "0.2.0-beta.37"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/fs-extra": "^11.0.4",
|