create-mcbe 0.1.0-beta.1 → 0.1.0-beta.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.js
CHANGED
|
@@ -1,51 +1,53 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as e}from"node:module";import{styleText as t}from"node:util";import n,{stdin as r,stdout as i}from"node:process";import a from"node:readline";import o from"node:path";import s from"node:fs/promises";import{spawn as c}from"node:child_process";import l from"node:crypto";import{fileURLToPath as u}from"node:url";var d=Object.create,f=Object.defineProperty,p=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyNames,h=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty,_=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),v=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=m(t),a=0,o=i.length,s;a<o;a++)s=i[a],!g.call(e,s)&&s!==n&&f(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=p(t,s))||r.enumerable});return e},y=(e,t,n)=>(n=e==null?{}:d(h(e)),v(t||!e||!e.__esModule?f(n,`default`,{value:e,enumerable:!0}):n,e));const
|
|
3
|
-
`),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===``){
|
|
4
|
-
`){a&&(r+=
|
|
5
|
-
`&&(i&&
|
|
6
|
-
`)}var
|
|
2
|
+
import{createRequire as e}from"node:module";import{styleText as t}from"node:util";import n,{stdin as r,stdout as i}from"node:process";import a from"node:readline";import o from"node:path";import s from"node:fs/promises";import{spawn as c}from"node:child_process";import l from"node:crypto";import{fileURLToPath as u}from"node:url";var d=Object.create,f=Object.defineProperty,p=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyNames,h=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty,_=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),v=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=m(t),a=0,o=i.length,s;a<o;a++)s=i[a],!g.call(e,s)&&s!==n&&f(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=p(t,s))||r.enumerable});return e},y=(e,t,n)=>(n=e==null?{}:d(h(e)),v(t||!e||!e.__esModule||!g.call(e,`default`)?f(n,`default`,{value:e,enumerable:!0}):n,e));const ee=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),b=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,te=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,ne=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,re=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,ie=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,ae=/\t{1,1000}/y,oe=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,se=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,ce=/\p{M}+/gu,le={limit:1/0,ellipsis:``},x=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?x(i,le,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[se,l],[ne,0],[re,o],[ae,s],[oe,c],[ie,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,S=0,C=0,w=0;outer:for(;;){if(S>y||p>=m&&p>f){let t=e.slice(y,S)||e.slice(f,p);h=0;for(let e of t.replaceAll(ce,``)){let t=e.codePointAt(0)||0;if(w=b(t)?2:te(t)?u:l,C+w>v&&(_=Math.min(_,Math.max(y,f)+h)),C+w>r){g=!0;break outer}h+=e.length,C+=w}y=S=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===ie?ee(e.slice(p,n.lastIndex)):n===oe?1:n.lastIndex-p,w=h*i,C+w>v&&(_=Math.min(_,p+Math.floor((v-C)/i))),C+w>r){g=!0;break outer}C+=w,y=f,S=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:C,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},S={limit:1/0,ellipsis:``,ellipsisWidth:0},C=(e,t={})=>x(e,S,t).width,w=`]8;;`,ue=RegExp(`(?:\\[(?<code>\\d+)m|\\${w}(?<uri>.*))`,`y`),de=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},fe=e=>`[${e}m`,pe=e=>`${w}${e}`,T=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:C(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=C(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===``)&&(i=!0,a=t.startsWith(w,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},me=e=>{let t=e.split(` `),n=t.length;for(;n&&!C(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},he=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=C(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=C(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),T(s,r,t),c=C(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){T(s,r,t),c=C(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){T(s,r,t),c=C(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>me(e)));let l=s.join(`
|
|
3
|
+
`),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===``){ue.lastIndex=e+1;let t=ue.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
|
|
4
|
+
`){a&&(r+=pe(``));let e=i?de(i):void 0;i&&e&&(r+=fe(e))}else t===`
|
|
5
|
+
`&&(i&&de(i)&&(r+=fe(i)),a&&(r+=pe(a)))}return r},ge=/\r?\n/;function E(e,t,n){return String(e).normalize().split(ge).map(e=>he(e,t,n)).join(`
|
|
6
|
+
`)}var D=(/* @__PURE__ */ _(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})))();function O(e,t,n){if(!n.some(e=>!e.disabled))return e;let r=e+t,i=Math.max(n.length-1,0),a=r<0?i:r>i?0:r;return n[a]?.disabled?O(a,t<0?-1:1,n):a}const k={actions:/* @__PURE__ */ new Set([`up`,`down`,`left`,`right`,`space`,`enter`,`cancel`]),aliases:/* @__PURE__ */ new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`],[``,`cancel`],[`escape`,`cancel`]]),messages:{cancel:`Canceled`,error:`Something went wrong`},withGuide:!0,accessible:void 0,date:{monthNames:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],messages:{required:`Please enter a valid date`,invalidMonth:`There are only 12 months in a year`,invalidDay:(e,t)=>`There are only ${e} days in ${t}`,afterMin:e=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:e=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function _e(e){if(e!==void 0)return e;if(k.accessible!==void 0)return k.accessible;let t=process.env.ACCESSIBLE;return t!==void 0&&t!==``&&t!==`0`&&t!==`false`}function ve(e,t){if(typeof e==`string`)return k.aliases.get(e)===t;for(let n of e)if(n!==void 0&&ve(n,t))return!0;return!1}function ye(e,t){if(e===t)return;let n=e.split(`
|
|
7
7
|
`),r=t.split(`
|
|
8
|
-
`),i=Math.max(n.length,r.length),a=[];for(let e=0;e<i;e++)n[e]!==r[e]&&a.push(e);return{lines:a,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}globalThis.process.platform.startsWith(`win`);const
|
|
8
|
+
`),i=Math.max(n.length,r.length),a=[];for(let e=0;e<i;e++)n[e]!==r[e]&&a.push(e);return{lines:a,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}globalThis.process.platform.startsWith(`win`);const A=Symbol(`clack:cancel`);function j(e){return e===A}function M(e,t){let n=e;n.isTTY&&n.setRawMode(t)}const N=e=>`columns`in e&&typeof e.columns==`number`?e.columns:80,P=e=>`rows`in e&&typeof e.rows==`number`?e.rows:20;function F(e,t,n,r=n,a=n,o){return E(t,N(e??i)-n.length,{hard:!0,trim:!1}).split(`
|
|
9
9
|
`).map((e,t,i)=>{let s=o?o(e,t):e;return t===0?`${r}${s}`:t===i.length-1?`${a}${s}`:`${n}${s}`}).join(`
|
|
10
|
-
`)}function
|
|
11
|
-
`),
|
|
12
|
-
`).length-1;this.output.write(
|
|
13
|
-
`);this.output.write(t[a]),this._prevFrame=e,this.output.write(
|
|
10
|
+
`)}function be(e,t){if(`~standard`in e){let n=e[`~standard`].validate(t);return n instanceof Promise?n.then(e=>e.issues?.at(0)?.message):n.issues?.at(0)?.message}return e(t)}var I=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame=``;_subscribers=/* @__PURE__ */ new Map;_cursor=0;state=`initial`;error=``;value;userInput=``;get accessible(){return _e(this.opts.accessible)}constructor(e,t=!0){let{input:n=r,output:a=i,render:o,signal:s,...c}=e;this.opts=c,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=o.bind(this),this._track=t,this._abortSignal=s,this.input=n,this.output=a}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state=`cancel`,this.close(),e(A);this._abortSignal.addEventListener(`abort`,()=>{this.state=`cancel`,this.close()},{once:!0})}this.rl=a.createInterface({input:this.input,tabSize:2,prompt:``,escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on(`keypress`,this.onKeypress),M(this.input,!0),this.output.on(`resize`,this.render),this.render(),this.once(`submit`,()=>{this.output.write(D.cursor.show),this.output.off(`resize`,this.render),M(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(D.cursor.show),this.output.off(`resize`,this.render),M(this.input,!1),e(A)})})}_isActionKey(e,t){return e===` `}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit(`value`,this.value)}_setUserInput(e,t){this.userInput=e??``,this.emit(`userInput`,this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:`u`}),this._setUserInput(``)}async onKeypress(e,t){if(this.state!==`validating`){if(this._track&&t.name!==`return`&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:`h`}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state===`error`&&(this.state=`active`),t?.name&&(!this._track&&k.aliases.has(t.name)&&this.emit(`cursor`,k.aliases.get(t.name)),k.actions.has(t.name)&&this.emit(`cursor`,t.name)),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),this.emit(`key`,e,t),t?.name===`return`&&this._shouldSubmit(e,t)){if(this.opts.validate){let e=be(this.opts.validate,this.value),t;e instanceof Promise?(this.state=`validating`,this.render(),t=await e):t=e,t&&(this.error=t instanceof Error?t.message:t,this.state=`error`,this.rl?.write(this.userInput))}this.state!==`error`&&(this.state=`submit`)}ve([e,t?.name,t?.sequence],`cancel`)&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
|
|
11
|
+
`),M(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=E(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
12
|
+
`).length-1;this.output.write(D.cursor.move(-999,e*-1))}render(){let e=E(this._render(this)??``,process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(D.cursor.hide);else{let t=ye(this._prevFrame,e),n=P(this.output);if(this.restoreCursor(),t){let r=Math.max(0,t.numLinesAfter-n),i=Math.max(0,t.numLinesBefore-n),a=t.lines.find(e=>e>=r);if(a===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(D.cursor.move(0,a-i)),this.output.write(D.erase.lines(1));let t=e.split(`
|
|
13
|
+
`);this.output.write(t[a]),this._prevFrame=e,this.output.write(D.cursor.move(0,t.length-a-1));return}if(t.lines.length>1){if(r<i)a=r;else{let e=a-i;e>0&&this.output.write(D.cursor.move(0,e))}this.output.write(D.erase.down());let t=e.split(`
|
|
14
14
|
`).slice(a);this.output.write(t.join(`
|
|
15
|
-
`)),this._prevFrame=e;return}}this.output.write(
|
|
16
|
-
`);_.push(a),v+=a.length}if(v>d){let t=0,n=0,r=v,i=e-y,a=d,o=()=>
|
|
15
|
+
`)),this._prevFrame=e;return}}this.output.write(D.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},xe=class extends I{get cursor(){return+!this.value}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`userInput`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(D.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}};let Se=class extends I{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let e=this._selectedValue;this.value=e===void 0?void 0:e.value}constructor(e){super(e,!1),this.options=e.options;let t=this.options.findIndex(({value:t})=>t===e.initialValue),n=t===-1?0:t;this.cursor=this.options[n]?.disabled?O(n,1,this.options):n,this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=O(this.cursor,-1,this.options);break;case`down`:case`right`:this.cursor=O(this.cursor,1,this.options)}this.changeValue()})}};var Ce=class extends I{get userInputWithCursor(){if(this.state===`submit`)return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}\u2588`;let n=e.slice(0,this.cursor),r=e.slice(this.cursor,this.cursor+1),i=e.slice(this.cursor+1);return`${n}${t(`inverse`,r)}${i}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on(`userInput`,e=>{this._setValue(e)}),this.on(`finalize`,()=>{this.value||=e.defaultValue,this.value===void 0&&(this.value=``)})}};function we(){return n.platform===`win32`?!!n.env.CI||!!n.env.WT_SESSION||!!n.env.TERMINUS_SUBLIME||n.env.ConEmuTask===`{cmd::Cmder}`||n.env.TERM_PROGRAM===`Terminus-Sublime`||n.env.TERM_PROGRAM===`vscode`||n.env.TERM===`xterm-256color`||n.env.TERM===`alacritty`||n.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:n.env.TERM!==`linux`}const Te=we(),L=(e,t)=>Te?e:t,Ee=L(`◆`,`*`),De=L(`■`,`x`),Oe=L(`▲`,`x`),ke=L(`◇`,`o`),R=L(`│`,`|`),z=L(`└`,`—`),B=L(`●`,`>`),V=L(`○`,` `),H=e=>{switch(e){case`initial`:case`active`:return t(`cyan`,Ee);case`cancel`:return t(`red`,De);case`error`:return t(`yellow`,Oe);case`submit`:return t(`green`,ke);case`validating`:return t(`dim`,Ee)}},Ae=e=>{switch(e){case`initial`:case`active`:return t(`cyan`,R);case`cancel`:return t(`red`,R);case`error`:return t(`yellow`,R);case`submit`:return t(`green`,R)}};function je(e,n){let r=[`${n?`${t(`cyan`,R)} `:``}${e.join(` • `)}`];return n&&r.push(t(`cyan`,z)),r}const Me=(e,t,n,r,i,a=!1)=>{let o=t,s=0;if(a)for(let t=r-1;t>=n;t--){let n=e[t];if(n&&(o-=n.length),s++,o<=i)break}else for(let t=n;t<r;t++){let n=e[t];if(n&&(o-=n.length),s++,o<=i)break}return{lineCount:o,removals:s}},Ne=({cursor:e,options:n,style:r,output:i=process.stdout,maxItems:a=1/0,columnPadding:o=0,rowPadding:s=4})=>{let c=N(i)-o,l=P(i),u=t(`dim`,`...`),d=Math.max(l-s,0),f=Math.max(Math.min(a,d),5),p=0;e>=f-3&&(p=Math.max(Math.min(e-f+3,n.length-f),0));let m=f<n.length&&p>0,h=f<n.length&&p+f<n.length,g=Math.min(p+f,n.length),_=[],v=0;m&&v++,h&&v++;let y=p+ +!!m,ee=g-+!!h;for(let t=y;t<ee;t++){let i=n[t],a=E(i?r(i,t===e):``,c,{hard:!0,trim:!1}).split(`
|
|
16
|
+
`);_.push(a),v+=a.length}if(v>d){let t=0,n=0,r=v,i=e-y,a=d,o=()=>Me(_,r,0,i,a),s=()=>Me(_,r,i+1,_.length,a,!0);m?({lineCount:r,removals:t}=o(),r>a&&(h||--a,{lineCount:r,removals:n}=s())):(h||--a,{lineCount:r,removals:n}=s(),r>a&&(--a,{lineCount:r,removals:t}=o())),t>0&&(m=!0,_.splice(0,t)),n>0&&(h=!0,_.splice(_.length-n,n))}let b=[];m&&b.push(u);for(let e of _)for(let t of e)b.push(t);return h&&b.push(u),b},Pe=e=>{let n=e.active??`Yes`,r=e.inactive??`No`;return new xe({active:n,inactive:r,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=e.withGuide??k.withGuide,a=`${H(this.state)} `,o=i?`${t(`gray`,R)} `:``,s=F(e.output,e.message,o,a),c=`${i?`${t(`gray`,R)}
|
|
17
17
|
`:``}${s}
|
|
18
|
-
`,l=this.value?n:r;switch(this.state){case`submit`:return`${c}${i?`${t(`gray`,
|
|
19
|
-
${t(`gray`,
|
|
20
|
-
${t(`cyan`,
|
|
21
|
-
`:` ${t(`dim`,`/`)} `}${this.value?`${t(`dim`,
|
|
18
|
+
`,l=this.value?n:r;switch(this.state){case`submit`:return`${c}${i?`${t(`gray`,R)} `:``}${t(`dim`,l)}`;case`cancel`:return`${c}${i?`${t(`gray`,R)} `:``}${t([`strikethrough`,`dim`],l)}${i?`
|
|
19
|
+
${t(`gray`,R)}`:``}`;default:{let a=i?`${t(`cyan`,R)} `:``,o=i?t(`cyan`,z):``;return`${c}${a}${this.value?`${t(`green`,B)} ${n}`:`${t(`dim`,V)} ${t(`dim`,n)}`}${e.vertical?i?`
|
|
20
|
+
${t(`cyan`,R)} `:`
|
|
21
|
+
`:` ${t(`dim`,`/`)} `}${this.value?`${t(`dim`,V)} ${t(`dim`,r)}`:`${t(`green`,B)} ${r}`}
|
|
22
22
|
${o}
|
|
23
|
-
`}}}}).prompt()};`${t(`dim`,`↑/↓`)}`,`${t(`dim`,`Space:`)}`,`${t(`dim`,`Enter:`)}`;const
|
|
23
|
+
`}}}}).prompt()};`${t(`dim`,`↑/↓`)}`,`${t(`dim`,`Space:`)}`,`${t(`dim`,`Enter:`)}`;const Fe=(e=``,n)=>{let r=n?.output??process.stdout,i=n?.withGuide??k.withGuide?`${t(`gray`,z)} `:``;r.write(`${i}${t(`red`,e)}
|
|
24
24
|
|
|
25
|
-
`)},
|
|
26
|
-
${t(`gray`,
|
|
25
|
+
`)},Ie=(e=``,n)=>{let r=n?.output??process.stdout,i=n?.withGuide??k.withGuide?`${t(`gray`,R)}
|
|
26
|
+
${t(`gray`,z)} `:``;r.write(`${i}${e}
|
|
27
27
|
|
|
28
|
-
`)},
|
|
28
|
+
`)},Le=[`${t(`dim`,`↑/↓`)} to navigate`,`${t(`dim`,`Enter:`)} confirm`],U=(e,t)=>e.includes(`
|
|
29
29
|
`)?e.split(`
|
|
30
30
|
`).map(e=>t(e)).join(`
|
|
31
|
-
`):t(e),
|
|
31
|
+
`):t(e),W=e=>{let n=(e,n)=>{if(e===void 0)return``;let r=e.label??String(e.value);switch(n){case`disabled`:return`${t(`gray`,V)} ${U(r,e=>t(`gray`,e))}${e.hint?` ${t(`dim`,`(${e.hint??`disabled`})`)}`:``}`;case`selected`:return`${U(r,e=>t(`dim`,e))}`;case`active`:return`${t(`green`,B)} ${r}${e.hint?` ${t(`dim`,`(${e.hint})`)}`:``}`;case`cancelled`:return`${U(r,e=>t([`strikethrough`,`dim`],e))}`;default:return`${t(`dim`,V)} ${U(r,e=>t(`dim`,e))}`}},r=e.showInstructions??!0;return new Se({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let i=e.withGuide??k.withGuide,a=`${H(this.state)} `,o=`${Ae(this.state)} `,s=F(e.output,e.message,o,a),c=`${i?`${t(`gray`,R)}
|
|
32
32
|
`:``}${s}
|
|
33
|
-
`;switch(this.state){case`submit`:{let r=i?`${t(`gray`,
|
|
34
|
-
${t(`gray`,
|
|
35
|
-
`).length,s=r?
|
|
36
|
-
`),u=s.length+1;return`${c}${a}${
|
|
33
|
+
`;switch(this.state){case`submit`:{let r=i?`${t(`gray`,R)} `:``;return`${c}${F(e.output,n(this.options[this.cursor],`selected`),r)}`}case`cancel`:{let r=i?`${t(`gray`,R)} `:``;return`${c}${F(e.output,n(this.options[this.cursor],`cancelled`),r)}${i?`
|
|
34
|
+
${t(`gray`,R)}`:``}`}default:{let a=i?`${t(`cyan`,R)} `:``,o=c.split(`
|
|
35
|
+
`).length,s=r?je(Le,i):i?[t(`cyan`,z)]:[],l=s.join(`
|
|
36
|
+
`),u=s.length+1;return`${c}${a}${Ne({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:a.length,rowPadding:o+u,style:(e,t)=>n(e,e.disabled?`disabled`:t?`active`:`inactive`)}).join(`
|
|
37
37
|
${a}`)}
|
|
38
38
|
${l}
|
|
39
|
-
`}}}}).prompt()};`${t(`gray`,
|
|
40
|
-
`:``}${
|
|
41
|
-
`,i=e.placeholder&&e.placeholder.length>0?t(`inverse`,e.placeholder[0])+t(`dim`,e.placeholder.slice(1)):t([`inverse`,`hidden`],`_`),a=this.userInput?this.userInputWithCursor:i,o=this.value??``;switch(this.state){case`
|
|
39
|
+
`}}}}).prompt()};`${t(`gray`,R)}`;const Re=e=>new Ce({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let n=e?.withGuide??k.withGuide,r=`${`${n?`${t(`gray`,R)}
|
|
40
|
+
`:``}${H(this.state)} `}${e.message}
|
|
41
|
+
`,i=e.placeholder&&e.placeholder.length>0?t(`inverse`,e.placeholder[0])+t(`dim`,e.placeholder.slice(1)):t([`inverse`,`hidden`],`_`),a=this.userInput?this.userInputWithCursor:i,o=this.value??``;switch(this.state){case`validating`:{let e=n?`${t(`cyan`,R)} `:``,i=n?t(`cyan`,z):``;return`${r}${e}${t(`dim`,a)}
|
|
42
|
+
${i} ${t(`dim`,`Validating...`)}
|
|
43
|
+
`}case`error`:{let e=this.error?` ${t(`yellow`,this.error)}`:``,i=n?`${t(`yellow`,R)} `:``,o=n?t(`yellow`,z):``;return`${r.trim()}
|
|
42
44
|
${i}${a}
|
|
43
45
|
${o}${e}
|
|
44
|
-
`}case`submit`:{let e=o?` ${t(`dim`,o)}`:``;return`${r}${n?t(`gray`,
|
|
45
|
-
${i}`:``}`}default:return`${r}${n?`${t(`cyan`,
|
|
46
|
-
${n?t(`cyan`,
|
|
47
|
-
`}}}).prompt();let
|
|
48
|
-
$1$2: `),i=t?r.replace(/^\{\n/,n?`{\n plugins: [${t.call}],\n`:`{\n plugins: ['${t.name}'],\n`):r,a=n&&t?`import { defineConfig, ${t.importName} } from '@bepack/cli';`:n?`import { defineConfig } from '@bepack/cli';`:``,o=n?`defineConfig(${i})`:i;return`${a?`${a}\n\n`:``}export default ${o};\n`}function
|
|
49
|
-
`));let n=await
|
|
50
|
-
Next steps:`);for(let t of e.nextSteps)console.log(` ${t}`)}function
|
|
51
|
-
`)}\n`}await
|
|
46
|
+
`}case`submit`:{let e=o?`${n?` `:``}${t(`dim`,o)}`:``;return`${r}${n?t(`gray`,R):``}${e}`}case`cancel`:{let e=o?` ${t([`strikethrough`,`dim`],o)}`:``,i=n?t(`gray`,R):``;return`${r}${i}${e}${o.trim()?`
|
|
47
|
+
${i}`:``}`}default:return`${r}${n?`${t(`cyan`,R)} `:``}${a}
|
|
48
|
+
${n?t(`cyan`,z):``}
|
|
49
|
+
`}}}).prompt();let G=!0;const K=typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{};let ze=0;if(K.process&&K.process.env&&K.process.stdout){let{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,NO_COLOR:n,TERM:r,COLORTERM:i}=K.process.env;G=t||n||e===`0`?!1:e===`1`||e===`2`||e===`3`?!0:r===`dumb`?!1:`CI`in K.process.env&&[`TRAVIS`,`CIRCLECI`,`APPVEYOR`,`GITLAB_CI`,`GITHUB_ACTIONS`,`BUILDKITE`,`DRONE`].some(e=>e in K.process.env)?!0:process.stdout.isTTY,G&&(ze=process.platform===`win32`||i&&(i===`truecolor`||i===`24bit`)?3:r&&(r.endsWith(`-256color`)||r.endsWith(`256`))?2:1)}let Be={enabled:G,supportLevel:ze};function q(e,t,n=1){let r=`\x1b[${e}m`,i=`\x1b[${t}m`,a=RegExp(`\\x1b\\[${t}m`,`g`);return e=>Be.enabled&&Be.supportLevel>=n?r+(``+e).replace(a,r)+i:``+e}q(0,0);const Ve=q(1,22),He=q(2,22);q(3,23),q(4,24),q(7,27),q(8,28),q(9,29),q(30,39);const Ue=q(31,39),We=q(32,39);q(33,39),q(34,39),q(35,39);const Ge=q(36,39);q(97,39),q(90,39),q(37,39),q(91,39),q(92,39),q(93,39),q(94,39),q(95,39),q(96,39),q(40,49),q(41,49),q(42,49),q(43,49),q(44,49),q(45,49),q(46,49),q(107,49),q(100,49),q(101,49),q(102,49),q(103,49),q(104,49),q(105,49),q(106,49),q(47,49);async function J(e){try{return await s.access(e),!0}catch{return!1}}async function Ke(e){if(!await J(e))return!0;let t=await s.readdir(e);return t.length===0||t.every(e=>e===`.git`)}async function qe(e){await s.mkdir(e,{recursive:!0});let t=await s.readdir(e);await Promise.all(t.map(async t=>{t!==`.git`&&await s.rm(o.join(e,t),{recursive:!0,force:!0})}))}async function Je(e,t){await s.mkdir(t,{recursive:!0});let n=await s.readdir(e,{withFileTypes:!0});for(let r of n){if(r.name===`.DS_Store`)continue;let n=o.join(e,r.name),i=o.join(t,Ye(r.name));if(r.isDirectory())await Je(n,i);else if(r.isFile())await s.mkdir(o.dirname(i),{recursive:!0}),await s.copyFile(n,i);else if(r.isSymbolicLink()){let e=await s.readlink(n);await s.symlink(e,i)}}}function Ye(e){return e===`_gitignore`?`.gitignore`:e===`_npmrc`?`.npmrc`:e}function Xe(){let e=process.env.npm_config_user_agent||``;return e.startsWith(`pnpm`)?`pnpm`:e.startsWith(`yarn`)?`yarn`:e.startsWith(`bun`)?`bun`:`npm`}function Ze(e){return{npm:`npm@11`,pnpm:`pnpm@9`,yarn:`yarn@1.22`,bun:`bun@1`}[e]}function Qe(e,t){return e===`npm`?`npm run ${t}`:e===`yarn`?`yarn ${t}`:e===`bun`?`bun run ${t}`:`pnpm ${t}`}async function $e(e,t){await Y(e,e===`yarn`?[]:[`install`],t)}async function et(e,t){for(let n of e)await Y(`npx`,[`--yes`,`skills@latest`,`add`,n,`--copy`,`--yes`],t)}function tt(e){return e.map(e=>`npx --yes skills@latest add ${e} --copy --yes`).join(` && `)}async function nt(e){await Y(`git`,[`init`],e)}function Y(e,t,n){return new Promise((r,i)=>{let a=c(e,t,{cwd:n,stdio:`ignore`,shell:process.platform===`win32`});a.on(`error`,i),a.on(`close`,n=>{n===0?r():i(/* @__PURE__ */ Error(`${e} ${t.join(` `)} failed with code ${n}`))})})}function rt(e){return e.trim().replace(/([a-z])([A-Z])/g,`$1-$2`).replace(/\s+/g,`-`).replace(/_/g,`-`).toLowerCase().replace(/[^a-z0-9@/.-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``)||`mcbe-addon`}function it(e){let t=e.trim(),n=t.toLowerCase().replace(/([a-z])([A-Z])/g,`$1_$2`).replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`mcbe_${at(t)}`;return`${/^[a-z]/.test(n)?n:`mcbe_${n}`}_${l.randomBytes(3).toString(`hex`)}`}function at(e){return l.createHash(`sha1`).update(e,`utf8`).digest(`hex`).slice(0,8)}async function ot(e){let t=await s.readFile(e,`utf8`);return JSON.parse(t)}async function st(e,t){await s.writeFile(e,`${JSON.stringify(t,null,2)}\n`,`utf8`)}async function ct(e,t){let n=await ot(e);return await t(n),await st(e,n),n}async function X(e){let t=[[o.join(e.root,`bp`,`manifest.json`),`BP`],[o.join(e.root,`rp`,`manifest.json`),`RP`],[o.join(e.root,`manifest.json`),e.template.id===`resource-pack`?`RP`:`BP`]];for(let[n,r]of t)await J(n)&&await ct(n,t=>{t.header.name=`${e.projectName} ${r}`,t.header.description=`${e.projectName} ${r.toLowerCase()}`,t.header.uuid=l.randomUUID();for(let e of t.modules??[])e.uuid=l.randomUUID()})}async function lt(e,t){await X(e);let n=JSON.parse(await s.readFile(o.join(e.root,t.bpRoot,`manifest.json`),`utf8`)),r=t.rpRoot?JSON.parse(await s.readFile(o.join(e.root,t.rpRoot,`manifest.json`),`utf8`)):void 0,i=n.modules?.find(e=>e.type===`script`);t.namespace&&await ut(e,it(e.projectName));let a={name:e.packageName,version:`1.0.0`,description:`${e.projectName} Bedrock add-on`,target:`latest`,packs:{bp:{root:t.bpRoot,uuid:n.header.uuid,...i?.uuid?{moduleUuid:i.uuid}:{},compile:{entry:`src/main.ts`},dependencies:t.dependencies??{"@minecraft/server":`stable`}},...r?{rp:{root:t.rpRoot,uuid:r.header.uuid,moduleUuid:r.modules?.[0]?.uuid}}:{}},pack:{outDir:`dist`},...t.replaceBuiltins?{replace:{builtins:{NAME:!0,DESCRIPTION:!0,VERSION:!0,UUID:!0}}}:{}};await s.writeFile(o.join(e.root,`bepack.config.ts`),dt(a,t.plugin,e.installBepack),`utf8`)}async function ut(e,t){let n=o.join(e.root,`src`,`main.ts`);if(!await J(n))return;let r=await s.readFile(n,`utf8`);await s.writeFile(n,r.replaceAll(`**NAMESPACE**`,t),`utf8`)}function dt(e,t,n){let r=JSON.stringify(e,null,2).replace(/\n( +)"([a-zA-Z_$][a-zA-Z0-9_$]*)": /g,`
|
|
50
|
+
$1$2: `),i=t?r.replace(/^\{\n/,n?`{\n plugins: [${t.call}],\n`:`{\n plugins: ['${t.name}'],\n`):r,a=n&&t?`import { defineConfig, ${t.importName} } from '@bepack/cli';`:n?`import { defineConfig } from '@bepack/cli';`:``,o=n?`defineConfig(${i})`:i;return`${a?`${a}\n\n`:``}export default ${o};\n`}function Z(e){let{id:t,title:n,description:r,templateDir:i,skills:a,...o}=e;return{id:t,title:n,description:r,templateDir:i,defaultPackageManager:`npm`,skills:a,workflow:`bepack`,prepare:e=>lt(e,o)}}const Q=[Z({id:`sapi-pro`,title:`SAPI-Pro + BEPack`,description:`SAPI-Pro behavior pack managed and packed by BEPack.`,templateDir:`sapi-pro`,bpRoot:`.`,dependencies:{"@minecraft/server":`stable`,"@minecraft/server-ui":`stable`,"@minecraft/vanilla-data":`stable`,"sapi-pro":`stable`},plugin:{name:`sapi-pro`,importName:`sapiPro`,call:`sapiPro()`},replaceBuiltins:!0,namespace:!0}),Z({id:`bepack-behavior`,title:`BEPack Behavior Pack`,description:`TypeScript Script API behavior pack built and packed by BEPack.`,templateDir:`bepack-behavior`,bpRoot:`.`}),Z({id:`bepack-addon`,title:`BEPack Add-on (BP + RP)`,description:`TypeScript behavior pack plus resource pack, managed by BEPack.`,templateDir:`bepack-addon`,bpRoot:`bp`,rpRoot:`rp`}),{id:`behavior-pack`,title:`Behavior Pack`,description:`Simple behavior pack without scripts or build tools.`,templateDir:`behavior-pack`,prepare:X},{id:`resource-pack`,title:`Resource Pack`,description:`Simple resource pack without scripts or build tools.`,templateDir:`resource-pack`,prepare:X}];function ft(e){return o.join(e,`package.json`)}async function pt(e,t){return ct(ft(e),t)}async function mt(e,t){return pt(e,e=>{e.name=t.name,t.packageManager&&(e.packageManager=Ze(t.packageManager))})}const ht=o.resolve(o.dirname(u(import.meta.url)),`..`);async function gt(e){let t=await _t(e);bt(t);let n=await vt(e),r=await yt(e,n),i=o.resolve(e.cwd,t),a=e.packageManager||n.defaultPackageManager||`npm`,s={cli:e,cwd:e.cwd,root:i,projectName:t,packageName:rt(t),template:n,packageManager:a,installBepack:r,templateOptions:n.defaultOptions??{}};await xt(s),await Je(o.resolve(ht,`templates`,n.templateDir),i),await J(o.join(i,`package.json`))&&(await mt(i,{name:s.packageName,packageManager:a}),n.workflow===`bepack`&&!r&&await Tt(i)),await n.prepare?.(s);let c=!1;e.git&&(await nt(i),c=!0);let l=!1,u=!1;if(e.install){await J(o.join(i,`package.json`))&&(n.workflow===`bepack`&&r?(await $e(a,i),await wt(a,`bepack:install`,i)):n.workflow===`bepack`?await Y(`bepack`,[`install`],i):await $e(a,i),l=!0);let t=Ct(n.skills);!e.skipSkillsInstall&&t.length>0&&(await et(t,i),u=!0)}return{root:i,projectName:t,template:n.id,packageManager:a,installedDependencies:l,installedSkills:u,initializedGit:c,warnings:[],nextSteps:St(s,l,u||e.skipSkillsInstall)}}async function _t(e){if(e.projectName)return e.projectName;if(e.yes||!process.stdin.isTTY)return`mcbe-addon`;let t=await Re({message:`Project name`,placeholder:`my-addon`,defaultValue:`my-addon`,validate(e){if(!e?.trim())return`Project name is required.`}});if(j(t))throw t;return String(t)}async function vt(e){if(e.template){let t=Q.find(t=>t.id===e.template);if(!t)throw Error(`Unknown template "${e.template}". Available: ${Q.map(e=>e.id).join(`, `)}`);return t}if(e.yes||!process.stdin.isTTY)return Q[0];let t=await W({message:`Select a template`,options:Q.map(e=>({value:e.id,label:e.title,hint:e.description}))});if(j(t))throw t;return Q.find(e=>e.id===String(t))}async function yt(e,t){if(t.workflow!==`bepack`)return!1;if(e.installBepack!==void 0)return e.installBepack;if(e.yes||!process.stdin.isTTY)return!0;let n=await Pe({message:`Install BEPack in this project?`,initialValue:!0});if(j(n))throw n;return!!n}function bt(e){if(!e.trim()||e===`.`||e===`..`||o.isAbsolute(e))throw Error(`Project name must be a non-empty relative child directory, not . or an absolute path.`);let t=o.normalize(e);if(t===`..`||t.startsWith(`..${o.sep}`))throw Error(`Project name cannot escape the working directory.`)}async function xt(e){if(!await J(e.root)){await s.mkdir(e.root,{recursive:!0});return}if(await Ke(e.root))return;if(e.cli.force){await qe(e.root);return}if(e.cli.yes||!process.stdin.isTTY)throw Error(`Target directory is not empty: ${e.root}. Use --force to overwrite.`);let t=await W({message:`Target directory ${e.projectName} is not empty`,options:[{value:`cancel`,label:`Cancel`},{value:`overwrite`,label:`Overwrite`}]});if(j(t)||t===`cancel`)throw Error(`Cancelled.`);await qe(e.root)}function St(e,t,n){let r=[`cd ${o.relative(process.cwd(),e.root)||`.`}`];if(e.template.workflow===`bepack`&&(e.installBepack&&!t?(r.push(`${e.packageManager} install`),r.push(Qe(e.packageManager,`bepack:install`))):e.installBepack||r.push(`bepack install`),r.push(Qe(e.packageManager,`build`))),!n){let t=Ct(e.template.skills);t.length>0&&r.push(tt(t))}return r}function Ct(e){return(Array.isArray(e)?e:e?[e]:[]).map(e=>e.trim()).filter(Boolean)}async function wt(e,t,n){return e===`npm`?Y(`npm`,[`run`,t],n):e===`pnpm`?Y(`pnpm`,[t],n):e===`yarn`?Y(`yarn`,[t],n):Y(`bun`,[`run`,t],n)}async function Tt(e){let t=o.join(e,`package.json`),n=JSON.parse(await s.readFile(t,`utf8`));n.devDependencies&&delete n.devDependencies[`@bepack/cli`],n.scripts&&delete n.scripts[`bepack:install`],await s.writeFile(t,`${JSON.stringify(n,null,2)}\n`,`utf8`)}var Et=/* @__PURE__ */ y((/* @__PURE__ */ _(((e,t)=>{function n(e){return e==null?[]:Array.isArray(e)?e:[e]}function r(e,t,n,r){var i,a=e[t],o=~r.string.indexOf(t)?n==null||n===!0?``:String(n):typeof n==`boolean`?n:~r.boolean.indexOf(t)?n===`false`?!1:n===`true`||(e._.push((i=+n,i*0==0?i:n)),!!n):(i=+n,i*0==0?i:n);e[t]=a==null?o:Array.isArray(a)?a.concat(o):[a,o]}t.exports=function(e,t){e||=[],t||={};var i,a,o,s,c,l={_:[]},u=0,d=0,f=0,p=e.length;let m=t.alias!==void 0,h=t.unknown!==void 0,g=t.default!==void 0;if(t.alias=t.alias||{},t.string=n(t.string),t.boolean=n(t.boolean),m)for(i in t.alias)for(a=t.alias[i]=n(t.alias[i]),u=0;u<a.length;u++)(t.alias[a[u]]=a.concat(i)).splice(u,1);for(u=t.boolean.length;u-->0;)for(a=t.alias[t.boolean[u]]||[],d=a.length;d-->0;)t.boolean.push(a[d]);for(u=t.string.length;u-->0;)for(a=t.alias[t.string[u]]||[],d=a.length;d-->0;)t.string.push(a[d]);if(g){for(i in t.default)if(s=typeof t.default[i],a=t.alias[i]=t.alias[i]||[],t[s]!==void 0)for(t[s].push(i),u=0;u<a.length;u++)t[s].push(a[u])}let _=h?Object.keys(t.alias):[];for(u=0;u<p;u++){if(o=e[u],o===`--`){l._=l._.concat(e.slice(++u));break}for(d=0;d<o.length&&o.charCodeAt(d)===45;d++);if(d===0)l._.push(o);else if(o.substring(d,d+3)===`no-`){if(s=o.substring(d+3),h&&!~_.indexOf(s))return t.unknown(o);l[s]=!1}else{for(f=d+1;f<o.length&&o.charCodeAt(f)!==61;f++);for(s=o.substring(d,f),c=o.substring(++f)||u+1===p||(``+e[u+1]).charCodeAt(0)===45||e[++u],a=d===2?[s]:s,f=0;f<a.length;f++){if(s=a[f],h&&!~_.indexOf(s))return t.unknown(`-`.repeat(d)+s);r(l,s,f+1<a.length||c,t)}}}if(g)for(i in t.default)l[i]===void 0&&(l[i]=t.default[i]);if(m)for(i in l)for(a=t.alias[i]||[];a.length>0;)l[a.shift()]=l[i];return l}})))(),1);const Dt=/* @__PURE__ */ new Set([`npm`,`pnpm`,`yarn`,`bun`]);function Ot(e=[]){let t=(0,Et.default)(e,{alias:{h:`help`,v:`version`,t:`template`},boolean:[`help`,`version`,`yes`,`force`,`install`,`skip-skills-install`,`install-bepack`,`skip-bepack-install`,`git`,`json`,`list-templates`],string:[`template`,`pm`,`cwd`],default:{install:!1,git:!1}}),n=String(t.pm||Xe());if(!Dt.has(n))throw Error(`Unknown package manager: ${n}`);if(t[`install-bepack`]&&t[`skip-bepack-install`])throw Error(`--install-bepack and --skip-bepack-install cannot be used together.`);let r=Array.isArray(t._)?t._.find(Boolean):void 0;return{cwd:o.resolve(String(t.cwd||process.cwd())),projectName:r===void 0?void 0:String(r),template:t.template?String(t.template):void 0,packageManager:n,yes:!!t.yes,force:!!t.force,install:!!t.install,skipSkillsInstall:!!t[`skip-skills-install`],installBepack:t[`skip-bepack-install`]?!1:t[`install-bepack`]?!0:void 0,git:!!t.git,json:!!t.json,listTemplates:!!t[`list-templates`],help:!!t.help,version:!!t.version}}const $=e(import.meta.url)(`../package.json`);async function kt(e=process.argv.slice(2)){let t;try{if(t=Ot(e),t.help)return console.log(jt());if(t.version)return console.log($.version);if(t.listTemplates)return console.log(Q.map(e=>`${Ge(e.id.padEnd(18))} ${e.description}`).join(`
|
|
51
|
+
`));let n=await gt(t);if(t.json)return console.log(JSON.stringify({ok:!0,result:n},null,2));At(n)}catch(n){let r=n instanceof Error?n.message:String(n),i=j(n);t?.json||e.includes(`--json`)?console.log(JSON.stringify({ok:!1,error:i?`cancelled`:r},null,2)):i?Fe(`Cancelled.`):console.error(Ue(`Error: ${r}`)),process.exitCode=1}}function At(e){Ie(`${We(`Created`)} ${Ve(e.projectName)}`),console.log(He(`\nTemplate: ${e.template}`)),console.log(`
|
|
52
|
+
Next steps:`);for(let t of e.nextSteps)console.log(` ${t}`)}function jt(){return`\n${[`${Ve(`create-mcbe`)} ${He(`v${$.version}`)}`,``,`Usage:`,` npm create mcbe@latest [project-name] -- [options]`,``,`Options:`,` --template <id> Template id`,` --pm <npm|pnpm|yarn|bun>`,` --yes Use defaults`,` --force Overwrite a non-empty target directory`,` --install Install dependencies after creation`,` --skip-skills-install Skip template skills installation`,` --install-bepack Install BEPack in the project`,` --skip-bepack-install Use global BEPack instead`,` --git Initialize git`,` --cwd <dir> Working directory`,` --json Machine-readable output`,` --list-templates List templates`,` -h, --help Show help`,` -v, --version Show version`,``,`Templates:`,...Q.map(e=>` ${e.id.padEnd(18)} ${e.description}`)].join(`
|
|
53
|
+
`)}\n`}await kt();export{};
|
package/package.json
CHANGED