adamantite 0.30.0 → 0.30.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +22 -22
- package/dist/presets/format.json +44 -0
- package/dist/presets/knip.json +29 -0
- package/dist/presets/lint/core.d.ts +430 -0
- package/dist/presets/lint/core.js +463 -0
- package/dist/presets/lint/jest.d.ts +58 -0
- package/dist/presets/lint/jest.js +62 -0
- package/dist/presets/lint/nextjs.d.ts +27 -0
- package/dist/presets/lint/nextjs.js +31 -0
- package/dist/presets/lint/node.d.ts +9 -0
- package/dist/presets/lint/node.js +13 -0
- package/dist/presets/lint/react.d.ts +77 -0
- package/dist/presets/lint/react.js +84 -0
- package/dist/presets/lint/vitest.d.ts +21 -0
- package/dist/presets/lint/vitest.js +25 -0
- package/dist/presets/lint/vue.d.ts +22 -0
- package/dist/presets/lint/vue.js +26 -0
- package/dist/presets/tsconfig.json +24 -0
- package/package.json +22 -18
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
`)}class
|
|
3
|
-
`)}}class
|
|
4
|
-
`).reduce((
|
|
5
|
-
`).pipe(
|
|
6
|
-
`).pipe(
|
|
7
|
-
`)}function
|
|
8
|
-
`)}var
|
|
9
|
-
`).pipe(
|
|
10
|
-
`).pipe(
|
|
1
|
+
import*as wg from"@effect/platform-node/NodeRuntime";import*as eg from"@effect/platform-node/NodeServices";import*as X from"effect/Effect";import*as dg from"effect/Exit";import*as cg from"effect/Layer";import*as pg from"effect/Runtime";import*as t from"effect/unstable/cli/Command";import*as sg from"effect/unstable/process/ChildProcessSpawner";import*as zg from"effect/Effect";import*as w from"effect/unstable/cli/Command";import*as e from"effect/unstable/cli/Flag";import*as Ug from"effect/unstable/process/ChildProcessSpawner";import*as q from"effect/Data";import{printParseErrorCode as a$}from"jsonc-parser";function g$(a=[]){if(a.length===0)return"- Unknown JSON/JSONC parsing error";return a.slice(0,3).map((g)=>`- ${a$(g.error)} (offset: ${g.offset})`).join(`
|
|
2
|
+
`)}class Ta extends q.TaggedError("CliNotFound"){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}}class L extends q.TaggedError("CommandFailed"){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}}class P extends q.TaggedError("FailedToCreateDirectory"){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:"the target directory"}.`}}class Fa extends q.TaggedError("FailedToInstallDependency"){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(", ")}`:""}.`}}class Ha extends q.TaggedError("FailedToInstallExtension"){get message(){return`Failed to install ${this.extension?`\`${this.extension}\``:"the target extension"}.`}}class Ia extends q.TaggedError("FailedToMergeConfig"){get message(){return`Failed to merge configuration.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class ka extends q.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:",g$(this.errors)].join(`
|
|
3
|
+
`)}}class Z extends q.TaggedError("FailedToReadFile"){get message(){return`Failed to read ${this.path?`\`${this.path}\``:"the target file"}.`}}class oa extends q.TaggedError("FailedToDeleteFile"){get message(){return`Failed to delete ${this.path?`\`${this.path}\``:"the target file"}.`}}class z extends q.TaggedError("FailedToWriteFile"){get message(){return`Failed to write ${this.path?`\`${this.path}\``:"the target file"}.`}}class h extends q.TaggedError("FileNotFound"){get message(){return this.path?`File not found: \`${this.path}\`.`:"File not found."}}class j extends q.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 _a extends q.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 $$ extends q.TaggedError("MissingPackageVersion"){get message(){return`Missing version field in ${this.path?`\`${this.path}\``:"package.json"}.`}}class Za extends q.TaggedError("OperationCancelled"){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:""}`}}class xa extends q.TaggedError("UnknownScript"){get message(){return`Unknown script: \`${this.script}\`.`}}class ta extends q.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*as m from"effect/Effect";import*as Xa from"effect/FileSystem";import*as ia from"effect/Path";var ag={$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"]};import na from"node:process";import{defu as v$}from"defu";import*as gg from"effect/Console";import*as U from"effect/Effect";import*as ba from"effect/FileSystem";import*as Pa from"effect/Path";import*as $g from"effect/Terminal";import*as Dg from"effect/unstable/process/ChildProcess";import*as vg from"effect/unstable/process/ChildProcessSpawner";import{parse as l$}from"jsonc-parser";var lg=(a)=>{let g=na.platform==="win32"?"where":"which";return U.scoped(U.gen(function*(){return yield*(yield*Dg.make(g,[a],{stderr:"ignore",stdin:"ignore",stdout:"ignore"})).exitCode})).pipe(U.flatMap(($)=>$===vg.ExitCode(0)?U.succeed(!0):U.fail(new Ta({command:a}))))},A=(a,g)=>U.sync(()=>{let $=[],D=l$(a,$,{allowTrailingComma:!0});return{errors:$,parsed:D}}).pipe(U.flatMap(({errors:$,parsed:D})=>$.length>0?U.fail(new ka({errors:$,path:g})):U.succeed(D)));function W(a){return a!==null&&typeof a==="object"&&!Array.isArray(a)}var y$=/^workspace:/,E$=/^[\^~]/;function yg(a){return a.trim().replace(y$,"").replace(E$,"")}var u=(a,g)=>U.try({catch:($)=>new Ia({cause:$}),try:()=>v$(a,g)}),za=(a=na.cwd())=>U.gen(function*(){let g=yield*ba.FileSystem,D=(yield*Pa.Path).join(a,"package.json"),l=yield*g.readFileString(D).pipe(U.mapError((y)=>new Z({cause:y,path:D})));return yield*A(l,D)}),ha=(a=na.cwd())=>U.gen(function*(){let g=yield*ba.FileSystem,$=yield*Pa.Path;if(yield*g.exists($.join(a,"pnpm-workspace.yaml")))return!0;return(yield*za(a)).workspaces!==void 0}),Eg=(a)=>U.gen(function*(){yield*(yield*ba.FileSystem).makeDirectory(a,{recursive:!0}).pipe(U.mapError(($)=>new P({cause:$,path:a})))}),Ka=()=>U.gen(function*(){let g=yield*(yield*$g.Terminal).columns,$='\n .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',D='\n .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'.split(`
|
|
4
|
+
`).reduce((l,v)=>Math.max(l,v.trim().length),0);if(!g||g<D)return;yield*gg.info('\n .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')});var Ca="knip.json",f$="knip.jsonc",M={config:ag,create:(a)=>m.gen(function*(){let g=yield*Xa.FileSystem,D=(yield*ia.Path).join(a,Ca),l=JSON.stringify(M.config,null,2);yield*g.writeFileString(D,`${l}
|
|
5
|
+
`).pipe(m.mapError((v)=>new z({cause:v,path:D})))}),exists:(a)=>m.gen(function*(){let g=yield*Xa.FileSystem,$=yield*ia.Path,D=$.join(a,Ca),l=$.join(a,f$);if(yield*g.exists(D))return{path:D};if(yield*g.exists(l))return{path:l};return{path:null}}),name:"knip",update:(a)=>m.gen(function*(){let g=yield*Xa.FileSystem,{path:$}=yield*M.exists(a);if(!$)return yield*new h({path:Ca});let D=yield*g.readFileString($).pipe(m.mapError((E)=>new Z({cause:E,path:$}))),l=yield*A(D,$);if(!W(l))return yield*new j({path:$});let v=yield*u(l,M.config),y=$.endsWith(".jsonc");v.$schema=y?"https://unpkg.com/knip@5/schema-jsonc.json":"https://unpkg.com/knip@5/schema.json",yield*g.writeFileString($,`${JSON.stringify(v,null,2)}
|
|
6
|
+
`).pipe(m.mapError((E)=>new z({cause:E,path:$})))}),version:"5.85.0"};import*as J from"effect/Effect";import*as fg from"effect/Layer";import*as Tg from"effect/ServiceMap";import*as _g from"effect/unstable/process/ChildProcess";class b extends Tg.Service()("CommandRunner"){static layer=fg.succeed(this)({run:({args:a,command:g,cwd:$,stderr:D="inherit",stdin:l="ignore",stdout:v="inherit"})=>J.mapError(J.scoped(J.gen(function*(){return yield*(yield*J.fromYieldable(_g.make(g,a,{cwd:$,stderr:D,stdin:l,stdout:v}))).exitCode})),(y)=>y.reason._tag==="NotFound"?new Ta({command:g}):y)})}var T$=e.boolean("fix").pipe(e.withDescription("Automatically fix issues")),_$=e.boolean("strict").pipe(e.withDescription("Enable strict mode")),Bg=w.make("analyze",{fix:T$,strict:_$}).pipe(w.withDescription("Find unused dependencies, exports, and files using knip"),w.withHandler(({fix:a,strict:g})=>zg.gen(function*(){let $=yield*b,D=[];if(a)D.push("--fix","--allow-remove-files");if(g)D.push("--production","--strict");let l=yield*$.run({args:D,command:M.name});if(l!==Ug.ExitCode(0))yield*new L({command:M.name,exitCode:l})})));import*as Zg from"effect/Effect";import*as d from"effect/unstable/cli/Argument";import*as c from"effect/unstable/cli/Command";import*as bg from"effect/unstable/process/ChildProcessSpawner";import*as G from"effect/Effect";import*as Ma from"effect/FileSystem";import*as Va from"effect/Path";var wa="oxlint.config.ts",Qg=".oxlintrc.json",z$=/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/,U$=/^adamantite\/lint(?:\/([a-z0-9-]+))?$/;function qg(a=[]){return a.includes("core")?a:["core",...a]}function B$(a){if(Array.isArray(a))return a.filter((g)=>typeof g==="string");if(typeof a==="string")return[a];return[]}function Yg(a){return a.replaceAll(/-([a-z])/g,(g,$)=>$.toUpperCase())}function Q$(a){return a==="core"?"adamantite/lint":`adamantite/lint/${a}`}function q$(a){let g=a.match(z$);if(g?.[1])return g[1];let $=a.match(U$);if($)return $[1]??"core";return null}function Y$(a,g){let $=" ".repeat(g);return a.map(([D,l])=>`${$}${D}: ${l},`).join(`
|
|
7
|
+
`)}function Hg(a,g,$=[]){let D=['import { defineConfig } from "oxlint"',...g.map((f)=>`import ${Yg(f)} from "${Q$(f)}"`)],v=[...g.map((f)=>Yg(f)),...$.map((f)=>JSON.stringify(f))],y=[...Object.entries(a).map(([f,Ea])=>[f,JSON.stringify(Ea,null,2)]),["extends",`[${v.join(", ")}]`]],E=Y$(y,2);return[...D,"","export default defineConfig({",E,"})",""].join(`
|
|
8
|
+
`)}var Y={create:(a,g=[])=>G.gen(function*(){let $=yield*Ma.FileSystem,l=(yield*Va.Path).join(a,wa),v=Hg({},qg(g));yield*$.writeFileString(l,v).pipe(G.mapError((y)=>new z({cause:y,path:l})))}),exists:(a)=>G.gen(function*(){let g=yield*Ma.FileSystem,$=yield*Va.Path,D=$.join(a,wa),l=$.join(a,Qg),v=yield*g.exists(D),y=yield*g.exists(l),E=v?"ts":y?"json":null;return{format:E,hasBoth:v&&y,jsonPath:y?l:null,path:E==="ts"?D:E==="json"?l:null,tsPath:v?D:null}}),name:"oxlint",update:(a,g=[])=>G.gen(function*(){let $=yield*Ma.FileSystem,D=yield*Va.Path,l=yield*Y.exists(a);if(l.tsPath)return;if(!l.jsonPath)return yield*new h({path:Qg});let v=l.jsonPath,y=D.join(a,wa),E=yield*$.readFileString(v).pipe(G.mapError((H)=>new Z({cause:H,path:v}))),f=yield*A(E,v);if(!W(f))return yield*new j({path:v});let{$schema:Ea,...Ba}=f,Qa=B$(Ba.extends),fa=new Set(qg(g)),qa=new Set;for(let H of Qa){let n=q$(H);if(n)fa.add(n);else qa.add(H)}let{extends:ra,...Ya}=Ba;yield*$.writeFileString(y,Hg(Ya,[...fa],[...qa])).pipe(G.mapError((H)=>new z({cause:H,path:y}))),yield*$.remove(v).pipe(G.mapError((H)=>new oa({cause:H,path:v})))}),version:"1.50.0"},Ua={name:"oxlint-tsgolint",version:"0.14.2"};var H$=d.file("files",{mustExist:!0}).pipe(d.withDescription("Specific files to lint (optional)"),d.variadic()),Kg=c.make("check",{files:H$}).pipe(c.withDescription("Find issues in code using oxlint"),c.withHandler(({files:a})=>Zg.gen(function*(){let $=yield*(yield*b).run({args:["--type-aware",...a],command:Y.name});if($!==bg.ExitCode(0))yield*new L({command:Y.name,exitCode:$})})));import*as Xg from"effect/Effect";import*as p from"effect/unstable/cli/Argument";import*as s from"effect/unstable/cli/Command";import*as r from"effect/unstable/cli/Flag";import*as Mg from"effect/unstable/process/ChildProcessSpawner";var Z$=p.file("files",{mustExist:!0}).pipe(p.withDescription("Specific files to fix (optional)"),p.variadic()),b$=r.boolean("suggested").pipe(r.withDescription("Apply suggested fixes")),K$=r.boolean("dangerous").pipe(r.withDescription("Apply dangerous fixes")),X$=r.boolean("all").pipe(r.withDescription("Apply all fixes, including suggested and dangerous fixes")),Vg=s.make("fix",{all:X$,dangerous:K$,files:Z$,suggested:b$}).pipe(s.withDescription("Fix issues in code using oxlint"),s.withHandler(({all:a,dangerous:g,files:$,suggested:D})=>Xg.gen(function*(){let l=yield*b,v=new Set(["--type-aware","--fix"]);if(D||a)v.add("--fix-suggestions");if(g||a)v.add("--fix-dangerously");for(let E of $)v.add(E);let y=yield*l.run({args:[...v],command:Y.name});if(y!==Mg.ExitCode(0))yield*new L({command:Y.name,exitCode:y})})));import*as jg from"effect/Effect";import*as aa from"effect/unstable/cli/Argument";import*as ga from"effect/unstable/cli/Command";import*as ja from"effect/unstable/cli/Flag";import*as Ag from"effect/unstable/process/ChildProcessSpawner";import*as F from"effect/Effect";import*as La from"effect/FileSystem";import*as da from"effect/Path";var Lg={$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 ea=".oxfmtrc.jsonc",V$=".oxfmtrc.json",K={config:{...Lg,$schema:"./node_modules/oxfmt/configuration_schema.json"},create:(a)=>F.gen(function*(){let g=yield*La.FileSystem,D=(yield*da.Path).join(a,ea),l=JSON.stringify(K.config,null,2);yield*g.writeFileString(D,`${l}
|
|
9
|
+
`).pipe(F.mapError((v)=>new z({cause:v,path:D})))}),exists:(a)=>F.gen(function*(){let g=yield*La.FileSystem,$=yield*da.Path,D=$.join(a,ea),l=$.join(a,V$);if(yield*g.exists(D))return{path:D};if(yield*g.exists(l))return{path:l};return{path:null}}),name:"oxfmt",update:(a)=>F.gen(function*(){let g=yield*La.FileSystem,{path:$}=yield*K.exists(a);if(!$)return yield*new h({path:ea});let D=yield*g.readFileString($).pipe(F.mapError((y)=>new Z({cause:y,path:$}))),l=yield*A(D,$);if(!W(l))return yield*new j({path:$});let v=yield*u(l,K.config);v.$schema=K.config.$schema,yield*g.writeFileString($,`${JSON.stringify(v,null,2)}
|
|
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
|
|
11
11
|
uses: actions/setup-node@v6
|
|
12
12
|
with:
|
|
13
13
|
node-version: "22"
|
|
@@ -54,7 +54,7 @@ import Ft from"node:process";import*as P from"@effect/cli/Command";import*as Cn
|
|
|
54
54
|
cache: "yarn"
|
|
55
55
|
|
|
56
56
|
- name: Install dependencies
|
|
57
|
-
run: yarn install --frozen-lockfile`},
|
|
57
|
+
run: yarn install --frozen-lockfile`},Og=[{name:"lint",script:"check"},{args:["--check"],name:"format",script:"format"},{name:"types",script:"typecheck"},{name:"monorepo",script:"check:monorepo"},{name:"analyze",script:"analyze"}];function Ng({packageManager:a,scripts:g}){let $=[];for(let v of Og){if(!g.includes(v.script))continue;$.push({command:A$(a,v.script,{args:v.args}),name:v.name})}if($.length===0)return null;return`${`name: adamantite
|
|
58
58
|
|
|
59
59
|
on:
|
|
60
60
|
push:
|
|
@@ -79,23 +79,23 @@ jobs:
|
|
|
79
79
|
fail-fast: false
|
|
80
80
|
matrix:
|
|
81
81
|
include:
|
|
82
|
-
${
|
|
83
|
-
command: ${
|
|
82
|
+
${$.map((v)=>` - name: ${v.name}
|
|
83
|
+
command: ${v.command}`).join(`
|
|
84
84
|
`)}
|
|
85
85
|
|
|
86
86
|
steps:
|
|
87
87
|
- name: Checkout
|
|
88
88
|
uses: actions/checkout@v4
|
|
89
89
|
|
|
90
|
-
${
|
|
90
|
+
${W$[a]}
|
|
91
91
|
|
|
92
92
|
- name: Run \${{ matrix.name }}
|
|
93
93
|
run: \${{ matrix.command }}`}
|
|
94
|
-
`}var
|
|
95
|
-
`).pipe(
|
|
96
|
-
`).pipe(
|
|
97
|
-
`).pipe(
|
|
98
|
-
`).pipe(
|
|
99
|
-
`).pipe(
|
|
100
|
-
`).pipe(
|
|
101
|
-
`).pipe(a.mapError((S)=>new l({cause:S,path:f}))),r.stop("Scripts added to your `package.json`")}),Qt=()=>a.gen(function*(){let t=(yield*p).spinner();t.start("Setting up knip config...");let n=yield*j.exists();if(n.path)t.message(`Found \`${n.path}\`, updating...`),yield*j.update(),t.stop("knip config updated successfully.");else t.message("`knip.json` not found, creating..."),yield*j.create(),t.stop("knip config created successfully.")}),Ot=()=>a.gen(function*(){let t=(yield*p).spinner();if(t.start("Setting up TypeScript config..."),yield*Z.exists())t.message("`tsconfig.json` found, updating..."),yield*Z.update(),t.stop("`tsconfig.json` updated successfully");else t.message("`tsconfig.json` not found, creating..."),yield*Z.create(),t.stop("`tsconfig.json` created successfully")}),Wt=(e)=>a.gen(function*(){let t=yield*p;if(e.includes("vscode")){let n=t.spinner();if(n.start("Checking for `.vscode/settings.json`..."),yield*N.exists())n.message("`.vscode/settings.json` found, updating..."),yield*N.update(),n.stop("`.vscode/settings.json` updated with Adamantite preset.");else n.message("`.vscode/settings.json` not found, creating..."),yield*N.create(),n.stop("`.vscode/settings.json` created with Adamantite preset.")}if(e.includes("zed")){let n=t.spinner();if(n.start("Checking for `.zed/settings.json`..."),yield*ge.exists())n.message("`.zed/settings.json` found, updating..."),yield*ge.update(),n.stop("`.zed/settings.json` updated with Adamantite preset.");else n.message("`.zed/settings.json` not found, creating..."),yield*ge.create(),n.stop("`.zed/settings.json` created with Adamantite preset.")}}),Xt=(e,t)=>a.gen(function*(){let n=yield*p,i=n.spinner();i.start("Installing editor extensions...");let o=e.includes("zed"),s=e.includes("vscode");if(yield*a.gen(function*(){if(e.includes("vscode"))i.message("Installing VS Code extension..."),yield*N.extension(t);return!0}).pipe(a.tapError(()=>a.sync(()=>{i.stop()})),a.catchTags({FailedToInstallExtension:(y)=>a.gen(function*(){return yield*n.log.warning(`⚠️ Failed to install the \`${y.extension}\` extension.`),yield*n.log.warning("Please install it manually after setup completes."),!1}),VscodeCliNotFound:()=>a.gen(function*(){return yield*n.log.error("VSCode CLI ('code' command) not found."),yield*n.log.info("To install it:"),yield*n.log.info(" 1. Open VS Code"),yield*n.log.info(" 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)"),yield*n.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1})})))if(o&&!s)i.stop("Zed extensions require manual install.");else i.stop("Editor extensions installed successfully.");if(o)yield*n.log.info("Install the Zed `oxc` extension: zed://extension/oxc")}),Lt=(e,t)=>a.gen(function*(){let i=(yield*p).spinner();if(i.start("Setting up GitHub Actions workflow..."),yield*_e.exists())i.message("`.github/workflows/adamantite.yml` found, updating..."),yield*_e.update({packageManager:e,scripts:t}),i.stop("GitHub Actions workflow updated successfully.");else i.message("Creating `.github/workflows/adamantite.yml`..."),yield*_e.create({packageManager:e,scripts:t}),i.stop("GitHub Actions workflow created successfully.")}).pipe(a.option),Rn=pe.make("init").pipe(pe.withDescription("Initialize Adamantite in the current directory"),pe.withHandler(()=>a.gen(function*(){let e=yield*p;yield*ze(),yield*e.intro("\uD83D\uDCA0 adamantite init");let t=yield*a.tryPromise({catch:(v)=>new ke({cause:v}),try:()=>_t(Zt.cwd())});if(!t)return yield*a.fail(new ke({}));if(t.warnings?.length)for(let v of t.warnings)yield*e.log.warning(v);yield*e.log.info(`Detected package manager: ${t.name}`);let n=yield*Ce();if(n)yield*e.log.info("We've detected a monorepo setup in your project.");let i=yield*e.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:!n,hint:n?void 0:"available for monorepo projects",label:"check:monorepo - check for monorepo-specific issues using Sherif",value:"check:monorepo"},{disabled:!n,hint:n?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"}]}),o=i.includes("check")||i.includes("fix"),s=[];if(o)s=yield*e.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 r=yield*e.multiselect({message:"Which editors do you want to configure? (optional)",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}),y=!1;if(r.length>0)y=yield*e.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"});let f=Kn(i),S=!1;if(f)S=yield*e.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"});let he=i.includes("format"),xe=i.includes("check:monorepo")||i.includes("fix:monorepo"),we=i.includes("typecheck"),Xe=i.includes("analyze"),Y=["adamantite"];if(o)Y.push(`${m.name}@${m.version}`),Y.push(`${be.name}@${be.version}`);if(he)Y.push(`${E.name}@${E.version}`);if(xe)Y.push(`${I.name}@${I.version}`);if(we)Y.push(`${Z.name}@${Z.version}`);if(Xe)Y.push(`${j.name}@${j.version}`);if(yield*qt(Y),he)yield*Yt();if(o)yield*Bt(s);if(Xe)yield*Qt();if(yield*Kt(i),we)yield*Ot();if(yield*Wt(r),y)yield*Xt(r,i);if(S)yield*Lt(t.name,i);yield*e.log.success("Your project is now configured"),yield*e.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe(a.catchTags({OperationCancelled:()=>a.gen(function*(){yield*(yield*p).cancel("You've cancelled the initialization process.")})}))));import*as ue from"@effect/cli/Command";import*as We from"@effect/cli/Options";import*as q from"@effect/platform/Command";import*as Gn from"@effect/platform/CommandExecutor";import*as me from"effect/Effect";var Rt=We.boolean("fix").pipe(We.withDescription("Automatically fix issues")),Jn=ue.make("monorepo",{fix:Rt}).pipe(ue.withDescription("Find and fix monorepo-specific issues using Sherif"),ue.withHandler(({fix:e})=>me.gen(function*(){let t=[];if(e)t.push("--fix");return yield*q.make(I.name,...t).pipe(q.stdin("inherit"),q.stdout("inherit"),q.stderr("inherit"),q.exitCode,me.filterOrFail((n)=>n===Gn.ExitCode(0),(n)=>new h({command:I.name,exitCode:n})),me.asVoid)})));import*as fe from"@effect/cli/Command";import*as T from"@effect/cli/Options";import*as B from"@effect/platform/Command";import*as Nn from"@effect/platform/CommandExecutor";import*as ye from"effect/Effect";import*as Fn from"effect/Option";var Gt=T.file("project").pipe(T.withAlias("p"),T.optional,T.withDescription("Path to tsconfig.json file")),Jt=T.boolean("watch").pipe(T.withAlias("w"),T.withDescription("Run in watch mode")),In=fe.make("typecheck",{project:Gt,watch:Jt}).pipe(fe.withDescription("Run TypeScript type checking"),fe.withHandler(({project:e,watch:t})=>ye.gen(function*(){let i=yield*(yield*K).get,o=["--noEmit"];if(Fn.isSome(e))o.push("--project",e.value);if(t)o.push("--watch");return yield*B.make(Z.command,...o).pipe(B.workingDirectory(i),B.stdout("inherit"),B.stderr("inherit"),B.exitCode,ye.filterOrFail((s)=>s===Nn.ExitCode(0),(s)=>new h({command:Z.command,exitCode:s})),ye.asVoid)})));import*as ve from"@effect/cli/Command";import*as b from"effect/Effect";import{addDevDependency as Nt}from"nypm";var Pn=ve.make("update").pipe(ve.withDescription("Update adamantite dependencies to latest compatible versions"),ve.withHandler(()=>b.gen(function*(){let e=yield*p,t=yield*$e(),n=yield*m.exists(),i=n.format==="json";yield*ze(),yield*e.intro("\uD83D\uDCA0 adamantite update");let o=[];for(let s of[m,be,E,I]){let r=t.devDependencies?.[s.name];if(r&&$n(r)!==s.version)o.push({currentVersion:r,isDevDependency:!0,name:s.name,targetVersion:s.version})}if(o.length===0&&!i)return yield*e.log.success("All adamantite dependencies are already up to date!"),"no-updates";if(o.length>0){yield*e.log.info("The following dependencies will be updated:");for(let r of o)yield*e.log.info(` ${r.name}: ${r.currentVersion} → ${r.targetVersion}`);if(!(yield*e.confirm({message:"Do you want to proceed with these updates?"})))return"cancelled"}if(o.length>0){let s=e.spinner();s.start("Updating dependencies..."),yield*b.tryPromise({catch:(r)=>new Ee({cause:r,packages:o.map((y)=>y.name)}),try:()=>Nt(o.map((r)=>`${r.name}@${r.targetVersion}`),{silent:!0})}).pipe(b.tapError(()=>b.sync(()=>{s.stop("Failed to update dependencies")}))),s.stop("Dependencies updated successfully")}if(n.hasBoth)yield*e.log.warning("Found both `oxlint.config.ts` and `.oxlintrc.json`. Adamantite will use `oxlint.config.ts`.");if(i){let s=e.spinner();s.start("Migrating `.oxlintrc.json` to `oxlint.config.ts`..."),yield*m.update(),s.stop("Oxlint config migrated successfully")}if(o.length===0&&i)return"migrated";return"updated"}).pipe(b.tap((e)=>b.gen(function*(){let t=yield*p;switch(e){case"no-updates":yield*t.outro("✅ No updates needed");break;case"cancelled":yield*t.outro("⚠️ Update cancelled");break;case"updated":yield*t.outro("✅ Dependencies updated successfully!");break;case"migrated":yield*t.outro("✅ Oxlint config migrated to `oxlint.config.ts`!");break;default:break}})),b.catchTags({OperationCancelled:()=>b.gen(function*(){yield*(yield*p).cancel("You've cancelled the update process.")})}))));var It=P.make("adamantite").pipe(P.withDescription("Opinionated preset package for modern TypeScript applications"),P.withSubcommands([xn,An,Vn,qn,Rn,Jn,In,Pn])),Pt=await"0.30.0",Ct=P.run(It,{name:"adamantite",version:Pt});Ct(Ft.argv).pipe(A.as(cn.ExitCode(0)),A.catchTag("CommandFailed",(e)=>A.succeed(e.exitCode)),A.catchAll((e)=>A.gen(function*(){let t=yield*p,n="message"in e&&e.message?e.message:"An unexpected error occurred.";return yield*t.log.error(n),cn.ExitCode(1)}))).pipe(A.provide(tt.mergeAll(Cn.layer,Wn,fn)),et.runMain({teardown:(e,t)=>{t(nt.isSuccess(e)?e.value:1)}}));
|
|
94
|
+
`}var N$=new Set(Og.map((a)=>a.script));function Sg(a){return a.some((g)=>N$.has(g))}var Na={create:(a,g)=>C.gen(function*(){let $=yield*Aa.FileSystem,D=yield*Wa.Path,l=D.join(a,".github","workflows");yield*Eg(l);let v=Ng(g);if(!v)return;let y=D.join(l,"adamantite.yml");yield*$.writeFileString(y,v).pipe(C.mapError((E)=>new z({cause:E,path:y})))}),exists:(a)=>C.gen(function*(){let g=yield*Aa.FileSystem,$=yield*Wa.Path;return yield*g.exists($.join(a,".github","workflows","adamantite.yml"))}),update:(a,g)=>C.gen(function*(){let $=yield*Aa.FileSystem,l=(yield*Wa.Path).join(a,".github","workflows","adamantite.yml"),v=Ng(g);if(!v)return;yield*$.writeFileString(l,v).pipe(C.mapError((y)=>new z({cause:y,path:l})))}),workflowPath:".github/workflows/adamantite.yml"};import*as _ from"effect/Effect";import*as Oa from"effect/FileSystem";import*as Sa from"effect/Path";import*as ug from"effect/unstable/process/ChildProcess";import*as Gg from"effect/unstable/process/ChildProcessSpawner";var ca="settings.json",I={cliExists:()=>lg("code").pipe(_.mapError((a)=>new ta({cause:a}))),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,"typescript.tsdk":"node_modules/typescript/lib"},create:(a)=>_.gen(function*(){let g=yield*Oa.FileSystem,$=yield*Sa.Path,D=$.join(a,".vscode"),l=$.join(D,ca);yield*g.makeDirectory(D,{recursive:!0}).pipe(_.mapError((v)=>new P({cause:v,path:D}))),yield*g.writeFileString(l,`${JSON.stringify(I.config,null,2)}
|
|
95
|
+
`).pipe(_.mapError((v)=>new z({cause:v,path:l})))}),exists:(a)=>_.gen(function*(){let g=yield*Oa.FileSystem,$=yield*Sa.Path;return yield*g.exists($.join(a,".vscode",ca))}),extension:(a=[])=>_.scoped(_.gen(function*(){yield*I.cliExists();function g(v){return _.gen(function*(){return yield*(yield*ug.make("code",["--install-extension",v],{stderr:"inherit",stdin:"ignore",stdout:"inherit"})).exitCode}).pipe(_.mapError((y)=>new Ha({cause:y,extension:v})),_.filterOrFail((y)=>y===Gg.ExitCode(0),(y)=>new Ha({cause:y,extension:v})),_.asVoid)}let $=[a.includes("check")||a.includes("fix")||a.includes("format")?g("oxc.oxc-vscode"):_.void,a.includes("analyze")?g("webpro.vscode-knip"):_.void],l=(yield*_.all($.map((v)=>v.pipe(_.match({onFailure:(y)=>y,onSuccess:()=>null}))))).find((v)=>v!==null);if(l)yield*_.fail(l)})),update:(a)=>_.gen(function*(){let g=yield*Oa.FileSystem,D=(yield*Sa.Path).join(a,".vscode",ca),l=yield*g.readFileString(D).pipe(_.mapError((E)=>new Z({cause:E,path:D}))),v=yield*A(l,D);if(!W(v))return yield*new j({path:D});let y=yield*u(I.config,v);yield*g.writeFileString(D,`${JSON.stringify(y,null,2)}
|
|
96
|
+
`).pipe(_.mapError((E)=>new z({cause:E,path:D})))})};import*as R from"effect/Effect";import*as ua from"effect/FileSystem";import*as Ga from"effect/Path";var pa="settings.json",$a={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"}}]},TypeScript:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},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:(a)=>R.gen(function*(){let g=yield*ua.FileSystem,$=yield*Ga.Path,D=$.join(a,".zed"),l=$.join(D,pa);yield*g.makeDirectory(D,{recursive:!0}).pipe(R.mapError((v)=>new P({cause:v,path:D}))),yield*g.writeFileString(l,`${JSON.stringify($a.config,null,2)}
|
|
97
|
+
`).pipe(R.mapError((v)=>new z({cause:v,path:l})))}),exists:(a)=>R.gen(function*(){let g=yield*ua.FileSystem,$=yield*Ga.Path;return yield*g.exists($.join(a,".zed",pa))}),update:(a)=>R.gen(function*(){let g=yield*ua.FileSystem,D=(yield*Ga.Path).join(a,".zed",pa),l=yield*g.readFileString(D).pipe(R.mapError((E)=>new Z({cause:E,path:D}))),v=yield*A(l,D);if(!W(v))return yield*new j({path:D});let y=yield*u($a.config,v);yield*g.writeFileString(D,`${JSON.stringify(y,null,2)}
|
|
98
|
+
`).pipe(R.mapError((E)=>new z({cause:E,path:D})))})};var k={name:"sherif",version:"1.10.0"};import*as o from"effect/Effect";import*as Ra from"effect/FileSystem";import*as ma from"effect/Path";var sa="tsconfig.json",S={command:"tsc",config:{extends:"adamantite/typescript"},create:(a)=>o.gen(function*(){let g=yield*Ra.FileSystem,D=(yield*ma.Path).join(a,sa),l=JSON.stringify(S.config,null,2);yield*g.writeFileString(D,`${l}
|
|
99
|
+
`).pipe(o.mapError((v)=>new z({cause:v,path:D})))}),exists:(a)=>o.gen(function*(){let g=yield*Ra.FileSystem,$=yield*ma.Path;return yield*g.exists($.join(a,sa))}),name:"typescript",update:(a)=>o.gen(function*(){let g=yield*Ra.FileSystem,D=(yield*ma.Path).join(a,sa),l=yield*g.readFileString(D).pipe(o.mapError((E)=>new Z({cause:E,path:D}))),v=yield*A(l,D);if(!W(v))return yield*new j({path:D});let y=yield*u(S.config,v);yield*g.writeFileString(D,`${JSON.stringify(y,null,2)}
|
|
100
|
+
`).pipe(o.mapError((E)=>new z({cause:E,path:D})))}),version:"5.9.3"};import*as i from"effect/Effect";import*as Rg from"effect/Layer";import*as mg from"effect/ServiceMap";import{addDevDependency as O$,detectPackageManager as S$}from"nypm";class x extends mg.Service()("DependencyInstaller"){static layer=Rg.succeed(this)({addDevDependencies:(a,g,$)=>i.tryPromise({catch:(D)=>new Fa({cause:D,packages:a}),try:()=>O$(a,{...$,cwd:g})}).pipe(i.asVoid),detectPackageManager:(a)=>i.tryPromise({catch:(g)=>new _a({cause:g}),try:()=>S$(a)}).pipe(i.map((g)=>g??null))})}import*as B from"@clack/prompts";import*as V from"effect/Effect";import*as Jg from"effect/Layer";import*as rg from"effect/ServiceMap";class Q extends rg.Service()("Prompter"){static layer=Jg.succeed(this)({cancel:(a)=>V.sync(()=>{B.cancel(a)}),confirm:(a)=>V.promise(()=>B.confirm(a)).pipe(V.filterOrFail((g)=>!B.isCancel(g),()=>new Za({}))),intro:(a)=>V.sync(()=>{B.intro(a)}),log:{error:(a)=>V.sync(()=>{B.log.error(a)}),info:(a)=>V.sync(()=>{B.log.info(a)}),success:(a)=>V.sync(()=>{B.log.success(a)}),warning:(a)=>V.sync(()=>{B.log.warning(a)})},multiselect:(a)=>V.promise(()=>B.multiselect(a)).pipe(V.filterOrFail((g)=>!B.isCancel(g),()=>new Za({}))),outro:(a)=>V.sync(()=>{B.outro(a)}),spinner:()=>B.spinner()})}var G$=(a,g)=>T.gen(function*(){let $=yield*x,l=(yield*Q).spinner();l.start("Installing dependencies...");let v=yield*ha(a);yield*$.addDevDependencies(g,a,{silent:!0,workspace:v}).pipe(T.tapError(()=>T.sync(()=>{l.stop("Failed to install dependencies.")}))),l.stop("Dependencies installed.")}),R$=(a,g)=>T.gen(function*(){let $=yield*Q,D=$.spinner();D.start("Setting up oxlint config...");let l=yield*Y.exists(a);if(l.hasBoth)yield*$.log.warning("Found both `oxlint.config.ts` and `.oxlintrc.json`. Adamantite will use `oxlint.config.ts`.");if(l.format==="json")D.message("Found `.oxlintrc.json`, migrating to `oxlint.config.ts`..."),yield*Y.update(a,g),D.stop("oxlint config migrated successfully.");else if(l.format==="ts")D.message("Found `oxlint.config.ts`, keeping existing config."),D.stop("oxlint config is ready.");else D.message("`oxlint.config.ts` not found, creating..."),yield*Y.create(a,g),D.stop("oxlint config created successfully.")}),m$=(a)=>T.gen(function*(){let $=(yield*Q).spinner();$.start("Setting up oxfmt config...");let D=yield*K.exists(a);if(D.path)$.message(`Found \`${D.path}\`, updating...`),yield*K.update(a),$.stop("oxfmt config updated successfully.");else $.message("`.oxfmtrc.jsonc` or `.oxfmtrc.json` not found, creating..."),yield*K.create(a),$.stop("oxfmt config created successfully.")}),J$=(a,g)=>T.gen(function*(){let $=yield*Fg.FileSystem,D=yield*Ig.Path,l=yield*Q,v=yield*za(a),y=l.spinner();y.start("Adding scripts to your `package.json`..."),v.scripts??={};for(let f of g)switch(f){case"check":v.scripts.check="adamantite check";break;case"fix":v.scripts.fix="adamantite fix";break;case"format":v.scripts.format="adamantite format";break;case"typecheck":v.scripts.typecheck="adamantite typecheck";break;case"check:monorepo":v.scripts["check:monorepo"]="adamantite monorepo";break;case"fix:monorepo":v.scripts["fix:monorepo"]="adamantite monorepo --fix";break;case"analyze":v.scripts.analyze="adamantite analyze";break;default:return yield*new xa({script:f})}let E=D.join(a,"package.json");yield*$.writeFileString(E,`${JSON.stringify(v,null,2)}
|
|
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)}});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../node_modules/oxfmt/configuration_schema.json",
|
|
3
|
+
"arrowParens": "always",
|
|
4
|
+
"bracketSameLine": false,
|
|
5
|
+
"bracketSpacing": true,
|
|
6
|
+
"embeddedLanguageFormatting": "auto",
|
|
7
|
+
"endOfLine": "lf",
|
|
8
|
+
"sortImports": {
|
|
9
|
+
"groups": [
|
|
10
|
+
["value-builtin", "type-import"],
|
|
11
|
+
["value-external"],
|
|
12
|
+
["type-internal"],
|
|
13
|
+
["value-internal"],
|
|
14
|
+
["type-subpath"],
|
|
15
|
+
["value-subpath"],
|
|
16
|
+
["type-parent", "type-sibling", "type-index"],
|
|
17
|
+
["value-parent", "value-sibling", "value-index"],
|
|
18
|
+
["unknown"]
|
|
19
|
+
],
|
|
20
|
+
"ignoreCase": true,
|
|
21
|
+
"newlinesBetween": false,
|
|
22
|
+
"partitionByNewline": true,
|
|
23
|
+
"order": "asc",
|
|
24
|
+
"partitionByComment": true,
|
|
25
|
+
"sortSideEffects": false
|
|
26
|
+
},
|
|
27
|
+
"sortTailwindcss": {
|
|
28
|
+
"attributes": ["className", "class"],
|
|
29
|
+
"functions": ["clsx", "cn", "cva", "tw", "twMerge"],
|
|
30
|
+
"preserveDuplicates": false,
|
|
31
|
+
"preserveWhitespace": false
|
|
32
|
+
},
|
|
33
|
+
"insertFinalNewline": true,
|
|
34
|
+
"jsxSingleQuote": false,
|
|
35
|
+
"objectWrap": "preserve",
|
|
36
|
+
"printWidth": 100,
|
|
37
|
+
"quoteProps": "as-needed",
|
|
38
|
+
"semi": false,
|
|
39
|
+
"singleAttributePerLine": false,
|
|
40
|
+
"singleQuote": false,
|
|
41
|
+
"tabWidth": 2,
|
|
42
|
+
"trailingComma": "es5",
|
|
43
|
+
"useTabs": false
|
|
44
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://unpkg.com/knip@5/schema.json",
|
|
3
|
+
"rules": {
|
|
4
|
+
"files": "error",
|
|
5
|
+
"dependencies": "error",
|
|
6
|
+
"devDependencies": "error",
|
|
7
|
+
"optionalPeerDependencies": "warn",
|
|
8
|
+
"unlisted": "error",
|
|
9
|
+
"binaries": "error",
|
|
10
|
+
"unresolved": "error",
|
|
11
|
+
"exports": "warn",
|
|
12
|
+
"nsExports": "warn",
|
|
13
|
+
"types": "warn",
|
|
14
|
+
"nsTypes": "warn",
|
|
15
|
+
"enumMembers": "off",
|
|
16
|
+
"classMembers": "off",
|
|
17
|
+
"duplicates": "warn"
|
|
18
|
+
},
|
|
19
|
+
"ignoreExportsUsedInFile": true,
|
|
20
|
+
"ignoreFiles": [
|
|
21
|
+
"**/dist/**",
|
|
22
|
+
"**/build/**",
|
|
23
|
+
"**/coverage/**",
|
|
24
|
+
"**/.next/**",
|
|
25
|
+
"**/.vercel/**",
|
|
26
|
+
"**/.turbo/**"
|
|
27
|
+
],
|
|
28
|
+
"ignore": ["**/*.d.ts"]
|
|
29
|
+
}
|