@mahameru/cli 0.0.19 → 0.0.21
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/README.md +254 -0
- package/cli.js +25 -23
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# MahameruJS CLI Utility
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/mahameru)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
`@mahameru/cli` is the command-line interface for building, running, and managing Mahameru-based applications.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
Install the CLI globally so the `mahameru` command is available from your terminal:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install -g @mahameru/cli
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
If you do not have a MahameruJS project yet, create one with:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm create mahameru
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
or:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx create-mahameru
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Project Requirements
|
|
29
|
+
|
|
30
|
+
This CLI expects a `mahameru.config.ts` file in the project root for development mode.
|
|
31
|
+
|
|
32
|
+
Some commands also rely on these project dependencies:
|
|
33
|
+
|
|
34
|
+
- `tsx` to load the TypeScript config file for `mahameru dev`
|
|
35
|
+
- `typescript` for the compile step in `mahameru build`
|
|
36
|
+
- `tsc-alias` to rewrite path aliases after compilation
|
|
37
|
+
|
|
38
|
+
For application source aliases, prefer `tsconfig.json` paths such as `@/*`. Do not rely on `package.json#imports` for `src/**` files that must run from `dist/` in production.
|
|
39
|
+
|
|
40
|
+
## Command Reference
|
|
41
|
+
|
|
42
|
+
### `mahameru dev`
|
|
43
|
+
|
|
44
|
+
Start the MahameruJS development server with hot reload.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
mahameru dev
|
|
48
|
+
mahameru dev --port 3000
|
|
49
|
+
mahameru dev --host localhost
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Options:
|
|
53
|
+
|
|
54
|
+
- `-p, --port <number>` Port to run the server on
|
|
55
|
+
- `-H, --host <string>` Host to run the server on
|
|
56
|
+
|
|
57
|
+
Behavior:
|
|
58
|
+
|
|
59
|
+
- loads `mahameru.config.ts`
|
|
60
|
+
- runs TypeScript typechecking before each start or restart
|
|
61
|
+
- applies default config values when they are not provided
|
|
62
|
+
- runs the Mahameru application from the current project
|
|
63
|
+
- watches `src/**` and `mahameru.config.ts`, then restarts automatically when files change
|
|
64
|
+
|
|
65
|
+
If typechecking fails, the error is shown in the console and the dev server waits for the next valid save before starting again.
|
|
66
|
+
|
|
67
|
+
### `mahameru build`
|
|
68
|
+
|
|
69
|
+
Build the production output for the current project.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
mahameru build
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Behavior:
|
|
76
|
+
|
|
77
|
+
- runs `tsc --project tsconfig.json`
|
|
78
|
+
- runs `tsc-alias -p tsconfig.json`
|
|
79
|
+
- fails if compiled `dist/**/*.js` files still contain unresolved `@/` or `#/` specifiers
|
|
80
|
+
|
|
81
|
+
### `mahameru start`
|
|
82
|
+
|
|
83
|
+
Request the Mahameru Process Manager daemon to start the current project in production mode.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
mahameru start
|
|
87
|
+
mahameru start --port 8000
|
|
88
|
+
mahameru start --host 127.0.0.1
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Options:
|
|
92
|
+
|
|
93
|
+
- `-p, --port <number>` Port to run the app on. Default: `8000`
|
|
94
|
+
- `-H, --host <string>` Host to run the app on. Default: `127.0.0.1`
|
|
95
|
+
|
|
96
|
+
Important:
|
|
97
|
+
|
|
98
|
+
- this command does not directly boot `dist/` by itself
|
|
99
|
+
- it connects to the Mahameru PM daemon over IPC and asks the daemon to fork the current project
|
|
100
|
+
- the daemon must already be running, either through `mahameru pm start` or `mahameru pm service install`
|
|
101
|
+
- on Windows, Mahameru may request elevation automatically when the daemon is running with Administrator privileges
|
|
102
|
+
|
|
103
|
+
### `mahameru stop`
|
|
104
|
+
|
|
105
|
+
Request the Mahameru Process Manager daemon to stop the current managed project.
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
mahameru stop
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Important:
|
|
112
|
+
|
|
113
|
+
- this command depends on the Mahameru PM daemon being available
|
|
114
|
+
- it stops the managed project registered under the current package name
|
|
115
|
+
|
|
116
|
+
### `mahameru status`
|
|
117
|
+
|
|
118
|
+
Show the status of the current managed project.
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
mahameru status
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Important:
|
|
125
|
+
|
|
126
|
+
- this command depends on the Mahameru PM daemon being available
|
|
127
|
+
- it shows the managed project status, PID, host, port, and root path
|
|
128
|
+
- on Windows, Mahameru may request elevation automatically when connecting to an elevated daemon
|
|
129
|
+
|
|
130
|
+
## Process Manager
|
|
131
|
+
|
|
132
|
+
The Process Manager is responsible for hosting managed production apps and exposing a small management server.
|
|
133
|
+
|
|
134
|
+
### `mahameru pm start`
|
|
135
|
+
|
|
136
|
+
Start the Mahameru Process Manager manually.
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
mahameru pm start
|
|
140
|
+
mahameru pm start --port 8000 --host 127.0.0.1
|
|
141
|
+
mahameru pm start --cert ./cert.pem --key ./key.pem
|
|
142
|
+
mahameru pm start --daemon
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Options:
|
|
146
|
+
|
|
147
|
+
- `-p, --port <number>` Port to run the server on. Default: `8000`
|
|
148
|
+
- `-H, --host <string>` Host to run the server on. Default: `127.0.0.1`
|
|
149
|
+
- `--cert <string>` Path to the SSL certificate file
|
|
150
|
+
- `--key <string>` Path to the SSL key file
|
|
151
|
+
- `-d, --daemon` Run as a daemon
|
|
152
|
+
|
|
153
|
+
Notes:
|
|
154
|
+
|
|
155
|
+
- HTTPS is enabled only when both `--cert` and `--key` are provided
|
|
156
|
+
- the Process Manager serves the management UI and API
|
|
157
|
+
- the Process Manager also restores previously running managed projects on startup when available
|
|
158
|
+
|
|
159
|
+
### `mahameru pm status`
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
mahameru pm status
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
This command exists in the CLI, but it is not implemented yet.
|
|
166
|
+
|
|
167
|
+
### `mahameru pm service install`
|
|
168
|
+
|
|
169
|
+
Install the Mahameru Process Manager as a system service.
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
mahameru pm service install
|
|
173
|
+
mahameru pm service install --port 8080 --host 127.0.0.1
|
|
174
|
+
mahameru pm service install --cert ./cert.pem --key ./key.pem
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Options:
|
|
178
|
+
|
|
179
|
+
- `-p, --port <number>` Port to run the server on. Default: `8080`
|
|
180
|
+
- `-H, --host <string>` Host to run the server on. Default: `127.0.0.1`
|
|
181
|
+
- `--cert <string>` Path to the SSL certificate file
|
|
182
|
+
- `--key <string>` Path to the SSL key file
|
|
183
|
+
|
|
184
|
+
Notes:
|
|
185
|
+
|
|
186
|
+
- this registers the Process Manager to start with the operating system
|
|
187
|
+
- Administrator or root privileges may be required, depending on the platform
|
|
188
|
+
|
|
189
|
+
### `mahameru pm service uninstall`
|
|
190
|
+
|
|
191
|
+
Uninstall the Mahameru Process Manager service.
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
mahameru pm service uninstall
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Administrator or root privileges may be required.
|
|
198
|
+
|
|
199
|
+
### `mahameru pm service start`
|
|
200
|
+
|
|
201
|
+
Start the installed Mahameru Process Manager service.
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
mahameru pm service start
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Administrator or root privileges may be required.
|
|
208
|
+
|
|
209
|
+
### `mahameru pm service stop`
|
|
210
|
+
|
|
211
|
+
Stop the installed Mahameru Process Manager service.
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
mahameru pm service stop
|
|
215
|
+
mahameru pm service stop --graceful
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Options:
|
|
219
|
+
|
|
220
|
+
- `-g, --graceful` Gracefully stop the service
|
|
221
|
+
|
|
222
|
+
Administrator or root privileges may be required.
|
|
223
|
+
|
|
224
|
+
### `mahameru pm service status`
|
|
225
|
+
|
|
226
|
+
Show the installed service status.
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
mahameru pm service status
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
This command reports the Process Manager service status for the current platform.
|
|
233
|
+
|
|
234
|
+
## Recommended Workflow
|
|
235
|
+
|
|
236
|
+
For local development:
|
|
237
|
+
|
|
238
|
+
1. Run `mahameru dev`.
|
|
239
|
+
2. Make changes inside `src/**` and let the dev server restart automatically.
|
|
240
|
+
|
|
241
|
+
For production-style managed runs:
|
|
242
|
+
|
|
243
|
+
1. Run `mahameru build`.
|
|
244
|
+
2. Start the Process Manager with `mahameru pm start`, or install it with `mahameru pm service install`.
|
|
245
|
+
3. Run `mahameru start` from your project directory to register and start the app through the daemon.
|
|
246
|
+
4. Use `mahameru status` to inspect the managed project.
|
|
247
|
+
5. Use `mahameru stop` to stop it.
|
|
248
|
+
|
|
249
|
+
## Notes
|
|
250
|
+
|
|
251
|
+
- If `mahameru.config.ts` is missing, development commands will fail.
|
|
252
|
+
- If `tsx`, `typescript`, or `tsc-alias` are not installed in the project, the related command will fail.
|
|
253
|
+
- `mahameru dev` ignores changes inside `dist/` and `node_modules/`.
|
|
254
|
+
- `mahameru start`, `mahameru stop`, and `mahameru status` are PM-daemon-backed commands, not standalone local process commands.
|
package/cli.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* ┌────────────────────────────────────────────┐
|
|
4
4
|
* │ │
|
|
5
5
|
* │ ▲ MahameruJS - CLI │
|
|
6
|
-
* │ Version: 0.0.
|
|
6
|
+
* │ Version: 0.0.21 │
|
|
7
7
|
* │ Built: 2026 │
|
|
8
8
|
* │ │
|
|
9
9
|
* │ Copyright (c) Bintan <hello@bintvn.co> │
|
|
@@ -29,9 +29,9 @@ console.error(n.default.yellow("Please use tsconfig path aliases such as @/* and
|
|
|
29
29
|
r.succeed(n.default.green(" Build success."))}catch(e){r.fail(n.default.red(" Internal error.")),console.error(e),
|
|
30
30
|
process.exit(1)}}}
|
|
31
31
|
;const s=o(8330),n=r(o(5205)),i=r(o(8720)),a=o(1455),c=o(6760),l=o(242),d=o(5775),u=o(5412),p=o(5242),f=o(5183),m=o(760)
|
|
32
|
-
},7022(e,t,o){t.dev=function({version:e}){return async({host:t,port:o})=>{
|
|
33
|
-
|
|
34
|
-
port:o})}};const r=o(
|
|
32
|
+
},7022(e,t,o){t.dev=function({version:e}){return async({host:t,port:o})=>{const a=(0,s.ensureDevEnvironment)();(0,
|
|
33
|
+
n.printCliBanner)(e),o=await(0,r.freePortFinder)(o),await(0,i.startWatchedDevServer)({version:e,environment:a,host:t,
|
|
34
|
+
port:o})}};const r=o(7209),s=o(242),n=o(1785),i=o(8320)},3674(e,t,o){var r=this&&this.__importDefault||function(e){
|
|
35
35
|
return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.install=void 0
|
|
36
36
|
;const s=o(1421),n=o(3024),i=r(o(5205)),a=o(6760),c=o(6921),l=o(6718),d=o(6471),u=r(o(8720))
|
|
37
37
|
;t.install=e=>({host:t,port:o,cert:r,key:p})=>{const f="linux"===process.platform,m="win32"===process.platform;let h=""
|
|
@@ -170,9 +170,9 @@ return e.includes("Starting compilation in watch mode...")||e.includes("File cha
|
|
|
170
170
|
function(e){
|
|
171
171
|
return["Starting compilation in watch mode...","File change detected. Starting incremental compilation...","Found 0 errors. Watching for file changes.","Watching for file changes."].some(t=>e.includes(t))
|
|
172
172
|
}(t)||console.log(`${c.default.yellow("[Mahameru TSC]")} ${t}`)}),N=$((0,i.resolve)((0,i.join)(h,"types"))),I=e=>{
|
|
173
|
-
const t=$((0,i.resolve)(e));return t===N||t.startsWith(`${N}/`)},
|
|
174
|
-
;
|
|
175
|
-
;
|
|
173
|
+
const t=$((0,i.resolve)(e));return t===N||t.startsWith(`${N}/`)},F=C.watchFile?.bind(C)
|
|
174
|
+
;F&&(C.watchFile=(e,t,o,r)=>I(e)?{close(){}}:F(e,t,o,r));const H=C.watchDirectory?.bind(C)
|
|
175
|
+
;H&&(C.watchDirectory=(e,t,o,r)=>I(e)?{close(){}}:H(e,t,o,r));const W=C,J=W.writeFile?.bind(W)??S.writeFile.bind(S)
|
|
176
176
|
;W.writeFile=(e,t,o,r,s,n)=>{J?.(e,t,o,r,s,n),q(e,s)};const U=C.afterProgramCreate;C.afterProgramCreate=e=>{U?.(e)
|
|
177
177
|
;const t=0===T?1:T;T=t,R=R.then(()=>B(e,t)).catch(e=>{
|
|
178
178
|
console.error(c.default.red("[Mahameru Dev] Build lifecycle failed.")),console.error(e)})};const L=u(C)
|
|
@@ -200,11 +200,11 @@ i.resolve)(e.fileName)).filter(e=>{const o=$(e);return o.startsWith(t)&&o.endsWi
|
|
|
200
200
|
}(t))s.changedRuntimeSourceFiles.add(e)}}try{return await k,L}catch(e){throw L.close(),e}}({environment:e,spinner:k,
|
|
201
201
|
onBuildStart:()=>{T=!0},
|
|
202
202
|
onBuildSuccess:({durationMs:e,emittedRuntimeFiles:t,changedRuntimeSourceFiles:o,initialBuild:r})=>{if(b=e,T=!1,!r){
|
|
203
|
-
for(const e of t)D.add(e);for(const e of o)O.add(e)}T||!u?.initialized||E||(x||A||0!==D.size)&&
|
|
203
|
+
for(const e of t)D.add(e);for(const e of o)O.add(e)}T||!u?.initialized||E||(x||A||0!==D.size)&&H()},onBuildFailure:()=>{
|
|
204
204
|
T=!1,b=0,A=!1,D.clear(),O.clear(),j&&(clearTimeout(j),j=null)}
|
|
205
205
|
}),k.succeed(`${c.default.green("[Mahameru]")} Initial build completed.\n`),await u.start()
|
|
206
|
-
;const N=new l.Watchman([h,P]),I=new l.Watchman(y);let
|
|
207
|
-
j=setTimeout(()=>{
|
|
206
|
+
;const N=new l.Watchman([h,P]),I=new l.Watchman(y);let F=Promise.resolve();const H=()=>{j&&clearTimeout(j),
|
|
207
|
+
j=setTimeout(()=>{F=F.then(async()=>{if(E||!u)return;if(T)return void H();const e=[...D],t=[...O],o=A,r=x;if(x=!1,A=!1,
|
|
208
208
|
D.clear(),
|
|
209
209
|
O.clear(),j=null,r)return console.log(c.default.yellow("\n [Mahameru] Config file changed. Reloading server...\n")),
|
|
210
210
|
await u.stop(),u=new d.App(C),console.clear(),void await u.start();if(0===e.length&&!o)return
|
|
@@ -216,7 +216,7 @@ console.error(c.default.red("[Mahameru Dev] Hot reload failed.")),console.error(
|
|
|
216
216
|
i.resolve)(g)),n=$((0,i.resolve)(P));if(!o.startsWith(`${r}/`)&&o!==n)return null
|
|
217
217
|
;if(o.endsWith(".d.ts")||o.endsWith(".map")||o.endsWith(".tsbuildinfo"))return null;if(o===n)return"config"
|
|
218
218
|
;if(!o.endsWith(".js"))return null;if(o.startsWith(`${s}/`))return"runtime";return null}(t)
|
|
219
|
-
;o&&("runtime"===o&&"delete"!==e&&"rename"!==e||((e,t)=>{"config"===e?x=!0:(D.add(t),O.add(S(t))),T||
|
|
219
|
+
;o&&("runtime"===o&&"delete"!==e&&"rename"!==e||((e,t)=>{"config"===e?x=!0:(D.add(t),O.add(S(t))),T||H()})(o,t))}),
|
|
220
220
|
I.on("all",async({event:e,filePath:t,oldFilePath:o})=>{if("delete"!==e&&"rename"!==e)return;const r="rename"===e&&o?o:t
|
|
221
221
|
;(function(e){const t=`${$((0,i.resolve)(y))}/`;return $((0,i.resolve)(e)).startsWith(t)})(r)&&(await async function(e){
|
|
222
222
|
const t=(0,i.resolve)(e),o=(0,i.relative)(y,t);if(o.startsWith(".."))return;if(/\.[^\\/]+$/.test(o)){
|
|
@@ -224,7 +224,7 @@ const e=function(e){const t=(0,i.relative)(y,e);return(0,i.resolve)(g,t.replace(
|
|
|
224
224
|
;return void await Promise.all([(0,n.rm)(e,{force:!0}).catch(()=>{}),(0,n.rm)(`${e}.map`,{force:!0}).catch(()=>{}),(0,
|
|
225
225
|
n.rm)(e.replace(/\.js$/i,".d.ts"),{force:!0}).catch(()=>{}),(0,n.rm)(e.replace(/\.js$/i,".d.ts.map"),{force:!0
|
|
226
226
|
}).catch(()=>{})])}await(0,n.rm)((0,i.resolve)(g,o),{recursive:!0,force:!0}).catch(()=>{})}(r),A=!0,O.add((0,
|
|
227
|
-
i.resolve)(r)),T||
|
|
227
|
+
i.resolve)(r)),T||H())}),await N.start(),await I.start();const W=async(e=0)=>{E||(E=!0,j&&(clearTimeout(j),j=null),
|
|
228
228
|
N.stop(),I.stop(),await u.stop(),M?.close(),process.exit(e))};process.once("SIGINT",()=>{W(0)}),
|
|
229
229
|
process.once("SIGTERM",()=>{W(0)}),await new Promise(()=>{})}
|
|
230
230
|
;const s=o(3024),n=o(1455),i=o(6760),a=r(o(8720)),c=r(o(5205)),l=o(6469),d=o(1205),u=o(8995),p=o(5183),f=(0,
|
|
@@ -457,7 +457,7 @@ var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:
|
|
|
457
457
|
;const s=o(6858),n=r(o(5205)),i=o(8330),a=o(7022),c=o(545),l=o(5775),d=o(3674),u=o(6478),p=o(6571),f=o(1471),m=o(5019),h=o(7659),g=o(846),y=o(7695),v=o(2074),P=new s.Command
|
|
458
458
|
;(async()=>{try{const e=process.cwd(),t="mahameru-pm"
|
|
459
459
|
;P.name("mahameru").description(`${n.default.bold(n.default.cyan("▲ MahameruJS"))} ${n.default.dim(`CLI v${i.version}`)}`).version(i.version,"-v, --version","Display help for command"),
|
|
460
|
-
P.command("dev").description("Start MahameruJS development server.").option("-p, --port <number>","Port to run the server on",l.parsePort).option("-H, --host <string>","Host to run the server on").action((0,
|
|
460
|
+
P.command("dev").description("Start MahameruJS development server.").option("-p, --port <number>","Port to run the server on",l.parsePort,3e3).option("-H, --host <string>","Host to run the server on","127.0.0.1").action((0,
|
|
461
461
|
a.dev)({version:i.version})),P.command("build").description("Build MahameruJS production application.").action((0,
|
|
462
462
|
c.build)({rootPath:e
|
|
463
463
|
})),P.command("start").description("Start MahameruJS production server.").option("-p, --port <number>","Port to run the server on",l.parsePort,8e3).option("-H, --host <string>","Host to run the server on","127.0.0.1").action((0,
|
|
@@ -538,17 +538,17 @@ o.write(JSON.stringify({success:!0,message:`Project ${r} successfully started by
|
|
|
538
538
|
mpmUrl:`http://${e}:${t}`}));else if("PROCESS_USAGE"===n){const e=(0,h.getProject)(r);e&&G.emit("process-usage",{data:i,
|
|
539
539
|
project:(0,g.parseProject)(e)})}},D=e=>t=>{console.log(`[MPM] Project ${e} errored: ${t.message}`)},O=e=>({success:!0,
|
|
540
540
|
data:e}),R=e=>({success:!1,error:e}),k=e=>(0,g.parseProject)(e),C=()=>(0,h.getProjects)().map(g.parseProject),N=e=>{
|
|
541
|
-
console.log(`[MPM] ${e}`)},I=()=>{G.emit("projects",C())},
|
|
541
|
+
console.log(`[MPM] ${e}`)},I=()=>{G.emit("projects",C())},F=e=>{
|
|
542
542
|
const t=(0,d.join)(e.rootPath,"node_modules","mahameru","dist","server.js");if(!(0,
|
|
543
543
|
v.existsSync)(t))throw new Error(`Mahameru package is not installed in ${e.rootPath} project. Please install it by running: npm install mahameru`)
|
|
544
|
-
;return t},
|
|
544
|
+
;return t},H=e=>({MAHAMERU__SEND_PROCESS_USAGE_INTERVAL:"3000",MAHAMERU__ROOT_PATH:e.rootPath,
|
|
545
545
|
MAHAMERU__MODE:"production",...e.host?{MAHAMERU__HTTP_LISTEN_HOST:e.host.trim()}:{},...e.port?{
|
|
546
546
|
MAHAMERU__HTTP_LISTEN_PORT:e.port.toString().trim()}:{}}),W=(e,t,o=null)=>{t.stdout?.on("data",T(e.name)),
|
|
547
547
|
t.stderr?.on("data",A(e.name)),t.on("message",b(o,e.name,t)),t.on("error",D(e.name)),t.once("exit",o=>{e.child===t&&(0,
|
|
548
548
|
h.getProject)(e.name)&&(e.status=0===o||null===o?"stopped":"errored",e.pid=void 0,e.child=void 0,
|
|
549
549
|
G.emit("project-update",k(e)),I())})},J=(e,t)=>new Promise(o=>{const r=s=>{t.includes(s.type)&&(e.off("message",r),o(s))
|
|
550
|
-
};e.on("message",r)}),U=(e,t=null)=>new Promise((o,r)=>{let s=!1;const n=e=>{s||(s=!0,e())};try{const s=
|
|
551
|
-
l.fork)(s,[],{cwd:e.rootPath,env:{...process.env,...
|
|
550
|
+
};e.on("message",r)}),U=(e,t=null)=>new Promise((o,r)=>{let s=!1;const n=e=>{s||(s=!0,e())};try{const s=F(e),i=(0,
|
|
551
|
+
l.fork)(s,[],{cwd:e.rootPath,env:{...process.env,...H(e)},stdio:["inherit","pipe","pipe","ipc"]});e.status="stopped",
|
|
552
552
|
e.pid=i.pid,e.child=i,(0,h.setProject)(e),W(e,i,t),J(i,["READY","ERROR"]).then(({type:t,data:s})=>{"READY"===t?n(()=>{
|
|
553
553
|
e.status="running",e.pid=i.pid,e.child=i,(0,h.setProject)(e),o(e)}):"ERROR"===t&&n(()=>{e.status="errored",e.pid=void 0,
|
|
554
554
|
e.child=void 0,(0,h.setProject)(e),r(new Error("string"==typeof s?s:`Failed to start project ${e.name}`))})}),
|
|
@@ -612,11 +612,13 @@ t.getProjects)().map(e=>({...e,child:void 0,pid:void 0,isLastStatusIsRunning:"ru
|
|
|
612
612
|
throw new Error("Failed to save projects")}}},7209(e,t,o){var r=this&&this.__importDefault||function(e){
|
|
613
613
|
return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),
|
|
614
614
|
t.freePortFinder=async function(e=3e3){let t=e;const o=e+999;for(;t<o;)try{return await n(t)}catch(e){t++}
|
|
615
|
-
throw new Error(`Port ${e} - 999 is not available`)}
|
|
616
|
-
const r=s.default.createServer();r.once("error",e=>{e.code,o(
|
|
617
|
-
r.listen(e,"127.0.0.1")})}
|
|
618
|
-
|
|
619
|
-
|
|
615
|
+
throw new Error(`Port ${e} - 999 is not available`)},t.isPortAvailable=function(e){return new Promise((t,o)=>{
|
|
616
|
+
const r=s.default.createServer();r.once("error",e=>{e.code,o(!1)}),r.once("listening",()=>{r.close(()=>t(!0))}),
|
|
617
|
+
r.listen(e,"127.0.0.1")})};const s=r(o(7030));function n(e){return new Promise((t,o)=>{const r=s.default.createServer()
|
|
618
|
+
;r.once("error",e=>{e.code,o(e)}),r.once("listening",()=>{r.close(()=>t(e))}),r.listen(e,"127.0.0.1")})}},4830(e,t,o){
|
|
619
|
+
t.getProjectJson=async function(e){try{return JSON.parse(await(0,r.readFile)((0,s.join)(e,"package.json"),"utf-8"))
|
|
620
|
+
}catch(e){throw new Error("package.json not found")}};const r=o(1455),s=o(6760)},6718(e,t,o){
|
|
621
|
+
t.getNodeModulesPath=function(){try{return(0,r.execSync)("npm root -g",{stdio:["ignore","pipe","ignore"]
|
|
620
622
|
}).toString().trim()}catch(e){throw new Error("npm is not installed or not accessible on your system.")}}
|
|
621
623
|
;const r=o(1421)},4813(e,t,o){t.isMahameruProjectDir=function(e){const t=(0,s.join)(e,"package.json"),o=(0,
|
|
622
624
|
s.join)(e,"node_modules");if(!(0,r.existsSync)(t)&&(0,r.existsSync)(o))return!1;try{const e=(0,
|
|
@@ -643,6 +645,6 @@ e.exports=require("module")},9278(e){e.exports=require("net")},1421(e){e.exports
|
|
|
643
645
|
e.exports=require("node:cluster")},3024(e){e.exports=require("node:fs")},1455(e){e.exports=require("node:fs/promises")},
|
|
644
646
|
7067(e){e.exports=require("node:http")},4708(e){e.exports=require("node:https")},8995(e){
|
|
645
647
|
e.exports=require("node:module")},7030(e){e.exports=require("node:net")},8161(e){e.exports=require("node:os")},6760(e){
|
|
646
|
-
e.exports=require("node:path")},6928(e){e.exports=require("path")},8330(e){e.exports={version:"0.0.
|
|
648
|
+
e.exports=require("node:path")},6928(e){e.exports=require("path")},8330(e){e.exports={version:"0.0.21"}}};const t={}
|
|
647
649
|
;(function o(r){const s=t[r];if(void 0!==s)return s.exports;const n=t[r]={exports:{}}
|
|
648
650
|
;return e[r].call(n.exports,n,n.exports,o),n.exports})(8625)})();
|