adamantite 0.34.1 → 0.34.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +140 -192
- package/dist/index.js +39 -39
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<h1 align="center">💠 Adamantite</h1>
|
|
3
3
|
<p align="center">
|
|
4
|
-
<strong>Opinionated
|
|
4
|
+
<strong>Opinionated code-quality tooling for modern TypeScript projects.</strong>
|
|
5
5
|
</p>
|
|
6
6
|
</p>
|
|
7
7
|
|
|
@@ -17,73 +17,61 @@
|
|
|
17
17
|
</a>
|
|
18
18
|
</p>
|
|
19
19
|
|
|
20
|
-
Adamantite
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
[TypeScript](https://www.typescriptlang.org/) and
|
|
24
|
-
[sherif](https://github.com/QuiiBz/sherif) that are designed to help humans and agents write
|
|
25
|
-
maintainable and scalable type-safe code, both for individual projects and monorepos.
|
|
20
|
+
Adamantite provides one CLI and a set of presets for linting, formatting, type checking,
|
|
21
|
+
dependency analysis, and monorepo checks. It configures Oxlint, Oxfmt, TypeScript, Knip,
|
|
22
|
+
and Sherif so humans and coding agents can use the same project workflow.
|
|
26
23
|
|
|
27
24
|
---
|
|
28
25
|
|
|
29
|
-
## Quick Start
|
|
30
|
-
|
|
31
|
-
Run the following command on your project to get started:
|
|
32
|
-
|
|
33
|
-
```shell
|
|
34
|
-
npx adamantite init
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Adamantite will automatically configure your project with linting, formatting, and type-safety rules.
|
|
38
|
-
|
|
39
|
-
```shell
|
|
40
|
-
adamantite check # Check code for issues and type errors using oxlint
|
|
41
|
-
adamantite fix # Fix code issues using oxlint
|
|
42
|
-
adamantite format # Format code using oxfmt
|
|
43
|
-
adamantite monorepo # Check monorepo for dependency issues using Sherif
|
|
44
|
-
adamantite update # Update Adamantite's dependencies to the latest compatible versions
|
|
45
|
-
```
|
|
46
|
-
|
|
47
26
|
## Features
|
|
48
27
|
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
-
|
|
56
|
-
|
|
28
|
+
- **Fast checks**: Run Oxlint and Oxfmt on the Oxc toolchain.
|
|
29
|
+
- **Strict defaults**: Use opinionated lint and TypeScript presets without assembling a
|
|
30
|
+
configuration from scratch.
|
|
31
|
+
- **Framework presets**: Add rules for React, Next.js, Vue, Node.js, Jest, or Vitest.
|
|
32
|
+
- **Project setup**: Create package scripts, configuration files, editor settings, and CI
|
|
33
|
+
through an interactive or non-interactive initializer.
|
|
34
|
+
- **Setup maintenance**: Assess managed integrations with `doctor`, apply safe fixes, and
|
|
35
|
+
migrate older Adamantite configurations.
|
|
36
|
+
- **Workspace checks**: Find unused code with Knip and dependency inconsistencies with
|
|
37
|
+
Sherif.
|
|
38
|
+
- **Agent guidance**: Add a managed Adamantite section to `AGENTS.md`.
|
|
57
39
|
|
|
58
|
-
##
|
|
40
|
+
## Quick start
|
|
59
41
|
|
|
60
|
-
|
|
42
|
+
Run the initializer from the root of a TypeScript project:
|
|
61
43
|
|
|
62
|
-
```
|
|
44
|
+
```sh
|
|
63
45
|
npx adamantite init
|
|
64
46
|
```
|
|
65
47
|
|
|
66
|
-
|
|
48
|
+
The interactive setup lets you choose package scripts, presets, TypeScript, editors, CI,
|
|
49
|
+
and agent guidance. After setup, use the scripts written to `package.json`:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
bun run check
|
|
53
|
+
bun run fix
|
|
54
|
+
bun run format
|
|
55
|
+
bun run analyze
|
|
56
|
+
```
|
|
67
57
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
- Create `oxfmt.config.ts` with formatting configuration
|
|
71
|
-
- Set up `tsconfig.json` with strict TypeScript rules
|
|
72
|
-
- Add lint/format scripts to your `package.json`
|
|
73
|
-
- Also adds monorepo-specific scripts if running a monorepo
|
|
74
|
-
- Configure editor settings
|
|
58
|
+
Use the equivalent `adamantite` commands directly when the project does not have managed
|
|
59
|
+
scripts:
|
|
75
60
|
|
|
76
|
-
|
|
61
|
+
```sh
|
|
62
|
+
adamantite check
|
|
63
|
+
adamantite fix
|
|
64
|
+
adamantite format
|
|
65
|
+
adamantite analyze
|
|
66
|
+
adamantite monorepo
|
|
67
|
+
```
|
|
77
68
|
|
|
78
|
-
|
|
79
|
-
`--script` is required, repeat `--script`, `--preset`, and `--editor` to select multiple
|
|
80
|
-
values, and add boolean flags only when that setup should be enabled.
|
|
69
|
+
## Non-interactive setup
|
|
81
70
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
npx adamantite init --non-interactive --script check
|
|
71
|
+
Use `--non-interactive` to configure a project entirely from flags. Specify at least one
|
|
72
|
+
`--script`. Repeat `--script`, `--preset`, and `--editor` to select multiple values.
|
|
85
73
|
|
|
86
|
-
|
|
74
|
+
```sh
|
|
87
75
|
npx adamantite init \
|
|
88
76
|
--non-interactive \
|
|
89
77
|
--script check \
|
|
@@ -91,7 +79,6 @@ npx adamantite init \
|
|
|
91
79
|
--script format \
|
|
92
80
|
--script analyze \
|
|
93
81
|
--preset react \
|
|
94
|
-
--preset node \
|
|
95
82
|
--editor vscode \
|
|
96
83
|
--typescript \
|
|
97
84
|
--install-extensions \
|
|
@@ -99,202 +86,163 @@ npx adamantite init \
|
|
|
99
86
|
--agents
|
|
100
87
|
```
|
|
101
88
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
- Scripts: `check`, `fix`, `format`, `analyze`, `check:monorepo`, and `fix:monorepo`
|
|
105
|
-
- Presets: `react`, `nextjs`, `vue`, `jest`, `vitest`, and `node`
|
|
106
|
-
- Editors: `vscode` and `zed`
|
|
107
|
-
|
|
108
|
-
Omitted boolean flags are disabled. Setup flags require `--non-interactive`; without it,
|
|
109
|
-
`adamantite init` keeps the interactive setup flow.
|
|
110
|
-
|
|
111
|
-
## 📋 Commands
|
|
89
|
+
Available setup values:
|
|
112
90
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
91
|
+
- Scripts: `check`, `fix`, `format`, `analyze`, `check:monorepo`, and `fix:monorepo`.
|
|
92
|
+
- Presets: `react`, `nextjs`, `vue`, `jest`, `vitest`, and `node`.
|
|
93
|
+
- Editors: `vscode` and `zed`.
|
|
116
94
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
# Automatically fix issues, including removing unused files
|
|
122
|
-
adamantite analyze --fix
|
|
95
|
+
Presets and TypeScript require the `check` or `fix` script. Editor extension installation
|
|
96
|
+
requires an editor. Monorepo scripts require a detected monorepo. GitHub Actions requires a
|
|
97
|
+
compatible script and a supported package manager. Omitted boolean flags are disabled.
|
|
123
98
|
|
|
124
|
-
|
|
125
|
-
adamantite analyze --strict
|
|
99
|
+
## Commands
|
|
126
100
|
|
|
127
|
-
|
|
128
|
-
adamantite analyze -- --directory packages/app
|
|
129
|
-
```
|
|
101
|
+
Run `adamantite --help` or `adamantite <command> --help` for the complete CLI reference.
|
|
130
102
|
|
|
131
103
|
### `adamantite check`
|
|
132
104
|
|
|
133
|
-
|
|
105
|
+
Find lint and type errors without changing files:
|
|
134
106
|
|
|
135
|
-
```
|
|
136
|
-
# Check all files
|
|
107
|
+
```sh
|
|
137
108
|
adamantite check
|
|
138
|
-
|
|
139
|
-
# Check specific files
|
|
140
|
-
adamantite check src/components/**/*.ts
|
|
109
|
+
adamantite check src
|
|
141
110
|
```
|
|
142
111
|
|
|
143
112
|
### `adamantite fix`
|
|
144
113
|
|
|
145
|
-
|
|
114
|
+
Apply safe Oxlint fixes. Suggested and dangerous fixes require explicit flags:
|
|
146
115
|
|
|
147
|
-
```
|
|
148
|
-
# Fix all files
|
|
116
|
+
```sh
|
|
149
117
|
adamantite fix
|
|
150
|
-
|
|
151
|
-
# Fix specific files
|
|
152
|
-
adamantite fix src/index.ts
|
|
153
|
-
|
|
154
|
-
# Apply suggested fixes
|
|
155
118
|
adamantite fix --suggested
|
|
156
|
-
|
|
157
|
-
# Apply dangerous fixes
|
|
158
119
|
adamantite fix --dangerous
|
|
159
|
-
|
|
160
|
-
# Apply all fixes
|
|
161
120
|
adamantite fix --all
|
|
162
121
|
```
|
|
163
122
|
|
|
164
123
|
### `adamantite format`
|
|
165
124
|
|
|
166
|
-
Format
|
|
125
|
+
Format files with Oxfmt, or check formatting without writing:
|
|
167
126
|
|
|
168
|
-
```
|
|
169
|
-
# Format all files
|
|
127
|
+
```sh
|
|
170
128
|
adamantite format
|
|
171
|
-
|
|
172
|
-
# Format specific files
|
|
173
129
|
adamantite format src/index.ts
|
|
174
|
-
|
|
175
|
-
# Check if files are formatted without writing
|
|
176
130
|
adamantite format --check
|
|
177
131
|
```
|
|
178
132
|
|
|
179
|
-
### `adamantite
|
|
180
|
-
|
|
181
|
-
Special tooling for monorepo projects using [Sherif](https://github.com/QuiiBz/sherif):
|
|
133
|
+
### `adamantite analyze`
|
|
182
134
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
adamantite monorepo
|
|
135
|
+
Find unused dependencies, exports, and files with Knip. The `--fix` option can remove
|
|
136
|
+
unused files, so review its effect before use.
|
|
186
137
|
|
|
187
|
-
|
|
188
|
-
adamantite
|
|
138
|
+
```sh
|
|
139
|
+
adamantite analyze
|
|
140
|
+
adamantite analyze --strict
|
|
141
|
+
adamantite analyze --fix
|
|
189
142
|
```
|
|
190
143
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
- Inconsistent dependency versions across packages
|
|
194
|
-
- Missing dependencies in package.json
|
|
195
|
-
- Unused dependencies
|
|
196
|
-
- Package.json formatting issues
|
|
197
|
-
|
|
198
|
-
### Passing arguments to underlying tools
|
|
144
|
+
### `adamantite monorepo`
|
|
199
145
|
|
|
200
|
-
|
|
201
|
-
the underlying CLI. Place Adamantite arguments before `--` and underlying CLI arguments
|
|
202
|
-
after it:
|
|
146
|
+
Find dependency consistency problems in a monorepo with Sherif:
|
|
203
147
|
|
|
204
|
-
```
|
|
205
|
-
adamantite
|
|
206
|
-
adamantite
|
|
207
|
-
adamantite format -- --ignore-path .formatignore
|
|
208
|
-
adamantite monorepo -- --ignore-package package-a
|
|
148
|
+
```sh
|
|
149
|
+
adamantite monorepo
|
|
150
|
+
adamantite monorepo --fix
|
|
209
151
|
```
|
|
210
152
|
|
|
211
|
-
|
|
212
|
-
second separator for Adamantite:
|
|
153
|
+
### `adamantite doctor`
|
|
213
154
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
155
|
+
Assess every Adamantite-managed integration. The default command is read-only. Use
|
|
156
|
+
`--fix` to install or update managed packages, create missing supported configurations,
|
|
157
|
+
update supported configurations, and run known migrations.
|
|
158
|
+
|
|
159
|
+
```sh
|
|
160
|
+
adamantite doctor
|
|
161
|
+
adamantite doctor --fix
|
|
162
|
+
adamantite doctor
|
|
217
163
|
```
|
|
218
164
|
|
|
219
|
-
|
|
220
|
-
commands do not invoke a single underlying CLI.
|
|
165
|
+
Manual-fix findings remain report-only.
|
|
221
166
|
|
|
222
167
|
### `adamantite update`
|
|
223
168
|
|
|
224
169
|
Run applicable migrations and update Adamantite-managed dependencies:
|
|
225
170
|
|
|
226
|
-
```
|
|
227
|
-
# Run migrations and update managed dependencies
|
|
171
|
+
```sh
|
|
228
172
|
adamantite update
|
|
173
|
+
adamantite doctor --fix
|
|
174
|
+
adamantite doctor
|
|
229
175
|
```
|
|
230
176
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
### Linting ([presets/lint/](./presets/lint/))
|
|
236
|
-
|
|
237
|
-
Adamantite provides comprehensive linting rules for TypeScript and JavaScript:
|
|
238
|
-
|
|
239
|
-
#### Core ([core.ts](./presets/lint/core.ts))
|
|
240
|
-
|
|
241
|
-
Extensive ruleset covering:
|
|
177
|
+
`update` handles known legacy transitions, including JSON Oxlint, Oxfmt, and Knip
|
|
178
|
+
configurations and the legacy type-check script. Use `doctor --fix` afterward to complete
|
|
179
|
+
safe setup repairs.
|
|
242
180
|
|
|
243
|
-
|
|
244
|
-
- **Performance**: Optimization patterns and performance best practices
|
|
245
|
-
- **Restriction**: Enforcing coding standards and preventing problematic patterns
|
|
246
|
-
- **Suspicious**: Detecting code smells and potential bugs
|
|
247
|
-
- **Pedantic**: Strict code quality and consistency enforcement
|
|
248
|
-
- **Style**: Consistent code formatting and naming conventions
|
|
249
|
-
- **Nursery**: Experimental rules under active development
|
|
181
|
+
### Pass arguments to underlying tools
|
|
250
182
|
|
|
251
|
-
|
|
183
|
+
Commands that invoke Knip, Oxlint, Oxfmt, or Sherif forward arguments after `--`:
|
|
252
184
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
- **Jest** ([jest.ts](./presets/lint/jest.ts)) - Jest testing rules
|
|
260
|
-
- **Vitest** ([vitest.ts](./presets/lint/vitest.ts)) - Vitest testing rules
|
|
261
|
-
|
|
262
|
-
### Formatting ([format.ts](./presets/format.ts))
|
|
263
|
-
|
|
264
|
-
Opinionated code formatting with oxfmt, configured for consistency and readability. The published formatter preset is available as `adamantite/format` and is designed to be used from `oxfmt.config.ts`.
|
|
265
|
-
|
|
266
|
-
### Analyze ([analyze.ts](./presets/analyze.ts))
|
|
267
|
-
|
|
268
|
-
Opinionated Knip configuration for dependency and unused-file analysis. The published analyze preset is available as `adamantite/analyze` and is designed to be used from `knip.config.ts`.
|
|
269
|
-
|
|
270
|
-
### TypeScript ([presets/tsconfig.json](./presets/tsconfig.json))
|
|
271
|
-
|
|
272
|
-
Strict TypeScript configuration for maximum type safety. Catches errors at compile-time that would otherwise cause runtime failures. The preset requires TypeScript 7 or newer.
|
|
273
|
-
|
|
274
|
-
````
|
|
185
|
+
```sh
|
|
186
|
+
adamantite analyze --strict -- --directory packages/app
|
|
187
|
+
adamantite check src -- --deny-warnings
|
|
188
|
+
adamantite format -- --ignore-path .formatignore
|
|
189
|
+
adamantite monorepo -- --ignore-package package-a
|
|
190
|
+
```
|
|
275
191
|
|
|
276
|
-
|
|
192
|
+
Package managers consume one separator, so package scripts need a second one:
|
|
277
193
|
|
|
278
|
-
|
|
194
|
+
```sh
|
|
195
|
+
bun run analyze -- -- --directory packages/app
|
|
196
|
+
npm run analyze -- -- --directory packages/app
|
|
197
|
+
```
|
|
279
198
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
bun install
|
|
199
|
+
`init`, `doctor`, and `update` do not forward arguments because they do not invoke one
|
|
200
|
+
underlying CLI.
|
|
283
201
|
|
|
284
|
-
|
|
285
|
-
bun test
|
|
202
|
+
## Presets
|
|
286
203
|
|
|
287
|
-
|
|
288
|
-
|
|
204
|
+
Adamantite publishes configuration that can also be consumed directly:
|
|
205
|
+
|
|
206
|
+
| Export | Purpose |
|
|
207
|
+
| ------------------------ | ------------------------------------------ |
|
|
208
|
+
| `adamantite/lint` | Core Oxlint rules. |
|
|
209
|
+
| `adamantite/lint/react` | React, JSX accessibility, and performance. |
|
|
210
|
+
| `adamantite/lint/nextjs` | Next.js rules. |
|
|
211
|
+
| `adamantite/lint/vue` | Vue rules. |
|
|
212
|
+
| `adamantite/lint/node` | Node.js rules. |
|
|
213
|
+
| `adamantite/lint/jest` | Jest rules. |
|
|
214
|
+
| `adamantite/lint/vitest` | Vitest rules. |
|
|
215
|
+
| `adamantite/format` | Oxfmt configuration. |
|
|
216
|
+
| `adamantite/analyze` | Knip configuration. |
|
|
217
|
+
| `adamantite/typescript` | Strict TypeScript configuration for TS 7+. |
|
|
218
|
+
|
|
219
|
+
## Requirements and boundaries
|
|
220
|
+
|
|
221
|
+
- Adamantite requires Node.js 24 or later when run with Node.js.
|
|
222
|
+
- This repository uses Bun, but the CLI can configure projects that use Bun, Deno, npm,
|
|
223
|
+
pnpm, or Yarn where the selected integration supports them.
|
|
224
|
+
- Adamantite manages recognized package scripts and supported configuration shapes. It
|
|
225
|
+
reports custom configurations that require manual work instead of overwriting them.
|
|
226
|
+
- `fix`, `format`, `analyze --fix`, `monorepo --fix`, `doctor --fix`, `init`, and `update`
|
|
227
|
+
can change project files. Review the resulting diff.
|
|
228
|
+
|
|
229
|
+
## Agent skill
|
|
230
|
+
|
|
231
|
+
Install the first-party Adamantite skill to teach coding agents how to initialize, assess,
|
|
232
|
+
repair, and update a project:
|
|
233
|
+
|
|
234
|
+
```sh
|
|
235
|
+
npx skills add adelrodriguez/adamantite --list
|
|
236
|
+
npx skills add adelrodriguez/adamantite --skill adamantite
|
|
237
|
+
```
|
|
289
238
|
|
|
290
|
-
|
|
291
|
-
bun run check
|
|
292
|
-
````
|
|
239
|
+
## Contributing
|
|
293
240
|
|
|
294
|
-
|
|
241
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the repository workflow. Contributors should
|
|
242
|
+
also read the [domain glossary](CONTEXT.md) and [architecture reference](docs/architecture.md).
|
|
295
243
|
|
|
296
|
-
|
|
244
|
+
## License
|
|
297
245
|
|
|
298
|
-
|
|
246
|
+
Adamantite uses the [MIT License](LICENSE).
|
|
299
247
|
|
|
300
|
-
|
|
248
|
+
Made with [🥐 `pastry`](https://github.com/adelrodriguez/pastry)
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import*as
|
|
2
|
-
`)}class
|
|
3
|
-
`)}}class R extends F.TaggedError("FailedToReadFile"){get message(){return`Failed to read ${this.path?`\`${this.path}\``:"the target file"}.`}}class ne extends F.TaggedError("FailedToDeleteFile"){get message(){return`Failed to delete ${this.path?`\`${this.path}\``:"the target file"}.`}}class
|
|
1
|
+
import*as Qr from"@effect/platform-node/NodeRuntime";import*as Wr from"@effect/platform-node/NodeServices";import*as _ from"effect/Effect";import*as Zr from"effect/Exit";import*as Xr from"effect/Layer";import*as Yr from"effect/Runtime";import*as Hr from"effect/Stdio";import*as Kr from"effect/unstable/process/ChildProcessSpawner";import*as Vt from"effect/Array";import*as Pt from"effect/Effect";import*as de from"effect/unstable/cli/Command";import*as pn from"effect/Effect";import*as fe from"effect/unstable/cli/Command";import*as Ie from"effect/unstable/cli/Flag";import*as un from"effect/unstable/process/ChildProcessSpawner";import*as re from"effect/Effect";import*as ot from"effect/FileSystem";import*as it from"effect/Path";function I(e,...t){return e}import*as F from"effect/Data";import{printParseErrorCode as xr}from"jsonc-parser";function Lr(e=[]){if(e.length===0)return"- Unknown JSON/JSONC parsing error";return e.slice(0,3).map((t)=>`- ${xr(t.error)} (offset: ${t.offset})`).join(`
|
|
2
|
+
`)}class It extends F.TaggedError("CliNotFound"){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}}class q extends F.TaggedError("CommandFailed"){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}}class ge extends F.TaggedError("FailedToCreateDirectory"){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:"the target directory"}.`}}class Nt extends F.TaggedError("FailedToInstallDependency"){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(", ")}`:""}.`}}class tt extends F.TaggedError("FailedToInstallExtension"){get message(){return`Failed to install ${this.extension?`\`${this.extension}\``:"the target extension"}.`}}class Tt extends F.TaggedError("FailedToMergeConfig"){get message(){return`Failed to merge configuration.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class _t extends F.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:",Lr(this.errors)].join(`
|
|
3
|
+
`)}}class R extends F.TaggedError("FailedToReadFile"){get message(){return`Failed to read ${this.path?`\`${this.path}\``:"the target file"}.`}}class ne extends F.TaggedError("FailedToDeleteFile"){get message(){return`Failed to delete ${this.path?`\`${this.path}\``:"the target file"}.`}}class S extends F.TaggedError("FailedToWriteFile"){get message(){return`Failed to write ${this.path?`\`${this.path}\``:"the target file"}.`}}class bt extends F.TaggedError("FileNotFound"){get message(){return this.path?`File not found: \`${this.path}\`.`:"File not found."}}class Z extends F.TaggedError("InvalidConfigFormat"){get message(){return`Invalid config format in ${this.path?`\`${this.path}\``:"the target config file"}. The config must be a JSON object (for example: {}).`}}class w extends F.TaggedError("InvalidInitOptions"){get message(){return`Invalid init options. ${this.reason}`}}class qt extends F.TaggedError("UnsupportedConfigState"){get message(){let e=this.path?`\`${this.path}\``:"the target config file",t=this.reason?` ${this.reason}`:"";return`Unsupported config state in ${e}.${t}`}}class Xe extends F.TaggedError("NoPackageManager"){get message(){return`No package manager detected. Please run this command from a project with a lockfile.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class Mr extends F.TaggedError("MissingPackageVersion"){get message(){let e=this.path?`\`${this.path}\``:"package.json";if(this.dependency)return`Missing \`${this.dependency}\` in ${e} dependencies or devDependencies.`;return`Missing version field in ${e}.`}}class x extends F.TaggedError("MigrationValidationFailed"){get message(){return`Migration \`${this.migrationId}\` validation failed. ${this.reason}`}}class nt extends F.TaggedError("OperationCancelled"){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:""}`}}class zt extends F.TaggedError("PassthroughNotSupported"){get message(){return`Command \`adamantite ${this.command}\` does not invoke a single underlying CLI and cannot accept passthrough arguments.`}}class Jt extends F.TaggedError("UnknownScript"){get message(){return`Unknown script: \`${this.script}\`.`}}class Ut extends F.TaggedError("VscodeCliNotFound"){get message(){return`VS Code CLI (\`code\`) not found. Please install it to manage extensions.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}import{defu as wr}from"defu";import*as G from"effect/Effect";import{parse as Gr}from"jsonc-parser";var A=(e,t)=>G.sync(()=>{let n=[],r=Gr(e,n,{allowTrailingComma:!0});return{errors:n,parsed:r}}).pipe(G.flatMap(({errors:n,parsed:r})=>n.length>0?G.fail(new _t({errors:n,path:t})):G.succeed(r)));function Re(e,t={}){let{continuationIndent:n,indentation:r=2}=t,o=JSON.stringify(e,null,r).replaceAll(/"([A-Za-z_$][\w$]*)":/g,"$1:");if(!n)return o;return o.replaceAll(`
|
|
4
4
|
`,`
|
|
5
|
-
${n}`)}var De=(e,t)=>G.try({catch:(n)=>new
|
|
5
|
+
${n}`)}var De=(e,t)=>G.try({catch:(n)=>new Tt({cause:n}),try:()=>wr(e,t)});function rt(e={}){let t=Object.entries(e).map(([n,r])=>{if(n==="rules"&&typeof r==="object"&&r!==null&&!Array.isArray(r))return[" rules: {"," ...analyze.rules,",...Object.entries(r).map(([i,s])=>` ${i}: ${Re(s,{continuationIndent:" ",indentation:" "})},`)," },"].join(`
|
|
6
6
|
`);return` ${n}: ${Re(r)},`});if(t.length===0)return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = analyze","","export default config",""].join(`
|
|
7
7
|
`);return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = {"," ...analyze,",...t,"}","","export default config",""].join(`
|
|
8
|
-
`)}import
|
|
9
|
-
`).pipe(Ve.mapError((i)=>new
|
|
10
|
-
`);return[...i,"","export default defineConfig({",
|
|
11
|
-
`)}
|
|
8
|
+
`)}import Cr from"node:process";import*as Ve from"effect/Effect";import*as At from"effect/FileSystem";import*as kt from"effect/Path";var eo=/^workspace:/,to=/^[\^~]/;function Y(e){return e.trim().replace(eo,"").replace(to,"")}var v=(e=Cr.cwd())=>Ve.gen(function*(){let t=yield*At.FileSystem,r=(yield*kt.Path).join(e,"package.json"),o=yield*t.readFileString(r).pipe(Ve.mapError((s)=>new R({cause:s,path:r})));return yield*A(o,r)}),on=(e,t)=>Ve.gen(function*(){let n=yield*At.FileSystem,o=(yield*kt.Path).join(e,"package.json");yield*n.writeFileString(o,`${JSON.stringify(t,null,2)}
|
|
9
|
+
`).pipe(Ve.mapError((i)=>new S({cause:i,path:o})))});function Ye(e){return e==="bun"||e==="deno"||e==="npm"||e==="pnpm"||e==="yarn"}var He={analyze:"adamantite analyze",check:"adamantite check","check:monorepo":"adamantite monorepo",fix:"adamantite fix","fix:monorepo":"adamantite monorepo --fix",format:"adamantite format"};function H(e){let t=e.scripts??{},n=[];for(let[r,o]of Object.entries(He))if(t[r]===o)n.push(r);return n}var k=[{path:"knip.config.ts",type:"config"},{path:"knip.json",type:"legacy_config"},{path:"knip.jsonc",type:"legacy_config"}];var m=I({assess:(e)=>re.gen(function*(){let t=yield*ot.FileSystem,n=yield*it.Path,r=yield*v(e);if(!H(r).includes("analyze"))return{applicable:!1,warnings:[]};let i=r.devDependencies?.knip??r.dependencies?.knip,s=n.join(e,k[0].path),a=n.join(e,k[1].path),f=n.join(e,k[2].path),{hasConfig:l,hasLegacyJson:p,hasLegacyJsonc:u}=yield*re.all({hasConfig:t.exists(s),hasLegacyJson:t.exists(a),hasLegacyJsonc:t.exists(f)},{concurrency:"unbounded"}),E=l?"ts":u?"jsonc":p?"json":null,j=[],N=[];if(l&&(p||u))N.push("Found both `knip.config.ts` and `knip.json(c)`. Adamantite will use `knip.config.ts`.");if(!l&&p&&u)N.push("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(!i)j.push({description:`Install \`knip@${"6.31.0"}\` for the managed \`analyze\` script.`,package:"knip",targetVersion:"6.31.0",type:"install_package"});else if(Y(i)!=="6.31.0")j.push({currentVersion:i,description:`Update \`knip\` from \`${i}\` to \`${"6.31.0"}\`.`,package:"knip",targetVersion:"6.31.0",type:"update_package"});if(E===null)j.push({description:`Create \`${k[0].path}\` for \`knip\`.`,path:k[0].path,type:"create_config"});if(E==="json"||E==="jsonc")j.push({description:`Migrate legacy \`${E==="json"?k[1].path:k[2].path}\` to \`${k[0].path}\`.`,migrationId:"legacy-knip-json",type:"run_migration"});return{actions:j,applicable:!0,warnings:N}}),config:k[0].path,create:(e)=>re.gen(function*(){let t=yield*ot.FileSystem,r=(yield*it.Path).join(e,k[0].path);yield*t.writeFileString(r,rt()).pipe(re.mapError((o)=>new S({cause:o,path:r})))}),detect:(e)=>re.gen(function*(){let t=yield*ot.FileSystem,n=yield*it.Path,r=n.join(e,k[0].path),o=n.join(e,k[1].path),i=n.join(e,k[2].path),{hasJson:s,hasJsonc:a,hasTs:f}=yield*re.all({hasJson:t.exists(o),hasJsonc:t.exists(i),hasTs:t.exists(r)},{concurrency:"unbounded"}),l=f?"ts":a?"jsonc":s?"json":null,p=[];if(f&&s)p.push({format:"json",path:o});if(f&&a)p.push({format:"jsonc",path:i});if(!f&&s&&a)p.push({format:"json",path:o});return{active:l===null?null:{format:l,path:l==="ts"?r:l==="jsonc"?i:o},legacy:p}}),files:k,kind:"tooling",name:"knip",version:"6.31.0"});import*as sn from"effect/Context";import*as Pe from"effect/Effect";import*as an from"effect/Layer";import*as fn from"effect/unstable/process/ChildProcess";class T extends sn.Service()("CommandRunner"){static layer=an.succeed(this)({run:({args:e,command:t,cwd:n,stderr:r="inherit",stdin:o="ignore",stdout:i="inherit"})=>Pe.mapError(Pe.scoped(Pe.gen(function*(){return yield*(yield*fn.make(t,e,{cwd:n,stderr:r,stdin:o,stdout:i})).exitCode})),(s)=>s.reason._tag==="NotFound"?new It({command:t}):s)})}import*as ln from"effect/Context";var B=ln.Reference("adamantite/ForwardedArguments",{defaultValue:()=>[]});var no=Ie.boolean("fix").pipe(Ie.withDescription("Automatically fix issues")),ro=Ie.boolean("strict").pipe(Ie.withDescription("Enable strict mode")),Bt=fe.make("analyze",{fix:no,strict:ro}).pipe(fe.withDescription("Find unused dependencies, exports, and files using knip"),fe.withExamples([{command:"adamantite analyze -- --directory packages/app",description:"Run knip from a specific directory"}]),fe.withHandler(({fix:e,strict:t})=>pn.gen(function*(){let n=yield*B,r=yield*T,o=[];if(e)o.push("--fix","--allow-remove-files");if(t)o.push("--production","--strict");o.push(...n);let i=yield*r.run({args:o,command:m.name});if(i!==un.ExitCode(0))yield*new q({command:m.name,exitCode:i})})));import*as jn from"effect/Effect";import*as Ne from"effect/unstable/cli/Argument";import*as Te from"effect/unstable/cli/Command";import*as $n from"effect/unstable/process/ChildProcessSpawner";import*as X from"effect/Effect";import*as Ke from"effect/FileSystem";import*as xe from"effect/Path";import*as g from"effect/Option";import*as En from"effect/Predicate";import{print as oo}from"esrap";import io from"esrap/languages/ts";import{parseSync as so}from"oxc-parser";var gn=["respectEslintDisableDirectives","typeAware","typeCheck"],cn="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",yn="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",mn="`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.",On="Adamantite could not generate the required `options` patch.";function st(e=[]){return e.includes("core")?e:["core",...e]}function hn(e){return e.replaceAll(/-([a-z])/g,(t,n)=>n.toUpperCase())}function at(e,t,n=[]){let{options:r,...o}=e,i=['import { defineConfig } from "oxlint"',...t.map((E)=>`import ${hn(E)} from "${E==="core"?"adamantite/lint":`adamantite/lint/${E}`}"`)],a=[...t.map((E)=>hn(E)),...n.map((E)=>JSON.stringify(E))],f=JSON.stringify(En.isObject(r)?{...r,respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0}:{respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0},null,2),l=Object.entries(o).map(([E,j])=>[E,JSON.stringify(j,null,2)]),p=`[${a.join(", ")}]`,u=[["options",f],...l,["extends",p]].map(([E,j])=>` ${E}: ${j},`).join(`
|
|
10
|
+
`);return[...i,"","export default defineConfig({",u,"})",""].join(`
|
|
11
|
+
`)}var ao=g.liftThrowable((e)=>so("oxlint.config.ts",e,{astType:"ts",lang:"ts",sourceType:"module"}));function Qt(e){return ao(e).pipe(g.flatMap((t)=>t.errors.length===0?g.fromNullishOr(t.program):g.none()))}function Sn(e){let{code:t}=oo(e,io({quotes:"double"}));return t.endsWith(`
|
|
12
12
|
`)?t:`${t}
|
|
13
|
-
`}function
|
|
14
|
-
`,n=
|
|
15
|
-
`,t=
|
|
13
|
+
`}function dn(e){if(e.type==="Identifier")return e.name;if(e.type==="Literal"&&typeof e.value==="string")return e.value;return null}function Wt(e){let t=e.body.filter((i)=>i.type==="ExportDefaultDeclaration");if(t.length!==1)return g.none();let[n]=t;if(!n)return g.none();let r=n.declaration;if(r.type==="ObjectExpression")return g.fromNullishOr(r);if(r.type!=="CallExpression")return g.none();if(r.callee.type!=="Identifier"||r.callee.name!=="defineConfig")return g.none();if(r.arguments.length!==1)return g.none();let[o]=r.arguments;if(o?.type==="ObjectExpression")return g.fromNullishOr(o);return g.none()}function Zt(e,t){let n=null;for(let r of e.properties){if(r.type==="SpreadElement")return{status:"manual"};if(r.computed)return{status:"manual"};if(r.method||r.kind!=="init"){if(dn(r.key)===t)return{status:"manual"};continue}if(dn(r.key)!==t)continue;if(n)return{status:"manual"};n=r}if(!n)return{status:"missing"};return{property:n,status:"found"}}function fo(e){let t=`export default { options: { ${e.map((s)=>`${s}: true`).join(", ")} } }
|
|
14
|
+
`,n=Qt(t);if(g.isNone(n))return g.none();let r=Wt(n.value);if(g.isNone(r))return g.none();let o=Zt(r.value,"options");if(o.status!=="found")return g.none();if(o.property.value.type!=="ObjectExpression")return g.none();let i=o.property.value.properties.filter((s)=>s.type==="Property");return i.length===o.property.value.properties.length?g.fromNullishOr(i):g.none()}function lo(){let e=`export default { options: { ${gn.map((o)=>`${o}: true`).join(", ")} } }
|
|
15
|
+
`,t=Qt(e);if(g.isNone(t))return g.none();let n=Wt(t.value);if(g.isNone(n)||n.value.properties.length!==1)return g.none();let[r]=n.value.properties;if(r?.type!=="Property"||r.computed||r.method||r.kind!=="init")return g.none();return g.fromNullishOr(r)}function po(e,t){let n=[],r=!1;for(let o of gn){let i=Zt(t,o);if(i.status==="manual")return{kind:"manual",reason:mn};if(i.status==="missing"){n.push(o);continue}let s=i.property.value;if(s.type!=="Literal"||typeof s.value!=="boolean")return{kind:"manual",reason:mn};if(s.value)continue;s.raw="true",s.value=!0,r=!0}if(n.length>0){let o=fo(n);if(g.isNone(o))return{kind:"manual",reason:On};t.properties.unshift(...o.value),r=!0}if(!r)return{kind:"configured"};return{kind:"patchable",updatedContent:Sn(e)}}function Xt(e){let t=Qt(e);if(g.isNone(t))return{kind:"manual",reason:cn};let n=Wt(t.value);if(g.isNone(n))return{kind:"manual",reason:cn};let r=Zt(n.value,"options");if(r.status==="manual")return{kind:"manual",reason:yn};if(r.status==="missing"){let o=lo();if(g.isNone(o))return{kind:"manual",reason:On};return n.value.properties.unshift(o.value),{kind:"patchable",updatedContent:Sn(t.value)}}if(r.property.value.type!=="ObjectExpression")return{kind:"manual",reason:yn};return po(t.value,r.property.value)}var z=[{path:"oxlint.config.ts",type:"config"},{path:".oxlintrc.json",type:"legacy_config"}];var y=I({assess:(e)=>X.gen(function*(){let t=yield*Ke.FileSystem,n=yield*xe.Path,r=yield*v(e),o=H(r);if(!o.includes("check")&&!o.includes("fix"))return{applicable:!1,warnings:[]};let i=r.devDependencies?.oxlint??r.dependencies?.oxlint,s=n.join(e,z[0].path),a=n.join(e,z[1].path),{hasJson:f,hasTs:l}=yield*X.all({hasJson:t.exists(a),hasTs:t.exists(s)},{concurrency:"unbounded"}),p={active:l?{format:"ts",path:s}:f?{format:"json",path:a}:null,legacy:l&&f?[{format:"json",path:a}]:[]},u=[],E=[];if(p.active?.format==="ts"&&p.legacy.length>0)E.push("Found both `oxlint.config.ts` and `.oxlintrc.json`. Adamantite will use `oxlint.config.ts`.");if(!i)u.push({description:`Install \`oxlint@${"1.77.0"}\` for the managed lint scripts.`,package:"oxlint",targetVersion:"1.77.0",type:"install_package"});else if(Y(i)!=="1.77.0")u.push({currentVersion:i,description:`Update \`oxlint\` from \`${i}\` to \`${"1.77.0"}\`.`,package:"oxlint",targetVersion:"1.77.0",type:"update_package"});if(p.active===null)u.push({description:`Create \`${z[0].path}\` for \`oxlint\`.`,path:z[0].path,type:"create_config"});if(p.active?.format==="json")u.push({description:`Migrate legacy \`${z[1].path}\` to \`${z[0].path}\`.`,migrationId:"legacy-oxlint-json",type:"run_migration"});if(p.active?.format==="ts"){let j=yield*t.readFileString(s).pipe(X.mapError((P)=>new R({cause:P,path:s}))),N=Xt(j);if(N.kind==="patchable")u.push({description:"Update `oxlint.config.ts` with Adamantite's required options.",path:z[0].path,type:"update_config"});if(N.kind==="manual")u.push({description:"Manually update `oxlint.config.ts` with Adamantite's required options; Adamantite cannot patch the current file shape safely.",path:z[0].path,type:"manual_fix"})}return{actions:u,applicable:!0,warnings:E}}),config:z[0].path,create:(e,t=[])=>X.gen(function*(){let n=yield*Ke.FileSystem,o=(yield*xe.Path).join(e,z[0].path),i=at({},st(t));yield*n.writeFileString(o,i).pipe(X.mapError((s)=>new S({cause:s,path:o})))}),detect:(e)=>X.gen(function*(){let t=yield*Ke.FileSystem,n=yield*xe.Path,r=n.join(e,z[0].path),o=n.join(e,z[1].path),{hasJson:i,hasTs:s}=yield*X.all({hasJson:t.exists(o),hasTs:t.exists(r)},{concurrency:"unbounded"}),a=s?"ts":i?"json":null,f=[];if(s&&i)f.push({format:"json",path:o});return{active:a===null?null:{format:a,path:a==="ts"?r:o},legacy:f}}),files:z,kind:"tooling",name:"oxlint",update:(e)=>X.gen(function*(){let t=yield*Ke.FileSystem,r=(yield*xe.Path).join(e,z[0].path);if(!(yield*t.exists(r)))return yield*new bt({path:z[0].path});let o=yield*t.readFileString(r).pipe(X.mapError((s)=>new R({cause:s,path:r}))),i=Xt(o);if(i.kind==="configured")return;if(i.kind==="manual")return yield*new qt({path:z[0].path,reason:i.reason});yield*t.writeFileString(r,i.updatedContent).pipe(X.mapError((s)=>new S({cause:s,path:r})))}),version:"1.77.0"});var uo=Ne.file("files",{mustExist:!0}).pipe(Ne.withDescription("Specific files to lint (optional)"),Ne.variadic()),Yt=Te.make("check",{files:uo}).pipe(Te.withDescription("Find issues and type errors in code using oxlint"),Te.withHandler(({files:e})=>jn.gen(function*(){let t=yield*B,r=yield*(yield*T).run({args:[...e,...t],command:y.name});if(r!==$n.ExitCode(0))yield*new q({command:y.name,exitCode:r})})));import Po from"node:process";import*as be from"effect/Effect";import*as qe from"effect/unstable/cli/Command";import*as St from"effect/unstable/cli/Flag";import*as Lt from"effect/unstable/process/ChildProcessSpawner";import*as oe from"effect/Effect";import*as lt from"effect/FileSystem";import*as pt from"effect/Path";import*as Fn from"effect/Predicate";var co=new Set(["sortImports","sortPackageJson","sortTailwindcss"]);function yo(e){let t=e.split(`
|
|
16
16
|
`);if(t.length===1)return e.slice(1,-1).trim();return t.slice(1,-1).map((n)=>` ${n.trimStart()}`).join(`
|
|
17
|
-
`)}function
|
|
18
|
-
`)}function
|
|
17
|
+
`)}function mo(e,t){let n=Re(t),r=yo(n);return[` ${e}: {`,` ...format.${e},`,...r===""?[]:[r]," },"].join(`
|
|
18
|
+
`)}function ft(e={}){let t=Object.entries(e).map(([n,r])=>{if(co.has(n)&&Fn.isObject(r))return mo(n,r);let o=Re(r,{continuationIndent:" "});return` ${n}: ${o},`});if(t.length===0)return['import { defineConfig } from "oxfmt"','import format from "adamantite/format"',"","export default defineConfig(format)",""].join(`
|
|
19
19
|
`);return['import { defineConfig } from "oxfmt"','import format from "adamantite/format"',"","export default defineConfig({"," ...format,",...t,"})",""].join(`
|
|
20
|
-
`)}var Q=[{path:"oxfmt.config.ts",type:"config"},{path:".oxfmtrc.json",type:"legacy_config"},{path:".oxfmtrc.jsonc",type:"legacy_config"}];var m=I({assess:(e)=>oe.gen(function*(){let t=yield*pt.FileSystem,n=yield*ut.Path,r=yield*v(e);if(!H(r).includes("format"))return{applicable:!1,warnings:[]};let i=r.devDependencies?.oxfmt??r.dependencies?.oxfmt,s=n.join(e,Q[0].path),a=n.join(e,Q[1].path),u=n.join(e,Q[2].path),{hasConfig:f,hasLegacyJson:l,hasLegacyJsonc:p}=yield*oe.all({hasConfig:t.exists(s),hasLegacyJson:t.exists(a),hasLegacyJsonc:t.exists(u)},{concurrency:"unbounded"}),E=f?"ts":p?"jsonc":l?"json":null,S=[],T=[];if(f&&(l||p))T.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(!f&&l&&p)T.push("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(!i)S.push({description:`Install \`oxfmt@${"0.62.0"}\` for the managed \`format\` script.`,package:"oxfmt",targetVersion:"0.62.0",type:"install_package"});else if(Y(i)!=="0.62.0")S.push({currentVersion:i,description:`Update \`oxfmt\` from \`${i}\` to \`${"0.62.0"}\`.`,package:"oxfmt",targetVersion:"0.62.0",type:"update_package"});if(E===null)S.push({description:`Create \`${Q[0].path}\` for \`oxfmt\`.`,path:Q[0].path,type:"create_config"});if(E==="json"||E==="jsonc")S.push({description:`Migrate legacy \`${E==="json"?Q[1].path:Q[2].path}\` to \`${Q[0].path}\`.`,migrationId:"legacy-oxfmt-json",type:"run_migration"});return{actions:S,applicable:!0,warnings:T}}),config:Q[0].path,create:(e)=>oe.gen(function*(){let t=yield*pt.FileSystem,r=(yield*ut.Path).join(e,Q[0].path);yield*t.writeFileString(r,lt()).pipe(oe.mapError((o)=>new j({cause:o,path:r})))}),detect:(e)=>oe.gen(function*(){let t=yield*pt.FileSystem,n=yield*ut.Path,r=n.join(e,Q[0].path),o=n.join(e,Q[1].path),i=n.join(e,Q[2].path),{hasJson:s,hasJsonc:a,hasTs:u}=yield*oe.all({hasJson:t.exists(o),hasJsonc:t.exists(i),hasTs:t.exists(r)},{concurrency:"unbounded"}),f=u?"ts":a?"jsonc":s?"json":null,l=[];if(u&&s)l.push({format:"json",path:o});if(u&&a)l.push({format:"jsonc",path:i});if(!u&&s&&a)l.push({format:"json",path:o});return{active:f===null?null:{format:f,path:f==="ts"?r:f==="jsonc"?i:o},legacy:l}}),files:Q,kind:"tooling",name:"oxfmt",version:"0.62.0"});import*as vn from"effect/Effect";var L=I({assess:(e)=>vn.gen(function*(){let t=yield*v(e),n=H(t);if(!n.includes("check:monorepo")&&!n.includes("fix:monorepo"))return{applicable:!1,warnings:[]};let r=t.devDependencies?.sherif??t.dependencies?.sherif,o=[];if(!r)o.push({description:`Install \`sherif@${"1.13.0"}\` for the managed monorepo scripts.`,package:"sherif",targetVersion:"1.13.0",type:"install_package"});else if(Y(r)!=="1.13.0")o.push({currentVersion:r,description:`Update \`sherif\` from \`${r}\` to \`${"1.13.0"}\`.`,package:"sherif",targetVersion:"1.13.0",type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"sherif",version:"1.13.0"});import*as Rn from"effect/Effect";var le=I({assess:(e)=>Rn.gen(function*(){let t=yield*v(e),n=H(t);if(!n.includes("check")&&!n.includes("fix"))return{applicable:!1,warnings:[]};let r=t.devDependencies?.["oxlint-tsgolint"]??t.dependencies?.["oxlint-tsgolint"],o=[];if(!r)o.push({description:`Install \`oxlint-tsgolint@${"7.0.2001"}\` for the managed lint scripts.`,package:"oxlint-tsgolint",targetVersion:"7.0.2001",type:"install_package"});else if(Y(r)!=="7.0.2001")o.push({currentVersion:r,description:`Update \`oxlint-tsgolint\` from \`${r}\` to \`${"7.0.2001"}\`.`,package:"oxlint-tsgolint",targetVersion:"7.0.2001",type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"oxlint-tsgolint",version:"7.0.2001"});import*as W from"effect/Effect";import*as Dn from"effect/FileSystem";import*as Vn from"effect/Path";function pe(e){return e}function Le(e,t,n){return W.gen(function*(){let r=yield*Dn.FileSystem,o=yield*Vn.Path,i=e.files??[],s=new Map;for(let a of i){let u=o.join(t.cwd,a);if(yield*r.exists(u)){let l=yield*r.readFileString(u);s.set(u,l)}else s.set(u,null)}yield*e.migrate(t).pipe(W.andThen(()=>e.validate?.(t)??W.void),W.onError(()=>W.gen(function*(){if(n?.onRestore)yield*n.onRestore;for(let[a,u]of s){if(u!==null){yield*r.writeFileString(a,u).pipe(W.ignore);continue}if(!(yield*r.exists(a).pipe(W.orElseSucceed(()=>!1))))continue;yield*r.remove(a).pipe(W.ignore)}})))})}import*as C from"effect/Effect";import*as Tn from"effect/FileSystem";import*as _n from"effect/Path";import*as D from"@clack/prompts";import*as Pn from"effect/Context";import*as V from"effect/Effect";import*as In from"effect/Exit";import*as Nn from"effect/Layer";class O extends Pn.Service()("Prompter"){static layer=Nn.succeed(this)({cancel:(e)=>V.sync(()=>{D.cancel(e)}),confirm:(e)=>V.promise(()=>D.confirm(e)).pipe(V.filterOrFail((t)=>!D.isCancel(t),()=>new nt({}))),intro:(e)=>V.sync(()=>{D.intro(e)}),log:{error:(e)=>V.sync(()=>{D.log.error(e)}),info:(e)=>V.sync(()=>{D.log.info(e)}),success:(e)=>V.sync(()=>{D.log.success(e)}),warning:(e)=>V.sync(()=>{D.log.warning(e)})},multiselect:(e)=>V.promise(()=>D.multiselect(e)).pipe(V.filterOrFail((t)=>!D.isCancel(t),()=>new nt({}))),outro:(e)=>V.sync(()=>{D.outro(e)}),withSpinner:(e,t)=>V.acquireUseRelease(V.sync(()=>{let n=D.spinner();return n.start(t.start),n}),(n)=>e({message:(r)=>V.sync(()=>{n.message(r)})}),(n,r)=>V.sync(()=>{n.stop(In.match(r,{onFailure:()=>t.failure,onSuccess:(o)=>typeof t.success==="function"?t.success(o):t.success}))}))})}function qn(){return[h.files[1].path,h.files[2].path]}function lo(e){let t=qn();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${h.config}\`.`}function po(e){return C.gen(function*(){let t=yield*Tn.FileSystem,n=yield*_n.Path,r=yield*h.detect(e);if(r.active?.format!=="json"&&r.active?.format!=="jsonc")return;let o=r.active.path,i=n.join(e,h.config),s=yield*t.readFileString(o).pipe(C.mapError((p)=>new R({cause:p,path:o}))),a=yield*A(s,o);if(!N(a))return yield*new Z({path:o});let{$schema:u,...f}=a;yield*t.writeFileString(i,rt(f)).pipe(C.mapError((p)=>new j({cause:p,path:i}))),yield*t.remove(o).pipe(C.mapError((p)=>new ne({cause:p,path:o})));let l=r.legacy[0]?.path??null;if(l&&l!==o)yield*t.remove(l).pipe(C.mapError((p)=>new ne({cause:p,path:l})))})}var xt=pe({check:(e)=>C.gen(function*(){let t=yield*h.detect(e.cwd),n=[];if(t.active?.format==="ts"&&t.legacy.length>0)n.push("Found both `knip.config.ts` and `knip.json(c)`. Adamantite will use `knip.config.ts`.");if(t.active&&t.active.format!=="ts"&&t.legacy.length>0)n.push("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(t.active?.format==="json"||t.active?.format==="jsonc")return{applicable:!0,summary:lo(t.active.format),warnings:n};if(t.active?.format==="ts")return{applicable:!0,warnings:n};return{applicable:!1,warnings:n}}),files:[h.config,...qn()],id:"legacy-knip-json",migrate:(e)=>C.gen(function*(){let t=yield*O,r=(yield*h.detect(e.cwd)).active?.path.endsWith(h.files[2].path)?h.files[2].path:h.files[1].path;yield*t.withSpinner(()=>po(e.cwd),{failure:`Failed to migrate ${r}.`,start:`Migrating \`${r}\` to \`${h.config}\`...`,success:`Knip config migrated to \`${h.config}\` successfully.`})}),tags:["update"],title:"Legacy Knip JSON config",validate:(e)=>C.gen(function*(){if((yield*h.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-knip-json",reason:`\`${h.config}\` is not the active Knip config.`})})});import*as ee from"effect/Effect";import*as zn from"effect/FileSystem";import*as bn from"effect/Path";function Un(){return[m.files[1].path,m.files[2].path]}function uo(e){let t=Un();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${m.config}\`.`}function co(e){return ee.gen(function*(){let t=yield*zn.FileSystem,n=yield*bn.Path,r=yield*m.detect(e);if(r.active?.format!=="json"&&r.active?.format!=="jsonc")return;let o=r.active.path,i=n.join(e,m.config),s=yield*t.readFileString(o).pipe(ee.mapError((p)=>new R({cause:p,path:o}))),a=yield*A(s,o);if(!N(a))return yield*new Z({path:o});let{$schema:u,...f}=a;yield*t.writeFileString(i,lt(f)).pipe(ee.mapError((p)=>new j({cause:p,path:i}))),yield*t.remove(o).pipe(ee.mapError((p)=>new ne({cause:p,path:o})));let l=r.legacy[0]?.path??null;if(l&&l!==o)yield*t.remove(l).pipe(ee.mapError((p)=>new ne({cause:p,path:l})))})}var Lt=pe({check:(e)=>ee.gen(function*(){let t=yield*m.detect(e.cwd),n=[];if(t.active?.format==="ts"&&t.legacy.length>0)n.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(t.active&&t.active.format!=="ts"&&t.legacy.length>0)n.push("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(t.active?.format==="json"||t.active?.format==="jsonc")return{applicable:!0,summary:uo(t.active.format),warnings:n};if(t.active?.format==="ts")return{applicable:!0,warnings:n};return{applicable:!1,warnings:n}}),files:[m.config,...Un()],id:"legacy-oxfmt-json",migrate:(e)=>ee.gen(function*(){let t=yield*O,r=(yield*m.detect(e.cwd)).active?.path.endsWith(m.files[2].path)?m.files[2].path:m.files[1].path;yield*t.withSpinner(()=>co(e.cwd),{failure:`Failed to migrate ${r}.`,start:`Migrating \`${r}\` to \`${m.config}\`...`,success:`Oxfmt config migrated to \`${m.config}\` successfully.`})}),tags:["update"],title:"Legacy oxfmt JSON config",validate:(e)=>ee.gen(function*(){if((yield*m.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-oxfmt-json",reason:`\`${m.config}\` is not the active oxfmt config.`})})});import*as ie from"effect/Effect";import*as kn from"effect/FileSystem";import*as An from"effect/Path";function yo(e){return ie.gen(function*(){let t=yield*kn.FileSystem,n=yield*An.Path,r=yield*y.detect(e);if(r.active?.format!=="json")return;let o=r.active.path,i=n.join(e,y.config),s=yield*t.readFileString(o).pipe(ie.mapError((P)=>new R({cause:P,path:o}))),a=yield*A(s,o);if(!N(a))return yield*new Z({path:o});let{$schema:u,...f}=a,l=Array.isArray(f.extends)?f.extends.filter((P)=>typeof P==="string"):typeof f.extends==="string"?[f.extends]:[],p=new Set(at()),E=new Set;for(let P of l){let te=P.match(/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/),c=P.match(/^adamantite\/lint(?:\/([a-z0-9-]+))?$/),z=te?.[1]??(c?c[1]??"core":null);if(z)p.add(z);else E.add(P)}let{extends:S,...T}=f;yield*t.writeFileString(i,ft(T,[...p],[...E])).pipe(ie.mapError((P)=>new j({cause:P,path:i}))),yield*t.remove(o).pipe(ie.mapError((P)=>new ne({cause:P,path:o})))})}var wt=pe({id:"legacy-oxlint-json",files:[y.config,y.files[1].path],tags:["update"],title:"Legacy oxlint JSON config",check:(e)=>ie.gen(function*(){let t=yield*y.detect(e.cwd),n=t.active?.format==="ts"&&t.legacy.length>0?[`Found both \`${y.config}\` and \`${y.files[1].path}\`. Adamantite will use \`${y.config}\`.`]:[];if(t.active?.format==="json")return{applicable:!0,summary:`Migrating legacy \`${y.files[1].path}\` configuration to \`${y.config}\`.`,warnings:n};if(t.active?.format==="ts")return{applicable:!0,warnings:n};return{applicable:!1,warnings:n}}),migrate:(e)=>ie.gen(function*(){yield*(yield*O).withSpinner(()=>yo(e.cwd),{failure:`Failed to migrate ${y.files[1].path}.`,start:`Migrating \`${y.files[1].path}\` to \`${y.config}\`...`,success:`Oxlint config migrated to \`${y.config}\` successfully.`})}),validate:(e)=>ie.gen(function*(){if((yield*y.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-oxlint-json",reason:`\`${y.config}\` is not the active oxlint config.`})})});import*as Se from"effect/Effect";import*as Oe from"effect/Effect";import*as ht from"effect/FileSystem";import*as mt from"effect/Path";import*as ct from"effect/Effect";import*as Jn from"effect/FileSystem";var Bn=(e)=>ct.gen(function*(){yield*(yield*Jn.FileSystem).makeDirectory(e,{recursive:!0}).pipe(ct.mapError((n)=>new ge({cause:n,path:e})))});import{runScriptCommand as ho}from"nypm";var Qn=[{name:"check",script:"check"},{args:["--check"],name:"format",script:"format"},{name:"monorepo",script:"check:monorepo"},{name:"analyze",script:"analyze"}];function Wn(e,t){let n=[];for(let r of Qn){if(!t.includes(r.script))continue;n.push({command:ho(e,r.script,{args:r.args}),name:r.name})}return n}function we(e){return Qn.some((t)=>e.includes(t.script))}var mo={bun:` - name: Setup Node.js
|
|
21
|
-
uses: actions/setup-node@
|
|
20
|
+
`)}var Q=[{path:"oxfmt.config.ts",type:"config"},{path:".oxfmtrc.json",type:"legacy_config"},{path:".oxfmtrc.jsonc",type:"legacy_config"}];var h=I({assess:(e)=>oe.gen(function*(){let t=yield*lt.FileSystem,n=yield*pt.Path,r=yield*v(e);if(!H(r).includes("format"))return{applicable:!1,warnings:[]};let i=r.devDependencies?.oxfmt??r.dependencies?.oxfmt,s=n.join(e,Q[0].path),a=n.join(e,Q[1].path),f=n.join(e,Q[2].path),{hasConfig:l,hasLegacyJson:p,hasLegacyJsonc:u}=yield*oe.all({hasConfig:t.exists(s),hasLegacyJson:t.exists(a),hasLegacyJsonc:t.exists(f)},{concurrency:"unbounded"}),E=l?"ts":u?"jsonc":p?"json":null,j=[],N=[];if(l&&(p||u))N.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(!l&&p&&u)N.push("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(!i)j.push({description:`Install \`oxfmt@${"0.62.0"}\` for the managed \`format\` script.`,package:"oxfmt",targetVersion:"0.62.0",type:"install_package"});else if(Y(i)!=="0.62.0")j.push({currentVersion:i,description:`Update \`oxfmt\` from \`${i}\` to \`${"0.62.0"}\`.`,package:"oxfmt",targetVersion:"0.62.0",type:"update_package"});if(E===null)j.push({description:`Create \`${Q[0].path}\` for \`oxfmt\`.`,path:Q[0].path,type:"create_config"});if(E==="json"||E==="jsonc")j.push({description:`Migrate legacy \`${E==="json"?Q[1].path:Q[2].path}\` to \`${Q[0].path}\`.`,migrationId:"legacy-oxfmt-json",type:"run_migration"});return{actions:j,applicable:!0,warnings:N}}),config:Q[0].path,create:(e)=>oe.gen(function*(){let t=yield*lt.FileSystem,r=(yield*pt.Path).join(e,Q[0].path);yield*t.writeFileString(r,ft()).pipe(oe.mapError((o)=>new S({cause:o,path:r})))}),detect:(e)=>oe.gen(function*(){let t=yield*lt.FileSystem,n=yield*pt.Path,r=n.join(e,Q[0].path),o=n.join(e,Q[1].path),i=n.join(e,Q[2].path),{hasJson:s,hasJsonc:a,hasTs:f}=yield*oe.all({hasJson:t.exists(o),hasJsonc:t.exists(i),hasTs:t.exists(r)},{concurrency:"unbounded"}),l=f?"ts":a?"jsonc":s?"json":null,p=[];if(f&&s)p.push({format:"json",path:o});if(f&&a)p.push({format:"jsonc",path:i});if(!f&&s&&a)p.push({format:"json",path:o});return{active:l===null?null:{format:l,path:l==="ts"?r:l==="jsonc"?i:o},legacy:p}}),files:Q,kind:"tooling",name:"oxfmt",version:"0.62.0"});import*as vn from"effect/Effect";var L=I({assess:(e)=>vn.gen(function*(){let t=yield*v(e),n=H(t);if(!n.includes("check:monorepo")&&!n.includes("fix:monorepo"))return{applicable:!1,warnings:[]};let r=t.devDependencies?.sherif??t.dependencies?.sherif,o=[];if(!r)o.push({description:`Install \`sherif@${"1.13.0"}\` for the managed monorepo scripts.`,package:"sherif",targetVersion:"1.13.0",type:"install_package"});else if(Y(r)!=="1.13.0")o.push({currentVersion:r,description:`Update \`sherif\` from \`${r}\` to \`${"1.13.0"}\`.`,package:"sherif",targetVersion:"1.13.0",type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"sherif",version:"1.13.0"});import*as Rn from"effect/Effect";var le=I({assess:(e)=>Rn.gen(function*(){let t=yield*v(e),n=H(t);if(!n.includes("check")&&!n.includes("fix"))return{applicable:!1,warnings:[]};let r=t.devDependencies?.["oxlint-tsgolint"]??t.dependencies?.["oxlint-tsgolint"],o=[];if(!r)o.push({description:`Install \`oxlint-tsgolint@${"7.0.2001"}\` for the managed lint scripts.`,package:"oxlint-tsgolint",targetVersion:"7.0.2001",type:"install_package"});else if(Y(r)!=="7.0.2001")o.push({currentVersion:r,description:`Update \`oxlint-tsgolint\` from \`${r}\` to \`${"7.0.2001"}\`.`,package:"oxlint-tsgolint",targetVersion:"7.0.2001",type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"oxlint-tsgolint",version:"7.0.2001"});import*as W from"effect/Effect";import*as Dn from"effect/FileSystem";import*as Vn from"effect/Path";function pe(e){return e}function Le(e,t,n){return W.gen(function*(){let r=yield*Dn.FileSystem,o=yield*Vn.Path,i=e.files??[],s=new Map;for(let a of i){let f=o.join(t.cwd,a);if(yield*r.exists(f)){let p=yield*r.readFileString(f);s.set(f,p)}else s.set(f,null)}yield*e.migrate(t).pipe(W.andThen(()=>e.validate?.(t)??W.void),W.onError(()=>W.gen(function*(){if(n?.onRestore)yield*n.onRestore;for(let[a,f]of s){if(f!==null){yield*r.writeFileString(a,f).pipe(W.ignore);continue}if(!(yield*r.exists(a).pipe(W.orElseSucceed(()=>!1))))continue;yield*r.remove(a).pipe(W.ignore)}})))})}import*as C from"effect/Effect";import*as Tn from"effect/FileSystem";import*as _n from"effect/Path";import*as bn from"effect/Predicate";import*as D from"@clack/prompts";import*as Pn from"effect/Context";import*as V from"effect/Effect";import*as In from"effect/Exit";import*as Nn from"effect/Layer";class O extends Pn.Service()("Prompter"){static layer=Nn.succeed(this)({cancel:(e)=>V.sync(()=>{D.cancel(e)}),confirm:(e)=>V.promise(()=>D.confirm(e)).pipe(V.filterOrFail((t)=>!D.isCancel(t),()=>new nt({}))),intro:(e)=>V.sync(()=>{D.intro(e)}),log:{error:(e)=>V.sync(()=>{D.log.error(e)}),info:(e)=>V.sync(()=>{D.log.info(e)}),success:(e)=>V.sync(()=>{D.log.success(e)}),warning:(e)=>V.sync(()=>{D.log.warning(e)})},multiselect:(e)=>V.promise(()=>D.multiselect(e)).pipe(V.filterOrFail((t)=>!D.isCancel(t),()=>new nt({}))),outro:(e)=>V.sync(()=>{D.outro(e)}),withSpinner:(e,t)=>V.acquireUseRelease(V.sync(()=>{let n=D.spinner();return n.start(t.start),n}),(n)=>e({message:(r)=>V.sync(()=>{n.message(r)})}),(n,r)=>V.sync(()=>{n.stop(In.match(r,{onFailure:()=>t.failure,onSuccess:(o)=>typeof t.success==="function"?t.success(o):t.success}))}))})}function qn(){return[m.files[1].path,m.files[2].path]}function ho(e){let t=qn();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${m.config}\`.`}function Eo(e){return C.gen(function*(){let t=yield*Tn.FileSystem,n=yield*_n.Path,r=yield*m.detect(e);if(r.active?.format!=="json"&&r.active?.format!=="jsonc")return;let o=r.active.path,i=n.join(e,m.config),s=yield*t.readFileString(o).pipe(C.mapError((u)=>new R({cause:u,path:o}))),a=yield*A(s,o);if(!bn.isObject(a))return yield*new Z({path:o});let{$schema:f,...l}=a;yield*t.writeFileString(i,rt(l)).pipe(C.mapError((u)=>new S({cause:u,path:i}))),yield*t.remove(o).pipe(C.mapError((u)=>new ne({cause:u,path:o})));let p=r.legacy[0]?.path??null;if(p&&p!==o)yield*t.remove(p).pipe(C.mapError((u)=>new ne({cause:u,path:p})))})}var Ht=pe({check:(e)=>C.gen(function*(){let t=yield*m.detect(e.cwd),n=[];if(t.active?.format==="ts"&&t.legacy.length>0)n.push("Found both `knip.config.ts` and `knip.json(c)`. Adamantite will use `knip.config.ts`.");if(t.active&&t.active.format!=="ts"&&t.legacy.length>0)n.push("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(t.active?.format==="json"||t.active?.format==="jsonc")return{applicable:!0,summary:ho(t.active.format),warnings:n};if(t.active?.format==="ts")return{applicable:!0,warnings:n};return{applicable:!1,warnings:n}}),files:[m.config,...qn()],id:"legacy-knip-json",migrate:(e)=>C.gen(function*(){let t=yield*O,r=(yield*m.detect(e.cwd)).active?.path.endsWith(m.files[2].path)?m.files[2].path:m.files[1].path;yield*t.withSpinner(()=>Eo(e.cwd),{failure:`Failed to migrate ${r}.`,start:`Migrating \`${r}\` to \`${m.config}\`...`,success:`Knip config migrated to \`${m.config}\` successfully.`})}),tags:["update"],title:"Legacy Knip JSON config",validate:(e)=>C.gen(function*(){if((yield*m.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-knip-json",reason:`\`${m.config}\` is not the active Knip config.`})})});import*as ee from"effect/Effect";import*as zn from"effect/FileSystem";import*as Jn from"effect/Path";import*as Un from"effect/Predicate";function An(){return[h.files[1].path,h.files[2].path]}function go(e){let t=An();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${h.config}\`.`}function Oo(e){return ee.gen(function*(){let t=yield*zn.FileSystem,n=yield*Jn.Path,r=yield*h.detect(e);if(r.active?.format!=="json"&&r.active?.format!=="jsonc")return;let o=r.active.path,i=n.join(e,h.config),s=yield*t.readFileString(o).pipe(ee.mapError((u)=>new R({cause:u,path:o}))),a=yield*A(s,o);if(!Un.isObject(a))return yield*new Z({path:o});let{$schema:f,...l}=a;yield*t.writeFileString(i,ft(l)).pipe(ee.mapError((u)=>new S({cause:u,path:i}))),yield*t.remove(o).pipe(ee.mapError((u)=>new ne({cause:u,path:o})));let p=r.legacy[0]?.path??null;if(p&&p!==o)yield*t.remove(p).pipe(ee.mapError((u)=>new ne({cause:u,path:p})))})}var Kt=pe({check:(e)=>ee.gen(function*(){let t=yield*h.detect(e.cwd),n=[];if(t.active?.format==="ts"&&t.legacy.length>0)n.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(t.active&&t.active.format!=="ts"&&t.legacy.length>0)n.push("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(t.active?.format==="json"||t.active?.format==="jsonc")return{applicable:!0,summary:go(t.active.format),warnings:n};if(t.active?.format==="ts")return{applicable:!0,warnings:n};return{applicable:!1,warnings:n}}),files:[h.config,...An()],id:"legacy-oxfmt-json",migrate:(e)=>ee.gen(function*(){let t=yield*O,r=(yield*h.detect(e.cwd)).active?.path.endsWith(h.files[2].path)?h.files[2].path:h.files[1].path;yield*t.withSpinner(()=>Oo(e.cwd),{failure:`Failed to migrate ${r}.`,start:`Migrating \`${r}\` to \`${h.config}\`...`,success:`Oxfmt config migrated to \`${h.config}\` successfully.`})}),tags:["update"],title:"Legacy oxfmt JSON config",validate:(e)=>ee.gen(function*(){if((yield*h.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-oxfmt-json",reason:`\`${h.config}\` is not the active oxfmt config.`})})});import*as ie from"effect/Effect";import*as kn from"effect/FileSystem";import*as Bn from"effect/Path";import*as Qn from"effect/Predicate";function So(e){return ie.gen(function*(){let t=yield*kn.FileSystem,n=yield*Bn.Path,r=yield*y.detect(e);if(r.active?.format!=="json")return;let o=r.active.path,i=n.join(e,y.config),s=yield*t.readFileString(o).pipe(ie.mapError((P)=>new R({cause:P,path:o}))),a=yield*A(s,o);if(!Qn.isObject(a))return yield*new Z({path:o});let{$schema:f,...l}=a,p=Array.isArray(l.extends)?l.extends.filter((P)=>typeof P==="string"):typeof l.extends==="string"?[l.extends]:[],u=new Set(st()),E=new Set;for(let P of p){let te=P.match(/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/),c=P.match(/^adamantite\/lint(?:\/([a-z0-9-]+))?$/),b=te?.[1]??(c?c[1]??"core":null);if(b)u.add(b);else E.add(P)}let{extends:j,...N}=l;yield*t.writeFileString(i,at(N,[...u],[...E])).pipe(ie.mapError((P)=>new S({cause:P,path:i}))),yield*t.remove(o).pipe(ie.mapError((P)=>new ne({cause:P,path:o})))})}var xt=pe({id:"legacy-oxlint-json",files:[y.config,y.files[1].path],tags:["update"],title:"Legacy oxlint JSON config",check:(e)=>ie.gen(function*(){let t=yield*y.detect(e.cwd),n=t.active?.format==="ts"&&t.legacy.length>0?[`Found both \`${y.config}\` and \`${y.files[1].path}\`. Adamantite will use \`${y.config}\`.`]:[];if(t.active?.format==="json")return{applicable:!0,summary:`Migrating legacy \`${y.files[1].path}\` configuration to \`${y.config}\`.`,warnings:n};if(t.active?.format==="ts")return{applicable:!0,warnings:n};return{applicable:!1,warnings:n}}),migrate:(e)=>ie.gen(function*(){yield*(yield*O).withSpinner(()=>So(e.cwd),{failure:`Failed to migrate ${y.files[1].path}.`,start:`Migrating \`${y.files[1].path}\` to \`${y.config}\`...`,success:`Oxlint config migrated to \`${y.config}\` successfully.`})}),validate:(e)=>ie.gen(function*(){if((yield*y.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-oxlint-json",reason:`\`${y.config}\` is not the active oxlint config.`})})});import*as je from"effect/Effect";import*as Oe from"effect/Effect";import*as yt from"effect/FileSystem";import*as mt from"effect/Path";import*as ut from"effect/Effect";import*as Wn from"effect/FileSystem";var Zn=(e)=>ut.gen(function*(){yield*(yield*Wn.FileSystem).makeDirectory(e,{recursive:!0}).pipe(ut.mapError((n)=>new ge({cause:n,path:e})))});import{runScriptCommand as jo}from"nypm";var Xn=[{name:"check",script:"check"},{args:["--check"],name:"format",script:"format"},{name:"monorepo",script:"check:monorepo"},{name:"analyze",script:"analyze"}];function Yn(e,t){let n=[];for(let r of Xn){if(!t.includes(r.script))continue;n.push({command:jo(e,r.script,{args:r.args}),name:r.name})}return n}function Me(e){return Xn.some((t)=>e.includes(t.script))}var $o={bun:` - name: Setup Node.js
|
|
21
|
+
uses: actions/setup-node@v7
|
|
22
22
|
with:
|
|
23
|
-
node-version: "
|
|
23
|
+
node-version: "24"
|
|
24
24
|
|
|
25
25
|
- name: Setup Bun
|
|
26
26
|
uses: oven-sh/setup-bun@v2
|
|
27
27
|
|
|
28
28
|
- name: Cache dependencies
|
|
29
|
-
uses: actions/cache@
|
|
29
|
+
uses: actions/cache@v6
|
|
30
30
|
with:
|
|
31
31
|
path: |
|
|
32
32
|
~/.bun/install/cache
|
|
@@ -41,9 +41,9 @@ ${n}`)}var De=(e,t)=>G.try({catch:(n)=>new _t({cause:n}),try:()=>Yr(e,t)});funct
|
|
|
41
41
|
|
|
42
42
|
- name: Install dependencies
|
|
43
43
|
run: deno install --frozen`,npm:` - name: Setup Node.js
|
|
44
|
-
uses: actions/setup-node@
|
|
44
|
+
uses: actions/setup-node@v7
|
|
45
45
|
with:
|
|
46
|
-
node-version: "
|
|
46
|
+
node-version: "24"
|
|
47
47
|
cache: "npm"
|
|
48
48
|
|
|
49
49
|
- name: Install dependencies
|
|
@@ -51,20 +51,20 @@ ${n}`)}var De=(e,t)=>G.try({catch:(n)=>new _t({cause:n}),try:()=>Yr(e,t)});funct
|
|
|
51
51
|
uses: pnpm/action-setup@v4
|
|
52
52
|
|
|
53
53
|
- name: Setup Node.js
|
|
54
|
-
uses: actions/setup-node@
|
|
54
|
+
uses: actions/setup-node@v7
|
|
55
55
|
with:
|
|
56
|
-
node-version: "
|
|
56
|
+
node-version: "24"
|
|
57
57
|
cache: "pnpm"
|
|
58
58
|
|
|
59
59
|
- name: Install dependencies
|
|
60
60
|
run: pnpm install --frozen-lockfile`,yarn:` - name: Setup Node.js
|
|
61
|
-
uses: actions/setup-node@
|
|
61
|
+
uses: actions/setup-node@v7
|
|
62
62
|
with:
|
|
63
|
-
node-version: "
|
|
63
|
+
node-version: "24"
|
|
64
64
|
cache: "yarn"
|
|
65
65
|
|
|
66
66
|
- name: Install dependencies
|
|
67
|
-
run: yarn install --frozen-lockfile`};function
|
|
67
|
+
run: yarn install --frozen-lockfile`};function Hn({packageManager:e,scripts:t}){let n=Yn(e,t);if(n.length===0)return null;return`${`name: adamantite
|
|
68
68
|
|
|
69
69
|
on:
|
|
70
70
|
push:
|
|
@@ -95,28 +95,28 @@ ${n.map((i)=>` - name: ${i.name}
|
|
|
95
95
|
|
|
96
96
|
steps:
|
|
97
97
|
- name: Checkout
|
|
98
|
-
uses: actions/checkout@
|
|
98
|
+
uses: actions/checkout@v7
|
|
99
99
|
|
|
100
|
-
${
|
|
100
|
+
${$o[e]}
|
|
101
101
|
|
|
102
102
|
- name: Run \${{ matrix.name }}
|
|
103
103
|
run: \${{ matrix.command }}`}
|
|
104
|
-
`}var
|
|
105
|
-
`).pipe(ue.mapError((i)=>new
|
|
106
|
-
`).pipe(ue.mapError((a)=>new
|
|
107
|
-
`).reduce((r,o)=>Math.max(r,o.trim().length),0);if(!t||t<n)return;yield*
|
|
108
|
-
`).pipe(
|
|
109
|
-
`).pipe(
|
|
110
|
-
`).pipe(ae.mapError((i)=>new
|
|
111
|
-
`).pipe(ae.mapError((
|
|
112
|
-
`);return[
|
|
113
|
-
`)}var
|
|
104
|
+
`}var ct=[{path:".github/workflows/adamantite.yml",type:"ci"}],se=I({create:(e,t)=>Oe.gen(function*(){let n=yield*yt.FileSystem,r=yield*mt.Path,o=r.join(e,ct[0].path);yield*Zn(r.dirname(o));let i=Hn(t);if(!i)return;yield*n.writeFileString(o,i).pipe(Oe.mapError((s)=>new S({cause:s,path:o})))}),detect:(e)=>Oe.gen(function*(){let t=yield*yt.FileSystem,n=yield*mt.Path;return yield*t.exists(n.join(e,ct[0].path))}),files:ct,kind:"ci",name:"github",update:(e,t)=>Oe.gen(function*(){let n=yield*yt.FileSystem,o=(yield*mt.Path).join(e,ct[0].path),i=Hn(t);if(!i)return;yield*n.writeFileString(o,i).pipe(Oe.mapError((s)=>new S({cause:s,path:o})))})});import*as Kn from"effect/Context";import*as Se from"effect/Effect";import*as xn from"effect/Layer";import{addDevDependency as Fo,detectPackageManager as vo}from"nypm";class K extends Kn.Service()("DependencyInstaller"){static layer=xn.succeed(this)({addDevDependencies:(e,t,n)=>Se.tryPromise({catch:(r)=>new Nt({cause:r,packages:e}),try:()=>Fo(e,{...n,cwd:t})}).pipe(Se.asVoid),detectPackageManager:(e)=>Se.tryPromise({catch:(t)=>new Xe({cause:t}),try:()=>vo(e)}).pipe(Se.map((t)=>t??null))})}import*as ue from"effect/Effect";import*as ht from"effect/FileSystem";import*as dt from"effect/Path";import*as Mn from"effect/Predicate";var we=[{path:"tsconfig.json",type:"config"}],Ln={extends:"adamantite/typescript"},J=I({config:we[0].path,create:(e)=>ue.gen(function*(){let t=yield*ht.FileSystem,r=(yield*dt.Path).join(e,we[0].path),o=JSON.stringify(Ln,null,2);yield*t.writeFileString(r,`${o}
|
|
105
|
+
`).pipe(ue.mapError((i)=>new S({cause:i,path:r})))}),detect:(e)=>ue.gen(function*(){let t=yield*ht.FileSystem,n=yield*dt.Path;return yield*t.exists(n.join(e,we[0].path))}),files:we,kind:"workspace",name:"tsconfig",update:(e)=>ue.gen(function*(){let t=yield*ht.FileSystem,r=(yield*dt.Path).join(e,we[0].path),o=yield*t.readFileString(r).pipe(ue.mapError((a)=>new R({cause:a,path:r}))),i=yield*A(o,r);if(!Mn.isObject(i))return yield*new Z({path:r});let s=yield*De(Ln,i);yield*t.writeFileString(r,`${JSON.stringify(s,null,2)}
|
|
106
|
+
`).pipe(ue.mapError((a)=>new S({cause:a,path:r})))})});var Gn="adamantite typecheck";function Ro(){return y.files[1].path}function Do(){return se.files[0].path}function wn(e){let t={...e.scripts};if(t.typecheck!==Gn)return{migrated:!1,packageJson:e};return delete t.typecheck,t.check??=He.check,{migrated:!0,packageJson:{...e,scripts:t}}}var Cn=pe({check:(e)=>je.gen(function*(){let t=yield*v(e.cwd),{migrated:n}=wn(t);if(!n)return{applicable:!1,warnings:[]};return{applicable:!0,summary:"Migrating `typecheck` to `check` so oxlint handles linting and type diagnostics together.",warnings:[]}}),files:["package.json",y.config,Ro(),J.config,Do()],id:"legacy-typecheck-script",migrate:(e)=>je.gen(function*(){let t=yield*O,n=yield*K,r=je.gen(function*(){let o=yield*v(e.cwd),i=wn(o);if(!i.migrated)return"noop";yield*on(e.cwd,i.packageJson);let s=yield*y.detect(e.cwd);if(s.active===null)yield*y.create(e.cwd);else if(s.active.format==="ts")yield*y.update(e.cwd);yield*(yield*J.detect(e.cwd))?J.update(e.cwd):J.create(e.cwd);let f=yield*se.detect(e.cwd),l=H(i.packageJson);if(f&&Me(l)){let p=yield*n.detectPackageManager(e.cwd);if(p&&Ye(p.name)){let u=p.name;yield*t.withSpinner(()=>se.update(e.cwd,{packageManager:u,scripts:l}),{failure:"Failed to update GitHub Actions workflow.",start:"Updating GitHub Actions workflow...",success:"GitHub Actions workflow updated successfully"})}else if(p)yield*t.log.warning(`\`${p.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow was not updated.`);else yield*t.log.warning("Could not detect a package manager, so the GitHub Actions workflow was not updated.")}return"migrated"});yield*t.withSpinner(()=>r,{failure:"Legacy `typecheck` script migration failed.",start:"Migrating `typecheck` script to unified `check` command...",success:(o)=>o==="noop"?"No migration needed.":"Legacy `typecheck` script migrated to `check` successfully."}).pipe(je.asVoid)}),tags:["update"],title:"Legacy typecheck script",validate:(e)=>je.gen(function*(){if((yield*v(e.cwd)).scripts?.typecheck===Gn)return yield*new x({migrationId:"legacy-typecheck-script",reason:"The legacy `typecheck` script is still present in `package.json`."});if((yield*y.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-typecheck-script",reason:`\`${y.config}\` is not the active oxlint config.`});if(!(yield*J.detect(e.cwd)))return yield*new x({migrationId:"legacy-typecheck-script",reason:`\`${J.config}\` is missing after the migration.`})})});var Et=[Kt,Ht,xt,Cn],er=Object.fromEntries(Et.map((e)=>[e.id,e])),tr={[Ht.id]:m.name,[Kt.id]:h.name,[xt.id]:y.name};import*as nr from"effect/Array";import*as $e from"effect/Effect";import*as gt from"effect/Option";var Vo=$e.fn("collectApplicableAssessments")((e,t)=>$e.forEach((n)=>n.assess(t).pipe($e.map((r)=>r.applicable?gt.some({assessment:r,integration:n}):gt.none())))(e).pipe($e.map((n)=>nr.getSomes(n))));function Ot(e,t){return Vo(e,t)}import*as rr from"effect/Console";import*as or from"effect/Effect";import*as ir from"effect/Terminal";var _e=()=>or.gen(function*(){let t=yield*(yield*ir.Terminal).columns,n=' .o8 . o8o . \n "888 .o8 `"\' .o8 \n .oooo. .oooo888 .oooo. ooo. .oo. .oo. .oooo. ooo. .oo. .o888oo oooo .o888oo .ooooo. \n`P )88b d88\' `888 `P )88b `888P"Y88bP"Y88b `P )88b `888P"Y88b 888 `888 888 d88\' `88b \n .oP"888 888 888 .oP"888 888 888 888 .oP"888 888 888 888 888 888 888ooo888 \nd8( 888 888 888 d8( 888 888 888 888 d8( 888 888 888 888 . 888 888 . 888 .o \n`Y888""8o `Y8bod88P" `Y888""8o o888o o888o o888o `Y888""8o o888o o888o "888" o888o "888" `Y8bod8P\' \n \n \n '.split(`
|
|
107
|
+
`).reduce((r,o)=>Math.max(r,o.trim().length),0);if(!t||t<n)return;yield*rr.info(' .o8 . o8o . \n "888 .o8 `"\' .o8 \n .oooo. .oooo888 .oooo. ooo. .oo. .oo. .oooo. ooo. .oo. .o888oo oooo .o888oo .ooooo. \n`P )88b d88\' `888 `P )88b `888P"Y88bP"Y88b `P )88b `888P"Y88b 888 `888 888 d88\' `88b \n .oP"888 888 888 .oP"888 888 888 888 .oP"888 888 888 888 888 888 888ooo888 \nd8( 888 888 888 d8( 888 888 888 888 d8( 888 888 888 888 . 888 888 . 888 .o \n`Y888""8o `Y8bod88P" `Y888""8o o888o o888o o888o `Y888""8o o888o o888o "888" o888o "888" `Y8bod8P\' \n \n \n ')});var Io=St.boolean("fix").pipe(St.withDescription("Automatically fix safe package install/update issues")),No=[m,h,y,L,le],sr={[m.name]:m,[h.name]:h,[y.name]:y},ar={[y.name]:y};function fr(e,t){return Object.hasOwn(e,t)}function Ge(e,t){switch(t.type){case"install_package":return`${e}:${t.type}:${t.package}:${t.targetVersion}`;case"update_package":return`${e}:${t.type}:${t.package}:${t.targetVersion}`;case"create_config":case"update_config":return`${e}:${t.type}:${t.path}`;case"manual_fix":return`${e}:${t.type}:${t.path??t.description}`;case"run_migration":return`${e}:${t.type}:${t.migrationId}`}}var lr=qe.make("doctor",{fix:Io}).pipe(qe.withDescription("Check Adamantite-managed integrations in the current project"),qe.withHandler(({fix:e})=>be.gen(function*(){let t=Po.cwd(),n=yield*O;yield*_e(),yield*n.intro("\uD83D\uDCA0 adamantite doctor");let r=yield*v(t);if(!r.devDependencies?.adamantite&&!r.dependencies?.adamantite)yield*n.log.warning("`adamantite` is not installed in this project. Install it before running `adamantite doctor`."),yield*n.outro("⚠️ Doctor found issues."),yield*new q({command:"doctor",exitCode:Lt.ExitCode(1)});let o=yield*Ot(No,t);for(let{assessment:f}of o)for(let l of f.warnings)yield*n.log.warning(l);if(o.length===0){yield*n.log.success("No applicable integrations found."),yield*n.outro("✅ Doctor completed successfully!");return}let i=o.flatMap(({assessment:f,integration:l})=>f.actions.map((p)=>({action:p,integration:l})));if(i.length===0){yield*n.log.success("No issues found."),yield*n.outro("✅ Doctor completed successfully!");return}let s=new Set;if(e)yield*be.gen(function*(){let f=i.filter(({action:l})=>l.type==="install_package"||l.type==="update_package");if(f.length>0){let l=yield*K,p=[];for(let{action:u}of f)if(u.type==="install_package"||u.type==="update_package")p.push(`${u.package}@${u.targetVersion}`);yield*l.addDevDependencies(p,t,{silent:!0});for(let{action:u,integration:E}of f){if(u.type==="install_package")yield*n.log.success(`Fixed: installed \`${u.package}@${u.targetVersion}\`.`);if(u.type==="update_package")yield*n.log.success(`Fixed: updated \`${u.package}\` from \`${u.currentVersion}\` to \`${u.targetVersion}\`.`);s.add(Ge(E.name,u))}}for(let{action:l,integration:p}of i){if(l.type!=="create_config")continue;if(!fr(sr,p.name))continue;yield*sr[p.name].create(t),yield*n.log.success(`Fixed: created \`${l.path}\`.`),s.add(Ge(p.name,l))}for(let{action:l,integration:p}of i){if(l.type!=="update_config")continue;if(!fr(ar,p.name))continue;yield*ar[p.name].update(t),yield*n.log.success(`Fixed: updated \`${l.path}\`.`),s.add(Ge(p.name,l))}for(let{action:l,integration:p}of i){if(l.type!=="run_migration")continue;let u=er[l.migrationId];if(!u)continue;yield*Le(u,{cwd:t}),s.add(Ge(p.name,l))}}).pipe(be.tapError(()=>be.gen(function*(){yield*n.outro("❌ Doctor failed")})));let a=i.filter(({action:f,integration:l})=>!s.has(Ge(l.name,f)));if(e&&a.length===0){yield*n.outro("✅ Doctor completed successfully!");return}for(let{action:f}of e?a:i)yield*n.log.warning(`Needs attention: ${f.description}`);yield*n.outro("⚠️ Doctor found issues."),yield*new q({command:"doctor",exitCode:Lt.ExitCode(1)})})));import*as pr from"effect/Array";import*as ur from"effect/Effect";import*as ze from"effect/unstable/cli/Argument";import*as Je from"effect/unstable/cli/Command";import*as ce from"effect/unstable/cli/Flag";import*as cr from"effect/unstable/process/ChildProcessSpawner";var To=ze.file("files",{mustExist:!0}).pipe(ze.withDescription("Specific files to fix (optional)"),ze.variadic()),_o=ce.boolean("suggested").pipe(ce.withDescription("Apply suggested fixes")),bo=ce.boolean("dangerous").pipe(ce.withDescription("Apply dangerous fixes")),qo=ce.boolean("all").pipe(ce.withDescription("Apply all fixes, including suggested and dangerous fixes")),Mt=Je.make("fix",{all:qo,dangerous:bo,files:To,suggested:_o}).pipe(Je.withDescription("Fix issues in code using oxlint"),Je.withHandler(({all:e,dangerous:t,files:n,suggested:r})=>ur.gen(function*(){let o=yield*B,i=yield*T,s=pr.dedupe(["--fix",...r||e?["--fix-suggestions"]:[],...t||e?["--fix-dangerously"]:[],...n]),a=yield*i.run({args:[...s,...o],command:y.name});if(a!==cr.ExitCode(0))yield*new q({command:y.name,exitCode:a})})));import*as yr from"effect/Effect";import*as Ue from"effect/unstable/cli/Argument";import*as Ae from"effect/unstable/cli/Command";import*as jt from"effect/unstable/cli/Flag";import*as mr from"effect/unstable/process/ChildProcessSpawner";var zo=Ue.file("files",{mustExist:!0}).pipe(Ue.withDescription("Specific files to format (optional)"),Ue.variadic()),Jo=jt.boolean("check").pipe(jt.withDescription("Check if files are formatted without writing")),wt=Ae.make("format",{check:Jo,files:zo}).pipe(Ae.withDescription("Format files using oxfmt"),Ae.withHandler(({check:e,files:t})=>yr.gen(function*(){let n=yield*B,r=yield*T,o=[];if(e)o.push("--check");o.push(...t,...n);let i=yield*r.run({args:o,command:h.name});if(i!==mr.ExitCode(0))yield*new q({command:h.name,exitCode:i})})));import Zo from"node:process";import*as ke from"effect/Array";import*as d from"effect/Effect";import*as Nr from"effect/FileSystem";import*as Tr from"effect/Path";import*as _r from"effect/Predicate";import*as me from"effect/unstable/cli/Command";import*as $ from"effect/unstable/cli/Flag";import*as M from"effect/Effect";import*as $t from"effect/FileSystem";import*as Ft from"effect/Path";import*as dr from"effect/Predicate";import*as Er from"effect/unstable/process/ChildProcessSpawner";var Ce=[{path:".vscode/settings.json",type:"config"}],hr={"[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},ye=I({config:Ce[0].path,create:(e)=>M.gen(function*(){let t=yield*$t.FileSystem,n=yield*Ft.Path,r=n.join(e,Ce[0].path),o=n.dirname(r);yield*t.makeDirectory(o,{recursive:!0}).pipe(M.mapError((i)=>new ge({cause:i,path:o}))),yield*t.writeFileString(r,`${JSON.stringify(hr,null,2)}
|
|
108
|
+
`).pipe(M.mapError((i)=>new S({cause:i,path:r})))}),detect:(e)=>M.gen(function*(){let t=yield*$t.FileSystem,n=yield*Ft.Path;return yield*t.exists(n.join(e,Ce[0].path))}),extension:(e=[])=>M.gen(function*(){let t=[];if(e.includes("check")||e.includes("fix")||e.includes("format"))t.push("oxc.oxc-vscode");if(e.includes("analyze"))t.push("webpro.vscode-knip");for(let n of t){let o=yield*(yield*T).run({args:["--install-extension",n],command:"code"}).pipe(M.mapError((i)=>i._tag==="CliNotFound"&&i.command==="code"?new Ut({cause:i}):new tt({cause:i,extension:n})));if(o!==Er.ExitCode(0))return yield*new tt({cause:o,extension:n})}}),files:Ce,kind:"editor",name:"vscode",update:(e)=>M.gen(function*(){let t=yield*$t.FileSystem,r=(yield*Ft.Path).join(e,Ce[0].path),o=yield*t.readFileString(r).pipe(M.mapError((a)=>new R({cause:a,path:r}))),i=yield*A(o,r);if(!dr.isObject(i))return yield*new Z({path:r});let s=yield*De(hr,i);yield*t.writeFileString(r,`${JSON.stringify(s,null,2)}
|
|
109
|
+
`).pipe(M.mapError((a)=>new S({cause:a,path:r})))})});import*as gr from"effect/Array";import*as ae from"effect/Effect";import*as vt from"effect/FileSystem";import*as Rt from"effect/Path";import*as Or from"effect/Predicate";import*as U from"effect/Schema";var et=[{path:".zed/settings.json",type:"config"}],Gt={languages:{CSS:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},HTML:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JSON:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JSONC:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JavaScript:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},MDX:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},Markdown:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},TSX:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},TypeScript:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},YAML:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]}},lsp:{oxfmt:{initialization_options:{settings:{configPath:null,"fmt.experimental":!0,run:"onSave",typeAware:!1,unusedDisableDirectives:!1}}},oxlint:{initialization_options:{settings:{configPath:null,fixKind:"safe_fix",run:"onType",typeAware:!0,unusedDisableDirectives:"deny"}}}}};function Uo(e){let t=e.languages;if(!U.is(U.Record(U.String,U.Json))(t))return e;let n=Object.fromEntries(Object.entries(t).map(([r,o])=>{if(r in Gt.languages&&U.is(U.Record(U.String,U.Json))(o)&&U.is(U.Array(U.Json))(o.formatter))return[r,Object.fromEntries([...Object.entries(o),["formatter",gr.dedupe(o.formatter)]])];return[r,o]}));return{...e,languages:n}}var Fe=I({config:et[0].path,create:(e)=>ae.gen(function*(){let t=yield*vt.FileSystem,n=yield*Rt.Path,r=n.join(e,et[0].path),o=n.dirname(r);yield*t.makeDirectory(o,{recursive:!0}).pipe(ae.mapError((i)=>new ge({cause:i,path:o}))),yield*t.writeFileString(r,`${JSON.stringify(Gt,null,2)}
|
|
110
|
+
`).pipe(ae.mapError((i)=>new S({cause:i,path:r})))}),detect:(e)=>ae.gen(function*(){let t=yield*vt.FileSystem,n=yield*Rt.Path;return yield*t.exists(n.join(e,et[0].path))}),files:et,kind:"editor",name:"zed",update:(e)=>ae.gen(function*(){let t=yield*vt.FileSystem,r=(yield*Rt.Path).join(e,et[0].path),o=yield*t.readFileString(r).pipe(ae.mapError((f)=>new R({cause:f,path:r}))),i=yield*A(o,r);if(!Or.isObject(i))return yield*new Z({path:r});let s=yield*De(Gt,i),a=Uo(s);yield*t.writeFileString(r,`${JSON.stringify(a,null,2)}
|
|
111
|
+
`).pipe(ae.mapError((f)=>new S({cause:f,path:r})))})});import*as ve from"effect/Effect";import*as Sr from"effect/FileSystem";import*as jr from"effect/Path";import{runScriptCommand as Ao}from"nypm";var ko="AGENTS.md",$r="<!-- ADAMANTITE:START -->",Ct="<!-- ADAMANTITE:END -->";function Bo(e,t){let n=Ao(e,t),r=He[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 Qo({packageManager:e,scripts:t}){let r=["format","check","fix","analyze","check:monorepo","fix:monorepo"].filter((i)=>t.includes(i)).map((i)=>Bo(e,i)),o=["## Adamantite","","This project uses Adamantite for its managed formatting, linting, type checking, and dependency-analysis setup.","",...r.length>0?["- Prefer the package scripts Adamantite added for this workspace.",...r]:[],"- Use `adamantite doctor` to inspect managed setup and `adamantite doctor --fix` for safe local fixes."].join(`
|
|
112
|
+
`);return[$r,"",o,"",Ct,""].join(`
|
|
113
|
+
`)}var Fr=(e,t)=>ve.gen(function*(){let n=yield*Sr.FileSystem,o=(yield*jr.Path).join(e,ko),s=(yield*n.exists(o).pipe(ve.mapError((u)=>new R({cause:u,path:o}))))?yield*n.readFileString(o).pipe(ve.mapError((u)=>new R({cause:u,path:o}))):"",a=s.indexOf($r),f=s.indexOf(Ct),l=Qo(t);if(a!==-1&&f!==-1&&a<f){let u=f+Ct.length,E=`${s.slice(0,a)}${l.trimEnd()}${s.slice(u)}`;return yield*n.writeFileString(o,E.endsWith(`
|
|
114
114
|
`)?E:`${E}
|
|
115
|
-
`).pipe(ve.mapError((
|
|
115
|
+
`).pipe(ve.mapError((j)=>new S({cause:j,path:o}))),"updated"}if(a!==-1||f!==-1)return"malformed";let p=s.length===0||s.endsWith(`
|
|
116
116
|
|
|
117
117
|
`)?"":s.endsWith(`
|
|
118
118
|
`)?`
|
|
119
119
|
`:`
|
|
120
120
|
|
|
121
|
-
`;return yield*n.writeFileString(o,`${s}${
|
|
122
|
-
`).pipe(d.mapError((a)=>new j({cause:a,path:s})))}),{failure:"Failed to add scripts to `package.json`.",start:"Adding scripts to your `package.json`...",success:"Scripts added to your `package.json`"})}),Qo=(e)=>d.gen(function*(){let t=yield*O,n=yield*t.withSpinner((r)=>d.gen(function*(){let o=yield*h.detect(e);if(o.active?.format==="ts"&&o.legacy.length>0)yield*t.log.warning(`Found both \`${h.config}\` and \`knip.json(c)\`. Adamantite will use \`${h.config}\`.`);if(o.active&&o.active.format!=="ts"&&o.legacy.length>0)yield*t.log.warning("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(o.active?.format==="json"||o.active?.format==="jsonc"){let i=o.active.path.endsWith(h.files[1].path)?h.files[1].path:h.files[2].path;return yield*r.message(`Found \`${i}\`, keeping existing config.`),{created:!1,legacyConfig:i}}if(o.active?.format==="ts")return yield*r.message(`Found \`${h.config}\`, keeping existing config.`),{created:!1,legacyConfig:null};return yield*r.message(`\`${h.config}\` not found, creating...`),yield*h.create(e),{created:!0,legacyConfig:null}}),{failure:"Failed to set up knip config.",start:"Setting up knip config...",success:(r)=>r.created?"knip config created successfully.":"knip config is ready."});if(n.legacyConfig)yield*nn("knip",n.legacyConfig)}),Wo=(e)=>d.gen(function*(){yield*(yield*O).withSpinner((n)=>d.gen(function*(){if(yield*k.detect(e))return yield*n.message(`\`${k.config}\` found, updating...`),yield*k.update(e),!1;return yield*n.message(`\`${k.config}\` not found, creating...`),yield*k.create(e),!0}),{failure:"Failed to set up TypeScript config.",start:"Setting up TypeScript config...",success:(n)=>n?`\`${k.config}\` created successfully`:`\`${k.config}\` updated successfully`})}),Zo=(e,t)=>d.gen(function*(){let n=yield*O;if(t.includes("vscode"))yield*n.withSpinner((r)=>d.gen(function*(){let o=yield*ye.detect(e);return yield*r.message(`\`${ye.config}\` ${o?"found, updating":"not found, creating"}...`),yield*o?ye.update(e):ye.create(e),!o}),{failure:"Failed to set up VS Code config.",start:`Checking for \`${ye.config}\`...`,success:(r)=>`\`${ye.config}\` ${r?"created":"updated"} with Adamantite preset.`});if(t.includes("zed"))yield*n.withSpinner((r)=>d.gen(function*(){let o=yield*Fe.detect(e);return yield*r.message(`\`${Fe.config}\` ${o?"found, updating":"not found, creating"}...`),yield*o?Fe.update(e):Fe.create(e),!o}),{failure:"Failed to set up Zed config.",start:`Checking for \`${Fe.config}\`...`,success:(r)=>`\`${Fe.config}\` ${r?"created":"updated"} with Adamantite preset.`})}),Xo=(e,t)=>d.gen(function*(){let n=yield*O,r=e.includes("zed"),o=e.includes("vscode");if(yield*n.withSpinner((i)=>d.gen(function*(){if(o)yield*i.message("Installing VS Code extension..."),yield*ye.extension(t);return!0}),{start:"Installing editor extensions...",success:r&&!o?"Zed extensions require manual install.":"Editor extensions installed successfully."}).pipe(d.catchTag("FailedToInstallExtension",(i)=>d.gen(function*(){return yield*n.log.warning(`⚠️ Failed to install the \`${i.extension}\` extension.`),yield*n.log.warning("Please install it manually after setup completes."),!1})),d.catchTag("VscodeCliNotFound",()=>d.gen(function*(){return yield*n.log.error("VSCode CLI ('code' command) not found."),yield*n.log.info("To install it:"),yield*n.log.info(" 1. Open VS Code"),yield*n.log.info(" 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)"),yield*n.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))),r)yield*n.log.info("Install the Zed `oxc` extension: zed://extension/oxc")}),Yo=(e,t,n)=>d.gen(function*(){let r=yield*O,o=se.files[0].path;yield*r.withSpinner((i)=>d.gen(function*(){let s=yield*se.detect(e);return yield*i.message(s?`\`${o}\` found, updating...`:`Creating \`${o}\`...`),yield*s?se.update(e,{packageManager:t,scripts:n}):se.create(e,{packageManager:t,scripts:n}),!s}),{failure:"Failed to set up GitHub Actions workflow.",start:"Setting up GitHub Actions workflow...",success:(i)=>`GitHub Actions workflow ${i?"created":"updated"} successfully.`})}).pipe(d.option),Ho=(e,t,n)=>d.gen(function*(){let r=yield*O,o=yield*r.withSpinner(()=>Er(e,{packageManager:t,scripts:n}),{failure:"Failed to update AGENTS.md.",start:"Updating AGENTS.md...",success:"AGENTS.md check complete."}).pipe(d.catchTag(["FailedToReadFile","FailedToWriteFile"],(i)=>d.gen(function*(){return yield*r.log.warning(`Could not update AGENTS.md. ${i.message} Adamantite will continue initialization.`),"failed"})));if(o==="failed")return;if(o==="malformed")yield*r.log.warning("Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.")}),Sr=["check","fix","format","check:monorepo","fix:monorepo","analyze"],$r=["react","nextjs","vue","jest","vitest","node"],Fr=["vscode","zed"],Ko=d.fn("validateInitOptions")(function*(e,t){let n={agents:e.agents,editors:Je.dedupe(e.editors),githubActions:e.githubActions,installExtensions:e.installExtensions,presets:Je.dedupe(e.presets),scripts:Je.dedupe(e.scripts),typescript:e.typescript};if(n.scripts.length===0)return yield*new M({reason:"Select at least one script with `--script <name>`."});let r=n.scripts.includes("check")||n.scripts.includes("fix");if((n.scripts.includes("check:monorepo")||n.scripts.includes("fix:monorepo"))&&!t.isMonorepo)return yield*new M({reason:"Monorepo scripts can only be selected in a detected monorepo."});if(n.presets.length>0&&!r)return yield*new M({reason:"`--preset` requires the `check` or `fix` script."});if(n.typescript&&!r)return yield*new M({reason:"`--typescript` requires the `check` or `fix` script."});if(n.installExtensions&&n.editors.length===0)return yield*new M({reason:"`--install-extensions` requires at least one `--editor`."});if(n.githubActions&&!we(n.scripts))return yield*new M({reason:"`--github-actions` requires a CI-compatible script."});if(n.githubActions&&t.nonInteractive&&!Ye(t.packageManager))return yield*new M({reason:`\`--github-actions\` does not support the detected package manager \`${t.packageManager}\`. Use bun, deno, npm, pnpm, or yarn.`});return n}),xo=$.boolean("non-interactive").pipe($.withDescription("Configure without prompts; requires at least one --script")),Lo=$.choice("script",Sr).pipe($.atMost(Sr.length),$.withDescription("Package script to configure; repeatable and required in non-interactive mode. Monorepo scripts require a detected monorepo")),wo=$.choice("preset",$r).pipe($.atMost($r.length),$.withDescription("Oxlint preset to configure; repeatable and requires --script check or fix")),Mo=$.choice("editor",Fr).pipe($.atMost(Fr.length),$.withDescription("Editor to configure; may be specified multiple times")),Go=$.boolean("typescript").pipe($.withDescription("Configure the TypeScript preset; requires --script check or fix")),Co=$.boolean("install-extensions").pipe($.withDescription("Install recommended extensions; requires at least one --editor")),ei=$.boolean("github-actions").pipe($.withDescription("Configure CI; requires a compatible script and bun, deno, npm, pnpm, or yarn")),ti=$.boolean("agents").pipe($.withDescription("Add Adamantite guidance to AGENTS.md")),ni=d.fn("collectInteractiveInitOptions")(function*(e){let t=yield*O,n=yield*t.multiselect({message:"Which scripts do you want to add to your `package.json`?",options:[{hint:"recommended",label:"check - find issues and type errors using oxlint",value:"check"},{hint:"recommended",label:"fix - fix code issues using oxlint",value:"fix"},{hint:"recommended",label:"format - code formatting using oxfmt",value:"format"},{disabled:!e,hint:e?void 0:"available for monorepo projects",label:"check:monorepo - check for monorepo-specific issues using Sherif",value:"check:monorepo"},{disabled:!e,hint:e?void 0:"available for monorepo projects",label:"fix:monorepo - fix monorepo-specific issues using Sherif",value:"fix:monorepo"},{label:"analyze - find unused dependencies, exports, and files using knip",value:"analyze"}]}),r=n.includes("check")||n.includes("fix"),o=[];if(r)o=yield*t.multiselect({message:"Which presets do you want to install? (core is always included)",options:[{label:"React",value:"react"},{label:"Next.js",value:"nextjs"},{label:"Vue",value:"vue"},{label:"Jest",value:"jest"},{label:"Vitest",value:"vitest"},{label:"Node",value:"node"}],required:!1});let i=r?yield*t.confirm({initialValue:!0,message:"Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?"}):!1,s=yield*t.multiselect({message:"Which editors do you want to configure? (optional)",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}),a=s.length>0?yield*t.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"}):!1,u=we(n)?yield*t.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"}):!1;return{agents:yield*t.confirm({initialValue:!0,message:"Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?"}),editors:s,githubActions:u,installExtensions:a,presets:o,scripts:n,typescript:i}}),Vr=he.make("init",{agents:ti,editors:Mo,githubActions:ei,installExtensions:Co,nonInteractive:xo,presets:wo,scripts:Lo,typescript:Go}).pipe(he.withDescription("Initialize Adamantite in the current directory. Setup flags require --non-interactive; omitted boolean setup flags are disabled"),he.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"}]),he.withHandler((e)=>d.gen(function*(){let t=Uo.cwd(),n=yield*O;yield*_e(),yield*n.intro("\uD83D\uDCA0 adamantite init");let o=yield*(yield*K).detectPackageManager(t);if(!o)return yield*new Xe({});if(o.warnings?.length)for(let Ze of o.warnings)yield*n.log.warning(Ze);yield*n.log.info(`Detected package manager: ${o.name}`);let i=yield*tn(t);if(i)yield*n.log.info("We've detected a monorepo setup in your project.");if(!e.nonInteractive&&Je.some([e.scripts.length>0,e.presets.length>0,e.editors.length>0,e.typescript,e.installExtensions,e.githubActions,e.agents],Dr.isTruthy))return yield*new M({reason:"Setup flags require `--non-interactive`."});let s=e.nonInteractive?e:yield*ni(i),a=yield*Ko(s,{isMonorepo:i,nonInteractive:e.nonInteractive,packageManager:o.name}),u=a.scripts,f=a.presets,l=a.editors,p=a.typescript,E=a.installExtensions,S=a.githubActions,T=a.agents,P=u.includes("check")||u.includes("fix"),te=u.includes("format"),c=u.includes("check:monorepo")||u.includes("fix:monorepo"),z=u.includes("analyze"),Ee=["adamantite"];if(P)Ee.push(`${y.name}@${y.version}`,`${le.name}@${le.version}`);if(te)Ee.push(`${m.name}@${m.version}`);if(c)Ee.push(`${L.name}@${L.version}`);if(z)Ee.push(`${h.name}@${h.version}`);if(yield*ko(t,Ee),te)yield*Jo(t);if(P)yield*Ao(t,f);if(z)yield*Qo(t);if(yield*Bo(t,u),T)yield*Ho(t,o.name,u);if(p)yield*Wo(t);if(yield*Zo(t,l),E)yield*Xo(l,u);if(S){let Ze=o.name;if(Ye(Ze))yield*Yo(t,Ze,u);else yield*n.log.warning(`Skipping GitHub Actions setup: \`${Ze}\` is not a supported package manager for CI workflow generation.`)}yield*n.log.success("Your project is now configured"),yield*n.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe(d.catchTags({OperationCancelled:()=>d.gen(function*(){yield*(yield*O).cancel("You've cancelled the initialization process.")})}))));import*as Pr from"effect/Effect";import*as Be from"effect/unstable/cli/Command";import*as Vt from"effect/unstable/cli/Flag";import*as Ir from"effect/unstable/process/ChildProcessSpawner";var ri=Vt.boolean("fix").pipe(Vt.withDescription("Automatically fix issues")),rn=Be.make("monorepo",{fix:ri}).pipe(Be.withDescription("Find and fix monorepo-specific issues using Sherif"),Be.withHandler(({fix:e})=>Pr.gen(function*(){let t=yield*B,n=yield*_,r=e?["--fix",...t]:[...t],o=yield*n.run({args:r,command:L.name,stdin:"inherit"});if(o!==Ir.ExitCode(0))yield*new b({command:L.name,exitCode:o})})));import*as Nr from"effect/Effect";import*as Qe from"effect/unstable/cli/Command";import*as Tr from"effect/unstable/process/ChildProcessSpawner";var on=Qe.make("typecheck").pipe(Qe.withDescription("Deprecated alias for `check`"),Qe.withHandler(()=>Nr.gen(function*(){let e=yield*B,t=yield*O,n=yield*_;yield*t.log.warning("Deprecated. Use `adamantite check` for typechecking.");let r=yield*n.run({args:[...e],command:y.name});if(r!==Tr.ExitCode(0))yield*new b({command:y.name,exitCode:r})})));import oi from"node:process";import*as me from"effect/Effect";import*as We from"effect/unstable/cli/Command";var ii=[y,le,m,L,h],si=[y,le,m,L,h];function ai(e,t){let n=[];for(let r of si){if(t.has(r.name))continue;let o=e.devDependencies?.[r.name]??e.dependencies?.[r.name];if(o&&Y(o)!==r.version)n.push({currentVersion:o,name:r.name,targetVersion:r.version})}return n}var _r=We.make("update").pipe(We.withDescription("Run applicable Adamantite migrations and update managed dependencies"),We.withHandler(()=>me.gen(function*(){let e=oi.cwd(),t=yield*O,n=yield*K,r={cwd:e};yield*_e(),yield*t.intro("\uD83D\uDCA0 adamantite update");let o=()=>jt(ii,e),i=yield*o();for(let{assessment:c}of i)for(let z of c.warnings)yield*t.log.warning(z);let s=new Set(i.map(({integration:c})=>c.name)),a=i.flatMap(({assessment:c})=>c.actions),u=new Set(a.filter((c)=>c.type==="run_migration").map((c)=>c.migrationId)),f=[];for(let c of gt.filter((z)=>z.tags.includes("update"))){let z=Mn[c.id];if(s.has(z))continue;let Ee=yield*c.check(r);f.push({migration:c,result:Ee})}for(let c of f){for(let z of c.result.warnings)yield*t.log.warning(z);if(c.result.applicable&&c.result.summary)yield*t.log.info(c.result.summary)}let l=[];for(let c of gt){if(!u.has(c.id))continue;yield*Le(c,r,{onRestore:t.log.warning(`Migration "${c.title}" failed, restoring files...`)}),l.push(c.id)}for(let{migration:c,result:z}of f){if(!z.applicable||!z.summary)continue;yield*Le(c,r,{onRestore:t.log.warning(`Migration "${c.title}" failed, restoring files...`)}),l.push(c.id)}if(l.length>0)yield*t.log.success("Migrations ran successfully.");let p=yield*v(e),E=yield*o(),S=E.flatMap(({assessment:c})=>c.actions).filter((c)=>c.type==="create_config"||c.type==="update_config"||c.type==="manual_fix"),T=E.flatMap(({assessment:c})=>c.actions).filter((c)=>c.type==="install_package"||c.type==="update_package").map((c)=>c.type==="install_package"?{currentVersion:"not installed",name:c.package,targetVersion:c.targetVersion}:{currentVersion:c.currentVersion,name:c.package,targetVersion:c.targetVersion}),P=new Set(T.map((c)=>c.name)),te=[...T,...ai(p,P)];if(te.length>0){yield*t.log.info("The following dependencies will be updated:");for(let c of te)yield*t.log.info(` ${c.name}: ${c.currentVersion} → ${c.targetVersion}`);yield*t.withSpinner(()=>n.addDevDependencies(te.map((c)=>`${c.name}@${c.targetVersion}`),e,{silent:!0}),{failure:"Failed to update dependencies",start:"Updating dependencies...",success:"Dependencies updated successfully"}),yield*t.log.success("Dependencies updated successfully.")}if(S.length>0){yield*t.log.warning("Some configuration follow-up belongs to `adamantite doctor --fix`.");for(let c of S)yield*t.log.warning(`Doctor follow-up: ${c.description}`)}if(l.length===0&&te.length===0&&S.length===0)return yield*t.log.success("No changes needed."),"no-changes";return"success"}).pipe(me.tapError(()=>me.gen(function*(){yield*(yield*O).outro("❌ Update failed")})),me.tap((e)=>me.gen(function*(){let t=yield*O;switch(e){case"no-changes":yield*t.outro("✅ Adamantite is already up to date.");break;case"success":yield*t.outro("✅ Update completed successfully!");break;default:break}})))));var fi=[Qt,Kt,Gt,Ct,rn,on],qr=[Qt,Kt,ir,Gt,Ct,Vr,rn,on,_r],li=new Set(qr.map((e)=>e.name)),pi=new Set(fi.map((e)=>e.name)),ui=de.make("adamantite").pipe(de.withDescription("Opinionated preset package for modern TypeScript applications"),de.withSubcommands(qr)),zr=It.fn("runCli")(function*(e,t){let[n,r]=Pt.splitWhere(e,(s)=>s==="--"),o=Pt.drop(r,1),i=n.find((s)=>li.has(s));if(o.length>0&&i!==void 0&&!pi.has(i))return yield*new Ut({command:i});yield*de.runWith(ui,{version:t})(n).pipe(It.provideService(B,o))});var ci=q.gen(function*(){let t=yield*(yield*Br.Stdio).args;yield*zr(t,"0.34.1")}).pipe(q.as(0),q.catchTag("CommandFailed",(e)=>q.succeed(e.exitCode)),q.catch((e)=>q.service(O).pipe(q.flatMap((t)=>t.log.error(e.message)),q.as(Qr.ExitCode(1)))),q.provide(Ar.mergeAll(Ur.layer,O.layer,_.layer,K.layer)));br.runMain(ci,{teardown:(e,t)=>{if(kr.isSuccess(e)){t(Number(e.value));return}Jr.defaultTeardown(e,t)}});
|
|
121
|
+
`;return yield*n.writeFileString(o,`${s}${p}${l}`).pipe(ve.mapError((u)=>new S({cause:u,path:o}))),"updated"});import Wo from"node:process";import*as vr from"effect/Effect";import*as Rr from"effect/FileSystem";import*as Dr from"effect/Path";var en=(e=Wo.cwd())=>vr.gen(function*(){let t=yield*Rr.FileSystem,n=yield*Dr.Path;if(yield*t.exists(n.join(e,"pnpm-workspace.yaml")))return!0;return(yield*v(e)).workspaces!==void 0});var Xo=(e,t)=>d.gen(function*(){let n=yield*K;yield*(yield*O).withSpinner(()=>d.gen(function*(){let o=yield*en(e);yield*n.addDevDependencies(t,e,{silent:!0,workspace:o})}),{failure:"Failed to install dependencies.",start:"Installing dependencies...",success:"Dependencies installed."})});function tn(e,t){return d.gen(function*(){yield*(yield*O).log.info(`Legacy \`${t}\` was preserved during \`adamantite init\`. \`adamantite init\` does not migrate legacy ${e} configs yet.`)})}var Yo=(e,t)=>d.gen(function*(){let n=yield*O,r=yield*n.withSpinner((o)=>d.gen(function*(){let i=yield*y.detect(e),s=y.files[1].path;if(i.active?.format==="ts"&&i.legacy.length>0)yield*n.log.warning(`Found both \`${y.config}\` and \`${s}\`. Adamantite will use \`${y.config}\`.`);if(i.active?.format==="json")return yield*o.message(`Found \`${s}\`, keeping existing config.`),{created:!1,legacyConfig:s};if(i.active?.format==="ts")return yield*o.message(`Found \`${y.config}\`, keeping existing config.`),{created:!1,legacyConfig:null};return yield*o.message(`\`${y.config}\` not found, creating...`),yield*y.create(e,t),{created:!0,legacyConfig:null}}),{failure:"Failed to set up oxlint config.",start:"Setting up oxlint config...",success:(o)=>o.created?"oxlint config created successfully.":"oxlint config is ready."});if(r.legacyConfig)yield*tn("oxlint",r.legacyConfig)}),Ho=(e)=>d.gen(function*(){let t=yield*O,n=yield*t.withSpinner((r)=>d.gen(function*(){let o=yield*h.detect(e);if(o.active?.format==="ts"&&o.legacy.length>0)yield*t.log.warning(`Found both \`${h.config}\` and \`.oxfmtrc.json(c)\`. Adamantite will use \`${h.config}\`.`);if(o.active&&o.active.format!=="ts"&&o.legacy.length>0)yield*t.log.warning("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(o.active?.format==="json"||o.active?.format==="jsonc"){let i=o.active.path.endsWith(h.files[1].path)?h.files[1].path:h.files[2].path;return yield*r.message(`Found \`${i}\`, keeping existing config.`),{created:!1,legacyConfig:i}}if(o.active?.format==="ts")return yield*r.message(`Found \`${h.config}\`, keeping existing config.`),{created:!1,legacyConfig:null};return yield*r.message(`\`${h.config}\` not found, creating...`),yield*h.create(e),{created:!0,legacyConfig:null}}),{failure:"Failed to set up oxfmt config.",start:"Setting up oxfmt config...",success:(r)=>r.created?"oxfmt config created successfully.":"oxfmt config is ready."});if(n.legacyConfig)yield*tn("oxfmt",n.legacyConfig)}),Ko=(e,t)=>d.gen(function*(){let n=yield*Nr.FileSystem,r=yield*Tr.Path,o=yield*O,i=yield*v(e);yield*o.withSpinner(()=>d.gen(function*(){i.scripts??={};for(let a of t)switch(a){case"check":i.scripts.check="adamantite check";break;case"fix":i.scripts.fix="adamantite fix";break;case"format":i.scripts.format="adamantite format";break;case"check:monorepo":i.scripts["check:monorepo"]="adamantite monorepo";break;case"fix:monorepo":i.scripts["fix:monorepo"]="adamantite monorepo --fix";break;case"analyze":i.scripts.analyze="adamantite analyze";break;default:return yield*new Jt({script:a})}let s=r.join(e,"package.json");yield*n.writeFileString(s,`${JSON.stringify(i,null,2)}
|
|
122
|
+
`).pipe(d.mapError((a)=>new S({cause:a,path:s})))}),{failure:"Failed to add scripts to `package.json`.",start:"Adding scripts to your `package.json`...",success:"Scripts added to your `package.json`"})}),xo=(e)=>d.gen(function*(){let t=yield*O,n=yield*t.withSpinner((r)=>d.gen(function*(){let o=yield*m.detect(e);if(o.active?.format==="ts"&&o.legacy.length>0)yield*t.log.warning(`Found both \`${m.config}\` and \`knip.json(c)\`. Adamantite will use \`${m.config}\`.`);if(o.active&&o.active.format!=="ts"&&o.legacy.length>0)yield*t.log.warning("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(o.active?.format==="json"||o.active?.format==="jsonc"){let i=o.active.path.endsWith(m.files[1].path)?m.files[1].path:m.files[2].path;return yield*r.message(`Found \`${i}\`, keeping existing config.`),{created:!1,legacyConfig:i}}if(o.active?.format==="ts")return yield*r.message(`Found \`${m.config}\`, keeping existing config.`),{created:!1,legacyConfig:null};return yield*r.message(`\`${m.config}\` not found, creating...`),yield*m.create(e),{created:!0,legacyConfig:null}}),{failure:"Failed to set up knip config.",start:"Setting up knip config...",success:(r)=>r.created?"knip config created successfully.":"knip config is ready."});if(n.legacyConfig)yield*tn("knip",n.legacyConfig)}),Lo=(e)=>d.gen(function*(){yield*(yield*O).withSpinner((n)=>d.gen(function*(){if(yield*J.detect(e))return yield*n.message(`\`${J.config}\` found, updating...`),yield*J.update(e),!1;return yield*n.message(`\`${J.config}\` not found, creating...`),yield*J.create(e),!0}),{failure:"Failed to set up TypeScript config.",start:"Setting up TypeScript config...",success:(n)=>n?`\`${J.config}\` created successfully`:`\`${J.config}\` updated successfully`})}),Mo=(e,t)=>d.gen(function*(){let n=yield*O;if(t.includes("vscode"))yield*n.withSpinner((r)=>d.gen(function*(){let o=yield*ye.detect(e);return yield*r.message(`\`${ye.config}\` ${o?"found, updating":"not found, creating"}...`),yield*o?ye.update(e):ye.create(e),!o}),{failure:"Failed to set up VS Code config.",start:`Checking for \`${ye.config}\`...`,success:(r)=>`\`${ye.config}\` ${r?"created":"updated"} with Adamantite preset.`});if(t.includes("zed"))yield*n.withSpinner((r)=>d.gen(function*(){let o=yield*Fe.detect(e);return yield*r.message(`\`${Fe.config}\` ${o?"found, updating":"not found, creating"}...`),yield*o?Fe.update(e):Fe.create(e),!o}),{failure:"Failed to set up Zed config.",start:`Checking for \`${Fe.config}\`...`,success:(r)=>`\`${Fe.config}\` ${r?"created":"updated"} with Adamantite preset.`})}),wo=(e,t)=>d.gen(function*(){let n=yield*O,r=e.includes("zed"),o=e.includes("vscode");if(yield*n.withSpinner((i)=>d.gen(function*(){if(o)yield*i.message("Installing VS Code extension..."),yield*ye.extension(t);return!0}),{start:"Installing editor extensions...",success:r&&!o?"Zed extensions require manual install.":"Editor extensions installed successfully."}).pipe(d.catchTag("FailedToInstallExtension",(i)=>d.gen(function*(){return yield*n.log.warning(`⚠️ Failed to install the \`${i.extension}\` extension.`),yield*n.log.warning("Please install it manually after setup completes."),!1})),d.catchTag("VscodeCliNotFound",()=>d.gen(function*(){return yield*n.log.error("VSCode CLI ('code' command) not found."),yield*n.log.info("To install it:"),yield*n.log.info(" 1. Open VS Code"),yield*n.log.info(" 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)"),yield*n.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))),r)yield*n.log.info("Install the Zed `oxc` extension: zed://extension/oxc")}),Go=(e,t,n)=>d.gen(function*(){let r=yield*O,o=se.files[0].path;yield*r.withSpinner((i)=>d.gen(function*(){let s=yield*se.detect(e);return yield*i.message(s?`\`${o}\` found, updating...`:`Creating \`${o}\`...`),yield*s?se.update(e,{packageManager:t,scripts:n}):se.create(e,{packageManager:t,scripts:n}),!s}),{failure:"Failed to set up GitHub Actions workflow.",start:"Setting up GitHub Actions workflow...",success:(i)=>`GitHub Actions workflow ${i?"created":"updated"} successfully.`})}).pipe(d.option),Co=(e,t,n)=>d.gen(function*(){let r=yield*O,o=yield*r.withSpinner(()=>Fr(e,{packageManager:t,scripts:n}),{failure:"Failed to update AGENTS.md.",start:"Updating AGENTS.md...",success:"AGENTS.md check complete."}).pipe(d.catchTag(["FailedToReadFile","FailedToWriteFile"],(i)=>d.gen(function*(){return yield*r.log.warning(`Could not update AGENTS.md. ${i.message} Adamantite will continue initialization.`),"failed"})));if(o==="failed")return;if(o==="malformed")yield*r.log.warning("Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.")}),Vr=["check","fix","format","check:monorepo","fix:monorepo","analyze"],Pr=["react","nextjs","vue","jest","vitest","node"],Ir=["vscode","zed"],ei=d.fn("validateInitOptions")(function*(e,t){let n={agents:e.agents,editors:ke.dedupe(e.editors),githubActions:e.githubActions,installExtensions:e.installExtensions,presets:ke.dedupe(e.presets),scripts:ke.dedupe(e.scripts),typescript:e.typescript};if(n.scripts.length===0)return yield*new w({reason:"Select at least one script with `--script <name>`."});let r=n.scripts.includes("check")||n.scripts.includes("fix");if((n.scripts.includes("check:monorepo")||n.scripts.includes("fix:monorepo"))&&!t.isMonorepo)return yield*new w({reason:"Monorepo scripts can only be selected in a detected monorepo."});if(n.presets.length>0&&!r)return yield*new w({reason:"`--preset` requires the `check` or `fix` script."});if(n.typescript&&!r)return yield*new w({reason:"`--typescript` requires the `check` or `fix` script."});if(n.installExtensions&&n.editors.length===0)return yield*new w({reason:"`--install-extensions` requires at least one `--editor`."});if(n.githubActions&&!Me(n.scripts))return yield*new w({reason:"`--github-actions` requires a CI-compatible script."});if(n.githubActions&&t.nonInteractive&&!Ye(t.packageManager))return yield*new w({reason:`\`--github-actions\` does not support the detected package manager \`${t.packageManager}\`. Use bun, deno, npm, pnpm, or yarn.`});return n}),ti=$.boolean("non-interactive").pipe($.withDescription("Configure without prompts; requires at least one --script")),ni=$.choice("script",Vr).pipe($.atMost(Vr.length),$.withDescription("Package script to configure; repeatable and required in non-interactive mode. Monorepo scripts require a detected monorepo")),ri=$.choice("preset",Pr).pipe($.atMost(Pr.length),$.withDescription("Oxlint preset to configure; repeatable and requires --script check or fix")),oi=$.choice("editor",Ir).pipe($.atMost(Ir.length),$.withDescription("Editor to configure; may be specified multiple times")),ii=$.boolean("typescript").pipe($.withDescription("Configure the TypeScript preset; requires --script check or fix")),si=$.boolean("install-extensions").pipe($.withDescription("Install recommended extensions; requires at least one --editor")),ai=$.boolean("github-actions").pipe($.withDescription("Configure CI; requires a compatible script and bun, deno, npm, pnpm, or yarn")),fi=$.boolean("agents").pipe($.withDescription("Add Adamantite guidance to AGENTS.md")),li=d.fn("collectInteractiveInitOptions")(function*(e){let t=yield*O,n=yield*t.multiselect({message:"Which scripts do you want to add to your `package.json`?",options:[{hint:"recommended",label:"check - find issues and type errors using oxlint",value:"check"},{hint:"recommended",label:"fix - fix code issues using oxlint",value:"fix"},{hint:"recommended",label:"format - code formatting using oxfmt",value:"format"},{disabled:!e,hint:e?void 0:"available for monorepo projects",label:"check:monorepo - check for monorepo-specific issues using Sherif",value:"check:monorepo"},{disabled:!e,hint:e?void 0:"available for monorepo projects",label:"fix:monorepo - fix monorepo-specific issues using Sherif",value:"fix:monorepo"},{label:"analyze - find unused dependencies, exports, and files using knip",value:"analyze"}]}),r=n.includes("check")||n.includes("fix"),o=[];if(r)o=yield*t.multiselect({message:"Which presets do you want to install? (core is always included)",options:[{label:"React",value:"react"},{label:"Next.js",value:"nextjs"},{label:"Vue",value:"vue"},{label:"Jest",value:"jest"},{label:"Vitest",value:"vitest"},{label:"Node",value:"node"}],required:!1});let i=r?yield*t.confirm({initialValue:!0,message:"Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?"}):!1,s=yield*t.multiselect({message:"Which editors do you want to configure? (optional)",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}),a=s.length>0?yield*t.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"}):!1,f=Me(n)?yield*t.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"}):!1;return{agents:yield*t.confirm({initialValue:!0,message:"Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?"}),editors:s,githubActions:f,installExtensions:a,presets:o,scripts:n,typescript:i}}),br=me.make("init",{agents:fi,editors:oi,githubActions:ai,installExtensions:si,nonInteractive:ti,presets:ri,scripts:ni,typescript:ii}).pipe(me.withDescription("Initialize Adamantite in the current directory. Setup flags require --non-interactive; omitted boolean setup flags are disabled"),me.withExamples([{command:"adamantite init --non-interactive --script check",description:"Configure linting without prompts"},{command:"adamantite init --non-interactive --script check --script format --preset react --editor vscode --typescript --install-extensions --github-actions --agents",description:"Configure a React project with VS Code, TypeScript, CI, and agent guidance"},{command:"adamantite init --non-interactive --script check:monorepo",description:"Configure monorepo checks in a detected monorepo"}]),me.withHandler((e)=>d.gen(function*(){let t=Zo.cwd(),n=yield*O;yield*_e(),yield*n.intro("\uD83D\uDCA0 adamantite init");let o=yield*(yield*K).detectPackageManager(t);if(!o)return yield*new Xe({});if(o.warnings?.length)for(let Ze of o.warnings)yield*n.log.warning(Ze);yield*n.log.info(`Detected package manager: ${o.name}`);let i=yield*en(t);if(i)yield*n.log.info("We've detected a monorepo setup in your project.");if(!e.nonInteractive&&ke.some([e.scripts.length>0,e.presets.length>0,e.editors.length>0,e.typescript,e.installExtensions,e.githubActions,e.agents],_r.isTruthy))return yield*new w({reason:"Setup flags require `--non-interactive`."});let s=e.nonInteractive?e:yield*li(i),a=yield*ei(s,{isMonorepo:i,nonInteractive:e.nonInteractive,packageManager:o.name}),f=a.scripts,l=a.presets,p=a.editors,u=a.typescript,E=a.installExtensions,j=a.githubActions,N=a.agents,P=f.includes("check")||f.includes("fix"),te=f.includes("format"),c=f.includes("check:monorepo")||f.includes("fix:monorepo"),b=f.includes("analyze"),Ee=["adamantite"];if(P)Ee.push(`${y.name}@${y.version}`,`${le.name}@${le.version}`);if(te)Ee.push(`${h.name}@${h.version}`);if(c)Ee.push(`${L.name}@${L.version}`);if(b)Ee.push(`${m.name}@${m.version}`);if(yield*Xo(t,Ee),te)yield*Ho(t);if(P)yield*Yo(t,l);if(b)yield*xo(t);if(yield*Ko(t,f),N)yield*Co(t,o.name,f);if(u)yield*Lo(t);if(yield*Mo(t,p),E)yield*wo(p,f);if(j){let Ze=o.name;if(Ye(Ze))yield*Go(t,Ze,f);else yield*n.log.warning(`Skipping GitHub Actions setup: \`${Ze}\` is not a supported package manager for CI workflow generation.`)}yield*n.log.success("Your project is now configured"),yield*n.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe(d.catchTags({OperationCancelled:()=>d.gen(function*(){yield*(yield*O).cancel("You've cancelled the initialization process.")})}))));import*as qr from"effect/Effect";import*as Be from"effect/unstable/cli/Command";import*as Dt from"effect/unstable/cli/Flag";import*as zr from"effect/unstable/process/ChildProcessSpawner";var pi=Dt.boolean("fix").pipe(Dt.withDescription("Automatically fix issues")),nn=Be.make("monorepo",{fix:pi}).pipe(Be.withDescription("Find and fix monorepo-specific issues using Sherif"),Be.withHandler(({fix:e})=>qr.gen(function*(){let t=yield*B,n=yield*T,r=e?["--fix",...t]:[...t],o=yield*n.run({args:r,command:L.name,stdin:"inherit"});if(o!==zr.ExitCode(0))yield*new q({command:L.name,exitCode:o})})));import*as Jr from"effect/Effect";import*as Qe from"effect/unstable/cli/Command";import*as Ur from"effect/unstable/process/ChildProcessSpawner";var rn=Qe.make("typecheck").pipe(Qe.withDescription("Deprecated alias for `check`"),Qe.withHandler(()=>Jr.gen(function*(){let e=yield*B,t=yield*O,n=yield*T;yield*t.log.warning("Deprecated. Use `adamantite check` for typechecking.");let r=yield*n.run({args:[...e],command:y.name});if(r!==Ur.ExitCode(0))yield*new q({command:y.name,exitCode:r})})));import ui from"node:process";import*as he from"effect/Effect";import*as We from"effect/unstable/cli/Command";var ci=[y,le,h,L,m],yi=[y,le,h,L,m];function mi(e,t){let n=[];for(let r of yi){if(t.has(r.name))continue;let o=e.devDependencies?.[r.name]??e.dependencies?.[r.name];if(o&&Y(o)!==r.version)n.push({currentVersion:o,name:r.name,targetVersion:r.version})}return n}var Ar=We.make("update").pipe(We.withDescription("Run applicable Adamantite migrations and update managed dependencies"),We.withHandler(()=>he.gen(function*(){let e=ui.cwd(),t=yield*O,n=yield*K,r={cwd:e};yield*_e(),yield*t.intro("\uD83D\uDCA0 adamantite update");let o=()=>Ot(ci,e),i=yield*o();for(let{assessment:c}of i)for(let b of c.warnings)yield*t.log.warning(b);let s=new Set(i.map(({integration:c})=>c.name)),a=i.flatMap(({assessment:c})=>c.actions),f=new Set(a.filter((c)=>c.type==="run_migration").map((c)=>c.migrationId)),l=[];for(let c of Et.filter((b)=>b.tags.includes("update"))){let b=tr[c.id];if(s.has(b))continue;let Ee=yield*c.check(r);l.push({migration:c,result:Ee})}for(let c of l){for(let b of c.result.warnings)yield*t.log.warning(b);if(c.result.applicable&&c.result.summary)yield*t.log.info(c.result.summary)}let p=[];for(let c of Et){if(!f.has(c.id))continue;yield*Le(c,r,{onRestore:t.log.warning(`Migration "${c.title}" failed, restoring files...`)}),p.push(c.id)}for(let{migration:c,result:b}of l){if(!b.applicable||!b.summary)continue;yield*Le(c,r,{onRestore:t.log.warning(`Migration "${c.title}" failed, restoring files...`)}),p.push(c.id)}if(p.length>0)yield*t.log.success("Migrations ran successfully.");let u=yield*v(e),E=yield*o(),j=E.flatMap(({assessment:c})=>c.actions).filter((c)=>c.type==="create_config"||c.type==="update_config"||c.type==="manual_fix"),N=E.flatMap(({assessment:c})=>c.actions).filter((c)=>c.type==="install_package"||c.type==="update_package").map((c)=>c.type==="install_package"?{currentVersion:"not installed",name:c.package,targetVersion:c.targetVersion}:{currentVersion:c.currentVersion,name:c.package,targetVersion:c.targetVersion}),P=new Set(N.map((c)=>c.name)),te=[...N,...mi(u,P)];if(te.length>0){yield*t.log.info("The following dependencies will be updated:");for(let c of te)yield*t.log.info(` ${c.name}: ${c.currentVersion} → ${c.targetVersion}`);yield*t.withSpinner(()=>n.addDevDependencies(te.map((c)=>`${c.name}@${c.targetVersion}`),e,{silent:!0}),{failure:"Failed to update dependencies",start:"Updating dependencies...",success:"Dependencies updated successfully"}),yield*t.log.success("Dependencies updated successfully.")}if(j.length>0){yield*t.log.warning("Some configuration follow-up belongs to `adamantite doctor --fix`.");for(let c of j)yield*t.log.warning(`Doctor follow-up: ${c.description}`)}if(p.length===0&&te.length===0&&j.length===0)return yield*t.log.success("No changes needed."),"no-changes";return"success"}).pipe(he.tapError(()=>he.gen(function*(){yield*(yield*O).outro("❌ Update failed")})),he.tap((e)=>he.gen(function*(){let t=yield*O;switch(e){case"no-changes":yield*t.outro("✅ Adamantite is already up to date.");break;case"success":yield*t.outro("✅ Update completed successfully!");break;default:break}})))));var hi=[Bt,Yt,Mt,wt,nn,rn],kr=[Bt,Yt,lr,Mt,wt,br,nn,rn,Ar],di=new Set(kr.map((e)=>e.name)),Ei=new Set(hi.map((e)=>e.name)),gi=de.make("adamantite").pipe(de.withDescription("Opinionated preset package for modern TypeScript applications"),de.withSubcommands(kr)),Br=Pt.fn("runCli")(function*(e,t){let[n,r]=Vt.splitWhere(e,(s)=>s==="--"),o=Vt.drop(r,1),i=n.find((s)=>di.has(s));if(o.length>0&&i!==void 0&&!Ei.has(i))return yield*new zt({command:i});yield*de.runWith(gi,{version:t})(n).pipe(Pt.provideService(B,o))});var Oi=_.gen(function*(){let t=yield*(yield*Hr.Stdio).args;yield*Br(t,"0.34.2")}).pipe(_.as(0),_.catchTag("CommandFailed",(e)=>_.succeed(e.exitCode)),_.catch((e)=>_.service(O).pipe(_.flatMap((t)=>t.log.error(e.message)),_.as(Kr.ExitCode(1)))),_.provide(Xr.mergeAll(Wr.layer,O.layer,T.layer,K.layer)));Qr.runMain(Oi,{teardown:(e,t)=>{if(Zr.isSuccess(e)){t(Number(e.value));return}Yr.defaultTeardown(e,t)}});
|