ultracite 6.3.9 → 6.3.10
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/config/next/biome.jsonc +1 -1
- package/dist/index.js +21 -21
- package/package.json +1 -1
package/config/next/biome.jsonc
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var q=Object.defineProperty;var Ze=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var et=Object.prototype.hasOwnProperty;var ee=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),ke=t=>e=>{var o=t[e];if(o)return o();throw new Error("Module not found in bundle: "+e)};var D=(t,e)=>()=>(t&&(e=t(t=0)),e);var te=(t,e)=>{for(var o in e)q(t,o,{get:e[o],enumerable:!0})},tt=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qe(e))!et.call(t,n)&&n!==o&&q(t,n,{get:()=>e[n],enumerable:!(s=Ze(e,n))||s.enumerable});return t};var oe=t=>tt(q({},"__esModule",{value:!0}),t);import{access as st,readFile as be,writeFile as nt}from"fs/promises";import{parse as it}from"jsonc-parser";var l,h,xe,b,at,rt,L,p=D(()=>{"use strict";l=async t=>{try{return await st(t),!0}catch{return!1}},h=async()=>{if(await l("pnpm-workspace.yaml"))return!0;try{let t=it(await be("package.json","utf-8"));return t?!!t.workspaces||!!t.workspace:!1}catch{return!1}},xe=`
|
|
3
3
|
888 888 888 88888888888 8888888b. d8888 .d8888b. 8888888 88888888888 8888888888
|
|
4
4
|
888 888 888 888 888 Y88b d88888 d88P Y88b 888 888 888
|
|
5
5
|
888 888 888 888 888 888 d88P888 888 888 888 888 888
|
|
@@ -8,7 +8,7 @@ var Z=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var Ze=Object
|
|
|
8
8
|
888 888 888 888 888 T88b d88P 888 888 888 888 888 888
|
|
9
9
|
Y88b. .d88P 888 888 888 T88b d8888888888 Y88b d88P 888 888 888
|
|
10
10
|
"Y88888P" 88888888 888 888 T88b d88P 888 "Y8888P" 8888888 888 8888888888
|
|
11
|
-
`,b=async({dependencies:t,devDependencies:e,scripts:o})=>{let s=await
|
|
11
|
+
`,b=async({dependencies:t,devDependencies:e,scripts:o})=>{let s=await be("package.json","utf8"),n=JSON.parse(s),i={...n};(n.devDependencies||e)&&(i.devDependencies={...n.devDependencies,...e}),(n.dependencies||t)&&(i.dependencies={...n.dependencies,...t}),(n.scripts||o)&&(i.scripts={...n.scripts,...o}),await nt("package.json",JSON.stringify(i,null,2))},at=/[ $(){}[\]&|;<>!"'`*?#~]/,rt=/'/g,L=t=>t.map(e=>at.test(e)?`'${e.replace(rt,"'\\''")}' `:e)});var Le={};te(Le,{husky:()=>x});import{execSync as oo}from"child_process";import{mkdir as so,readFile as no,writeFile as Je}from"fs/promises";import{addDevDependency as io,dlxCommand as de}from"nypm";var _e,K,x,fe=D(()=>{"use strict";p();_e=t=>`#!/bin/sh
|
|
12
12
|
# Exit on any error
|
|
13
13
|
set -e
|
|
14
14
|
|
|
@@ -76,10 +76,10 @@ if [ "$STAGED_HASH" != "$NEW_STAGED_HASH" ]; then
|
|
|
76
76
|
fi
|
|
77
77
|
|
|
78
78
|
exit $FORMAT_EXIT_CODE
|
|
79
|
-
`,
|
|
80
|
-
${s}`)}}});var
|
|
79
|
+
`,K="./.husky/pre-commit",x={exists:()=>l(K),install:async t=>{await io("husky",{packageManager:t,workspace:await h()}),await b({scripts:{prepare:"husky"}})},init:t=>{let e=de(t,"husky",{args:["init"]});try{oo(e,{stdio:"inherit"})}catch{}},create:async t=>{await so(".husky",{recursive:!0});let e=de(t,"ultracite",{args:["fix"],short:t==="npm"}),o=_e(e);await Je(K,o)},update:async t=>{let e=await no(K,"utf-8"),o=de(t,"ultracite",{args:["fix"],short:t==="npm"}),s=_e(o);await Je(K,`${e}
|
|
80
|
+
${s}`)}}});var Be={};te(Be,{lefthook:()=>E});import{execSync as ao}from"child_process";import{readFile as ro,writeFile as J}from"fs/promises";import{addDevDependency as co,dlxCommand as We}from"nypm";var lo,fo,ze,v,He,E,me=D(()=>{"use strict";p();lo=/(pre-commit:\s*\n\s*jobs:\s*\n)/,fo=/(pre-commit:\s*\n)/,ze=t=>We(t,"ultracite",{args:["fix"],short:t==="npm"}),v="./lefthook.yml",He=t=>`pre-commit:
|
|
81
81
|
jobs:
|
|
82
|
-
- run: ${
|
|
82
|
+
- run: ${ze(t)}
|
|
83
83
|
glob:
|
|
84
84
|
- "*.js"
|
|
85
85
|
- "*.jsx"
|
|
@@ -89,7 +89,7 @@ ${s}`)}}});var ze={};ee(ze,{lefthook:()=>R});import{execSync as Qt}from"child_pr
|
|
|
89
89
|
- "*.jsonc"
|
|
90
90
|
- "*.css"
|
|
91
91
|
stage_fixed: true
|
|
92
|
-
`,
|
|
92
|
+
`,E={exists:()=>l(v),install:async t=>{await co("lefthook",{packageManager:t,workspace:await h()});let e=We(t,"lefthook",{args:["install"],short:t==="npm"});ao(e)},create:async t=>{let e=He(t);await J(v,e)},update:async t=>{let e=await ro(v,"utf-8"),o=ze(t),s=He(t);if(e.includes(o))return;if(e.startsWith("# EXAMPLE USAGE:")){await J(v,s);return}if(e.includes("pre-commit:"))if(e.includes("jobs:")){let i=` - run: ${o}
|
|
93
93
|
glob:
|
|
94
94
|
- "*.js"
|
|
95
95
|
- "*.jsx"
|
|
@@ -98,8 +98,8 @@ ${s}`)}}});var ze={};ee(ze,{lefthook:()=>R});import{execSync as Qt}from"child_pr
|
|
|
98
98
|
- "*.json"
|
|
99
99
|
- "*.jsonc"
|
|
100
100
|
- "*.css"
|
|
101
|
-
stage_fixed: true`,a=e.replace(
|
|
102
|
-
`);await
|
|
101
|
+
stage_fixed: true`,a=e.replace(lo,`$1${i}
|
|
102
|
+
`);await J(v,a)}else{let i=` jobs:
|
|
103
103
|
- run: ${o}
|
|
104
104
|
glob:
|
|
105
105
|
- "*.js"
|
|
@@ -109,26 +109,26 @@ ${s}`)}}});var ze={};ee(ze,{lefthook:()=>R});import{execSync as Qt}from"child_pr
|
|
|
109
109
|
- "*.json"
|
|
110
110
|
- "*.jsonc"
|
|
111
111
|
- "*.css"
|
|
112
|
-
stage_fixed: true`,a=e.replace(
|
|
113
|
-
`);await
|
|
114
|
-
${s}`)}}});var
|
|
115
|
-
`).filter(i=>i.trim()&&!i.trim().startsWith("#")),o={},s=null,n=[];for(let i of e){let a=
|
|
112
|
+
stage_fixed: true`,a=e.replace(fo,`$1${i}
|
|
113
|
+
`);await J(v,a)}else await J(v,`${e}
|
|
114
|
+
${s}`)}}});var mo,pe=D(()=>{mo=ke({"./husky.ts":()=>(fe(),oe(Le)),"./lefthook.ts":()=>(me(),oe(Be)),"./lint-staged.ts":()=>(ue(),oe(Ge))})});var Ge={};te(Ge,{lintStaged:()=>A});import{readFile as X,writeFile as C}from"fs/promises";import{pathToFileURL as po}from"url";import _ from"deepmerge";import{parse as he}from"jsonc-parser";import{addDevDependency as uo,dlxCommand as go}from"nypm";var y,Ve,ho,wo,yo,ko,bo,xo,vo,Co,jo,ge,Po,A,ue=D(()=>{"use strict";p();pe();y=t=>({"*.{js,jsx,ts,tsx,json,jsonc,css,scss,md,mdx}":[go(t,"ultracite",{args:["fix"],short:t==="npm"})]}),Ve=["./package.json","./.lintstagedrc.json","./.lintstagedrc.js","./.lintstagedrc.cjs","./.lintstagedrc.mjs","./lint-staged.config.js","./lint-staged.config.cjs","./lint-staged.config.mjs","./.lintstagedrc.yaml","./.lintstagedrc.yml","./.lintstagedrc"],ho=(t,e,o,s)=>{let n=t.trim();if(n.includes(":")&&!n.startsWith("-")){o&&s.length>0&&(e[o]=s);let[i,...a]=n.split(":"),r=a.join(":").trim(),f=i.trim().replace(/['"]/g,"");return r&&r!==""?(r.startsWith("[")&&r.endsWith("]")?e[f]=r.slice(1,-1).split(",").map(g=>g.trim().replace(/['"]/g,"")):e[f]=r.replace(/['"]/g,""),{newCurrentKey:null,newCurrentArray:[]}):{newCurrentKey:f,newCurrentArray:[]}}if(n.startsWith("-")&&o){let i=[...s,n.slice(1).trim().replace(/['"]/g,"")];return{newCurrentKey:o,newCurrentArray:i}}return{newCurrentKey:o,newCurrentArray:s}},wo=t=>{let e=t.split(`
|
|
115
|
+
`).filter(i=>i.trim()&&!i.trim().startsWith("#")),o={},s=null,n=[];for(let i of e){let a=ho(i,o,s,n);s=a.newCurrentKey,n=a.newCurrentArray}return s&&n.length>0&&(o[s]=n),o},yo=t=>{let e="";for(let[o,s]of Object.entries(t))if(Array.isArray(s)){e+=`${o}:
|
|
116
116
|
`;for(let n of s)e+=` - '${n}'
|
|
117
117
|
`}else e+=`${o}: '${s}'
|
|
118
|
-
`;return e},
|
|
119
|
-
`;await C(t,a)},
|
|
120
|
-
`;await C(t,n)},
|
|
121
|
-
`),t.push(
|
|
118
|
+
`;return e},ko=async()=>{try{let t=he(await X("./package.json","utf-8"));return t?t.type==="module":!1}catch{return!1}},bo=async t=>{let e=he(await X("./package.json","utf-8"));e&&(e["lint-staged"]?e["lint-staged"]=_(e["lint-staged"],y(t)):e["lint-staged"]=y(t),await C("./package.json",JSON.stringify(e,null,2)))},xo=async(t,e)=>{let o=await X(t,"utf-8"),s=he(o);if(!s)return;let n=_(s,y(e));await C(t,JSON.stringify(n,null,2))},vo=async(t,e)=>{let o=await X(t,"utf-8"),s=wo(o);if(!s)return;let n=_(s,y(e));await C(t,yo(n))},Co=async(t,e)=>{let n=(await import(po(t).href)).default||{},i=_(n,y(e)),a=`export default ${JSON.stringify(i,null,2)};
|
|
119
|
+
`;await C(t,a)},jo=async(t,e)=>{delete ee.cache[ee.resolve(`./${t}`)];let o=mo(`./${t}`),s=_(o,y(e)),n=`module.exports = ${JSON.stringify(s,null,2)};
|
|
120
|
+
`;await C(t,n)},ge=async t=>{await C(".lintstagedrc.json",JSON.stringify(y(t),null,2))},Po=async(t,e)=>{if(t==="./package.json"){await bo(e);return}if(t.endsWith(".json")||t==="./.lintstagedrc"){await xo(t,e);return}if(t.endsWith(".yaml")||t.endsWith(".yml")){await vo(t,e);return}let o=await ko();if(t.endsWith(".mjs")||t.endsWith(".js")&&o){try{await Co(t,e)}catch{await ge(e)}return}if(t.endsWith(".cjs")||t.endsWith(".js")&&!o)try{await jo(t,e)}catch{await ge(e)}},A={exists:async()=>{for(let t of Ve)if(await l(t))return!0;return!1},install:async t=>{await uo("lint-staged",{packageManager:t,workspace:await h()})},create:async t=>{await C(".lintstagedrc.json",JSON.stringify(y(t),null,2))},update:async t=>{let e=null;for(let o of Ve)if(await l(o)){e=o;break}if(!e){await ge(t);return}await Po(e,t)}}});import{initTRPC as Ko}from"@trpc/server";import{createCli as Xo}from"trpc-cli";import c from"zod";var k={name:"ultracite",description:"The AI-ready formatter that helps you write and generate code faster.",version:"6.3.10",type:"module",bin:{ultracite:"dist/index.js"},files:["config","dist","README.md"],scripts:{build:"tsup",test:"bun test","test:coverage":"bun test --coverage"},exports:{"./*":"./config/*/biome.jsonc"},author:"Hayden Bleasel <hello@haydenbleasel.com>",bugs:{url:"https://github.com/haydenbleasel/ultracite/issues"},homepage:"https://www.ultracite.ai/",keywords:["ultracite","biome","linter","formatter","fixer"],license:"MIT",publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},repository:{type:"git",url:"git+https://github.com/haydenbleasel/ultracite.git"},devDependencies:{"@biomejs/biome":"2.3.8","@types/node":"^24.10.1",tsup:"^8.5.1",turbo:"^2.6.2"},dependencies:{"@clack/prompts":"^0.11.0","@trpc/server":"^11.7.2",deepmerge:"^4.3.1",glob:"^13.0.0","jsonc-parser":"^3.3.1",nypm:"^0.6.2","trpc-cli":"^0.12.1",zod:"^4.1.13"},packageManager:"bun@1.3.3"};p();import{spawnSync as ct}from"child_process";import lt from"process";import{detectPackageManager as dt,dlxCommand as ft}from"nypm";var se=async t=>{let e=t?.[0]||[],o=t?.[1]["diagnostic-level"],s=["check","--no-errors-on-unmatched","--max-diagnostics=none"];o&&s.push(`--diagnostic-level=${o}`),e.length>0?s.push(...L(e)):s.push("./");let i=(await dt(lt.cwd()))?.name||"npm",a=ft(i,"@biomejs/biome",{args:s,short:i==="npm"}),r=ct(a,{stdio:"inherit",shell:!0});if(r.error)throw new Error(`Failed to run Ultracite: ${r.error.message}`);if(r.status!==0)throw new Error(`Ultracite check failed with status ${r.status??1}`)};import S from"process";import{spawnSync as St}from"child_process";import{existsSync as T}from"fs";import{readFile as Ee}from"fs/promises";import{join as M}from"path";import{detectPackageManager as Rt,dlxCommand as Et}from"nypm";import{parse as At}from"jsonc-parser";p();import{readFile as ve,unlink as mt,writeFile as pt}from"fs/promises";import{parse as Ce}from"jsonc-parser";import{removeDependency as ut}from"nypm";var H=[".eslintrc",".eslintrc.js",".eslintrc.json",".eslintrc.yml",".eslintrc.yaml",".eslintrc.config.js","eslint.config.js","eslint.config.mjs","eslint.config.cjs",".eslintignore"],je=async()=>{try{let t=await ve("package.json","utf-8"),e=Ce(t);if(!e||typeof e!="object")return[];let o=e.dependencies||{},s=e.devDependencies||{},n={...o,...s};return Object.keys(n).filter(i=>i.includes("eslint"))}catch{return[]}},gt=async(t,e)=>{if(e.length!==0)try{for(let o of e)await ut(o,{packageManager:t})}catch(o){console.warn(o)}},ht=async()=>{let t=[];for(let e of H)if(await l(e))try{await mt(e),t.push(e)}catch(o){console.warn(o)}return t},wt=async()=>{let t="./.vscode/settings.json";if(!await l(t))return!1;try{let e=await ve(t,"utf-8"),o=Ce(e);if(!o||typeof o!="object")return!1;let s=!1,n={...o},i=["eslint.enable","eslint.format.enable","eslint.validate","eslint.workingDirectories","eslint.codeAction.showDocumentation","eslint.run","eslint.autoFixOnSave","eslint.quiet","eslint.packageManager","eslint.options","eslint.trace.server"];for(let a of i)a in n&&(delete n[a],s=!0);if("editor.codeActionsOnSave"in n){let a=n["editor.codeActionsOnSave"];if(a&&typeof a=="object"){let r=["source.fixAll.eslint","source.organizeImports.eslint"];for(let f of r)f in a&&(delete a[f],s=!0);Object.keys(a).length===0&&(n["editor.codeActionsOnSave"]=void 0)}}return s?(await pt(t,JSON.stringify(n,null,2)),!0):!1}catch(e){return console.warn(e),!1}},yt=async()=>{if((await je()).length>0)return!0;for(let e of H)if(await l(e))return!0;return!1},ne={hasEsLint:yt,remove:async t=>{let e=await je();await gt(t,e);let o=await ht(),s=await wt();return{packagesRemoved:e,filesRemoved:o,vsCodeCleaned:s}}};p();import{readFile as Pe,unlink as kt,writeFile as bt}from"fs/promises";import{parse as Se}from"jsonc-parser";import{removeDependency as xt}from"nypm";var W=[".prettierrc",".prettierrc.js",".prettierrc.json",".prettierrc.yml",".prettierrc.yaml",".prettierrc.config.js","prettier.config.js","prettier.config.mjs",".prettierignore"],Re=async()=>{try{let t=await Pe("package.json","utf-8"),e=Se(t);if(!e||typeof e!="object")return[];let o=e.dependencies||{},s=e.devDependencies||{},n={...o,...s};return Object.keys(n).filter(i=>i.includes("prettier"))}catch{return[]}},vt=async(t,e)=>{if(e.length!==0)try{for(let o of e)await xt(o,{packageManager:t})}catch(o){console.warn(o)}},Ct=async()=>{let t=[];for(let e of W)if(await l(e))try{await kt(e),t.push(e)}catch(o){console.warn(o)}return t},jt=async()=>{let t="./.vscode/settings.json";if(!await l(t))return!1;try{let e=await Pe(t,"utf-8"),o=Se(e);if(!o||typeof o!="object")return!1;let s=!1,n={...o},i=["editor.defaultFormatter","prettier.enable","prettier.requireConfig","prettier.configPath","prettier.printWidth","prettier.tabWidth","prettier.useTabs","prettier.semi","prettier.singleQuote","prettier.quoteProps","prettier.trailingComma","prettier.bracketSpacing","prettier.arrowParens","prettier.endOfLine"];for(let r of i)r in n&&(r==="editor.defaultFormatter"&&n[r]==="esbenp.prettier-vscode"||r!=="editor.defaultFormatter")&&(delete n[r],s=!0);let a=Object.keys(n).filter(r=>r.startsWith("[")&&r.includes("javascript"));for(let r of a){let f=n[r];f&&typeof f=="object"&&"editor.defaultFormatter"in f&&f["editor.defaultFormatter"]==="esbenp.prettier-vscode"&&(delete f["editor.defaultFormatter"],s=!0,Object.keys(f).length===0&&delete n[r])}return s?(await bt(t,JSON.stringify(n,null,2)),!0):!1}catch(e){return console.warn(e),!1}},Pt=async()=>{if((await Re()).length>0)return!0;for(let e of W)if(await l(e))return!0;return!1},ie={hasPrettier:Pt,remove:async t=>{let e=await Re();await vt(t,e);let o=await Ct(),s=await jt();return{packagesRemoved:e,filesRemoved:o,vsCodeCleaned:s}}};var Ft=async()=>{let e=(await Rt(S.cwd()))?.name||"npm",o=Et(e,"@biomejs/biome",{args:["--version"],short:e==="npm"}),s=St(o,{shell:!0,encoding:"utf-8"});return s.status===0&&s.stdout?{name:"Biome installation",status:"pass",message:`Biome is installed (${s.stdout.trim()})`}:{name:"Biome installation",status:"fail",message:"Biome is not installed or not accessible"}},$t=async()=>{let t=M(S.cwd(),"biome.json"),e=M(S.cwd(),"biome.jsonc"),o=null;if(T(t)?o=t:T(e)&&(o=e),!o)return{name:"Biome configuration",status:"fail",message:"No biome.json or biome.jsonc file found"};try{let s=await Ee(o,"utf-8"),n=At(s);return Array.isArray(n?.extends)&&n.extends.includes("ultracite/core")?{name:"Biome configuration",status:"pass",message:"biome.json(c) extends ultracite/core"}:{name:"Biome configuration",status:"warn",message:"biome.json(c) exists but doesn't extend ultracite/core"}}catch{return{name:"Biome configuration",status:"fail",message:"Could not parse biome.json(c) file"}}},Nt=async()=>{let t=M(S.cwd(),"package.json");if(!T(t))return{name:"Ultracite dependency",status:"warn",message:"No package.json found"};try{let e=JSON.parse(await Ee(t,"utf-8")),o=e.dependencies?.ultracite||e.devDependencies?.ultracite||e.peerDependencies?.ultracite;return o?{name:"Ultracite dependency",status:"pass",message:`Ultracite is in package.json (${o})`}:{name:"Ultracite dependency",status:"warn",message:"Ultracite not found in package.json dependencies"}}catch{return{name:"Ultracite dependency",status:"warn",message:"Could not parse package.json"}}},Ot=()=>{let t=W.some(o=>T(M(S.cwd(),o))),e=H.some(o=>T(M(S.cwd(),o)));if(t||e){let o=[];return t&&o.push("Prettier"),e&&o.push("ESLint"),{name:"Conflicting tools",status:"warn",message:`Found potentially conflicting tools: ${o.join(", ")}`}}return{name:"Conflicting tools",status:"pass",message:"No conflicting formatting/linting tools found"}},Ae=async()=>{let t=[];console.log(`\u{1FA7A} Running Ultracite doctor...
|
|
121
|
+
`),t.push(await Ft()),t.push(await $t()),t.push(await Nt()),t.push(Ot());let e=t.filter(n=>n.status==="pass").length,o=t.filter(n=>n.status==="fail").length,s=t.filter(n=>n.status==="warn").length;for(let n of t){let i;n.status==="pass"?i="\u2705":n.status==="fail"?i="\u274C":i="\u26A0\uFE0F",console.log(`${i} ${n.name}: ${n.message}`)}if(console.log(`
|
|
122
122
|
\u{1F4CA} Summary:`),console.log(` ${e} passed, ${s} warnings, ${o} failed`),o>0)throw console.log(`
|
|
123
123
|
\u{1F4A1} To fix issues, run: npx ultracite init`),new Error("Doctor checks failed");s>0?console.log(`
|
|
124
124
|
\u{1F4A1} Some optional improvements available. Run 'npx ultracite init' to configure.`):console.log(`
|
|
125
|
-
\u2728 Everything looks good!`)};
|
|
125
|
+
\u2728 Everything looks good!`)};p();import{spawnSync as Dt}from"child_process";import Tt from"process";import{detectPackageManager as Mt,dlxCommand as Ut}from"nypm";var ae=async(t,e={})=>{let o=["check","--write","--no-errors-on-unmatched","--max-diagnostics=none"];e.unsafe&&o.push("--unsafe"),t.length>0?o.push(...L(t)):o.push("./");let n=(await Mt(Tt.cwd()))?.name||"npm",i=Ut(n,"@biomejs/biome",{args:o,short:n==="npm"}),a=Dt(i,{stdio:"inherit",shell:!0});if(a.error)throw new Error(`Failed to run Ultracite: ${a.error.message}`);if(a.status!==0)throw new Error(`Ultracite fix failed with status ${a.status??1}`)};import{packageManagers as It}from"nypm";var w={packageManagers:It.map(t=>t.name),editorConfigs:["vscode","zed"],agents:["vscode-copilot","cursor","windsurf","zed","claude","codex","kiro","cline","amp","aider","firebase-studio","open-hands","gemini-cli","junie","augmentcode","kilo-code","goose","roo-code","warp","droid"],integrations:["husky","lefthook","lint-staged"],hooks:["cursor","claude"],frameworks:["react","next","solid","vue","svelte","qwik","remix","angular","astro"],migrations:["eslint","prettier"]};import Oo from"process";import{cancel as F,intro as Do,isCancel as $,log as Q,multiselect as N,spinner as u}from"@clack/prompts";import{addDevDependency as To,detectPackageManager as Mo}from"nypm";import{mkdir as Jt,readFile as _t,writeFile as z}from"fs/promises";import{dirname as Lt}from"path";var Fe={"vscode-copilot":{path:"./.github/copilot-instructions.md",header:`---
|
|
126
126
|
applyTo: "**/*.{ts,tsx,js,jsx}"
|
|
127
127
|
---`,appendMode:!0},cursor:{path:"./.cursor/rules/ultracite.mdc",header:`---
|
|
128
128
|
description: Ultracite Rules - AI-Ready Formatter and Linter
|
|
129
129
|
globs: "**/*.{ts,tsx,js,jsx,json,jsonc,html,vue,svelte,astro,css,yaml,yml,graphql,gql,md,mdx,grit}"
|
|
130
130
|
alwaysApply: false
|
|
131
|
-
---`},windsurf:{path:"./.windsurf/rules/ultracite.md"},zed:{path:"./.rules",appendMode:!0},claude:{path:"./.claude/CLAUDE.md",appendMode:!0},codex:{path:"./AGENTS.md",appendMode:!0},kiro:{path:"./.kiro/steering/ultracite.md"},cline:{path:"./.clinerules",appendMode:!0},amp:{path:"./AGENT.md",appendMode:!0},aider:{path:"./ultracite.md"},"firebase-studio":{path:"./.idx/airules.md",appendMode:!0},"open-hands":{path:"./.openhands/microagents/repo.md",appendMode:!0},"gemini-cli":{path:"./GEMINI.md",appendMode:!0},junie:{path:"./.junie/guidelines.md",appendMode:!0},augmentcode:{path:"./.augment/rules/ultracite.md"},"kilo-code":{path:"./.kilocode/rules/ultracite.md"},goose:{path:"./.goosehints",appendMode:!0},"roo-code":{path:"./.roo/rules/ultracite.md",appendMode:!0},warp:{path:"./WARP.md",appendMode:!0},droid:{path:"./AGENTS.md",appendMode:!0}}
|
|
131
|
+
---`},windsurf:{path:"./.windsurf/rules/ultracite.md"},zed:{path:"./.rules",appendMode:!0},claude:{path:"./.claude/CLAUDE.md",appendMode:!0},codex:{path:"./AGENTS.md",appendMode:!0},kiro:{path:"./.kiro/steering/ultracite.md"},cline:{path:"./.clinerules",appendMode:!0},amp:{path:"./AGENT.md",appendMode:!0},aider:{path:"./ultracite.md"},"firebase-studio":{path:"./.idx/airules.md",appendMode:!0},"open-hands":{path:"./.openhands/microagents/repo.md",appendMode:!0},"gemini-cli":{path:"./GEMINI.md",appendMode:!0},junie:{path:"./.junie/guidelines.md",appendMode:!0},augmentcode:{path:"./.augment/rules/ultracite.md"},"kilo-code":{path:"./.kilocode/rules/ultracite.md"},goose:{path:"./.goosehints",appendMode:!0},"roo-code":{path:"./.roo/rules/ultracite.md",appendMode:!0},warp:{path:"./WARP.md",appendMode:!0},droid:{path:"./AGENTS.md",appendMode:!0}},$e={cursor:{path:"./.cursor/hooks.json",command:"npx ultracite fix"},claude:{path:"./.claude/settings.json",command:"npx ultracite fix"}};p();var U=`# Ultracite Code Standards
|
|
132
132
|
|
|
133
133
|
This project uses **Ultracite**, a zero-config Biome preset that enforces strict code quality standards through automated formatting and linting.
|
|
134
134
|
|
|
@@ -251,8 +251,8 @@ Biome's linter will catch most issues automatically. Focus your attention on:
|
|
|
251
251
|
---
|
|
252
252
|
|
|
253
253
|
Most formatting and common issues are automatically fixed by Biome. Run \`npx ultracite fix\` before committing to ensure compliance.
|
|
254
|
-
`;var
|
|
254
|
+
`;var Ne=t=>{let e=Fe[t],o=e.header?`${e.header}
|
|
255
255
|
|
|
256
|
-
${
|
|
256
|
+
${U}`:U,s=async()=>{let n=Lt(e.path);if(n!=="."){let i=n.startsWith("./")?n.slice(2):n;await Jt(i,{recursive:!0})}};return{exists:()=>l(e.path),create:async()=>{await s(),await z(e.path,o)},update:async()=>{if(await s(),e.appendMode){if(!await l(e.path)){await z(e.path,o);return}let n=await _t(e.path,"utf-8");if(n.includes(U.trim()))return;await z(e.path,`${n}
|
|
257
257
|
|
|
258
|
-
${M}`)}else await W(e.path,o)}}};m();import{readFile as Ot,writeFile as Ne}from"fs/promises";import Dt from"deepmerge";import{parse as Tt}from"jsonc-parser";var Oe={$schema:"./node_modules/@biomejs/biome/configuration_schema.json",extends:["ultracite/core"]},ae=async()=>await l("./biome.json")?"./biome.json":"./biome.jsonc",z={exists:async()=>{let t=await ae();return l(t)},create:async t=>{let e=await ae(),o=["ultracite/core"];if(t?.frameworks&&t.frameworks.length>0)for(let n of t.frameworks)o.push(`ultracite/${n}`);let s={...Oe,extends:o};return Ne(e,JSON.stringify(s,null,2))},update:async t=>{let e=await ae(),o=await Ot(e,"utf-8"),n=Tt(o)||{},a=[...n.extends&&Array.isArray(n.extends)?n.extends:[]];if(a.includes("ultracite/core")||a.push("ultracite/core"),t?.frameworks&&t.frameworks.length>0)for(let g of t.frameworks){let N=`ultracite/${g}`;a.includes(N)||a.push(N)}n.extends=a;let c={$schema:Oe.$schema},f=Dt(n,c);await Ne(e,JSON.stringify(f,null,2))}};import{mkdir as Mt,readFile as De,writeFile as S}from"fs/promises";import{dirname as Ut}from"path";m();var Te=t=>{let e=Fe[t],o=async()=>{let s=Ut(e.path);if(s!=="."){let n=s.startsWith("./")?s.slice(2):s;await Mt(n,{recursive:!0})}};return{exists:()=>l(e.path),create:async()=>{await o(),t==="cursor"?await S(e.path,JSON.stringify({version:1,hooks:{afterFileEdit:[{command:e.command}]}},null,2)):t==="claude"&&await S(e.path,JSON.stringify({hooks:{PostToolUse:[{matcher:"Edit|Write",hooks:[{type:"command",command:e.command}]}]}},null,2))},update:async()=>{if(await o(),t==="cursor"){if(!await l(e.path)){await S(e.path,JSON.stringify({version:1,hooks:{afterFileEdit:[{command:e.command}]}},null,2));return}let s=await De(e.path,"utf-8"),n=JSON.parse(s);n.hooks.afterFileEdit.some(a=>a.command.includes("ultracite"))||(n.hooks.afterFileEdit.push({command:e.command}),await S(e.path,JSON.stringify(n,null,2)))}else if(t==="claude"){if(!await l(e.path)){await S(e.path,JSON.stringify({hooks:{PostToolUse:[{matcher:"Edit|Write",hooks:[{type:"command",command:e.command}]}]}},null,2));return}let s=await De(e.path,"utf-8"),n=JSON.parse(s);n.hooks||(n.hooks={}),n.hooks.PostToolUse||(n.hooks.PostToolUse=[]),n.hooks.PostToolUse.some(a=>a.hooks?.some(c=>c.command.includes("ultracite")))||(n.hooks.PostToolUse.push({matcher:"Edit|Write",hooks:[{type:"command",command:e.command}]}),await S(e.path,JSON.stringify(n,null,2)))}}}};m();import{spawnSync as It}from"child_process";import{mkdir as Jt,readFile as _t,writeFile as Me}from"fs/promises";import Lt from"deepmerge";import{parse as Ht}from"jsonc-parser";var re={"editor.defaultFormatter":"esbenp.prettier-vscode","[javascript]":{"editor.defaultFormatter":"biomejs.biome"},"[typescript]":{"editor.defaultFormatter":"biomejs.biome"},"[javascriptreact]":{"editor.defaultFormatter":"biomejs.biome"},"[typescriptreact]":{"editor.defaultFormatter":"biomejs.biome"},"[json]":{"editor.defaultFormatter":"biomejs.biome"},"[jsonc]":{"editor.defaultFormatter":"biomejs.biome"},"[css]":{"editor.defaultFormatter":"biomejs.biome"},"[graphql]":{"editor.defaultFormatter":"biomejs.biome"},"typescript.tsdk":"node_modules/typescript/lib","editor.formatOnSave":!0,"editor.formatOnPaste":!0,"emmet.showExpandedAbbreviation":"never","editor.codeActionsOnSave":{"source.fixAll.biome":"explicit","source.organizeImports.biome":"explicit"}};var B="./.vscode/settings.json",U={exists:()=>l(B),create:async()=>{await Jt(".vscode",{recursive:!0}),await Me(B,JSON.stringify(re,null,2))},update:async()=>{let t=await _t(B,"utf-8"),o=Ht(t)||{},s=Lt(o,re);await Me(B,JSON.stringify(s,null,2))},extension:()=>It("code --install-extension biomejs.biome",{stdio:"inherit",shell:!0})};m();import{mkdir as Wt,readFile as zt,writeFile as Ue}from"fs/promises";import Bt from"deepmerge";import{parse as Gt}from"jsonc-parser";var ce={formatter:"language_server",format_on_save:"on",languages:{JavaScript:{formatter:{language_server:{name:"biome"}},code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0}},TypeScript:{formatter:{language_server:{name:"biome"}},code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0}},TSX:{formatter:{language_server:{name:"biome"}},code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0}}},lsp:{"typescript-language-server":{settings:{typescript:{preferences:{includePackageJsonAutoImports:"on"}}}}}};var G="./.zed/settings.json",V={exists:()=>l(G),create:async()=>{await Wt(".zed",{recursive:!0}),await Ue(G,JSON.stringify(ce,null,2))},update:async()=>{let t=await zt(G,"utf-8"),o=Gt(t)||{},s=Bt(o,ce);await Ue(G,JSON.stringify(s,null,2))}};de();fe();me();import{readFile as wo,writeFile as yo}from"fs/promises";import ko from"deepmerge";import{glob as bo}from"glob";import{parse as xo}from"jsonc-parser";var vo={compilerOptions:{strictNullChecks:!0}},Ve=async()=>{try{return await bo("**/tsconfig*.json",{ignore:["**/node_modules/**","**/dist/**","**/build/**","**/.next/**"],absolute:!1})}catch{return[]}},Co=async t=>{try{let e=await wo(t,"utf-8"),s=xo(e)||{},n=ko(s,vo);await yo(t,JSON.stringify(n,null,2))}catch(e){console.warn(`Failed to update ${t}:`,e)}},he={exists:async()=>(await Ve()).length>0,update:async()=>{let t=await Ve();if(t.length===0){console.warn("No tsconfig.json files found in the project");return}await Promise.all(t.map(e=>Co(e)))}};m();var Ye=k.devDependencies["@biomejs/biome"],Ke=k.version,Eo=async(t,e=!0,o=!1)=>{let s=u();o||s.start("Installing dependencies...");let n=[`ultracite@${Ke}`,`@biomejs/biome@${Ye}`];if(e)for(let i of n)await So(i,{packageManager:t,workspace:await h(),silent:o});else await b({devDependencies:{"@biomejs/biome":Ye,ultracite:Ke}});o||s.stop("Dependencies installed.")},Ao=async(t=!1)=>{let e=u();if(t||e.start("Checking for tsconfig.json files..."),await he.exists()){t||e.message("Found tsconfig.json files, updating with strictNullChecks..."),await he.update(),t||e.stop("tsconfig.json files updated.");return}t||e.stop("No tsconfig.json files found, skipping.")},Fo=async(t=!1)=>{let e=u();if(t||e.start("Checking for .vscode/settings.json..."),await U.exists()){t||e.message("settings.json found, updating..."),await U.update(),t||e.stop("settings.json updated.");return}t||e.message("settings.json not found, creating..."),await U.create(),t||(e.message("settings.json created."),e.message("Installing Biome extension..."));try{U.extension(),t||e.stop("settings.json created.")}catch(o){t||e.stop(`Failed to install Biome extension (${o}), but continuing...`)}},$o=async(t=!1)=>{let e=u();if(t||e.start("Checking for .zed/settings.json..."),await V.exists()){t||e.message("settings.json found, updating..."),await V.update(),t||e.stop("settings.json updated.");return}t||e.message("settings.json not found, creating..."),await V.create(),t||e.message("settings.json created. Install the Biome extension: https://biomejs.dev/reference/zed/")},No=async(t,e=!1)=>{let o=u();if(e||o.start("Checking for Biome configuration..."),await z.exists()){e||o.message("Biome configuration found, updating..."),await z.update({frameworks:t}),e||o.stop("Biome configuration updated.");return}e||o.message("Biome configuration not found, creating..."),await z.create({frameworks:t}),e||o.stop("Biome configuration created.")},Oo=async(t,e=!0,o=!1)=>{let s=u();if(o||(s.start("Initializing pre-commit hooks..."),s.message("Installing Husky...")),e?await x.install(t):await b({devDependencies:{husky:"latest"},scripts:{prepare:"husky"}}),o||s.message("Initializing Husky..."),x.init(t),await x.exists()){o||s.message("Pre-commit hook found, updating..."),await x.update(t),o||s.stop("Pre-commit hook updated.");return}o||s.message("Pre-commit hook not found, creating..."),await x.create(t),o||s.stop("Pre-commit hook created.")},Do=async(t,e=!0,o=!1)=>{let s=u();if(o||(s.start("Initializing lefthook..."),s.message("Installing lefthook...")),e?await R.install(t):await b({devDependencies:{lefthook:"latest"}}),await R.exists()){o||s.message("lefthook.yml found, updating..."),await R.update(t),o||s.stop("lefthook.yml updated.");return}o||s.message("lefthook.yml not found, creating..."),await R.create(t),o||s.stop("lefthook.yml created.")},To=async(t,e=!0,o=!1)=>{let s=u();if(o||(s.start("Initializing lint-staged..."),s.message("Installing lint-staged...")),e?await E.install(t):await b({devDependencies:{"lint-staged":"latest"}}),await E.exists()){o||s.message("lint-staged found, updating..."),await E.update(t),o||s.stop("lint-staged updated.");return}o||s.message("lint-staged not found, creating..."),await E.create(t),o||s.stop("lint-staged created.")},Mo=async(t,e,o=!1)=>{let s=u();o||s.start(`Checking for ${e}...`);let n=$e(t);if(await n.exists()){o||s.message(`${e} found, updating...`),await n.update(),o||s.stop(`${e} updated.`);return}o||s.message(`${e} not found, creating...`),await n.create(),o||s.stop(`${e} created.`)},Uo=async(t,e,o=!1)=>{let s=u();o||s.start(`Checking for ${e} hooks...`);let n=Te(t);if(await n.exists()){o||s.message(`${e} hooks found, updating...`),await n.update(),o||s.stop(`${e} hooks updated.`);return}o||s.message(`${e} hooks not found, creating...`),await n.create(),o||s.stop(`${e} hooks created.`)},Io=async(t,e=!1)=>{let o=u();e||o.start("Removing Prettier dependencies and configuration...");try{let s=await ne.remove(t);e||(s.packagesRemoved.length>0&&o.message(`Removed Prettier packages: ${s.packagesRemoved.join(", ")}`),s.filesRemoved.length>0&&o.message(`Removed config files: ${s.filesRemoved.join(", ")}`),s.vsCodeCleaned&&o.message("Cleaned VS Code settings"),o.stop("Prettier removed successfully."))}catch{e||o.stop("Failed to remove Prettier completely, but continuing...")}},Jo=async(t,e=!1)=>{let o=u();e||o.start("Removing ESLint dependencies and configuration...");try{let s=await se.remove(t);e||(s.packagesRemoved.length>0&&o.message(`Removed ESLint packages: ${s.packagesRemoved.join(", ")}`),s.filesRemoved.length>0&&o.message(`Removed config files: ${s.filesRemoved.join(", ")}`),s.vsCodeCleaned&&o.message("Cleaned VS Code settings"),o.stop("ESLint removed successfully."))}catch{e||o.stop("Failed to remove ESLint completely, but continuing...")}},Xe=async t=>{let e=t??{},o=e.quiet??!1;o||Po(be);try{let{pm:s}=e;if(!s){let d=await Ro(jo.cwd());if(!d)throw new Error("No package manager specified or detected");if(!o&&d.warnings)for(let p of d.warnings)X.warn(p);o||X.info(`Detected lockfile, using ${d.name}`),s=d.name}let n=e.migrate?.includes("prettier"),i=e.migrate?.includes("eslint");if(!o&&(n===void 0||i===void 0)){let d=[];if(n===void 0&&await ne.hasPrettier()&&d.push({label:"Remove Prettier (dependencies, config files, VS Code settings)",value:"prettier"}),i===void 0&&await se.hasEsLint()&&d.push({label:"Remove ESLint (dependencies, config files, VS Code settings)",value:"eslint"}),d.length>0){let p=await $({message:"Remove existing formatters/linters (recommended for clean migration)?",options:d,required:!1});if(F(p)){A("Operation cancelled.");return}n===void 0&&(n=p.includes("prettier")),i===void 0&&(i=p.includes("eslint"))}}o&&(n===void 0&&(n=!1),i===void 0&&(i=!1));let a=e.frameworks;if(a===void 0)if(o||e.pm||e.editors||e.agents||e.hooks||e.integrations!==void 0||e.migrate!==void 0)a=[];else{let p=await $({message:"Which frameworks are you using (optional)?",options:[{label:"React",value:"react"},{label:"Next.js",value:"next"},{label:"Solid",value:"solid"},{label:"Vue",value:"vue"},{label:"Svelte",value:"svelte"},{label:"Qwik",value:"qwik"},{label:"Angular",value:"angular"},{label:"Remix / TanStack Router / React Router",value:"remix"},{label:"Astro",value:"astro"}],required:!1});if(F(p)){A("Operation cancelled.");return}a=p}let c=e.editors;if(!c)if(o)c=[];else{let d=await $({message:"Which editors do you want to configure (recommended)?",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1});if(F(d)){A("Operation cancelled.");return}c=d}let f=e.agents,g=e.hooks,N={"vscode-copilot":"GitHub Copilot (VSCode)",cursor:"Cursor",windsurf:"Windsurf",zed:"Zed",claude:"Claude Code",codex:"OpenAI Codex / Jules / OpenCode",kiro:"Kiro IDE",cline:"Cline",amp:"AMP",aider:"Aider","firebase-studio":"Firebase Studio","open-hands":"Open Hands","gemini-cli":"Gemini CLI",junie:"Junie",augmentcode:"Augment Code","kilo-code":"Kilo Code",goose:"Codename Goose","roo-code":"Roo Code",warp:"Warp",droid:"Droid"};if(!f)if(o)f=[];else{let d=await $({message:"Which agents do you want to enable (optional)?",options:Object.entries(N).map(([p,Q])=>({value:p,label:Q})),required:!1});if(F(d)){A("Operation cancelled.");return}f=d}let we={cursor:"Cursor",claude:"Claude Code"};if(!g)if(o)g=[];else{let d=await $({message:"Which agent hooks do you want to enable (optional)?",options:Object.entries(we).map(([p,Q])=>({value:p,label:Q})),required:!1});if(F(d)){A("Operation cancelled.");return}g=d}let P=e.integrations;if(P===void 0)if(o||e.pm||e.editors||e.agents||e.hooks||e.migrate!==void 0)P=[];else{let p=await $({message:"Would you like any of the following (optional)?",options:[{label:"Husky pre-commit hook",value:"husky"},{label:"Lefthook pre-commit hook",value:"lefthook"},{label:"Lint-staged",value:"lint-staged"}],required:!1});if(F(p)){A("Operation cancelled.");return}P=p}n&&await Io(s,o),i&&await Jo(s,o),await Eo(s,!e.skipInstall,o),await Ao(o),await No(a,o),c?.includes("vscode")&&await Fo(o),c?.includes("zed")&&await $o(o);for(let d of f??[])await Mo(d,N[d],o);for(let d of g??[])await Uo(d,we[d],o);P?.includes("husky")&&await Oo(s,!e.skipInstall,o),P?.includes("lefthook")&&await Do(s,!e.skipInstall,o),P?.includes("lint-staged")&&await To(s,!e.skipInstall,o),o||X.success("Successfully initialized Ultracite configuration!")}catch(s){let n=s instanceof Error?s.message:"Unknown error";throw o||X.error(`Failed to initialize Ultracite configuration: ${n}`),s}};var j=_o.meta().create(),Ho=j.router({init:j.procedure.meta({description:"Initialize Ultracite in the current directory"}).input(r.object({pm:r.enum(w.packageManagers).optional().describe("Package manager to use"),editors:r.array(r.enum(w.editorConfigs)).optional().describe("Editors to configure"),agents:r.array(r.enum(w.agents)).optional().describe("Agents to enable"),hooks:r.array(r.enum(w.hooks)).optional().describe("Hooks to enable"),frameworks:r.array(r.enum(w.frameworks)).optional().describe("Frameworks being used"),integrations:r.array(r.enum(w.integrations)).optional().describe("Additional integrations to enable"),migrate:r.array(r.enum(w.migrations)).optional().describe("Migration tools to remove (e.g., eslint, prettier). Removes dependencies, config files, and editor settings."),skipInstall:r.boolean().default(!1).describe("Skip installing dependencies"),quiet:r.boolean().default(process.env.CI==="true"||process.env.CI==="1").describe("Suppress all interactive prompts and visual output. Automatically enabled in CI environments.")})).mutation(async({input:t})=>{await Xe(t)}),check:j.procedure.meta({description:"Run Biome linter without fixing files"}).input(r.tuple([r.array(r.string()).optional().default([]).describe("specific files to lint"),r.object({"diagnostic-level":r.enum(["info","warn","error"]).optional().describe("level of diagnostics to show. In order, from the lowest to the most important: info, warn, error.")})]).optional()).query(({input:t})=>{oe(t)}),fix:j.procedure.meta({description:"Run Biome linter and fixes files"}).input(r.tuple([r.array(r.string()).optional().default([]).describe("specific files to format"),r.object({unsafe:r.boolean().optional().describe("apply unsafe fixes")})])).mutation(({input:t})=>{let[e,o]=t;ie(e,{unsafe:o.unsafe})}),doctor:j.procedure.meta({description:"Verify your Ultracite setup and check for issues"}).query(async()=>{await Ee()}),lint:j.procedure.meta({description:"\u26A0\uFE0F DEPRECATED: Use 'check' instead - Run Biome linter without fixing files"}).input(r.array(r.string()).optional().default([]).describe("specific files to lint")).query(({input:t})=>{console.warn("\u26A0\uFE0F Warning: 'lint' command is deprecated. Please use 'check' instead."),oe([t,{}])}),format:j.procedure.meta({description:"\u26A0\uFE0F DEPRECATED: Use 'fix' instead - Run Biome linter and fixes files"}).input(r.tuple([r.array(r.string()).optional().default([]).describe("specific files to format"),r.object({unsafe:r.boolean().optional().describe("apply unsafe fixes")})])).mutation(({input:t})=>{let[e,o]=t;console.warn("\u26A0\uFE0F Warning: 'format' command is deprecated. Please use 'fix' instead."),ie(e,{unsafe:o.unsafe})})}),Wo=Lo({router:Ho,name:k.name,version:k.version,description:k.description});process.env.TEST||Wo.run();export{Ho as router};
|
|
258
|
+
${U}`)}else await z(e.path,o)}}};p();import{readFile as Ht,writeFile as Oe}from"fs/promises";import Wt from"deepmerge";import{parse as zt}from"jsonc-parser";var De={$schema:"./node_modules/@biomejs/biome/configuration_schema.json",extends:["ultracite/core"]},re=async()=>await l("./biome.json")?"./biome.json":"./biome.jsonc",B={exists:async()=>{let t=await re();return l(t)},create:async t=>{let e=await re(),o=["ultracite/core"];if(t?.frameworks&&t.frameworks.length>0)for(let n of t.frameworks)o.push(`ultracite/${n}`);let s={...De,extends:o};return Oe(e,JSON.stringify(s,null,2))},update:async t=>{let e=await re(),o=await Ht(e,"utf-8"),n=zt(o)||{},a=[...n.extends&&Array.isArray(n.extends)?n.extends:[]];if(a.includes("ultracite/core")||a.push("ultracite/core"),t?.frameworks&&t.frameworks.length>0)for(let g of t.frameworks){let O=`ultracite/${g}`;a.includes(O)||a.push(O)}n.extends=a;let r={$schema:De.$schema},f=Wt(n,r);await Oe(e,JSON.stringify(f,null,2))}};import{mkdir as Bt,readFile as Te,writeFile as R}from"fs/promises";import{dirname as Gt}from"path";p();var Me=t=>{let e=$e[t],o=async()=>{let s=Gt(e.path);if(s!=="."){let n=s.startsWith("./")?s.slice(2):s;await Bt(n,{recursive:!0})}};return{exists:()=>l(e.path),create:async()=>{await o(),t==="cursor"?await R(e.path,JSON.stringify({version:1,hooks:{afterFileEdit:[{command:e.command}]}},null,2)):t==="claude"&&await R(e.path,JSON.stringify({hooks:{PostToolUse:[{matcher:"Edit|Write",hooks:[{type:"command",command:e.command}]}]}},null,2))},update:async()=>{if(await o(),t==="cursor"){if(!await l(e.path)){await R(e.path,JSON.stringify({version:1,hooks:{afterFileEdit:[{command:e.command}]}},null,2));return}let s=await Te(e.path,"utf-8"),n=JSON.parse(s);n.hooks.afterFileEdit.some(a=>a.command.includes("ultracite"))||(n.hooks.afterFileEdit.push({command:e.command}),await R(e.path,JSON.stringify(n,null,2)))}else if(t==="claude"){if(!await l(e.path)){await R(e.path,JSON.stringify({hooks:{PostToolUse:[{matcher:"Edit|Write",hooks:[{type:"command",command:e.command}]}]}},null,2));return}let s=await Te(e.path,"utf-8"),n=JSON.parse(s);n.hooks||(n.hooks={}),n.hooks.PostToolUse||(n.hooks.PostToolUse=[]),n.hooks.PostToolUse.some(a=>a.hooks?.some(r=>r.command.includes("ultracite")))||(n.hooks.PostToolUse.push({matcher:"Edit|Write",hooks:[{type:"command",command:e.command}]}),await R(e.path,JSON.stringify(n,null,2)))}}}};p();import{spawnSync as Vt}from"child_process";import{mkdir as Yt,readFile as Kt,writeFile as Ue}from"fs/promises";import Xt from"deepmerge";import{parse as Qt}from"jsonc-parser";var ce={"editor.defaultFormatter":"esbenp.prettier-vscode","[javascript]":{"editor.defaultFormatter":"biomejs.biome"},"[typescript]":{"editor.defaultFormatter":"biomejs.biome"},"[javascriptreact]":{"editor.defaultFormatter":"biomejs.biome"},"[typescriptreact]":{"editor.defaultFormatter":"biomejs.biome"},"[json]":{"editor.defaultFormatter":"biomejs.biome"},"[jsonc]":{"editor.defaultFormatter":"biomejs.biome"},"[css]":{"editor.defaultFormatter":"biomejs.biome"},"[graphql]":{"editor.defaultFormatter":"biomejs.biome"},"typescript.tsdk":"node_modules/typescript/lib","editor.formatOnSave":!0,"editor.formatOnPaste":!0,"emmet.showExpandedAbbreviation":"never","editor.codeActionsOnSave":{"source.fixAll.biome":"explicit","source.organizeImports.biome":"explicit"}};var G="./.vscode/settings.json",I={exists:()=>l(G),create:async()=>{await Yt(".vscode",{recursive:!0}),await Ue(G,JSON.stringify(ce,null,2))},update:async()=>{let t=await Kt(G,"utf-8"),o=Qt(t)||{},s=Xt(o,ce);await Ue(G,JSON.stringify(s,null,2))},extension:()=>Vt("code --install-extension biomejs.biome",{stdio:"inherit",shell:!0})};p();import{mkdir as Zt,readFile as qt,writeFile as Ie}from"fs/promises";import eo from"deepmerge";import{parse as to}from"jsonc-parser";var le={formatter:"language_server",format_on_save:"on",languages:{JavaScript:{formatter:{language_server:{name:"biome"}},code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0}},TypeScript:{formatter:{language_server:{name:"biome"}},code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0}},TSX:{formatter:{language_server:{name:"biome"}},code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0}}},lsp:{"typescript-language-server":{settings:{typescript:{preferences:{includePackageJsonAutoImports:"on"}}}}}};var V="./.zed/settings.json",Y={exists:()=>l(V),create:async()=>{await Zt(".zed",{recursive:!0}),await Ie(V,JSON.stringify(le,null,2))},update:async()=>{let t=await qt(V,"utf-8"),o=to(t)||{},s=eo(o,le);await Ie(V,JSON.stringify(s,null,2))}};fe();me();ue();import{readFile as So,writeFile as Ro}from"fs/promises";import Eo from"deepmerge";import{glob as Ao}from"glob";import{parse as Fo}from"jsonc-parser";var $o={compilerOptions:{strictNullChecks:!0}},Ye=async()=>{try{return await Ao("**/tsconfig*.json",{ignore:["**/node_modules/**","**/dist/**","**/build/**","**/.next/**"],absolute:!1})}catch{return[]}},No=async t=>{try{let e=await So(t,"utf-8"),s=Fo(e)||{},n=Eo(s,$o);await Ro(t,JSON.stringify(n,null,2))}catch(e){console.warn(`Failed to update ${t}:`,e)}},we={exists:async()=>(await Ye()).length>0,update:async()=>{let t=await Ye();if(t.length===0){console.warn("No tsconfig.json files found in the project");return}await Promise.all(t.map(e=>No(e)))}};p();var Ke=k.devDependencies["@biomejs/biome"],Xe=k.version,Uo=async(t,e=!0,o=!1)=>{let s=u();o||s.start("Installing dependencies...");let n=[`ultracite@${Xe}`,`@biomejs/biome@${Ke}`];if(e)for(let i of n)await To(i,{packageManager:t,workspace:await h(),silent:o});else await b({devDependencies:{"@biomejs/biome":Ke,ultracite:Xe}});o||s.stop("Dependencies installed.")},Io=async(t=!1)=>{let e=u();if(t||e.start("Checking for tsconfig.json files..."),await we.exists()){t||e.message("Found tsconfig.json files, updating with strictNullChecks..."),await we.update(),t||e.stop("tsconfig.json files updated.");return}t||e.stop("No tsconfig.json files found, skipping.")},Jo=async(t=!1)=>{let e=u();if(t||e.start("Checking for .vscode/settings.json..."),await I.exists()){t||e.message("settings.json found, updating..."),await I.update(),t||e.stop("settings.json updated.");return}t||e.message("settings.json not found, creating..."),await I.create(),t||(e.message("settings.json created."),e.message("Installing Biome extension..."));try{I.extension(),t||e.stop("settings.json created.")}catch(o){t||e.stop(`Failed to install Biome extension (${o}), but continuing...`)}},_o=async(t=!1)=>{let e=u();if(t||e.start("Checking for .zed/settings.json..."),await Y.exists()){t||e.message("settings.json found, updating..."),await Y.update(),t||e.stop("settings.json updated.");return}t||e.message("settings.json not found, creating..."),await Y.create(),t||e.message("settings.json created. Install the Biome extension: https://biomejs.dev/reference/zed/")},Lo=async(t,e=!1)=>{let o=u();if(e||o.start("Checking for Biome configuration..."),await B.exists()){e||o.message("Biome configuration found, updating..."),await B.update({frameworks:t}),e||o.stop("Biome configuration updated.");return}e||o.message("Biome configuration not found, creating..."),await B.create({frameworks:t}),e||o.stop("Biome configuration created.")},Ho=async(t,e=!0,o=!1)=>{let s=u();if(o||(s.start("Initializing pre-commit hooks..."),s.message("Installing Husky...")),e?await x.install(t):await b({devDependencies:{husky:"latest"},scripts:{prepare:"husky"}}),o||s.message("Initializing Husky..."),x.init(t),await x.exists()){o||s.message("Pre-commit hook found, updating..."),await x.update(t),o||s.stop("Pre-commit hook updated.");return}o||s.message("Pre-commit hook not found, creating..."),await x.create(t),o||s.stop("Pre-commit hook created.")},Wo=async(t,e=!0,o=!1)=>{let s=u();if(o||(s.start("Initializing lefthook..."),s.message("Installing lefthook...")),e?await E.install(t):await b({devDependencies:{lefthook:"latest"}}),await E.exists()){o||s.message("lefthook.yml found, updating..."),await E.update(t),o||s.stop("lefthook.yml updated.");return}o||s.message("lefthook.yml not found, creating..."),await E.create(t),o||s.stop("lefthook.yml created.")},zo=async(t,e=!0,o=!1)=>{let s=u();if(o||(s.start("Initializing lint-staged..."),s.message("Installing lint-staged...")),e?await A.install(t):await b({devDependencies:{"lint-staged":"latest"}}),await A.exists()){o||s.message("lint-staged found, updating..."),await A.update(t),o||s.stop("lint-staged updated.");return}o||s.message("lint-staged not found, creating..."),await A.create(t),o||s.stop("lint-staged created.")},Bo=async(t,e,o=!1)=>{let s=u();o||s.start(`Checking for ${e}...`);let n=Ne(t);if(await n.exists()){o||s.message(`${e} found, updating...`),await n.update(),o||s.stop(`${e} updated.`);return}o||s.message(`${e} not found, creating...`),await n.create(),o||s.stop(`${e} created.`)},Go=async(t,e,o=!1)=>{let s=u();o||s.start(`Checking for ${e} hooks...`);let n=Me(t);if(await n.exists()){o||s.message(`${e} hooks found, updating...`),await n.update(),o||s.stop(`${e} hooks updated.`);return}o||s.message(`${e} hooks not found, creating...`),await n.create(),o||s.stop(`${e} hooks created.`)},Vo=async(t,e=!1)=>{let o=u();e||o.start("Removing Prettier dependencies and configuration...");try{let s=await ie.remove(t);e||(s.packagesRemoved.length>0&&o.message(`Removed Prettier packages: ${s.packagesRemoved.join(", ")}`),s.filesRemoved.length>0&&o.message(`Removed config files: ${s.filesRemoved.join(", ")}`),s.vsCodeCleaned&&o.message("Cleaned VS Code settings"),o.stop("Prettier removed successfully."))}catch{e||o.stop("Failed to remove Prettier completely, but continuing...")}},Yo=async(t,e=!1)=>{let o=u();e||o.start("Removing ESLint dependencies and configuration...");try{let s=await ne.remove(t);e||(s.packagesRemoved.length>0&&o.message(`Removed ESLint packages: ${s.packagesRemoved.join(", ")}`),s.filesRemoved.length>0&&o.message(`Removed config files: ${s.filesRemoved.join(", ")}`),s.vsCodeCleaned&&o.message("Cleaned VS Code settings"),o.stop("ESLint removed successfully."))}catch{e||o.stop("Failed to remove ESLint completely, but continuing...")}},Qe=async t=>{let e=t??{},o=e.quiet??!1;o||Do(xe);try{let{pm:s}=e;if(!s){let d=await Mo(Oo.cwd());if(!d)throw new Error("No package manager specified or detected");if(!o&&d.warnings)for(let m of d.warnings)Q.warn(m);o||Q.info(`Detected lockfile, using ${d.name}`),s=d.name}let n=e.migrate?.includes("prettier"),i=e.migrate?.includes("eslint");if(!o&&(n===void 0||i===void 0)){let d=[];if(n===void 0&&await ie.hasPrettier()&&d.push({label:"Remove Prettier (dependencies, config files, VS Code settings)",value:"prettier"}),i===void 0&&await ne.hasEsLint()&&d.push({label:"Remove ESLint (dependencies, config files, VS Code settings)",value:"eslint"}),d.length>0){let m=await N({message:"Remove existing formatters/linters (recommended for clean migration)?",options:d,required:!1});if($(m)){F("Operation cancelled.");return}n===void 0&&(n=m.includes("prettier")),i===void 0&&(i=m.includes("eslint"))}}o&&(n===void 0&&(n=!1),i===void 0&&(i=!1));let a=e.frameworks;if(a===void 0)if(o||e.pm||e.editors||e.agents||e.hooks||e.integrations!==void 0||e.migrate!==void 0)a=[];else{let m=await N({message:"Which frameworks are you using (optional)?",options:[{label:"React",value:"react"},{label:"Next.js",value:"next"},{label:"Solid",value:"solid"},{label:"Vue",value:"vue"},{label:"Svelte",value:"svelte"},{label:"Qwik",value:"qwik"},{label:"Angular",value:"angular"},{label:"Remix / TanStack Router / React Router",value:"remix"},{label:"Astro",value:"astro"}],required:!1});if($(m)){F("Operation cancelled.");return}a=m}let r=e.editors;if(!r)if(o)r=[];else{let d=await N({message:"Which editors do you want to configure (recommended)?",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1});if($(d)){F("Operation cancelled.");return}r=d}let f=e.agents,g=e.hooks,O={"vscode-copilot":"GitHub Copilot (VSCode)",cursor:"Cursor",windsurf:"Windsurf",zed:"Zed",claude:"Claude Code",codex:"OpenAI Codex / Jules / OpenCode",kiro:"Kiro IDE",cline:"Cline",amp:"AMP",aider:"Aider","firebase-studio":"Firebase Studio","open-hands":"Open Hands","gemini-cli":"Gemini CLI",junie:"Junie",augmentcode:"Augment Code","kilo-code":"Kilo Code",goose:"Codename Goose","roo-code":"Roo Code",warp:"Warp",droid:"Droid"};if(!f)if(o)f=[];else{let d=await N({message:"Which agents do you want to enable (optional)?",options:Object.entries(O).map(([m,Z])=>({value:m,label:Z})),required:!1});if($(d)){F("Operation cancelled.");return}f=d}let ye={cursor:"Cursor",claude:"Claude Code"};if(!g)if(o)g=[];else{let d=await N({message:"Which agent hooks do you want to enable (optional)?",options:Object.entries(ye).map(([m,Z])=>({value:m,label:Z})),required:!1});if($(d)){F("Operation cancelled.");return}g=d}let P=e.integrations;if(P===void 0)if(o||e.pm||e.editors||e.agents||e.hooks||e.migrate!==void 0)P=[];else{let m=await N({message:"Would you like any of the following (optional)?",options:[{label:"Husky pre-commit hook",value:"husky"},{label:"Lefthook pre-commit hook",value:"lefthook"},{label:"Lint-staged",value:"lint-staged"}],required:!1});if($(m)){F("Operation cancelled.");return}P=m}n&&await Vo(s,o),i&&await Yo(s,o),await Uo(s,!e.skipInstall,o),await Io(o),await Lo(a,o),r?.includes("vscode")&&await Jo(o),r?.includes("zed")&&await _o(o);for(let d of f??[])await Bo(d,O[d],o);for(let d of g??[])await Go(d,ye[d],o);P?.includes("husky")&&await Ho(s,!e.skipInstall,o),P?.includes("lefthook")&&await Wo(s,!e.skipInstall,o),P?.includes("lint-staged")&&await zo(s,!e.skipInstall,o),o||Q.success("Successfully initialized Ultracite configuration!")}catch(s){let n=s instanceof Error?s.message:"Unknown error";throw o||Q.error(`Failed to initialize Ultracite configuration: ${n}`),s}};var j=Ko.meta().create(),Qo=j.router({init:j.procedure.meta({description:"Initialize Ultracite in the current directory"}).input(c.object({pm:c.enum(w.packageManagers).optional().describe("Package manager to use"),editors:c.array(c.enum(w.editorConfigs)).optional().describe("Editors to configure"),agents:c.array(c.enum(w.agents)).optional().describe("Agents to enable"),hooks:c.array(c.enum(w.hooks)).optional().describe("Hooks to enable"),frameworks:c.array(c.enum(w.frameworks)).optional().describe("Frameworks being used"),integrations:c.array(c.enum(w.integrations)).optional().describe("Additional integrations to enable"),migrate:c.array(c.enum(w.migrations)).optional().describe("Migration tools to remove (e.g., eslint, prettier). Removes dependencies, config files, and editor settings."),skipInstall:c.boolean().default(!1).describe("Skip installing dependencies"),quiet:c.boolean().default(process.env.CI==="true"||process.env.CI==="1").describe("Suppress all interactive prompts and visual output. Automatically enabled in CI environments.")})).mutation(async({input:t})=>{await Qe(t)}),check:j.procedure.meta({description:"Run Biome linter without fixing files"}).input(c.tuple([c.array(c.string()).optional().default([]).describe("specific files to lint"),c.object({"diagnostic-level":c.enum(["info","warn","error"]).optional().describe("level of diagnostics to show. In order, from the lowest to the most important: info, warn, error.")})]).optional()).query(async({input:t})=>{await se(t)}),fix:j.procedure.meta({description:"Run Biome linter and fixes files"}).input(c.tuple([c.array(c.string()).optional().default([]).describe("specific files to format"),c.object({unsafe:c.boolean().optional().describe("apply unsafe fixes")})])).mutation(async({input:t})=>{let[e,o]=t;await ae(e,{unsafe:o.unsafe})}),doctor:j.procedure.meta({description:"Verify your Ultracite setup and check for issues"}).query(async()=>{await Ae()}),lint:j.procedure.meta({description:"\u26A0\uFE0F DEPRECATED: Use 'check' instead - Run Biome linter without fixing files"}).input(c.array(c.string()).optional().default([]).describe("specific files to lint")).query(async({input:t})=>{console.warn("\u26A0\uFE0F Warning: 'lint' command is deprecated. Please use 'check' instead."),await se([t,{}])}),format:j.procedure.meta({description:"\u26A0\uFE0F DEPRECATED: Use 'fix' instead - Run Biome linter and fixes files"}).input(c.tuple([c.array(c.string()).optional().default([]).describe("specific files to format"),c.object({unsafe:c.boolean().optional().describe("apply unsafe fixes")})])).mutation(async({input:t})=>{let[e,o]=t;console.warn("\u26A0\uFE0F Warning: 'format' command is deprecated. Please use 'fix' instead."),await ae(e,{unsafe:o.unsafe})})}),Zo=Xo({router:Qo,name:k.name,version:k.version,description:k.description});process.env.TEST||Zo.run();export{Qo as router};
|