santux 0.0.0-stage → 3.0.0

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.
Files changed (3) hide show
  1. package/README.md +28 -2
  2. package/build/index.js +129 -0
  3. package/package.json +56 -4
package/README.md CHANGED
@@ -1,3 +1,29 @@
1
- # Temporary Holding Version
1
+ # santux
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Applies an opinionated tooling setup (lint, format, commit message linting, git hooks, editor settings and Node version pin) to an existing TypeScript project.
4
+
5
+ ## Usage
6
+
7
+ Run it inside a project that has a `package.json`:
8
+
9
+ ```sh
10
+ npx santux init
11
+ ```
12
+
13
+ ## CLI Options
14
+
15
+ - `--dry-run`: print the plan and exit without changing anything.
16
+ - `--toolchain oxc|eslint`: choose the lint and format Toolchain without being asked (`oxc` is the default). `oxc` installs `@santux/oxc-config` with oxlint and oxfmt.
17
+ - `--yes`: accept the plan without asking for confirmation.
18
+
19
+ Use `-h` or `--help` to see all available options.
20
+
21
+ ## Updating
22
+
23
+ After a config package update, run `npx santux init` again: it installs the latest config package and the tool versions it pins, and never rewrites your config files.
24
+
25
+ ## Migrating from `create-santux`
26
+
27
+ `santux` replaces the deprecated `create-santux` package. It no longer creates projects from templates: create the project with the official tool of your framework (for example `create-next-app` or `create-vite`), then run `npx santux init` inside it.
28
+
29
+ Projects created with `create-santux` can run `npx santux init` too. It replaces their lint and format configs with the ones from the config package of the chosen Toolchain, and lists every file it removes or replaces before applying the plan.
package/build/index.js ADDED
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env node
2
+ import{Command as e,Option as t}from"@commander-js/extra-typings";import{styleText as n}from"node:util";import r,{stdin as i,stdout as a}from"node:process";import o,*as s from"node:readline";import{ReadStream as c}from"node:tty";import{dirname as l,join as u}from"node:path";import{applyEdits as d,modify as f,parse as p}from"jsonc-parser";import{generateCode as m,parseModule as h}from"magicast";import{getDefaultExportOptions as g}from"magicast/helpers";import{access as _,mkdir as v,readFile as y,readdir as b,rm as x,writeFile as S}from"node:fs/promises";import{execa as C}from"execa";import{fileURLToPath as ee}from"node:url";var te=`3.0.0`;const ne=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),re=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,w=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,ie=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,ae=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,T=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,oe=/\t{1,1000}/y,se=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,ce=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,le=/\p{M}+/gu,ue={limit:1/0,ellipsis:``},de=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?de(i,ue,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[ce,l],[ie,0],[ae,o],[oe,s],[se,c],[T,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(le,``)){let t=e.codePointAt(0)||0;if(S=re(t)?2:w(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===T?ne(e.slice(p,n.lastIndex)):n===se?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},fe={limit:1/0,ellipsis:``,ellipsisWidth:0},E=(e,t={})=>de(e,fe,t).width,pe=`]8;;`,me=RegExp(`(?:\\[(?<code>\\d+)m|\\${pe}(?<uri>.*))`,`y`),he=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},ge=e=>`[${e}m`,_e=e=>`${pe}${e}`,ve=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:E(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=E(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(pe,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},ye=e=>{let t=e.split(` `),n=t.length;for(;n&&!E(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},be=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=E(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=E(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),ve(s,r,t),c=E(s.at(-1)??``)}else{if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){ve(s,r,t),c=E(s.at(-1)??``);continue}s.push(``),c=0}c+i>t&&n.wordWrap===!1?(ve(s,r,t),c=E(s.at(-1)??``)):(s[s.length-1]+=r,c+=i)}}n.trim!==!1&&(s=s.map(e=>ye(e)));let l=s.join(`
3
+ `),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===`›`){me.lastIndex=e+1;let t=me.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
4
+ `){a&&(r+=_e(``));let e=i?he(i):void 0;i&&e&&(r+=ge(e))}else t===`
5
+ `&&(i&&he(i)&&(r+=ge(i)),a&&(r+=_e(a)))}return r},xe=/\r?\n/;function D(e,t,n){return String(e).normalize().split(xe).map(e=>be(e,t,n)).join(`
6
+ `)}const O={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`},k={screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let n=0;n<e;n++)t+=this.line+(n<e-1?O.up():``);return e&&(t+=O.left),t}};function A(e,t,n){if(!n.some(e=>!e.disabled))return e;let r=e+t,i=Math.max(n.length-1,0),a=r<0?i:r>i?0:r;return n[a]?.disabled?A(a,t<0?-1:1,n):a}const j={actions:/* @__PURE__ */ new Set([`up`,`down`,`left`,`right`,`space`,`enter`,`cancel`]),aliases:/* @__PURE__ */ new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`],[``,`cancel`],[`escape`,`cancel`]]),messages:{cancel:`Canceled`,error:`Something went wrong`},withGuide:!0,accessible:void 0,date:{monthNames:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],messages:{required:`Please enter a valid date`,invalidMonth:`There are only 12 months in a year`,invalidDay:(e,t)=>`There are only ${e} days in ${t}`,afterMin:e=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:e=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function Se(e){if(e!==void 0)return e;if(j.accessible!==void 0)return j.accessible;let t=process.env.ACCESSIBLE;return t!==void 0&&t!==``&&t!==`0`&&t!==`false`}function Ce(e,t){if(typeof e==`string`)return j.aliases.get(e)===t;for(let n of e)if(n!==void 0&&Ce(n,t))return!0;return!1}function we(e,t){if(e===t)return;let n=e.split(`
7
+ `),r=t.split(`
8
+ `),i=Math.max(n.length,r.length),a=[];for(let e=0;e<i;e++)n[e]!==r[e]&&a.push(e);return{lines:a,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}const Te=globalThis.process.platform.startsWith(`win`),Ee=Symbol(`clack:cancel`);function De(e){return e===Ee}function M(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function Oe({input:e=i,output:t=a,overwrite:n=!0,hideCursor:r=!0}={}){let o=s.createInterface({input:e,output:t,prompt:``,tabSize:1});s.emitKeypressEvents(e,o),e instanceof c&&e.isTTY&&e.setRawMode(!0);let l=(i,{name:a,sequence:o})=>{if(Ce([String(i),a,o],`cancel`)){r&&t.write(O.show),process.exit(0);return}if(!n)return;let c=a===`return`?0:-1,u=a===`return`?-1:0;s.moveCursor(t,c,u,()=>{s.clearLine(t,1,()=>{e.once(`keypress`,l)})})};return r&&t.write(O.hide),e.once(`keypress`,l),()=>{e.off(`keypress`,l),r&&t.write(O.show),e instanceof c&&e.isTTY&&!Te&&e.setRawMode(!1),o.terminal=!1,o.close()}}const N=e=>`columns`in e&&typeof e.columns==`number`?e.columns:80,ke=e=>`rows`in e&&typeof e.rows==`number`?e.rows:20;function P(e,t,n,r=n,i=n,o){return D(t,N(e??a)-E(n),{hard:!0,trim:!1}).split(`
9
+ `).map((e,t,a)=>{let s=o?o(e,t):e;return t===0?`${r}${s}`:t===a.length-1?`${i}${s}`:`${n}${s}`}).join(`
10
+ `)}function Ae(e,t){if(`~standard`in e){let n=e[`~standard`].validate(t);return n instanceof Promise?n.then(e=>e.issues?.at(0)?.message):n.issues?.at(0)?.message}return e(t)}let je=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame=``;_subscribers=/* @__PURE__ */ new Map;_cursor=0;state=`initial`;error=``;value;userInput=``;get accessible(){return Se(this.opts.accessible)}constructor(e,t=!0){let{input:n=i,output:r=a,render:o,signal:s,...c}=e;this.opts=c,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=o.bind(this),this._track=t,this._abortSignal=s,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state=`cancel`,this.close(),e(Ee);this._abortSignal.addEventListener(`abort`,()=>{this.state=`cancel`,this.close()},{once:!0})}this.rl=o.createInterface({input:this.input,tabSize:2,prompt:``,escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on(`keypress`,this.onKeypress),M(this.input,!0),this.output.on(`resize`,this.render),this.render(),this.once(`submit`,()=>{this.output.write(O.show),this.output.off(`resize`,this.render),M(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(O.show),this.output.off(`resize`,this.render),M(this.input,!1),e(Ee)})})}_isActionKey(e,t){return e===` `}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit(`value`,this.value)}_setUserInput(e,t){this.userInput=e??``,this.emit(`userInput`,this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:`u`}),this._setUserInput(``)}async onKeypress(e,t){if(this.state!==`validating`){if(this._track&&t.name!==`return`&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:`h`}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state===`error`&&(this.state=`active`),t?.name&&(!this._track&&j.aliases.has(t.name)&&this.emit(`cursor`,j.aliases.get(t.name)),j.actions.has(t.name)&&this.emit(`cursor`,t.name)),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),this.emit(`key`,e,t),t?.name===`return`&&this._shouldSubmit(e,t)){if(this.opts.validate){let e=Ae(this.opts.validate,this.value),t;e instanceof Promise?(this.state=`validating`,this.render(),t=await e):t=e,t&&(this.error=t instanceof Error?t.message:t,this.state=`error`,this.rl?.write(this.userInput))}this.state!==`error`&&(this.state=`submit`)}Ce([e,t?.name,t?.sequence],`cancel`)&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
11
+ `),M(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=D(this._prevFrame,N(this.output),{hard:!0,trim:!1}).split(`
12
+ `).length-1;this.output.write(O.move(-999,e*-1))}render(){let e=D(this._render(this)??``,N(this.output),{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(O.hide);else{let t=we(this._prevFrame,e),n=ke(this.output);if(this.restoreCursor(),t){let r=Math.max(0,t.numLinesAfter-n),i=Math.max(0,t.numLinesBefore-n),a=t.lines.find(e=>e>=r);if(a===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(O.move(0,a-i)),this.output.write(k.lines(1));let t=e.split(`
13
+ `);this.output.write(t[a]),this._prevFrame=e,this.output.write(O.move(0,t.length-a-1));return}if(t.lines.length>1){if(r<i)a=r;else{let e=a-i;e>0&&this.output.write(O.move(0,e))}this.output.write(k.down());let t=e.split(`
14
+ `).slice(a);this.output.write(t.join(`
15
+ `)),this._prevFrame=e;return}}this.output.write(k.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}};var Me=class extends je{get cursor(){return+!this.value}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`userInput`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(O.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},Ne=class extends je{options;cursor=0;get _value(){return this.options[this.cursor]?.value}get _enabledOptions(){return this.options.filter(e=>e.disabled!==!0)}toggleAll(){let e=this._enabledOptions,t=this.value!==void 0&&this.value.length===e.length;this.value=t?[]:e.map(e=>e.value)}toggleInvert(){let e=this.value;if(!e)return;let t=this._enabledOptions.filter(t=>!e.includes(t.value));this.value=t.map(e=>e.value)}toggleValue(){this.value===void 0&&(this.value=[]);let e=this.value.includes(this._value);this.value=e?this.value.filter(e=>e!==this._value):[...this.value,this._value]}constructor(e){super(e,!1),this.options=e.options,this.value=[...e.initialValues??[]];let t=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0);this.cursor=this.options[t]?.disabled?A(t,1,this.options):t,this.on(`key`,(e,t)=>{t.name===`a`&&this.toggleAll(),t.name===`i`&&this.toggleInvert(),t.name===void 0&&e===` `&&this.toggleValue()}),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=A(this.cursor,-1,this.options);break;case`down`:case`right`:this.cursor=A(this.cursor,1,this.options);break;case`space`:this.toggleValue()}})}};let Pe=class extends je{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let e=this._selectedValue;this.value=e===void 0?void 0:e.value}constructor(e){super(e,!1),this.options=e.options;let t=this.options.findIndex(({value:t})=>t===e.initialValue),n=t===-1?0:t;this.cursor=this.options[n]?.disabled?A(n,1,this.options):n,this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=A(this.cursor,-1,this.options);break;case`down`:case`right`:this.cursor=A(this.cursor,1,this.options)}this.changeValue()})}};function Fe(){return r.platform===`win32`?!!r.env.CI||!!r.env.WT_SESSION||!!r.env.TERMINUS_SUBLIME||r.env.ConEmuTask===`{cmd::Cmder}`||r.env.TERM_PROGRAM===`Terminus-Sublime`||r.env.TERM_PROGRAM===`vscode`||r.env.TERM===`xterm-256color`||r.env.TERM===`alacritty`||r.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:r.env.TERM!==`linux`}const Ie=Fe(),Le=()=>process.env.CI===`true`,Re=e=>e.isTTY===!0,F=(e,t)=>Ie?e:t,ze=F(`◆`,`*`),Be=F(`■`,`x`),Ve=F(`▲`,`x`),I=F(`◇`,`o`),He=F(`┌`,`T`),L=F(`│`,`|`),R=F(`└`,`—`),Ue=F(`┐`,`T`),We=F(`┘`,`—`),Ge=F(`●`,`>`),z=F(`○`,` `),Ke=F(`◻`,`[•]`),qe=F(`◼`,`[+]`),Je=F(`◻`,`[ ]`),Ye=F(`─`,`-`),Xe=F(`╮`,`+`),Ze=F(`├`,`+`),Qe=F(`╯`,`+`),$e=F(`╰`,`+`),et=F(`╭`,`+`),tt=F(`●`,`•`),nt=F(`◆`,`*`),rt=F(`▲`,`!`),it=F(`■`,`x`),at=e=>{switch(e){case`initial`:case`active`:return n(`cyan`,ze);case`cancel`:return n(`red`,Be);case`error`:return n(`yellow`,Ve);case`submit`:return n(`green`,I);case`validating`:return n(`dim`,ze)}},ot=e=>{switch(e){case`initial`:case`active`:return n(`cyan`,L);case`cancel`:return n(`red`,L);case`error`:return n(`yellow`,L);case`submit`:return n(`green`,L)}};function st(e,t,r){let i=r?`${n(`cyan`,L)} `:``,a=P(e,t.join(` • `),i).split(`
16
+ `);return r&&a.push(n(`cyan`,R)),a}const ct=(e,t,n,r,i,a=!1)=>{let o=t,s=0;if(a)for(let t=r-1;t>=n;t--){let n=e[t];if(n&&(o-=n.length),s++,o<=i)break}else for(let t=n;t<r;t++){let n=e[t];if(n&&(o-=n.length),s++,o<=i)break}return{lineCount:o,removals:s}},lt=({cursor:e,options:t,style:r,output:i=process.stdout,maxItems:a=1/0,columnPadding:o=0,rowPadding:s=4})=>{let c=N(i)-o,l=ke(i),u=n(`dim`,`...`),d=Math.max(l-s,0),f=Math.max(Math.min(a,d),5),p=0;e>=f-3&&(p=Math.max(Math.min(e-f+3,t.length-f),0));let m=f<t.length&&p>0,h=f<t.length&&p+f<t.length,g=Math.min(p+f,t.length),_=[],v=0;m&&v++,h&&v++;let y=p+ +!!m,b=g-+!!h;for(let n=y;n<b;n++){let i=t[n],a=D(i===void 0?``:r(i,n===e),c,{hard:!0,trim:!1}).split(`
17
+ `);_.push(a),v+=a.length}if(v>d){let t=0,n=0,r=v,i=e-y,a=d,o=()=>ct(_,r,0,i,a),s=()=>ct(_,r,i+1,_.length,a,!0);m?({lineCount:r,removals:t}=o(),r>a&&(h||--a,{lineCount:r,removals:n}=s())):(h||--a,{lineCount:r,removals:n}=s(),r>a&&(--a,{lineCount:r,removals:t}=o())),t>0&&(m=!0,_.splice(0,t)),n>0&&(h=!0,_.splice(_.length-n,n))}let x=[];m&&x.push(u);for(let e of _)for(let t of e)x.push(t);return h&&x.push(u),x},ut=[et,Xe,$e,Qe],dt=[He,Ue,R,We];function ft(e,t,n,r){let i=n,a=n;return r===`center`?i=Math.floor((t-e)/2):r===`right`&&(i=t-e-n),a=t-i-e,[i,a]}const pt=e=>e,mt=(e=``,t=``,r)=>{let i=r?.output??process.stdout,a=N(i),o=r?.titlePadding??1,s=r?.contentPadding??2,c=r?.width===void 0||r.width===`auto`?1:Math.min(1,r.width),l=r?.withGuide??j.withGuide?`${n(`gray`,L)} `:``,u=r?.formatBorder??pt,d=(r?.rounded?ut:dt).map(u),f=u(Ye),p=u(L),m=E(l),h=E(t),g=a-m,_=Math.floor(a*c)-m;if(r?.width===`auto`){let t=e.split(`
18
+ `),n=h+o*2;for(let e of t){let t=E(e)+s*2;t>n&&(n=t)}let r=n+2;r<_&&(_=r)}_%2!=0&&(_<g?_++:_--);let v=_-2,y=v-o*2,b=h>y?`${t.slice(0,y-3)}...`:t,[x,S]=ft(E(b),v,o,r?.titleAlign),C=D(e,v-s*2,{hard:!0,trim:!1});i.write(`${l}${d[0]}${f.repeat(x)}${b}${f.repeat(S)}${d[1]}
19
+ `);let ee=C.split(`
20
+ `);for(let e of ee){let[t,n]=ft(E(e),v,s,r?.contentAlign);i.write(`${l}${p}${` `.repeat(t)}${e}${` `.repeat(n)}${p}
21
+ `)}i.write(`${l}${d[2]}${f.repeat(v)}${d[3]}
22
+ `)},ht=e=>{let t=e.active??`Yes`,r=e.inactive??`No`;return new Me({active:t,inactive:r,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=e.withGuide??j.withGuide,a=`${at(this.state)} `,o=i?`${n(`gray`,L)} `:``,s=P(e.output,e.message,o,a),c=`${i?`${n(`gray`,L)}
23
+ `:``}${s}
24
+ `,l=this.value?t:r;switch(this.state){case`submit`:return`${c}${i?`${n(`gray`,L)} `:``}${n(`dim`,l)}`;case`cancel`:return`${c}${i?`${n(`gray`,L)} `:``}${n([`strikethrough`,`dim`],l)}${i?`
25
+ ${n(`gray`,L)}`:``}`;default:{let a=i?`${n(`cyan`,L)} `:``,o=i?n(`cyan`,R):``;return`${c}${a}${this.value?`${n(`green`,Ge)} ${t}`:`${n(`dim`,z)} ${n(`dim`,t)}`}${e.vertical?i?`
26
+ ${n(`cyan`,L)} `:`
27
+ `:` ${n(`dim`,`/`)} `}${this.value?`${n(`dim`,z)} ${n(`dim`,r)}`:`${n(`green`,Ge)} ${r}`}
28
+ ${o}
29
+ `}}}}).prompt()},gt=[`${n(`dim`,`↑/↓`)} to navigate`,`${n(`dim`,`Space:`)} select`,`${n(`dim`,`Enter:`)} confirm`],B=(e,t)=>e.split(`
30
+ `).map(e=>t(e)).join(`
31
+ `),_t=e=>{let t=(e,t)=>{let r=e.label??String(e.value);return t===`disabled`?`${n(`gray`,Je)} ${B(r,e=>n([`strikethrough`,`gray`],e))}${e.hint?` ${n(`dim`,`(${e.hint??`disabled`})`)}`:``}`:t===`active`?`${n(`cyan`,Ke)} ${r}${e.hint?` ${n(`dim`,`(${e.hint})`)}`:``}`:t===`selected`?`${n(`green`,qe)} ${B(r,e=>n(`dim`,e))}${e.hint?` ${n(`dim`,`(${e.hint})`)}`:``}`:t===`cancelled`?`${B(r,e=>n([`strikethrough`,`dim`],e))}`:t===`active-selected`?`${n(`green`,qe)} ${r}${e.hint?` ${n(`dim`,`(${e.hint})`)}`:``}`:t===`submitted`?`${B(r,e=>n(`dim`,e))}`:`${n(`dim`,Je)} ${B(r,e=>n(`dim`,e))}`},r=e.required??!0,i=e.showInstructions??!0;return new Ne({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:r,cursorAt:e.cursorAt,validate(e){if(r&&(e===void 0||e.length===0))return`Please select at least one option.
32
+ ${n(`reset`,n(`dim`,`Press ${n([`gray`,`bgWhite`,`inverse`],` space `)} to select, ${n(`gray`,n(`bgWhite`,n(`inverse`,` enter `)))} to submit`))}`},render(){let r=e.withGuide??j.withGuide,a=P(e.output,e.message,r?`${ot(this.state)} `:``,`${at(this.state)} `),o=`${r?`${n(`gray`,L)}
33
+ `:``}${a}
34
+ `,s=this.value??[],c=(e,n)=>{if(e.disabled)return t(e,`disabled`);let r=s.includes(e.value);return n&&r?t(e,`active-selected`):r?t(e,`selected`):t(e,n?`active`:`inactive`)};switch(this.state){case`submit`:{let i=this.options.filter(({value:e})=>s.includes(e)).map(e=>t(e,`submitted`)).join(n(`dim`,`, `))||n(`dim`,`none`);return`${o}${P(e.output,i,r?`${n(`gray`,L)} `:``)}`}case`cancel`:{let i=this.options.filter(({value:e})=>s.includes(e)).map(e=>t(e,`cancelled`)).join(n(`dim`,`, `));return i.trim()===``?`${o}${n(`gray`,L)}`:`${o}${P(e.output,i,r?`${n(`gray`,L)} `:``)}${r?`
35
+ ${n(`gray`,L)}`:``}`}case`error`:{let t=r?`${n(`yellow`,L)} `:``,i=this.error.split(`
36
+ `).map((e,t)=>t===0?`${r?`${n(`yellow`,R)} `:``}${n(`yellow`,e)}`:` ${e}`).join(`
37
+ `),a=o.split(`
38
+ `).length,s=i.split(`
39
+ `).length+1;return`${o}${t}${lt({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:t.length,rowPadding:a+s,style:c}).join(`
40
+ ${t}`)}
41
+ ${i}
42
+ `}default:{let t=r?`${n(`cyan`,L)} `:``,a=o.split(`
43
+ `).length,s=i?st(e.output,gt,r):r?[n(`cyan`,R)]:[],l=s.join(`
44
+ `),u=s.length+1;return`${o}${t}${lt({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:t.length,rowPadding:a+u,style:c}).join(`
45
+ ${t}`)}
46
+ ${l}
47
+ `}}}}).prompt()},V={message:(e=[],{symbol:t=n(`gray`,L),secondarySymbol:r=n(`gray`,L),output:i=process.stdout,spacing:a=1,withGuide:o}={})=>{let s=[],c=o??j.withGuide,l=c?r:``,u=c?`${t} `:``,d=c?`${r} `:``;for(let e=0;e<a;e++)s.push(l);let f=Array.isArray(e)?e:e.split(`
48
+ `);if(f.length>0){let[e,...n]=f;e.length>0?s.push(`${u}${e}`):s.push(c?t:``);for(let e of n)e.length>0?s.push(`${d}${e}`):s.push(c?r:``)}i.write(`${s.join(`
49
+ `)}
50
+ `)},info:(e,t)=>{V.message(e,{...t,symbol:n(`blue`,tt)})},success:(e,t)=>{V.message(e,{...t,symbol:n(`green`,nt)})},step:(e,t)=>{V.message(e,{...t,symbol:n(`green`,I)})},warn:(e,t)=>{V.message(e,{...t,symbol:n(`yellow`,rt)})},warning:(e,t)=>{V.warn(e,t)},error:(e,t)=>{V.message(e,{...t,symbol:n(`red`,it)})}},vt=(e=``,t)=>{let r=t?.output??process.stdout,i=t?.withGuide??j.withGuide?`${n(`gray`,R)} `:``;r.write(`${i}${n(`red`,e)}
51
+
52
+ `)},yt=(e=``,t)=>{let r=t?.output??process.stdout,i=t?.withGuide??j.withGuide?`${n(`gray`,He)} `:``;r.write(`${i}${e}
53
+ `)},bt=(e=``,t)=>{let r=t?.output??process.stdout,i=t?.withGuide??j.withGuide?`${n(`gray`,L)}
54
+ ${n(`gray`,R)} `:``;r.write(`${i}${e}
55
+
56
+ `)},xt=e=>e,St=(e,t,n)=>{let r={hard:!0,trim:!1},i=D(e,t,r).split(`
57
+ `),a=i.reduce((e,t)=>Math.max(E(t),e),0);return D(e,t-(i.map(n).reduce((e,t)=>Math.max(E(t),e),0)-a),r)},Ct=(e=``,t=``,i)=>{let a=i?.output??r.stdout,o=i?.withGuide??j.withGuide,s=i?.format??xt,c=[``,...St(e,N(a)-6,s).split(`
58
+ `).map(s),``],l=E(t),u=Math.max(c.reduce((e,t)=>{let n=E(t);return n>e?n:e},0),l)+2,d=c.map(e=>`${n(`gray`,L)} ${e}${` `.repeat(u-E(e))}${n(`gray`,L)}`).join(`
59
+ `),f=o?`${n(`gray`,L)}
60
+ `:``,p=o?Ze:$e;a.write(`${f}${n(`green`,I)} ${n(`reset`,t)} ${n(`gray`,Ye.repeat(Math.max(u-l-1,1))+Xe)}
61
+ ${d}
62
+ ${n(`gray`,p+Ye.repeat(u+2)+Qe)}
63
+ `)},wt=e=>n(`magenta`,e),Tt=({indicator:e=`dots`,onCancel:t,output:r=process.stdout,cancelMessage:i,errorMessage:a,frames:o=Ie?[`◒`,`◐`,`◓`,`◑`]:[`•`,`o`,`O`,`0`],delay:s=Ie?80:120,signal:c,...l}={})=>{let u=Le(),d=Se(l.accessible),f,p,m=!1,h=!1,g=``,_,v=performance.now(),y=N(r),b=l?.styleFrame??wt,x=e=>{let n=e>1?a??j.messages.error:i??j.messages.cancel;h=e===1,m&&(T(n,e),h&&typeof t==`function`&&t())},S=()=>x(2),C=()=>x(1),ee=()=>{process.on(`uncaughtExceptionMonitor`,S),process.on(`unhandledRejection`,S),process.on(`SIGINT`,C),process.on(`SIGTERM`,C),process.on(`exit`,x),c&&c.addEventListener(`abort`,C)},te=()=>{process.removeListener(`uncaughtExceptionMonitor`,S),process.removeListener(`unhandledRejection`,S),process.removeListener(`SIGINT`,C),process.removeListener(`SIGTERM`,C),process.removeListener(`exit`,x),c&&c.removeEventListener(`abort`,C)},ne=()=>{if(_===void 0)return;u&&r.write(`
64
+ `);let e=D(_,y,{hard:!0,trim:!1}).split(`
65
+ `);e.length>1&&r.write(O.up(e.length-1)),r.write(O.to(0)),r.write(k.down())},re=e=>e.replace(/\.+$/,``),w=e=>{let t=(performance.now()-e)/1e3,n=Math.floor(t/60),r=Math.floor(t%60);return n>0?`[${n}m ${r}s]`:`[${r}s]`},ie=l.withGuide??j.withGuide,ae=(t=``)=>{if(m=!0,h=!1,g=re(t),v=performance.now(),ee(),d){g!==``&&r.write(`${g}
66
+ `),p=setInterval(()=>{r.write(g===``?`still working
67
+ `:`still working: ${g}
68
+ `)},3e4);return}f=Oe({output:r}),ie&&r.write(`${n(`gray`,L)}
69
+ `);let i=0,a=0;p=setInterval(()=>{if(u&&g===_)return;ne(),_=g;let t=b(o[i]),n;if(u)n=`${t} ${g}...`;else if(e===`timer`)n=`${t} ${g} ${w(v)}`;else{let e=`.`.repeat(Math.floor(a)).slice(0,3);n=`${t} ${g}${e}`}let s=D(n,y,{hard:!0,trim:!1});r.write(s),i=i+1<o.length?i+1:0,a=a<4?a+.125:0},s)},T=(t=``,o=0,s=!1)=>{if(m){if(m=!1,h=o===1,clearInterval(p),d||ne(),g=t??g,!s){if(d){let t=o===1?i??j.messages.cancel:o===2?a??j.messages.error:`Done`,n=g||t;e===`timer`?r.write(`${n} ${w(v)}
70
+ `):r.write(`${n}
71
+ `)}else{let t=o===0?n(`green`,I):o===1?n(`red`,Be):n(`red`,Ve);e===`timer`?r.write(`${t} ${g} ${w(v)}
72
+ `):r.write(`${t} ${g}
73
+ `)}}te(),f?.()}};return{start:ae,stop:(e=``)=>T(e,0),message:(e=``)=>{g=re(e??g)},cancel:(e=``)=>T(e,1),error:(e=``)=>T(e,2),clear:()=>T(``,0,!0),get isCancelled(){return h}}},Et=[`${n(`dim`,`↑/↓`)} to navigate`,`${n(`dim`,`Enter:`)} confirm`],H=(e,t)=>e.includes(`
74
+ `)?e.split(`
75
+ `).map(e=>t(e)).join(`
76
+ `):t(e),Dt=e=>{let t=(e,t)=>{if(e===void 0)return``;let r=e.label??String(e.value);switch(t){case`disabled`:return`${n(`gray`,z)} ${H(r,e=>n(`gray`,e))}${e.hint?` ${n(`dim`,`(${e.hint??`disabled`})`)}`:``}`;case`selected`:return`${H(r,e=>n(`dim`,e))}`;case`active`:return`${n(`green`,Ge)} ${r}${e.hint?` ${n(`dim`,`(${e.hint})`)}`:``}`;case`cancelled`:return`${H(r,e=>n([`strikethrough`,`dim`],e))}`;default:return`${n(`dim`,z)} ${H(r,e=>n(`dim`,e))}`}},r=e.showInstructions??!0;return new Pe({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let i=e.withGuide??j.withGuide,a=`${at(this.state)} `,o=`${ot(this.state)} `,s=P(e.output,e.message,o,a),c=`${i?`${n(`gray`,L)}
77
+ `:``}${s}
78
+ `;switch(this.state){case`submit`:{let r=i?`${n(`gray`,L)} `:``;return`${c}${P(e.output,t(this.options[this.cursor],`selected`),r)}`}case`cancel`:{let r=i?`${n(`gray`,L)} `:``;return`${c}${P(e.output,t(this.options[this.cursor],`cancelled`),r)}${i?`
79
+ ${n(`gray`,L)}`:``}`}default:{let a=i?`${n(`cyan`,L)} `:``,o=c.split(`
80
+ `).length,s=r?st(e.output,Et,i):i?[n(`cyan`,R)]:[],l=s.join(`
81
+ `),u=s.length+1;return`${c}${a}${lt({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:a.length,rowPadding:o+u,style:(e,n)=>t(e,e.disabled?`disabled`:n?`active`:`inactive`)}).join(`
82
+ ${a}`)}
83
+ ${l}
84
+ `}}}}).prompt()};`${n(`gray`,L)}`;const Ot=e=>e.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g,``),kt=e=>{let t=e.output??process.stdout,r=N(t),i=n(`gray`,L),a=e.spacing??1,o=e.retainLog===!0,s=!Le()&&Re(t);t.write(`${i}
85
+ `),t.write(`${n(`green`,I)} ${e.title}
86
+ `);for(let e=0;e<a;e++)t.write(`${i}
87
+ `);let c=[{value:``,full:``}],l=!1,u=e=>{if(c.length===0)return;let n=0;e&&(n+=a+2);for(let e of c){let{value:t,result:i}=e,a=i?.message??t;if(a.length===0)continue;i===void 0&&e.header!==void 0&&e.header!==``&&(a+=`
88
+ ${e.header}`);let o=a.split(`
89
+ `).reduce((e,t)=>t===``?e+1:e+Math.ceil((t.length+3)/r),0);n+=o}n>0&&(n+=1,t.write(k.lines(n)))},d=(e,r,o)=>{let s=o?`${e.full}
90
+ ${e.value}`:e.value;e.header!==void 0&&e.header!==``&&V.message(e.header.split(`
91
+ `).map(e=>n(`bold`,e)),{output:t,secondarySymbol:i,symbol:i,spacing:0}),V.message(s.split(`
92
+ `).map(e=>n(`dim`,e)),{output:t,secondarySymbol:i,symbol:i,spacing:r??a})},f=()=>{for(let e of c){let{header:t,value:n,full:r}=e;(t===void 0||t.length===0)&&n.length===0||d(e,void 0,o===!0&&r.length>0)}},p=(t,n,r)=>{if(u(!1),r?.raw===!0&&l||t.value===``||(t.value+=`
93
+ `),t.value+=Ot(n),l=r?.raw===!0,e.limit!==void 0){let n=t.value.split(`
94
+ `),r=n.length-e.limit;if(r>0){let e=n.splice(0,r);o&&(t.full+=(t.full===``?``:`
95
+ `)+e.join(`
96
+ `))}t.value=n.join(`
97
+ `)}s&&m()},m=()=>{for(let e of c)e.result?e.result.status===`error`?V.error(e.result.message,{output:t,secondarySymbol:i,spacing:0}):V.success(e.result.message,{output:t,secondarySymbol:i,spacing:0}):e.value!==``&&d(e,0)},h=(e,t)=>{u(!1),e.result=t,s&&m()};return{message(e,t){p(c[0],e,t)},group(e){let t={header:e,value:``,full:``};return c.push(t),{message(e,n){p(t,e,n)},error(e){h(t,{status:`error`,message:e})},success(e){h(t,{status:`success`,message:e})}}},error(e,n){u(!0),V.error(e,{output:t,secondarySymbol:i,spacing:1}),n?.showLog!==!1&&f(),c.splice(1,c.length-1),c[0].value=``,c[0].full=``},success(e,n){u(!0),V.success(e,{output:t,secondarySymbol:i,spacing:1}),n?.showLog===!0&&f(),c.splice(1,c.length-1),c[0].value=``,c[0].full=``}}},At={next:[`next`],"tanstack-start":[`@tanstack/react-start`],astro:[`astro`],"react-vite":[`vite`,`react`]},jt=[`express`,`fastify`,`hono`,`koa`,`@nestjs/core`],Mt={next:[`@next/eslint-plugin-next`,`eslint-plugin-jsx-a11y`,`eslint-plugin-react`,`eslint-plugin-react-hooks`,`globals`],"tanstack-start":[`eslint-plugin-jsx-a11y`,`eslint-plugin-react`,`eslint-plugin-react-hooks`,`globals`],astro:[`@astrojs/compiler-rs`,`eslint-plugin-astro`,`eslint-plugin-jsx-a11y`,`globals`,`prettier-plugin-astro`],"react-vite":[`eslint-plugin-jsx-a11y`,`eslint-plugin-react`,`eslint-plugin-react-hooks`,`eslint-plugin-react-refresh`,`globals`]},U={base:[`**/build`,`**/dist`],next:[`**/.next/**`,`**/out/**`,`**/next-env.d.ts`],"tanstack-start":[`**/.output/**`,`**/.tanstack/**`,`**/routeTree.gen.ts`],astro:[`**/.astro/**`],"react-vite":[]},Nt={"tanstack-start":[`routeTree.gen.ts`]},Pt={tailwind:[`tailwindcss`],react:[`@astrojs/react`]},Ft={react:`astro`},It={tailwind:[`@shadcn/lint`,`prettier-plugin-tailwindcss`],react:[`eslint-plugin-react`,`eslint-plugin-react-hooks`]},Lt={tailwind:`tailwind`,react:`astro-react`},Rt={bun:`bun`,npm:`npm`,pnpm:`pnpm`,yarn:`yarn`},zt={"pnpm-lock.yaml":`pnpm`,"bun.lock":`bun`,"yarn.lock":`yarn`,"package-lock.json":`npm`},Bt={bun:{path:`bunfig.toml`,section:`[install]`,line:`minimumReleaseAge = 86400`,setting:/^[ \t]*minimumReleaseAge[ \t]*=[ \t]*([^\s#]*)/m,since:`1.3.0`},npm:{path:`.npmrc`,line:`min-release-age=1`,setting:/^[ \t]*(?:min-release-age[ \t]*=[ \t]*([^\s#;]*)|before[ \t]*=)/m,since:`11.10.0`},pnpm:{path:`pnpm-workspace.yaml`,line:`minimumReleaseAge: 1440`,setting:/^(?:minimumReleaseAge:|[ \t]*minimum-release-age[ \t]*=)[ \t]*([^\s#;]*)/m,since:`10.16.0`},yarn:{path:`.yarnrc.yml`,line:`npmMinimalAgeGate: 1440`,setting:/^npmMinimalAgeGate:[ \t]*([^\s#]*)/m,since:`4.10.0`}},W={eslint:`@santux/eslint-config`,oxc:`@santux/oxc-config`},G={eslint:[`eslint.config.js`,`prettier.config.js`],oxc:[`oxlint.config.ts`,`oxfmt.config.ts`]};function Vt(e,t){let n=Ft[e];return n===void 0||n===t}function Ht(e){let t=Object.entries(zt).find(([t])=>e.lockfiles.includes(t))?.[1]??Object.values(Rt).find(t=>e.userAgent?.startsWith(`${t}/`))??null,n=Object.keys(At).filter(t=>At[t].every(t=>e.dependencies.includes(t))),r=jt.some(t=>e.productionDependencies.includes(t))?[`node`]:[],i=[...n,...r];return{addons:Object.keys(Pt).filter(t=>Pt[t].every(t=>e.dependencies.includes(t))&&Vt(t,n[0]??null)),frameworks:i,packageManager:t,toolchain:Object.keys(G).find(t=>G[t].some(t=>e.existingFiles.includes(t)))??null}}const K=[`js`,`cjs`,`mjs`,`ts`,`cts`,`mts`],Ut=[...K.map(e=>`eslint.config.${e}`),`.eslintrc`,...[`js`,`cjs`,`mjs`,`json`,`yaml`,`yml`].map(e=>`.eslintrc.${e}`),`.eslintignore`,`.prettierrc`,...[`json`,`json5`,`yaml`,`yml`,`toml`,...K].map(e=>`.prettierrc.${e}`),...K.map(e=>`prettier.config.${e}`),`biome.json`,`biome.jsonc`,`.oxlintrc.json`,...[`ts`,`mts`].map(e=>`oxlint.config.${e}`),`.oxfmtrc.json`,`.oxfmtrc.jsonc`,...[`ts`,`mts`].map(e=>`oxfmt.config.${e}`),`.commitlintrc`,...[`json`,`yaml`,`yml`,...K].map(e=>`.commitlintrc.${e}`),...K.map(e=>`commitlint.config.${e}`)],Wt=/^(?:eslint|prettier|oxlint|oxlint-tsgolint|oxfmt|typescript-eslint|@biomejs\/biome)$|^(?:eslint-|prettier-|@eslint\/|@prettier\/|@typescript-eslint\/)|^@[^/]+\/eslint-(?:plugin|config)/,Gt=`@typescript/typescript6`,Kt=`typescript-7`,qt=[`./src/*`],Jt=e=>e.replaceAll(/\[\s*("(?:[^"\\\n]|\\.)*"(?:\s*,\s*"(?:[^"\\\n]|\\.)*")*)\s*\]/g,(e,t)=>`[${(t.match(/"(?:[^"\\\n]|\\.)*"/g)??[]).join(`, `)}]`);function Yt(e){let t=/^[\t ]+(?=\S)/m.exec(e)?.[0]??` `,n=t.startsWith(` `),r=f(e,[`compilerOptions`,`paths`,`@/*`],qt,{formattingOptions:{insertSpaces:!n,tabSize:n?1:t.length}});return d(e,r.map(e=>({...e,content:Jt(e.content)})))}const Xt=e=>g(e),Zt=e=>Xt(h(e)).resolve?.tsconfigPaths===!0;function Qt(e){try{let t=h(e),n=Xt(t);n.resolve??={},n.resolve.tsconfigPaths=!0;let r=m(t).code.trimEnd();return Zt(r)?`${r}\n`:null}catch{return null}}function $t(e,t){let n={manualSteps:[],operations:[],warnings:[]},r=`tsconfig.app.json`in e.tsconfigs?`tsconfig.app.json`:`tsconfig.json`,i=e.tsconfigs[r];if(!e.hasSrcDirectory)return n.warnings.push(`No src/ folder found, the @/* path alias was skipped`),n;if(i===void 0)return n.warnings.push(`${r} not found, the @/* path alias was skipped`),n;if(p(i)?.compilerOptions?.paths?.[`@/*`]!==void 0)return n.warnings.push(`${r} already defines @/* and was left untouched`),n;n.operations.push({type:`update-file`,path:r,content:Yt(i)});let{viteConfig:a}=e;if(a||t===`react-vite`){let e=a?Qt(a.content):null;a&&e!==null?n.operations.push({type:`update-file`,path:a.path,content:e}):n.manualSteps.push("Add `resolve: { tsconfigPaths: true }` to your Vite config so the @/* alias works in the dev server")}return n}const en={eslint:{lint:`eslint .`,"lint:fix":`eslint . --fix`,format:`prettier . --check`,"format:fix":`prettier . --write`,prepare:`husky`},oxc:{lint:`oxlint`,"lint:fix":`oxlint --fix`,format:`oxfmt --check`,"format:fix":`oxfmt`,prepare:`husky`}};function q(e,t){return`export { default } from '${W[e]}/${t}'\n`}const J=e=>e.replaceAll(/-(\w)/g,(e,t)=>t.toUpperCase());function tn({nodeLts:e,nodeVersion:t}){return`${e??String(Number.parseInt(t.replace(/^v/,``),10))}\n`}const nn=`.husky/commit-msg`,rn=`commitlint.config.js`,an=(e,t)=>[...e?[e]:[],...t.map(e=>Lt[e])],on={eslint:{astro:`format-astro`,tailwind:`format-tailwind`},oxc:{next:`format-next`,astro:`format-astro`,tailwind:`format-tailwind`}},sn=(e,t,n)=>[...t?[t]:[],...n].flatMap(t=>on[e][t]??[]),Y=(e,t,n)=>[[`santux`,t],...n.map(e=>[J(e),e])].sort(([,e],[,t])=>e<t?-1:1).map(([t,n])=>`import ${t} from '${W[e]}/${n}'\n`).join(``);function cn(e,t){let n=an(e,t);return`${Y(`eslint`,`lint`,n)}import { defineConfig } from 'eslint/config'
98
+
99
+ export default defineConfig([${[`santux`,...n.map(J)].join(`, `)}])
100
+ `}function ln(e,t){let n=an(e,t),r=[...U.base,...e?U[e]:[]];return`${Y(`oxc`,`lint`,n)}import { defineConfig } from 'oxlint'
101
+
102
+ export default defineConfig({
103
+ extends: [${[`santux`,...n.map(J)].join(`, `)}],
104
+ ignorePatterns: [${r.map(e=>`'${e}'`).join(`, `)}],
105
+ })
106
+ `}function un(e,t){let n=sn(`eslint`,e,t);if(n.length===0)return q(`eslint`,`format`);let r=[`santux`,...n.map(J)].map(e=>`...${e}`);if(n.length===1)return`${Y(`eslint`,`format`,n)}
107
+ export default { ${r.join(`, `)} }
108
+ `;let i=n.map(e=>`...${J(e)}.plugins`).join(`, `);return`${Y(`eslint`,`format`,n)}
109
+ export default {
110
+ ${[...r,`plugins: [${i}]`].map(e=>` ${e},\n`).join(``)}}
111
+ `}function dn(e,t){let n=sn(`oxc`,e,t);return n.length===0?q(`oxc`,`format`):`${Y(`oxc`,`format`,n)}import { defineConfig } from 'oxfmt'
112
+
113
+ export default defineConfig({ ...${[`santux`,...n.map(J)].join(`, ...`)} })
114
+ `}function fn(e,t){let n=[`build`,`dist`,...Object.keys(zt).sort(),...(t&&Nt[t])??[]];return{[rn]:q(e,`commitlint`),[nn]:`npx --no -- commitlint --edit $1
115
+ `,".editorconfig":`root = true
116
+
117
+ [*]
118
+ insert_final_newline = true
119
+ charset = utf-8
120
+ indent_style = space
121
+ indent_size = 2
122
+ trim_trailing_whitespace = true
123
+ max_line_length = 100
124
+ `,".prettierignore":`${n.join(`
125
+ `)}\n`}}function pn({addons:e,framework:t,toolchain:n}){return n===`eslint`?{"eslint.config.js":cn(t,e),"prettier.config.js":un(t,e)}:{"oxlint.config.ts":ln(t,e),"oxfmt.config.ts":dn(t,e)}}function mn(e,t){let{addons:n,framework:r,toolchain:i}=e,[a,o]=G[i],s=W[i],c=(e,n)=>e in t&&!t[e]?.includes(`${s}/${n}`),l=e=>`\`import ${J(e)} from '${s}/${e}'\``,u=[],d=i===`eslint`?"the `defineConfig([...])` array":"`extends`";for(let e of an(r,n).filter(e=>c(a,e))){let t=i===`oxc`&&e===r?`, plus these \`ignorePatterns\`: ${[...U.base,...U[r]].map(e=>`\`${e}\``).join(`, `)} if they are missing`:``;u.push(`Add ${l(e)} to ${a} and \`${J(e)}\` to ${d}${t}`)}let f=sn(i,r,n),p=f.filter(e=>c(o,e));if(p.length===0)return u;if(t[o]?.trim()===q(i,`format`).trim())return u.push(`Replace ${o} with:\n${pn(e)[o]??``}`),u;let m=i===`eslint`&&f.length>1?`, then set its \`plugins\` to \`[${f.map(e=>`...${J(e)}.plugins`).join(`, `)}]\``:``;for(let e of p)u.push(`Add ${l(e)} to ${o} and spread \`...${J(e)}\` into its exported config${m}`);return u}const hn=`No package.json found in the current directory`;function gn(e,t){let n=/^>=\s*v?(\d+)(?:\.(\d+))?(?:\.(\d+))?$/.exec(t);if(!n)return!1;let r=n.slice(1).map(e=>Number(e||0)),i=e.replace(/^v/,``).split(`.`).map(e=>Number.parseInt(e,10));for(let[e,t]of r.entries()){let n=i[e]??0;if(n!==t)return n<t}return!1}function _n(e,t,n){let{line:r,path:i,section:a,setting:o,since:s}=Bt[e];if(Object.values(t).some(e=>o.test(e)))return{};if(!n||gn(n,`>=${s}`))return{warning:`The minimum release age was not set, since it needs ${e} ${s} or later and found ${n??`an unknown version`}`};let c=t[i]?.trimEnd(),l=c?c.split(`
126
+ `):[],u=a?l.findIndex(e=>e.trim()===a):-1;return u===-1?l.push(...a?[a]:[],r):l.splice(u+1,0,r),{operation:{type:`set-minimum-release-age`,path:i,content:`${l.join(`
127
+ `)}\n`}}}const vn=`.node-version`,yn=[...Object.keys(fn(`eslint`,null)),...Object.values(G).flat(),vn];function bn(e,t,n,r){let i=[],a=[],o=[];e.hasPackageJson||o.push(hn);let s=n.engines?.node;s&&gn(r.nodeVersion,s)&&o.push(`${n.name} requires Node ${s}, but you are running ${r.nodeVersion}`);let c=e.huskyFiles.filter(e=>e!==nn);c.length>0&&o.push(`Found unrecognized files in .husky/: ${c.join(`, `)}. Remove or migrate them and run santux again`);let{toolchain:l}=t,u={...pn(t),...fn(l,t.framework),[vn]:tn(r)},d=[...t.framework?Mt[t.framework]:[],...t.addons.flatMap(e=>It[e])],f=Object.entries(n.peerDependencies??{}).filter(([e])=>n.peerDependenciesMeta?.[e]?.optional!==!0||d.includes(e)),p=[[n.name,n.version],...f],m=Object.entries(G).flatMap(([e,t])=>e===l?[]:t),h=[...e.conflictFiles,...e.existingFiles.filter(e=>m.includes(e))].map(e=>({type:`delete-file`,path:e}));e.hasPrettierKey&&h.push({type:`remove-package-json-key`,key:`prettier`}),e.isModule||(h.push({type:`set-module-type`}),e.rootJsFiles.length>0&&i.push(`Setting "type": "module" makes Node load ${e.rootJsFiles.join(`, `)} as ES modules. Rename any that use require or module.exports to .cjs`));let g=e.existingFiles.some(e=>m.includes(e)),_=!g&&G[l].some(t=>e.existingFiles.includes(t)),v=Object.fromEntries(p.filter(([t,n])=>!_||e.dependencyVersions[t]!==n)),y=_?[]:e.dependencies.filter(e=>(Wt.test(e)||Object.values(W).includes(e))&&!(e in v));y.length>0&&h.push({type:`remove-dependencies`,dependencies:y});for(let[t,n]of Object.entries(u))e.existingFiles.includes(t)?g&&t===rn?h.push({type:`update-file`,path:t,content:n}):_||i.push(`${t} already exists and was left untouched`):h.push({type:`create-file`,path:t,content:n});if(_&&a.push(...mn(t,e.toolchainConfigs)),t.alias){let n=$t(e,t.framework);h.push(...n.operations),i.push(...n.warnings),a.push(...n.manualSteps)}if(!_){let t=en[l],n=Object.keys(t).filter(n=>n in e.scripts&&e.scripts[n]!==t[n]);n.length>0&&i.push(`package.json scripts replaced: ${n.map(t=>`${t} (was \`${e.scripts[t]??``}\`)`).join(`, `)}`),h.push({type:`set-scripts`,scripts:t})}let b=l===`eslint`?e.typescriptVersion:null,x=Number(/\d+/.exec(b??``)?.[0]);if(b&&Number.isNaN(x))i.push(`Could not tell the TypeScript version from "${b}". Install your dependencies and run santux again so TypeScript 7 gets TypeScript 6 side by side`);else if(b&&x>=7){let e=n.peerDependencies?.[Gt];if(e){let n={typescript:`npm:${Gt}@${e}`,[Kt]:`npm:typescript@${b}`};t.packageManager===`npm`?a.push(`TypeScript ${b} needs TypeScript 6 side by side for type-aware lint rules. Replace your TypeScript dependency in package.json with ${Object.entries(n).map(([e,t])=>`"${e}": "${t}"`).join(`, `)}. npm then links \`tsc\` to TypeScript 6, so run TypeScript 7 as \`node_modules/${Kt}/bin/tsc\``):Object.assign(v,n)}else i.push(`${n.name} declares no ${Gt} peer, so TypeScript ${b} was left as is and type-aware lint rules may fail`)}Object.keys(v).length>0&&h.push({type:`add-dev-dependencies`,dependencies:v});let S=_n(t.packageManager,e.packageManagerConfigs,r.packageManagerVersion);return S.operation&&h.push(S.operation),S.warning&&i.push(S.warning),e.hasGit||a.push(`Run \`git init\` and then \`${t.packageManager} run prepare\` to enable git hooks`),{errors:o,manualSteps:a,operations:o.length>0?[]:h,warnings:i}}const xn={bun:[`add`,`--dev`,`--exact`],npm:[`install`,`--save-dev`,`--save-exact`],pnpm:[`add`,`--save-dev`,`--save-exact`],yarn:[`add`,`--dev`,`--exact`]};async function X(e,t){let n=u(e,`package.json`),r=await y(n,`utf8`),i=JSON.parse(r),a=/^[\t ]+(?=")/m.exec(r)?.[0]??2;t(i),await S(n,`${JSON.stringify(i,null,a)}\n`,`utf8`)}const Sn=(e,t)=>X(e,e=>{e.scripts={...e.scripts,...t}}),Cn=e=>e===`pnpm`?[`--config.strict-dep-builds=false`]:[];async function wn(e,t,n){switch(e.type){case`create-file`:case`update-file`:await v(l(u(t,e.path)),{recursive:!0}),await S(u(t,e.path),e.content,`utf8`);return;case`set-scripts`:return Sn(t,e.scripts);case`delete-file`:return x(u(t,e.path),{force:!0,recursive:!0});case`remove-package-json-key`:return X(t,t=>{Reflect.deleteProperty(t,e.key)});case`set-module-type`:return X(t,e=>{e.type=`module`});case`remove-dependencies`:await C(n,[`remove`,...Cn(n),...e.dependencies],{cwd:t})}}async function Tn(e,t,n){for(let r of e.operations)r.type!==`add-dev-dependencies`&&r.type!==`set-minimum-release-age`&&await wn(r,t,n)}async function En(e,t,n,r){let i=C(e,t,{all:!0,buffer:!1,cwd:n});for await(let e of i.iterable({from:`all`}))r(e);await i}async function Dn(e,t,n,r){let i=e.operations.find(e=>e.type===`add-dev-dependencies`);if(i){let e=Object.entries(i.dependencies).map(([e,t])=>`${e}@${t}`);await En(n,[...xn[n],...Cn(n),...e],t,r)}await En(n,[`run`,`prepare`],t,r);let a=e.operations.find(e=>e.type===`set-minimum-release-age`);a&&await S(u(t,a.path),a.content,`utf8`)}const On={bun:[`bun`,`info`],npm:[`npm`,`view`],pnpm:[`pnpm`,`view`],yarn:[`npm`,`view`]};async function kn(e,t,n){let[r,...i]=On[t],a=W[e];if(process.env.SANTUX_LOCAL){let t=ee(new URL(`../../${e}-config`,import.meta.url));return{...JSON.parse(await y(`${t}/package.json`,`utf8`)),version:`file:${t}`}}try{let{stdout:e}=await C(r??t,[...i,a,`--json`],{cwd:n});return JSON.parse(e)}catch(e){throw Error(`Could not read ${a} from the registry`,{cause:e})}}async function An(e,t){let{stdout:n}=await C(e,[`--version`],{cwd:t,reject:!1});return/^\d+\.\d+\.\d+/.exec(n.trim())?.[0]??null}async function jn(){try{return(await(await fetch(`https://nodejs.org/dist/index.json`,{signal:AbortSignal.timeout(5e3)})).json()).find(({date:e,lts:t,security:n})=>t&&n&&Date.parse(e)+1728e5<=Date.now())?.version.replace(/^v/,``)??null}catch{return null}}const Mn=e=>_(e).then(()=>!0,()=>!1),Nn=[`tsconfig.json`,`tsconfig.app.json`],Pn=[`ts`,`mts`,`js`,`mjs`,`cts`,`cjs`].map(e=>`vite.config.${e}`);async function Fn(e,t){return(await Promise.all(t.map(async t=>{let n=await y(u(e,t),`utf8`).catch(()=>null);return n===null?null:{content:n,path:t}}))).filter(e=>e!==null)}async function In(e){return(await b(u(e,`.husky`),{withFileTypes:!0}).catch(()=>[])).filter(e=>e.isFile()).map(e=>`.husky/${e.name}`)}async function Ln(e){let t=async t=>(await Promise.all(t.map(async t=>await Mn(u(e,t))?t:null))).filter(e=>e!==null),[n,r,i,a,o,s,c,l,d]=await Promise.all([t(yn),t(Ut.filter(e=>!yn.includes(e))),t(Object.keys(zt)),Mn(u(e,`package.json`)),In(e),Mn(u(e,`src`)),Fn(e,Nn),Fn(e,Pn),Fn(e,Object.values(Bt).map(({path:e})=>e))]),f=a?JSON.parse(await y(u(e,`package.json`),`utf8`)):null,p=Object.fromEntries(await Promise.all(Object.values(G).flat().filter(e=>n.includes(e)).map(async t=>[t,await y(u(e,t),`utf8`)]))),m=e=>Object.values(W).some(t=>e.includes(t)),h=Object.keys(p).filter(e=>!m(p[e]??``)),g=await y(u(e,`node_modules/typescript/package.json`),`utf8`).then(e=>JSON.parse(e).version,()=>void 0),_=(await b(e,{withFileTypes:!0})).map(e=>e.isFile()?e.name:``).filter(e=>e.endsWith(`.js`)&&!yn.includes(e)&&!Ut.includes(e)),{exitCode:v}=await C(`git`,[`rev-parse`,`--is-inside-work-tree`],{cwd:e,reject:!1}),x={...f?.dependencies,...f?.devDependencies};return{conflictFiles:[...r,...h],dependencies:Object.keys(x),dependencyVersions:x,existingFiles:n.filter(e=>!h.includes(e)),hasGit:v===0,hasPackageJson:a,hasPrettierKey:f?.prettier!==void 0,hasSrcDirectory:s,huskyFiles:o,isModule:f?.type===`module`,lockfiles:i,packageManagerConfigs:Object.fromEntries(d.map(({content:e,path:t})=>[t,e])),productionDependencies:Object.keys(f?.dependencies??{}),rootJsFiles:_,scripts:f?.scripts??{},toolchainConfigs:Object.fromEntries(Object.entries(p).filter(([,e])=>m(e))),tsconfigs:Object.fromEntries(c.map(({content:e,path:t})=>[t,e])),typescriptVersion:g??f?.devDependencies?.typescript??f?.dependencies?.typescript??null,userAgent:process.env.npm_config_user_agent,viteConfig:l[0]??null}}const Rn=[`┏━┓┏━┓┏┓╻╺┳╸╻ ╻╻ ╻`,`┗━┓┣━┫┃┗┫ ┃ ┃ ┃┏╋┛`,`┗━┛╹ ╹╹ ╹ ╹ ┗━┛╹ ╹`],zn=[[137,180,250],[180,190,254],[203,166,247],[242,205,205],[245,224,220]],Bn=[[30,102,245],[114,135,253],[136,57,239],[221,120,120],[220,138,120]],Vn=process.stdout.isTTY&&process.stdout.hasColors(2**24);function Hn(){let{stdin:e,stdout:t}=process;return!e.isTTY||!t.isTTY?Promise.resolve(!1):new Promise(n=>{let r=t=>{clearTimeout(a),e.off(`data`,i),e.setRawMode(!1),e.pause(),n(t)},i=e=>{let t=/rgb:([\da-f]+)\/([\da-f]+)\/([\da-f]+)/i.exec(e.toString());if(!t){r(!1);return}let[n=0,i=0,a=0]=t.slice(1).map(e=>Number.parseInt(e,16)/(16**e.length-1));r(.2126*n+.7152*i+.0722*a>.5)},a=setTimeout(()=>r(!1),150);e.setRawMode(!0),e.on(`data`,i),t.write(`\x1B]11;?\x07`)})}function Un(e,t){let n=t*(e.length-1),r=Math.min(Math.floor(n),e.length-2),i=n-r,a=e[r]??[],o=e[r+1]??[];return a.map((e,t)=>Math.round(e+((o[t]??e)-e)*i))}function Wn(e,t){let n=Array.from(e);return`${n.map((e,r)=>{let[i,a,o]=Un(t,r/Math.max(n.length-1,1));return`\x1b[38;2;${String(i)};${String(a)};${String(o)}m${e}`}).join(``)}\x1b[39m`}async function Gn(){let e=Vn&&(await Hn()?Bn:zn),t=e?Rn.map(t=>Wn(t,e)):Rn;yt(t.join(`\n${n(`gray`,`│`)} `))}function Kn(e=`Bye 👋`){bt(n(`inverse`,` ${e} `))}function Z(e){return De(e)&&(vt(`santux aborted`),process.exit(0)),e}async function qn(){return Z(await Dt({message:`Which package manager do you want to use?`,options:Object.values(Rt).map(e=>({label:e,value:e}))}))}const Jn={oxc:`oxlint + oxfmt`,eslint:`ESLint + Prettier`};async function Yn(e){return Z(await Dt({message:`Which toolchain do you want to use?`,options:Object.keys(Jn).map(e=>({label:Jn[e],value:e})),initialValue:e}))}async function Xn(){return Z(await ht({message:`Apply these changes?`}))}const Zn={next:`Next.js`,"tanstack-start":`TanStack Start`,astro:`Astro`,"react-vite":`React + Vite`},Qn={tailwind:`Tailwind CSS`,react:`React (Astro islands)`};async function $n(e,t){let n=Object.keys(At),r=n.find(t=>e.includes(t))??null,i=Z(await Dt({message:`Which framework does the project use?`,options:[...n.map(e=>({label:Zn[e],value:e,...e===r&&{hint:`detected`}})),{label:`None`,value:null,hint:`base layer only`}],initialValue:r})),a=Object.keys(Pt).filter(e=>Vt(e,i));return a.length===0?{addons:[],framework:i}:{addons:Z(await _t({message:`Which add-ons does the project use?`,options:a.map(e=>({label:Qn[e],value:e,...t.includes(e)&&{hint:`detected`}})),initialValues:a.filter(e=>t.includes(e)),required:!1})),framework:i}}const er=e=>n(`green`,e),Q=e=>n(`yellow`,e),$=e=>n(`red`,e);function tr(e){switch(e.type){case`create-file`:return[`${er(`create`)} ${e.path}`];case`update-file`:return[`${Q(`update`)} ${e.path}`];case`set-minimum-release-age`:return[`${Q(`set`)} minimum release age in ${e.path}`];case`set-scripts`:return[`${Q(`set`)} package.json scripts: ${Object.keys(e.scripts).join(`, `)}`];case`delete-file`:return[`${$(`remove`)} ${e.path}`];case`remove-package-json-key`:return[`${$(`remove`)} "${e.key}" from package.json`];case`set-module-type`:return[`${Q(`set`)} package.json "type": "module"`];case`remove-dependencies`:return e.dependencies.map(e=>`${$(`remove`)} ${e}`);case`add-dev-dependencies`:return Object.entries(e.dependencies).map(([e,t])=>`${er(`add`)} ${e}${n(`dim`,`@${t}`)}`)}}function nr({operations:e,warnings:t}){e.length===0?V.success(`Nothing to install or change`):mt(e.flatMap(e=>tr(e)).join(`
128
+ `),`Plan`);for(let e of t)V.warn(e)}function rr(e){e.length>0&&Ct(e.map((e,t)=>`${String(t+1)}. ${e}`).join(`
129
+ `),`Next steps`)}async function ir({alias:e=!0,dryRun:t,toolchain:n,yes:r}){let i=process.cwd();await Gn();try{let a=await Ln(i);a.hasPackageJson||(V.error(hn),process.exit(1));let o=Ht(a),s=o.packageManager??(r?`npm`:await qn()),c=o.toolchain??`oxc`,l=n??(r?c:await Yn(c)),{addons:u,framework:d}=r?{addons:o.addons,framework:o.frameworks.find(e=>e!==`node`)??null}:await $n(o.frameworks,o.addons),f=Tt();f.start(`Resolving versions`);let[p,m,h]=await Promise.all([kn(l,s,i),jn(),An(s,i)]).catch(e=>{throw f.error(`Failed to resolve versions`),e});f.stop(`Versions resolved`);let g=bn(a,{addons:u,alias:e,framework:d,packageManager:s,toolchain:l},p,{nodeLts:m,nodeVersion:process.version,packageManagerVersion:h});if(g.errors.length>0){for(let e of g.errors)V.error(e);process.exit(1)}if(nr(g),t||g.operations.length===0){rr(g.manualSteps),Kn(t?`Dry run, nothing written`:`Bye 👋`);return}if(!r&&!await Xn()){vt(`santux aborted`);return}f.start(`Updating project files`),await Tn(g,i,s).catch(e=>{throw f.error(`Failed to update project files`),e}),f.stop(`Project files updated`);let _=kt({title:`Installing dependencies`,limit:8});try{await Dn(g,i,s,e=>{_.message(e)})}catch(e){throw _.error(`Failed to install dependencies`),e}_.success(`Dependencies installed`),rr(g.manualSteps),Kn(`Done ✨`)}catch(e){vt(e instanceof Error?e.message:String(e)),process.exit(1)}}const ar=new e(`santux`).description(`Applies an opinionated tooling setup to an existing TypeScript project.`).version(te);ar.command(`init`).description(`Apply the tooling layer to the project in the current directory`).option(`--dry-run`,`Print the plan and exit without changing anything`).option(`--no-alias`,`Skip adding the @/* path alias`).addOption(new t(`--toolchain <name>`,`Lint and format toolchain to apply`).choices(Object.keys(W))).option(`--yes`,`Accept the plan without asking for confirmation`).action(ir),ar.parse(process.argv);export{};
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "santux",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "3.0.0",
4
+ "description": "Applies an opinionated tooling setup to an existing TypeScript project.",
5
+ "keywords": [
6
+ "commitlint",
7
+ "eslint",
8
+ "husky",
9
+ "oxc",
10
+ "oxfmt",
11
+ "oxlint",
12
+ "prettier",
13
+ "typescript"
14
+ ],
15
+ "license": "ISC",
16
+ "author": {
17
+ "name": "Nicolás Santuccio",
18
+ "email": "nico.santuccio@gmail.com"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/nicosantux/santux.git",
23
+ "directory": "packages/cli"
24
+ },
25
+ "bin": {
26
+ "santux": "build/index.js"
27
+ },
28
+ "files": [
29
+ "build/**/*",
30
+ "README.md"
31
+ ],
32
+ "type": "module",
33
+ "main": "build/index.js",
34
+ "scripts": {
35
+ "build": "tsdown",
36
+ "dev": "tsdown --watch",
37
+ "link-cli": "pnpm build && npm uninstall -g santux && npm link",
38
+ "test": "vitest run",
39
+ "typecheck": "tsc --noEmit"
40
+ },
41
+ "dependencies": {
42
+ "@commander-js/extra-typings": "15.1.0",
43
+ "commander": "15.1.0",
44
+ "execa": "10.2.1",
45
+ "jsonc-parser": "3.3.1",
46
+ "magicast": "0.5.5"
47
+ },
48
+ "devDependencies": {
49
+ "@clack/prompts": "1.9.0",
50
+ "@types/node": "24.19.2",
51
+ "tsdown": "0.23.7",
52
+ "typescript": "6.0.3",
53
+ "vitest": "5.1.0"
54
+ },
55
+ "engines": {
56
+ "node": ">=22.18"
57
+ }
58
+ }