@minejs/hmm 0.0.7 → 0.0.8
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 +5 -4
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
</div>
|
|
9
9
|
|
|
10
10
|
<div align="center">
|
|
11
|
-
<img src="https://img.shields.io/badge/v-0.0.
|
|
11
|
+
<img src="https://img.shields.io/badge/v-0.0.8-black"/>
|
|
12
12
|
<a href="https://github.com/minejs-org"> <img src="https://img.shields.io/badge/🔥-@minejs-black"/> </a>
|
|
13
13
|
<br>
|
|
14
14
|
<img src="https://img.shields.io/badge/coverage---%25-brightgreen" alt="Test Coverage" />
|
|
@@ -116,9 +116,10 @@
|
|
|
116
116
|
hmm build
|
|
117
117
|
|
|
118
118
|
# Start the project (builds first, then runs)
|
|
119
|
-
|
|
120
|
-
hmm
|
|
121
|
-
hmm
|
|
119
|
+
# you can use `go` or `start`
|
|
120
|
+
hmm go # Run the built main file
|
|
121
|
+
hmm go --help # Pass args to your app
|
|
122
|
+
hmm go arg1 arg2 --flag # All args passed through
|
|
122
123
|
|
|
123
124
|
# Run tests
|
|
124
125
|
hmm test # Run all tests
|
package/dist/index.cjs
CHANGED
|
@@ -17,7 +17,7 @@ ${e}`),this.interval=setInterval(()=>{process.stdout.write(`\r${this.frames[this
|
|
|
17
17
|
|
|
18
18
|
`);}stopWithError(e){this.interval&&(clearInterval(this.interval),this.interval=null),process.stdout.write(`\r\u2718 ${e}
|
|
19
19
|
|
|
20
|
-
`);}};var
|
|
20
|
+
`);}};var L=class m{constructor(e){this.config=e;this.pm=null;this.spaceManager=new F,this.initPackageManager();}static create(e){return new m(e)}run(){cli.cli(this.config.name,this.config.version).description(this.config.desc).command({name:"init",description:"Create a new space (lib or cli)",args:[{name:"name",required:false,default:"my-space",description:"Name of the space (supports @org/name format)"}],options:[{name:"type",flag:"-t",type:"string",required:false,description:"Type of space (lib or cli)"},{name:"description",flag:"--desc",type:"string",required:false,description:"Description of the space"}],action:e=>this.createNewSpaceOnGroundViaCLI(e)}).command({name:"lint",description:"Run linter for the current space",options:[{name:"fix",flag:"--fix",type:"boolean",required:false,description:"Automatically fix linting issues"}],action:e=>this.runLint(e)}).command({name:"info",description:"Show current space information",action:()=>this.showSpaceInfo()}).command({name:"install",aliases:["i"],description:"Install packages",allowDynamicArgs:true,args:[{name:"packages",required:false,description:"Packages to install (space-separated)"}],options:[{name:"dev",flag:"--dev",type:"boolean",required:false,description:"Install as dev dependency"},{name:"global",flag:"--global",type:"boolean",required:false,description:"Install globally"}],action:e=>this.installPackages(e)}).command({name:"remove",aliases:["r"],description:"Remove packages",allowDynamicArgs:true,args:[{name:"packages",required:true,description:"Packages to remove (space-separated)"}],options:[{name:"global",flag:"--global",type:"boolean",required:false,description:"Remove globally"}],action:e=>this.removePackages(e)}).command({name:"update",aliases:["up"],description:"Update packages",allowDynamicArgs:true,args:[{name:"packages",required:false,description:"Packages to update (space-separated, or all if empty)"}],action:e=>this.updatePackages(e)}).command({name:"link",description:"Link package globally (no args) or link global package(s) to project (with package name(s))",allowDynamicArgs:true,args:[{name:"package",required:false,description:"Package name(s) to link from global (optional, supports multiple)"}],action:e=>this.linkPackage(e)}).command({name:"unlink",description:"Unlink package globally (no args) or unlink global package(s) from project (with package name(s))",allowDynamicArgs:true,args:[{name:"package",required:false,description:"Package name(s) to unlink from global (optional, supports multiple)"}],action:e=>this.unlinkPackage(e)}).command({name:"list",aliases:["ls"],description:"List installed packages",options:[{name:"global",flag:"--global",type:"boolean",required:false,description:"List global packages"}],action:e=>this.listPackages(e)}).command({name:"build",description:"Build the current space",action:()=>this.buildSpace()}).command({name:"test",description:"Run tests for the current space",args:[{name:"path",required:false,description:"Specific test file or folder (optional)"}],options:[{name:"coverage",flag:"--coverage",type:"boolean",required:false,description:"Generate code coverage report"},{name:"watch",flag:"--watch",type:"boolean",required:false,description:"Run tests in watch mode"},{name:"bail",flag:"--bail",type:"boolean",required:false,description:"Exit on first test failure"},{name:"timeout",flag:"--timeout",type:"string",required:false,description:"Set test timeout in milliseconds"},{name:"rerun-each",flag:"--rerun-each",type:"string",required:false,description:"Re-run each test N times"},{name:"concurrent",flag:"--concurrent",type:"boolean",required:false,description:"Run tests concurrently"},{name:"coverage-reporter",flag:"--coverage-reporter",type:"string",required:false,description:"Coverage reporter format (text, lcov, etc.)"},{name:"test-name-pattern",flag:"-t",type:"string",required:false,description:"Filter tests by name pattern"}],action:e=>this.runTests(e)}).command({name:"run",description:"Run any script from package.json",args:[{name:"script",required:true,description:"Script name from package.json"}],allowDynamicArgs:true,allowDynamicOptions:true,action:e=>this.runScript(e)}).command({name:"clean",description:"Clean build artifacts",action:()=>this.clean()}).command({name:"start",description:"Start the main file",allowDynamicArgs:true,allowDynamicOptions:true,action:e=>this.startMain(e)}).command({name:"go",description:"Start the main file (short for start)",allowDynamicArgs:true,allowDynamicOptions:true,action:e=>this.startMain(e)}).command({name:"publish",description:"Publish space to npm registry",options:[{name:"tag",flag:"--tag",type:"string",required:false,description:"Publish with tag (e.g., beta, next)"},{name:"access",flag:"--access",type:"string",required:false,description:"Access level (public or restricted)"}],action:e=>this.publish(e)}).build().run();}static defaultConfig(){return {name:"Space",version:"0.0.1",desc:"Build flexible spaces for any platform"}}initPackageManager(){this.spaceManager.isSpace()&&(this.pm=new O);}ensureSpace(){return this.spaceManager.isSpace()?true:(console.error('\u2718 Not a space directory. Run "space init <name> -t lib|cli" first.'),false)}parsePackageName(e){let t=/^@([a-z0-9-_]+)\/([a-z0-9-_]+)$/i,r=e.match(t);return r?{org:r[1],name:r[2]}:{org:"",name:e}}async deleteDirectoryWithRetry(e,t=3){for(let r=0;r<t;r++)try{if(g__namespace.rmSync(e,{recursive:!0,force:!0,maxRetries:3,retryDelay:100}),!g__namespace.existsSync(e))return}catch(s){if(r===t-1)throw s;await new Promise(a=>setTimeout(a,500*(r+1)));}throw new Error("Failed to delete directory after multiple attempts")}async createNewSpaceOnGroundViaCLI(e){try{let t=await l.promptInit({type:e.options.type,template:e.options.template,org:"",name:e.args.name,desc:e.options.desc}),{org:r,name:s}=this.parsePackageName(t.name);["lib","cli","server","web"].includes(t.type)||(l.showError("Invalid space type. Must be lib, cli, server or web."),process.exit(1));let{TemplateRegistry:a}=await Promise.resolve().then(()=>(j(),N));a.isValidTemplate(t.type,t.template)||(l.showError("Invalid template for this space type."),process.exit(1)),a.isTemplateReady(t.type,t.template)||(l.showError("This template is not ready yet. Please choose another template."),process.exit(1));let i,n=A__namespace.basename(process.cwd());if(!s||s.trim()===""?await l.promptUseCurrentDir(n)?i=process.cwd():(l.showError("Space name is required when not using current directory"),process.exit(1)):n===s&&await l.promptUseCurrentDir(s)&&(i=process.cwd()),i||(i=A__namespace.join(process.cwd(),s)),g__namespace.existsSync(i)){g__namespace.statSync(i).isDirectory()||(l.showError(`Path "${i}" exists but is not a directory`),process.exit(1)),await l.promptDeleteExistingDir(i)||(l.showInfo("Space creation cancelled"),process.exit(0));try{await this.deleteDirectoryWithRetry(i);}catch(p){p instanceof Error?p.message&&(p.message.includes("EBUSY")||p.message.includes("EPERM")||p.message.includes("resource busy"))?l.showError(`Cannot delete directory - it's being used by another program.
|
|
21
21
|
|
|
22
22
|
Please try:
|
|
23
23
|
1. Close any terminals/editors with "${i}" open
|
|
@@ -25,5 +25,5 @@ Please try:
|
|
|
25
25
|
3. Run PowerShell/Terminal as Administrator
|
|
26
26
|
4. Wait a few seconds and try again`):l.showError("Failed to delete existing directory.",p):l.showError("Failed to delete existing directory.",new Error("Unknown error")),process.exit(1);}}await this.spaceManager.createSpace({type:t.type,template:t.template,pm:"bun",repo:{org:r,name:s,version:"0.0.1",desc:t.description,kw:t.keywords.length>0?t.keywords:[],license:t.license||"MIT"},author:{id:t.githubId,name:t.author,email:t.authorEmail,url:""},createdAt:new Date().toISOString()},i),l.showSuccess(s,[i===process.cwd()?"space install":`cd ${s}`,"space install","space build"]);}catch(t){l.showError("Failed to create space",t),process.exit(1);}}showSpaceInfo(){if(!this.ensureSpace())return;let e=this.spaceManager.loadSpaceConfig();if(!e){console.error("\u2718 Could not load space configuration.");return}console.log("");let r=e.repo?.org&&e.repo.org.trim()!==""?`${e.repo.org}/${e.repo.name}`:e.repo.name;if(console.log(`Name: ${r}`),console.log(`Type: ${e.type}`),console.log(`Version: ${e.repo.version}`),e.repo.desc&&e.repo.desc!=="{{desc}}"&&e.repo.desc!=="{{description}}"&&console.log(`Description: ${e.repo.desc}`),e.repo.kw){let s=[];if(Array.isArray(e.repo.kw))s=e.repo.kw.filter(a=>a&&typeof a=="string"&&a.trim()!==""&&a!=="{{kw}}"&&a!=="{{keywords}}");else if(typeof e.repo.kw=="string"){let a=e.repo.kw;a!=="{{kw}}"&&a!=="{{keywords}}"&&a.trim()!==""&&(s=a.split(",").map(i=>i.trim()).filter(i=>i!==""));}s.length>0&&console.log(`Keywords: ${s.join(", ")}`);}e.repo.license&&e.repo.license!=="{{license}}"&&console.log(`License: ${e.repo.license}`),console.log("PackageManager: bun"),e.author?.name&&e.author.name!=="{{author}}"&&e.author.name!=="{{author_name}}"&&console.log(`Author: ${e.author.name}`),console.log(`Created: ${new Date(e.createdAt).toLocaleDateString()}`),console.log("");}runLint(e){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let t=[];e?.options?.fix&&t.push("--fix"),t.length>0?this.pm.run("lint",t):this.pm.run("lint");}async installPackages(e){if(this.ensureSpace()){this.pm||this.initPackageManager();try{let t=[];if(e.args?.packages){let s=e.args.packages.split(" ").filter(a=>a.trim());t.push(...s);}e?.dynamicArgs&&Array.isArray(e.dynamicArgs)&&t.push(...e.dynamicArgs);let r=e.options?.dev||!1;if(t.length===0&&!await l.promptConfirm("No packages specified. Install all dependencies from package.json?",!0)){let a=await l.promptInstall();t=a.packages,r=a.isDev;}this.pm.install(t.length>0?t:void 0,{dev:r,global:e.options?.global});}catch(t){l.showError("\u2718 Installation failed",t),process.exit(1);}}}async removePackages(e){if(this.ensureSpace()){this.pm||this.initPackageManager();try{let t=[];if(e.args?.packages){let s=e.args.packages.split(" ").filter(a=>a.trim());t.push(...s);}if(e?.dynamicArgs&&Array.isArray(e.dynamicArgs)&&t.push(...e.dynamicArgs),t.length===0){l.showError("Please specify packages to remove");return}if(!(await l.promptRemove(t)).confirm){l.showInfo("Removal cancelled");return}this.pm.remove(t,{global:e.options?.global});}catch(t){l.showError("\u2718 Removal failed",t),process.exit(1);}}}async updatePackages(e){if(this.ensureSpace()){this.pm||this.initPackageManager();try{let t;if(e.args?.packages){let r=e.args.packages.split(" ").filter(s=>s.trim());t=r.length>0?r:void 0;}if(e?.dynamicArgs&&Array.isArray(e.dynamicArgs)&&(t||(t=[]),t.push(...e.dynamicArgs)),!t||t.length===0){let r=await l.promptUpdate();t=r.updateAll?void 0:r.packages;}this.pm.update(t);}catch(t){l.showError("\u2718 Update failed",t),process.exit(1);}}}linkPackage(e){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let t=[];e?.args?.package&&(typeof e.args.package=="string"?t.push(e.args.package):Array.isArray(e.args.package)&&t.push(...e.args.package)),e?.dynamicArgs&&Array.isArray(e.dynamicArgs)&&t.push(...e.dynamicArgs),this.pm.link(t.length>0?t:void 0);}unlinkPackage(e){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let t=[];e?.args?.package&&(typeof e.args.package=="string"?t.push(e.args.package):Array.isArray(e.args.package)&&t.push(...e.args.package)),e?.dynamicArgs&&Array.isArray(e.dynamicArgs)&&t.push(...e.dynamicArgs),this.pm.unlink(t.length>0?t:void 0);}listPackages(e){this.ensureSpace()&&(this.pm||this.initPackageManager(),this.pm.list({global:e.options?.global??false}));}runScript(e){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let t=e?.args?.script;if(!t){l.showError("Please specify a script name");return}try{let r=[];if(e?.dynamicArgs&&Array.isArray(e.dynamicArgs)&&r.push(...e.dynamicArgs),e?.dynamicOptions&&typeof e.dynamicOptions=="object")for(let[s,a]of Object.entries(e.dynamicOptions))r.push(`--${s}`),a!==!0&&a!==!1&&r.push(String(a));this.pm.run(t,r.length>0?r:void 0);}catch(r){l.showError(`Failed to run script "${t}"`,r),process.exit(1);}}buildSpace(e){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let t=new x;t.start("Building space...");try{this.pm.runSilent("build"),t.stop(e?"":"\u2714 Build succeeded");}catch{t.stopWithError("\u2718 Build failed"),process.exit(1);}}buildSpaceBool(e){if(!this.ensureSpace())return false;this.pm||this.initPackageManager();let t=new x;t.start("Building space...");try{return this.pm.runSilent("build"),t.stop(e?"":"\u2714 Build succeeded"),!0}catch{return t.stopWithError("\u2718 Build failed!"),false}}runTests(e){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let t=[],r=e?.args?.path;r&&t.push(r),e?.options?.coverage&&t.push("--coverage"),e?.options?.["coverage-reporter"]&&t.push("--coverage-reporter",e.options["coverage-reporter"]),e?.options?.watch&&t.push("--watch"),e?.options?.bail&&t.push("--bail"),e?.options?.timeout&&t.push("--timeout",e.options.timeout),e?.options?.["rerun-each"]&&t.push("--rerun-each",e.options["rerun-each"]),e?.options?.concurrent&&t.push("--concurrent"),e?.options?.["test-name-pattern"]&&t.push("-t",e.options["test-name-pattern"]),t.length>0?this.pm.run("test",t):this.pm.run("test");}clean(){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let e=new x;e.start("Cleaning build artifacts...");try{this.pm.run("clean"),e.stop("\u2714 Clean complete!");}catch{e.stopWithError("\u2718 Clean failed!"),process.exit(1);}}startMain(e){if(this.buildSpaceBool(true))try{let t=this.findBuiltMainFile();t||(l.showError(`Could not find built entry point.
|
|
27
27
|
Expected to find dist/index.js or dist/index.js after build.`),process.exit(1));let r=[];if(e?.dynamicArgs&&Array.isArray(e.dynamicArgs)&&r.push(...e.dynamicArgs),e?.dynamicOptions&&typeof e.dynamicOptions=="object")for(let[a,i]of Object.entries(e.dynamicOptions))r.push(`--${a}`),i!==!0&&i!==!1&&r.push(String(i));r.length>0;let s=child_process.spawnSync("bun",[t,...r],{stdio:"inherit",cwd:process.cwd()});s.error&&(l.showError("Failed to start process",s.error),process.exit(1)),s.status!==0&&s.status!==null&&(console.error(`
|
|
28
|
-
\u2718 Process exited with error`),process.exit(s.status));}catch(t){l.showError("Failed to start",t),process.exit(1);}}findBuiltMainFile(){let e=["dist/index.js","dist/index.js","dist/app.js"];for(let t of e)if(g__namespace.existsSync(A__namespace.join(process.cwd(),t)))return t;try{let t=A__namespace.join(process.cwd(),"package.json");if(g__namespace.existsSync(t)){let r=JSON.parse(g__namespace.readFileSync(t,"utf-8"));if(r.main&&g__namespace.existsSync(r.main))return r.main}}catch{}return null}async publish(e){if(this.buildSpaceBool(true))try{let t=this.spaceManager.loadSpaceConfig();if(!t){l.showError("Could not load space configuration");return}let r=t.repo.org?`@${t.repo.org}/${t.repo.name}`:t.repo.name,s=e.options?.tag||void 0,a=e.options?.access||void 0;if(!s&&!a){let n=await l.promptPublish(r);if(!n.confirm){l.showInfo("Publish cancelled");return}s=n.tag,a=n.access;}let i=new x;i.start("Publishing package..."),this.pm.publish({tag:s,access:a},i);}catch(t){l.showError("Publish failed",t),process.exit(1);}}};var Y=
|
|
28
|
+
\u2718 Process exited with error`),process.exit(s.status));}catch(t){l.showError("Failed to start",t),process.exit(1);}}findBuiltMainFile(){let e=["dist/index.js","dist/index.js","dist/app.js"];for(let t of e)if(g__namespace.existsSync(A__namespace.join(process.cwd(),t)))return t;try{let t=A__namespace.join(process.cwd(),"package.json");if(g__namespace.existsSync(t)){let r=JSON.parse(g__namespace.readFileSync(t,"utf-8"));if(r.main&&g__namespace.existsSync(r.main))return r.main}}catch{}return null}async publish(e){if(this.buildSpaceBool(true))try{let t=this.spaceManager.loadSpaceConfig();if(!t){l.showError("Could not load space configuration");return}let r=t.repo.org?`@${t.repo.org}/${t.repo.name}`:t.repo.name,s=e.options?.tag||void 0,a=e.options?.access||void 0;if(!s&&!a){let n=await l.promptPublish(r);if(!n.confirm){l.showInfo("Publish cancelled");return}s=n.tag,a=n.access;}let i=new x;i.start("Publishing package..."),this.pm.publish({tag:s,access:a},i);}catch(t){l.showError("Publish failed",t),process.exit(1);}}};var Y=L.create({name:"Space",version:"0.0.2",desc:"Build flexible spaces for any platform"});Y.run();//# sourceMappingURL=index.cjs.map
|
|
29
29
|
//# sourceMappingURL=index.cjs.map
|