arkos 1.4.0-canary.38 → 1.4.0-canary.39
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/cjs/utils/cli/start.js +9 -48
- package/dist/cjs/utils/cli/start.js.map +1 -1
- package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/esm/utils/cli/start.js +9 -48
- package/dist/esm/utils/cli/start.js.map +1 -1
- package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,6 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const child_process_1 = require("child_process");
|
|
11
11
|
const dotenv_helpers_1 = require("../dotenv.helpers");
|
|
12
|
-
const global_helpers_1 = require("../helpers/global.helpers");
|
|
13
12
|
const fs_helpers_1 = require("../helpers/fs.helpers");
|
|
14
13
|
const port_and_host_allocator_1 = __importDefault(require("../features/port-and-host-allocator"));
|
|
15
14
|
const watermark_stamper_1 = __importDefault(require("./utils/watermark-stamper"));
|
|
@@ -43,53 +42,15 @@ async function startCommand(options = {}) {
|
|
|
43
42
|
child.kill();
|
|
44
43
|
process.exit(0);
|
|
45
44
|
});
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
watermark_stamper_1.default.stamp({
|
|
56
|
-
envFiles,
|
|
57
|
-
port: "port" in config && config?.port !== undefined
|
|
58
|
-
? hostAndPort.port
|
|
59
|
-
: undefined,
|
|
60
|
-
host: hostAndPort.host,
|
|
61
|
-
});
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
if (!err?.message?.includes("../../server"))
|
|
68
|
-
console.error(err);
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
const waitForConfig = async () => {
|
|
73
|
-
let attempts = 0;
|
|
74
|
-
const maxAttempts = 15;
|
|
75
|
-
while (attempts < maxAttempts) {
|
|
76
|
-
const ready = await checkConfig();
|
|
77
|
-
if (ready)
|
|
78
|
-
break;
|
|
79
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
80
|
-
attempts++;
|
|
81
|
-
}
|
|
82
|
-
if (attempts >= maxAttempts) {
|
|
83
|
-
if (env.CLI_PORT || env.PORT)
|
|
84
|
-
port_and_host_allocator_1.default.logWarnings();
|
|
85
|
-
watermark_stamper_1.default.stamp({
|
|
86
|
-
envFiles,
|
|
87
|
-
host: env.CLI_HOST || env.HOST,
|
|
88
|
-
port: env.CLI_PORT || env.PORT,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
waitForConfig();
|
|
45
|
+
const hostAndPort = await port_and_host_allocator_1.default.getHostAndAvailablePort(env, {
|
|
46
|
+
logWarning: true,
|
|
47
|
+
});
|
|
48
|
+
if (env.CLI_PORT || env.PORT)
|
|
49
|
+
port_and_host_allocator_1.default.logWarnings();
|
|
50
|
+
watermark_stamper_1.default.stamp({
|
|
51
|
+
envFiles,
|
|
52
|
+
...hostAndPort,
|
|
53
|
+
});
|
|
93
54
|
}
|
|
94
55
|
catch (error) {
|
|
95
56
|
console.error("❌ Production server failed to start:", error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../../src/utils/cli/start.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../../src/utils/cli/start.ts"],"names":[],"mappings":";;;;;AAmBA,oCAuDC;AAKD,4EAGC;AAlFD,gDAAwB;AACxB,4CAAoB;AACpB,iDAAoD;AACpD,sDAA6D;AAC7D,sDAAqD;AACrD,kGAAuE;AACvE,kFAAyD;AAOzD,IAAI,KAAK,GAAwB,IAAI,CAAC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YAExB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,MAAM,iCAAoB,CAAC,uBAAuB,CACpE,GAAG,EACH;YAEE,UAAU,EAAE,IAAI;SACjB,CACF,CAAC;QAEF,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI;YAAE,iCAAoB,CAAC,WAAW,EAAE,CAAC;QAEjE,2BAAgB,CAAC,KAAK,CAAC;YACrB,QAAQ;YACR,GAAG,WAAW;SACf,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;QAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAKD,SAAgB,gCAAgC;IAC7C,KAAsB,EAAE,IAAI,EAAE,EAAE,CAAC;IAClC,KAAK,GAAG,IAAI,CAAC;AACf,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { ChildProcess, spawn } from \"child_process\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { fullCleanCwd } from \"../helpers/fs.helpers\";\nimport portAndHostAllocator from \"../features/port-and-host-allocator\";\nimport watermarkStamper from \"./utils/watermark-stamper\";\n\ninterface StartOptions {\n port?: string;\n host?: string;\n}\n\nlet child: ChildProcess | null = null;\nlet envFiles: string[] | undefined;\n\n/**\n * Production start command for the arkos CLI\n */\nexport async function startCommand(options: StartOptions = {}) {\n if (process.env.NODE_ENV === \"test\" || !process.env.NODE_ENV)\n process.env.NODE_ENV = \"production\";\n envFiles = loadEnvironmentVariables();\n\n try {\n const { port, host } = options;\n\n const entryPoint = path.join(process.cwd(), \".build\", \"src\", \"app.js\");\n\n if (!fs.existsSync(path.join(entryPoint))) {\n console.error(\n `❌ Could not find built application entry point at ${fullCleanCwd(entryPoint)}`\n );\n process.exit(1);\n }\n\n const env: { [x: string]: string } = {\n NODE_ENV: \"production\",\n ...process.env,\n ...(port && { CLI_PORT: port }),\n ...(host && { CLI_HOST: host }),\n ARKOS_BUILD: \"true\",\n };\n\n child = spawn(\"node\", [entryPoint], {\n stdio: \"inherit\",\n env,\n shell: true,\n });\n\n process.on(\"SIGINT\", () => {\n if (child) child.kill();\n\n process.exit(0);\n });\n\n const hostAndPort = await portAndHostAllocator.getHostAndAvailablePort(\n env,\n {\n // ...config,\n logWarning: true,\n }\n );\n\n if (env.CLI_PORT || env.PORT) portAndHostAllocator.logWarnings();\n\n watermarkStamper.stamp({\n envFiles,\n ...hostAndPort,\n });\n } catch (error) {\n console.error(\"❌ Production server failed to start:\", error);\n process.exit(1);\n }\n}\n\n/**\n * Help function to help other processes to terminate the production server child process\n */\nexport function killProductionServerChildProcess() {\n (child as ChildProcess)?.kill?.();\n child = null;\n}\n"]}
|
|
@@ -2,7 +2,6 @@ import path from "path";
|
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import { spawn } from "child_process";
|
|
4
4
|
import { loadEnvironmentVariables } from "../dotenv.helpers.js";
|
|
5
|
-
import { importModule } from "../helpers/global.helpers.js";
|
|
6
5
|
import { fullCleanCwd } from "../helpers/fs.helpers.js";
|
|
7
6
|
import portAndHostAllocator from "../features/port-and-host-allocator.js";
|
|
8
7
|
import watermarkStamper from "./utils/watermark-stamper.js";
|
|
@@ -36,53 +35,15 @@ export async function startCommand(options = {}) {
|
|
|
36
35
|
child.kill();
|
|
37
36
|
process.exit(0);
|
|
38
37
|
});
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
watermarkStamper.stamp({
|
|
49
|
-
envFiles,
|
|
50
|
-
port: "port" in config && config?.port !== undefined
|
|
51
|
-
? hostAndPort.port
|
|
52
|
-
: undefined,
|
|
53
|
-
host: hostAndPort.host,
|
|
54
|
-
});
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
catch (err) {
|
|
60
|
-
if (!err?.message?.includes("../../server"))
|
|
61
|
-
console.error(err);
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const waitForConfig = async () => {
|
|
66
|
-
let attempts = 0;
|
|
67
|
-
const maxAttempts = 15;
|
|
68
|
-
while (attempts < maxAttempts) {
|
|
69
|
-
const ready = await checkConfig();
|
|
70
|
-
if (ready)
|
|
71
|
-
break;
|
|
72
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
73
|
-
attempts++;
|
|
74
|
-
}
|
|
75
|
-
if (attempts >= maxAttempts) {
|
|
76
|
-
if (env.CLI_PORT || env.PORT)
|
|
77
|
-
portAndHostAllocator.logWarnings();
|
|
78
|
-
watermarkStamper.stamp({
|
|
79
|
-
envFiles,
|
|
80
|
-
host: env.CLI_HOST || env.HOST,
|
|
81
|
-
port: env.CLI_PORT || env.PORT,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
waitForConfig();
|
|
38
|
+
const hostAndPort = await portAndHostAllocator.getHostAndAvailablePort(env, {
|
|
39
|
+
logWarning: true,
|
|
40
|
+
});
|
|
41
|
+
if (env.CLI_PORT || env.PORT)
|
|
42
|
+
portAndHostAllocator.logWarnings();
|
|
43
|
+
watermarkStamper.stamp({
|
|
44
|
+
envFiles,
|
|
45
|
+
...hostAndPort,
|
|
46
|
+
});
|
|
86
47
|
}
|
|
87
48
|
catch (error) {
|
|
88
49
|
console.error("❌ Production server failed to start:", error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../../src/utils/cli/start.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAgB,KAAK,EAAE,M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\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { fullCleanCwd } from \"../helpers/fs.helpers\";\nimport portAndHostAllocator from \"../features/port-and-host-allocator\";\nimport watermarkStamper from \"./utils/watermark-stamper\";\n\ninterface StartOptions {\n port?: string;\n host?: string;\n}\n\nlet child: ChildProcess | null = null;\nlet envFiles: string[] | undefined;\n\n/**\n * Production start command for the arkos CLI\n */\nexport async function startCommand(options: StartOptions = {}) {\n if (process.env.NODE_ENV === \"test\" || !process.env.NODE_ENV)\n process.env.NODE_ENV = \"production\";\n envFiles = loadEnvironmentVariables();\n\n try {\n const { port, host } = options;\n\n const entryPoint = path.join(process.cwd(), \".build\", \"src\", \"app.js\");\n\n if (!fs.existsSync(path.join(entryPoint))) {\n console.error(\n `❌ Could not find built application entry point at ${fullCleanCwd(entryPoint)}`\n );\n process.exit(1);\n }\n\n const env: { [x: string]: string } = {\n NODE_ENV: \"production\",\n ...process.env,\n ...(port && { CLI_PORT: port }),\n ...(host && { CLI_HOST: host }),\n ARKOS_BUILD: \"true\",\n };\n\n child = spawn(\"node\", [entryPoint], {\n stdio: \"inherit\",\n env,\n shell: true,\n });\n\n process.on(\"SIGINT\", () => {\n if (child) child.kill();\n\n process.exit(0);\n });\n\n const hostAndPort = await portAndHostAllocator.getHostAndAvailablePort(\n env,\n {\n // ...config,\n logWarning: true,\n }\n );\n\n if (env.CLI_PORT || env.PORT) portAndHostAllocator.logWarnings();\n\n watermarkStamper.stamp({\n envFiles,\n ...hostAndPort,\n });\n } catch (error) {\n console.error(\"❌ Production server failed to start:\", error);\n process.exit(1);\n }\n}\n\n/**\n * Help function to help other processes to terminate the production server child process\n */\nexport function killProductionServerChildProcess() {\n (child as ChildProcess)?.kill?.();\n child = null;\n}\n"]}
|