spfn 0.2.0-beta.16 → 0.2.0-beta.17

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.
Files changed (2) hide show
  1. package/dist/index.js +34 -21
  2. package/package.json +1 -1
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.16";
758
+ return "0.2.0-beta.17";
759
759
  }
760
760
  function getTagFromVersion(version) {
761
761
  const match = version.match(/-([a-z]+)\./i);
@@ -2607,12 +2607,12 @@ async function dbMigrate(options = {}) {
2607
2607
  console.error(chalk16.red("\u274C DATABASE_URL not found in environment"));
2608
2608
  process.exit(1);
2609
2609
  }
2610
- const connection = postgres.default(env4.DATABASE_URL, { max: 1 });
2611
- const db = drizzle(connection);
2612
- try {
2613
- const { discoverFunctionMigrations: discoverFunctionMigrations2 } = await Promise.resolve().then(() => (init_function_migrations(), function_migrations_exports));
2614
- const functions = discoverFunctionMigrations2(process.cwd());
2615
- if (functions.length > 0) {
2610
+ const { discoverFunctionMigrations: discoverFunctionMigrations2 } = await Promise.resolve().then(() => (init_function_migrations(), function_migrations_exports));
2611
+ const functions = discoverFunctionMigrations2(process.cwd());
2612
+ if (functions.length > 0) {
2613
+ const fnConn = postgres.default(env4.DATABASE_URL, { max: 1 });
2614
+ const fnDb = drizzle(fnConn);
2615
+ try {
2616
2616
  console.log(chalk16.blue("\u{1F4E6} Applying function package migrations:"));
2617
2617
  functions.forEach((func) => {
2618
2618
  console.log(chalk16.dim(` - ${func.packageName}`));
@@ -2620,25 +2620,38 @@ async function dbMigrate(options = {}) {
2620
2620
  for (const func of functions) {
2621
2621
  console.log(chalk16.blue(`
2622
2622
  \u{1F4E6} Running ${func.packageName} migrations...`));
2623
- await migrate(db, { migrationsFolder: func.migrationsDir });
2623
+ await migrate(fnDb, { migrationsFolder: func.migrationsDir });
2624
2624
  console.log(chalk16.green(` \u2713 ${func.packageName} migrations applied`));
2625
2625
  }
2626
2626
  console.log(chalk16.green("\u2705 Function migrations applied\n"));
2627
+ } finally {
2628
+ await fnConn.end();
2627
2629
  }
2628
- const projectMigrationsDir = join16(process.cwd(), "src/server/drizzle");
2629
- if (existsSync18(projectMigrationsDir)) {
2630
- console.log(chalk16.blue("\u{1F4E6} Running project migrations..."));
2631
- await migrate(db, { migrationsFolder: projectMigrationsDir });
2632
- console.log(chalk16.green("\u2705 Project migrations applied successfully"));
2633
- } else {
2634
- console.log(chalk16.dim("No project migrations found (src/server/drizzle)"));
2630
+ }
2631
+ const projectMigrationsDir = join16(process.cwd(), "src/server/drizzle");
2632
+ if (existsSync18(projectMigrationsDir)) {
2633
+ const projConn = postgres.default(env4.DATABASE_URL, { max: 1 });
2634
+ const projDb = drizzle(projConn);
2635
+ try {
2636
+ const beforeCount = await projConn`
2637
+ SELECT count(*)::int as count FROM drizzle.__drizzle_migrations
2638
+ `;
2639
+ console.log(chalk16.blue(`\u{1F4E6} Running project migrations... (${beforeCount[0].count} already recorded)`));
2640
+ await migrate(projDb, { migrationsFolder: projectMigrationsDir });
2641
+ const afterCount = await projConn`
2642
+ SELECT count(*)::int as count FROM drizzle.__drizzle_migrations
2643
+ `;
2644
+ const applied = afterCount[0].count - beforeCount[0].count;
2645
+ if (applied > 0) {
2646
+ console.log(chalk16.green(`\u2705 Project migrations applied successfully (${applied} new)`));
2647
+ } else {
2648
+ console.log(chalk16.yellow(`\u26A0\uFE0F No new project migrations to apply (${afterCount[0].count} already recorded)`));
2649
+ }
2650
+ } finally {
2651
+ await projConn.end();
2635
2652
  }
2636
- } catch (error) {
2637
- console.error(chalk16.red("\n\u274C Failed to apply migrations"));
2638
- console.error(chalk16.red(error instanceof Error ? error.message : "Unknown error"));
2639
- process.exit(1);
2640
- } finally {
2641
- await connection.end();
2653
+ } else {
2654
+ console.log(chalk16.dim("No project migrations found (src/server/drizzle)"));
2642
2655
  }
2643
2656
  }
2644
2657
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spfn",
3
- "version": "0.2.0-beta.16",
3
+ "version": "0.2.0-beta.17",
4
4
  "description": "Superfunction CLI - Add SPFN to your Next.js project",
5
5
  "type": "module",
6
6
  "bin": {