create-stencil
Advanced tools
Comparing version 1.5.0 to 1.5.1
#! /usr/bin/env node | ||
function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var child_process=require("child_process"),fs=require("fs"),readline=_interopDefault(require("readline")),events=_interopDefault(require("events")),__awaiter=function(e,t,i,s){return new(i||(i=Promise))(function(r,o){function n(e){try{h(s.next(e))}catch(e){o(e)}}function l(e){try{h(s.throw(e))}catch(e){o(e)}}function h(e){e.done?r(e.value):new i(function(t){t(e.value)}).then(n,l)}h((s=s.apply(e,t||[])).next())})};function createApp(e,t){return __awaiter(this,void 0,void 0,function*(){if(fs.existsSync(t))throw new Error(`Folder "./${t}" already exists, please choose a different project name.`);yield cloneApp(e.repo,t),yield cdIntoNewApp(t),yield removeOrigin(),yield installPackages(),console.log(`\n ๐ All done!\n\n\tcd ./${t}\n\tnpm start\n`),e.docs&&console.log(`Check out the docs: ${e.docs}\n`)})}function cloneApp(e,t){return new Promise((i,s)=>{try{console.log(`\n ๐ Cloning ${e}...`),child_process.exec(`git clone "https://github.com/${e}" "${t}" --branch master --single-branch --depth 1`,(e,r,o)=>{e?s(`โ ๏ธ Couldn't check out "${t}"`):i()})}catch(i){s(`โ ๏ธ Couldn't check out Stencil ${e} into "${t}"`)}})}function cdIntoNewApp(e){return new Promise(t=>{console.log(" ๐โ Changing directories..."),process.chdir(`${e}`),t()})}function removeOrigin(){return new Promise(e=>{console.log(" ๐จ Preparing repo..."),child_process.exec("rm -rf .git",()=>{e()})})}function installPackages(){return new Promise(e=>{console.log(" ๐ฆ Installing packages..."),child_process.exec("npm ci",()=>{e()})})}function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var ansi=(e=>({reset:e(["[0m"]),newLine:["\n",""],tab:["\t",""],black:e(["[30m","[39m"]),red:e(["[31m","[39m"]),green:e(["[32m","[39m"]),yellow:e(["[33m","[39m"]),blue:e(["[34m","[39m"]),magenta:e(["[35m","[39m"]),cyan:e(["[36m","[39m"]),white:e(["[37m","[39m"]),gray:e(["[90m","[39m"]),bgBlack:e(["[40m","[49m"]),bgRed:e(["[41m","[49m"]),bgGreen:e(["[42m","[49m"]),bgYellow:e(["[43m","[49m"]),bgBlue:e(["[44m","[49m"]),bgMagenta:e(["[45m","[49m"]),bgCyan:e(["[46m","[49m"]),bgWhite:e(["[47m","[49m"]),dim:e(["[2m","[22m"]),bold:e(["[1m","[22m"]),hidden:e(["[8m","[28m"]),italic:e(["[3m","[23m"]),underline:e(["[4m","[24m"]),inverse:e(["[7m","[27m"]),strikethrough:e(["[9m","[29m"])}))(e=>process.env.FORCE_COLOR||"win32"===process.platform||process.stdout.isTTY&&process.env.TERM&&"dumb"!==process.env.TERM?e:["",""]),clorox=function e(t,i){const s=t=>e(s.toString(t));return s.toString=(e=>t+(e||"")+(i||ansi.reset[0])),Object.keys(ansi).map(r=>{Object.defineProperty(s,r,{get:()=>e(t+ansi[r][0],(i||"")+ansi[r][1])})}),s}(""),action=e=>{if(e.ctrl){if("a"===e.name)return"first";if("c"===e.name)return"abort";if("d"===e.name)return"abort";if("e"===e.name)return"last";if("g"===e.name)return"reset"}return"return"===e.name?"submit":"enter"===e.name?"submit":"backspace"===e.name?"delete":"abort"===e.name?"abort":"escape"===e.name?"abort":"tab"===e.name?"next":"up"===e.name?"up":"down"===e.name?"down":"right"===e.name?"right":"left"===e.name&&"left"},strip=e=>{const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),i=new RegExp(t,"g");return"string"==typeof e?e.replace(i,""):e};const ESC="[",clear="",beep="",cursor={to:(e,t)=>t?`[${t+1};${e+1}H`:`[${e+1}G`,move(e,t){let i="";return e<0?i+=`[${-e}D`:e>0&&(i+=`[${e}C`),t<0?i+=`[${-t}A`:t>0&&(i+=`[${t}B`),i},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>"[E".repeat(e),prevLine:(e=1)=>"[F".repeat(e),left:"[G",hide:"[?25l",show:"[?25h"},scroll={up:(e=1)=>"[S".repeat(e),down:(e=1)=>"[T".repeat(e)},erase={screen:"[2J",up:"[1J",down:"[J",line:"[2K",lineEnd:"[K",lineStart:"[1K",lines(e){let t="";for(let i=0;i<e;i++)t+=this.line+(i<e-1?cursor.up():"");return e&&(t+=cursor.left),t}};var src={cursor:cursor,scroll:scroll,erase:erase,beep:"",clear:""};const{erase:erase$1,cursor:cursor$1}=src,width=e=>[...strip(e)].length;var clear$1=function(e,t=process.stdout.columns){if(!t)return erase$1.line+cursor$1.to(0);let i=0;const s=e.split(/\r?\n/);for(let e of s)i+=1+Math.floor(Math.max(width(e)-1,0)/t);return(erase$1.line+cursor$1.prevLine()).repeat(i-1)+erase$1.line+cursor$1.to(0)};const main={tick:"โ",cross:"โ",ellipsis:"โฆ",pointerSmall:"โบ",line:"โ",pointer:"โฏ"},win={tick:"โ",cross:"ร",ellipsis:"...",pointerSmall:"ยป",line:"โ",pointer:">"},figures="win32"===process.platform?win:main;var figures_1=figures;const styles=Object.freeze({password:{scale:1,render:e=>"*".repeat(e.length)},emoji:{scale:2,render:e=>"๐".repeat(e.length)},invisible:{scale:0,render:e=>""},default:{scale:1,render:e=>`${e}`}}),render=e=>styles[e]||styles.default,symbols=Object.freeze({aborted:clorox.red(figures_1.cross),done:clorox.green(figures_1.tick),default:clorox.cyan("?")}),symbol=(e,t)=>t?symbols.aborted:e?symbols.done:symbols.default,delimiter=e=>clorox.gray(e?figures_1.ellipsis:figures_1.pointerSmall),item=(e,t)=>clorox.gray(e?t?figures_1.pointerSmall:"+":figures_1.line);var style={styles:styles,render:render,symbols:symbols,symbol:symbol,delimiter:delimiter,item:item},util={action:action,clear:clear$1,style:style,strip:strip,figures:figures_1};const{action:action$1}=util,{beep:beep$1,cursor:cursor$2}=src;class Prompt extends events{constructor(e={}){super(),this.in=e.in||process.stdin,this.out=e.out||process.stdout;const t=readline.createInterface(this.in);readline.emitKeypressEvents(this.in,t),this.in.isTTY&&this.in.setRawMode(!0);const i=(e,t)=>{let i=action$1(t);!1===i?this._&&this._(e,t):"function"==typeof this[i]?this[i](t):this.bell()};this.close=(()=>{this.out.write(cursor$2.show),this.in.removeListener("keypress",i),this.in.setRawMode(!1),t.close(),this.emit(this.aborted?"abort":"submit",this.value)}),this.in.on("keypress",i)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted})}bell(){this.out.write(beep$1)}}var prompt=Prompt;const{cursor:cursor$3}=src,{style:style$1,clear:clear$2}=util;class TextPrompt extends prompt{constructor(e={}){super(e),this.transform=style$1.render(e.style),this.scale=this.transform.scale,this.msg=e.message,this.initial=e.initial||"",this.value="",this.cursor=this.rendered.length,this.clear=clear$2(""),this.render()}set value(e){!e&&this.initial?(this.placeholder=!0,this.rendered=clorox.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(e)),this._value=e,this.fire()}get value(){return this._value}reset(){this.value="",this.fire(),this.render()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.value=this.value||this.initial,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(e){this.placeholder||(this.cursor=this.cursor+e)}_(e,t){let i=this.value.slice(0,this.cursor),s=this.value.slice(this.cursor);this.moveCursor(1),this.value=`${i}${e}${s}`,this.placeholder&&(this.cursor=0),this.render()}delete(){if(0===this.value.length)return this.bell();let e=this.value.slice(0,this.cursor-1),t=this.value.slice(this.cursor);this.value=`${e}${t}`,this.moveCursor(-1),this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}render(){const e=[style$1.symbol(this.done,this.aborted),clorox.bold(this.msg),style$1.delimiter(this.done),this.rendered].join(" ");this.out.write(this.clear+e),this.out.write(cursor$3.move(this.placeholder?-this.initial.length*this.scale:-this.rendered.length+this.cursor*this.scale)),this.clear=clear$2(e)}}var text=TextPrompt;const{style:style$2,clear:clear$3}=util,{erase:erase$2,cursor:cursor$4}=src;class SelectPrompt extends prompt{constructor(e={}){super(e),this.msg=e.message,this.hint=e.hint||"- Use arrow-keys. Return to submit.",this.cursor=e.initial||0,this.values=e.choices||[],this.value=e.choices[this.cursor].value,this.clear=clear$3(""),this.render(!0)}moveCursor(e){this.cursor=e,this.value=this.values[e].value,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.values.length-1),this.render()}up(){if(0===this.cursor)return this.bell();this.moveCursor(this.cursor-1),this.render()}down(){if(this.cursor===this.values.length-1)return this.bell();this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.values.length),this.render()}_(e,t){if(" "===e)return this.submit()}render(e){e?this.out.write(cursor$4.hide):this.out.write(erase$2.lines(this.values.length+1)),this.out.write([style$2.symbol(this.done,this.aborted),clorox.bold(this.msg),style$2.delimiter(!1),this.done?this.values[this.cursor].title:clorox.gray(this.hint)].join(" ")),this.done||this.out.write("\n"+this.values.map((e,t)=>{let i=this.cursor===t?clorox.cyan.underline(e.title):e.title;return`${this.cursor===t?clorox.cyan("โฏ "):" "} ${i}`}).join("\n"))}}var select=SelectPrompt;const{style:style$3,clear:clear$4}=util,{cursor:cursor$5,erase:erase$3}=src;class TogglePrompt extends prompt{constructor(e={}){super(e),this.msg=e.message,this.value=!!e.initial,this.active=e.active,this.inactive=e.inactive,this.initialValue=this.value,this.render(!0)}reset(){this.value=this.initialValue,this.fire(),this.render()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}deactivate(){if(!1===this.value)return this.bell();this.value=!1,this.render()}activate(){if(!0===this.value)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(e,t){if(" "===e)this.value=!this.value,this.render();else if("1"===e)this.value=!0,this.render();else{if("0"!==e)return this.bell();this.value=!1,this.render()}}render(e){e&&this.out.write(cursor$5.hide),this.out.write(erase$3.line+cursor$5.to(0)+[style$3.symbol(this.done,this.aborted),clorox.bold(this.msg),style$3.delimiter(this.done),this.value?this.inactive:clorox.cyan.underline(this.inactive),clorox.gray("/"),this.value?clorox.cyan.underline(this.active):this.active].join(" "))}}var toggle=TogglePrompt;const{cursor:cursor$6,erase:erase$4}=src,{style:style$4,clear:clear$5}=util,isNumber=/[0-9]/,isDef=e=>void 0!==e,round=(e,t)=>{let i=Math.pow(10,t);return Math.round(e*i)/i};class NumberPrompt extends prompt{constructor(e={}){super(e),this.transform=style$4.render(e.style),this.msg=e.message,this.initial=isDef(e.initial)?e.initial:"",this.float=!!e.float,this.round=e.round||2,this.inc=e.increment||1,this.min=isDef(e.min)?e.min:-1/0,this.max=isDef(e.max)?e.max:1/0,this.value="",this.typed="",this.lastHit=0,this.render()}set value(e){e||0===e?(this.placeholder=!1,this.rendered=this.transform.render(`${round(e,this.round)}`),this._value=round(e,this.round)):(this.placeholder=!0,this.rendered=clorox.gray(this.transform.render(`${this.initial}`)),this._value=""),this.fire()}get value(){return this._value}parse(e){return this.float?parseFloat(e):parseInt(e)}valid(e){return"-"===e||"."===e&&this.float||isNumber.test(e)}reset(){this.typed="",this.value="",this.fire(),this.render()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.value=this.value||this.initial,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}up(){if(this.typed="",this.value>=this.max)return this.bell();this.value+=this.inc,this.fire(),this.render()}down(){if(this.typed="",this.value<=this.min)return this.bell();this.value-=this.inc,this.fire(),this.render()}delete(){let e=this.value.toString();if(0===e.length)return this.bell();this.value=this.parse(e=e.slice(0,-1))||"",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(e,t){if(!this.valid(e))return this.bell();const i=Date.now();if(i-this.lastHit>1e3&&(this.typed=""),this.typed+=e,this.lastHit=i,"."===e)return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){let e=!this.done||!this.done&&!this.placeholder;this.out.write(erase$4.line+cursor$6.to(0)+[style$4.symbol(this.done,this.aborted),clorox.bold(this.msg),style$4.delimiter(this.done),e?clorox.cyan.underline(this.rendered):this.rendered].join(" "))}}var number=NumberPrompt;const{cursor:cursor$7}=src,{clear:clear$6,figures:figures$1,style:style$5}=util;class MultiselectPrompt extends prompt{constructor(e={}){super(e),this.msg=e.message,this.cursor=e.cursor||0,this.hint=e.hint||"- Space to select. Return to submit",this.maxChoices=e.max,this.value=e.choices.map(e=>Object.assign({title:e.value,selected:!1},e)),this.clear=clear$6(""),this.render(!0)}reset(){this.value.map(e=>!e.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(e=>e.selected)}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){if(0===this.cursor)return this.bell();this.cursor--,this.render()}down(){if(this.cursor===this.value.length-1)return this.bell();this.cursor++,this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}_(e,t){if(" "!==e)return this.bell();const i=this.value[this.cursor];if(i.selected)i.selected=!1,this.render();else{if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();i.selected=!0,this.render()}}render(e){e&&this.out.write(cursor$7.hide);const t=this.value.filter(e=>e.selected).map(e=>e.title).join(", ");let i=[style$5.symbol(this.done,this.aborted),clorox.bold(this.msg),style$5.delimiter(!1),this.done?t:clorox.gray(this.hint)].join(" ");if(!this.done){const e=this.cursor;i+="\n"+this.value.map((t,i)=>(t.selected?clorox.green(figures$1.tick):" ")+" "+(e===i?clorox.cyan.underline(t.title):t.title)).join("\n")}this.out.write(this.clear+i),this.clear=clear$6(i)}}var multiselect=MultiselectPrompt;const{cursor:cursor$8}=src,getVal=(e,t)=>e[t]&&(e[t].value||e[t].title||e[t]);class AutocompletePrompt extends prompt{constructor(e={}){super(e),this.msg=e.message,this.suggest=e.suggest,this.choices=e.choices,this.initial=e.initial,this.cursor=e.initial||e.cursor||0,this.fallback=e.fallback||void 0!==e.initial?`โบ ${getVal(this.choices,this.initial)}`:"โบ no matches found",this.suggestions=[],this.input="",this.limit=e.limit||10,this.transform=util.style.render(e.style),this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=util.clear(""),this.complete(this.render),this.render(!0)}moveCursor(e){this.cursor=e,this.suggestions.length>0?this.value=getVal(this.suggestions,e):this.value=void 0!==this.initial?getVal(this.choices,this.initial):null,this.fire()}async complete(e){const t=this.completing=this.suggest(this.input,this.choices),i=await t;if(this.completing!==t)return;this.suggestions=i.slice(0,this.limit).map(e=>util.strip(e)),this.completing=!1;const s=Math.max(i.length-1,0);this.moveCursor(Math.min(s,this.cursor)),e&&e()}reset(){this.input="",this.complete(()=>{this.moveCursor(void 0!==this.initial?this.initial:0),this.render()}),this.render()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}_(e,t){this.input+=e,this.complete(this.render),this.render()}delete(){if(0===this.input.length)return this.bell();this.input=this.input.slice(0,-1),this.complete(this.render),this.render()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.suggestions.length-1),this.render()}up(){if(this.cursor<=0)return this.bell();this.moveCursor(this.cursor-1),this.render()}down(){if(this.cursor>=this.suggestions.length-1)return this.bell();this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.suggestions.length),this.render()}render(e){e&&this.out.write(cursor$8.hide);let t=[util.style.symbol(this.done,this.aborted),this.msg,util.style.delimiter(this.completing),this.done&&this.suggestions[this.cursor]?this.suggestions[this.cursor].title:this.transform.render(this.input)].join(" ");if(!this.done){let e=this.suggestions.map((e,t)=>`\n${t===this.cursor?clorox.cyan(e.title):e.title}`);t+=e.length?e.reduce((e,t)=>e+t,""):`\n${clorox.gray(this.fallback)}`}this.out.write(this.clear+t),this.clear=util.clear(t)}}var autocomplete=AutocompletePrompt;const{style:style$6,clear:clear$7}=util,{erase:erase$5,cursor:cursor$9}=src;class ConfirmPrompt extends prompt{constructor(e={}){super(e),this.msg=e.message,this.value=e.initial,this.initialValue=!!e.initial,this.render(!0)}reset(){this.value=this.initialValue,this.fire(),this.render()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}_(e,t){return"y"===e.toLowerCase()?(this.value=!0,this.submit()):"n"===e.toLowerCase()?(this.value=!1,this.submit()):this.bell()}render(e){e&&this.out.write(cursor$9.hide),this.out.write(erase$5.line+cursor$9.to(0)+[style$6.symbol(this.done,this.aborted),clorox.bold(this.msg),style$6.delimiter(this.done),this.done?this.value?"yes":"no":clorox.gray(this.initialValue?"(Y/n)":"(y/N)")].join(" "))}}var confirm=ConfirmPrompt,elements={TextPrompt:text,SelectPrompt:select,TogglePrompt:toggle,NumberPrompt:number,MultiselectPrompt:multiselect,AutocompletePrompt:autocomplete,ConfirmPrompt:confirm},prompts=createCommonjsModule(function(e,t){const i=t,s=e=>e;function r(e,t,i={}){return new Promise((r,o)=>{const n=new elements[e](t),l=i.onAbort||s,h=i.onSubmit||s;n.on("state",t.onState||s),n.on("submit",e=>r(h(e))),n.on("abort",e=>o(l(e)))})}i.text=(e=>r("TextPrompt",e)),i.password=(e=>(e.style="password",i.text(e))),i.invisible=(e=>(e.style="invisible",i.text(e))),i.number=(e=>r("NumberPrompt",e)),i.confirm=(e=>r("ConfirmPrompt",e)),i.list=(e=>{const t=e.separator||",";return r("TextPrompt",e,{onSubmit:e=>e.split(t).map(e=>e.trim())})}),i.toggle=(e=>r("TogglePrompt",e)),i.select=(e=>r("SelectPrompt",e)),i.multiselect=(e=>{e.choices=[].concat(e.choices||[]);const t=e=>e.filter(e=>e.selected).map(e=>e.value);return r("MultiselectPrompt",e,{onAbort:t,onSubmit:t})});const o=(e,t)=>Promise.resolve(t.filter(t=>t.title.slice(0,e.length).toLowerCase()===e.toLowerCase()));i.autocomplete=(e=>(e.suggest=e.suggest||o,e.choices=[].concat(e.choices||[]),r("AutocompletePrompt",e)))});const ignore=["suggest","format","onState"],noop=()=>{};async function prompt$1(e=[],{onSubmit:t=noop,onCancel:i=noop}={}){const s={};let r,o,n,l,h;e=[].concat(e);let a=prompt$1._map||{};for(o of e)if(({name:l,type:h}=o),void 0===a[l]){for(let e in o){if(ignore.includes(e))continue;let t=o[e];o[e]="function"==typeof t?await t(r,{...s},o):t}if("string"!=typeof o.message)throw new Error("prompt message is required");if(({name:l,type:h}=o),h){if(void 0===prompts[h])throw new Error(`prompt type (${h}) is not defined`);try{r=await prompts[h](o),s[l]=r=o.format?await o.format(r,s):r,n=t(o,r)}catch(e){n=!i(o)}if(n)return s}}else s[l]=a[l],delete a[l];return s}function inject(e){prompt$1._map=prompt$1._map||{};for(let t in e)prompt$1._map[t]=e[t]}var lib=Object.assign(prompt$1,{prompt:prompt$1,prompts:prompts,inject:inject});const STARTERS=[{name:"component",repo:"ionic-team/stencil-component-starter",description:"Collection of web components that can be used anywhere",docs:"https://github.com/ionic-team/stencil-component-starter"},{name:"app",repo:"ionic-team/stencil-app-starter",description:"Minimal starter for building a Stencil app or website",docs:"https://github.com/ionic-team/stencil-app-starter"},{name:"ionic-pwa",repo:"ionic-team/ionic-pwa-toolkit",description:"Everything you need to build fast, production ready PWAs",docs:"https://stenciljs.com/pwa/"}];function getStarterRepo(e){if(e.includes("/"))return{name:e,repo:e};const t=STARTERS.find(t=>t.name===e);if(!t)throw new Error(`Starter "${e}" does not exist.`);return t}var __awaiter$1=function(e,t,i,s){return new(i||(i=Promise))(function(r,o){function n(e){try{h(s.next(e))}catch(e){o(e)}}function l(e){try{h(s.throw(e))}catch(e){o(e)}}function h(e){e.done?r(e.value):new i(function(t){t(e.value)}).then(n,l)}h((s=s.apply(e,t||[])).next())})};function runInteractive(e){return __awaiter$1(this,void 0,void 0,function*(){console.log("๐ Welcome to Stencil Create App!\n"),e||(e=yield askStarterName());const t=getStarterRepo(e),i=yield askProjectName();(yield askConfirm(t,i))?yield createApp(t,i):console.log("\n aborting, bye bye \n")})}function askStarterName(){return __awaiter$1(this,void 0,void 0,function*(){console.log(" What kind of project do you want to create? \n");const{starterName:e}=yield lib([{type:"select",name:"starterName",message:"Pick a starter",choices:getChoices()},{type:e=>null===e?"text":null,name:"starterName",message:"Type a custom starter"}]);if(!e)throw new Error("No starter was provided, try again.");return e})}function getChoices(){const e=Math.max(...STARTERS.map(e=>e.name.length))+1;return[...STARTERS.map(t=>({title:`๐ ${padEnd(t.name,e)} (${t.description})`,value:t.name})),{title:"Other (specify)",value:null}]}function askProjectName(){return __awaiter$1(this,void 0,void 0,function*(){const{projectName:e}=yield lib([{type:"text",name:"projectName",message:"Project name"}]);if(!e)throw new Error("No project name was provided, try again.");return e})}function askConfirm(e,t){return __awaiter$1(this,void 0,void 0,function*(){console.log(`\nWe are about to clone "${e.repo}" into "./${t}"`);const{confirm:i}=yield lib([{type:"confirm",name:"confirm",message:"Confirm?"}]);return i})}function padEnd(e,t,i=" "){return t>>=0,e.length>t?e:((t-=e.length)>i.length&&(i+=i.repeat(t/i.length)),String(e)+i.slice(0,t))}var __awaiter$2=function(e,t,i,s){return new(i||(i=Promise))(function(r,o){function n(e){try{h(s.next(e))}catch(e){o(e)}}function l(e){try{h(s.throw(e))}catch(e){o(e)}}function h(e){e.done?r(e.value):new i(function(t){t(e.value)}).then(n,l)}h((s=s.apply(e,t||[])).next())})};const USAGE_DOCS="Usage:\n\nnpm init stencil [starter] [project-name]\n";function run(){return __awaiter$2(this,void 0,void 0,function*(){const e=process.argv.slice(2);if(e.indexOf("--help")>=0)return console.log(USAGE_DOCS),0;try{if(2===e.length)yield createApp(getStarterRepo(e[0]),e[1]);else{if(!(e.length<2))throw new Error(USAGE_DOCS);yield runInteractive(e[0])}}catch(e){return console.error(`\nโ ${e.message}\n`),-1}})}run(); | ||
function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var child_process=require("child_process"),fs=require("fs"),readline=_interopDefault(require("readline")),events=_interopDefault(require("events")),__awaiter=function(t,e,i,s){return new(i||(i=Promise))(function(r,n){function o(t){try{h(s.next(t))}catch(t){n(t)}}function l(t){try{h(s.throw(t))}catch(t){n(t)}}function h(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(o,l)}h((s=s.apply(t,e||[])).next())})};function createApp(t,e){return __awaiter(this,void 0,void 0,function*(){if(fs.existsSync(e))throw new Error(`Folder "./${e}" already exists, please choose a different project name.`);yield cloneApp(t.repo,e),yield cdIntoNewApp(e),yield removeOrigin(),yield installPackages(),console.log(`\n ๐ All done!\n\n\tcd ./${e}\n\tnpm start\n`),t.docs&&console.log(`Check out the docs: ${t.docs}\n`)})}function cloneApp(t,e){return new Promise((i,s)=>{try{console.log(`\n ๐ Cloning ${t}...`),child_process.exec(`git clone "https://github.com/${t}" "${e}" --branch master --single-branch --depth 1`,(t,r,n)=>{t?s(`โ ๏ธ Couldn't check out "${e}"`):i()})}catch(i){s(`โ ๏ธ Couldn't check out Stencil ${t} into "${e}"`)}})}function cdIntoNewApp(t){return new Promise(e=>{console.log(" ๐โ Changing directories..."),process.chdir(`${t}`),e()})}function removeOrigin(){return new Promise(t=>{console.log(" ๐จ Preparing repo..."),child_process.exec("rm -rf .git",()=>{t()})})}function installPackages(){return new Promise(t=>{console.log(" ๐ฆ Installing packages..."),child_process.exec("npm ci",()=>{t()})})}function createCommonjsModule(t,e){return t(e={exports:{}},e.exports),e.exports}const $={enabled:!0},CODES={reset:fmt(0,0),bold:fmt(1,22),dim:fmt(2,22),italic:fmt(3,23),underline:fmt(4,24),inverse:fmt(7,27),hidden:fmt(8,28),strikethrough:fmt(9,29),black:fmt(30,39),red:fmt(31,39),green:fmt(32,39),yellow:fmt(33,39),blue:fmt(34,39),magenta:fmt(35,39),cyan:fmt(36,39),white:fmt(37,39),gray:fmt(90,39),bgBlack:fmt(40,49),bgRed:fmt(41,49),bgGreen:fmt(42,49),bgYellow:fmt(43,49),bgBlue:fmt(44,49),bgMagenta:fmt(45,49),bgCyan:fmt(46,49),bgWhite:fmt(47,49)};function fmt(t,e){return{open:`[${t}m`,close:`[${e}m`,rgx:new RegExp(`\\x1b\\[${e}m`,"g")}}function run(t,e){let i=CODES[t];return i.open+e.replace(i.rgx,i.open)+i.close}function exec(t,e){if(e+="",!$.enabled)return e;let i=this.keys;for(;i.length>0;)e=run(i.shift(),e);return this.keys.push(t),e}function attach(t){let e={keys:[t]},i=exec.bind(e,t);for(let t in CODES)Reflect.defineProperty(i,t,{get:()=>(e.keys.push(t),i)});return i}for(let t in CODES)$[t]=attach(t);var kleur=$,action=t=>{if(t.ctrl){if("a"===t.name)return"first";if("c"===t.name)return"abort";if("d"===t.name)return"abort";if("e"===t.name)return"last";if("g"===t.name)return"reset"}return"return"===t.name?"submit":"enter"===t.name?"submit":"backspace"===t.name?"delete":"abort"===t.name?"abort":"escape"===t.name?"abort":"tab"===t.name?"next":"up"===t.name?"up":"down"===t.name?"down":"right"===t.name?"right":"left"===t.name&&"left"},strip=t=>{const e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),i=new RegExp(e,"g");return"string"==typeof t?t.replace(i,""):t};const ESC="[",clear="",beep="",cursor={to:(t,e)=>e?`[${e+1};${t+1}H`:`[${t+1}G`,move(t,e){let i="";return t<0?i+=`[${-t}D`:t>0&&(i+=`[${t}C`),e<0?i+=`[${-e}A`:e>0&&(i+=`[${e}B`),i},up:(t=1)=>`[${t}A`,down:(t=1)=>`[${t}B`,forward:(t=1)=>`[${t}C`,backward:(t=1)=>`[${t}D`,nextLine:(t=1)=>"[E".repeat(t),prevLine:(t=1)=>"[F".repeat(t),left:"[G",hide:"[?25l",show:"[?25h"},scroll={up:(t=1)=>"[S".repeat(t),down:(t=1)=>"[T".repeat(t)},erase={screen:"[2J",up:"[1J",down:"[J",line:"[2K",lineEnd:"[K",lineStart:"[1K",lines(t){let e="";for(let i=0;i<t;i++)e+=this.line+(i<t-1?cursor.up():"");return t&&(e+=cursor.left),e}};var src={cursor:cursor,scroll:scroll,erase:erase,beep:"",clear:""};const erase$1=src.erase,cursor$1=src.cursor,width=t=>[...strip(t)].length;var clear$1=function(t,e=process.stdout.columns){if(!e)return erase$1.line+cursor$1.to(0);let i=0;const s=t.split(/\r?\n/);var r=!0,n=!1,o=void 0;try{for(var l,h=s[Symbol.iterator]();!(r=(l=h.next()).done);r=!0){let t=l.value;i+=1+Math.floor(Math.max(width(t)-1,0)/e)}}catch(t){n=!0,o=t}finally{try{!r&&h.return&&h.return()}finally{if(n)throw o}}return(erase$1.line+cursor$1.prevLine()).repeat(i-1)+erase$1.line+cursor$1.to(0)};const main={tick:"โ",cross:"โ",ellipsis:"โฆ",pointerSmall:"โบ",line:"โ",pointer:"โฏ"},win={tick:"โ",cross:"ร",ellipsis:"...",pointerSmall:"ยป",line:"โ",pointer:">"},figures="win32"===process.platform?win:main;var figures_1=figures;const styles=Object.freeze({password:{scale:1,render:t=>"*".repeat(t.length)},emoji:{scale:2,render:t=>"๐".repeat(t.length)},invisible:{scale:0,render:t=>""},default:{scale:1,render:t=>`${t}`}}),render=t=>styles[t]||styles.default,symbols=Object.freeze({aborted:kleur.red(figures_1.cross),done:kleur.green(figures_1.tick),default:kleur.cyan("?")}),symbol=(t,e)=>e?symbols.aborted:t?symbols.done:symbols.default,delimiter=t=>kleur.gray(t?figures_1.ellipsis:figures_1.pointerSmall),item=(t,e)=>kleur.gray(t?e?figures_1.pointerSmall:"+":figures_1.line);var style={styles:styles,render:render,symbols:symbols,symbol:symbol,delimiter:delimiter,item:item},util={action:action,clear:clear$1,style:style,strip:strip,figures:figures_1};const action$1=util.action,beep$1=src.beep,cursor$2=src.cursor;class Prompt extends events{constructor(t={}){super(),this.in=t.in||process.stdin,this.out=t.out||process.stdout;const e=readline.createInterface(this.in);readline.emitKeypressEvents(this.in,e),this.in.isTTY&&this.in.setRawMode(!0);const i=(t,e)=>{let i=action$1(e);!1===i?this._&&this._(t,e):"function"==typeof this[i]?this[i](e):this.bell()};this.close=(()=>{this.out.write(cursor$2.show),this.in.removeListener("keypress",i),this.in.isTTY&&this.in.setRawMode(!1),e.close(),this.emit(this.aborted?"abort":"submit",this.value)}),this.in.on("keypress",i)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted})}bell(){this.out.write(beep$1)}}var prompt=Prompt;const cursor$3=src.cursor,style$1=util.style,clear$2=util.clear;class TextPrompt extends prompt{constructor(t={}){super(t),this.transform=style$1.render(t.style),this.scale=this.transform.scale,this.msg=t.message,this.initial=t.initial||"",this.value="",this.cursor=Number(!!this.initial),this.clear=clear$2(""),this.render()}set value(t){!t&&this.initial?(this.placeholder=!0,this.rendered=kleur.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(t)),this._value=t,this.fire()}get value(){return this._value}reset(){this.value="",this.fire(),this.render()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.value=this.value||this.initial,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(t){this.placeholder||(this.cursor=this.cursor+t)}_(t,e){let i=this.value.slice(0,this.cursor),s=this.value.slice(this.cursor);this.moveCursor(1),this.value=`${i}${t}${s}`,this.placeholder&&(this.cursor=0),this.render()}delete(){if(0===this.value.length)return this.bell();let t=this.value.slice(0,this.cursor-1),e=this.value.slice(this.cursor);this.value=`${t}${e}`,this.moveCursor(-1),this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}render(){const t=[style$1.symbol(this.done,this.aborted),kleur.bold(this.msg),style$1.delimiter(this.done),this.rendered].join(" ");this.out.write(this.clear+t),this.out.write(cursor$3.move(this.placeholder?-this.initial.length*this.scale:-this.rendered.length+this.cursor*this.scale)),this.clear=clear$2(t)}}var text=TextPrompt;const style$2=util.style,clear$3=util.clear,erase$2=src.erase,cursor$4=src.cursor;class SelectPrompt extends prompt{constructor(t={}){super(t),this.msg=t.message,this.hint=t.hint||"- Use arrow-keys. Return to submit.",this.cursor=t.initial||0,this.values=t.choices||[],this.value=t.choices[this.cursor].value,this.clear=clear$3(""),this.render(!0)}moveCursor(t){this.cursor=t,this.value=this.values[t].value,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.values.length-1),this.render()}up(){if(0===this.cursor)return this.bell();this.moveCursor(this.cursor-1),this.render()}down(){if(this.cursor===this.values.length-1)return this.bell();this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.values.length),this.render()}_(t,e){if(" "===t)return this.submit()}render(t){t?this.out.write(cursor$4.hide):this.out.write(erase$2.lines(this.values.length+1)),this.out.write([style$2.symbol(this.done,this.aborted),kleur.bold(this.msg),style$2.delimiter(!1),this.done?this.values[this.cursor].title:kleur.gray(this.hint)].join(" ")),this.done||this.out.write("\n"+this.values.map((t,e)=>{let i=this.cursor===e?kleur.cyan.underline(t.title):t.title;return`${this.cursor===e?kleur.cyan("โฏ "):" "} ${i}`}).join("\n"))}}var select=SelectPrompt;const style$3=util.style,cursor$5=src.cursor,erase$3=src.erase;class TogglePrompt extends prompt{constructor(t={}){super(t),this.msg=t.message,this.value=!!t.initial,this.active=t.active,this.inactive=t.inactive,this.initialValue=this.value,this.render(!0)}reset(){this.value=this.initialValue,this.fire(),this.render()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}deactivate(){if(!1===this.value)return this.bell();this.value=!1,this.render()}activate(){if(!0===this.value)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(t,e){if(" "===t)this.value=!this.value,this.render();else if("1"===t)this.value=!0,this.render();else{if("0"!==t)return this.bell();this.value=!1,this.render()}}render(t){t&&this.out.write(cursor$5.hide),this.out.write(erase$3.lines(t?1:this.msg.split(/\n/g).length)+cursor$5.to(0)+[style$3.symbol(this.done,this.aborted),kleur.bold(this.msg),style$3.delimiter(this.done),this.value?this.inactive:kleur.cyan.underline(this.inactive),kleur.gray("/"),this.value?kleur.cyan.underline(this.active):this.active].join(" "))}}var toggle=TogglePrompt;const cursor$6=src.cursor,erase$4=src.erase,style$4=util.style,isNumber=/[0-9]/,isDef=t=>void 0!==t,round=(t,e)=>{let i=Math.pow(10,e);return Math.round(t*i)/i};class NumberPrompt extends prompt{constructor(t={}){super(t),this.transform=style$4.render(t.style),this.msg=t.message,this.initial=isDef(t.initial)?t.initial:"",this.float=!!t.float,this.round=t.round||2,this.inc=t.increment||1,this.min=isDef(t.min)?t.min:-1/0,this.max=isDef(t.max)?t.max:1/0,this.value="",this.typed="",this.lastHit=0,this.render()}set value(t){t||0===t?(this.placeholder=!1,this.rendered=this.transform.render(`${round(t,this.round)}`),this._value=round(t,this.round)):(this.placeholder=!0,this.rendered=kleur.gray(this.transform.render(`${this.initial}`)),this._value=""),this.fire()}get value(){return this._value}parse(t){return this.float?parseFloat(t):parseInt(t)}valid(t){return"-"===t||"."===t&&this.float||isNumber.test(t)}reset(){this.typed="",this.value="",this.fire(),this.render()}abort(){let t=this.value;this.value=""!==t?t:this.initial,this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){let t=this.value;this.value=""!==t?t:this.initial,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}up(){if(this.typed="",this.value>=this.max)return this.bell();this.value+=this.inc,this.fire(),this.render()}down(){if(this.typed="",this.value<=this.min)return this.bell();this.value-=this.inc,this.fire(),this.render()}delete(){let t=this.value.toString();if(0===t.length)return this.bell();this.value=this.parse(t=t.slice(0,-1))||"",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(t,e){if(!this.valid(t))return this.bell();const i=Date.now();if(i-this.lastHit>1e3&&(this.typed=""),this.typed+=t,this.lastHit=i,"."===t)return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){let t=!this.done||!this.done&&!this.placeholder;this.out.write(erase$4.line+cursor$6.to(0)+[style$4.symbol(this.done,this.aborted),kleur.bold(this.msg),style$4.delimiter(this.done),t?kleur.cyan.underline(this.rendered):this.rendered].join(" "))}}var number=NumberPrompt;const cursor$7=src.cursor,clear$6=util.clear,figures$1=util.figures,style$5=util.style;class MultiselectPrompt extends prompt{constructor(t={}){super(t),this.msg=t.message,this.cursor=t.cursor||0,this.hint=t.hint||"- Space to select. Return to submit",this.maxChoices=t.max,this.value=t.choices.map(t=>Object.assign({title:t.value,selected:!1},t)),this.clear=clear$6(""),this.render(!0)}reset(){this.value.map(t=>!t.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(t=>t.selected)}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){if(0===this.cursor)return this.bell();this.cursor--,this.render()}down(){if(this.cursor===this.value.length-1)return this.bell();this.cursor++,this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}_(t,e){if(" "!==t)return this.bell();const i=this.value[this.cursor];if(i.selected)i.selected=!1,this.render();else{if(this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();i.selected=!0,this.render()}}render(t){t&&this.out.write(cursor$7.hide);const e=this.value.filter(t=>t.selected).map(t=>t.title).join(", ");let i=[style$5.symbol(this.done,this.aborted),kleur.bold(this.msg),style$5.delimiter(!1),this.done?e:kleur.gray(this.hint)].join(" ");if(!this.done){const t=this.cursor;i+="\n"+this.value.map((e,i)=>(e.selected?kleur.green(figures$1.tick):" ")+" "+(t===i?kleur.cyan.underline(e.title):e.title)).join("\n")}this.out.write(this.clear+i),this.clear=clear$6(i)}}var multiselect=MultiselectPrompt;function _asyncToGenerator(t){return function(){var e=t.apply(this,arguments);return new Promise(function(t,i){return function s(r,n){try{var o=e[r](n),l=o.value}catch(t){return void i(t)}if(!o.done)return Promise.resolve(l).then(function(t){s("next",t)},function(t){s("throw",t)});t(l)}("next")})}}const cursor$8=src.cursor,getVal=(t,e)=>t[e]&&(t[e].value||t[e].title||t[e]);class AutocompletePrompt extends prompt{constructor(t={}){super(t),this.msg=t.message,this.suggest=t.suggest,this.choices=t.choices,this.initial=t.initial,this.cursor=t.initial||t.cursor||0,this.fallback=t.fallback||void 0!==t.initial?`โบ ${getVal(this.choices,this.initial)}`:"โบ no matches found",this.suggestions=[],this.input="",this.limit=t.limit||10,this.transform=util.style.render(t.style),this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=util.clear(""),this.complete(this.render),this.render(!0)}moveCursor(t){this.cursor=t,this.suggestions.length>0?this.value=getVal(this.suggestions,t):this.value=void 0!==this.initial?getVal(this.choices,this.initial):null,this.fire()}complete(t){var e=this;return _asyncToGenerator(function*(){const i=e.completing=e.suggest(e.input,e.choices),s=yield i;if(e.completing!==i)return;e.suggestions=s.slice(0,e.limit).map(function(t){return util.strip(t)}),e.completing=!1;const r=Math.max(s.length-1,0);e.moveCursor(Math.min(r,e.cursor)),t&&t()})()}reset(){this.input="",this.complete(()=>{this.moveCursor(void 0!==this.initial?this.initial:0),this.render()}),this.render()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}_(t,e){this.input+=t,this.complete(this.render),this.render()}delete(){if(0===this.input.length)return this.bell();this.input=this.input.slice(0,-1),this.complete(this.render),this.render()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.suggestions.length-1),this.render()}up(){if(this.cursor<=0)return this.bell();this.moveCursor(this.cursor-1),this.render()}down(){if(this.cursor>=this.suggestions.length-1)return this.bell();this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.suggestions.length),this.render()}render(t){t&&this.out.write(cursor$8.hide);let e=[util.style.symbol(this.done,this.aborted),this.msg,util.style.delimiter(this.completing),this.done&&this.suggestions[this.cursor]?this.suggestions[this.cursor].title:this.transform.render(this.input)].join(" ");if(!this.done){let t=this.suggestions.map((t,e)=>`\n${e===this.cursor?kleur.cyan(t.title):t.title}`);e+=t.length?t.reduce((t,e)=>t+e,""):`\n${kleur.gray(this.fallback)}`}this.out.write(this.clear+e),this.clear=util.clear(e)}}var autocomplete=AutocompletePrompt;const style$6=util.style,erase$5=src.erase,cursor$9=src.cursor;class ConfirmPrompt extends prompt{constructor(t={}){super(t),this.msg=t.message,this.value=t.initial,this.initialValue=!!t.initial,this.render(!0)}reset(){this.value=this.initialValue,this.fire(),this.render()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}_(t,e){return"y"===t.toLowerCase()?(this.value=!0,this.submit()):"n"===t.toLowerCase()?(this.value=!1,this.submit()):this.bell()}render(t){t&&this.out.write(cursor$9.hide),this.out.write(erase$5.line+cursor$9.to(0)+[style$6.symbol(this.done,this.aborted),kleur.bold(this.msg),style$6.delimiter(this.done),this.done?this.value?"yes":"no":kleur.gray(this.initialValue?"(Y/n)":"(y/N)")].join(" "))}}var confirm=ConfirmPrompt,elements={TextPrompt:text,SelectPrompt:select,TogglePrompt:toggle,NumberPrompt:number,MultiselectPrompt:multiselect,AutocompletePrompt:autocomplete,ConfirmPrompt:confirm},prompts=createCommonjsModule(function(t,e){const i=e,s=t=>t;function r(t,e,i={}){return new Promise((r,n)=>{const o=new elements[t](e),l=i.onAbort||s,h=i.onSubmit||s;o.on("state",e.onState||s),o.on("submit",t=>r(h(t))),o.on("abort",t=>n(l(t)))})}i.text=(t=>r("TextPrompt",t)),i.password=(t=>(t.style="password",i.text(t))),i.invisible=(t=>(t.style="invisible",i.text(t))),i.number=(t=>r("NumberPrompt",t)),i.confirm=(t=>r("ConfirmPrompt",t)),i.list=(t=>{const e=t.separator||",";return r("TextPrompt",t,{onSubmit:t=>t.split(e).map(t=>t.trim())})}),i.toggle=(t=>r("TogglePrompt",t)),i.select=(t=>r("SelectPrompt",t)),i.multiselect=(t=>{t.choices=[].concat(t.choices||[]);const e=t=>t.filter(t=>t.selected).map(t=>t.value);return r("MultiselectPrompt",t,{onAbort:e,onSubmit:e})});const n=(t,e)=>Promise.resolve(e.filter(e=>e.title.slice(0,t.length).toLowerCase()===t.toLowerCase()));i.autocomplete=(t=>(t.suggest=t.suggest||n,t.choices=[].concat(t.choices||[]),r("AutocompletePrompt",t)))}),_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t};let prompt$1=(()=>{var t=_asyncToGenerator$1(function*(t=[],{onSubmit:e=noop,onCancel:i=noop}={}){const s={};let r,n,o,l,h;t=[].concat(t);let a=prompt$1._map||{};var u=!0,c=!1,d=void 0;try{for(var m,p=t[Symbol.iterator]();!(u=(m=p.next()).done);u=!0){var f=n=m.value;if(l=f.name,h=f.type,void 0===a[l]){for(let t in n){if(ignore.includes(t))continue;let e=n[t];n[t]="function"==typeof e?yield e(r,_extends({},s),n):e}if("string"!=typeof n.message)throw new Error("prompt message is required");var v=n;if(l=v.name,h=v.type){if(void 0===prompts[h])throw new Error(`prompt type (${h}) is not defined`);try{r=yield prompts[h](n),s[l]=r=n.format?yield n.format(r,s):r,o=e(n,r)}catch(t){o=!i(n)}if(o)return s}}else s[l]=a[l],delete a[l]}}catch(t){c=!0,d=t}finally{try{!u&&p.return&&p.return()}finally{if(c)throw d}}return s});return function(){return t.apply(this,arguments)}})();function _asyncToGenerator$1(t){return function(){var e=t.apply(this,arguments);return new Promise(function(t,i){return function s(r,n){try{var o=e[r](n),l=o.value}catch(t){return void i(t)}if(!o.done)return Promise.resolve(l).then(function(t){s("next",t)},function(t){s("throw",t)});t(l)}("next")})}}const ignore=["suggest","format","onState"],noop=()=>{};function inject(t){prompt$1._map=prompt$1._map||{};for(let e in t)prompt$1._map[e]=t[e]}var dist=Object.assign(prompt$1,{prompt:prompt$1,prompts:prompts,inject:inject}),action$2=t=>{if(t.ctrl){if("a"===t.name)return"first";if("c"===t.name)return"abort";if("d"===t.name)return"abort";if("e"===t.name)return"last";if("g"===t.name)return"reset"}return"return"===t.name?"submit":"enter"===t.name?"submit":"backspace"===t.name?"delete":"abort"===t.name?"abort":"escape"===t.name?"abort":"tab"===t.name?"next":"up"===t.name?"up":"down"===t.name?"down":"right"===t.name?"right":"left"===t.name&&"left"},strip$1=t=>{const e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),i=new RegExp(e,"g");return"string"==typeof t?t.replace(i,""):t};const{erase:erase$6,cursor:cursor$a}=src,width$1=t=>[...strip$1(t)].length;var clear$8=function(t,e=process.stdout.columns){if(!e)return erase$6.line+cursor$a.to(0);let i=0;const s=t.split(/\r?\n/);for(let t of s)i+=1+Math.floor(Math.max(width$1(t)-1,0)/e);return(erase$6.line+cursor$a.prevLine()).repeat(i-1)+erase$6.line+cursor$a.to(0)};const main$1={tick:"โ",cross:"โ",ellipsis:"โฆ",pointerSmall:"โบ",line:"โ",pointer:"โฏ"},win$1={tick:"โ",cross:"ร",ellipsis:"...",pointerSmall:"ยป",line:"โ",pointer:">"},figures$2="win32"===process.platform?win$1:main$1;var figures_1$1=figures$2;const styles$1=Object.freeze({password:{scale:1,render:t=>"*".repeat(t.length)},emoji:{scale:2,render:t=>"๐".repeat(t.length)},invisible:{scale:0,render:t=>""},default:{scale:1,render:t=>`${t}`}}),render$1=t=>styles$1[t]||styles$1.default,symbols$1=Object.freeze({aborted:kleur.red(figures_1$1.cross),done:kleur.green(figures_1$1.tick),default:kleur.cyan("?")}),symbol$1=(t,e)=>e?symbols$1.aborted:t?symbols$1.done:symbols$1.default,delimiter$1=t=>kleur.gray(t?figures_1$1.ellipsis:figures_1$1.pointerSmall),item$1=(t,e)=>kleur.gray(t?e?figures_1$1.pointerSmall:"+":figures_1$1.line);var style$7={styles:styles$1,render:render$1,symbols:symbols$1,symbol:symbol$1,delimiter:delimiter$1,item:item$1},util$1={action:action$2,clear:clear$8,style:style$7,strip:strip$1,figures:figures_1$1};const{action:action$3}=util$1,{beep:beep$2,cursor:cursor$b}=src;class Prompt$1 extends events{constructor(t={}){super(),this.in=t.in||process.stdin,this.out=t.out||process.stdout;const e=readline.createInterface(this.in);readline.emitKeypressEvents(this.in,e),this.in.isTTY&&this.in.setRawMode(!0);const i=(t,e)=>{let i=action$3(e);!1===i?this._&&this._(t,e):"function"==typeof this[i]?this[i](e):this.bell()};this.close=(()=>{this.out.write(cursor$b.show),this.in.removeListener("keypress",i),this.in.isTTY&&this.in.setRawMode(!1),e.close(),this.emit(this.aborted?"abort":"submit",this.value)}),this.in.on("keypress",i)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted})}bell(){this.out.write(beep$2)}}var prompt$2=Prompt$1;const{cursor:cursor$c}=src,{style:style$8,clear:clear$9}=util$1;class TextPrompt$1 extends prompt$2{constructor(t={}){super(t),this.transform=style$8.render(t.style),this.scale=this.transform.scale,this.msg=t.message,this.initial=t.initial||"",this.value="",this.cursor=Number(!!this.initial),this.clear=clear$9(""),this.render()}set value(t){!t&&this.initial?(this.placeholder=!0,this.rendered=kleur.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(t)),this._value=t,this.fire()}get value(){return this._value}reset(){this.value="",this.fire(),this.render()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.value=this.value||this.initial,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(t){this.placeholder||(this.cursor=this.cursor+t)}_(t,e){let i=this.value.slice(0,this.cursor),s=this.value.slice(this.cursor);this.moveCursor(1),this.value=`${i}${t}${s}`,this.placeholder&&(this.cursor=0),this.render()}delete(){if(0===this.value.length)return this.bell();let t=this.value.slice(0,this.cursor-1),e=this.value.slice(this.cursor);this.value=`${t}${e}`,this.moveCursor(-1),this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}render(){const t=[style$8.symbol(this.done,this.aborted),kleur.bold(this.msg),style$8.delimiter(this.done),this.rendered].join(" ");this.out.write(this.clear+t),this.out.write(cursor$c.move(this.placeholder?-this.initial.length*this.scale:-this.rendered.length+this.cursor*this.scale)),this.clear=clear$9(t)}}var text$1=TextPrompt$1;const{style:style$9,clear:clear$a}=util$1,{erase:erase$7,cursor:cursor$d}=src;class SelectPrompt$1 extends prompt$2{constructor(t={}){super(t),this.msg=t.message,this.hint=t.hint||"- Use arrow-keys. Return to submit.",this.cursor=t.initial||0,this.values=t.choices||[],this.value=t.choices[this.cursor].value,this.clear=clear$a(""),this.render(!0)}moveCursor(t){this.cursor=t,this.value=this.values[t].value,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.values.length-1),this.render()}up(){if(0===this.cursor)return this.bell();this.moveCursor(this.cursor-1),this.render()}down(){if(this.cursor===this.values.length-1)return this.bell();this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.values.length),this.render()}_(t,e){if(" "===t)return this.submit()}render(t){t?this.out.write(cursor$d.hide):this.out.write(erase$7.lines(this.values.length+1)),this.out.write([style$9.symbol(this.done,this.aborted),kleur.bold(this.msg),style$9.delimiter(!1),this.done?this.values[this.cursor].title:kleur.gray(this.hint)].join(" ")),this.done||this.out.write("\n"+this.values.map((t,e)=>{let i=this.cursor===e?kleur.cyan.underline(t.title):t.title;return`${this.cursor===e?kleur.cyan("โฏ "):" "} ${i}`}).join("\n"))}}var select$1=SelectPrompt$1;const{style:style$a,clear:clear$b}=util$1,{cursor:cursor$e,erase:erase$8}=src;class TogglePrompt$1 extends prompt$2{constructor(t={}){super(t),this.msg=t.message,this.value=!!t.initial,this.active=t.active,this.inactive=t.inactive,this.initialValue=this.value,this.render(!0)}reset(){this.value=this.initialValue,this.fire(),this.render()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}deactivate(){if(!1===this.value)return this.bell();this.value=!1,this.render()}activate(){if(!0===this.value)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(t,e){if(" "===t)this.value=!this.value,this.render();else if("1"===t)this.value=!0,this.render();else{if("0"!==t)return this.bell();this.value=!1,this.render()}}render(t){t&&this.out.write(cursor$e.hide),this.out.write(erase$8.lines(t?1:this.msg.split(/\n/g).length)+cursor$e.to(0)+[style$a.symbol(this.done,this.aborted),kleur.bold(this.msg),style$a.delimiter(this.done),this.value?this.inactive:kleur.cyan.underline(this.inactive),kleur.gray("/"),this.value?kleur.cyan.underline(this.active):this.active].join(" "))}}var toggle$1=TogglePrompt$1;const{cursor:cursor$f,erase:erase$9}=src,{style:style$b,clear:clear$c}=util$1,isNumber$1=/[0-9]/,isDef$1=t=>void 0!==t,round$1=(t,e)=>{let i=Math.pow(10,e);return Math.round(t*i)/i};class NumberPrompt$1 extends prompt$2{constructor(t={}){super(t),this.transform=style$b.render(t.style),this.msg=t.message,this.initial=isDef$1(t.initial)?t.initial:"",this.float=!!t.float,this.round=t.round||2,this.inc=t.increment||1,this.min=isDef$1(t.min)?t.min:-1/0,this.max=isDef$1(t.max)?t.max:1/0,this.value="",this.typed="",this.lastHit=0,this.render()}set value(t){t||0===t?(this.placeholder=!1,this.rendered=this.transform.render(`${round$1(t,this.round)}`),this._value=round$1(t,this.round)):(this.placeholder=!0,this.rendered=kleur.gray(this.transform.render(`${this.initial}`)),this._value=""),this.fire()}get value(){return this._value}parse(t){return this.float?parseFloat(t):parseInt(t)}valid(t){return"-"===t||"."===t&&this.float||isNumber$1.test(t)}reset(){this.typed="",this.value="",this.fire(),this.render()}abort(){let t=this.value;this.value=""!==t?t:this.initial,this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){let t=this.value;this.value=""!==t?t:this.initial,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}up(){if(this.typed="",this.value>=this.max)return this.bell();this.value+=this.inc,this.fire(),this.render()}down(){if(this.typed="",this.value<=this.min)return this.bell();this.value-=this.inc,this.fire(),this.render()}delete(){let t=this.value.toString();if(0===t.length)return this.bell();this.value=this.parse(t=t.slice(0,-1))||"",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(t,e){if(!this.valid(t))return this.bell();const i=Date.now();if(i-this.lastHit>1e3&&(this.typed=""),this.typed+=t,this.lastHit=i,"."===t)return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){let t=!this.done||!this.done&&!this.placeholder;this.out.write(erase$9.line+cursor$f.to(0)+[style$b.symbol(this.done,this.aborted),kleur.bold(this.msg),style$b.delimiter(this.done),t?kleur.cyan.underline(this.rendered):this.rendered].join(" "))}}var number$1=NumberPrompt$1;const{cursor:cursor$g}=src,{clear:clear$d,figures:figures$3,style:style$c}=util$1;class MultiselectPrompt$1 extends prompt$2{constructor(t={}){super(t),this.msg=t.message,this.cursor=t.cursor||0,this.hint=t.hint||"- Space to select. Return to submit",this.maxChoices=t.max,this.value=t.choices.map(t=>Object.assign({title:t.value,selected:!1},t)),this.clear=clear$d(""),this.render(!0)}reset(){this.value.map(t=>!t.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(t=>t.selected)}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){if(0===this.cursor)return this.bell();this.cursor--,this.render()}down(){if(this.cursor===this.value.length-1)return this.bell();this.cursor++,this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}_(t,e){if(" "!==t)return this.bell();const i=this.value[this.cursor];if(i.selected)i.selected=!1,this.render();else{if(this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();i.selected=!0,this.render()}}render(t){t&&this.out.write(cursor$g.hide);const e=this.value.filter(t=>t.selected).map(t=>t.title).join(", ");let i=[style$c.symbol(this.done,this.aborted),kleur.bold(this.msg),style$c.delimiter(!1),this.done?e:kleur.gray(this.hint)].join(" ");if(!this.done){const t=this.cursor;i+="\n"+this.value.map((e,i)=>(e.selected?kleur.green(figures$3.tick):" ")+" "+(t===i?kleur.cyan.underline(e.title):e.title)).join("\n")}this.out.write(this.clear+i),this.clear=clear$d(i)}}var multiselect$1=MultiselectPrompt$1;const{cursor:cursor$h}=src,getVal$1=(t,e)=>t[e]&&(t[e].value||t[e].title||t[e]);class AutocompletePrompt$1 extends prompt$2{constructor(t={}){super(t),this.msg=t.message,this.suggest=t.suggest,this.choices=t.choices,this.initial=t.initial,this.cursor=t.initial||t.cursor||0,this.fallback=t.fallback||void 0!==t.initial?`โบ ${getVal$1(this.choices,this.initial)}`:"โบ no matches found",this.suggestions=[],this.input="",this.limit=t.limit||10,this.transform=util$1.style.render(t.style),this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=util$1.clear(""),this.complete(this.render),this.render(!0)}moveCursor(t){this.cursor=t,this.suggestions.length>0?this.value=getVal$1(this.suggestions,t):this.value=void 0!==this.initial?getVal$1(this.choices,this.initial):null,this.fire()}async complete(t){const e=this.completing=this.suggest(this.input,this.choices),i=await e;if(this.completing!==e)return;this.suggestions=i.slice(0,this.limit).map(t=>util$1.strip(t)),this.completing=!1;const s=Math.max(i.length-1,0);this.moveCursor(Math.min(s,this.cursor)),t&&t()}reset(){this.input="",this.complete(()=>{this.moveCursor(void 0!==this.initial?this.initial:0),this.render()}),this.render()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}_(t,e){this.input+=t,this.complete(this.render),this.render()}delete(){if(0===this.input.length)return this.bell();this.input=this.input.slice(0,-1),this.complete(this.render),this.render()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.suggestions.length-1),this.render()}up(){if(this.cursor<=0)return this.bell();this.moveCursor(this.cursor-1),this.render()}down(){if(this.cursor>=this.suggestions.length-1)return this.bell();this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.suggestions.length),this.render()}render(t){t&&this.out.write(cursor$h.hide);let e=[util$1.style.symbol(this.done,this.aborted),this.msg,util$1.style.delimiter(this.completing),this.done&&this.suggestions[this.cursor]?this.suggestions[this.cursor].title:this.transform.render(this.input)].join(" ");if(!this.done){let t=this.suggestions.map((t,e)=>`\n${e===this.cursor?kleur.cyan(t.title):t.title}`);e+=t.length?t.reduce((t,e)=>t+e,""):`\n${kleur.gray(this.fallback)}`}this.out.write(this.clear+e),this.clear=util$1.clear(e)}}var autocomplete$1=AutocompletePrompt$1;const{style:style$d,clear:clear$e}=util$1,{erase:erase$a,cursor:cursor$i}=src;class ConfirmPrompt$1 extends prompt$2{constructor(t={}){super(t),this.msg=t.message,this.value=t.initial,this.initialValue=!!t.initial,this.render(!0)}reset(){this.value=this.initialValue,this.fire(),this.render()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}_(t,e){return"y"===t.toLowerCase()?(this.value=!0,this.submit()):"n"===t.toLowerCase()?(this.value=!1,this.submit()):this.bell()}render(t){t&&this.out.write(cursor$i.hide),this.out.write(erase$a.line+cursor$i.to(0)+[style$d.symbol(this.done,this.aborted),kleur.bold(this.msg),style$d.delimiter(this.done),this.done?this.value?"yes":"no":kleur.gray(this.initialValue?"(Y/n)":"(y/N)")].join(" "))}}var confirm$1=ConfirmPrompt$1,elements$1={TextPrompt:text$1,SelectPrompt:select$1,TogglePrompt:toggle$1,NumberPrompt:number$1,MultiselectPrompt:multiselect$1,AutocompletePrompt:autocomplete$1,ConfirmPrompt:confirm$1},prompts$1=createCommonjsModule(function(t,e){const i=e,s=t=>t;function r(t,e,i={}){return new Promise((r,n)=>{const o=new elements$1[t](e),l=i.onAbort||s,h=i.onSubmit||s;o.on("state",e.onState||s),o.on("submit",t=>r(h(t))),o.on("abort",t=>n(l(t)))})}i.text=(t=>r("TextPrompt",t)),i.password=(t=>(t.style="password",i.text(t))),i.invisible=(t=>(t.style="invisible",i.text(t))),i.number=(t=>r("NumberPrompt",t)),i.confirm=(t=>r("ConfirmPrompt",t)),i.list=(t=>{const e=t.separator||",";return r("TextPrompt",t,{onSubmit:t=>t.split(e).map(t=>t.trim())})}),i.toggle=(t=>r("TogglePrompt",t)),i.select=(t=>r("SelectPrompt",t)),i.multiselect=(t=>{t.choices=[].concat(t.choices||[]);const e=t=>t.filter(t=>t.selected).map(t=>t.value);return r("MultiselectPrompt",t,{onAbort:e,onSubmit:e})});const n=(t,e)=>Promise.resolve(e.filter(e=>e.title.slice(0,t.length).toLowerCase()===t.toLowerCase()));i.autocomplete=(t=>(t.suggest=t.suggest||n,t.choices=[].concat(t.choices||[]),r("AutocompletePrompt",t)))});const ignore$1=["suggest","format","onState"],noop$1=()=>{};async function prompt$3(t=[],{onSubmit:e=noop$1,onCancel:i=noop$1}={}){const s={};let r,n,o,l,h;t=[].concat(t);let a=prompt$3._map||{};for(n of t)if(({name:l,type:h}=n),void 0===a[l]){for(let t in n){if(ignore$1.includes(t))continue;let e=n[t];n[t]="function"==typeof e?await e(r,{...s},n):e}if("string"!=typeof n.message)throw new Error("prompt message is required");if(({name:l,type:h}=n),h){if(void 0===prompts$1[h])throw new Error(`prompt type (${h}) is not defined`);try{r=await prompts$1[h](n),s[l]=r=n.format?await n.format(r,s):r,o=e(n,r)}catch(t){o=!i(n)}if(o)return s}}else s[l]=a[l],delete a[l];return s}function inject$1(t){prompt$3._map=prompt$3._map||{};for(let e in t)prompt$3._map[e]=t[e]}var lib=Object.assign(prompt$3,{prompt:prompt$3,prompts:prompts$1,inject:inject$1}),prompts$2=parseInt(process.versions.node,10)<8?dist:lib;const STARTERS=[{name:"component",repo:"ionic-team/stencil-component-starter",description:"Collection of web components that can be used anywhere",docs:"https://github.com/ionic-team/stencil-component-starter"},{name:"components",repo:"ionic-team/stencil-component-starter",description:"Collection of web components that can be used anywhere",docs:"https://github.com/ionic-team/stencil-component-starter",hidden:!0},{name:"app",repo:"ionic-team/stencil-app-starter",description:"Minimal starter for building a Stencil app or website",docs:"https://github.com/ionic-team/stencil-app-starter"},{name:"ionic-pwa",repo:"ionic-team/ionic-pwa-toolkit",description:"Everything you need to build fast, production ready PWAs",docs:"https://stenciljs.com/pwa/"}];function getStarterRepo(t){if(t.includes("/"))return{name:t,repo:t};const e=STARTERS.find(e=>e.name===t);if(!e)throw new Error(`Starter "${t}" does not exist.`);return e}var __awaiter$1=function(t,e,i,s){return new(i||(i=Promise))(function(r,n){function o(t){try{h(s.next(t))}catch(t){n(t)}}function l(t){try{h(s.throw(t))}catch(t){n(t)}}function h(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(o,l)}h((s=s.apply(t,e||[])).next())})};function runInteractive(t){return __awaiter$1(this,void 0,void 0,function*(){console.log("๐ Welcome to Stencil Create App!\n"),t||(t=yield askStarterName());const e=getStarterRepo(t),i=yield askProjectName();(yield askConfirm(e,i))?yield createApp(e,i):console.log("\n aborting, bye bye \n")})}function askStarterName(){return __awaiter$1(this,void 0,void 0,function*(){console.log(" What kind of project do you want to create? \n");const{starterName:t}=yield prompts$2([{type:"select",name:"starterName",message:"Pick a starter",choices:getChoices()},{type:t=>null===t?"text":null,name:"starterName",message:"Type a custom starter"}]);if(!t)throw new Error("No starter was provided, try again.");return t})}function getChoices(){const t=Math.max(...STARTERS.map(t=>t.name.length))+1;return[...STARTERS.filter(t=>!0!==t.hidden).map(e=>({title:`๐ ${padEnd(e.name,t)} (${e.description})`,value:e.name})),{title:"Other (specify)",value:null}]}function askProjectName(){return __awaiter$1(this,void 0,void 0,function*(){const{projectName:t}=yield prompts$2([{type:"text",name:"projectName",message:"Project name"}]);if(!t)throw new Error("No project name was provided, try again.");return t})}function askConfirm(t,e){return __awaiter$1(this,void 0,void 0,function*(){console.log(`\nWe are about to clone "${t.repo}" into "./${e}"`);const{confirm:i}=yield prompts$2([{type:"confirm",name:"confirm",message:"Confirm?"}]);return i})}function padEnd(t,e,i=" "){return e>>=0,t.length>e?t:((e-=t.length)>i.length&&(i+=i.repeat(e/i.length)),String(t)+i.slice(0,e))}var __awaiter$2=function(t,e,i,s){return new(i||(i=Promise))(function(r,n){function o(t){try{h(s.next(t))}catch(t){n(t)}}function l(t){try{h(s.throw(t))}catch(t){n(t)}}function h(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(o,l)}h((s=s.apply(t,e||[])).next())})};const USAGE_DOCS="Usage:\n\nnpm init stencil [starter] [project-name]\n";function run$1(){return __awaiter$2(this,void 0,void 0,function*(){const t=process.argv.slice(2);if(t.indexOf("--help")>=0)return console.log(USAGE_DOCS),0;try{if(2===t.length)yield createApp(getStarterRepo(t[0]),t[1]);else{if(!(t.length<2))throw new Error(USAGE_DOCS);yield runInteractive(t[0])}}catch(t){return console.error(`\nโ ${t.message}\n`),-1}})}run$1(); |
{ | ||
"name": "create-stencil", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"description": "Quickly create a new stencil application: npm init stencil", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
46297
2