create-mugnavo 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +1 -1
- package/package.json +13 -14
package/dist/index.mjs
CHANGED
|
@@ -92,4 +92,4 @@ ${t?i(`cyan`,I):``}
|
|
|
92
92
|
`)}catch(e){console.error(e)}}const gn=/^no[-A-Z]/;async function _n(e,t){let n=await V(e.meta||{}),r=dn(await V(e.args||{})),i=await V(t?.meta||{}),a=`${i.name?`${i.name} `:``}`+(n.name||process.argv[1]),o=[],s=[],c=[],l=[];for(let e of r)if(e.type===`positional`){let t=e.name.toUpperCase(),n=e.required!==!1&&e.default===void 0,r=e.default?`="${e.default}"`:``;s.push([U(t+r),e.description||``,e.valueHint?`<${e.valueHint}>`:``]),l.push(n?`<${t}>`:`[${t}]`)}else{let t=e.required===!0&&e.default===void 0,n=[...(e.alias||[]).map(e=>`-${e}`),`--${e.name}`].join(`, `)+(e.type===`string`&&(e.valueHint||e.default)?`=${e.valueHint?`<${e.valueHint}>`:`"${e.default||``}"`}`:``)+(e.type===`enum`&&e.options?`=<${e.options.join(`|`)}>`:``);if(o.push([U(n+(t?` (required)`:``)),e.description||``]),e.type===`boolean`&&(e.default===!0||e.negativeDescription)&&!gn.test(e.name)){let n=[...(e.alias||[]).map(e=>`--no-${e}`),`--no-${e.name}`].join(`, `);o.push([U(n+(t?` (required)`:``)),e.negativeDescription||``])}t&&l.push(n)}if(e.subCommands){let t=[],n=await V(e.subCommands);for(let[e,r]of Object.entries(n)){let n=await V((await V(r))?.meta);n?.hidden||(c.push([U(e),n?.description||``]),t.push(e))}l.push(t.join(`|`))}let u=[],d=n.version||i.version;u.push(cn(`${n.description} (${a+(d?` v${d}`:``)})`),``);let f=o.length>0||s.length>0;return u.push(`${ln(sn(`USAGE`))} ${U(`${a}${f?` [OPTIONS]`:``} ${l.join(` `)}`)}`,``),s.length>0&&(u.push(ln(sn(`ARGUMENTS`)),``),u.push(nn(s,` `)),u.push(``)),o.length>0&&(u.push(ln(sn(`OPTIONS`)),``),u.push(nn(o,` `)),u.push(``)),c.length>0&&(u.push(ln(sn(`COMMANDS`)),``),u.push(nn(c,` `)),u.push(``,`Use ${U(`${a} <command> --help`)} for more information about a command.`)),u.filter(e=>typeof e==`string`).join(`
|
|
93
93
|
`)}async function vn(e,t={}){let n=t.rawArgs||process.argv.slice(2),r=t.showUsage||hn;try{if(n.includes(`--help`)||n.includes(`-h`))await r(...await mn(e,n)),process.exit(0);else if(n.length===1&&n[0]===`--version`){let t=typeof e.meta==`function`?await e.meta():await e.meta;if(!t?.version)throw new H(`No version specified`,`E_NO_VERSION`);console.log(t.version)}else await pn(e,{rawArgs:n})}catch(t){t instanceof H?(await r(...await mn(e,n)),console.error(t.message)):console.error(t,`
|
|
94
94
|
`),process.exit(1)}}var yn=ce({a:()=>W,n:()=>An,r:()=>kn,t:()=>pr});const bn=/^[A-Za-z]:\//;function xn(e=``){return e&&e.replace(/\\/g,`/`).replace(bn,e=>e.toUpperCase())}const Sn=/^[/\\]{2}/,Cn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,wn=/^[A-Za-z]:$/,Tn=function(e){if(e.length===0)return`.`;e=xn(e);let t=e.match(Sn),n=G(e),r=e[e.length-1]===`/`;return e=On(e,!n),e.length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),wn.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!G(e)?`/${e}`:e)},En=function(...e){let t=``;for(let n of e)if(n)if(t.length>0){let e=t[t.length-1]===`/`,r=n[0]===`/`;e&&r?t+=n.slice(1):t+=e||r?n:`/${n}`}else t+=n;return Tn(t)};function Dn(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}const W=function(...e){e=e.map(e=>xn(e));let t=``,n=!1;for(let r=e.length-1;r>=-1&&!n;r--){let i=r>=0?e[r]:Dn();!i||i.length===0||(t=`${i}/${t}`,n=G(i))}return t=On(t,!n),n&&!G(t)?`/${t}`:t.length>0?t:`.`};function On(e,t){let n=``,r=0,i=-1,a=0,o=null;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o===`/`)break;else o=`/`;if(o===`/`){if(!(i===s-1||a===1))if(a===2){if(n.length<2||r!==2||n[n.length-1]!==`.`||n[n.length-2]!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}else if(n.length>0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}const G=function(e){return Cn.test(e)},kn=function(e){let t=xn(e).replace(/\/$/,``).split(`/`).slice(0,-1);return t.length===1&&wn.test(t[0])&&(t[0]+=`/`),t.join(`/`)||(G(e)?`/`:`.`)},An=function(e,t){let n=xn(e).split(`/`),r=``;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t){r=t;break}}return t&&r.endsWith(t)?r.slice(0,-t.length):r};var jn=Object.create,Mn=Object.defineProperty,Nn=Object.getOwnPropertyDescriptor,Pn=Object.getOwnPropertyNames,Fn=Object.getPrototypeOf,In=Object.prototype.hasOwnProperty,K=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ln=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Pn(t),a=0,o=i.length,s;a<o;a++)s=i[a],!In.call(e,s)&&s!==n&&Mn(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Nn(t,s))||r.enumerable});return e},Rn=(e,t,n)=>(n=e==null?{}:jn(Fn(e)),Ln(t||!e||!e.__esModule?Mn(n,`default`,{value:e,enumerable:!0}):n,e)),q=E(import.meta.url);const zn=/^path$/i,Bn={key:`PATH`,value:``};function Vn(e){for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t)||!zn.test(t))continue;let n=e[t];return n?{key:t,value:n}:Bn}return Bn}function Hn(e,t){let n=t.value.split(_),r=e,i;do n.push(x(r,`node_modules`,`.bin`)),i=r,r=v(r);while(r!==i);return{key:t.key,value:n.join(_)}}function Un(e,t){let n={...process.env,...t},r=Hn(e,Vn(n));return n[r.key]=r.value,n}const Wn=e=>{let t=e.length,n=new T,r=()=>{--t===0&&n.emit(`end`)};for(let t of e)t.pipe(n,{end:!1}),t.on(`end`,r);return n};var Gn=K((e,t)=>{t.exports=a,a.sync=o;var n=q(`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)}}),Kn=K((e,t)=>{t.exports=r,r.sync=i;var n=q(`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}}),qn=K((e,t)=>{q(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?Gn():Kn();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}}}),Jn=K((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=q(`path`),i=n?`;`:`:`,a=qn(),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)}}),Yn=K((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}),Xn=K((e,t)=>{let n=q(`path`),r=Jn(),i=Yn();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}),Zn=K((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(/(\\*)"/g,`$1$1\\"`),e=e.replace(/(\\*)$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i}),Qn=K((e,t)=>{t.exports=/^#!(.*)/}),$n=K((e,t)=>{let n=Qn();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}}),er=K((e,t)=>{let n=q(`fs`),r=$n();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}),tr=K((e,t)=>{let n=q(`path`),r=Xn(),i=Zn(),a=er(),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}),nr=K((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,`spawn`);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}}),rr=Rn(K((e,t)=>{let n=q(`child_process`),r=tr(),i=nr();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})(),1),ir=class extends Error{result;output;get exitCode(){if(this.result.exitCode!==null)return this.result.exitCode}constructor(e,t){super(`Process exited with non-zero status (${e.exitCode})`),this.result=e,this.output=t}};const ar={timeout:void 0,persist:!1},or={windowsHide:!0};function sr(e,t){return{command:b(e),args:t??[]}}function cr(e){let t=new AbortController;for(let n of e){if(n.aborted)return t.abort(),n;n.addEventListener(`abort`,()=>{t.abort(n.reason)},{signal:t.signal})}return t.signal}async function lr(e){let t=``;for await(let n of e)t+=n.toString();return t}var ur=class{_process;_aborted=!1;_options;_command;_args;_resolveClose;_processClosed;_thrownError;get process(){return this._process}get pid(){return this._process?.pid}get exitCode(){if(this._process&&this._process.exitCode!==null)return this._process.exitCode}constructor(e,t,n){this._options={...ar,...n},this._command=e,this._args=t??[],this._processClosed=new Promise(e=>{this._resolveClose=e})}kill(e){return this._process?.kill(e)===!0}get aborted(){return this._aborted}get killed(){return this._process?.killed===!0}pipe(e,t,n){return fr(e,t,{...n,stdin:this})}async*[Symbol.asyncIterator](){let e=this._process;if(!e)return;let t=[];this._streamErr&&t.push(this._streamErr),this._streamOut&&t.push(this._streamOut);let n=Wn(t),r=u.createInterface({input:n});for await(let e of r)yield e.toString();if(await this._processClosed,e.removeAllListeners(),this._thrownError)throw this._thrownError;if(this._options?.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new ir(this)}async _waitForOutput(){let e=this._process;if(!e)throw Error(`No process was started`);let[t,n]=await Promise.all([this._streamOut?lr(this._streamOut):``,this._streamErr?lr(this._streamErr):``]);if(await this._processClosed,this._options?.stdin&&await this._options.stdin,e.removeAllListeners(),this._thrownError)throw this._thrownError;let r={stderr:n,stdout:t,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new ir(this,r);return r}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=o(),t=this._options,n={...or,...t.nodeOptions},r=[];this._resetState(),t.timeout!==void 0&&r.push(AbortSignal.timeout(t.timeout)),t.signal!==void 0&&r.push(t.signal),t.persist===!0&&(n.detached=!0),r.length>0&&(n.signal=cr(r)),n.env=Un(e,n.env);let{command:i,args:a}=sr(this._command,this._args),s=(0,rr._parse)(i,a,n),c=re(s.command,s.args,s.options);if(c.stderr&&(this._streamErr=c.stderr),c.stdout&&(this._streamOut=c.stdout),this._process=c,c.once(`error`,this._onError),c.once(`close`,this._onClose),t.stdin!==void 0&&c.stdin&&t.stdin.process){let{stdout:e}=t.stdin.process;e&&e.pipe(c.stdin)}}_resetState(){this._aborted=!1,this._processClosed=new Promise(e=>{this._resolveClose=e}),this._thrownError=void 0}_onError=e=>{if(e.name===`AbortError`&&(!(e.cause instanceof Error)||e.cause.name!==`TimeoutError`)){this._aborted=!0;return}this._thrownError=e};_onClose=()=>{this._resolveClose&&this._resolveClose()}};const dr=(e,t,n)=>{let r=new ur(e,t,n);return r.spawn(),r},fr=dr;var pr=e({detectPackageManager:()=>br,installDependencies:()=>xr,packageManagers:()=>J});async function mr(e,t,n={}){let r=Tn(e).split(`/`);for(;r.length>0;){let e=await t(r.join(`/`)||`/`);if(e||!n.includeParentDirs)return e;r.pop()}}function hr(e){let t;return()=>(t===void 0&&(t=e().then(e=>(t=e,t))),t)}const gr=hr(async()=>{if(globalThis.process?.versions?.webcontainer)return!1;try{let{exitCode:e}=await dr(`corepack`,[`--version`]);return e===0}catch{return!1}});async function _r(e,t,n={}){let r=e!==`npm`&&e!==`bun`&&e!==`deno`&&n.corepack!==!1&&await gr()?[`corepack`,[e,...t]]:[e,t],{exitCode:i,stdout:a,stderr:o}=await dr(r[0],r[1],{nodeOptions:{cwd:W(n.cwd||process.cwd()),env:n.env,stdio:n.silent?`pipe`:`inherit`}});if(i!==0)throw Error(`\`${r.flat().join(` `)}\` failed.${n.silent?[``,a,o].join(`
|
|
95
|
-
`):``}`)}async function vr(e={}){let t=e.cwd||process.cwd(),n={...process.env,...e.env},r=(typeof e.packageManager==`string`?J.find(t=>t.name===e.packageManager):e.packageManager)||await br(e.cwd||process.cwd());if(!r)throw Error(`No package manager auto-detected.`);return{cwd:t,env:n,silent:e.silent??!1,packageManager:r,dev:e.dev??!1,workspace:e.workspace,global:e.global??!1,dry:e.dry??!1,corepack:e.corepack??!0}}function yr(e){let[t,n]=(e||``).split(`@`),[r,i]=n?.split(`+`)||[];if(t&&t!==`-`&&/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(t))return{name:t,version:r,buildMeta:i};let a=(t||``).replace(/\W+/g,``);return{name:a,version:r,buildMeta:i,warnings:[`Abnormal characters found in \`packageManager\` field, sanitizing from \`${t}\` to \`${a}\``]}}const J=[{name:`npm`,command:`npm`,lockFile:`package-lock.json`},{name:`pnpm`,command:`pnpm`,lockFile:`pnpm-lock.yaml`,files:[`pnpm-workspace.yaml`]},{name:`bun`,command:`bun`,lockFile:[`bun.lockb`,`bun.lock`]},{name:`yarn`,command:`yarn`,lockFile:`yarn.lock`,files:[`.yarnrc.yml`]},{name:`deno`,command:`deno`,lockFile:`deno.lock`,files:[`deno.json`]}];async function br(e,t={}){let n=await mr(W(e||`.`),async e=>{if(!t.ignorePackageJSON){let t=En(e,`package.json`);if(m(t)){let e=JSON.parse(await w(t,`utf8`));if(e?.packageManager){let{name:t,version:n=`0.0.0`,buildMeta:r,warnings:i}=yr(e.packageManager);if(t){let e=n.split(`.`)[0],a=J.find(n=>n.name===t&&n.majorVersion===e)||J.find(e=>e.name===t);return{name:t,command:t,version:n,majorVersion:e,buildMeta:r,warnings:i,files:a?.files,lockFile:a?.lockFile}}}}if(m(En(e,`deno.json`)))return J.find(e=>e.name===`deno`)}if(!t.ignoreLockFile){for(let t of J)if([t.lockFile,t.files].flat().filter(Boolean).some(t=>m(W(e,t))))return{...t}}},{includeParentDirs:t.includeParentDirs??!0});if(!n&&!t.ignoreArgv){let e=process.argv[1];if(e){for(let t of J)if(RegExp(`[/\\\\]\\.?${t.command}`).test(e))return t}}return n}async function xr(e={}){let t=await vr(e),n=e.frozenLockFile?{npm:[`ci`],yarn:[`install`,`--immutable`],bun:[`install`,`--frozen-lockfile`],pnpm:[`install`,`--frozen-lockfile`],deno:[`install`,`--frozen`]}[t.packageManager.name]:[`install`];return e.ignoreWorkspace&&t.packageManager.name===`pnpm`&&n.push(`--ignore-workspace`),t.dry||await _r(t.packageManager.command,n,{cwd:t.cwd,silent:t.silent,corepack:t.corepack}),{exec:{command:t.packageManager.command,args:n}}}async function Sr(e,t,r={}){let i=t+`.json`,a=JSON.parse(await w(i,`utf8`).catch(()=>`{}`)),o=(await X(e,{method:`HEAD`,headers:r.headers}).catch(()=>void 0))?.headers.get(`etag`);if(a.etag===o&&m(t))return;typeof o==`string`&&(a.etag=o);let s=await X(e,{headers:r.headers});if(s.status>=400)throw Error(`Failed to download ${e}: ${s.status} ${s.statusText}`);let c=p(t);await n(ne)(s.body,c),await te(i,JSON.stringify(a),`utf8`)}const Cr=/^(?<repo>[\w.-]+\/[\w.-]+)(?<subdir>[^#]+)?(?<ref>#[\w./@-]+)?/;function wr(e){let t=e.match(Cr)?.groups||{};return{repo:t.repo||``,subdir:t.subdir||`/`,ref:t.ref?t.ref.slice(1):`main`}}function Y(...e){process.env.DEBUG&&console.debug(`[giget]`,...e)}async function X(e,t={}){t.headers?.[`sec-fetch-mode`]&&(t.mode=t.headers[`sec-fetch-mode`]);let n=await fetch(e,{...t,headers:Er(t.headers)}).catch(t=>{throw Error(`Failed to download ${e}: ${t}`,{cause:t})});if(t.validateStatus&&n.status>=400)throw Error(`Failed to fetch ${e}: ${n.status} ${n.statusText}`);return n}function Tr(){let e=process.env.XDG_CACHE_HOME?W(process.env.XDG_CACHE_HOME,`giget`):W(ie(),`.cache/giget`);if(process.platform===`win32`){let t=W(ae(),`giget`);if(!m(t)&&m(e))try{g(e,t)}catch{}return t}return e}function Er(e={}){let t={};for(let[n,r]of Object.entries(e))r&&(t[n.toLowerCase()]=r);return t}const Dr=async(e,t)=>{if(e.endsWith(`.json`))return await Or(e,t);let n=new URL(e),r=An(n.pathname);try{let i=await X(n.href,{method:`HEAD`,validateStatus:!0,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0}});if((i.headers.get(`content-type`)||``).includes(`application/json`))return await Or(e,t);let a=i.headers.get(`content-disposition`)?.match(/filename="?(.+)"?/)?.[1];a&&(r=a.split(`.`)[0])}catch(e){Y(`Failed to fetch HEAD for ${n.href}:`,e)}return{name:`${r}-${n.href.slice(0,8)}`,version:``,subdir:``,tar:n.href,defaultDir:r,headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0}}},Or=async(e,t)=>{let n=await(await X(e,{validateStatus:!0,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0}})).json();if(!n.tar||!n.name)throw Error(`Invalid template info from ${e}. name or tar fields are missing!`);return n},kr=(e,t)=>{let n=wr(e),r=process.env.GIGET_GITHUB_URL||`https://api.github.com`;return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0,Accept:`application/vnd.github+json`,"X-GitHub-Api-Version":`2022-11-28`},url:`${r.replace(`api.github.com`,`github.com`)}/${n.repo}/tree/${n.ref}${n.subdir}`,tar:`${r}/repos/${n.repo}/tarball/${n.ref}`}},Ar={http:Dr,https:Dr,github:kr,gh:kr,gitlab:(e,t)=>{let n=wr(e),r=process.env.GIGET_GITLAB_URL||`https://gitlab.com`;return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0,"sec-fetch-mode":`same-origin`},url:`${r}/${n.repo}/tree/${n.ref}${n.subdir}`,tar:`${r}/${n.repo}/-/archive/${n.ref}.tar.gz`}},bitbucket:(e,t)=>{let n=wr(e);return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0},url:`https://bitbucket.com/${n.repo}/src/${n.ref}${n.subdir}`,tar:`https://bitbucket.org/${n.repo}/get/${n.ref}.tar.gz`}},sourcehut:(e,t)=>{let n=wr(e);return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0},url:`https://git.sr.ht/~${n.repo}/tree/${n.ref}/item${n.subdir}`,tar:`https://git.sr.ht/~${n.repo}/archive/${n.ref}.tar.gz`}}},jr=(e=`https://raw.githubusercontent.com/unjs/giget/main/templates`,t={})=>(async n=>{let r=Date.now(),i=`${e}/${n}.json`,a=await X(i,{headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0}});if(a.status>=400)throw Error(`Failed to download ${n} template info from ${i}: ${a.status} ${a.statusText}`);let o=await a.json();if(!o.tar||!o.name)throw Error(`Invalid template info from ${i}. name or tar fields are missing!`);return Y(`Fetched ${n} template info from ${i} in ${Date.now()-r}ms`),o}),Mr=/^([\w-.]+):/;async function Nr(e,t={}){t.registry=process.env.GIGET_REGISTRY??t.registry,t.auth=process.env.GIGET_AUTH??t.auth;let n=t.registry===!1?void 0:jr(t.registry,{auth:t.auth}),r=t.provider||(n?`registry`:`github`),i=e,a=e.match(Mr);a&&(r=a[1],i=e.slice(a[0].length),(r===`http`||r===`https`)&&(i=e));let o=t.providers?.[r]||Ar[r]||n;if(!o)throw Error(`Unsupported provider: ${r}`);let s=await Promise.resolve().then(()=>o(i,{auth:t.auth})).catch(e=>{throw Error(`Failed to download template from ${r}: ${e.message}`)});if(!s)throw Error(`Failed to resolve template from ${r}`);s.name=(s.name||`template`).replace(/[^\da-z-]/gi,`-`),s.defaultDir=(s.defaultDir||s.name).replace(/[^\da-z-]/gi,`-`);let c=W(W(Tr(),r,s.name),(s.version||s.name)+`.tar.gz`);if(t.preferOffline&&m(c)&&(t.offline=!0),!t.offline){await C(kn(c),{recursive:!0});let e=Date.now();await Sr(s.tar,c,{headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0,...Er(s.headers)}}).catch(e=>{if(!m(c))throw e;Y(`Download error. Using cached version:`,e),t.offline=!0}),Y(`Downloaded ${s.tar} to ${c} in ${Date.now()-e}ms`)}if(!m(c))throw Error(`Tarball not found: ${c} (offline: ${t.offline})`);let l=W(W(t.cwd||`.`),t.dir||s.defaultDir);if(t.forceClean&&await ee(l,{recursive:!0,force:!0}),!t.force&&m(l)&&h(l).length>0)throw Error(`Destination ${l} already exists.`);await C(l,{recursive:!0});let u=Date.now(),d=s.subdir?.replace(/^\//,``)||``,{extract:f}=await import(`./tar-hYiUQrDY.mjs`).then(e=>e.t);if(await f({file:c,cwd:l,onReadEntry(e){e.path=e.path.split(`/`).splice(1).join(`/`),d&&(e.path.startsWith(d+`/`)?e.path=e.path.slice(d.length):e.path=``)}}),Y(`Extracted to ${l} in ${Date.now()-u}ms`),t.install){Y(`Installing dependencies...`);let{installDependencies:e}=await Promise.resolve().then(()=>yn).then(e=>e.t);await e({cwd:l,silent:t.silent,...typeof t.install==`object`?t.install:{}})}return{...s,source:i,dir:l}}function Pr(e){return e}const Fr=Pr([`default`,`monorepo`]),Ir=Pr([`pnpm`,`npm`,`bun`,`yarn`,`deno`]),Lr={name:{type:`positional`,description:`Project name`,required:!1},template:{type:`enum`,description:`Template to use`,options:Fr,required:!1,alias:[`t`]},install:{type:`boolean`,description:`Install dependencies`,required:!1,alias:[`i`]},packageManager:{type:`enum`,description:`Package manager to use`,options:Ir,required:!1,alias:[`p`]}};var Rr=Object.create,zr=Object.defineProperty,Br=Object.getOwnPropertyDescriptor,Vr=Object.getOwnPropertyNames,Hr=Object.getPrototypeOf,Ur=Object.prototype.hasOwnProperty,Z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Wr=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Vr(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ur.call(e,s)&&s!==n&&zr(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Br(t,s))||r.enumerable});return e},Gr=(e,t,n)=>(n=e==null?{}:Rr(Hr(e)),Wr(t||!e||!e.__esModule?zr(n,`default`,{value:e,enumerable:!0}):n,e)),Q=E(import.meta.url);const Kr=/^path$/i,qr={key:`PATH`,value:``};function Jr(e){for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t)||!Kr.test(t))continue;let n=e[t];return n?{key:t,value:n}:qr}return qr}function Yr(e,t){let n=t.value.split(_),r=e,i;do n.push(x(r,`node_modules`,`.bin`)),i=r,r=v(r);while(r!==i);return{key:t.key,value:n.join(_)}}function Xr(e,t){let n={...process.env,...t},r=Yr(e,Jr(n));return n[r.key]=r.value,n}const Zr=e=>{let t=e.length,n=new T,r=()=>{--t===0&&n.emit(`end`)};for(let t of e)t.pipe(n,{end:!1}),t.on(`end`,r);return n};var Qr=Z((e,t)=>{t.exports=a,a.sync=o;var n=Q(`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)}}),$r=Z((e,t)=>{t.exports=r,r.sync=i;var n=Q(`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}}),ei=Z((e,t)=>{Q(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?Qr():$r();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}}}),ti=Z((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=Q(`path`),i=n?`;`:`:`,a=ei(),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)}}),ni=Z((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}),ri=Z((e,t)=>{let n=Q(`path`),r=ti(),i=ni();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}),ii=Z((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(/(\\*)"/g,`$1$1\\"`),e=e.replace(/(\\*)$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i}),ai=Z((e,t)=>{t.exports=/^#!(.*)/}),oi=Z((e,t)=>{let n=ai();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}}),si=Z((e,t)=>{let n=Q(`fs`),r=oi();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}),ci=Z((e,t)=>{let n=Q(`path`),r=ri(),i=ii(),a=si(),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}),li=Z((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,`spawn`);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}}),ui=Gr(Z((e,t)=>{let n=Q(`child_process`),r=ci(),i=li();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})(),1),di=class extends Error{result;output;get exitCode(){if(this.result.exitCode!==null)return this.result.exitCode}constructor(e,t){super(`Process exited with non-zero status (${e.exitCode})`),this.result=e,this.output=t}};const fi={timeout:void 0,persist:!1},pi={windowsHide:!0};function mi(e,t){return{command:b(e),args:t??[]}}function hi(e){let t=new AbortController;for(let n of e){if(n.aborted)return t.abort(),n;n.addEventListener(`abort`,()=>{t.abort(n.reason)},{signal:t.signal})}return t.signal}async function gi(e){let t=``;for await(let n of e)t+=n.toString();return t}var _i=class{_process;_aborted=!1;_options;_command;_args;_resolveClose;_processClosed;_thrownError;get process(){return this._process}get pid(){return this._process?.pid}get exitCode(){if(this._process&&this._process.exitCode!==null)return this._process.exitCode}constructor(e,t,n){this._options={...fi,...n},this._command=e,this._args=t??[],this._processClosed=new Promise(e=>{this._resolveClose=e})}kill(e){return this._process?.kill(e)===!0}get aborted(){return this._aborted}get killed(){return this._process?.killed===!0}pipe(e,t,n){return vi(e,t,{...n,stdin:this})}async*[Symbol.asyncIterator](){let e=this._process;if(!e)return;let t=[];this._streamErr&&t.push(this._streamErr),this._streamOut&&t.push(this._streamOut);let n=Zr(t),r=u.createInterface({input:n});for await(let e of r)yield e.toString();if(await this._processClosed,e.removeAllListeners(),this._thrownError)throw this._thrownError;if(this._options?.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new di(this)}async _waitForOutput(){let e=this._process;if(!e)throw Error(`No process was started`);let[t,n]=await Promise.all([this._streamOut?gi(this._streamOut):``,this._streamErr?gi(this._streamErr):``]);if(await this._processClosed,this._options?.stdin&&await this._options.stdin,e.removeAllListeners(),this._thrownError)throw this._thrownError;let r={stderr:n,stdout:t,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new di(this,r);return r}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=o(),t=this._options,n={...pi,...t.nodeOptions},r=[];this._resetState(),t.timeout!==void 0&&r.push(AbortSignal.timeout(t.timeout)),t.signal!==void 0&&r.push(t.signal),t.persist===!0&&(n.detached=!0),r.length>0&&(n.signal=hi(r)),n.env=Xr(e,n.env);let{command:i,args:a}=mi(this._command,this._args),s=(0,ui._parse)(i,a,n),c=re(s.command,s.args,s.options);if(c.stderr&&(this._streamErr=c.stderr),c.stdout&&(this._streamOut=c.stdout),this._process=c,c.once(`error`,this._onError),c.once(`close`,this._onClose),t.stdin!==void 0&&c.stdin&&t.stdin.process){let{stdout:e}=t.stdin.process;e&&e.pipe(c.stdin)}}_resetState(){this._aborted=!1,this._processClosed=new Promise(e=>{this._resolveClose=e}),this._thrownError=void 0}_onError=e=>{if(e.name===`AbortError`&&(!(e.cause instanceof Error)||e.cause.name!==`TimeoutError`)){this._aborted=!0;return}this._thrownError=e};_onClose=()=>{this._resolveClose&&this._resolveClose()}};const $=(e,t,n)=>{let r=new _i(e,t,n);return r.spawn(),r},vi=$;function yi(){let e=process.env.npm_config_user_agent??``;return e.startsWith(`pnpm/`)?`pnpm`:e.startsWith(`yarn/`)?`yarn`:e.startsWith(`bun/`)?`bun`:e.startsWith(`deno/`)?`deno`:`npm`}async function bi(){try{return await $(`pnpm`,[`--version`],{throwOnError:!0}),!0}catch{return!1}}async function xi(e){await $(`git`,[`init`],{throwOnError:!1,nodeOptions:{cwd:e,stdio:`inherit`}})}async function Si(e,t){let n=Wt({title:`Installing dependencies with ${t}...`,limit:5,retainLog:!1}),r=$(t,[`install`],{throwOnError:!1,nodeOptions:{cwd:e}});for await(let e of r){let t=e.trim();t&&n.message(t)}return(await r).exitCode===0?(n.success(`Dependencies installed`),!0):(n.error(`Dependency installation failed. You can run ${t} install manually.`),!1)}function Ci(e){return e===`npm`?`npm run dev`:e===`deno`?`deno task dev`:`${e} dev`}function wi(e,t){return typeof t==`string`&&e.includes(t)}async function Ti(){let e=await Gt({message:`Project name?`,placeholder:`my-project`,defaultValue:`my-project`,validate(e){if(e&&e.includes(` `))return`Project name cannot contain spaces`}});if(A(e)){Nt(`Operation cancelled.`);return}return e}async function Ei(){let e=await Vt({message:`Select a template to use`,options:[{value:`default`,label:`Default`,hint:`minimal TanStarter template`},{value:`monorepo`,label:`Monorepo`,hint:`TanStarter via Turborepo & pnpm workspaces`}]});if(A(e)){Nt(`Operation cancelled.`);return}return e}async function Di(){let e=await Mt({message:`Install dependencies after scaffolding?`,initialValue:!0});if(A(e)){Nt(`Operation cancelled.`);return}return e}async function Oi(e){let t=await Vt({message:`Select a package manager`,options:[{value:`pnpm`,label:`pnpm (Recommended)`},{value:`npm`,label:`npm`},{value:`bun`,label:`bun`},{value:`yarn`,label:`yarn`},{value:`deno`,label:`deno`}],initialValue:e});if(A(t)){Nt(`Operation cancelled.`);return}return t}async function ki(e){let t=e.name,n=e.template,r=e.install,i=e.packageManager,a=await bi()?`pnpm`:yi();if(!(!t&&(t=await Ti(),!t))&&!(!n&&(n=await Ei(),!n))&&!(r===void 0&&(r=await Di(),r===void 0))&&!(r&&!i&&(i=await Oi(a),!i))&&!(!wi(Fr,n)||typeof r!=`boolean`)&&!(i!==void 0&&!wi(Ir,i)))return{projectName:String(t),template:n,install:r,selectedPackageManager:i,preferredPackageManager:a}}const Ai={default:{source:`github:mugnavo/tanstarter`,homeUrl:`https://github.com/mugnavo/tanstarter`},monorepo:{source:`github:mugnavo/tanstarter#next`,homeUrl:`https://github.com/mugnavo/tanstarter/tree/next`}};function ji(e){return Ai[e]}async function Mi(e,t){try{await ee(y(e,`LICENSE`),{force:!0})}catch{}try{if(t===`default`){await S(y(e,`.env.example`),y(e,`.env`),f.COPYFILE_EXCL);return}await S(y(e,`apps`,`web`,`.env.example`),y(e,`apps`,`web`,`.env`),f.COPYFILE_EXCL),await S(y(e,`packages`,`db`,`.env.example`),y(e,`packages`,`db`,`.env`),f.COPYFILE_EXCL)}catch{}}vn(fn({meta:{name:`create-mugnavo`,version:`0.1.4`,description:`Create a project using Mugnavo templates.`},args:Lr,async run({args:e}){let t=await ki(e);if(!t)return;let{projectName:n,template:r,install:i,selectedPackageManager:a,preferredPackageManager:o}=t,s=zt();try{let e=ji(r);s.start(`Cloning project...`);let{dir:t,source:c}=await Nr(e.source,{dir:n});await Mi(t,r);let l=a||o;s.stop(`Project cloned from ${c}`),await xi(t),i&&(await Si(t,l)||(i=!1));let u=Ci(l);Lt(`cd ${n}${i?``:`\n${l} install`}\n${u}\n\nSee README.md for next steps\n${e.homeUrl}`,`Next steps`),Pt(`Project created successfully`)}catch(e){s.stop(),Pt(`Failed to download template. Please try again later.`),console.error(e);return}}}));export{};
|
|
95
|
+
`):``}`)}async function vr(e={}){let t=e.cwd||process.cwd(),n={...process.env,...e.env},r=(typeof e.packageManager==`string`?J.find(t=>t.name===e.packageManager):e.packageManager)||await br(e.cwd||process.cwd());if(!r)throw Error(`No package manager auto-detected.`);return{cwd:t,env:n,silent:e.silent??!1,packageManager:r,dev:e.dev??!1,workspace:e.workspace,global:e.global??!1,dry:e.dry??!1,corepack:e.corepack??!0}}function yr(e){let[t,n]=(e||``).split(`@`),[r,i]=n?.split(`+`)||[];if(t&&t!==`-`&&/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(t))return{name:t,version:r,buildMeta:i};let a=(t||``).replace(/\W+/g,``);return{name:a,version:r,buildMeta:i,warnings:[`Abnormal characters found in \`packageManager\` field, sanitizing from \`${t}\` to \`${a}\``]}}const J=[{name:`npm`,command:`npm`,lockFile:`package-lock.json`},{name:`pnpm`,command:`pnpm`,lockFile:`pnpm-lock.yaml`,files:[`pnpm-workspace.yaml`]},{name:`bun`,command:`bun`,lockFile:[`bun.lockb`,`bun.lock`]},{name:`yarn`,command:`yarn`,lockFile:`yarn.lock`,files:[`.yarnrc.yml`]},{name:`deno`,command:`deno`,lockFile:`deno.lock`,files:[`deno.json`]}];async function br(e,t={}){let n=await mr(W(e||`.`),async e=>{if(!t.ignorePackageJSON){let t=En(e,`package.json`);if(m(t)){let e=JSON.parse(await w(t,`utf8`));if(e?.packageManager){let{name:t,version:n=`0.0.0`,buildMeta:r,warnings:i}=yr(e.packageManager);if(t){let e=n.split(`.`)[0],a=J.find(n=>n.name===t&&n.majorVersion===e)||J.find(e=>e.name===t);return{name:t,command:t,version:n,majorVersion:e,buildMeta:r,warnings:i,files:a?.files,lockFile:a?.lockFile}}}}if(m(En(e,`deno.json`)))return J.find(e=>e.name===`deno`)}if(!t.ignoreLockFile){for(let t of J)if([t.lockFile,t.files].flat().filter(Boolean).some(t=>m(W(e,t))))return{...t}}},{includeParentDirs:t.includeParentDirs??!0});if(!n&&!t.ignoreArgv){let e=process.argv[1];if(e){for(let t of J)if(RegExp(`[/\\\\]\\.?${t.command}`).test(e))return t}}return n}async function xr(e={}){let t=await vr(e),n=e.frozenLockFile?{npm:[`ci`],yarn:[`install`,`--immutable`],bun:[`install`,`--frozen-lockfile`],pnpm:[`install`,`--frozen-lockfile`],deno:[`install`,`--frozen`]}[t.packageManager.name]:[`install`];return e.ignoreWorkspace&&t.packageManager.name===`pnpm`&&n.push(`--ignore-workspace`),t.dry||await _r(t.packageManager.command,n,{cwd:t.cwd,silent:t.silent,corepack:t.corepack}),{exec:{command:t.packageManager.command,args:n}}}async function Sr(e,t,r={}){let i=t+`.json`,a=JSON.parse(await w(i,`utf8`).catch(()=>`{}`)),o=(await X(e,{method:`HEAD`,headers:r.headers}).catch(()=>void 0))?.headers.get(`etag`);if(a.etag===o&&m(t))return;typeof o==`string`&&(a.etag=o);let s=await X(e,{headers:r.headers});if(s.status>=400)throw Error(`Failed to download ${e}: ${s.status} ${s.statusText}`);let c=p(t);await n(ne)(s.body,c),await te(i,JSON.stringify(a),`utf8`)}const Cr=/^(?<repo>[\w.-]+\/[\w.-]+)(?<subdir>[^#]+)?(?<ref>#[\w./@-]+)?/;function wr(e){let t=e.match(Cr)?.groups||{};return{repo:t.repo||``,subdir:t.subdir||`/`,ref:t.ref?t.ref.slice(1):`main`}}function Y(...e){process.env.DEBUG&&console.debug(`[giget]`,...e)}async function X(e,t={}){t.headers?.[`sec-fetch-mode`]&&(t.mode=t.headers[`sec-fetch-mode`]);let n=await fetch(e,{...t,headers:Er(t.headers)}).catch(t=>{throw Error(`Failed to download ${e}: ${t}`,{cause:t})});if(t.validateStatus&&n.status>=400)throw Error(`Failed to fetch ${e}: ${n.status} ${n.statusText}`);return n}function Tr(){let e=process.env.XDG_CACHE_HOME?W(process.env.XDG_CACHE_HOME,`giget`):W(ie(),`.cache/giget`);if(process.platform===`win32`){let t=W(ae(),`giget`);if(!m(t)&&m(e))try{g(e,t)}catch{}return t}return e}function Er(e={}){let t={};for(let[n,r]of Object.entries(e))r&&(t[n.toLowerCase()]=r);return t}const Dr=async(e,t)=>{if(e.endsWith(`.json`))return await Or(e,t);let n=new URL(e),r=An(n.pathname);try{let i=await X(n.href,{method:`HEAD`,validateStatus:!0,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0}});if((i.headers.get(`content-type`)||``).includes(`application/json`))return await Or(e,t);let a=i.headers.get(`content-disposition`)?.match(/filename="?(.+)"?/)?.[1];a&&(r=a.split(`.`)[0])}catch(e){Y(`Failed to fetch HEAD for ${n.href}:`,e)}return{name:`${r}-${n.href.slice(0,8)}`,version:``,subdir:``,tar:n.href,defaultDir:r,headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0}}},Or=async(e,t)=>{let n=await(await X(e,{validateStatus:!0,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0}})).json();if(!n.tar||!n.name)throw Error(`Invalid template info from ${e}. name or tar fields are missing!`);return n},kr=(e,t)=>{let n=wr(e),r=process.env.GIGET_GITHUB_URL||`https://api.github.com`;return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0,Accept:`application/vnd.github+json`,"X-GitHub-Api-Version":`2022-11-28`},url:`${r.replace(`api.github.com`,`github.com`)}/${n.repo}/tree/${n.ref}${n.subdir}`,tar:`${r}/repos/${n.repo}/tarball/${n.ref}`}},Ar={http:Dr,https:Dr,github:kr,gh:kr,gitlab:(e,t)=>{let n=wr(e),r=process.env.GIGET_GITLAB_URL||`https://gitlab.com`;return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0,"sec-fetch-mode":`same-origin`},url:`${r}/${n.repo}/tree/${n.ref}${n.subdir}`,tar:`${r}/${n.repo}/-/archive/${n.ref}.tar.gz`}},bitbucket:(e,t)=>{let n=wr(e);return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0},url:`https://bitbucket.com/${n.repo}/src/${n.ref}${n.subdir}`,tar:`https://bitbucket.org/${n.repo}/get/${n.ref}.tar.gz`}},sourcehut:(e,t)=>{let n=wr(e);return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0},url:`https://git.sr.ht/~${n.repo}/tree/${n.ref}/item${n.subdir}`,tar:`https://git.sr.ht/~${n.repo}/archive/${n.ref}.tar.gz`}}},jr=(e=`https://raw.githubusercontent.com/unjs/giget/main/templates`,t={})=>(async n=>{let r=Date.now(),i=`${e}/${n}.json`,a=await X(i,{headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0}});if(a.status>=400)throw Error(`Failed to download ${n} template info from ${i}: ${a.status} ${a.statusText}`);let o=await a.json();if(!o.tar||!o.name)throw Error(`Invalid template info from ${i}. name or tar fields are missing!`);return Y(`Fetched ${n} template info from ${i} in ${Date.now()-r}ms`),o}),Mr=/^([\w-.]+):/;async function Nr(e,t={}){t.registry=process.env.GIGET_REGISTRY??t.registry,t.auth=process.env.GIGET_AUTH??t.auth;let n=t.registry===!1?void 0:jr(t.registry,{auth:t.auth}),r=t.provider||(n?`registry`:`github`),i=e,a=e.match(Mr);a&&(r=a[1],i=e.slice(a[0].length),(r===`http`||r===`https`)&&(i=e));let o=t.providers?.[r]||Ar[r]||n;if(!o)throw Error(`Unsupported provider: ${r}`);let s=await Promise.resolve().then(()=>o(i,{auth:t.auth})).catch(e=>{throw Error(`Failed to download template from ${r}: ${e.message}`)});if(!s)throw Error(`Failed to resolve template from ${r}`);s.name=(s.name||`template`).replace(/[^\da-z-]/gi,`-`),s.defaultDir=(s.defaultDir||s.name).replace(/[^\da-z-]/gi,`-`);let c=W(W(Tr(),r,s.name),(s.version||s.name)+`.tar.gz`);if(t.preferOffline&&m(c)&&(t.offline=!0),!t.offline){await C(kn(c),{recursive:!0});let e=Date.now();await Sr(s.tar,c,{headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0,...Er(s.headers)}}).catch(e=>{if(!m(c))throw e;Y(`Download error. Using cached version:`,e),t.offline=!0}),Y(`Downloaded ${s.tar} to ${c} in ${Date.now()-e}ms`)}if(!m(c))throw Error(`Tarball not found: ${c} (offline: ${t.offline})`);let l=W(W(t.cwd||`.`),t.dir||s.defaultDir);if(t.forceClean&&await ee(l,{recursive:!0,force:!0}),!t.force&&m(l)&&h(l).length>0)throw Error(`Destination ${l} already exists.`);await C(l,{recursive:!0});let u=Date.now(),d=s.subdir?.replace(/^\//,``)||``,{extract:f}=await import(`./tar-hYiUQrDY.mjs`).then(e=>e.t);if(await f({file:c,cwd:l,onReadEntry(e){e.path=e.path.split(`/`).splice(1).join(`/`),d&&(e.path.startsWith(d+`/`)?e.path=e.path.slice(d.length):e.path=``)}}),Y(`Extracted to ${l} in ${Date.now()-u}ms`),t.install){Y(`Installing dependencies...`);let{installDependencies:e}=await Promise.resolve().then(()=>yn).then(e=>e.t);await e({cwd:l,silent:t.silent,...typeof t.install==`object`?t.install:{}})}return{...s,source:i,dir:l}}function Pr(e){return e}const Fr=Pr([`default`,`monorepo`]),Ir=Pr([`pnpm`,`npm`,`bun`,`yarn`,`deno`]),Lr={name:{type:`positional`,description:`Project name`,required:!1},template:{type:`enum`,description:`Template to use`,options:Fr,required:!1,alias:[`t`]},install:{type:`boolean`,description:`Install dependencies`,required:!1,alias:[`i`]},packageManager:{type:`enum`,description:`Package manager to use`,options:Ir,required:!1,alias:[`p`]}};var Rr=Object.create,zr=Object.defineProperty,Br=Object.getOwnPropertyDescriptor,Vr=Object.getOwnPropertyNames,Hr=Object.getPrototypeOf,Ur=Object.prototype.hasOwnProperty,Z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Wr=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Vr(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ur.call(e,s)&&s!==n&&zr(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Br(t,s))||r.enumerable});return e},Gr=(e,t,n)=>(n=e==null?{}:Rr(Hr(e)),Wr(t||!e||!e.__esModule?zr(n,`default`,{value:e,enumerable:!0}):n,e)),Q=E(import.meta.url);const Kr=/^path$/i,qr={key:`PATH`,value:``};function Jr(e){for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t)||!Kr.test(t))continue;let n=e[t];return n?{key:t,value:n}:qr}return qr}function Yr(e,t){let n=t.value.split(_),r=e,i;do n.push(x(r,`node_modules`,`.bin`)),i=r,r=v(r);while(r!==i);return{key:t.key,value:n.join(_)}}function Xr(e,t){let n={...process.env,...t},r=Yr(e,Jr(n));return n[r.key]=r.value,n}const Zr=e=>{let t=e.length,n=new T,r=()=>{--t===0&&n.emit(`end`)};for(let t of e)t.pipe(n,{end:!1}),t.on(`end`,r);return n};var Qr=Z((e,t)=>{t.exports=a,a.sync=o;var n=Q(`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)}}),$r=Z((e,t)=>{t.exports=r,r.sync=i;var n=Q(`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}}),ei=Z((e,t)=>{Q(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?Qr():$r();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}}}),ti=Z((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=Q(`path`),i=n?`;`:`:`,a=ei(),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)}}),ni=Z((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}),ri=Z((e,t)=>{let n=Q(`path`),r=ti(),i=ni();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}),ii=Z((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(/(\\*)"/g,`$1$1\\"`),e=e.replace(/(\\*)$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i}),ai=Z((e,t)=>{t.exports=/^#!(.*)/}),oi=Z((e,t)=>{let n=ai();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}}),si=Z((e,t)=>{let n=Q(`fs`),r=oi();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}),ci=Z((e,t)=>{let n=Q(`path`),r=ri(),i=ii(),a=si(),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}),li=Z((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,`spawn`);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}}),ui=Gr(Z((e,t)=>{let n=Q(`child_process`),r=ci(),i=li();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})(),1),di=class extends Error{result;output;get exitCode(){if(this.result.exitCode!==null)return this.result.exitCode}constructor(e,t){super(`Process exited with non-zero status (${e.exitCode})`),this.result=e,this.output=t}};const fi={timeout:void 0,persist:!1},pi={windowsHide:!0};function mi(e,t){return{command:b(e),args:t??[]}}function hi(e){let t=new AbortController;for(let n of e){if(n.aborted)return t.abort(),n;n.addEventListener(`abort`,()=>{t.abort(n.reason)},{signal:t.signal})}return t.signal}async function gi(e){let t=``;for await(let n of e)t+=n.toString();return t}var _i=class{_process;_aborted=!1;_options;_command;_args;_resolveClose;_processClosed;_thrownError;get process(){return this._process}get pid(){return this._process?.pid}get exitCode(){if(this._process&&this._process.exitCode!==null)return this._process.exitCode}constructor(e,t,n){this._options={...fi,...n},this._command=e,this._args=t??[],this._processClosed=new Promise(e=>{this._resolveClose=e})}kill(e){return this._process?.kill(e)===!0}get aborted(){return this._aborted}get killed(){return this._process?.killed===!0}pipe(e,t,n){return vi(e,t,{...n,stdin:this})}async*[Symbol.asyncIterator](){let e=this._process;if(!e)return;let t=[];this._streamErr&&t.push(this._streamErr),this._streamOut&&t.push(this._streamOut);let n=Zr(t),r=u.createInterface({input:n});for await(let e of r)yield e.toString();if(await this._processClosed,e.removeAllListeners(),this._thrownError)throw this._thrownError;if(this._options?.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new di(this)}async _waitForOutput(){let e=this._process;if(!e)throw Error(`No process was started`);let[t,n]=await Promise.all([this._streamOut?gi(this._streamOut):``,this._streamErr?gi(this._streamErr):``]);if(await this._processClosed,this._options?.stdin&&await this._options.stdin,e.removeAllListeners(),this._thrownError)throw this._thrownError;let r={stderr:n,stdout:t,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new di(this,r);return r}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=o(),t=this._options,n={...pi,...t.nodeOptions},r=[];this._resetState(),t.timeout!==void 0&&r.push(AbortSignal.timeout(t.timeout)),t.signal!==void 0&&r.push(t.signal),t.persist===!0&&(n.detached=!0),r.length>0&&(n.signal=hi(r)),n.env=Xr(e,n.env);let{command:i,args:a}=mi(this._command,this._args),s=(0,ui._parse)(i,a,n),c=re(s.command,s.args,s.options);if(c.stderr&&(this._streamErr=c.stderr),c.stdout&&(this._streamOut=c.stdout),this._process=c,c.once(`error`,this._onError),c.once(`close`,this._onClose),t.stdin!==void 0&&c.stdin&&t.stdin.process){let{stdout:e}=t.stdin.process;e&&e.pipe(c.stdin)}}_resetState(){this._aborted=!1,this._processClosed=new Promise(e=>{this._resolveClose=e}),this._thrownError=void 0}_onError=e=>{if(e.name===`AbortError`&&(!(e.cause instanceof Error)||e.cause.name!==`TimeoutError`)){this._aborted=!0;return}this._thrownError=e};_onClose=()=>{this._resolveClose&&this._resolveClose()}};const $=(e,t,n)=>{let r=new _i(e,t,n);return r.spawn(),r},vi=$;function yi(){let e=process.env.npm_config_user_agent??``;return e.startsWith(`pnpm/`)?`pnpm`:e.startsWith(`yarn/`)?`yarn`:e.startsWith(`bun/`)?`bun`:e.startsWith(`deno/`)?`deno`:`npm`}async function bi(){try{return await $(`pnpm`,[`--version`],{throwOnError:!0}),!0}catch{return!1}}async function xi(e){await $(`git`,[`init`],{throwOnError:!1,nodeOptions:{cwd:e,stdio:`inherit`}})}async function Si(e,t){let n=Wt({title:`Installing dependencies with ${t}...`,limit:5,retainLog:!1}),r=$(t,[`install`],{throwOnError:!1,nodeOptions:{cwd:e}});for await(let e of r){let t=e.trim();t&&n.message(t)}return(await r).exitCode===0?(n.success(`Dependencies installed`),!0):(n.error(`Dependency installation failed. You can run \`${t} install\` manually.`),!1)}function Ci(e){return e===`npm`?`npm run dev`:e===`deno`?`deno task dev`:`${e} dev`}function wi(e,t){return typeof t==`string`&&e.includes(t)}async function Ti(){let e=await Gt({message:`Project name?`,placeholder:`my-project`,defaultValue:`my-project`,validate(e){if(e&&e.includes(` `))return`Project name cannot contain spaces`}});if(A(e)){Nt(`Operation cancelled.`);return}return e}async function Ei(){let e=await Vt({message:`Select a template to use`,options:[{value:`default`,label:`Default`,hint:`minimal TanStarter template`},{value:`monorepo`,label:`Monorepo`,hint:`TanStarter via Turborepo & pnpm workspaces`}]});if(A(e)){Nt(`Operation cancelled.`);return}return e}async function Di(){let e=await Mt({message:`Install dependencies after scaffolding?`,initialValue:!0});if(A(e)){Nt(`Operation cancelled.`);return}return e}async function Oi(e){let t=await Vt({message:`Select a package manager`,options:[{value:`pnpm`,label:`pnpm (Recommended)`},{value:`npm`,label:`npm`},{value:`bun`,label:`bun`},{value:`yarn`,label:`yarn`},{value:`deno`,label:`deno`}],initialValue:e});if(A(t)){Nt(`Operation cancelled.`);return}return t}async function ki(e){let t=e.name,n=e.template,r=e.install,i=e.packageManager,a=await bi()?`pnpm`:yi();if(!(!t&&(t=await Ti(),!t))&&!(!n&&(n=await Ei(),!n))&&!(r===void 0&&(r=await Di(),r===void 0))&&!(r&&!i&&(i=await Oi(a),!i))&&!(!wi(Fr,n)||typeof r!=`boolean`)&&!(i!==void 0&&!wi(Ir,i)))return{projectName:String(t),template:n,install:r,selectedPackageManager:i,preferredPackageManager:a}}const Ai={default:{source:`github:mugnavo/tanstarter`,homeUrl:`https://github.com/mugnavo/tanstarter`},monorepo:{source:`github:mugnavo/tanstarter#next`,homeUrl:`https://github.com/mugnavo/tanstarter/tree/next`}};function ji(e){return Ai[e]}async function Mi(e,t){try{await ee(y(e,`LICENSE`),{force:!0})}catch{}try{if(t===`default`){await S(y(e,`.env.example`),y(e,`.env`),f.COPYFILE_EXCL);return}await S(y(e,`apps`,`web`,`.env.example`),y(e,`apps`,`web`,`.env`),f.COPYFILE_EXCL),await S(y(e,`packages`,`db`,`.env.example`),y(e,`packages`,`db`,`.env`),f.COPYFILE_EXCL)}catch{}}vn(fn({meta:{name:`create-mugnavo`,version:`0.1.6`,description:`Create a project using Mugnavo templates.`},args:Lr,async run({args:e}){let t=await ki(e);if(!t)return;let{projectName:n,template:r,install:i,selectedPackageManager:a,preferredPackageManager:o}=t,s=zt();try{let e=ji(r);s.start(`Cloning project...`);let{dir:t,source:c}=await Nr(e.source,{dir:n});await Mi(t,r);let l=a||o;s.stop(`Project cloned from ${c}`),await xi(t),i&&(await Si(t,l)||(i=!1));let u=Ci(l);Lt(`cd ${n}${i?``:`\n${l} install`}\n${u}\n\nSee README.md for next steps\n${e.homeUrl}`,`Next steps`),Pt(`All set. Happy coding! 🚀`)}catch(e){s.stop(),Pt(`Failed to download template. Please try again later.`),console.error(e);return}}}));export{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-mugnavo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Create a project using Mugnavo templates.",
|
|
5
5
|
"homepage": "https://github.com/mugnavo/create-mugnavo#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -17,18 +17,6 @@
|
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "tsdown",
|
|
22
|
-
"dev": "tsdown --watch",
|
|
23
|
-
"lint": "oxlint --type-aware --type-check",
|
|
24
|
-
"lint:fix": "oxlint --type-aware --type-check --fix",
|
|
25
|
-
"format": "oxfmt",
|
|
26
|
-
"format:check": "oxfmt --check",
|
|
27
|
-
"check": "pnpm run format && pnpm run lint",
|
|
28
|
-
"deps": "pnpm dlx taze@latest -Ilw",
|
|
29
|
-
"test": "vitest",
|
|
30
|
-
"prepublishOnly": "pnpm run build"
|
|
31
|
-
},
|
|
32
20
|
"devDependencies": {
|
|
33
21
|
"@clack/prompts": "^1.1.0",
|
|
34
22
|
"@types/node": "^24.12.0",
|
|
@@ -45,5 +33,16 @@
|
|
|
45
33
|
},
|
|
46
34
|
"engines": {
|
|
47
35
|
"node": ">=24"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsdown",
|
|
39
|
+
"dev": "tsdown --watch",
|
|
40
|
+
"lint": "oxlint --type-aware --type-check",
|
|
41
|
+
"lint:fix": "oxlint --type-aware --type-check --fix",
|
|
42
|
+
"format": "oxfmt",
|
|
43
|
+
"format:check": "oxfmt --check",
|
|
44
|
+
"check": "pnpm run format && pnpm run lint",
|
|
45
|
+
"deps": "pnpm dlx taze@latest -Ilw",
|
|
46
|
+
"test": "vitest"
|
|
48
47
|
}
|
|
49
|
-
}
|
|
48
|
+
}
|