create-mugnavo 0.2.2 → 0.3.1
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/README.md +3 -3
- package/dist/index.mjs +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
CLI for creating projects with Mugnavo templates.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
pnpm create mugnavo
|
|
6
|
+
pnpm create mugnavo
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
## Templates
|
|
10
10
|
|
|
11
|
-
- [`default`](https://github.com/mugnavo/tanstarter) - Minimal TanStarter template
|
|
12
|
-
- [`monorepo`](https://github.com/mugnavo/tanstarter
|
|
11
|
+
- [`default`](https://github.com/mugnavo/tanstarter) - Minimal TanStarter template
|
|
12
|
+
- [`monorepo`](https://github.com/mugnavo/tanstarter-monorepo) - TanStarter via Turborepo & pnpm workspaces
|
|
13
13
|
|
|
14
14
|
## License
|
|
15
15
|
|
package/dist/index.mjs
CHANGED
|
@@ -93,14 +93,14 @@ ${t?i(`cyan`,I):``}
|
|
|
93
93
|
`)}catch(e){console.error(e)}}const yn=/^no[-A-Z]/;async function bn(e,t){let n=await H(e.meta||{}),r=mn(await H(e.args||{})),i=await H(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([W(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([W(n+(t?` (required)`:``)),e.description||``]),e.type===`boolean`&&(e.default===!0||e.negativeDescription)&&!yn.test(e.name)){let n=[...(e.alias||[]).map(e=>`--no-${e}`),`--no-${e.name}`].join(`, `);o.push([W(n+(t?` (required)`:``)),e.negativeDescription||``])}t&&l.push(n)}if(e.subCommands){let t=[],n=await H(e.subCommands);for(let[e,r]of Object.entries(n)){let n=await H((await H(r))?.meta);n?.hidden||(c.push([W(e),n?.description||``]),t.push(e))}l.push(t.join(`|`))}let u=[],d=n.version||i.version;u.push(dn(`${n.description} (${a+(d?` v${d}`:``)})`),``);let f=o.length>0||s.length>0;return u.push(`${fn(un(`USAGE`))} ${W(`${a}${f?` [OPTIONS]`:``} ${l.join(` `)}`)}`,``),s.length>0&&(u.push(fn(un(`ARGUMENTS`)),``),u.push(on(s,` `)),u.push(``)),o.length>0&&(u.push(fn(un(`OPTIONS`)),``),u.push(on(o,` `)),u.push(``)),c.length>0&&(u.push(fn(un(`COMMANDS`)),``),u.push(on(c,` `)),u.push(``,`Use ${W(`${a} <command> --help`)} for more information about a command.`)),u.filter(e=>typeof e==`string`).join(`
|
|
94
94
|
`)}async function xn(e,t={}){let n=t.rawArgs||process.argv.slice(2),r=t.showUsage||vn;try{if(n.includes(`--help`)||n.includes(`-h`))await r(...await _n(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 U(`No version specified`,`E_NO_VERSION`);console.log(t.version)}else await gn(e,{rawArgs:n})}catch(t){t instanceof U?(await r(...await _n(e,n)),console.error(t.message)):console.error(t,`
|
|
95
95
|
`),process.exit(1)}}var Sn=le({a:()=>G,n:()=>Nn,r:()=>Mn,t:()=>gr});const Cn=/^[A-Za-z]:\//;function wn(e=``){return e&&e.replace(/\\/g,`/`).replace(Cn,e=>e.toUpperCase())}const Tn=/^[/\\]{2}/,En=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,Dn=/^[A-Za-z]:$/,On=function(e){if(e.length===0)return`.`;e=wn(e);let t=e.match(Tn),n=K(e),r=e[e.length-1]===`/`;return e=jn(e,!n),e.length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),Dn.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!K(e)?`/${e}`:e)},kn=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 On(t)};function An(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}const G=function(...e){e=e.map(e=>wn(e));let t=``,n=!1;for(let r=e.length-1;r>=-1&&!n;r--){let i=r>=0?e[r]:An();!i||i.length===0||(t=`${i}/${t}`,n=K(i))}return t=jn(t,!n),n&&!K(t)?`/${t}`:t.length>0?t:`.`};function jn(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 K=function(e){return En.test(e)},Mn=function(e){let t=wn(e).replace(/\/$/,``).split(`/`).slice(0,-1);return t.length===1&&Dn.test(t[0])&&(t[0]+=`/`),t.join(`/`)||(K(e)?`/`:`.`)},Nn=function(e,t){let n=wn(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 Pn=Object.create,Fn=Object.defineProperty,In=Object.getOwnPropertyDescriptor,Ln=Object.getOwnPropertyNames,Rn=Object.getPrototypeOf,zn=Object.prototype.hasOwnProperty,q=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Bn=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Ln(t),a=0,o=i.length,s;a<o;a++)s=i[a],!zn.call(e,s)&&s!==n&&Fn(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=In(t,s))||r.enumerable});return e},Vn=(e,t,n)=>(n=e==null?{}:Pn(Rn(e)),Bn(t||!e||!e.__esModule?Fn(n,`default`,{value:e,enumerable:!0}):n,e)),J=ie(import.meta.url);const Hn=/^path$/i,Un={key:`PATH`,value:``};function Wn(e){for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t)||!Hn.test(t))continue;let n=e[t];return n?{key:t,value:n}:Un}return Un}function Gn(e,t){let n=t.value.split(v),r=e,i;do n.push(S(r,`node_modules`,`.bin`)),i=r,r=y(r);while(r!==i);return{key:t.key,value:n.join(v)}}function Kn(e,t){let n={...process.env,...t},r=Gn(e,Wn(n));return n[r.key]=r.value,n}const qn=e=>{let t=e.length,n=new ne,r=()=>{--t===0&&n.emit(`end`)};for(let t of e)t.pipe(n,{end:!1}),t.on(`end`,r);return n};var Jn=q((e,t)=>{t.exports=a,a.sync=o;var n=J(`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)}}),Yn=q((e,t)=>{t.exports=r,r.sync=i;var n=J(`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}}),Xn=q((e,t)=>{J(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?Jn():Yn();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}}}),Zn=q((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=J(`path`),i=n?`;`:`:`,a=Xn(),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)}}),Qn=q((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}),$n=q((e,t)=>{let n=J(`path`),r=Zn(),i=Qn();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}),er=q((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}),tr=q((e,t)=>{t.exports=/^#!(.*)/}),nr=q((e,t)=>{let n=tr();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}}),rr=q((e,t)=>{let n=J(`fs`),r=nr();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}),ir=q((e,t)=>{let n=J(`path`),r=$n(),i=er(),a=rr(),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}),ar=q((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}}),or=Vn(q((e,t)=>{let n=J(`child_process`),r=ir(),i=ar();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),sr=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 cr={timeout:void 0,persist:!1},lr={windowsHide:!0};function ur(e,t){return{command:x(e),args:t??[]}}function dr(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 fr(e){let t=``;for await(let n of e)t+=n.toString();return t}var pr=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={...cr,...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 hr(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=qn(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 sr(this)}async _waitForOutput(){let e=this._process;if(!e)throw Error(`No process was started`);let[t,n]=await Promise.all([this._streamOut?fr(this._streamOut):``,this._streamErr?fr(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 sr(this,r);return r}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=o(),t=this._options,n={...lr,...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=dr(r)),n.env=Kn(e,n.env);let{command:i,args:a}=ur(this._command,this._args),s=(0,or._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 mr=(e,t,n)=>{let r=new pr(e,t,n);return r.spawn(),r},hr=mr;var gr=e({detectPackageManager:()=>Cr,installDependencies:()=>wr,packageManagers:()=>Y});async function _r(e,t,n={}){let r=On(e).split(`/`);for(;r.length>0;){let e=await t(r.join(`/`)||`/`);if(e||!n.includeParentDirs)return e;r.pop()}}function vr(e){let t;return()=>(t===void 0&&(t=e().then(e=>(t=e,t))),t)}const yr=vr(async()=>{if(globalThis.process?.versions?.webcontainer)return!1;try{let{exitCode:e}=await mr(`corepack`,[`--version`]);return e===0}catch{return!1}});async function br(e,t,n={}){let r=e!==`npm`&&e!==`bun`&&e!==`deno`&&n.corepack!==!1&&await yr()?[`corepack`,[e,...t]]:[e,t],{exitCode:i,stdout:a,stderr:o}=await mr(r[0],r[1],{nodeOptions:{cwd:G(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(`
|
|
96
|
-
`):``}`)}async function xr(e={}){let t=e.cwd||process.cwd(),n={...process.env,...e.env},r=(typeof e.packageManager==`string`?Y.find(t=>t.name===e.packageManager):e.packageManager)||await Cr(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 Sr(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 Y=[{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 Cr(e,t={}){let n=await _r(G(e||`.`),async e=>{if(!t.ignorePackageJSON){let t=kn(e,`package.json`);if(m(t)){let e=JSON.parse(await T(t,`utf8`));if(e?.packageManager){let{name:t,version:n=`0.0.0`,buildMeta:r,warnings:i}=Sr(e.packageManager);if(t){let e=n.split(`.`)[0],a=Y.find(n=>n.name===t&&n.majorVersion===e)||Y.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(kn(e,`deno.json`)))return Y.find(e=>e.name===`deno`)}if(!t.ignoreLockFile){for(let t of Y)if([t.lockFile,t.files].flat().filter(Boolean).some(t=>m(G(e,t))))return{...t}}},{includeParentDirs:t.includeParentDirs??!0});if(!n&&!t.ignoreArgv){let e=process.argv[1];if(e){for(let t of Y)if(RegExp(`[/\\\\]\\.?${t.command}`).test(e))return t}}return n}async function wr(e={}){let t=await xr(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 br(t.packageManager.command,n,{cwd:t.cwd,silent:t.silent,corepack:t.corepack}),{exec:{command:t.packageManager.command,args:n}}}async function Tr(e,t,r={}){let i=t+`.json`,a=JSON.parse(await T(i,`utf8`).catch(()=>`{}`)),o=(await Z(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 Z(e,{headers:r.headers});if(s.status>=400)throw Error(`Failed to download ${e}: ${s.status} ${s.statusText}`);let c=p(t);await n(D)(s.body,c),await E(i,JSON.stringify(a),`utf8`)}const Er=/^(?<repo>[\w.-]+\/[\w.-]+)(?<subdir>[^#]+)?(?<ref>#[\w./@-]+)?/;function Dr(e){let t=e.match(Er)?.groups||{};return{repo:t.repo||``,subdir:t.subdir||`/`,ref:t.ref?t.ref.slice(1):`main`}}function X(...e){process.env.DEBUG&&console.debug(`[giget]`,...e)}async function Z(e,t={}){t.headers?.[`sec-fetch-mode`]&&(t.mode=t.headers[`sec-fetch-mode`]);let n=await fetch(e,{...t,headers:kr(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 Or(){let e=process.env.XDG_CACHE_HOME?G(process.env.XDG_CACHE_HOME,`giget`):G(ae(),`.cache/giget`);if(process.platform===`win32`){let t=G(oe(),`giget`);if(!m(t)&&m(e))try{g(e,t)}catch{}return t}return e}function kr(e={}){let t={};for(let[n,r]of Object.entries(e))r&&(t[n.toLowerCase()]=r);return t}const Ar=async(e,t)=>{if(e.endsWith(`.json`))return await jr(e,t);let n=new URL(e),r=Nn(n.pathname);try{let i=await Z(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 jr(e,t);let a=i.headers.get(`content-disposition`)?.match(/filename="?(.+)"?/)?.[1];a&&(r=a.split(`.`)[0])}catch(e){X(`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}}},jr=async(e,t)=>{let n=await(await Z(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},Mr=(e,t)=>{let n=Dr(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}`}},Nr={http:Ar,https:Ar,github:Mr,gh:Mr,gitlab:(e,t)=>{let n=Dr(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=Dr(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=Dr(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`}}},Pr=(e=`https://raw.githubusercontent.com/unjs/giget/main/templates`,t={})=>(async n=>{let r=Date.now(),i=`${e}/${n}.json`,a=await Z(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 X(`Fetched ${n} template info from ${i} in ${Date.now()-r}ms`),o}),Fr=/^([\w-.]+):/;async function Ir(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:Pr(t.registry,{auth:t.auth}),r=t.provider||(n?`registry`:`github`),i=e,a=e.match(Fr);a&&(r=a[1],i=e.slice(a[0].length),(r===`http`||r===`https`)&&(i=e));let o=t.providers?.[r]||Nr[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=G(G(Or(),r,s.name),(s.version||s.name)+`.tar.gz`);if(t.preferOffline&&m(c)&&(t.offline=!0),!t.offline){await w(Mn(c),{recursive:!0});let e=Date.now();await Tr(s.tar,c,{headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0,...kr(s.headers)}}).catch(e=>{if(!m(c))throw e;X(`Download error. Using cached version:`,e),t.offline=!0}),X(`Downloaded ${s.tar} to ${c} in ${Date.now()-e}ms`)}if(!m(c))throw Error(`Tarball not found: ${c} (offline: ${t.offline})`);let l=G(G(t.cwd||`.`),t.dir||s.defaultDir);if(t.forceClean&&await te(l,{recursive:!0,force:!0}),!t.force&&m(l)&&h(l).length>0)throw Error(`Destination ${l} already exists.`);await w(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=``)}}),X(`Extracted to ${l} in ${Date.now()-u}ms`),t.install){X(`Installing dependencies...`);let{installDependencies:e}=await Promise.resolve().then(()=>Sn).then(e=>e.t);await e({cwd:l,silent:t.silent,...typeof t.install==`object`?t.install:{}})}return{...s,source:i,dir:l}}function Lr(e){return e}const Rr=Lr([`default`,`monorepo`]),zr=Lr([`pnpm`,`npm`,`bun`,`yarn`,`deno`]),Br={name:{type:`positional`,description:`Project name`,required:!1},template:{type:`enum`,description:`Template to use`,options:Rr,required:!1,alias:[`t`]},install:{type:`boolean`,description:`Install dependencies`,required:!1,alias:[`i`]},packageManager:{type:`enum`,description:`Package manager to use`,options:zr,required:!1,alias:[`p`]}};var Vr=Object.create,Hr=Object.defineProperty,Ur=Object.getOwnPropertyDescriptor,Wr=Object.getOwnPropertyNames,Gr=Object.getPrototypeOf,Kr=Object.prototype.hasOwnProperty,Q=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),qr=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Wr(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Kr.call(e,s)&&s!==n&&Hr(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Ur(t,s))||r.enumerable});return e},Jr=(e,t,n)=>(n=e==null?{}:Vr(Gr(e)),qr(t||!e||!e.__esModule?Hr(n,`default`,{value:e,enumerable:!0}):n,e)),$=ie(import.meta.url);const Yr=/^path$/i,Xr={key:`PATH`,value:``};function Zr(e){for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t)||!Yr.test(t))continue;let n=e[t];return n?{key:t,value:n}:Xr}return Xr}function Qr(e,t){let n=t.value.split(v),r=e,i;do n.push(S(r,`node_modules`,`.bin`)),i=r,r=y(r);while(r!==i);return{key:t.key,value:n.join(v)}}function $r(e,t){let n={...process.env,...t},r=Qr(e,Zr(n));return n[r.key]=r.value,n}const ei=e=>{let t=e.length,n=new ne,r=()=>{--t===0&&n.emit(`end`)};for(let t of e)t.pipe(n,{end:!1}),t.on(`end`,r);return n};var ti=Q((e,t)=>{t.exports=a,a.sync=o;var n=$(`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)}}),ni=Q((e,t)=>{t.exports=r,r.sync=i;var n=$(`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}}),ri=Q((e,t)=>{$(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?ti():ni();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}}}),ii=Q((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=$(`path`),i=n?`;`:`:`,a=ri(),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)}}),ai=Q((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}),oi=Q((e,t)=>{let n=$(`path`),r=ii(),i=ai();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}),si=Q((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}),ci=Q((e,t)=>{t.exports=/^#!(.*)/}),li=Q((e,t)=>{let n=ci();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}}),ui=Q((e,t)=>{let n=$(`fs`),r=li();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}),di=Q((e,t)=>{let n=$(`path`),r=oi(),i=si(),a=ui(),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}),fi=Q((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}}),pi=Jr(Q((e,t)=>{let n=$(`child_process`),r=di(),i=fi();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),mi=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 hi={timeout:void 0,persist:!1},gi={windowsHide:!0};function _i(e,t){return{command:x(e),args:t??[]}}function vi(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 yi(e){let t=``;for await(let n of e)t+=n.toString();return t}var bi=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={...hi,...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 Si(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=ei(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 mi(this)}async _waitForOutput(){let e=this._process;if(!e)throw Error(`No process was started`);let[t,n]=await Promise.all([this._streamOut?yi(this._streamOut):``,this._streamErr?yi(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 mi(this,r);return r}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=o(),t=this._options,n={...gi,...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=vi(r)),n.env=$r(e,n.env);let{command:i,args:a}=_i(this._command,this._args),s=(0,pi._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 xi=(e,t,n)=>{let r=new bi(e,t,n);return r.spawn(),r},Si=xi;function Ci(){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 wi(){try{return await xi(`pnpm`,[`--version`],{throwOnError:!0}),!0}catch{return!1}}async function Ti(e){await xi(`git`,[`init`],{throwOnError:!1,nodeOptions:{cwd:e,stdio:`inherit`}})}async function Ei(e,t){let n=qt({title:`Installing dependencies with ${t}...`,limit:5,retainLog:!1}),r=Ht();r.start();let i=[`install`];t===`npm`&&i.push(`--legacy-peer-deps`);let a=xi(t,i,{throwOnError:!1,nodeOptions:{cwd:e}});for await(let e of a){let t=e.trim();t&&n.message(t)}let o=await a;return r.stop(),o.exitCode===0?(n.success(`Dependencies installed`),!0):(n.error(`Dependency installation failed. You can run \`${t} install\` manually.`),!1)}function Di(e){return e===`npm`?`npm run dev`:e===`deno`?`deno task dev`:`${e} dev`}const Oi=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;function ki(e){for(let t of e){let e=t.codePointAt(0);if(e!==void 0&&(e<=31||`<>:"|?*`.includes(t)))return!0}return!1}function Ai(e){let t=e.trim();if(t.length===0)return`Project name is required`;if(t!==`.`){if(t.includes(`/`)||t.includes(`\\`))return`Project name cannot contain path separators`;if(ki(t))return`Project name contains invalid characters`;if(t===`..`)return`Project name cannot be ..`;if(t.startsWith(`.`))return`Project name cannot start with a period`;if(t.endsWith(`.`)||t.endsWith(`-`))return`Project name cannot end with a period or hyphen`;if(t.length>214)return`Project name must be 214 characters or fewer`;if(!Oi.test(t))return`Use letters, numbers, periods, underscores, or hyphens`}}function ji(e,t){return typeof t==`string`&&e.includes(t)}async function Mi(e){let t;try{t=await ee(e)}catch(e){if(e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`)return;throw e}if(t.length>0)return`Directory must be empty.`}async function Ni(){let e=await Jt({message:`Project name`,placeholder:`my-project`,defaultValue:`my-project`,validate(e){if(typeof e==`string`)return Ai(e)}});if(j(e)){B(`Operation cancelled.`);return}return e}async function Pi(){let e=await Wt({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(j(e)){B(`Operation cancelled.`);return}return e}async function Fi(){let e=await Ft({message:`Install dependencies after scaffolding?`,initialValue:!0});if(j(e)){B(`Operation cancelled.`);return}return e}async function Ii(e){let t=await Wt({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(j(t)){B(`Operation cancelled.`);return}return t}async function Li(e){let t=e.name,n=e.template,r=e.install,i=e.packageManager,a=await wi()?`pnpm`:Ci();if(!t&&(t=await Ni(),!t))return;t=String(t).trim();let o=await Mi(t===`.`?process.cwd():b(process.cwd(),t));if(o){B(o);return}let s=Ai(t);if(s){B(s);return}if(!(!n&&(n=await Pi(),!n))&&!(r===void 0&&(r=await Fi(),r===void 0))&&!(r&&!i&&(i=await Ii(a),!i))&&!(!ji(Rr,n)||typeof r!=`boolean`)&&!(i!==void 0&&!ji(zr,i)))return{projectName:t,template:n,install:r,selectedPackageManager:i,preferredPackageManager:a}}const Ri={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 zi(e){return Ri[e]}function Bi(e,t){return t===`.`?_(S(e))||`app`:t}async function Vi(e){await te(b(e,`LICENSE`),{force:!0})}async function Hi(e,t){if(t===`default`){await C(b(e,`.env.example`),b(e,`.env`),f.COPYFILE_EXCL);return}t===`monorepo`&&(await C(b(e,`apps`,`web`,`.env.example`),b(e,`apps`,`web`,`.env`),f.COPYFILE_EXCL),await C(b(e,`packages`,`db`,`.env.example`),b(e,`packages`,`db`,`.env`),f.COPYFILE_EXCL))}async function Ui(e,t){let n=b(e,`package.json`),r=JSON.parse(await T(n,`utf8`));r.name=Bi(e,t),await E(n,`${JSON.stringify(r,null,2)}\n`)}async function Wi(e,t){let n=b(e,`README.md`),r=Bi(e,t),i=await T(n,`utf8`),a=i.includes(`\r
|
|
96
|
+
`):``}`)}async function xr(e={}){let t=e.cwd||process.cwd(),n={...process.env,...e.env},r=(typeof e.packageManager==`string`?Y.find(t=>t.name===e.packageManager):e.packageManager)||await Cr(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 Sr(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 Y=[{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 Cr(e,t={}){let n=await _r(G(e||`.`),async e=>{if(!t.ignorePackageJSON){let t=kn(e,`package.json`);if(m(t)){let e=JSON.parse(await T(t,`utf8`));if(e?.packageManager){let{name:t,version:n=`0.0.0`,buildMeta:r,warnings:i}=Sr(e.packageManager);if(t){let e=n.split(`.`)[0],a=Y.find(n=>n.name===t&&n.majorVersion===e)||Y.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(kn(e,`deno.json`)))return Y.find(e=>e.name===`deno`)}if(!t.ignoreLockFile){for(let t of Y)if([t.lockFile,t.files].flat().filter(Boolean).some(t=>m(G(e,t))))return{...t}}},{includeParentDirs:t.includeParentDirs??!0});if(!n&&!t.ignoreArgv){let e=process.argv[1];if(e){for(let t of Y)if(RegExp(`[/\\\\]\\.?${t.command}`).test(e))return t}}return n}async function wr(e={}){let t=await xr(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 br(t.packageManager.command,n,{cwd:t.cwd,silent:t.silent,corepack:t.corepack}),{exec:{command:t.packageManager.command,args:n}}}async function Tr(e,t,r={}){let i=t+`.json`,a=JSON.parse(await T(i,`utf8`).catch(()=>`{}`)),o=(await Z(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 Z(e,{headers:r.headers});if(s.status>=400)throw Error(`Failed to download ${e}: ${s.status} ${s.statusText}`);let c=p(t);await n(D)(s.body,c),await E(i,JSON.stringify(a),`utf8`)}const Er=/^(?<repo>[\w.-]+\/[\w.-]+)(?<subdir>[^#]+)?(?<ref>#[\w./@-]+)?/;function Dr(e){let t=e.match(Er)?.groups||{};return{repo:t.repo||``,subdir:t.subdir||`/`,ref:t.ref?t.ref.slice(1):`main`}}function X(...e){process.env.DEBUG&&console.debug(`[giget]`,...e)}async function Z(e,t={}){t.headers?.[`sec-fetch-mode`]&&(t.mode=t.headers[`sec-fetch-mode`]);let n=await fetch(e,{...t,headers:kr(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 Or(){let e=process.env.XDG_CACHE_HOME?G(process.env.XDG_CACHE_HOME,`giget`):G(ae(),`.cache/giget`);if(process.platform===`win32`){let t=G(oe(),`giget`);if(!m(t)&&m(e))try{g(e,t)}catch{}return t}return e}function kr(e={}){let t={};for(let[n,r]of Object.entries(e))r&&(t[n.toLowerCase()]=r);return t}const Ar=async(e,t)=>{if(e.endsWith(`.json`))return await jr(e,t);let n=new URL(e),r=Nn(n.pathname);try{let i=await Z(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 jr(e,t);let a=i.headers.get(`content-disposition`)?.match(/filename="?(.+)"?/)?.[1];a&&(r=a.split(`.`)[0])}catch(e){X(`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}}},jr=async(e,t)=>{let n=await(await Z(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},Mr=(e,t)=>{let n=Dr(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}`}},Nr={http:Ar,https:Ar,github:Mr,gh:Mr,gitlab:(e,t)=>{let n=Dr(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=Dr(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=Dr(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`}}},Pr=(e=`https://raw.githubusercontent.com/unjs/giget/main/templates`,t={})=>(async n=>{let r=Date.now(),i=`${e}/${n}.json`,a=await Z(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 X(`Fetched ${n} template info from ${i} in ${Date.now()-r}ms`),o}),Fr=/^([\w-.]+):/;async function Ir(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:Pr(t.registry,{auth:t.auth}),r=t.provider||(n?`registry`:`github`),i=e,a=e.match(Fr);a&&(r=a[1],i=e.slice(a[0].length),(r===`http`||r===`https`)&&(i=e));let o=t.providers?.[r]||Nr[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=G(G(Or(),r,s.name),(s.version||s.name)+`.tar.gz`);if(t.preferOffline&&m(c)&&(t.offline=!0),!t.offline){await w(Mn(c),{recursive:!0});let e=Date.now();await Tr(s.tar,c,{headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0,...kr(s.headers)}}).catch(e=>{if(!m(c))throw e;X(`Download error. Using cached version:`,e),t.offline=!0}),X(`Downloaded ${s.tar} to ${c} in ${Date.now()-e}ms`)}if(!m(c))throw Error(`Tarball not found: ${c} (offline: ${t.offline})`);let l=G(G(t.cwd||`.`),t.dir||s.defaultDir);if(t.forceClean&&await te(l,{recursive:!0,force:!0}),!t.force&&m(l)&&h(l).length>0)throw Error(`Destination ${l} already exists.`);await w(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=``)}}),X(`Extracted to ${l} in ${Date.now()-u}ms`),t.install){X(`Installing dependencies...`);let{installDependencies:e}=await Promise.resolve().then(()=>Sn).then(e=>e.t);await e({cwd:l,silent:t.silent,...typeof t.install==`object`?t.install:{}})}return{...s,source:i,dir:l}}function Lr(e){return e}const Rr=Lr([`default`,`monorepo`]),zr=Lr([`pnpm`,`npm`,`bun`,`yarn`,`deno`]),Br={name:{type:`positional`,description:`Project name`,required:!1},template:{type:`enum`,description:`Template to use`,options:Rr,required:!1,alias:[`t`]},install:{type:`boolean`,description:`Install dependencies`,required:!1,alias:[`i`]},packageManager:{type:`enum`,description:`Package manager to use`,options:zr,required:!1,alias:[`p`]}};var Vr=Object.create,Hr=Object.defineProperty,Ur=Object.getOwnPropertyDescriptor,Wr=Object.getOwnPropertyNames,Gr=Object.getPrototypeOf,Kr=Object.prototype.hasOwnProperty,Q=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),qr=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Wr(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Kr.call(e,s)&&s!==n&&Hr(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Ur(t,s))||r.enumerable});return e},Jr=(e,t,n)=>(n=e==null?{}:Vr(Gr(e)),qr(t||!e||!e.__esModule?Hr(n,`default`,{value:e,enumerable:!0}):n,e)),$=ie(import.meta.url);const Yr=/^path$/i,Xr={key:`PATH`,value:``};function Zr(e){for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t)||!Yr.test(t))continue;let n=e[t];return n?{key:t,value:n}:Xr}return Xr}function Qr(e,t){let n=t.value.split(v),r=e,i;do n.push(S(r,`node_modules`,`.bin`)),i=r,r=y(r);while(r!==i);return{key:t.key,value:n.join(v)}}function $r(e,t){let n={...process.env,...t},r=Qr(e,Zr(n));return n[r.key]=r.value,n}const ei=e=>{let t=e.length,n=new ne,r=()=>{--t===0&&n.emit(`end`)};for(let t of e)t.pipe(n,{end:!1}),t.on(`end`,r);return n};var ti=Q((e,t)=>{t.exports=a,a.sync=o;var n=$(`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)}}),ni=Q((e,t)=>{t.exports=r,r.sync=i;var n=$(`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}}),ri=Q((e,t)=>{$(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?ti():ni();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}}}),ii=Q((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=$(`path`),i=n?`;`:`:`,a=ri(),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)}}),ai=Q((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}),oi=Q((e,t)=>{let n=$(`path`),r=ii(),i=ai();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}),si=Q((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}),ci=Q((e,t)=>{t.exports=/^#!(.*)/}),li=Q((e,t)=>{let n=ci();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}}),ui=Q((e,t)=>{let n=$(`fs`),r=li();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}),di=Q((e,t)=>{let n=$(`path`),r=oi(),i=si(),a=ui(),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}),fi=Q((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}}),pi=Jr(Q((e,t)=>{let n=$(`child_process`),r=di(),i=fi();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),mi=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 hi={timeout:void 0,persist:!1},gi={windowsHide:!0};function _i(e,t){return{command:x(e),args:t??[]}}function vi(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 yi(e){let t=``;for await(let n of e)t+=n.toString();return t}var bi=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={...hi,...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 Si(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=ei(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 mi(this)}async _waitForOutput(){let e=this._process;if(!e)throw Error(`No process was started`);let[t,n]=await Promise.all([this._streamOut?yi(this._streamOut):``,this._streamErr?yi(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 mi(this,r);return r}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=o(),t=this._options,n={...gi,...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=vi(r)),n.env=$r(e,n.env);let{command:i,args:a}=_i(this._command,this._args),s=(0,pi._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 xi=(e,t,n)=>{let r=new bi(e,t,n);return r.spawn(),r},Si=xi;function Ci(){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 wi(){try{return await xi(`pnpm`,[`--version`],{throwOnError:!0}),!0}catch{return!1}}async function Ti(e){await xi(`git`,[`init`],{throwOnError:!1,nodeOptions:{cwd:e,stdio:`inherit`}})}async function Ei(e,t){let n=qt({title:`Installing dependencies with ${t}...`,limit:5,retainLog:!1}),r=Ht();r.start();let i=[`install`];t===`npm`&&i.push(`--legacy-peer-deps`);let a=xi(t,i,{throwOnError:!1,nodeOptions:{cwd:e}});for await(let e of a){let t=e.trim();t&&n.message(t)}let o=await a;return r.stop(),o.exitCode===0?(n.success(`Dependencies installed`),!0):(n.error(`Dependency installation failed. You can run \`${t} install\` manually.`),!1)}function Di(e){return e===`npm`?`npm run dev`:e===`deno`?`deno task dev`:`${e} dev`}const Oi=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;function ki(e){for(let t of e){let e=t.codePointAt(0);if(e!==void 0&&(e<=31||`<>:"|?*`.includes(t)))return!0}return!1}function Ai(e){let t=e.trim();if(t.length===0)return`Project name is required`;if(t!==`.`){if(t.includes(`/`)||t.includes(`\\`))return`Project name cannot contain path separators`;if(ki(t))return`Project name contains invalid characters`;if(t===`..`)return`Project name cannot be ..`;if(t.startsWith(`.`))return`Project name cannot start with a period`;if(t.endsWith(`.`)||t.endsWith(`-`))return`Project name cannot end with a period or hyphen`;if(t.length>214)return`Project name must be 214 characters or fewer`;if(!Oi.test(t))return`Use letters, numbers, periods, underscores, or hyphens`}}function ji(e,t){return typeof t==`string`&&e.includes(t)}async function Mi(e){let t;try{t=await ee(e)}catch(e){if(e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`)return;throw e}if(t.length>0)return`Directory must be empty.`}async function Ni(){let e=await Jt({message:`Project name`,placeholder:`my-project`,defaultValue:`my-project`,validate(e){if(typeof e==`string`)return Ai(e)}});if(j(e)){B(`Operation cancelled.`);return}return e}async function Pi(){let e=await Wt({message:`Select a template to use`,options:[{value:`default`,label:`Default`,hint:`minimal TanStarter template`},{value:`monorepo`,label:`Monorepo (beta)`,hint:`TanStarter via Turborepo & pnpm workspaces`}]});if(j(e)){B(`Operation cancelled.`);return}return e}async function Fi(){let e=await Ft({message:`Install dependencies after scaffolding?`,initialValue:!0});if(j(e)){B(`Operation cancelled.`);return}return e}async function Ii(e){let t=await Wt({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(j(t)){B(`Operation cancelled.`);return}return t}async function Li(e){let t=e.name,n=e.template,r=e.install,i=e.packageManager,a=await wi()?`pnpm`:Ci();if(!t&&(t=await Ni(),!t))return;t=String(t).trim();let o=await Mi(t===`.`?process.cwd():b(process.cwd(),t));if(o){B(o);return}let s=Ai(t);if(s){B(s);return}if(!(!n&&(n=await Pi(),!n))&&!(r===void 0&&(r=await Fi(),r===void 0))&&!(r&&!i&&(i=await Ii(a),!i))&&!(!ji(Rr,n)||typeof r!=`boolean`)&&!(i!==void 0&&!ji(zr,i)))return{projectName:t,template:n,install:r,selectedPackageManager:i,preferredPackageManager:a}}const Ri={default:{source:`github:mugnavo/tanstarter`,homeUrl:`https://github.com/mugnavo/tanstarter`},monorepo:{source:`github:mugnavo/tanstarter-monorepo`,homeUrl:`https://github.com/mugnavo/tanstarter-monorepo`}};function zi(e){return Ri[e]}function Bi(e,t){return t===`.`?_(S(e))||`app`:t}async function Vi(e){await te(b(e,`LICENSE`),{force:!0})}async function Hi(e,t){if(t===`default`){await C(b(e,`.env.example`),b(e,`.env`),f.COPYFILE_EXCL);return}t===`monorepo`&&(await C(b(e,`apps`,`web`,`.env.example`),b(e,`apps`,`web`,`.env`),f.COPYFILE_EXCL),await C(b(e,`packages`,`db`,`.env.example`),b(e,`packages`,`db`,`.env`),f.COPYFILE_EXCL))}async function Ui(e,t){let n=b(e,`package.json`),r=JSON.parse(await T(n,`utf8`));r.name=Bi(e,t),await E(n,`${JSON.stringify(r,null,2)}\n`)}async function Wi(e,t){let n=b(e,`README.md`),r=Bi(e,t),i=await T(n,`utf8`),a=i.includes(`\r
|
|
97
97
|
`)?`\r
|
|
98
98
|
`:`
|
|
99
99
|
`,o=i.split(/\r?\n/),s=o.findIndex(e=>e.startsWith(`# `));s===-1?o.length>0&&(o[0]=`# ${r}`):o[s]=`# ${r}`,Gi(o,[{marker:`<!-- scaffold:description -->`,replacementContent:"This project was scaffolded with [`create-mugnavo`](https://github.com/mugnavo/create-mugnavo).",skipEmptyLinesAfterMarker:!0}]);let c=o.join(a);c!==i&&await E(n,c)}function Gi(e,t){let n=!1;for(let{marker:r,replacementContent:i,skipEmptyLinesAfterMarker:a}of t){let t=e.findIndex(e=>e.trim()===r);if(t===-1)continue;let o=t+1;if(a)for(;e[o]!==void 0&&e[o]?.trim()===``;)o+=1;let s=e[o];if(s===void 0){e.splice(t,1),n=!0;continue}let c=`${s.match(/^\s*/)?.[0]??``}${i}`;e.splice(t,o-t+1,c),n=!0}return n}async function Ki(e,t){let n=await T(e,`utf8`),r=n.includes(`\r
|
|
100
100
|
`)?`\r
|
|
101
101
|
`:`
|
|
102
102
|
`,i=n.split(/\r?\n/);Gi(i,t)&&await E(e,i.join(r))}async function qi(e,t,n){let r=Bi(e,n);await Ki(t===`default`?b(e,`src`,`routes`,`__root.tsx`):b(e,`apps`,`web`,`src`,`routes`,`__root.tsx`),[{marker:`// scaffold:title`,replacementContent:`title: ${JSON.stringify(r)},`},{marker:`// scaffold:description`,replacementContent:`content: "A TanStack Start project scaffolded with create-mugnavo.",`}])}async function Ji(e,t,n){await Promise.allSettled([Vi(e),Hi(e,t),Ui(e,n),Wi(e,n),qi(e,t,n)])}function Yi(e,t,n,r){let i=[];return e!==`.`&&i.push(`cd ${e}`),t||i.push(`${n} install${n===`npm`?` --legacy-peer-deps`:``}`),i.push(r,``,`See README.md for next steps`),i.join(`
|
|
103
|
-
`)}xn(hn({meta:{name:`create-mugnavo`,version:`0.
|
|
103
|
+
`)}xn(hn({meta:{name:`create-mugnavo`,version:`0.3.1`,description:`Create a project using Mugnavo templates.`},args:Br,async run({args:e}){It(`
|
|
104
104
|
⢀⣀ ⡀⣀ ⢀⡀ ⢀⣀ ⣰⡀ ⢀⡀ ⣀⣀ ⡀⢀ ⢀⡀ ⣀⡀ ⢀⣀ ⡀⢀ ⢀⡀
|
|
105
105
|
⠣⠤ ⠏ ⠣⠭ ⠣⠼ ⠘⠤ ⠣⠭ ⠉⠉ ⠇⠇⠇ ⠣⠼ ⣑⡺ ⠇⠸ ⠣⠼ ⠱⠃ ⠣⠜
|
|
106
106
|
`);let t=await Li(e);if(!t)return;let{projectName:n,template:r,install:i,selectedPackageManager:a,preferredPackageManager:o}=t,s=Ht();try{let e=zi(r);s.start(`Cloning project...`);let{dir:t,source:c}=await Ir(e.source,{dir:n,force:!0,forceClean:!0});await Ji(t,r,n);let l=a||o;s.stop(`Project cloned from ${c}`),await Ti(t),i&&(await Ei(t,l)||(i=!1)),Bt(`${Yi(n,i,l,Di(l))}\n${e.homeUrl}`,`Next steps`),Lt(`All set. Happy coding! 🚀`)}catch(e){s.stop(),Lt(`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.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Create a project using Mugnavo templates.",
|
|
5
5
|
"homepage": "https://github.com/mugnavo/create-mugnavo#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"citty": "^0.2.1",
|
|
25
25
|
"giget": "^3.1.2",
|
|
26
26
|
"oxfmt": "^0.36.0",
|
|
27
|
-
"oxlint": "^1.
|
|
27
|
+
"oxlint": "^1.52.0",
|
|
28
28
|
"oxlint-tsgolint": "^0.16.0",
|
|
29
29
|
"tinyexec": "^1.0.2",
|
|
30
|
-
"tsdown": "^0.21.
|
|
30
|
+
"tsdown": "^0.21.1",
|
|
31
31
|
"typescript": "^5.9.3",
|
|
32
32
|
"vitest": "^4.0.18"
|
|
33
33
|
},
|