create-bc-app 1.1.1 → 1.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/index.mjs CHANGED
@@ -45,5 +45,5 @@ Instructions:
45
45
  Filtered results for: ${this.inputValue?this.inputValue:j.gray("Enter something to filter")}
46
46
  `}renderOption(t,e,i){let n;return e.disabled?n=t===i?j.gray().underline(e.title):j.strikethrough().gray(e.title):n=t===i?j.cyan().underline(e.title):e.title,(e.selected?j.green(B.radioOn):B.radioOff)+" "+n}renderDoneOrInstructions(){if(this.done)return this.value.filter(e=>e.selected).map(e=>e.title).join(", ");const t=[j.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&t.push(j.yellow(this.warn)),t.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(li.hide),super.render();let t=[Ht.symbol(this.done,this.aborted),j.bold(this.msg),Ht.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(t+=j.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),t+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+t),this.clear=Vt(t,this.out.columns)}}var ui=ai;const Bt=M,ci=F,{style:Ut,clear:di}=D,{erase:fi,cursor:zt}=P;class pi extends ci{constructor(t={}){super(t),this.msg=t.message,this.value=t.initial,this.initialValue=!!t.initial,this.yesMsg=t.yes||"yes",this.yesOption=t.yesOption||"(Y/n)",this.noMsg=t.no||"no",this.noOption=t.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
47
47
  `),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
48
- `),this.close()}_(t,e){return t.toLowerCase()==="y"?(this.value=!0,this.submit()):t.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(zt.hide):this.out.write(di(this.outputText,this.out.columns)),super.render(),this.outputText=[Ut.symbol(this.done,this.aborted),Bt.bold(this.msg),Ut.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:Bt.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(fi.line+zt.to(0)+this.outputText))}}var mi=pi,gi={TextPrompt:He,SelectPrompt:Ge,TogglePrompt:Xe,DatePrompt:Vs,NumberPrompt:Gs,MultiselectPrompt:Ft,AutocompletePrompt:oi,AutocompleteMultiselectPrompt:ui,ConfirmPrompt:mi};(function(s){const t=s,e=gi,i=r=>r;function n(r,l,g={}){return new Promise((u,T)=>{const p=new e[r](l),a=g.onAbort||i,h=g.onSubmit||i,v=g.onExit||i;p.on("state",l.onState||i),p.on("submit",x=>u(h(x))),p.on("exit",x=>u(v(x))),p.on("abort",x=>T(a(x)))})}t.text=r=>n("TextPrompt",r),t.password=r=>(r.style="password",t.text(r)),t.invisible=r=>(r.style="invisible",t.text(r)),t.number=r=>n("NumberPrompt",r),t.date=r=>n("DatePrompt",r),t.confirm=r=>n("ConfirmPrompt",r),t.list=r=>{const l=r.separator||",";return n("TextPrompt",r,{onSubmit:g=>g.split(l).map(u=>u.trim())})},t.toggle=r=>n("TogglePrompt",r),t.select=r=>n("SelectPrompt",r),t.multiselect=r=>{r.choices=[].concat(r.choices||[]);const l=g=>g.filter(u=>u.selected).map(u=>u.value);return n("MultiselectPrompt",r,{onAbort:l,onSubmit:l})},t.autocompleteMultiselect=r=>{r.choices=[].concat(r.choices||[]);const l=g=>g.filter(u=>u.selected).map(u=>u.value);return n("AutocompleteMultiselectPrompt",r,{onAbort:l,onSubmit:l})};const o=(r,l)=>Promise.resolve(l.filter(g=>g.title.slice(0,r.length).toLowerCase()===r.toLowerCase()));t.autocomplete=r=>(r.suggest=r.suggest||o,r.choices=[].concat(r.choices||[]),n("AutocompletePrompt",r))})(bt);const pt=bt,vi=["suggest","format","onState","validate","onRender","type"],Jt=()=>{};async function N(s=[],{onSubmit:t=Jt,onCancel:e=Jt}={}){const i={},n=N._override||{};s=[].concat(s);let o,r,l,g,u,T;const p=async(a,h,v=!1)=>{if(!(!v&&a.validate&&a.validate(h)!==!0))return a.format?await a.format(h,i):h};for(r of s)if({name:g,type:u}=r,typeof u=="function"&&(u=await u(o,{...i},r),r.type=u),!!u){for(let a in r){if(vi.includes(a))continue;let h=r[a];r[a]=typeof h=="function"?await h(o,{...i},T):h}if(T=r,typeof r.message!="string")throw new Error("prompt message is required");if({name:g,type:u}=r,pt[u]===void 0)throw new Error(`prompt type (${u}) is not defined`);if(n[r.name]!==void 0&&(o=await p(r,n[r.name]),o!==void 0)){i[g]=o;continue}try{o=N._injected?bi(N._injected,r.initial):await pt[u](r),i[g]=o=await p(r,o,!0),l=await t(r,o,i)}catch{l=!await e(r,i)}if(l)return i}return i}function bi(s,t){const e=s.shift();if(e instanceof Error)throw e;return e===void 0?t:e}function wi(s){N._injected=(N._injected||[]).concat(s)}function $i(s){N._override=Object.assign({},s)}var yi=Object.assign(N,{prompt:N,prompts:pt,inject:wi,override:$i});const kt=vt(yi);function xi(s,t){var e=s;t.slice(0,-1).forEach(function(n){e=e[n]||{}});var i=t[t.length-1];return i in e}function Gt(s){return typeof s=="number"||/^0x[0-9a-f]+$/i.test(s)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(s)}function Kt(s,t){return t==="constructor"&&typeof s[t]=="function"||t==="__proto__"}var Si=function(s,t){t||(t={});var e={bools:{},strings:{},unknownFn:null};typeof t.unknown=="function"&&(e.unknownFn=t.unknown),typeof t.boolean=="boolean"&&t.boolean?e.allBools=!0:[].concat(t.boolean).filter(Boolean).forEach(function(c){e.bools[c]=!0});var i={};function n(c){return i[c].some(function(w){return e.bools[w]})}Object.keys(t.alias||{}).forEach(function(c){i[c]=[].concat(t.alias[c]),i[c].forEach(function(w){i[w]=[c].concat(i[c].filter(function(I){return w!==I}))})}),[].concat(t.string).filter(Boolean).forEach(function(c){e.strings[c]=!0,i[c]&&[].concat(i[c]).forEach(function(w){e.strings[w]=!0})});var o=t.default||{},r={_:[]};function l(c,w){return e.allBools&&/^--[^=]+$/.test(w)||e.strings[c]||e.bools[c]||i[c]}function g(c,w,I){for(var f=c,z=0;z<w.length-1;z++){var C=w[z];if(Kt(f,C))return;f[C]===void 0&&(f[C]={}),(f[C]===Object.prototype||f[C]===Number.prototype||f[C]===String.prototype)&&(f[C]={}),f[C]===Array.prototype&&(f[C]=[]),f=f[C]}var _=w[w.length-1];Kt(f,_)||((f===Object.prototype||f===Number.prototype||f===String.prototype)&&(f={}),f===Array.prototype&&(f=[]),f[_]===void 0||e.bools[_]||typeof f[_]=="boolean"?f[_]=I:Array.isArray(f[_])?f[_].push(I):f[_]=[f[_],I])}function u(c,w,I){if(!(I&&e.unknownFn&&!l(c,I)&&e.unknownFn(I)===!1)){var f=!e.strings[c]&&Gt(w)?Number(w):w;g(r,c.split("."),f),(i[c]||[]).forEach(function(z){g(r,z.split("."),f)})}}Object.keys(e.bools).forEach(function(c){u(c,o[c]===void 0?!1:o[c])});var T=[];s.indexOf("--")!==-1&&(T=s.slice(s.indexOf("--")+1),s=s.slice(0,s.indexOf("--")));for(var p=0;p<s.length;p++){var a=s[p],h,v;if(/^--.+=/.test(a)){var x=a.match(/^--([^=]+)=([\s\S]*)$/);h=x[1];var st=x[2];e.bools[h]&&(st=st!=="false"),u(h,st,a)}else if(/^--no-.+/.test(a))h=a.match(/^--no-(.+)/)[1],u(h,!1,a);else if(/^--.+/.test(a))h=a.match(/^--(.+)/)[1],v=s[p+1],v!==void 0&&!/^(-|--)[^-]/.test(v)&&!e.bools[h]&&!e.allBools&&(!i[h]||!n(h))?(u(h,v,a),p+=1):/^(true|false)$/.test(v)?(u(h,v==="true",a),p+=1):u(h,e.strings[h]?"":!0,a);else if(/^-[^-]+/.test(a)){for(var S=a.slice(1,-1).split(""),Z=!1,$=0;$<S.length;$++){if(v=a.slice($+2),v==="-"){u(S[$],v,a);continue}if(/[A-Za-z]/.test(S[$])&&v[0]==="="){u(S[$],v.slice(1),a),Z=!0;break}if(/[A-Za-z]/.test(S[$])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(v)){u(S[$],v,a),Z=!0;break}if(S[$+1]&&S[$+1].match(/\W/)){u(S[$],a.slice($+2),a),Z=!0;break}else u(S[$],e.strings[S[$]]?"":!0,a)}h=a.slice(-1)[0],!Z&&h!=="-"&&(s[p+1]&&!/^(-|--)[^-]/.test(s[p+1])&&!e.bools[h]&&(!i[h]||!n(h))?(u(h,s[p+1],a),p+=1):s[p+1]&&/^(true|false)$/.test(s[p+1])?(u(h,s[p+1]==="true",a),p+=1):u(h,e.strings[h]?"":!0,a))}else if((!e.unknownFn||e.unknownFn(a)!==!1)&&r._.push(e.strings._||!Gt(a)?a:Number(a)),t.stopEarly){r._.push.apply(r._,s.slice(p+1));break}}return Object.keys(o).forEach(function(c){xi(r,c.split("."))||(g(r,c.split("."),o[c]),(i[c]||[]).forEach(function(w){g(r,w.split("."),o[c])}))}),t["--"]?r["--"]=T.slice():T.forEach(function(c){r._.push(c)}),r};const Oi=vt(Si);let V=!0;const U=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let W=0;if(U.process&&U.process.env&&U.process.stdout){const{FORCE_COLOR:s,NODE_DISABLE_COLORS:t,NO_COLOR:e,TERM:i,COLORTERM:n}=U.process.env;t||e||s==="0"?V=!1:s==="1"||s==="2"||s==="3"?V=!0:i==="dumb"?V=!1:"CI"in U.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(o=>o in U.process.env)?V=!0:V=process.stdout.isTTY,V&&(process.platform==="win32"||n&&(n==="truecolor"||n==="24bit")?W=3:i&&(i.endsWith("-256color")||i.endsWith("256"))?W=2:W=1)}let Wt={enabled:V,supportLevel:W};function Zt(s,t,e=1){const i=`\x1B[${s}m`,n=`\x1B[${t}m`,o=new RegExp(`\\x1b\\[${t}m`,"g");return r=>Wt.enabled&&Wt.supportLevel>=e?i+(""+r).replace(o,i)+n:""+r}const qt=Zt(0,0),Xt=Zt(31,39),mt=process.cwd(),Qt=Oi(process.argv.slice(2),{default:{help:!1},alias:{h:"help",t:"template"},string:["_"]}),Mi={_gitignore:".gitignore"},te="fsapp-project";async function Pi(){let s=se(Qt._[0])||te;const t=()=>s==="."?O.basename(O.resolve()):s;let e;kt.override({overwrite:Qt.overwrite});try{e=await kt([{type:"text",name:"projectName",message:qt("Project name:"),onState:h=>{s=se(h.value)||te}},{type:()=>!y.existsSync(s)||Ci(s)?null:"select",name:"overwrite",message:()=>(s==="."?"Current directory":`Target directory ${s}`)+"is not empty. Please choose how to proceed:",initial:0,choices:[{title:"Remove existing files and continue",value:"yes"},{title:"Cancel operation",value:"no"},{title:"Ignore files and continue",value:"ignore"}]},{type:(h,{overwrite:v})=>{if(v==="no")throw new Error(Xt("\u2716")+" Operation cancelled");return null},name:"overwriteChecker"},{type:()=>ie(t())?null:"text",name:"packageName",message:qt("Package name:"),initial:()=>Di(t()),validate:h=>ie(h)||"Invalid package.json name"},{type:"select",name:"template",message:"Select a template",choices:[{title:"Vue",value:"vue"},{title:"Docs",value:"docs"}]},{type:"select",name:"variant",message:"Select a templateUse arrow-keys. Return to submit.",choices:h=>h==="vue"?[{title:"TypeScript",value:"ts"},{title:"JavaScript",value:"js"}]:h==="docs"?[{title:"VitePress",value:"vitepress"},{title:"VuePress",value:"vuepress"}]:[]}],{onCancel:()=>{throw new Error(Xt("\u2716")+" Operation cancelled")}})}catch(h){console.log(h.message);return}const{overwrite:i,template:n,packageName:o,variant:r}=e,l=O.join(mt,s);i==="yes"?Ei(l):y.existsSync(l)||y.mkdirSync(l,{recursive:!0});const g=O.resolve(re(import.meta.url),"../..",`template-${n}-${r}`),u=(h,v)=>{const x=O.join(l,Mi[h]??h);v?y.writeFileSync(x,v):ee(O.join(g,h),x)},T=y.readdirSync(g);for(const h of T.filter(v=>v!=="package.json"))u(h);const p=JSON.parse(y.readFileSync(O.join(g,"package.json"),"utf-8"));p.name=o||t(),u("package.json",JSON.stringify(p,null,2)+`
49
- `);const a=O.relative(mt,l);console.log("Done. Now run:"),l!==mt&&console.log(` cd ${a.includes(" ")?`"${a}"`:a}`),n==="vue"&&(console.log(" npm install"),console.log(" npm run dev")),n==="docs"&&(console.log(" npm install"),console.log(" npm run docs:dev"))}function ee(s,t){y.statSync(s).isDirectory()?Ti(s,t):y.copyFileSync(s,t)}function Ti(s,t){y.mkdirSync(t,{recursive:!0});for(const e of y.readdirSync(s)){const i=O.resolve(s,e),n=O.resolve(t,e);ee(i,n)}}function Ci(s){const t=y.readdirSync(s);return t.length===0||t.length===1&&t[0]===".git"}function se(s){return s?.trim().replace(/\/+$/g,"")}function ie(s){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(s)}function Di(s){return s.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function Ei(s){if(y.existsSync(s))for(const t of y.readdirSync(s))t!==".git"&&y.rmSync(O.resolve(s,t),{recursive:!0,force:!0})}Pi().catch(console.error);
48
+ `),this.close()}_(t,e){return t.toLowerCase()==="y"?(this.value=!0,this.submit()):t.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(zt.hide):this.out.write(di(this.outputText,this.out.columns)),super.render(),this.outputText=[Ut.symbol(this.done,this.aborted),Bt.bold(this.msg),Ut.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:Bt.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(fi.line+zt.to(0)+this.outputText))}}var mi=pi,gi={TextPrompt:He,SelectPrompt:Ge,TogglePrompt:Xe,DatePrompt:Vs,NumberPrompt:Gs,MultiselectPrompt:Ft,AutocompletePrompt:oi,AutocompleteMultiselectPrompt:ui,ConfirmPrompt:mi};(function(s){const t=s,e=gi,i=r=>r;function n(r,l,g={}){return new Promise((u,T)=>{const p=new e[r](l),a=g.onAbort||i,h=g.onSubmit||i,v=g.onExit||i;p.on("state",l.onState||i),p.on("submit",x=>u(h(x))),p.on("exit",x=>u(v(x))),p.on("abort",x=>T(a(x)))})}t.text=r=>n("TextPrompt",r),t.password=r=>(r.style="password",t.text(r)),t.invisible=r=>(r.style="invisible",t.text(r)),t.number=r=>n("NumberPrompt",r),t.date=r=>n("DatePrompt",r),t.confirm=r=>n("ConfirmPrompt",r),t.list=r=>{const l=r.separator||",";return n("TextPrompt",r,{onSubmit:g=>g.split(l).map(u=>u.trim())})},t.toggle=r=>n("TogglePrompt",r),t.select=r=>n("SelectPrompt",r),t.multiselect=r=>{r.choices=[].concat(r.choices||[]);const l=g=>g.filter(u=>u.selected).map(u=>u.value);return n("MultiselectPrompt",r,{onAbort:l,onSubmit:l})},t.autocompleteMultiselect=r=>{r.choices=[].concat(r.choices||[]);const l=g=>g.filter(u=>u.selected).map(u=>u.value);return n("AutocompleteMultiselectPrompt",r,{onAbort:l,onSubmit:l})};const o=(r,l)=>Promise.resolve(l.filter(g=>g.title.slice(0,r.length).toLowerCase()===r.toLowerCase()));t.autocomplete=r=>(r.suggest=r.suggest||o,r.choices=[].concat(r.choices||[]),n("AutocompletePrompt",r))})(bt);const pt=bt,vi=["suggest","format","onState","validate","onRender","type"],Jt=()=>{};async function N(s=[],{onSubmit:t=Jt,onCancel:e=Jt}={}){const i={},n=N._override||{};s=[].concat(s);let o,r,l,g,u,T;const p=async(a,h,v=!1)=>{if(!(!v&&a.validate&&a.validate(h)!==!0))return a.format?await a.format(h,i):h};for(r of s)if({name:g,type:u}=r,typeof u=="function"&&(u=await u(o,{...i},r),r.type=u),!!u){for(let a in r){if(vi.includes(a))continue;let h=r[a];r[a]=typeof h=="function"?await h(o,{...i},T):h}if(T=r,typeof r.message!="string")throw new Error("prompt message is required");if({name:g,type:u}=r,pt[u]===void 0)throw new Error(`prompt type (${u}) is not defined`);if(n[r.name]!==void 0&&(o=await p(r,n[r.name]),o!==void 0)){i[g]=o;continue}try{o=N._injected?bi(N._injected,r.initial):await pt[u](r),i[g]=o=await p(r,o,!0),l=await t(r,o,i)}catch{l=!await e(r,i)}if(l)return i}return i}function bi(s,t){const e=s.shift();if(e instanceof Error)throw e;return e===void 0?t:e}function wi(s){N._injected=(N._injected||[]).concat(s)}function $i(s){N._override=Object.assign({},s)}var yi=Object.assign(N,{prompt:N,prompts:pt,inject:wi,override:$i});const kt=vt(yi);function xi(s,t){var e=s;t.slice(0,-1).forEach(function(n){e=e[n]||{}});var i=t[t.length-1];return i in e}function Gt(s){return typeof s=="number"||/^0x[0-9a-f]+$/i.test(s)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(s)}function Kt(s,t){return t==="constructor"&&typeof s[t]=="function"||t==="__proto__"}var Si=function(s,t){t||(t={});var e={bools:{},strings:{},unknownFn:null};typeof t.unknown=="function"&&(e.unknownFn=t.unknown),typeof t.boolean=="boolean"&&t.boolean?e.allBools=!0:[].concat(t.boolean).filter(Boolean).forEach(function(c){e.bools[c]=!0});var i={};function n(c){return i[c].some(function(w){return e.bools[w]})}Object.keys(t.alias||{}).forEach(function(c){i[c]=[].concat(t.alias[c]),i[c].forEach(function(w){i[w]=[c].concat(i[c].filter(function(I){return w!==I}))})}),[].concat(t.string).filter(Boolean).forEach(function(c){e.strings[c]=!0,i[c]&&[].concat(i[c]).forEach(function(w){e.strings[w]=!0})});var o=t.default||{},r={_:[]};function l(c,w){return e.allBools&&/^--[^=]+$/.test(w)||e.strings[c]||e.bools[c]||i[c]}function g(c,w,I){for(var f=c,z=0;z<w.length-1;z++){var C=w[z];if(Kt(f,C))return;f[C]===void 0&&(f[C]={}),(f[C]===Object.prototype||f[C]===Number.prototype||f[C]===String.prototype)&&(f[C]={}),f[C]===Array.prototype&&(f[C]=[]),f=f[C]}var _=w[w.length-1];Kt(f,_)||((f===Object.prototype||f===Number.prototype||f===String.prototype)&&(f={}),f===Array.prototype&&(f=[]),f[_]===void 0||e.bools[_]||typeof f[_]=="boolean"?f[_]=I:Array.isArray(f[_])?f[_].push(I):f[_]=[f[_],I])}function u(c,w,I){if(!(I&&e.unknownFn&&!l(c,I)&&e.unknownFn(I)===!1)){var f=!e.strings[c]&&Gt(w)?Number(w):w;g(r,c.split("."),f),(i[c]||[]).forEach(function(z){g(r,z.split("."),f)})}}Object.keys(e.bools).forEach(function(c){u(c,o[c]===void 0?!1:o[c])});var T=[];s.indexOf("--")!==-1&&(T=s.slice(s.indexOf("--")+1),s=s.slice(0,s.indexOf("--")));for(var p=0;p<s.length;p++){var a=s[p],h,v;if(/^--.+=/.test(a)){var x=a.match(/^--([^=]+)=([\s\S]*)$/);h=x[1];var st=x[2];e.bools[h]&&(st=st!=="false"),u(h,st,a)}else if(/^--no-.+/.test(a))h=a.match(/^--no-(.+)/)[1],u(h,!1,a);else if(/^--.+/.test(a))h=a.match(/^--(.+)/)[1],v=s[p+1],v!==void 0&&!/^(-|--)[^-]/.test(v)&&!e.bools[h]&&!e.allBools&&(!i[h]||!n(h))?(u(h,v,a),p+=1):/^(true|false)$/.test(v)?(u(h,v==="true",a),p+=1):u(h,e.strings[h]?"":!0,a);else if(/^-[^-]+/.test(a)){for(var S=a.slice(1,-1).split(""),Z=!1,$=0;$<S.length;$++){if(v=a.slice($+2),v==="-"){u(S[$],v,a);continue}if(/[A-Za-z]/.test(S[$])&&v[0]==="="){u(S[$],v.slice(1),a),Z=!0;break}if(/[A-Za-z]/.test(S[$])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(v)){u(S[$],v,a),Z=!0;break}if(S[$+1]&&S[$+1].match(/\W/)){u(S[$],a.slice($+2),a),Z=!0;break}else u(S[$],e.strings[S[$]]?"":!0,a)}h=a.slice(-1)[0],!Z&&h!=="-"&&(s[p+1]&&!/^(-|--)[^-]/.test(s[p+1])&&!e.bools[h]&&(!i[h]||!n(h))?(u(h,s[p+1],a),p+=1):s[p+1]&&/^(true|false)$/.test(s[p+1])?(u(h,s[p+1]==="true",a),p+=1):u(h,e.strings[h]?"":!0,a))}else if((!e.unknownFn||e.unknownFn(a)!==!1)&&r._.push(e.strings._||!Gt(a)?a:Number(a)),t.stopEarly){r._.push.apply(r._,s.slice(p+1));break}}return Object.keys(o).forEach(function(c){xi(r,c.split("."))||(g(r,c.split("."),o[c]),(i[c]||[]).forEach(function(w){g(r,w.split("."),o[c])}))}),t["--"]?r["--"]=T.slice():T.forEach(function(c){r._.push(c)}),r};const Oi=vt(Si);let V=!0;const U=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let W=0;if(U.process&&U.process.env&&U.process.stdout){const{FORCE_COLOR:s,NODE_DISABLE_COLORS:t,NO_COLOR:e,TERM:i,COLORTERM:n}=U.process.env;t||e||s==="0"?V=!1:s==="1"||s==="2"||s==="3"?V=!0:i==="dumb"?V=!1:"CI"in U.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(o=>o in U.process.env)?V=!0:V=process.stdout.isTTY,V&&(process.platform==="win32"||n&&(n==="truecolor"||n==="24bit")?W=3:i&&(i.endsWith("-256color")||i.endsWith("256"))?W=2:W=1)}let Wt={enabled:V,supportLevel:W};function Zt(s,t,e=1){const i=`\x1B[${s}m`,n=`\x1B[${t}m`,o=new RegExp(`\\x1b\\[${t}m`,"g");return r=>Wt.enabled&&Wt.supportLevel>=e?i+(""+r).replace(o,i)+n:""+r}const qt=Zt(0,0),Xt=Zt(31,39),mt=process.cwd(),Qt=Oi(process.argv.slice(2),{default:{help:!1},alias:{h:"help",t:"template"},string:["_"]}),Mi={_gitignore:".gitignore"},te="fsapp-project";async function Pi(){let s=se(Qt._[0])||te;const t=()=>s==="."?O.basename(O.resolve()):s;let e;kt.override({overwrite:Qt.overwrite});try{e=await kt([{type:"text",name:"projectName",message:qt("Project name:"),onState:h=>{s=se(h.value)||te}},{type:()=>!y.existsSync(s)||Ci(s)?null:"select",name:"overwrite",message:()=>(s==="."?"Current directory":`Target directory ${s}`)+"is not empty. Please choose how to proceed:",initial:0,choices:[{title:"Remove existing files and continue",value:"yes"},{title:"Cancel operation",value:"no"},{title:"Ignore files and continue",value:"ignore"}]},{type:(h,{overwrite:v})=>{if(v==="no")throw new Error(Xt("\u2716")+" Operation cancelled");return null},name:"overwriteChecker"},{type:()=>ie(t())?null:"text",name:"packageName",message:qt("Package name:"),initial:()=>Di(t()),validate:h=>ie(h)||"Invalid package.json name"},{type:"select",name:"template",message:"Select a template",choices:[{title:"Vue",value:"vue"},{title:"Docs",value:"docs"},{title:"Protocut",value:"protocut"}]},{type:"select",name:"variant",message:"Select a templateUse arrow-keys. Return to submit.",choices:h=>h==="vue"?[{title:"TypeScript",value:"ts"},{title:"JavaScript",value:"js"}]:h==="docs"?[{title:"VitePress",value:"vitepress"},{title:"VuePress",value:"vuepress"}]:h==="protocut"?[{title:"2D",value:"2d"},{title:"3D",value:"3d"}]:[]}],{onCancel:()=>{throw new Error(Xt("\u2716")+" Operation cancelled")}})}catch(h){console.log(h.message);return}const{overwrite:i,template:n,packageName:o,variant:r}=e,l=O.join(mt,s);i==="yes"?Ei(l):y.existsSync(l)||y.mkdirSync(l,{recursive:!0});const g=O.resolve(re(import.meta.url),"../..",`template-${n}-${r}`),u=(h,v)=>{const x=O.join(l,Mi[h]??h);v?y.writeFileSync(x,v):ee(O.join(g,h),x)},T=y.readdirSync(g);for(const h of T.filter(v=>v!=="package.json"))u(h);const p=JSON.parse(y.readFileSync(O.join(g,"package.json"),"utf-8"));p.name=o||t(),u("package.json",JSON.stringify(p,null,2)+`
49
+ `);const a=O.relative(mt,l);console.log("Done. Now run:"),l!==mt&&console.log(` cd ${a.includes(" ")?`"${a}"`:a}`),(n==="vue"||n==="protocut")&&(console.log(" npm install"),console.log(" npm run dev")),n==="docs"&&(console.log(" npm install"),console.log(" npm run docs:dev"))}function ee(s,t){y.statSync(s).isDirectory()?Ti(s,t):y.copyFileSync(s,t)}function Ti(s,t){y.mkdirSync(t,{recursive:!0});for(const e of y.readdirSync(s)){const i=O.resolve(s,e),n=O.resolve(t,e);ee(i,n)}}function Ci(s){const t=y.readdirSync(s);return t.length===0||t.length===1&&t[0]===".git"}function se(s){return s?.trim().replace(/\/+$/g,"")}function ie(s){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(s)}function Di(s){return s.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function Ei(s){if(y.existsSync(s))for(const t of y.readdirSync(s))t!==".git"&&y.rmSync(O.resolve(s,t),{recursive:!0,force:!0})}Pi().catch(console.error);
package/package.json CHANGED
@@ -1,34 +1,37 @@
1
- {
2
- "name": "create-bc-app",
3
- "version": "1.1.1",
4
- "description": "",
5
- "bin": "index.js",
6
- "type": "module",
7
- "scripts": {
8
- "build": "unbuild"
9
- },
10
- "author": "wbb",
11
- "license": "ISC",
12
- "devDependencies": {
13
- "@types/minimist": "^1.2.5",
14
- "@types/prompts": "^2.4.9",
15
- "cross-spawn": "^7.0.3",
16
- "kolorist": "^1.8.0",
17
- "minimist": "^1.2.8",
18
- "prompts": "^2.4.2",
19
- "unbuild": "^2.0.0"
20
- },
21
- "publishConfig": {
22
- "registry": "https://registry.npmjs.org"
23
- },
24
- "files": [
25
- "template-vue-js/.gitignore",
26
- "template-vue-js/",
27
- "template-vue-ts/",
28
- "template-docs-vitepress/",
29
- "template-docs-vuepress/",
30
- "template-vue-ts/.gitignore",
31
- "dist/",
32
- "index.js"
33
- ]
34
- }
1
+ {
2
+ "name": "create-bc-app",
3
+ "version": "1.1.2",
4
+ "description": "",
5
+ "bin": "index.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "build": "unbuild"
9
+ },
10
+ "author": "wbb",
11
+ "license": "ISC",
12
+ "devDependencies": {
13
+ "@types/minimist": "^1.2.5",
14
+ "@types/prompts": "^2.4.9",
15
+ "cross-spawn": "^7.0.3",
16
+ "kolorist": "^1.8.0",
17
+ "minimist": "^1.2.8",
18
+ "prompts": "^2.4.2",
19
+ "typescript": "^5.5.4",
20
+ "unbuild": "^2.0.0"
21
+ },
22
+ "publishConfig": {
23
+ "registry": "https://registry.npmjs.org"
24
+ },
25
+ "files": [
26
+ "template-vue-js/.gitignore",
27
+ "template-vue-js/",
28
+ "template-vue-ts/",
29
+ "template-protocut-2d/.gitignore",
30
+ "template-protocut-2d/",
31
+ "template-docs-vitepress/",
32
+ "template-docs-vuepress/",
33
+ "template-vue-ts/.gitignore",
34
+ "dist/",
35
+ "index.js"
36
+ ]
37
+ }
@@ -0,0 +1,203 @@
1
+ /* eslint-env node */
2
+ require('@rushstack/eslint-patch/modern-module-resolution')
3
+
4
+ module.exports = {
5
+ root: true,
6
+ extends: [
7
+ 'plugin:vue/recommended',
8
+ 'plugin:vue/vue3-essential',
9
+ 'plugin:vue/vue3-strongly-recommended',
10
+ 'plugin:@typescript-eslint/recommended',
11
+ 'eslint:recommended'
12
+ ],
13
+ ignorePatterns: ['sdk/'], globals: {
14
+ 'process': true
15
+ },
16
+ parser: 'vue-eslint-parser',
17
+ parserOptions: {
18
+ ecmaVersion: 'latest',
19
+ parser: '@typescript-eslint/parser'
20
+ },
21
+ rules: {
22
+ '@typescript-eslint/no-unused-vars': 'error',
23
+ '@typescript-eslint/no-explicit-any': 'off',
24
+ '@typescript-eslint/ban-ts-comment': 'off',
25
+ 'vue/multi-word-component-names': ['off'],
26
+ 'vue/no-v-for-template-key': 'off',
27
+ 'vue/no-multiple-template-root': 'off',
28
+ 'vue/no-v-model-argument': 'off',
29
+ 'vue/max-attributes-per-line': ['error', {
30
+ 'singleline': {
31
+ 'max': 3
32
+ },
33
+ 'multiline': {
34
+ 'max': 3
35
+ }
36
+ }],
37
+ 'accessor-pairs': 2,
38
+ 'arrow-spacing': [2, {
39
+ 'before': true,
40
+ 'after': true
41
+ }],
42
+ 'block-spacing': [2, 'always'],
43
+ 'brace-style': [2, '1tbs', {
44
+ 'allowSingleLine': true
45
+ }],
46
+ 'camelcase': [2, {
47
+ 'properties': 'always'
48
+ }],
49
+ 'comma-dangle': [2, 'never'],
50
+ 'comma-spacing': [2, {
51
+ 'before': false,
52
+ 'after': true
53
+ }],
54
+ 'comma-style': [2, 'last'],
55
+ 'constructor-super': 2,
56
+ 'curly': [2, 'multi-line'],
57
+ 'dot-location': [2, 'property'],
58
+ 'eol-last': 2,
59
+ 'eqeqeq': [2, 'allow-null'],
60
+ 'generator-star-spacing': [2, {
61
+ 'before': true,
62
+ 'after': true
63
+ }],
64
+ 'handle-callback-err': [2, '^(err|error)$'],
65
+ 'indent': [1, 2, {
66
+ 'SwitchCase': 1
67
+ }],
68
+ 'jsx-quotes': [2, 'prefer-single'],
69
+ 'key-spacing': [2, {
70
+ 'beforeColon': false,
71
+ 'afterColon': true
72
+ }],
73
+ 'keyword-spacing': [2, {
74
+ 'before': true,
75
+ 'after': true
76
+ }],
77
+ 'new-cap': [2, {
78
+ 'newIsCap': true,
79
+ 'capIsNew': false
80
+ }],
81
+ 'new-parens': 2,
82
+ 'no-array-constructor': 2,
83
+ 'no-caller': 2,
84
+ 'no-console': process.env.NODE_ENV === 'production' ? 2 : 0,
85
+ 'no-class-assign': 2,
86
+ 'no-cond-assign': 2,
87
+ 'no-const-assign': 2,
88
+ 'no-control-regex': 0,
89
+ 'no-delete-var': 2,
90
+ 'no-dupe-args': 2,
91
+ 'no-dupe-class-members': 2,
92
+ 'no-dupe-keys': 2,
93
+ 'no-duplicate-case': 2,
94
+ 'no-empty-character-class': 2,
95
+ 'no-empty-pattern': 2,
96
+ 'no-eval': 2,
97
+ 'no-ex-assign': 2,
98
+ 'no-extend-native': 2,
99
+ 'no-extra-bind': 2,
100
+ 'no-extra-boolean-cast': 2,
101
+ 'no-extra-parens': [2, 'functions'],
102
+ 'no-fallthrough': 2,
103
+ 'no-floating-decimal': 2,
104
+ 'no-func-assign': 2,
105
+ 'no-implied-eval': 2,
106
+ 'no-inner-declarations': [2, 'functions'],
107
+ 'no-invalid-regexp': 2,
108
+ 'no-irregular-whitespace': 2,
109
+ 'no-iterator': 2,
110
+ 'no-label-var': 2,
111
+ 'no-labels': [2, {
112
+ 'allowLoop': false,
113
+ 'allowSwitch': false
114
+ }],
115
+ 'no-lone-blocks': 2,
116
+ 'no-mixed-spaces-and-tabs': 2,
117
+ 'no-multi-spaces': 2,
118
+ 'no-multi-str': 2,
119
+ 'no-multiple-empty-lines': [2, {
120
+ 'max': 1
121
+ }],
122
+ 'no-native-reassign': 2,
123
+ 'no-negated-in-lhs': 2,
124
+ 'no-new-object': 2,
125
+ 'no-new-require': 2,
126
+ 'no-new-symbol': 2,
127
+ 'no-new-wrappers': 2,
128
+ 'no-obj-calls': 2,
129
+ 'no-octal': 2,
130
+ 'no-octal-escape': 2,
131
+ 'no-path-concat': 2,
132
+ 'no-proto': 2,
133
+ 'no-redeclare': 2,
134
+ 'no-regex-spaces': 2,
135
+ 'no-return-assign': [2, 'except-parens'],
136
+ 'no-self-assign': 2,
137
+ 'no-self-compare': 2,
138
+ 'no-sequences': 2,
139
+ 'no-shadow-restricted-names': 2,
140
+ 'no-spaced-func': 2,
141
+ 'no-sparse-arrays': 2,
142
+ 'no-this-before-super': 2,
143
+ 'no-throw-literal': 2,
144
+ 'no-trailing-spaces': 2,
145
+ 'no-undef': 2,
146
+ 'no-undef-init': 2,
147
+ 'no-unexpected-multiline': 2,
148
+ 'no-unmodified-loop-condition': 2,
149
+ 'no-unneeded-ternary': [2, {
150
+ 'defaultAssignment': false
151
+ }],
152
+ 'no-unreachable': 2,
153
+ 'no-unsafe-finally': 2,
154
+ 'no-unused-vars': 'off',
155
+ 'no-useless-call': 2,
156
+ 'no-useless-computed-key': 2,
157
+ 'no-useless-constructor': 2,
158
+ 'no-useless-escape': 1,
159
+ 'no-whitespace-before-property': 2,
160
+ 'no-with': 2,
161
+ 'one-var': [2, {
162
+ 'initialized': 'never'
163
+ }],
164
+ 'operator-linebreak': [2, 'after', {
165
+ 'overrides': {
166
+ '?': 'before',
167
+ ':': 'before'
168
+ }
169
+ }],
170
+ 'padded-blocks': [2, 'never'],
171
+ 'quotes': [1, 'single', {
172
+ 'avoidEscape': true,
173
+ 'allowTemplateLiterals': true
174
+ }],
175
+ 'semi': [2, 'never'],
176
+ 'semi-spacing': [2, {
177
+ 'before': false,
178
+ 'after': true
179
+ }],
180
+ 'space-before-blocks': [2, 'always'],
181
+ 'space-in-parens': [2, 'never'],
182
+ 'space-infix-ops': 2,
183
+ 'space-unary-ops': [2, {
184
+ 'words': true,
185
+ 'nonwords': false
186
+ }],
187
+ 'spaced-comment': [2, 'always', {
188
+ 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
189
+ }],
190
+ 'template-curly-spacing': [2, 'never'],
191
+ 'use-isnan': 2,
192
+ 'valid-typeof': 2,
193
+ 'wrap-iife': [2, 'any'],
194
+ 'yield-star-spacing': [2, 'both'],
195
+ 'yoda': [2, 'never'],
196
+ 'prefer-const': 0,
197
+ 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
198
+ 'object-curly-spacing': [2, 'always', {
199
+ objectsInObjects: false
200
+ }],
201
+ 'array-bracket-spacing': [2, 'never']
202
+ }
203
+ }
@@ -0,0 +1,24 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ dist
12
+ dist-ssr
13
+ *.local
14
+
15
+ # Editor directories and files
16
+ .vscode/*
17
+ !.vscode/extensions.json
18
+ .idea
19
+ .DS_Store
20
+ *.suo
21
+ *.ntvs*
22
+ *.njsproj
23
+ *.sln
24
+ *.sw?
@@ -0,0 +1,41 @@
1
+ stages:
2
+ - install
3
+ - eslint
4
+ - notify
5
+
6
+ cache:
7
+ key: '$CI_COMMIT_REF_SLUG'
8
+
9
+ install:
10
+ stage: install
11
+ cache:
12
+ paths:
13
+ - node_modules/
14
+ script:
15
+ - cnpm install
16
+ tags:
17
+ - sonar
18
+
19
+ eslint:
20
+ stage: eslint
21
+ cache:
22
+ paths:
23
+ - node_modules/
24
+ script:
25
+ - npm run lint
26
+ tags:
27
+ - sonar
28
+
29
+ notify-fail:
30
+ stage: notify
31
+ cache:
32
+ paths:
33
+ - node_modules/
34
+ script:
35
+ - >
36
+ curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=10a543ce-7d15-4339-9ef4-48f1ac5f5c87'
37
+ -H 'Content-Type: application/json'
38
+ -d "{\"msgtype\":\"markdown\",\"markdown\":{\"content\":\"项目构建结果:<font color=\\"warning\\">失败</font>\n>本次构建由: $GITLAB_USER_NAME 触发\n>项目名称:$CI_PROJECT_NAME\n>提交号:$CI_COMMIT_SHA\n>提交日志:$CI_COMMIT_MESSAGE\n>构建分支: $CI_COMMIT_REF_NAME\n>流水线地址:[$CI_PIPELINE_URL]($CI_PIPELINE_URL)\"}}"
39
+ when: on_failure
40
+ tags:
41
+ - sonar
@@ -0,0 +1,17 @@
1
+ # 这是一个 Vue 3 + TypeScript + Vite 的示例项目
2
+ 该项目已经配置:
3
+ - eslint
4
+ - less
5
+ - bochui
6
+ - eslint gitlab 代码检查流水线
7
+ - 单元测试
8
+ - vitest 官方文档
9
+ ![alt text](image.png)
10
+
11
+
12
+ 你可能需要配置:
13
+ - vue-router
14
+ - pinia
15
+ - fs-utils
16
+ - axios
17
+ - 拉下代码,修改仓库地址 git remote set-url origin 项目远程仓库地址
Binary file
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>example project</title>
8
+ </head>
9
+ <body>
10
+ <div id="app"></div>
11
+ <script type="module" src="/src/main.ts"></script>
12
+ </body>
13
+ </html>