@solution-lib/space 0.1.1 → 0.1.2

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/dist/main.js CHANGED
@@ -23,7 +23,7 @@ Please try:
23
23
  1. Close any terminals/editors with "${i}" open
24
24
  2. Navigate out of the directory in all terminals
25
25
  3. Run PowerShell/Terminal as Administrator
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:e.type,template:e.template,pm:"bun",repo:{org:r,name:s,version:"0.0.1",desc:e.description,kw:e.keywords.length>0?e.keywords:[],license:e.license||"MIT"},author:{id:e.githubId,name:e.author,email:e.authorEmail,url:""},createdAt:new Date().toISOString()},i),l.showSuccess(s,[i===process.cwd()?"space install":`cd ${s}`,"space install","space build"]);}catch(e){l.showError("Failed to create space",e),process.exit(1);}}showSpaceInfo(){if(!this.ensureSpace())return;let t=this.spaceManager.loadSpaceConfig();if(!t){console.error("\u2718 Could not load space configuration.");return}console.log("");let r=t.repo?.org&&t.repo.org.trim()!==""?`${t.repo.org}/${t.repo.name}`:t.repo.name;if(console.log(`Name: ${r}`),console.log(`Type: ${t.type}`),console.log(`Version: ${t.repo.version}`),t.repo.desc&&t.repo.desc!=="{{desc}}"&&t.repo.desc!=="{{description}}"&&console.log(`Description: ${t.repo.desc}`),t.repo.kw){let s=[];if(Array.isArray(t.repo.kw))s=t.repo.kw.filter(a=>a&&typeof a=="string"&&a.trim()!==""&&a!=="{{kw}}"&&a!=="{{keywords}}");else if(typeof t.repo.kw=="string"){let a=t.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(", ")}`);}t.repo.license&&t.repo.license!=="{{license}}"&&console.log(`License: ${t.repo.license}`),console.log("PackageManager: bun"),t.author?.name&&t.author.name!=="{{author}}"&&t.author.name!=="{{author_name}}"&&console.log(`Author: ${t.author.name}`),console.log(`Created: ${new Date(t.createdAt).toLocaleDateString()}`),console.log("");}runLint(t){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let e=[];t?.options?.fix&&e.push("--fix"),e.length>0?this.pm.run("lint",e):this.pm.run("lint");}async installPackages(t){if(this.ensureSpace()){this.pm||this.initPackageManager();try{let e=t.args?.packages?t.args.packages.split(" ").filter(s=>s.trim()):void 0,r=t.options?.dev||!1;if((!e||e.length===0)&&!await l.promptConfirm("No packages specified. Install all dependencies from package.json?",!0)){let a=await l.promptInstall();e=a.packages,r=a.isDev;}this.pm.install(e,{dev:r,global:t.options?.global});}catch(e){l.showError("\u2718 Installation failed",e),process.exit(1);}}}async removePackages(t){if(this.ensureSpace()){this.pm||this.initPackageManager();try{let e=t.args?.packages.split(" ").filter(s=>s.trim());if(!e||e.length===0){l.showError("Please specify packages to remove");return}if(!(await l.promptRemove(e)).confirm){l.showInfo("Removal cancelled");return}this.pm.remove(e,{global:t.options?.global});}catch(e){l.showError("\u2718 Removal failed",e),process.exit(1);}}}async updatePackages(t){if(this.ensureSpace()){this.pm||this.initPackageManager();try{let e=t.args?.packages?t.args.packages.split(" ").filter(r=>r.trim()):void 0;if(!e||e.length===0){let r=await l.promptUpdate();e=r.updateAll?void 0:r.packages;}this.pm.update(e);}catch(e){l.showError("\u2718 Update failed",e),process.exit(1);}}}linkPackage(t){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let e=t?.args?.package;this.pm.link(e);}unlinkPackage(t){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let e=t?.args?.package;this.pm.unlink(e);}listPackages(t){this.ensureSpace()&&(this.pm||this.initPackageManager(),this.pm.list({global:t.options?.global??false}));}runScript(t){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let e=t?.args?.script;if(!e){l.showError("Please specify a script name");return}try{let r=[];if(t?.dynamicArgs&&Array.isArray(t.dynamicArgs)&&r.push(...t.dynamicArgs),t?.dynamicOptions&&typeof t.dynamicOptions=="object")for(let[s,a]of Object.entries(t.dynamicOptions))r.push(`--${s}`),a!==!0&&a!==!1&&r.push(String(a));this.pm.run(e,r.length>0?r:void 0);}catch(r){l.showError(`Failed to run script "${e}"`,r),process.exit(1);}}buildSpace(t){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let e=new x;e.start("Building space...");try{this.pm.runSilent("build"),e.stop(t?"":"\u2714 Build succeeded");}catch{e.stopWithError("\u2718 Build failed"),process.exit(1);}}buildSpaceBool(t){if(!this.ensureSpace())return false;this.pm||this.initPackageManager();let e=new x;e.start("Building space...");try{return this.pm.runSilent("build"),e.stop(t?"":"\u2714 Build succeeded"),!0}catch{return e.stopWithError("\u2718 Build failed!"),false}}runTests(t){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let e=[],r=t?.args?.path;r&&e.push(r),t?.options?.coverage&&e.push("--coverage"),t?.options?.["coverage-reporter"]&&e.push("--coverage-reporter",t.options["coverage-reporter"]),t?.options?.watch&&e.push("--watch"),t?.options?.bail&&e.push("--bail"),t?.options?.timeout&&e.push("--timeout",t.options.timeout),t?.options?.["rerun-each"]&&e.push("--rerun-each",t.options["rerun-each"]),t?.options?.concurrent&&e.push("--concurrent"),t?.options?.["test-name-pattern"]&&e.push("-t",t.options["test-name-pattern"]),e.length>0?this.pm.run("test",e):this.pm.run("test");}clean(){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let t=new x;t.start("Cleaning build artifacts...");try{this.pm.run("clean"),t.stop("\u2714 Clean complete!");}catch{t.stopWithError("\u2718 Clean failed!"),process.exit(1);}}startMain(t){if(this.buildSpaceBool(true))try{let e=this.findBuiltMainFile();e||(l.showError(`Could not find built entry point.
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:e.type,template:e.template,pm:"bun",repo:{org:r,name:s,version:"0.0.1",desc:e.description,kw:e.keywords.length>0?e.keywords:[],license:e.license||"MIT"},author:{id:e.githubId,name:e.author,email:e.authorEmail,url:""},createdAt:new Date().toISOString()},i),l.showSuccess(s,[i===process.cwd()?"space install":`cd ${s}`,"space install","space build"]);}catch(e){l.showError("Failed to create space",e),process.exit(1);}}showSpaceInfo(){if(!this.ensureSpace())return;let t=this.spaceManager.loadSpaceConfig();if(!t){console.error("\u2718 Could not load space configuration.");return}console.log("");let r=t.repo?.org&&t.repo.org.trim()!==""?`${t.repo.org}/${t.repo.name}`:t.repo.name;if(console.log(`Name: ${r}`),console.log(`Type: ${t.type}`),console.log(`Version: ${t.repo.version}`),t.repo.desc&&t.repo.desc!=="{{desc}}"&&t.repo.desc!=="{{description}}"&&console.log(`Description: ${t.repo.desc}`),t.repo.kw){let s=[];if(Array.isArray(t.repo.kw))s=t.repo.kw.filter(a=>a&&typeof a=="string"&&a.trim()!==""&&a!=="{{kw}}"&&a!=="{{keywords}}");else if(typeof t.repo.kw=="string"){let a=t.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(", ")}`);}t.repo.license&&t.repo.license!=="{{license}}"&&console.log(`License: ${t.repo.license}`),console.log("PackageManager: bun"),t.author?.name&&t.author.name!=="{{author}}"&&t.author.name!=="{{author_name}}"&&console.log(`Author: ${t.author.name}`),console.log(`Created: ${new Date(t.createdAt).toLocaleDateString()}`),console.log("");}runLint(t){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let e=[];t?.options?.fix&&e.push("--fix"),e.length>0?this.pm.run("lint",e):this.pm.run("lint");}async installPackages(t){if(this.ensureSpace()){this.pm||this.initPackageManager();try{let e=t.args?.packages?t.args.packages.split(" ").filter(s=>s.trim()):void 0,r=t.options?.dev||!1;if((!e||e.length===0)&&!await l.promptConfirm("No packages specified. Install all dependencies from package.json?",!0)){let a=await l.promptInstall();e=a.packages,r=a.isDev;}this.pm.install(e,{dev:r,global:t.options?.global});}catch(e){l.showError("\u2718 Installation failed",e),process.exit(1);}}}async removePackages(t){if(this.ensureSpace()){this.pm||this.initPackageManager();try{let e=t.args&&t.args.packages?t.args?.packages.split(" ").filter(s=>s.trim()):void 0;if(!e||e.length===0){l.showError("Please specify packages to remove");return}if(!(await l.promptRemove(e)).confirm){l.showInfo("Removal cancelled");return}this.pm.remove(e,{global:t.options?.global});}catch(e){l.showError("\u2718 Removal failed",e),process.exit(1);}}}async updatePackages(t){if(this.ensureSpace()){this.pm||this.initPackageManager();try{let e=t.args?.packages?t.args.packages.split(" ").filter(r=>r.trim()):void 0;if(!e||e.length===0){let r=await l.promptUpdate();e=r.updateAll?void 0:r.packages;}this.pm.update(e);}catch(e){l.showError("\u2718 Update failed",e),process.exit(1);}}}linkPackage(t){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let e=t?.args?.package;this.pm.link(e);}unlinkPackage(t){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let e=t?.args?.package;this.pm.unlink(e);}listPackages(t){this.ensureSpace()&&(this.pm||this.initPackageManager(),this.pm.list({global:t.options?.global??false}));}runScript(t){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let e=t?.args?.script;if(!e){l.showError("Please specify a script name");return}try{let r=[];if(t?.dynamicArgs&&Array.isArray(t.dynamicArgs)&&r.push(...t.dynamicArgs),t?.dynamicOptions&&typeof t.dynamicOptions=="object")for(let[s,a]of Object.entries(t.dynamicOptions))r.push(`--${s}`),a!==!0&&a!==!1&&r.push(String(a));this.pm.run(e,r.length>0?r:void 0);}catch(r){l.showError(`Failed to run script "${e}"`,r),process.exit(1);}}buildSpace(t){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let e=new x;e.start("Building space...");try{this.pm.runSilent("build"),e.stop(t?"":"\u2714 Build succeeded");}catch{e.stopWithError("\u2718 Build failed"),process.exit(1);}}buildSpaceBool(t){if(!this.ensureSpace())return false;this.pm||this.initPackageManager();let e=new x;e.start("Building space...");try{return this.pm.runSilent("build"),e.stop(t?"":"\u2714 Build succeeded"),!0}catch{return e.stopWithError("\u2718 Build failed!"),false}}runTests(t){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let e=[],r=t?.args?.path;r&&e.push(r),t?.options?.coverage&&e.push("--coverage"),t?.options?.["coverage-reporter"]&&e.push("--coverage-reporter",t.options["coverage-reporter"]),t?.options?.watch&&e.push("--watch"),t?.options?.bail&&e.push("--bail"),t?.options?.timeout&&e.push("--timeout",t.options.timeout),t?.options?.["rerun-each"]&&e.push("--rerun-each",t.options["rerun-each"]),t?.options?.concurrent&&e.push("--concurrent"),t?.options?.["test-name-pattern"]&&e.push("-t",t.options["test-name-pattern"]),e.length>0?this.pm.run("test",e):this.pm.run("test");}clean(){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let t=new x;t.start("Cleaning build artifacts...");try{this.pm.run("clean"),t.stop("\u2714 Clean complete!");}catch{t.stopWithError("\u2718 Clean failed!"),process.exit(1);}}startMain(t){if(this.buildSpaceBool(true))try{let e=this.findBuiltMainFile();e||(l.showError(`Could not find built entry point.
27
27
  Expected to find dist/main.js or dist/index.js after build.`),process.exit(1));let r=[];if(t?.dynamicArgs&&Array.isArray(t.dynamicArgs)&&r.push(...t.dynamicArgs),t?.dynamicOptions&&typeof t.dynamicOptions=="object")for(let[a,i]of Object.entries(t.dynamicOptions))r.push(`--${a}`),i!==!0&&i!==!1&&r.push(String(i));r.length>0;let s=spawnSync("bun",[e,...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
28
  \u2718 Process exited with error`),process.exit(s.status));}catch(e){l.showError("Failed to start",e),process.exit(1);}}findBuiltMainFile(){let t=["dist/main.js","dist/index.js","dist/app.js"];for(let e of t)if(m.existsSync(P.join(process.cwd(),e)))return e;try{let e=P.join(process.cwd(),"package.json");if(m.existsSync(e)){let r=JSON.parse(m.readFileSync(e,"utf-8"));if(r.main&&m.existsSync(r.main))return r.main}}catch{}return null}async publish(t){if(this.buildSpaceBool(true))try{let e=this.spaceManager.loadSpaceConfig();if(!e){l.showError("Could not load space configuration");return}let r=e.repo.org?`@${e.repo.org}/${e.repo.name}`:e.repo.name,s=t.options?.tag||void 0,a=t.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(e){l.showError("Publish failed",e),process.exit(1);}}};var W=M.create({name:"Space",version:"0.0.2",desc:"Build flexible spaces for any platform"});W.run();//# sourceMappingURL=main.js.map
29
29
  //# sourceMappingURL=main.js.map