magalh 1.0.0

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 (4) hide show
  1. package/bin/mgl.js +53 -0
  2. package/bin/msh.js +53 -0
  3. package/msh.js +2 -0
  4. package/package.json +130 -0
package/bin/mgl.js ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const fs = require("node:fs");
6
+ const path = require("node:path");
7
+ const { spawn } = require("node:child_process");
8
+
9
+ const args = process.argv.slice(2);
10
+
11
+ if (args.includes("--help") || args.includes("-h")) {
12
+ process.stdout.write(
13
+ [
14
+ "msh - start Magala server",
15
+ "",
16
+ "Usage:",
17
+ " msh [--help]",
18
+ "",
19
+ "Notes:",
20
+ " - Runs bundled msh.js if present, otherwise runs pro.js",
21
+ " - Pass PORTS env var to control ports (e.g., PORTS=80,800,737)",
22
+ "",
23
+ ].join("\n"),
24
+ );
25
+ process.exit(0);
26
+ }
27
+
28
+ const rootDir = path.resolve(__dirname, "..");
29
+ const bundledEntry = path.join(rootDir, "msh.js");
30
+ const devEntry = path.join(rootDir, "pro.js");
31
+
32
+ const entryFile = fs.existsSync(bundledEntry) ? bundledEntry : devEntry;
33
+
34
+ const child = spawn(process.execPath, [entryFile, ...args], {
35
+ cwd: rootDir,
36
+ env: process.env,
37
+ stdio: "inherit",
38
+ windowsHide: true,
39
+ });
40
+
41
+ child.on("exit", (code, signal) => {
42
+ if (signal) process.exit(1);
43
+ process.exit(typeof code === "number" ? code : 0);
44
+ });
45
+
46
+ child.on("error", (err) => {
47
+ try {
48
+ process.stderr.write(`Failed to start msh: ${err?.message || String(err)}\n`);
49
+ } catch {
50
+ // ignore
51
+ }
52
+ process.exit(1);
53
+ });
package/bin/msh.js ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const fs = require("node:fs");
6
+ const path = require("node:path");
7
+ const { spawn } = require("node:child_process");
8
+
9
+ const args = process.argv.slice(2);
10
+
11
+ if (args.includes("--help") || args.includes("-h")) {
12
+ process.stdout.write(
13
+ [
14
+ "msh - start Magala server",
15
+ "",
16
+ "Usage:",
17
+ " msh [--help]",
18
+ "",
19
+ "Notes:",
20
+ " - Runs bundled msh.js if present, otherwise runs pro.js",
21
+ " - Pass PORTS env var to control ports (e.g., PORTS=80,800,737)",
22
+ "",
23
+ ].join("\n"),
24
+ );
25
+ process.exit(0);
26
+ }
27
+
28
+ const rootDir = path.resolve(__dirname, "..");
29
+ const bundledEntry = path.join(rootDir, "msh.js");
30
+ const devEntry = path.join(rootDir, "pro.js");
31
+
32
+ const entryFile = fs.existsSync(bundledEntry) ? bundledEntry : devEntry;
33
+
34
+ const child = spawn(process.execPath, [entryFile, ...args], {
35
+ cwd: rootDir,
36
+ env: process.env,
37
+ stdio: "inherit",
38
+ windowsHide: true,
39
+ });
40
+
41
+ child.on("exit", (code, signal) => {
42
+ if (signal) process.exit(1);
43
+ process.exit(typeof code === "number" ? code : 0);
44
+ });
45
+
46
+ child.on("error", (err) => {
47
+ try {
48
+ process.stderr.write(`Failed to start msh: ${err?.message || String(err)}\n`);
49
+ } catch {
50
+ // ignore
51
+ }
52
+ process.exit(1);
53
+ });