@mahameru/cli 0.0.27 → 0.0.28

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 (3) hide show
  1. package/README.md +9 -19
  2. package/cli.js +31 -29
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -16,27 +16,15 @@ npm install -g @mahameru/cli
16
16
  If you do not have a MahameruJS project yet, create one with:
17
17
 
18
18
  ```bash
19
- npm create mahameru
19
+ npm create mahameru@latest
20
20
  ```
21
21
 
22
22
  or:
23
23
 
24
24
  ```bash
25
- npx create-mahameru
25
+ npx create-mahameru@latest
26
26
  ```
27
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
28
  ## Command Reference
41
29
 
42
30
  ### `mahameru dev`
@@ -56,10 +44,12 @@ Options:
56
44
 
57
45
  Behavior:
58
46
 
59
- - loads `mahameru.config.ts`
47
+ - loads `mahameru.config.ts` (if present)
60
48
  - runs TypeScript typechecking before each start or restart
61
49
  - applies default config values when they are not provided
62
- - runs the Mahameru application from the current project
50
+ - runs the Mahameru application from the current project in development mode
51
+ - automatically generate routes types from `src/routes/**` (if present)
52
+ - automatically generate TypeORM data source types from `src/databases/**` (if present)
63
53
  - watches `src/**` and `mahameru.config.ts`, then restarts automatically when files change
64
54
 
65
55
  If typechecking fails, the error is shown in the console and the dev server waits for the next valid save before starting again.
@@ -76,7 +66,7 @@ Behavior:
76
66
 
77
67
  - runs `tsc --project tsconfig.json`
78
68
  - runs `tsc-alias -p tsconfig.json`
79
- - fails if compiled `dist/**/*.js` files still contain unresolved `@/` or `#/` specifiers
69
+ - outputs to `.mahameru`
80
70
 
81
71
  ### `mahameru start`
82
72
 
@@ -95,9 +85,9 @@ Options:
95
85
 
96
86
  Important:
97
87
 
98
- - this command does not directly boot `dist/` by itself
88
+ - this command does not directly boot `.mahameru/` by itself
99
89
  - 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`
90
+ - the MahameruJS Process Manager must already be running, either through `mahameru pm start` or `mahameru pm service install`
101
91
  - on Windows, Mahameru may request elevation automatically when the daemon is running with Administrator privileges
102
92
 
103
93
  ### `mahameru stop`
package/cli.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * ┌────────────────────────────────────────────┐
4
4
  * │ │
5
5
  * │ ▲ MahameruJS - CLI │
6
- * │ Version: 0.0.27
6
+ * │ Version: 0.0.28
7
7
  * │ Built: 2026 │
8
8
  * │ │
9
9
  * │ Copyright (c) Bintan <hello@bintvn.co> │
@@ -290,7 +290,7 @@ return 0===o.length?i.default.dirname(e):o.join("/")}normalizePath(e){return e.r
290
290
  a.isMahameruProjectDir)(o)||(console.error(s.default.red(`\n${o} is not a Mahameru project directory.`)),
291
291
  process.exit(1));const g=await(0,l.getProjectJson)(o);if(!(0,p.existsSync)((0,f.join)(o,"node_modules"))||!(0,
292
292
  p.existsSync)((0,f.join)(o,"package-lock.json"))){const e=(0,c.default)("Installing dependencies...").start();(0,
293
- m.execSync)("npm install",{stdio:"inherit",cwd:o}),e.succeed(s.default.green("\nDependencies installed."))}const y=(0,
293
+ m.execSync)("npm install",{stdio:"inherit",cwd:o}),e.succeed(s.default.green("Dependencies installed."))}const y=(0,
294
294
  c.default)("Checking available port...").start(),v=await(0,i.freePortFinder)(r)
295
295
  ;y.text="Connecting to MahameruJS PM Daemon...";const P=n.default.createConnection({path:u.IPC_SOCKET_PATH},()=>{
296
296
  P.write(JSON.stringify({command:"FORK_PROJECT",payload:{name:g.name,description:g.description,version:g.version,
@@ -304,7 +304,7 @@ console.log(`\n${s.default.dim("Use `mahameru status` to inspect this managed pr
304
304
  version:g.version,mode:"production",host:n.host,port:n.port,pid:n.pid,mpmUrl:a}),
305
305
  y.succeed(s.default.green(`\n${r}`))):(y.fail(s.default.red("Failed to start project!")),console.error(t)),P.end(),
306
306
  process.exit(0)}),P.on("error",e=>{
307
- "ENOENT"===e.code||"ECONNREFUSED"===e.code?y.fail(s.default.red(`\nMahameru PM Daemon is not running.\nCannot connect to Mahameru PM Daemon. Make sure you run ${s.default.bold("mahameru pm service install")} first.`)):"win32"===process.platform&&"EPERM"===e.code?function(e,t){
307
+ "ENOENT"===e.code||"ECONNREFUSED"===e.code?y.fail(`${s.default.red("Mahameru PM Service is not running. Cannot connect to Mahameru PM Service.")}\n\nMake sure you run ${s.default.bold(s.default.cyan("mahameru pm service install"))} first to install the service.\nOr open new terminal and run ${s.default.bold(s.default.cyan("mahameru pm start"))} to run the MahameruJS PM foreground process. Then you can run ${s.default.bold(s.default.cyan("mahameru start"))} again on this directory.`):"win32"===process.platform&&"EPERM"===e.code?function(e,t){
308
308
  if(!(0,d.hasWindowsElevationRetry)()&&!(0,d.isWindowsProcessElevated)()){
309
309
  e.warn(s.default.yellow("\nWindows blocked access to the Mahameru PM pipe. Requesting Administrator approval..."))
310
310
  ;const o=(0,d.relaunchCurrentProcessAsAdmin)(t)
@@ -317,7 +317,7 @@ process.exit(0))
317
317
  o.errorText&&console.error(s.default.dim(o.errorText)),process.exit(1)}
318
318
  e.fail(s.default.red(`\nAccess denied while connecting to Mahameru PM Daemon.\nThe daemon or Windows service is likely running elevated, and the elevated retry still could not access ${s.default.bold(u.IPC_SOCKET_PATH)}.`)),
319
319
  console.log(s.default.dim("Check the visible Administrator PowerShell window for the detailed failure output.")),
320
- process.exit(1)}(y,o):(y.fail(s.default.red(`\n${e.message}`)),console.error(e)),process.exit(1)})}},1471(e,t,o){
320
+ process.exit(1)}(y,o):(y.fail(s.default.red(`${e.message}`)),console.error(e)),process.exit(1)})}},1471(e,t,o){
321
321
  var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}}
322
322
  ;Object.defineProperty(t,"__esModule",{value:!0}),t.startService=void 0
323
323
  ;const n=o(6921),s=o(1421),a=o(3024),i=o(6760),c=r(o(5205));t.startService=e=>()=>{
@@ -630,30 +630,32 @@ Object.defineProperty(t,"__esModule",{value:!0
630
630
  ;t.getSocket=e=>l.get(e);t.setSocket=e=>l.set(e.id,e);t.deleteSocket=e=>l.delete(e);t.clearSockets=()=>l.clear()
631
631
  ;t.loadProjects=async()=>{try{if((0,r.existsSync)((0,n.dirname)(a.PROJECTS_FILE_PATH))||await(0,s.mkdir)((0,
632
632
  n.dirname)(a.PROJECTS_FILE_PATH),{recursive:!0}),!(0,r.existsSync)(a.PROJECTS_FILE_PATH))return await(0,
633
- s.writeFile)(a.PROJECTS_FILE_PATH,"[]","utf-8"),[];const e=await(0,s.readFile)(a.PROJECTS_FILE_PATH,"utf-8")
634
- ;return JSON.parse(e)}catch(e){throw new Error("Failed to load projects")}};t.saveProjects=async e=>{try{
635
- e?Array.isArray(e)||((0,t.setProject)(e),e=(0,t.getProjects)().map(i.parseProject)):e=(0,
636
- t.getProjects)().map(i.parseProject);const o=e.map(i.parseProject),r=JSON.stringify(o,null,2);await(0,
637
- s.writeFile)(a.PROJECTS_FILE_PATH,r,"utf-8")}catch(e){throw new Error("Failed to save projects")}}},7209(e,t,o){
638
- var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}}
639
- ;Object.defineProperty(t,"__esModule",{value:!0}),t.freePortFinder=async function(e=3e3){let t=e;const o=e+999
640
- ;for(;t<o;)try{return await s(t)}catch(e){t++}throw new Error(`Port ${e} - 999 is not available`)},
641
- t.isPortAvailable=function(e){return new Promise((t,o)=>{const r=n.default.createServer();r.once("error",e=>{e.code,
642
- o(!1)}),r.once("listening",()=>{r.close(()=>t(!0))}),r.listen(e,"127.0.0.1")})};const n=r(o(7030));function s(e){
643
- return new Promise((t,o)=>{const r=n.default.createServer();r.once("error",e=>{e.code,o(e)}),r.once("listening",()=>{
644
- r.close(()=>t(e))}),r.listen(e,"127.0.0.1")})}},4830(e,t,o){t.getProjectJson=async function(e){try{
645
- return JSON.parse(await(0,r.readFile)((0,n.join)(e,"package.json"),"utf-8"))}catch(e){
646
- throw new Error("package.json not found")}};const r=o(1455),n=o(6760)},6718(e,t,o){t.getNodeModulesPath=function(){try{
647
- return(0,r.execSync)("npm root -g",{stdio:["ignore","pipe","ignore"]}).toString().trim()}catch(e){
648
- throw new Error("npm is not installed or not accessible on your system.")}};const r=o(1421)},4813(e,t,o){
649
- t.isMahameruProjectDir=function(e){const t=(0,n.join)(e,"package.json"),o=(0,n.join)(e,"node_modules");if(!(0,
650
- r.existsSync)(t)&&(0,r.existsSync)(o))return!1;try{const e=(0,r.readFileSync)(t,"utf-8"),o=JSON.parse(e)
651
- ;return!(!o.dependencies||!o.dependencies.mahameru)}catch(e){return!1}};const r=o(3024),n=o(6760)},6929(e,t){
652
- t.parseProject=function(e){return{pid:e.pid,createdAt:e.createdAt,isDisabled:e.isDisabled,name:e.name,
653
- description:e.description,version:e.version,mode:e.mode,rootPath:e.rootPath,port:e.port,host:e.host,status:e.status,
654
- isLastStatusIsRunning:e.isLastStatusIsRunning}}},3157(e,t,o){t.hasWindowsElevationRetry=function(){
655
- return"1"===process.env[n]},t.getWindowsElevatedWorkingDirectory=function(){return process.env[s]},
656
- t.isWindowsProcessElevated=function(){if("win32"!==process.platform)return!1;const e=(0,
633
+ s.writeFile)(a.PROJECTS_FILE_PATH,"[]","utf-8"),[]
634
+ ;const e=await(0,s.readFile)(a.PROJECTS_FILE_PATH,"utf-8"),o=JSON.parse(e);for(const[e,t]of o.entries())(0,
635
+ r.existsSync)((0,n.join)(t.rootPath,"package.json"))&&(0,r.existsSync)((0,n.join)(t.rootPath,"node_modules"))&&(0,
636
+ r.existsSync)((0,n.join)(t.rootPath,"node_modules","mahameru"))||o.splice(e,1);return await(0,t.saveProjects)(o),o
637
+ }catch(e){throw new Error("Failed to load projects")}};t.saveProjects=async e=>{try{e?Array.isArray(e)||((0,
638
+ t.setProject)(e),e=(0,t.getProjects)().map(i.parseProject)):e=(0,t.getProjects)().map(i.parseProject)
639
+ ;const o=e.map(i.parseProject),r=JSON.stringify(o,null,2);await(0,s.writeFile)(a.PROJECTS_FILE_PATH,r,"utf-8")}catch(e){
640
+ throw new Error("Failed to save projects")}}},7209(e,t,o){var r=this&&this.__importDefault||function(e){
641
+ return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),
642
+ t.freePortFinder=async function(e=3e3){let t=e;const o=e+999;for(;t<o;)try{return await s(t)}catch(e){t++}
643
+ throw new Error(`Port ${e} - 999 is not available`)},t.isPortAvailable=function(e){return new Promise((t,o)=>{
644
+ const r=n.default.createServer();r.once("error",e=>{e.code,o(!1)}),r.once("listening",()=>{r.close(()=>t(!0))}),
645
+ r.listen(e,"127.0.0.1")})};const n=r(o(7030));function s(e){return new Promise((t,o)=>{const r=n.default.createServer()
646
+ ;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){
647
+ t.getProjectJson=async function(e){try{return JSON.parse(await(0,r.readFile)((0,n.join)(e,"package.json"),"utf-8"))
648
+ }catch(e){throw new Error("package.json not found")}};const r=o(1455),n=o(6760)},6718(e,t,o){
649
+ t.getNodeModulesPath=function(){try{return(0,r.execSync)("npm root -g",{stdio:["ignore","pipe","ignore"]
650
+ }).toString().trim()}catch(e){throw new Error("npm is not installed or not accessible on your system.")}}
651
+ ;const r=o(1421)},4813(e,t,o){t.isMahameruProjectDir=function(e){const t=(0,n.join)(e,"package.json"),o=(0,
652
+ n.join)(e,"node_modules");if(!(0,r.existsSync)(t)&&(0,r.existsSync)(o))return!1;try{const e=(0,
653
+ r.readFileSync)(t,"utf-8"),o=JSON.parse(e);return!(!o.dependencies||!o.dependencies.mahameru)}catch(e){return!1}}
654
+ ;const r=o(3024),n=o(6760)},6929(e,t){t.parseProject=function(e){return{pid:e.pid,createdAt:e.createdAt,
655
+ isDisabled:e.isDisabled,name:e.name,description:e.description,version:e.version,mode:e.mode,rootPath:e.rootPath,
656
+ port:e.port,host:e.host,status:e.status,isLastStatusIsRunning:e.isLastStatusIsRunning}}},3157(e,t,o){
657
+ t.hasWindowsElevationRetry=function(){return"1"===process.env[n]},t.getWindowsElevatedWorkingDirectory=function(){
658
+ return process.env[s]},t.isWindowsProcessElevated=function(){if("win32"!==process.platform)return!1;const e=(0,
657
659
  r.spawnSync)("powershell.exe",["-NoProfile","-NonInteractive","-Command","([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)"],{
658
660
  encoding:"utf8",windowsHide:!0});return 0===e.status&&"true"===e.stdout.trim().toLowerCase()},
659
661
  t.relaunchCurrentProcessAsAdmin=function(e){if("win32"!==process.platform)return{ok:!1,reason:"unsupported-platform"}
@@ -679,5 +681,5 @@ e.exports=require("node:child_process")},139(e){e.exports=require("node:cluster"
679
681
  },1455(e){e.exports=require("node:fs/promises")},7067(e){e.exports=require("node:http")},4708(e){
680
682
  e.exports=require("node:https")},8995(e){e.exports=require("node:module")},7030(e){e.exports=require("node:net")},
681
683
  8161(e){e.exports=require("node:os")},6760(e){e.exports=require("node:path")},6928(e){e.exports=require("path")},
682
- 8330(e){e.exports={version:"0.0.27"}}};const t={};(function o(r){const n=t[r];if(void 0!==n)return n.exports
684
+ 8330(e){e.exports={version:"0.0.28"}}};const t={};(function o(r){const n=t[r];if(void 0!==n)return n.exports
683
685
  ;const s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,o),s.exports})(8625)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mahameru/cli",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "MahameruJS CLI Utility - The command-line interface for running and building Mahameru-based applications",
5
5
  "bin": {
6
6
  "mahameru": "./cli.js"