ultracite 7.0.4 → 7.0.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.d.ts +5 -0
- package/dist/index.js +2 -2
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ declare const router: _trpc_server.TRPCBuiltRouter<{
|
|
|
17
17
|
frameworks?: ("react" | "next" | "solid" | "vue" | "svelte" | "qwik" | "remix" | "angular" | "astro")[] | undefined;
|
|
18
18
|
integrations?: ("husky" | "lefthook" | "lint-staged" | "pre-commit")[] | undefined;
|
|
19
19
|
migrate?: ("eslint" | "prettier")[] | undefined;
|
|
20
|
+
"type-aware"?: boolean | undefined;
|
|
20
21
|
skipInstall?: boolean | undefined;
|
|
21
22
|
quiet?: boolean | undefined;
|
|
22
23
|
};
|
|
@@ -27,6 +28,8 @@ declare const router: _trpc_server.TRPCBuiltRouter<{
|
|
|
27
28
|
input: [string[] | undefined, {
|
|
28
29
|
"diagnostic-level"?: "info" | "warn" | "error" | undefined;
|
|
29
30
|
linter?: "biome" | "eslint" | "oxlint" | undefined;
|
|
31
|
+
"type-aware"?: boolean | undefined;
|
|
32
|
+
"type-check"?: boolean | undefined;
|
|
30
33
|
}] | undefined;
|
|
31
34
|
output: void;
|
|
32
35
|
meta: TrpcCliMeta;
|
|
@@ -35,6 +38,8 @@ declare const router: _trpc_server.TRPCBuiltRouter<{
|
|
|
35
38
|
input: [string[] | undefined, {
|
|
36
39
|
unsafe?: boolean | undefined;
|
|
37
40
|
linter?: "biome" | "eslint" | "oxlint" | undefined;
|
|
41
|
+
"type-aware"?: boolean | undefined;
|
|
42
|
+
"type-check"?: boolean | undefined;
|
|
38
43
|
}] | undefined;
|
|
39
44
|
output: void;
|
|
40
45
|
meta: TrpcCliMeta;
|
package/dist/index.js
CHANGED
|
@@ -168,7 +168,7 @@ export default defineConfig([
|
|
|
168
168
|
"arrowParens": "always",
|
|
169
169
|
"proseWrap": "never",
|
|
170
170
|
"printWidth": 80,
|
|
171
|
-
}`}],vscodeExtensionId:"oxc.oxc-vscode"}];var e2=["react","next","solid","vue","svelte","qwik","remix","angular","astro"],i2=["husky","lefthook","lint-staged","pre-commit"],o2=["eslint","prettier"],v={linters:s1.map(t=>t.id),editorConfigs:x.map(t=>t.id),agents:_.map(t=>t.id),integrations:i2,hooks:x.filter(t=>t.hooks).map(t=>t.id),frameworks:e2,migrations:o2};import{initTRPC as pi}from"@trpc/server";import{packageManagers as gi}from"nypm";import{createCli as ui}from"trpc-cli";import d from"zod";var y={name:"ultracite",description:"The AI-ready formatter that helps you write and generate code faster.",version:"7.0.4",type:"module",bin:{ultracite:"dist/index.js"},files:["config","dist/index.js","dist/index.d.ts","README.md"],scripts:{build:"tsup",test:"bun test","test:coverage":"bun test --coverage"},exports:{"./biome/*":"./config/biome/*/biome.jsonc","./eslint/*":"./config/eslint/*/eslint.config.mjs","./oxlint/*":"./config/oxlint/*/.oxlintrc.json","./prettier":"./config/prettier/prettier.config.mjs","./stylelint":"./config/stylelint/stylelint.config.mjs","./*":"./config/biome/*/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","@eslint/js":"^9.39.2","@next/eslint-plugin-next":"^16.1.1","@repo/data":"workspace:*","@tanstack/eslint-plugin-query":"^5.91.2","@types/node":"^25.0.3","@typescript-eslint/eslint-plugin":"^8.51.0","@typescript-eslint/parser":"^8.51.0","eslint-config-prettier":"^10.1.8","eslint-import-resolver-typescript":"^4.4.4","eslint-plugin-angular":"^5.0.0","eslint-plugin-astro":"^1.5.0","eslint-plugin-compat":"^6.0.2","eslint-plugin-cypress":"^5.2.0","eslint-plugin-github":"6.0.0","eslint-plugin-html":"^8.1.3","eslint-plugin-import":"^2.32.0","eslint-plugin-jest":"^29.12.0","eslint-plugin-jsx-a11y":"^6.10.2","eslint-plugin-n":"^17.23.1","eslint-plugin-prettier":"^5.5.4","eslint-plugin-promise":"^7.2.1","eslint-plugin-qwik":"^1.18.0","eslint-plugin-react":"^7.37.5","eslint-plugin-react-hooks":"^7.0.1","eslint-plugin-remix":"^1.1.1","eslint-plugin-solid":"^0.14.5","eslint-plugin-sonarjs":"^3.0.5","eslint-plugin-storybook":"^10.1.11","eslint-plugin-svelte":"^3.13.1","eslint-plugin-tailwindcss":"^3.18.2","eslint-plugin-unicorn":"^62.0.0","eslint-plugin-unused-imports":"^4.3.0","eslint-plugin-vue":"^10.6.2",globals:"^16.5.0","prettier-plugin-tailwindcss":"^0.7.2","stylelint-config-idiomatic-order":"^10.0.0","stylelint-config-standard":"^39.0.1","stylelint-prettier":"^5.0.3",tsup:"^8.5.1"},dependencies:{"@clack/prompts":"^0.11.0","@trpc/server":"^11.8.1",deepmerge:"^4.3.1",glob:"^13.0.0","jsonc-parser":"^3.3.1",nypm:"^0.6.2",oxlint:"^1.36.0","trpc-cli":"^0.12.1",zod:"^4.3.2"},packageManager:"bun@1.3.5"};f();import{spawnSync as L}from"child_process";import R from"process";import{detectPackageManager as D,dlxCommand as N}from"nypm";var u2=async(t,e)=>{let i=["check","--no-errors-on-unmatched"];e&&i.push(`--diagnostic-level=${e}`),t.length>0?i.push(...u(t)):i.push("./");let n=(await D(R.cwd()))?.name||"npm",s=N(n,"@biomejs/biome",{args:i,short:n==="npm"}),r=L(s,{stdio:"inherit",shell:!0});if(r.error)throw new Error(`Failed to run Biome: ${r.error.message}`);return{hasErrors:r.status!==0}},h2=async t=>{let e=t.length>0?u(t):["."],o=(await D(R.cwd()))?.name||"npm",n=N(o,"eslint",{args:e,short:o==="npm"}),s=L(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run ESLint: ${s.error.message}`);return{hasErrors:s.status!==0}},w2=async t=>{let e=["--check",...t.length>0?u(t):["."]],o=(await D(R.cwd()))?.name||"npm",n=N(o,"prettier",{args:e,short:o==="npm"}),s=L(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run Prettier: ${s.error.message}`);return{hasErrors:s.status!==0}},x2=async t=>{let e=t.length>0?u(t):["."],o=(await D(R.cwd()))?.name||"npm",n=N(o,"stylelint",{args:e,short:o==="npm"}),s=L(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run Stylelint: ${s.error.message}`);return{hasErrors:s.status!==0}},v2=async t=>{let e=t.length>0?u(t):["."],o=(await D(R.cwd()))?.name||"npm",n=N(o,"oxlint",{args:e,short:o==="npm"}),s=L(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run Oxlint: ${s.error.message}`);return{hasErrors:s.status!==0}},y2=async t=>{let e=["--check",...t.length>0?u(t):["."]],o=(await D(R.cwd()))?.name||"npm",n=N(o,"oxfmt",{args:e,short:o==="npm"}),s=L(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run oxfmt: ${s.error.message}`);return{hasErrors:s.status!==0}},St=async t=>{let e=t?.[0]||[],i=t?.[1]["diagnostic-level"],n=t?.[1].linter||await r1();if(!n)throw new Error("No linter configuration found. Run `ultracite init` to set up a linter.");switch(n){case"eslint":{let s=await w2(e),r=await h2(e),a=await x2(e);return{hasErrors:s.hasErrors||r.hasErrors||a.hasErrors}}case"oxlint":{let s=await y2(e),r=await v2(e);return{hasErrors:s.hasErrors||r.hasErrors}}default:return u2(e,i)}};import{spawnSync as j1}from"child_process";import{existsSync as A}from"fs";import{readFile as c1}from"fs/promises";import{join as O}from"path";import w from"process";import{intro as k2,log as a1,outro as S1,spinner as b2}from"@clack/prompts";import{parse as jt}from"jsonc-parser";import{detectPackageManager as l1,dlxCommand as d1}from"nypm";var z2=[".prettierrc",".prettierrc.js",".prettierrc.cjs",".prettierrc.mjs",".prettierrc.json",".prettierrc.yaml",".prettierrc.yml","prettier.config.js","prettier.config.mjs","prettier.config.cjs"],C2=[".eslintrc",".eslintrc.js",".eslintrc.cjs",".eslintrc.mjs",".eslintrc.json",".eslintrc.yaml",".eslintrc.yml","eslint.config.js","eslint.config.mjs","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts"],S2=async()=>{let e=(await l1(w.cwd()))?.name||"npm",i=d1(e,"@biomejs/biome",{args:["--version"],short:e==="npm"}),o=j1(i,{shell:!0,encoding:"utf-8"});return o.status===0&&o.stdout?{name:"Biome installation",status:"pass",message:`Biome is installed (${o.stdout.trim()})`}:{name:"Biome installation",status:"fail",message:"Biome is not installed or not accessible"}},j2=async()=>{let e=(await l1(w.cwd()))?.name||"npm",i=d1(e,"eslint",{args:["--version"],short:e==="npm"}),o=j1(i,{shell:!0,encoding:"utf-8"});return o.status===0&&o.stdout?{name:"ESLint installation",status:"pass",message:`ESLint is installed (${o.stdout.trim()})`}:{name:"ESLint installation",status:"warn",message:"ESLint is not installed (optional)"}},P2=async()=>{let e=(await l1(w.cwd()))?.name||"npm",i=d1(e,"oxlint",{args:["--version"],short:e==="npm"}),o=j1(i,{shell:!0,encoding:"utf-8"});return o.status===0&&o.stdout?{name:"Oxlint installation",status:"pass",message:`Oxlint is installed (${o.stdout.trim()})`}:{name:"Oxlint installation",status:"warn",message:"Oxlint is not installed (optional)"}},E2=async()=>{let t=O(w.cwd(),"biome.json"),e=O(w.cwd(),"biome.jsonc"),i=null;if(A(t)?i=t:A(e)&&(i=e),!i)return{name:"Biome configuration",status:"warn",message:"No biome.json or biome.jsonc file found"};try{let o=await c1(i,"utf-8"),n=jt(o);return Array.isArray(n?.extends)&&n.extends.includes("ultracite/biome/core")?{name:"Biome configuration",status:"pass",message:"biome.json(c) extends ultracite/biome/core"}:{name:"Biome configuration",status:"warn",message:"biome.json(c) exists but doesn't extend ultracite/biome/core"}}catch{return{name:"Biome configuration",status:"fail",message:"Could not parse biome.json(c) file"}}},A2=async()=>{let t=["eslint.config.mjs","eslint.config.js","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts"],e=null;for(let i of t){let o=O(w.cwd(),i);if(A(o)){e=o;break}}if(!e)return{name:"ESLint configuration",status:"warn",message:"No eslint.config.* file found (optional)"};try{return(await c1(e,"utf-8")).includes("ultracite/eslint")?{name:"ESLint configuration",status:"pass",message:"eslint.config.* imports ultracite/eslint"}:{name:"ESLint configuration",status:"warn",message:"eslint.config.* exists but doesn't import ultracite/eslint"}}catch{return{name:"ESLint configuration",status:"fail",message:"Could not read eslint.config.* file"}}},O2=async()=>{let t=O(w.cwd(),".oxlintrc.json");if(!A(t))return{name:"Oxlint configuration",status:"warn",message:"No .oxlintrc.json file found (optional)"};try{let e=await c1(t,"utf-8"),i=jt(e);return Array.isArray(i?.extends)&&i.extends.includes("ultracite/oxlint/core")?{name:"Oxlint configuration",status:"pass",message:".oxlintrc.json extends ultracite/oxlint/core"}:{name:"Oxlint configuration",status:"warn",message:".oxlintrc.json exists but doesn't extend ultracite/oxlint/core"}}catch{return{name:"Oxlint configuration",status:"fail",message:"Could not parse .oxlintrc.json file"}}},B2=async()=>{let t=O(w.cwd(),"package.json");if(!A(t))return{name:"Ultracite dependency",status:"warn",message:"No package.json found"};try{let e=JSON.parse(await c1(t,"utf-8")),i=e.dependencies?.ultracite||e.devDependencies?.ultracite||e.peerDependencies?.ultracite;return i?{name:"Ultracite dependency",status:"pass",message:`Ultracite is in package.json (${i})`}:{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"}}},I2=()=>{let t=z2.some(o=>A(O(w.cwd(),o))),i=C2.filter(o=>!o.startsWith("eslint.config")).some(o=>A(O(w.cwd(),o)));if(t||i){let o=[];return t&&o.push("Prettier"),i&&o.push("ESLint (legacy config)"),{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"}},C=async(t,e)=>{let i=b2();i.start(`Checking ${e}...`);let o=await t();return o.status==="pass"||o.status,i.stop(o.message),o},Pt=async()=>{k2(`Ultracite v${y.version} Doctor`);let e=(await l1(w.cwd()))?.name||"npm",i=d1(e,"ultracite",{args:["init"],short:e==="npm"}),o=[];o.push(await C(S2,"Biome installation")),o.push(await C(j2,"ESLint installation")),o.push(await C(P2,"Oxlint installation")),o.push(await C(E2,"Biome configuration")),o.push(await C(A2,"ESLint configuration")),o.push(await C(O2,"Oxlint configuration")),o.push(await C(B2,"Ultracite dependency")),o.push(await C(I2,"conflicting tools"));let n=o.filter(a=>a.status==="pass").length,s=o.filter(a=>a.status==="fail").length,r=o.filter(a=>a.status==="warn").length;if(a1.info(`Summary: ${n} passed, ${r} warnings, ${s} failed`),s>0)throw a1.error(`Some checks failed. Run '${i}' to fix issues.`),S1("Doctor complete"),new Error("Doctor checks failed");if(r>0){a1.warn(`Some optional improvements available. Run '${i}' to configure.`),S1("Doctor complete");return}a1.success("Everything looks good!"),S1("Doctor complete")};f();import{spawnSync as T}from"child_process";import G from"process";import{detectPackageManager as M,dlxCommand as J}from"nypm";var F2=async(t,e)=>{let i=["check","--write","--no-errors-on-unmatched"];e&&i.push("--unsafe"),t.length>0?i.push(...u(t)):i.push("./");let n=(await M(G.cwd()))?.name||"npm",s=J(n,"@biomejs/biome",{args:i,short:n==="npm"}),r=T(s,{stdio:"inherit",shell:!0});if(r.error)throw new Error(`Failed to run Biome: ${r.error.message}`);return{hasErrors:r.status!==0}},$2=async t=>{let e=["--fix",...t.length>0?u(t):["."]],o=(await M(G.cwd()))?.name||"npm",n=J(o,"eslint",{args:e,short:o==="npm"}),s=T(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run ESLint: ${s.error.message}`);return{hasErrors:s.status!==0}},_2=async t=>{let e=["--write",...t.length>0?u(t):["."]],o=(await M(G.cwd()))?.name||"npm",n=J(o,"prettier",{args:e,short:o==="npm"}),s=T(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run Prettier: ${s.error.message}`);return{hasErrors:s.status!==0}},U2=async t=>{let e=["--fix",...t.length>0?u(t):["."]],o=(await M(G.cwd()))?.name||"npm",n=J(o,"stylelint",{args:e,short:o==="npm"}),s=T(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run Stylelint: ${s.error.message}`);return{hasErrors:s.status!==0}},L2=async t=>{let e=["--fix",...t.length>0?u(t):["."]],o=(await M(G.cwd()))?.name||"npm",n=J(o,"oxlint",{args:e,short:o==="npm"}),s=T(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run Oxlint: ${s.error.message}`);return{hasErrors:s.status!==0}},R2=async t=>{let e=["--write",...t.length>0?u(t):["."]],o=(await M(G.cwd()))?.name||"npm",n=J(o,"oxfmt",{args:e,short:o==="npm"}),s=T(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run oxfmt: ${s.error.message}`);return{hasErrors:s.status!==0}},Et=async(t,e={})=>{let i=e.linter||await r1();if(!i)throw new Error("No linter configuration found. Run `ultracite init` to set up a linter.");switch(i){case"eslint":{let o=await _2(t),n=await $2(t),s=await U2(t);return{hasErrors:o.hasErrors||n.hasErrors||s.hasErrors}}case"oxlint":{let o=await R2(t),n=await L2(t);return{hasErrors:o.hasErrors||n.hasErrors}}default:return F2(t,e.unsafe)}};import V3 from"process";import{cancel as V,intro as X3,isCancel as X,log as k1,multiselect as q,select as Q3,spinner as p}from"@clack/prompts";import{addDevDependency as K3,detectPackageManager as Y3}from"nypm";import{readFile as D2,writeFile as P1}from"fs/promises";var At=t=>`# Ultracite Code Standards
|
|
171
|
+
}`}],vscodeExtensionId:"oxc.oxc-vscode"}];var e2=["react","next","solid","vue","svelte","qwik","remix","angular","astro"],i2=["husky","lefthook","lint-staged","pre-commit"],o2=["eslint","prettier"],v={linters:s1.map(t=>t.id),editorConfigs:x.map(t=>t.id),agents:_.map(t=>t.id),integrations:i2,hooks:x.filter(t=>t.hooks).map(t=>t.id),frameworks:e2,migrations:o2};import{initTRPC as pi}from"@trpc/server";import{packageManagers as gi}from"nypm";import{createCli as ui}from"trpc-cli";import l from"zod";var y={name:"ultracite",description:"The AI-ready formatter that helps you write and generate code faster.",version:"7.0.6",type:"module",bin:{ultracite:"dist/index.js"},files:["config","dist/index.js","dist/index.d.ts","README.md"],scripts:{build:"tsup",test:"bun test","test:coverage":"bun test --coverage"},exports:{"./biome/*":"./config/biome/*/biome.jsonc","./eslint/*":"./config/eslint/*/eslint.config.mjs","./oxlint/*":"./config/oxlint/*/.oxlintrc.json","./prettier":"./config/prettier/prettier.config.mjs","./stylelint":"./config/stylelint/stylelint.config.mjs","./*":"./config/biome/*/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.11","@eslint/js":"^9.39.2","@next/eslint-plugin-next":"^16.1.1","@repo/data":"workspace:*","@tanstack/eslint-plugin-query":"^5.91.2","@types/node":"^25.0.3","@typescript-eslint/eslint-plugin":"^8.51.0","@typescript-eslint/parser":"^8.51.0","eslint-config-prettier":"^10.1.8","eslint-import-resolver-typescript":"^4.4.4","eslint-plugin-angular":"^5.0.0","eslint-plugin-astro":"^1.5.0","eslint-plugin-compat":"^6.0.2","eslint-plugin-cypress":"^5.2.0","eslint-plugin-github":"6.0.0","eslint-plugin-html":"^8.1.3","eslint-plugin-import":"^2.32.0","eslint-plugin-jest":"^29.12.0","eslint-plugin-jsx-a11y":"^6.10.2","eslint-plugin-n":"^17.23.1","eslint-plugin-prettier":"^5.5.4","eslint-plugin-promise":"^7.2.1","eslint-plugin-qwik":"^1.18.0","eslint-plugin-react":"^7.37.5","eslint-plugin-react-hooks":"^7.0.1","eslint-plugin-remix":"^1.1.1","eslint-plugin-solid":"^0.14.5","eslint-plugin-sonarjs":"^3.0.5","eslint-plugin-storybook":"^10.1.11","eslint-plugin-svelte":"^3.13.1","eslint-plugin-tailwindcss":"^3.18.2","eslint-plugin-unicorn":"^62.0.0","eslint-plugin-unused-imports":"^4.3.0","eslint-plugin-vue":"^10.6.2",globals:"^16.5.0","prettier-plugin-tailwindcss":"^0.7.2","stylelint-config-idiomatic-order":"^10.0.0","stylelint-config-standard":"^39.0.1","stylelint-prettier":"^5.0.3",tsup:"^8.5.1"},dependencies:{"@clack/prompts":"^0.11.0","@trpc/server":"^11.8.1",deepmerge:"^4.3.1",glob:"^13.0.0","jsonc-parser":"^3.3.1",nypm:"^0.6.2",oxlint:"^1.36.0","trpc-cli":"^0.12.1",zod:"^4.3.2"},packageManager:"bun@1.3.5"};f();import{spawnSync as L}from"child_process";import R from"process";import{detectPackageManager as D,dlxCommand as N}from"nypm";var u2=async(t,e)=>{let i=["check","--no-errors-on-unmatched"];e&&i.push(`--diagnostic-level=${e}`),t.length>0?i.push(...u(t)):i.push("./");let n=(await D(R.cwd()))?.name||"npm",s=N(n,"@biomejs/biome",{args:i,short:n==="npm"}),r=L(s,{stdio:"inherit",shell:!0});if(r.error)throw new Error(`Failed to run Biome: ${r.error.message}`);return{hasErrors:r.status!==0}},h2=async t=>{let e=t.length>0?u(t):["."],o=(await D(R.cwd()))?.name||"npm",n=N(o,"eslint",{args:e,short:o==="npm"}),s=L(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run ESLint: ${s.error.message}`);return{hasErrors:s.status!==0}},w2=async t=>{let e=["--check",...t.length>0?u(t):["."]],o=(await D(R.cwd()))?.name||"npm",n=N(o,"prettier",{args:e,short:o==="npm"}),s=L(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run Prettier: ${s.error.message}`);return{hasErrors:s.status!==0}},x2=async t=>{let e=t.length>0?u(t):["."],o=(await D(R.cwd()))?.name||"npm",n=N(o,"stylelint",{args:e,short:o==="npm"}),s=L(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run Stylelint: ${s.error.message}`);return{hasErrors:s.status!==0}},v2=async(t,e,i)=>{let o=[];e&&o.push("--type-aware"),i&&o.push("--type-check"),o.push(...t.length>0?u(t):["."]);let s=(await D(R.cwd()))?.name||"npm",r=N(s,"oxlint",{args:o,short:s==="npm"}),a=L(r,{stdio:"inherit",shell:!0});if(a.error)throw new Error(`Failed to run Oxlint: ${a.error.message}`);return{hasErrors:a.status!==0}},y2=async t=>{let e=["--check",...t.length>0?u(t):["."]],o=(await D(R.cwd()))?.name||"npm",n=N(o,"oxfmt",{args:e,short:o==="npm"}),s=L(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run oxfmt: ${s.error.message}`);return{hasErrors:s.status!==0}},St=async t=>{let e=t?.[0]||[],i=t?.[1]["diagnostic-level"],n=t?.[1].linter||await r1();if(!n)throw new Error("No linter configuration found. Run `ultracite init` to set up a linter.");switch(n){case"eslint":{let s=await w2(e),r=await h2(e),a=await x2(e);return{hasErrors:s.hasErrors||r.hasErrors||a.hasErrors}}case"oxlint":{let s=await y2(e),r=await v2(e,t?.[1]["type-aware"],t?.[1]["type-check"]);return{hasErrors:s.hasErrors||r.hasErrors}}default:return u2(e,i)}};import{spawnSync as j1}from"child_process";import{existsSync as A}from"fs";import{readFile as c1}from"fs/promises";import{join as O}from"path";import w from"process";import{intro as k2,log as a1,outro as S1,spinner as b2}from"@clack/prompts";import{parse as jt}from"jsonc-parser";import{detectPackageManager as l1,dlxCommand as d1}from"nypm";var z2=[".prettierrc",".prettierrc.js",".prettierrc.cjs",".prettierrc.mjs",".prettierrc.json",".prettierrc.yaml",".prettierrc.yml","prettier.config.js","prettier.config.mjs","prettier.config.cjs"],C2=[".eslintrc",".eslintrc.js",".eslintrc.cjs",".eslintrc.mjs",".eslintrc.json",".eslintrc.yaml",".eslintrc.yml","eslint.config.js","eslint.config.mjs","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts"],S2=async()=>{let e=(await l1(w.cwd()))?.name||"npm",i=d1(e,"@biomejs/biome",{args:["--version"],short:e==="npm"}),o=j1(i,{shell:!0,encoding:"utf-8"});return o.status===0&&o.stdout?{name:"Biome installation",status:"pass",message:`Biome is installed (${o.stdout.trim()})`}:{name:"Biome installation",status:"fail",message:"Biome is not installed or not accessible"}},j2=async()=>{let e=(await l1(w.cwd()))?.name||"npm",i=d1(e,"eslint",{args:["--version"],short:e==="npm"}),o=j1(i,{shell:!0,encoding:"utf-8"});return o.status===0&&o.stdout?{name:"ESLint installation",status:"pass",message:`ESLint is installed (${o.stdout.trim()})`}:{name:"ESLint installation",status:"warn",message:"ESLint is not installed (optional)"}},P2=async()=>{let e=(await l1(w.cwd()))?.name||"npm",i=d1(e,"oxlint",{args:["--version"],short:e==="npm"}),o=j1(i,{shell:!0,encoding:"utf-8"});return o.status===0&&o.stdout?{name:"Oxlint installation",status:"pass",message:`Oxlint is installed (${o.stdout.trim()})`}:{name:"Oxlint installation",status:"warn",message:"Oxlint is not installed (optional)"}},E2=async()=>{let t=O(w.cwd(),"biome.json"),e=O(w.cwd(),"biome.jsonc"),i=null;if(A(t)?i=t:A(e)&&(i=e),!i)return{name:"Biome configuration",status:"warn",message:"No biome.json or biome.jsonc file found"};try{let o=await c1(i,"utf-8"),n=jt(o);return Array.isArray(n?.extends)&&n.extends.includes("ultracite/biome/core")?{name:"Biome configuration",status:"pass",message:"biome.json(c) extends ultracite/biome/core"}:{name:"Biome configuration",status:"warn",message:"biome.json(c) exists but doesn't extend ultracite/biome/core"}}catch{return{name:"Biome configuration",status:"fail",message:"Could not parse biome.json(c) file"}}},A2=async()=>{let t=["eslint.config.mjs","eslint.config.js","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts"],e=null;for(let i of t){let o=O(w.cwd(),i);if(A(o)){e=o;break}}if(!e)return{name:"ESLint configuration",status:"warn",message:"No eslint.config.* file found (optional)"};try{return(await c1(e,"utf-8")).includes("ultracite/eslint")?{name:"ESLint configuration",status:"pass",message:"eslint.config.* imports ultracite/eslint"}:{name:"ESLint configuration",status:"warn",message:"eslint.config.* exists but doesn't import ultracite/eslint"}}catch{return{name:"ESLint configuration",status:"fail",message:"Could not read eslint.config.* file"}}},O2=async()=>{let t=O(w.cwd(),".oxlintrc.json");if(!A(t))return{name:"Oxlint configuration",status:"warn",message:"No .oxlintrc.json file found (optional)"};try{let e=await c1(t,"utf-8"),i=jt(e);return Array.isArray(i?.extends)&&i.extends.includes("ultracite/oxlint/core")?{name:"Oxlint configuration",status:"pass",message:".oxlintrc.json extends ultracite/oxlint/core"}:{name:"Oxlint configuration",status:"warn",message:".oxlintrc.json exists but doesn't extend ultracite/oxlint/core"}}catch{return{name:"Oxlint configuration",status:"fail",message:"Could not parse .oxlintrc.json file"}}},B2=async()=>{let t=O(w.cwd(),"package.json");if(!A(t))return{name:"Ultracite dependency",status:"warn",message:"No package.json found"};try{let e=JSON.parse(await c1(t,"utf-8")),i=e.dependencies?.ultracite||e.devDependencies?.ultracite||e.peerDependencies?.ultracite;return i?{name:"Ultracite dependency",status:"pass",message:`Ultracite is in package.json (${i})`}:{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"}}},I2=()=>{let t=z2.some(o=>A(O(w.cwd(),o))),i=C2.filter(o=>!o.startsWith("eslint.config")).some(o=>A(O(w.cwd(),o)));if(t||i){let o=[];return t&&o.push("Prettier"),i&&o.push("ESLint (legacy config)"),{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"}},C=async(t,e)=>{let i=b2();i.start(`Checking ${e}...`);let o=await t();return o.status==="pass"||o.status,i.stop(o.message),o},Pt=async()=>{k2(`Ultracite v${y.version} Doctor`);let e=(await l1(w.cwd()))?.name||"npm",i=d1(e,"ultracite",{args:["init"],short:e==="npm"}),o=[];o.push(await C(S2,"Biome installation")),o.push(await C(j2,"ESLint installation")),o.push(await C(P2,"Oxlint installation")),o.push(await C(E2,"Biome configuration")),o.push(await C(A2,"ESLint configuration")),o.push(await C(O2,"Oxlint configuration")),o.push(await C(B2,"Ultracite dependency")),o.push(await C(I2,"conflicting tools"));let n=o.filter(a=>a.status==="pass").length,s=o.filter(a=>a.status==="fail").length,r=o.filter(a=>a.status==="warn").length;if(a1.info(`Summary: ${n} passed, ${r} warnings, ${s} failed`),s>0)throw a1.error(`Some checks failed. Run '${i}' to fix issues.`),S1("Doctor complete"),new Error("Doctor checks failed");if(r>0){a1.warn(`Some optional improvements available. Run '${i}' to configure.`),S1("Doctor complete");return}a1.success("Everything looks good!"),S1("Doctor complete")};f();import{spawnSync as T}from"child_process";import G from"process";import{detectPackageManager as M,dlxCommand as J}from"nypm";var F2=async(t,e)=>{let i=["check","--write","--no-errors-on-unmatched"];e&&i.push("--unsafe"),t.length>0?i.push(...u(t)):i.push("./");let n=(await M(G.cwd()))?.name||"npm",s=J(n,"@biomejs/biome",{args:i,short:n==="npm"}),r=T(s,{stdio:"inherit",shell:!0});if(r.error)throw new Error(`Failed to run Biome: ${r.error.message}`);return{hasErrors:r.status!==0}},$2=async t=>{let e=["--fix",...t.length>0?u(t):["."]],o=(await M(G.cwd()))?.name||"npm",n=J(o,"eslint",{args:e,short:o==="npm"}),s=T(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run ESLint: ${s.error.message}`);return{hasErrors:s.status!==0}},_2=async t=>{let e=["--write",...t.length>0?u(t):["."]],o=(await M(G.cwd()))?.name||"npm",n=J(o,"prettier",{args:e,short:o==="npm"}),s=T(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run Prettier: ${s.error.message}`);return{hasErrors:s.status!==0}},U2=async t=>{let e=["--fix",...t.length>0?u(t):["."]],o=(await M(G.cwd()))?.name||"npm",n=J(o,"stylelint",{args:e,short:o==="npm"}),s=T(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run Stylelint: ${s.error.message}`);return{hasErrors:s.status!==0}},L2=async(t,e,i)=>{let o=["--fix"];e&&o.push("--type-aware"),i&&o.push("--type-check"),o.push(...t.length>0?u(t):["."]);let s=(await M(G.cwd()))?.name||"npm",r=J(s,"oxlint",{args:o,short:s==="npm"}),a=T(r,{stdio:"inherit",shell:!0});if(a.error)throw new Error(`Failed to run Oxlint: ${a.error.message}`);return{hasErrors:a.status!==0}},R2=async t=>{let e=["--write",...t.length>0?u(t):["."]],o=(await M(G.cwd()))?.name||"npm",n=J(o,"oxfmt",{args:e,short:o==="npm"}),s=T(n,{stdio:"inherit",shell:!0});if(s.error)throw new Error(`Failed to run oxfmt: ${s.error.message}`);return{hasErrors:s.status!==0}},Et=async(t,e={})=>{let i=e.linter||await r1();if(!i)throw new Error("No linter configuration found. Run `ultracite init` to set up a linter.");switch(i){case"eslint":{let o=await _2(t),n=await $2(t),s=await U2(t);return{hasErrors:o.hasErrors||n.hasErrors||s.hasErrors}}case"oxlint":{let o=await R2(t),n=await L2(t,e["type-aware"],e["type-check"]);return{hasErrors:o.hasErrors||n.hasErrors}}default:return F2(t,e.unsafe)}};import V3 from"process";import{cancel as V,intro as X3,isCancel as X,log as k1,multiselect as q,select as Q3,spinner as p}from"@clack/prompts";import{addDevDependency as K3,detectPackageManager as Y3}from"nypm";import{readFile as D2,writeFile as P1}from"fs/promises";var At=t=>`# Ultracite Code Standards
|
|
172
172
|
|
|
173
173
|
This project uses **Ultracite**, a zero-config Biome preset that enforces strict code quality standards through automated formatting and linting.
|
|
174
174
|
|
|
@@ -310,4 +310,4 @@ ${JSON.stringify(Kt,null,2)}
|
|
|
310
310
|
${JSON.stringify(o,null,2)}
|
|
311
311
|
`;await Qt(u1,n)}};f();import{readFile as A3,writeFile as Yt}from"fs/promises";import O3 from"deepmerge";import{parse as B3}from"jsonc-parser";var w1="./.oxlintrc.json",Zt={$schema:"./node_modules/oxlint/configuration_schema.json",extends:["ultracite/oxlint/core"]},x1={exists:async()=>await c(w1),create:async t=>{let e=["ultracite/oxlint/core"];if(t?.frameworks&&t.frameworks.length>0)for(let o of t.frameworks)e.push(`ultracite/oxlint/${o}`);let i={...Zt,extends:e};return await Yt(w1,JSON.stringify(i,null,2))},update:async t=>{let e=await A3(w1,"utf-8"),o=B3(e)||{},s=[...o.extends&&Array.isArray(o.extends)?o.extends:[]];if(s.includes("ultracite/oxlint/core")||s.push("ultracite/oxlint/core"),t?.frameworks&&t.frameworks.length>0)for(let m of t.frameworks){let h=`ultracite/oxlint/${m}`;s.includes(h)||s.push(h)}o.extends=s;let r={$schema:Zt.$schema},a=O3(o,r);await Yt(w1,JSON.stringify(a,null,2))}};f();import{readFile as I3,writeFile as qt}from"fs/promises";var F3=["./.prettierrc.mjs","./prettier.config.mjs","./.prettierrc.mts","./prettier.config.mts","./.prettierrc.cjs","./prettier.config.cjs","./.prettierrc.cts","./prettier.config.cts","./.prettierrc.js","./prettier.config.js","./.prettierrc.ts","./prettier.config.ts","./.prettierrc","./.prettierrc.json","./.prettierrc.json5","./.prettierrc.yml","./.prettierrc.yaml","./.prettierrc.toml"],te="./prettier.config.mjs",$3=async()=>{try{return"prettier"in JSON.parse(await I3("./package.json","utf-8"))}catch{return!1}},_3=async()=>{if(await $3())return"./package.json";for(let t of F3)if(await c(t))return t;return null},ee=()=>`export { default } from "ultracite/prettier";
|
|
312
312
|
`,v1={exists:async()=>await _3()!==null,create:async()=>{let t=ee();await qt(te,t)},update:async()=>{let t=ee();await qt(te,t)}};f();import{readFile as U3,writeFile as ie}from"fs/promises";var L3=["./.stylelintrc.mjs","./stylelint.config.mjs","./.stylelintrc.cjs","./stylelint.config.cjs","./.stylelintrc.js","./stylelint.config.js","./.stylelintrc","./.stylelintrc.json","./.stylelintrc.yml","./.stylelintrc.yaml"],oe="./stylelint.config.mjs",R3=async()=>{try{return"stylelint"in JSON.parse(await U3("./package.json","utf-8"))}catch{return!1}},D3=async()=>{if(await R3())return"./package.json";for(let t of L3)if(await c(t))return t;return null},ne=()=>`export { default } from "ultracite/stylelint";
|
|
313
|
-
`,y1={exists:async()=>await D3()!==null,create:async()=>{let t=ne();await ie(oe,t)},update:async()=>{let t=ne();await ie(oe,t)}};import{readFile as N3,writeFile as se}from"fs/promises";import{glob as T3}from"glob";import{applyEdits as G3,modify as M3,parse as J3}from"jsonc-parser";var re=async()=>{try{return await T3("**/tsconfig*.json",{ignore:["**/node_modules/**","**/dist/**","**/build/**","**/.next/**"],absolute:!1})}catch{return[]}},W3=t=>{if(!t)return!1;let e=t.compilerOptions;return e?e.strict===!0||e.strictNullChecks===!0:!1},H3=async t=>{try{let e=await N3(t,"utf-8"),i=J3(e);if(W3(i))return;if(i===void 0){await se(t,JSON.stringify({compilerOptions:{strictNullChecks:!0}},null,2));return}let n=M3(e,["compilerOptions","strictNullChecks"],!0,{formattingOptions:{tabSize:2,insertSpaces:!0}}),s=G3(e,n);await se(t,s)}catch(e){console.warn(`Failed to update ${t}:`,e)}},N1={exists:async()=>(await re()).length>0,update:async()=>{let t=await re();if(t.length===0){console.warn("No tsconfig.json files found in the project");return}await Promise.all(t.map(e=>H3(e)))}};f();var ae=y.devDependencies["@biomejs/biome"],T1=y.version,Z3=async(t,e="biome",i=!0,o=!1)=>{let n=p();o||n.start("Installing dependencies...");let s=[`ultracite@${T1}`];if(e==="biome"&&s.push(`@biomejs/biome@${ae}`),e==="eslint"&&(s.push("eslint@latest"),s.push("prettier@latest"),s.push("stylelint@latest")),e==="oxlint"&&(s.push("oxlint@latest"),s.push("oxfmt@latest")),i)for(let r of s)await K3(r,{packageManager:t,workspace:await z(),silent:!0});else{let r={ultracite:T1};e==="biome"&&(r["@biomejs/biome"]=ae),e==="eslint"&&(r.eslint="latest",r.prettier="latest",r.stylelint="latest"),e==="oxlint"&&(r.oxlint="latest",r.oxfmt="latest"),await k({devDependencies:r})}o||n.stop("Dependencies installed.")},q3=async(t=!1)=>{let e=p();if(t||e.start("Checking for tsconfig.json files..."),await N1.exists()){t||e.message("Found tsconfig.json files, updating with strictNullChecks..."),await N1.update(),t||e.stop("tsconfig.json files updated.");return}t||e.stop("No tsconfig.json files found, skipping.")},ti=async(t,e="biome",i=!1)=>{let o=x.find(r=>r.id===t);if(!o)throw new Error(`Editor "${t}" not found`);let n=Bt(t,e),s=p();if(i||s.start(`Checking for ${o.config.path}...`),await n.exists()){i||s.message(`${o.config.path} found, updating...`),await n.update(),i||s.stop(`${o.config.path} updated.`);return}if(i||s.message(`${o.config.path} not found, creating...`),await n.create(),n.extension){let r=s1.find(a=>a.id===e)?.vscodeExtensionId;if(!r)throw new Error(`Linter extension not found for ${e}`);i||s.message(`Installing ${r} extension...`);try{if(n.extension(r).status===0){i||s.stop(`${o.config.path} created and ${r} extension installed.`);return}}catch{}i||s.stop(`${o.config.path} created. Install ${r} extension manually.`);return}i||(t==="zed"?s.stop(`${o.config.path} created. Install the Biome extension: https://biomejs.dev/reference/zed/`):s.stop(`${o.config.path} created.`))},ei=async(t,e=!1)=>{let i=p();if(e||i.start("Checking for Biome configuration..."),await p1.exists()){e||i.message("Biome configuration found, updating..."),await p1.update({frameworks:t}),e||i.stop("Biome configuration updated.");return}e||i.message("Biome configuration not found, creating..."),await p1.create({frameworks:t}),e||i.stop("Biome configuration created.")},ii=async(t,e=!1)=>{let i=p();if(e||i.start("Checking for ESLint configuration..."),await g1.exists()){e||i.message("ESLint configuration found, updating..."),await g1.update({frameworks:t}),e||i.stop("ESLint configuration updated.");return}e||i.message("ESLint configuration not found, creating..."),await g1.create({frameworks:t}),e||i.stop("ESLint configuration created.")},oi=async(t,e=!1)=>{let i=p();if(e||i.start("Checking for Oxlint configuration..."),await x1.exists()){e||i.message("Oxlint configuration found, updating..."),await x1.update({frameworks:t}),e||i.stop("Oxlint configuration updated.");return}e||i.message("Oxlint configuration not found, creating..."),await x1.create({frameworks:t}),e||i.stop("Oxlint configuration created.")},ni=async(t=!1)=>{let e=p();if(t||e.start("Checking for Prettier configuration..."),await v1.exists()){t||e.message("Prettier configuration found, updating..."),await v1.update(),t||e.stop("Prettier configuration updated.");return}t||e.message("Prettier configuration not found, creating..."),await v1.create(),t||e.stop("Prettier configuration created.")},si=async(t=!1)=>{let e=p();if(t||e.start("Checking for Stylelint configuration..."),await y1.exists()){t||e.message("Stylelint configuration found, updating..."),await y1.update(),t||e.stop("Stylelint configuration updated.");return}t||e.message("Stylelint configuration not found, creating..."),await y1.create(),t||e.stop("Stylelint configuration created.")},ri=async(t=!1)=>{let e=p();if(t||e.start("Checking for oxfmt configuration..."),await h1.exists()){t||e.message("oxfmt configuration found, updating..."),await h1.update(),t||e.stop("oxfmt configuration updated.");return}t||e.message("oxfmt configuration not found, creating..."),await h1.create(),t||e.stop("oxfmt configuration created.")},ai=async(t,e=!0,i=!1)=>{let o=p();if(i||(o.start("Initializing pre-commit hooks..."),o.message("Installing Husky...")),e?await B.install(t):await k({devDependencies:{husky:"latest"},scripts:{prepare:"husky"}}),i||o.message("Initializing Husky..."),B.init(t),await B.exists()){i||o.message("Pre-commit hook found, updating..."),await B.update(t),i||o.stop("Pre-commit hook updated.");return}i||o.message("Pre-commit hook not found, creating..."),await B.create(t),i||o.stop("Pre-commit hook created.")},ci=async(t,e=!0,i=!1)=>{let o=p();if(i||(o.start("Initializing lefthook..."),o.message("Installing lefthook...")),e?await W.install(t):await k({devDependencies:{lefthook:"latest"}}),await W.exists()){i||o.message("lefthook.yml found, updating..."),await W.update(t),i||o.stop("lefthook.yml updated.");return}i||o.message("lefthook.yml not found, creating..."),await W.create(t),i||o.stop("lefthook.yml created.")},li=async(t,e=!0,i=!1)=>{let o=p();if(i||(o.start("Initializing lint-staged..."),o.message("Installing lint-staged...")),e?await H.install(t):await k({devDependencies:{"lint-staged":"latest"}}),await H.exists()){i||o.message("lint-staged found, updating..."),await H.update(t),i||o.stop("lint-staged updated.");return}i||o.message("lint-staged not found, creating..."),await H.create(t),i||o.stop("lint-staged created.")},di=async(t,e=!1)=>{let i=p();if(e||i.start("Initializing pre-commit..."),await Y.exists()){e||i.message(".pre-commit-config.yaml found, updating..."),await Y.update(t),e||i.stop(".pre-commit-config.yaml updated.");return}e||i.message(".pre-commit-config.yaml not found, creating..."),await Y.create(t),e||i.stop(".pre-commit-config.yaml created.")},fi=async(t,e,i,o=!1)=>{let n=p();o||n.start(`Checking for ${e}...`);let s=Ot(t,i);if(await s.exists()){o||n.message(`${e} found, updating...`),await s.update(),o||n.stop(`${e} updated.`);return}o||n.message(`${e} not found, creating...`),await s.create(),o||n.stop(`${e} created.`)},mi=async(t,e,i,o=!1)=>{let n=p();o||n.start(`Checking for ${e} hooks...`);let s=It(t,i);if(await s.exists()){o||n.message(`${e} hooks found, updating...`),await s.update(),o||n.stop(`${e} hooks updated.`);return}o||n.message(`${e} hooks not found, creating...`),await s.create(),o||n.stop(`${e} hooks created.`)},ce=async t=>{let e=t??{},i=e.quiet??!1;i||X3(`Ultracite v${T1} Initialization`);try{let{pm:o}=e;if(!o){let l=await Y3(V3.cwd());if(!l)throw new Error("No package manager specified or detected");if(!i&&l.warnings)for(let g of l.warnings)k1.warn(g);i||k1.info(`Detected lockfile, using ${l.name}`),o=l.name}let n=e.linter;if(n===void 0)if(i||e.pm||e.editors||e.agents||e.hooks||e.integrations!==void 0||e.frameworks!==void 0)n="biome";else{let g=await Q3({message:"Which linter do you want to use?",options:[{label:"Biome (Recommended)",value:"biome"},{label:"ESLint + Prettier + Stylelint",value:"eslint"},{label:"Oxlint + Oxfmt",value:"oxlint"}]});if(X(g)){V("Operation cancelled.");return}n=g}let s=e.frameworks;if(s===void 0)if(i||e.pm||e.editors||e.agents||e.hooks||e.integrations!==void 0)s=[];else{let g=await q({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(X(g)){V("Operation cancelled.");return}s=g}let r=e.editors;if(!r)if(i)r=[];else{let l=await q({message:"Which editors do you want to configure (recommended)?",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1});if(X(l)){V("Operation cancelled.");return}r=l}let a=e.agents,m=e.hooks,h=Object.fromEntries(_.map(l=>[l.id,l.name]));if(!a)if(i)a=[];else{let l=await q({message:"Which agents do you want to enable (optional)?",options:Object.entries(h).map(([g,b1])=>({value:g,label:b1})),required:!1});if(X(l)){V("Operation cancelled.");return}a=l}let j=Object.fromEntries(x.filter(l=>l.hooks).map(l=>[l.id,l.name]));if(!m)if(i)m=[];else{let l=await q({message:"Which agent hooks do you want to enable (optional)?",options:Object.entries(j).map(([g,b1])=>({value:g,label:b1})),required:!1});if(X(l)){V("Operation cancelled.");return}m=l}let P=e.integrations;if(P===void 0)if(i||e.pm||e.editors||e.agents||e.hooks)P=[];else{let g=await q({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(X(g)){V("Operation cancelled.");return}P=g}await Z3(o,n,!e.skipInstall,i),await q3(i),n==="biome"&&await ei(s,i),n==="eslint"&&(await ii(s,i),await ni(i),await si(i)),n==="oxlint"&&(await oi(s,i),await ri(i));for(let l of r??[])await ti(l,n,i);for(let l of a??[])await fi(l,h[l],o,i);for(let l of m??[])await mi(l,j[l],o,i);P?.includes("husky")&&await ai(o,!e.skipInstall,i),P?.includes("lefthook")&&await ci(o,!e.skipInstall,i),P?.includes("lint-staged")&&await li(o,!e.skipInstall,i),P?.includes("pre-commit")&&await di(o,i),i||k1.success("Successfully initialized Ultracite configuration!")}catch(o){let n=o instanceof Error?o.message:"Unknown error";throw i||k1.error(`Failed to initialize Ultracite configuration: ${n}`),o}};var t1=pi.meta().create(),hi=t1.router({init:t1.procedure.meta({description:"Initialize Ultracite in the current directory"}).input(d.object({pm:d.enum(gi.map(t=>t.name)).optional().describe("Package manager to use"),linter:d.enum(v.linters).optional().describe("Linter / formatter to use"),editors:d.array(d.enum(v.editorConfigs)).optional().describe("Editors to configure"),agents:d.array(d.enum(v.agents)).optional().describe("Agents to enable"),hooks:d.array(d.enum(v.hooks)).optional().describe("Hooks to enable"),frameworks:d.array(d.enum(v.frameworks)).optional().describe("Frameworks being used"),integrations:d.array(d.enum(v.integrations)).optional().describe("Additional integrations to enable"),migrate:d.array(d.enum(v.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:t})=>{await ce(t)}),check:t1.procedure.meta({description:"Run 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."),linter:d.enum(v.linters).optional().describe("linter to use (biome, eslint, or oxlint)")})]).optional()).query(async({input:t})=>{await St(t)}),fix:t1.procedure.meta({description:"Run linter and fix 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"),linter:d.enum(v.linters).optional().describe("linter to use (biome, eslint, or oxlint)")})]).optional()).mutation(async({input:t})=>{let[e,i]=t??[[],{}];await Et(e,{unsafe:i.unsafe,linter:i.linter})}),doctor:t1.procedure.meta({description:"Verify your Ultracite setup and check for issues"}).query(async()=>{await Pt()})}),wi=ui({router:hi,name:y.name,version:y.version,description:y.description});process.env.TEST||wi.run();export{hi as router};
|
|
313
|
+
`,y1={exists:async()=>await D3()!==null,create:async()=>{let t=ne();await ie(oe,t)},update:async()=>{let t=ne();await ie(oe,t)}};import{readFile as N3,writeFile as se}from"fs/promises";import{glob as T3}from"glob";import{applyEdits as G3,modify as M3,parse as J3}from"jsonc-parser";var re=async()=>{try{return await T3("**/tsconfig*.json",{ignore:["**/node_modules/**","**/dist/**","**/build/**","**/.next/**"],absolute:!1})}catch{return[]}},W3=t=>{if(!t)return!1;let e=t.compilerOptions;return e?e.strict===!0||e.strictNullChecks===!0:!1},H3=async t=>{try{let e=await N3(t,"utf-8"),i=J3(e);if(W3(i))return;if(i===void 0){await se(t,JSON.stringify({compilerOptions:{strictNullChecks:!0}},null,2));return}let n=M3(e,["compilerOptions","strictNullChecks"],!0,{formattingOptions:{tabSize:2,insertSpaces:!0}}),s=G3(e,n);await se(t,s)}catch(e){console.warn(`Failed to update ${t}:`,e)}},N1={exists:async()=>(await re()).length>0,update:async()=>{let t=await re();if(t.length===0){console.warn("No tsconfig.json files found in the project");return}await Promise.all(t.map(e=>H3(e)))}};f();var ae=y.devDependencies["@biomejs/biome"],T1=y.version,Z3=async(t,e="biome",i=!0,o=!1,n=!1)=>{let s=p();o||s.start("Installing dependencies...");let r=[`ultracite@${T1}`];if(e==="biome"&&r.push(`@biomejs/biome@${ae}`),e==="eslint"&&(r.push("eslint@latest"),r.push("prettier@latest"),r.push("stylelint@latest")),e==="oxlint"&&(r.push("oxlint@latest"),r.push("oxfmt@latest"),n&&r.push("oxlint-tsgolint@latest")),i)for(let a of r)await K3(a,{packageManager:t,workspace:await z(),silent:!0});else{let a={ultracite:T1};e==="biome"&&(a["@biomejs/biome"]=ae),e==="eslint"&&(a.eslint="latest",a.prettier="latest",a.stylelint="latest"),e==="oxlint"&&(a.oxlint="latest",a.oxfmt="latest",n&&(a["oxlint-tsgolint"]="latest")),await k({devDependencies:a})}o||s.stop("Dependencies installed.")},q3=async(t=!1)=>{let e=p();if(t||e.start("Checking for tsconfig.json files..."),await N1.exists()){t||e.message("Found tsconfig.json files, updating with strictNullChecks..."),await N1.update(),t||e.stop("tsconfig.json files updated.");return}t||e.stop("No tsconfig.json files found, skipping.")},ti=async(t,e="biome",i=!1)=>{let o=x.find(r=>r.id===t);if(!o)throw new Error(`Editor "${t}" not found`);let n=Bt(t,e),s=p();if(i||s.start(`Checking for ${o.config.path}...`),await n.exists()){i||s.message(`${o.config.path} found, updating...`),await n.update(),i||s.stop(`${o.config.path} updated.`);return}if(i||s.message(`${o.config.path} not found, creating...`),await n.create(),n.extension){let r=s1.find(a=>a.id===e)?.vscodeExtensionId;if(!r)throw new Error(`Linter extension not found for ${e}`);i||s.message(`Installing ${r} extension...`);try{if(n.extension(r).status===0){i||s.stop(`${o.config.path} created and ${r} extension installed.`);return}}catch{}i||s.stop(`${o.config.path} created. Install ${r} extension manually.`);return}i||(t==="zed"?s.stop(`${o.config.path} created. Install the Biome extension: https://biomejs.dev/reference/zed/`):s.stop(`${o.config.path} created.`))},ei=async(t,e=!1)=>{let i=p();if(e||i.start("Checking for Biome configuration..."),await p1.exists()){e||i.message("Biome configuration found, updating..."),await p1.update({frameworks:t}),e||i.stop("Biome configuration updated.");return}e||i.message("Biome configuration not found, creating..."),await p1.create({frameworks:t}),e||i.stop("Biome configuration created.")},ii=async(t,e=!1)=>{let i=p();if(e||i.start("Checking for ESLint configuration..."),await g1.exists()){e||i.message("ESLint configuration found, updating..."),await g1.update({frameworks:t}),e||i.stop("ESLint configuration updated.");return}e||i.message("ESLint configuration not found, creating..."),await g1.create({frameworks:t}),e||i.stop("ESLint configuration created.")},oi=async(t,e=!1)=>{let i=p();if(e||i.start("Checking for Oxlint configuration..."),await x1.exists()){e||i.message("Oxlint configuration found, updating..."),await x1.update({frameworks:t}),e||i.stop("Oxlint configuration updated.");return}e||i.message("Oxlint configuration not found, creating..."),await x1.create({frameworks:t}),e||i.stop("Oxlint configuration created.")},ni=async(t=!1)=>{let e=p();if(t||e.start("Checking for Prettier configuration..."),await v1.exists()){t||e.message("Prettier configuration found, updating..."),await v1.update(),t||e.stop("Prettier configuration updated.");return}t||e.message("Prettier configuration not found, creating..."),await v1.create(),t||e.stop("Prettier configuration created.")},si=async(t=!1)=>{let e=p();if(t||e.start("Checking for Stylelint configuration..."),await y1.exists()){t||e.message("Stylelint configuration found, updating..."),await y1.update(),t||e.stop("Stylelint configuration updated.");return}t||e.message("Stylelint configuration not found, creating..."),await y1.create(),t||e.stop("Stylelint configuration created.")},ri=async(t=!1)=>{let e=p();if(t||e.start("Checking for oxfmt configuration..."),await h1.exists()){t||e.message("oxfmt configuration found, updating..."),await h1.update(),t||e.stop("oxfmt configuration updated.");return}t||e.message("oxfmt configuration not found, creating..."),await h1.create(),t||e.stop("oxfmt configuration created.")},ai=async(t,e=!0,i=!1)=>{let o=p();if(i||(o.start("Initializing pre-commit hooks..."),o.message("Installing Husky...")),e?await B.install(t):await k({devDependencies:{husky:"latest"},scripts:{prepare:"husky"}}),i||o.message("Initializing Husky..."),B.init(t),await B.exists()){i||o.message("Pre-commit hook found, updating..."),await B.update(t),i||o.stop("Pre-commit hook updated.");return}i||o.message("Pre-commit hook not found, creating..."),await B.create(t),i||o.stop("Pre-commit hook created.")},ci=async(t,e=!0,i=!1)=>{let o=p();if(i||(o.start("Initializing lefthook..."),o.message("Installing lefthook...")),e?await W.install(t):await k({devDependencies:{lefthook:"latest"}}),await W.exists()){i||o.message("lefthook.yml found, updating..."),await W.update(t),i||o.stop("lefthook.yml updated.");return}i||o.message("lefthook.yml not found, creating..."),await W.create(t),i||o.stop("lefthook.yml created.")},li=async(t,e=!0,i=!1)=>{let o=p();if(i||(o.start("Initializing lint-staged..."),o.message("Installing lint-staged...")),e?await H.install(t):await k({devDependencies:{"lint-staged":"latest"}}),await H.exists()){i||o.message("lint-staged found, updating..."),await H.update(t),i||o.stop("lint-staged updated.");return}i||o.message("lint-staged not found, creating..."),await H.create(t),i||o.stop("lint-staged created.")},di=async(t,e=!1)=>{let i=p();if(e||i.start("Initializing pre-commit..."),await Y.exists()){e||i.message(".pre-commit-config.yaml found, updating..."),await Y.update(t),e||i.stop(".pre-commit-config.yaml updated.");return}e||i.message(".pre-commit-config.yaml not found, creating..."),await Y.create(t),e||i.stop(".pre-commit-config.yaml created.")},fi=async(t,e,i,o=!1)=>{let n=p();o||n.start(`Checking for ${e}...`);let s=Ot(t,i);if(await s.exists()){o||n.message(`${e} found, updating...`),await s.update(),o||n.stop(`${e} updated.`);return}o||n.message(`${e} not found, creating...`),await s.create(),o||n.stop(`${e} created.`)},mi=async(t,e,i,o=!1)=>{let n=p();o||n.start(`Checking for ${e} hooks...`);let s=It(t,i);if(await s.exists()){o||n.message(`${e} hooks found, updating...`),await s.update(),o||n.stop(`${e} hooks updated.`);return}o||n.message(`${e} hooks not found, creating...`),await s.create(),o||n.stop(`${e} hooks created.`)},ce=async t=>{let e=t??{},i=e.quiet??!1;i||X3(`Ultracite v${T1} Initialization`);try{let{pm:o}=e;if(!o){let d=await Y3(V3.cwd());if(!d)throw new Error("No package manager specified or detected");if(!i&&d.warnings)for(let g of d.warnings)k1.warn(g);i||k1.info(`Detected lockfile, using ${d.name}`),o=d.name}let n=e.linter;if(n===void 0)if(i||e.pm||e.editors||e.agents||e.hooks||e.integrations!==void 0||e.frameworks!==void 0)n="biome";else{let g=await Q3({message:"Which linter do you want to use?",options:[{label:"Biome (Recommended)",value:"biome"},{label:"ESLint + Prettier + Stylelint",value:"eslint"},{label:"Oxlint + Oxfmt",value:"oxlint"}]});if(X(g)){V("Operation cancelled.");return}n=g}let s=e.frameworks;if(s===void 0)if(i||e.pm||e.editors||e.agents||e.hooks||e.integrations!==void 0)s=[];else{let g=await q({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(X(g)){V("Operation cancelled.");return}s=g}let r=e.editors;if(!r)if(i)r=[];else{let d=await q({message:"Which editors do you want to configure (recommended)?",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1});if(X(d)){V("Operation cancelled.");return}r=d}let a=e.agents,m=e.hooks,h=Object.fromEntries(_.map(d=>[d.id,d.name]));if(!a)if(i)a=[];else{let d=await q({message:"Which agents do you want to enable (optional)?",options:Object.entries(h).map(([g,b1])=>({value:g,label:b1})),required:!1});if(X(d)){V("Operation cancelled.");return}a=d}let j=Object.fromEntries(x.filter(d=>d.hooks).map(d=>[d.id,d.name]));if(!m)if(i)m=[];else{let d=await q({message:"Which agent hooks do you want to enable (optional)?",options:Object.entries(j).map(([g,b1])=>({value:g,label:b1})),required:!1});if(X(d)){V("Operation cancelled.");return}m=d}let P=e.integrations;if(P===void 0)if(i||e.pm||e.editors||e.agents||e.hooks)P=[];else{let g=await q({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(X(g)){V("Operation cancelled.");return}P=g}await Z3(o,n,!e.skipInstall,i,n==="oxlint"&&e["type-aware"]),await q3(i),n==="biome"&&await ei(s,i),n==="eslint"&&(await ii(s,i),await ni(i),await si(i)),n==="oxlint"&&(await oi(s,i),await ri(i));for(let d of r??[])await ti(d,n,i);for(let d of a??[])await fi(d,h[d],o,i);for(let d of m??[])await mi(d,j[d],o,i);P?.includes("husky")&&await ai(o,!e.skipInstall,i),P?.includes("lefthook")&&await ci(o,!e.skipInstall,i),P?.includes("lint-staged")&&await li(o,!e.skipInstall,i),P?.includes("pre-commit")&&await di(o,i),i||k1.success("Successfully initialized Ultracite configuration!")}catch(o){let n=o instanceof Error?o.message:"Unknown error";throw i||k1.error(`Failed to initialize Ultracite configuration: ${n}`),o}};var t1=pi.meta().create(),hi=t1.router({init:t1.procedure.meta({description:"Initialize Ultracite in the current directory"}).input(l.object({pm:l.enum(gi.map(t=>t.name)).optional().describe("Package manager to use"),linter:l.enum(v.linters).optional().describe("Linter / formatter to use"),editors:l.array(l.enum(v.editorConfigs)).optional().describe("Editors to configure"),agents:l.array(l.enum(v.agents)).optional().describe("Agents to enable"),hooks:l.array(l.enum(v.hooks)).optional().describe("Hooks to enable"),frameworks:l.array(l.enum(v.frameworks)).optional().describe("Frameworks being used"),integrations:l.array(l.enum(v.integrations)).optional().describe("Additional integrations to enable"),migrate:l.array(l.enum(v.migrations)).optional().describe("Migration tools to remove (e.g., eslint, prettier). Removes dependencies, config files, and editor settings."),"type-aware":l.boolean().optional().describe("enable type-aware linting (oxlint only, installs oxlint-tsgolint)"),skipInstall:l.boolean().default(!1).describe("Skip installing dependencies"),quiet:l.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 ce(t)}),check:t1.procedure.meta({description:"Run linter without fixing files"}).input(l.tuple([l.array(l.string()).optional().default([]).describe("specific files to lint"),l.object({"diagnostic-level":l.enum(["info","warn","error"]).optional().describe("level of diagnostics to show. In order, from the lowest to the most important: info, warn, error."),linter:l.enum(v.linters).optional().describe("linter to use (biome, eslint, or oxlint)"),"type-aware":l.boolean().optional().describe("enable type-aware linting rules (oxlint only)"),"type-check":l.boolean().optional().describe("enable TypeScript compiler diagnostics (oxlint only)")})]).optional()).query(async({input:t})=>{await St(t)}),fix:t1.procedure.meta({description:"Run linter and fix files"}).input(l.tuple([l.array(l.string()).optional().default([]).describe("specific files to format"),l.object({unsafe:l.boolean().optional().describe("apply unsafe fixes"),linter:l.enum(v.linters).optional().describe("linter to use (biome, eslint, or oxlint)"),"type-aware":l.boolean().optional().describe("enable type-aware linting rules (oxlint only)"),"type-check":l.boolean().optional().describe("enable TypeScript compiler diagnostics (oxlint only)")})]).optional()).mutation(async({input:t})=>{let[e,i]=t??[[],{}];await Et(e,{unsafe:i.unsafe,linter:i.linter,"type-aware":i["type-aware"],"type-check":i["type-check"]})}),doctor:t1.procedure.meta({description:"Verify your Ultracite setup and check for issues"}).query(async()=>{await Pt()})}),wi=ui({router:hi,name:y.name,version:y.version,description:y.description});process.env.TEST||wi.run();export{hi as router};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ultracite",
|
|
3
3
|
"description": "The AI-ready formatter that helps you write and generate code faster.",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"ultracite": "dist/index.js"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"url": "git+https://github.com/haydenbleasel/ultracite.git"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@biomejs/biome": "2.3.
|
|
50
|
+
"@biomejs/biome": "2.3.11",
|
|
51
51
|
"@eslint/js": "^9.39.2",
|
|
52
52
|
"@next/eslint-plugin-next": "^16.1.1",
|
|
53
53
|
"@repo/data": "workspace:*",
|