89 lines
40 KiB
JavaScript
89 lines
40 KiB
JavaScript
import{createRequire as e}from"node:module";import t from"node:fs";import n from"node:path";import{fileURLToPath as r}from"node:url";import i,{stripVTControlCharacters as a,styleText as o}from"node:util";import s,{stdin as c,stdout as l}from"node:process";import"node:readline";import u from"node:readline";import"node:tty";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)),b=e(import.meta.url),x=_(((e,t)=>{t.exports=a,a.sync=o;var n=b(`fs`);function r(e,t){var n=t.pathExt===void 0?process.env.PATHEXT:t.pathExt;if(!n||(n=n.split(`;`),n.indexOf(``)!==-1))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}function i(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:r(t,n)}function a(e,t,r){n.stat(e,function(n,a){r(n,n?!1:i(a,e,t))})}function o(e,t){return i(n.statSync(e),e,t)}})),S=_(((e,t)=>{t.exports=r,r.sync=i;var n=b(`fs`);function r(e,t,r){n.stat(e,function(e,n){r(e,e?!1:a(n,t))})}function i(e,t){return a(n.statSync(e),t)}function a(e,t){return e.isFile()&&o(e,t)}function o(e,t){var n=e.mode,r=e.uid,i=e.gid,a=t.uid===void 0?process.getuid&&process.getuid():t.uid,o=t.gid===void 0?process.getgid&&process.getgid():t.gid,s=64,c=8,l=1,u=s|c;return n&l||n&c&&i===o||n&s&&r===a||n&u&&a===0}})),C=_(((e,t)=>{b(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?x():S();t.exports=r,r.sync=i;function r(e,t,i){if(typeof t==`function`&&(i=t,t={}),!i){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(n,i){r(e,t||{},function(e,t){e?i(e):n(t)})})}n(e,t||{},function(e,n){e&&(e.code===`EACCES`||t&&t.ignoreErrors)&&(e=null,n=!1),i(e,n)})}function i(e,t){try{return n.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code===`EACCES`)return!1;throw e}}})),w=_(((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=b(`path`),i=n?`;`:`:`,a=C(),o=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),s=(e,t)=>{let r=t.colon||i,a=e.match(/\//)||n&&e.match(/\\/)?[``]:[...n?[process.cwd()]:[],...(t.path||process.env.PATH||``).split(r)],o=n?t.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,s=n?o.split(r):[``];return n&&e.indexOf(`.`)!==-1&&s[0]!==``&&s.unshift(``),{pathEnv:a,pathExt:s,pathExtExe:o}},c=(e,t,n)=>{typeof t==`function`&&(n=t,t={}),t||={};let{pathEnv:i,pathExt:c,pathExtExe:l}=s(e,t),u=[],d=n=>new Promise((a,s)=>{if(n===i.length)return t.all&&u.length?a(u):s(o(e));let c=i[n],l=/^".*"$/.test(c)?c.slice(1,-1):c,d=r.join(l,e);a(f(!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d,n,0))}),f=(e,n,r)=>new Promise((i,o)=>{if(r===c.length)return i(d(n+1));let s=c[r];a(e+s,{pathExt:l},(a,o)=>{if(!a&&o)if(t.all)u.push(e+s);else return i(e+s);return i(f(e,n,r+1))})});return n?d(0).then(e=>n(null,e),n):d(0)};t.exports=c,c.sync=(e,t)=>{t||={};let{pathEnv:n,pathExt:i,pathExtExe:c}=s(e,t),l=[];for(let o=0;o<n.length;o++){let s=n[o],u=/^".*"$/.test(s)?s.slice(1,-1):s,d=r.join(u,e),f=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let e=0;e<i.length;e++){let n=f+i[e];try{if(a.sync(n,{pathExt:c}))if(t.all)l.push(n);else return n}catch{}}}if(t.all&&l.length)return l;if(t.nothrow)return null;throw o(e)}})),ee=_(((e,t)=>{let n=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};t.exports=n,t.exports.default=n})),te=_(((e,t)=>{let n=b(`path`),r=w(),i=ee();function a(e,t){let a=e.options.env||process.env,o=process.cwd(),s=e.options.cwd!=null,c=s&&process.chdir!==void 0&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch{}let l;try{l=r.sync(e.command,{path:a[i({env:a})],pathExt:t?n.delimiter:void 0})}catch{}finally{c&&process.chdir(o)}return l&&=n.resolve(s?e.options.cwd:``,l),l}function o(e){return a(e)||a(e,!0)}t.exports=o})),ne=_(((e,t)=>{let n=/([()\][%!^"`<>&|;, *?])/g;function r(e){return e=e.replace(n,`^$1`),e}function i(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,`$1$1\\"`),e=e.replace(/(?=(\\+?)?)\1$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i})),re=_(((e,t)=>{t.exports=/^#!(.*)/})),ie=_(((e,t)=>{let n=re();t.exports=(e=``)=>{let t=e.match(n);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,``).split(` `),a=r.split(`/`).pop();return a===`env`?i:i?`${a} ${i}`:a}})),ae=_(((e,t)=>{let n=b(`fs`),r=ie();function i(e){let t=Buffer.alloc(150),i;try{i=n.openSync(e,`r`),n.readSync(i,t,0,150,0),n.closeSync(i)}catch{}return r(t.toString())}t.exports=i})),oe=_(((e,t)=>{let n=b(`path`),r=te(),i=ne(),a=ae(),o=process.platform===`win32`,s=/\.(?:com|exe)$/i,c=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function l(e){e.file=r(e);let t=e.file&&a(e.file);return t?(e.args.unshift(e.file),e.command=t,r(e)):e.file}function u(e){if(!o)return e;let t=l(e),r=!s.test(t);if(e.options.forceShell||r){let r=c.test(t);e.command=n.normalize(e.command),e.command=i.command(e.command),e.args=e.args.map(e=>i.argument(e,r)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function d(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:u(r)}t.exports=d})),se=_(((e,t)=>{let n=process.platform===`win32`;function r(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function i(e,t){if(!n)return;let r=e.emit;e.emit=function(n,i){if(n===`exit`){let n=a(i,t);if(n)return r.call(e,`error`,n)}return r.apply(e,arguments)}}function a(e,t){return n&&e===1&&!t.file?r(t.original,`spawn`):null}function o(e,t){return n&&e===1&&!t.file?r(t.original,`spawnSync`):null}t.exports={hookChildProcess:i,verifyENOENT:a,verifyENOENTSync:o,notFoundError:r}})),ce=_(((e,t)=>{let n=b(`child_process`),r=oe(),i=se();function a(e,t,a){let o=r(e,t,a),s=n.spawn(o.command,o.args,o.options);return i.hookChildProcess(s,o),s}function o(e,t,a){let o=r(e,t,a),s=n.spawnSync(o.command,o.args,o.options);return s.error=s.error||i.verifyENOENTSync(s.status,o),s}t.exports=a,t.exports.spawn=a,t.exports.sync=o,t.exports._parse=r,t.exports._enoent=i})),le=_(((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}})),ue=y(ce(),1),de=y(le(),1);const fe=(()=>{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}})(),pe=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,me=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,he=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,ge=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,_e=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,ve=/\t{1,1000}/y,ye=/[\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,be=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,xe=/\p{M}+/gu,Se={limit:1/0,ellipsis:``},Ce=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Ce(i,Se,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[be,l],[he,0],[ge,o],[ve,s],[ye,c],[_e,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(xe,``)){let t=e.codePointAt(0)||0;if(S=pe(t)?2:me(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=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===_e?fe(e.slice(p,n.lastIndex)):n===ye?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},we={limit:1/0,ellipsis:``,ellipsisWidth:0},T=(e,t={})=>Ce(e,we,t).width,E=`]8;;`,Te=RegExp(`(?:\\[(?<code>\\d+)m|\\${E}(?<uri>.*))`,`y`),Ee=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},De=e=>`[${e}m`,Oe=e=>`${E}${e}`,D=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:T(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=T(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===``)&&(i=!0,a=t.startsWith(E,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())},ke=e=>{let t=e.split(` `),n=t.length;for(;n&&!T(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ae=(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=T(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=T(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(``),D(s,r,t),c=T(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){D(s,r,t),c=T(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){D(s,r,t),c=T(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>ke(e)));let l=s.join(`
|
||
`),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===``){Te.lastIndex=e+1;let t=Te.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]===`
|
||
`){a&&(r+=Oe(``));let e=i?Ee(i):void 0;i&&e&&(r+=De(e))}else t===`
|
||
`&&(i&&Ee(i)&&(r+=De(i)),a&&(r+=Oe(a)))}return r},je=/\r?\n/;function O(e,t,n){return String(e).normalize().split(je).map(e=>Ae(e,t,n)).join(`
|
||
`)}var k=_(((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 A(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?A(a,t<0?-1:1,n):a}const j={actions:new Set([`up`,`down`,`left`,`right`,`space`,`enter`,`cancel`]),aliases:new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`],[``,`cancel`],[`escape`,`cancel`]]),messages:{cancel:`Canceled`,error:`Something went wrong`},withGuide:!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 Me(e,t){if(typeof e==`string`)return j.aliases.get(e)===t;for(let n of e)if(n!==void 0&&Me(n,t))return!0;return!1}function Ne(e,t){if(e===t)return;let n=e.split(`
|
||
`),r=t.split(`
|
||
`),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 M=Symbol(`clack:cancel`);function N(e){return e===M}function P(e,t){let n=e;n.isTTY&&n.setRawMode(t)}const Pe=e=>`columns`in e&&typeof e.columns==`number`?e.columns:80,Fe=e=>`rows`in e&&typeof e.rows==`number`?e.rows:20;function F(e,t,n,r=n,i){return O(t,Pe(e??l)-n.length,{hard:!0,trim:!1}).split(`
|
||
`).map((e,t)=>{let a=i?i(e,t):e;return`${t===0?r:n}${a}`}).join(`
|
||
`)}let I=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame=``;_subscribers=new Map;_cursor=0;state=`initial`;error=``;value;userInput=``;constructor(e,t=!0){let{input:n=c,output:r=l,render:i,signal:a,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=a,this.input=n,this.output=r}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(M);this._abortSignal.addEventListener(`abort`,()=>{this.state=`cancel`,this.close()},{once:!0})}this.rl=u.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),P(this.input,!0),this.output.on(`resize`,this.render),this.render(),this.once(`submit`,()=>{this.output.write(k.cursor.show),this.output.off(`resize`,this.render),P(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(k.cursor.show),this.output.off(`resize`,this.render),P(this.input,!1),e(M)})})}_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(``)}onKeypress(e,t){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&&j.aliases.has(t.name)&&this.emit(`cursor`,j.aliases.get(t.name)),j.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?.toLowerCase(),t),t?.name===`return`&&this._shouldSubmit(e,t)){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e instanceof Error?e.message:e,this.state=`error`,this.rl?.write(this.userInput))}this.state!==`error`&&(this.state=`submit`)}Me([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(`
|
||
`),P(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=O(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
||
`).length-1;this.output.write(k.cursor.move(-999,e*-1))}render(){let e=O(this._render(this)??``,process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(k.cursor.hide);else{let t=Ne(this._prevFrame,e),n=Fe(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(k.cursor.move(0,a-i)),this.output.write(k.erase.lines(1));let t=e.split(`
|
||
`);this.output.write(t[a]),this._prevFrame=e,this.output.write(k.cursor.move(0,t.length-a-1));return}else if(t.lines.length>1){if(r<i)a=r;else{let e=a-i;e>0&&this.output.write(k.cursor.move(0,e))}this.output.write(k.erase.down());let t=e.split(`
|
||
`).slice(a);this.output.write(t.join(`
|
||
`)),this._prevFrame=e;return}}this.output.write(k.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}};var Ie=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(k.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},Le=class extends I{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.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?A(n,1,this.options):n,this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=A(this.cursor,-1,this.options);break;case`down`:case`right`:this.cursor=A(this.cursor,1,this.options);break}this.changeValue()})}},Re=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 t=e.slice(0,this.cursor),[n,...r]=e.slice(this.cursor);return`${t}${o(`inverse`,n)}${r.join(``)}`}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 ze(){return s.platform===`win32`?!!s.env.CI||!!s.env.WT_SESSION||!!s.env.TERMINUS_SUBLIME||s.env.ConEmuTask===`{cmd::Cmder}`||s.env.TERM_PROGRAM===`Terminus-Sublime`||s.env.TERM_PROGRAM===`vscode`||s.env.TERM===`xterm-256color`||s.env.TERM===`alacritty`||s.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:s.env.TERM!==`linux`}const Be=ze(),L=(e,t)=>Be?e:t,Ve=L(`◆`,`*`),He=L(`■`,`x`),Ue=L(`▲`,`x`),R=L(`◇`,`o`),z=L(`│`,`|`),B=L(`└`,`—`),We=L(`●`,`>`),V=L(`○`,` `),Ge=L(`●`,`•`),Ke=L(`◆`,`*`),qe=L(`▲`,`!`),Je=L(`■`,`x`),Ye=e=>{switch(e){case`initial`:case`active`:return o(`cyan`,Ve);case`cancel`:return o(`red`,He);case`error`:return o(`yellow`,Ue);case`submit`:return o(`green`,R)}},Xe=e=>{switch(e){case`initial`:case`active`:return o(`cyan`,z);case`cancel`:return o(`red`,z);case`error`:return o(`yellow`,z);case`submit`:return o(`green`,z)}},Ze=(e,t,n,r,i)=>{let a=t,o=0;for(let t=n;t<r;t++){let n=e[t];if(a-=n.length,o++,a<=i)break}return{lineCount:a,removals:o}},Qe=({cursor:e,options:t,style:n,output:r=process.stdout,maxItems:i=1/0,columnPadding:a=0,rowPadding:s=4})=>{let c=Pe(r)-a,l=Fe(r),u=o(`dim`,`...`),d=Math.max(l-s,0),f=Math.max(Math.min(i,d),5),p=0;e>=f-3&&(p=Math.max(Math.min(e-f+3,t.length-f),0));let m=f<t.length&&p>0,h=f<t.length&&p+f<t.length,g=Math.min(p+f,t.length),_=[],v=0;m&&v++,h&&v++;let y=p+ +!!m,b=g-+!!h;for(let r=y;r<b;r++){let i=O(n(t[r],r===e),c,{hard:!0,trim:!1}).split(`
|
||
`);_.push(i),v+=i.length}if(v>d){let t=0,n=0,r=v,i=e-y,a=(e,t)=>Ze(_,r,e,t,d);m?({lineCount:r,removals:t}=a(0,i),r>d&&({lineCount:r,removals:n}=a(i+1,_.length))):({lineCount:r,removals:n}=a(i+1,_.length),r>d&&({lineCount:r,removals:t}=a(0,i))),t>0&&(m=!0,_.splice(0,t)),n>0&&(h=!0,_.splice(_.length-n,n))}let x=[];m&&x.push(u);for(let e of _)for(let t of e)x.push(t);return h&&x.push(u),x},$e=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new Ie({active:t,inactive:n,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let r=e.withGuide??j.withGuide,i=`${Ye(this.state)} `,a=r?`${o(`gray`,z)} `:``,s=F(e.output,e.message,a,i),c=`${r?`${o(`gray`,z)}
|
||
`:``}${s}
|
||
`,l=this.value?t:n;switch(this.state){case`submit`:return`${c}${r?`${o(`gray`,z)} `:``}${o(`dim`,l)}`;case`cancel`:return`${c}${r?`${o(`gray`,z)} `:``}${o([`strikethrough`,`dim`],l)}${r?`
|
||
${o(`gray`,z)}`:``}`;default:{let i=r?`${o(`cyan`,z)} `:``,a=r?o(`cyan`,B):``;return`${c}${i}${this.value?`${o(`green`,We)} ${t}`:`${o(`dim`,V)} ${o(`dim`,t)}`}${e.vertical?r?`
|
||
${o(`cyan`,z)} `:`
|
||
`:` ${o(`dim`,`/`)} `}${this.value?`${o(`dim`,V)} ${o(`dim`,n)}`:`${o(`green`,We)} ${n}`}
|
||
${a}
|
||
`}}}}).prompt()},H={message:(e=[],{symbol:t=o(`gray`,z),secondarySymbol:n=o(`gray`,z),output:r=process.stdout,spacing:i=1,withGuide:a}={})=>{let s=[],c=a??j.withGuide,l=c?n:``,u=c?`${t} `:``,d=c?`${n} `:``;for(let e=0;e<i;e++)s.push(l);let f=Array.isArray(e)?e:e.split(`
|
||
`);if(f.length>0){let[e,...r]=f;e.length>0?s.push(`${u}${e}`):s.push(c?t:``);for(let e of r)e.length>0?s.push(`${d}${e}`):s.push(c?n:``)}r.write(`${s.join(`
|
||
`)}
|
||
`)},info:(e,t)=>{H.message(e,{...t,symbol:o(`blue`,Ge)})},success:(e,t)=>{H.message(e,{...t,symbol:o(`green`,Ke)})},step:(e,t)=>{H.message(e,{...t,symbol:o(`green`,R)})},warn:(e,t)=>{H.message(e,{...t,symbol:o(`yellow`,qe)})},warning:(e,t)=>{H.warn(e,t)},error:(e,t)=>{H.message(e,{...t,symbol:o(`red`,Je)})}},et=(e=``,t)=>{let n=t?.output??process.stdout,r=t?.withGuide??j.withGuide?`${o(`gray`,B)} `:``;n.write(`${r}${o(`red`,e)}
|
||
|
||
`)},tt=(e=``,t)=>{let n=t?.output??process.stdout,r=t?.withGuide??j.withGuide?`${o(`gray`,z)}
|
||
${o(`gray`,B)} `:``;n.write(`${r}${e}
|
||
|
||
`)},U=(e,t)=>e.includes(`
|
||
`)?e.split(`
|
||
`).map(e=>t(e)).join(`
|
||
`):t(e),nt=e=>{let t=(e,t)=>{let n=e.label??String(e.value);switch(t){case`disabled`:return`${o(`gray`,V)} ${U(n,e=>o(`gray`,e))}${e.hint?` ${o(`dim`,`(${e.hint??`disabled`})`)}`:``}`;case`selected`:return`${U(n,e=>o(`dim`,e))}`;case`active`:return`${o(`green`,We)} ${n}${e.hint?` ${o(`dim`,`(${e.hint})`)}`:``}`;case`cancelled`:return`${U(n,e=>o([`strikethrough`,`dim`],e))}`;default:return`${o(`dim`,V)} ${U(n,e=>o(`dim`,e))}`}};return new Le({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let n=e.withGuide??j.withGuide,r=`${Ye(this.state)} `,i=`${Xe(this.state)} `,a=F(e.output,e.message,i,r),s=`${n?`${o(`gray`,z)}
|
||
`:``}${a}
|
||
`;switch(this.state){case`submit`:{let r=n?`${o(`gray`,z)} `:``;return`${s}${F(e.output,t(this.options[this.cursor],`selected`),r)}`}case`cancel`:{let r=n?`${o(`gray`,z)} `:``;return`${s}${F(e.output,t(this.options[this.cursor],`cancelled`),r)}${n?`
|
||
${o(`gray`,z)}`:``}`}default:{let r=n?`${o(`cyan`,z)} `:``,i=n?o(`cyan`,B):``,a=s.split(`
|
||
`).length,c=n?2:1;return`${s}${r}${Qe({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:r.length,rowPadding:a+c,style:(e,n)=>t(e,e.disabled?`disabled`:n?`active`:`inactive`)}).join(`
|
||
${r}`)}
|
||
${i}
|
||
`}}}}).prompt()},rt=`${o(`gray`,z)} `,W={message:async(e,{symbol:t=o(`gray`,z)}={})=>{process.stdout.write(`${o(`gray`,z)}
|
||
${t} `);let n=3;for await(let t of e){t=t.replace(/\n/g,`
|
||
${rt}`),t.includes(`
|
||
`)&&(n=3+a(t.slice(t.lastIndexOf(`
|
||
`))).length);let e=a(t).length;n+e<process.stdout.columns?(n+=e,process.stdout.write(t)):(process.stdout.write(`
|
||
${rt}${t.trimStart()}`),n=3+a(t.trimStart()).length)}process.stdout.write(`
|
||
`)},info:e=>W.message(e,{symbol:o(`blue`,Ge)}),success:e=>W.message(e,{symbol:o(`green`,Ke)}),step:e=>W.message(e,{symbol:o(`green`,R)}),warn:e=>W.message(e,{symbol:o(`yellow`,qe)}),warning:e=>W.warn(e),error:e=>W.message(e,{symbol:o(`red`,Je)})},it=e=>new Re({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??j.withGuide,n=`${`${t?`${o(`gray`,z)}
|
||
`:``}${Ye(this.state)} `}${e.message}
|
||
`,r=e.placeholder?o(`inverse`,e.placeholder[0])+o(`dim`,e.placeholder.slice(1)):o([`inverse`,`hidden`],`_`),i=this.userInput?this.userInputWithCursor:r,a=this.value??``;switch(this.state){case`error`:{let e=this.error?` ${o(`yellow`,this.error)}`:``,r=t?`${o(`yellow`,z)} `:``,a=t?o(`yellow`,B):``;return`${n.trim()}
|
||
${r}${i}
|
||
${a}${e}
|
||
`}case`submit`:{let e=a?` ${o(`dim`,a)}`:``;return`${n}${t?o(`gray`,z):``}${e}`}case`cancel`:{let e=a?` ${o([`strikethrough`,`dim`],a)}`:``,r=t?o(`gray`,z):``;return`${n}${r}${e}${a.trim()?`
|
||
${r}`:``}`}default:return`${n}${t?`${o(`cyan`,z)} `:``}${i}
|
||
${t?o(`cyan`,B):``}
|
||
`}}}).prompt();var at=_(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{KNOWN_AGENTS:()=>ee,determineAgent:()=>te}),t.exports=c(l);var u=b(`node:fs/promises`),d=b(`node:fs`);let f=`cursor`,p=`cursor-cli`,m=`claude`,h=`cowork`,g=`devin`,_=`replit`,v=`gemini`,y=`codex`,x=`antigravity`,S=`augment-cli`,C=`opencode`,w=`github-copilot`,ee={CURSOR:f,CURSOR_CLI:p,CLAUDE:m,COWORK:h,DEVIN:g,REPLIT:_,GEMINI:v,CODEX:y,ANTIGRAVITY:x,AUGMENT_CLI:S,OPENCODE:C,GITHUB_COPILOT:w,V0:`v0`};async function te(){if(process.env.AI_AGENT){let e=process.env.AI_AGENT.trim();if(e)return e===w||e===`github-copilot-cli`?{isAgent:!0,agent:{name:w}}:e===`v0`?{isAgent:!0,agent:{name:`v0`}}:{isAgent:!0,agent:{name:e}}}if(process.env.CURSOR_TRACE_ID)return{isAgent:!0,agent:{name:f}};if(process.env.CURSOR_AGENT||process.env.CURSOR_EXTENSION_HOST_ROLE===`agent-exec`)return{isAgent:!0,agent:{name:p}};if(process.env.GEMINI_CLI)return{isAgent:!0,agent:{name:v}};if(process.env.CODEX_SANDBOX||process.env.CODEX_CI||process.env.CODEX_THREAD_ID)return{isAgent:!0,agent:{name:y}};if(process.env.ANTIGRAVITY_AGENT)return{isAgent:!0,agent:{name:x}};if(process.env.AUGMENT_AGENT)return{isAgent:!0,agent:{name:S}};if(process.env.OPENCODE_CLIENT)return{isAgent:!0,agent:{name:C}};if(process.env.CLAUDECODE||process.env.CLAUDE_CODE)return process.env.CLAUDE_CODE_IS_COWORK?{isAgent:!0,agent:{name:h}}:{isAgent:!0,agent:{name:m}};if(process.env.REPL_ID)return{isAgent:!0,agent:{name:_}};if(process.env.COPILOT_MODEL||process.env.COPILOT_ALLOW_ALL||process.env.COPILOT_GITHUB_TOKEN)return{isAgent:!0,agent:{name:w}};try{return await(0,u.access)(`/opt/.devin`,d.constants.F_OK),{isAgent:!0,agent:{name:g}}}catch{}return{isAgent:!1,agent:void 0}}}))();const{blue:G,blueBright:K,cyan:q,green:ot,greenBright:st,magenta:J,red:Y,redBright:X,reset:ct,underline:lt,yellow:Z}=Pt(),Q=(0,de.default)(process.argv.slice(2),{boolean:[`help`,`overwrite`,`immediate`,`interactive`],alias:{h:`help`,t:`template`,i:`immediate`},string:[`template`]}),ut=process.cwd(),dt=`\
|
||
Usage: create-vite [OPTION]... [DIRECTORY]
|
||
|
||
Create a new Vite project in JavaScript or TypeScript.
|
||
When running in TTY, the CLI will start in interactive mode.
|
||
|
||
Options:
|
||
-t, --template NAME use a specific template
|
||
-i, --immediate install dependencies and start dev
|
||
--overwrite remove existing files if target directory is not empty
|
||
--interactive / --no-interactive force interactive / non-interactive mode
|
||
|
||
Available templates:
|
||
${Z(`vanilla-ts vanilla`)}
|
||
${ot(`vue-ts vue`)}
|
||
${q(`react-ts react`)}
|
||
${q(`react-compiler-ts react-compiler`)}
|
||
${J(`preact-ts preact`)}
|
||
${X(`lit-ts lit`)}
|
||
${Y(`svelte-ts svelte`)}
|
||
${G(`solid-ts solid`)}
|
||
${K(`qwik-ts qwik`)}`,$=[{name:`vanilla`,display:`Vanilla`,color:Z,variants:[{name:`vanilla-ts`,display:`TypeScript`,color:G},{name:`vanilla`,display:`JavaScript`,color:Z}]},{name:`vue`,display:`Vue`,color:ot,variants:[{name:`vue-ts`,display:`TypeScript`,color:G},{name:`vue`,display:`JavaScript`,color:Z},{name:`custom-create-vue`,display:`Official Vue Starter ↗`,color:ot,customCommand:`npm create vue@latest TARGET_DIR`},{name:`custom-nuxt`,display:`Nuxt ↗`,link:`https://nuxt.com`,color:st,customCommand:`npm exec nuxi init TARGET_DIR`},{name:`custom-vike-vue`,display:`Vike ↗`,link:`https://vike.dev`,color:st,customCommand:`npm create -- vike@latest --vue TARGET_DIR`}]},{name:`react`,display:`React`,color:q,variants:[{name:`react-ts`,display:`TypeScript`,color:G},{name:`react-compiler-ts`,display:`TypeScript + React Compiler`,color:G},{name:`react`,display:`JavaScript`,color:Z},{name:`react-compiler`,display:`JavaScript + React Compiler`,color:Z},{name:`rsc`,display:`RSC`,color:J,customCommand:`npm exec tiged vitejs/vite-plugin-react/packages/plugin-rsc/examples/starter TARGET_DIR`},{name:`custom-react-router`,display:`React Router v7 ↗`,link:`https://reactrouter.com`,color:q,customCommand:`npm create react-router@latest TARGET_DIR`},{name:`custom-tanstack-router-react`,display:`TanStack Router ↗`,link:`https://tanstack.com/router`,color:q,customCommand:`npm exec -- @tanstack/cli@latest create TARGET_DIR --framework react --interactive`},{name:`redwoodsdk-standard`,display:`RedwoodSDK ↗`,link:`https://rwsdk.com`,color:q,customCommand:`npm create rwsdk@latest TARGET_DIR`},{name:`custom-vike-react`,display:`Vike ↗`,link:`https://vike.dev`,color:q,customCommand:`npm create -- vike@latest --react TARGET_DIR`}]},{name:`preact`,display:`Preact`,color:J,variants:[{name:`preact-ts`,display:`TypeScript`,color:G},{name:`preact`,display:`JavaScript`,color:Z},{name:`custom-create-preact`,display:`Official Preact Starter ↗`,color:J,customCommand:`npm create preact@latest TARGET_DIR`}]},{name:`lit`,display:`Lit`,color:X,variants:[{name:`lit-ts`,display:`TypeScript`,color:G},{name:`lit`,display:`JavaScript`,color:Z}]},{name:`svelte`,display:`Svelte`,color:Y,variants:[{name:`svelte-ts`,display:`TypeScript`,color:G},{name:`svelte`,display:`JavaScript`,color:Z},{name:`custom-svelte-kit`,display:`SvelteKit ↗`,color:Y,customCommand:`npm exec sv create TARGET_DIR`}]},{name:`solid`,display:`Solid`,color:G,variants:[{name:`solid-ts`,display:`TypeScript`,color:G},{name:`solid`,display:`JavaScript`,color:Z},{name:`custom-tanstack-router-solid`,display:`TanStack Router ↗`,link:`https://tanstack.com/router`,color:q,customCommand:`npm exec -- @tanstack/cli@latest create TARGET_DIR --framework solid --interactive`},{name:`custom-vike-solid`,display:`Vike ↗`,link:`https://vike.dev`,color:q,customCommand:`npm create -- vike@latest --solid TARGET_DIR`}]},{name:`ember`,display:`Ember`,color:X,variants:[{name:`ember-app-ts`,display:`TypeScript ↗`,color:K,customCommand:`npm exec -- ember-cli@latest new TARGET_DIR --typescript`},{name:`ember-app`,display:`JavaScript ↗`,color:X,customCommand:`npm exec -- ember-cli@latest new TARGET_DIR`}]},{name:`qwik`,display:`Qwik`,color:K,variants:[{name:`qwik-ts`,display:`TypeScript`,color:K},{name:`qwik`,display:`JavaScript`,color:Z},{name:`custom-qwik-city`,display:`QwikCity ↗`,color:K,customCommand:`npm create qwik@latest empty TARGET_DIR`}]},{name:`angular`,display:`Angular`,color:Y,variants:[{name:`custom-angular`,display:`Angular ↗`,color:Y,customCommand:`npm exec @angular/cli@latest new TARGET_DIR`},{name:`custom-analog`,display:`Analog ↗`,color:Z,customCommand:`npm create analog@latest TARGET_DIR`}]},{name:`marko`,display:`Marko`,color:J,variants:[{name:`marko-run`,display:`Marko Run ↗`,color:J,customCommand:`npm create -- marko@latest --name TARGET_DIR`}]},{name:`others`,display:`Others`,color:ct,variants:[{name:`create-vite-extra`,display:`Extra Vite Starters ↗`,color:ct,customCommand:`npm create vite-extra@latest TARGET_DIR`},{name:`create-electron-vite`,display:`Electron ↗`,color:ct,customCommand:`npm create electron-vite@latest TARGET_DIR`}]}],ft=$.map(e=>e.variants.map(e=>e.name)).reduce((e,t)=>e.concat(t),[]),pt={_gitignore:`.gitignore`},mt=`vite-project`;function ht([e,...t],n){let{status:r,error:i}=ue.default.sync(e,t,n);r!=null&&r>0&&process.exit(r),i&&(console.error(`\n${e} ${t.join(` `)} error!`),console.error(i),process.exit(1))}function gt(e,t){if(process.env._VITE_TEST_CLI){H.step(`Installing dependencies with ${t}... (skipped in test)`);return}H.step(`Installing dependencies with ${t}...`),ht(Mt(t),{stdio:`inherit`,cwd:e})}function _t(e,t){if(process.env._VITE_TEST_CLI){H.step(`Starting dev server... (skipped in test)`);return}H.step(`Starting dev server...`),ht(Nt(t,`dev`),{stdio:`inherit`,cwd:e})}async function vt(){let e=Q._[0]?yt(String(Q._[0])):void 0,i=Q.template,a=Q.overwrite,o=Q.immediate,s=Q.interactive;if(Q.help){console.log(dt);return}let c=s??process.stdin.isTTY,{isAgent:l}=await(0,at.determineAgent)();l&&c&&console.log(`
|
||
To create in one go, run: create-vite <DIRECTORY> --no-interactive --template <TEMPLATE>
|
||
`);let u=Et(process.env.npm_config_user_agent),d=()=>et(`Operation cancelled`),f=e;if(!f)if(c){let e=await it({message:`Project name:`,defaultValue:mt,placeholder:mt,validate:e=>!e||yt(e).length>0?void 0:`Invalid project name`});if(N(e))return d();f=yt(e)}else f=mt;if(t.existsSync(f)&&!wt(f)){let e=a?`yes`:void 0;if(!e)if(c){let t=await nt({message:(f===`.`?`Current directory`:`Target directory "${f}"`)+` is not empty. Please choose how to proceed:`,options:[{label:`Cancel operation`,value:`no`},{label:`Remove existing files and continue`,value:`yes`},{label:`Ignore files and continue`,value:`ignore`}]});if(N(t))return d();e=t}else e=`no`;switch(e){case`yes`:Tt(f);break;case`no`:d();return}}let p=n.basename(n.resolve(f));if(!xt(p))if(c){let e=await it({message:`Package name:`,defaultValue:St(p),placeholder:St(p),validate(e){if(e&&!xt(e))return`Invalid package.json name`}});if(N(e))return d();p=e}else p=St(p);let m=i,h=!1;if(i&&!ft.includes(i)&&(m=void 0,h=!0),!m)if(c){let e=await nt({message:h?`"${i}" isn't a valid template. Please choose from below: `:`Select a framework:`,options:$.map(e=>{let t=e.color;return{label:t(e.display||e.name),value:e}})});if(N(e))return d();let t=await nt({message:`Select a variant:`,options:e.variants.map(e=>{let t=e.customCommand?At(e.customCommand,u).replace(/ TARGET_DIR$/,``):void 0;return{label:jt(e),value:e.name,hint:t}})});if(N(t))return d();m=t}else m=`vanilla-ts`;let g=u?u.name:`npm`,_=n.join(ut,f),v=!1;m.includes(`react-compiler`)&&(v=!0,m=m.replace(`-compiler`,``));let{customCommand:y}=$.flatMap(e=>e.variants).find(e=>e.name===m)??{};if(y){let[e,...t]=At(y,u).split(` `),n=t.map(e=>e.replace(`TARGET_DIR`,()=>f)),{status:r}=ue.default.sync(e,n,{stdio:`inherit`});process.exit(r??0)}let b=o;if(b===void 0)if(c){let e=await $e({message:`Install with ${g} and start now?`});if(N(e))return d();b=e}else b=!1;t.mkdirSync(_,{recursive:!0}),H.step(`Scaffolding project in ${_}...`);let x=n.resolve(r(import.meta.url),`../..`,`template-${m}`),S=(e,r)=>{let i=n.join(_,pt[e]??e);if(r)t.writeFileSync(i,r);else if(e===`index.html`){let r=n.join(x,e),a=t.readFileSync(r,`utf-8`).replace(/<title>.*?<\/title>/,`<title>${p}</title>`);t.writeFileSync(i,a)}else bt(n.join(x,e),i)},C=t.readdirSync(x);for(let e of C.filter(e=>e!==`package.json`))S(e);let w=JSON.parse(t.readFileSync(n.join(x,`package.json`),`utf-8`));if(w.name=p,S(`package.json`,JSON.stringify(w,null,2)+`
|
||
`),v&&Dt(_,m.endsWith(`-ts`)),b)gt(_,g),_t(_,g);else{let e=``,t=n.relative(ut,_);e+=`Done. Now run:
|
||
`,_!==ut&&(e+=`\n cd ${t.includes(` `)?`"${t}"`:t}`),e+=`\n ${Mt(g).join(` `)}`,e+=`\n ${Nt(g,`dev`).join(` `)}`,tt(e)}}function yt(e){return e.trim().replace(/[<>:"\\|?*]/g,``).replace(/\/+$/g,``)}function bt(e,n){t.statSync(e).isDirectory()?Ct(e,n):t.copyFileSync(e,n)}function xt(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function St(e){return e.trim().toLowerCase().replace(/\s+/g,`-`).replace(/^[._]/,``).replace(/[^a-z\d\-~]+/g,`-`)}function Ct(e,r){t.mkdirSync(r,{recursive:!0});for(let i of t.readdirSync(e))bt(n.resolve(e,i),n.resolve(r,i))}function wt(e){let n=t.readdirSync(e);return n.length===0||n.length===1&&n[0]===`.git`}function Tt(e){if(t.existsSync(e))for(let r of t.readdirSync(e))r!==`.git`&&t.rmSync(n.resolve(e,r),{recursive:!0,force:!0})}function Et(e){if(!e)return;let t=e.split(` `)[0].split(`/`);return{name:t[0],version:t[1]}}function Dt(e,t){kt(n.resolve(e,`package.json`),e=>{let n=JSON.parse(e),r=Object.entries(n.devDependencies);return r.push([`@rolldown/plugin-babel`,`^0.2.3`]),r.push([`babel-plugin-react-compiler`,`^1.0.0`]),r.push([`@babel/core`,`^7.29.0`]),t&&r.push([`@types/babel__core`,`^7.20.5`]),r.sort(),n.devDependencies=Object.fromEntries(r),JSON.stringify(n,null,2)+`
|
||
`}),kt(n.resolve(e,`vite.config.${t?`ts`:`js`}`),e=>e.replace(`import react from '@vitejs/plugin-react'`,`import react, { reactCompilerPreset } from '@vitejs/plugin-react'
|
||
import babel from '@rolldown/plugin-babel'`).replace(` plugins: [react()],`,` plugins: [
|
||
react(),
|
||
babel({ presets: [reactCompilerPreset()] })
|
||
],`)),Ot(e,`The React Compiler is enabled on this template. See [this documentation](https://react.dev/learn/react-compiler) for more information.
|
||
|
||
Note: This will impact Vite dev & build performances.`)}function Ot(e,t){kt(n.resolve(e,`README.md`),e=>{let n=e.indexOf(`## React Compiler`),r=e.indexOf(`
|
||
|
||
`,n),i=e.indexOf(`
|
||
## `,r);return n===-1||r===-1||i===-1?(console.warn(`Could not update compiler section in README.md`),e):e.replace(e.slice(r+2,i-1),t)})}function kt(e,n){let r=t.readFileSync(e,`utf-8`);t.writeFileSync(e,n(r),`utf-8`)}function At(e,t){let n=t?t.name:`npm`,r=n===`yarn`&&t?.version.startsWith(`1.`);return e.replace(/^npm create (?:-- )?/,()=>n===`bun`?`bun x create-`:n===`deno`?`deno run -A npm:create-`:n===`pnpm`?`pnpm create `:e.startsWith(`npm create -- `)?`${n} create -- `:`${n} create `).replace(`@latest`,()=>r?``:`@latest`).replace(/^npm exec (?:-- )?/,()=>n===`pnpm`?`pnpm dlx `:n===`yarn`&&!r?`yarn dlx `:n===`bun`?`bun x `:n===`deno`?`deno run -A npm:`:e.startsWith(`npm exec -- `)?`npm exec -- `:`npm exec `)}function jt(e){let t=e.display||e.name,n=e.color(t),{link:r}=e;return r&&(n+=` ${lt(r)}`),n}function Mt(e){return e===`yarn`?[e]:[e,`install`]}function Nt(e,t){switch(e){case`yarn`:case`pnpm`:case`bun`:return[e,t];case`deno`:return[e,`task`,t];default:return[e,`run`,t]}}function Pt(){return new Proxy({},{get(e,t){return e=>i.styleText(t,e)}})}vt().catch(e=>{console.error(e)});export{}; |