@solution-lib/space 0.0.5 → 0.0.6

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
@@ -17,7 +17,7 @@ ${t}`),this.interval=setInterval(()=>{process.stdout.write(`\r${this.frames[this
17
17
 
18
18
  `);}stopWithError(t){this.interval&&(clearInterval(this.interval),this.interval=null),process.stdout.write(`\r\u2718 ${t}
19
19
 
20
- `);}},M=class h{constructor(t){this.config=t;this.pm=null;this.spaceManager=new I,this.initPackageManager();}static create(t){return new h(t)}run(){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:"--type",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:t=>this.createNewSpaceOnGroundViaCLI(t)}).command({name:"info",description:"Show current space information",action:()=>this.showSpaceInfo()}).command({name:"install",aliases:["i"],description:"Install packages",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:t=>this.installPackages(t)}).command({name:"remove",aliases:["r"],description:"Remove packages",args:[{name:"packages",required:true,description:"Packages to remove (space-separated)"}],options:[{name:"global",flag:"--global",type:"boolean",required:false,description:"Remove globally"}],action:t=>this.removePackages(t)}).command({name:"update",aliases:["up"],description:"Update packages",args:[{name:"packages",required:false,description:"Packages to update (space-separated, or all if empty)"}],action:t=>this.updatePackages(t)}).command({name:"link",description:"Link package globally (no args) or link global package to project (with package name)",args:[{name:"package",required:false,description:"Package name to link from global (optional)"}],action:t=>this.linkPackage(t)}).command({name:"unlink",description:"Unlink package globally (no args) or unlink global package from project (with package name)",args:[{name:"package",required:false,description:"Package name to unlink from global (optional)"}],action:t=>this.unlinkPackage(t)}).command({name:"list",aliases:["ls"],description:"List installed packages",options:[{name:"global",flag:"--global",type:"boolean",required:false,description:"List global packages"}],action:t=>this.listPackages(t)}).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)"}],action:t=>this.runTests(t)}).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:t=>this.runScript(t)}).command({name:"clean",description:"Clean build artifacts",action:()=>this.clean()}).command({name:"start",description:"Start the main file",allowDynamicArgs:true,allowDynamicOptions:true,action:t=>this.startMain(t)}).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:t=>this.publish(t)}).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> --type lib|cli" first.'),false)}parsePackageName(t){let e=/^@([a-z0-9-_]+)\/([a-z0-9-_]+)$/i,r=t.match(e);return r?{org:r[1],name:r[2]}:{org:"",name:t}}async deleteDirectoryWithRetry(t,e=3){for(let r=0;r<e;r++)try{if(u.rmSync(t,{recursive:!0,force:!0,maxRetries:3,retryDelay:100}),!u.existsSync(t))return}catch(s){if(r===e-1)throw s;await new Promise(a=>setTimeout(a,500*(r+1)));}throw new Error("Failed to delete directory after multiple attempts")}async createNewSpaceOnGroundViaCLI(t){try{let e=await o.promptInit({type:t.options.type,template:t.options.template,org:"",name:t.args.name,desc:t.options.desc}),{org:r,name:s}=this.parsePackageName(e.name);["lib","cli","server"].includes(e.type)||(o.showError("Invalid space type. Must be lib, cli or server."),process.exit(1));let{TemplateRegistry:a}=await Promise.resolve().then(()=>(D(),N));a.isValidTemplate(e.type,e.template)||(o.showError("Invalid template for this space type."),process.exit(1)),a.isTemplateReady(e.type,e.template)||(o.showError("This template is not ready yet. Please choose another template."),process.exit(1));let i,n=T.basename(process.cwd());if(!s||s.trim()===""?await o.promptUseCurrentDir(n)?i=process.cwd():(o.showError("Space name is required when not using current directory"),process.exit(1)):n===s&&await o.promptUseCurrentDir(s)&&(i=process.cwd()),i||(i=T.join(process.cwd(),s)),u.existsSync(i)){u.statSync(i).isDirectory()||(o.showError(`Path "${i}" exists but is not a directory`),process.exit(1)),await o.promptDeleteExistingDir(i)||(o.showInfo("Space creation cancelled"),process.exit(0));try{await this.deleteDirectoryWithRetry(i);}catch(f){f.message&&(f.message.includes("EBUSY")||f.message.includes("EPERM")||f.message.includes("resource busy"))?o.showError(`Cannot delete directory - it's being used by another program.
20
+ `);}},M=class h{constructor(t){this.config=t;this.pm=null;this.spaceManager=new I,this.initPackageManager();}static create(t){return new h(t)}run(){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:t=>this.createNewSpaceOnGroundViaCLI(t)}).command({name:"info",description:"Show current space information",action:()=>this.showSpaceInfo()}).command({name:"install",aliases:["i"],description:"Install packages",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:t=>this.installPackages(t)}).command({name:"remove",aliases:["r"],description:"Remove packages",args:[{name:"packages",required:true,description:"Packages to remove (space-separated)"}],options:[{name:"global",flag:"--global",type:"boolean",required:false,description:"Remove globally"}],action:t=>this.removePackages(t)}).command({name:"update",aliases:["up"],description:"Update packages",args:[{name:"packages",required:false,description:"Packages to update (space-separated, or all if empty)"}],action:t=>this.updatePackages(t)}).command({name:"link",description:"Link package globally (no args) or link global package to project (with package name)",args:[{name:"package",required:false,description:"Package name to link from global (optional)"}],action:t=>this.linkPackage(t)}).command({name:"unlink",description:"Unlink package globally (no args) or unlink global package from project (with package name)",args:[{name:"package",required:false,description:"Package name to unlink from global (optional)"}],action:t=>this.unlinkPackage(t)}).command({name:"list",aliases:["ls"],description:"List installed packages",options:[{name:"global",flag:"--global",type:"boolean",required:false,description:"List global packages"}],action:t=>this.listPackages(t)}).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)"}],action:t=>this.runTests(t)}).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:t=>this.runScript(t)}).command({name:"clean",description:"Clean build artifacts",action:()=>this.clean()}).command({name:"start",description:"Start the main file",allowDynamicArgs:true,allowDynamicOptions:true,action:t=>this.startMain(t)}).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:t=>this.publish(t)}).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(t){let e=/^@([a-z0-9-_]+)\/([a-z0-9-_]+)$/i,r=t.match(e);return r?{org:r[1],name:r[2]}:{org:"",name:t}}async deleteDirectoryWithRetry(t,e=3){for(let r=0;r<e;r++)try{if(u.rmSync(t,{recursive:!0,force:!0,maxRetries:3,retryDelay:100}),!u.existsSync(t))return}catch(s){if(r===e-1)throw s;await new Promise(a=>setTimeout(a,500*(r+1)));}throw new Error("Failed to delete directory after multiple attempts")}async createNewSpaceOnGroundViaCLI(t){try{let e=await o.promptInit({type:t.options.type,template:t.options.template,org:"",name:t.args.name,desc:t.options.desc}),{org:r,name:s}=this.parsePackageName(e.name);["lib","cli","server"].includes(e.type)||(o.showError("Invalid space type. Must be lib, cli or server."),process.exit(1));let{TemplateRegistry:a}=await Promise.resolve().then(()=>(D(),N));a.isValidTemplate(e.type,e.template)||(o.showError("Invalid template for this space type."),process.exit(1)),a.isTemplateReady(e.type,e.template)||(o.showError("This template is not ready yet. Please choose another template."),process.exit(1));let i,n=T.basename(process.cwd());if(!s||s.trim()===""?await o.promptUseCurrentDir(n)?i=process.cwd():(o.showError("Space name is required when not using current directory"),process.exit(1)):n===s&&await o.promptUseCurrentDir(s)&&(i=process.cwd()),i||(i=T.join(process.cwd(),s)),u.existsSync(i)){u.statSync(i).isDirectory()||(o.showError(`Path "${i}" exists but is not a directory`),process.exit(1)),await o.promptDeleteExistingDir(i)||(o.showInfo("Space creation cancelled"),process.exit(0));try{await this.deleteDirectoryWithRetry(i);}catch(f){f.message&&(f.message.includes("EBUSY")||f.message.includes("EPERM")||f.message.includes("resource busy"))?o.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