ultracite 6.3.5 → 6.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +26 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var Z=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var qe=Object.prototype.hasOwnProperty;var q=(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')}),ye=t=>e=>{var o=t[e];if(o)return o();throw new Error("Module not found in bundle: "+e)};var O=(t,e)=>()=>(t&&(e=t(t=0)),e);var ee=(t,e)=>{for(var o in e)Z(t,o,{get:e[o],enumerable:!0})},et=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ze(e))!qe.call(t,n)&&n!==o&&Z(t,n,{get:()=>e[n],enumerable:!(s=Qe(e,n))||s.enumerable});return t};var te=t=>et(Z({},"__esModule",{value:!0}),t);import{access as ot,readFile as ke,writeFile as st}from"fs/promises";import{parse as nt}from"jsonc-parser";var l,h,be,b,it,at,_,m=O(()=>{"use strict";l=async t=>{try{return await ot(t),!0}catch{return!1}},h=async()=>{if(await l("pnpm-workspace.yaml"))return!0;try{let t=nt(await ke("package.json","utf-8"));return t?!!t.workspaces||!!t.workspace:!1}catch{return!1}},be=`
|
|
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 q=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=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
|
-
`,
|
|
11
|
+
`,b=async({dependencies:t,devDependencies:e,scripts:o})=>{let s=await ke("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 st("package.json",JSON.stringify(i,null,2))},it=/[ $(){}[\]&|;<>!"'`*?#~]/,at=/'/g,_=t=>t.map(e=>it.test(e)?`'${e.replace(at,"'\\''")}' `:e)});var _e={};ee(_e,{husky:()=>x});import{execSync as Vt}from"child_process";import{mkdir as Yt,readFile as Kt,writeFile as Ie}from"fs/promises";import{addDevDependency as Xt,dlxCommand as le}from"nypm";var Je,Y,x,de=O(()=>{"use strict";m();Je=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
|
-
${
|
|
79
|
+
`,Y="./.husky/pre-commit",x={exists:()=>l(Y),install:async t=>{await Xt("husky",{packageManager:t,workspace:await h()}),await b({scripts:{prepare:"husky"}})},init:t=>{let e=le(t,"husky",{args:["init"]});try{Vt(e,{stdio:"inherit"})}catch{}},create:async t=>{await Yt(".husky",{recursive:!0});let e=le(t,"ultracite",{args:["fix"],short:t==="npm"}),o=Je(e);await Ie(Y,o)},update:async t=>{let e=await Kt(Y,"utf-8"),o=le(t,"ultracite",{args:["fix"],short:t==="npm"}),s=Je(o);await Ie(Y,`${e}
|
|
80
|
+
${s}`)}}});var ze={};ee(ze,{lefthook:()=>R});import{execSync as Qt}from"child_process";import{readFile as Zt,writeFile as I}from"fs/promises";import{addDevDependency as qt,dlxCommand as He}from"nypm";var eo,to,We,v,Le,R,fe=O(()=>{"use strict";m();eo=/(pre-commit:\s*\n\s*jobs:\s*\n)/,to=/(pre-commit:\s*\n)/,We=t=>He(t,"ultracite",{args:["fix"],short:t==="npm"}),v="./lefthook.yml",Le=t=>`pre-commit:
|
|
81
81
|
jobs:
|
|
82
|
-
- run: ${
|
|
82
|
+
- run: ${We(t)}
|
|
83
83
|
glob:
|
|
84
84
|
- "*.js"
|
|
85
85
|
- "*.jsx"
|
|
@@ -89,7 +89,7 @@ ${o}`)}}});var Ve={};te(Ve,{lefthook:()=>A});import{execSync as es}from"child_pr
|
|
|
89
89
|
- "*.jsonc"
|
|
90
90
|
- "*.css"
|
|
91
91
|
stage_fixed: true
|
|
92
|
-
`,
|
|
92
|
+
`,R={exists:()=>l(v),install:async t=>{await qt("lefthook",{packageManager:t,workspace:await h()});let e=He(t,"lefthook",{args:["install"],short:t==="npm"});Qt(e)},create:async t=>{let e=Le(t);await I(v,e)},update:async t=>{let e=await Zt(v,"utf-8"),o=We(t),s=Le(t);if(e.includes(o))return;if(e.startsWith("# EXAMPLE USAGE:")){await I(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,9 +98,9 @@ ${o}`)}}});var Ve={};te(Ve,{lefthook:()=>A});import{execSync as es}from"child_pr
|
|
|
98
98
|
- "*.json"
|
|
99
99
|
- "*.jsonc"
|
|
100
100
|
- "*.css"
|
|
101
|
-
stage_fixed: true`,a=e.replace(
|
|
102
|
-
`);await
|
|
103
|
-
- run: ${
|
|
101
|
+
stage_fixed: true`,a=e.replace(eo,`$1${i}
|
|
102
|
+
`);await I(v,a)}else{let i=` jobs:
|
|
103
|
+
- run: ${o}
|
|
104
104
|
glob:
|
|
105
105
|
- "*.js"
|
|
106
106
|
- "*.jsx"
|
|
@@ -109,26 +109,26 @@ ${o}`)}}});var Ve={};te(Ve,{lefthook:()=>A});import{execSync as es}from"child_pr
|
|
|
109
109
|
- "*.json"
|
|
110
110
|
- "*.jsonc"
|
|
111
111
|
- "*.css"
|
|
112
|
-
stage_fixed: true`,a=e.replace(
|
|
113
|
-
`);await
|
|
114
|
-
${
|
|
115
|
-
`).filter(i=>i.trim()&&!i.trim().startsWith("#")),
|
|
116
|
-
`;for(let n of
|
|
117
|
-
`}else e+=`${
|
|
118
|
-
`;return e},
|
|
119
|
-
`;await
|
|
120
|
-
`;await
|
|
121
|
-
`),t.push(
|
|
122
|
-
\u{1F4CA} Summary:`),console.log(` ${e} passed, ${
|
|
123
|
-
\u{1F4A1} To fix issues, run: npx ultracite init`),
|
|
112
|
+
stage_fixed: true`,a=e.replace(to,`$1${i}
|
|
113
|
+
`);await I(v,a)}else await I(v,`${e}
|
|
114
|
+
${s}`)}}});var oo,pe=O(()=>{oo=ye({"./husky.ts":()=>(de(),te(_e)),"./lefthook.ts":()=>(fe(),te(ze)),"./lint-staged.ts":()=>(me(),te(Be))})});var Be={};ee(Be,{lintStaged:()=>E});import{readFile as K,writeFile as C}from"fs/promises";import{pathToFileURL as so}from"url";import J from"deepmerge";import{parse as ge}from"jsonc-parser";import{addDevDependency as no,dlxCommand as io}from"nypm";var y,Ge,ao,ro,co,lo,fo,po,mo,uo,go,ue,ho,E,me=O(()=>{"use strict";m();pe();y=t=>({"*.{js,jsx,ts,tsx,json,jsonc,css,scss,md,mdx}":[io(t,"ultracite",{args:["fix"],short:t==="npm"})]}),Ge=["./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"],ao=(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(":"),c=a.join(":").trim(),f=i.trim().replace(/['"]/g,"");return c&&c!==""?(c.startsWith("[")&&c.endsWith("]")?e[f]=c.slice(1,-1).split(",").map(g=>g.trim().replace(/['"]/g,"")):e[f]=c.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}},ro=t=>{let e=t.split(`
|
|
115
|
+
`).filter(i=>i.trim()&&!i.trim().startsWith("#")),o={},s=null,n=[];for(let i of e){let a=ao(i,o,s,n);s=a.newCurrentKey,n=a.newCurrentArray}return s&&n.length>0&&(o[s]=n),o},co=t=>{let e="";for(let[o,s]of Object.entries(t))if(Array.isArray(s)){e+=`${o}:
|
|
116
|
+
`;for(let n of s)e+=` - '${n}'
|
|
117
|
+
`}else e+=`${o}: '${s}'
|
|
118
|
+
`;return e},lo=async()=>{try{let t=ge(await K("./package.json","utf-8"));return t?t.type==="module":!1}catch{return!1}},fo=async t=>{let e=ge(await K("./package.json","utf-8"));e&&(e["lint-staged"]?e["lint-staged"]=J(e["lint-staged"],y(t)):e["lint-staged"]=y(t),await C("./package.json",JSON.stringify(e,null,2)))},po=async(t,e)=>{let o=await K(t,"utf-8"),s=ge(o);if(!s)return;let n=J(s,y(e));await C(t,JSON.stringify(n,null,2))},mo=async(t,e)=>{let o=await K(t,"utf-8"),s=ro(o);if(!s)return;let n=J(s,y(e));await C(t,co(n))},uo=async(t,e)=>{let n=(await import(so(t).href)).default||{},i=J(n,y(e)),a=`export default ${JSON.stringify(i,null,2)};
|
|
119
|
+
`;await C(t,a)},go=async(t,e)=>{delete q.cache[q.resolve(`./${t}`)];let o=oo(`./${t}`),s=J(o,y(e)),n=`module.exports = ${JSON.stringify(s,null,2)};
|
|
120
|
+
`;await C(t,n)},ue=async t=>{await C(".lintstagedrc.json",JSON.stringify(y(t),null,2))},ho=async(t,e)=>{if(t==="./package.json"){await fo(e);return}if(t.endsWith(".json")||t==="./.lintstagedrc"){await po(t,e);return}if(t.endsWith(".yaml")||t.endsWith(".yml")){await mo(t,e);return}let o=await lo();if(t.endsWith(".mjs")||t.endsWith(".js")&&o){try{await uo(t,e)}catch{await ue(e)}return}if(t.endsWith(".cjs")||t.endsWith(".js")&&!o)try{await go(t,e)}catch{await ue(e)}},E={exists:async()=>{for(let t of Ge)if(await l(t))return!0;return!1},install:async t=>{await no("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 Ge)if(await l(o)){e=o;break}if(!e){await ue(t);return}await ho(e,t)}}});import{initTRPC as _o}from"@trpc/server";import{createCli as Lo}from"trpc-cli";import r from"zod";var k={name:"ultracite",description:"The AI-ready formatter that helps you write and generate code faster.",version:"6.3.6",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.7","@types/node":"^24.10.1",tsup:"^8.5.1",turbo:"^2.6.1"},dependencies:{"@clack/prompts":"^0.11.0","@trpc/server":"^11.7.1",deepmerge:"^4.3.1",glob:"^12.0.0","jsonc-parser":"^3.3.1",nypm:"^0.6.2","trpc-cli":"^0.12.0",zod:"^4.1.12"},packageManager:"bun@1.3.2"};m();import{spawnSync as rt}from"child_process";var oe=t=>{let e=t?.[0]||[],o=t?.[1]["diagnostic-level"],s=["npx","@biomejs/biome","check","--no-errors-on-unmatched","--max-diagnostics=none"];o&&s.push(`--diagnostic-level=${o}`),e.length>0?s.push(..._(e)):s.push("./");let n=s.join(" "),i=rt(n,{stdio:"inherit",shell:!0});if(i.error)throw new Error(`Failed to run Ultracite: ${i.error.message}`);if(i.status!==0)throw new Error(`Ultracite check failed with status ${i.status??1}`)};import{spawnSync as vt}from"child_process";import{existsSync as D}from"fs";import{readFile as Re}from"fs/promises";import{join as T}from"path";import{parse as Ct}from"jsonc-parser";m();import{readFile as xe,unlink as ct,writeFile as lt}from"fs/promises";import{parse as ve}from"jsonc-parser";import{removeDependency as dt}from"nypm";var L=[".eslintrc",".eslintrc.js",".eslintrc.json",".eslintrc.yml",".eslintrc.yaml",".eslintrc.config.js","eslint.config.js","eslint.config.mjs","eslint.config.cjs",".eslintignore"],Ce=async()=>{try{let t=await xe("package.json","utf-8"),e=ve(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[]}},ft=async(t,e)=>{if(e.length!==0)try{for(let o of e)await dt(o,{packageManager:t})}catch(o){console.warn(o)}},pt=async()=>{let t=[];for(let e of L)if(await l(e))try{await ct(e),t.push(e)}catch(o){console.warn(o)}return t},mt=async()=>{let t="./.vscode/settings.json";if(!await l(t))return!1;try{let e=await xe(t,"utf-8"),o=ve(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 c=["source.fixAll.eslint","source.organizeImports.eslint"];for(let f of c)f in a&&(delete a[f],s=!0);Object.keys(a).length===0&&(n["editor.codeActionsOnSave"]=void 0)}}return s?(await lt(t,JSON.stringify(n,null,2)),!0):!1}catch(e){return console.warn(e),!1}},ut=async()=>{if((await Ce()).length>0)return!0;for(let e of L)if(await l(e))return!0;return!1},se={hasEsLint:ut,remove:async t=>{let e=await Ce();await ft(t,e);let o=await pt(),s=await mt();return{packagesRemoved:e,filesRemoved:o,vsCodeCleaned:s}}};m();import{readFile as je,unlink as gt,writeFile as ht}from"fs/promises";import{parse as Pe}from"jsonc-parser";import{removeDependency as wt}from"nypm";var H=[".prettierrc",".prettierrc.js",".prettierrc.json",".prettierrc.yml",".prettierrc.yaml",".prettierrc.config.js","prettier.config.js","prettier.config.mjs",".prettierignore"],Se=async()=>{try{let t=await je("package.json","utf-8"),e=Pe(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[]}},yt=async(t,e)=>{if(e.length!==0)try{for(let o of e)await wt(o,{packageManager:t})}catch(o){console.warn(o)}},kt=async()=>{let t=[];for(let e of H)if(await l(e))try{await gt(e),t.push(e)}catch(o){console.warn(o)}return t},bt=async()=>{let t="./.vscode/settings.json";if(!await l(t))return!1;try{let e=await je(t,"utf-8"),o=Pe(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 c of i)c in n&&(c==="editor.defaultFormatter"&&n[c]==="esbenp.prettier-vscode"||c!=="editor.defaultFormatter")&&(delete n[c],s=!0);let a=Object.keys(n).filter(c=>c.startsWith("[")&&c.includes("javascript"));for(let c of a){let f=n[c];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[c])}return s?(await ht(t,JSON.stringify(n,null,2)),!0):!1}catch(e){return console.warn(e),!1}},xt=async()=>{if((await Se()).length>0)return!0;for(let e of H)if(await l(e))return!0;return!1},ne={hasPrettier:xt,remove:async t=>{let e=await Se();await yt(t,e);let o=await kt(),s=await bt();return{packagesRemoved:e,filesRemoved:o,vsCodeCleaned:s}}};var jt=()=>{let t=vt("npx @biomejs/biome --version",{shell:!0,encoding:"utf-8"});return t.status===0&&t.stdout?{name:"Biome installation",status:"pass",message:`Biome is installed (${t.stdout.trim()})`}:{name:"Biome installation",status:"fail",message:"Biome is not installed or not accessible"}},Pt=async()=>{let t=T(process.cwd(),"biome.json"),e=T(process.cwd(),"biome.jsonc"),o=null;if(D(t)?o=t:D(e)&&(o=e),!o)return{name:"Biome configuration",status:"fail",message:"No biome.json or biome.jsonc file found"};try{let s=await Re(o,"utf-8"),n=Ct(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"}}},St=async()=>{let t=T(process.cwd(),"package.json");if(!D(t))return{name:"Ultracite dependency",status:"warn",message:"No package.json found"};try{let e=JSON.parse(await Re(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"}}},Rt=()=>{let t=H.some(o=>D(T(process.cwd(),o))),e=L.some(o=>D(T(process.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"}},Ee=async()=>{let t=[];console.log(`\u{1FA7A} Running Ultracite doctor...
|
|
121
|
+
`),t.push(jt()),t.push(await Pt()),t.push(await St()),t.push(Rt());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
|
+
\u{1F4CA} Summary:`),console.log(` ${e} passed, ${s} warnings, ${o} failed`),o>0)throw console.log(`
|
|
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!`)};m();import{spawnSync as
|
|
125
|
+
\u2728 Everything looks good!`)};m();import{spawnSync as Et}from"child_process";var ie=(t,e={})=>{let o=["npx","@biomejs/biome","check","--write","--no-errors-on-unmatched","--max-diagnostics=none"];e.unsafe&&o.push("--unsafe"),t.length>0?o.push(..._(t)):o.push("./");let s=o.join(" "),n=Et(s,{stdio:"inherit",shell:!0});if(n.error)throw new Error(`Failed to run Ultracite: ${n.error.message}`);if(n.status!==0)throw new Error(`Ultracite fix failed with status ${n.status??1}`)};import{packageManagers as At}from"nypm";var w={packageManagers:At.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"],integrations:["husky","lefthook","lint-staged"],hooks:["cursor","claude"],frameworks:["react","next","solid","vue","svelte","qwik","remix","angular","astro"],migrations:["eslint","prettier"]};import jo from"process";import{cancel as A,intro as Po,isCancel as F,log as X,multiselect as $,spinner as u}from"@clack/prompts";import{addDevDependency as So,detectPackageManager as Ro}from"nypm";import{mkdir as Ft,readFile as $t,writeFile as W}from"fs/promises";import{dirname as Nt}from"path";var Ae={"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}},
|
|
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}},Fe={cursor:{path:"./.cursor/hooks.json",command:"npx ultracite fix"},claude:{path:"./.claude/settings.json",command:"npx ultracite fix"}};m();var M=`# 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 $e=t=>{let e=Ae[t],o=e.header?`${e.header}
|
|
255
255
|
|
|
256
|
-
${
|
|
256
|
+
${M}`:M,s=async()=>{let n=Nt(e.path);if(n!=="."){let i=n.startsWith("./")?n.slice(2):n;await Ft(i,{recursive:!0})}};return{exists:()=>l(e.path),create:async()=>{await s(),await W(e.path,o)},update:async()=>{if(await s(),e.appendMode){if(!await l(e.path)){await W(e.path,o);return}let n=await $t(e.path,"utf-8");if(n.includes(M.trim()))return;await W(e.path,`${n}
|
|
257
257
|
|
|
258
|
-
${I}`)}else await z(e.path,s)}}};m();import{readFile as Mt,writeFile as Te}from"fs/promises";import It from"deepmerge";import{parse as Ut}from"jsonc-parser";var Me={$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(),s=["ultracite/core"];if(t?.frameworks&&t.frameworks.length>0)for(let n of t.frameworks)s.push(`ultracite/${n}`);let o={...Me,extends:s};return Te(e,JSON.stringify(o,null,2))},update:async t=>{let e=await re(),s=await Mt(e,"utf-8"),n=Ut(s)||{},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 c={$schema:Me.$schema},f=It(n,c);await Te(e,JSON.stringify(f,null,2))}};import{mkdir as Jt,readFile as Ie,writeFile as R}from"fs/promises";import{dirname as _t}from"path";m();var Ue=t=>{let e=Oe[t],s=async()=>{let o=_t(e.path);if(o!=="."){let n=o.startsWith("./")?o.slice(2):o;await Jt(n,{recursive:!0})}};return{exists:()=>l(e.path),create:async()=>{await s(),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 s(),t==="cursor"){if(!await l(e.path)){await R(e.path,JSON.stringify({version:1,hooks:{afterFileEdit:[{command:e.command}]}},null,2));return}let o=await Ie(e.path,"utf-8"),n=JSON.parse(o);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 o=await Ie(e.path,"utf-8"),n=JSON.parse(o);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 R(e.path,JSON.stringify(n,null,2)))}}}};m();import{spawnSync as Lt}from"child_process";import{mkdir as Ht,readFile as Wt,writeFile as Je}from"fs/promises";import zt from"deepmerge";import{parse as Bt}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",U={exists:()=>l(G),create:async()=>{await Ht(".vscode",{recursive:!0}),await Je(G,JSON.stringify(ce,null,2))},update:async()=>{let t=await Wt(G,"utf-8"),s=Bt(t)||{},o=zt(s,ce);await Je(G,JSON.stringify(o,null,2))},extension:()=>Lt("code --install-extension biomejs.biome",{stdio:"inherit",shell:!0})};m();import{mkdir as Gt,readFile as Vt,writeFile as _e}from"fs/promises";import Yt from"deepmerge";import{parse as Kt}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 Gt(".zed",{recursive:!0}),await _e(V,JSON.stringify(le,null,2))},update:async()=>{let t=await Vt(V,"utf-8"),s=Kt(t)||{},o=Yt(s,le);await _e(V,JSON.stringify(o,null,2))}};fe();pe();ue();import{readFile as ks,writeFile as bs}from"fs/promises";import xs from"deepmerge";import{glob as vs}from"glob";import{parse as Cs}from"jsonc-parser";var js={compilerOptions:{strictNullChecks:!0}},Xe=async()=>{try{return await vs("**/tsconfig*.json",{ignore:["**/node_modules/**","**/dist/**","**/build/**","**/.next/**"],absolute:!1})}catch{return[]}},Ps=async t=>{try{let e=await ks(t,"utf-8"),o=Cs(e)||{},n=xs(o,js);await bs(t,JSON.stringify(n,null,2))}catch(e){console.warn(`Failed to update ${t}:`,e)}},ye={exists:async()=>(await Xe()).length>0,update:async()=>{let t=await Xe();if(t.length===0){console.warn("No tsconfig.json files found in the project");return}await Promise.all(t.map(e=>Ps(e)))}};m();var Qe=b.devDependencies["@biomejs/biome"],Ze=b.version,Es=async(t,e=!0,s=!1)=>{let o=u();s||o.start("Installing dependencies...");let n=[`ultracite@${Ze}`,`@biomejs/biome@${Qe}`];if(e)for(let i of n)await Rs(i,{packageManager:t,workspace:await h(),silent:s});else await x({devDependencies:{"@biomejs/biome":Qe,ultracite:Ze}});s||o.stop("Dependencies installed.")},Fs=async(t=!1)=>{let e=u();if(t||e.start("Checking for tsconfig.json files..."),await ye.exists()){t||e.message("Found tsconfig.json files, updating with strictNullChecks..."),await ye.update(),t||e.stop("tsconfig.json files updated.");return}t||e.stop("No tsconfig.json files found, skipping.")},$s=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(s){t||e.stop(`Failed to install Biome extension (${s}), but continuing...`)}},Ns=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/")},Os=async(t,e=!1)=>{let s=u();if(e||s.start("Checking for Biome configuration..."),await B.exists()){e||s.message("Biome configuration found, updating..."),await B.update({frameworks:t}),e||s.stop("Biome configuration updated.");return}e||s.message("Biome configuration not found, creating..."),await B.create({frameworks:t}),e||s.stop("Biome configuration created.")},Ds=async(t,e=!0,s=!1)=>{let o=u();if(s||(o.start("Initializing pre-commit hooks..."),o.message("Installing Husky...")),e?await v.install(t):await x({devDependencies:{husky:"latest"},scripts:{prepare:"husky"}}),s||o.message("Initializing Husky..."),v.init(t),await v.exists()){s||o.message("Pre-commit hook found, updating..."),await v.update(t),s||o.stop("Pre-commit hook updated.");return}s||o.message("Pre-commit hook not found, creating..."),await v.create(t),s||o.stop("Pre-commit hook created.")},Ts=async(t,e=!0,s=!1)=>{let o=u();if(s||(o.start("Initializing lefthook..."),o.message("Installing lefthook...")),e?await A.install(t):await x({devDependencies:{lefthook:"latest"}}),await A.exists()){s||o.message("lefthook.yml found, updating..."),await A.update(t),s||o.stop("lefthook.yml updated.");return}s||o.message("lefthook.yml not found, creating..."),await A.create(t),s||o.stop("lefthook.yml created.")},Ms=async(t,e=!0,s=!1)=>{let o=u();if(s||(o.start("Initializing lint-staged..."),o.message("Installing lint-staged...")),e?await E.install(t):await x({devDependencies:{"lint-staged":"latest"}}),await E.exists()){s||o.message("lint-staged found, updating..."),await E.update(t),s||o.stop("lint-staged updated.");return}s||o.message("lint-staged not found, creating..."),await E.create(t),s||o.stop("lint-staged created.")},Is=async(t,e,s=!1)=>{let o=u();s||o.start(`Checking for ${e}...`);let n=De(t);if(await n.exists()){s||o.message(`${e} found, updating...`),await n.update(),s||o.stop(`${e} updated.`);return}s||o.message(`${e} not found, creating...`),await n.create(),s||o.stop(`${e} created.`)},Us=async(t,e,s=!1)=>{let o=u();s||o.start(`Checking for ${e} hooks...`);let n=Ue(t);if(await n.exists()){s||o.message(`${e} hooks found, updating...`),await n.update(),s||o.stop(`${e} hooks updated.`);return}s||o.message(`${e} hooks not found, creating...`),await n.create(),s||o.stop(`${e} hooks created.`)},Js=async(t,e=!1)=>{let s=u();e||s.start("Removing Prettier dependencies and configuration...");try{let o=await ie.remove(t);e||(o.packagesRemoved.length>0&&s.message(`Removed Prettier packages: ${o.packagesRemoved.join(", ")}`),o.filesRemoved.length>0&&s.message(`Removed config files: ${o.filesRemoved.join(", ")}`),o.vsCodeCleaned&&s.message("Cleaned VS Code settings"),s.stop("Prettier removed successfully."))}catch{e||s.stop("Failed to remove Prettier completely, but continuing...")}},_s=async(t,e=!1)=>{let s=u();e||s.start("Removing ESLint dependencies and configuration...");try{let o=await ne.remove(t);e||(o.packagesRemoved.length>0&&s.message(`Removed ESLint packages: ${o.packagesRemoved.join(", ")}`),o.filesRemoved.length>0&&s.message(`Removed config files: ${o.filesRemoved.join(", ")}`),o.vsCodeCleaned&&s.message("Cleaned VS Code settings"),s.stop("ESLint removed successfully."))}catch{e||s.stop("Failed to remove ESLint completely, but continuing...")}},qe=async t=>{let e=t??{},s=e.quiet??!1;s||Ss(xe);try{let{pm:o}=e;if(!o){let d=await As(k.cwd());if(!d)throw new Error("No package manager specified or detected");if(!s&&d.warnings)for(let p of d.warnings)Q.warn(p);s||Q.info(`Detected lockfile, using ${d.name}`),o=d.name}let n=e.migrate?.includes("prettier"),i=e.migrate?.includes("eslint");if(!s&&(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 p=await N({message:"Remove existing formatters/linters (recommended for clean migration)?",options:d,required:!1});$(p)&&(F("Operation cancelled."),k.exit(0)),n===void 0&&(n=p.includes("prettier")),i===void 0&&(i=p.includes("eslint"))}}s&&(n===void 0&&(n=!1),i===void 0&&(i=!1));let a=e.frameworks;if(a===void 0)if(s||e.pm||e.editors||e.agents||e.hooks||e.integrations!==void 0||e.migrate!==void 0)a=[];else{let p=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});$(p)&&(F("Operation cancelled."),k.exit(0)),a=p}let c=e.editors;if(!c)if(s)c=[];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});$(d)&&(F("Operation cancelled."),k.exit(0)),c=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"};if(!f)if(s)f=[];else{let d=await N({message:"Which agents do you want to enable (optional)?",options:Object.entries(O).map(([p,Z])=>({value:p,label:Z})),required:!1});$(d)&&(F("Operation cancelled."),k.exit(0)),f=d}let we={cursor:"Cursor",claude:"Claude Code"};if(!g)if(s)g=[];else{let d=await N({message:"Which agent hooks do you want to enable (optional)?",options:Object.entries(we).map(([p,Z])=>({value:p,label:Z})),required:!1});$(d)&&(F("Operation cancelled."),k.exit(0)),g=d}let S=e.integrations;if(S===void 0)if(s||e.pm||e.editors||e.agents||e.hooks||e.migrate!==void 0)S=[];else{let p=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});$(p)&&(F("Operation cancelled."),k.exit(0)),S=p}n&&await Js(o,s),i&&await _s(o,s),await Es(o,!e.skipInstall,s),await Fs(s),await Os(a,s),c?.includes("vscode")&&await $s(s),c?.includes("zed")&&await Ns(s);for(let d of f??[])await Is(d,O[d],s);for(let d of g??[])await Us(d,we[d],s);S?.includes("husky")&&await Ds(o,!e.skipInstall,s),S?.includes("lefthook")&&await Ts(o,!e.skipInstall,s),S?.includes("lint-staged")&&await Ms(o,!e.skipInstall,s),s||Q.success("Successfully initialized Ultracite configuration!")}catch(o){let n=o instanceof Error?o.message:"Unknown error";s||Q.error(`Failed to initialize Ultracite configuration: ${n}`),k.exit(1)}};var P=Ls.meta().create(),Ws=P.router({init:P.procedure.meta({description:"Initialize Ultracite in the current directory"}).input(r.object({pm:r.enum(y.packageManagers).optional().describe("Package manager to use"),editors:r.array(r.enum(y.editorConfigs)).optional().describe("Editors to configure"),agents:r.array(r.enum(y.agents)).optional().describe("Agents to enable"),hooks:r.array(r.enum(y.hooks)).optional().describe("Hooks to enable"),frameworks:r.array(r.enum(y.frameworks)).optional().describe("Frameworks being used"),integrations:r.array(r.enum(y.integrations)).optional().describe("Additional integrations to enable"),migrate:r.array(r.enum(y.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 qe(t)}),check:P.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:P.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,s]=t;ae(e,{unsafe:s.unsafe})}),doctor:P.procedure.meta({description:"Verify your Ultracite setup and check for issues"}).query(async()=>{await Fe()}),lint:P.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:P.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,s]=t;console.warn("\u26A0\uFE0F Warning: 'format' command is deprecated. Please use 'fix' instead."),ae(e,{unsafe:s.unsafe})})}),zs=Hs({router:Ws,name:b.name,version:b.version,description:b.description});process.env.TEST||zs.run();export{Ws as router};
|
|
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"};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};
|