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.
Files changed (2) hide show
  1. package/cli/cli.js +34 -11
  2. package/package.json +1 -1
package/cli/cli.js CHANGED
@@ -50,13 +50,17 @@ Options:
50
50
  }
51
51
  }
52
52
 
53
- const standaloneDir = path.join(__dirname, "app");
54
- const serverPath = path.join(standaloneDir, "server.js");
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
- if (!fs.existsSync(serverPath)) {
57
- console.error("Error: Standalone build not found at cli/app/server.js");
58
- console.error("Run 'npm run build:cli' first.");
59
- process.exit(1);
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
- const server = spawn(process.execPath, ["--max-old-space-size=4096", serverPath], {
97
- cwd: standaloneDir,
98
- stdio: showLog ? "inherit" : "ignore",
99
- env: { ...process.env, PORT: String(port), HOSTNAME: host }
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kentutai-app",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "KentutAI web dashboard",
5
5
  "private": false,
6
6
  "bin": {