adamantite 0.15.0 → 0.17.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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +263 -160
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -72,7 +72,7 @@ npm install --save-dev adamantite @biomejs/biome
72
72
  echo '{ "extends": ["adamantite"] }' > biome.jsonc
73
73
 
74
74
  # Extend TypeScript configuration
75
- echo '{ "extends": "adamantite/tsconfig" }' > tsconfig.json
75
+ echo '{ "extends": "adamantite/typescript" }' > tsconfig.json
76
76
  ```
77
77
 
78
78
  ## 📋 Commands
package/dist/index.js CHANGED
@@ -153,18 +153,57 @@ var check_default = defineCommand({
153
153
  })
154
154
  });
155
155
 
156
- // src/commands/ci.ts
156
+ // src/commands/fix.ts
157
157
  import process4 from "node:process";
158
158
  import { log as log2 } from "@clack/prompts";
159
- import { Fault as Fault5 } from "faultier";
160
- import { ok as ok5, safeTry as safeTry5 } from "neverthrow";
159
+ import { Fault as Fault4 } from "faultier";
160
+ import { ok as ok4, safeTry as safeTry4 } from "neverthrow";
161
161
  import { dlxCommand as dlxCommand2 } from "nypm";
162
+ var fix_default = defineCommand({
163
+ command: "fix [files..]",
164
+ describe: "Fix issues in code using Biome",
165
+ builder: (yargs) => yargs.positional("files", {
166
+ describe: "Specific files to fix (optional)",
167
+ type: "string",
168
+ array: true
169
+ }).option("unsafe", {
170
+ type: "boolean",
171
+ description: "Apply unsafe fixes"
172
+ }),
173
+ handler: (argv) => safeTry4(async function* () {
174
+ const packageManager = yield* getPackageManagerName();
175
+ const args = ["check", "--write"];
176
+ if (argv.unsafe) {
177
+ args.push("--unsafe");
178
+ }
179
+ if (argv.files && argv.files.length > 0) {
180
+ args.push(...argv.files);
181
+ }
182
+ const command = dlxCommand2(packageManager, biome.name, { args });
183
+ yield* runCommand(command);
184
+ return ok4();
185
+ }).match(() => {
186
+ process4.exit(0);
187
+ }, (error) => {
188
+ if (Fault4.isFault(error) && error.tag === "NO_PACKAGE_MANAGER") {
189
+ log2.error(error.flatten());
190
+ }
191
+ process4.exit(1);
192
+ })
193
+ });
194
+
195
+ // src/commands/format.ts
196
+ import process5 from "node:process";
197
+ import { log as log3 } from "@clack/prompts";
198
+ import { Fault as Fault6 } from "faultier";
199
+ import { ok as ok6, safeTry as safeTry6 } from "neverthrow";
200
+ import { dlxCommand as dlxCommand3 } from "nypm";
162
201
 
163
202
  // src/helpers/packages/oxfmt.ts
164
203
  import { readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
165
204
  import { join as join3 } from "node:path";
166
- import { Fault as Fault4 } from "faultier";
167
- import { err as err3, fromPromise as fromPromise3, ok as ok4, safeTry as safeTry4 } from "neverthrow";
205
+ import { Fault as Fault5 } from "faultier";
206
+ import { err as err3, fromPromise as fromPromise3, ok as ok5, safeTry as safeTry5 } from "neverthrow";
168
207
  // presets/oxfmt.json
169
208
  var oxfmt_default = {
170
209
  arrowParens: "always",
@@ -221,121 +260,25 @@ var oxfmt = {
221
260
  }
222
261
  return { path: null };
223
262
  },
224
- create: () => fromPromise3(writeFile2(join3(process.cwd(), ".oxfmtrc.jsonc"), JSON.stringify(oxfmt.config, null, 2)), (error) => Fault4.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write oxfmt configuration", "We're unable to write the oxfmt configuration to the current directory.")),
225
- update: () => safeTry4(async function* () {
263
+ create: () => fromPromise3(writeFile2(join3(process.cwd(), ".oxfmtrc.jsonc"), JSON.stringify(oxfmt.config, null, 2)), (error) => Fault5.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write oxfmt configuration", "We're unable to write the oxfmt configuration to the current directory.")),
264
+ update: () => safeTry5(async function* () {
226
265
  const exists = await oxfmt.exists();
227
266
  if (!exists.path) {
228
- return err3(Fault4.create("FILE_NOT_FOUND").withDescription("No `.oxfmtrc.jsonc` or `.oxfmtrc.json` found", "We're unable to find an oxfmt configuration in the current directory."));
267
+ 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."));
229
268
  }
230
- const oxfmtFile = yield* fromPromise3(readFile3(exists.path, "utf-8"), (error) => Fault4.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."));
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."));
231
270
  const existingConfig = yield* parseJson(oxfmtFile);
232
271
  if (!existingConfig || Object.keys(existingConfig).length === 0) {
233
- return err3(Fault4.create("INVALID_OXFMT_CONFIG").withDescription("Invalid oxfmt configuration", "The oxfmt configuration file is empty or invalid.").withContext({ path: exists.path }));
272
+ return err3(Fault5.create("INVALID_OXFMT_CONFIG").withDescription("Invalid oxfmt configuration", "The oxfmt configuration file is empty or invalid.").withContext({ path: exists.path }));
234
273
  }
235
274
  const mergedConfig = yield* mergeConfig(existingConfig, oxfmt.config);
236
275
  mergedConfig.$schema = oxfmt.config.$schema;
237
- yield* fromPromise3(writeFile2(exists.path, JSON.stringify(mergedConfig, null, 2)), (error) => Fault4.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write oxfmt configuration", "We're unable to write the oxfmt configuration to the current directory.").withContext({ path: exists.path }));
238
- return ok4();
239
- })
240
- };
241
-
242
- // src/helpers/packages/sherif.ts
243
- var sherif = {
244
- name: "sherif",
245
- version: "1.9.0"
246
- };
247
-
248
- // src/commands/ci.ts
249
- var ci_default = defineCommand({
250
- command: "ci",
251
- describe: "Run Adamantite in a CI environment",
252
- builder: (yargs) => yargs.option("monorepo", {
253
- type: "boolean",
254
- description: "Run additional monorepo-specific checks"
255
- }).option("github", {
256
- type: "boolean",
257
- description: "Use GitHub reporter"
258
- }),
259
- handler: (argv) => safeTry5(async function* () {
260
- const packageManager = yield* getPackageManagerName();
261
- const tools = [
262
- {
263
- package: biome.name,
264
- args: ["ci", ...argv.github ? ["--reporter", "github"] : []]
265
- }
266
- ];
267
- const oxfmtConfig = await oxfmt.exists();
268
- if (oxfmtConfig.path) {
269
- tools.push({
270
- package: oxfmt.name,
271
- args: ["--check"]
272
- });
273
- }
274
- if (argv.monorepo) {
275
- tools.push({ package: sherif.name, args: [] });
276
- }
277
- for (const tool of tools) {
278
- const command = dlxCommand2(packageManager, tool.package, {
279
- args: tool.args
280
- });
281
- yield* runCommand(command);
282
- }
276
+ yield* fromPromise3(writeFile2(exists.path, JSON.stringify(mergedConfig, null, 2)), (error) => Fault5.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write oxfmt configuration", "We're unable to write the oxfmt configuration to the current directory.").withContext({ path: exists.path }));
283
277
  return ok5();
284
- }).match(() => {
285
- process4.exit(0);
286
- }, (error) => {
287
- if (Fault5.isFault(error) && error.tag === "NO_PACKAGE_MANAGER") {
288
- log2.error(error.flatten());
289
- }
290
- process4.exit(1);
291
278
  })
292
- });
293
-
294
- // src/commands/fix.ts
295
- import process5 from "node:process";
296
- import { log as log3 } from "@clack/prompts";
297
- import { Fault as Fault6 } from "faultier";
298
- import { ok as ok6, safeTry as safeTry6 } from "neverthrow";
299
- import { dlxCommand as dlxCommand3 } from "nypm";
300
- var fix_default = defineCommand({
301
- command: "fix [files..]",
302
- describe: "Fix issues in code using Biome",
303
- builder: (yargs) => yargs.positional("files", {
304
- describe: "Specific files to fix (optional)",
305
- type: "string",
306
- array: true
307
- }).option("unsafe", {
308
- type: "boolean",
309
- description: "Apply unsafe fixes"
310
- }),
311
- handler: (argv) => safeTry6(async function* () {
312
- const packageManager = yield* getPackageManagerName();
313
- const args = ["check", "--write"];
314
- if (argv.unsafe) {
315
- args.push("--unsafe");
316
- }
317
- if (argv.files && argv.files.length > 0) {
318
- args.push(...argv.files);
319
- }
320
- const command = dlxCommand3(packageManager, biome.name, { args });
321
- yield* runCommand(command);
322
- return ok6();
323
- }).match(() => {
324
- process5.exit(0);
325
- }, (error) => {
326
- if (Fault6.isFault(error) && error.tag === "NO_PACKAGE_MANAGER") {
327
- log3.error(error.flatten());
328
- }
329
- process5.exit(1);
330
- })
331
- });
279
+ };
332
280
 
333
281
  // src/commands/format.ts
334
- import process6 from "node:process";
335
- import { log as log4 } from "@clack/prompts";
336
- import { Fault as Fault7 } from "faultier";
337
- import { ok as ok7, safeTry as safeTry7 } from "neverthrow";
338
- import { dlxCommand as dlxCommand4 } from "nypm";
339
282
  var format_default = defineCommand({
340
283
  command: "format [files..]",
341
284
  describe: "Format files using oxfmt",
@@ -347,7 +290,7 @@ var format_default = defineCommand({
347
290
  type: "boolean",
348
291
  description: "Check if files are formatted without writing"
349
292
  }),
350
- handler: (argv) => safeTry7(async function* () {
293
+ handler: (argv) => safeTry6(async function* () {
351
294
  const packageManager = yield* getPackageManagerName();
352
295
  const args = [];
353
296
  if (argv.check) {
@@ -356,33 +299,152 @@ var format_default = defineCommand({
356
299
  if (argv.files && argv.files.length > 0) {
357
300
  args.push(...argv.files);
358
301
  }
359
- const command = dlxCommand4(packageManager, oxfmt.name, { args });
302
+ const command = dlxCommand3(packageManager, oxfmt.name, { args });
360
303
  const result = yield* runCommand(command);
361
- return ok7(result);
304
+ return ok6(result);
362
305
  }).match(() => {
363
- process6.exit(0);
306
+ process5.exit(0);
364
307
  }, (error) => {
365
- if (Fault7.isFault(error) && error.tag === "NO_PACKAGE_MANAGER") {
366
- log4.error(error.flatten());
308
+ if (Fault6.isFault(error) && error.tag === "NO_PACKAGE_MANAGER") {
309
+ log3.error(error.flatten());
367
310
  }
368
- process6.exit(1);
311
+ process5.exit(1);
369
312
  })
370
313
  });
371
314
 
372
315
  // src/commands/init.ts
373
- import { writeFile as writeFile5 } from "node:fs/promises";
374
- import { join as join6 } from "node:path";
316
+ import { writeFile as writeFile6 } from "node:fs/promises";
317
+ import { join as join7 } from "node:path";
375
318
  import process7 from "node:process";
376
319
  import * as p from "@clack/prompts";
377
320
  import { Fault as Fault10 } from "faultier";
378
- import { err as err4, fromPromise as fromPromise6, fromSafePromise, ok as ok10, safeTry as safeTry10 } from "neverthrow";
321
+ import { err as err4, fromPromise as fromPromise7, fromSafePromise, ok as ok10, safeTry as safeTry10 } from "neverthrow";
379
322
  import { addDevDependency } from "nypm";
380
323
 
381
- // src/helpers/editors/vscode.ts
382
- import { mkdir, readFile as readFile4, writeFile as writeFile3 } from "node:fs/promises";
324
+ // src/helpers/ci/github.ts
325
+ import { mkdir, writeFile as writeFile3 } from "node:fs/promises";
383
326
  import { join as join4 } from "node:path";
327
+ import process6 from "node:process";
328
+ import { Fault as Fault7 } from "faultier";
329
+ import { fromPromise as fromPromise4, ok as ok7, safeTry as safeTry7 } from "neverthrow";
330
+ import { runScriptCommand } from "nypm";
331
+ var CI_COMPATIBLE_SCRIPTS = ["check", "format", "typecheck", "check:monorepo"];
332
+ var setupSteps = {
333
+ bun: ` - name: Setup Bun
334
+ uses: oven-sh/setup-bun@v2
335
+
336
+ - name: Install dependencies
337
+ run: bun install --frozen-lockfile`,
338
+ pnpm: ` - name: Setup pnpm
339
+ uses: pnpm/action-setup@v4
340
+
341
+ - name: Setup Node.js
342
+ uses: actions/setup-node@v6
343
+ with:
344
+ node-version: "22"
345
+ cache: "pnpm"
346
+
347
+ - name: Install dependencies
348
+ run: pnpm install --frozen-lockfile`,
349
+ yarn: ` - name: Setup Node.js
350
+ uses: actions/setup-node@v6
351
+ with:
352
+ node-version: "22"
353
+ cache: "yarn"
354
+
355
+ - name: Install dependencies
356
+ run: yarn install --frozen-lockfile`,
357
+ npm: ` - name: Setup Node.js
358
+ uses: actions/setup-node@v6
359
+ with:
360
+ node-version: "22"
361
+ cache: "npm"
362
+
363
+ - name: Install dependencies
364
+ run: npm ci`,
365
+ deno: ` - name: Setup Deno
366
+ uses: denoland/setup-deno@v2
367
+
368
+ - name: Install dependencies
369
+ run: deno install --frozen`
370
+ };
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)}`;
383
+ var generateWorkflow = ({ packageManager, scripts }) => {
384
+ const jobs = [];
385
+ if (scripts.includes("check")) {
386
+ jobs.push(generateJob("lint", "Run linter", "check", packageManager));
387
+ }
388
+ if (scripts.includes("format")) {
389
+ jobs.push(generateJob("format", "Check formatting", "format --check", packageManager));
390
+ }
391
+ if (scripts.includes("typecheck")) {
392
+ jobs.push(generateJob("typecheck", "Run type check", "typecheck", packageManager));
393
+ }
394
+ if (scripts.includes("check:monorepo")) {
395
+ jobs.push(generateJob("monorepo", "Check monorepo", "check:monorepo", packageManager));
396
+ }
397
+ if (jobs.length === 0) {
398
+ return null;
399
+ }
400
+ const workflow = `name: CI
401
+
402
+ on:
403
+ push:
404
+ branches:
405
+ - main
406
+ pull_request:
407
+ types: [opened, synchronize, reopened]
408
+
409
+ concurrency:
410
+ group: \${{ github.workflow }}-\${{ github.ref }}
411
+ cancel-in-progress: true
412
+
413
+ jobs:${jobs.join(`
414
+ `)}`;
415
+ return `${workflow}
416
+ `;
417
+ };
418
+ var hasCICompatibleScripts = (scripts) => scripts.some((script) => CI_COMPATIBLE_SCRIPTS.includes(script));
419
+ var github = {
420
+ workflowPath: ".github/workflows/adamantite.yml",
421
+ exists: () => checkIfExists(join4(process6.cwd(), ".github", "workflows", "adamantite.yml")),
422
+ create: (options) => safeTry7(async function* () {
423
+ const workflowDir = join4(process6.cwd(), ".github", "workflows");
424
+ yield* fromPromise4(mkdir(workflowDir, { recursive: true }), (error) => Fault7.wrap(error).withTag("FAILED_TO_CREATE_DIRECTORY").withDescription("Failed to create .github/workflows directory", "We're unable to create the .github/workflows directory in the current directory.").withContext({ path: workflowDir }));
425
+ const workflowContent = generateWorkflow(options);
426
+ if (!workflowContent) {
427
+ return ok7();
428
+ }
429
+ yield* fromPromise4(writeFile3(join4(workflowDir, "adamantite.yml"), workflowContent), (error) => Fault7.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write GitHub Actions workflow", "We're unable to write the GitHub Actions workflow file.").withContext({ path: join4(workflowDir, "adamantite.yml") }));
430
+ return ok7();
431
+ }),
432
+ update: (options) => safeTry7(async function* () {
433
+ const workflowPath = join4(process6.cwd(), ".github", "workflows", "adamantite.yml");
434
+ const workflowContent = generateWorkflow(options);
435
+ if (!workflowContent) {
436
+ return ok7();
437
+ }
438
+ yield* fromPromise4(writeFile3(workflowPath, workflowContent), (error) => Fault7.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write GitHub Actions workflow", "We're unable to update the GitHub Actions workflow file.").withContext({ path: workflowPath }));
439
+ return ok7();
440
+ })
441
+ };
442
+
443
+ // src/helpers/editors/vscode.ts
444
+ import { mkdir as mkdir2, readFile as readFile4, writeFile as writeFile4 } from "node:fs/promises";
445
+ import { join as join5 } from "node:path";
384
446
  import { Fault as Fault8 } from "faultier";
385
- import { fromPromise as fromPromise4, ok as ok8, safeTry as safeTry8 } from "neverthrow";
447
+ import { fromPromise as fromPromise5, ok as ok8, safeTry as safeTry8 } from "neverthrow";
386
448
  var vscode = {
387
449
  config: {
388
450
  "typescript.tsdk": "node_modules/typescript/lib",
@@ -395,37 +457,43 @@ var vscode = {
395
457
  "editor.defaultFormatter": "oxc.oxc-vscode"
396
458
  }
397
459
  },
398
- exists: () => checkIfExists(join4(process.cwd(), ".vscode", "settings.json")),
460
+ exists: () => checkIfExists(join5(process.cwd(), ".vscode", "settings.json")),
399
461
  create: () => safeTry8(async function* () {
400
- const vscodePath = join4(process.cwd(), ".vscode");
401
- yield* fromPromise4(mkdir(vscodePath, { recursive: true }), (error) => Fault8.wrap(error).withTag("FAILED_TO_CREATE_DIRECTORY").withDescription("Failed to create .vscode directory", "We're unable to create the .vscode directory in the current directory.").withContext({ path: vscodePath }));
402
- yield* fromPromise4(writeFile3(join4(vscodePath, "settings.json"), JSON.stringify(vscode.config, 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."));
462
+ const vscodePath = join5(process.cwd(), ".vscode");
463
+ yield* fromPromise5(mkdir2(vscodePath, { recursive: true }), (error) => Fault8.wrap(error).withTag("FAILED_TO_CREATE_DIRECTORY").withDescription("Failed to create .vscode directory", "We're unable to create the .vscode directory in the current directory.").withContext({ path: vscodePath }));
464
+ yield* fromPromise5(writeFile4(join5(vscodePath, "settings.json"), JSON.stringify(vscode.config, 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."));
403
465
  return ok8();
404
466
  }),
405
467
  update: () => safeTry8(async function* () {
406
- const vscodePath = join4(process.cwd(), ".vscode", "settings.json");
407
- const vscodeFile = yield* fromPromise4(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 }));
468
+ 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 }));
408
470
  const existingConfig = yield* parseJson(vscodeFile);
409
471
  const newConfig = yield* mergeConfig(vscode.config, existingConfig);
410
- yield* fromPromise4(writeFile3(join4(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 }));
472
+ 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 }));
411
473
  return ok8();
412
474
  })
413
475
  };
414
476
 
477
+ // src/helpers/packages/sherif.ts
478
+ var sherif = {
479
+ name: "sherif",
480
+ version: "1.9.0"
481
+ };
482
+
415
483
  // src/helpers/tsconfig.ts
416
- import { readFile as readFile5, writeFile as writeFile4 } from "node:fs/promises";
417
- import { join as join5 } from "node:path";
484
+ import { readFile as readFile5, writeFile as writeFile5 } from "node:fs/promises";
485
+ import { join as join6 } from "node:path";
418
486
  import { Fault as Fault9 } from "faultier";
419
- import { fromPromise as fromPromise5, ok as ok9, safeTry as safeTry9 } from "neverthrow";
487
+ import { fromPromise as fromPromise6, ok as ok9, safeTry as safeTry9 } from "neverthrow";
420
488
  var tsconfig = {
421
- config: { extends: "adamantite/tsconfig" },
422
- exists: () => checkIfExists(join5(process.cwd(), "tsconfig.json")),
423
- create: () => fromPromise5(writeFile4(join5(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.")),
489
+ config: { extends: "adamantite/typescript" },
490
+ 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.")),
424
492
  update: () => safeTry9(async function* () {
425
- const tsconfigFile = yield* fromPromise5(readFile5(join5(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."));
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."));
426
494
  const existingConfig = yield* parseJson(tsconfigFile);
427
495
  const newConfig = yield* mergeConfig(tsconfig.config, existingConfig);
428
- yield* fromPromise5(writeFile4(join5(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."));
496
+ 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."));
429
497
  return ok9();
430
498
  })
431
499
  };
@@ -436,7 +504,7 @@ var installDependencies = (packages) => safeTry10(async function* () {
436
504
  s.start("Installing dependencies...");
437
505
  const isMonorepo = yield* checkIsMonorepo();
438
506
  for (const pkg of packages) {
439
- yield* fromPromise6(addDevDependency(pkg, { silent: true, workspace: isMonorepo }), (error) => Fault10.wrap(error).withTag("FAILED_TO_INSTALL_DEPENDENCY").withMessage(`Failed to install ${pkg}`));
507
+ yield* fromPromise7(addDevDependency(pkg, { silent: true, workspace: isMonorepo }), (error) => Fault10.wrap(error).withTag("FAILED_TO_INSTALL_DEPENDENCY").withMessage(`Failed to install ${pkg}`));
440
508
  }
441
509
  s.stop("Dependencies installed.");
442
510
  return ok10();
@@ -490,6 +558,9 @@ var addScripts = (scripts) => safeTry10(async function* () {
490
558
  case "format":
491
559
  packageJson.scripts.format = "adamantite format";
492
560
  break;
561
+ case "typecheck":
562
+ packageJson.scripts.typecheck = "tsc --noEmit";
563
+ break;
493
564
  case "check:monorepo":
494
565
  packageJson.scripts["check:monorepo"] = "adamantite monorepo";
495
566
  break;
@@ -500,7 +571,7 @@ var addScripts = (scripts) => safeTry10(async function* () {
500
571
  return err4(Fault10.create("UNKNOWN_SCRIPT").withContext({ script }));
501
572
  }
502
573
  }
503
- yield* fromPromise6(writeFile5(join6(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: join6(cwd, "package.json") }));
574
+ 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") }));
504
575
  spinner2.stop("Scripts added to your `package.json`");
505
576
  return ok10();
506
577
  });
@@ -535,6 +606,20 @@ var setupEditors = (editors) => safeTry10(async function* () {
535
606
  if (editors.includes("zed")) {}
536
607
  return ok10();
537
608
  });
609
+ var setupGitHubActions = (packageManager, scripts) => safeTry10(async function* () {
610
+ const spinner2 = p.spinner();
611
+ spinner2.start("Setting up GitHub Actions workflow...");
612
+ if (await github.exists()) {
613
+ spinner2.message("`.github/workflows/adamantite.yml` found, updating...");
614
+ yield* github.update({ packageManager, scripts });
615
+ spinner2.stop("GitHub Actions workflow updated successfully.");
616
+ } else {
617
+ spinner2.message("Creating `.github/workflows/adamantite.yml`...");
618
+ yield* github.create({ packageManager, scripts });
619
+ spinner2.stop("GitHub Actions workflow created successfully.");
620
+ }
621
+ return ok10();
622
+ });
538
623
  var init_default = defineCommand({
539
624
  command: "init",
540
625
  describe: "Initialize Adamantite in the current directory",
@@ -566,6 +651,11 @@ var init_default = defineCommand({
566
651
  value: "format",
567
652
  hint: "recommended"
568
653
  },
654
+ {
655
+ label: "typecheck - type-check your code using strict TypeScript preset",
656
+ value: "typecheck",
657
+ hint: "extends the `adamantite/typescript` preset in your `tsconfig.json`"
658
+ },
569
659
  {
570
660
  label: "check:monorepo - check for monorepo-specific issues using Sherif",
571
661
  value: "check:monorepo",
@@ -583,12 +673,6 @@ var init_default = defineCommand({
583
673
  if (p.isCancel(scripts)) {
584
674
  return err4(Fault10.create("OPERATION_CANCELLED"));
585
675
  }
586
- const typescriptPreset = yield* fromSafePromise(p.confirm({
587
- message: "Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to install it?"
588
- }));
589
- if (p.isCancel(typescriptPreset)) {
590
- return err4(Fault10.create("OPERATION_CANCELLED"));
591
- }
592
676
  const editors = yield* fromSafePromise(p.multiselect({
593
677
  message: "Which editors do you want to configure? (optional)",
594
678
  options: [
@@ -600,9 +684,22 @@ var init_default = defineCommand({
600
684
  if (p.isCancel(editors)) {
601
685
  return err4(Fault10.create("OPERATION_CANCELLED"));
602
686
  }
687
+ const hasCIScripts = hasCICompatibleScripts(scripts);
688
+ let enableGitHubActions = false;
689
+ if (hasCIScripts) {
690
+ const response = yield* fromSafePromise(p.confirm({
691
+ message: "Do you want to add a GitHub Actions workflow to run checks in CI?",
692
+ initialValue: false
693
+ }));
694
+ if (p.isCancel(response)) {
695
+ return err4(Fault10.create("OPERATION_CANCELLED"));
696
+ }
697
+ enableGitHubActions = response;
698
+ }
603
699
  const hasBiome = scripts.includes("check") || scripts.includes("fix");
604
700
  const hasOxfmt = scripts.includes("format");
605
701
  const hasSherif = scripts.includes("check:monorepo") || scripts.includes("fix:monorepo");
702
+ const hasTypecheck = scripts.includes("typecheck");
606
703
  const dependencies = ["adamantite"];
607
704
  if (hasBiome) {
608
705
  dependencies.push(`${biome.name}@${biome.version}`);
@@ -613,6 +710,9 @@ var init_default = defineCommand({
613
710
  if (hasSherif) {
614
711
  dependencies.push(`${sherif.name}@${sherif.version}`);
615
712
  }
713
+ if (hasTypecheck) {
714
+ dependencies.push("typescript");
715
+ }
616
716
  yield* installDependencies(dependencies);
617
717
  if (hasOxfmt) {
618
718
  yield* setupOxfmtConfig();
@@ -621,10 +721,13 @@ var init_default = defineCommand({
621
721
  yield* setupBiomeConfig();
622
722
  }
623
723
  yield* addScripts(scripts);
624
- if (typescriptPreset) {
724
+ if (hasTypecheck) {
625
725
  yield* setupTypescript();
626
726
  }
627
727
  yield* setupEditors(editors);
728
+ if (enableGitHubActions) {
729
+ yield* setupGitHubActions(packageManager, scripts);
730
+ }
628
731
  return ok10();
629
732
  }).match(() => {
630
733
  p.outro("\uD83D\uDCA0 Adamantite initialized successfully!");
@@ -647,10 +750,10 @@ var init_default = defineCommand({
647
750
 
648
751
  // src/commands/monorepo.ts
649
752
  import process8 from "node:process";
650
- import { log as log6 } from "@clack/prompts";
753
+ import { log as log5 } from "@clack/prompts";
651
754
  import { Fault as Fault11 } from "faultier";
652
755
  import { ok as ok11, safeTry as safeTry11 } from "neverthrow";
653
- import { dlxCommand as dlxCommand5 } from "nypm";
756
+ import { dlxCommand as dlxCommand4 } from "nypm";
654
757
  var monorepo_default = defineCommand({
655
758
  command: "monorepo",
656
759
  describe: "Find and fix monorepo-specific issues using Sherif",
@@ -664,14 +767,14 @@ var monorepo_default = defineCommand({
664
767
  if (argv.fix) {
665
768
  args.push("--fix");
666
769
  }
667
- const command = dlxCommand5(packageManager, sherif.name, { args });
770
+ const command = dlxCommand4(packageManager, sherif.name, { args });
668
771
  yield* runCommand(command);
669
772
  return ok11(undefined);
670
773
  }).match(() => {
671
774
  process8.exit(0);
672
775
  }, (error) => {
673
776
  if (Fault11.isFault(error) && error.tag === "NO_PACKAGE_MANAGER") {
674
- log6.error(error.flatten());
777
+ log5.error(error.flatten());
675
778
  }
676
779
  process8.exit(1);
677
780
  })
@@ -679,9 +782,9 @@ var monorepo_default = defineCommand({
679
782
 
680
783
  // src/commands/update.ts
681
784
  import process9 from "node:process";
682
- 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";
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";
683
786
  import { Fault as Fault12 } from "faultier";
684
- import { err as err5, fromPromise as fromPromise7, fromSafePromise as fromSafePromise2, ok as ok12, safeTry as safeTry12 } from "neverthrow";
787
+ import { err as err5, fromPromise as fromPromise8, fromSafePromise as fromSafePromise2, ok as ok12, safeTry as safeTry12 } from "neverthrow";
685
788
  import { addDevDependency as addDevDependency2 } from "nypm";
686
789
  var update_default = defineCommand({
687
790
  command: "update",
@@ -704,15 +807,15 @@ var update_default = defineCommand({
704
807
  }
705
808
  }
706
809
  if (updates.length === 0) {
707
- log7.success("All adamantite dependencies are already up to date!");
810
+ log6.success("All adamantite dependencies are already up to date!");
708
811
  return ok12("no-updates");
709
812
  }
710
- log7.message("The following dependencies will be updated:");
711
- log7.message("");
813
+ log6.message("The following dependencies will be updated:");
814
+ log6.message("");
712
815
  for (const dep of updates) {
713
- log7.message(` ${dep.name}: ${dep.currentVersion} → ${dep.targetVersion}`);
816
+ log6.message(` ${dep.name}: ${dep.currentVersion} → ${dep.targetVersion}`);
714
817
  }
715
- log7.message("");
818
+ log6.message("");
716
819
  const shouldUpdate = yield* fromSafePromise2(confirm2({
717
820
  message: "Do you want to proceed with these updates?"
718
821
  }));
@@ -725,7 +828,7 @@ var update_default = defineCommand({
725
828
  const s = spinner2();
726
829
  s.start("Updating dependencies...");
727
830
  for (const dep of updates) {
728
- yield* fromPromise7(addDevDependency2(`${dep.name}@${dep.targetVersion}`), (error) => Fault12.wrap(error).withTag("FAILED_TO_INSTALL_DEPENDENCY").withMessage(`Failed to update ${dep.name}`));
831
+ yield* fromPromise8(addDevDependency2(`${dep.name}@${dep.targetVersion}`), (error) => Fault12.wrap(error).withTag("FAILED_TO_INSTALL_DEPENDENCY").withMessage(`Failed to update ${dep.name}`));
729
832
  }
730
833
  s.stop("Dependencies updated successfully");
731
834
  return ok12("updated");
@@ -744,9 +847,9 @@ var update_default = defineCommand({
744
847
  process9.exit(0);
745
848
  }
746
849
  if (Fault12.isFault(error)) {
747
- log7.error(error.flatten());
850
+ log6.error(error.flatten());
748
851
  } else {
749
- log7.error(String(error));
852
+ log6.error(String(error));
750
853
  }
751
854
  cancel2("Failed to update dependencies");
752
855
  process9.exit(1);
@@ -754,4 +857,4 @@ var update_default = defineCommand({
754
857
  });
755
858
 
756
859
  // src/index.ts
757
- yargs(hideBin(process.argv)).scriptName("adamantite").version("0.15.0").command(check_default).command(ci_default).command(fix_default).command(format_default).command(init_default).command(monorepo_default).command(update_default).demandCommand(1).strict().help().parse();
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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adamantite",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "An strict and opinionated set of presets for modern TypeScript applications",
5
5
  "keywords": [
6
6
  "adamantite",
@@ -37,7 +37,7 @@
37
37
  "exports": {
38
38
  ".": "./presets/biome.jsonc",
39
39
  "./biome": "./presets/biome.jsonc",
40
- "./tsconfig": "./presets/tsconfig.json",
40
+ "./typescript": "./presets/tsconfig.json",
41
41
  "./presets/*": "./presets/*"
42
42
  },
43
43
  "scripts": {