@mxfb/cli 0.0.42 → 0.0.44
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/cli/assets/version.txt +1 -1
- package/cli/index.js +3 -3
- package/make-template/index.js +2 -2
- package/package.json +1 -1
package/cli/assets/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.44
|
package/cli/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
`).map(
|
|
4
|
-
`);console.log(
|
|
2
|
+
import a from"node:process";import{promises as c}from"node:fs";import f from"node:url";import i from"node:path";import{spawn as g}from"node:child_process";import{program as s}from"commander";console.log("i am cli");var u=f.fileURLToPath(import.meta.url),e=i.dirname(u);s.name("@mxfb-cli/cli").description("The home of @mxfb/cli's project");s.command("list").description("list all the available commands").action(h);s.command("version").description("print current version of the package").action(b);s.command("*",{hidden:!0}).allowUnknownOption().action(async(...t)=>{let[,n]=t;console.log(n.args),console.log(a.argv);let[o]=n.args;if(o===void 0)return s.help();if(!(await m()).includes(o))return s.help();let l=a.argv.slice(2).slice(1),p=i.join(e,"../",o,"index.js");g(p,l,{stdio:"inherit"}).on("error",d=>console.error(`Failed to start subprogram '${o}':`,d))});s.parse(a.argv);async function m(){let t=i.join(e,"assets/list.txt");return(await c.readFile(t,{encoding:"utf-8"})).split(`
|
|
3
|
+
`).map(o=>o.trim())}async function h(){let n=(await m()).map(o=>{let r=Object.assign(new Array(24).fill(" "),o.split("")).join("");return o==="cli"?`${r} # npx @mxfb/cli --help`:`${r} # npx @mxfb/cli ${o} --help`}).join(`
|
|
4
|
+
`);console.log(n)}async function b(){let t=i.join(e,"assets/version.txt"),n=await c.readFile(t,{encoding:"utf-8"});console.log(n)}
|
package/make-template/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import s from"node:process";import{promises as h,existsSync as j}from"node:fs";import y from"node:url";import
|
|
3
|
-
`},{encoding:"utf-8"}),await new Promise((
|
|
2
|
+
import s from"node:process";import{promises as h,existsSync as j}from"node:fs";import y from"node:url";import r from"node:path";import{exec as k}from"node:child_process";import{program as l}from"commander";import w from"prompts";import{promises as g}from"node:fs";async function d(e,o,...i){let[m,a]=i,c=await g.readFile(e,m),t=o(c),n=i.length===2?a:m;return await g.writeFile(e,t,n),t}console.log("i am make-template");var x=y.fileURLToPath(import.meta.url),p=r.dirname(x),f=s.cwd();l.name("@mxfb-cli/make-template").description("Generate in cwd a project template");l.command("html").description("make simple html project structure").action(P);l.command("react").description("make react + typescript project structure").action(S);l.parse(s.argv);async function P(){console.log("I make html"),console.log(p);let e=r.join(p,"assets/html");if(console.log(e),!j(e))return console.error(`Could not find the template to copy at ${e}`),s.exit(1);console.log(f);let o=r.join(f,"html-template");console.log(o),await h.cp(e,o,{recursive:!0})}async function S(){let e=r.join(p,"assets/react");if(!j(e))return console.error(`Could not find the template to copy at ${e}`),s.exit(1);let o=r.join(f,"react-template");await h.cp(e,o,{recursive:!0});let{projectName:i}=await w({name:"projectName",message:"Project name ? (for package.json name field)",type:"text"}),m=r.join(o,"package.json");await d(m,a=>{let c=typeof a=="string"?a:a.toString(),t=JSON.parse(c);delete t.name;let n={name:i,...t};return`${JSON.stringify(n,null,2)}
|
|
3
|
+
`},{encoding:"utf-8"}),await new Promise((a,c)=>{k(`cd ${o} && npm i`,(t,n,u)=>t!==null?(console.error(t),c(t)):(n!==""&&console.log(n),u!==""&&console.log(u),a(!0)))})}
|