ultracite 6.4.3 → 6.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/core/biome.jsonc +4 -50
- package/config/next/biome.jsonc +0 -3
- package/config/qwik/biome.jsonc +0 -4
- package/config/react/biome.jsonc +0 -3
- package/config/vue/biome.jsonc +0 -17
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/config/core/biome.jsonc
CHANGED
|
@@ -236,31 +236,8 @@
|
|
|
236
236
|
"noUnmatchableAnbSelector": "error"
|
|
237
237
|
},
|
|
238
238
|
"nursery": {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
"noDuplicatedSpreadProps": "error",
|
|
242
|
-
"noEmptySource": "error",
|
|
243
|
-
"noEqualsToNull": "error",
|
|
244
|
-
"noIncrementDecrement": {
|
|
245
|
-
"level": "error",
|
|
246
|
-
"options": {
|
|
247
|
-
"allowForLoopAfterthoughts": true
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
"noLeakedRender": "error",
|
|
251
|
-
"noMultiStr": "error",
|
|
252
|
-
"noParametersOnlyUsedInRecursion": "error",
|
|
253
|
-
"noProto": "error",
|
|
254
|
-
"noScriptUrl": "error",
|
|
255
|
-
"noShadow": "error",
|
|
256
|
-
"noSyncScripts": "error",
|
|
257
|
-
"noUndeclaredEnvVars": "error",
|
|
258
|
-
"noUnusedExpressions": "error",
|
|
259
|
-
"noUselessUndefined": "error",
|
|
260
|
-
"useConsistentArrowReturn": "error",
|
|
261
|
-
"useConsistentGraphqlDescriptions": "error",
|
|
262
|
-
"useDeprecatedDate": "error",
|
|
263
|
-
"useMaxParams": "error",
|
|
239
|
+
// Typically we don't enable nursery rules anymore (https://github.com/haydenbleasel/ultracite/issues/457)
|
|
240
|
+
// but this was requested specifically by a lot of people.
|
|
264
241
|
"useSortedClasses": {
|
|
265
242
|
"fix": "safe",
|
|
266
243
|
"level": "error",
|
|
@@ -268,30 +245,7 @@
|
|
|
268
245
|
"attributes": ["className"],
|
|
269
246
|
"functions": ["clsx", "cva", "tw", "twMerge", "cn", "twJoin", "tv"]
|
|
270
247
|
}
|
|
271
|
-
}
|
|
272
|
-
"useSpread": "error",
|
|
273
|
-
"useUniqueGraphqlOperationName": "error",
|
|
274
|
-
|
|
275
|
-
"noContinue": "off",
|
|
276
|
-
"noForIn": "off",
|
|
277
|
-
"noJsxLiterals": "off",
|
|
278
|
-
"noTernary": "off",
|
|
279
|
-
"noUselessCatchBinding": "off",
|
|
280
|
-
"useExplicitType": "off",
|
|
281
|
-
"useRequiredScripts": "off",
|
|
282
|
-
|
|
283
|
-
/** ------ Project rules use Scanner and are too slow (https://biomejs.dev/linter/domains/#project-rules) ------ **/
|
|
284
|
-
"noDeprecatedImports": "off",
|
|
285
|
-
"noFloatingPromises": "off",
|
|
286
|
-
"noMisusedPromises": "off",
|
|
287
|
-
"noUnnecessaryConditions": "off",
|
|
288
|
-
"noUnresolvedImports": "off",
|
|
289
|
-
"noImportCycles": "off",
|
|
290
|
-
"useArraySortCompare": "off",
|
|
291
|
-
"useAwaitThenable": "off",
|
|
292
|
-
"useFind": "off",
|
|
293
|
-
"useExhaustiveSwitchCases": "off",
|
|
294
|
-
"useRegexpExec": "off"
|
|
248
|
+
}
|
|
295
249
|
},
|
|
296
250
|
"performance": {
|
|
297
251
|
/** ------------------------ JavaScript Rules ------------------------ **/
|
|
@@ -352,7 +306,7 @@
|
|
|
352
306
|
"useConsistentTypeDefinitions": {
|
|
353
307
|
"level": "error",
|
|
354
308
|
"options": {
|
|
355
|
-
"style": "
|
|
309
|
+
"style": "interface"
|
|
356
310
|
}
|
|
357
311
|
},
|
|
358
312
|
"useConst": "error",
|
package/config/next/biome.jsonc
CHANGED
package/config/qwik/biome.jsonc
CHANGED
package/config/react/biome.jsonc
CHANGED
package/config/vue/biome.jsonc
CHANGED
|
@@ -12,23 +12,6 @@
|
|
|
12
12
|
"includes": ["**/*.vue"],
|
|
13
13
|
"linter": {
|
|
14
14
|
"rules": {
|
|
15
|
-
"nursery": {
|
|
16
|
-
"noVueDataObjectDeclaration": "error",
|
|
17
|
-
"noVueDuplicateKeys": "error",
|
|
18
|
-
"noVueVIfWithVFor": "error",
|
|
19
|
-
"noVueSetupPropsReactivityLoss": "error",
|
|
20
|
-
"noVueReservedKeys": "error",
|
|
21
|
-
"noVueReservedProps": "error",
|
|
22
|
-
"useVueHyphenatedAttributes": "error",
|
|
23
|
-
"useVueMultiWordComponentNames": "error",
|
|
24
|
-
"useVueValidVBind": "error",
|
|
25
|
-
"useVueValidVElseIf": "error",
|
|
26
|
-
"useVueValidVElse": "error",
|
|
27
|
-
"useVueValidVHtml": "error",
|
|
28
|
-
"useVueValidVIf": "error",
|
|
29
|
-
"useVueValidVOn": "error",
|
|
30
|
-
"useVueValidVText": "error"
|
|
31
|
-
},
|
|
32
15
|
"correctness": {
|
|
33
16
|
"noUnusedVariables": "off",
|
|
34
17
|
"noUnusedImports": "off"
|
package/dist/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ declare const router: _trpc_server.TRPCBuiltRouter<{
|
|
|
32
32
|
fix: _trpc_server.TRPCMutationProcedure<{
|
|
33
33
|
input: [string[] | undefined, {
|
|
34
34
|
unsafe?: boolean | undefined;
|
|
35
|
-
}];
|
|
35
|
+
}] | undefined;
|
|
36
36
|
output: void;
|
|
37
37
|
meta: TrpcCliMeta;
|
|
38
38
|
}>;
|
|
@@ -49,7 +49,7 @@ declare const router: _trpc_server.TRPCBuiltRouter<{
|
|
|
49
49
|
format: _trpc_server.TRPCMutationProcedure<{
|
|
50
50
|
input: [string[] | undefined, {
|
|
51
51
|
unsafe?: boolean | undefined;
|
|
52
|
-
}];
|
|
52
|
+
}] | undefined;
|
|
53
53
|
output: void;
|
|
54
54
|
meta: TrpcCliMeta;
|
|
55
55
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -137,7 +137,7 @@ ${n}`)}}});var Gs,je=F(()=>{Gs=Ee({"./husky.ts":()=>(be(),G(st)),"./lefthook.ts"
|
|
|
137
137
|
`}else t+=`${s}: '${n}'
|
|
138
138
|
`;return t},qs=async()=>{try{let e=Se(await re("./package.json","utf-8"));return e?e.type==="module":!1}catch{return!1}},en=async e=>{let t=Se(await re("./package.json","utf-8"));t&&(t["lint-staged"]?t["lint-staged"]=H(t["lint-staged"],P(e)):t["lint-staged"]=P(e),await E("./package.json",JSON.stringify(t,null,2)))},tn=async(e,t)=>{let s=await re(e,"utf-8"),n=Se(s);if(!n)return;let o=H(n,P(t));await E(e,JSON.stringify(o,null,2))},sn=async(e,t)=>{let s=await re(e,"utf-8"),n=Qs(s);if(!n)return;let o=H(n,P(t));await E(e,Zs(o))},nn=async(e,t)=>{let o=(await import(Vs(e).href)).default||{},i=H(o,P(t)),a=`export default ${JSON.stringify(i,null,2)};
|
|
139
139
|
`;await E(e,a)},on=async(e,t)=>{delete de.cache[de.resolve(`./${e}`)];let s=Gs(`./${e}`),n=H(s,P(t)),o=`module.exports = ${JSON.stringify(n,null,2)};
|
|
140
|
-
`;await E(e,o)},$e=async e=>{await E(".lintstagedrc.json",JSON.stringify(P(e),null,2))},rn=async(e,t)=>{if(e==="./package.json"){await en(t);return}if(e.endsWith(".json")||e==="./.lintstagedrc"){await tn(e,t);return}if(e.endsWith(".yaml")||e.endsWith(".yml")){await sn(e,t);return}let s=await qs();if(e.endsWith(".mjs")||e.endsWith(".js")&&s){try{await nn(e,t)}catch{await $e(t)}return}if(e.endsWith(".cjs")||e.endsWith(".js")&&!s)try{await on(e,t)}catch{await $e(t)}},D={exists:async()=>{for(let e of dt)if(await f(e))return!0;return!1},install:async e=>{await Ys("lint-staged",{packageManager:e,workspace:await C(),silent:!0})},create:async e=>{await E(".lintstagedrc.json",JSON.stringify(P(e),null,2))},update:async e=>{let t=null;for(let s of dt)if(await f(s)){t=s;break}if(!t){await $e(e);return}await rn(t,e)}}});import{initTRPC as Fn}from"@trpc/server";import{createCli as Nn}from"trpc-cli";import d from"zod";var k={name:"ultracite",description:"The AI-ready formatter that helps you write and generate code faster.",version:"6.
|
|
140
|
+
`;await E(e,o)},$e=async e=>{await E(".lintstagedrc.json",JSON.stringify(P(e),null,2))},rn=async(e,t)=>{if(e==="./package.json"){await en(t);return}if(e.endsWith(".json")||e==="./.lintstagedrc"){await tn(e,t);return}if(e.endsWith(".yaml")||e.endsWith(".yml")){await sn(e,t);return}let s=await qs();if(e.endsWith(".mjs")||e.endsWith(".js")&&s){try{await nn(e,t)}catch{await $e(t)}return}if(e.endsWith(".cjs")||e.endsWith(".js")&&!s)try{await on(e,t)}catch{await $e(t)}},D={exists:async()=>{for(let e of dt)if(await f(e))return!0;return!1},install:async e=>{await Ys("lint-staged",{packageManager:e,workspace:await C(),silent:!0})},create:async e=>{await E(".lintstagedrc.json",JSON.stringify(P(e),null,2))},update:async e=>{let t=null;for(let s of dt)if(await f(s)){t=s;break}if(!t){await $e(e);return}await rn(t,e)}}});import{initTRPC as Fn}from"@trpc/server";import{createCli as Nn}from"trpc-cli";import d from"zod";var k={name:"ultracite",description:"The AI-ready formatter that helps you write and generate code faster.",version:"6.5.1",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.10","@types/node":"^25.0.0",tsup:"^8.5.1",turbo:"^2.6.3"},dependencies:{"@clack/prompts":"^0.11.0","@trpc/server":"^11.8.0",deepmerge:"^4.3.1",glob:"^13.0.0","jsonc-parser":"^3.3.1",nypm:"^0.6.2",picocolors:"^1.1.1","trpc-cli":"^0.12.1",zod:"^4.1.13"},packageManager:"bun@1.3.4"};import{spawnSync as Mt}from"child_process";import Tt from"process";import{detectPackageManager as Ut,dlxCommand as It}from"nypm";import l from"picocolors";var b=e=>`\x1B[38;5;208m${e}\x1B[39m`,Ae=(e,t)=>{let n=e.slice(0,t[0]).split(`
|
|
141
141
|
`);return{line:n.length,column:(n.at(-1)?.length??0)+1}},xt=(e,t)=>{let s=e.split(`
|
|
142
142
|
`),{line:n,column:o}=Ae(e,t),i=[],a=Math.max(1,n-1),r=Math.min(s.length,n+2);for(let c=a;c<=r;c++){let p=String(c).padStart(5," "),u=s[c-1]||"";if(c===n){i.push(`${b(">")}${l.dim(p)} ${l.gray("\u2502")} ${u}`);let x=" ".repeat(o-1),y=Math.min(t[1]-t[0],u.length-o+1),m="^".repeat(Math.max(1,y));i.push(`${l.dim(" ")} ${l.gray("\u2502")} ${x}${b(m)}`)}else i.push(` ${l.dim(p)} ${l.gray("\u2502")} ${u}`)}return i},vt=e=>{let t=e.secs*1e3+e.nanos/1e6;return t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(2)}s`},Ct=l.dim("\u2500".repeat(60)),jt=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),Pt=e=>{let t=e.split("/");if(t.length<3||t[0]!=="lint")return null;let s=t.at(-1);return s?`https://biomejs.dev/linter/rules/${jt(s)}/`:null},$t=e=>["",`${b("Ultracite")} ${b(`v${k.version}`)} ${e}`],St=(e,t)=>{let s=[],n=e.changed+e.unchanged,o=e.errors+e.warnings,i=vt(e.duration);if(o>0){let r=o!==1?"errors":"error";s.push(`${l.dim("Found")} ${o} ${r}${l.dim(".")}`)}let a=n!==1?"files":"file";if(s.push(`${l.green("\u2713")} ${l.dim("Finished in")} ${i} ${l.dim("on")} ${n} ${a}${l.dim(".")}`),t==="fix"&&e.changed>0){let r=e.changed!==1?"files":"file";s.push(`${l.dim("Fixed")} ${e.changed} ${r}${l.dim(".")}`)}if(t==="fix"&&e.suggestedFixesSkipped>0){let r=e.suggestedFixesSkipped!==1?"fixes":"fix";s.push(`${l.yellow("!")} ${l.dim("Skipped")} ${e.suggestedFixesSkipped} ${l.dim("unsafe")} ${r}${l.dim(".")}`),s.push(` ${l.dim("Run with")} ${l.cyan("--unsafe")} ${l.dim("to apply them.")}`)}return s},Rt=e=>{let t=[],{location:s,category:n,description:o,advices:i}=e,a=s.path.file,r=a;if(s.span&&s.sourceCode){let{line:p,column:u}=Ae(s.sourceCode,s.span);r=`${a}:${p}:${u}`}if(t.push(`${b(r)} ${l.dim(n)}`),t.push(l.dim(o)),s.span&&s.sourceCode){t.push("");let p=xt(s.sourceCode,s.span);for(let u of p)t.push(` ${u}`)}for(let p of i.advices)if(p.log){let[u,x]=p.log,y=b(u==="info"?"i":"!"),m=l.dim(x.map(g=>g.content).join(""));t.push(""),t.push(` ${y} ${m}`)}let c=Pt(n);return c&&(t.push(""),t.push(` ${l.cyan("\u2192")} ${l.dim("Docs:")} ${l.cyan(c)}`)),t.push(""),t.push(`${Ct}`),t.push(""),t},Et=(e,t)=>{if(e.length===0)return[];let s=[""],n=t==="fix"?"Here are the issues we couldn't fix automatically:":"Issues found:";s.push(`${l.yellow(n)}`),s.push("");for(let o of e)s.push(...Rt(o));return s},V=(e,t)=>{if(!e.trim())return{output:`${b("Ultracite")} ${b(`v${k.version}`)} ${l.magenta(t)}
|
|
143
143
|
${l.red("Error:")} No output received from Biome. The command may have failed silently.`,hasErrors:!0};try{let s=JSON.parse(e),{summary:n,diagnostics:o}=s;return{output:[...$t(t),...St(n,t),...Et(o,t)].join(`
|
|
@@ -278,4 +278,4 @@ Most formatting and common issues are automatically fixed by Biome. Run \`${e} u
|
|
|
278
278
|
|
|
279
279
|
${o}`:o,a=async()=>{let r=us(s.path);if(r!=="."){let c=r.startsWith("./")?r.slice(2):r;await ms(c,{recursive:!0})}};return{exists:()=>f(s.path),create:async()=>{await a(),await ee(s.path,i)},update:async()=>{if(await a(),s.appendMode){if(!await f(s.path)){await ee(s.path,i);return}let r=await ps(s.path,"utf-8");if(r.includes(o.trim()))return;await ee(s.path,`${r}
|
|
280
280
|
|
|
281
|
-
${o}`)}else await ee(s.path,i)}}};h();import{readFile as hs,writeFile as Ge}from"fs/promises";import ys from"deepmerge";import{parse as ws}from"jsonc-parser";var Ve={$schema:"./node_modules/@biomejs/biome/configuration_schema.json",extends:["ultracite/core"]},he=async()=>await f("./biome.json")?"./biome.json":"./biome.jsonc",te={exists:async()=>{let e=await he();return f(e)},create:async e=>{let t=await he(),s=["ultracite/core"];if(e?.frameworks&&e.frameworks.length>0)for(let o of e.frameworks)s.push(`ultracite/${o}`);let n={...Ve,extends:s};return Ge(t,JSON.stringify(n,null,2))},update:async e=>{let t=await he(),s=await hs(t,"utf-8"),o=ws(s)||{},a=[...o.extends&&Array.isArray(o.extends)?o.extends:[]];if(a.includes("ultracite/core")||a.push("ultracite/core"),e?.frameworks&&e.frameworks.length>0)for(let p of e.frameworks){let u=`ultracite/${p}`;a.includes(u)||a.push(u)}o.extends=a;let r={$schema:Ve.$schema},c=ys(o,r);await Ge(t,JSON.stringify(c,null,2))}};h();import{spawnSync as ks}from"child_process";import{mkdir as bs,readFile as xs,writeFile as Ye}from"fs/promises";import vs from"deepmerge";import{parse as Cs}from"jsonc-parser";var ye={"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 se="./.vscode/settings.json",J={exists:()=>f(se),create:async()=>{await bs(".vscode",{recursive:!0}),await Ye(se,JSON.stringify(ye,null,2))},update:async()=>{let e=await xs(se,"utf-8"),s=Cs(e)||{},n=vs(s,ye);await Ye(se,JSON.stringify(n,null,2))},extension:()=>ks("code --install-extension biomejs.biome",{stdio:"pipe",shell:!0})};h();import{mkdir as js,readFile as Ps,writeFile as Ke}from"fs/promises";import $s from"deepmerge";import{parse as Ss}from"jsonc-parser";var we={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 ne="./.zed/settings.json",oe={exists:()=>f(ne),create:async()=>{await js(".zed",{recursive:!0}),await Ke(ne,JSON.stringify(we,null,2))},update:async()=>{let e=await Ps(ne,"utf-8"),s=Ss(e)||{},n=$s(s,we);await Ke(ne,JSON.stringify(n,null,2))}};import{mkdir as Rs,readFile as Xe,writeFile as N}from"fs/promises";import{dirname as Es}from"path";import{dlxCommand as As}from"nypm";h();var Qe=e=>({version:1,hooks:{afterFileEdit:[{command:e}]}}),Ze=e=>({hooks:{PostToolUse:[{matcher:"Edit|Write",hooks:[{type:"command",command:e}]}]}}),Fs=async(e,t)=>{if(!await f(e)){await N(e,JSON.stringify(Qe(t),null,2));return}let s=await Xe(e,"utf-8"),n=JSON.parse(s);n.hooks.afterFileEdit.some(i=>i.command.includes("ultracite"))||(n.hooks.afterFileEdit.push({command:t}),await N(e,JSON.stringify(n,null,2)))},Ns=async(e,t)=>{if(!await f(e)){await N(e,JSON.stringify(Ze(t),null,2));return}let s=await Xe(e,"utf-8"),n=JSON.parse(s);n.hooks||(n.hooks={}),n.hooks.PostToolUse||(n.hooks.PostToolUse=[]),n.hooks.PostToolUse.some(i=>i.hooks?.some(a=>a.command.includes("ultracite")))||(n.hooks.PostToolUse.push({matcher:"Edit|Write",hooks:[{type:"command",command:t}]}),await N(e,JSON.stringify(n,null,2)))},qe=(e,t)=>{let s=We[e],n=As(t,"ultracite",{args:["fix"],short:t==="npm"}),o=async()=>{let i=Es(s.path);if(i!=="."){let a=i.startsWith("./")?i.slice(2):i;await Rs(a,{recursive:!0})}};return{exists:()=>f(s.path),create:async()=>{await o(),e==="cursor"?await N(s.path,JSON.stringify(Qe(n),null,2)):e==="claude"&&await N(s.path,JSON.stringify(Ze(n),null,2))},update:async()=>{await o(),e==="cursor"?await Fs(s.path,n):e==="claude"&&await Ns(s.path,n)}}};be();xe();Pe();Ce();import{readFile as an,writeFile as ft}from"fs/promises";import{glob as cn}from"glob";import{applyEdits as ln,modify as dn,parse as fn}from"jsonc-parser";var mt=async()=>{try{return await cn("**/tsconfig*.json",{ignore:["**/node_modules/**","**/dist/**","**/build/**","**/.next/**"],absolute:!1})}catch{return[]}},mn=e=>{if(!e)return!1;let t=e.compilerOptions;return t?t.strict===!0||t.strictNullChecks===!0:!1},pn=async e=>{try{let t=await an(e,"utf-8"),s=fn(t);if(mn(s))return;if(s===void 0){await ft(e,JSON.stringify({compilerOptions:{strictNullChecks:!0}},null,2));return}let o=dn(t,["compilerOptions","strictNullChecks"],!0,{formattingOptions:{tabSize:2,insertSpaces:!0}}),i=ln(t,o);await ft(e,i)}catch(t){console.warn(`Failed to update ${e}:`,t)}},Re={exists:async()=>(await mt()).length>0,update:async()=>{let e=await mt();if(e.length===0){console.warn("No tsconfig.json files found in the project");return}await Promise.all(e.map(t=>pn(t)))}};h();var pt=k.devDependencies["@biomejs/biome"],ut=k.version,wn=async(e,t=!0,s=!1)=>{let n=w();s||n.start("Installing dependencies...");let o=[`ultracite@${ut}`,`@biomejs/biome@${pt}`];if(t)for(let i of o)await hn(i,{packageManager:e,workspace:await C(),silent:!0});else await v({devDependencies:{"@biomejs/biome":pt,ultracite:ut}});s||n.stop("Dependencies installed.")},kn=async(e=!1)=>{let t=w();if(e||t.start("Checking for tsconfig.json files..."),await Re.exists()){e||t.message("Found tsconfig.json files, updating with strictNullChecks..."),await Re.update(),e||t.stop("tsconfig.json files updated.");return}e||t.stop("No tsconfig.json files found, skipping.")},bn=async(e=!1)=>{let t=w();if(e||t.start("Checking for .vscode/settings.json..."),await J.exists()){e||t.message("settings.json found, updating..."),await J.update(),e||t.stop("settings.json updated.");return}e||t.message("settings.json not found, creating..."),await J.create(),e||(t.message("settings.json created."),t.message("Installing Biome extension..."));try{let s=J.extension();e||(s.status===0?t.stop("settings.json created and Biome extension installed."):t.stop("settings.json created. Install Biome extension manually."))}catch{e||t.stop("settings.json created. Install Biome extension manually.")}},xn=async(e=!1)=>{let t=w();if(e||t.start("Checking for .zed/settings.json..."),await oe.exists()){e||t.message("settings.json found, updating..."),await oe.update(),e||t.stop("settings.json updated.");return}e||t.message("settings.json not found, creating..."),await oe.create(),e||t.message("settings.json created. Install the Biome extension: https://biomejs.dev/reference/zed/")},vn=async(e,t=!1)=>{let s=w();if(t||s.start("Checking for Biome configuration..."),await te.exists()){t||s.message("Biome configuration found, updating..."),await te.update({frameworks:e}),t||s.stop("Biome configuration updated.");return}t||s.message("Biome configuration not found, creating..."),await te.create({frameworks:e}),t||s.stop("Biome configuration created.")},Cn=async(e,t=!0,s=!1)=>{let n=w();if(s||(n.start("Initializing pre-commit hooks..."),n.message("Installing Husky...")),t?await S.install(e):await v({devDependencies:{husky:"latest"},scripts:{prepare:"husky"}}),s||n.message("Initializing Husky..."),S.init(e),await S.exists()){s||n.message("Pre-commit hook found, updating..."),await S.update(e),s||n.stop("Pre-commit hook updated.");return}s||n.message("Pre-commit hook not found, creating..."),await S.create(e),s||n.stop("Pre-commit hook created.")},jn=async(e,t=!0,s=!1)=>{let n=w();if(s||(n.start("Initializing lefthook..."),n.message("Installing lefthook...")),t?await O.install(e):await v({devDependencies:{lefthook:"latest"}}),await O.exists()){s||n.message("lefthook.yml found, updating..."),await O.update(e),s||n.stop("lefthook.yml updated.");return}s||n.message("lefthook.yml not found, creating..."),await O.create(e),s||n.stop("lefthook.yml created.")},Pn=async(e,t=!0,s=!1)=>{let n=w();if(s||(n.start("Initializing lint-staged..."),n.message("Installing lint-staged...")),t?await D.install(e):await v({devDependencies:{"lint-staged":"latest"}}),await D.exists()){s||n.message("lint-staged found, updating..."),await D.update(e),s||n.stop("lint-staged updated.");return}s||n.message("lint-staged not found, creating..."),await D.create(e),s||n.stop("lint-staged created.")},$n=async(e,t=!1)=>{let s=w();if(t||s.start("Initializing pre-commit..."),await W.exists()){t||s.message(".pre-commit-config.yaml found, updating..."),await W.update(e),t||s.stop(".pre-commit-config.yaml updated.");return}t||s.message(".pre-commit-config.yaml not found, creating..."),await W.create(e),t||s.stop(".pre-commit-config.yaml created.")},Sn=async(e,t,s,n=!1)=>{let o=w();n||o.start(`Checking for ${t}...`);let i=ze(e,s);if(await i.exists()){n||o.message(`${t} found, updating...`),await i.update(),n||o.stop(`${t} updated.`);return}n||o.message(`${t} not found, creating...`),await i.create(),n||o.stop(`${t} created.`)},Rn=async(e,t,s,n=!1)=>{let o=w();n||o.start(`Checking for ${t} hooks...`);let i=qe(e,s);if(await i.exists()){n||o.message(`${t} hooks found, updating...`),await i.update(),n||o.stop(`${t} hooks updated.`);return}n||o.message(`${t} hooks not found, creating...`),await i.create(),n||o.stop(`${t} hooks created.`)},En=async(e,t=!1)=>{let s=w();t||s.start("Removing Prettier dependencies and configuration...");try{let n=await pe.remove(e);t||(n.packagesRemoved.length>0&&s.message(`Removed Prettier packages: ${n.packagesRemoved.join(", ")}`),n.filesRemoved.length>0&&s.message(`Removed config files: ${n.filesRemoved.join(", ")}`),n.vsCodeCleaned&&s.message("Cleaned VS Code settings"),s.stop("Prettier removed successfully."))}catch{t||s.stop("Failed to remove Prettier completely, but continuing...")}},An=async(e,t=!1)=>{let s=w();t||s.start("Removing ESLint dependencies and configuration...");try{let n=await me.remove(e);t||(n.packagesRemoved.length>0&&s.message(`Removed ESLint packages: ${n.packagesRemoved.join(", ")}`),n.filesRemoved.length>0&&s.message(`Removed config files: ${n.filesRemoved.join(", ")}`),n.vsCodeCleaned&&s.message("Cleaned VS Code settings"),s.stop("ESLint removed successfully."))}catch{t||s.stop("Failed to remove ESLint completely, but continuing...")}},gt=async e=>{let t=e??{},s=t.quiet??!1;s||gn(Y);try{let{pm:n}=t;if(!n){let m=await yn(un.cwd());if(!m)throw new Error("No package manager specified or detected");if(!s&&m.warnings)for(let g of m.warnings)ae.warn(g);s||ae.info(`Detected lockfile, using ${m.name}`),n=m.name}let o=t.migrate?.includes("prettier"),i=t.migrate?.includes("eslint");if(!s&&(o===void 0||i===void 0)){let m=[];if(o===void 0&&await pe.hasPrettier()&&m.push({label:"Remove Prettier (dependencies, config files, VS Code settings)",value:"prettier"}),i===void 0&&await me.hasEsLint()&&m.push({label:"Remove ESLint (dependencies, config files, VS Code settings)",value:"eslint"}),m.length>0){let g=await U({message:"Remove existing formatters/linters (recommended for clean migration)?",options:m,required:!1});if(T(g)){M("Operation cancelled.");return}o===void 0&&(o=g.includes("prettier")),i===void 0&&(i=g.includes("eslint"))}}s&&(o===void 0&&(o=!1),i===void 0&&(i=!1));let a=t.frameworks;if(a===void 0)if(s||t.pm||t.editors||t.agents||t.hooks||t.integrations!==void 0||t.migrate!==void 0)a=[];else{let g=await U({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(T(g)){M("Operation cancelled.");return}a=g}let r=t.editors;if(!r)if(s)r=[];else{let m=await U({message:"Which editors do you want to configure (recommended)?",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1});if(T(m)){M("Operation cancelled.");return}r=m}let c=t.agents,p=t.hooks,u={"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",antigravity:"Antigravity"};if(!c)if(s)c=[];else{let m=await U({message:"Which agents do you want to enable (optional)?",options:Object.entries(u).map(([g,ce])=>({value:g,label:ce})),required:!1});if(T(m)){M("Operation cancelled.");return}c=m}let x={cursor:"Cursor",claude:"Claude Code"};if(!p)if(s)p=[];else{let m=await U({message:"Which agent hooks do you want to enable (optional)?",options:Object.entries(x).map(([g,ce])=>({value:g,label:ce})),required:!1});if(T(m)){M("Operation cancelled.");return}p=m}let y=t.integrations;if(y===void 0)if(s||t.pm||t.editors||t.agents||t.hooks||t.migrate!==void 0)y=[];else{let g=await U({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"},{label:"pre-commit (Python framework)",value:"pre-commit"}],required:!1});if(T(g)){M("Operation cancelled.");return}y=g}o&&await En(n,s),i&&await An(n,s),await wn(n,!t.skipInstall,s),await kn(s),await vn(a,s),r?.includes("vscode")&&await bn(s),r?.includes("zed")&&await xn(s);for(let m of c??[])await Sn(m,u[m],n,s);for(let m of p??[])await Rn(m,x[m],n,s);y?.includes("husky")&&await Cn(n,!t.skipInstall,s),y?.includes("lefthook")&&await jn(n,!t.skipInstall,s),y?.includes("lint-staged")&&await Pn(n,!t.skipInstall,s),y?.includes("pre-commit")&&await $n(n,s),s||ae.success("Successfully initialized Ultracite configuration!")}catch(n){let o=n instanceof Error?n.message:"Unknown error";throw s||ae.error(`Failed to initialize Ultracite configuration: ${o}`),n}};var A=Fn.meta().create(),On=A.router({init:A.procedure.meta({description:"Initialize Ultracite in the current directory"}).input(d.object({pm:d.enum(j.packageManagers).optional().describe("Package manager to use"),editors:d.array(d.enum(j.editorConfigs)).optional().describe("Editors to configure"),agents:d.array(d.enum(j.agents)).optional().describe("Agents to enable"),hooks:d.array(d.enum(j.hooks)).optional().describe("Hooks to enable"),frameworks:d.array(d.enum(j.frameworks)).optional().describe("Frameworks being used"),integrations:d.array(d.enum(j.integrations)).optional().describe("Additional integrations to enable"),migrate:d.array(d.enum(j.migrations)).optional().describe("Migration tools to remove (e.g., eslint, prettier). Removes dependencies, config files, and editor settings."),skipInstall:d.boolean().default(!1).describe("Skip installing dependencies"),quiet:d.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:e})=>{await gt(e)}),check:A.procedure.meta({description:"Run Biome linter without fixing files"}).input(d.tuple([d.array(d.string()).optional().default([]).describe("specific files to lint"),d.object({"diagnostic-level":d.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:e})=>{await fe(e)}),fix:A.procedure.meta({description:"Run Biome linter and fixes files"}).input(d.tuple([d.array(d.string()).optional().default([]).describe("specific files to format"),d.object({unsafe:d.boolean().optional().describe("apply unsafe fixes")})])).mutation(async({input:e})=>{let[t,s]=e;await ge(t,{unsafe:s.unsafe})}),doctor:A.procedure.meta({description:"Verify your Ultracite setup and check for issues"}).query(async()=>{await Be()}),lint:A.procedure.meta({description:"\u26A0\uFE0F DEPRECATED: Use 'check' instead - Run Biome linter without fixing files"}).input(d.array(d.string()).optional().default([]).describe("specific files to lint")).query(async({input:e})=>{console.warn("\u26A0\uFE0F Warning: 'lint' command is deprecated. Please use 'check' instead."),await fe([e,{}])}),format:A.procedure.meta({description:"\u26A0\uFE0F DEPRECATED: Use 'fix' instead - Run Biome linter and fixes files"}).input(d.tuple([d.array(d.string()).optional().default([]).describe("specific files to format"),d.object({unsafe:d.boolean().optional().describe("apply unsafe fixes")})])).mutation(async({input:e})=>{let[t,s]=e;console.warn("\u26A0\uFE0F Warning: 'format' command is deprecated. Please use 'fix' instead."),await ge(t,{unsafe:s.unsafe})})}),Dn=Nn({router:On,name:k.name,version:k.version,description:k.description});process.env.TEST||Dn.run();export{On as router};
|
|
281
|
+
${o}`)}else await ee(s.path,i)}}};h();import{readFile as hs,writeFile as Ge}from"fs/promises";import ys from"deepmerge";import{parse as ws}from"jsonc-parser";var Ve={$schema:"./node_modules/@biomejs/biome/configuration_schema.json",extends:["ultracite/core"]},he=async()=>await f("./biome.json")?"./biome.json":"./biome.jsonc",te={exists:async()=>{let e=await he();return f(e)},create:async e=>{let t=await he(),s=["ultracite/core"];if(e?.frameworks&&e.frameworks.length>0)for(let o of e.frameworks)s.push(`ultracite/${o}`);let n={...Ve,extends:s};return Ge(t,JSON.stringify(n,null,2))},update:async e=>{let t=await he(),s=await hs(t,"utf-8"),o=ws(s)||{},a=[...o.extends&&Array.isArray(o.extends)?o.extends:[]];if(a.includes("ultracite/core")||a.push("ultracite/core"),e?.frameworks&&e.frameworks.length>0)for(let p of e.frameworks){let u=`ultracite/${p}`;a.includes(u)||a.push(u)}o.extends=a;let r={$schema:Ve.$schema},c=ys(o,r);await Ge(t,JSON.stringify(c,null,2))}};h();import{spawnSync as ks}from"child_process";import{mkdir as bs,readFile as xs,writeFile as Ye}from"fs/promises";import vs from"deepmerge";import{parse as Cs}from"jsonc-parser";var ye={"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 se="./.vscode/settings.json",J={exists:()=>f(se),create:async()=>{await bs(".vscode",{recursive:!0}),await Ye(se,JSON.stringify(ye,null,2))},update:async()=>{let e=await xs(se,"utf-8"),s=Cs(e)||{},n=vs(s,ye);await Ye(se,JSON.stringify(n,null,2))},extension:()=>ks("code --install-extension biomejs.biome",{stdio:"pipe",shell:!0})};h();import{mkdir as js,readFile as Ps,writeFile as Ke}from"fs/promises";import $s from"deepmerge";import{parse as Ss}from"jsonc-parser";var we={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 ne="./.zed/settings.json",oe={exists:()=>f(ne),create:async()=>{await js(".zed",{recursive:!0}),await Ke(ne,JSON.stringify(we,null,2))},update:async()=>{let e=await Ps(ne,"utf-8"),s=Ss(e)||{},n=$s(s,we);await Ke(ne,JSON.stringify(n,null,2))}};import{mkdir as Rs,readFile as Xe,writeFile as N}from"fs/promises";import{dirname as Es}from"path";import{dlxCommand as As}from"nypm";h();var Qe=e=>({version:1,hooks:{afterFileEdit:[{command:e}]}}),Ze=e=>({hooks:{PostToolUse:[{matcher:"Edit|Write",hooks:[{type:"command",command:e}]}]}}),Fs=async(e,t)=>{if(!await f(e)){await N(e,JSON.stringify(Qe(t),null,2));return}let s=await Xe(e,"utf-8"),n=JSON.parse(s);n.hooks.afterFileEdit.some(i=>i.command.includes("ultracite"))||(n.hooks.afterFileEdit.push({command:t}),await N(e,JSON.stringify(n,null,2)))},Ns=async(e,t)=>{if(!await f(e)){await N(e,JSON.stringify(Ze(t),null,2));return}let s=await Xe(e,"utf-8"),n=JSON.parse(s);n.hooks||(n.hooks={}),n.hooks.PostToolUse||(n.hooks.PostToolUse=[]),n.hooks.PostToolUse.some(i=>i.hooks?.some(a=>a.command.includes("ultracite")))||(n.hooks.PostToolUse.push({matcher:"Edit|Write",hooks:[{type:"command",command:t}]}),await N(e,JSON.stringify(n,null,2)))},qe=(e,t)=>{let s=We[e],n=As(t,"ultracite",{args:["fix"],short:t==="npm"}),o=async()=>{let i=Es(s.path);if(i!=="."){let a=i.startsWith("./")?i.slice(2):i;await Rs(a,{recursive:!0})}};return{exists:()=>f(s.path),create:async()=>{await o(),e==="cursor"?await N(s.path,JSON.stringify(Qe(n),null,2)):e==="claude"&&await N(s.path,JSON.stringify(Ze(n),null,2))},update:async()=>{await o(),e==="cursor"?await Fs(s.path,n):e==="claude"&&await Ns(s.path,n)}}};be();xe();Pe();Ce();import{readFile as an,writeFile as ft}from"fs/promises";import{glob as cn}from"glob";import{applyEdits as ln,modify as dn,parse as fn}from"jsonc-parser";var mt=async()=>{try{return await cn("**/tsconfig*.json",{ignore:["**/node_modules/**","**/dist/**","**/build/**","**/.next/**"],absolute:!1})}catch{return[]}},mn=e=>{if(!e)return!1;let t=e.compilerOptions;return t?t.strict===!0||t.strictNullChecks===!0:!1},pn=async e=>{try{let t=await an(e,"utf-8"),s=fn(t);if(mn(s))return;if(s===void 0){await ft(e,JSON.stringify({compilerOptions:{strictNullChecks:!0}},null,2));return}let o=dn(t,["compilerOptions","strictNullChecks"],!0,{formattingOptions:{tabSize:2,insertSpaces:!0}}),i=ln(t,o);await ft(e,i)}catch(t){console.warn(`Failed to update ${e}:`,t)}},Re={exists:async()=>(await mt()).length>0,update:async()=>{let e=await mt();if(e.length===0){console.warn("No tsconfig.json files found in the project");return}await Promise.all(e.map(t=>pn(t)))}};h();var pt=k.devDependencies["@biomejs/biome"],ut=k.version,wn=async(e,t=!0,s=!1)=>{let n=w();s||n.start("Installing dependencies...");let o=[`ultracite@${ut}`,`@biomejs/biome@${pt}`];if(t)for(let i of o)await hn(i,{packageManager:e,workspace:await C(),silent:!0});else await v({devDependencies:{"@biomejs/biome":pt,ultracite:ut}});s||n.stop("Dependencies installed.")},kn=async(e=!1)=>{let t=w();if(e||t.start("Checking for tsconfig.json files..."),await Re.exists()){e||t.message("Found tsconfig.json files, updating with strictNullChecks..."),await Re.update(),e||t.stop("tsconfig.json files updated.");return}e||t.stop("No tsconfig.json files found, skipping.")},bn=async(e=!1)=>{let t=w();if(e||t.start("Checking for .vscode/settings.json..."),await J.exists()){e||t.message("settings.json found, updating..."),await J.update(),e||t.stop("settings.json updated.");return}e||t.message("settings.json not found, creating..."),await J.create(),e||(t.message("settings.json created."),t.message("Installing Biome extension..."));try{let s=J.extension();e||(s.status===0?t.stop("settings.json created and Biome extension installed."):t.stop("settings.json created. Install Biome extension manually."))}catch{e||t.stop("settings.json created. Install Biome extension manually.")}},xn=async(e=!1)=>{let t=w();if(e||t.start("Checking for .zed/settings.json..."),await oe.exists()){e||t.message("settings.json found, updating..."),await oe.update(),e||t.stop("settings.json updated.");return}e||t.message("settings.json not found, creating..."),await oe.create(),e||t.message("settings.json created. Install the Biome extension: https://biomejs.dev/reference/zed/")},vn=async(e,t=!1)=>{let s=w();if(t||s.start("Checking for Biome configuration..."),await te.exists()){t||s.message("Biome configuration found, updating..."),await te.update({frameworks:e}),t||s.stop("Biome configuration updated.");return}t||s.message("Biome configuration not found, creating..."),await te.create({frameworks:e}),t||s.stop("Biome configuration created.")},Cn=async(e,t=!0,s=!1)=>{let n=w();if(s||(n.start("Initializing pre-commit hooks..."),n.message("Installing Husky...")),t?await S.install(e):await v({devDependencies:{husky:"latest"},scripts:{prepare:"husky"}}),s||n.message("Initializing Husky..."),S.init(e),await S.exists()){s||n.message("Pre-commit hook found, updating..."),await S.update(e),s||n.stop("Pre-commit hook updated.");return}s||n.message("Pre-commit hook not found, creating..."),await S.create(e),s||n.stop("Pre-commit hook created.")},jn=async(e,t=!0,s=!1)=>{let n=w();if(s||(n.start("Initializing lefthook..."),n.message("Installing lefthook...")),t?await O.install(e):await v({devDependencies:{lefthook:"latest"}}),await O.exists()){s||n.message("lefthook.yml found, updating..."),await O.update(e),s||n.stop("lefthook.yml updated.");return}s||n.message("lefthook.yml not found, creating..."),await O.create(e),s||n.stop("lefthook.yml created.")},Pn=async(e,t=!0,s=!1)=>{let n=w();if(s||(n.start("Initializing lint-staged..."),n.message("Installing lint-staged...")),t?await D.install(e):await v({devDependencies:{"lint-staged":"latest"}}),await D.exists()){s||n.message("lint-staged found, updating..."),await D.update(e),s||n.stop("lint-staged updated.");return}s||n.message("lint-staged not found, creating..."),await D.create(e),s||n.stop("lint-staged created.")},$n=async(e,t=!1)=>{let s=w();if(t||s.start("Initializing pre-commit..."),await W.exists()){t||s.message(".pre-commit-config.yaml found, updating..."),await W.update(e),t||s.stop(".pre-commit-config.yaml updated.");return}t||s.message(".pre-commit-config.yaml not found, creating..."),await W.create(e),t||s.stop(".pre-commit-config.yaml created.")},Sn=async(e,t,s,n=!1)=>{let o=w();n||o.start(`Checking for ${t}...`);let i=ze(e,s);if(await i.exists()){n||o.message(`${t} found, updating...`),await i.update(),n||o.stop(`${t} updated.`);return}n||o.message(`${t} not found, creating...`),await i.create(),n||o.stop(`${t} created.`)},Rn=async(e,t,s,n=!1)=>{let o=w();n||o.start(`Checking for ${t} hooks...`);let i=qe(e,s);if(await i.exists()){n||o.message(`${t} hooks found, updating...`),await i.update(),n||o.stop(`${t} hooks updated.`);return}n||o.message(`${t} hooks not found, creating...`),await i.create(),n||o.stop(`${t} hooks created.`)},En=async(e,t=!1)=>{let s=w();t||s.start("Removing Prettier dependencies and configuration...");try{let n=await pe.remove(e);t||(n.packagesRemoved.length>0&&s.message(`Removed Prettier packages: ${n.packagesRemoved.join(", ")}`),n.filesRemoved.length>0&&s.message(`Removed config files: ${n.filesRemoved.join(", ")}`),n.vsCodeCleaned&&s.message("Cleaned VS Code settings"),s.stop("Prettier removed successfully."))}catch{t||s.stop("Failed to remove Prettier completely, but continuing...")}},An=async(e,t=!1)=>{let s=w();t||s.start("Removing ESLint dependencies and configuration...");try{let n=await me.remove(e);t||(n.packagesRemoved.length>0&&s.message(`Removed ESLint packages: ${n.packagesRemoved.join(", ")}`),n.filesRemoved.length>0&&s.message(`Removed config files: ${n.filesRemoved.join(", ")}`),n.vsCodeCleaned&&s.message("Cleaned VS Code settings"),s.stop("ESLint removed successfully."))}catch{t||s.stop("Failed to remove ESLint completely, but continuing...")}},gt=async e=>{let t=e??{},s=t.quiet??!1;s||gn(Y);try{let{pm:n}=t;if(!n){let m=await yn(un.cwd());if(!m)throw new Error("No package manager specified or detected");if(!s&&m.warnings)for(let g of m.warnings)ae.warn(g);s||ae.info(`Detected lockfile, using ${m.name}`),n=m.name}let o=t.migrate?.includes("prettier"),i=t.migrate?.includes("eslint");if(!s&&(o===void 0||i===void 0)){let m=[];if(o===void 0&&await pe.hasPrettier()&&m.push({label:"Remove Prettier (dependencies, config files, VS Code settings)",value:"prettier"}),i===void 0&&await me.hasEsLint()&&m.push({label:"Remove ESLint (dependencies, config files, VS Code settings)",value:"eslint"}),m.length>0){let g=await U({message:"Remove existing formatters/linters (recommended for clean migration)?",options:m,required:!1});if(T(g)){M("Operation cancelled.");return}o===void 0&&(o=g.includes("prettier")),i===void 0&&(i=g.includes("eslint"))}}s&&(o===void 0&&(o=!1),i===void 0&&(i=!1));let a=t.frameworks;if(a===void 0)if(s||t.pm||t.editors||t.agents||t.hooks||t.integrations!==void 0||t.migrate!==void 0)a=[];else{let g=await U({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(T(g)){M("Operation cancelled.");return}a=g}let r=t.editors;if(!r)if(s)r=[];else{let m=await U({message:"Which editors do you want to configure (recommended)?",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1});if(T(m)){M("Operation cancelled.");return}r=m}let c=t.agents,p=t.hooks,u={"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",antigravity:"Antigravity"};if(!c)if(s)c=[];else{let m=await U({message:"Which agents do you want to enable (optional)?",options:Object.entries(u).map(([g,ce])=>({value:g,label:ce})),required:!1});if(T(m)){M("Operation cancelled.");return}c=m}let x={cursor:"Cursor",claude:"Claude Code"};if(!p)if(s)p=[];else{let m=await U({message:"Which agent hooks do you want to enable (optional)?",options:Object.entries(x).map(([g,ce])=>({value:g,label:ce})),required:!1});if(T(m)){M("Operation cancelled.");return}p=m}let y=t.integrations;if(y===void 0)if(s||t.pm||t.editors||t.agents||t.hooks||t.migrate!==void 0)y=[];else{let g=await U({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"},{label:"pre-commit (Python framework)",value:"pre-commit"}],required:!1});if(T(g)){M("Operation cancelled.");return}y=g}o&&await En(n,s),i&&await An(n,s),await wn(n,!t.skipInstall,s),await kn(s),await vn(a,s),r?.includes("vscode")&&await bn(s),r?.includes("zed")&&await xn(s);for(let m of c??[])await Sn(m,u[m],n,s);for(let m of p??[])await Rn(m,x[m],n,s);y?.includes("husky")&&await Cn(n,!t.skipInstall,s),y?.includes("lefthook")&&await jn(n,!t.skipInstall,s),y?.includes("lint-staged")&&await Pn(n,!t.skipInstall,s),y?.includes("pre-commit")&&await $n(n,s),s||ae.success("Successfully initialized Ultracite configuration!")}catch(n){let o=n instanceof Error?n.message:"Unknown error";throw s||ae.error(`Failed to initialize Ultracite configuration: ${o}`),n}};var A=Fn.meta().create(),On=A.router({init:A.procedure.meta({description:"Initialize Ultracite in the current directory"}).input(d.object({pm:d.enum(j.packageManagers).optional().describe("Package manager to use"),editors:d.array(d.enum(j.editorConfigs)).optional().describe("Editors to configure"),agents:d.array(d.enum(j.agents)).optional().describe("Agents to enable"),hooks:d.array(d.enum(j.hooks)).optional().describe("Hooks to enable"),frameworks:d.array(d.enum(j.frameworks)).optional().describe("Frameworks being used"),integrations:d.array(d.enum(j.integrations)).optional().describe("Additional integrations to enable"),migrate:d.array(d.enum(j.migrations)).optional().describe("Migration tools to remove (e.g., eslint, prettier). Removes dependencies, config files, and editor settings."),skipInstall:d.boolean().default(!1).describe("Skip installing dependencies"),quiet:d.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:e})=>{await gt(e)}),check:A.procedure.meta({description:"Run Biome linter without fixing files"}).input(d.tuple([d.array(d.string()).optional().default([]).describe("specific files to lint"),d.object({"diagnostic-level":d.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:e})=>{await fe(e)}),fix:A.procedure.meta({description:"Run Biome linter and fixes files"}).input(d.tuple([d.array(d.string()).optional().default([]).describe("specific files to format"),d.object({unsafe:d.boolean().optional().describe("apply unsafe fixes")})]).optional()).mutation(async({input:e})=>{let[t,s]=e??[[],{}];await ge(t,{unsafe:s.unsafe})}),doctor:A.procedure.meta({description:"Verify your Ultracite setup and check for issues"}).query(async()=>{await Be()}),lint:A.procedure.meta({description:"\u26A0\uFE0F DEPRECATED: Use 'check' instead - Run Biome linter without fixing files"}).input(d.array(d.string()).optional().default([]).describe("specific files to lint")).query(async({input:e})=>{console.warn("\u26A0\uFE0F Warning: 'lint' command is deprecated. Please use 'check' instead."),await fe([e,{}])}),format:A.procedure.meta({description:"\u26A0\uFE0F DEPRECATED: Use 'fix' instead - Run Biome linter and fixes files"}).input(d.tuple([d.array(d.string()).optional().default([]).describe("specific files to format"),d.object({unsafe:d.boolean().optional().describe("apply unsafe fixes")})]).optional()).mutation(async({input:e})=>{let[t,s]=e??[[],{}];console.warn("\u26A0\uFE0F Warning: 'format' command is deprecated. Please use 'fix' instead."),await ge(t,{unsafe:s.unsafe})})}),Dn=Nn({router:On,name:k.name,version:k.version,description:k.description});process.env.TEST||Dn.run();export{On as router};
|