@mahameru/cli 0.0.22 → 0.0.24
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.js +85 -78
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* ┌────────────────────────────────────────────┐
|
|
4
4
|
* │ │
|
|
5
5
|
* │ ▲ MahameruJS - CLI │
|
|
6
|
-
* │ Version: 0.0.
|
|
6
|
+
* │ Version: 0.0.24 │
|
|
7
7
|
* │ Built: 2026 │
|
|
8
8
|
* │ │
|
|
9
9
|
* │ Copyright (c) Bintan <hello@bintvn.co> │
|
|
@@ -20,10 +20,10 @@ f.generateRouteTypes)((0,c.join)(e,"src","routes"),(0,c.join)(o,"types","routes.
|
|
|
20
20
|
f.generateDataSourceTypes)((0,c.join)(e,"src","databases"),(0,c.join)(o,"types","dataSources.d.ts")),await(0,
|
|
21
21
|
f.generateTypesBarrel)((0,c.join)(o,"types","index.d.ts")),await(0,f.generateMahameruDts)((0,c.join)(e,"mahameru.d.ts"))
|
|
22
22
|
;const n="tsconfig.build.json",a=(0,c.join)(e,n),l=(0,c.join)(e,"tsconfig.json"),v=await(0,i.readFile)(l,"utf8")
|
|
23
|
-
;let
|
|
24
|
-
i.writeFile)(a,JSON.stringify(
|
|
25
|
-
const
|
|
26
|
-
d.deleteDirIfExists)(o),process.exit(
|
|
23
|
+
;let w=null;try{w=JSON.parse(v),w.compilerOptions.outDir=".mahameru",w.compilerOptions.rootDir="src",await(0,
|
|
24
|
+
i.writeFile)(a,JSON.stringify(w,null,2))}catch(e){console.error(`Error parsing ${l}: ${e}`),process.exit(1)}
|
|
25
|
+
const P=await(0,u.runNodeScript)(g,["--project",n],e);0!==P&&(r.fail(s.default.red(" Build failed!")),await(0,
|
|
26
|
+
d.deleteDirIfExists)(o),process.exit(P));const S=await(0,u.runNodeScript)(y,["--project",n],e)
|
|
27
27
|
;0!==S&&(r.fail(s.default.red(" tsc-alias failed.")),await(0,d.deleteDirIfExists)(o),process.exit(S));const $=(0,
|
|
28
28
|
p.findUnresolvedAliases)(o);if($.length>0){r.fail(s.default.red(" Build produced unresolved path aliases.")),
|
|
29
29
|
console.error(s.default.yellow("Please use tsconfig path aliases such as @/* and avoid package.json imports for app source files."))
|
|
@@ -38,10 +38,11 @@ h.createZip)((0,c.join)(process.cwd(),t),(0,c.join)(process.cwd(),`${t}.zip`),!1
|
|
|
38
38
|
r.succeed(s.default.green(" Build success."))}catch(e){r.fail(s.default.red(" Internal error.")),console.error(e),
|
|
39
39
|
process.exit(1)}}}
|
|
40
40
|
;const n=o(8330),s=r(o(5205)),a=r(o(8720)),i=o(1455),c=o(6760),l=o(242),d=o(5775),u=o(5412),p=o(5242),f=o(1855),m=o(3024),h=o(8419)
|
|
41
|
-
},7022(e,t,o){t.dev=function({version:e}){return async({host:t,port:o})=>{const i=(0,
|
|
42
|
-
s.printCliBanner)(e),o=await(0,r.freePortFinder)(o),await(0,a.startWatchedDevServer)({
|
|
43
|
-
port:o})}};const r=o(7209),n=o(242),s=o(1785),a=o(8320)},3674(e,t,o){
|
|
44
|
-
return e&&e.__esModule?e:{default:e}}
|
|
41
|
+
},7022(e,t,o){t.dev=function({version:e}){return async({host:t,port:o})=>{console.clear();const i=(0,
|
|
42
|
+
n.ensureDevEnvironment)();(0,s.printCliBanner)(e),o=await(0,r.freePortFinder)(o),await(0,a.startWatchedDevServer)({
|
|
43
|
+
version:e,environment:i,host:t,port:o})}};const r=o(7209),n=o(242),s=o(1785),a=o(8320)},3674(e,t,o){
|
|
44
|
+
var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}}
|
|
45
|
+
;Object.defineProperty(t,"__esModule",{value:!0}),t.install=void 0
|
|
45
46
|
;const n=o(1421),s=o(3024),a=r(o(5205)),i=o(6760),c=o(6921),l=o(6718),d=o(6471),u=r(o(8720)),p=o(1455)
|
|
46
47
|
;t.install=e=>({host:t,port:o,cert:r,key:f})=>{const m="linux"===process.platform,h="win32"===process.platform;let g=""
|
|
47
48
|
;try{g=(0,l.getNodeModulesPath)()}catch(e){return void console.error(a.default.red(`❌ ${e.message}`))}const y=(0,
|
|
@@ -146,8 +147,11 @@ t.generateTypesBarrel=async function(e){await(0,n.mkdir)((0,s.dirname)(e),{recur
|
|
|
146
147
|
n.writeFile)(e,"export * from './dataSources';\nexport * from './routes';\n","utf-8")},
|
|
147
148
|
t.generateMahameruDts=async function(e){
|
|
148
149
|
await(0,n.writeFile)(e,'/// <reference path="./.mahameru/types/index.d.ts" />\n\n// Do not edit this file, it is generated by MahameruJS\n',"utf-8")
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
;try{const e=(0,s.join)(process.cwd(),"tsconfig.json"),t=JSON.parse(await(0,n.readFile)(e,"utf-8"))
|
|
151
|
+
;void 0===t.include?t.include=["mahameru.d.ts"]:t.include.includes("mahameru.d.ts")||t.include.push("mahameru.d.ts"),
|
|
152
|
+
await(0,n.writeFile)(e,JSON.stringify(t,null,2),"utf-8")}catch(e){console.error(e)}};const r=o(3024),n=o(1455),s=o(6760)
|
|
153
|
+
},1785(e,t,o){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}}
|
|
154
|
+
;Object.defineProperty(t,"__esModule",{value:!0}),t.printCliBanner=function(e){
|
|
151
155
|
console.log(`${n.default.bold(n.default.cyan("▲ Mahameru"))} ${n.default.dim(`CLI v${e}`)}\n`)};const n=r(o(5205))},
|
|
152
156
|
8235(e,t){t.printServerReady=function({mode:e,dev:t,host:o,port:r}){console.log("[32m Mahameru Server Ready![0m"),
|
|
153
157
|
console.log(` [1mMode:[22m [36m${e}[0m`),console.log(` [1mLocal:[22m [36mhttp://${o}:${r}[0m`),
|
|
@@ -158,82 +162,85 @@ return new Promise((n,s)=>{const a=(0,r.spawn)(process.execPath,[e,...t],{stdio:
|
|
|
158
162
|
var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}}
|
|
159
163
|
;Object.defineProperty(t,"__esModule",{value:!0
|
|
160
164
|
}),t.startWatchedDevServer=async function({environment:e,host:t,port:o,version:r}){
|
|
161
|
-
let
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
let u,_=null,j=!1,x=null,E=!1,T=!0,A=!1,b=0;const D=new Set,O=new Set;await(0,p.generateRouteTypes)((0,
|
|
166
|
+
a.join)(m,"src","routes"),(0,a.join)(h,"types","routes.d.ts")),await(0,p.generateDataSourceTypes)((0,
|
|
167
|
+
a.join)(m,"src","databases"),(0,a.join)(h,"types","dataSources.d.ts")),await(0,p.generateTypesBarrel)((0,
|
|
168
|
+
a.join)(h,"types","index.d.ts")),await(0,p.generateMahameruDts)((0,a.join)(m,"mahameru.d.ts")),await(0,s.mkdir)(h,{
|
|
169
|
+
recursive:!0});const R=(0,i.default)({text:`${c.default.cyan("[Mahameru]")} Starting TypeScript watch...`,
|
|
170
|
+
spinner:"triangle"}).start(),k={dev:!0,host:t,port:o,rootPath:m};u=new d.App(k),
|
|
171
|
+
_=await async function({environment:e,spinner:t,onBuildStart:o,onBuildSuccess:r,onBuildFailure:i}){const l=(0,
|
|
172
|
+
a.resolve)((0,
|
|
173
|
+
a.join)(m,"node_modules","typescript")),{createWatchCompilerHost:d,createWatchProgram:u,formatDiagnosticsWithColorAndContext:p,formatDiagnostic:w,sys:S,createEmitAndSemanticDiagnosticsBuilderProgram:_}=f(l),j={
|
|
174
|
+
getCanonicalFileName:e=>e,getCurrentDirectory:()=>m,getNewLine:()=>S.newLine};let x=!1,E=!1,T=0
|
|
175
|
+
;const A=new Map,b=new Map;let D,O,R=Promise.resolve();const k=new Promise((e,t)=>{D=e,O=t}),C=d(v,{rootDir:y,outDir:h
|
|
176
|
+
},S,_,e=>{E=!0;const t=e.file?p([e],j):w(e,j);process.stderr.write(t.endsWith("\n")?t:`${t}\n`)},e=>{
|
|
170
177
|
const t=e.messageText.toString().trim();(function(e){
|
|
171
178
|
return e.includes("Starting compilation in watch mode...")||e.includes("File change detected. Starting incremental compilation...")
|
|
172
179
|
})(t)&&(T+=1,A.set(T,Date.now()),b.set(T,{emittedRuntimeFiles:new Set,changedRuntimeSourceFiles:new Set}),E=!1,o()),
|
|
173
180
|
function(e){
|
|
174
181
|
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))
|
|
175
|
-
}(t)||console.log(`${c.default.yellow("[Mahameru TSC]")} ${t}`)}),N
|
|
176
|
-
const t
|
|
182
|
+
}(t)||console.log(`${c.default.yellow("[Mahameru TSC]")} ${t}`)}),N=$((0,a.resolve)((0,a.join)(h,"types"))),F=e=>{
|
|
183
|
+
const t=$((0,a.resolve)(e));return t===N||t.startsWith(`${N}/`)},I=C.watchFile?.bind(C)
|
|
177
184
|
;I&&(C.watchFile=(e,t,o,r)=>F(e)?{close(){}}:I(e,t,o,r));const H=C.watchDirectory?.bind(C)
|
|
178
|
-
;H&&(C.watchDirectory=(e,t,o,r)=>F(e)?{close(){}}:H(e,t,o,r));const W=C,J=W.writeFile?.bind(W)??
|
|
185
|
+
;H&&(C.watchDirectory=(e,t,o,r)=>F(e)?{close(){}}:H(e,t,o,r));const W=C,J=W.writeFile?.bind(W)??S.writeFile.bind(S)
|
|
179
186
|
;W.writeFile=(e,t,o,r,n,s)=>{J?.(e,t,o,r,n,s),q(e,n)};const U=C.afterProgramCreate;C.afterProgramCreate=e=>{U?.(e)
|
|
180
187
|
;const t=0===T?1:T;T=t,R=R.then(()=>B(e,t)).catch(e=>{
|
|
181
|
-
console.error(c.default.red("[Mahameru Dev] Build lifecycle failed.")),console.error(e)})};const L=
|
|
188
|
+
console.error(c.default.red("[Mahameru Dev] Build lifecycle failed.")),console.error(e)})};const L=u(C)
|
|
182
189
|
;async function B(e,o){const l=A.get(o)??Date.now(),d=b.get(o)??{emittedRuntimeFiles:new Set,
|
|
183
190
|
changedRuntimeSourceFiles:new Set}
|
|
184
191
|
;if(E)return x||(x=!0,t.fail(`${c.default.red("[Mahameru]")} Initial TypeScript build failed.`),
|
|
185
192
|
O(new Error("Initial TypeScript build failed."))),b.delete(o),A.delete(o),void i();try{if(x)await async function(e){
|
|
186
|
-
if(0===e.length)return;const t=await async function(){if(!
|
|
187
|
-
a.join)(__dirname,"node_modules","tsc-alias")),{prepareSingleFileReplaceTscAliasPaths:t}=
|
|
188
|
-
})}return
|
|
193
|
+
if(0===e.length)return;const t=await async function(){if(!P){const e=(0,a.resolve)((0,
|
|
194
|
+
a.join)(__dirname,"node_modules","tsc-alias")),{prepareSingleFileReplaceTscAliasPaths:t}=f(e);P=t({configFile:v,outDir:h
|
|
195
|
+
})}return P}();for(const o of e){if(!(0,n.existsSync)(o))continue;const e=await(0,s.readFile)(o,"utf8"),r=t({
|
|
189
196
|
fileContents:e,filePath:o});r!==e&&await(0,s.writeFile)(o,r)}}([...d.emittedRuntimeFiles]);else{
|
|
190
|
-
await async function(e=3e4){const t=Date.now();for(;Date.now()-t<e;){if((0,n.existsSync)(
|
|
191
|
-
;await
|
|
192
|
-
a.join)(__dirname,"node_modules","tsc-alias")),{replaceTscAliasPaths:t}=
|
|
197
|
+
await async function(e=3e4){const t=Date.now();for(;Date.now()-t<e;){if((0,n.existsSync)(g))return void await M(200)
|
|
198
|
+
;await M(100)}throw new Error("Timed out waiting for emitted dev runtime artifacts.")}();const e=(0,a.resolve)((0,
|
|
199
|
+
a.join)(__dirname,"node_modules","tsc-alias")),{replaceTscAliasPaths:t}=f(e);await t({configFile:v,outDir:h})}}catch(e){
|
|
193
200
|
return console.error(c.default.red("[Mahameru Alias] Alias rewrite failed.")),console.error(e),x||(x=!0,
|
|
194
201
|
t.fail(`${c.default.red("[Mahameru]")} Initial alias rewrite failed.`),O(e instanceof Error?e:new Error(String(e)))),
|
|
195
|
-
b.delete(o),A.delete(o),void i()}const
|
|
202
|
+
b.delete(o),A.delete(o),void i()}const u=Date.now()-l;try{await r({durationMs:u,
|
|
196
203
|
emittedRuntimeFiles:[...d.emittedRuntimeFiles],changedRuntimeSourceFiles:[...d.changedRuntimeSourceFiles],
|
|
197
204
|
initialBuild:!x})}catch(e){return console.error(c.default.red("[Mahameru Alias] Alias rewrite failed.")),
|
|
198
205
|
console.error(e),void i()}finally{b.delete(o),A.delete(o)}x||(x=!0,D())}function q(e,t){const o=(0,
|
|
199
|
-
a.resolve)(e),r
|
|
206
|
+
a.resolve)(e),r=$(o),n=b.get(T);if(n&&function(e){const t=`${$((0,a.resolve)(g))}/`
|
|
200
207
|
;return e.startsWith(t)&&e.endsWith(".js")&&!e.endsWith(".d.ts")&&!e.endsWith(".map")}(r)){n.emittedRuntimeFiles.add(o)
|
|
201
|
-
;for(const e of function(e){if(!e)return[];const t=`${
|
|
202
|
-
a.resolve)(e.fileName)).filter(e=>{const o
|
|
203
|
-
}(t))n.changedRuntimeSourceFiles.add(e)}}try{return await k,L}catch(e){throw L.close(),e}}({environment:e,spinner:
|
|
204
|
-
onBuildStart:()=>{
|
|
205
|
-
onBuildSuccess:({durationMs:e,emittedRuntimeFiles:t,changedRuntimeSourceFiles:o,initialBuild:r})=>{if(
|
|
206
|
-
for(const e of t)
|
|
207
|
-
|
|
208
|
-
}),
|
|
209
|
-
;const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
await
|
|
214
|
-
;const n=e[e.length-1],s=t[t.length-1]??(n?
|
|
215
|
-
;const l=Date.now()-i,
|
|
216
|
-
a.relative)(
|
|
208
|
+
;for(const e of function(e){if(!e)return[];const t=`${$((0,a.resolve)(y))}/`;return e.map(e=>(0,
|
|
209
|
+
a.resolve)(e.fileName)).filter(e=>{const o=$(e);return o.startsWith(t)&&o.endsWith(".ts")&&!o.endsWith(".d.ts")})
|
|
210
|
+
}(t))n.changedRuntimeSourceFiles.add(e)}}try{return await k,L}catch(e){throw L.close(),e}}({environment:e,spinner:R,
|
|
211
|
+
onBuildStart:()=>{T=!0},
|
|
212
|
+
onBuildSuccess:({durationMs:e,emittedRuntimeFiles:t,changedRuntimeSourceFiles:o,initialBuild:r})=>{if(b=e,T=!1,!r){
|
|
213
|
+
for(const e of t)D.add(e);for(const e of o)O.add(e)}T||!u?.initialized||j||(E||A||0!==D.size)&&I()},onBuildFailure:()=>{
|
|
214
|
+
T=!1,b=0,A=!1,D.clear(),O.clear(),x&&(clearTimeout(x),x=null)}
|
|
215
|
+
}),R.succeed(`${c.default.green("[Mahameru]")} Initial build completed.\n`),await u.start()
|
|
216
|
+
;const C=new l.Watchman([h,w]),N=new l.Watchman(y);let F=Promise.resolve();const I=()=>{x&&clearTimeout(x),
|
|
217
|
+
x=setTimeout(()=>{F=F.then(async()=>{if(j||!u)return;if(T)return void I();const e=[...D],t=[...O],o=A,r=E;if(E=!1,A=!1,
|
|
218
|
+
D.clear(),
|
|
219
|
+
O.clear(),x=null,r)return console.log(c.default.yellow("\n [Mahameru] Config file changed. Reloading server...\n")),
|
|
220
|
+
await u.stop(),u=new d.App(k),console.clear(),void await u.start();if(0===e.length&&!o)return
|
|
221
|
+
;const n=e[e.length-1],s=t[t.length-1]??(n?S(n):(0,a.resolve)(y)),i=Date.now();o?await u.devHRM():await u.devHRM(n)
|
|
222
|
+
;const l=Date.now()-i,p=b+l;console.log(`${c.default.green("[Mahameru Dev]")} Rebuilt ${(0,
|
|
223
|
+
a.relative)(m,s).replace(/\\/g,"/")} build: ${b}ms runtime: ${l}ms total: ${p}ms`)}).catch(e=>{
|
|
217
224
|
console.error(c.default.red("[Mahameru Dev] Hot reload failed.")),console.error(e)})},250)}
|
|
218
|
-
;
|
|
219
|
-
a.resolve)(
|
|
225
|
+
;C.on("all",({event:e,filePath:t})=>{const o=function(e){const t=(0,a.resolve)(e),o=$(t),r=$((0,a.resolve)(h)),n=$((0,
|
|
226
|
+
a.resolve)(g)),s=$((0,a.resolve)(w));if(!o.startsWith(`${r}/`)&&o!==s)return null
|
|
220
227
|
;if(o.endsWith(".d.ts")||o.endsWith(".map")||o.endsWith(".tsbuildinfo"))return null;if(o===s)return"config"
|
|
221
228
|
;if(!o.endsWith(".js"))return null;if(o.startsWith(`${n}/`))return"runtime";return null}(t)
|
|
222
|
-
;o&&("runtime"===o&&"delete"!==e&&"rename"!==e||((e,t)=>{"config"===e?
|
|
223
|
-
|
|
224
|
-
;(function(e){const t=`${
|
|
225
|
-
const t=(0,a.resolve)(e),o=(0,a.relative)(
|
|
226
|
-
const e=function(e){const t=(0,a.relative)(
|
|
229
|
+
;o&&("runtime"===o&&"delete"!==e&&"rename"!==e||((e,t)=>{"config"===e?E=!0:(D.add(t),O.add(S(t))),T||I()})(o,t))}),
|
|
230
|
+
N.on("all",async({event:e,filePath:t,oldFilePath:o})=>{if("delete"!==e&&"rename"!==e)return;const r="rename"===e&&o?o:t
|
|
231
|
+
;(function(e){const t=`${$((0,a.resolve)(y))}/`;return $((0,a.resolve)(e)).startsWith(t)})(r)&&(await async function(e){
|
|
232
|
+
const t=(0,a.resolve)(e),o=(0,a.relative)(y,t);if(o.startsWith(".."))return;if(/\.[^\\/]+$/.test(o)){
|
|
233
|
+
const e=function(e){const t=(0,a.relative)(y,e);return(0,a.resolve)(g,t.replace(/\.ts$/i,".js"))}(t)
|
|
227
234
|
;return void await Promise.all([(0,s.rm)(e,{force:!0}).catch(()=>{}),(0,s.rm)(`${e}.map`,{force:!0}).catch(()=>{}),(0,
|
|
228
235
|
s.rm)(e.replace(/\.js$/i,".d.ts"),{force:!0}).catch(()=>{}),(0,s.rm)(e.replace(/\.js$/i,".d.ts.map"),{force:!0
|
|
229
|
-
}).catch(()=>{})])}await(0,s.rm)((0,a.resolve)(
|
|
230
|
-
a.resolve)(r)),
|
|
231
|
-
|
|
232
|
-
process.once("SIGTERM",()=>{
|
|
233
|
-
;const n=o(3024),s=o(1455),a=o(6760),i=r(o(8720)),c=r(o(5205)),l=o(6469),d=o(1205),u=(0,
|
|
234
|
-
|
|
235
|
-
a.join)(
|
|
236
|
-
;return(0,a.resolve)(
|
|
236
|
+
}).catch(()=>{})])}await(0,s.rm)((0,a.resolve)(g,o),{recursive:!0,force:!0}).catch(()=>{})}(r),A=!0,O.add((0,
|
|
237
|
+
a.resolve)(r)),T||I())}),await C.start(),await N.start();const H=async(e=0)=>{j||(j=!0,x&&(clearTimeout(x),x=null),
|
|
238
|
+
C.stop(),N.stop(),await u.stop(),_?.close(),process.exit(e))};process.once("SIGINT",()=>{H(0)}),
|
|
239
|
+
process.once("SIGTERM",()=>{H(0)}),await new Promise(()=>{})}
|
|
240
|
+
;const n=o(3024),s=o(1455),a=o(6760),i=r(o(8720)),c=r(o(5205)),l=o(6469),d=o(1205),u=o(8995),p=o(1855),f=(0,
|
|
241
|
+
u.createRequire)(__filename),m=process.cwd(),h=(0,a.join)(m,".mahameru"),g=h,y=(0,a.join)(m,"src"),v=(0,
|
|
242
|
+
a.join)(m,"tsconfig.json"),w=(0,a.join)(m,"mahameru.config.ts");let P=null;function S(e){const t=(0,a.relative)(g,e)
|
|
243
|
+
;return(0,a.resolve)(y,t.replace(/\.js$/i,".ts"))}function $(e){return e.replace(/\\/g,"/")}function M(e){
|
|
237
244
|
return new Promise(t=>{setTimeout(t,e)})}},5775(e,t,o){t.deleteDirIfExists=async function(e){return await(0,r.rm)(e,{
|
|
238
245
|
recursive:!0,force:!0})},t.parsePort=function(e){const t=parseInt(e,10);return isNaN(t)?void 0:t}
|
|
239
246
|
;const r=o(1455),n=o(8161)},6469(e,t,o){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{
|
|
@@ -458,17 +465,17 @@ s.execSync)(`sc stop "${e}"`)}catch(e){}
|
|
|
458
465
|
console.error(c.default.red("❌ Uninstallation failed:"),e.message)}}},8625(e,t,o){
|
|
459
466
|
var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}}
|
|
460
467
|
;Object.defineProperty(t,"__esModule",{value:!0})
|
|
461
|
-
;const n=o(6858),s=r(o(5205)),a=o(8330),i=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),
|
|
468
|
+
;const n=o(6858),s=r(o(5205)),a=o(8330),i=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),w=new n.Command
|
|
462
469
|
;(async()=>{try{const e=process.cwd(),t="mahameru-pm"
|
|
463
|
-
;
|
|
464
|
-
|
|
465
|
-
i.dev)({version:a.version})),
|
|
470
|
+
;w.name("mahameru").description(`${s.default.bold(s.default.cyan("▲ MahameruJS"))} ${s.default.dim(`CLI v${a.version}`)}`).version(a.version,"-v, --version","Display help for command"),
|
|
471
|
+
w.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,
|
|
472
|
+
i.dev)({version:a.version})),w.command("build").description("Build MahameruJS production application.").action((0,
|
|
466
473
|
c.build)({rootPath:e
|
|
467
|
-
})),
|
|
468
|
-
g.startFork)({rootPath:e})),
|
|
469
|
-
v.stopFork)(e,a.version)),
|
|
474
|
+
})),w.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,
|
|
475
|
+
g.startFork)({rootPath:e})),w.command("stop").description("Stop MahameruJS production server.").action((0,
|
|
476
|
+
v.stopFork)(e,a.version)),w.command("status").description("View MahameruJS production server status.").action((0,
|
|
470
477
|
y.projectStatus)(e,a.version))
|
|
471
|
-
;const o=
|
|
478
|
+
;const o=w.command("pm").description(`${s.default.bold(s.default.cyan("▲ MahameruJS"))} ${s.default.dim(`Process Manager v${a.version}`)}`)
|
|
472
479
|
;o.command("start").description("Start MahameruJS Process Manager.").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").option("--cert <string>","Path to the SSL certificate file").option("--key <string>","Path to the SSL key file").option("-d, --daemon","Run as a daemon",!1).action((0,
|
|
473
480
|
u.pm)(a.version)),
|
|
474
481
|
o.command("status").description("Start MahameruJS Process Manager.").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").option("-d, --daemon","Run as a daemon",!1).action(()=>{
|
|
@@ -484,7 +491,7 @@ p.uninstall)(t)),r.command("start").description("Start MahameruJS Process Manage
|
|
|
484
491
|
f.startService)(t)),
|
|
485
492
|
r.command("stop").description("Stop MahameruJS Process Manager service.").option("-g, --graceful","Gracefully stop the service.",!1).action((0,
|
|
486
493
|
m.stopService)(t)),r.command("status").description("Get MahameruJS Process Manager status.").action((0,
|
|
487
|
-
h.status)(t,a.version)),await
|
|
494
|
+
h.status)(t,a.version)),await w.parseAsync(process.argv)}catch(e){console.error(e),process.exit(1)}})()},6921(e,t,o){
|
|
488
495
|
t.IPC_SOCKET_PATH=t.MQ=t.PROJECTS_FILE_PATH=t.APPDATA_PATH=t.Ds=t.ig=t.vL=t.IS_WINDOWS=void 0;const r=o(6760)
|
|
489
496
|
;"darwin"===process.platform||"win32"===process.platform||process.platform,t.IS_WINDOWS="win32"===process.platform,
|
|
490
497
|
t.vL="darwin"===process.platform,t.ig="linux"===process.platform,t.Ds="mahameru",t.APPDATA_PATH=(()=>{
|
|
@@ -508,7 +515,7 @@ return r=Object.getOwnPropertyNames||function(e){var t=[]
|
|
|
508
515
|
if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o=r(e),a=0;a<o.length;a++)"default"!==o[a]&&n(t,e,o[a])
|
|
509
516
|
;return s(t,e),t}),i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}}
|
|
510
517
|
;Object.defineProperty(t,"__esModule",{value:!0}),t.processManager=void 0
|
|
511
|
-
;const c=i(o(5205)),l=o(1421),d=o(6760),u=i(o(7030)),p=o(7067),f=o(4708),m=o(6921),h=o(5043),g=o(6929),y=o(7209),v=a(o(3024)),
|
|
518
|
+
;const c=i(o(5205)),l=o(1421),d=o(6760),u=i(o(7030)),p=o(7067),f=o(4708),m=o(6921),h=o(5043),g=o(6929),y=o(7209),v=a(o(3024)),w=o(4437),P=(0,
|
|
512
519
|
d.join)(__dirname,"mpm"),S={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",
|
|
513
520
|
".png":"image/png",".jpg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon"}
|
|
514
521
|
;t.processManager=async({host:e,port:t,daemon:r,cert:n,key:s},a)=>{try{const i=await(0,y.freePortFinder)(t),$=(e,t)=>{
|
|
@@ -517,10 +524,10 @@ t.setHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS"),
|
|
|
517
524
|
t.setHeader("Access-Control-Allow-Headers","Content-Type, Authorization"),t.setHeader("X-Powered-By","MahameruJS"),
|
|
518
525
|
"OPTIONS"===e.method)return t.writeHead(204),t.end();if("/api/process"===e.url&&"GET"===e.method){t.writeHead(200,{
|
|
519
526
|
"Content-Type":"application/json"});const e=(0,h.getProjects)().map(g.parseProject);return t.end(JSON.stringify(e))}
|
|
520
|
-
if("GET"===e.method){const o="/"===e.url?"/index.html":e.url;let r=(0,d.join)(
|
|
521
|
-
;return r.startsWith(
|
|
527
|
+
if("GET"===e.method){const o="/"===e.url?"/index.html":e.url;let r=(0,d.join)(P,o)
|
|
528
|
+
;return r.startsWith(P)?void v.default.access(r,v.default.constants.F_OK,e=>{if(!e){const e=(0,
|
|
522
529
|
d.extname)(r).toLowerCase(),o=S[e]||"application/octet-stream";return t.writeHead(200,{"Content-Type":o}),
|
|
523
|
-
v.default.createReadStream(r).pipe(t)}{const e=(0,d.join)(
|
|
530
|
+
v.default.createReadStream(r).pipe(t)}{const e=(0,d.join)(P,"index.html")
|
|
524
531
|
;v.default.access(e,v.default.constants.F_OK,o=>o?(t.writeHead(404,{"Content-Type":"text/html"}),
|
|
525
532
|
t.end("<h1>404 - Frontend Build Not Found</h1>")):(t.writeHead(200,{"Content-Type":"text/html"}),
|
|
526
533
|
v.default.createReadStream(e).pipe(t)))}}):(t.writeHead(403,{"Content-Type":"text/plain"}),t.end("Forbidden"))}
|
|
@@ -588,7 +595,7 @@ h.getProject)(t.name);if(r){const{child:t,...o}=r;e.write(JSON.stringify({succes
|
|
|
588
595
|
error:t.message}))}})});q.on("close",()=>{console.log("[MPM IPC SERVER] IPC Server closed")}),q.on("error",e=>{
|
|
589
596
|
"EADDRINUSE"===e.code?console.error(`[MPM IPC SERVER] IPC Server already running on ${m.IPC_SOCKET_PATH}`):console.error("[MPM IPC SERVER]",e),
|
|
590
597
|
process.exit(1)}),q.listen(m.IPC_SOCKET_PATH,()=>{
|
|
591
|
-
console.log(`[MPM IPC SERVER] IPC Server listening on ${m.IPC_SOCKET_PATH}`)});const z=new
|
|
598
|
+
console.log(`[MPM IPC SERVER] IPC Server listening on ${m.IPC_SOCKET_PATH}`)});const z=new w.Server(E,{cors:{origin:"*"
|
|
592
599
|
},path:"/ws",serveClient:!1});z.on("connection",e=>{(0,h.setSocket)(e);const t=(0,h.getProjects)().map(g.parseProject)
|
|
593
600
|
;e.emit("projects",t),e.on("getProjects",e=>e({success:!0,data:(0,h.getProjects)().map(g.parseProject)})),
|
|
594
601
|
e.on("start",(e,t)=>{const o=(0,h.getProject)(e)
|
|
@@ -656,6 +663,6 @@ e.exports=require("ora")},5205(e){e.exports=require("picocolors")},6471(e){e.exp
|
|
|
656
663
|
e.exports=require("node:cluster")},3024(e){e.exports=require("node:fs")},1455(e){e.exports=require("node:fs/promises")},
|
|
657
664
|
7067(e){e.exports=require("node:http")},4708(e){e.exports=require("node:https")},8995(e){
|
|
658
665
|
e.exports=require("node:module")},7030(e){e.exports=require("node:net")},8161(e){e.exports=require("node:os")},6760(e){
|
|
659
|
-
e.exports=require("node:path")},6928(e){e.exports=require("path")},8330(e){e.exports={version:"0.0.
|
|
666
|
+
e.exports=require("node:path")},6928(e){e.exports=require("path")},8330(e){e.exports={version:"0.0.24"}}};const t={}
|
|
660
667
|
;(function o(r){const n=t[r];if(void 0!==n)return n.exports;const s=t[r]={exports:{}}
|
|
661
668
|
;return e[r].call(s.exports,s,s.exports,o),s.exports})(8625)})();
|