New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@eternalheart/x-cli

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eternalheart/x-cli - npm Package Compare versions

Comparing version 1.0.4-alpha-0 to 1.0.4-alpha-1

4

bin/x.js

@@ -138,3 +138,3 @@ #!/usr/bin/env node

}`),l(n,`@import "./variables/public";
@include variables();`),d(s,ct),l(_,"{}"),l(f,pt),l(D,q),d(k,at),...r.map(O=>{let U=`${o}/src/${O}`;return R(U)}),m(`${o}/src/app/nx-welcome.component.ts`),m(`${o}/src/app/app.component.spec.ts`),m(`${o}/src/app/app.component.css`),d(`${o}/src/app/app.component.scss`),u(`${o}/src/app/app.component.html`,`<${e}-nx-welcome></${e}-nx-welcome> `,""),u(`${o}/src/app/app.component.ts`,[["import { NxWelcomeComponent } from './nx-welcome.component';",""],["NxWelcomeComponent, ",""],["'./app.component.css'",""]]))},ut=async({packageManager:e,componentLibName:t})=>{await F(e).install(["@compodoc/compodoc","@storybook/addon-essentials","@storybook/addon-docs","@storybook/react-dom-shim","@storybook/builder-webpack5","esbuild@^0.19.2"],!0);let o=b(`${t}/.storybook/tsconfig.json`),r=await M(o);r?.include?.push("../src/**/*.ts"),await l(o,r);let i=b("tsconfig.base.json"),n=await M(i);n.compilerOptions.resolveJsonModule=!0,n.compilerOptions.allowSyntheticDefaultImports=!0,await l(i,n);let s=b(`${t}/.storybook/main.ts`),f=b(`${t}/project.json`),_=await M(f),D={compodoc:!0,compodocArgs:["-e","json","-d",`${t}/src`,"-p",`${t}/tsconfig.json`,"--disablePrivate","--disableInternal","--disableProtected","--disableLifeCycleHooks"],styles:[`${t}/src/lib/styles/public.scss`]};Object.assign(_.targets?.storybook.options,D),Object.assign(_.targets?.["build-storybook"]?.options,D),await l(f,_)},dt=async({projectName:e,componentLibName:t,demoLibName:o,registry:r})=>{let i="package.json",n=await M(i);Object.assign(n.scripts,{"fix:nx":"rm -rf .nx && rm -rf .angular",clean:"rm -rf dist && rm -rf node_modules",play:`nx run ${o??"play"}:serve`,"doc:serve":`nx run ${t??"ui"}:storybook`,"doc:build":`nx run ${t??"ui"}:build-storybook`,"ui:build":`nx run ${t??"ui"}:build`,"ui:unpublish":`npm unpublish ${e} --force --registry ${r}`,"ui:publish":`pnpm build && cd dist/${e} && npm publish --registry ${r}`}),await l(i,n)},gt=async({projectName:e,packageManager:t,prefix:o,componentLibName:r,demoLibName:i})=>{let n=".xrc",s={version:"1.0.4-alpha-0",name:e,prefix:o,projects:{[r]:{type:"component"},[i]:{type:"demo"}},packageManager:t};await l(n,s)};var xt=async e=>{await mt(p(e));let t=await E("\u8BF7\u8F93\u5165\u7EC4\u4EF6\u5E93\u7684\u540D\u79F0(\u56DE\u8F66\u786E\u8BA4)","ui"),o=await E("\u8BF7\u8F93\u5165\u7EC4\u4EF6\u5E93\u4F7F\u7528\u7684\u7EC4\u4EF6\u524D\u7F00[prefix](\u56DE\u8F66\u786E\u8BA4)",p(t)),r=await E("\u8BF7\u8F93\u5165demo\u5E93\u7684\u540D\u79F0(\u56DE\u8F66\u786E\u8BA4)","play"),i=await Be("\u9009\u62E9\u4F60\u7684\u5305\u7BA1\u7406\u5668(\u56DE\u8F66\u786E\u8BA4)","pnpm",["pnpm","npm","yarn"]),n=await E("\u6307\u5B9A\u4ED3\u5E93\u6E90(\u56DE\u8F66\u786E\u8BA4)","https://registry.npmjs.com"),s={projectName:p(e),componentLibName:p(t),demoLibName:p(r),packageManager:i,registry:n,prefix:o};try{await lt(s),await ft(s),await ut(s),await dt(s),await gt(s),await x(`git init && git add . && git commit -m "chore: init project ${e}"`)}catch(f){a.error(f)}};import{resolve as S}from"node:path";import{resolve as $}from"node:path";var yt=e=>e.toString().split("-").map((t,o)=>o===0?t:t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("");var ae={upper:e=>e.toString().toUpperCase(),lower:e=>e.toString().toLowerCase(),capital:e=>{let t=e.toString();return t.at(0).toUpperCase()+t.slice(1)},camel:e=>yt(e),kebabcase:e=>p(e)},lo=Object.keys(ae),fo=new RegExp(`{@[0-9a-zA-Z]+(?:__(${lo.join("|")}))*}`,"img"),uo=e=>e.toString().replace(/[@{}]+/g,"").split("__")[0]?.toLowerCase().replace(/[@{}]+/g,""),go=e=>e.toString().replace(/[@{}]+/g,"").split("__").slice(1).map(t=>t.toLowerCase().replace(/[@{}]+/g,"")),wt=(e,t)=>{let o=Object.keys(e).filter(r=>r.toLowerCase()===t)?.[0];return e[o]},c=(e,t)=>e.replace(fo,o=>{let r=go(o),i=uo(o);return wt(t,i)?r.reduce((n,s)=>Object.hasOwn(ae,s)?ae[s](n):n,wt(t,i)):o});var ce=async(e,t,{needExport:o=!1}={})=>{let{prefix:r}=await g();e=p(e);let i=$(t,e),n=$(t,"index.ts"),s=$(i,`${e}.component.html`),f=$(i,`${e}.component.scss`),_=$(i,`${e}.component.ts`),D=$(i,`${e}.stories.ts`),q=$(i,"index.ts");await R(i);let k={name:e,prefix:r};await y(d(s,c(xo,k)),d(f,c(yo,k)),d(_,c(wo,k)),d(D,c(vo,k)),d(q,c(Co,k))),o&&await L(n,c(pe,k))},vt=async(e,t)=>{let{prefix:o,name:r}=await g();e=p(e);let i=$(t,e),n=$(i,`${e}.component.ts`),s=$(t,"../app","app.routes.ts"),f={name:e,project:r,prefix:o};await R(i),await d(n,c(ho,f)),await u(s,"/router';",`/router';
@include variables();`),d(s,ct),l(_,"{}"),l(f,pt),l(D,q),d(k,at),...r.map(O=>{let U=`${o}/src/${O}`;return R(U)}),m(`${o}/src/app/nx-welcome.component.ts`),m(`${o}/src/app/app.component.spec.ts`),m(`${o}/src/app/app.component.css`),d(`${o}/src/app/app.component.scss`),u(`${o}/src/app/app.component.html`,`<${e}-nx-welcome></${e}-nx-welcome> `,""),u(`${o}/src/app/app.component.ts`,[["import { NxWelcomeComponent } from './nx-welcome.component';",""],["NxWelcomeComponent, ",""],["'./app.component.css'",""]]))},ut=async({packageManager:e,componentLibName:t})=>{await F(e).install(["@compodoc/compodoc","@storybook/addon-essentials","@storybook/addon-docs","@storybook/react-dom-shim","@storybook/builder-webpack5","esbuild@^0.19.2","react","react-dom"],!0);let o=b(`${t}/.storybook/tsconfig.json`),r=await M(o);r?.include?.push("../src/**/*.ts"),await l(o,r);let i=b("tsconfig.base.json"),n=await M(i);n.compilerOptions.resolveJsonModule=!0,n.compilerOptions.allowSyntheticDefaultImports=!0,await l(i,n);let s=b(`${t}/.storybook/main.ts`),f=b(`${t}/project.json`),_=await M(f),D={compodoc:!0,compodocArgs:["-e","json","-d",`${t}/src`,"-p",`${t}/tsconfig.json`,"--disablePrivate","--disableInternal","--disableProtected","--disableLifeCycleHooks"],styles:[`${t}/src/lib/styles/public.scss`]};Object.assign(_.targets?.storybook.options,D),Object.assign(_.targets?.["build-storybook"]?.options,D),await l(f,_)},dt=async({projectName:e,componentLibName:t,demoLibName:o,registry:r})=>{let i="package.json",n=await M(i);Object.assign(n.scripts,{"fix:nx":"rm -rf .nx && rm -rf .angular",clean:"rm -rf dist && rm -rf node_modules",play:`nx run ${o??"play"}:serve`,"doc:serve":`nx run ${t??"ui"}:storybook`,"doc:build":`nx run ${t??"ui"}:build-storybook`,"ui:build":`nx run ${t??"ui"}:build`,"ui:unpublish":`npm unpublish ${e} --force --registry ${r}`,"ui:publish":`pnpm build && cd dist/${e} && npm publish --registry ${r}`}),await l(i,n)},gt=async({projectName:e,packageManager:t,prefix:o,componentLibName:r,demoLibName:i})=>{let n=".xrc",s={version:"1.0.4-alpha-1",name:e,prefix:o,projects:{[r]:{type:"component"},[i]:{type:"demo"}},packageManager:t};await l(n,s)};var xt=async e=>{await mt(p(e));let t=await E("\u8BF7\u8F93\u5165\u7EC4\u4EF6\u5E93\u7684\u540D\u79F0(\u56DE\u8F66\u786E\u8BA4)","ui"),o=await E("\u8BF7\u8F93\u5165\u7EC4\u4EF6\u5E93\u4F7F\u7528\u7684\u7EC4\u4EF6\u524D\u7F00[prefix](\u56DE\u8F66\u786E\u8BA4)",p(t)),r=await E("\u8BF7\u8F93\u5165demo\u5E93\u7684\u540D\u79F0(\u56DE\u8F66\u786E\u8BA4)","play"),i=await Be("\u9009\u62E9\u4F60\u7684\u5305\u7BA1\u7406\u5668(\u56DE\u8F66\u786E\u8BA4)","pnpm",["pnpm","npm","yarn"]),n=await E("\u6307\u5B9A\u4ED3\u5E93\u6E90(\u56DE\u8F66\u786E\u8BA4)","https://registry.npmjs.com"),s={projectName:p(e),componentLibName:p(t),demoLibName:p(r),packageManager:i,registry:n,prefix:o};try{await lt(s),await ft(s),await ut(s),await dt(s),await gt(s),await x(`git init && git add . && git commit -m "chore: init project ${e}"`)}catch(f){a.error(f)}};import{resolve as S}from"node:path";import{resolve as $}from"node:path";var yt=e=>e.toString().split("-").map((t,o)=>o===0?t:t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("");var ae={upper:e=>e.toString().toUpperCase(),lower:e=>e.toString().toLowerCase(),capital:e=>{let t=e.toString();return t.at(0).toUpperCase()+t.slice(1)},camel:e=>yt(e),kebabcase:e=>p(e)},lo=Object.keys(ae),fo=new RegExp(`{@[0-9a-zA-Z]+(?:__(${lo.join("|")}))*}`,"img"),uo=e=>e.toString().replace(/[@{}]+/g,"").split("__")[0]?.toLowerCase().replace(/[@{}]+/g,""),go=e=>e.toString().replace(/[@{}]+/g,"").split("__").slice(1).map(t=>t.toLowerCase().replace(/[@{}]+/g,"")),wt=(e,t)=>{let o=Object.keys(e).filter(r=>r.toLowerCase()===t)?.[0];return e[o]},c=(e,t)=>e.replace(fo,o=>{let r=go(o),i=uo(o);return wt(t,i)?r.reduce((n,s)=>Object.hasOwn(ae,s)?ae[s](n):n,wt(t,i)):o});var ce=async(e,t,{needExport:o=!1}={})=>{let{prefix:r}=await g();e=p(e);let i=$(t,e),n=$(t,"index.ts"),s=$(i,`${e}.component.html`),f=$(i,`${e}.component.scss`),_=$(i,`${e}.component.ts`),D=$(i,`${e}.stories.ts`),q=$(i,"index.ts");await R(i);let k={name:e,prefix:r};await y(d(s,c(xo,k)),d(f,c(yo,k)),d(_,c(wo,k)),d(D,c(vo,k)),d(q,c(Co,k))),o&&await L(n,c(pe,k))},vt=async(e,t)=>{let{prefix:o,name:r}=await g();e=p(e);let i=$(t,e),n=$(i,`${e}.component.ts`),s=$(t,"../app","app.routes.ts"),f={name:e,project:r,prefix:o};await R(i),await d(n,c(ho,f)),await u(s,"/router';",`/router';
${c(me,f)}

@@ -262,2 +262,2 @@ `),await u(s,"Route[] = [",`Route[] = [

`+c(ue,r),"")},Pt=async(e,t)=>{e=p(e);let{prefix:o,name:r}=await g(),i=oe(t,`${e}.directive.ts`),n=oe(t,"../app","app.routes.ts"),s={name:e,project:r,prefix:o};await m(i),await u(n,c(de,s),""),await u(n,c(ge,s),"")};import{resolve as re}from"node:path";var Ae=async(e,t)=>{e=p(e);let{prefix:o}=await g(),r={name:e,prefix:o},i=re(t,`${e}.pipe.ts`),n=re(t,"index.ts");await m(i),await u(n,`
`+c(ye,r),"")},kt=async(e,t)=>{e=p(e);let{prefix:o,name:r}=await g(),i=re(t,`${e}.pipe.ts`),n=re(t,"../app","app.routes.ts"),s={name:e,project:r,prefix:o};await m(i),await u(n,c(we,s),""),await u(n,c(ve,s),"")};import{resolve as To}from"node:path";var Mt=async(e,t)=>{e=p(e);let o=To(t,`${e}.mdx`);await m(o)};import{resolve as Io}from"node:path";var Dt=async(e,t)=>{e=p(e);let o=Io(t,`${e}.service.ts`);await m(o)};var Tt=async(e,t,o)=>{if(!await Q()){let n="\u5F53\u524D\u9879\u76EE\u4E0D\u662F x \u9879\u76EE";throw a.warn(n),new Error(n)}let r=!o&&["component","directive","pipe"].includes(e),i=B(process.cwd(),o??"");await So[e](t,i,r)},So={component:async(e,t,o)=>{await j(o,async(r,i)=>{await Ce(e,B(`${r}/src/lib/components`),{needExport:!0}),await bt(e,B(`${i}/src/components`))},async()=>{await Ce(e,t,{needExport:!1})})},directive:async(e,t,o)=>{await j(o,async(r,i)=>{await he(e,B(`${r}/src/lib/directives`)),await Pt(e,B(`${i}/src/directives`))},async()=>{await he(e,t)})},pipe:async(e,t,o)=>{await j(o,async(r,i)=>{await Ae(e,B(`${r}/src/lib/pipes`)),await kt(e,B(`${i}/src/pipes`))},async()=>{await Ae(e,t)})},service:async(e,t)=>{await Dt(e,t)},doc:async(e,t)=>{await Mt(e,t)}};import{resolve as jo}from"node:path";var Bo="1.0.4-alpha-0";P.version(Bo).description("A cli for any create standard project.").allowUnknownOption().on("command:*",e=>{a.error(`Invalid command: ${e}`),process.exit(1)}).on("--help",()=>{console.log(Se),process.exit(0)});P.command("init").description("Initialize cli dependencies").action(()=>{a.info("Initializing cli dependencies"),Re().then(()=>{a.info("Initialized cli dependencies"),process.exit(0)}).catch(()=>process.exit(1))});P.command("new <projectName>").description("Initialize a new project").action(e=>{a.info(`Initializing new project: ${e}`),xt(e).then(()=>{a.info(`Initialized new project: ${e}.`),process.exit(0)}).catch(()=>process.exit(1))});P.command("create <type> <name>").option("-d,--directory [directory]","Specify a directory").option("-b,--bind [bind]","Create with binding.").description("Create a new component, directive, pipe, service, or documentation").action((e,t,{directory:o,bind:r})=>{a.info(`Creating ${e} named ${t}.`,o?`[ Specified directory at ${o}.]`:""),Et(e,t,o,r).then(()=>{a.info(`Created ${e} named ${t}.`),process.exit(0)}).catch(()=>{process.exit(1)})});P.command("remove <type> <name>").option("-d,--directory [directory]","Specify a directory").description("Remove an existing component, directive, pipe, service, or documentation").action((e,t,{directory:o})=>{a.info(`Removing ${e} named ${t}.`,o?`[ Specified directory at ${o}.]`:""),Tt(e,t,o).then(()=>{a.info(`Removed ${e} named ${t}.`),process.exit(0)}).catch(()=>{process.exit(1)})});P.command("plugin <install|uninstall|list> [pluginName]").description("Manage plugins by adding, removing, or listing them").action((e,t)=>{rt(e,t).then(()=>{a.info(`The ${t??"plugins"} has been ${e}ed.`),process.exit(0)}).catch(()=>process.exit(1))});P.command("update").description("Update x-cli to lts.").action(()=>{a.info("Updating..."),it().then(()=>{a.info("Updated."),process.exit(0)}).catch(()=>{process.exit(1)})});P.command("doc").description("Display the documentation.").action(()=>{a.off(),K(jo(I,"readme.md")).then(e=>{a.on(),console.info(e),process.exit(0)}).catch(()=>process.exit(1))});P.parse(process.argv);
`+c(ye,r),"")},kt=async(e,t)=>{e=p(e);let{prefix:o,name:r}=await g(),i=re(t,`${e}.pipe.ts`),n=re(t,"../app","app.routes.ts"),s={name:e,project:r,prefix:o};await m(i),await u(n,c(we,s),""),await u(n,c(ve,s),"")};import{resolve as To}from"node:path";var Mt=async(e,t)=>{e=p(e);let o=To(t,`${e}.mdx`);await m(o)};import{resolve as Io}from"node:path";var Dt=async(e,t)=>{e=p(e);let o=Io(t,`${e}.service.ts`);await m(o)};var Tt=async(e,t,o)=>{if(!await Q()){let n="\u5F53\u524D\u9879\u76EE\u4E0D\u662F x \u9879\u76EE";throw a.warn(n),new Error(n)}let r=!o&&["component","directive","pipe"].includes(e),i=B(process.cwd(),o??"");await So[e](t,i,r)},So={component:async(e,t,o)=>{await j(o,async(r,i)=>{await Ce(e,B(`${r}/src/lib/components`),{needExport:!0}),await bt(e,B(`${i}/src/components`))},async()=>{await Ce(e,t,{needExport:!1})})},directive:async(e,t,o)=>{await j(o,async(r,i)=>{await he(e,B(`${r}/src/lib/directives`)),await Pt(e,B(`${i}/src/directives`))},async()=>{await he(e,t)})},pipe:async(e,t,o)=>{await j(o,async(r,i)=>{await Ae(e,B(`${r}/src/lib/pipes`)),await kt(e,B(`${i}/src/pipes`))},async()=>{await Ae(e,t)})},service:async(e,t)=>{await Dt(e,t)},doc:async(e,t)=>{await Mt(e,t)}};import{resolve as jo}from"node:path";var Bo="1.0.4-alpha-1";P.version(Bo).description("A cli for any create standard project.").allowUnknownOption().on("command:*",e=>{a.error(`Invalid command: ${e}`),process.exit(1)}).on("--help",()=>{console.log(Se),process.exit(0)});P.command("init").description("Initialize cli dependencies").action(()=>{a.info("Initializing cli dependencies"),Re().then(()=>{a.info("Initialized cli dependencies"),process.exit(0)}).catch(()=>process.exit(1))});P.command("new <projectName>").description("Initialize a new project").action(e=>{a.info(`Initializing new project: ${e}`),xt(e).then(()=>{a.info(`Initialized new project: ${e}.`),process.exit(0)}).catch(()=>process.exit(1))});P.command("create <type> <name>").option("-d,--directory [directory]","Specify a directory").option("-b,--bind [bind]","Create with binding.").description("Create a new component, directive, pipe, service, or documentation").action((e,t,{directory:o,bind:r})=>{a.info(`Creating ${e} named ${t}.`,o?`[ Specified directory at ${o}.]`:""),Et(e,t,o,r).then(()=>{a.info(`Created ${e} named ${t}.`),process.exit(0)}).catch(()=>{process.exit(1)})});P.command("remove <type> <name>").option("-d,--directory [directory]","Specify a directory").description("Remove an existing component, directive, pipe, service, or documentation").action((e,t,{directory:o})=>{a.info(`Removing ${e} named ${t}.`,o?`[ Specified directory at ${o}.]`:""),Tt(e,t,o).then(()=>{a.info(`Removed ${e} named ${t}.`),process.exit(0)}).catch(()=>{process.exit(1)})});P.command("plugin <install|uninstall|list> [pluginName]").description("Manage plugins by adding, removing, or listing them").action((e,t)=>{rt(e,t).then(()=>{a.info(`The ${t??"plugins"} has been ${e}ed.`),process.exit(0)}).catch(()=>process.exit(1))});P.command("update").description("Update x-cli to lts.").action(()=>{a.info("Updating..."),it().then(()=>{a.info("Updated."),process.exit(0)}).catch(()=>{process.exit(1)})});P.command("doc").description("Display the documentation.").action(()=>{a.off(),K(jo(I,"readme.md")).then(e=>{a.on(),console.info(e),process.exit(0)}).catch(()=>process.exit(1))});P.parse(process.argv);
#!/usr/bin/env node
import{program as X}from"commander";var l=e=>e?Array.isArray(e)?e.join(" "):e:"";import{exec as q,spawn as J}from"child_process";import g from"chalk";var y=()=>import.meta.url?.endsWith("env.js")?"dev":"prod";var f=(...e)=>{let r=0;return e.reduce((t,[n,a])=>{let o=typeof a=="number"?r=a&&r++:a??r++;return t[n]=o,t[o]=n,t},{})};var x=class{_TypeBg=f(["info","bgBlue"],["warn","bgYellow"],["error","bgRedBright"]);_logo=r=>g.bgBlueBright(g.whiteBright(" X-CLI "))+g[this._TypeBg[r]](` ${r.toUpperCase()} `);isOn=!0;constructor(r){}on(){this.isOn=!0}off(){this.isOn=!1}get forbidden(){return!this.isOn}info(...r){this.forbidden||console.log(this._logo("info"),...r)}warn(...r){this.forbidden||console.log(this._logo("warn"),...r)}error(...r){this.forbidden||console.log(this._logo("error"),...r)}},s=new x(y());import V from"ora";var w=e=>{let r=V(e),t=setTimeout(()=>{r.start()},1500);return{stop:()=>{clearTimeout(t),r.stop()},text:n=>{r.text=n},succeed:n=>{clearTimeout(t),r.succeed(` ${n}`)},fail:n=>{clearTimeout(t),r.fail(` ${n}`)},warn:n=>{clearTimeout(t),r.warn(` ${n}`)},info:n=>{clearTimeout(t),r.info(` ${n}`)}}};var c=e=>{if(!e)return Promise.reject("Not a standard command.");s.info(e);let r=w(e);return new Promise(t=>{q(e,(n,a,o)=>{n&&t(!1),t(a)})}).finally(()=>r.stop())},m=e=>e?(s.info(e),new Promise((r,t)=>{let[n,...a]=e.split(/\s+/).filter(i=>i);J(n,a,{stdio:"inherit",shell:!0}).on("close",i=>{i===0?r(!0):t(i)})})):Promise.reject("Not a standard command.");var $=(e,r=!1,t=!1,n={})=>{let a="pnpm",o="add";r?o="add --save-dev":t&&(o="add --global"),e||(o="install");let i=`${a} ${o} ${l(e)} ${Object.entries(n).map(([p,H])=>`--${p}=${H}`).join(" ")}`;return c(i)},h=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"pnpm remove -g":"pnpm remove"} ${l(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return c(a)},j=(e,r={})=>{let t=`pnpm ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},v=e=>m(`pnpx -y ${e}`);var u=(e,r=!1,t=!1,n={})=>{let a="npm",o="install";r?o="install --save-dev":t?(a="npm",o="install -g"):a="npm";let i=`${a} ${o} ${l(e)} ${Object.keys(n).map(p=>`--${p}=${n[p]}`).join(" ")}`;return c(i)},b=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"npm uninstall -g":"npm uninstall"} ${l(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return c(a)},k=(e,r={})=>{let t=`npm run ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},d=async(e,r=!1)=>{let t=`npm list ${l(e)} ${r?"-g":""} --depth=0`;s.off();let n=await c(`${t} | grep ${e}`);return s.on(),typeof n=="boolean"?n:n.toString()?.trim()?.includes(e)},C=e=>m(`npx -y ${e} `);var I=(e,r=!1,t=!1,n={})=>{let a="yarn",o="add";r?o="add --dev":t?(a="yarn global",o="add"):a="yarn",e||(o="");let i=`${a} ${o} ${l(e)} ${Object.keys(n).map(p=>`--${p}=${n[p]}`).join(" ")}`;return c(i)},N=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"yarn global remove":"yarn remove"} ${l(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return c(a)},L=(e,r={})=>{let t=`yarn run ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},T=e=>m(`yarn create -y ${e}`);import{dirname as Y,sep as O}from"path";import{readdir as W}from"node:fs/promises";var M=async()=>{let e=process.cwd();try{for(;e!==O&&!(await W(e)).includes(".xrc");)e=Y(e);return e===O&&new Error("Not in a x project."),e}catch(r){throw s.error(r),r}};import{mkdir as Re,writeFile as Ae,readFile as z,appendFile as Pe}from"node:fs/promises";var S=async e=>(s.info(`loading file:${e}`),await z(e,"utf-8"));var F=async e=>{if(!e)return s.warn("\u8BF7\u8F93\u5165\u6587\u4EF6\u540D"),null;let r=await S(e);return JSON.parse(r)};import{resolve as K}from"node:path";var _=async()=>{try{let e=await M();return await F(K(e,".xrc"))}catch{return{}}};import{readdir as Q}from"node:fs/promises";import{resolve as Z}from"node:path";var B="npm",R=["package-lock.json","pnpm-lock.yaml","yarn.lock"],A=f(["npm","package-lock.json"],["pnpm","pnpm-lock.yaml"],["yarn","yarn.lock"]);var P=e=>{switch(e){case"pnpm":return{has:d,install:$,uninstall:h,run:j,npx:v};case"yarn":return{has:d,install:I,uninstall:N,run:L,npx:T};case"npm":default:return{has:d,install:u,uninstall:b,run:k,npx:C}}},G=async()=>{try{let e=await _(),{packageManager:r}=e;return r}catch{return}},ee=async()=>{let r=(await Q(Z("."))).filter(t=>R.includes(t));if(r.length>1)throw new Error("There are multiple lock files in the project, please remove one of them");{let[t="package-lock.json"]=r;return A[t]}},D=async()=>{let e=await G();return e||await ee()};var U=async e=>{let r;try{s.off(),r=await D(),s.on()}catch{r=B}finally{await e?.(P(r))}};var E=async(e,r,t)=>{await U(async({has:n,install:a})=>{e?await a(e,r,t):await a()})};var re="1.0.4-alpha-0";X.version(re).arguments("[packageName]").option("-D,--save-dev","Save as development dependency").option("-g,--global","Save as global dependency").description("Install or uninstall a dependency in the project.").action((e,{saveDev:r,global:t})=>{E(e,r,t).then(()=>{s.info(`The ${e??"packages"} has been installed successfully.`),process.exit(0)}).catch(()=>process.exit(1))});X.parse(process.argv);
import{program as X}from"commander";var l=e=>e?Array.isArray(e)?e.join(" "):e:"";import{exec as q,spawn as J}from"child_process";import g from"chalk";var y=()=>import.meta.url?.endsWith("env.js")?"dev":"prod";var f=(...e)=>{let r=0;return e.reduce((t,[n,a])=>{let o=typeof a=="number"?r=a&&r++:a??r++;return t[n]=o,t[o]=n,t},{})};var x=class{_TypeBg=f(["info","bgBlue"],["warn","bgYellow"],["error","bgRedBright"]);_logo=r=>g.bgBlueBright(g.whiteBright(" X-CLI "))+g[this._TypeBg[r]](` ${r.toUpperCase()} `);isOn=!0;constructor(r){}on(){this.isOn=!0}off(){this.isOn=!1}get forbidden(){return!this.isOn}info(...r){this.forbidden||console.log(this._logo("info"),...r)}warn(...r){this.forbidden||console.log(this._logo("warn"),...r)}error(...r){this.forbidden||console.log(this._logo("error"),...r)}},s=new x(y());import V from"ora";var w=e=>{let r=V(e),t=setTimeout(()=>{r.start()},1500);return{stop:()=>{clearTimeout(t),r.stop()},text:n=>{r.text=n},succeed:n=>{clearTimeout(t),r.succeed(` ${n}`)},fail:n=>{clearTimeout(t),r.fail(` ${n}`)},warn:n=>{clearTimeout(t),r.warn(` ${n}`)},info:n=>{clearTimeout(t),r.info(` ${n}`)}}};var c=e=>{if(!e)return Promise.reject("Not a standard command.");s.info(e);let r=w(e);return new Promise(t=>{q(e,(n,a,o)=>{n&&t(!1),t(a)})}).finally(()=>r.stop())},m=e=>e?(s.info(e),new Promise((r,t)=>{let[n,...a]=e.split(/\s+/).filter(i=>i);J(n,a,{stdio:"inherit",shell:!0}).on("close",i=>{i===0?r(!0):t(i)})})):Promise.reject("Not a standard command.");var $=(e,r=!1,t=!1,n={})=>{let a="pnpm",o="add";r?o="add --save-dev":t&&(o="add --global"),e||(o="install");let i=`${a} ${o} ${l(e)} ${Object.entries(n).map(([p,H])=>`--${p}=${H}`).join(" ")}`;return c(i)},h=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"pnpm remove -g":"pnpm remove"} ${l(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return c(a)},j=(e,r={})=>{let t=`pnpm ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},v=e=>m(`pnpx -y ${e}`);var u=(e,r=!1,t=!1,n={})=>{let a="npm",o="install";r?o="install --save-dev":t?(a="npm",o="install -g"):a="npm";let i=`${a} ${o} ${l(e)} ${Object.keys(n).map(p=>`--${p}=${n[p]}`).join(" ")}`;return c(i)},b=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"npm uninstall -g":"npm uninstall"} ${l(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return c(a)},k=(e,r={})=>{let t=`npm run ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},d=async(e,r=!1)=>{let t=`npm list ${l(e)} ${r?"-g":""} --depth=0`;s.off();let n=await c(`${t} | grep ${e}`);return s.on(),typeof n=="boolean"?n:n.toString()?.trim()?.includes(e)},C=e=>m(`npx -y ${e} `);var I=(e,r=!1,t=!1,n={})=>{let a="yarn",o="add";r?o="add --dev":t?(a="yarn global",o="add"):a="yarn",e||(o="");let i=`${a} ${o} ${l(e)} ${Object.keys(n).map(p=>`--${p}=${n[p]}`).join(" ")}`;return c(i)},N=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"yarn global remove":"yarn remove"} ${l(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return c(a)},L=(e,r={})=>{let t=`yarn run ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},O=e=>m(`yarn create -y ${e}`);import{dirname as Y,sep as T}from"path";import{readdir as W}from"node:fs/promises";var M=async()=>{let e=process.cwd();try{for(;e!==T&&!(await W(e)).includes(".xrc");)e=Y(e);return e===T&&new Error("Not in a x project."),e}catch(r){throw s.error(r),r}};import{mkdir as Re,writeFile as Ae,readFile as z,appendFile as Pe}from"node:fs/promises";var S=async e=>(s.info(`loading file:${e}`),await z(e,"utf-8"));var F=async e=>{if(!e)return s.warn("\u8BF7\u8F93\u5165\u6587\u4EF6\u540D"),null;let r=await S(e);return JSON.parse(r)};import{resolve as K}from"node:path";var _=async()=>{try{let e=await M();return await F(K(e,".xrc"))}catch{return{}}};import{readdir as Q}from"node:fs/promises";import{resolve as Z}from"node:path";var B="npm",R=["package-lock.json","pnpm-lock.yaml","yarn.lock"],A=f(["npm","package-lock.json"],["pnpm","pnpm-lock.yaml"],["yarn","yarn.lock"]);var P=e=>{switch(e){case"pnpm":return{has:d,install:$,uninstall:h,run:j,npx:v};case"yarn":return{has:d,install:I,uninstall:N,run:L,npx:O};case"npm":default:return{has:d,install:u,uninstall:b,run:k,npx:C}}},G=async()=>{try{let e=await _(),{packageManager:r}=e;return r}catch{return}},ee=async()=>{let r=(await Q(Z("."))).filter(t=>R.includes(t));if(r.length>1)throw new Error("There are multiple lock files in the project, please remove one of them");{let[t="package-lock.json"]=r;return A[t]}},D=async()=>{let e=await G();return e||await ee()};var U=async e=>{let r;try{s.off(),r=await D(),s.on()}catch{r=B}finally{await e?.(P(r))}};var E=async(e,r,t)=>{await U(async({has:n,install:a})=>{e?await a(e,r,t):await a()})};var re="1.0.4-alpha-1";X.version(re).arguments("[packageName]").option("-D,--save-dev","Save as development dependency").option("-g,--global","Save as global dependency").description("Install or uninstall a dependency in the project.").allowUnknownOption(!0).action((e,{saveDev:r,global:t})=>{E(e,r,t).then(()=>{s.info(`The ${e??"packages"} has been installed successfully.`),process.exit(0)}).catch(()=>process.exit(1))});X.parse(process.argv);
#!/usr/bin/env node
import{program as y}from"commander";import g from"chalk";var w=()=>import.meta.url?.endsWith("env.js")?"dev":"prod";var f=(...e)=>{let r=0;return e.reduce((t,[n,a])=>{let o=typeof a=="number"?r=a&&r++:a??r++;return t[n]=o,t[o]=n,t},{})};var x=class{_TypeBg=f(["info","bgBlue"],["warn","bgYellow"],["error","bgRedBright"]);_logo=r=>g.bgBlueBright(g.whiteBright(" X-CLI "))+g[this._TypeBg[r]](` ${r.toUpperCase()} `);isOn=!0;constructor(r){}on(){this.isOn=!0}off(){this.isOn=!1}get forbidden(){return!this.isOn}info(...r){this.forbidden||console.log(this._logo("info"),...r)}warn(...r){this.forbidden||console.log(this._logo("warn"),...r)}error(...r){this.forbidden||console.log(this._logo("error"),...r)}},s=new x(w());var c=e=>e?Array.isArray(e)?e.join(" "):e:"";import{exec as q,spawn as J}from"child_process";import V from"ora";var $=e=>{let r=V(e),t=setTimeout(()=>{r.start()},1500);return{stop:()=>{clearTimeout(t),r.stop()},text:n=>{r.text=n},succeed:n=>{clearTimeout(t),r.succeed(` ${n}`)},fail:n=>{clearTimeout(t),r.fail(` ${n}`)},warn:n=>{clearTimeout(t),r.warn(` ${n}`)},info:n=>{clearTimeout(t),r.info(` ${n}`)}}};var l=e=>{if(!e)return Promise.reject("Not a standard command.");s.info(e);let r=$(e);return new Promise(t=>{q(e,(n,a,o)=>{n&&t(!1),t(a)})}).finally(()=>r.stop())},m=e=>e?(s.info(e),new Promise((r,t)=>{let[n,...a]=e.split(/\s+/).filter(i=>i);J(n,a,{stdio:"inherit",shell:!0}).on("close",i=>{i===0?r(!0):t(i)})})):Promise.reject("Not a standard command.");var h=(e,r=!1,t=!1,n={})=>{let a="pnpm",o="add";r?o="add --save-dev":t&&(o="add --global"),e||(o="install");let i=`${a} ${o} ${c(e)} ${Object.entries(n).map(([p,H])=>`--${p}=${H}`).join(" ")}`;return l(i)},j=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"pnpm remove -g":"pnpm remove"} ${c(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return l(a)},b=(e,r={})=>{let t=`pnpm ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},v=e=>m(`pnpx -y ${e}`);var u=(e,r=!1,t=!1,n={})=>{let a="npm",o="install";r?o="install --save-dev":t?(a="npm",o="install -g"):a="npm";let i=`${a} ${o} ${c(e)} ${Object.keys(n).map(p=>`--${p}=${n[p]}`).join(" ")}`;return l(i)},k=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"npm uninstall -g":"npm uninstall"} ${c(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return l(a)},C=(e,r={})=>{let t=`npm run ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},d=async(e,r=!1)=>{let t=`npm list ${c(e)} ${r?"-g":""} --depth=0`;s.off();let n=await l(`${t} | grep ${e}`);return s.on(),typeof n=="boolean"?n:n.toString()?.trim()?.includes(e)},N=e=>m(`npx -y ${e} `);var I=(e,r=!1,t=!1,n={})=>{let a="yarn",o="add";r?o="add --dev":t?(a="yarn global",o="add"):a="yarn",e||(o="");let i=`${a} ${o} ${c(e)} ${Object.keys(n).map(p=>`--${p}=${n[p]}`).join(" ")}`;return l(i)},O=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"yarn global remove":"yarn remove"} ${c(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return l(a)},T=(e,r={})=>{let t=`yarn run ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},L=e=>m(`yarn create -y ${e}`);import{dirname as Y,sep as M}from"path";import{readdir as W}from"node:fs/promises";var F=async()=>{let e=process.cwd();try{for(;e!==M&&!(await W(e)).includes(".xrc");)e=Y(e);return e===M&&new Error("Not in a x project."),e}catch(r){throw s.error(r),r}};import{mkdir as Be,writeFile as Pe,readFile as z,appendFile as Ae}from"node:fs/promises";var R=async e=>(s.info(`loading file:${e}`),await z(e,"utf-8"));var S=async e=>{if(!e)return s.warn("\u8BF7\u8F93\u5165\u6587\u4EF6\u540D"),null;let r=await R(e);return JSON.parse(r)};import{resolve as K}from"node:path";var _=async()=>{try{let e=await F();return await S(K(e,".xrc"))}catch{return{}}};import{readdir as Q}from"node:fs/promises";import{resolve as Z}from"node:path";var B="npm",P=["package-lock.json","pnpm-lock.yaml","yarn.lock"],A=f(["npm","package-lock.json"],["pnpm","pnpm-lock.yaml"],["yarn","yarn.lock"]);var U=e=>{switch(e){case"pnpm":return{has:d,install:h,uninstall:j,run:b,npx:v};case"yarn":return{has:d,install:I,uninstall:O,run:T,npx:L};case"npm":default:return{has:d,install:u,uninstall:k,run:C,npx:N}}},G=async()=>{try{let e=await _(),{packageManager:r}=e;return r}catch{return}},ee=async()=>{let r=(await Q(Z("."))).filter(t=>P.includes(t));if(r.length>1)throw new Error("There are multiple lock files in the project, please remove one of them");{let[t="package-lock.json"]=r;return A[t]}},D=async()=>{let e=await G();return e||await ee()};var E=async e=>{let r;try{s.off(),r=await D(),s.on()}catch{r=B}finally{await e?.(U(r))}};var X=async e=>{if(!e){let r="[X] Please enter the script name.";throw s.warn(r),new Error(r)}await E(async({run:r})=>{await r(e)})};var re="1.0.4-alpha-0";y.version(re).arguments("[script]").allowUnknownOption(!0).description("Run the specified script by correctly.").action(e=>{s.info(`The script ${e} is running...`);let r=y.args.slice(1).join(" "),t=`${e} ${r}`;X(t).then(()=>{s.info(`The ${e} has been executed successfully.`),process.exit(0)}).catch(()=>{process.exit(1)})});y.parse(process.argv);
import{program as y}from"commander";import g from"chalk";var w=()=>import.meta.url?.endsWith("env.js")?"dev":"prod";var f=(...e)=>{let r=0;return e.reduce((t,[n,a])=>{let o=typeof a=="number"?r=a&&r++:a??r++;return t[n]=o,t[o]=n,t},{})};var x=class{_TypeBg=f(["info","bgBlue"],["warn","bgYellow"],["error","bgRedBright"]);_logo=r=>g.bgBlueBright(g.whiteBright(" X-CLI "))+g[this._TypeBg[r]](` ${r.toUpperCase()} `);isOn=!0;constructor(r){}on(){this.isOn=!0}off(){this.isOn=!1}get forbidden(){return!this.isOn}info(...r){this.forbidden||console.log(this._logo("info"),...r)}warn(...r){this.forbidden||console.log(this._logo("warn"),...r)}error(...r){this.forbidden||console.log(this._logo("error"),...r)}},s=new x(w());var c=e=>e?Array.isArray(e)?e.join(" "):e:"";import{exec as q,spawn as J}from"child_process";import V from"ora";var $=e=>{let r=V(e),t=setTimeout(()=>{r.start()},1500);return{stop:()=>{clearTimeout(t),r.stop()},text:n=>{r.text=n},succeed:n=>{clearTimeout(t),r.succeed(` ${n}`)},fail:n=>{clearTimeout(t),r.fail(` ${n}`)},warn:n=>{clearTimeout(t),r.warn(` ${n}`)},info:n=>{clearTimeout(t),r.info(` ${n}`)}}};var l=e=>{if(!e)return Promise.reject("Not a standard command.");s.info(e);let r=$(e);return new Promise(t=>{q(e,(n,a,o)=>{n&&t(!1),t(a)})}).finally(()=>r.stop())},m=e=>e?(s.info(e),new Promise((r,t)=>{let[n,...a]=e.split(/\s+/).filter(i=>i);J(n,a,{stdio:"inherit",shell:!0}).on("close",i=>{i===0?r(!0):t(i)})})):Promise.reject("Not a standard command.");var h=(e,r=!1,t=!1,n={})=>{let a="pnpm",o="add";r?o="add --save-dev":t&&(o="add --global"),e||(o="install");let i=`${a} ${o} ${c(e)} ${Object.entries(n).map(([p,H])=>`--${p}=${H}`).join(" ")}`;return l(i)},j=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"pnpm remove -g":"pnpm remove"} ${c(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return l(a)},b=(e,r={})=>{let t=`pnpm ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},v=e=>m(`pnpx -y ${e}`);var u=(e,r=!1,t=!1,n={})=>{let a="npm",o="install";r?o="install --save-dev":t?(a="npm",o="install -g"):a="npm";let i=`${a} ${o} ${c(e)} ${Object.keys(n).map(p=>`--${p}=${n[p]}`).join(" ")}`;return l(i)},k=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"npm uninstall -g":"npm uninstall"} ${c(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return l(a)},C=(e,r={})=>{let t=`npm run ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},d=async(e,r=!1)=>{let t=`npm list ${c(e)} ${r?"-g":""} --depth=0`;s.off();let n=await l(`${t} | grep ${e}`);return s.on(),typeof n=="boolean"?n:n.toString()?.trim()?.includes(e)},N=e=>m(`npx -y ${e} `);var I=(e,r=!1,t=!1,n={})=>{let a="yarn",o="add";r?o="add --dev":t?(a="yarn global",o="add"):a="yarn",e||(o="");let i=`${a} ${o} ${c(e)} ${Object.keys(n).map(p=>`--${p}=${n[p]}`).join(" ")}`;return l(i)},O=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"yarn global remove":"yarn remove"} ${c(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return l(a)},T=(e,r={})=>{let t=`yarn run ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},L=e=>m(`yarn create -y ${e}`);import{dirname as Y,sep as M}from"path";import{readdir as W}from"node:fs/promises";var F=async()=>{let e=process.cwd();try{for(;e!==M&&!(await W(e)).includes(".xrc");)e=Y(e);return e===M&&new Error("Not in a x project."),e}catch(r){throw s.error(r),r}};import{mkdir as Be,writeFile as Pe,readFile as z,appendFile as Ae}from"node:fs/promises";var R=async e=>(s.info(`loading file:${e}`),await z(e,"utf-8"));var S=async e=>{if(!e)return s.warn("\u8BF7\u8F93\u5165\u6587\u4EF6\u540D"),null;let r=await R(e);return JSON.parse(r)};import{resolve as K}from"node:path";var _=async()=>{try{let e=await F();return await S(K(e,".xrc"))}catch{return{}}};import{readdir as Q}from"node:fs/promises";import{resolve as Z}from"node:path";var B="npm",P=["package-lock.json","pnpm-lock.yaml","yarn.lock"],A=f(["npm","package-lock.json"],["pnpm","pnpm-lock.yaml"],["yarn","yarn.lock"]);var U=e=>{switch(e){case"pnpm":return{has:d,install:h,uninstall:j,run:b,npx:v};case"yarn":return{has:d,install:I,uninstall:O,run:T,npx:L};case"npm":default:return{has:d,install:u,uninstall:k,run:C,npx:N}}},G=async()=>{try{let e=await _(),{packageManager:r}=e;return r}catch{return}},ee=async()=>{let r=(await Q(Z("."))).filter(t=>P.includes(t));if(r.length>1)throw new Error("There are multiple lock files in the project, please remove one of them");{let[t="package-lock.json"]=r;return A[t]}},D=async()=>{let e=await G();return e||await ee()};var E=async e=>{let r;try{s.off(),r=await D(),s.on()}catch{r=B}finally{await e?.(U(r))}};var X=async e=>{if(!e){let r="[X] Please enter the script name.";throw s.warn(r),new Error(r)}await E(async({run:r})=>{await r(e)})};var re="1.0.4-alpha-1";y.version(re).arguments("[script]").allowUnknownOption(!0).description("Run the specified script by correctly.").action(e=>{s.info(`The script ${e} is running...`);let r=y.args.slice(1).join(" "),t=`${e} ${r}`;X(t).then(()=>{s.info(`The ${e} has been executed successfully.`),process.exit(0)}).catch(()=>{process.exit(1)})});y.parse(process.argv);
#!/usr/bin/env node
import{program as X}from"commander";var l=e=>e?Array.isArray(e)?e.join(" "):e:"";import{exec as V,spawn as J}from"child_process";import g from"chalk";var y=()=>import.meta.url?.endsWith("env.js")?"dev":"prod";var f=(...e)=>{let r=0;return e.reduce((t,[n,a])=>{let o=typeof a=="number"?r=a&&r++:a??r++;return t[n]=o,t[o]=n,t},{})};var x=class{_TypeBg=f(["info","bgBlue"],["warn","bgYellow"],["error","bgRedBright"]);_logo=r=>g.bgBlueBright(g.whiteBright(" X-CLI "))+g[this._TypeBg[r]](` ${r.toUpperCase()} `);isOn=!0;constructor(r){}on(){this.isOn=!0}off(){this.isOn=!1}get forbidden(){return!this.isOn}info(...r){this.forbidden||console.log(this._logo("info"),...r)}warn(...r){this.forbidden||console.log(this._logo("warn"),...r)}error(...r){this.forbidden||console.log(this._logo("error"),...r)}},s=new x(y());import H from"ora";var w=e=>{let r=H(e),t=setTimeout(()=>{r.start()},1500);return{stop:()=>{clearTimeout(t),r.stop()},text:n=>{r.text=n},succeed:n=>{clearTimeout(t),r.succeed(` ${n}`)},fail:n=>{clearTimeout(t),r.fail(` ${n}`)},warn:n=>{clearTimeout(t),r.warn(` ${n}`)},info:n=>{clearTimeout(t),r.info(` ${n}`)}}};var c=e=>{if(!e)return Promise.reject("Not a standard command.");s.info(e);let r=w(e);return new Promise(t=>{V(e,(n,a,o)=>{n&&t(!1),t(a)})}).finally(()=>r.stop())},m=e=>e?(s.info(e),new Promise((r,t)=>{let[n,...a]=e.split(/\s+/).filter(i=>i);J(n,a,{stdio:"inherit",shell:!0}).on("close",i=>{i===0?r(!0):t(i)})})):Promise.reject("Not a standard command.");var $=(e,r=!1,t=!1,n={})=>{let a="pnpm",o="add";r?o="add --save-dev":t&&(o="add --global"),e||(o="install");let i=`${a} ${o} ${l(e)} ${Object.entries(n).map(([p,q])=>`--${p}=${q}`).join(" ")}`;return c(i)},h=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"pnpm remove -g":"pnpm remove"} ${l(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return c(a)},j=(e,r={})=>{let t=`pnpm ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},b=e=>m(`pnpx -y ${e}`);var u=(e,r=!1,t=!1,n={})=>{let a="npm",o="install";r?o="install --save-dev":t?(a="npm",o="install -g"):a="npm";let i=`${a} ${o} ${l(e)} ${Object.keys(n).map(p=>`--${p}=${n[p]}`).join(" ")}`;return c(i)},v=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"npm uninstall -g":"npm uninstall"} ${l(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return c(a)},k=(e,r={})=>{let t=`npm run ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},d=async(e,r=!1)=>{let t=`npm list ${l(e)} ${r?"-g":""} --depth=0`;s.off();let n=await c(`${t} | grep ${e}`);return s.on(),typeof n=="boolean"?n:n.toString()?.trim()?.includes(e)},C=e=>m(`npx -y ${e} `);var I=(e,r=!1,t=!1,n={})=>{let a="yarn",o="add";r?o="add --dev":t?(a="yarn global",o="add"):a="yarn",e||(o="");let i=`${a} ${o} ${l(e)} ${Object.keys(n).map(p=>`--${p}=${n[p]}`).join(" ")}`;return c(i)},N=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"yarn global remove":"yarn remove"} ${l(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return c(a)},L=(e,r={})=>{let t=`yarn run ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},T=e=>m(`yarn create -y ${e}`);import{dirname as Y,sep as O}from"path";import{readdir as W}from"node:fs/promises";var M=async()=>{let e=process.cwd();try{for(;e!==O&&!(await W(e)).includes(".xrc");)e=Y(e);return e===O&&new Error("Not in a x project."),e}catch(r){throw s.error(r),r}};import{mkdir as Be,writeFile as Ae,readFile as z,appendFile as Pe}from"node:fs/promises";var F=async e=>(s.info(`loading file:${e}`),await z(e,"utf-8"));var R=async e=>{if(!e)return s.warn("\u8BF7\u8F93\u5165\u6587\u4EF6\u540D"),null;let r=await F(e);return JSON.parse(r)};import{resolve as K}from"node:path";var S=async()=>{try{let e=await M();return await R(K(e,".xrc"))}catch{return{}}};import{readdir as Q}from"node:fs/promises";import{resolve as Z}from"node:path";var _="npm",B=["package-lock.json","pnpm-lock.yaml","yarn.lock"],A=f(["npm","package-lock.json"],["pnpm","pnpm-lock.yaml"],["yarn","yarn.lock"]);var P=e=>{switch(e){case"pnpm":return{has:d,install:$,uninstall:h,run:j,npx:b};case"yarn":return{has:d,install:I,uninstall:N,run:L,npx:T};case"npm":default:return{has:d,install:u,uninstall:v,run:k,npx:C}}},G=async()=>{try{let e=await S(),{packageManager:r}=e;return r}catch{return}},ee=async()=>{let r=(await Q(Z("."))).filter(t=>B.includes(t));if(r.length>1)throw new Error("There are multiple lock files in the project, please remove one of them");{let[t="package-lock.json"]=r;return A[t]}},U=async()=>{let e=await G();return e||await ee()};var D=async e=>{let r;try{s.off(),r=await U(),s.on()}catch{r=_}finally{await e?.(P(r))}};var E=async(e,r)=>{if(!e){let t="Require a packageName.";throw s.warn(t),new Error(t)}await D(async({has:t,uninstall:n})=>{e&&await n(e,r)})};var re="1.0.4-alpha-0";X.version(re).arguments("[packageName]").option("-g,--global","Uninstall the global dependency").description("Uninstall a dependency in the project.").action((e,{global:r})=>{E(e,r).then(()=>{s.info(`The ${e} has been uninstalled successfully.`),process.exit(0)}).catch(()=>process.exit(1))});X.parse(process.argv);
import{program as X}from"commander";var l=e=>e?Array.isArray(e)?e.join(" "):e:"";import{exec as V,spawn as J}from"child_process";import g from"chalk";var y=()=>import.meta.url?.endsWith("env.js")?"dev":"prod";var f=(...e)=>{let r=0;return e.reduce((t,[n,a])=>{let o=typeof a=="number"?r=a&&r++:a??r++;return t[n]=o,t[o]=n,t},{})};var x=class{_TypeBg=f(["info","bgBlue"],["warn","bgYellow"],["error","bgRedBright"]);_logo=r=>g.bgBlueBright(g.whiteBright(" X-CLI "))+g[this._TypeBg[r]](` ${r.toUpperCase()} `);isOn=!0;constructor(r){}on(){this.isOn=!0}off(){this.isOn=!1}get forbidden(){return!this.isOn}info(...r){this.forbidden||console.log(this._logo("info"),...r)}warn(...r){this.forbidden||console.log(this._logo("warn"),...r)}error(...r){this.forbidden||console.log(this._logo("error"),...r)}},s=new x(y());import H from"ora";var w=e=>{let r=H(e),t=setTimeout(()=>{r.start()},1500);return{stop:()=>{clearTimeout(t),r.stop()},text:n=>{r.text=n},succeed:n=>{clearTimeout(t),r.succeed(` ${n}`)},fail:n=>{clearTimeout(t),r.fail(` ${n}`)},warn:n=>{clearTimeout(t),r.warn(` ${n}`)},info:n=>{clearTimeout(t),r.info(` ${n}`)}}};var c=e=>{if(!e)return Promise.reject("Not a standard command.");s.info(e);let r=w(e);return new Promise(t=>{V(e,(n,a,o)=>{n&&t(!1),t(a)})}).finally(()=>r.stop())},m=e=>e?(s.info(e),new Promise((r,t)=>{let[n,...a]=e.split(/\s+/).filter(i=>i);J(n,a,{stdio:"inherit",shell:!0}).on("close",i=>{i===0?r(!0):t(i)})})):Promise.reject("Not a standard command.");var $=(e,r=!1,t=!1,n={})=>{let a="pnpm",o="add";r?o="add --save-dev":t&&(o="add --global"),e||(o="install");let i=`${a} ${o} ${l(e)} ${Object.entries(n).map(([p,q])=>`--${p}=${q}`).join(" ")}`;return c(i)},h=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"pnpm remove -g":"pnpm remove"} ${l(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return c(a)},j=(e,r={})=>{let t=`pnpm ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},b=e=>m(`pnpx -y ${e}`);var u=(e,r=!1,t=!1,n={})=>{let a="npm",o="install";r?o="install --save-dev":t?(a="npm",o="install -g"):a="npm";let i=`${a} ${o} ${l(e)} ${Object.keys(n).map(p=>`--${p}=${n[p]}`).join(" ")}`;return c(i)},v=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"npm uninstall -g":"npm uninstall"} ${l(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return c(a)},k=(e,r={})=>{let t=`npm run ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},d=async(e,r=!1)=>{let t=`npm list ${l(e)} ${r?"-g":""} --depth=0`;s.off();let n=await c(`${t} | grep ${e}`);return s.on(),typeof n=="boolean"?n:n.toString()?.trim()?.includes(e)},C=e=>m(`npx -y ${e} `);var I=(e,r=!1,t=!1,n={})=>{let a="yarn",o="add";r?o="add --dev":t?(a="yarn global",o="add"):a="yarn",e||(o="");let i=`${a} ${o} ${l(e)} ${Object.keys(n).map(p=>`--${p}=${n[p]}`).join(" ")}`;return c(i)},N=(e,r=!1,t={})=>{if(!e)return Promise.reject("packageName is required");let a=`${r?"yarn global remove":"yarn remove"} ${l(e)} ${Object.keys(t).map(o=>`--${o}=${t[o]}`).join(" ")}`;return c(a)},L=(e,r={})=>{let t=`yarn run ${e} ${Object.keys(r).map(n=>`--${n}=${r[n]}`).join(" ")}`;return m(t)},T=e=>m(`yarn create -y ${e}`);import{dirname as Y,sep as O}from"path";import{readdir as W}from"node:fs/promises";var M=async()=>{let e=process.cwd();try{for(;e!==O&&!(await W(e)).includes(".xrc");)e=Y(e);return e===O&&new Error("Not in a x project."),e}catch(r){throw s.error(r),r}};import{mkdir as Be,writeFile as Ae,readFile as z,appendFile as Pe}from"node:fs/promises";var F=async e=>(s.info(`loading file:${e}`),await z(e,"utf-8"));var R=async e=>{if(!e)return s.warn("\u8BF7\u8F93\u5165\u6587\u4EF6\u540D"),null;let r=await F(e);return JSON.parse(r)};import{resolve as K}from"node:path";var S=async()=>{try{let e=await M();return await R(K(e,".xrc"))}catch{return{}}};import{readdir as Q}from"node:fs/promises";import{resolve as Z}from"node:path";var _="npm",B=["package-lock.json","pnpm-lock.yaml","yarn.lock"],A=f(["npm","package-lock.json"],["pnpm","pnpm-lock.yaml"],["yarn","yarn.lock"]);var P=e=>{switch(e){case"pnpm":return{has:d,install:$,uninstall:h,run:j,npx:b};case"yarn":return{has:d,install:I,uninstall:N,run:L,npx:T};case"npm":default:return{has:d,install:u,uninstall:v,run:k,npx:C}}},G=async()=>{try{let e=await S(),{packageManager:r}=e;return r}catch{return}},ee=async()=>{let r=(await Q(Z("."))).filter(t=>B.includes(t));if(r.length>1)throw new Error("There are multiple lock files in the project, please remove one of them");{let[t="package-lock.json"]=r;return A[t]}},U=async()=>{let e=await G();return e||await ee()};var D=async e=>{let r;try{s.off(),r=await U(),s.on()}catch{r=_}finally{await e?.(P(r))}};var E=async(e,r)=>{if(!e){let t="Require a packageName.";throw s.warn(t),new Error(t)}await D(async({has:t,uninstall:n})=>{e&&await n(e,r)})};var re="1.0.4-alpha-1";X.version(re).arguments("[packageName]").option("-g,--global","Uninstall the global dependency").description("Uninstall a dependency in the project.").action((e,{global:r})=>{E(e,r).then(()=>{s.info(`The ${e} has been uninstalled successfully.`),process.exit(0)}).catch(()=>process.exit(1))});X.parse(process.argv);

@@ -1,1 +0,1 @@

{"name":"@eternalheart/x-cli","version":"1.0.4-alpha-0","type":"module","description":"A cli for project to create all needed.","bin":{"x":"bin/x.js","xi":"bin/xi.js","xu":"bin/xu.js","xr":"bin/xr.js"},"publishConfig":{"access":"public"},"author":"EternalHeart","license":"ISC","dependencies":{"chalk":"^5.3.0","commander":"^12.0.0","d":"^1.0.2","inquirer":"^9.2.17","ora":"^8.0.1"}}
{"name":"@eternalheart/x-cli","version":"1.0.4-alpha-1","type":"module","description":"A cli for project to create all needed.","bin":{"x":"bin/x.js","xi":"bin/xi.js","xu":"bin/xu.js","xr":"bin/xr.js"},"publishConfig":{"access":"public"},"author":"EternalHeart","license":"ISC","dependencies":{"chalk":"^5.3.0","commander":"^12.0.0","d":"^1.0.2","inquirer":"^9.2.17","ora":"^8.0.1"}}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc