create-crust 0.5.4 → 0.5.5
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/bin/create-crust.js +1 -1
- package/package.json +1 -1
package/bin/create-crust.js
CHANGED
|
@@ -61,7 +61,7 @@ return __eta.res;
|
|
|
61
61
|
`:Object.hasOwn(t.customTags,i)&&(s+=`__eta.res+=this.config.customTags[${JSON.stringify(i)}](${JSON.stringify(a)},${t.varName});
|
|
62
62
|
`)}}return s}function pi(e,t,n,r){let s,o;return Array.isArray(t.autoTrim)?(s=t.autoTrim[1],o=t.autoTrim[0]):s=o=t.autoTrim,(n||n===!1)&&(s=n),(r||r===!1)&&(o=r),!o&&!s?e:s==="slurp"&&o==="slurp"?e.trim():(s==="_"||s==="slurp"?e=e.trimStart():(s==="-"||s==="nl")&&(e=e.replace(/^(?:\r\n|\n|\r)/,"")),o==="_"||o==="slurp"?e=e.trimEnd():(o==="-"||o==="nl")&&(e=e.replace(/(?:\r\n|\n|\r)$/,"")),e)}var gi={"&":"&","<":"<",">":">",'"':""","'":"'"};function hi(e){return gi[e]}function bi(e){let t=String(e);return/[&<>"']/.test(t)?t.replace(/[&<>"']/g,hi):t}var Pn={autoEscape:!0,autoFilter:!1,autoTrim:[!1,"nl"],cache:!1,cacheFilepaths:!0,customTags:{},debug:!1,escapeFunction:bi,filterFunction:(e)=>String(e),outputFunctionName:"output",functionHeader:"",parse:{exec:"",interpolate:"=",raw:"~"},plugins:[],rmWhitespace:!1,tags:["<%","%>"],useWith:!1,varName:"it",defaultExtension:".eta"},ce=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,le=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,ue=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;function fe(e){return e.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&")}function wi(e,t){return e.slice(0,t).split(`
|
|
63
63
|
`).length}function yi(e){let t=this.config,n=[],r=!1,s=0,o=t.parse,i=Object.keys(t.customTags);if(t.plugins)for(let d=0;d<t.plugins.length;d++){let p=t.plugins[d];p.processTemplate&&(e=p.processTemplate(e,t))}t.rmWhitespace&&(e=e.replace(/[\r\n]+/g,`
|
|
64
|
-
`).replace(/^\s+|\s+$/gm,"")),ce.lastIndex=0,le.lastIndex=0,ue.lastIndex=0;function a(d,p){d&&(d=pi(d,t,r,p),d&&(d=d.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),n.push(d)))}let c=[o.exec,o.interpolate,o.raw,...i].reduce((d,p)=>d&&p?d+"|"+fe(p):p?fe(p):d,""),l=RegExp(fe(t.tags[0])+"(-|_)?\\s*("+c+")?\\s*","g"),u=RegExp("'|\"|`|\\/\\*|(\\s*(-|_)?"+fe(t.tags[1])+")","g"),f;for(;f=l.exec(e);){let d=e.slice(s,f.index);s=f[0].length+f.index;let p=f[1],b=f[2]||"";a(d,p),u.lastIndex=s;let m,g=!1;for(;m=u.exec(e);)if(m[1]){let w=e.slice(s,m.index);l.lastIndex=s=u.lastIndex,r=m[2],g={t:b===o.exec?"e":b===o.raw?"r":b===o.interpolate?"i":i.includes(b)?b:"",val:w};break}else{let w=m[0];if(w==="/*"){let S=e.indexOf("*/",u.lastIndex);S===-1&&W("unclosed comment",e,m.index),u.lastIndex=S}else w==="'"?(le.lastIndex=m.index,le.exec(e)?u.lastIndex=le.lastIndex:W("unclosed string",e,m.index)):w==='"'?(ue.lastIndex=m.index,ue.exec(e)?u.lastIndex=ue.lastIndex:W("unclosed string",e,m.index)):w==="`"&&(ce.lastIndex=m.index,ce.exec(e)?u.lastIndex=ce.lastIndex:W("unclosed string",e,m.index))}g?(t.debug&&(g.lineNo=wi(e,f.index)),n.push(g)):W("unclosed tag",e,f.index)}if(a(e.slice(s,e.length),!1),t.plugins)for(let d=0;d<t.plugins.length;d++){let p=t.plugins[d];p.processAST&&(n=p.processAST(n,t))}return n}function Mn(e,t){let n=t?.async?this.templatesAsync:this.templatesSync;if(this.resolvePath&&this.readFile&&!e.startsWith("@")){let r=t.filepath,s=n.get(r);if(this.config.cache&&s)return s;{let o=this.readFile(r),i=this.compile(o,t);return this.config.cache&&n.define(r,i),i}}else{let r=n.get(e);if(r)return r;throw new ci(`Failed to get template '${e}'`)}}function Ln(e,t,n){let r,s={...n,async:!1};return typeof e=="string"?(this.resolvePath&&this.readFile&&!e.startsWith("@")&&(s.filepath=this.resolvePath(e,s)),r=Mn.call(this,e,s)):r=e,r.call(this,t,s)}function zn(e,t,n){let r,s={...n,async:!0};typeof e=="string"?(this.resolvePath&&this.readFile&&!e.startsWith("@")&&(s.filepath=this.resolvePath(e,s)),r=Mn.call(this,e,s)):r=e;let o=r.call(this,t,s);return Promise.resolve(o)}function vi(e,t){let n=this.compile(e,{async:!1});return Ln.call(this,n,t)}function xi(e,t){let n=this.compile(e,{async:!0});return zn.call(this,n,t)}var Rn=class{constructor(e){this.cache=e}define(e,t){this.cache[e]=t}get(e){return this.cache[e]}remove(e){delete this.cache[e]}reset(){this.cache={}}load(e){this.cache={...this.cache,...e}}},Si=class{constructor(e){e?this.config={...Pn,...e}:this.config={...Pn};let t=[this.config.parse.exec,this.config.parse.interpolate,this.config.parse.raw,"-","_"];for(let n of Object.keys(this.config.customTags))if(t.includes(n))throw new de(`Custom tag prefix "${n}" conflicts with a built-in prefix`)}config;RuntimeErr=li;compile=fi;compileToString=di;compileBody=mi;parse=yi;render=Ln;renderAsync=zn;renderString=vi;renderStringAsync=xi;filepathCache={};templatesSync=new Rn({});templatesAsync=new Rn({});resolvePath=null;readFile=null;configure(e){this.config={...this.config,...e}}withConfig(e){return{...this,config:{...this.config,...e}}}loadTemplate(e,t,n){if(typeof t=="string")((n?.async)?this.templatesAsync:this.templatesSync).define(e,this.compile(t,n));else{let r=this.templatesSync;(t.constructor.name==="AsyncFunction"||n?.async)&&(r=this.templatesAsync),r.define(e,t)}}},Bn=class extends Si{};var Wn={name:"@crustjs/core",version:"0.5.
|
|
64
|
+
`).replace(/^\s+|\s+$/gm,"")),ce.lastIndex=0,le.lastIndex=0,ue.lastIndex=0;function a(d,p){d&&(d=pi(d,t,r,p),d&&(d=d.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),n.push(d)))}let c=[o.exec,o.interpolate,o.raw,...i].reduce((d,p)=>d&&p?d+"|"+fe(p):p?fe(p):d,""),l=RegExp(fe(t.tags[0])+"(-|_)?\\s*("+c+")?\\s*","g"),u=RegExp("'|\"|`|\\/\\*|(\\s*(-|_)?"+fe(t.tags[1])+")","g"),f;for(;f=l.exec(e);){let d=e.slice(s,f.index);s=f[0].length+f.index;let p=f[1],b=f[2]||"";a(d,p),u.lastIndex=s;let m,g=!1;for(;m=u.exec(e);)if(m[1]){let w=e.slice(s,m.index);l.lastIndex=s=u.lastIndex,r=m[2],g={t:b===o.exec?"e":b===o.raw?"r":b===o.interpolate?"i":i.includes(b)?b:"",val:w};break}else{let w=m[0];if(w==="/*"){let S=e.indexOf("*/",u.lastIndex);S===-1&&W("unclosed comment",e,m.index),u.lastIndex=S}else w==="'"?(le.lastIndex=m.index,le.exec(e)?u.lastIndex=le.lastIndex:W("unclosed string",e,m.index)):w==='"'?(ue.lastIndex=m.index,ue.exec(e)?u.lastIndex=ue.lastIndex:W("unclosed string",e,m.index)):w==="`"&&(ce.lastIndex=m.index,ce.exec(e)?u.lastIndex=ce.lastIndex:W("unclosed string",e,m.index))}g?(t.debug&&(g.lineNo=wi(e,f.index)),n.push(g)):W("unclosed tag",e,f.index)}if(a(e.slice(s,e.length),!1),t.plugins)for(let d=0;d<t.plugins.length;d++){let p=t.plugins[d];p.processAST&&(n=p.processAST(n,t))}return n}function Mn(e,t){let n=t?.async?this.templatesAsync:this.templatesSync;if(this.resolvePath&&this.readFile&&!e.startsWith("@")){let r=t.filepath,s=n.get(r);if(this.config.cache&&s)return s;{let o=this.readFile(r),i=this.compile(o,t);return this.config.cache&&n.define(r,i),i}}else{let r=n.get(e);if(r)return r;throw new ci(`Failed to get template '${e}'`)}}function Ln(e,t,n){let r,s={...n,async:!1};return typeof e=="string"?(this.resolvePath&&this.readFile&&!e.startsWith("@")&&(s.filepath=this.resolvePath(e,s)),r=Mn.call(this,e,s)):r=e,r.call(this,t,s)}function zn(e,t,n){let r,s={...n,async:!0};typeof e=="string"?(this.resolvePath&&this.readFile&&!e.startsWith("@")&&(s.filepath=this.resolvePath(e,s)),r=Mn.call(this,e,s)):r=e;let o=r.call(this,t,s);return Promise.resolve(o)}function vi(e,t){let n=this.compile(e,{async:!1});return Ln.call(this,n,t)}function xi(e,t){let n=this.compile(e,{async:!0});return zn.call(this,n,t)}var Rn=class{constructor(e){this.cache=e}define(e,t){this.cache[e]=t}get(e){return this.cache[e]}remove(e){delete this.cache[e]}reset(){this.cache={}}load(e){this.cache={...this.cache,...e}}},Si=class{constructor(e){e?this.config={...Pn,...e}:this.config={...Pn};let t=[this.config.parse.exec,this.config.parse.interpolate,this.config.parse.raw,"-","_"];for(let n of Object.keys(this.config.customTags))if(t.includes(n))throw new de(`Custom tag prefix "${n}" conflicts with a built-in prefix`)}config;RuntimeErr=li;compile=fi;compileToString=di;compileBody=mi;parse=yi;render=Ln;renderAsync=zn;renderString=vi;renderStringAsync=xi;filepathCache={};templatesSync=new Rn({});templatesAsync=new Rn({});resolvePath=null;readFile=null;configure(e){this.config={...this.config,...e}}withConfig(e){return{...this,config:{...this.config,...e}}}loadTemplate(e,t,n){if(typeof t=="string")((n?.async)?this.templatesAsync:this.templatesSync).define(e,this.compile(t,n));else{let r=this.templatesSync;(t.constructor.name==="AsyncFunction"||n?.async)&&(r=this.templatesAsync),r.define(e,t)}}},Bn=class extends Si{};var Wn={name:"@crustjs/core",version:"0.5.5",description:"Define, parse, route, and run type-safe CLI commands with Contexts and Extensions",type:"module",sideEffects:!1,license:"MIT",author:"chenxin-yan",repository:{type:"git",url:"git+https://github.com/chenxin-yan/crust.git",directory:"packages/core"},homepage:"https://crustjs.com",bugs:{url:"https://github.com/chenxin-yan/crust/issues"},keywords:["cli","command","framework","parser","bun","typescript"],files:["dist"],types:"./dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./tooling":{types:"./dist/tooling.d.ts",import:"./dist/tooling.js"}},publishConfig:{access:"public"},scripts:{build:"vp run build:task",dev:"vp pack --watch","check:types":"vp run check:types:task",test:"vp run test:task",prepack:"cp ../../LICENSE LICENSE",postpack:"rm -f LICENSE"},dependencies:{"@crustjs/utils":"workspace:^"},devDependencies:{"@crustjs/config":"workspace:*","vite-plus":"catalog:"},peerDependencies:{typescript:"^7.0.0"},peerDependenciesMeta:{typescript:{optional:!0}},engines:{bun:">=1.4.0",node:">=24",deno:">=2.8"}};var Un={name:"@crustjs/crust",version:"0.5.5",description:"CLI to build and publish Crust apps as npm packages or standalone binaries",type:"module",license:"MIT",author:"chenxin-yan",repository:{type:"git",url:"git+https://github.com/chenxin-yan/crust.git",directory:"packages/crust"},homepage:"https://crustjs.com",bugs:{url:"https://github.com/chenxin-yan/crust/issues"},keywords:["cli","build","compile","standalone","bun","typescript"],publishConfig:{access:"public"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"}},crust:{artifact:"binary",include:["schema","dist"]},bin:{crust:"src/cli.ts"},scripts:{build:"vp run build:task",release:"bun src/cli.ts publish",dev:"bun src/cli.ts",start:"bun .crust/root/bin/crust.js","check:types":"vp run check:types:task",test:"vp run test:task"},dependencies:{"@crustjs/core":"workspace:^","@crustjs/extensions":"workspace:^","@crustjs/style":"workspace:^"},optionalDependencies:{"@tsdown/exe":"0.23.0",tsdown:"0.23.0"},peerDependencies:{"@crustjs/core":"^0.5.0"},devDependencies:{"@arethetypeswrong/core":"^0.18.5","@crustjs/config":"workspace:*","@crustjs/testing":"workspace:*","@crustjs/utils":"workspace:*","@types/semver":"^7.8.0",publint:"^0.3.24",semver:"^7.8.5","vite-plus":"catalog:"},engines:{bun:">=1.4.0"}};var Vn={name:"@crustjs/extensions",version:"0.5.5",description:"Official Crust Extensions for help, version, completion, typo hints, color, and updates",type:"module",sideEffects:!1,license:"MIT",author:"chenxin-yan",repository:{type:"git",url:"git+https://github.com/chenxin-yan/crust.git",directory:"packages/extensions"},homepage:"https://crustjs.com",bugs:{url:"https://github.com/chenxin-yan/crust/issues"},keywords:["cli","extension","help","version","completion","did-you-mean","bun","typescript"],files:["dist"],exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"}},publishConfig:{access:"public"},scripts:{build:"vp run build:task",dev:"vp pack --watch","check:types":"vp run check:types:task",test:"vp run test:task",prepack:"cp ../../LICENSE LICENSE",postpack:"rm -f LICENSE"},dependencies:{"@crustjs/store":"workspace:^","@crustjs/style":"workspace:^","@crustjs/utils":"workspace:^"},devDependencies:{"@crustjs/config":"workspace:*","@crustjs/core":"workspace:*","@crustjs/testing":"workspace:*","vite-plus":"catalog:"},peerDependencies:{"@crustjs/core":"workspace:^",typescript:"^7.0.0"},peerDependenciesMeta:{typescript:{optional:!0}},engines:{bun:">=1.4.0",node:">=24",deno:">=2.8"}};var qn={name:"create-crust",version:"0.5.5",description:"Scaffold a new Crust CLI project for Bun, Node.js, or Deno",type:"module",sideEffects:!1,license:"MIT",author:"chenxin-yan",repository:{type:"git",url:"git+https://github.com/chenxin-yan/crust.git",directory:"packages/create-crust"},homepage:"https://crustjs.com",bugs:{url:"https://github.com/chenxin-yan/crust/issues"},keywords:["cli","scaffold","create","generator","bun","typescript","crust"],publishConfig:{access:"public"},crust:{runtime:"node",artifact:"package",include:["templates"]},bin:{"create-crust":"src/index.ts"},scripts:{build:"vp run build:task",dev:"pnpm run build && bun src/index.ts",release:"crust publish","check:types":"vp run check:types:task",test:"vp run test:task","test:smoke":"vp test tests/cli.smoke.test.ts"},dependencies:{"@crustjs/core":"workspace:^","@crustjs/create":"workspace:^","@crustjs/progress":"workspace:^","@crustjs/prompts":"workspace:^",eta:"^4.6.0"},devDependencies:{"@crustjs/config":"workspace:*","@crustjs/crust":"workspace:*","@crustjs/extensions":"workspace:*","vite-plus":"catalog:"},engines:{bun:">=1.4.0",node:">=24",deno:">=2.8"}};var ki={bun:{shebang:"#!/usr/bin/env bun",tsLib:'"ESNext"',tsTypes:'"bun"'},node:{shebang:"#!/usr/bin/env node",tsLib:'"ESNext"',tsTypes:'"node"'},deno:{shebang:"#!/usr/bin/env -S deno run -A",tsLib:'"ESNext", "deno.window"',tsTypes:""}},Ni=new Bn({autoEscape:!1,autoTrim:!1});function Jn(e){if(!Mt(e))throw Error(`Project name ${JSON.stringify(e)} is not safe for the generated project.
|
|
65
65
|
The directory basename becomes the package and command name: use ${Dt}.`)}var Ai=/[<>:"|?*\\]/;function Ti(e){if(!e)throw Error("Project directory cannot be empty");if(Ai.test(e))throw Error(`Project directory contains invalid characters: ${e}`);Jn(Kn(Yn(e)))}var Fi=new Z("create-crust",{description:qn.description}).flags({name:"runtime",type:"string",choices:["bun","node","deno"],description:'Runtime to develop and build for ("bun", "node", or "deno")'},{name:"artifact",type:"string",choices:["package","binary"],description:"Build output: runtime package or standalone binary"},{name:"install",type:"boolean",description:"Install dependencies after scaffolding"},{name:"git",type:"boolean",description:"Initialize a git repository after scaffolding"},{name:"overwrite",type:"boolean",description:"Overwrite the destination directory if it already exists"}).args({name:"directory",type:"string",description:"Project directory to scaffold into"}).action(async({args:e,flags:t})=>{let n=e.directory??await Fn({message:"Project directory",default:"my-cli",validate:Ti}),r=Yn(process.cwd(),n),s=r===process.cwd(),o=Kn(r);Jn(o);let i=s?Ci(r).length>0:Hn(r),a=!1;if(i){if(a=await ae({message:s?"Current directory is not empty. Overwrite conflicting files?":`Directory "${o}" already exists. Overwrite?`,default:!1,initial:t.overwrite}),!a){console.log("Aborted.");return}}let c=await Ze({message:"Runtime",choices:[{label:"Bun (recommended)",value:"bun",hint:"Bun APIs and TypeScript execution"},{label:"Node.js",value:"node",hint:"Node.js APIs and ecosystem"},{label:"Deno",value:"deno",hint:"Deno APIs and permission model"}],default:"bun",initial:t.runtime}),l=await Ze({message:"Build output",choices:[{label:"Standalone binary",value:"binary",hint:"Embeds the runtime; users need no separate JavaScript runtime"},{label:"Runtime package",value:"package",hint:c==="deno"?"Requires Deno installed; experimental bundling":"JavaScript bundle; requires the selected runtime installed"}],default:c==="node"?"package":"binary",initial:t.artifact}),u=await ae({message:"Install dependencies?",default:!0,initial:t.install}),f=r;while(!Hn(f)&&Gn(f)!==f)f=Gn(f);let p=Zt(f)?!1:await ae({message:"Initialize a git repository?",default:!0,initial:t.git}),b=c==="deno"?"deno":De(r),m={name:o,runtime:c,artifact:l,run:b==="deno"?"deno task":`${b} run`,install:`${b} install`,...ki[c],coreVersion:Wn.version,extensionsVersion:Vn.version,crustVersion:Un.version};if(await qe({message:"Scaffolding project...",task:()=>Xt({template:_i(he("templates"),"base"),dest:r,context:m,render:(g,w)=>Ni.renderString(g,w),conflict:a?"overwrite":"abort"})}),u)await Me([c==="deno"?{type:"command",cmd:"deno install"}:{type:"install"}],r);if(p)await qe({message:"Initializing git repository...",task:()=>Me([{type:"git-init",commit:"chore: initial commit"}],r)});if(console.log(`
|
|
66
66
|
Created ${o}!
|
|
67
67
|
`),console.log("Next steps:"),!s){let g=ji(n)||n.startsWith(".")?n:`./${n}`;console.log(` cd ${g}`)}if(!u)console.log(` ${m.install}`);console.log(` ${m.run} dev`),console.log(` ${m.run} build`)});await Fi.execute();
|