adamantite 0.36.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/index.js +24 -24
- package/dist/presets/lint/antislop.js +1 -1
- package/dist/presets/lint/react.js +18 -2
- package/package.json +3 -2
- /package/dist/presets/lint/{antislop → vendor/antislop}/license.md +0 -0
- /package/dist/presets/lint/{antislop → vendor/antislop}/plugin.d.mts +0 -0
- /package/dist/presets/lint/{antislop → vendor/antislop}/plugin.mjs +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# adamantite
|
|
2
2
|
|
|
3
|
+
## 0.37.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#382](https://github.com/adelrodriguez/adamantite/pull/382) [`a70fd83`](https://github.com/adelrodriguez/adamantite/commit/a70fd83d0209ed4c1acba108a5c5aa699066b9b2) Thanks [@adelrodriguez](https://github.com/adelrodriguez)! - Adopt the React Compiler rules that replace `react/react-compiler` in oxlint 1.79.0
|
|
8
|
+
|
|
9
|
+
oxlint 1.79.0 removed the nursery `react/react-compiler` rule and split it into per-category React Compiler rules. The react preset now enables the correctness rules (`error-boundaries`, `globals`, `immutability`, `incompatible-library`, `preserve-manual-memoization`, `purity`, `refs`, `set-state-in-effect`, `set-state-in-render`, `static-components`, `use-memo`, `void-use-memo`), the suspicious rules (`capitalized-calls`, `hooks`, `memo-dependencies`), and the perf rule `no-deriving-state-in-effects` as errors. `exhaustive-effect-dependencies` stays off because it duplicates the diagnostics `react/exhaustive-deps` already reports, and the restriction-category rules (`invariant`, `rule-suppression`, `syntax`, `todo`, `unsupported-syntax`) stay off because they only apply to codebases running the React Compiler build.
|
|
10
|
+
|
|
11
|
+
**Breaking behavior:** oxlint 1.79.0 fails to load any config that still references the removed rule — linting stays completely down until the reference is gone. Projects that only extend the Adamantite presets are covered by this release, but if your own `oxlint.config.ts` overrides `react/react-compiler` (for example to turn it off), delete that entry when you update. Managed projects install oxlint 1.79.0 on the next `adamantite update`.
|
|
12
|
+
|
|
13
|
+
- [#381](https://github.com/adelrodriguez/adamantite/pull/381) [`e60bfb5`](https://github.com/adelrodriguez/adamantite/commit/e60bfb52b1b22c9dae88383b11c08974b21f3051) Thanks [@adelrodriguez](https://github.com/adelrodriguez)! - Add Astro formatting to the Zed preset and migrate stale Zed oxfmt settings
|
|
14
|
+
|
|
15
|
+
The Zed preset now formats `.astro` files through Zed's managed Prettier with `prettier-plugin-astro` (oxfmt cannot format Astro), mirroring Zed's shipped defaults, and explicitly disables Prettier for the languages oxfmt owns so the two formatters never compete. A new migration removes settings the old Zed preset wrote under the oxfmt language server that the formatter never reads (`configPath`, `typeAware`, `unusedDisableDirectives`, and the deprecated `fmt.experimental`); only exact value matches are removed, so user-edited values survive.
|
|
16
|
+
|
|
3
17
|
## 0.36.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import*as e from"@effect/platform-node/NodeRuntime";import*as t from"@effect/platform-node/NodeServices";import*as n from"effect/Effect";import*as r from"effect/Exit";import*as i from"effect/Layer";import*as a from"effect/Runtime";import*as o from"effect/Stdio";import*as s from"effect/unstable/process/ChildProcessSpawner";import*as c from"effect/Array";import*as l from"effect/unstable/cli/Command";import*as u from"effect/unstable/cli/Flag";import*as d from"effect/Context";import*as ee from"effect/unstable/process/ChildProcess";import{stripVTControlCharacters as f}from"node:util";import*as p from"effect/Data";import{pipe as m}from"effect/Function";import*as h from"effect/Option";import*as g from"effect/Predicate";import*as _ from"effect/String";import{parse as te,printParseErrorCode as v}from"jsonc-parser";import*as y from"effect/FileSystem";import*as b from"effect/Path";import
|
|
2
|
-
`)}`}function
|
|
3
|
-
`)}var
|
|
4
|
-
`)}},
|
|
5
|
-
`,`\n${n}`):i}const
|
|
6
|
-
`):` ${e}: ${
|
|
1
|
+
import*as e from"@effect/platform-node/NodeRuntime";import*as t from"@effect/platform-node/NodeServices";import*as n from"effect/Effect";import*as r from"effect/Exit";import*as i from"effect/Layer";import*as a from"effect/Runtime";import*as o from"effect/Stdio";import*as s from"effect/unstable/process/ChildProcessSpawner";import*as c from"effect/Array";import*as l from"effect/unstable/cli/Command";import*as u from"effect/unstable/cli/Flag";import*as d from"effect/Context";import*as ee from"effect/unstable/process/ChildProcess";import{stripVTControlCharacters as f}from"node:util";import*as p from"effect/Data";import{pipe as m}from"effect/Function";import*as h from"effect/Option";import*as g from"effect/Predicate";import*as _ from"effect/String";import{parse as te,printParseErrorCode as v}from"jsonc-parser";import*as y from"effect/FileSystem";import*as b from"effect/Path";import ne from"node:process";import*as re from"effect/Record";import*as x from"effect/Result";import{defu as ie}from"defu";import*as S from"effect/unstable/cli/Argument";import{print as ae}from"esrap";import oe from"esrap/languages/ts";import{parseSync as se}from"oxc-parser";import{addDevDependency as ce,detectPackageManager as le,runScriptCommand as ue}from"nypm";import*as C from"effect/Schema";import*as w from"@clack/prompts";import*as de from"effect/Console";import*as fe from"effect/Terminal";function pe(e){return g.isError(e)?m(f(e.message),_.split(/\r\n|[\r\n]/),c.map(e=>_.trimEnd(e)),c.filter(e=>_.isNonEmpty(e))):[]}function T(e){return m(pe(e),c.head,h.map(e=>{let t=_.trim(e);return/[.!?]$/.test(t)?` Cause: ${t}`:` Cause: ${t}.`}),h.getOrElse(()=>``))}function me(e){let t=pe(e);if(!c.isReadonlyArrayNonEmpty(t))return``;let n=c.takeRight(t,20);return`\n${(n.length<t.length?[`…`,...n]:n).join(`
|
|
2
|
+
`)}`}function he(e=[]){return e.length===0?`- Unknown JSON/JSONC parsing error`:e.slice(0,3).map(e=>`- ${v(e.error)} (offset: ${e.offset})`).join(`
|
|
3
|
+
`)}var ge=class extends p.TaggedError(`CliNotFound`){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}},E=class extends p.TaggedError(`CommandFailed`){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}},_e=class extends p.TaggedError(`FailedToCreateDirectory`){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:`the target directory`}.${T(this.cause)}`}},ve=class extends p.TaggedError(`FailedToInstallDependency`){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(`, `)}`:``}.${me(this.cause)}`}},ye=class extends p.TaggedError(`FailedToInstallExtension`){get message(){let e=this.extension?`\`${this.extension}\``:`the target extension`;return g.isNumber(this.cause)?`Failed to install ${e}. The \`code\` CLI exited with code ${this.cause}.`:`Failed to install ${e}.${T(this.cause)}`}},be=class extends p.TaggedError(`FailedToMergeConfig`){get message(){return`Failed to merge configuration.${T(this.cause)}`}},xe=class extends p.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:`,he(this.errors)].join(`
|
|
4
|
+
`)}},Se=class extends p.TaggedError(`FailedToReadFile`){get message(){return`Failed to read ${this.path?`\`${this.path}\``:`the target file`}.${T(this.cause)}`}},Ce=class extends p.TaggedError(`FailedToDeleteFile`){get message(){return`Failed to delete ${this.path?`\`${this.path}\``:`the target file`}.${T(this.cause)}`}},we=class extends p.TaggedError(`FailedToWriteFile`){get message(){return`Failed to write ${this.path?`\`${this.path}\``:`the target file`}.${T(this.cause)}`}},Te=class extends p.TaggedError(`FileNotFound`){get message(){return this.path?`File not found: \`${this.path}\`.`:`File not found.`}},Ee=class extends p.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: {}).`}},D=class extends p.TaggedError(`InvalidInitOptions`){get message(){return`Invalid init options. ${this.reason}`}},De=class extends p.TaggedError(`UnsupportedConfigState`){get message(){return`Unsupported config state in ${this.path?`\`${this.path}\``:`the target config file`}.${this.reason?` ${this.reason}`:``}`}},Oe=class extends p.TaggedError(`NoPackageManager`){get message(){return`No package manager detected. Please run this command from a project with a lockfile.${T(this.cause)}`}};p.TaggedError(`MissingPackageVersion`);var O=class extends p.TaggedError(`MigrationValidationFailed`){get message(){return`Migration \`${this.migrationId}\` validation failed. ${this.reason}`}},ke=class extends p.TaggedError(`OperationCancelled`){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:``}`}},Ae=class extends p.TaggedError(`PassthroughNotSupported`){get message(){return`Command \`adamantite ${this.command}\` does not invoke a single underlying CLI and cannot accept passthrough arguments.`}},je=class extends p.TaggedError(`VscodeCliNotFound`){get message(){return`VS Code CLI (\`code\`) not found. Please install it to manage extensions.${T(this.cause)}`}},k=class extends d.Service()(`CommandRunner`){static layer=i.succeed(this)({run:n.fn(`CommandRunner.run`)(function*({args:e,command:t,cwd:r,stderr:i=`inherit`,stdin:a=`ignore`,stdout:o=`inherit`}){return yield*n.scoped(n.gen(function*(){return yield*(yield*ee.make(t,e,{cwd:r,stderr:i,stdin:a,stdout:o})).exitCode})).pipe(n.mapError(e=>e.reason._tag===`NotFound`?new ge({command:t}):e))})})};const A=d.Reference(`adamantite/ForwardedArguments`,{defaultValue:()=>[]});function j(e){return e}const Me=e=>y.FileSystem.pipe(n.flatMap(t=>t.makeDirectory(e,{recursive:!0})),n.mapError(t=>new _e({cause:t,path:e}))),M=e=>y.FileSystem.pipe(n.flatMap(t=>t.readFileString(e)),n.mapError(t=>new Se({cause:t,path:e}))),Ne=e=>y.FileSystem.pipe(n.flatMap(t=>t.readFileString(e)),n.map(e=>m(e,h.some)),n.catch(t=>t.reason._tag===`NotFound`?n.succeedNone:n.fail(new Se({cause:t,path:e})))),N=(e,t)=>y.FileSystem.pipe(n.flatMap(n=>n.writeFileString(e,t)),n.mapError(t=>new we({cause:t,path:e}))),P=(e,t)=>N(e,`${JSON.stringify(t,null,2)}\n`),Pe=e=>y.FileSystem.pipe(n.flatMap(t=>t.remove(e)),n.mapError(t=>new Ce({cause:t,path:e}))),F=(e,t)=>n.suspend(()=>{let r=[],i=te(e,r,{allowTrailingComma:!0});return r.length>0?n.fail(new xe({errors:r,path:t})):n.succeed(i)}),I=e=>g.isObject(e),Fe=e=>Array.isArray(e);function Ie(e,t={}){let{continuationIndent:n,indentation:r=2}=t,i=JSON.stringify(e,null,r).replaceAll(/"([A-Za-z_$][\w$]*)":/g,`$1:`);return n?i.replaceAll(`
|
|
5
|
+
`,`\n${n}`):i}const Le=(e,t)=>n.try({catch:e=>new be({cause:e}),try:()=>ie(e,t)}),Re=/^workspace:/,ze=/^[\^~]/;function Be(e){return e.trim().replace(Re,``).replace(ze,``)}const L=(e=ne.cwd())=>n.gen(function*(){let t=(yield*b.Path).join(e,`package.json`),n=yield*M(t);return yield*F(n,t)}),Ve=(e,t)=>n.gen(function*(){let n=yield*b.Path;yield*P(n.join(e,`package.json`),t)});function He(e){return e===`bun`||e===`deno`||e===`npm`||e===`pnpm`||e===`yarn`}const R={analyze:`adamantite analyze`,check:`adamantite check`,"check:monorepo":`adamantite monorepo`,fix:`adamantite fix`,"fix:monorepo":`adamantite monorepo --fix`,format:`adamantite format`};function Ue(e){let t=e.scripts??{};return m(re.keys(R),c.filter(e=>t[e]===R[e]))}function We(e,t){let n=e.scripts??{};return c.filterMap(t,e=>{let t=n[e];return t!==void 0&&t!==``&&t!==R[e]?x.succeed({command:t,script:e}):x.failVoid})}function Ge(e){return e.endsWith(`.jsonc`)?`jsonc`:e.endsWith(`.json`)?`json`:`ts`}function Ke(e,t){return c.findFirst(e.legacyConfigs,e=>Ge(e)===t)}function qe(e){let t=Ke(e,`json`),n=Ke(e,`jsonc`);return m(h.zipWith(t,n,e=>`${e}(c)`),h.orElse(()=>n),h.orElse(()=>t),h.getOrElse(()=>``))}function Je(e,t,n,r){return n===null||r.length===0?[]:n.format===`ts`?[`Found both \`${t.config}\` and \`${qe(t)}\`. Adamantite will use \`${t.config}\`.`]:m(h.zipWith(Ke(t,`json`),Ke(t,`jsonc`),(t,n)=>`Found both \`${t}\` and \`${n}\`. Multiple legacy ${e} configs exist; Adamantite will treat \`${n}\` as the source of truth when migration is needed.`),h.toArray)}const Ye=n.fn(`detectToolingConfig`)(function*(e,t,r){let i=yield*y.FileSystem,a=yield*b.Path,o=[r.config,...r.legacyConfigs].map(t=>({file:t,format:Ge(t),path:a.join(e,t)})),s=yield*n.forEach(o,e=>i.exists(e.path),{concurrency:`unbounded`}),l=o.filter((e,t)=>s[t]),u=m(c.findFirst(l,e=>e.format===`ts`),h.orElse(()=>c.findFirst(l,e=>e.format===`jsonc`)),h.orElse(()=>c.findFirst(l,e=>e.format===`json`)),h.getOrNull),d=l.filter(e=>e!==u&&e.format!==`ts`);return{active:u,legacy:d,warnings:Je(t,r,u,d)}});function Xe(e,t,n){let r=e.devDependencies?.[t.name]??e.dependencies?.[t.name];return r?Be(r)===t.version?[]:[{currentVersion:r,description:`Update \`${t.name}\` from \`${r}\` to \`${t.version}\`.`,package:t.name,targetVersion:t.version,type:`update_package`}]:[{description:`Install \`${t.name}@${t.version}\` for ${n}.`,package:t.name,targetVersion:t.version,type:`install_package`}]}function Ze(e,t){return e.active===null?[{description:`Create \`${t.configFile}\` for \`${t.toolName}\`.`,path:t.configFile,type:`create_config`}]:e.active.format===`ts`?[]:[{description:`Migrate legacy \`${e.active.file}\` to \`${t.configFile}\`.`,migrationId:t.migrationId,type:`run_migration`}]}function Qe(e,t){let n=Ue(e);return t.some(e=>n.includes(e))}function $e(e){return j({assess:(t,r)=>n.sync(()=>Qe(r,e.scripts)?{actions:Xe(r,e,e.purpose),applicable:!0,warnings:[]}:{applicable:!1,warnings:[]}),kind:`tooling`,name:e.name,version:e.version})}function et(e){let t=[{path:e.configFiles.config,type:`config`},...e.configFiles.legacyConfigs.map(e=>({path:e,type:`legacy_config`}))],r=t=>Ye(t,e.name,e.configFiles);return j({assess:(t,i)=>n.gen(function*(){if(!Qe(i,e.scripts))return{applicable:!1,warnings:[]};let n=yield*r(t);return{actions:[...Xe(i,e,e.purpose),...Ze(n,{configFile:e.configFiles.config,migrationId:e.migrationId,toolName:e.name})],applicable:!0,warnings:n.warnings}}),config:e.configFiles.config,create:t=>n.gen(function*(){let n=yield*b.Path;yield*N(n.join(t,e.configFiles.config),e.configContent())}),detect:r,files:t,kind:`tooling`,name:e.name,version:e.version})}function tt(e={}){let t=Object.entries(e).map(([e,t])=>e===`rules`&&I(t)?[` rules: {`,` ...analyze.rules,`,...Object.entries(t).map(([e,t])=>` ${e}: ${Ie(t,{continuationIndent:` `,indentation:` `})},`),` },`].join(`
|
|
6
|
+
`):` ${e}: ${Ie(t)},`);return t.length===0?[`import type { KnipConfig } from "knip"`,`import analyze from "adamantite/analyze"`,``,`const config: KnipConfig = analyze`,``,`export default config`,``].join(`
|
|
7
7
|
`):[`import type { KnipConfig } from "knip"`,`import analyze from "adamantite/analyze"`,``,`const config: KnipConfig = {`,` ...analyze,`,...t,`}`,``,`export default config`,``].join(`
|
|
8
|
-
`)}var z
|
|
8
|
+
`)}var z=et({configContent:()=>tt(),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`});const nt=u.boolean(`fix`).pipe(u.withDescription(`Automatically fix issues`)),rt=u.boolean(`strict`).pipe(u.withDescription(`Enable strict mode`));var it=l.make(`analyze`,{fix:nt,strict:rt}).pipe(l.withDescription(`Find unused dependencies, exports, and files using knip`),l.withExamples([{command:`adamantite analyze -- --directory packages/app`,description:`Run knip from a specific directory`}]),l.withHandler(({fix:e,strict:t})=>n.gen(function*(){let n=yield*A,r=yield*k,i=[];e&&i.push(`--fix`,`--allow-remove-files`),t&&i.push(`--production`,`--strict`),i.push(...n);let a=yield*r.run({args:i,command:z.name});a!==s.ExitCode(0)&&(yield*new E({command:z.name,exitCode:a}))})));const at=`**/node_modules,**/.yarn,**/.git,**/dist,**/build,**/out,**/.next,**/.open-next,**/.nuxt,**/.output,**/.svelte-kit,**/.vitepress/cache,**/.turbo,**/.vercel,**/.netlify,**/.wrangler,**/.docusaurus,**/.cache,**/.parcel-cache,**/.vite,**/.astro,**/_astro,**/storybook-static,**/_generated,**/__generated__,**/*.gen.*,**/*.generated.*,**/generated,**/codegen,**/graphql-types.*,**/*.d.ts.map,**/coverage,**/.nyc_output,**/.expo,**/.expo-shared,**/next-env.d.ts,**/worker-configuration.d.ts`.split(`,`),ot=[`respectEslintDisableDirectives`,`typeAware`,`typeCheck`],st="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",ct="`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 ut(e=[]){return e.includes(`core`)?e:[`core`,...e]}function dt(e){return e.replaceAll(/-([a-z])/g,(e,t)=>t.toUpperCase())}function ft(e){let t=(c.isArray(e)?e:[]).filter(e=>g.isString(e)).filter(e=>!at.includes(e));return t.length===0?`core.ignorePatterns`:`[...core.ignorePatterns, ${t.map(e=>JSON.stringify(e)).join(`, `)}]`}function pt(e,t,n=[]){let{ignorePatterns:r,options:i,...a}=e,o=[`import { defineConfig } from "oxlint"`,...t.map(e=>`import ${dt(e)} from "${e===`core`?`adamantite/lint`:`adamantite/lint/${e}`}"`)],s=[...t.map(e=>dt(e)),...n.map(e=>JSON.stringify(e))],c=JSON.stringify(g.isObject(i)?{...i,respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0}:{respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0},null,2),l=Object.entries(a).map(([e,t])=>[e,JSON.stringify(t,null,2)]),u=`[${s.join(`, `)}]`,d=[[`options`,c],[`ignorePatterns`,ft(r)],...l,[`extends`,u]].map(([e,t])=>` ${e}: ${t},`).join(`
|
|
9
9
|
`);return[...o,``,`export default defineConfig({`,d,`})`,``].join(`
|
|
10
|
-
`)}const
|
|
11
|
-
`)?t:`${t}\n`}function
|
|
10
|
+
`)}const mt=h.liftThrowable(e=>se(`oxlint.config.ts`,e,{astType:`ts`,lang:`ts`,sourceType:`module`}));function ht(e){return mt(e).pipe(h.flatMap(e=>e.errors.length===0?h.fromNullishOr(e.program):h.none()))}function gt(e){let{code:t}=ae(e,oe({quotes:`double`}));return t.endsWith(`
|
|
11
|
+
`)?t:`${t}\n`}function _t(e){return e.type===`Identifier`?m(e.name,h.some):e.type===`Literal`&&g.isString(e.value)?m(e.value,h.some):h.none()}function vt(e){return e.type===`ObjectExpression`?m(e,h.some):e.type!==`CallExpression`||e.callee.type!==`Identifier`||e.callee.name!==`defineConfig`?h.none():m(e.arguments.length===1?c.head(e.arguments):h.none(),h.filter(e=>e.type===`ObjectExpression`))}function yt(e){return m(e.body,c.filter(e=>e.type===`ExportDefaultDeclaration`),e=>e.length===1?c.head(e):h.none(),h.flatMap(e=>vt(e.declaration)))}function bt(e,t){let n=null;for(let r of e.properties){if(r.type===`SpreadElement`||r.computed)return{status:`manual`};let e=h.contains(_t(r.key),t);if(r.method||r.kind!==`init`){if(e)return{status:`manual`};continue}if(e){if(n)return{status:`manual`};n=r}}return n?{property:n,status:`found`}:{status:`missing`}}function xt(e){return{computed:!1,end:0,key:{end:0,name:e,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 St(){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:ot.map(e=>xt(e)),start:0,type:`ObjectExpression`}}}function Ct(e,t){let n=[],r=!1;for(let e of ot){let i=bt(t,e);if(i.status===`manual`)return{kind:`manual`,reason:lt};if(i.status===`missing`){n.push(e);continue}let a=i.property.value;if(a.type!==`Literal`||!g.isBoolean(a.value))return{kind:`manual`,reason:lt};a.value||(a.raw=`true`,a.value=!0,r=!0)}return n.length>0&&(t.properties.unshift(...n.map(e=>xt(e))),r=!0),r?{kind:`patchable`,updatedContent:gt(e)}:{kind:`configured`}}function wt(e){let t=ht(e);if(h.isNone(t))return{kind:`manual`,reason:st};let n=yt(t.value);if(h.isNone(n))return{kind:`manual`,reason:st};let r=bt(n.value,`options`);return r.status===`manual`?{kind:`manual`,reason:ct}:r.status===`missing`?(n.value.properties.unshift(St()),{kind:`patchable`,updatedContent:gt(t.value)}):r.property.value.type===`ObjectExpression`?Ct(t.value,r.property.value):{kind:`manual`,reason:ct}}const B=`oxlint.config.ts`,Tt=`.oxlintrc.json`,Et=[{path:B,type:`config`},{path:Tt,type:`legacy_config`}],Dt={config:B,legacyConfigs:[Tt]},Ot=`1.79.0`,kt=e=>Ye(e,`oxlint`,Dt);var V=j({assess:(e,t)=>n.gen(function*(){let n=Ue(t);if(!n.includes(`check`)&&!n.includes(`fix`))return{applicable:!1,warnings:[]};let r=yield*kt(e),i=[...Xe(t,{name:`oxlint`,version:Ot},`the managed lint scripts`),...Ze(r,{configFile:B,migrationId:`legacy-oxlint-json`,toolName:`oxlint`})],a=r.active;if(a?.format===`ts`){let e=wt(yield*M(a.path));e.kind===`patchable`&&i.push({description:"Update `oxlint.config.ts` with Adamantite's required options.",path:B,type:`update_config`}),e.kind===`manual`&&i.push({description:"Manually update `oxlint.config.ts` with Adamantite's required options; Adamantite cannot patch the current file shape safely.",path:B,type:`manual_fix`})}return{actions:i,applicable:!0,warnings:r.warnings}}),config:B,create:(e,t=[])=>n.gen(function*(){let n=yield*b.Path,r=pt({},ut(t));yield*N(n.join(e,B),r)}),detect:kt,files:Et,kind:`tooling`,name:`oxlint`,update:e=>n.gen(function*(){let t=yield*y.FileSystem,n=(yield*b.Path).join(e,B);if(!(yield*t.exists(n)))return yield*new Te({path:B});let r=wt(yield*M(n));if(r.kind!==`configured`){if(r.kind===`manual`)return yield*new De({path:B,reason:r.reason});yield*N(n,r.updatedContent)}}),version:Ot});const At=S.file(`files`,{mustExist:!0}).pipe(S.withDescription(`Specific files to lint (optional)`),S.variadic());var jt=l.make(`check`,{files:At}).pipe(l.withDescription(`Find issues and type errors in code using oxlint`),l.withHandler(({files:e})=>n.gen(function*(){let t=yield*A,n=yield*(yield*k).run({args:[...e,...t],command:V.name});n!==s.ExitCode(0)&&(yield*new E({command:V.name,exitCode:n}))})));const Mt=new Set([`sortImports`,`sortPackageJson`,`sortTailwindcss`]);function Nt(e){let t=e.split(`
|
|
12
12
|
`);return t.length===1?e.slice(1,-1).trim():t.slice(1,-1).map(e=>` ${e.trimStart()}`).join(`
|
|
13
|
-
`)}function
|
|
14
|
-
`)}function
|
|
13
|
+
`)}function Pt(e,t){let n=Nt(Ie(t));return[` ${e}: {`,` ...format.${e},`,...n===``?[]:[n],` },`].join(`
|
|
14
|
+
`)}function Ft(e={}){let t=Object.entries(e).map(([e,t])=>Mt.has(e)&&I(t)?Pt(e,t):` ${e}: ${Ie(t,{continuationIndent:` `})},`);return t.length===0?[`import { defineConfig } from "oxfmt"`,`import format from "adamantite/format"`,``,`export default defineConfig(format)`,``].join(`
|
|
15
15
|
`):[`import { defineConfig } from "oxfmt"`,`import format from "adamantite/format"`,``,`export default defineConfig({`,` ...format,`,...t,`})`,``].join(`
|
|
16
|
-
`)}var H
|
|
17
|
-
`).map(e=>e.split(`#`)[0]?.trim()??``).some(e=>/^node(?:js)?\s+\S/.test(e))}function
|
|
16
|
+
`)}var H=et({configContent:()=>Ft(),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`}),U=$e({name:`sherif`,purpose:`the managed monorepo scripts`,scripts:[`check:monorepo`,`fix:monorepo`],version:`1.13.0`}),W=$e({name:`oxlint-tsgolint`,purpose:`the managed lint scripts`,scripts:[`check`,`fix`],version:`7.0.2001`});function It(e){return e}const Lt=n.fn(`runMigration`)(function*(e,t){let r=yield*b.Path,i=e.files??[],a=yield*n.forEach(i,e=>{let i=r.join(t.cwd,e);return Ne(i).pipe(n.map(e=>[i,e]))},{concurrency:`unbounded`});return yield*e.migrate(t).pipe(n.tap(()=>e.validate?.(t)??n.void),n.onError(()=>n.forEach(([e,t])=>h.match(t,{onNone:()=>Pe(e).pipe(n.ignore),onSome:t=>N(e,t).pipe(n.ignore)}))(a)))}),Rt=[{name:`check`,script:`check`},{args:[`--check`],name:`format`,script:`format`},{name:`monorepo`,script:`check:monorepo`},{name:`analyze`,script:`analyze`}];function zt(e,t){let n=[];for(let r of Rt)t.includes(r.script)&&n.push({command:ue(e,r.script,{args:r.args}),name:r.name});return n}function Bt(e){return Rt.some(t=>e.includes(t.script))}function Vt(e){return{_tag:`File`,path:e}}function Ht(e){return{_tag:`Version`,value:e}}const Ut=[`.node-version`,`.nvmrc`],Wt=C.Struct({volta:C.Struct({node:C.NonEmptyString})}),Gt=C.Struct({engines:C.Struct({node:C.NonEmptyString})}),Kt=C.Struct({name:C.NonEmptyString,version:C.NonEmptyString});function qt(e){return e.split(`
|
|
17
|
+
`).map(e=>e.split(`#`)[0]?.trim()??``).some(e=>/^node(?:js)?\s+\S/.test(e))}function Jt(e){return C.is(Kt)(e)&&e.name.toLowerCase()===`node`}function Yt(e){if(C.is(Wt)(e))return!0;if(g.isObject(e)&&g.isObject(e.devEngines)){let t=e.devEngines.runtime;if((Array.isArray(t)?t:[t]).some(e=>Jt(e)))return!0}return C.is(Gt)(e)}var Xt=class extends d.Service()(`NodeVersionResolver`){static layer=i.effect(this,n.gen(function*(){let e=yield*y.FileSystem,t=yield*b.Path,r=(r,i)=>Ne(t.join(r,i)).pipe(n.provideService(y.FileSystem,e));return{resolve:n.fn(`NodeVersionResolver.resolve`)(function*(e){for(let t of Ut){let n=yield*r(e,t);if(h.exists(n,e=>_.isNonEmpty(e.trim())))return Vt(t)}let n=yield*r(e,`.tool-versions`);if(h.exists(n,e=>qt(e)))return Vt(`.tool-versions`);let i=yield*r(e,`package.json`);return h.isSome(i)&&Yt(yield*F(i.value,t.join(e,`package.json`)))?Vt(`package.json`):Ht(`lts/*`)})}}))};function Zt(e){return` - name: Setup Node.js
|
|
18
18
|
uses: actions/setup-node@v7
|
|
19
19
|
with:
|
|
20
|
-
${e._tag===`File`?`node-version-file: "${e.path}"`:`node-version: "${e.value}"`}`}function
|
|
20
|
+
${e._tag===`File`?`node-version-file: "${e.path}"`:`node-version: "${e.value}"`}`}function Qt(e){return{bun:`${Zt(e)}
|
|
21
21
|
|
|
22
22
|
- name: Setup Bun
|
|
23
23
|
uses: oven-sh/setup-bun@v2
|
|
@@ -37,22 +37,22 @@ import*as e from"@effect/platform-node/NodeRuntime";import*as t from"@effect/pla
|
|
|
37
37
|
uses: denoland/setup-deno@v2
|
|
38
38
|
|
|
39
39
|
- name: Install dependencies
|
|
40
|
-
run: deno install --frozen`,npm:`${
|
|
40
|
+
run: deno install --frozen`,npm:`${Zt(e)}
|
|
41
41
|
cache: "npm"
|
|
42
42
|
|
|
43
43
|
- name: Install dependencies
|
|
44
44
|
run: npm ci`,pnpm:` - name: Setup pnpm
|
|
45
45
|
uses: pnpm/action-setup@v4
|
|
46
46
|
|
|
47
|
-
${
|
|
47
|
+
${Zt(e)}
|
|
48
48
|
cache: "pnpm"
|
|
49
49
|
|
|
50
50
|
- name: Install dependencies
|
|
51
|
-
run: pnpm install --frozen-lockfile`,yarn:`${
|
|
51
|
+
run: pnpm install --frozen-lockfile`,yarn:`${Zt(e)}
|
|
52
52
|
cache: "yarn"
|
|
53
53
|
|
|
54
54
|
- name: Install dependencies
|
|
55
|
-
run: yarn install --frozen-lockfile`}}function
|
|
55
|
+
run: yarn install --frozen-lockfile`}}function $t({packageManager:e,scripts:t},n){let r=zt(e,t);return r.length===0?null:`${`name: adamantite
|
|
56
56
|
|
|
57
57
|
on:
|
|
58
58
|
push:
|
|
@@ -84,17 +84,17 @@ ${r.map(e=>` - name: ${e.name}\n command: ${e.command}`).joi
|
|
|
84
84
|
- name: Checkout
|
|
85
85
|
uses: actions/checkout@v7
|
|
86
86
|
|
|
87
|
-
${
|
|
87
|
+
${Qt(n)[e]}
|
|
88
88
|
|
|
89
89
|
- name: Run \${{ matrix.name }}
|
|
90
|
-
run: \${{ matrix.command }}`}\n`}const $t=[{path:`.github/workflows/adamantite.yml`,type:`ci`}],en=(e,t)=>n.gen(function*(){let n=yield*b.Path,r=yield*Yt,i=n.join(e,$t[0].path),a=Qt(t,yield*r.resolve(e));a&&(yield*P(i,a))});var G=M({create:(e,t)=>n.gen(function*(){let n=yield*b.Path;yield*je(n.dirname(n.join(e,$t[0].path))),yield*en(e,t)}),detect:e=>n.gen(function*(){let t=yield*y.FileSystem,n=yield*b.Path;return yield*t.exists(n.join(e,$t[0].path))}),files:$t,kind:`ci`,name:`github`,update:en}),K=class extends d.Service()(`DependencyInstaller`){static layer=i.succeed(this)({addDevDependencies:n.fn(`DependencyInstaller.addDevDependencies`)((e,t,r)=>n.tryPromise({catch:t=>new _e({cause:t,packages:e}),try:()=>se(e,{...r,cwd:t})}).pipe(n.asVoid)),detectPackageManager:n.fn(`DependencyInstaller.detectPackageManager`)(e=>n.tryPromise({catch:e=>new De({cause:e}),try:()=>ce(e)}).pipe(n.map(e=>e??null)))})};const tn=/^\s*node-version:\s*"?\d/m;function nn(){return G.files[0].path}const rn=e=>n.gen(function*(){let t=yield*b.Path;return yield*Me(t.join(e,nn()))}),an=e=>n.gen(function*(){let t=yield*K,n=He(yield*L(e));if(!zt(n))return{reason:`scripts`,supported:!1};let r=yield*t.detectPackageManager(e);return r?Ve(r.name)?{packageManager:r.name,scripts:n,supported:!0}:{packageManagerName:r.name,reason:`unsupported-package-manager`,supported:!1}:{reason:`no-package-manager`,supported:!1}});var on=Ft({check:e=>n.gen(function*(){let t=yield*rn(e.cwd);if(!h.exists(t,e=>tn.test(e)))return{status:`not-applicable`,warnings:[]};let n=yield*an(e.cwd);return n.supported?{status:`needed`,summary:`Replacing the hard-coded Node.js version in the GitHub Actions workflow with the project's Node.js version declaration.`,warnings:[]}:{status:`not-applicable`,warnings:[n.reason===`scripts`?`No CI-compatible managed scripts were found, so the GitHub Actions workflow was not updated.`:n.reason===`no-package-manager`?`Could not detect a package manager, so the GitHub Actions workflow was not updated.`:`\`${n.packageManagerName}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow was not updated.`]}}),files:[nn()],id:`hardcoded-node-version`,migrate:e=>n.gen(function*(){let t=yield*an(e.cwd);return t.supported?(yield*G.update(e.cwd,{packageManager:t.packageManager,scripts:t.scripts}),{warnings:[]}):yield*n.die(Error(`check() guaranteed workflow regeneration is supported`))}),tags:[`update`],title:`Hard-coded workflow Node.js version`,validate:e=>n.gen(function*(){let t=yield*rn(e.cwd);if(h.exists(t,e=>tn.test(e)))return yield*new k({migrationId:`hardcoded-node-version`,reason:`The GitHub Actions workflow still contains a hard-coded Node.js version.`})})});function sn(e,t){return n.gen(function*(){let r=yield*b.Path,i=yield*t.integration.detect(e);if(i.active===null||i.active.format===`ts`)return yield*n.die(Error(`check() guaranteed a legacy ${t.displayName} config exists`));let a=i.active.path,o=r.join(e,t.integration.config),s=yield*N(a),c=yield*I(s,a);if(!Pe(c))return yield*new Te({path:a});let{$schema:l,...u}=c;yield*P(o,t.serialize(u));for(let e of[i.active,...i.legacy])yield*Ne(e.path);return{warnings:[]}})}function cn(e){return Ft({check:t=>n.gen(function*(){let n=yield*e.integration.detect(t.cwd);return n.active===null||n.active.format===`ts`?{status:`not-applicable`,warnings:n.warnings}:{status:`needed`,summary:`Migrating legacy \`${n.active.file}\` configuration to \`${e.integration.config}\`.`,warnings:n.warnings}}),files:e.integration.files.map(e=>e.path),id:e.id,migrate:t=>sn(t.cwd,e),tags:[`update`],title:e.title,validate:t=>n.gen(function*(){if((yield*e.integration.detect(t.cwd)).active?.format!==`ts`)return yield*new k({migrationId:e.id,reason:`\`${e.integration.config}\` is not the active ${e.displayName} config.`})})})}var ln=cn({displayName:`Knip`,id:`legacy-knip-json`,integration:z,serialize:et,title:`Legacy Knip JSON config`}),un=cn({displayName:`Oxfmt`,id:`legacy-oxfmt-json`,integration:H,serialize:Pt,title:`Legacy oxfmt JSON config`});const dn=/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/,fn=/^adamantite\/lint(?:\/([a-z0-9-]+))?$/;function pn(e){let t=Array.isArray(e.extends)?e.extends.filter(e=>typeof e==`string`):g.isString(e.extends)?[e.extends]:[],n=new Set(lt()),r=new Set;for(let e of t){let t=e.match(dn),i=e.match(fn),a=t?.[1]??(i?i[1]??`core`:null);a?n.add(a):r.add(e)}let{extends:i,...a}=e;return ft(a,[...n],[...r])}var mn=cn({displayName:`Oxlint`,id:`legacy-oxlint-json`,integration:V,serialize:pn,title:`Legacy oxlint JSON config`});const hn=(e=x.cwd())=>n.gen(function*(){let t=yield*y.FileSystem,n=yield*b.Path;return(yield*t.exists(n.join(e,`pnpm-workspace.yaml`)))?!0:(yield*L(e)).workspaces!==void 0}),q=[{path:`tsconfig.json`,type:`config`}],J=`adamantite/typescript`,gn={extends:J},_n=["Skipping `tsconfig.json` setup: a root config in a monorepo makes TypeScript treat all packages as one project.",`To use the TypeScript preset, add \`"extends": "${J}"\` to each package's \`tsconfig.json\` or to a shared base config.`];function vn(e){return g.isString(e)?e===J?e:[e,J]:c.isArray(e)?e.includes(J)?e:[...e,J]:J}var Y=M({config:q[0].path,create:e=>n.gen(function*(){let t=yield*b.Path;yield*F(t.join(e,q[0].path),gn)}),detect:e=>n.gen(function*(){let t=yield*y.FileSystem,n=yield*b.Path;return yield*t.exists(n.join(e,q[0].path))}),files:q,kind:`workspace`,name:`tsconfig`,update:e=>n.gen(function*(){let t=(yield*b.Path).join(e,q[0].path),n=yield*N(t),r=yield*I(n,t);if(!g.isObject(r))return yield*new Te({path:t});let i={...yield*Ie(gn,r),extends:vn(`extends`in r?r.extends:void 0)};yield*F(t,i)})});const yn=`adamantite typecheck`;function bn(){return V.files[1].path}function xn(){return G.files[0].path}function Sn(e){let t={...e.scripts};return t.typecheck===yn?(delete t.typecheck,t.check??=R.check,{migrated:!0,packageJson:{...e,scripts:t}}):{migrated:!1,packageJson:e}}const Cn=[un,ln,mn,Ft({check:e=>n.gen(function*(){let{migrated:t}=Sn(yield*L(e.cwd));return t?{status:`needed`,summary:"Migrating `typecheck` to `check` so oxlint handles linting and type diagnostics together.",warnings:[]}:{status:`not-applicable`,warnings:[]}}),files:[`package.json`,V.config,bn(),Y.config,xn()],id:`legacy-typecheck-script`,migrate:e=>n.gen(function*(){let t=yield*K,r=[],i=Sn(yield*L(e.cwd));if(!i.migrated)return yield*n.die(Error(`check() guaranteed the legacy typecheck script exists`));yield*Be(e.cwd,i.packageJson);let a=yield*V.detect(e.cwd);a.active===null?yield*V.create(e.cwd):a.active.format===`ts`&&(yield*V.update(e.cwd)),(yield*hn(e.cwd))?r.push(..._n):yield*(yield*Y.detect(e.cwd))?Y.update(e.cwd):Y.create(e.cwd);let o=yield*G.detect(e.cwd),s=He(i.packageJson);if(o&&zt(s)){let n=yield*t.detectPackageManager(e.cwd);n&&Ve(n.name)?yield*G.update(e.cwd,{packageManager:n.name,scripts:s}):n?r.push(`\`${n.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow was not updated.`):r.push(`Could not detect a package manager, so the GitHub Actions workflow was not updated.`)}return{warnings:r}}),tags:[`update`],title:`Legacy typecheck script`,validate:e=>n.gen(function*(){if((yield*L(e.cwd)).scripts?.typecheck===yn)return yield*new k({migrationId:`legacy-typecheck-script`,reason:"The legacy `typecheck` script is still present in `package.json`."});if((yield*V.detect(e.cwd)).active?.format!==`ts`)return yield*new k({migrationId:`legacy-typecheck-script`,reason:`\`${V.config}\` is not the active oxlint config.`});if(!(yield*hn(e.cwd))&&!(yield*Y.detect(e.cwd)))return yield*new k({migrationId:`legacy-typecheck-script`,reason:`\`${Y.config}\` is missing after the migration.`})})}),on],wn=Object.fromEntries(Cn.map(e=>[e.id,e])),Tn=n.fn(`collectApplicableAssessments`)(function*(e,t,r){let i=r??(yield*L(t));return yield*n.forEach(e,e=>e.assess(t,i).pipe(n.map(t=>t.applicable?h.some({assessment:t,integration:e}):h.none())),{concurrency:`unbounded`}).pipe(n.map(e=>c.getSomes(e)))});function En(e,t,n){return Tn(e,t,n)}var X=class extends d.Service()(`Prompter`){static layerWithSpinner(e){return i.succeed(this)({cancel:e=>n.sync(()=>{T.cancel(e)}),confirm:e=>n.promise(()=>T.confirm(e)).pipe(n.filterOrFail(e=>!T.isCancel(e),()=>new Oe({}))),intro:e=>n.sync(()=>{T.intro(e)}),log:{error:e=>n.sync(()=>{T.log.error(e)}),info:e=>n.sync(()=>{T.log.info(e)}),success:e=>n.sync(()=>{T.log.success(e)}),warning:e=>n.sync(()=>{T.log.warning(e)})},multiselect:e=>n.promise(()=>T.multiselect(e)).pipe(n.filterOrFail(e=>!T.isCancel(e),()=>new Oe({}))),outro:e=>n.sync(()=>{T.outro(e)}),withSpinner:(t,i)=>n.acquireUseRelease(n.sync(()=>{let t=e();return t.start(i.start),t}),e=>t({message:t=>n.sync(()=>{e.message(t)})}),(e,t)=>n.sync(()=>{e.stop(r.match(t,{onFailure:()=>i.failure,onSuccess:e=>g.isFunction(i.success)?i.success(e):i.success}))}))})}static layer=this.layerWithSpinner(T.spinner)};const Dn=' .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 ',On=()=>n.gen(function*(){let e=yield*(yield*de.Terminal).columns,t=Dn.split(`
|
|
91
|
-
`).reduce((e,t)=>Math.max(e,t.trim().length),0);!e||e<t||(yield*
|
|
92
|
-
`);return[
|
|
93
|
-
`)}const
|
|
90
|
+
run: \${{ matrix.command }}`}\n`}const en=[{path:`.github/workflows/adamantite.yml`,type:`ci`}],tn=(e,t)=>n.gen(function*(){let n=yield*b.Path,r=yield*Xt,i=n.join(e,en[0].path),a=$t(t,yield*r.resolve(e));a&&(yield*N(i,a))});var G=j({create:(e,t)=>n.gen(function*(){let n=yield*b.Path;yield*Me(n.dirname(n.join(e,en[0].path))),yield*tn(e,t)}),detect:e=>n.gen(function*(){let t=yield*y.FileSystem,n=yield*b.Path;return yield*t.exists(n.join(e,en[0].path))}),files:en,kind:`ci`,name:`github`,update:tn}),K=class extends d.Service()(`DependencyInstaller`){static layer=i.succeed(this)({addDevDependencies:n.fn(`DependencyInstaller.addDevDependencies`)((e,t,r)=>n.tryPromise({catch:t=>new ve({cause:t,packages:e}),try:()=>ce(e,{...r,cwd:t})}).pipe(n.asVoid)),detectPackageManager:n.fn(`DependencyInstaller.detectPackageManager`)(e=>n.tryPromise({catch:e=>new Oe({cause:e}),try:()=>le(e)}).pipe(n.map(e=>e??null)))})};const nn=/^\s*node-version:\s*"?\d/m;function rn(){return G.files[0].path}const an=e=>n.gen(function*(){let t=yield*b.Path;return yield*Ne(t.join(e,rn()))}),on=e=>n.gen(function*(){let t=yield*K,n=Ue(yield*L(e));if(!Bt(n))return{reason:`scripts`,supported:!1};let r=yield*t.detectPackageManager(e);return r?He(r.name)?{packageManager:r.name,scripts:n,supported:!0}:{packageManagerName:r.name,reason:`unsupported-package-manager`,supported:!1}:{reason:`no-package-manager`,supported:!1}});var sn=It({check:e=>n.gen(function*(){let t=yield*an(e.cwd);if(!h.exists(t,e=>nn.test(e)))return{status:`not-applicable`,warnings:[]};let n=yield*on(e.cwd);return n.supported?{status:`needed`,summary:`Replacing the hard-coded Node.js version in the GitHub Actions workflow with the project's Node.js version declaration.`,warnings:[]}:{status:`not-applicable`,warnings:[n.reason===`scripts`?`No CI-compatible managed scripts were found, so the GitHub Actions workflow was not updated.`:n.reason===`no-package-manager`?`Could not detect a package manager, so the GitHub Actions workflow was not updated.`:`\`${n.packageManagerName}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow was not updated.`]}}),files:[rn()],id:`hardcoded-node-version`,migrate:e=>n.gen(function*(){let t=yield*on(e.cwd);return t.supported?(yield*G.update(e.cwd,{packageManager:t.packageManager,scripts:t.scripts}),{warnings:[]}):yield*n.die(Error(`check() guaranteed workflow regeneration is supported`))}),tags:[`update`],title:`Hard-coded workflow Node.js version`,validate:e=>n.gen(function*(){let t=yield*an(e.cwd);if(h.exists(t,e=>nn.test(e)))return yield*new O({migrationId:`hardcoded-node-version`,reason:`The GitHub Actions workflow still contains a hard-coded Node.js version.`})})});function cn(e,t){return n.gen(function*(){let r=yield*b.Path,i=yield*t.integration.detect(e);if(i.active===null||i.active.format===`ts`)return yield*n.die(Error(`check() guaranteed a legacy ${t.displayName} config exists`));let a=i.active.path,o=r.join(e,t.integration.config),s=yield*M(a),c=yield*F(s,a);if(!I(c))return yield*new Ee({path:a});let{$schema:l,...u}=c;yield*N(o,t.serialize(u));for(let e of[i.active,...i.legacy])yield*Pe(e.path);return{warnings:[]}})}function ln(e){return It({check:t=>n.gen(function*(){let n=yield*e.integration.detect(t.cwd);return n.active===null||n.active.format===`ts`?{status:`not-applicable`,warnings:n.warnings}:{status:`needed`,summary:`Migrating legacy \`${n.active.file}\` configuration to \`${e.integration.config}\`.`,warnings:n.warnings}}),files:e.integration.files.map(e=>e.path),id:e.id,migrate:t=>cn(t.cwd,e),tags:[`update`],title:e.title,validate:t=>n.gen(function*(){if((yield*e.integration.detect(t.cwd)).active?.format!==`ts`)return yield*new O({migrationId:e.id,reason:`\`${e.integration.config}\` is not the active ${e.displayName} config.`})})})}var un=ln({displayName:`Knip`,id:`legacy-knip-json`,integration:z,serialize:tt,title:`Legacy Knip JSON config`}),dn=ln({displayName:`Oxfmt`,id:`legacy-oxfmt-json`,integration:H,serialize:Ft,title:`Legacy oxfmt JSON config`});const fn=/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/,pn=/^adamantite\/lint(?:\/([a-z0-9-]+))?$/;function mn(e){let t=Array.isArray(e.extends)?e.extends.filter(e=>typeof e==`string`):g.isString(e.extends)?[e.extends]:[],n=new Set(ut()),r=new Set;for(let e of t){let t=e.match(fn),i=e.match(pn),a=t?.[1]??(i?i[1]??`core`:null);a?n.add(a):r.add(e)}let{extends:i,...a}=e;return pt(a,[...n],[...r])}var hn=ln({displayName:`Oxlint`,id:`legacy-oxlint-json`,integration:V,serialize:mn,title:`Legacy oxlint JSON config`});const gn=(e=ne.cwd())=>n.gen(function*(){let t=yield*y.FileSystem,n=yield*b.Path;return(yield*t.exists(n.join(e,`pnpm-workspace.yaml`)))?!0:(yield*L(e)).workspaces!==void 0}),q=[{path:`tsconfig.json`,type:`config`}],J=`adamantite/typescript`,_n={extends:J},vn=["Skipping `tsconfig.json` setup: a root config in a monorepo makes TypeScript treat all packages as one project.",`To use the TypeScript preset, add \`"extends": "${J}"\` to each package's \`tsconfig.json\` or to a shared base config.`];function yn(e){return g.isString(e)?e===J?e:[e,J]:c.isArray(e)?e.includes(J)?e:[...e,J]:J}var Y=j({config:q[0].path,create:e=>n.gen(function*(){let t=yield*b.Path;yield*P(t.join(e,q[0].path),_n)}),detect:e=>n.gen(function*(){let t=yield*y.FileSystem,n=yield*b.Path;return yield*t.exists(n.join(e,q[0].path))}),files:q,kind:`workspace`,name:`tsconfig`,update:e=>n.gen(function*(){let t=(yield*b.Path).join(e,q[0].path),n=yield*M(t),r=yield*F(n,t);if(!g.isObject(r))return yield*new Ee({path:t});let i={...yield*Le(_n,r),extends:yn(`extends`in r?r.extends:void 0)};yield*P(t,i)})});const bn=`adamantite typecheck`;function xn(){return V.files[1].path}function Sn(){return G.files[0].path}function Cn(e){let t={...e.scripts};return t.typecheck===bn?(delete t.typecheck,t.check??=R.check,{migrated:!0,packageJson:{...e,scripts:t}}):{migrated:!1,packageJson:e}}var wn=It({check:e=>n.gen(function*(){let{migrated:t}=Cn(yield*L(e.cwd));return t?{status:`needed`,summary:"Migrating `typecheck` to `check` so oxlint handles linting and type diagnostics together.",warnings:[]}:{status:`not-applicable`,warnings:[]}}),files:[`package.json`,V.config,xn(),Y.config,Sn()],id:`legacy-typecheck-script`,migrate:e=>n.gen(function*(){let t=yield*K,r=[],i=Cn(yield*L(e.cwd));if(!i.migrated)return yield*n.die(Error(`check() guaranteed the legacy typecheck script exists`));yield*Ve(e.cwd,i.packageJson);let a=yield*V.detect(e.cwd);a.active===null?yield*V.create(e.cwd):a.active.format===`ts`&&(yield*V.update(e.cwd)),(yield*gn(e.cwd))?r.push(...vn):yield*(yield*Y.detect(e.cwd))?Y.update(e.cwd):Y.create(e.cwd);let o=yield*G.detect(e.cwd),s=Ue(i.packageJson);if(o&&Bt(s)){let n=yield*t.detectPackageManager(e.cwd);n&&He(n.name)?yield*G.update(e.cwd,{packageManager:n.name,scripts:s}):n?r.push(`\`${n.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow was not updated.`):r.push(`Could not detect a package manager, so the GitHub Actions workflow was not updated.`)}return{warnings:r}}),tags:[`update`],title:`Legacy typecheck script`,validate:e=>n.gen(function*(){if((yield*L(e.cwd)).scripts?.typecheck===bn)return yield*new O({migrationId:`legacy-typecheck-script`,reason:"The legacy `typecheck` script is still present in `package.json`."});if((yield*V.detect(e.cwd)).active?.format!==`ts`)return yield*new O({migrationId:`legacy-typecheck-script`,reason:`\`${V.config}\` is not the active oxlint config.`});if(!(yield*gn(e.cwd))&&!(yield*Y.detect(e.cwd)))return yield*new O({migrationId:`legacy-typecheck-script`,reason:`\`${Y.config}\` is missing after the migration.`})})});const X=[{path:`.zed/settings.json`,type:`config`}],Tn={languages:{Astro:{format_on_save:`on`,prettier:{allowed:!0,plugins:[`prettier-plugin-astro`]}},CSS:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},HTML:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},JSON:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},JSONC:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},JavaScript:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}},{code_action:`source.fixAll.oxc`}],prettier:{allowed:!1}},MDX:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},Markdown:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},TSX:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}},{code_action:`source.fixAll.oxc`}],prettier:{allowed:!1}},TypeScript:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}},{code_action:`source.fixAll.oxc`}],prettier:{allowed:!1}},YAML:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}}},lsp:{oxfmt:{initialization_options:{settings:{"fmt.configPath":null,run:`onSave`}}},oxlint:{initialization_options:{settings:{configPath:null,fixKind:`safe_fix`,run:`onType`,typeAware:!0,unusedDisableDirectives:`deny`}}}}};function En(e){return!I(e)||!Fe(e.plugins)?e:Object.fromEntries([...Object.entries(e),[`plugins`,c.dedupe(e.plugins)]])}function Dn(e){let t=e.languages;if(!I(t))return e;let n=Object.fromEntries(Object.entries(t).map(([e,t])=>!(e in Tn.languages)||!I(t)?[e,t]:[e,Object.fromEntries(Object.entries(t).map(([e,t])=>e===`formatter`&&Fe(t)?[e,c.dedupe(t)]:e===`prettier`?[e,En(t)]:[e,t]))]));return{...e,languages:n}}var Z=j({config:X[0].path,create:e=>n.gen(function*(){let t=yield*b.Path,n=t.join(e,X[0].path);yield*Me(t.dirname(n)),yield*P(n,Tn)}),detect:e=>n.gen(function*(){let t=yield*y.FileSystem,n=yield*b.Path;return yield*t.exists(n.join(e,X[0].path))}),files:X,kind:`editor`,name:`zed`,update:e=>n.gen(function*(){let t=(yield*b.Path).join(e,X[0].path),n=yield*M(t),r=yield*F(n,t);if(!g.isObject(r))return yield*new Ee({path:t});let i=Dn(yield*Le(Tn,r));yield*P(t,i)})});const On=Object.entries({configPath:null,"fmt.experimental":!0,typeAware:!1,unusedDisableDirectives:!1});function kn(){return Z.files[0].path}function An(e,t){return On.some(([n,r])=>n===e&&r===t)}function jn(e){let t=e.lsp;if(!I(t))return null;let n=t.oxfmt;if(!I(n))return null;let r=n.initialization_options;if(!I(r))return null;let i=r.settings;return I(i)?{initializationOptions:r,lsp:t,oxfmt:n,settings:i}:null}const Mn=e=>n.gen(function*(){let t=(yield*b.Path).join(e,kn()),n=yield*Ne(t);if(h.isNone(n))return null;let r=yield*F(n.value,t);return I(r)?{config:r,settingsPath:t}:null}),Nn=e=>n.gen(function*(){let t=yield*Mn(e),n=t===null?null:jn(t.config);if(t===null||n===null)return null;let r=Object.entries(n.settings).filter(([e,t])=>An(e,t)).map(([e])=>e);return{...t,...n,staleKeys:r}}),Pn=[dn,un,hn,wn,sn,It({check:e=>n.gen(function*(){let t=yield*Nn(e.cwd);return t===null||t.staleKeys.length===0?{status:`not-applicable`,warnings:[]}:{status:`needed`,summary:`Removing lint-only and deprecated settings from the Zed oxfmt language server configuration.`,warnings:[]}}),files:[kn()],id:`legacy-zed-oxfmt-settings`,migrate:e=>n.gen(function*(){let t=yield*Nn(e.cwd);if(t===null||t.staleKeys.length===0)return yield*n.die(Error(`check() guaranteed stale Zed oxfmt settings exist`));let r={"fmt.configPath":null,...Object.fromEntries(Object.entries(t.settings).filter(([e,t])=>!An(e,t)))};return yield*P(t.settingsPath,{...t.config,lsp:{...t.lsp,oxfmt:{...t.oxfmt,initialization_options:{...t.initializationOptions,settings:r}}}}),{warnings:[]}}),tags:[`update`],title:`Legacy Zed oxfmt settings`,validate:e=>n.gen(function*(){let t=yield*Nn(e.cwd);if(t!==null&&t.staleKeys.length>0)return yield*new O({migrationId:`legacy-zed-oxfmt-settings`,reason:`\`${kn()}\` still contains stale oxfmt language server settings.`})})})],Fn=Object.fromEntries(Pn.map(e=>[e.id,e])),In=n.fn(`collectApplicableAssessments`)(function*(e,t,r){let i=r??(yield*L(t));return yield*n.forEach(e,e=>e.assess(t,i).pipe(n.map(t=>t.applicable?h.some({assessment:t,integration:e}):h.none())),{concurrency:`unbounded`}).pipe(n.map(e=>c.getSomes(e)))});function Ln(e,t,n){return In(e,t,n)}var Q=class extends d.Service()(`Prompter`){static layerWithSpinner(e){return i.succeed(this)({cancel:e=>n.sync(()=>{w.cancel(e)}),confirm:e=>n.promise(()=>w.confirm(e)).pipe(n.filterOrFail(e=>!w.isCancel(e),()=>new ke({}))),intro:e=>n.sync(()=>{w.intro(e)}),log:{error:e=>n.sync(()=>{w.log.error(e)}),info:e=>n.sync(()=>{w.log.info(e)}),success:e=>n.sync(()=>{w.log.success(e)}),warning:e=>n.sync(()=>{w.log.warning(e)})},multiselect:e=>n.promise(()=>w.multiselect(e)).pipe(n.filterOrFail(e=>!w.isCancel(e),()=>new ke({}))),outro:e=>n.sync(()=>{w.outro(e)}),withSpinner:(t,i)=>n.acquireUseRelease(n.sync(()=>{let t=e();return t.start(i.start),t}),e=>t({message:t=>n.sync(()=>{e.message(t)})}),(e,t)=>n.sync(()=>{e.stop(r.match(t,{onFailure:()=>i.failure,onSuccess:e=>g.isFunction(i.success)?i.success(e):i.success}))}))})}static layer=this.layerWithSpinner(w.spinner)};const Rn=' .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 ',zn=()=>n.gen(function*(){let e=yield*(yield*fe.Terminal).columns,t=Rn.split(`
|
|
91
|
+
`).reduce((e,t)=>Math.max(e,t.trim().length),0);!e||e<t||(yield*de.info(Rn))}),Bn=u.boolean(`fix`).pipe(u.withDescription(`Automatically fix safe package install/update issues`)),Vn=[z,H,V,U,W];var Hn=l.make(`doctor`,{fix:Bn}).pipe(l.withDescription(`Check Adamantite-managed integrations in the current project`),l.withHandler(({fix:e})=>n.gen(function*(){let t=ne.cwd(),r=yield*Q;yield*zn(),yield*r.intro(`💠 adamantite doctor`);let i=yield*L(t);if(!i.devDependencies?.adamantite&&!i.dependencies?.adamantite)return yield*r.log.warning("`adamantite` is not installed in this project. Install it before running `adamantite doctor`."),yield*r.outro(`⚠️ Doctor found issues.`),yield*new E({command:`doctor`,exitCode:s.ExitCode(1)});let a=yield*Ln(Vn,t,i);for(let{assessment:e}of a)for(let t of e.warnings)yield*r.log.warning(t);if(a.length===0){yield*r.log.success(`No applicable integrations found.`),yield*r.outro(`✅ Doctor completed successfully!`);return}let o=a.flatMap(({assessment:e,integration:t})=>e.actions.map(e=>({action:e,integration:t})));if(o.length===0){yield*r.log.success(`No issues found.`),yield*r.outro(`✅ Doctor completed successfully!`);return}let c=new Set;e&&(yield*n.gen(function*(){let e=o.filter(({action:e})=>e.type===`install_package`||e.type===`update_package`);if(e.length>0){let n=yield*K,i=[];for(let{action:t}of e)(t.type===`install_package`||t.type===`update_package`)&&i.push(`${t.package}@${t.targetVersion}`);yield*n.addDevDependencies(i,t,{silent:!0});for(let t of e){let{action:e}=t;e.type===`install_package`&&(yield*r.log.success(`Fixed: installed \`${e.package}@${e.targetVersion}\`.`)),e.type===`update_package`&&(yield*r.log.success(`Fixed: updated \`${e.package}\` from \`${e.currentVersion}\` to \`${e.targetVersion}\`.`)),c.add(t)}}for(let e of o){let{action:n,integration:i}=e;n.type!==`create_config`||!(`create`in i)||(yield*i.create(t),yield*r.log.success(`Fixed: created \`${n.path}\`.`),c.add(e))}for(let e of o){let{action:n,integration:i}=e;n.type!==`update_config`||!(`update`in i)||(yield*i.update(t),yield*r.log.success(`Fixed: updated \`${n.path}\`.`),c.add(e))}for(let e of o){let{action:n}=e;if(n.type!==`run_migration`)continue;let i=Fn[n.migrationId];if(!i)continue;let a=yield*i.check({cwd:t});for(let e of a.warnings)yield*r.log.warning(e);if(a.status!==`needed`){c.add(e);continue}let o=yield*r.withSpinner(()=>Lt(i,{cwd:t}),{failure:`Migration "${i.title}" failed, files restored.`,start:a.summary,success:`Fixed: ${n.description}`});for(let e of o.warnings)yield*r.log.warning(e);c.add(e)}}).pipe(n.tapError(()=>n.gen(function*(){yield*r.outro(`❌ Doctor failed`)}))));let l=o.filter(e=>!c.has(e));if(e&&l.length===0){yield*r.outro(`✅ Doctor completed successfully!`);return}for(let{action:t}of e?l:o)yield*r.log.warning(`Needs attention: ${t.description}`);yield*r.outro(`⚠️ Doctor found issues.`),yield*new E({command:`doctor`,exitCode:s.ExitCode(1)})})));const Un=S.file(`files`,{mustExist:!0}).pipe(S.withDescription(`Specific files to fix (optional)`),S.variadic()),Wn=u.boolean(`suggested`).pipe(u.withDescription(`Apply suggested fixes`)),Gn=u.boolean(`dangerous`).pipe(u.withDescription(`Apply dangerous fixes`)),Kn=u.boolean(`all`).pipe(u.withDescription(`Apply all fixes, including suggested and dangerous fixes`));var qn=l.make(`fix`,{all:Kn,dangerous:Gn,files:Un,suggested:Wn}).pipe(l.withDescription(`Fix issues in code using oxlint`),l.withHandler(({all:e,dangerous:t,files:r,suggested:i})=>n.gen(function*(){let n=yield*A,a=yield*k,o=c.dedupe([`--fix`,...i||e?[`--fix-suggestions`]:[],...t||e?[`--fix-dangerously`]:[],...r]),l=yield*a.run({args:[...o,...n],command:V.name});l!==s.ExitCode(0)&&(yield*new E({command:V.name,exitCode:l}))})));const Jn=S.file(`files`,{mustExist:!0}).pipe(S.withDescription(`Specific files to format (optional)`),S.variadic()),Yn=u.boolean(`check`).pipe(u.withDescription(`Check if files are formatted without writing`));var Xn=l.make(`format`,{check:Yn,files:Jn}).pipe(l.withDescription(`Format files using oxfmt`),l.withHandler(({check:e,files:t})=>n.gen(function*(){let n=yield*A,r=yield*k,i=[];e&&i.push(`--check`),i.push(...t,...n);let a=yield*r.run({args:i,command:H.name});a!==s.ExitCode(0)&&(yield*new E({command:H.name,exitCode:a}))})));const Zn=[{path:`.vscode/settings.json`,type:`config`}],Qn={"[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};var $=j({config:Zn[0].path,create:e=>n.gen(function*(){let t=yield*b.Path,n=t.join(e,Zn[0].path);yield*Me(t.dirname(n)),yield*P(n,Qn)}),detect:e=>n.gen(function*(){let t=yield*y.FileSystem,n=yield*b.Path;return yield*t.exists(n.join(e,Zn[0].path))}),extension:(e=[])=>n.gen(function*(){let t=[];(e.includes(`check`)||e.includes(`fix`)||e.includes(`format`))&&t.push(`oxc.oxc-vscode`),e.includes(`analyze`)&&t.push(`webpro.vscode-knip`);for(let e of t){let t=yield*(yield*k).run({args:[`--install-extension`,e],command:`code`}).pipe(n.mapError(t=>t._tag===`CliNotFound`&&t.command===`code`?new je({cause:t}):new ye({cause:t,extension:e})));if(t!==s.ExitCode(0))return yield*new ye({cause:t,extension:e})}}),files:Zn,kind:`editor`,name:`vscode`,update:e=>n.gen(function*(){let t=(yield*b.Path).join(e,Zn[0].path),n=yield*M(t),r=yield*F(n,t);if(!g.isObject(r))return yield*new Ee({path:t});let i=yield*Le(Qn,r);yield*P(t,i)})});const $n=`<!-- ADAMANTITE:START -->`,er=`<!-- ADAMANTITE:END -->`;function tr(e,t){let n=ue(e,t),r=R[t];switch(t){case`analyze`:return`- Run \`${n}\` after changing dependencies, imports, or exports. Direct command: \`${r}\`.`;case`check`:return`- Run \`${n}\` to catch lint and type issues. Direct command: \`${r}\`.`;case`check:monorepo`:return`- Run \`${n}\` to check monorepo package consistency. Direct command: \`${r}\`.`;case`fix`:return`- Run \`${n}\` to apply safe lint fixes. Direct command: \`${r}\`.`;case`fix:monorepo`:return`- Run \`${n}\` to fix monorepo package consistency. Direct command: \`${r}\`.`;case`format`:return`- Run \`${n}\` after editing files. Direct command: \`${r}\`.`}}function nr({packageManager:e,scripts:t}){let n=[`format`,`check`,`fix`,`analyze`,`check:monorepo`,`fix:monorepo`].filter(e=>t.includes(e)).map(t=>tr(e,t)),r=[`## 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(`
|
|
92
|
+
`);return[$n,``,r,``,er,``].join(`
|
|
93
|
+
`)}const rr=(e,t)=>n.gen(function*(){let n=(yield*b.Path).join(e,`AGENTS.md`),r=m(yield*Ne(n),h.getOrElse(()=>``)),i=m(r,_.indexOf($n)),a=m(r,_.indexOf(er)),o=m(h.all({end:a,start:i}),h.filter(({end:e,start:t})=>t<e)),s=nr(t);if(h.isSome(o)){let{end:e,start:t}=o.value,i=e+23,a=`${r.slice(0,t)}${s.trimEnd()}${r.slice(i)}`;return yield*N(n,a.endsWith(`
|
|
94
94
|
`)?a:`${a}\n`),`updated`}if(h.isSome(i)||h.isSome(a))return`malformed`;let c=r.length===0||r.endsWith(`
|
|
95
95
|
|
|
96
96
|
`)?``:r.endsWith(`
|
|
97
97
|
`)?`
|
|
98
98
|
`:`
|
|
99
99
|
|
|
100
|
-
`;return yield*P(n,`${r}${c}${s}`),`updated`}),Yn=(e,t)=>n.gen(function*(){let r=yield*K;yield*(yield*X).withSpinner(()=>n.gen(function*(){let n=yield*hn(e);yield*r.addDevDependencies(t,e,{silent:!0,workspace:n})}),{failure:`Failed to install dependencies.`,start:`Installing dependencies...`,success:`Dependencies installed.`})});function Xn(e,t,r){return n.gen(function*(){let i=yield*X,a=yield*i.withSpinner(a=>n.gen(function*(){let n=yield*t.detect(e);for(let e of n.warnings)yield*i.log.warning(e);return n.active===null?(yield*a.message(`\`${t.config}\` not found, creating...`),yield*r,{created:!0,legacyConfig:null}):n.active.format===`ts`?(yield*a.message(`Found \`${t.config}\`, keeping existing config.`),{created:!1,legacyConfig:null}):(yield*a.message(`Found \`${n.active.file}\`, keeping existing config.`),{created:!1,legacyConfig:n.active.file})}),{failure:`Failed to set up ${t.name} config.`,start:`Setting up ${t.name} config...`,success:e=>e.created?`${t.name} config created successfully.`:`${t.name} config is ready.`});a.legacyConfig&&(yield*i.log.info(`Legacy \`${a.legacyConfig}\` was preserved during \`adamantite init\`. Run \`adamantite doctor --fix\` to migrate it to the latest ${t.name} config.`))})}const Zn=e=>`\`${e.script}\` is currently \`${e.command}\`; Adamantite would replace it with \`${R[e.script]}\`.`,Qn=(e,t,r)=>n.gen(function*(){let i=yield*X,a=yield*L(e),o=r.overwriteScripts?[]:Ue(a,t),s=new Set(o.map(e=>e.script)),c=t.filter(e=>!s.has(e));yield*i.withSpinner(()=>n.gen(function*(){if(c.length!==0){a.scripts??={};for(let e of c)a.scripts[e]=R[e];yield*Be(e,a)}}),{failure:"Failed to add scripts to `package.json`.",start:"Adding scripts to your `package.json`...",success:o.length===0?"Scripts added to your `package.json`":c.length===0?"Kept your existing `package.json` scripts.":"Scripts added to your `package.json`; conflicting scripts were kept."});let l=r.nonInteractive?"Use `--overwrite-scripts` to replace it.":"Re-run `adamantite init` and confirm overwriting to replace it.";for(let e of o)yield*i.log.warning(`Kept existing \`${e.script}\` script (\`${e.command}\`) instead of \`${R[e.script]}\`. ${l}`);return o.length>0&&(yield*i.log.info("Adamantite commands forward extra arguments after `--`, so custom flags can be kept, e.g. `adamantite monorepo -- --ignore-dependency tailwindcss`.")),c}),$n=(e,t)=>n.gen(function*(){let r=yield*X;if(t){yield*m(_n,n.forEach(e=>r.log.info(e)));return}yield*r.withSpinner(t=>n.gen(function*(){return(yield*Y.detect(e))?(yield*t.message(`\`${Y.config}\` found, updating...`),yield*Y.update(e),!1):(yield*t.message(`\`${Y.config}\` not found, creating...`),yield*Y.create(e),!0)}),{failure:`Failed to set up TypeScript config.`,start:`Setting up TypeScript config...`,success:e=>e?`\`${Y.config}\` created successfully`:`\`${Y.config}\` updated successfully`})}),er=(e,t)=>n.gen(function*(){let r=yield*X;t.includes(`vscode`)&&(yield*r.withSpinner(t=>n.gen(function*(){let n=yield*Q.detect(e);return yield*t.message(`\`${Q.config}\` ${n?`found, updating`:`not found, creating`}...`),yield*n?Q.update(e):Q.create(e),!n}),{failure:`Failed to set up VS Code config.`,start:`Checking for \`${Q.config}\`...`,success:e=>`\`${Q.config}\` ${e?`created`:`updated`} with Adamantite preset.`})),t.includes(`zed`)&&(yield*r.withSpinner(t=>n.gen(function*(){let n=yield*$.detect(e);return yield*t.message(`\`${$.config}\` ${n?`found, updating`:`not found, creating`}...`),yield*n?$.update(e):$.create(e),!n}),{failure:`Failed to set up Zed config.`,start:`Checking for \`${$.config}\`...`,success:e=>`\`${$.config}\` ${e?`created`:`updated`} with Adamantite preset.`}))}),tr=(e,t)=>n.gen(function*(){let r=yield*X,i=e.includes(`zed`),a=e.includes(`vscode`);yield*r.withSpinner(e=>n.gen(function*(){return a&&(yield*e.message(`Installing VS Code extension...`),yield*Q.extension(t)),!0}),{start:`Installing editor extensions...`,success:i&&!a?`Zed extensions require manual install.`:`Editor extensions installed successfully.`}).pipe(n.catchTag(`FailedToInstallExtension`,e=>n.gen(function*(){return yield*r.log.warning(`⚠️ ${e.message}`),yield*r.log.warning(`Please install it manually after setup completes.`),!1})),n.catchTag(`VscodeCliNotFound`,()=>n.gen(function*(){return yield*r.log.error(`VSCode CLI ('code' command) not found.`),yield*r.log.info(`To install it:`),yield*r.log.info(` 1. Open VS Code`),yield*r.log.info(` 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)`),yield*r.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))),i&&(yield*r.log.info("Install the Zed `oxc` extension: zed://extension/oxc"))}),nr=(e,t,r)=>n.gen(function*(){let i=yield*X,a=G.files[0].path;yield*i.withSpinner(i=>n.gen(function*(){let n=yield*G.detect(e);return yield*i.message(n?`\`${a}\` found, updating...`:`Creating \`${a}\`...`),yield*n?G.update(e,{packageManager:t,scripts:r}):G.create(e,{packageManager:t,scripts:r}),!n}),{failure:`Failed to set up GitHub Actions workflow.`,start:`Setting up GitHub Actions workflow...`,success:e=>`GitHub Actions workflow ${e?`created`:`updated`} successfully.`})}).pipe(n.catchTag([`FailedToCreateDirectory`,`FailedToParseFile`,`FailedToReadFile`,`FailedToWriteFile`,`PlatformError`],e=>n.gen(function*(){let t=yield*X;yield*t.log.warning(`Could not set up the GitHub Actions workflow. ${e.message}`),yield*t.log.warning("Fix the reported problem and run `adamantite init` again, or create the workflow manually.")}))),rr=(e,t,r)=>n.gen(function*(){let i=yield*X,a=yield*i.withSpinner(()=>Jn(e,{packageManager:t,scripts:r}),{failure:`Failed to update AGENTS.md.`,start:`Updating AGENTS.md...`,success:`AGENTS.md check complete.`}).pipe(n.catchTag([`FailedToReadFile`,`FailedToWriteFile`],e=>n.gen(function*(){return yield*i.log.warning(`Could not update AGENTS.md. ${e.message} Adamantite will continue initialization.`),`failed`})));a!==`failed`&&a===`malformed`&&(yield*i.log.warning(`Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.`))}),ir=[`check`,`fix`,`format`,`check:monorepo`,`fix:monorepo`,`analyze`],ar=[`react`,`nextjs`,`vue`,`jest`,`vitest`,`node`,`antislop`],or=[`vscode`,`zed`],sr=n.fn(`validateInitOptions`)(function*(e,t){let n={agents:e.agents,editors:c.dedupe(e.editors),githubActions:e.githubActions,installExtensions:e.installExtensions,overwriteScripts:e.overwriteScripts,presets:c.dedupe(e.presets),scripts:c.dedupe(e.scripts),typescript:e.typescript};if(n.scripts.length===0)return yield*new O({reason:"Select at least one script with `--script <name>`."});let r=n.scripts.includes(`check`)||n.scripts.includes(`fix`);return(n.scripts.includes(`check:monorepo`)||n.scripts.includes(`fix:monorepo`))&&!t.isMonorepo?yield*new O({reason:`Monorepo scripts can only be selected in a detected monorepo.`}):n.presets.length>0&&!r?yield*new O({reason:"`--preset` requires the `check` or `fix` script."}):n.typescript&&!r?yield*new O({reason:"`--typescript` requires the `check` or `fix` script."}):n.installExtensions&&n.editors.length===0?yield*new O({reason:"`--install-extensions` requires at least one `--editor`."}):n.githubActions&&!zt(n.scripts)?yield*new O({reason:"`--github-actions` requires a CI-compatible script."}):n.githubActions&&t.nonInteractive&&!Ve(t.packageManager)?yield*new O({reason:`\`--github-actions\` does not support the detected package manager \`${t.packageManager}\`. Use bun, deno, npm, pnpm, or yarn.`}):n}),cr=u.boolean(`non-interactive`).pipe(u.withDescription(`Configure without prompts; requires at least one --script`)),lr=u.choice(`script`,ir).pipe(u.atMost(ir.length),u.withDescription(`Package script to configure; repeatable and required in non-interactive mode. Monorepo scripts require a detected monorepo`)),ur=u.choice(`preset`,ar).pipe(u.atMost(ar.length),u.withDescription(`Oxlint preset to configure; repeatable and requires --script check or fix`)),dr=u.choice(`editor`,or).pipe(u.atMost(or.length),u.withDescription(`Editor to configure; may be specified multiple times`)),fr=u.boolean(`typescript`).pipe(u.withDescription(`Configure the TypeScript preset; requires --script check or fix`)),pr=u.boolean(`install-extensions`).pipe(u.withDescription(`Install recommended extensions; requires at least one --editor`)),mr=u.boolean(`github-actions`).pipe(u.withDescription(`Configure CI; requires a compatible script and bun, deno, npm, pnpm, or yarn`)),hr=u.boolean(`agents`).pipe(u.withDescription(`Add Adamantite guidance to AGENTS.md`)),gr=u.boolean(`overwrite-scripts`).pipe(u.withDescription(`Replace existing package scripts that conflict with Adamantite's managed commands`)),_r=n.fn(`collectInteractiveInitOptions`)(function*(e,t){let n=yield*X,r=yield*n.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:!t,hint:t?void 0:`available for monorepo projects`,label:`check:monorepo - check for monorepo-specific issues using Sherif`,value:`check:monorepo`},{disabled:!t,hint:t?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`}]}),i=Ue(yield*L(e),r),a=!1;if(i.length>0){for(let e of i)yield*n.log.warning(Zn(e));a=yield*n.confirm({initialValue:!1,message:i.length===1?`Overwrite this existing script with Adamantite's command?`:`Overwrite these existing scripts with Adamantite's commands?`})}let o=r.includes(`check`)||r.includes(`fix`),s=[];o&&(s=yield*n.multiselect({message:`Which presets do you want to install? (core is always included)`,options:[{hint:`React, JSX accessibility, and performance rules`,label:`React`,value:`react`},{hint:`Next.js rules`,label:`Next.js`,value:`nextjs`},{hint:`Vue rules`,label:`Vue`,value:`vue`},{hint:`Jest rules`,label:`Jest`,value:`jest`},{hint:`Vitest rules`,label:`Vitest`,value:`vitest`},{hint:`Node.js rules`,label:`Node`,value:`node`},{hint:`anti-slop rules that reject low-evidence, low-signal patterns`,label:`antislop`,value:`antislop`}],required:!1}));let c=o?yield*n.confirm({initialValue:!0,message:t?"Adamantite provides a TypeScript preset to enforce strict type-safety. In a monorepo, each package's `tsconfig.json` must extend it. Would you like instructions on how to set it up?":`Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?`}):!1,l=yield*n.multiselect({message:`Which editors do you want to configure? (optional)`,options:[{label:`VSCode / Cursor / Windsurf`,value:`vscode`},{label:`Zed`,value:`zed`}],required:!1}),u=l.length>0?yield*n.confirm({initialValue:!0,message:`Do you want to install the recommended editor extensions?`}):!1,d=zt(r)?yield*n.confirm({message:`Do you want to add a GitHub Actions workflow to run checks in CI?`}):!1;return{agents:yield*n.confirm({initialValue:!0,message:`Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?`}),editors:l,githubActions:d,installExtensions:u,overwriteScripts:a,presets:s,scripts:r,typescript:c}});var vr=l.make(`init`,{agents:hr,editors:dr,githubActions:mr,installExtensions:pr,nonInteractive:cr,overwriteScripts:gr,presets:ur,scripts:lr,typescript:fr}).pipe(l.withDescription(`Initialize Adamantite in the current directory. Setup flags require --non-interactive; omitted boolean setup flags are disabled`),l.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`}]),l.withHandler(e=>n.gen(function*(){let t=x.cwd(),n=yield*X;yield*On(),yield*n.intro(`💠 adamantite init`);let r=yield*(yield*K).detectPackageManager(t);if(!r)return yield*new De({});if(r.warnings?.length)for(let e of r.warnings)yield*n.log.warning(e);yield*n.log.info(`Detected package manager: ${r.name}`);let i=yield*hn(t);if(i&&(yield*n.log.info(`We've detected a monorepo setup in your project.`)),!e.nonInteractive&&c.some([e.scripts.length>0,e.presets.length>0,e.editors.length>0,e.typescript,e.installExtensions,e.githubActions,e.agents,e.overwriteScripts],g.isTruthy))return yield*new O({reason:"Setup flags require `--non-interactive`."});let a=e.nonInteractive?e:yield*_r(t,i),o=yield*sr(a,{isMonorepo:i,nonInteractive:e.nonInteractive,packageManager:r.name}),s=o.scripts,l=o.presets,u=o.editors,d=o.typescript,ee=o.installExtensions,f=o.githubActions,p=o.agents,m=s.includes(`check`)||s.includes(`fix`),h=s.includes(`format`),_=s.includes(`check:monorepo`)||s.includes(`fix:monorepo`),te=s.includes(`analyze`),v=[`adamantite`];m&&v.push(`${V.name}@${V.version}`,`${W.name}@${W.version}`),h&&v.push(`${H.name}@${H.version}`),_&&v.push(`${U.name}@${U.version}`),te&&v.push(`${z.name}@${z.version}`),yield*Yn(t,v),h&&(yield*Xn(t,H,H.create(t))),m&&(yield*Xn(t,V,V.create(t,l))),te&&(yield*Xn(t,z,z.create(t)));let y=yield*Qn(t,s,{nonInteractive:e.nonInteractive,overwriteScripts:o.overwriteScripts});if(p&&(yield*rr(t,r.name,y)),d&&(yield*$n(t,i)),yield*er(t,u),ee&&(yield*tr(u,s)),f){let e=r.name;Ve(e)?yield*nr(t,e,s):yield*n.log.warning(`Skipping GitHub Actions setup: \`${e}\` is not a supported package manager for CI workflow generation.`)}yield*n.log.success(`Your project is now configured`),yield*n.outro(`💠 Adamantite initialized successfully!`)}).pipe(n.catchTags({OperationCancelled:()=>n.gen(function*(){yield*(yield*X).cancel(`You've cancelled the initialization process.`)})}))));const yr=u.boolean(`fix`).pipe(u.withDescription(`Automatically fix issues`));var br=l.make(`monorepo`,{fix:yr}).pipe(l.withDescription(`Find and fix monorepo-specific issues using Sherif`),l.withHandler(({fix:e})=>n.gen(function*(){let t=yield*j,n=yield*A,r=e?[`--fix`,...t]:[...t],i=yield*n.run({args:r,command:U.name,stdin:`inherit`});i!==s.ExitCode(0)&&(yield*new D({command:U.name,exitCode:i}))}))),xr=l.make(`typecheck`).pipe(l.withDescription("Deprecated alias for `check`"),l.withHandler(()=>n.gen(function*(){let e=yield*j,t=yield*X,n=yield*A;yield*t.log.warning("Deprecated. Use `adamantite check` for typechecking.");let r=yield*n.run({args:[...e],command:V.name});r!==s.ExitCode(0)&&(yield*new D({command:V.name,exitCode:r}))})));const Sr=[V,W,H,U,z],Cr=[V,W,H,U,z];function wr(e,t){return c.filterMap(Cr,n=>{if(t.has(n.name))return S.failVoid;let r=e.devDependencies?.[n.name]??e.dependencies?.[n.name];return r&&ze(r)!==n.version?S.succeed({currentVersion:r,name:n.name,targetVersion:n.version}):S.failVoid})}var Tr=l.make(`update`).pipe(l.withDescription(`Run applicable Adamantite migrations and update managed dependencies`),l.withHandler(()=>n.gen(function*(){let e=x.cwd(),t=yield*X,r=yield*K,i={cwd:e};yield*On(),yield*t.intro(`💠 adamantite update`);let a=t=>En(Sr,e,t),o=yield*a(),s=new Set,l=e=>n.gen(function*(){for(let n of e)s.has(n)||(s.add(n),yield*t.log.warning(n))});yield*l(o.flatMap(({assessment:e})=>e.warnings));let u=[];for(let e of Cn.filter(e=>e.tags.includes(`update`))){let n=yield*e.check(i);yield*l(n.warnings),n.status===`needed`&&(yield*l((yield*t.withSpinner(()=>It(e,i),{failure:`Migration "${e.title}" failed, files restored.`,start:n.summary,success:`Migration "${e.title}" completed successfully.`})).warnings),u.push(e.id))}u.length>0&&(yield*t.log.success(`Migrations ran successfully.`));let d=yield*L(e),ee=(yield*a(d)).flatMap(({assessment:e})=>e.actions),f=ee.filter(e=>e.type===`create_config`||e.type===`update_config`||e.type===`manual_fix`),p=c.filterMap(ee,e=>{switch(e.type){case`install_package`:return S.succeed({currentVersion:`not installed`,name:e.package,targetVersion:e.targetVersion});case`update_package`:return S.succeed({currentVersion:e.currentVersion,name:e.package,targetVersion:e.targetVersion});default:return S.failVoid}}),m=new Set(p.map(e=>e.name)),h=[...p,...wr(d,m)];if(h.length>0){yield*t.log.info(`The following dependencies will be updated:`);for(let e of h)yield*t.log.info(` ${e.name}: ${e.currentVersion} → ${e.targetVersion}`);yield*t.withSpinner(()=>r.addDevDependencies(h.map(e=>`${e.name}@${e.targetVersion}`),e,{silent:!0}),{failure:`Failed to update dependencies`,start:`Updating dependencies...`,success:`Dependencies updated successfully`}),yield*t.log.success(`Dependencies updated successfully.`)}if(f.length>0){yield*t.log.warning("Some configuration follow-up belongs to `adamantite doctor --fix`.");for(let e of f)yield*t.log.warning(`Doctor follow-up: ${e.description}`)}return u.length===0&&h.length===0&&f.length===0?(yield*t.log.success(`No changes needed.`),`no-changes`):`success`}).pipe(n.tapError(()=>n.gen(function*(){yield*(yield*X).outro(`❌ Update failed`)})),n.tap(e=>n.gen(function*(){let t=yield*X;switch(e){case`no-changes`:yield*t.outro(`✅ Adamantite is already up to date.`);break;case`success`:yield*t.outro(`✅ Update completed successfully!`)}})))));const Er=[rt,At,In,zn,br,xr],Dr=[rt,At,jn,In,zn,vr,br,xr,Tr],Or=new Set(Dr.map(e=>e.name)),kr=new Set(Er.map(e=>e.name)),Ar=l.make(`adamantite`).pipe(l.withDescription(`Opinionated preset package for modern TypeScript applications`),l.withSubcommands(Dr)),jr=n.fn(`runCli`)(function*(e,t){let[r,i]=c.splitWhere(e,e=>e===`--`),a=c.drop(i,1),o=r.find(e=>Or.has(e));if(a.length>0&&o!==void 0&&!kr.has(o))return yield*new ke({command:o});yield*l.runWith(Ar,{version:t})(r).pipe(n.provideService(j,a))}),Mr=n.gen(function*(){let e=yield*(yield*o.Stdio).args;yield*jr(e,`0.36.0`)}).pipe(n.as(0),n.catchTag(`CommandFailed`,e=>n.succeed(e.exitCode)),n.catch(e=>n.service(X).pipe(n.flatMap(t=>t.log.error(e.message)),n.as(s.ExitCode(1)))),n.provide(i.mergeAll(t.layer,Yt.layer.pipe(i.provide(t.layer)),X.layer,A.layer,K.layer)));e.runMain(Mr,{teardown:(e,t)=>{if(r.isSuccess(e)){t(Number(e.value));return}a.defaultTeardown(e,t)}});export{};
|
|
100
|
+
`;return yield*N(n,`${r}${c}${s}`),`updated`}),ir=(e,t)=>n.gen(function*(){let r=yield*K;yield*(yield*Q).withSpinner(()=>n.gen(function*(){let n=yield*gn(e);yield*r.addDevDependencies(t,e,{silent:!0,workspace:n})}),{failure:`Failed to install dependencies.`,start:`Installing dependencies...`,success:`Dependencies installed.`})});function ar(e,t,r){return n.gen(function*(){let i=yield*Q,a=yield*i.withSpinner(a=>n.gen(function*(){let n=yield*t.detect(e);for(let e of n.warnings)yield*i.log.warning(e);return n.active===null?(yield*a.message(`\`${t.config}\` not found, creating...`),yield*r,{created:!0,legacyConfig:null}):n.active.format===`ts`?(yield*a.message(`Found \`${t.config}\`, keeping existing config.`),{created:!1,legacyConfig:null}):(yield*a.message(`Found \`${n.active.file}\`, keeping existing config.`),{created:!1,legacyConfig:n.active.file})}),{failure:`Failed to set up ${t.name} config.`,start:`Setting up ${t.name} config...`,success:e=>e.created?`${t.name} config created successfully.`:`${t.name} config is ready.`});a.legacyConfig&&(yield*i.log.info(`Legacy \`${a.legacyConfig}\` was preserved during \`adamantite init\`. Run \`adamantite doctor --fix\` to migrate it to the latest ${t.name} config.`))})}const or=e=>`\`${e.script}\` is currently \`${e.command}\`; Adamantite would replace it with \`${R[e.script]}\`.`,sr=(e,t,r)=>n.gen(function*(){let i=yield*Q,a=yield*L(e),o=r.overwriteScripts?[]:We(a,t),s=new Set(o.map(e=>e.script)),c=t.filter(e=>!s.has(e));yield*i.withSpinner(()=>n.gen(function*(){if(c.length!==0){a.scripts??={};for(let e of c)a.scripts[e]=R[e];yield*Ve(e,a)}}),{failure:"Failed to add scripts to `package.json`.",start:"Adding scripts to your `package.json`...",success:o.length===0?"Scripts added to your `package.json`":c.length===0?"Kept your existing `package.json` scripts.":"Scripts added to your `package.json`; conflicting scripts were kept."});let l=r.nonInteractive?"Use `--overwrite-scripts` to replace it.":"Re-run `adamantite init` and confirm overwriting to replace it.";for(let e of o)yield*i.log.warning(`Kept existing \`${e.script}\` script (\`${e.command}\`) instead of \`${R[e.script]}\`. ${l}`);return o.length>0&&(yield*i.log.info("Adamantite commands forward extra arguments after `--`, so custom flags can be kept, e.g. `adamantite monorepo -- --ignore-dependency tailwindcss`.")),c}),cr=(e,t)=>n.gen(function*(){let r=yield*Q;if(t){yield*m(vn,n.forEach(e=>r.log.info(e)));return}yield*r.withSpinner(t=>n.gen(function*(){return(yield*Y.detect(e))?(yield*t.message(`\`${Y.config}\` found, updating...`),yield*Y.update(e),!1):(yield*t.message(`\`${Y.config}\` not found, creating...`),yield*Y.create(e),!0)}),{failure:`Failed to set up TypeScript config.`,start:`Setting up TypeScript config...`,success:e=>e?`\`${Y.config}\` created successfully`:`\`${Y.config}\` updated successfully`})}),lr=(e,t)=>n.gen(function*(){let r=yield*Q;t.includes(`vscode`)&&(yield*r.withSpinner(t=>n.gen(function*(){let n=yield*$.detect(e);return yield*t.message(`\`${$.config}\` ${n?`found, updating`:`not found, creating`}...`),yield*n?$.update(e):$.create(e),!n}),{failure:`Failed to set up VS Code config.`,start:`Checking for \`${$.config}\`...`,success:e=>`\`${$.config}\` ${e?`created`:`updated`} with Adamantite preset.`})),t.includes(`zed`)&&(yield*r.withSpinner(t=>n.gen(function*(){let n=yield*Z.detect(e);return yield*t.message(`\`${Z.config}\` ${n?`found, updating`:`not found, creating`}...`),yield*n?Z.update(e):Z.create(e),!n}),{failure:`Failed to set up Zed config.`,start:`Checking for \`${Z.config}\`...`,success:e=>`\`${Z.config}\` ${e?`created`:`updated`} with Adamantite preset.`}))}),ur=(e,t)=>n.gen(function*(){let r=yield*Q,i=e.includes(`zed`),a=e.includes(`vscode`);yield*r.withSpinner(e=>n.gen(function*(){return a&&(yield*e.message(`Installing VS Code extension...`),yield*$.extension(t)),!0}),{start:`Installing editor extensions...`,success:i&&!a?`Zed extensions require manual install.`:`Editor extensions installed successfully.`}).pipe(n.catchTag(`FailedToInstallExtension`,e=>n.gen(function*(){return yield*r.log.warning(`⚠️ ${e.message}`),yield*r.log.warning(`Please install it manually after setup completes.`),!1})),n.catchTag(`VscodeCliNotFound`,()=>n.gen(function*(){return yield*r.log.error(`VSCode CLI ('code' command) not found.`),yield*r.log.info(`To install it:`),yield*r.log.info(` 1. Open VS Code`),yield*r.log.info(` 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)`),yield*r.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))),i&&(yield*r.log.info("Install the Zed `oxc` extension: zed://extension/oxc"))}),dr=(e,t,r)=>n.gen(function*(){let i=yield*Q,a=G.files[0].path;yield*i.withSpinner(i=>n.gen(function*(){let n=yield*G.detect(e);return yield*i.message(n?`\`${a}\` found, updating...`:`Creating \`${a}\`...`),yield*n?G.update(e,{packageManager:t,scripts:r}):G.create(e,{packageManager:t,scripts:r}),!n}),{failure:`Failed to set up GitHub Actions workflow.`,start:`Setting up GitHub Actions workflow...`,success:e=>`GitHub Actions workflow ${e?`created`:`updated`} successfully.`})}).pipe(n.catchTag([`FailedToCreateDirectory`,`FailedToParseFile`,`FailedToReadFile`,`FailedToWriteFile`,`PlatformError`],e=>n.gen(function*(){let t=yield*Q;yield*t.log.warning(`Could not set up the GitHub Actions workflow. ${e.message}`),yield*t.log.warning("Fix the reported problem and run `adamantite init` again, or create the workflow manually.")}))),fr=(e,t,r)=>n.gen(function*(){let i=yield*Q,a=yield*i.withSpinner(()=>rr(e,{packageManager:t,scripts:r}),{failure:`Failed to update AGENTS.md.`,start:`Updating AGENTS.md...`,success:`AGENTS.md check complete.`}).pipe(n.catchTag([`FailedToReadFile`,`FailedToWriteFile`],e=>n.gen(function*(){return yield*i.log.warning(`Could not update AGENTS.md. ${e.message} Adamantite will continue initialization.`),`failed`})));a!==`failed`&&a===`malformed`&&(yield*i.log.warning(`Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.`))}),pr=[`check`,`fix`,`format`,`check:monorepo`,`fix:monorepo`,`analyze`],mr=[`react`,`nextjs`,`vue`,`jest`,`vitest`,`node`,`antislop`],hr=[`vscode`,`zed`],gr=n.fn(`validateInitOptions`)(function*(e,t){let n={agents:e.agents,editors:c.dedupe(e.editors),githubActions:e.githubActions,installExtensions:e.installExtensions,overwriteScripts:e.overwriteScripts,presets:c.dedupe(e.presets),scripts:c.dedupe(e.scripts),typescript:e.typescript};if(n.scripts.length===0)return yield*new D({reason:"Select at least one script with `--script <name>`."});let r=n.scripts.includes(`check`)||n.scripts.includes(`fix`);return(n.scripts.includes(`check:monorepo`)||n.scripts.includes(`fix:monorepo`))&&!t.isMonorepo?yield*new D({reason:`Monorepo scripts can only be selected in a detected monorepo.`}):n.presets.length>0&&!r?yield*new D({reason:"`--preset` requires the `check` or `fix` script."}):n.typescript&&!r?yield*new D({reason:"`--typescript` requires the `check` or `fix` script."}):n.installExtensions&&n.editors.length===0?yield*new D({reason:"`--install-extensions` requires at least one `--editor`."}):n.githubActions&&!Bt(n.scripts)?yield*new D({reason:"`--github-actions` requires a CI-compatible script."}):n.githubActions&&t.nonInteractive&&!He(t.packageManager)?yield*new D({reason:`\`--github-actions\` does not support the detected package manager \`${t.packageManager}\`. Use bun, deno, npm, pnpm, or yarn.`}):n}),_r=u.boolean(`non-interactive`).pipe(u.withDescription(`Configure without prompts; requires at least one --script`)),vr=u.choice(`script`,pr).pipe(u.atMost(pr.length),u.withDescription(`Package script to configure; repeatable and required in non-interactive mode. Monorepo scripts require a detected monorepo`)),yr=u.choice(`preset`,mr).pipe(u.atMost(mr.length),u.withDescription(`Oxlint preset to configure; repeatable and requires --script check or fix`)),br=u.choice(`editor`,hr).pipe(u.atMost(hr.length),u.withDescription(`Editor to configure; may be specified multiple times`)),xr=u.boolean(`typescript`).pipe(u.withDescription(`Configure the TypeScript preset; requires --script check or fix`)),Sr=u.boolean(`install-extensions`).pipe(u.withDescription(`Install recommended extensions; requires at least one --editor`)),Cr=u.boolean(`github-actions`).pipe(u.withDescription(`Configure CI; requires a compatible script and bun, deno, npm, pnpm, or yarn`)),wr=u.boolean(`agents`).pipe(u.withDescription(`Add Adamantite guidance to AGENTS.md`)),Tr=u.boolean(`overwrite-scripts`).pipe(u.withDescription(`Replace existing package scripts that conflict with Adamantite's managed commands`)),Er=n.fn(`collectInteractiveInitOptions`)(function*(e,t){let n=yield*Q,r=yield*n.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:!t,hint:t?void 0:`available for monorepo projects`,label:`check:monorepo - check for monorepo-specific issues using Sherif`,value:`check:monorepo`},{disabled:!t,hint:t?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`}]}),i=We(yield*L(e),r),a=!1;if(i.length>0){for(let e of i)yield*n.log.warning(or(e));a=yield*n.confirm({initialValue:!1,message:i.length===1?`Overwrite this existing script with Adamantite's command?`:`Overwrite these existing scripts with Adamantite's commands?`})}let o=r.includes(`check`)||r.includes(`fix`),s=[];o&&(s=yield*n.multiselect({message:`Which presets do you want to install? (core is always included)`,options:[{hint:`React correctness, JSX accessibility, and render performance rules`,label:`react`,value:`react`},{hint:`Next.js pitfalls around scripts, fonts, images, and document/head usage`,label:`next.js`,value:`nextjs`},{hint:`Vue 3 correctness rules and deprecated API detection`,label:`vue`,value:`vue`},{hint:`Jest test hygiene: focused/disabled tests, matcher and snapshot discipline`,label:`jest`,value:`jest`},{hint:`Vitest test hygiene: focused/disabled tests, matcher and snapshot discipline`,label:`vitest`,value:`vitest`},{hint:`Node.js callback and CommonJS pitfalls`,label:`node`,value:`node`},{hint:`Rejects low-signal escape hatches: unjustified assertions, unknown leaks, module mocks`,label:`antislop`,value:`antislop`}],required:!1}));let c=o?yield*n.confirm({initialValue:!0,message:t?"Adamantite provides a TypeScript preset to enforce strict type-safety. In a monorepo, each package's `tsconfig.json` must extend it. Would you like instructions on how to set it up?":`Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?`}):!1,l=yield*n.multiselect({message:`Which editors do you want to configure? (optional)`,options:[{label:`VSCode / Cursor / Windsurf`,value:`vscode`},{label:`Zed`,value:`zed`}],required:!1}),u=l.length>0?yield*n.confirm({initialValue:!0,message:`Do you want to install the recommended editor extensions?`}):!1,d=Bt(r)?yield*n.confirm({message:`Do you want to add a GitHub Actions workflow to run checks in CI?`}):!1;return{agents:yield*n.confirm({initialValue:!0,message:`Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?`}),editors:l,githubActions:d,installExtensions:u,overwriteScripts:a,presets:s,scripts:r,typescript:c}});var Dr=l.make(`init`,{agents:wr,editors:br,githubActions:Cr,installExtensions:Sr,nonInteractive:_r,overwriteScripts:Tr,presets:yr,scripts:vr,typescript:xr}).pipe(l.withDescription(`Initialize Adamantite in the current directory. Setup flags require --non-interactive; omitted boolean setup flags are disabled`),l.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`}]),l.withHandler(e=>n.gen(function*(){let t=ne.cwd(),n=yield*Q;yield*zn(),yield*n.intro(`💠 adamantite init`);let r=yield*(yield*K).detectPackageManager(t);if(!r)return yield*new Oe({});if(r.warnings?.length)for(let e of r.warnings)yield*n.log.warning(e);yield*n.log.info(`Detected package manager: ${r.name}`);let i=yield*gn(t);if(i&&(yield*n.log.info(`We've detected a monorepo setup in your project.`)),!e.nonInteractive&&c.some([e.scripts.length>0,e.presets.length>0,e.editors.length>0,e.typescript,e.installExtensions,e.githubActions,e.agents,e.overwriteScripts],g.isTruthy))return yield*new D({reason:"Setup flags require `--non-interactive`."});let a=e.nonInteractive?e:yield*Er(t,i),o=yield*gr(a,{isMonorepo:i,nonInteractive:e.nonInteractive,packageManager:r.name}),s=o.scripts,l=o.presets,u=o.editors,d=o.typescript,ee=o.installExtensions,f=o.githubActions,p=o.agents,m=s.includes(`check`)||s.includes(`fix`),h=s.includes(`format`),_=s.includes(`check:monorepo`)||s.includes(`fix:monorepo`),te=s.includes(`analyze`),v=[`adamantite`];m&&v.push(`${V.name}@${V.version}`,`${W.name}@${W.version}`),h&&v.push(`${H.name}@${H.version}`),_&&v.push(`${U.name}@${U.version}`),te&&v.push(`${z.name}@${z.version}`),yield*ir(t,v),h&&(yield*ar(t,H,H.create(t))),m&&(yield*ar(t,V,V.create(t,l))),te&&(yield*ar(t,z,z.create(t)));let y=yield*sr(t,s,{nonInteractive:e.nonInteractive,overwriteScripts:o.overwriteScripts});if(p&&(yield*fr(t,r.name,y)),d&&(yield*cr(t,i)),yield*lr(t,u),ee&&(yield*ur(u,s)),f){let e=r.name;He(e)?yield*dr(t,e,s):yield*n.log.warning(`Skipping GitHub Actions setup: \`${e}\` is not a supported package manager for CI workflow generation.`)}yield*n.log.success(`Your project is now configured`),yield*n.outro(`💠 Adamantite initialized successfully!`)}).pipe(n.catchTags({OperationCancelled:()=>n.gen(function*(){yield*(yield*Q).cancel(`You've cancelled the initialization process.`)})}))));const Or=u.boolean(`fix`).pipe(u.withDescription(`Automatically fix issues`));var kr=l.make(`monorepo`,{fix:Or}).pipe(l.withDescription(`Find and fix monorepo-specific issues using Sherif`),l.withHandler(({fix:e})=>n.gen(function*(){let t=yield*A,n=yield*k,r=e?[`--fix`,...t]:[...t],i=yield*n.run({args:r,command:U.name,stdin:`inherit`});i!==s.ExitCode(0)&&(yield*new E({command:U.name,exitCode:i}))}))),Ar=l.make(`typecheck`).pipe(l.withDescription("Deprecated alias for `check`"),l.withHandler(()=>n.gen(function*(){let e=yield*A,t=yield*Q,n=yield*k;yield*t.log.warning("Deprecated. Use `adamantite check` for typechecking.");let r=yield*n.run({args:[...e],command:V.name});r!==s.ExitCode(0)&&(yield*new E({command:V.name,exitCode:r}))})));const jr=[V,W,H,U,z],Mr=[V,W,H,U,z];function Nr(e,t){return c.filterMap(Mr,n=>{if(t.has(n.name))return x.failVoid;let r=e.devDependencies?.[n.name]??e.dependencies?.[n.name];return r&&Be(r)!==n.version?x.succeed({currentVersion:r,name:n.name,targetVersion:n.version}):x.failVoid})}var Pr=l.make(`update`).pipe(l.withDescription(`Run applicable Adamantite migrations and update managed dependencies`),l.withHandler(()=>n.gen(function*(){let e=ne.cwd(),t=yield*Q,r=yield*K,i={cwd:e};yield*zn(),yield*t.intro(`💠 adamantite update`);let a=t=>Ln(jr,e,t),o=yield*a(),s=new Set,l=e=>n.gen(function*(){for(let n of e)s.has(n)||(s.add(n),yield*t.log.warning(n))});yield*l(o.flatMap(({assessment:e})=>e.warnings));let u=[];for(let e of Pn.filter(e=>e.tags.includes(`update`))){let n=yield*e.check(i);yield*l(n.warnings),n.status===`needed`&&(yield*l((yield*t.withSpinner(()=>Lt(e,i),{failure:`Migration "${e.title}" failed, files restored.`,start:n.summary,success:`Migration "${e.title}" completed successfully.`})).warnings),u.push(e.id))}u.length>0&&(yield*t.log.success(`Migrations ran successfully.`));let d=yield*L(e),ee=(yield*a(d)).flatMap(({assessment:e})=>e.actions),f=ee.filter(e=>e.type===`create_config`||e.type===`update_config`||e.type===`manual_fix`),p=c.filterMap(ee,e=>{switch(e.type){case`install_package`:return x.succeed({currentVersion:`not installed`,name:e.package,targetVersion:e.targetVersion});case`update_package`:return x.succeed({currentVersion:e.currentVersion,name:e.package,targetVersion:e.targetVersion});default:return x.failVoid}}),m=new Set(p.map(e=>e.name)),h=[...p,...Nr(d,m)];if(h.length>0){yield*t.log.info(`The following dependencies will be updated:`);for(let e of h)yield*t.log.info(` ${e.name}: ${e.currentVersion} → ${e.targetVersion}`);yield*t.withSpinner(()=>r.addDevDependencies(h.map(e=>`${e.name}@${e.targetVersion}`),e,{silent:!0}),{failure:`Failed to update dependencies`,start:`Updating dependencies...`,success:`Dependencies updated successfully`}),yield*t.log.success(`Dependencies updated successfully.`)}if(f.length>0){yield*t.log.warning("Some configuration follow-up belongs to `adamantite doctor --fix`.");for(let e of f)yield*t.log.warning(`Doctor follow-up: ${e.description}`)}return u.length===0&&h.length===0&&f.length===0?(yield*t.log.success(`No changes needed.`),`no-changes`):`success`}).pipe(n.tapError(()=>n.gen(function*(){yield*(yield*Q).outro(`❌ Update failed`)})),n.tap(e=>n.gen(function*(){let t=yield*Q;switch(e){case`no-changes`:yield*t.outro(`✅ Adamantite is already up to date.`);break;case`success`:yield*t.outro(`✅ Update completed successfully!`)}})))));const Fr=[it,jt,qn,Xn,kr,Ar],Ir=[it,jt,Hn,qn,Xn,Dr,kr,Ar,Pr],Lr=new Set(Ir.map(e=>e.name)),Rr=new Set(Fr.map(e=>e.name)),zr=l.make(`adamantite`).pipe(l.withDescription(`Opinionated preset package for modern TypeScript applications`),l.withSubcommands(Ir)),Br=n.fn(`runCli`)(function*(e,t){let[r,i]=c.splitWhere(e,e=>e===`--`),a=c.drop(i,1),o=r.find(e=>Lr.has(e));if(a.length>0&&o!==void 0&&!Rr.has(o))return yield*new Ae({command:o});yield*l.runWith(zr,{version:t})(r).pipe(n.provideService(A,a))}),Vr=n.gen(function*(){let e=yield*(yield*o.Stdio).args;yield*Br(e,`0.37.0`)}).pipe(n.as(0),n.catchTag(`CommandFailed`,e=>n.succeed(e.exitCode)),n.catch(e=>n.service(Q).pipe(n.flatMap(t=>t.log.error(e.message)),n.as(s.ExitCode(1)))),n.provide(i.mergeAll(t.layer,Xt.layer.pipe(i.provide(t.layer)),Q.layer,k.layer,K.layer)));e.runMain(Vr,{teardown:(e,t)=>{if(r.isSuccess(e)){t(Number(e.value));return}a.defaultTeardown(e,t)}});export{};
|
|
@@ -42,16 +42,23 @@ const config = {
|
|
|
42
42
|
"jsx-a11y/scope": "error",
|
|
43
43
|
"jsx-a11y/tabindex-no-positive": "error",
|
|
44
44
|
"react/button-has-type": "error",
|
|
45
|
+
"react/capitalized-calls": "error",
|
|
45
46
|
"react/checked-requires-onchange-or-readonly": "error",
|
|
46
47
|
"react/display-name": "off",
|
|
48
|
+
"react/error-boundaries": "error",
|
|
47
49
|
"react/exhaustive-deps": "error",
|
|
50
|
+
"react/exhaustive-effect-dependencies": "off",
|
|
48
51
|
"react/forward-ref-uses-ref": "error",
|
|
49
52
|
"react/function-component-definition": ["error", {
|
|
50
53
|
namedComponents: "function-declaration",
|
|
51
54
|
unnamedComponents: "arrow-function"
|
|
52
55
|
}],
|
|
56
|
+
"react/globals": "error",
|
|
53
57
|
"react/hook-use-state": "error",
|
|
58
|
+
"react/hooks": "error",
|
|
54
59
|
"react/iframe-missing-sandbox": "error",
|
|
60
|
+
"react/immutability": "error",
|
|
61
|
+
"react/incompatible-library": "error",
|
|
55
62
|
"react/jsx-boolean-value": "error",
|
|
56
63
|
"react/jsx-curly-brace-presence": ["error", {
|
|
57
64
|
children: "never",
|
|
@@ -68,11 +75,13 @@ const config = {
|
|
|
68
75
|
"react/jsx-no-useless-fragment": "error",
|
|
69
76
|
"react/jsx-pascal-case": "error",
|
|
70
77
|
"react/jsx-props-no-spread-multi": "error",
|
|
78
|
+
"react/memo-dependencies": "error",
|
|
71
79
|
"react/no-array-index-key": "error",
|
|
72
80
|
"react/no-children-prop": "error",
|
|
73
81
|
"react/no-clone-element": "error",
|
|
74
82
|
"react/no-danger": "error",
|
|
75
83
|
"react/no-danger-with-children": "error",
|
|
84
|
+
"react/no-deriving-state-in-effects": "error",
|
|
76
85
|
"react/no-direct-mutation-state": "error",
|
|
77
86
|
"react/no-find-dom-node": "error",
|
|
78
87
|
"react/no-is-mounted": "error",
|
|
@@ -89,13 +98,20 @@ const config = {
|
|
|
89
98
|
"react/no-unstable-nested-components": "error",
|
|
90
99
|
"react/prefer-es6-class": ["error", "always"],
|
|
91
100
|
"react/prefer-function-component": "error",
|
|
92
|
-
"react/
|
|
101
|
+
"react/preserve-manual-memoization": "error",
|
|
102
|
+
"react/purity": "error",
|
|
103
|
+
"react/refs": "error",
|
|
93
104
|
"react/require-render-return": "error",
|
|
94
105
|
"react/rules-of-hooks": "error",
|
|
95
106
|
"react/self-closing-comp": "error",
|
|
107
|
+
"react/set-state-in-effect": "error",
|
|
108
|
+
"react/set-state-in-render": "error",
|
|
96
109
|
"react/state-in-constructor": ["error", "never"],
|
|
110
|
+
"react/static-components": "error",
|
|
97
111
|
"react/style-prop-object": "error",
|
|
98
|
-
"react/
|
|
112
|
+
"react/use-memo": "error",
|
|
113
|
+
"react/void-dom-elements-no-children": "error",
|
|
114
|
+
"react/void-use-memo": "error"
|
|
99
115
|
}
|
|
100
116
|
};
|
|
101
117
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adamantite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "An strict and opinionated set of presets for modern TypeScript applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adamantite",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"figlet": "1.11.4",
|
|
78
78
|
"knip": "6.32.2",
|
|
79
79
|
"oxfmt": "0.63.0",
|
|
80
|
-
"oxlint": "1.
|
|
80
|
+
"oxlint": "1.79.0",
|
|
81
81
|
"oxlint-tsgolint": "7.0.2001",
|
|
82
82
|
"sherif": "1.13.0",
|
|
83
83
|
"tsdown": "0.22.14",
|
|
@@ -103,6 +103,7 @@
|
|
|
103
103
|
"format": "oxfmt",
|
|
104
104
|
"release": "changeset publish",
|
|
105
105
|
"test": "vitest run",
|
|
106
|
+
"test:build": "pnpm run build && node scripts/test-build.ts",
|
|
106
107
|
"test:coverage": "vitest run --coverage",
|
|
107
108
|
"test:watch": "vitest",
|
|
108
109
|
"version": "changeset version"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|