spfn 0.2.0-beta.50 → 0.2.0-beta.52

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 +19 -5
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -789,7 +789,7 @@ var init_deployment_config = __esm({
789
789
 
790
790
  // src/utils/version.ts
791
791
  function getCliVersion() {
792
- return "0.2.0-beta.50";
792
+ return "0.2.0-beta.52";
793
793
  }
794
794
  function getTagFromVersion(version) {
795
795
  const match = version.match(/-([a-z]+)\./i);
@@ -2291,6 +2291,20 @@ import chalk9 from "chalk";
2291
2291
  import ora6 from "ora";
2292
2292
  import { env } from "@spfn/core/config";
2293
2293
  import { loadEnv } from "@spfn/core/server";
2294
+ function shouldRelaxDbTls(databaseUrl) {
2295
+ if (process.env.SPFN_DB_INSECURE_TLS === "1" || process.env.SPFN_DB_INSECURE_TLS === "true") {
2296
+ return true;
2297
+ }
2298
+ if (!databaseUrl) {
2299
+ return false;
2300
+ }
2301
+ try {
2302
+ const host = new URL(databaseUrl).hostname.replace(/^\[|\]$/g, "");
2303
+ return host === "localhost" || host === "127.0.0.1" || host === "::1";
2304
+ } catch {
2305
+ return false;
2306
+ }
2307
+ }
2294
2308
  function validateDatabasePrerequisites() {
2295
2309
  loadEnv();
2296
2310
  if (!env.DATABASE_URL) {
@@ -2329,7 +2343,7 @@ async function runDrizzleCommand(command) {
2329
2343
  stdio: "inherit",
2330
2344
  // Allow interactive input
2331
2345
  shell: true,
2332
- env: { ...process.env, NODE_TLS_REJECT_UNAUTHORIZED: "0" }
2346
+ env: shouldRelaxDbTls(env.DATABASE_URL) ? { ...process.env, NODE_TLS_REJECT_UNAUTHORIZED: "0" } : { ...process.env }
2333
2347
  });
2334
2348
  const cleanup = () => {
2335
2349
  if (!hasUserConfig && existsSync15(tempConfigPath)) {
@@ -2386,12 +2400,12 @@ async function createPushConnection() {
2386
2400
  if (!env.DATABASE_URL) {
2387
2401
  throw new Error("DATABASE_URL is required");
2388
2402
  }
2389
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
2390
2403
  const pg = await import("pg");
2391
2404
  const { drizzle } = await import("drizzle-orm/node-postgres");
2392
2405
  const pool = new pg.default.Pool({
2393
2406
  connectionString: env.DATABASE_URL,
2394
- max: 1
2407
+ max: 1,
2408
+ ...shouldRelaxDbTls(env.DATABASE_URL) ? { ssl: { rejectUnauthorized: false } } : {}
2395
2409
  });
2396
2410
  const db = drizzle(pool);
2397
2411
  return {
@@ -3113,7 +3127,7 @@ async function dbStudio(requestedPort) {
3113
3127
  const studioProcess = spawn3("drizzle-kit", ["studio", `--port=${port}`, `--config=${configPath}`], {
3114
3128
  stdio: "inherit",
3115
3129
  shell: true,
3116
- env: { ...process.env, NODE_TLS_REJECT_UNAUTHORIZED: "0" }
3130
+ env: shouldRelaxDbTls(env5.DATABASE_URL) ? { ...process.env, NODE_TLS_REJECT_UNAUTHORIZED: "0" } : { ...process.env }
3117
3131
  });
3118
3132
  const cleanup = () => {
3119
3133
  if (!hasUserConfig && existsSync19(tempConfigPath)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spfn",
3
- "version": "0.2.0-beta.50",
3
+ "version": "0.2.0-beta.52",
4
4
  "description": "Superfunction CLI - Add SPFN to your Next.js project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -78,7 +78,7 @@
78
78
  "concurrently": "^9.2.1",
79
79
  "tsx": "^4.20.6",
80
80
  "typescript": "^5.3.3",
81
- "@spfn/core": "0.2.0-beta.54"
81
+ "@spfn/core": "0.2.0-beta.56"
82
82
  },
83
83
  "scripts": {
84
84
  "build": "tsup && node scripts/copy-templates.js",