spfn 0.2.0-beta.12 → 0.2.0-beta.14
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 +33 -31
- 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.14";
|
|
759
759
|
}
|
|
760
760
|
function getTagFromVersion(version) {
|
|
761
761
|
const match = version.match(/-([a-z]+)\./i);
|
|
@@ -782,6 +782,7 @@ async function setupPackageJson(cwd, packageJsonPath, packageJson, packageManage
|
|
|
782
782
|
const spfnTag = getSpfnTag();
|
|
783
783
|
packageJson.dependencies["@spfn/core"] = spfnTag;
|
|
784
784
|
packageJson.dependencies["@sinclair/typebox"] = "^0.34.0";
|
|
785
|
+
packageJson.dependencies["drizzle-orm"] = "^0.45.0";
|
|
785
786
|
packageJson.dependencies["drizzle-typebox"] = "^0.1.0";
|
|
786
787
|
packageJson.dependencies["spfn"] = spfnTag;
|
|
787
788
|
packageJson.dependencies["concurrently"] = "^9.2.1";
|
|
@@ -1262,29 +1263,28 @@ init_init();
|
|
|
1262
1263
|
init_logger();
|
|
1263
1264
|
init_package_manager();
|
|
1264
1265
|
import { Command as Command4 } from "commander";
|
|
1265
|
-
import { existsSync as existsSync11, readFileSync as readFileSync3, writeFileSync as writeFileSync6, mkdirSync } from "fs";
|
|
1266
|
+
import { existsSync as existsSync11, readFileSync as readFileSync3, writeFileSync as writeFileSync6, mkdirSync, unlinkSync, watch } from "fs";
|
|
1266
1267
|
import { join as join11 } from "path";
|
|
1267
|
-
import { createConnection } from "net";
|
|
1268
1268
|
import { execa as execa4 } from "execa";
|
|
1269
1269
|
import chokidar from "chokidar";
|
|
1270
|
-
function
|
|
1271
|
-
const start = Date.now();
|
|
1270
|
+
function waitForReadyFile(filePath, timeoutMs = 3e4) {
|
|
1272
1271
|
return new Promise((resolve2, reject) => {
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1272
|
+
if (existsSync11(filePath)) {
|
|
1273
|
+
unlinkSync(filePath);
|
|
1274
|
+
}
|
|
1275
|
+
const timer = setTimeout(() => {
|
|
1276
|
+
watcher.close();
|
|
1277
|
+
reject(new Error(`Server did not become ready within ${timeoutMs / 1e3}s`));
|
|
1278
|
+
}, timeoutMs);
|
|
1279
|
+
const dir = join11(filePath, "..");
|
|
1280
|
+
const fileName = filePath.split("/").pop();
|
|
1281
|
+
const watcher = watch(dir, (event, name) => {
|
|
1282
|
+
if (name === fileName && existsSync11(filePath)) {
|
|
1283
|
+
watcher.close();
|
|
1284
|
+
clearTimeout(timer);
|
|
1285
|
+
resolve2(readFileSync3(filePath, "utf-8").trim());
|
|
1277
1286
|
}
|
|
1278
|
-
|
|
1279
|
-
socket.destroy();
|
|
1280
|
-
resolve2();
|
|
1281
|
-
});
|
|
1282
|
-
socket.on("error", () => {
|
|
1283
|
-
socket.destroy();
|
|
1284
|
-
setTimeout(tryConnect, 300);
|
|
1285
|
-
});
|
|
1286
|
-
};
|
|
1287
|
-
tryConnect();
|
|
1287
|
+
});
|
|
1288
1288
|
});
|
|
1289
1289
|
}
|
|
1290
1290
|
var devCommand = new Command4("dev").description("Start SPFN development server (detects and runs Next.js + Hono)").option("-p, --port <port>", "Server port").option("-H, --host <host>", "Server host").option("--routes <path>", "Routes directory path").option("--server-only", "Run only Hono server (skip Next.js)").option("--watch", "Enable hot reload (watch mode)").action(async (options) => {
|
|
@@ -1314,17 +1314,22 @@ var devCommand = new Command4("dev").description("Start SPFN development server
|
|
|
1314
1314
|
if (options.host) configParts.push(`host: '${options.host}'`);
|
|
1315
1315
|
if (options.routes) configParts.push(`routesPath: '${options.routes}'`);
|
|
1316
1316
|
configParts.push("debug: true");
|
|
1317
|
+
const readyFile = join11(tempDir, "server-ready");
|
|
1317
1318
|
writeFileSync6(serverEntry, `
|
|
1319
|
+
import { writeFileSync } from 'fs';
|
|
1320
|
+
|
|
1318
1321
|
// Load environment variables FIRST (before any imports that depend on them)
|
|
1319
|
-
// Use centralized environment loader for standard dotenv priority
|
|
1320
1322
|
await import('@spfn/core/config');
|
|
1321
1323
|
|
|
1322
1324
|
// Import and start server
|
|
1323
1325
|
const { startServer } = await import('@spfn/core/server');
|
|
1324
1326
|
|
|
1325
|
-
await startServer({
|
|
1327
|
+
const instance = await startServer({
|
|
1326
1328
|
${configParts.join(",\n ")}
|
|
1327
1329
|
});
|
|
1330
|
+
|
|
1331
|
+
// Signal ready with actual port
|
|
1332
|
+
writeFileSync(${JSON.stringify(readyFile)}, String(instance.config.port));
|
|
1328
1333
|
`);
|
|
1329
1334
|
writeFileSync6(watcherEntry, `
|
|
1330
1335
|
// Load environment variables
|
|
@@ -1577,12 +1582,9 @@ catch (error)
|
|
|
1577
1582
|
process.on("SIGTERM", cleanup);
|
|
1578
1583
|
startWatcher();
|
|
1579
1584
|
startServer();
|
|
1580
|
-
const serverHost = options.host ?? process.env.HOST ?? "localhost";
|
|
1581
|
-
const serverPort = Number(options.port ?? process.env.PORT ?? 4e3);
|
|
1582
1585
|
try {
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
logger.info(`[SPFN] Server ready, starting Next.js...
|
|
1586
|
+
const port = await waitForReadyFile(readyFile);
|
|
1587
|
+
logger.info(`[SPFN] Server ready on port ${port}, starting Next.js...
|
|
1586
1588
|
`);
|
|
1587
1589
|
} catch (error) {
|
|
1588
1590
|
logger.warn(`[SPFN] Server readiness check timed out, starting Next.js anyway...`);
|
|
@@ -2106,7 +2108,7 @@ import { Command as Command9 } from "commander";
|
|
|
2106
2108
|
import chalk10 from "chalk";
|
|
2107
2109
|
|
|
2108
2110
|
// src/commands/db/utils/drizzle.ts
|
|
2109
|
-
import { existsSync as existsSync15, writeFileSync as writeFileSync9, unlinkSync } from "fs";
|
|
2111
|
+
import { existsSync as existsSync15, writeFileSync as writeFileSync9, unlinkSync as unlinkSync2 } from "fs";
|
|
2110
2112
|
import { spawn } from "child_process";
|
|
2111
2113
|
import chalk9 from "chalk";
|
|
2112
2114
|
import ora6 from "ora";
|
|
@@ -2153,7 +2155,7 @@ async function runDrizzleCommand(command) {
|
|
|
2153
2155
|
});
|
|
2154
2156
|
const cleanup = () => {
|
|
2155
2157
|
if (!hasUserConfig && existsSync15(tempConfigPath)) {
|
|
2156
|
-
|
|
2158
|
+
unlinkSync2(tempConfigPath);
|
|
2157
2159
|
}
|
|
2158
2160
|
};
|
|
2159
2161
|
drizzleProcess.on("close", (code) => {
|
|
@@ -2619,7 +2621,7 @@ async function dbMigrate(options = {}) {
|
|
|
2619
2621
|
|
|
2620
2622
|
// src/commands/db/studio.ts
|
|
2621
2623
|
import chalk17 from "chalk";
|
|
2622
|
-
import { existsSync as existsSync18, writeFileSync as writeFileSync10, unlinkSync as
|
|
2624
|
+
import { existsSync as existsSync18, writeFileSync as writeFileSync10, unlinkSync as unlinkSync3 } from "fs";
|
|
2623
2625
|
import { spawn as spawn3 } from "child_process";
|
|
2624
2626
|
import { env as env4 } from "@spfn/core/config";
|
|
2625
2627
|
import "@spfn/core/config";
|
|
@@ -2664,7 +2666,7 @@ async function dbStudio(requestedPort) {
|
|
|
2664
2666
|
});
|
|
2665
2667
|
const cleanup = () => {
|
|
2666
2668
|
if (!hasUserConfig && existsSync18(tempConfigPath)) {
|
|
2667
|
-
|
|
2669
|
+
unlinkSync3(tempConfigPath);
|
|
2668
2670
|
}
|
|
2669
2671
|
};
|
|
2670
2672
|
studioProcess.on("exit", (code) => {
|
|
@@ -2694,7 +2696,7 @@ async function dbStudio(requestedPort) {
|
|
|
2694
2696
|
});
|
|
2695
2697
|
} catch (error) {
|
|
2696
2698
|
if (!hasUserConfig && existsSync18(tempConfigPath)) {
|
|
2697
|
-
|
|
2699
|
+
unlinkSync3(tempConfigPath);
|
|
2698
2700
|
}
|
|
2699
2701
|
console.error(chalk17.red("\u274C Failed to start Drizzle Studio"));
|
|
2700
2702
|
console.error(chalk17.red(error instanceof Error ? error.message : "Unknown error"));
|
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.14",
|
|
4
4
|
"description": "Superfunction CLI - Add SPFN to your Next.js project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"postgres": "^3.4.0",
|
|
68
68
|
"prompts": "^2.4.2",
|
|
69
69
|
"tsup": "^8.5.0",
|
|
70
|
-
"@spfn/core": "0.2.0-beta.
|
|
70
|
+
"@spfn/core": "0.2.0-beta.16"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/fs-extra": "^11.0.4",
|