adamantite 0.34.2 → 0.34.4
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 +36 -39
- package/dist/presets/analyze.js +0 -9
- package/package.json +10 -10
- package/presets/analyze.ts +0 -9
package/dist/index.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import*as
|
|
2
|
-
`)}class
|
|
3
|
-
`)}}class R extends
|
|
1
|
+
import*as Rn from"@effect/platform-node/NodeRuntime";import*as bn from"@effect/platform-node/NodeServices";import*as U from"effect/Effect";import*as sn from"effect/Exit";import*as Un from"effect/Layer";import*as Qn from"effect/Runtime";import*as Vn from"effect/Stdio";import*as Wn from"effect/unstable/process/ChildProcessSpawner";import*as ve from"effect/Array";import*as De from"effect/Effect";import*as nr from"effect/unstable/cli/Command";import*as tt from"effect/Effect";import*as w from"effect/unstable/cli/Command";import*as vr from"effect/unstable/cli/Flag";import*as nt from"effect/unstable/process/ChildProcessSpawner";import*as L from"effect/Effect";import*as Pe from"effect/FileSystem";import*as Fe from"effect/Path";function T(r){return r}import*as D from"effect/Data";import{printParseErrorCode as Kn}from"jsonc-parser";function Pn(r=[]){if(r.length===0)return"- Unknown JSON/JSONC parsing error";return r.slice(0,3).map((e)=>`- ${Kn(e.error)} (offset: ${e.offset})`).join(`
|
|
2
|
+
`)}class ze extends D.TaggedError("CliNotFound"){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}}class Q extends D.TaggedError("CommandFailed"){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}}class qe extends D.TaggedError("FailedToCreateDirectory"){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:"the target directory"}.`}}class Be extends D.TaggedError("FailedToInstallDependency"){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(", ")}`:""}.`}}class Ir extends D.TaggedError("FailedToInstallExtension"){get message(){return`Failed to install ${this.extension?`\`${this.extension}\``:"the target extension"}.`}}class Re extends D.TaggedError("FailedToMergeConfig"){get message(){return`Failed to merge configuration.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class be extends D.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:",Pn(this.errors)].join(`
|
|
3
|
+
`)}}class R extends D.TaggedError("FailedToReadFile"){get message(){return`Failed to read ${this.path?`\`${this.path}\``:"the target file"}.`}}class se extends D.TaggedError("FailedToDeleteFile"){get message(){return`Failed to delete ${this.path?`\`${this.path}\``:"the target file"}.`}}class S extends D.TaggedError("FailedToWriteFile"){get message(){return`Failed to write ${this.path?`\`${this.path}\``:"the target file"}.`}}class Ue extends D.TaggedError("FileNotFound"){get message(){return this.path?`File not found: \`${this.path}\`.`:"File not found."}}class A extends D.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 X extends D.TaggedError("InvalidInitOptions"){get message(){return`Invalid init options. ${this.reason}`}}class Qe extends D.TaggedError("UnsupportedConfigState"){get message(){let r=this.path?`\`${this.path}\``:"the target config file",e=this.reason?` ${this.reason}`:"";return`Unsupported config state in ${r}.${e}`}}class _r extends D.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 Fn extends D.TaggedError("MissingPackageVersion"){get message(){let r=this.path?`\`${this.path}\``:"package.json";if(this.dependency)return`Missing \`${this.dependency}\` in ${r} dependencies or devDependencies.`;return`Missing version field in ${r}.`}}class fr extends D.TaggedError("MigrationValidationFailed"){get message(){return`Migration \`${this.migrationId}\` validation failed. ${this.reason}`}}class dr extends D.TaggedError("OperationCancelled"){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:""}`}}class Ve extends D.TaggedError("PassthroughNotSupported"){get message(){return`Command \`adamantite ${this.command}\` does not invoke a single underlying CLI and cannot accept passthrough arguments.`}}class We extends D.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 _n from"node:process";import*as jr from"effect/Effect";import*as Ze from"effect/FileSystem";import*as Ke from"effect/Path";import{defu as Tn}from"defu";import*as N from"effect/Effect";import{parse as Yn}from"jsonc-parser";var H=(r,e)=>N.sync(()=>{let t=[],n=Yn(r,t,{allowTrailingComma:!0});return{errors:t,parsed:n}}).pipe(N.flatMap(({errors:t,parsed:n})=>t.length>0?N.fail(new be({errors:t,path:e})):N.succeed(n)));function $r(r,e={}){let{continuationIndent:t,indentation:n=2}=e,f=JSON.stringify(r,null,n).replaceAll(/"([A-Za-z_$][\w$]*)":/g,"$1:");if(!t)return f;return f.replaceAll(`
|
|
4
4
|
`,`
|
|
5
|
-
${
|
|
6
|
-
`);return
|
|
7
|
-
`);return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig =
|
|
8
|
-
`)
|
|
9
|
-
`)
|
|
10
|
-
`);return[...
|
|
11
|
-
`)}var
|
|
12
|
-
`)?
|
|
13
|
-
`}function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
`)
|
|
17
|
-
`)
|
|
18
|
-
`)}function
|
|
19
|
-
`);return['import { defineConfig } from "oxfmt"','import format from "adamantite/format"',"","export default defineConfig({"," ...format,",...t,"})",""].join(`
|
|
20
|
-
`)}var Q=[{path:"oxfmt.config.ts",type:"config"},{path:".oxfmtrc.json",type:"legacy_config"},{path:".oxfmtrc.jsonc",type:"legacy_config"}];var h=I({assess:(e)=>oe.gen(function*(){let t=yield*lt.FileSystem,n=yield*pt.Path,r=yield*v(e);if(!H(r).includes("format"))return{applicable:!1,warnings:[]};let i=r.devDependencies?.oxfmt??r.dependencies?.oxfmt,s=n.join(e,Q[0].path),a=n.join(e,Q[1].path),f=n.join(e,Q[2].path),{hasConfig:l,hasLegacyJson:p,hasLegacyJsonc:u}=yield*oe.all({hasConfig:t.exists(s),hasLegacyJson:t.exists(a),hasLegacyJsonc:t.exists(f)},{concurrency:"unbounded"}),E=l?"ts":u?"jsonc":p?"json":null,j=[],N=[];if(l&&(p||u))N.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(!l&&p&&u)N.push("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(!i)j.push({description:`Install \`oxfmt@${"0.62.0"}\` for the managed \`format\` script.`,package:"oxfmt",targetVersion:"0.62.0",type:"install_package"});else if(Y(i)!=="0.62.0")j.push({currentVersion:i,description:`Update \`oxfmt\` from \`${i}\` to \`${"0.62.0"}\`.`,package:"oxfmt",targetVersion:"0.62.0",type:"update_package"});if(E===null)j.push({description:`Create \`${Q[0].path}\` for \`oxfmt\`.`,path:Q[0].path,type:"create_config"});if(E==="json"||E==="jsonc")j.push({description:`Migrate legacy \`${E==="json"?Q[1].path:Q[2].path}\` to \`${Q[0].path}\`.`,migrationId:"legacy-oxfmt-json",type:"run_migration"});return{actions:j,applicable:!0,warnings:N}}),config:Q[0].path,create:(e)=>oe.gen(function*(){let t=yield*lt.FileSystem,r=(yield*pt.Path).join(e,Q[0].path);yield*t.writeFileString(r,ft()).pipe(oe.mapError((o)=>new S({cause:o,path:r})))}),detect:(e)=>oe.gen(function*(){let t=yield*lt.FileSystem,n=yield*pt.Path,r=n.join(e,Q[0].path),o=n.join(e,Q[1].path),i=n.join(e,Q[2].path),{hasJson:s,hasJsonc:a,hasTs:f}=yield*oe.all({hasJson:t.exists(o),hasJsonc:t.exists(i),hasTs:t.exists(r)},{concurrency:"unbounded"}),l=f?"ts":a?"jsonc":s?"json":null,p=[];if(f&&s)p.push({format:"json",path:o});if(f&&a)p.push({format:"jsonc",path:i});if(!f&&s&&a)p.push({format:"json",path:o});return{active:l===null?null:{format:l,path:l==="ts"?r:l==="jsonc"?i:o},legacy:p}}),files:Q,kind:"tooling",name:"oxfmt",version:"0.62.0"});import*as vn from"effect/Effect";var L=I({assess:(e)=>vn.gen(function*(){let t=yield*v(e),n=H(t);if(!n.includes("check:monorepo")&&!n.includes("fix:monorepo"))return{applicable:!1,warnings:[]};let r=t.devDependencies?.sherif??t.dependencies?.sherif,o=[];if(!r)o.push({description:`Install \`sherif@${"1.13.0"}\` for the managed monorepo scripts.`,package:"sherif",targetVersion:"1.13.0",type:"install_package"});else if(Y(r)!=="1.13.0")o.push({currentVersion:r,description:`Update \`sherif\` from \`${r}\` to \`${"1.13.0"}\`.`,package:"sherif",targetVersion:"1.13.0",type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"sherif",version:"1.13.0"});import*as Rn from"effect/Effect";var le=I({assess:(e)=>Rn.gen(function*(){let t=yield*v(e),n=H(t);if(!n.includes("check")&&!n.includes("fix"))return{applicable:!1,warnings:[]};let r=t.devDependencies?.["oxlint-tsgolint"]??t.dependencies?.["oxlint-tsgolint"],o=[];if(!r)o.push({description:`Install \`oxlint-tsgolint@${"7.0.2001"}\` for the managed lint scripts.`,package:"oxlint-tsgolint",targetVersion:"7.0.2001",type:"install_package"});else if(Y(r)!=="7.0.2001")o.push({currentVersion:r,description:`Update \`oxlint-tsgolint\` from \`${r}\` to \`${"7.0.2001"}\`.`,package:"oxlint-tsgolint",targetVersion:"7.0.2001",type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"oxlint-tsgolint",version:"7.0.2001"});import*as W from"effect/Effect";import*as Dn from"effect/FileSystem";import*as Vn from"effect/Path";function pe(e){return e}function Le(e,t,n){return W.gen(function*(){let r=yield*Dn.FileSystem,o=yield*Vn.Path,i=e.files??[],s=new Map;for(let a of i){let f=o.join(t.cwd,a);if(yield*r.exists(f)){let p=yield*r.readFileString(f);s.set(f,p)}else s.set(f,null)}yield*e.migrate(t).pipe(W.andThen(()=>e.validate?.(t)??W.void),W.onError(()=>W.gen(function*(){if(n?.onRestore)yield*n.onRestore;for(let[a,f]of s){if(f!==null){yield*r.writeFileString(a,f).pipe(W.ignore);continue}if(!(yield*r.exists(a).pipe(W.orElseSucceed(()=>!1))))continue;yield*r.remove(a).pipe(W.ignore)}})))})}import*as C from"effect/Effect";import*as Tn from"effect/FileSystem";import*as _n from"effect/Path";import*as bn from"effect/Predicate";import*as D from"@clack/prompts";import*as Pn from"effect/Context";import*as V from"effect/Effect";import*as In from"effect/Exit";import*as Nn from"effect/Layer";class O extends Pn.Service()("Prompter"){static layer=Nn.succeed(this)({cancel:(e)=>V.sync(()=>{D.cancel(e)}),confirm:(e)=>V.promise(()=>D.confirm(e)).pipe(V.filterOrFail((t)=>!D.isCancel(t),()=>new nt({}))),intro:(e)=>V.sync(()=>{D.intro(e)}),log:{error:(e)=>V.sync(()=>{D.log.error(e)}),info:(e)=>V.sync(()=>{D.log.info(e)}),success:(e)=>V.sync(()=>{D.log.success(e)}),warning:(e)=>V.sync(()=>{D.log.warning(e)})},multiselect:(e)=>V.promise(()=>D.multiselect(e)).pipe(V.filterOrFail((t)=>!D.isCancel(t),()=>new nt({}))),outro:(e)=>V.sync(()=>{D.outro(e)}),withSpinner:(e,t)=>V.acquireUseRelease(V.sync(()=>{let n=D.spinner();return n.start(t.start),n}),(n)=>e({message:(r)=>V.sync(()=>{n.message(r)})}),(n,r)=>V.sync(()=>{n.stop(In.match(r,{onFailure:()=>t.failure,onSuccess:(o)=>typeof t.success==="function"?t.success(o):t.success}))}))})}function qn(){return[m.files[1].path,m.files[2].path]}function ho(e){let t=qn();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${m.config}\`.`}function Eo(e){return C.gen(function*(){let t=yield*Tn.FileSystem,n=yield*_n.Path,r=yield*m.detect(e);if(r.active?.format!=="json"&&r.active?.format!=="jsonc")return;let o=r.active.path,i=n.join(e,m.config),s=yield*t.readFileString(o).pipe(C.mapError((u)=>new R({cause:u,path:o}))),a=yield*A(s,o);if(!bn.isObject(a))return yield*new Z({path:o});let{$schema:f,...l}=a;yield*t.writeFileString(i,rt(l)).pipe(C.mapError((u)=>new S({cause:u,path:i}))),yield*t.remove(o).pipe(C.mapError((u)=>new ne({cause:u,path:o})));let p=r.legacy[0]?.path??null;if(p&&p!==o)yield*t.remove(p).pipe(C.mapError((u)=>new ne({cause:u,path:p})))})}var Ht=pe({check:(e)=>C.gen(function*(){let t=yield*m.detect(e.cwd),n=[];if(t.active?.format==="ts"&&t.legacy.length>0)n.push("Found both `knip.config.ts` and `knip.json(c)`. Adamantite will use `knip.config.ts`.");if(t.active&&t.active.format!=="ts"&&t.legacy.length>0)n.push("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(t.active?.format==="json"||t.active?.format==="jsonc")return{applicable:!0,summary:ho(t.active.format),warnings:n};if(t.active?.format==="ts")return{applicable:!0,warnings:n};return{applicable:!1,warnings:n}}),files:[m.config,...qn()],id:"legacy-knip-json",migrate:(e)=>C.gen(function*(){let t=yield*O,r=(yield*m.detect(e.cwd)).active?.path.endsWith(m.files[2].path)?m.files[2].path:m.files[1].path;yield*t.withSpinner(()=>Eo(e.cwd),{failure:`Failed to migrate ${r}.`,start:`Migrating \`${r}\` to \`${m.config}\`...`,success:`Knip config migrated to \`${m.config}\` successfully.`})}),tags:["update"],title:"Legacy Knip JSON config",validate:(e)=>C.gen(function*(){if((yield*m.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-knip-json",reason:`\`${m.config}\` is not the active Knip config.`})})});import*as ee from"effect/Effect";import*as zn from"effect/FileSystem";import*as Jn from"effect/Path";import*as Un from"effect/Predicate";function An(){return[h.files[1].path,h.files[2].path]}function go(e){let t=An();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${h.config}\`.`}function Oo(e){return ee.gen(function*(){let t=yield*zn.FileSystem,n=yield*Jn.Path,r=yield*h.detect(e);if(r.active?.format!=="json"&&r.active?.format!=="jsonc")return;let o=r.active.path,i=n.join(e,h.config),s=yield*t.readFileString(o).pipe(ee.mapError((u)=>new R({cause:u,path:o}))),a=yield*A(s,o);if(!Un.isObject(a))return yield*new Z({path:o});let{$schema:f,...l}=a;yield*t.writeFileString(i,ft(l)).pipe(ee.mapError((u)=>new S({cause:u,path:i}))),yield*t.remove(o).pipe(ee.mapError((u)=>new ne({cause:u,path:o})));let p=r.legacy[0]?.path??null;if(p&&p!==o)yield*t.remove(p).pipe(ee.mapError((u)=>new ne({cause:u,path:p})))})}var Kt=pe({check:(e)=>ee.gen(function*(){let t=yield*h.detect(e.cwd),n=[];if(t.active?.format==="ts"&&t.legacy.length>0)n.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(t.active&&t.active.format!=="ts"&&t.legacy.length>0)n.push("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(t.active?.format==="json"||t.active?.format==="jsonc")return{applicable:!0,summary:go(t.active.format),warnings:n};if(t.active?.format==="ts")return{applicable:!0,warnings:n};return{applicable:!1,warnings:n}}),files:[h.config,...An()],id:"legacy-oxfmt-json",migrate:(e)=>ee.gen(function*(){let t=yield*O,r=(yield*h.detect(e.cwd)).active?.path.endsWith(h.files[2].path)?h.files[2].path:h.files[1].path;yield*t.withSpinner(()=>Oo(e.cwd),{failure:`Failed to migrate ${r}.`,start:`Migrating \`${r}\` to \`${h.config}\`...`,success:`Oxfmt config migrated to \`${h.config}\` successfully.`})}),tags:["update"],title:"Legacy oxfmt JSON config",validate:(e)=>ee.gen(function*(){if((yield*h.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-oxfmt-json",reason:`\`${h.config}\` is not the active oxfmt config.`})})});import*as ie from"effect/Effect";import*as kn from"effect/FileSystem";import*as Bn from"effect/Path";import*as Qn from"effect/Predicate";function So(e){return ie.gen(function*(){let t=yield*kn.FileSystem,n=yield*Bn.Path,r=yield*y.detect(e);if(r.active?.format!=="json")return;let o=r.active.path,i=n.join(e,y.config),s=yield*t.readFileString(o).pipe(ie.mapError((P)=>new R({cause:P,path:o}))),a=yield*A(s,o);if(!Qn.isObject(a))return yield*new Z({path:o});let{$schema:f,...l}=a,p=Array.isArray(l.extends)?l.extends.filter((P)=>typeof P==="string"):typeof l.extends==="string"?[l.extends]:[],u=new Set(st()),E=new Set;for(let P of p){let te=P.match(/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/),c=P.match(/^adamantite\/lint(?:\/([a-z0-9-]+))?$/),b=te?.[1]??(c?c[1]??"core":null);if(b)u.add(b);else E.add(P)}let{extends:j,...N}=l;yield*t.writeFileString(i,at(N,[...u],[...E])).pipe(ie.mapError((P)=>new S({cause:P,path:i}))),yield*t.remove(o).pipe(ie.mapError((P)=>new ne({cause:P,path:o})))})}var xt=pe({id:"legacy-oxlint-json",files:[y.config,y.files[1].path],tags:["update"],title:"Legacy oxlint JSON config",check:(e)=>ie.gen(function*(){let t=yield*y.detect(e.cwd),n=t.active?.format==="ts"&&t.legacy.length>0?[`Found both \`${y.config}\` and \`${y.files[1].path}\`. Adamantite will use \`${y.config}\`.`]:[];if(t.active?.format==="json")return{applicable:!0,summary:`Migrating legacy \`${y.files[1].path}\` configuration to \`${y.config}\`.`,warnings:n};if(t.active?.format==="ts")return{applicable:!0,warnings:n};return{applicable:!1,warnings:n}}),migrate:(e)=>ie.gen(function*(){yield*(yield*O).withSpinner(()=>So(e.cwd),{failure:`Failed to migrate ${y.files[1].path}.`,start:`Migrating \`${y.files[1].path}\` to \`${y.config}\`...`,success:`Oxlint config migrated to \`${y.config}\` successfully.`})}),validate:(e)=>ie.gen(function*(){if((yield*y.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-oxlint-json",reason:`\`${y.config}\` is not the active oxlint config.`})})});import*as je from"effect/Effect";import*as Oe from"effect/Effect";import*as yt from"effect/FileSystem";import*as mt from"effect/Path";import*as ut from"effect/Effect";import*as Wn from"effect/FileSystem";var Zn=(e)=>ut.gen(function*(){yield*(yield*Wn.FileSystem).makeDirectory(e,{recursive:!0}).pipe(ut.mapError((n)=>new ge({cause:n,path:e})))});import{runScriptCommand as jo}from"nypm";var Xn=[{name:"check",script:"check"},{args:["--check"],name:"format",script:"format"},{name:"monorepo",script:"check:monorepo"},{name:"analyze",script:"analyze"}];function Yn(e,t){let n=[];for(let r of Xn){if(!t.includes(r.script))continue;n.push({command:jo(e,r.script,{args:r.args}),name:r.name})}return n}function Me(e){return Xn.some((t)=>e.includes(t.script))}var $o={bun:` - name: Setup Node.js
|
|
5
|
+
${t}`)}var ir=(r,e)=>N.try({catch:(t)=>new Re({cause:t}),try:()=>Tn(r,e)});var Xn=/^workspace:/,Nn=/^[\^~]/;function Ar(r){return r.trim().replace(Xn,"").replace(Nn,"")}var b=(r=_n.cwd())=>jr.gen(function*(){let e=yield*Ze.FileSystem,n=(yield*Ke.Path).join(r,"package.json"),f=yield*e.readFileString(n).pipe(jr.mapError((l)=>new R({cause:l,path:n})));return yield*H(f,n)}),Gr=(r,e)=>jr.gen(function*(){let t=yield*Ze.FileSystem,f=(yield*Ke.Path).join(r,"package.json");yield*t.writeFileString(f,`${JSON.stringify(e,null,2)}
|
|
6
|
+
`).pipe(jr.mapError((u)=>new S({cause:u,path:f})))});function Xr(r){return r==="bun"||r==="deno"||r==="npm"||r==="pnpm"||r==="yarn"}var ur={analyze:"adamantite analyze",check:"adamantite check","check:monorepo":"adamantite monorepo",fix:"adamantite fix","fix:monorepo":"adamantite monorepo --fix",format:"adamantite format"};function or(r){let e=r.scripts??{},t=[];for(let[n,f]of Object.entries(ur))if(e[n]===f)t.push(n);return t}function Nr(r){if(r.endsWith(".jsonc"))return"jsonc";if(r.endsWith(".json"))return"json";return"ts"}function Hn(r){let e=r.legacyConfigs.find((n)=>Nr(n)==="json"),t=r.legacyConfigs.find((n)=>Nr(n)==="jsonc");if(e&&t)return`${e}(c)`;return t??e??""}function Ln(r,e,t,n){if(t===null||n.length===0)return[];if(t.format==="ts")return[`Found both \`${e.config}\` and \`${Hn(e)}\`. Adamantite will use \`${e.config}\`.`];let f=e.legacyConfigs.find((l)=>Nr(l)==="json"),u=e.legacyConfigs.find((l)=>Nr(l)==="jsonc");if(!f||!u)return[];return[`Found both \`${f}\` and \`${u}\`. Multiple legacy ${r} configs exist; Adamantite will treat \`${u}\` as the source of truth when migration is needed.`]}var Te=L.fn("detectToolingConfig")(function*(r,e,t){let n=yield*Pe.FileSystem,f=yield*Fe.Path,u=[t.config,...t.legacyConfigs].map((m)=>({file:m,format:Nr(m),path:f.join(r,m)})),l=yield*L.forEach(u,(m)=>n.exists(m.path),{concurrency:"unbounded"}),a=u.filter((m,h)=>l[h]),y=a.find((m)=>m.format==="ts")??a.find((m)=>m.format==="jsonc")??a.find((m)=>m.format==="json")??null,O=a.filter((m)=>m!==y&&m.format!=="ts");return{active:y,legacy:O,warnings:Ln(e,t,y,O)}});function Mr(r,e,t){let n=r.devDependencies?.[e.name]??r.dependencies?.[e.name];if(!n)return[{description:`Install \`${e.name}@${e.version}\` for ${t}.`,package:e.name,targetVersion:e.version,type:"install_package"}];if(Ar(n)!==e.version)return[{currentVersion:n,description:`Update \`${e.name}\` from \`${n}\` to \`${e.version}\`.`,package:e.name,targetVersion:e.version,type:"update_package"}];return[]}function Ye(r,e){if(r.active===null)return[{description:`Create \`${e.configFile}\` for \`${e.toolName}\`.`,path:e.configFile,type:"create_config"}];if(r.active.format!=="ts")return[{description:`Migrate legacy \`${r.active.file}\` to \`${e.configFile}\`.`,migrationId:e.migrationId,type:"run_migration"}];return[]}function pe(r,e){let t=or(r);return e.some((n)=>t.includes(n))}function gr(r){return T({assess:(e)=>L.gen(function*(){let t=yield*b(e);if(!pe(t,r.scripts))return{applicable:!1,warnings:[]};return{actions:Mr(t,r,r.purpose),applicable:!0,warnings:[]}}),kind:"tooling",name:r.name,version:r.version})}function wr(r){let e=[{path:r.configFiles.config,type:"config"},...r.configFiles.legacyConfigs.map((n)=>({path:n,type:"legacy_config"}))],t=(n)=>Te(n,r.name,r.configFiles);return T({assess:(n)=>L.gen(function*(){let f=yield*b(n);if(!pe(f,r.scripts))return{applicable:!1,warnings:[]};let u=yield*t(n);return{actions:[...Mr(f,r,r.purpose),...Ye(u,{configFile:r.configFiles.config,migrationId:r.migrationId,toolName:r.name})],applicable:!0,warnings:u.warnings}}),config:r.configFiles.config,create:(n)=>L.gen(function*(){let f=yield*Pe.FileSystem,l=(yield*Fe.Path).join(n,r.configFiles.config);yield*f.writeFileString(l,r.configContent()).pipe(L.mapError((a)=>new S({cause:a,path:l})))}),detect:t,files:e,kind:"tooling",name:r.name,version:r.version})}function Cr(r={}){let e=Object.entries(r).map(([t,n])=>{if(t==="rules"&&typeof n==="object"&&n!==null&&!Array.isArray(n))return[" rules: {"," ...analyze.rules,",...Object.entries(n).map(([u,l])=>` ${u}: ${$r(l,{continuationIndent:" ",indentation:" "})},`)," },"].join(`
|
|
7
|
+
`);return` ${t}: ${$r(n)},`});if(e.length===0)return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = analyze","","export default config",""].join(`
|
|
8
|
+
`);return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = {"," ...analyze,",...e,"}","","export default config",""].join(`
|
|
9
|
+
`)}var Z=wr({configContent:()=>Cr(),configFiles:{config:"knip.config.ts",legacyConfigs:["knip.json","knip.jsonc"]},migrationId:"legacy-knip-json",name:"knip",purpose:"the managed `analyze` script",scripts:["analyze"],version:"6.32.2"});import*as ce from"effect/Context";import*as Sr from"effect/Effect";import*as ke from"effect/Layer";import*as rt from"effect/unstable/process/ChildProcess";class s extends ce.Service()("CommandRunner"){static layer=ke.succeed(this)({run:({args:r,command:e,cwd:t,stderr:n="inherit",stdin:f="ignore",stdout:u="inherit"})=>Sr.mapError(Sr.scoped(Sr.gen(function*(){return yield*(yield*rt.make(e,r,{cwd:t,stderr:n,stdin:f,stdout:u})).exitCode})),(l)=>l.reason._tag==="NotFound"?new ze({command:e}):l)})}import*as et from"effect/Context";var P=et.Reference("adamantite/ForwardedArguments",{defaultValue:()=>[]});var xn=vr.boolean("fix").pipe(vr.withDescription("Automatically fix issues")),Jn=vr.boolean("strict").pipe(vr.withDescription("Enable strict mode")),_e=w.make("analyze",{fix:xn,strict:Jn}).pipe(w.withDescription("Find unused dependencies, exports, and files using knip"),w.withExamples([{command:"adamantite analyze -- --directory packages/app",description:"Run knip from a specific directory"}]),w.withHandler(({fix:r,strict:e})=>tt.gen(function*(){let t=yield*P,n=yield*s,f=[];if(r)f.push("--fix","--allow-remove-files");if(e)f.push("--production","--strict");f.push(...t);let u=yield*n.run({args:f,command:Z.name});if(u!==nt.ExitCode(0))yield*new Q({command:Z.name,exitCode:u})})));import*as ot from"effect/Effect";import*as Dr from"effect/unstable/cli/Argument";import*as zr from"effect/unstable/cli/Command";import*as St from"effect/unstable/process/ChildProcessSpawner";import*as G from"effect/Effect";import*as kr from"effect/FileSystem";import*as Ne from"effect/Path";import*as q from"effect/Option";import*as mt from"effect/Predicate";import{print as In}from"esrap";import dn from"esrap/languages/ts";import{parseSync as An}from"oxc-parser";var Et=["respectEslintDisableDirectives","typeAware","typeCheck"],ft="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",ut="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",lt="`oxlint.config.ts` has an `options` object Adamantite cannot patch safely. Make sure each required option is a plain `key: true | false` property—avoid spreads (`...rest`), computed keys (`[name]: ...`), duplicate keys, methods/getters/setters, and non-boolean-literal values.";function pr(r=[]){return r.includes("core")?r:["core",...r]}function yt(r){return r.replaceAll(/-([a-z])/g,(e,t)=>t.toUpperCase())}function cr(r,e,t=[]){let{options:n,...f}=r,u=['import { defineConfig } from "oxlint"',...e.map((i)=>`import ${yt(i)} from "${i==="core"?"adamantite/lint":`adamantite/lint/${i}`}"`)],a=[...e.map((i)=>yt(i)),...t.map((i)=>JSON.stringify(i))],y=JSON.stringify(mt.isObject(n)?{...n,respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0}:{respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0},null,2),O=Object.entries(f).map(([i,I])=>[i,JSON.stringify(I,null,2)]),m=`[${a.join(", ")}]`,h=[["options",y],...O,["extends",m]].map(([i,I])=>` ${i}: ${I},`).join(`
|
|
10
|
+
`);return[...u,"","export default defineConfig({",h,"})",""].join(`
|
|
11
|
+
`)}var Gn=q.liftThrowable((r)=>An("oxlint.config.ts",r,{astType:"ts",lang:"ts",sourceType:"module"}));function Mn(r){return Gn(r).pipe(q.flatMap((e)=>e.errors.length===0?q.fromNullishOr(e.program):q.none()))}function ht(r){let{code:e}=In(r,dn({quotes:"double"}));return e.endsWith(`
|
|
12
|
+
`)?e:`${e}
|
|
13
|
+
`}function at(r){if(r.type==="Identifier")return r.name;if(r.type==="Literal"&&typeof r.value==="string")return r.value;return null}function gn(r){let e=r.body.filter((u)=>u.type==="ExportDefaultDeclaration");if(e.length!==1)return q.none();let[t]=e;if(!t)return q.none();let n=t.declaration;if(n.type==="ObjectExpression")return q.fromNullishOr(n);if(n.type!=="CallExpression")return q.none();if(n.callee.type!=="Identifier"||n.callee.name!=="defineConfig")return q.none();if(n.arguments.length!==1)return q.none();let[f]=n.arguments;if(f?.type==="ObjectExpression")return q.fromNullishOr(f);return q.none()}function Ot(r,e){let t=null;for(let n of r.properties){if(n.type==="SpreadElement")return{status:"manual"};if(n.computed)return{status:"manual"};if(n.method||n.kind!=="init"){if(at(n.key)===e)return{status:"manual"};continue}if(at(n.key)!==e)continue;if(t)return{status:"manual"};t=n}if(!t)return{status:"missing"};return{property:t,status:"found"}}function $t(r){return{computed:!1,end:0,key:{end:0,name:r,start:0,type:"Identifier"},kind:"init",method:!1,shorthand:!1,start:0,type:"Property",value:{end:0,raw:"true",start:0,type:"Literal",value:!0}}}function wn(){return{computed:!1,end:0,key:{end:0,name:"options",start:0,type:"Identifier"},kind:"init",method:!1,shorthand:!1,start:0,type:"Property",value:{end:0,properties:Et.map((r)=>$t(r)),start:0,type:"ObjectExpression"}}}function Cn(r,e){let t=[],n=!1;for(let f of Et){let u=Ot(e,f);if(u.status==="manual")return{kind:"manual",reason:lt};if(u.status==="missing"){t.push(f);continue}let l=u.property.value;if(l.type!=="Literal"||typeof l.value!=="boolean")return{kind:"manual",reason:lt};if(l.value)continue;l.raw="true",l.value=!0,n=!0}if(t.length>0)e.properties.unshift(...t.map((f)=>$t(f))),n=!0;if(!n)return{kind:"configured"};return{kind:"patchable",updatedContent:ht(r)}}function Xe(r){let e=Mn(r);if(q.isNone(e))return{kind:"manual",reason:ft};let t=gn(e.value);if(q.isNone(t))return{kind:"manual",reason:ft};let n=Ot(t.value,"options");if(n.status==="manual")return{kind:"manual",reason:ut};if(n.status==="missing")return t.value.properties.unshift(wn()),{kind:"patchable",updatedContent:ht(e.value)};if(n.property.value.type!=="ObjectExpression")return{kind:"manual",reason:ut};return Cn(e.value,n.property.value)}var x="oxlint.config.ts",jt=".oxlintrc.json",pn=[{path:x,type:"config"},{path:jt,type:"legacy_config"}],cn={config:x,legacyConfigs:[jt]};var it=(r)=>Te(r,"oxlint",cn),j=T({assess:(r)=>G.gen(function*(){let e=yield*kr.FileSystem,t=yield*b(r),n=or(t);if(!n.includes("check")&&!n.includes("fix"))return{applicable:!1,warnings:[]};let f=yield*it(r),u=[...Mr(t,{name:"oxlint",version:"1.78.0"},"the managed lint scripts"),...Ye(f,{configFile:x,migrationId:"legacy-oxlint-json",toolName:"oxlint"})],l=f.active;if(l?.format==="ts"){let a=yield*e.readFileString(l.path).pipe(G.mapError((O)=>new R({cause:O,path:l.path}))),y=Xe(a);if(y.kind==="patchable")u.push({description:"Update `oxlint.config.ts` with Adamantite's required options.",path:x,type:"update_config"});if(y.kind==="manual")u.push({description:"Manually update `oxlint.config.ts` with Adamantite's required options; Adamantite cannot patch the current file shape safely.",path:x,type:"manual_fix"})}return{actions:u,applicable:!0,warnings:f.warnings}}),config:x,create:(r,e=[])=>G.gen(function*(){let t=yield*kr.FileSystem,f=(yield*Ne.Path).join(r,x),u=cr({},pr(e));yield*t.writeFileString(f,u).pipe(G.mapError((l)=>new S({cause:l,path:f})))}),detect:it,files:pn,kind:"tooling",name:"oxlint",update:(r)=>G.gen(function*(){let e=yield*kr.FileSystem,n=(yield*Ne.Path).join(r,x);if(!(yield*e.exists(n)))return yield*new Ue({path:x});let f=yield*e.readFileString(n).pipe(G.mapError((l)=>new R({cause:l,path:n}))),u=Xe(f);if(u.kind==="configured")return;if(u.kind==="manual")return yield*new Qe({path:x,reason:u.reason});yield*e.writeFileString(n,u.updatedContent).pipe(G.mapError((l)=>new S({cause:l,path:n})))}),version:"1.78.0"});var kn=Dr.file("files",{mustExist:!0}).pipe(Dr.withDescription("Specific files to lint (optional)"),Dr.variadic()),He=zr.make("check",{files:kn}).pipe(zr.withDescription("Find issues and type errors in code using oxlint"),zr.withHandler(({files:r})=>ot.gen(function*(){let e=yield*P,n=yield*(yield*s).run({args:[...r,...e],command:j.name});if(n!==St.ExitCode(0))yield*new Q({command:j.name,exitCode:n})})));import jf from"node:process";import*as br from"effect/Effect";import*as sr from"effect/unstable/cli/Command";import*as he from"effect/unstable/cli/Flag";import*as xe from"effect/unstable/process/ChildProcessSpawner";import*as vt from"effect/Predicate";var rf=new Set(["sortImports","sortPackageJson","sortTailwindcss"]);function ef(r){let e=r.split(`
|
|
14
|
+
`);if(e.length===1)return r.slice(1,-1).trim();return e.slice(1,-1).map((t)=>` ${t.trimStart()}`).join(`
|
|
15
|
+
`)}function tf(r,e){let t=$r(e),n=ef(t);return[` ${r}: {`,` ...format.${r},`,...n===""?[]:[n]," },"].join(`
|
|
16
|
+
`)}function re(r={}){let e=Object.entries(r).map(([t,n])=>{if(rf.has(t)&&vt.isObject(n))return tf(t,n);let f=$r(n,{continuationIndent:" "});return` ${t}: ${f},`});if(e.length===0)return['import { defineConfig } from "oxfmt"','import format from "adamantite/format"',"","export default defineConfig(format)",""].join(`
|
|
17
|
+
`);return['import { defineConfig } from "oxfmt"','import format from "adamantite/format"',"","export default defineConfig({"," ...format,",...e,"})",""].join(`
|
|
18
|
+
`)}var K=wr({configContent:()=>re(),configFiles:{config:"oxfmt.config.ts",legacyConfigs:[".oxfmtrc.json",".oxfmtrc.jsonc"]},migrationId:"legacy-oxfmt-json",name:"oxfmt",purpose:"the managed `format` script",scripts:["format"],version:"0.63.0"});var _=gr({name:"sherif",purpose:"the managed monorepo scripts",scripts:["check:monorepo","fix:monorepo"],version:"1.13.0"});var C=gr({name:"oxlint-tsgolint",purpose:"the managed lint scripts",scripts:["check","fix"],version:"7.0.2001"});import*as F from"effect/Effect";import*as Dt from"effect/FileSystem";import*as zt from"effect/Path";function ee(r){return r}function te(r,e,t){return F.gen(function*(){let n=yield*Dt.FileSystem,f=yield*zt.Path,u=r.files??[],l=new Map;for(let a of u){let y=f.join(e.cwd,a);if(yield*n.exists(y)){let m=yield*n.readFileString(y);l.set(y,m)}else l.set(y,null)}yield*r.migrate(e).pipe(F.andThen(()=>r.validate?.(e)??F.void),F.onError(()=>F.gen(function*(){if(t?.onRestore)yield*t.onRestore;for(let[a,y]of l){if(y!==null){yield*n.writeFileString(a,y).pipe(F.ignore);continue}if(!(yield*n.exists(a).pipe(F.orElseSucceed(()=>!1))))continue;yield*n.remove(a).pipe(F.ignore)}})))})}import*as M from"effect/Effect";import*as bt from"effect/FileSystem";import*as st from"effect/Path";import*as Ut from"effect/Predicate";import*as z from"@clack/prompts";import*as qt from"effect/Context";import*as B from"effect/Effect";import*as Bt from"effect/Exit";import*as Rt from"effect/Layer";class o extends qt.Service()("Prompter"){static layer=Rt.succeed(this)({cancel:(r)=>B.sync(()=>{z.cancel(r)}),confirm:(r)=>B.promise(()=>z.confirm(r)).pipe(B.filterOrFail((e)=>!z.isCancel(e),()=>new dr({}))),intro:(r)=>B.sync(()=>{z.intro(r)}),log:{error:(r)=>B.sync(()=>{z.log.error(r)}),info:(r)=>B.sync(()=>{z.log.info(r)}),success:(r)=>B.sync(()=>{z.log.success(r)}),warning:(r)=>B.sync(()=>{z.log.warning(r)})},multiselect:(r)=>B.promise(()=>z.multiselect(r)).pipe(B.filterOrFail((e)=>!z.isCancel(e),()=>new dr({}))),outro:(r)=>B.sync(()=>{z.outro(r)}),withSpinner:(r,e)=>B.acquireUseRelease(B.sync(()=>{let t=z.spinner();return t.start(e.start),t}),(t)=>r({message:(n)=>B.sync(()=>{t.message(n)})}),(t,n)=>B.sync(()=>{t.stop(Bt.match(n,{onFailure:()=>e.failure,onSuccess:(f)=>typeof e.success==="function"?e.success(f):e.success}))}))})}function nf(r,e){return M.gen(function*(){let t=yield*bt.FileSystem,n=yield*st.Path,f=yield*e.integration.detect(r);if(f.active===null||f.active.format==="ts")return;let u=f.active.path,l=n.join(r,e.integration.config),a=yield*t.readFileString(u).pipe(M.mapError((h)=>new R({cause:h,path:u}))),y=yield*H(a,u);if(!Ut.isObject(y))return yield*new A({path:u});let{$schema:O,...m}=y;yield*t.writeFileString(l,e.serialize(m)).pipe(M.mapError((h)=>new S({cause:h,path:l})));for(let h of[f.active,...f.legacy])yield*t.remove(h.path).pipe(M.mapError((i)=>new se({cause:i,path:h.path})))})}function qr(r){return ee({check:(e)=>M.gen(function*(){let t=yield*r.integration.detect(e.cwd);if(t.active===null||t.active.format==="ts")return{status:"not-applicable",warnings:t.warnings};return{status:"needed",summary:`Migrating legacy \`${t.active.file}\` configuration to \`${r.integration.config}\`.`,warnings:t.warnings}}),files:r.integration.files.map((e)=>e.path),id:r.id,migrate:(e)=>M.gen(function*(){let t=yield*o,n=yield*r.integration.detect(e.cwd),f=n.active!==null&&n.active.format!=="ts"?n.active.file:r.integration.files[1]?.path??r.integration.config;yield*t.withSpinner(()=>nf(e.cwd,r),{failure:`Failed to migrate ${f}.`,start:`Migrating \`${f}\` to \`${r.integration.config}\`...`,success:`${r.displayName} config migrated to \`${r.integration.config}\` successfully.`})}),tags:["update"],title:r.title,validate:(e)=>M.gen(function*(){if((yield*r.integration.detect(e.cwd)).active?.format!=="ts")return yield*new fr({migrationId:r.id,reason:`\`${r.integration.config}\` is not the active ${r.displayName} config.`})})})}var Qt=qr({displayName:"Knip",id:"legacy-knip-json",integration:Z,serialize:Cr,title:"Legacy Knip JSON config"});var Vt=qr({displayName:"Oxfmt",id:"legacy-oxfmt-json",integration:K,serialize:re,title:"Legacy oxfmt JSON config"});var ff=/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/,uf=/^adamantite\/lint(?:\/([a-z0-9-]+))?$/;function lf(r){let e=Array.isArray(r.extends)?r.extends.filter((l)=>typeof l==="string"):typeof r.extends==="string"?[r.extends]:[],t=new Set(pr()),n=new Set;for(let l of e){let a=l.match(ff),y=l.match(uf),O=a?.[1]??(y?y[1]??"core":null);if(O)t.add(O);else n.add(l)}let{extends:f,...u}=r;return cr(u,[...t],[...n])}var Wt=qr({displayName:"Oxlint",id:"legacy-oxlint-json",integration:j,serialize:lf,title:"Legacy oxlint JSON config"});import*as ar from"effect/Effect";import*as lr from"effect/Effect";import*as ue from"effect/FileSystem";import*as le from"effect/Path";import*as ne from"effect/Effect";import*as Zt from"effect/FileSystem";var Br=(r)=>ne.gen(function*(){yield*(yield*Zt.FileSystem).makeDirectory(r,{recursive:!0}).pipe(ne.mapError((t)=>new qe({cause:t,path:r})))});import{runScriptCommand as yf}from"nypm";var Kt=[{name:"check",script:"check"},{args:["--check"],name:"format",script:"format"},{name:"monorepo",script:"check:monorepo"},{name:"analyze",script:"analyze"}];function Pt(r,e){let t=[];for(let n of Kt){if(!e.includes(n.script))continue;t.push({command:yf(r,n.script,{args:n.args}),name:n.name})}return t}function Hr(r){return Kt.some((e)=>r.includes(e.script))}var af={bun:` - name: Setup Node.js
|
|
21
19
|
uses: actions/setup-node@v7
|
|
22
20
|
with:
|
|
23
21
|
node-version: "24"
|
|
@@ -64,7 +62,7 @@ ${n}`)}var De=(e,t)=>G.try({catch:(n)=>new Tt({cause:n}),try:()=>wr(e,t)});funct
|
|
|
64
62
|
cache: "yarn"
|
|
65
63
|
|
|
66
64
|
- name: Install dependencies
|
|
67
|
-
run: yarn install --frozen-lockfile`};function
|
|
65
|
+
run: yarn install --frozen-lockfile`};function Ft({packageManager:r,scripts:e}){let t=Pt(r,e);if(t.length===0)return null;return`${`name: adamantite
|
|
68
66
|
|
|
69
67
|
on:
|
|
70
68
|
push:
|
|
@@ -89,34 +87,33 @@ jobs:
|
|
|
89
87
|
fail-fast: false
|
|
90
88
|
matrix:
|
|
91
89
|
include:
|
|
92
|
-
${
|
|
93
|
-
command: ${
|
|
90
|
+
${t.map((u)=>` - name: ${u.name}
|
|
91
|
+
command: ${u.command}`).join(`
|
|
94
92
|
`)}
|
|
95
93
|
|
|
96
94
|
steps:
|
|
97
95
|
- name: Checkout
|
|
98
96
|
uses: actions/checkout@v7
|
|
99
97
|
|
|
100
|
-
${
|
|
98
|
+
${af[r]}
|
|
101
99
|
|
|
102
100
|
- name: Run \${{ matrix.name }}
|
|
103
101
|
run: \${{ matrix.command }}`}
|
|
104
|
-
`}var
|
|
105
|
-
`).pipe(
|
|
106
|
-
`).pipe(
|
|
107
|
-
`).reduce((
|
|
108
|
-
`).pipe(
|
|
109
|
-
`).pipe(
|
|
110
|
-
`).pipe(
|
|
111
|
-
`).pipe(
|
|
112
|
-
`);return[
|
|
113
|
-
`)}var
|
|
114
|
-
`)?
|
|
115
|
-
`).pipe(
|
|
116
|
-
|
|
117
|
-
`)?"":
|
|
102
|
+
`}var fe=[{path:".github/workflows/adamantite.yml",type:"ci"}],g=T({create:(r,e)=>lr.gen(function*(){let t=yield*ue.FileSystem,n=yield*le.Path,f=n.join(r,fe[0].path);yield*Br(n.dirname(f));let u=Ft(e);if(!u)return;yield*t.writeFileString(f,u).pipe(lr.mapError((l)=>new S({cause:l,path:f})))}),detect:(r)=>lr.gen(function*(){let e=yield*ue.FileSystem,t=yield*le.Path;return yield*e.exists(t.join(r,fe[0].path))}),files:fe,kind:"ci",name:"github",update:(r,e)=>lr.gen(function*(){let t=yield*ue.FileSystem,f=(yield*le.Path).join(r,fe[0].path),u=Ft(e);if(!u)return;yield*t.writeFileString(f,u).pipe(lr.mapError((l)=>new S({cause:l,path:f})))})});import*as Tt from"effect/Context";import*as yr from"effect/Effect";import*as Yt from"effect/Layer";import{addDevDependency as mf,detectPackageManager as Ef}from"nypm";class Y extends Tt.Service()("DependencyInstaller"){static layer=Yt.succeed(this)({addDevDependencies:(r,e,t)=>yr.tryPromise({catch:(n)=>new Be({cause:n,packages:r}),try:()=>mf(r,{...t,cwd:e})}).pipe(yr.asVoid),detectPackageManager:(r)=>yr.tryPromise({catch:(e)=>new _r({cause:e}),try:()=>Ef(r)}).pipe(yr.map((e)=>e??null))})}import*as p from"effect/Effect";import*as ye from"effect/FileSystem";import*as ae from"effect/Path";import*as Xt from"effect/Predicate";var Lr=[{path:"tsconfig.json",type:"config"}],_t={extends:"adamantite/typescript"},V=T({config:Lr[0].path,create:(r)=>p.gen(function*(){let e=yield*ye.FileSystem,n=(yield*ae.Path).join(r,Lr[0].path),f=JSON.stringify(_t,null,2);yield*e.writeFileString(n,`${f}
|
|
103
|
+
`).pipe(p.mapError((u)=>new S({cause:u,path:n})))}),detect:(r)=>p.gen(function*(){let e=yield*ye.FileSystem,t=yield*ae.Path;return yield*e.exists(t.join(r,Lr[0].path))}),files:Lr,kind:"workspace",name:"tsconfig",update:(r)=>p.gen(function*(){let e=yield*ye.FileSystem,n=(yield*ae.Path).join(r,Lr[0].path),f=yield*e.readFileString(n).pipe(p.mapError((a)=>new R({cause:a,path:n}))),u=yield*H(f,n);if(!Xt.isObject(u))return yield*new A({path:n});let l=yield*ir(_t,u);yield*e.writeFileString(n,`${JSON.stringify(l,null,2)}
|
|
104
|
+
`).pipe(p.mapError((a)=>new S({cause:a,path:n})))})});var Ht="adamantite typecheck";function hf(){return j.files[1].path}function Of(){return g.files[0].path}function Nt(r){let e={...r.scripts};if(e.typecheck!==Ht)return{migrated:!1,packageJson:r};return delete e.typecheck,e.check??=ur.check,{migrated:!0,packageJson:{...r,scripts:e}}}var Lt=ee({check:(r)=>ar.gen(function*(){let e=yield*b(r.cwd),{migrated:t}=Nt(e);if(!t)return{status:"not-applicable",warnings:[]};return{status:"needed",summary:"Migrating `typecheck` to `check` so oxlint handles linting and type diagnostics together.",warnings:[]}}),files:["package.json",j.config,hf(),V.config,Of()],id:"legacy-typecheck-script",migrate:(r)=>ar.gen(function*(){let e=yield*o,t=yield*Y,n=ar.gen(function*(){let f=yield*b(r.cwd),u=Nt(f);if(!u.migrated)return"noop";yield*Gr(r.cwd,u.packageJson);let l=yield*j.detect(r.cwd);if(l.active===null)yield*j.create(r.cwd);else if(l.active.format==="ts")yield*j.update(r.cwd);yield*(yield*V.detect(r.cwd))?V.update(r.cwd):V.create(r.cwd);let y=yield*g.detect(r.cwd),O=or(u.packageJson);if(y&&Hr(O)){let m=yield*t.detectPackageManager(r.cwd);if(m&&Xr(m.name)){let h=m.name;yield*e.withSpinner(()=>g.update(r.cwd,{packageManager:h,scripts:O}),{failure:"Failed to update GitHub Actions workflow.",start:"Updating GitHub Actions workflow...",success:"GitHub Actions workflow updated successfully"})}else if(m)yield*e.log.warning(`\`${m.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow was not updated.`);else yield*e.log.warning("Could not detect a package manager, so the GitHub Actions workflow was not updated.")}return"migrated"});yield*e.withSpinner(()=>n,{failure:"Legacy `typecheck` script migration failed.",start:"Migrating `typecheck` script to unified `check` command...",success:(f)=>f==="noop"?"No migration needed.":"Legacy `typecheck` script migrated to `check` successfully."}).pipe(ar.asVoid)}),tags:["update"],title:"Legacy typecheck script",validate:(r)=>ar.gen(function*(){if((yield*b(r.cwd)).scripts?.typecheck===Ht)return yield*new fr({migrationId:"legacy-typecheck-script",reason:"The legacy `typecheck` script is still present in `package.json`."});if((yield*j.detect(r.cwd)).active?.format!=="ts")return yield*new fr({migrationId:"legacy-typecheck-script",reason:`\`${j.config}\` is not the active oxlint config.`});if(!(yield*V.detect(r.cwd)))return yield*new fr({migrationId:"legacy-typecheck-script",reason:`\`${V.config}\` is missing after the migration.`})})});var Le=[Vt,Qt,Wt,Lt],xt=Object.fromEntries(Le.map((r)=>[r.id,r]));import*as Jt from"effect/Array";import*as mr from"effect/Effect";import*as me from"effect/Option";var $f=mr.fn("collectApplicableAssessments")((r,e)=>mr.forEach((t)=>t.assess(e).pipe(mr.map((n)=>n.applicable?me.some({assessment:n,integration:t}):me.none())))(r).pipe(mr.map((t)=>Jt.getSomes(t))));function Ee(r,e){return $f(r,e)}import*as It from"effect/Console";import*as dt from"effect/Effect";import*as At from"effect/Terminal";var Rr=()=>dt.gen(function*(){let e=yield*(yield*At.Terminal).columns,t=' .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(`
|
|
105
|
+
`).reduce((n,f)=>Math.max(n,f.trim().length),0);if(!e||e<t)return;yield*It.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 ')});var of=he.boolean("fix").pipe(he.withDescription("Automatically fix safe package install/update issues")),Sf=[Z,K,j,_,C],Gt=sr.make("doctor",{fix:of}).pipe(sr.withDescription("Check Adamantite-managed integrations in the current project"),sr.withHandler(({fix:r})=>br.gen(function*(){let e=jf.cwd(),t=yield*o;yield*Rr(),yield*t.intro("\uD83D\uDCA0 adamantite doctor");let n=yield*b(e);if(!n.devDependencies?.adamantite&&!n.dependencies?.adamantite)yield*t.log.warning("`adamantite` is not installed in this project. Install it before running `adamantite doctor`."),yield*t.outro("⚠️ Doctor found issues."),yield*new Q({command:"doctor",exitCode:xe.ExitCode(1)});let f=yield*Ee(Sf,e);for(let{assessment:y}of f)for(let O of y.warnings)yield*t.log.warning(O);if(f.length===0){yield*t.log.success("No applicable integrations found."),yield*t.outro("✅ Doctor completed successfully!");return}let u=f.flatMap(({assessment:y,integration:O})=>y.actions.map((m)=>({action:m,integration:O})));if(u.length===0){yield*t.log.success("No issues found."),yield*t.outro("✅ Doctor completed successfully!");return}let l=new Set;if(r)yield*br.gen(function*(){let y=u.filter(({action:O})=>O.type==="install_package"||O.type==="update_package");if(y.length>0){let O=yield*Y,m=[];for(let{action:h}of y)if(h.type==="install_package"||h.type==="update_package")m.push(`${h.package}@${h.targetVersion}`);yield*O.addDevDependencies(m,e,{silent:!0});for(let h of y){let{action:i}=h;if(i.type==="install_package")yield*t.log.success(`Fixed: installed \`${i.package}@${i.targetVersion}\`.`);if(i.type==="update_package")yield*t.log.success(`Fixed: updated \`${i.package}\` from \`${i.currentVersion}\` to \`${i.targetVersion}\`.`);l.add(h)}}for(let O of u){let{action:m,integration:h}=O;if(m.type!=="create_config"||!("create"in h))continue;yield*h.create(e),yield*t.log.success(`Fixed: created \`${m.path}\`.`),l.add(O)}for(let O of u){let{action:m,integration:h}=O;if(m.type!=="update_config"||!("update"in h))continue;yield*h.update(e),yield*t.log.success(`Fixed: updated \`${m.path}\`.`),l.add(O)}for(let O of u){let{action:m}=O;if(m.type!=="run_migration")continue;let h=xt[m.migrationId];if(!h)continue;yield*te(h,{cwd:e}),l.add(O)}}).pipe(br.tapError(()=>br.gen(function*(){yield*t.outro("❌ Doctor failed")})));let a=u.filter((y)=>!l.has(y));if(r&&a.length===0){yield*t.outro("✅ Doctor completed successfully!");return}for(let{action:y}of r?a:u)yield*t.log.warning(`Needs attention: ${y.description}`);yield*t.outro("⚠️ Doctor found issues."),yield*new Q({command:"doctor",exitCode:xe.ExitCode(1)})})));import*as Mt from"effect/Array";import*as gt from"effect/Effect";import*as Ur from"effect/unstable/cli/Argument";import*as Qr from"effect/unstable/cli/Command";import*as c from"effect/unstable/cli/Flag";import*as wt from"effect/unstable/process/ChildProcessSpawner";var vf=Ur.file("files",{mustExist:!0}).pipe(Ur.withDescription("Specific files to fix (optional)"),Ur.variadic()),Df=c.boolean("suggested").pipe(c.withDescription("Apply suggested fixes")),zf=c.boolean("dangerous").pipe(c.withDescription("Apply dangerous fixes")),qf=c.boolean("all").pipe(c.withDescription("Apply all fixes, including suggested and dangerous fixes")),Je=Qr.make("fix",{all:qf,dangerous:zf,files:vf,suggested:Df}).pipe(Qr.withDescription("Fix issues in code using oxlint"),Qr.withHandler(({all:r,dangerous:e,files:t,suggested:n})=>gt.gen(function*(){let f=yield*P,u=yield*s,l=Mt.dedupe(["--fix",...n||r?["--fix-suggestions"]:[],...e||r?["--fix-dangerously"]:[],...t]),a=yield*u.run({args:[...l,...f],command:j.name});if(a!==wt.ExitCode(0))yield*new Q({command:j.name,exitCode:a})})));import*as Ct from"effect/Effect";import*as Vr from"effect/unstable/cli/Argument";import*as Wr from"effect/unstable/cli/Command";import*as Oe from"effect/unstable/cli/Flag";import*as pt from"effect/unstable/process/ChildProcessSpawner";var Bf=Vr.file("files",{mustExist:!0}).pipe(Vr.withDescription("Specific files to format (optional)"),Vr.variadic()),Rf=Oe.boolean("check").pipe(Oe.withDescription("Check if files are formatted without writing")),Ie=Wr.make("format",{check:Rf,files:Bf}).pipe(Wr.withDescription("Format files using oxfmt"),Wr.withHandler(({check:r,files:e})=>Ct.gen(function*(){let t=yield*P,n=yield*s,f=[];if(r)f.push("--check");f.push(...e,...t);let u=yield*n.run({args:f,command:K.name});if(u!==pt.ExitCode(0))yield*new Q({command:K.name,exitCode:u})})));import Zf from"node:process";import*as Zr from"effect/Array";import*as $ from"effect/Effect";import*as $n from"effect/Predicate";import*as er from"effect/unstable/cli/Command";import*as v from"effect/unstable/cli/Flag";import*as J from"effect/Effect";import*as $e from"effect/FileSystem";import*as ie from"effect/Path";import*as kt from"effect/Predicate";import*as rn from"effect/unstable/process/ChildProcessSpawner";var xr=[{path:".vscode/settings.json",type:"config"}],ct={"[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},k=T({config:xr[0].path,create:(r)=>J.gen(function*(){let e=yield*$e.FileSystem,t=yield*ie.Path,n=t.join(r,xr[0].path);yield*Br(t.dirname(n)),yield*e.writeFileString(n,`${JSON.stringify(ct,null,2)}
|
|
106
|
+
`).pipe(J.mapError((f)=>new S({cause:f,path:n})))}),detect:(r)=>J.gen(function*(){let e=yield*$e.FileSystem,t=yield*ie.Path;return yield*e.exists(t.join(r,xr[0].path))}),extension:(r=[])=>J.gen(function*(){let e=[];if(r.includes("check")||r.includes("fix")||r.includes("format"))e.push("oxc.oxc-vscode");if(r.includes("analyze"))e.push("webpro.vscode-knip");for(let t of e){let f=yield*(yield*s).run({args:["--install-extension",t],command:"code"}).pipe(J.mapError((u)=>u._tag==="CliNotFound"&&u.command==="code"?new We({cause:u}):new Ir({cause:u,extension:t})));if(f!==rn.ExitCode(0))return yield*new Ir({cause:f,extension:t})}}),files:xr,kind:"editor",name:"vscode",update:(r)=>J.gen(function*(){let e=yield*$e.FileSystem,n=(yield*ie.Path).join(r,xr[0].path),f=yield*e.readFileString(n).pipe(J.mapError((a)=>new R({cause:a,path:n}))),u=yield*H(f,n);if(!kt.isObject(u))return yield*new A({path:n});let l=yield*ir(ct,u);yield*e.writeFileString(n,`${JSON.stringify(l,null,2)}
|
|
107
|
+
`).pipe(J.mapError((a)=>new S({cause:a,path:n})))})});import*as en from"effect/Array";import*as rr from"effect/Effect";import*as je from"effect/FileSystem";import*as oe from"effect/Path";import*as tn from"effect/Predicate";import*as W from"effect/Schema";var Jr=[{path:".zed/settings.json",type:"config"}],de={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"}}}}};function bf(r){let e=r.languages;if(!W.is(W.Record(W.String,W.Json))(e))return r;let t=Object.fromEntries(Object.entries(e).map(([n,f])=>{if(n in de.languages&&W.is(W.Record(W.String,W.Json))(f)&&W.is(W.Array(W.Json))(f.formatter))return[n,Object.fromEntries([...Object.entries(f),["formatter",en.dedupe(f.formatter)]])];return[n,f]}));return{...r,languages:t}}var Er=T({config:Jr[0].path,create:(r)=>rr.gen(function*(){let e=yield*je.FileSystem,t=yield*oe.Path,n=t.join(r,Jr[0].path);yield*Br(t.dirname(n)),yield*e.writeFileString(n,`${JSON.stringify(de,null,2)}
|
|
108
|
+
`).pipe(rr.mapError((f)=>new S({cause:f,path:n})))}),detect:(r)=>rr.gen(function*(){let e=yield*je.FileSystem,t=yield*oe.Path;return yield*e.exists(t.join(r,Jr[0].path))}),files:Jr,kind:"editor",name:"zed",update:(r)=>rr.gen(function*(){let e=yield*je.FileSystem,n=(yield*oe.Path).join(r,Jr[0].path),f=yield*e.readFileString(n).pipe(rr.mapError((y)=>new R({cause:y,path:n}))),u=yield*H(f,n);if(!tn.isObject(u))return yield*new A({path:n});let l=yield*ir(de,u),a=bf(l);yield*e.writeFileString(n,`${JSON.stringify(a,null,2)}
|
|
109
|
+
`).pipe(rr.mapError((y)=>new S({cause:y,path:n})))})});import*as hr from"effect/Effect";import*as nn from"effect/FileSystem";import*as fn from"effect/Path";import{runScriptCommand as sf}from"nypm";var Uf="AGENTS.md",un="<!-- ADAMANTITE:START -->",Ae="<!-- ADAMANTITE:END -->";function Qf(r,e){let t=sf(r,e),n=ur[e];switch(e){case"analyze":return`- Run \`${t}\` after changing dependencies, imports, or exports. Direct command: \`${n}\`.`;case"check":return`- Run \`${t}\` to catch lint and type issues. Direct command: \`${n}\`.`;case"check:monorepo":return`- Run \`${t}\` to check monorepo package consistency. Direct command: \`${n}\`.`;case"fix":return`- Run \`${t}\` to apply safe lint fixes. Direct command: \`${n}\`.`;case"fix:monorepo":return`- Run \`${t}\` to fix monorepo package consistency. Direct command: \`${n}\`.`;case"format":return`- Run \`${t}\` after editing files. Direct command: \`${n}\`.`}}function Vf({packageManager:r,scripts:e}){let n=["format","check","fix","analyze","check:monorepo","fix:monorepo"].filter((u)=>e.includes(u)).map((u)=>Qf(r,u)),f=["## Adamantite","","This project uses Adamantite for its managed formatting, linting, type checking, and dependency-analysis setup.","",...n.length>0?["- Prefer the package scripts Adamantite added for this workspace.",...n]:[],"- Use `adamantite doctor` to inspect managed setup and `adamantite doctor --fix` for safe local fixes."].join(`
|
|
110
|
+
`);return[un,"",f,"",Ae,""].join(`
|
|
111
|
+
`)}var ln=(r,e)=>hr.gen(function*(){let t=yield*nn.FileSystem,f=(yield*fn.Path).join(r,Uf),l=(yield*t.exists(f).pipe(hr.mapError((h)=>new R({cause:h,path:f}))))?yield*t.readFileString(f).pipe(hr.mapError((h)=>new R({cause:h,path:f}))):"",a=l.indexOf(un),y=l.indexOf(Ae),O=Vf(e);if(a!==-1&&y!==-1&&a<y){let h=y+Ae.length,i=`${l.slice(0,a)}${O.trimEnd()}${l.slice(h)}`;return yield*t.writeFileString(f,i.endsWith(`
|
|
112
|
+
`)?i:`${i}
|
|
113
|
+
`).pipe(hr.mapError((I)=>new S({cause:I,path:f}))),"updated"}if(a!==-1||y!==-1)return"malformed";let m=l.length===0||l.endsWith(`
|
|
114
|
+
|
|
115
|
+
`)?"":l.endsWith(`
|
|
118
116
|
`)?`
|
|
119
117
|
`:`
|
|
120
118
|
|
|
121
|
-
`;return yield*n.writeFileString(o,`${s}${p}${l}`).pipe(ve.mapError((u)=>new S({cause:u,path:o}))),"updated"});import Wo from"node:process";import*as vr from"effect/Effect";import*as Rr from"effect/FileSystem";import*as Dr from"effect/Path";var en=(e=Wo.cwd())=>vr.gen(function*(){let t=yield*Rr.FileSystem,n=yield*Dr.Path;if(yield*t.exists(n.join(e,"pnpm-workspace.yaml")))return!0;return(yield*v(e)).workspaces!==void 0});var Xo=(e,t)=>d.gen(function*(){let n=yield*K;yield*(yield*O).withSpinner(()=>d.gen(function*(){let o=yield*en(e);yield*n.addDevDependencies(t,e,{silent:!0,workspace:o})}),{failure:"Failed to install dependencies.",start:"Installing dependencies...",success:"Dependencies installed."})});function tn(e,t){return d.gen(function*(){yield*(yield*O).log.info(`Legacy \`${t}\` was preserved during \`adamantite init\`. \`adamantite init\` does not migrate legacy ${e} configs yet.`)})}var Yo=(e,t)=>d.gen(function*(){let n=yield*O,r=yield*n.withSpinner((o)=>d.gen(function*(){let i=yield*y.detect(e),s=y.files[1].path;if(i.active?.format==="ts"&&i.legacy.length>0)yield*n.log.warning(`Found both \`${y.config}\` and \`${s}\`. Adamantite will use \`${y.config}\`.`);if(i.active?.format==="json")return yield*o.message(`Found \`${s}\`, keeping existing config.`),{created:!1,legacyConfig:s};if(i.active?.format==="ts")return yield*o.message(`Found \`${y.config}\`, keeping existing config.`),{created:!1,legacyConfig:null};return yield*o.message(`\`${y.config}\` not found, creating...`),yield*y.create(e,t),{created:!0,legacyConfig:null}}),{failure:"Failed to set up oxlint config.",start:"Setting up oxlint config...",success:(o)=>o.created?"oxlint config created successfully.":"oxlint config is ready."});if(r.legacyConfig)yield*tn("oxlint",r.legacyConfig)}),Ho=(e)=>d.gen(function*(){let t=yield*O,n=yield*t.withSpinner((r)=>d.gen(function*(){let o=yield*h.detect(e);if(o.active?.format==="ts"&&o.legacy.length>0)yield*t.log.warning(`Found both \`${h.config}\` and \`.oxfmtrc.json(c)\`. Adamantite will use \`${h.config}\`.`);if(o.active&&o.active.format!=="ts"&&o.legacy.length>0)yield*t.log.warning("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(o.active?.format==="json"||o.active?.format==="jsonc"){let i=o.active.path.endsWith(h.files[1].path)?h.files[1].path:h.files[2].path;return yield*r.message(`Found \`${i}\`, keeping existing config.`),{created:!1,legacyConfig:i}}if(o.active?.format==="ts")return yield*r.message(`Found \`${h.config}\`, keeping existing config.`),{created:!1,legacyConfig:null};return yield*r.message(`\`${h.config}\` not found, creating...`),yield*h.create(e),{created:!0,legacyConfig:null}}),{failure:"Failed to set up oxfmt config.",start:"Setting up oxfmt config...",success:(r)=>r.created?"oxfmt config created successfully.":"oxfmt config is ready."});if(n.legacyConfig)yield*tn("oxfmt",n.legacyConfig)}),Ko=(e,t)=>d.gen(function*(){let n=yield*Nr.FileSystem,r=yield*Tr.Path,o=yield*O,i=yield*v(e);yield*o.withSpinner(()=>d.gen(function*(){i.scripts??={};for(let a of t)switch(a){case"check":i.scripts.check="adamantite check";break;case"fix":i.scripts.fix="adamantite fix";break;case"format":i.scripts.format="adamantite format";break;case"check:monorepo":i.scripts["check:monorepo"]="adamantite monorepo";break;case"fix:monorepo":i.scripts["fix:monorepo"]="adamantite monorepo --fix";break;case"analyze":i.scripts.analyze="adamantite analyze";break;default:return yield*new Jt({script:a})}let s=r.join(e,"package.json");yield*n.writeFileString(s,`${JSON.stringify(i,null,2)}
|
|
122
|
-
`).pipe(d.mapError((a)=>new S({cause:a,path:s})))}),{failure:"Failed to add scripts to `package.json`.",start:"Adding scripts to your `package.json`...",success:"Scripts added to your `package.json`"})}),xo=(e)=>d.gen(function*(){let t=yield*O,n=yield*t.withSpinner((r)=>d.gen(function*(){let o=yield*m.detect(e);if(o.active?.format==="ts"&&o.legacy.length>0)yield*t.log.warning(`Found both \`${m.config}\` and \`knip.json(c)\`. Adamantite will use \`${m.config}\`.`);if(o.active&&o.active.format!=="ts"&&o.legacy.length>0)yield*t.log.warning("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(o.active?.format==="json"||o.active?.format==="jsonc"){let i=o.active.path.endsWith(m.files[1].path)?m.files[1].path:m.files[2].path;return yield*r.message(`Found \`${i}\`, keeping existing config.`),{created:!1,legacyConfig:i}}if(o.active?.format==="ts")return yield*r.message(`Found \`${m.config}\`, keeping existing config.`),{created:!1,legacyConfig:null};return yield*r.message(`\`${m.config}\` not found, creating...`),yield*m.create(e),{created:!0,legacyConfig:null}}),{failure:"Failed to set up knip config.",start:"Setting up knip config...",success:(r)=>r.created?"knip config created successfully.":"knip config is ready."});if(n.legacyConfig)yield*tn("knip",n.legacyConfig)}),Lo=(e)=>d.gen(function*(){yield*(yield*O).withSpinner((n)=>d.gen(function*(){if(yield*J.detect(e))return yield*n.message(`\`${J.config}\` found, updating...`),yield*J.update(e),!1;return yield*n.message(`\`${J.config}\` not found, creating...`),yield*J.create(e),!0}),{failure:"Failed to set up TypeScript config.",start:"Setting up TypeScript config...",success:(n)=>n?`\`${J.config}\` created successfully`:`\`${J.config}\` updated successfully`})}),Mo=(e,t)=>d.gen(function*(){let n=yield*O;if(t.includes("vscode"))yield*n.withSpinner((r)=>d.gen(function*(){let o=yield*ye.detect(e);return yield*r.message(`\`${ye.config}\` ${o?"found, updating":"not found, creating"}...`),yield*o?ye.update(e):ye.create(e),!o}),{failure:"Failed to set up VS Code config.",start:`Checking for \`${ye.config}\`...`,success:(r)=>`\`${ye.config}\` ${r?"created":"updated"} with Adamantite preset.`});if(t.includes("zed"))yield*n.withSpinner((r)=>d.gen(function*(){let o=yield*Fe.detect(e);return yield*r.message(`\`${Fe.config}\` ${o?"found, updating":"not found, creating"}...`),yield*o?Fe.update(e):Fe.create(e),!o}),{failure:"Failed to set up Zed config.",start:`Checking for \`${Fe.config}\`...`,success:(r)=>`\`${Fe.config}\` ${r?"created":"updated"} with Adamantite preset.`})}),wo=(e,t)=>d.gen(function*(){let n=yield*O,r=e.includes("zed"),o=e.includes("vscode");if(yield*n.withSpinner((i)=>d.gen(function*(){if(o)yield*i.message("Installing VS Code extension..."),yield*ye.extension(t);return!0}),{start:"Installing editor extensions...",success:r&&!o?"Zed extensions require manual install.":"Editor extensions installed successfully."}).pipe(d.catchTag("FailedToInstallExtension",(i)=>d.gen(function*(){return yield*n.log.warning(`⚠️ Failed to install the \`${i.extension}\` extension.`),yield*n.log.warning("Please install it manually after setup completes."),!1})),d.catchTag("VscodeCliNotFound",()=>d.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}))),r)yield*n.log.info("Install the Zed `oxc` extension: zed://extension/oxc")}),Go=(e,t,n)=>d.gen(function*(){let r=yield*O,o=se.files[0].path;yield*r.withSpinner((i)=>d.gen(function*(){let s=yield*se.detect(e);return yield*i.message(s?`\`${o}\` found, updating...`:`Creating \`${o}\`...`),yield*s?se.update(e,{packageManager:t,scripts:n}):se.create(e,{packageManager:t,scripts:n}),!s}),{failure:"Failed to set up GitHub Actions workflow.",start:"Setting up GitHub Actions workflow...",success:(i)=>`GitHub Actions workflow ${i?"created":"updated"} successfully.`})}).pipe(d.option),Co=(e,t,n)=>d.gen(function*(){let r=yield*O,o=yield*r.withSpinner(()=>Fr(e,{packageManager:t,scripts:n}),{failure:"Failed to update AGENTS.md.",start:"Updating AGENTS.md...",success:"AGENTS.md check complete."}).pipe(d.catchTag(["FailedToReadFile","FailedToWriteFile"],(i)=>d.gen(function*(){return yield*r.log.warning(`Could not update AGENTS.md. ${i.message} Adamantite will continue initialization.`),"failed"})));if(o==="failed")return;if(o==="malformed")yield*r.log.warning("Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.")}),Vr=["check","fix","format","check:monorepo","fix:monorepo","analyze"],Pr=["react","nextjs","vue","jest","vitest","node"],Ir=["vscode","zed"],ei=d.fn("validateInitOptions")(function*(e,t){let n={agents:e.agents,editors:ke.dedupe(e.editors),githubActions:e.githubActions,installExtensions:e.installExtensions,presets:ke.dedupe(e.presets),scripts:ke.dedupe(e.scripts),typescript:e.typescript};if(n.scripts.length===0)return yield*new w({reason:"Select at least one script with `--script <name>`."});let r=n.scripts.includes("check")||n.scripts.includes("fix");if((n.scripts.includes("check:monorepo")||n.scripts.includes("fix:monorepo"))&&!t.isMonorepo)return yield*new w({reason:"Monorepo scripts can only be selected in a detected monorepo."});if(n.presets.length>0&&!r)return yield*new w({reason:"`--preset` requires the `check` or `fix` script."});if(n.typescript&&!r)return yield*new w({reason:"`--typescript` requires the `check` or `fix` script."});if(n.installExtensions&&n.editors.length===0)return yield*new w({reason:"`--install-extensions` requires at least one `--editor`."});if(n.githubActions&&!Me(n.scripts))return yield*new w({reason:"`--github-actions` requires a CI-compatible script."});if(n.githubActions&&t.nonInteractive&&!Ye(t.packageManager))return yield*new w({reason:`\`--github-actions\` does not support the detected package manager \`${t.packageManager}\`. Use bun, deno, npm, pnpm, or yarn.`});return n}),ti=$.boolean("non-interactive").pipe($.withDescription("Configure without prompts; requires at least one --script")),ni=$.choice("script",Vr).pipe($.atMost(Vr.length),$.withDescription("Package script to configure; repeatable and required in non-interactive mode. Monorepo scripts require a detected monorepo")),ri=$.choice("preset",Pr).pipe($.atMost(Pr.length),$.withDescription("Oxlint preset to configure; repeatable and requires --script check or fix")),oi=$.choice("editor",Ir).pipe($.atMost(Ir.length),$.withDescription("Editor to configure; may be specified multiple times")),ii=$.boolean("typescript").pipe($.withDescription("Configure the TypeScript preset; requires --script check or fix")),si=$.boolean("install-extensions").pipe($.withDescription("Install recommended extensions; requires at least one --editor")),ai=$.boolean("github-actions").pipe($.withDescription("Configure CI; requires a compatible script and bun, deno, npm, pnpm, or yarn")),fi=$.boolean("agents").pipe($.withDescription("Add Adamantite guidance to AGENTS.md")),li=d.fn("collectInteractiveInitOptions")(function*(e){let t=yield*O,n=yield*t.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:!e,hint:e?void 0:"available for monorepo projects",label:"check:monorepo - check for monorepo-specific issues using Sherif",value:"check:monorepo"},{disabled:!e,hint:e?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"}]}),r=n.includes("check")||n.includes("fix"),o=[];if(r)o=yield*t.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 i=r?yield*t.confirm({initialValue:!0,message:"Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?"}):!1,s=yield*t.multiselect({message:"Which editors do you want to configure? (optional)",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}),a=s.length>0?yield*t.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"}):!1,f=Me(n)?yield*t.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"}):!1;return{agents:yield*t.confirm({initialValue:!0,message:"Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?"}),editors:s,githubActions:f,installExtensions:a,presets:o,scripts:n,typescript:i}}),br=me.make("init",{agents:fi,editors:oi,githubActions:ai,installExtensions:si,nonInteractive:ti,presets:ri,scripts:ni,typescript:ii}).pipe(me.withDescription("Initialize Adamantite in the current directory. Setup flags require --non-interactive; omitted boolean setup flags are disabled"),me.withExamples([{command:"adamantite init --non-interactive --script check",description:"Configure linting without prompts"},{command:"adamantite init --non-interactive --script check --script format --preset react --editor vscode --typescript --install-extensions --github-actions --agents",description:"Configure a React project with VS Code, TypeScript, CI, and agent guidance"},{command:"adamantite init --non-interactive --script check:monorepo",description:"Configure monorepo checks in a detected monorepo"}]),me.withHandler((e)=>d.gen(function*(){let t=Zo.cwd(),n=yield*O;yield*_e(),yield*n.intro("\uD83D\uDCA0 adamantite init");let o=yield*(yield*K).detectPackageManager(t);if(!o)return yield*new Xe({});if(o.warnings?.length)for(let Ze of o.warnings)yield*n.log.warning(Ze);yield*n.log.info(`Detected package manager: ${o.name}`);let i=yield*en(t);if(i)yield*n.log.info("We've detected a monorepo setup in your project.");if(!e.nonInteractive&&ke.some([e.scripts.length>0,e.presets.length>0,e.editors.length>0,e.typescript,e.installExtensions,e.githubActions,e.agents],_r.isTruthy))return yield*new w({reason:"Setup flags require `--non-interactive`."});let s=e.nonInteractive?e:yield*li(i),a=yield*ei(s,{isMonorepo:i,nonInteractive:e.nonInteractive,packageManager:o.name}),f=a.scripts,l=a.presets,p=a.editors,u=a.typescript,E=a.installExtensions,j=a.githubActions,N=a.agents,P=f.includes("check")||f.includes("fix"),te=f.includes("format"),c=f.includes("check:monorepo")||f.includes("fix:monorepo"),b=f.includes("analyze"),Ee=["adamantite"];if(P)Ee.push(`${y.name}@${y.version}`,`${le.name}@${le.version}`);if(te)Ee.push(`${h.name}@${h.version}`);if(c)Ee.push(`${L.name}@${L.version}`);if(b)Ee.push(`${m.name}@${m.version}`);if(yield*Xo(t,Ee),te)yield*Ho(t);if(P)yield*Yo(t,l);if(b)yield*xo(t);if(yield*Ko(t,f),N)yield*Co(t,o.name,f);if(u)yield*Lo(t);if(yield*Mo(t,p),E)yield*wo(p,f);if(j){let Ze=o.name;if(Ye(Ze))yield*Go(t,Ze,f);else yield*n.log.warning(`Skipping GitHub Actions setup: \`${Ze}\` is not a supported package manager for CI workflow generation.`)}yield*n.log.success("Your project is now configured"),yield*n.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe(d.catchTags({OperationCancelled:()=>d.gen(function*(){yield*(yield*O).cancel("You've cancelled the initialization process.")})}))));import*as qr from"effect/Effect";import*as Be from"effect/unstable/cli/Command";import*as Dt from"effect/unstable/cli/Flag";import*as zr from"effect/unstable/process/ChildProcessSpawner";var pi=Dt.boolean("fix").pipe(Dt.withDescription("Automatically fix issues")),nn=Be.make("monorepo",{fix:pi}).pipe(Be.withDescription("Find and fix monorepo-specific issues using Sherif"),Be.withHandler(({fix:e})=>qr.gen(function*(){let t=yield*B,n=yield*T,r=e?["--fix",...t]:[...t],o=yield*n.run({args:r,command:L.name,stdin:"inherit"});if(o!==zr.ExitCode(0))yield*new q({command:L.name,exitCode:o})})));import*as Jr from"effect/Effect";import*as Qe from"effect/unstable/cli/Command";import*as Ur from"effect/unstable/process/ChildProcessSpawner";var rn=Qe.make("typecheck").pipe(Qe.withDescription("Deprecated alias for `check`"),Qe.withHandler(()=>Jr.gen(function*(){let e=yield*B,t=yield*O,n=yield*T;yield*t.log.warning("Deprecated. Use `adamantite check` for typechecking.");let r=yield*n.run({args:[...e],command:y.name});if(r!==Ur.ExitCode(0))yield*new q({command:y.name,exitCode:r})})));import ui from"node:process";import*as he from"effect/Effect";import*as We from"effect/unstable/cli/Command";var ci=[y,le,h,L,m],yi=[y,le,h,L,m];function mi(e,t){let n=[];for(let r of yi){if(t.has(r.name))continue;let o=e.devDependencies?.[r.name]??e.dependencies?.[r.name];if(o&&Y(o)!==r.version)n.push({currentVersion:o,name:r.name,targetVersion:r.version})}return n}var Ar=We.make("update").pipe(We.withDescription("Run applicable Adamantite migrations and update managed dependencies"),We.withHandler(()=>he.gen(function*(){let e=ui.cwd(),t=yield*O,n=yield*K,r={cwd:e};yield*_e(),yield*t.intro("\uD83D\uDCA0 adamantite update");let o=()=>Ot(ci,e),i=yield*o();for(let{assessment:c}of i)for(let b of c.warnings)yield*t.log.warning(b);let s=new Set(i.map(({integration:c})=>c.name)),a=i.flatMap(({assessment:c})=>c.actions),f=new Set(a.filter((c)=>c.type==="run_migration").map((c)=>c.migrationId)),l=[];for(let c of Et.filter((b)=>b.tags.includes("update"))){let b=tr[c.id];if(s.has(b))continue;let Ee=yield*c.check(r);l.push({migration:c,result:Ee})}for(let c of l){for(let b of c.result.warnings)yield*t.log.warning(b);if(c.result.applicable&&c.result.summary)yield*t.log.info(c.result.summary)}let p=[];for(let c of Et){if(!f.has(c.id))continue;yield*Le(c,r,{onRestore:t.log.warning(`Migration "${c.title}" failed, restoring files...`)}),p.push(c.id)}for(let{migration:c,result:b}of l){if(!b.applicable||!b.summary)continue;yield*Le(c,r,{onRestore:t.log.warning(`Migration "${c.title}" failed, restoring files...`)}),p.push(c.id)}if(p.length>0)yield*t.log.success("Migrations ran successfully.");let u=yield*v(e),E=yield*o(),j=E.flatMap(({assessment:c})=>c.actions).filter((c)=>c.type==="create_config"||c.type==="update_config"||c.type==="manual_fix"),N=E.flatMap(({assessment:c})=>c.actions).filter((c)=>c.type==="install_package"||c.type==="update_package").map((c)=>c.type==="install_package"?{currentVersion:"not installed",name:c.package,targetVersion:c.targetVersion}:{currentVersion:c.currentVersion,name:c.package,targetVersion:c.targetVersion}),P=new Set(N.map((c)=>c.name)),te=[...N,...mi(u,P)];if(te.length>0){yield*t.log.info("The following dependencies will be updated:");for(let c of te)yield*t.log.info(` ${c.name}: ${c.currentVersion} → ${c.targetVersion}`);yield*t.withSpinner(()=>n.addDevDependencies(te.map((c)=>`${c.name}@${c.targetVersion}`),e,{silent:!0}),{failure:"Failed to update dependencies",start:"Updating dependencies...",success:"Dependencies updated successfully"}),yield*t.log.success("Dependencies updated successfully.")}if(j.length>0){yield*t.log.warning("Some configuration follow-up belongs to `adamantite doctor --fix`.");for(let c of j)yield*t.log.warning(`Doctor follow-up: ${c.description}`)}if(p.length===0&&te.length===0&&j.length===0)return yield*t.log.success("No changes needed."),"no-changes";return"success"}).pipe(he.tapError(()=>he.gen(function*(){yield*(yield*O).outro("❌ Update failed")})),he.tap((e)=>he.gen(function*(){let t=yield*O;switch(e){case"no-changes":yield*t.outro("✅ Adamantite is already up to date.");break;case"success":yield*t.outro("✅ Update completed successfully!");break;default:break}})))));var hi=[Bt,Yt,Mt,wt,nn,rn],kr=[Bt,Yt,lr,Mt,wt,br,nn,rn,Ar],di=new Set(kr.map((e)=>e.name)),Ei=new Set(hi.map((e)=>e.name)),gi=de.make("adamantite").pipe(de.withDescription("Opinionated preset package for modern TypeScript applications"),de.withSubcommands(kr)),Br=Pt.fn("runCli")(function*(e,t){let[n,r]=Vt.splitWhere(e,(s)=>s==="--"),o=Vt.drop(r,1),i=n.find((s)=>di.has(s));if(o.length>0&&i!==void 0&&!Ei.has(i))return yield*new zt({command:i});yield*de.runWith(gi,{version:t})(n).pipe(Pt.provideService(B,o))});var Oi=_.gen(function*(){let t=yield*(yield*Hr.Stdio).args;yield*Br(t,"0.34.2")}).pipe(_.as(0),_.catchTag("CommandFailed",(e)=>_.succeed(e.exitCode)),_.catch((e)=>_.service(O).pipe(_.flatMap((t)=>t.log.error(e.message)),_.as(Kr.ExitCode(1)))),_.provide(Xr.mergeAll(Wr.layer,O.layer,T.layer,K.layer)));Qr.runMain(Oi,{teardown:(e,t)=>{if(Zr.isSuccess(e)){t(Number(e.value));return}Yr.defaultTeardown(e,t)}});
|
|
119
|
+
`;return yield*t.writeFileString(f,`${l}${m}${O}`).pipe(hr.mapError((h)=>new S({cause:h,path:f}))),"updated"});import Wf from"node:process";import*as yn from"effect/Effect";import*as an from"effect/FileSystem";import*as mn from"effect/Path";var Ge=(r=Wf.cwd())=>yn.gen(function*(){let e=yield*an.FileSystem,t=yield*mn.Path;if(yield*e.exists(t.join(r,"pnpm-workspace.yaml")))return!0;return(yield*b(r)).workspaces!==void 0});var Kf=(r,e)=>$.gen(function*(){let t=yield*Y;yield*(yield*o).withSpinner(()=>$.gen(function*(){let f=yield*Ge(r);yield*t.addDevDependencies(e,r,{silent:!0,workspace:f})}),{failure:"Failed to install dependencies.",start:"Installing dependencies...",success:"Dependencies installed."})});function Me(r,e,t){return $.gen(function*(){let n=yield*o,f=yield*n.withSpinner((u)=>$.gen(function*(){let l=yield*e.detect(r);for(let a of l.warnings)yield*n.log.warning(a);if(l.active===null)return yield*u.message(`\`${e.config}\` not found, creating...`),yield*t,{created:!0,legacyConfig:null};if(l.active.format==="ts")return yield*u.message(`Found \`${e.config}\`, keeping existing config.`),{created:!1,legacyConfig:null};return yield*u.message(`Found \`${l.active.file}\`, keeping existing config.`),{created:!1,legacyConfig:l.active.file}}),{failure:`Failed to set up ${e.name} config.`,start:`Setting up ${e.name} config...`,success:(u)=>u.created?`${e.name} config created successfully.`:`${e.name} config is ready.`});if(f.legacyConfig)yield*n.log.info(`Legacy \`${f.legacyConfig}\` was preserved during \`adamantite init\`. Run \`adamantite doctor --fix\` to migrate it to the latest ${e.name} config.`)})}var Pf=(r,e)=>$.gen(function*(){let t=yield*o,n=yield*b(r);yield*t.withSpinner(()=>$.gen(function*(){n.scripts??={};for(let f of e)n.scripts[f]=ur[f];yield*Gr(r,n)}),{failure:"Failed to add scripts to `package.json`.",start:"Adding scripts to your `package.json`...",success:"Scripts added to your `package.json`"})}),Ff=(r)=>$.gen(function*(){yield*(yield*o).withSpinner((t)=>$.gen(function*(){if(yield*V.detect(r))return yield*t.message(`\`${V.config}\` found, updating...`),yield*V.update(r),!1;return yield*t.message(`\`${V.config}\` not found, creating...`),yield*V.create(r),!0}),{failure:"Failed to set up TypeScript config.",start:"Setting up TypeScript config...",success:(t)=>t?`\`${V.config}\` created successfully`:`\`${V.config}\` updated successfully`})}),Tf=(r,e)=>$.gen(function*(){let t=yield*o;if(e.includes("vscode"))yield*t.withSpinner((n)=>$.gen(function*(){let f=yield*k.detect(r);return yield*n.message(`\`${k.config}\` ${f?"found, updating":"not found, creating"}...`),yield*f?k.update(r):k.create(r),!f}),{failure:"Failed to set up VS Code config.",start:`Checking for \`${k.config}\`...`,success:(n)=>`\`${k.config}\` ${n?"created":"updated"} with Adamantite preset.`});if(e.includes("zed"))yield*t.withSpinner((n)=>$.gen(function*(){let f=yield*Er.detect(r);return yield*n.message(`\`${Er.config}\` ${f?"found, updating":"not found, creating"}...`),yield*f?Er.update(r):Er.create(r),!f}),{failure:"Failed to set up Zed config.",start:`Checking for \`${Er.config}\`...`,success:(n)=>`\`${Er.config}\` ${n?"created":"updated"} with Adamantite preset.`})}),Yf=(r,e)=>$.gen(function*(){let t=yield*o,n=r.includes("zed"),f=r.includes("vscode");if(yield*t.withSpinner((u)=>$.gen(function*(){if(f)yield*u.message("Installing VS Code extension..."),yield*k.extension(e);return!0}),{start:"Installing editor extensions...",success:n&&!f?"Zed extensions require manual install.":"Editor extensions installed successfully."}).pipe($.catchTag("FailedToInstallExtension",(u)=>$.gen(function*(){return yield*t.log.warning(`⚠️ Failed to install the \`${u.extension}\` extension.`),yield*t.log.warning("Please install it manually after setup completes."),!1})),$.catchTag("VscodeCliNotFound",()=>$.gen(function*(){return yield*t.log.error("VSCode CLI ('code' command) not found."),yield*t.log.info("To install it:"),yield*t.log.info(" 1. Open VS Code"),yield*t.log.info(" 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)"),yield*t.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))),n)yield*t.log.info("Install the Zed `oxc` extension: zed://extension/oxc")}),_f=(r,e,t)=>$.gen(function*(){let n=yield*o,f=g.files[0].path;yield*n.withSpinner((u)=>$.gen(function*(){let l=yield*g.detect(r);return yield*u.message(l?`\`${f}\` found, updating...`:`Creating \`${f}\`...`),yield*l?g.update(r,{packageManager:e,scripts:t}):g.create(r,{packageManager:e,scripts:t}),!l}),{failure:"Failed to set up GitHub Actions workflow.",start:"Setting up GitHub Actions workflow...",success:(u)=>`GitHub Actions workflow ${u?"created":"updated"} successfully.`})}).pipe($.option),Xf=(r,e,t)=>$.gen(function*(){let n=yield*o,f=yield*n.withSpinner(()=>ln(r,{packageManager:e,scripts:t}),{failure:"Failed to update AGENTS.md.",start:"Updating AGENTS.md...",success:"AGENTS.md check complete."}).pipe($.catchTag(["FailedToReadFile","FailedToWriteFile"],(u)=>$.gen(function*(){return yield*n.log.warning(`Could not update AGENTS.md. ${u.message} Adamantite will continue initialization.`),"failed"})));if(f==="failed")return;if(f==="malformed")yield*n.log.warning("Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.")}),En=["check","fix","format","check:monorepo","fix:monorepo","analyze"],hn=["react","nextjs","vue","jest","vitest","node"],On=["vscode","zed"],Nf=$.fn("validateInitOptions")(function*(r,e){let t={agents:r.agents,editors:Zr.dedupe(r.editors),githubActions:r.githubActions,installExtensions:r.installExtensions,presets:Zr.dedupe(r.presets),scripts:Zr.dedupe(r.scripts),typescript:r.typescript};if(t.scripts.length===0)return yield*new X({reason:"Select at least one script with `--script <name>`."});let n=t.scripts.includes("check")||t.scripts.includes("fix");if((t.scripts.includes("check:monorepo")||t.scripts.includes("fix:monorepo"))&&!e.isMonorepo)return yield*new X({reason:"Monorepo scripts can only be selected in a detected monorepo."});if(t.presets.length>0&&!n)return yield*new X({reason:"`--preset` requires the `check` or `fix` script."});if(t.typescript&&!n)return yield*new X({reason:"`--typescript` requires the `check` or `fix` script."});if(t.installExtensions&&t.editors.length===0)return yield*new X({reason:"`--install-extensions` requires at least one `--editor`."});if(t.githubActions&&!Hr(t.scripts))return yield*new X({reason:"`--github-actions` requires a CI-compatible script."});if(t.githubActions&&e.nonInteractive&&!Xr(e.packageManager))return yield*new X({reason:`\`--github-actions\` does not support the detected package manager \`${e.packageManager}\`. Use bun, deno, npm, pnpm, or yarn.`});return t}),Hf=v.boolean("non-interactive").pipe(v.withDescription("Configure without prompts; requires at least one --script")),Lf=v.choice("script",En).pipe(v.atMost(En.length),v.withDescription("Package script to configure; repeatable and required in non-interactive mode. Monorepo scripts require a detected monorepo")),xf=v.choice("preset",hn).pipe(v.atMost(hn.length),v.withDescription("Oxlint preset to configure; repeatable and requires --script check or fix")),Jf=v.choice("editor",On).pipe(v.atMost(On.length),v.withDescription("Editor to configure; may be specified multiple times")),If=v.boolean("typescript").pipe(v.withDescription("Configure the TypeScript preset; requires --script check or fix")),df=v.boolean("install-extensions").pipe(v.withDescription("Install recommended extensions; requires at least one --editor")),Af=v.boolean("github-actions").pipe(v.withDescription("Configure CI; requires a compatible script and bun, deno, npm, pnpm, or yarn")),Gf=v.boolean("agents").pipe(v.withDescription("Add Adamantite guidance to AGENTS.md")),Mf=$.fn("collectInteractiveInitOptions")(function*(r){let e=yield*o,t=yield*e.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:!r,hint:r?void 0:"available for monorepo projects",label:"check:monorepo - check for monorepo-specific issues using Sherif",value:"check:monorepo"},{disabled:!r,hint:r?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"}]}),n=t.includes("check")||t.includes("fix"),f=[];if(n)f=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 u=n?yield*e.confirm({initialValue:!0,message:"Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?"}):!1,l=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}),a=l.length>0?yield*e.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"}):!1,y=Hr(t)?yield*e.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"}):!1;return{agents:yield*e.confirm({initialValue:!0,message:"Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?"}),editors:l,githubActions:y,installExtensions:a,presets:f,scripts:t,typescript:u}}),jn=er.make("init",{agents:Gf,editors:Jf,githubActions:Af,installExtensions:df,nonInteractive:Hf,presets:xf,scripts:Lf,typescript:If}).pipe(er.withDescription("Initialize Adamantite in the current directory. Setup flags require --non-interactive; omitted boolean setup flags are disabled"),er.withExamples([{command:"adamantite init --non-interactive --script check",description:"Configure linting without prompts"},{command:"adamantite init --non-interactive --script check --script format --preset react --editor vscode --typescript --install-extensions --github-actions --agents",description:"Configure a React project with VS Code, TypeScript, CI, and agent guidance"},{command:"adamantite init --non-interactive --script check:monorepo",description:"Configure monorepo checks in a detected monorepo"}]),er.withHandler((r)=>$.gen(function*(){let e=Zf.cwd(),t=yield*o;yield*Rr(),yield*t.intro("\uD83D\uDCA0 adamantite init");let f=yield*(yield*Y).detectPackageManager(e);if(!f)return yield*new _r({});if(f.warnings?.length)for(let Yr of f.warnings)yield*t.log.warning(Yr);yield*t.log.info(`Detected package manager: ${f.name}`);let u=yield*Ge(e);if(u)yield*t.log.info("We've detected a monorepo setup in your project.");if(!r.nonInteractive&&Zr.some([r.scripts.length>0,r.presets.length>0,r.editors.length>0,r.typescript,r.installExtensions,r.githubActions,r.agents],$n.isTruthy))return yield*new X({reason:"Setup flags require `--non-interactive`."});let l=r.nonInteractive?r:yield*Mf(u),a=yield*Nf(l,{isMonorepo:u,nonInteractive:r.nonInteractive,packageManager:f.name}),y=a.scripts,O=a.presets,m=a.editors,h=a.typescript,i=a.installExtensions,I=a.githubActions,Or=a.agents,E=y.includes("check")||y.includes("fix"),d=y.includes("format"),Zn=y.includes("check:monorepo")||y.includes("fix:monorepo"),Ce=y.includes("analyze"),Tr=["adamantite"];if(E)Tr.push(`${j.name}@${j.version}`,`${C.name}@${C.version}`);if(d)Tr.push(`${K.name}@${K.version}`);if(Zn)Tr.push(`${_.name}@${_.version}`);if(Ce)Tr.push(`${Z.name}@${Z.version}`);if(yield*Kf(e,Tr),d)yield*Me(e,K,K.create(e));if(E)yield*Me(e,j,j.create(e,O));if(Ce)yield*Me(e,Z,Z.create(e));if(yield*Pf(e,y),Or)yield*Xf(e,f.name,y);if(h)yield*Ff(e);if(yield*Tf(e,m),i)yield*Yf(m,y);if(I){let Yr=f.name;if(Xr(Yr))yield*_f(e,Yr,y);else yield*t.log.warning(`Skipping GitHub Actions setup: \`${Yr}\` is not a supported package manager for CI workflow generation.`)}yield*t.log.success("Your project is now configured"),yield*t.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe($.catchTags({OperationCancelled:()=>$.gen(function*(){yield*(yield*o).cancel("You've cancelled the initialization process.")})}))));import*as on from"effect/Effect";import*as Kr from"effect/unstable/cli/Command";import*as Se from"effect/unstable/cli/Flag";import*as Sn from"effect/unstable/process/ChildProcessSpawner";var gf=Se.boolean("fix").pipe(Se.withDescription("Automatically fix issues")),ge=Kr.make("monorepo",{fix:gf}).pipe(Kr.withDescription("Find and fix monorepo-specific issues using Sherif"),Kr.withHandler(({fix:r})=>on.gen(function*(){let e=yield*P,t=yield*s,n=r?["--fix",...e]:[...e],f=yield*t.run({args:n,command:_.name,stdin:"inherit"});if(f!==Sn.ExitCode(0))yield*new Q({command:_.name,exitCode:f})})));import*as vn from"effect/Effect";import*as Pr from"effect/unstable/cli/Command";import*as Dn from"effect/unstable/process/ChildProcessSpawner";var we=Pr.make("typecheck").pipe(Pr.withDescription("Deprecated alias for `check`"),Pr.withHandler(()=>vn.gen(function*(){let r=yield*P,e=yield*o,t=yield*s;yield*e.log.warning("Deprecated. Use `adamantite check` for typechecking.");let n=yield*t.run({args:[...r],command:j.name});if(n!==Dn.ExitCode(0))yield*new Q({command:j.name,exitCode:n})})));import wf from"node:process";import*as tr from"effect/Effect";import*as Fr from"effect/unstable/cli/Command";var Cf=[j,C,K,_,Z],pf=[j,C,K,_,Z];function cf(r,e){let t=[];for(let n of pf){if(e.has(n.name))continue;let f=r.devDependencies?.[n.name]??r.dependencies?.[n.name];if(f&&Ar(f)!==n.version)t.push({currentVersion:f,name:n.name,targetVersion:n.version})}return t}var zn=Fr.make("update").pipe(Fr.withDescription("Run applicable Adamantite migrations and update managed dependencies"),Fr.withHandler(()=>tr.gen(function*(){let r=wf.cwd(),e=yield*o,t=yield*Y,n={cwd:r};yield*Rr(),yield*e.intro("\uD83D\uDCA0 adamantite update");let f=()=>Ee(Cf,r),u=yield*f(),l=[];for(let E of Le.filter((d)=>d.tags.includes("update"))){let d=yield*E.check(n);l.push({migration:E,result:d})}let a=new Set([...u.flatMap(({assessment:E})=>E.warnings),...l.flatMap(({result:E})=>E.warnings)]);for(let E of a)yield*e.log.warning(E);let y=[];for(let{migration:E,result:d}of l){if(d.status!=="needed")continue;yield*e.log.info(d.summary),yield*te(E,n,{onRestore:e.log.warning(`Migration "${E.title}" failed, restoring files...`)}),y.push(E.id)}if(y.length>0)yield*e.log.success("Migrations ran successfully.");let O=yield*b(r),m=yield*f(),h=m.flatMap(({assessment:E})=>E.actions).filter((E)=>E.type==="create_config"||E.type==="update_config"||E.type==="manual_fix"),i=m.flatMap(({assessment:E})=>E.actions).filter((E)=>E.type==="install_package"||E.type==="update_package").map((E)=>E.type==="install_package"?{currentVersion:"not installed",name:E.package,targetVersion:E.targetVersion}:{currentVersion:E.currentVersion,name:E.package,targetVersion:E.targetVersion}),I=new Set(i.map((E)=>E.name)),Or=[...i,...cf(O,I)];if(Or.length>0){yield*e.log.info("The following dependencies will be updated:");for(let E of Or)yield*e.log.info(` ${E.name}: ${E.currentVersion} → ${E.targetVersion}`);yield*e.withSpinner(()=>t.addDevDependencies(Or.map((E)=>`${E.name}@${E.targetVersion}`),r,{silent:!0}),{failure:"Failed to update dependencies",start:"Updating dependencies...",success:"Dependencies updated successfully"}),yield*e.log.success("Dependencies updated successfully.")}if(h.length>0){yield*e.log.warning("Some configuration follow-up belongs to `adamantite doctor --fix`.");for(let E of h)yield*e.log.warning(`Doctor follow-up: ${E.description}`)}if(y.length===0&&Or.length===0&&h.length===0)return yield*e.log.success("No changes needed."),"no-changes";return"success"}).pipe(tr.tapError(()=>tr.gen(function*(){yield*(yield*o).outro("❌ Update failed")})),tr.tap((r)=>tr.gen(function*(){let e=yield*o;switch(r){case"no-changes":yield*e.outro("✅ Adamantite is already up to date.");break;case"success":yield*e.outro("✅ Update completed successfully!");break;default:break}})))));var kf=[_e,He,Je,Ie,ge,we],qn=[_e,He,Gt,Je,Ie,jn,ge,we,zn],ru=new Set(qn.map((r)=>r.name)),eu=new Set(kf.map((r)=>r.name)),tu=nr.make("adamantite").pipe(nr.withDescription("Opinionated preset package for modern TypeScript applications"),nr.withSubcommands(qn)),Bn=De.fn("runCli")(function*(r,e){let[t,n]=ve.splitWhere(r,(l)=>l==="--"),f=ve.drop(n,1),u=t.find((l)=>ru.has(l));if(f.length>0&&u!==void 0&&!eu.has(u))return yield*new Ve({command:u});yield*nr.runWith(tu,{version:e})(t).pipe(De.provideService(P,f))});var nu=U.gen(function*(){let e=yield*(yield*Vn.Stdio).args;yield*Bn(e,"0.34.4")}).pipe(U.as(0),U.catchTag("CommandFailed",(r)=>U.succeed(r.exitCode)),U.catch((r)=>U.service(o).pipe(U.flatMap((e)=>e.log.error(r.message)),U.as(Wn.ExitCode(1)))),U.provide(Un.mergeAll(bn.layer,o.layer,s.layer,Y.layer)));Rn.runMain(nu,{teardown:(r,e)=>{if(sn.isSuccess(r)){e(Number(r.value));return}Qn.defaultTeardown(r,e)}});
|
package/dist/presets/analyze.js
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
// presets/analyze.ts
|
|
2
2
|
var config = {
|
|
3
|
-
ignore: ["**/*.d.ts"],
|
|
4
3
|
ignoreExportsUsedInFile: true,
|
|
5
|
-
ignoreFiles: [
|
|
6
|
-
"**/dist/**",
|
|
7
|
-
"**/build/**",
|
|
8
|
-
"**/coverage/**",
|
|
9
|
-
"**/.next/**",
|
|
10
|
-
"**/.vercel/**",
|
|
11
|
-
"**/.turbo/**"
|
|
12
|
-
],
|
|
13
4
|
rules: {
|
|
14
5
|
binaries: "error",
|
|
15
6
|
catalog: "error",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adamantite",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.4",
|
|
4
4
|
"description": "An strict and opinionated set of presets for modern TypeScript applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adamantite",
|
|
@@ -73,25 +73,25 @@
|
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@clack/prompts": "1.7.0",
|
|
76
|
-
"@effect/platform-node": "4.0.0-
|
|
76
|
+
"@effect/platform-node": "4.0.0-rc.108",
|
|
77
77
|
"defu": "6.1.7",
|
|
78
|
-
"effect": "4.0.0-
|
|
79
|
-
"esrap": "2.3.
|
|
78
|
+
"effect": "4.0.0-rc.108",
|
|
79
|
+
"esrap": "2.3.2",
|
|
80
80
|
"jsonc-parser": "3.3.1",
|
|
81
81
|
"nypm": "0.6.9",
|
|
82
|
-
"oxc-parser": "^0.
|
|
82
|
+
"oxc-parser": "^0.144.0"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@changesets/changelog-github": "0.
|
|
86
|
-
"@changesets/cli": "
|
|
85
|
+
"@changesets/changelog-github": "1.0.0",
|
|
86
|
+
"@changesets/cli": "3.0.0",
|
|
87
87
|
"@tanstack/intent": "0.3.6",
|
|
88
88
|
"@types/bun": "1.3.14",
|
|
89
89
|
"@types/figlet": "1.7.0",
|
|
90
90
|
"bunup": "0.16.32",
|
|
91
91
|
"figlet": "1.11.4",
|
|
92
|
-
"knip": "6.
|
|
93
|
-
"oxfmt": "0.
|
|
94
|
-
"oxlint": "1.
|
|
92
|
+
"knip": "6.32.2",
|
|
93
|
+
"oxfmt": "0.63.0",
|
|
94
|
+
"oxlint": "1.78.0",
|
|
95
95
|
"oxlint-tsgolint": "7.0.2001",
|
|
96
96
|
"sherif": "1.13.0",
|
|
97
97
|
"type-fest": "5.8.0",
|
package/presets/analyze.ts
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import type { KnipConfiguration } from "knip"
|
|
2
2
|
|
|
3
3
|
const config: KnipConfiguration = {
|
|
4
|
-
ignore: ["**/*.d.ts"],
|
|
5
4
|
ignoreExportsUsedInFile: true,
|
|
6
|
-
ignoreFiles: [
|
|
7
|
-
"**/dist/**",
|
|
8
|
-
"**/build/**",
|
|
9
|
-
"**/coverage/**",
|
|
10
|
-
"**/.next/**",
|
|
11
|
-
"**/.vercel/**",
|
|
12
|
-
"**/.turbo/**",
|
|
13
|
-
],
|
|
14
5
|
rules: {
|
|
15
6
|
binaries: "error",
|
|
16
7
|
catalog: "error",
|