kentutai-app 1.1.1 → 1.1.3
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/cli/cli.js +34 -11
- package/package.json +1 -1
package/cli/cli.js
CHANGED
|
@@ -50,13 +50,17 @@ Options:
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const
|
|
54
|
-
const
|
|
53
|
+
const appDir = path.join(__dirname, "app");
|
|
54
|
+
const standaloneServer = path.join(appDir, "server.js");
|
|
55
|
+
const mainAppDir = path.resolve(__dirname, "..");
|
|
56
|
+
const mainServerPath = path.join(mainAppDir, ".next", "standalone", "server.js");
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
const useStandalone = fs.existsSync(standaloneServer);
|
|
59
|
+
const useMainApp = !useStandalone && fs.existsSync(mainServerPath);
|
|
60
|
+
|
|
61
|
+
if (!useStandalone && !useMainApp) {
|
|
62
|
+
console.log("\n First run detected. Starting development server...\n");
|
|
63
|
+
console.log(" For production, run: npm run build\n");
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
function openBrowser(url) {
|
|
@@ -93,11 +97,30 @@ function startServer() {
|
|
|
93
97
|
const displayHost = host === DEFAULT_HOST ? "localhost" : host;
|
|
94
98
|
const url = `http://${displayHost}:${port}/dashboard`;
|
|
95
99
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
let server;
|
|
101
|
+
|
|
102
|
+
if (useStandalone) {
|
|
103
|
+
server = spawn(process.execPath, ["--max-old-space-size=4096", standaloneServer], {
|
|
104
|
+
cwd: appDir,
|
|
105
|
+
stdio: showLog ? "inherit" : "ignore",
|
|
106
|
+
env: { ...process.env, PORT: String(port), HOSTNAME: host }
|
|
107
|
+
});
|
|
108
|
+
} else if (useMainApp) {
|
|
109
|
+
server = spawn(process.execPath, ["--max-old-space-size=4096", mainServerPath], {
|
|
110
|
+
cwd: path.join(mainAppDir, ".next", "standalone"),
|
|
111
|
+
stdio: showLog ? "inherit" : "ignore",
|
|
112
|
+
env: { ...process.env, PORT: String(port), HOSTNAME: host }
|
|
113
|
+
});
|
|
114
|
+
} else {
|
|
115
|
+
const isWin = process.platform === "win32";
|
|
116
|
+
const npmCmd = isWin ? "npm.cmd" : "npm";
|
|
117
|
+
server = spawn(npmCmd, ["run", "dev", "--", "--port", String(port)], {
|
|
118
|
+
cwd: mainAppDir,
|
|
119
|
+
stdio: showLog ? "inherit" : "ignore",
|
|
120
|
+
shell: isWin,
|
|
121
|
+
env: { ...process.env, PORT: String(port) }
|
|
122
|
+
});
|
|
123
|
+
}
|
|
101
124
|
|
|
102
125
|
server.on("error", (err) => {
|
|
103
126
|
console.error("Failed to start server:", err.message);
|