adamantite 0.30.2 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -21
- package/dist/index.js +27 -22
- package/dist/presets/lint/core.d.ts +0 -1
- package/dist/presets/lint/core.js +0 -1
- package/package.json +12 -11
- package/presets/lint/core.ts +0 -1
package/README.md
CHANGED
|
@@ -37,10 +37,9 @@ npx adamantite init
|
|
|
37
37
|
Adamantite will automatically configure your project with linting, formatting, and type-safety rules.
|
|
38
38
|
|
|
39
39
|
```shell
|
|
40
|
-
adamantite check # Check code for issues
|
|
40
|
+
adamantite check # Check code for issues and type errors using oxlint
|
|
41
41
|
adamantite fix # Fix code issues using oxlint
|
|
42
42
|
adamantite format # Format code using oxfmt
|
|
43
|
-
adamantite typecheck # Run TypeScript type checking using the strict preset
|
|
44
43
|
adamantite monorepo # Check monorepo for dependency issues using Sherif
|
|
45
44
|
adamantite update # Update Adamantite's dependencies to the latest compatible versions
|
|
46
45
|
```
|
|
@@ -78,7 +77,7 @@ This interactive command will:
|
|
|
78
77
|
|
|
79
78
|
### `adamantite check`
|
|
80
79
|
|
|
81
|
-
Check your code for issues without automatically fixing them using oxlint:
|
|
80
|
+
Check your code for issues and type errors without automatically fixing them using oxlint:
|
|
82
81
|
|
|
83
82
|
```shell
|
|
84
83
|
# Check all files
|
|
@@ -97,7 +96,7 @@ Fix issues in your code with automatic formatting and safe fixes:
|
|
|
97
96
|
adamantite fix
|
|
98
97
|
|
|
99
98
|
# Fix specific files
|
|
100
|
-
adamantite fix src/
|
|
99
|
+
adamantite fix src/index.ts
|
|
101
100
|
|
|
102
101
|
# Apply suggested fixes
|
|
103
102
|
adamantite fix --suggested
|
|
@@ -118,7 +117,7 @@ Format your code using oxfmt:
|
|
|
118
117
|
adamantite format
|
|
119
118
|
|
|
120
119
|
# Format specific files
|
|
121
|
-
adamantite format src/
|
|
120
|
+
adamantite format src/index.ts
|
|
122
121
|
|
|
123
122
|
# Check if files are formatted without writing
|
|
124
123
|
adamantite format --check
|
|
@@ -143,24 +142,12 @@ Automatically detects and fixes:
|
|
|
143
142
|
- Unused dependencies
|
|
144
143
|
- Package.json formatting issues
|
|
145
144
|
|
|
146
|
-
### `adamantite typecheck`
|
|
147
|
-
|
|
148
|
-
Run TypeScript type checking using tsc and the strict preset:
|
|
149
|
-
|
|
150
|
-
```shell
|
|
151
|
-
# Type check all files
|
|
152
|
-
adamantite typecheck
|
|
153
|
-
|
|
154
|
-
# Type check a specific project
|
|
155
|
-
adamantite typecheck --project tsconfig.json
|
|
156
|
-
```
|
|
157
|
-
|
|
158
145
|
### `adamantite update`
|
|
159
146
|
|
|
160
|
-
|
|
147
|
+
Run applicable migrations and update Adamantite-managed dependencies:
|
|
161
148
|
|
|
162
149
|
```shell
|
|
163
|
-
#
|
|
150
|
+
# Run migrations and update managed dependencies
|
|
164
151
|
adamantite update
|
|
165
152
|
```
|
|
166
153
|
|
|
@@ -215,8 +202,8 @@ bun test
|
|
|
215
202
|
# Build CLI
|
|
216
203
|
bun run build
|
|
217
204
|
|
|
218
|
-
#
|
|
219
|
-
bun run
|
|
205
|
+
# Linting and type checking
|
|
206
|
+
bun run check
|
|
220
207
|
```
|
|
221
208
|
|
|
222
209
|
## 🤝 Contributing
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import*as
|
|
2
|
-
`)}class
|
|
3
|
-
`)}}class
|
|
4
|
-
`).
|
|
5
|
-
`).pipe(
|
|
6
|
-
`)
|
|
7
|
-
`)}
|
|
8
|
-
`)
|
|
9
|
-
`).pipe(
|
|
10
|
-
`).pipe(F.mapError((y)=>new z({cause:y,path:$})))}),version:"0.35.0"};var L$=aa.file("files",{mustExist:!0}).pipe(aa.withDescription("Specific files to format (optional)"),aa.variadic()),j$=ja.boolean("check").pipe(ja.withDescription("Check if files are formatted without writing")),Wg=ga.make("format",{check:j$,files:L$}).pipe(ga.withDescription("Format files using oxfmt"),ga.withHandler(({check:a,files:g})=>jg.gen(function*(){let $=yield*b,D=[];if(a)D.push("--check");D.push(...g);let l=yield*$.run({args:D,command:K.name});if(l!==Ag.ExitCode(0))yield*new L({command:K.name,exitCode:l})})));import u$ from"node:process";import*as T from"effect/Effect";import*as Fg from"effect/FileSystem";import*as Ig from"effect/Path";import*as Da from"effect/unstable/cli/Command";import*as C from"effect/Effect";import*as Aa from"effect/FileSystem";import*as Wa from"effect/Path";import{runScriptCommand as A$}from"nypm";var W$={bun:` - name: Setup Node.js
|
|
1
|
+
import*as Nr from"@effect/platform-node/NodeRuntime";import*as er from"@effect/platform-node/NodeServices";import*as H from"effect/Effect";import*as Pr from"effect/Exit";import*as hr from"effect/Layer";import*as or from"effect/Runtime";import*as p from"effect/unstable/cli/Command";import*as Or from"effect/unstable/process/ChildProcessSpawner";import*as Ll from"effect/Effect";import*as mf from"effect/unstable/cli/Command";import*as Ef from"effect/unstable/cli/Flag";import*as Bl from"effect/unstable/process/ChildProcessSpawner";import*as w from"effect/Effect";import*as Lf from"effect/FileSystem";import*as Bf from"effect/Path";function C(f){return f}import*as z from"effect/Data";import{printParseErrorCode as Cr}from"jsonc-parser";function Rr(f=[]){if(f.length===0)return"- Unknown JSON/JSONC parsing error";return f.slice(0,3).map((r)=>`- ${Cr(r.error)} (offset: ${r.offset})`).join(`
|
|
2
|
+
`)}class fl extends z.TaggedError("CliNotFound"){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}}class W extends z.TaggedError("CommandFailed"){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}}class c extends z.TaggedError("FailedToCreateDirectory"){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:"the target directory"}.`}}class ll extends z.TaggedError("FailedToInstallDependency"){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(", ")}`:""}.`}}class Uf extends z.TaggedError("FailedToInstallExtension"){get message(){return`Failed to install ${this.extension?`\`${this.extension}\``:"the target extension"}.`}}class rl extends z.TaggedError("FailedToMergeConfig"){get message(){return`Failed to merge configuration.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class Fl extends z.TaggedError("FailedToParseFile"){get message(){return[`Failed to parse ${this.path?`\`${this.path}\``:"the target file"}.`,"Please fix the JSON/JSONC syntax and run the command again.","","Parse details:",Rr(this.errors)].join(`
|
|
3
|
+
`)}}class X extends z.TaggedError("FailedToReadFile"){get message(){return`Failed to read ${this.path?`\`${this.path}\``:"the target file"}.`}}class al extends z.TaggedError("FailedToDeleteFile"){get message(){return`Failed to delete ${this.path?`\`${this.path}\``:"the target file"}.`}}class M extends z.TaggedError("FailedToWriteFile"){get message(){return`Failed to write ${this.path?`\`${this.path}\``:"the target file"}.`}}class ff extends z.TaggedError("FileNotFound"){get message(){return this.path?`File not found: \`${this.path}\`.`:"File not found."}}class Y extends z.TaggedError("InvalidConfigFormat"){get message(){return`Invalid config format in ${this.path?`\`${this.path}\``:"the target config file"}. The config must be a JSON object (for example: {}).`}}class Sf extends z.TaggedError("NoPackageManager"){get message(){return`No package manager detected. Please run this command from a project with a lockfile.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class kr extends z.TaggedError("MissingPackageVersion"){get message(){return`Missing version field in ${this.path?`\`${this.path}\``:"package.json"}.`}}class P extends z.TaggedError("MigrationValidationFailed"){get message(){return`Migration \`${this.migrationId}\` validation failed. ${this.reason}`}}class Wf extends z.TaggedError("OperationCancelled"){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:""}`}}class ml extends z.TaggedError("UnknownScript"){get message(){return`Unknown script: \`${this.script}\`.`}}class El extends z.TaggedError("VscodeCliNotFound"){get message(){return`VS Code CLI (\`code\`) not found. Please install it to manage extensions.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}import{defu as wr}from"defu";import*as h from"effect/Effect";import{parse as xr}from"jsonc-parser";var S=(f,r)=>h.sync(()=>{let l=[],F=xr(f,l,{allowTrailingComma:!0});return{errors:l,parsed:F}}).pipe(h.flatMap(({errors:l,parsed:F})=>l.length>0?h.fail(new Fl({errors:l,path:r})):h.succeed(F)));function _(f){return f!==null&&typeof f==="object"&&!Array.isArray(f)}var o=(f,r)=>h.try({catch:(l)=>new rl({cause:l}),try:()=>wr(f,r)});var Yf={$schema:"https://unpkg.com/knip@5/schema.json",rules:{files:"error",dependencies:"error",devDependencies:"error",optionalPeerDependencies:"warn",unlisted:"error",binaries:"error",unresolved:"error",exports:"warn",nsExports:"warn",types:"warn",nsTypes:"warn",enumMembers:"off",classMembers:"off",duplicates:"warn"},ignoreExportsUsedInFile:!0,ignoreFiles:["**/dist/**","**/build/**","**/coverage/**","**/.next/**","**/.vercel/**","**/.turbo/**"],ignore:["**/*.d.ts"]};var _f="knip.json",Ul="knip.jsonc",L=C({config:Yf,create:(f)=>w.gen(function*(){let r=yield*Lf.FileSystem,F=(yield*Bf.Path).join(f,_f),a=JSON.stringify(Yf,null,2);yield*r.writeFileString(F,`${a}
|
|
4
|
+
`).pipe(w.mapError((m)=>new M({cause:m,path:F})))}),exists:(f)=>w.gen(function*(){let r=yield*Lf.FileSystem,l=yield*Bf.Path,F=l.join(f,_f),a=l.join(f,Ul);if(yield*r.exists(F))return{path:F};if(yield*r.exists(a))return{path:a};return{path:null}}),name:"knip",update:(f)=>w.gen(function*(){let r=yield*Lf.FileSystem,l=yield*Bf.Path,F=l.join(f,_f),a=l.join(f,Ul),m=(yield*r.exists(F))?F:(yield*r.exists(a))?a:null;if(!m)return yield*new ff({path:_f});let E=yield*r.readFileString(m).pipe(w.mapError((v)=>new X({cause:v,path:m}))),y=yield*S(E,m);if(!_(y))return yield*new Y({path:m});let u=yield*o(y,Yf),T=m.endsWith(".jsonc");u.$schema=T?"https://unpkg.com/knip@5/schema-jsonc.json":"https://unpkg.com/knip@5/schema.json",yield*r.writeFileString(m,`${JSON.stringify(u,null,2)}
|
|
5
|
+
`).pipe(w.mapError((v)=>new M({cause:v,path:m})))}),version:"5.86.0"});import*as x from"effect/Effect";import*as Wl from"effect/Layer";import*as Yl from"effect/ServiceMap";import*as _l from"effect/unstable/process/ChildProcess";class q extends Yl.Service()("CommandRunner"){static layer=Wl.succeed(this)({run:({args:f,command:r,cwd:l,stderr:F="inherit",stdin:a="ignore",stdout:m="inherit"})=>x.mapError(x.scoped(x.gen(function*(){return yield*(yield*x.fromYieldable(_l.make(r,f,{cwd:l,stderr:F,stdin:a,stdout:m}))).exitCode})),(E)=>E.reason._tag==="NotFound"?new fl({command:r}):E)})}var br=Ef.boolean("fix").pipe(Ef.withDescription("Automatically fix issues")),tr=Ef.boolean("strict").pipe(Ef.withDescription("Enable strict mode")),Gl=mf.make("analyze",{fix:br,strict:tr}).pipe(mf.withDescription("Find unused dependencies, exports, and files using knip"),mf.withHandler(({fix:f,strict:r})=>Ll.gen(function*(){let l=yield*q,F=[];if(f)F.push("--fix","--allow-remove-files");if(r)F.push("--production","--strict");let a=yield*l.run({args:F,command:L.name});if(a!==Bl.ExitCode(0))yield*new W({command:L.name,exitCode:a})})));import*as el from"effect/Effect";import*as yf from"effect/unstable/cli/Argument";import*as vf from"effect/unstable/cli/Command";import*as Pl from"effect/unstable/process/ChildProcessSpawner";import*as R from"effect/Effect";import*as Af from"effect/FileSystem";import*as Jf from"effect/Path";var Gf="oxlint.config.ts",yl=".oxlintrc.json",nr=/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/,sr=/^adamantite\/lint(?:\/([a-z0-9-]+))?$/;function Al(f=[]){return f.includes("core")?f:["core",...f]}function Jl(f){return f.replaceAll(/-([a-z])/g,(r,l)=>l.toUpperCase())}function Nl(f,r,l=[]){let{options:F,...a}=f,m=['import { defineConfig } from "oxlint"',...r.map((V)=>`import ${Jl(V)} from "${V==="core"?"adamantite/lint":`adamantite/lint/${V}`}"`)],y=[...r.map((V)=>Jl(V)),...l.map((V)=>JSON.stringify(V))],u=JSON.stringify(_(F)?{...F,typeAware:!0,typeCheck:!0}:{typeAware:!0,typeCheck:!0},null,2),T=Object.entries(a).map(([V,Z])=>[V,JSON.stringify(Z,null,2)]),v=`[${y.join(", ")}]`,i=[["options",u],...T,["extends",v]].map(([V,Z])=>` ${V}: ${Z},`).join(`
|
|
6
|
+
`);return[...m,"","export default defineConfig({",i,"})",""].join(`
|
|
7
|
+
`)}var $=C({create:(f,r=[])=>R.gen(function*(){let l=yield*Af.FileSystem,a=(yield*Jf.Path).join(f,Gf),m=Nl({},Al(r));yield*l.writeFileString(a,m).pipe(R.mapError((E)=>new M({cause:E,path:a})))}),exists:(f)=>R.gen(function*(){let r=yield*Af.FileSystem,l=yield*Jf.Path,F=l.join(f,Gf),a=l.join(f,yl),m=yield*r.exists(F),E=yield*r.exists(a),y=m?"ts":E?"json":null;return{format:y,hasBoth:m&&E,jsonPath:E?a:null,path:y==="ts"?F:y==="json"?a:null,tsPath:m?F:null}}),name:"oxlint",update:(f,r=[])=>R.gen(function*(){let l=yield*Af.FileSystem,F=yield*Jf.Path,a=F.join(f,Gf),m=F.join(f,yl),E=yield*l.exists(a),y=yield*l.exists(m);if(E)return;if(!y)return yield*new ff({path:yl});let u=m,T=F.join(f,Gf),v=yield*l.readFileString(u).pipe(R.mapError((e)=>new X({cause:e,path:u}))),i=yield*S(v,u);if(!_(i))return yield*new Y({path:u});let{$schema:V,...Z}=i,cf=Array.isArray(Z.extends)?Z.extends.filter((e)=>typeof e==="string"):typeof Z.extends==="string"?[Z.extends]:[],Kf=new Set(Al(r)),j=new Set;for(let e of cf){let jr=e.match(nr),Hl=e.match(sr),Sl=jr?.[1]??(Hl?Hl[1]??"core":null);if(Sl)Kf.add(Sl);else j.add(e)}let{extends:Hf,...Ir}=Z;yield*l.writeFileString(T,Nl(Ir,[...Kf],[...j])).pipe(R.mapError((e)=>new M({cause:e,path:T}))),yield*l.remove(u).pipe(R.mapError((e)=>new al({cause:e,path:u})))}),version:"1.55.0"}),lf=C({name:"oxlint-tsgolint",version:"0.17.0"});var pr=yf.file("files",{mustExist:!0}).pipe(yf.withDescription("Specific files to lint (optional)"),yf.variadic()),hl=vf.make("check",{files:pr}).pipe(vf.withDescription("Find issues and type errors in code using oxlint"),vf.withHandler(({files:f})=>el.gen(function*(){let l=yield*(yield*q).run({args:[...f],command:$.name});if(l!==Pl.ExitCode(0))yield*new W({command:$.name,exitCode:l})})));import*as ol from"effect/Effect";import*as Tf from"effect/unstable/cli/Argument";import*as $f from"effect/unstable/cli/Command";import*as d from"effect/unstable/cli/Flag";import*as Ol from"effect/unstable/process/ChildProcessSpawner";var cr=Tf.file("files",{mustExist:!0}).pipe(Tf.withDescription("Specific files to fix (optional)"),Tf.variadic()),fF=d.boolean("suggested").pipe(d.withDescription("Apply suggested fixes")),lF=d.boolean("dangerous").pipe(d.withDescription("Apply dangerous fixes")),rF=d.boolean("all").pipe(d.withDescription("Apply all fixes, including suggested and dangerous fixes")),Il=$f.make("fix",{all:rF,dangerous:lF,files:cr,suggested:fF}).pipe($f.withDescription("Fix issues in code using oxlint"),$f.withHandler(({all:f,dangerous:r,files:l,suggested:F})=>ol.gen(function*(){let a=yield*q,m=new Set(["--fix"]);if(F||f)m.add("--fix-suggestions");if(r||f)m.add("--fix-dangerously");for(let y of l)m.add(y);let E=yield*a.run({args:[...m],command:$.name});if(E!==Ol.ExitCode(0))yield*new W({command:$.name,exitCode:E})})));import*as Cl from"effect/Effect";import*as uf from"effect/unstable/cli/Argument";import*as Df from"effect/unstable/cli/Command";import*as of from"effect/unstable/cli/Flag";import*as Rl from"effect/unstable/process/ChildProcessSpawner";import*as b from"effect/Effect";import*as Pf from"effect/FileSystem";import*as hf from"effect/Path";var Nf={$schema:"../node_modules/oxfmt/configuration_schema.json",arrowParens:"always",bracketSameLine:!1,bracketSpacing:!0,embeddedLanguageFormatting:"auto",endOfLine:"lf",sortImports:{groups:[["value-builtin","type-import"],["value-external"],["type-internal"],["value-internal"],["type-subpath"],["value-subpath"],["type-parent","type-sibling","type-index"],["value-parent","value-sibling","value-index"],["unknown"]],ignoreCase:!0,newlinesBetween:!1,partitionByNewline:!0,order:"asc",partitionByComment:!0,sortSideEffects:!1},sortTailwindcss:{attributes:["className","class"],functions:["clsx","cn","cva","tw","twMerge"],preserveDuplicates:!1,preserveWhitespace:!1},insertFinalNewline:!0,jsxSingleQuote:!1,objectWrap:"preserve",printWidth:100,quoteProps:"as-needed",semi:!1,singleAttributePerLine:!1,singleQuote:!1,tabWidth:2,trailingComma:"es5",useTabs:!1};var ef=".oxfmtrc.jsonc",jl=".oxfmtrc.json",B=C({config:{...Nf,$schema:"./node_modules/oxfmt/configuration_schema.json"},create:(f)=>b.gen(function*(){let r=yield*Pf.FileSystem,F=(yield*hf.Path).join(f,ef),a=JSON.stringify({...Nf,$schema:"./node_modules/oxfmt/configuration_schema.json"},null,2);yield*r.writeFileString(F,`${a}
|
|
8
|
+
`).pipe(b.mapError((m)=>new M({cause:m,path:F})))}),exists:(f)=>b.gen(function*(){let r=yield*Pf.FileSystem,l=yield*hf.Path,F=l.join(f,ef),a=l.join(f,jl);if(yield*r.exists(F))return{path:F};if(yield*r.exists(a))return{path:a};return{path:null}}),name:"oxfmt",update:(f)=>b.gen(function*(){let r=yield*Pf.FileSystem,l=yield*hf.Path,F=l.join(f,ef),a=l.join(f,jl),m=(yield*r.exists(F))?F:(yield*r.exists(a))?a:null;if(!m)return yield*new ff({path:ef});let E=yield*r.readFileString(m).pipe(b.mapError((T)=>new X({cause:T,path:m}))),y=yield*S(E,m);if(!_(y))return yield*new Y({path:m});let u=yield*o(y,{...Nf,$schema:"./node_modules/oxfmt/configuration_schema.json"});u.$schema="./node_modules/oxfmt/configuration_schema.json",yield*r.writeFileString(m,`${JSON.stringify(u,null,2)}
|
|
9
|
+
`).pipe(b.mapError((T)=>new M({cause:T,path:m})))}),version:"0.40.0"});var aF=uf.file("files",{mustExist:!0}).pipe(uf.withDescription("Specific files to format (optional)"),uf.variadic()),mF=of.boolean("check").pipe(of.withDescription("Check if files are formatted without writing")),kl=Df.make("format",{check:mF,files:aF}).pipe(Df.withDescription("Format files using oxfmt"),Df.withHandler(({check:f,files:r})=>Cl.gen(function*(){let l=yield*q,F=[];if(f)F.push("--check");F.push(...r);let a=yield*l.run({args:F,command:B.name});if(a!==Rl.ExitCode(0))yield*new W({command:B.name,exitCode:a})})));import gF from"node:process";import*as D from"effect/Effect";import*as vr from"effect/FileSystem";import*as Tr from"effect/Path";import*as Vf from"effect/unstable/cli/Command";import*as rf from"effect/Effect";import*as If from"effect/FileSystem";import*as jf from"effect/Path";import{runScriptCommand as EF}from"nypm";import*as Of from"effect/Effect";import*as wl from"effect/FileSystem";var xl=(f)=>Of.gen(function*(){yield*(yield*wl.FileSystem).makeDirectory(f,{recursive:!0}).pipe(Of.mapError((l)=>new c({cause:l,path:f})))});var yF={bun:` - name: Setup Node.js
|
|
11
10
|
uses: actions/setup-node@v6
|
|
12
11
|
with:
|
|
13
12
|
node-version: "22"
|
|
@@ -54,7 +53,7 @@ import*as wg from"@effect/platform-node/NodeRuntime";import*as eg from"@effect/p
|
|
|
54
53
|
cache: "yarn"
|
|
55
54
|
|
|
56
55
|
- name: Install dependencies
|
|
57
|
-
run: yarn install --frozen-lockfile`},
|
|
56
|
+
run: yarn install --frozen-lockfile`},bl=[{name:"lint",script:"check"},{args:["--check"],name:"format",script:"format"},{name:"monorepo",script:"check:monorepo"},{name:"analyze",script:"analyze"}];function dl({packageManager:f,scripts:r}){let l=[];for(let m of bl){if(!r.includes(m.script))continue;l.push({command:EF(f,m.script,{args:m.args}),name:m.name})}if(l.length===0)return null;return`${`name: adamantite
|
|
58
57
|
|
|
59
58
|
on:
|
|
60
59
|
push:
|
|
@@ -79,23 +78,29 @@ jobs:
|
|
|
79
78
|
fail-fast: false
|
|
80
79
|
matrix:
|
|
81
80
|
include:
|
|
82
|
-
${
|
|
83
|
-
command: ${
|
|
81
|
+
${l.map((m)=>` - name: ${m.name}
|
|
82
|
+
command: ${m.command}`).join(`
|
|
84
83
|
`)}
|
|
85
84
|
|
|
86
85
|
steps:
|
|
87
86
|
- name: Checkout
|
|
88
87
|
uses: actions/checkout@v4
|
|
89
88
|
|
|
90
|
-
${
|
|
89
|
+
${yF[f]}
|
|
91
90
|
|
|
92
91
|
- name: Run \${{ matrix.name }}
|
|
93
92
|
run: \${{ matrix.command }}`}
|
|
94
|
-
`}var
|
|
95
|
-
`).pipe(
|
|
96
|
-
`).pipe(
|
|
97
|
-
`).pipe(
|
|
98
|
-
`).pipe(
|
|
99
|
-
`).
|
|
100
|
-
`).pipe(
|
|
101
|
-
`).pipe(T.mapError((f)=>new z({cause:f,path:E}))),y.stop("Scripts added to your `package.json`")}),r$=(a)=>T.gen(function*(){let $=(yield*Q).spinner();$.start("Setting up knip config...");let D=yield*M.exists(a);if(D.path)$.message(`Found \`${D.path}\`, updating...`),yield*M.update(a),$.stop("knip config updated successfully.");else $.message("`knip.json` not found, creating..."),yield*M.create(a),$.stop("knip config created successfully.")}),F$=(a)=>T.gen(function*(){let $=(yield*Q).spinner();if($.start("Setting up TypeScript config..."),yield*S.exists(a))$.message("`tsconfig.json` found, updating..."),yield*S.update(a),$.stop("`tsconfig.json` updated successfully");else $.message("`tsconfig.json` not found, creating..."),yield*S.create(a),$.stop("`tsconfig.json` created successfully")}),I$=(a,g)=>T.gen(function*(){let $=yield*Q;if(g.includes("vscode")){let D=$.spinner();if(D.start("Checking for `.vscode/settings.json`..."),yield*I.exists(a))D.message("`.vscode/settings.json` found, updating..."),yield*I.update(a),D.stop("`.vscode/settings.json` updated with Adamantite preset.");else D.message("`.vscode/settings.json` not found, creating..."),yield*I.create(a),D.stop("`.vscode/settings.json` created with Adamantite preset.")}if(g.includes("zed")){let D=$.spinner();if(D.start("Checking for `.zed/settings.json`..."),yield*$a.exists(a))D.message("`.zed/settings.json` found, updating..."),yield*$a.update(a),D.stop("`.zed/settings.json` updated with Adamantite preset.");else D.message("`.zed/settings.json` not found, creating..."),yield*$a.create(a),D.stop("`.zed/settings.json` created with Adamantite preset.")}}),k$=(a,g)=>T.gen(function*(){let $=yield*Q,D=$.spinner();D.start("Installing editor extensions...");let l=a.includes("zed"),v=a.includes("vscode");if(yield*T.gen(function*(){if(a.includes("vscode"))D.message("Installing VS Code extension..."),yield*I.extension(g);return!0}).pipe(T.tapError(()=>T.sync(()=>{D.stop()})),T.catchTag("FailedToInstallExtension",(E)=>T.gen(function*(){return yield*$.log.warning(`⚠️ Failed to install the \`${E.extension}\` extension.`),yield*$.log.warning("Please install it manually after setup completes."),!1})),T.catchTag("VscodeCliNotFound",()=>T.gen(function*(){return yield*$.log.error("VSCode CLI ('code' command) not found."),yield*$.log.info("To install it:"),yield*$.log.info(" 1. Open VS Code"),yield*$.log.info(" 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)"),yield*$.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))))if(l&&!v)D.stop("Zed extensions require manual install.");else D.stop("Editor extensions installed successfully.");if(l)yield*$.log.info("Install the Zed `oxc` extension: zed://extension/oxc")}),o$=(a,g,$)=>T.gen(function*(){let l=(yield*Q).spinner();if(l.start("Setting up GitHub Actions workflow..."),yield*Na.exists(a))l.message("`.github/workflows/adamantite.yml` found, updating..."),yield*Na.update(a,{packageManager:g,scripts:$}),l.stop("GitHub Actions workflow updated successfully.");else l.message("Creating `.github/workflows/adamantite.yml`..."),yield*Na.create(a,{packageManager:g,scripts:$}),l.stop("GitHub Actions workflow created successfully.")}).pipe(T.option),kg=Da.make("init").pipe(Da.withDescription("Initialize Adamantite in the current directory"),Da.withHandler(()=>T.gen(function*(){let a=u$.cwd(),g=yield*Q;yield*Ka(),yield*g.intro("\uD83D\uDCA0 adamantite init");let D=yield*(yield*x).detectPackageManager(a);if(!D)return yield*new _a({});if(D.warnings?.length)for(let n of D.warnings)yield*g.log.warning(n);yield*g.log.info(`Detected package manager: ${D.name}`);let l=yield*ha(a);if(l)yield*g.log.info("We've detected a monorepo setup in your project.");let v=yield*g.multiselect({message:"Which scripts do you want to add to your `package.json`?",options:[{hint:"recommended",label:"check - find issues in code using oxlint",value:"check"},{hint:"recommended",label:"fix - fix code issues using oxlint",value:"fix"},{hint:"recommended",label:"format - code formatting using oxfmt",value:"format"},{hint:"extends the `adamantite/typescript` preset in your `tsconfig.json`",label:"typecheck - type-check your code using tsc",value:"typecheck"},{disabled:!l,hint:l?void 0:"available for monorepo projects",label:"check:monorepo - check for monorepo-specific issues using Sherif",value:"check:monorepo"},{disabled:!l,hint:l?void 0:"available for monorepo projects",label:"fix:monorepo - fix monorepo-specific issues using Sherif",value:"fix:monorepo"},{label:"analyze - find unused dependencies, exports, and files using knip",value:"analyze"}]}),y=v.includes("check")||v.includes("fix"),E=[];if(y)E=yield*g.multiselect({message:"Which presets do you want to install? (core is always included)",options:[{label:"React",value:"react"},{label:"Next.js",value:"nextjs"},{label:"Vue",value:"vue"},{label:"Jest",value:"jest"},{label:"Vitest",value:"vitest"},{label:"Node",value:"node"}],required:!1});let f=yield*g.multiselect({message:"Which editors do you want to configure? (optional)",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}),Ea=!1;if(f.length>0)Ea=yield*g.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"});let Ba=Sg(v),Qa=!1;if(Ba)Qa=yield*g.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"});let fa=v.includes("format"),qa=v.includes("check:monorepo")||v.includes("fix:monorepo"),ra=v.includes("typecheck"),Ya=v.includes("analyze"),H=["adamantite"];if(y)H.push(`${Y.name}@${Y.version}`),H.push(`${Ua.name}@${Ua.version}`);if(fa)H.push(`${K.name}@${K.version}`);if(qa)H.push(`${k.name}@${k.version}`);if(ra)H.push(`${S.name}@${S.version}`);if(Ya)H.push(`${M.name}@${M.version}`);if(yield*G$(a,H),fa)yield*m$(a);if(y)yield*R$(a,E);if(Ya)yield*r$(a);if(yield*J$(a,v),ra)yield*F$(a);if(yield*I$(a,f),Ea)yield*k$(f,v);if(Qa)yield*o$(a,D.name,v);yield*g.log.success("Your project is now configured"),yield*g.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe(T.catchTags({OperationCancelled:()=>T.gen(function*(){yield*(yield*Q).cancel("You've cancelled the initialization process.")})}))));import*as og from"effect/Effect";import*as va from"effect/unstable/cli/Command";import*as Ja from"effect/unstable/cli/Flag";import*as xg from"effect/unstable/process/ChildProcessSpawner";var x$=Ja.boolean("fix").pipe(Ja.withDescription("Automatically fix issues")),tg=va.make("monorepo",{fix:x$}).pipe(va.withDescription("Find and fix monorepo-specific issues using Sherif"),va.withHandler(({fix:a})=>og.gen(function*(){let g=yield*b,$=a?["--fix"]:[],D=yield*g.run({args:$,command:k.name,stdin:"inherit"});if(D!==xg.ExitCode(0))yield*new L({command:k.name,exitCode:D})})));import t$ from"node:process";import*as ng from"effect/Effect";import*as Pg from"effect/Option";import*as la from"effect/unstable/cli/Command";import*as N from"effect/unstable/cli/Flag";import*as hg from"effect/unstable/process/ChildProcessSpawner";var n$=N.file("project",{mustExist:!0}).pipe(N.withAlias("p"),N.optional,N.withDescription("Path to tsconfig.json file")),P$=N.boolean("watch").pipe(N.withAlias("w"),N.withDescription("Run in watch mode")),Cg=la.make("typecheck",{project:n$,watch:P$}).pipe(la.withDescription("Run TypeScript type checking"),la.withHandler(({project:a,watch:g})=>ng.gen(function*(){let $=yield*b,D=t$.cwd(),l=["--noEmit"];if(Pg.isSome(a))l.push("--project",a.value);if(g)l.push("--watch");let v=yield*$.run({args:l,command:S.command,cwd:D});if(v!==hg.ExitCode(0))yield*new L({command:S.command,exitCode:v})})));import h$ from"node:process";import*as O from"effect/Effect";import*as ya from"effect/unstable/cli/Command";var ig=ya.make("update").pipe(ya.withDescription("Update adamantite dependencies to latest compatible versions"),ya.withHandler(()=>O.gen(function*(){let a=h$.cwd(),g=yield*Q,$=yield*za(a),D=yield*Y.exists(a),l=D.format==="json";yield*Ka(),yield*g.intro("\uD83D\uDCA0 adamantite update");let v=yield*x,y=[];for(let E of[Y,Ua,K,k,M]){let f=$.devDependencies?.[E.name];if(f&&yg(f)!==E.version)y.push({currentVersion:f,isDevDependency:!0,name:E.name,targetVersion:E.version})}if(D.hasBoth)yield*g.log.warning("Found both `oxlint.config.ts` and `.oxlintrc.json`. Adamantite will use `oxlint.config.ts`.");if(y.length===0&&!l)return yield*g.log.success("All adamantite dependencies are already up to date!"),"no-updates";if(y.length>0){yield*g.log.info("The following dependencies will be updated:");for(let f of y)yield*g.log.info(` ${f.name}: ${f.currentVersion} → ${f.targetVersion}`);if(!(yield*g.confirm({message:"Do you want to proceed with these updates?"})))return"cancelled"}if(y.length>0){let E=g.spinner();E.start("Updating dependencies..."),yield*v.addDevDependencies(y.map((f)=>`${f.name}@${f.targetVersion}`),a,{silent:!0}).pipe(O.tapError(()=>O.sync(()=>{E.stop("Failed to update dependencies")}))),E.stop("Dependencies updated successfully")}if(l){let E=g.spinner();E.start("Migrating `.oxlintrc.json` to `oxlint.config.ts`..."),yield*Y.update(a),E.stop("Oxlint config migrated successfully")}if(y.length===0&&l)return"migrated";return"updated"}).pipe(O.tap((a)=>O.gen(function*(){let g=yield*Q;switch(a){case"no-updates":yield*g.outro("✅ No updates needed");break;case"cancelled":yield*g.outro("⚠️ Update cancelled");break;case"updated":yield*g.outro("✅ Dependencies updated successfully!");break;case"migrated":yield*g.outro("✅ Oxlint config migrated to `oxlint.config.ts`!");break;default:break}})),O.catchTags({OperationCancelled:()=>O.gen(function*(){yield*(yield*Q).cancel("You've cancelled the update process.")})}))));var C$=t.make("adamantite").pipe(t.withDescription("Opinionated preset package for modern TypeScript applications"),t.withSubcommands([Bg,Kg,Vg,Wg,kg,tg,Cg,ig])),i$=await"0.30.2",w$=t.run(C$,{version:i$}).pipe(X.as(0),X.catchTag("CommandFailed",(a)=>X.succeed(a.exitCode)),X.catch((a)=>X.service(Q).pipe(X.flatMap((g)=>g.log.error(a.message)),X.as(sg.ExitCode(1)))),X.provide(cg.mergeAll(eg.layer,Q.layer,b.layer,x.layer)));wg.runMain(w$,{teardown:(a,g)=>{if(dg.isSuccess(a)){g(Number(a.value));return}pg.defaultTeardown(a,g)}});
|
|
93
|
+
`}var vF=new Set(bl.map((f)=>f.script));function Cf(f){return f.some((r)=>vF.has(r))}var t={create:(f,r)=>rf.gen(function*(){let l=yield*If.FileSystem,F=yield*jf.Path,a=F.join(f,".github","workflows");yield*xl(a);let m=dl(r);if(!m)return;let E=F.join(a,"adamantite.yml");yield*l.writeFileString(E,m).pipe(rf.mapError((y)=>new M({cause:y,path:E})))}),exists:(f)=>rf.gen(function*(){let r=yield*If.FileSystem,l=yield*jf.Path;return yield*r.exists(l.join(f,".github","workflows","adamantite.yml"))}),update:(f,r)=>rf.gen(function*(){let l=yield*If.FileSystem,a=(yield*jf.Path).join(f,".github","workflows","adamantite.yml"),m=dl(r);if(!m)return;yield*l.writeFileString(a,m).pipe(rf.mapError((E)=>new M({cause:E,path:a})))}),workflowPath:".github/workflows/adamantite.yml"};import*as A from"effect/Effect";import*as Rf from"effect/FileSystem";import*as kf from"effect/Path";import*as tl from"effect/unstable/process/ChildProcessSpawner";var vl="settings.json",Ff={config:{"[css]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[graphql]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[javascript]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[javascriptreact]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[json]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[jsonc]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[typescript]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[typescriptreact]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"editor.codeActionsOnSave":{"source.fixAll.oxc":"explicit"},"editor.defaultFormatter":"oxc.oxc-vscode","editor.formatOnPaste":!0,"editor.formatOnSave":!0,"oxc.typeAware":!0},create:(f)=>A.gen(function*(){let r=yield*Rf.FileSystem,l=yield*kf.Path,F=l.join(f,".vscode"),a=l.join(F,vl);yield*r.makeDirectory(F,{recursive:!0}).pipe(A.mapError((m)=>new c({cause:m,path:F}))),yield*r.writeFileString(a,`${JSON.stringify(Ff.config,null,2)}
|
|
94
|
+
`).pipe(A.mapError((m)=>new M({cause:m,path:a})))}),exists:(f)=>A.gen(function*(){let r=yield*Rf.FileSystem,l=yield*kf.Path;return yield*r.exists(l.join(f,".vscode",vl))}),extension:(f=[])=>A.gen(function*(){function r(F){return A.gen(function*(){let m=yield*(yield*q).run({args:["--install-extension",F],command:"code"}).pipe(A.mapError((E)=>E._tag==="CliNotFound"&&E.command==="code"?new El({cause:E}):new Uf({cause:E,extension:F})));if(m!==tl.ExitCode(0))return yield*new Uf({cause:m,extension:F})})}let l=[];if(f.includes("check")||f.includes("fix")||f.includes("format"))l.push("oxc.oxc-vscode");if(f.includes("analyze"))l.push("webpro.vscode-knip");for(let F of l)yield*r(F)}),update:(f)=>A.gen(function*(){let r=yield*Rf.FileSystem,F=(yield*kf.Path).join(f,".vscode",vl),a=yield*r.readFileString(F).pipe(A.mapError((y)=>new X({cause:y,path:F}))),m=yield*S(a,F);if(!_(m))return yield*new Y({path:F});let E=yield*o(Ff.config,m);yield*r.writeFileString(F,`${JSON.stringify(E,null,2)}
|
|
95
|
+
`).pipe(A.mapError((y)=>new M({cause:y,path:F})))})};import*as k from"effect/Effect";import*as wf from"effect/FileSystem";import*as xf from"effect/Path";var Tl="settings.json",Mf={config:{languages:{CSS:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},HTML:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JSON:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JSONC:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JavaScript:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},MDX:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},Markdown:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},TSX:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},TypeScript:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},YAML:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]}},lsp:{oxfmt:{initialization_options:{settings:{configPath:null,"fmt.experimental":!0,run:"onSave",typeAware:!1,unusedDisableDirectives:!1}}},oxlint:{initialization_options:{settings:{configPath:null,fixKind:"safe_fix",run:"onType",typeAware:!0,unusedDisableDirectives:"deny"}}}}},create:(f)=>k.gen(function*(){let r=yield*wf.FileSystem,l=yield*xf.Path,F=l.join(f,".zed"),a=l.join(F,Tl);yield*r.makeDirectory(F,{recursive:!0}).pipe(k.mapError((m)=>new c({cause:m,path:F}))),yield*r.writeFileString(a,`${JSON.stringify(Mf.config,null,2)}
|
|
96
|
+
`).pipe(k.mapError((m)=>new M({cause:m,path:a})))}),exists:(f)=>k.gen(function*(){let r=yield*wf.FileSystem,l=yield*xf.Path;return yield*r.exists(l.join(f,".zed",Tl))}),update:(f)=>k.gen(function*(){let r=yield*wf.FileSystem,F=(yield*xf.Path).join(f,".zed",Tl),a=yield*r.readFileString(F).pipe(k.mapError((y)=>new X({cause:y,path:F}))),m=yield*S(a,F);if(!_(m))return yield*new Y({path:F});let E=yield*o(Mf.config,m);yield*r.writeFileString(F,`${JSON.stringify(E,null,2)}
|
|
97
|
+
`).pipe(k.mapError((y)=>new M({cause:y,path:F})))})};var O=C({name:"sherif",version:"1.10.0"});import*as af from"effect/Effect";import*as nl from"effect/Layer";import*as sl from"effect/ServiceMap";import{addDevDependency as TF,detectPackageManager as $F}from"nypm";class I extends sl.Service()("DependencyInstaller"){static layer=nl.succeed(this)({addDevDependencies:(f,r,l)=>af.tryPromise({catch:(F)=>new ll({cause:F,packages:f}),try:()=>TF(f,{...l,cwd:r})}).pipe(af.asVoid),detectPackageManager:(f)=>af.tryPromise({catch:(r)=>new Sf({cause:r}),try:()=>$F(f)}).pipe(af.map((r)=>r??null))})}import*as Q from"@clack/prompts";import*as U from"effect/Effect";import*as pl from"effect/Layer";import*as cl from"effect/ServiceMap";class g extends cl.Service()("Prompter"){static layer=pl.succeed(this)({cancel:(f)=>U.sync(()=>{Q.cancel(f)}),confirm:(f)=>U.promise(()=>Q.confirm(f)).pipe(U.filterOrFail((r)=>!Q.isCancel(r),()=>new Wf({}))),intro:(f)=>U.sync(()=>{Q.intro(f)}),log:{error:(f)=>U.sync(()=>{Q.log.error(f)}),info:(f)=>U.sync(()=>{Q.log.info(f)}),success:(f)=>U.sync(()=>{Q.log.success(f)}),warning:(f)=>U.sync(()=>{Q.log.warning(f)})},multiselect:(f)=>U.promise(()=>Q.multiselect(f)).pipe(U.filterOrFail((r)=>!Q.isCancel(r),()=>new Wf({}))),outro:(f)=>U.sync(()=>{Q.outro(f)}),spinner:()=>Q.spinner()})}import*as fr from"effect/Console";import*as lr from"effect/Effect";import*as rr from"effect/Terminal";var df=()=>lr.gen(function*(){let r=yield*(yield*rr.Terminal).columns,l=' .o8 . o8o . \n "888 .o8 `"\' .o8 \n .oooo. .oooo888 .oooo. ooo. .oo. .oo. .oooo. ooo. .oo. .o888oo oooo .o888oo .ooooo. \n`P )88b d88\' `888 `P )88b `888P"Y88bP"Y88b `P )88b `888P"Y88b 888 `888 888 d88\' `88b \n .oP"888 888 888 .oP"888 888 888 888 .oP"888 888 888 888 888 888 888ooo888 \nd8( 888 888 888 d8( 888 888 888 888 d8( 888 888 888 888 . 888 888 . 888 .o \n`Y888""8o `Y8bod88P" `Y888""8o o888o o888o o888o `Y888""8o o888o o888o "888" o888o "888" `Y8bod8P\' \n \n \n '.split(`
|
|
98
|
+
`).reduce((F,a)=>Math.max(F,a.trim().length),0);if(!r||r<l)return;yield*fr.info(' .o8 . o8o . \n "888 .o8 `"\' .o8 \n .oooo. .oooo888 .oooo. ooo. .oo. .oo. .oooo. ooo. .oo. .o888oo oooo .o888oo .ooooo. \n`P )88b d88\' `888 `P )88b `888P"Y88bP"Y88b `P )88b `888P"Y88b 888 `888 888 d88\' `88b \n .oP"888 888 888 .oP"888 888 888 888 .oP"888 888 888 888 888 888 888ooo888 \nd8( 888 888 888 d8( 888 888 888 888 d8( 888 888 888 888 . 888 888 . 888 .o \n`Y888""8o `Y8bod88P" `Y888""8o o888o o888o o888o `Y888""8o o888o o888o "888" o888o "888" `Y8bod8P\' \n \n \n ')});import MF from"node:process";import*as mr from"effect/Effect";import*as Er from"effect/FileSystem";import*as yr from"effect/Path";import uF from"node:process";import*as gf from"effect/Effect";import*as $l from"effect/FileSystem";import*as ul from"effect/Path";var DF=/^workspace:/,iF=/^[\^~]/;function Fr(f){return f.trim().replace(DF,"").replace(iF,"")}var J=(f=uF.cwd())=>gf.gen(function*(){let r=yield*$l.FileSystem,F=(yield*ul.Path).join(f,"package.json"),a=yield*r.readFileString(F).pipe(gf.mapError((E)=>new X({cause:E,path:F})));return yield*S(a,F)}),ar=(f,r)=>gf.gen(function*(){let l=yield*$l.FileSystem,a=(yield*ul.Path).join(f,"package.json");yield*l.writeFileString(a,`${JSON.stringify(r,null,2)}
|
|
99
|
+
`).pipe(gf.mapError((m)=>new M({cause:m,path:a})))});var Dl=(f=MF.cwd())=>mr.gen(function*(){let r=yield*Er.FileSystem,l=yield*yr.Path;if(yield*r.exists(l.join(f,"pnpm-workspace.yaml")))return!0;return(yield*J(f)).workspaces!==void 0});import*as n from"effect/Effect";import*as bf from"effect/FileSystem";import*as tf from"effect/Path";var il="tsconfig.json",N={config:{extends:"adamantite/typescript"},create:(f)=>n.gen(function*(){let r=yield*bf.FileSystem,F=(yield*tf.Path).join(f,il),a=JSON.stringify(N.config,null,2);yield*r.writeFileString(F,`${a}
|
|
100
|
+
`).pipe(n.mapError((m)=>new M({cause:m,path:F})))}),exists:(f)=>n.gen(function*(){let r=yield*bf.FileSystem,l=yield*tf.Path;return yield*r.exists(l.join(f,il))}),update:(f)=>n.gen(function*(){let r=yield*bf.FileSystem,F=(yield*tf.Path).join(f,il),a=yield*r.readFileString(F).pipe(n.mapError((y)=>new X({cause:y,path:F}))),m=yield*S(a,F);if(!_(m))return yield*new Y({path:F});let E=yield*o(N.config,m);yield*r.writeFileString(F,`${JSON.stringify(E,null,2)}
|
|
101
|
+
`).pipe(n.mapError((y)=>new M({cause:y,path:F})))})};var VF=(f,r)=>D.gen(function*(){let l=yield*I,a=(yield*g).spinner();a.start("Installing dependencies...");let m=yield*Dl(f);yield*l.addDevDependencies(r,f,{silent:!0,workspace:m}).pipe(D.tapError(()=>D.sync(()=>{a.stop("Failed to install dependencies.")}))),a.stop("Dependencies installed.")}),QF=(f,r)=>D.gen(function*(){let l=yield*g,F=l.spinner();F.start("Setting up oxlint config...");let a=yield*$.exists(f);if(a.hasBoth)yield*l.log.warning("Found both `oxlint.config.ts` and `.oxlintrc.json`. Adamantite will use `oxlint.config.ts`.");if(a.format==="json")F.message("Found `.oxlintrc.json`, migrating to `oxlint.config.ts`..."),yield*$.update(f,r),F.stop("oxlint config migrated successfully.");else if(a.format==="ts")F.message("Found `oxlint.config.ts`, keeping existing config."),F.stop("oxlint config is ready.");else F.message("`oxlint.config.ts` not found, creating..."),yield*$.create(f,r),F.stop("oxlint config created successfully.")}),zF=(f)=>D.gen(function*(){let l=(yield*g).spinner();l.start("Setting up oxfmt config...");let F=yield*B.exists(f);if(F.path)l.message(`Found \`${F.path}\`, updating...`),yield*B.update(f),l.stop("oxfmt config updated successfully.");else l.message("`.oxfmtrc.jsonc` or `.oxfmtrc.json` not found, creating..."),yield*B.create(f),l.stop("oxfmt config created successfully.")}),XF=(f,r)=>D.gen(function*(){let l=yield*vr.FileSystem,F=yield*Tr.Path,a=yield*g,m=yield*J(f),E=a.spinner();E.start("Adding scripts to your `package.json`..."),m.scripts??={};for(let u of r)switch(u){case"check":m.scripts.check="adamantite check";break;case"fix":m.scripts.fix="adamantite fix";break;case"format":m.scripts.format="adamantite format";break;case"check:monorepo":m.scripts["check:monorepo"]="adamantite monorepo";break;case"fix:monorepo":m.scripts["fix:monorepo"]="adamantite monorepo --fix";break;case"analyze":m.scripts.analyze="adamantite analyze";break;default:return yield*new ml({script:u})}let y=F.join(f,"package.json");yield*l.writeFileString(y,`${JSON.stringify(m,null,2)}
|
|
102
|
+
`).pipe(D.mapError((u)=>new M({cause:u,path:y}))),E.stop("Scripts added to your `package.json`")}),qF=(f)=>D.gen(function*(){let l=(yield*g).spinner();l.start("Setting up knip config...");let F=yield*L.exists(f);if(F.path)l.message(`Found \`${F.path}\`, updating...`),yield*L.update(f),l.stop("knip config updated successfully.");else l.message("`knip.json` not found, creating..."),yield*L.create(f),l.stop("knip config created successfully.")}),ZF=(f)=>D.gen(function*(){let l=(yield*g).spinner();if(l.start("Setting up TypeScript config..."),yield*N.exists(f))l.message("`tsconfig.json` found, updating..."),yield*N.update(f),l.stop("`tsconfig.json` updated successfully");else l.message("`tsconfig.json` not found, creating..."),yield*N.create(f),l.stop("`tsconfig.json` created successfully")}),KF=(f,r)=>D.gen(function*(){let l=yield*g;if(r.includes("vscode")){let F=l.spinner();if(F.start("Checking for `.vscode/settings.json`..."),yield*Ff.exists(f))F.message("`.vscode/settings.json` found, updating..."),yield*Ff.update(f),F.stop("`.vscode/settings.json` updated with Adamantite preset.");else F.message("`.vscode/settings.json` not found, creating..."),yield*Ff.create(f),F.stop("`.vscode/settings.json` created with Adamantite preset.")}if(r.includes("zed")){let F=l.spinner();if(F.start("Checking for `.zed/settings.json`..."),yield*Mf.exists(f))F.message("`.zed/settings.json` found, updating..."),yield*Mf.update(f),F.stop("`.zed/settings.json` updated with Adamantite preset.");else F.message("`.zed/settings.json` not found, creating..."),yield*Mf.create(f),F.stop("`.zed/settings.json` created with Adamantite preset.")}}),HF=(f,r)=>D.gen(function*(){let l=yield*g,F=l.spinner();F.start("Installing editor extensions...");let a=f.includes("zed"),m=f.includes("vscode");if(yield*D.gen(function*(){if(f.includes("vscode"))F.message("Installing VS Code extension..."),yield*Ff.extension(r);return!0}).pipe(D.tapError(()=>D.sync(()=>{F.stop()})),D.catchTag("FailedToInstallExtension",(y)=>D.gen(function*(){return yield*l.log.warning(`⚠️ Failed to install the \`${y.extension}\` extension.`),yield*l.log.warning("Please install it manually after setup completes."),!1})),D.catchTag("VscodeCliNotFound",()=>D.gen(function*(){return yield*l.log.error("VSCode CLI ('code' command) not found."),yield*l.log.info("To install it:"),yield*l.log.info(" 1. Open VS Code"),yield*l.log.info(" 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)"),yield*l.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))))if(a&&!m)F.stop("Zed extensions require manual install.");else F.stop("Editor extensions installed successfully.");if(a)yield*l.log.info("Install the Zed `oxc` extension: zed://extension/oxc")}),SF=(f,r,l)=>D.gen(function*(){let a=(yield*g).spinner();if(a.start("Setting up GitHub Actions workflow..."),yield*t.exists(f))a.message("`.github/workflows/adamantite.yml` found, updating..."),yield*t.update(f,{packageManager:r,scripts:l}),a.stop("GitHub Actions workflow updated successfully.");else a.message("Creating `.github/workflows/adamantite.yml`..."),yield*t.create(f,{packageManager:r,scripts:l}),a.stop("GitHub Actions workflow created successfully.")}).pipe(D.option),$r=Vf.make("init").pipe(Vf.withDescription("Initialize Adamantite in the current directory"),Vf.withHandler(()=>D.gen(function*(){let f=gF.cwd(),r=yield*g;yield*df(),yield*r.intro("\uD83D\uDCA0 adamantite init");let F=yield*(yield*I).detectPackageManager(f);if(!F)return yield*new Sf({});if(F.warnings?.length)for(let Hf of F.warnings)yield*r.log.warning(Hf);yield*r.log.info(`Detected package manager: ${F.name}`);let a=yield*Dl(f);if(a)yield*r.log.info("We've detected a monorepo setup in your project.");let m=yield*r.multiselect({message:"Which scripts do you want to add to your `package.json`?",options:[{hint:"recommended",label:"check - find issues and type errors using oxlint",value:"check"},{hint:"recommended",label:"fix - fix code issues using oxlint",value:"fix"},{hint:"recommended",label:"format - code formatting using oxfmt",value:"format"},{disabled:!a,hint:a?void 0:"available for monorepo projects",label:"check:monorepo - check for monorepo-specific issues using Sherif",value:"check:monorepo"},{disabled:!a,hint:a?void 0:"available for monorepo projects",label:"fix:monorepo - fix monorepo-specific issues using Sherif",value:"fix:monorepo"},{label:"analyze - find unused dependencies, exports, and files using knip",value:"analyze"}]}),E=m.includes("check")||m.includes("fix"),y=[];if(E)y=yield*r.multiselect({message:"Which presets do you want to install? (core is always included)",options:[{label:"React",value:"react"},{label:"Next.js",value:"nextjs"},{label:"Vue",value:"vue"},{label:"Jest",value:"jest"},{label:"Vitest",value:"vitest"},{label:"Node",value:"node"}],required:!1});let u=!1;if(E)u=yield*r.confirm({initialValue:!0,message:"Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?"});let T=yield*r.multiselect({message:"Which editors do you want to configure? (optional)",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}),v=!1;if(T.length>0)v=yield*r.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"});let i=Cf(m),V=!1;if(i)V=yield*r.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"});let Z=m.includes("format"),cf=m.includes("check:monorepo")||m.includes("fix:monorepo"),Kf=m.includes("analyze"),j=["adamantite"];if(E)j.push(`${$.name}@${$.version}`),j.push(`${lf.name}@${lf.version}`);if(Z)j.push(`${B.name}@${B.version}`);if(cf)j.push(`${O.name}@${O.version}`);if(Kf)j.push(`${L.name}@${L.version}`);if(yield*VF(f,j),Z)yield*zF(f);if(E)yield*QF(f,y);if(Kf)yield*qF(f);if(yield*XF(f,m),u)yield*ZF(f);if(yield*KF(f,T),v)yield*HF(T,m);if(V)yield*SF(f,F.name,m);yield*r.log.success("Your project is now configured"),yield*r.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe(D.catchTags({OperationCancelled:()=>D.gen(function*(){yield*(yield*g).cancel("You've cancelled the initialization process.")})}))));import*as ur from"effect/Effect";import*as Qf from"effect/unstable/cli/Command";import*as nf from"effect/unstable/cli/Flag";import*as Dr from"effect/unstable/process/ChildProcessSpawner";var UF=nf.boolean("fix").pipe(nf.withDescription("Automatically fix issues")),ir=Qf.make("monorepo",{fix:UF}).pipe(Qf.withDescription("Find and fix monorepo-specific issues using Sherif"),Qf.withHandler(({fix:f})=>ur.gen(function*(){let r=yield*q,l=f?["--fix"]:[],F=yield*r.run({args:l,command:O.name,stdin:"inherit"});if(F!==Dr.ExitCode(0))yield*new W({command:O.name,exitCode:F})})));import*as Mr from"effect/Effect";import*as zf from"effect/unstable/cli/Command";import*as gr from"effect/unstable/process/ChildProcessSpawner";var Vr=zf.make("typecheck").pipe(zf.withDescription("Deprecated alias for `check`"),zf.withHandler(()=>Mr.gen(function*(){let f=yield*g,r=yield*q;yield*f.log.warning("Deprecated. Use `adamantite check` for typechecking.");let l=yield*r.run({args:[],command:$.name});if(l!==gr.ExitCode(0))yield*new W({command:$.name,exitCode:l})})));import RF from"node:process";import*as K from"effect/Effect";import*as Zf from"effect/unstable/cli/Command";import*as Ml from"effect/Effect";import*as gl from"effect/FileSystem";import*as Qr from"effect/Path";function Xf(f){return f}function zr(f,r){return Ml.gen(function*(){let l=yield*gl.FileSystem,F=yield*Qr.Path,a=new Map;for(let m of r){let E=F.join(f,m);if(yield*l.exists(E)){let u=yield*l.readFileString(E);a.set(E,u)}else a.set(E,null)}return a})}function Xr(f){return Ml.gen(function*(){let r=yield*gl.FileSystem;for(let[l,F]of f)if(F===null){if(yield*r.exists(l))yield*r.remove(l)}else yield*r.writeFileString(l,F)})}import*as sf from"effect/Effect";var WF="Found both `oxlint.config.ts` and `.oxlintrc.json`. Adamantite will use `oxlint.config.ts`.",YF="Migrating legacy `.oxlintrc.json` configuration to `oxlint.config.ts`.",qr=Xf({id:"legacy-oxlint-json",files:["oxlint.config.ts",".oxlintrc.json"],tags:["update"],title:"Legacy oxlint JSON config",check:(f)=>sf.gen(function*(){let r=yield*$.exists(f.cwd),l=r.hasBoth?[WF]:[];if(r.format==="json")return{status:"needs_migration",summary:YF,warnings:l};if(r.format==="ts")return{status:"valid",warnings:l};return{status:"not_applicable",warnings:l}}),migrate:(f)=>sf.gen(function*(){let l=(yield*g).spinner();l.start("Migrating `.oxlintrc.json` to `oxlint.config.ts`..."),yield*$.update(f.cwd),l.stop("Oxlint config migrated to `oxlint.config.ts` successfully.")}),validate:(f)=>sf.gen(function*(){if((yield*$.exists(f.cwd)).format!=="ts")return yield*new P({migrationId:"legacy-oxlint-json",reason:"`oxlint.config.ts` is not the active oxlint config."})})});import*as G from"effect/Effect";import*as Ql from"effect/Exit";var Vl={analyze:"adamantite analyze",check:"adamantite check","check:monorepo":"adamantite monorepo",fix:"adamantite fix","fix:monorepo":"adamantite monorepo --fix",format:"adamantite format"};function qf(f){let r=f.scripts??{},l=[];for(let[F,a]of Object.entries(Vl))if(r[F]===a)l.push(F);return l}var Zr="adamantite typecheck";function pf(f){let r={...f.scripts};if(r.typecheck!==Zr)return{migrated:!1,packageJson:f};return delete r.typecheck,r.check??=Vl.check,{migrated:!0,packageJson:{...f,scripts:r}}}var Kr=Xf({check:(f)=>G.gen(function*(){let r=yield*J(f.cwd),{migrated:l}=pf(r);if(!l)return{status:"not_applicable",warnings:[]};return{status:"needs_migration",summary:"Migrating `typecheck` to `check` so oxlint handles linting and type diagnostics together.",warnings:[]}}),files:["package.json","oxlint.config.ts",".oxlintrc.json","tsconfig.json",t.workflowPath],id:"legacy-typecheck-script",migrate:(f)=>G.gen(function*(){let r=yield*g,l=yield*I,F=r.spinner(),a=G.gen(function*(){let m=yield*J(f.cwd),E=pf(m);if(!E.migrated)return"noop";if(yield*ar(f.cwd,E.packageJson),(yield*$.exists(f.cwd)).format===null)yield*$.create(f.cwd);yield*(yield*N.exists(f.cwd))?N.update(f.cwd):N.create(f.cwd);let T=yield*t.exists(f.cwd),v=qf(E.packageJson);if(T&&Cf(v)){let i=yield*l.detectPackageManager(f.cwd);if(i){let V=r.spinner();V.start("Updating GitHub Actions workflow..."),yield*t.update(f.cwd,{packageManager:i.name,scripts:v}).pipe(G.onExit((Z)=>G.sync(()=>{V.stop(Ql.match(Z,{onFailure:()=>"Failed to update GitHub Actions workflow.",onSuccess:()=>"GitHub Actions workflow updated successfully"}))})))}else yield*r.log.warning("Could not detect a package manager, so the GitHub Actions workflow was not updated.")}return"migrated"});F.start("Migrating `typecheck` script to unified `check` command..."),yield*a.pipe(G.onExit((m)=>G.sync(()=>{F.stop(Ql.match(m,{onFailure:()=>"Legacy `typecheck` script migration failed.",onSuccess:(E)=>E==="noop"?"No migration needed.":"Legacy `typecheck` script migrated to `check` successfully."}))})),G.asVoid)}),tags:["update"],title:"Legacy typecheck script",validate:(f)=>G.gen(function*(){if((yield*J(f.cwd)).scripts?.typecheck===Zr)return yield*new P({migrationId:"legacy-typecheck-script",reason:"The legacy `typecheck` script is still present in `package.json`."});if((yield*$.exists(f.cwd)).format!=="ts")return yield*new P({migrationId:"legacy-typecheck-script",reason:"`oxlint.config.ts` is not the active oxlint config."});if(!(yield*N.exists(f.cwd)))return yield*new P({migrationId:"legacy-typecheck-script",reason:"`tsconfig.json` is missing after the migration."})})});import{parse as _F}from"@babel/parser";import*as s from"effect/Effect";import*as Kl from"effect/FileSystem";import*as Ur from"effect/Path";var LF="oxlint.config.ts",BF="Updating `oxlint.config.ts` so `options.typeAware` and `options.typeCheck` are enabled for managed lint scripts.",GF="Adamantite found an `oxlint.config.ts` that still needs `typeAware` and `typeCheck`, but the file shape is not supported for automatic patching. The migration will stop and ask for a manual fix.",Wr=["typeAware","typeCheck"],ql="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",Zl="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",Hr="`oxlint.config.ts` already defines `typeAware` or `typeCheck`, but not as a boolean literal Adamantite can safely patch.";function AF(f){let r=pf(f).packageJson,l=qf(r);return l.includes("check")||l.includes("fix")}function Yr(f){return typeof f.start==="number"&&typeof f.end==="number"}function JF(f){return f.includes(`\r
|
|
103
|
+
`)?`\r
|
|
104
|
+
`:`
|
|
105
|
+
`}function NF(f,r){let l=f.lastIndexOf(`
|
|
106
|
+
`,r-1)+1,F=l;while(F<r){let a=f[F];if(a!==" "&&a!=="\t")break;F+=1}return f.slice(l,F)}function eF(f,r,l,F,a){let m=f.slice(r,l);if(!m.includes(a))return`${F} `;for(let E of m.split(a)){if(E.trim().length===0)continue;return E.match(/^[ \t]*/)?.[0]??`${F} `}return`${F} `}function _r(f,r){if(!Yr(r))return null;let l=r.end-1;if(f[r.start]!=="{"||f[l]!=="}")return null;let F=JF(f),a=NF(f,l);return{bodyEnd:l,bodyStart:r.start+1,closeIndent:a,newline:F,propertyIndent:eF(f,r.start+1,l,a,F)}}function Lr(f,r,l){if(r.length===0)return f;let F=f.startsWith(l.newline)?f.slice(l.newline.length):f.trim();if(F.trim().length===0)return`${l.newline}${r.join(l.newline)}${l.newline}${l.closeIndent}`;if(f.startsWith(l.newline))return`${l.newline}${r.join(l.newline)}${l.newline}${F}`;return`${l.newline}${r.join(l.newline)}${l.newline}${l.propertyIndent}${f.trim()}${l.newline}${l.closeIndent}`}function PF(f){let r=`${f.propertyIndent} `;return[`${f.propertyIndent}options: {`,...Wr.map((l)=>`${r}${l}: true,`),`${f.propertyIndent}},`].join(f.newline)}function hF(f,r){let l=f;for(let F of r)l=l.slice(0,F.start)+F.text+l.slice(F.end);return l}function oF(f,r){let l=f.findIndex((F)=>r.start>F.start);if(l===-1){f.push(r);return}f.splice(l,0,r)}function OF(f){try{return _F(f,{plugins:["typescript"],sourceType:"module"})}catch{return null}}function Sr(f){if(typeof f==="object"&&f!==null&&"type"in f&&f.type==="Identifier"&&"name"in f&&typeof f.name==="string")return f.name;if(typeof f==="object"&&f!==null&&"type"in f&&f.type==="StringLiteral"&&"value"in f&&typeof f.value==="string")return f.value;return null}function IF(f){let r=[];for(let a of f.program.body)if(typeof a==="object"&&"type"in a&&a.type==="ExportDefaultDeclaration"&&"declaration"in a)r.push(a);if(r.length!==1)return null;let l=r[0]?.declaration;if(typeof l==="object"&&l!==null&&"type"in l&&l.type==="ObjectExpression"&&"properties"in l&&Array.isArray(l.properties))return l;if(typeof l!=="object"||l===null||!("type"in l)||l.type!=="CallExpression"||!("callee"in l)||!("arguments"in l)||!Array.isArray(l.arguments))return null;if(typeof l.callee!=="object"||l.callee===null||!("type"in l.callee)||l.callee.type!=="Identifier"||!("name"in l.callee)||l.callee.name!=="defineConfig")return null;if(l.arguments.length!==1)return null;let[F]=l.arguments;if(typeof F==="object"&&F!==null&&"type"in F&&F.type==="ObjectExpression"&&"properties"in F&&Array.isArray(F.properties))return F;return null}function Br(f,r){let l=null;for(let F of f.properties){if(typeof F==="object"&&F!==null&&"type"in F&&F.type==="SpreadElement")return{status:"manual"};if(typeof F==="object"&&F!==null&&"type"in F&&F.type==="ObjectMethod"&&"key"in F){let m=F;if(m.computed)return{status:"manual"};if(Sr(m.key)===r)return{status:"manual"};continue}if(typeof F!=="object"||F===null||!("type"in F)||F.type!=="ObjectProperty"||!("key"in F)||!("value"in F))return{status:"manual"};let a=F;if(a.computed)return{status:"manual"};if(Sr(a.key)!==r)continue;if(l)return{status:"manual"};l=a}if(!l)return{status:"missing"};return{property:l,status:"found"}}function jF(f,r){let l=_r(f,r);if(!l)return{kind:"manual",reason:Zl};let F=f.slice(l.bodyStart,l.bodyEnd),a=[],m=[];for(let y of Wr){let u=Br(r,y);if(u.status==="manual")return{kind:"manual",reason:Hr};if(u.status==="missing"){a.push(y);continue}let T=u.property.value;if(typeof T!=="object"||T===null||!("type"in T)||T.type!=="BooleanLiteral"||!("value"in T)||typeof T.value!=="boolean"||!("start"in T)||!("end"in T)||!Yr(T))return{kind:"manual",reason:Hr};let v=T;if(v.value)continue;oF(m,{end:v.end-l.bodyStart,start:v.start-l.bodyStart,text:"true"})}let E=hF(F,m);if(a.length>0)E=Lr(E,a.map((y)=>`${l.propertyIndent}${y}: true,`),l);if(E===F)return{kind:"configured"};return{kind:"patchable",updatedContent:`${f.slice(0,l.bodyStart)}${E}${f.slice(l.bodyEnd)}`}}function CF(f,r){let l=_r(f,r);if(!l)return{kind:"manual",reason:ql};let F=Lr(f.slice(l.bodyStart,l.bodyEnd),[PF(l)],l);return{kind:"patchable",updatedContent:`${f.slice(0,l.bodyStart)}${F}${f.slice(l.bodyEnd)}`}}function zl(f){let r=OF(f);if(!r)return{kind:"manual",reason:ql};let l=IF(r);if(!l)return{kind:"manual",reason:ql};let F=Br(l,"options");if(F.status==="manual")return{kind:"manual",reason:Zl};if(F.status==="missing")return CF(f,l);if(typeof F.property.value!=="object"||F.property.value===null||!("type"in F.property.value)||F.property.value.type!=="ObjectExpression"||!("properties"in F.property.value)||!Array.isArray(F.property.value.properties))return{kind:"manual",reason:Zl};let a=F.property.value;return jF(f,a)}function Xl(f){return s.gen(function*(){let r=yield*J(f);if(!AF(r))return{status:"not_applicable"};if((yield*$.exists(f)).format!=="ts")return{status:"not_applicable"};let F=yield*Kl.FileSystem,m=(yield*Ur.Path).join(f,LF),E=yield*F.readFileString(m).pipe(s.mapError((y)=>new X({cause:y,path:m})));return{configPath:m,content:E,status:"applicable"}})}var Gr=Xf({check:(f)=>s.gen(function*(){let r=yield*Xl(f.cwd);if(r.status==="not_applicable")return{status:"not_applicable",warnings:[]};let l=zl(r.content);if(l.kind==="configured")return{status:"valid",warnings:[]};return{status:"needs_migration",summary:BF,warnings:l.kind==="manual"?[GF]:[]}}),files:["oxlint.config.ts"],id:"oxlint-typecheck",migrate:(f)=>s.gen(function*(){let l=(yield*g).spinner();l.start("Updating `oxlint.config.ts` for type-aware linting...");let F=yield*Xl(f.cwd);if(F.status==="not_applicable"){l.stop("No migration needed.");return}let a=zl(F.content);if(a.kind==="configured"){l.stop("`oxlint.config.ts` already enables type-aware linting.");return}if(a.kind==="manual")return yield*new P({migrationId:"oxlint-typecheck",reason:a.reason});yield*(yield*Kl.FileSystem).writeFileString(F.configPath,a.updatedContent).pipe(s.mapError((E)=>new M({cause:E,path:F.configPath}))),l.stop("`oxlint.config.ts` updated for type-aware linting.")}),tags:["update"],title:"Oxlint type-aware config",validate:(f)=>s.gen(function*(){let r=yield*Xl(f.cwd);if(r.status==="not_applicable")return;let l=zl(r.content);if(l.kind==="configured")return;return yield*new P({migrationId:"oxlint-typecheck",reason:l.kind==="patchable"?"`oxlint.config.ts` still needs `options.typeAware` and `options.typeCheck` set to `true`.":l.reason})})});var Ar=[qr,Gr,Kr];function kF(f){let r=new Map;if(f.includes("check")||f.includes("fix"))r.set($.name,$),r.set(lf.name,lf);if(f.includes("format"))r.set(B.name,B);if(f.includes("check:monorepo")||f.includes("fix:monorepo"))r.set(O.name,O);if(f.includes("analyze"))r.set(L.name,L);return[...r.values()]}var Jr=Zf.make("update").pipe(Zf.withDescription("Run applicable Adamantite migrations and update managed dependencies"),Zf.withHandler(()=>K.gen(function*(){let f=RF.cwd(),r=yield*g,l=yield*I,F={cwd:f};yield*df(),yield*r.intro("\uD83D\uDCA0 adamantite update");let a=[];for(let v of Ar.filter((i)=>i.tags.includes("update"))){let i=yield*v.check(F);a.push({migration:v,result:i})}for(let v of a){for(let i of v.result.warnings)yield*r.log.warning(i);if(v.result.status==="needs_migration"&&v.result.summary)yield*r.log.info(v.result.summary)}let m=[];for(let{migration:v,result:i}of a){if(i.status!=="needs_migration")continue;let V=v.files??[],Z=yield*zr(f,V);yield*K.gen(function*(){if(yield*v.migrate(F),v.validate)yield*v.validate(F);m.push(v.id)}).pipe(K.tapError(()=>K.gen(function*(){yield*r.log.warning(`Migration "${v.title}" failed, restoring files...`),yield*Xr(Z).pipe(K.ignore)})))}if(m.length>0)yield*r.log.success("Migrations ran successfully.");let E=yield*J(f),y=qf(E),u=kF(y),T=[];for(let v of[$,lf,B,O,L]){let i=E.devDependencies?.[v.name];if(i&&Fr(i)!==v.version)T.push({currentVersion:i,isDevDependency:!0,name:v.name,targetVersion:v.version})}for(let v of u)if(!E.devDependencies?.[v.name])T.push({currentVersion:"not installed",isDevDependency:!0,name:v.name,targetVersion:v.version});if(T.length>0){yield*r.log.info("The following dependencies will be updated:");for(let i of T)yield*r.log.info(` ${i.name}: ${i.currentVersion} → ${i.targetVersion}`);let v=r.spinner();v.start("Updating dependencies..."),yield*l.addDevDependencies(T.map((i)=>`${i.name}@${i.targetVersion}`),f,{silent:!0}).pipe(K.tapError(()=>K.sync(()=>{v.stop("Failed to update dependencies")}))),v.stop("Dependencies updated successfully"),yield*r.log.success("Dependencies updated successfully.")}if(m.length===0&&T.length===0)return yield*r.log.success("No changes needed."),"no-changes";return"success"}).pipe(K.tapError(()=>K.gen(function*(){yield*(yield*g).outro("❌ Update failed")})),K.tap((f)=>K.gen(function*(){let r=yield*g;switch(f){case"no-changes":yield*r.outro("✅ Adamantite is already up to date.");break;case"success":yield*r.outro("✅ Update completed successfully!");break;default:break}})))));var wF=p.make("adamantite").pipe(p.withDescription("Opinionated preset package for modern TypeScript applications"),p.withSubcommands([Gl,hl,Il,kl,$r,ir,Vr,Jr])),xF=await"0.31.0",dF=p.run(wF,{version:xF}).pipe(H.as(0),H.catchTag("CommandFailed",(f)=>H.succeed(f.exitCode)),H.catch((f)=>H.service(g).pipe(H.flatMap((r)=>r.log.error(f.message)),H.as(Or.ExitCode(1)))),H.provide(hr.mergeAll(er.layer,g.layer,q.layer,I.layer)));Nr.runMain(dF,{teardown:(f,r)=>{if(Pr.isSuccess(f)){r(Number(f.value));return}or.defaultTeardown(f,r)}});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// presets/lint/core.ts
|
|
2
2
|
import { defineConfig } from "oxlint";
|
|
3
3
|
var core_default = defineConfig({
|
|
4
|
-
ignorePatterns: ["**/node_modules", "**/.git", "**/build", "**/dist", "**/.next", "**/.vercel"],
|
|
5
4
|
plugins: ["eslint", "typescript", "unicorn", "oxc", "import", "jsdoc", "promise"],
|
|
6
5
|
rules: {
|
|
7
6
|
"accessor-pairs": "error",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adamantite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "An strict and opinionated set of presets for modern TypeScript applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adamantite",
|
|
@@ -60,29 +60,30 @@
|
|
|
60
60
|
"test": "bun test",
|
|
61
61
|
"test:coverage": "bun test --coverage",
|
|
62
62
|
"test:watch": "bun --watch test",
|
|
63
|
-
"typecheck": "bun run src/index.ts typecheck",
|
|
64
63
|
"version": "changeset version"
|
|
65
64
|
},
|
|
66
65
|
"dependencies": {
|
|
66
|
+
"@babel/parser": "^7.29.0",
|
|
67
67
|
"@clack/prompts": "1.1.0",
|
|
68
|
-
"@effect/platform-node": "4.0.0-beta.
|
|
68
|
+
"@effect/platform-node": "4.0.0-beta.33",
|
|
69
69
|
"defu": "6.1.4",
|
|
70
|
-
"effect": "4.0.0-beta.
|
|
70
|
+
"effect": "4.0.0-beta.33",
|
|
71
71
|
"jsonc-parser": "3.3.1",
|
|
72
72
|
"nypm": "0.6.5"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@changesets/cli": "2.30.0",
|
|
76
76
|
"@types/bun": "1.3.10",
|
|
77
|
-
"@
|
|
77
|
+
"@types/figlet": "1.7.0",
|
|
78
|
+
"@typescript/native-preview": "7.0.0-dev.20260313.1",
|
|
78
79
|
"bunup": "0.16.31",
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"oxlint
|
|
80
|
+
"figlet": "1.11.0",
|
|
81
|
+
"knip": "5.86.0",
|
|
82
|
+
"oxfmt": "0.40.0",
|
|
83
|
+
"oxlint": "1.55.0",
|
|
84
|
+
"oxlint-tsgolint": "0.17.0",
|
|
83
85
|
"sherif": "1.10.0",
|
|
84
|
-
"type-fest": "5.4.4"
|
|
85
|
-
"typescript": "5.9.3"
|
|
86
|
+
"type-fest": "5.4.4"
|
|
86
87
|
},
|
|
87
88
|
"engines": {
|
|
88
89
|
"bun": ">=1.3.6"
|
package/presets/lint/core.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from "oxlint"
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
|
-
ignorePatterns: ["**/node_modules", "**/.git", "**/build", "**/dist", "**/.next", "**/.vercel"],
|
|
5
4
|
plugins: ["eslint", "typescript", "unicorn", "oxc", "import", "jsdoc", "promise"],
|
|
6
5
|
rules: {
|
|
7
6
|
"accessor-pairs": "error",
|