adamantite 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { Fault as Fault3 } from "faultier";
9
9
  import { ok as ok3, safeTry as safeTry3 } from "neverthrow";
10
10
  import { dlxCommand } from "nypm";
11
11
 
12
- // src/helpers/packages/biome.ts
12
+ // src/helpers/packages/oxlint.ts
13
13
  import { readFile as readFile2, writeFile } from "node:fs/promises";
14
14
  import { join as join2 } from "node:path";
15
15
  import { Fault as Fault2 } from "faultier";
@@ -20,7 +20,7 @@ import { spawnSync } from "node:child_process";
20
20
  import { access, readFile } from "node:fs/promises";
21
21
  import { join } from "node:path";
22
22
  import process2 from "node:process";
23
- import defu from "defu";
23
+ import { defu } from "defu";
24
24
  import { Fault } from "faultier";
25
25
  import { parse } from "jsonc-parser";
26
26
  import { err, fromPromise, fromThrowable, ok, safeTry } from "neverthrow";
@@ -50,11 +50,12 @@ var parseJson = (content) => {
50
50
  }
51
51
  return ok(parsed);
52
52
  };
53
+ var isJsonObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
53
54
  var WORKSPACE_PREFIX_REGEX = /^workspace:/;
54
55
  var RANGE_PREFIX_REGEX = /^[\^~]/;
55
56
  var normalizeDependencyVersion = (specifier) => specifier.trim().replace(WORKSPACE_PREFIX_REGEX, "").replace(RANGE_PREFIX_REGEX, "");
56
57
  var mergeConfig = fromThrowable(defu, (error) => Fault.wrap(error).withTag("FAILED_TO_MERGE_CONFIG").withDescription("Failed to merge configuration", "We're unable to merge the configuration files."));
57
- var readPackageJson = (cwd = process2.cwd()) => fromPromise(readFile(join(cwd, "package.json"), "utf-8"), (error) => Fault.wrap(error).withTag("FAILED_TO_READ_FILE").withDescription("Failed to read package.json", "We're unable to read the package.json file in the current directory.").withContext({ path: join(cwd, "package.json") })).andThen((content) => parseJson(content)).andThen((parsed) => ok(parsed));
58
+ var readPackageJson = (cwd = process2.cwd()) => fromPromise(readFile(join(cwd, "package.json"), "utf8"), (error) => Fault.wrap(error).withTag("FAILED_TO_READ_FILE").withDescription("Failed to read package.json", "We're unable to read the package.json file in the current directory.").withContext({ path: join(cwd, "package.json") })).andThen((content) => parseJson(content)).andThen((parsed) => ok(parsed));
58
59
  var checkIsMonorepo = () => safeTry(async function* () {
59
60
  const pnpmWorkspace = await checkIfExists(join(process2.cwd(), "pnpm-workspace.yaml"));
60
61
  if (pnpmWorkspace) {
@@ -63,84 +64,93 @@ var checkIsMonorepo = () => safeTry(async function* () {
63
64
  const packageJson = yield* readPackageJson();
64
65
  return ok(packageJson?.workspaces !== undefined);
65
66
  });
66
- var TITLE = `
67
- o ooooooooo o oooo oooo o oooo oooo ooooooooooo ooooo ooooooooooo ooooooooooo
68
- 888 888 88o 888 8888o 888 888 8888o 88 88 888 88 888 88 888 88 888 88
69
- 8 88 888 888 8 88 88 888o8 88 8 88 88 888o88 888 888 888 888ooo8
70
- 8oooo88 888 888 8oooo88 88 888 88 8oooo88 88 8888 888 888 888 888 oo
71
- o88o o888o o888ooo88 o88o o888o o88o 8 o88o o88o o888o o88o 88 o888o o888o o888o o888ooo8888
72
- `;
73
67
  function printTitle() {
74
- const columns = TITLE.split(`
68
+ const title = `
69
+ .o8 . o8o .
70
+ "888 .o8 \`"' .o8
71
+ .oooo. .oooo888 .oooo. ooo. .oo. .oo. .oooo. ooo. .oo. .o888oo oooo .o888oo .ooooo.
72
+ \`P )88b d88' \`888 \`P )88b \`888P"Y88bP"Y88b \`P )88b \`888P"Y88b 888 \`888 888 d88' \`88b
73
+ .oP"888 888 888 .oP"888 888 888 888 .oP"888 888 888 888 888 888 888ooo888
74
+ d8( 888 888 888 d8( 888 888 888 888 d8( 888 888 888 888 . 888 888 . 888 .o
75
+ \`Y888""8o \`Y8bod88P" \`Y888""8o o888o o888o o888o \`Y888""8o o888o o888o "888" o888o "888" \`Y8bod8P'
76
+ `;
77
+ const columns = title.split(`
75
78
  `).reduce((max, line) => Math.max(max, line.trim().length), 0);
76
79
  if (process2.stdout.columns && process2.stdout.columns >= columns) {
77
- console.log(TITLE);
80
+ console.info(title);
78
81
  }
79
82
  }
80
83
 
81
- // src/helpers/packages/biome.ts
82
- var biome = {
83
- name: "@biomejs/biome",
84
- version: "2.3.10",
84
+ // src/helpers/packages/oxlint.ts
85
+ var oxlint = {
86
+ name: "oxlint",
87
+ version: "1.35.0",
85
88
  config: {
86
- $schema: "./node_modules/@biomejs/biome/configuration_schema.json"
89
+ $schema: "./node_modules/oxlint/configuration_schema.json"
87
90
  },
88
91
  exists: async () => {
89
- if (await checkIfExists(join2(process.cwd(), "biome.jsonc"))) {
90
- return { path: join2(process.cwd(), "biome.jsonc") };
91
- }
92
- if (await checkIfExists(join2(process.cwd(), "biome.json"))) {
93
- return { path: join2(process.cwd(), "biome.json") };
92
+ if (await checkIfExists(join2(process.cwd(), ".oxlintrc.json"))) {
93
+ return { path: join2(process.cwd(), ".oxlintrc.json") };
94
94
  }
95
95
  return { path: null };
96
96
  },
97
- create: () => fromPromise2(writeFile(join2(process.cwd(), "biome.jsonc"), JSON.stringify({ ...biome.config, extends: ["adamantite"] }, null, 2)), (error) => Fault2.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write Biome configuration", "We're unable to write the Biome configuration to the current directory.")),
98
- update: () => safeTry2(async function* () {
99
- const exists = await biome.exists();
97
+ create: (presets = []) => {
98
+ const extendsArray = ["adamantite/lint"];
99
+ for (const preset of presets) {
100
+ extendsArray.push(`adamantite/lint/${preset}`);
101
+ }
102
+ return fromPromise2(writeFile(join2(process.cwd(), ".oxlintrc.json"), JSON.stringify({ ...oxlint.config, extends: extendsArray }, null, 2)), (error) => Fault2.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write oxlint configuration", "We're unable to write the oxlint configuration to the current directory."));
103
+ },
104
+ update: (presets = []) => safeTry2(async function* () {
105
+ const exists = await oxlint.exists();
100
106
  if (!exists.path) {
101
- return err2(Fault2.create("FILE_NOT_FOUND").withDescription("No `biome.jsonc` or `biome.json` found", "We're unable to find a Biome configuration in the current directory."));
107
+ return err2(Fault2.create("FILE_NOT_FOUND").withDescription("No `.oxlintrc.json` found", "We're unable to find an oxlint configuration in the current directory."));
102
108
  }
103
- const biomeFile = yield* fromPromise2(readFile2(exists.path, "utf-8"), (error) => Fault2.wrap(error).withTag("FAILED_TO_READ_FILE").withDescription("Failed to read Biome configuration", "We're unable to read the Biome configuration from the current directory."));
104
- const existingConfig = yield* parseJson(biomeFile);
105
- if (!existingConfig || Object.keys(existingConfig).length === 0) {
106
- return err2(Fault2.create("INVALID_BIOME_CONFIG").withDescription("Invalid Biome configuration", "The Biome configuration file is empty or invalid.").withContext({ path: exists.path }));
109
+ const oxlintFile = yield* fromPromise2(readFile2(exists.path, "utf8"), (error) => Fault2.wrap(error).withTag("FAILED_TO_READ_FILE").withDescription("Failed to read oxlint configuration", "We're unable to read the oxlint configuration from the current directory."));
110
+ const existingConfig = yield* parseJson(oxlintFile);
111
+ if (!isJsonObject(existingConfig)) {
112
+ return err2(Fault2.create("INVALID_CONFIG_FORMAT").withDescription("Invalid oxlint configuration format", "The oxlint configuration must be a JSON object."));
107
113
  }
108
114
  const newConfig = { ...existingConfig };
109
- if (!Array.isArray(newConfig.extends)) {
110
- newConfig.extends = newConfig.extends ? [newConfig.extends] : [];
111
- }
112
- if (!newConfig.extends.includes("adamantite")) {
113
- newConfig.extends.push("adamantite");
115
+ const extendsArray = Array.isArray(newConfig.extends) ? newConfig.extends : typeof newConfig.extends === "string" ? [newConfig.extends] : [];
116
+ const hasAdamantite = extendsArray.some((ext) => ext === "adamantite/lint" || ext === "adamantite/lint/core");
117
+ if (!hasAdamantite) {
118
+ extendsArray.push("adamantite/lint");
119
+ }
120
+ for (const preset of presets) {
121
+ const presetPath = `adamantite/lint/${preset}`;
122
+ if (!extendsArray.includes(presetPath)) {
123
+ extendsArray.push(presetPath);
124
+ }
114
125
  }
115
- const mergedConfig = yield* mergeConfig(newConfig, biome.config);
116
- mergedConfig.$schema = biome.config.$schema;
117
- yield* fromPromise2(writeFile(exists.path, JSON.stringify(mergedConfig, null, 2)), (error) => Fault2.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write Biome configuration", "We're unable to write the Biome configuration to the current directory.").withContext({ path: exists.path }));
126
+ newConfig.extends = extendsArray;
127
+ const mergedConfig = yield* mergeConfig(newConfig, oxlint.config);
128
+ mergedConfig.$schema = oxlint.config.$schema;
129
+ yield* fromPromise2(writeFile(exists.path, JSON.stringify(mergedConfig, null, 2)), (error) => Fault2.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write oxlint configuration", "We're unable to write the oxlint configuration to the current directory.").withContext({ path: exists.path }));
118
130
  return ok2();
119
131
  })
120
132
  };
133
+ var tsgolint = {
134
+ name: "oxlint-tsgolint",
135
+ version: "0.10.0"
136
+ };
121
137
 
122
138
  // src/commands/check.ts
123
139
  var check_default = defineCommand({
124
140
  command: "check [files..]",
125
- describe: "Find issues in code using Biome",
141
+ describe: "Find issues in code using oxlint",
126
142
  builder: (yargs) => yargs.positional("files", {
127
143
  describe: "Specific files to lint (optional)",
128
144
  type: "string",
129
145
  array: true
130
- }).option("summary", {
131
- type: "boolean",
132
- description: "Show summary of lint results"
133
146
  }),
134
147
  handler: (argv) => safeTry3(async function* () {
135
148
  const packageManager = yield* getPackageManagerName();
136
- const args = ["check"];
137
- if (argv.summary) {
138
- args.push("--reporter", "summary");
139
- }
149
+ const args = ["--type-aware"];
140
150
  if (argv.files && argv.files.length > 0) {
141
151
  args.push(...argv.files);
142
152
  }
143
- const command = dlxCommand(packageManager, biome.name, { args });
153
+ const command = dlxCommand(packageManager, oxlint.name, { args });
144
154
  const result = yield* runCommand(command);
145
155
  return ok3(result);
146
156
  }).match(() => {
@@ -161,25 +171,43 @@ import { ok as ok4, safeTry as safeTry4 } from "neverthrow";
161
171
  import { dlxCommand as dlxCommand2 } from "nypm";
162
172
  var fix_default = defineCommand({
163
173
  command: "fix [files..]",
164
- describe: "Fix issues in code using Biome",
174
+ describe: "Fix issues in code using oxlint",
165
175
  builder: (yargs) => yargs.positional("files", {
166
176
  describe: "Specific files to fix (optional)",
167
177
  type: "string",
168
178
  array: true
169
- }).option("unsafe", {
179
+ }).option("suggested", {
180
+ type: "boolean",
181
+ description: "Apply suggested fixes",
182
+ default: false
183
+ }).option("dangerous", {
170
184
  type: "boolean",
171
- description: "Apply unsafe fixes"
185
+ description: "Apply dangerous fixes",
186
+ default: false
187
+ }).option("all", {
188
+ type: "boolean",
189
+ description: "Apply all fixes, including suggested and dangerous fixes",
190
+ default: false
172
191
  }),
173
192
  handler: (argv) => safeTry4(async function* () {
174
193
  const packageManager = yield* getPackageManagerName();
175
- const args = ["check", "--write"];
176
- if (argv.unsafe) {
177
- args.push("--unsafe");
194
+ const args = new Set(["--type-aware", "--fix"]);
195
+ if (argv.suggested) {
196
+ args.add("--fix-suggestions");
197
+ }
198
+ if (argv.dangerous) {
199
+ args.add("--fix-dangerously");
200
+ }
201
+ if (argv.all) {
202
+ args.add("--fix-suggestions");
203
+ args.add("--fix-dangerously");
178
204
  }
179
205
  if (argv.files && argv.files.length > 0) {
180
- args.push(...argv.files);
206
+ for (const file of argv.files) {
207
+ args.add(file);
208
+ }
181
209
  }
182
- const command = dlxCommand2(packageManager, biome.name, { args });
210
+ const command = dlxCommand2(packageManager, oxlint.name, { args: Array.from(args) });
183
211
  yield* runCommand(command);
184
212
  return ok4();
185
213
  }).match(() => {
@@ -266,10 +294,10 @@ var oxfmt = {
266
294
  if (!exists.path) {
267
295
  return err3(Fault5.create("FILE_NOT_FOUND").withDescription("No `.oxfmtrc.jsonc` or `.oxfmtrc.json` found", "We're unable to find an oxfmt configuration in the current directory."));
268
296
  }
269
- const oxfmtFile = yield* fromPromise3(readFile3(exists.path, "utf-8"), (error) => Fault5.wrap(error).withTag("FAILED_TO_READ_FILE").withDescription("Failed to read oxfmt configuration", "We're unable to read the oxfmt configuration from the current directory."));
297
+ const oxfmtFile = yield* fromPromise3(readFile3(exists.path, "utf8"), (error) => Fault5.wrap(error).withTag("FAILED_TO_READ_FILE").withDescription("Failed to read oxfmt configuration", "We're unable to read the oxfmt configuration from the current directory."));
270
298
  const existingConfig = yield* parseJson(oxfmtFile);
271
- if (!existingConfig || Object.keys(existingConfig).length === 0) {
272
- return err3(Fault5.create("INVALID_OXFMT_CONFIG").withDescription("Invalid oxfmt configuration", "The oxfmt configuration file is empty or invalid.").withContext({ path: exists.path }));
299
+ if (!isJsonObject(existingConfig)) {
300
+ return err3(Fault5.create("INVALID_CONFIG_FORMAT").withDescription("Invalid oxfmt configuration format", "The oxfmt configuration must be a JSON object."));
273
301
  }
274
302
  const mergedConfig = yield* mergeConfig(existingConfig, oxfmt.config);
275
303
  mergedConfig.$schema = oxfmt.config.$schema;
@@ -318,7 +346,7 @@ import { join as join7 } from "node:path";
318
346
  import process7 from "node:process";
319
347
  import * as p from "@clack/prompts";
320
348
  import { Fault as Fault10 } from "faultier";
321
- import { err as err4, fromPromise as fromPromise7, fromSafePromise, ok as ok10, safeTry as safeTry10 } from "neverthrow";
349
+ import { err as err6, fromPromise as fromPromise7, fromSafePromise, ok as ok10, safeTry as safeTry10 } from "neverthrow";
322
350
  import { addDevDependency } from "nypm";
323
351
 
324
352
  // src/helpers/ci/github.ts
@@ -328,11 +356,20 @@ import process6 from "node:process";
328
356
  import { Fault as Fault7 } from "faultier";
329
357
  import { fromPromise as fromPromise4, ok as ok7, safeTry as safeTry7 } from "neverthrow";
330
358
  import { runScriptCommand } from "nypm";
331
- var CI_COMPATIBLE_SCRIPTS = ["check", "format", "typecheck", "check:monorepo"];
332
359
  var setupSteps = {
333
360
  bun: ` - name: Setup Bun
334
361
  uses: oven-sh/setup-bun@v2
335
362
 
363
+ - name: Cache dependencies
364
+ uses: actions/cache@v4
365
+ with:
366
+ path: |
367
+ ~/.bun/install/cache
368
+ node_modules
369
+ key: \${{ runner.os }}-bun-\${{ hashFiles('bun.lock') }}
370
+ restore-keys: |
371
+ \${{ runner.os }}-bun-
372
+
336
373
  - name: Install dependencies
337
374
  run: bun install --frozen-lockfile`,
338
375
  pnpm: ` - name: Setup pnpm
@@ -368,36 +405,40 @@ var setupSteps = {
368
405
  - name: Install dependencies
369
406
  run: deno install --frozen`
370
407
  };
371
- var generateJob = (jobName, stepName, script, packageManager) => `
372
- ${jobName}:
373
- runs-on: ubuntu-latest
374
- timeout-minutes: 10
375
- steps:
376
- - name: Checkout code
377
- uses: actions/checkout@v4
378
-
379
- ${setupSteps[packageManager]}
380
-
381
- - name: ${stepName}
382
- run: ${runScriptCommand(packageManager, script)}`;
408
+ var buildCommand = (packageManager, script, args) => runScriptCommand(packageManager, script, { args });
383
409
  var generateWorkflow = ({ packageManager, scripts }) => {
384
- const jobs = [];
410
+ const matrixEntries = [];
385
411
  if (scripts.includes("check")) {
386
- jobs.push(generateJob("lint", "Run linter", "check", packageManager));
412
+ matrixEntries.push({
413
+ name: "lint",
414
+ command: buildCommand(packageManager, "check")
415
+ });
387
416
  }
388
417
  if (scripts.includes("format")) {
389
- jobs.push(generateJob("format", "Check formatting", "format --check", packageManager));
418
+ matrixEntries.push({
419
+ name: "format",
420
+ command: buildCommand(packageManager, "format", ["--check"])
421
+ });
390
422
  }
391
423
  if (scripts.includes("typecheck")) {
392
- jobs.push(generateJob("typecheck", "Run type check", "typecheck", packageManager));
424
+ matrixEntries.push({
425
+ name: "types",
426
+ command: buildCommand(packageManager, "typecheck")
427
+ });
393
428
  }
394
429
  if (scripts.includes("check:monorepo")) {
395
- jobs.push(generateJob("monorepo", "Check monorepo", "check:monorepo", packageManager));
430
+ matrixEntries.push({
431
+ name: "monorepo",
432
+ command: buildCommand(packageManager, "check:monorepo")
433
+ });
396
434
  }
397
- if (jobs.length === 0) {
435
+ if (matrixEntries.length === 0) {
398
436
  return null;
399
437
  }
400
- const workflow = `name: CI
438
+ const matrixInclude = matrixEntries.map((entry) => ` - name: ${entry.name}
439
+ command: ${entry.command}`).join(`
440
+ `);
441
+ const workflow = `name: adamantite
401
442
 
402
443
  on:
403
444
  push:
@@ -406,16 +447,36 @@ on:
406
447
  pull_request:
407
448
  types: [opened, synchronize, reopened]
408
449
 
450
+ permissions:
451
+ contents: read
452
+
409
453
  concurrency:
410
454
  group: \${{ github.workflow }}-\${{ github.ref }}
411
455
  cancel-in-progress: true
412
456
 
413
- jobs:${jobs.join(`
414
- `)}`;
457
+ jobs:
458
+ verify:
459
+ name: \${{ matrix.name }}
460
+ runs-on: ubuntu-latest
461
+ timeout-minutes: 10
462
+ strategy:
463
+ fail-fast: false
464
+ matrix:
465
+ include:
466
+ ${matrixInclude}
467
+
468
+ steps:
469
+ - name: Checkout
470
+ uses: actions/checkout@v4
471
+
472
+ ${setupSteps[packageManager]}
473
+
474
+ - name: Run \${{ matrix.name }}
475
+ run: \${{ matrix.command }}`;
415
476
  return `${workflow}
416
477
  `;
417
478
  };
418
- var hasCICompatibleScripts = (scripts) => scripts.some((script) => CI_COMPATIBLE_SCRIPTS.includes(script));
479
+ var hasCICompatibleScripts = (scripts) => scripts.some((script) => ["check", "format", "typecheck", "check:monorepo"].includes(script));
419
480
  var github = {
420
481
  workflowPath: ".github/workflows/adamantite.yml",
421
482
  exists: () => checkIfExists(join4(process6.cwd(), ".github", "workflows", "adamantite.yml")),
@@ -444,14 +505,14 @@ var github = {
444
505
  import { mkdir as mkdir2, readFile as readFile4, writeFile as writeFile4 } from "node:fs/promises";
445
506
  import { join as join5 } from "node:path";
446
507
  import { Fault as Fault8 } from "faultier";
447
- import { fromPromise as fromPromise5, ok as ok8, safeTry as safeTry8 } from "neverthrow";
508
+ import { err as err4, fromPromise as fromPromise5, ok as ok8, safeTry as safeTry8 } from "neverthrow";
448
509
  var vscode = {
449
510
  config: {
450
511
  "typescript.tsdk": "node_modules/typescript/lib",
451
512
  "editor.formatOnSave": true,
452
513
  "editor.formatOnPaste": true,
453
514
  "editor.codeActionsOnSave": {
454
- "source.fixAll.biome": "explicit"
515
+ "source.fixAll.oxc": "explicit"
455
516
  },
456
517
  "[javascript][typescript][javascriptreact][typescriptreact][json][jsonc][css][graphql]": {
457
518
  "editor.defaultFormatter": "oxc.oxc-vscode"
@@ -466,8 +527,11 @@ var vscode = {
466
527
  }),
467
528
  update: () => safeTry8(async function* () {
468
529
  const vscodePath = join5(process.cwd(), ".vscode", "settings.json");
469
- const vscodeFile = yield* fromPromise5(readFile4(vscodePath, "utf-8"), (error) => Fault8.wrap(error).withTag("FAILED_TO_READ_FILE").withDescription("Failed to read .vscode/settings.json", "We're unable to read the .vscode/settings.json file in the current directory.").withContext({ path: vscodePath }));
530
+ const vscodeFile = yield* fromPromise5(readFile4(vscodePath, "utf8"), (error) => Fault8.wrap(error).withTag("FAILED_TO_READ_FILE").withDescription("Failed to read .vscode/settings.json", "We're unable to read the .vscode/settings.json file in the current directory.").withContext({ path: vscodePath }));
470
531
  const existingConfig = yield* parseJson(vscodeFile);
532
+ if (!isJsonObject(existingConfig)) {
533
+ return err4(Fault8.create("INVALID_CONFIG_FORMAT").withDescription("Invalid .vscode/settings.json format", "The VS Code settings file must be a JSON object."));
534
+ }
471
535
  const newConfig = yield* mergeConfig(vscode.config, existingConfig);
472
536
  yield* fromPromise5(writeFile4(join5(process.cwd(), ".vscode", "settings.json"), JSON.stringify(newConfig, null, 2)), (error) => Fault8.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write .vscode/settings.json", "We're unable to write the .vscode/settings.json file in the current directory.").withContext({ path: vscodePath }));
473
537
  return ok8();
@@ -480,19 +544,25 @@ var sherif = {
480
544
  version: "1.9.0"
481
545
  };
482
546
 
483
- // src/helpers/tsconfig.ts
547
+ // src/helpers/packages/typescript.ts
484
548
  import { readFile as readFile5, writeFile as writeFile5 } from "node:fs/promises";
485
549
  import { join as join6 } from "node:path";
486
550
  import { Fault as Fault9 } from "faultier";
487
- import { fromPromise as fromPromise6, ok as ok9, safeTry as safeTry9 } from "neverthrow";
488
- var tsconfig = {
551
+ import { err as err5, fromPromise as fromPromise6, ok as ok9, safeTry as safeTry9 } from "neverthrow";
552
+ var typescript = {
553
+ name: "@typescript/native-preview",
554
+ version: "7.0.0-dev.20251227.1",
555
+ command: "tsgo",
489
556
  config: { extends: "adamantite/typescript" },
490
557
  exists: () => checkIfExists(join6(process.cwd(), "tsconfig.json")),
491
- create: () => fromPromise6(writeFile5(join6(process.cwd(), "tsconfig.json"), JSON.stringify(tsconfig.config, null, 2)), (error) => Fault9.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write tsconfig.json", "We're unable to write the tsconfig.json file in the current directory.")),
558
+ create: () => fromPromise6(writeFile5(join6(process.cwd(), "tsconfig.json"), JSON.stringify(typescript.config, null, 2)), (error) => Fault9.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write tsconfig.json", "We're unable to write the tsconfig.json file in the current directory.")),
492
559
  update: () => safeTry9(async function* () {
493
- const tsconfigFile = yield* fromPromise6(readFile5(join6(process.cwd(), "tsconfig.json"), "utf-8"), (error) => Fault9.wrap(error).withTag("FAILED_TO_READ_FILE").withDescription("Failed to read tsconfig.json", "We're unable to read the tsconfig.json file in the current directory."));
560
+ const tsconfigFile = yield* fromPromise6(readFile5(join6(process.cwd(), "tsconfig.json"), "utf8"), (error) => Fault9.wrap(error).withTag("FAILED_TO_READ_FILE").withDescription("Failed to read tsconfig.json", "We're unable to read the tsconfig.json file in the current directory."));
494
561
  const existingConfig = yield* parseJson(tsconfigFile);
495
- const newConfig = yield* mergeConfig(tsconfig.config, existingConfig);
562
+ if (!isJsonObject(existingConfig)) {
563
+ return err5(Fault9.create("INVALID_CONFIG_FORMAT").withDescription("Invalid tsconfig.json format", "The tsconfig.json file must be a JSON object."));
564
+ }
565
+ const newConfig = yield* mergeConfig(typescript.config, existingConfig);
496
566
  yield* fromPromise6(writeFile5(join6(process.cwd(), "tsconfig.json"), JSON.stringify(newConfig, null, 2)), (error) => Fault9.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write tsconfig.json", "We're unable to write the tsconfig.json file in the current directory."));
497
567
  return ok9();
498
568
  })
@@ -504,23 +574,24 @@ var installDependencies = (packages) => safeTry10(async function* () {
504
574
  s.start("Installing dependencies...");
505
575
  const isMonorepo = yield* checkIsMonorepo();
506
576
  for (const pkg of packages) {
577
+ s.message(`Installing dependency: ${pkg}...`);
507
578
  yield* fromPromise7(addDevDependency(pkg, { silent: true, workspace: isMonorepo }), (error) => Fault10.wrap(error).withTag("FAILED_TO_INSTALL_DEPENDENCY").withMessage(`Failed to install ${pkg}`));
508
579
  }
509
580
  s.stop("Dependencies installed.");
510
581
  return ok10();
511
582
  });
512
- var setupBiomeConfig = () => safeTry10(async function* () {
583
+ var setupOxlintConfig = (presets) => safeTry10(async function* () {
513
584
  const spinner2 = p.spinner();
514
- spinner2.start("Setting up Biome config...");
515
- const biomePath = await biome.exists();
516
- if (biomePath.path) {
517
- spinner2.message(`Found \`${biomePath.path}\`, updating...`);
518
- yield* biome.update();
519
- spinner2.stop("Biome config updated successfully.");
585
+ spinner2.start("Setting up oxlint config...");
586
+ const oxlintPath = await oxlint.exists();
587
+ if (oxlintPath.path) {
588
+ spinner2.message(`Found \`${oxlintPath.path}\`, updating...`);
589
+ yield* oxlint.update(presets);
590
+ spinner2.stop("oxlint config updated successfully.");
520
591
  } else {
521
- spinner2.message("`.biome.jsonc` or `.biome.json` not found, creating...");
522
- yield* biome.create();
523
- spinner2.stop("Biome config created successfully.");
592
+ spinner2.message("`.oxlintrc.json` not found, creating...");
593
+ yield* oxlint.create(presets);
594
+ spinner2.stop("oxlint config created successfully.");
524
595
  }
525
596
  return ok10();
526
597
  });
@@ -544,9 +615,7 @@ var addScripts = (scripts) => safeTry10(async function* () {
544
615
  const packageJson = yield* readPackageJson();
545
616
  const spinner2 = p.spinner();
546
617
  spinner2.start("Adding scripts to your `package.json`...");
547
- if (!packageJson.scripts) {
548
- packageJson.scripts = {};
549
- }
618
+ packageJson.scripts ??= {};
550
619
  for (const script of scripts) {
551
620
  switch (script) {
552
621
  case "check":
@@ -559,7 +628,7 @@ var addScripts = (scripts) => safeTry10(async function* () {
559
628
  packageJson.scripts.format = "adamantite format";
560
629
  break;
561
630
  case "typecheck":
562
- packageJson.scripts.typecheck = "tsc --noEmit";
631
+ packageJson.scripts.typecheck = "adamantite typecheck";
563
632
  break;
564
633
  case "check:monorepo":
565
634
  packageJson.scripts["check:monorepo"] = "adamantite monorepo";
@@ -568,7 +637,7 @@ var addScripts = (scripts) => safeTry10(async function* () {
568
637
  packageJson.scripts["fix:monorepo"] = "adamantite monorepo --fix";
569
638
  break;
570
639
  default:
571
- return err4(Fault10.create("UNKNOWN_SCRIPT").withContext({ script }));
640
+ return err6(Fault10.create("UNKNOWN_SCRIPT").withContext({ script }));
572
641
  }
573
642
  }
574
643
  yield* fromPromise7(writeFile6(join7(cwd, "package.json"), JSON.stringify(packageJson, null, 2)), (error) => Fault10.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write package.json", "We're unable to update the package.json file.").withContext({ path: join7(cwd, "package.json") }));
@@ -578,13 +647,13 @@ var addScripts = (scripts) => safeTry10(async function* () {
578
647
  var setupTypescript = () => safeTry10(async function* () {
579
648
  const spinner2 = p.spinner();
580
649
  spinner2.start("Setting up TypeScript config...");
581
- if (await tsconfig.exists()) {
650
+ if (await typescript.exists()) {
582
651
  spinner2.message("`tsconfig.json` found, updating...");
583
- yield* tsconfig.update();
652
+ yield* typescript.update();
584
653
  spinner2.stop("`tsconfig.json` updated successfully");
585
654
  } else {
586
655
  spinner2.message("`tsconfig.json` not found, creating...");
587
- yield* tsconfig.create();
656
+ yield* typescript.create();
588
657
  spinner2.stop("`tsconfig.json` created successfully");
589
658
  }
590
659
  return ok10();
@@ -637,12 +706,12 @@ var init_default = defineCommand({
637
706
  message: "Which scripts do you want to add to your `package.json`?",
638
707
  options: [
639
708
  {
640
- label: "check - find issues in code using Biome",
709
+ label: "check - find issues in code using oxlint",
641
710
  value: "check",
642
711
  hint: "recommended"
643
712
  },
644
713
  {
645
- label: "fix - fix code issues using Biome",
714
+ label: "fix - fix code issues using oxlint",
646
715
  value: "fix",
647
716
  hint: "recommended"
648
717
  },
@@ -652,7 +721,7 @@ var init_default = defineCommand({
652
721
  hint: "recommended"
653
722
  },
654
723
  {
655
- label: "typecheck - type-check your code using strict TypeScript preset",
724
+ label: "typecheck - type-check your code using tsgo",
656
725
  value: "typecheck",
657
726
  hint: "extends the `adamantite/typescript` preset in your `tsconfig.json`"
658
727
  },
@@ -671,7 +740,27 @@ var init_default = defineCommand({
671
740
  ]
672
741
  }));
673
742
  if (p.isCancel(scripts)) {
674
- return err4(Fault10.create("OPERATION_CANCELLED"));
743
+ return err6(Fault10.create("OPERATION_CANCELLED"));
744
+ }
745
+ const hasOxlint = scripts.includes("check") || scripts.includes("fix");
746
+ let presets = [];
747
+ if (hasOxlint) {
748
+ const presetsResponse = yield* fromSafePromise(p.multiselect({
749
+ message: "Which presets do you want to install? (core is always included)",
750
+ options: [
751
+ { label: "React", value: "react" },
752
+ { label: "Next.js", value: "nextjs" },
753
+ { label: "Vue", value: "vue" },
754
+ { label: "Jest", value: "jest" },
755
+ { label: "Vitest", value: "vitest" },
756
+ { label: "Node", value: "node" }
757
+ ],
758
+ required: false
759
+ }));
760
+ if (p.isCancel(presetsResponse)) {
761
+ return err6(Fault10.create("OPERATION_CANCELLED"));
762
+ }
763
+ presets = presetsResponse;
675
764
  }
676
765
  const editors = yield* fromSafePromise(p.multiselect({
677
766
  message: "Which editors do you want to configure? (optional)",
@@ -682,7 +771,7 @@ var init_default = defineCommand({
682
771
  required: false
683
772
  }));
684
773
  if (p.isCancel(editors)) {
685
- return err4(Fault10.create("OPERATION_CANCELLED"));
774
+ return err6(Fault10.create("OPERATION_CANCELLED"));
686
775
  }
687
776
  const hasCIScripts = hasCICompatibleScripts(scripts);
688
777
  let enableGitHubActions = false;
@@ -692,17 +781,17 @@ var init_default = defineCommand({
692
781
  initialValue: false
693
782
  }));
694
783
  if (p.isCancel(response)) {
695
- return err4(Fault10.create("OPERATION_CANCELLED"));
784
+ return err6(Fault10.create("OPERATION_CANCELLED"));
696
785
  }
697
786
  enableGitHubActions = response;
698
787
  }
699
- const hasBiome = scripts.includes("check") || scripts.includes("fix");
700
788
  const hasOxfmt = scripts.includes("format");
701
789
  const hasSherif = scripts.includes("check:monorepo") || scripts.includes("fix:monorepo");
702
790
  const hasTypecheck = scripts.includes("typecheck");
703
791
  const dependencies = ["adamantite"];
704
- if (hasBiome) {
705
- dependencies.push(`${biome.name}@${biome.version}`);
792
+ if (hasOxlint) {
793
+ dependencies.push(`${oxlint.name}@${oxlint.version}`);
794
+ dependencies.push(`${tsgolint.name}@${tsgolint.version}`);
706
795
  }
707
796
  if (hasOxfmt) {
708
797
  dependencies.push(`${oxfmt.name}@${oxfmt.version}`);
@@ -711,14 +800,14 @@ var init_default = defineCommand({
711
800
  dependencies.push(`${sherif.name}@${sherif.version}`);
712
801
  }
713
802
  if (hasTypecheck) {
714
- dependencies.push("typescript");
803
+ dependencies.push(`${typescript.name}@${typescript.version}`);
715
804
  }
716
805
  yield* installDependencies(dependencies);
717
806
  if (hasOxfmt) {
718
807
  yield* setupOxfmtConfig();
719
808
  }
720
- if (hasBiome) {
721
- yield* setupBiomeConfig();
809
+ if (hasOxlint) {
810
+ yield* setupOxlintConfig(presets);
722
811
  }
723
812
  yield* addScripts(scripts);
724
813
  if (hasTypecheck) {
@@ -769,7 +858,7 @@ var monorepo_default = defineCommand({
769
858
  }
770
859
  const command = dlxCommand4(packageManager, sherif.name, { args });
771
860
  yield* runCommand(command);
772
- return ok11(undefined);
861
+ return ok11();
773
862
  }).match(() => {
774
863
  process8.exit(0);
775
864
  }, (error) => {
@@ -780,22 +869,62 @@ var monorepo_default = defineCommand({
780
869
  })
781
870
  });
782
871
 
783
- // src/commands/update.ts
872
+ // src/commands/typecheck.ts
784
873
  import process9 from "node:process";
785
- import { cancel as cancel2, confirm as confirm2, intro as intro2, isCancel as isCancel2, log as log6, outro as outro2, spinner as spinner2 } from "@clack/prompts";
874
+ import { log as log6 } from "@clack/prompts";
786
875
  import { Fault as Fault12 } from "faultier";
787
- import { err as err5, fromPromise as fromPromise8, fromSafePromise as fromSafePromise2, ok as ok12, safeTry as safeTry12 } from "neverthrow";
876
+ import { ok as ok12, safeTry as safeTry12 } from "neverthrow";
877
+ import { dlxCommand as dlxCommand5 } from "nypm";
878
+ var typecheck_default = defineCommand({
879
+ command: "typecheck",
880
+ describe: "Run TypeScript type checking",
881
+ builder: (yargs) => yargs.option("project", {
882
+ alias: "p",
883
+ type: "string",
884
+ description: "Path to tsconfig.json file"
885
+ }).option("watch", {
886
+ alias: "w",
887
+ type: "boolean",
888
+ description: "Run in watch mode"
889
+ }),
890
+ handler: (argv) => safeTry12(async function* () {
891
+ const packageManager = yield* getPackageManagerName();
892
+ const args = ["--noEmit"];
893
+ if (argv.project) {
894
+ args.push("--project", argv.project);
895
+ }
896
+ if (argv.watch) {
897
+ args.push("--watch");
898
+ }
899
+ const command = dlxCommand5(packageManager, typescript.command, { args });
900
+ const result = yield* runCommand(command);
901
+ return ok12(result);
902
+ }).match(() => {
903
+ process9.exit(0);
904
+ }, (error) => {
905
+ if (Fault12.isFault(error) && error.tag === "NO_PACKAGE_MANAGER") {
906
+ log6.error(error.flatten());
907
+ }
908
+ process9.exit(1);
909
+ })
910
+ });
911
+
912
+ // src/commands/update.ts
913
+ import process10 from "node:process";
914
+ import { cancel as cancel2, confirm as confirm2, intro as intro2, isCancel as isCancel2, log as log7, outro as outro2, spinner as spinner2 } from "@clack/prompts";
915
+ import { Fault as Fault13 } from "faultier";
916
+ import { err as err7, fromPromise as fromPromise8, fromSafePromise as fromSafePromise2, ok as ok13, safeTry as safeTry13 } from "neverthrow";
788
917
  import { addDevDependency as addDevDependency2 } from "nypm";
789
918
  var update_default = defineCommand({
790
919
  command: "update",
791
920
  describe: "Update adamantite dependencies to latest compatible versions",
792
921
  builder: (yargs) => yargs,
793
- handler: async () => safeTry12(async function* () {
922
+ handler: () => safeTry13(async function* () {
794
923
  const packageJson = yield* readPackageJson();
795
924
  printTitle();
796
925
  intro2("\uD83D\uDCA0 adamantite update");
797
926
  const updates = [];
798
- for (const pkg of [biome, oxfmt, sherif]) {
927
+ for (const pkg of [oxlint, oxfmt, sherif]) {
799
928
  const dependency = packageJson.devDependencies?.[pkg.name];
800
929
  if (dependency && normalizeDependencyVersion(dependency) !== pkg.version) {
801
930
  updates.push({
@@ -807,31 +936,31 @@ var update_default = defineCommand({
807
936
  }
808
937
  }
809
938
  if (updates.length === 0) {
810
- log6.success("All adamantite dependencies are already up to date!");
811
- return ok12("no-updates");
939
+ log7.success("All adamantite dependencies are already up to date!");
940
+ return ok13("no-updates");
812
941
  }
813
- log6.message("The following dependencies will be updated:");
814
- log6.message("");
942
+ log7.message("The following dependencies will be updated:");
943
+ log7.message("");
815
944
  for (const dep of updates) {
816
- log6.message(` ${dep.name}: ${dep.currentVersion} → ${dep.targetVersion}`);
945
+ log7.message(` ${dep.name}: ${dep.currentVersion} → ${dep.targetVersion}`);
817
946
  }
818
- log6.message("");
947
+ log7.message("");
819
948
  const shouldUpdate = yield* fromSafePromise2(confirm2({
820
949
  message: "Do you want to proceed with these updates?"
821
950
  }));
822
951
  if (isCancel2(shouldUpdate)) {
823
- return err5(Fault12.create("OPERATION_CANCELLED"));
952
+ return err7(Fault13.create("OPERATION_CANCELLED"));
824
953
  }
825
954
  if (!shouldUpdate) {
826
- return ok12("cancelled");
955
+ return ok13("cancelled");
827
956
  }
828
957
  const s = spinner2();
829
958
  s.start("Updating dependencies...");
830
959
  for (const dep of updates) {
831
- yield* fromPromise8(addDevDependency2(`${dep.name}@${dep.targetVersion}`), (error) => Fault12.wrap(error).withTag("FAILED_TO_INSTALL_DEPENDENCY").withMessage(`Failed to update ${dep.name}`));
960
+ yield* fromPromise8(addDevDependency2(`${dep.name}@${dep.targetVersion}`), (error) => Fault13.wrap(error).withTag("FAILED_TO_INSTALL_DEPENDENCY").withMessage(`Failed to update ${dep.name}`));
832
961
  }
833
962
  s.stop("Dependencies updated successfully");
834
- return ok12("updated");
963
+ return ok13("updated");
835
964
  }).match((value) => {
836
965
  if (value === "no-updates") {
837
966
  outro2("✅ No updates needed");
@@ -840,21 +969,22 @@ var update_default = defineCommand({
840
969
  } else if (value === "updated") {
841
970
  outro2("✅ Dependencies updated successfully!");
842
971
  }
843
- process9.exit(0);
972
+ process10.exit(0);
844
973
  }, (error) => {
845
- if (Fault12.isFault(error) && error.tag === "OPERATION_CANCELLED") {
974
+ if (Fault13.isFault(error) && error.tag === "OPERATION_CANCELLED") {
846
975
  cancel2("You've cancelled the update process.");
847
- process9.exit(0);
976
+ process10.exit(0);
848
977
  }
849
- if (Fault12.isFault(error)) {
850
- log6.error(error.flatten());
978
+ if (Fault13.isFault(error)) {
979
+ log7.error(error.flatten());
851
980
  } else {
852
- log6.error(String(error));
981
+ log7.error(String(error));
853
982
  }
854
983
  cancel2("Failed to update dependencies");
855
- process9.exit(1);
984
+ process10.exit(1);
856
985
  })
857
986
  });
858
987
 
859
988
  // src/index.ts
860
- yargs(hideBin(process.argv)).scriptName("adamantite").version("0.17.0").command(check_default).command(fix_default).command(format_default).command(init_default).command(monorepo_default).command(update_default).demandCommand(1).strict().help().parse();
989
+ var version = await "0.19.0";
990
+ yargs(hideBin(process.argv)).scriptName("adamantite").version(version).command(check_default).command(fix_default).command(format_default).command(init_default).command(monorepo_default).command(typecheck_default).command(update_default).demandCommand(1).strict().help().parse();