adamantite 0.13.2 → 0.14.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 CHANGED
@@ -165,7 +165,7 @@ Adamantite's Biome preset includes:
165
165
  - React/JSX patterns
166
166
  - **File Patterns**: Pre-configured for TypeScript, JavaScript, JSON, and more
167
167
 
168
- ### TypeScript Configuration ([presets/tsconfig.json](./src/presets/tsconfig.json))
168
+ ### TypeScript Configuration ([presets/tsconfig.json](./presets/tsconfig.json))
169
169
 
170
170
  The TypeScript preset includes strict settings for maximum type safety:
171
171
 
package/dist/index.js ADDED
@@ -0,0 +1,537 @@
1
+ // src/index.ts
2
+ import yargs from "yargs";
3
+ import { hideBin } from "yargs/helpers";
4
+
5
+ // src/commands/check.ts
6
+ import process3 from "node:process";
7
+ import { log } from "@clack/prompts";
8
+ import { Fault as Fault3 } from "faultier";
9
+ import { ok as ok3, safeTry as safeTry2 } from "neverthrow";
10
+ import { dlxCommand } from "nypm";
11
+
12
+ // src/helpers/packages/biome.ts
13
+ import { readFile as readFile2, writeFile } from "node:fs/promises";
14
+ import { join as join2 } from "node:path";
15
+ import { Fault as Fault2 } from "faultier";
16
+ import { err as err2, fromPromise as fromPromise2, ok as ok2, safeTry } from "neverthrow";
17
+
18
+ // src/utils.ts
19
+ import { execSync } from "node:child_process";
20
+ import { access, readFile } from "node:fs/promises";
21
+ import { join } from "node:path";
22
+ import process2 from "node:process";
23
+ import defu from "defu";
24
+ import { Fault } from "faultier";
25
+ import { parse } from "jsonc-parser";
26
+ import { err, fromPromise, fromThrowable, ok } from "neverthrow";
27
+ import { detectPackageManager } from "nypm";
28
+ function defineCommand(input) {
29
+ return input;
30
+ }
31
+ var runCommand = fromThrowable(execSync, (error) => Fault.wrap(error).withTag("FAILED_TO_RUN_COMMAND"));
32
+ var getPackageManagerName = () => fromPromise(detectPackageManager(process2.cwd()), () => "Failed to detect package manager").andThen((result) => result ? ok(result.name) : err("Failed to resolve package manager")).mapErr((message) => Fault.create("NO_PACKAGE_MANAGER").withDescription(message, "We're unable to detect the package manager used in this project. Please ensure you have a package.json file in the current directory."));
33
+ var checkIfExists = (path) => fromPromise(access(path), () => new Error("File not found")).match(() => true, () => false);
34
+ var parseJson = (content) => {
35
+ const errors = [];
36
+ const parsed = parse(content, errors);
37
+ if (errors.length > 0) {
38
+ return err(Fault.create("FAILED_TO_PARSE_FILE").withDescription("Failed to parse JSON", "We're unable to parse the provided JSON file.").withContext({ errors }));
39
+ }
40
+ return ok(parsed);
41
+ };
42
+ 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."));
43
+ 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));
44
+ function getTitle() {
45
+ const terminalWidth = process2.stdout.columns || 80;
46
+ if (terminalWidth >= 120) {
47
+ return `
48
+ █████ █████ ███ █████
49
+ ░░███ ░░███ ░░░ ░░███
50
+ ██████ ███████ ██████ █████████████ ██████ ████████ ███████ ████ ███████ ██████
51
+ ░░░░░███ ███░░███ ░░░░░███ ░░███░░███░░███ ░░░░░███ ░░███░░███ ░░░███░ ░░███ ░░░███░ ███░░███
52
+ ███████ ░███ ░███ ███████ ░███ ░███ ░███ ███████ ░███ ░███ ░███ ░███ ░███ ░███████
53
+ ███░░███ ░███ ░███ ███░░███ ░███ ░███ ░███ ███░░███ ░███ ░███ ░███ ███ ░███ ░███ ███░███░░░
54
+ ░░████████░░████████░░████████ █████░███ █████░░████████ ████ █████ ░░█████ █████ ░░█████ ░░██████
55
+ ░░░░░░░░ ░░░░░░░░ ░░░░░░░░ ░░░░░ ░░░ ░░░░░ ░░░░░░░░ ░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░
56
+ `;
57
+ }
58
+ return `
59
+ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
60
+ ┃ ADAMANTITE ┃
61
+ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
62
+ `;
63
+ }
64
+
65
+ // src/helpers/packages/biome.ts
66
+ var biome = {
67
+ name: "@biomejs/biome",
68
+ version: "2.3.10",
69
+ config: {
70
+ $schema: "./node_modules/@biomejs/biome/configuration_schema.json"
71
+ },
72
+ exists: async () => {
73
+ if (await checkIfExists(join2(process.cwd(), "biome.jsonc"))) {
74
+ return { path: join2(process.cwd(), "biome.jsonc") };
75
+ }
76
+ if (await checkIfExists(join2(process.cwd(), "biome.json"))) {
77
+ return { path: join2(process.cwd(), "biome.json") };
78
+ }
79
+ return { path: null };
80
+ },
81
+ 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.")),
82
+ update: () => safeTry(async function* () {
83
+ const exists = await biome.exists();
84
+ if (!exists.path) {
85
+ 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."));
86
+ }
87
+ 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."));
88
+ const existingConfig = yield* parseJson(biomeFile);
89
+ if (!existingConfig || Object.keys(existingConfig).length === 0) {
90
+ return err2(Fault2.create("INVALID_BIOME_CONFIG").withDescription("Invalid Biome configuration", "The Biome configuration file is empty or invalid.").withContext({ path: exists.path }));
91
+ }
92
+ const newConfig = { ...existingConfig };
93
+ if (!Array.isArray(newConfig.extends)) {
94
+ newConfig.extends = newConfig.extends ? [newConfig.extends] : [];
95
+ }
96
+ if (!newConfig.extends.includes("adamantite")) {
97
+ newConfig.extends.push("adamantite");
98
+ }
99
+ const mergedConfig = yield* mergeConfig(newConfig, biome.config);
100
+ mergedConfig.$schema = biome.config.$schema;
101
+ 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 }));
102
+ return ok2();
103
+ })
104
+ };
105
+
106
+ // src/commands/check.ts
107
+ var check_default = defineCommand({
108
+ command: "check [files..]",
109
+ describe: "Run Biome linter and check files for issues",
110
+ builder: (yargs) => yargs.positional("files", {
111
+ describe: "Specific files to lint (optional)",
112
+ type: "string",
113
+ array: true
114
+ }).option("summary", {
115
+ type: "boolean",
116
+ description: "Show summary of lint results"
117
+ }),
118
+ handler: async (argv) => safeTry2(async function* () {
119
+ const packageManager = yield* getPackageManagerName();
120
+ const args = ["check"];
121
+ if (argv.summary) {
122
+ args.push("--reporter", "summary");
123
+ }
124
+ if (argv.files && argv.files.length > 0) {
125
+ args.push(...argv.files);
126
+ }
127
+ const command = dlxCommand(packageManager, biome.name, { args });
128
+ yield* runCommand(command, { stdio: "inherit" });
129
+ return ok3(undefined);
130
+ }).match(() => {
131
+ process3.exit(0);
132
+ }, (error) => {
133
+ if (Fault3.isFault(error) && error.tag === "NO_PACKAGE_MANAGER") {
134
+ log.error(error.flatten());
135
+ }
136
+ process3.exit(1);
137
+ })
138
+ });
139
+
140
+ // src/commands/ci.ts
141
+ import process4 from "node:process";
142
+ import { log as log2 } from "@clack/prompts";
143
+ import { Fault as Fault4 } from "faultier";
144
+ import { ok as ok4, safeTry as safeTry3 } from "neverthrow";
145
+ import { dlxCommand as dlxCommand2 } from "nypm";
146
+
147
+ // src/helpers/packages/sherif.ts
148
+ var sherif = {
149
+ name: "sherif",
150
+ version: "1.9.0"
151
+ };
152
+
153
+ // src/commands/ci.ts
154
+ var ci_default = defineCommand({
155
+ command: "ci",
156
+ describe: "Run Adamantite in a CI environment",
157
+ builder: (yargs) => yargs.option("monorepo", {
158
+ type: "boolean",
159
+ description: "Run additional monorepo-specific checks"
160
+ }).option("github", {
161
+ type: "boolean",
162
+ description: "Use GitHub reporter"
163
+ }),
164
+ handler: async (argv) => safeTry3(async function* () {
165
+ const packageManager = yield* getPackageManagerName();
166
+ const tools = [
167
+ {
168
+ package: biome.name,
169
+ args: ["ci", ...argv.github ? ["--reporter", "github"] : []]
170
+ }
171
+ ];
172
+ if (argv.monorepo) {
173
+ tools.push({ package: sherif.name, args: [] });
174
+ }
175
+ for (const tool of tools) {
176
+ const command = dlxCommand2(packageManager, tool.package, {
177
+ args: tool.args
178
+ });
179
+ yield* runCommand(command, {
180
+ stdio: "inherit"
181
+ });
182
+ }
183
+ return ok4(undefined);
184
+ }).match(() => {
185
+ process4.exit(0);
186
+ }, (error) => {
187
+ if (Fault4.isFault(error) && error.tag === "NO_PACKAGE_MANAGER") {
188
+ log2.error(error.flatten());
189
+ }
190
+ process4.exit(1);
191
+ })
192
+ });
193
+
194
+ // src/commands/fix.ts
195
+ import process5 from "node:process";
196
+ import { log as log3 } from "@clack/prompts";
197
+ import { Fault as Fault5 } from "faultier";
198
+ import { ok as ok5, safeTry as safeTry4 } from "neverthrow";
199
+ import { dlxCommand as dlxCommand3 } from "nypm";
200
+ var fix_default = defineCommand({
201
+ command: "fix [files..]",
202
+ describe: "Run Biome linter and fix issues in files",
203
+ builder: (yargs) => yargs.positional("files", {
204
+ describe: "Specific files to fix (optional)",
205
+ type: "string",
206
+ array: true
207
+ }).option("unsafe", {
208
+ type: "boolean",
209
+ description: "Apply unsafe fixes"
210
+ }),
211
+ handler: async (argv) => safeTry4(async function* () {
212
+ const packageManager = yield* getPackageManagerName();
213
+ const args = ["check", "--write"];
214
+ if (argv.unsafe) {
215
+ args.push("--unsafe");
216
+ }
217
+ if (argv.files && argv.files.length > 0) {
218
+ args.push(...argv.files);
219
+ }
220
+ const command = dlxCommand3(packageManager, biome.name, { args });
221
+ yield* runCommand(command, {
222
+ stdio: "inherit"
223
+ });
224
+ return ok5(undefined);
225
+ }).match(() => {
226
+ process5.exit(0);
227
+ }, (error) => {
228
+ if (Fault5.isFault(error) && error.tag === "NO_PACKAGE_MANAGER") {
229
+ log3.error(error.flatten());
230
+ }
231
+ process5.exit(1);
232
+ })
233
+ });
234
+
235
+ // src/commands/init.ts
236
+ import { writeFile as writeFile4 } from "node:fs/promises";
237
+ import { join as join5 } from "node:path";
238
+ import process6 from "node:process";
239
+ import { cancel, confirm, intro, isCancel, log as log4, multiselect, outro, spinner } from "@clack/prompts";
240
+ import { Fault as Fault8 } from "faultier";
241
+ import { err as err3, fromPromise as fromPromise5, fromSafePromise, ok as ok8, safeTry as safeTry7 } from "neverthrow";
242
+ import { addDevDependency } from "nypm";
243
+
244
+ // src/helpers/editors/vscode.ts
245
+ import { mkdir, readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
246
+ import { join as join3 } from "node:path";
247
+ import { Fault as Fault6 } from "faultier";
248
+ import { fromPromise as fromPromise3, ok as ok6, safeTry as safeTry5 } from "neverthrow";
249
+ var vscode = {
250
+ config: {
251
+ "typescript.tsdk": "node_modules/typescript/lib",
252
+ "editor.formatOnSave": true,
253
+ "editor.formatOnPaste": true,
254
+ "editor.codeActionsOnSave": {
255
+ "source.organizeImports.biome": "explicit",
256
+ "source.fixAll.biome": "explicit"
257
+ },
258
+ "[javascript][typescript][javascriptreact][typescriptreact][json][jsonc][css][graphql]": {
259
+ "editor.defaultFormatter": "biomejs.biome"
260
+ }
261
+ },
262
+ exists: () => checkIfExists(join3(process.cwd(), ".vscode", "settings.json")),
263
+ create: () => safeTry5(async function* () {
264
+ const vscodePath = join3(process.cwd(), ".vscode");
265
+ yield* fromPromise3(mkdir(vscodePath, { recursive: true }), (error) => Fault6.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 }));
266
+ yield* fromPromise3(writeFile2(join3(vscodePath, "settings.json"), JSON.stringify(vscode.config, null, 2)), (error) => Fault6.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."));
267
+ return ok6();
268
+ }),
269
+ update: () => safeTry5(async function* () {
270
+ const vscodePath = join3(process.cwd(), ".vscode", "settings.json");
271
+ const vscodeFile = yield* fromPromise3(readFile3(vscodePath, "utf-8"), (error) => Fault6.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 }));
272
+ const existingConfig = yield* parseJson(vscodeFile);
273
+ const newConfig = yield* mergeConfig(vscode.config, existingConfig);
274
+ yield* fromPromise3(writeFile2(join3(process.cwd(), ".vscode", "settings.json"), JSON.stringify(newConfig, null, 2)), (error) => Fault6.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 }));
275
+ return ok6();
276
+ })
277
+ };
278
+
279
+ // src/helpers/tsconfig.ts
280
+ import { readFile as readFile4, writeFile as writeFile3 } from "node:fs/promises";
281
+ import { join as join4 } from "node:path";
282
+ import { Fault as Fault7 } from "faultier";
283
+ import { fromPromise as fromPromise4, ok as ok7, safeTry as safeTry6 } from "neverthrow";
284
+ var tsconfig = {
285
+ config: { extends: "adamantite/tsconfig" },
286
+ exists: () => checkIfExists(join4(process.cwd(), "tsconfig.json")),
287
+ create: () => fromPromise4(writeFile3(join4(process.cwd(), "tsconfig.json"), JSON.stringify(tsconfig.config, null, 2)), (error) => Fault7.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.")),
288
+ update: () => safeTry6(async function* () {
289
+ const tsconfigFile = yield* fromPromise4(readFile4(join4(process.cwd(), "tsconfig.json"), "utf-8"), (error) => Fault7.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."));
290
+ const existingConfig = yield* parseJson(tsconfigFile);
291
+ const newConfig = yield* mergeConfig(tsconfig.config, existingConfig);
292
+ yield* fromPromise4(writeFile3(join4(process.cwd(), "tsconfig.json"), JSON.stringify(newConfig, null, 2)), (error) => Fault7.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."));
293
+ return ok7();
294
+ })
295
+ };
296
+
297
+ // src/commands/init.ts
298
+ var init_default = defineCommand({
299
+ command: "init",
300
+ describe: "Initialize Adamantite in the current directory",
301
+ builder: (yargs) => yargs,
302
+ handler: async () => {
303
+ const cwd = process6.cwd();
304
+ return safeTry7(async function* () {
305
+ let packageJson = yield* readPackageJson();
306
+ intro(getTitle());
307
+ const hasPnpmWorkspace = await checkIfExists(join5(process6.cwd(), "pnpm-workspace.yaml"));
308
+ const isMonorepo = packageJson.workspaces !== undefined || hasPnpmWorkspace;
309
+ const shouldInstallScripts = yield* fromSafePromise(confirm({
310
+ message: "Do you want to add the `check` and `fix` scripts to your `package.json`?"
311
+ }));
312
+ if (isCancel(shouldInstallScripts)) {
313
+ return err3(Fault8.create("OPERATION_CANCELLED"));
314
+ }
315
+ let shouldInstallMonorepoScripts = false;
316
+ if (isMonorepo) {
317
+ const shouldInstallMonorepoScriptsResponse = yield* fromSafePromise(confirm({
318
+ message: "We've detected a monorepo setup in your project. Would you like to install monorepo linting scripts?"
319
+ }));
320
+ if (isCancel(shouldInstallMonorepoScriptsResponse)) {
321
+ return err3(Fault8.create("OPERATION_CANCELLED"));
322
+ }
323
+ shouldInstallMonorepoScripts = shouldInstallMonorepoScriptsResponse;
324
+ }
325
+ const shouldInstallTypeScriptPreset = yield* fromSafePromise(confirm({
326
+ message: "Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to install it?"
327
+ }));
328
+ if (isCancel(shouldInstallTypeScriptPreset)) {
329
+ return err3(Fault8.create("OPERATION_CANCELLED"));
330
+ }
331
+ const selectedEditors = yield* fromSafePromise(multiselect({
332
+ message: "Which editors do you want to configure (recommended)?",
333
+ options: [
334
+ { label: "VSCode / Cursor / Windsurf", value: "vscode" },
335
+ { label: "Zed (coming soon)", value: "zed" }
336
+ ],
337
+ required: false
338
+ }));
339
+ if (isCancel(selectedEditors)) {
340
+ return err3(Fault8.create("OPERATION_CANCELLED"));
341
+ }
342
+ const installingDependencies = spinner();
343
+ installingDependencies.start("Installing dependencies...");
344
+ yield* fromPromise5(addDevDependency("adamantite"), (error) => Fault8.wrap(error).withTag("FAILED_TO_INSTALL_DEPENDENCY").withMessage("Failed to install Adamantite"));
345
+ yield* fromPromise5(addDevDependency(`${biome.name}@${biome.version}`), (error) => Fault8.wrap(error).withTag("FAILED_TO_INSTALL_DEPENDENCY").withMessage("Failed to install Biome"));
346
+ if (shouldInstallMonorepoScripts) {
347
+ yield* fromPromise5(addDevDependency(`${sherif.name}@${sherif.version}`), (error) => Fault8.wrap(error).withTag("FAILED_TO_INSTALL_DEPENDENCY").withMessage("Failed to install Sherif"));
348
+ }
349
+ installingDependencies.stop("Dependencies installed successfully");
350
+ const settingUpBiomeConfig = spinner();
351
+ settingUpBiomeConfig.start("Setting up Biome config...");
352
+ const biomePath = await biome.exists();
353
+ if (biomePath.path) {
354
+ settingUpBiomeConfig.message("Biome config found, updating...");
355
+ yield* biome.update();
356
+ settingUpBiomeConfig.stop("Biome config updated successfully");
357
+ } else {
358
+ settingUpBiomeConfig.message("Biome config not found, creating...");
359
+ yield* biome.create();
360
+ settingUpBiomeConfig.stop("Biome config created successfully");
361
+ }
362
+ if (shouldInstallScripts) {
363
+ const addingScripts = spinner();
364
+ packageJson = yield* readPackageJson();
365
+ addingScripts.start("Adding scripts to your `package.json`...");
366
+ if (!packageJson.scripts) {
367
+ packageJson.scripts = {};
368
+ }
369
+ packageJson.scripts.check = "adamantite check";
370
+ packageJson.scripts.fix = "adamantite fix";
371
+ if (shouldInstallMonorepoScripts) {
372
+ packageJson.scripts["lint:monorepo"] = "adamantite monorepo";
373
+ }
374
+ yield* fromPromise5(writeFile4(join5(cwd, "package.json"), JSON.stringify(packageJson, null, 2)), (error) => Fault8.wrap(error).withTag("FAILED_TO_WRITE_FILE").withDescription("Failed to write package.json", "We're unable to update the package.json file.").withContext({ path: join5(cwd, "package.json") }));
375
+ addingScripts.stop("Scripts added to your `package.json`");
376
+ }
377
+ if (shouldInstallTypeScriptPreset) {
378
+ const settingUpTypeScriptConfig = spinner();
379
+ settingUpTypeScriptConfig.start("Setting up TypeScript config...");
380
+ if (await tsconfig.exists()) {
381
+ settingUpTypeScriptConfig.message("`tsconfig.json` found, updating...");
382
+ yield* tsconfig.update();
383
+ settingUpTypeScriptConfig.stop("`tsconfig.json` updated successfully");
384
+ } else {
385
+ settingUpTypeScriptConfig.message("`tsconfig.json` not found, creating...");
386
+ yield* tsconfig.create();
387
+ settingUpTypeScriptConfig.stop("`tsconfig.json` created successfully");
388
+ }
389
+ }
390
+ if (selectedEditors.length > 0) {
391
+ const settingUpEditorConfig = spinner();
392
+ settingUpEditorConfig.start("Setting up editor config...");
393
+ if (selectedEditors.includes("vscode")) {
394
+ const settingUpVSCodeConfig = spinner();
395
+ settingUpVSCodeConfig.start("Setting up VSCode config...");
396
+ if (await vscode.exists()) {
397
+ settingUpVSCodeConfig.message("VSCode settings found, updating...");
398
+ yield* vscode.update();
399
+ settingUpVSCodeConfig.stop("VSCode settings updated with Adamantite preset");
400
+ } else {
401
+ settingUpVSCodeConfig.message("VSCode settings not found, creating...");
402
+ yield* vscode.create();
403
+ settingUpVSCodeConfig.stop("VSCode settings created with Adamantite preset");
404
+ }
405
+ }
406
+ if (selectedEditors.includes("zed")) {
407
+ log4.warning("Zed configuration coming soon...");
408
+ }
409
+ settingUpEditorConfig.stop("Editor config set up successfully");
410
+ }
411
+ return ok8();
412
+ }).match(() => {
413
+ outro("\uD83D\uDCA0 Adamantite initialized successfully!");
414
+ process6.exit(0);
415
+ }, (error) => {
416
+ if (Fault8.isFault(error) && error.tag === "OPERATION_CANCELLED") {
417
+ cancel("You've cancelled the initialization process.");
418
+ process6.exit(0);
419
+ return;
420
+ }
421
+ if (Fault8.isFault(error)) {
422
+ log4.error(error.flatten());
423
+ } else {
424
+ log4.error(String(error));
425
+ }
426
+ cancel("Failed to initialize Adamantite");
427
+ process6.exit(1);
428
+ });
429
+ }
430
+ });
431
+
432
+ // src/commands/monorepo.ts
433
+ import process7 from "node:process";
434
+ import { log as log5 } from "@clack/prompts";
435
+ import { Fault as Fault9 } from "faultier";
436
+ import { ok as ok9, safeTry as safeTry8 } from "neverthrow";
437
+ import { dlxCommand as dlxCommand4 } from "nypm";
438
+ var monorepo_default = defineCommand({
439
+ command: "monorepo",
440
+ describe: "Lint and automatically fix monorepo-specific issues using Sherif",
441
+ builder: (yargs) => yargs,
442
+ handler: async () => safeTry8(async function* () {
443
+ const packageManager = yield* getPackageManagerName();
444
+ const args = ["--fix"];
445
+ const command = dlxCommand4(packageManager, sherif.name, { args });
446
+ yield* runCommand(command, {
447
+ stdio: "inherit"
448
+ });
449
+ return ok9(undefined);
450
+ }).match(() => {
451
+ process7.exit(0);
452
+ }, (error) => {
453
+ if (Fault9.isFault(error) && error.tag === "NO_PACKAGE_MANAGER") {
454
+ log5.error(error.flatten());
455
+ }
456
+ process7.exit(1);
457
+ })
458
+ });
459
+
460
+ // src/commands/update.ts
461
+ import process8 from "node:process";
462
+ 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";
463
+ import { Fault as Fault10 } from "faultier";
464
+ import { err as err4, fromPromise as fromPromise6, fromSafePromise as fromSafePromise2, ok as ok10, safeTry as safeTry9 } from "neverthrow";
465
+ import { addDevDependency as addDevDependency2 } from "nypm";
466
+ var update_default = defineCommand({
467
+ command: "update",
468
+ describe: "Update adamantite dependencies to latest compatible versions",
469
+ builder: (yargs) => yargs,
470
+ handler: async () => safeTry9(async function* () {
471
+ const packageJson = yield* readPackageJson();
472
+ intro2(getTitle());
473
+ const updates = [];
474
+ for (const pkg of [biome, sherif]) {
475
+ const dependency = packageJson.devDependencies?.[pkg.name];
476
+ if (dependency && dependency !== pkg.version) {
477
+ updates.push({
478
+ name: pkg.name,
479
+ currentVersion: dependency,
480
+ targetVersion: pkg.version,
481
+ isDevDependency: true
482
+ });
483
+ }
484
+ }
485
+ if (updates.length === 0) {
486
+ log6.success("All adamantite dependencies are already up to date!");
487
+ return ok10("no-updates");
488
+ }
489
+ log6.message("The following dependencies will be updated:");
490
+ log6.message("");
491
+ for (const dep of updates) {
492
+ log6.message(` ${dep.name}: ${dep.currentVersion} → ${dep.targetVersion}`);
493
+ }
494
+ log6.message("");
495
+ const shouldUpdate = yield* fromSafePromise2(confirm2({
496
+ message: "Do you want to proceed with these updates?"
497
+ }));
498
+ if (isCancel2(shouldUpdate)) {
499
+ return err4(Fault10.create("OPERATION_CANCELLED"));
500
+ }
501
+ if (!shouldUpdate) {
502
+ return ok10("cancelled");
503
+ }
504
+ const s = spinner2();
505
+ s.start("Updating dependencies...");
506
+ for (const dep of updates) {
507
+ yield* fromPromise6(addDevDependency2(`${dep.name}@${dep.targetVersion}`), (error) => Fault10.wrap(error).withTag("FAILED_TO_INSTALL_DEPENDENCY").withMessage(`Failed to update ${dep.name}`));
508
+ }
509
+ s.stop("Dependencies updated successfully");
510
+ return ok10("updated");
511
+ }).match((value) => {
512
+ if (value === "no-updates") {
513
+ outro2("\uD83D\uDCA0 No updates needed");
514
+ } else if (value === "cancelled") {
515
+ outro2("\uD83D\uDCA0 Update cancelled");
516
+ } else if (value === "updated") {
517
+ outro2("\uD83D\uDCA0 Dependencies updated successfully!");
518
+ }
519
+ process8.exit(0);
520
+ }, (error) => {
521
+ if (Fault10.isFault(error) && error.tag === "OPERATION_CANCELLED") {
522
+ cancel2("You've cancelled the update process.");
523
+ process8.exit(0);
524
+ return;
525
+ }
526
+ if (Fault10.isFault(error)) {
527
+ log6.error(error.flatten());
528
+ } else {
529
+ log6.error(String(error));
530
+ }
531
+ cancel2("Failed to update dependencies");
532
+ process8.exit(1);
533
+ })
534
+ });
535
+
536
+ // src/index.ts
537
+ yargs(hideBin(process.argv)).scriptName("adamantite").version("0.14.2").command(check_default).command(ci_default).command(fix_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.13.2",
3
+ "version": "0.14.2",
4
4
  "description": "An strict and opinionated set of presets for modern TypeScript applications",
5
5
  "keywords": [
6
6
  "adamantite",
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "author": "Adel Rodriguez <hello@adelrodriguez.com>",
23
23
  "type": "module",
24
- "main": "src/presets/biome.jsonc",
24
+ "main": "presets/biome.jsonc",
25
25
  "bin": {
26
26
  "adamantite": "bin/adamantite"
27
27
  },
@@ -29,21 +29,21 @@
29
29
  "#*": "./src/*"
30
30
  },
31
31
  "exports": {
32
- ".": "./src/presets/biome.jsonc",
33
- "./biome": "./src/presets/biome.jsonc",
34
- "./tsconfig": "./src/presets/tsconfig.json",
35
- "./presets/*": "./src/presets/*"
32
+ ".": "./presets/biome.jsonc",
33
+ "./biome": "./presets/biome.jsonc",
34
+ "./tsconfig": "./presets/tsconfig.json",
35
+ "./presets/*": "./presets/*"
36
36
  },
37
37
  "files": [
38
38
  "bin",
39
39
  "dist",
40
- "src/presets"
40
+ "presets"
41
41
  ],
42
42
  "scripts": {
43
- "build": "tsdown",
43
+ "build": "bunup",
44
44
  "bump:deps": "bun update --interactive",
45
45
  "check": "bun --bun run src/index.ts check",
46
- "dev": "tsdown --watch",
46
+ "dev": "bunup --watch",
47
47
  "fix": "bun --bun run src/index.ts fix",
48
48
  "release": "changeset publish",
49
49
  "test": "bun test",
@@ -54,7 +54,9 @@
54
54
  "dependencies": {
55
55
  "@clack/prompts": "0.11.0",
56
56
  "defu": "6.1.4",
57
+ "faultier": "^1.0.4",
57
58
  "jsonc-parser": "3.3.1",
59
+ "neverthrow": "8.2.0",
58
60
  "nypm": "0.6.2",
59
61
  "yargs": "18.0.0"
60
62
  },
@@ -63,8 +65,8 @@
63
65
  "@changesets/cli": "2.29.8",
64
66
  "@types/bun": "1.3.5",
65
67
  "@types/yargs": "17.0.35",
68
+ "bunup": "0.16.11",
66
69
  "sherif": "1.9.0",
67
- "tsdown": "0.18.1",
68
70
  "type-fest": "5.3.1",
69
71
  "typescript": "5.9.3"
70
72
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "../../node_modules/@biomejs/biome/configuration_schema.json",
2
+ "$schema": "../node_modules/@biomejs/biome/configuration_schema.json",
3
3
  "root": false,
4
4
  // ---------------------------- FORMATTER -----------------------------
5
5
  // These are the generic settings that apply to all files in the project.
@@ -15,7 +15,7 @@
15
15
  // Use the system line ending.
16
16
  "lineEnding": "auto",
17
17
  // The expected line width for most editors.
18
- "lineWidth": 80,
18
+ "lineWidth": 100,
19
19
  // Don't force attributes to be on the same line as the element.
20
20
  "attributePosition": "auto",
21
21
  "bracketSpacing": true
@@ -103,9 +103,9 @@
103
103
  "noEmptyTypeParameters": "error",
104
104
  "noExtraBooleanCast": "error",
105
105
  "noExcessiveCognitiveComplexity": {
106
- "level": "error",
106
+ "level": "warn",
107
107
  "options": {
108
- "maxAllowedComplexity": 20
108
+ "maxAllowedComplexity": 40
109
109
  }
110
110
  },
111
111
  "noExcessiveNestedTestSuites": "error",
package/dist/index.mjs DELETED
@@ -1,472 +0,0 @@
1
- import yargs from "yargs";
2
- import { hideBin } from "yargs/helpers";
3
- import { execSync } from "child_process";
4
- import { addDevDependency, detectPackageManager, dlxCommand } from "nypm";
5
- import { access, mkdir, readFile, writeFile } from "fs/promises";
6
- import { join } from "path";
7
- import defu from "defu";
8
- import { parse } from "jsonc-parser";
9
- import process$1 from "process";
10
- import { cancel, confirm, intro, isCancel, log, multiselect, outro, spinner } from "@clack/prompts";
11
- import { readFileSync } from "fs";
12
-
13
- //#region src/utils.ts
14
- function defineCommand(input) {
15
- return input;
16
- }
17
- async function getPackageManagerName() {
18
- const result = await detectPackageManager(process$1.cwd());
19
- if (!result) throw new Error("No package manager found");
20
- const { warnings, ...packageManager } = result;
21
- if (warnings && warnings.length > 0) console.warn(warnings.join("\n"));
22
- return packageManager.name;
23
- }
24
- function handleCommandError(error) {
25
- const message = error instanceof Error ? error.message : "An unknown error occurred";
26
- console.error(message);
27
- cancel("Failed to run Adamantite");
28
- process$1.exit(1);
29
- }
30
- async function checkIfExists(path) {
31
- try {
32
- await access(path);
33
- return true;
34
- } catch {
35
- return false;
36
- }
37
- }
38
- /**
39
- * Reads and parses package.json with proper typing
40
- */
41
- async function readPackageJson(cwd = process$1.cwd()) {
42
- const currentPath = join(cwd, "package.json");
43
- if (!await checkIfExists(currentPath)) throw new Error("package.json not found in the current directory");
44
- try {
45
- const content = await readFile(currentPath, "utf-8");
46
- return JSON.parse(content);
47
- } catch (error) {
48
- throw new Error(`Failed to parse package.json: ${error instanceof Error ? error.message : "Unknown error"}`);
49
- }
50
- }
51
- /**
52
- * Writes package.json with proper formatting
53
- */
54
- async function writePackageJson(packageJson, cwd = process$1.cwd()) {
55
- const currentPath = join(cwd, "package.json");
56
- try {
57
- await writeFile(currentPath, JSON.stringify(packageJson, null, 2));
58
- } catch (error) {
59
- throw new Error(`Failed to write package.json: ${error instanceof Error ? error.message : "Unknown error"}`);
60
- }
61
- }
62
- function getTitle() {
63
- if ((process$1.stdout.columns || 80) >= 120) return `
64
- █████ █████ ███ █████
65
- ░░███ ░░███ ░░░ ░░███
66
- ██████ ███████ ██████ █████████████ ██████ ████████ ███████ ████ ███████ ██████
67
- ░░░░░███ ███░░███ ░░░░░███ ░░███░░███░░███ ░░░░░███ ░░███░░███ ░░░███░ ░░███ ░░░███░ ███░░███
68
- ███████ ░███ ░███ ███████ ░███ ░███ ░███ ███████ ░███ ░███ ░███ ░███ ░███ ░███████
69
- ███░░███ ░███ ░███ ███░░███ ░███ ░███ ░███ ███░░███ ░███ ░███ ░███ ███ ░███ ░███ ███░███░░░
70
- ░░████████░░████████░░████████ █████░███ █████░░████████ ████ █████ ░░█████ █████ ░░█████ ░░██████
71
- ░░░░░░░░ ░░░░░░░░ ░░░░░░░░ ░░░░░ ░░░ ░░░░░ ░░░░░░░░ ░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░
72
- `;
73
- return `
74
- ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
75
- ┃ ADAMANTITE ┃
76
- ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
77
- `;
78
- }
79
-
80
- //#endregion
81
- //#region src/commands/helpers.ts
82
- const tsconfig = {
83
- name: "tsconfig",
84
- config: { extends: "adamantite/tsconfig" },
85
- async exists() {
86
- return await checkIfExists(join(process.cwd(), "tsconfig.json"));
87
- },
88
- async create() {
89
- await writeFile(join(process.cwd(), "tsconfig.json"), JSON.stringify(this.config, null, 2));
90
- },
91
- async update() {
92
- const existingConfig = parse(await readFile(join(process.cwd(), "tsconfig.json"), "utf-8"));
93
- const newConfig = defu(this.config, existingConfig);
94
- await writeFile(join(process.cwd(), "tsconfig.json"), JSON.stringify(newConfig, null, 2));
95
- }
96
- };
97
- const biome = {
98
- name: "@biomejs/biome",
99
- version: "2.3.10",
100
- config: { $schema: "./node_modules/@biomejs/biome/configuration_schema.json" },
101
- async exists() {
102
- return await checkIfExists(join(process.cwd(), "biome.jsonc"));
103
- },
104
- async create() {
105
- await writeFile(join(process.cwd(), "biome.jsonc"), JSON.stringify({
106
- ...this.config,
107
- extends: ["adamantite"]
108
- }, null, 2));
109
- },
110
- async update() {
111
- const newConfig = { ...parse(await readFile(await checkIfExists(join(process.cwd(), "biome.jsonc")) ? join(process.cwd(), "biome.jsonc") : join(process.cwd(), "biome.json"), "utf-8")) };
112
- if (!Array.isArray(newConfig.extends)) newConfig.extends = newConfig.extends ? [newConfig.extends] : [];
113
- if (!newConfig.extends.includes("adamantite")) newConfig.extends.push("adamantite");
114
- const mergedConfig = defu(this.config, newConfig);
115
- await writeFile(join(process.cwd(), "biome.jsonc"), JSON.stringify(mergedConfig, null, 2));
116
- }
117
- };
118
- const vscode = {
119
- name: ".vscode",
120
- config: {
121
- "typescript.tsdk": "node_modules/typescript/lib",
122
- "editor.formatOnSave": true,
123
- "editor.formatOnPaste": true,
124
- "editor.codeActionsOnSave": {
125
- "source.organizeImports.biome": "explicit",
126
- "source.fixAll.biome": "explicit"
127
- },
128
- "[javascript][typescript][javascriptreact][typescriptreact][json][jsonc][css][graphql]": { "editor.defaultFormatter": "biomejs.biome" }
129
- },
130
- async exists() {
131
- return await checkIfExists(join(process.cwd(), ".vscode", "settings.json"));
132
- },
133
- async create() {
134
- const vscodePath = join(process.cwd(), ".vscode");
135
- await mkdir(vscodePath, { recursive: true });
136
- await writeFile(join(vscodePath, "settings.json"), JSON.stringify(this.config, null, 2));
137
- },
138
- async update() {
139
- const existingConfig = parse(await readFile(join(process.cwd(), ".vscode", "settings.json"), "utf-8"));
140
- const newConfig = defu(this.config, existingConfig);
141
- await writeFile(join(process.cwd(), ".vscode", "settings.json"), JSON.stringify(newConfig, null, 2));
142
- }
143
- };
144
- const sherif = { version: "1.9.0" };
145
-
146
- //#endregion
147
- //#region src/commands/check.ts
148
- var check_default = defineCommand({
149
- command: "check",
150
- describe: "Run Biome linter and check files for issues",
151
- builder: (yargs$1) => yargs$1.positional("files", {
152
- describe: "Specific files to lint (optional)",
153
- type: "string"
154
- }).option("summary", {
155
- type: "boolean",
156
- description: "Show summary of lint results"
157
- }),
158
- handler: async (argv) => {
159
- try {
160
- const packageManager = await getPackageManagerName();
161
- const args = ["check"];
162
- if (argv.summary) args.push("--reporter", "summary");
163
- if (argv.files && argv.files.length > 0) args.push(...argv.files);
164
- execSync(dlxCommand(packageManager, biome.name, { args }), { stdio: "inherit" });
165
- } catch (error) {
166
- handleCommandError(error);
167
- }
168
- }
169
- });
170
-
171
- //#endregion
172
- //#region src/commands/ci.ts
173
- var ci_default = defineCommand({
174
- command: "ci",
175
- describe: "Run Adamantite in a CI environment",
176
- builder: (yargs$1) => yargs$1.option("monorepo", {
177
- type: "boolean",
178
- description: "Run additional monorepo-specific checks"
179
- }).option("github", {
180
- type: "boolean",
181
- description: "Use GitHub reporter"
182
- }),
183
- handler: async (argv) => {
184
- try {
185
- const packageManager = await getPackageManagerName();
186
- const tools = [{
187
- package: "@biomejs/biome",
188
- args: ["ci", ...argv.github ? ["--reporter", "github"] : []]
189
- }, ...argv.monorepo ? [{
190
- package: "sherif",
191
- args: []
192
- }] : []];
193
- for (const tool of tools) execSync(dlxCommand(packageManager, tool.package, { args: tool.args }), { stdio: "inherit" });
194
- } catch (error) {
195
- handleCommandError(error);
196
- }
197
- }
198
- });
199
-
200
- //#endregion
201
- //#region src/commands/fix.ts
202
- var fix_default = defineCommand({
203
- command: "fix",
204
- describe: "Run Biome linter and fix issues in files",
205
- builder: (yargs$1) => yargs$1.positional("files", {
206
- describe: "Specific files to fix (optional)",
207
- type: "string"
208
- }).option("unsafe", {
209
- type: "boolean",
210
- description: "Apply unsafe fixes"
211
- }),
212
- handler: async (argv) => {
213
- try {
214
- const packageManager = await getPackageManagerName();
215
- const args = ["check", "--write"];
216
- if (argv.unsafe) args.push("--unsafe");
217
- if (argv.files && argv.files.length > 0) args.push(...argv.files);
218
- execSync(dlxCommand(packageManager, biome.name, { args }), { stdio: "inherit" });
219
- } catch (error) {
220
- handleCommandError(error);
221
- }
222
- }
223
- });
224
-
225
- //#endregion
226
- //#region src/commands/init.ts
227
- async function checkIsMonorepo() {
228
- if (await checkIfExists(join(process$1.cwd(), "pnpm-workspace.yaml"))) return true;
229
- try {
230
- return (await readPackageJson()).workspaces !== void 0;
231
- } catch {
232
- return false;
233
- }
234
- }
235
- async function setupBiomeConfig() {
236
- const s = spinner();
237
- if (await biome.exists()) {
238
- s.start("Biome config found, updating...");
239
- await biome.update();
240
- s.stop("Biome config updated with Adamantite preset");
241
- } else {
242
- s.start("Biome config not found, creating...");
243
- await biome.create();
244
- s.stop("Biome config created with Adamantite preset");
245
- }
246
- }
247
- async function setupScripts({ check, fix, monorepo }) {
248
- const s = spinner();
249
- s.start("Adding scripts to your `package.json`...");
250
- try {
251
- const packageJson = await readPackageJson();
252
- if (!packageJson.scripts) packageJson.scripts = {};
253
- if (check) packageJson.scripts["check"] = "adamantite check";
254
- if (fix) packageJson.scripts["fix"] = "adamantite fix";
255
- if (monorepo) packageJson.scripts["lint:monorepo"] = "adamantite monorepo";
256
- await writePackageJson(packageJson);
257
- s.stop("Scripts added to your `package.json`");
258
- } catch (error) {
259
- s.stop("Failed to add scripts");
260
- throw new Error(`Failed to modify package.json: ${error instanceof Error ? error.message : "Unknown error"}`);
261
- }
262
- }
263
- async function setupTsConfig() {
264
- const s = spinner();
265
- if (await tsconfig.exists()) {
266
- s.start("`tsconfig.json` found, updating...");
267
- await tsconfig.update();
268
- s.stop("Updated `tsconfig.json` with preset");
269
- } else {
270
- s.start("`tsconfig.json` not found, creating...");
271
- await tsconfig.create();
272
- s.stop("Created `tsconfig.json` with preset");
273
- }
274
- }
275
- async function selectEditorConfig() {
276
- const selected = await multiselect({
277
- message: "Which editors do you want to configure (recommended)?",
278
- options: [{
279
- label: "VSCode / Cursor / Windsurf",
280
- value: "vscode"
281
- }, {
282
- label: "Zed (coming soon)",
283
- value: "zed"
284
- }],
285
- required: false
286
- });
287
- if (isCancel(selected)) throw new Error("Operation cancelled");
288
- return selected;
289
- }
290
- async function setupEditorConfig(selectedEditors) {
291
- if (!selectedEditors || selectedEditors.length === 0) return;
292
- const s = spinner();
293
- if (selectedEditors.includes("vscode")) if (await vscode.exists()) {
294
- s.start("VSCode settings found, updating...");
295
- await vscode.update();
296
- s.stop("VSCode settings updated with Adamantite preset");
297
- } else {
298
- s.start("VSCode settings not found, creating...");
299
- await vscode.create();
300
- s.stop("VSCode settings created with Adamantite preset");
301
- }
302
- if (selectedEditors.includes("zed")) {
303
- s.start("Zed configuration coming soon...");
304
- s.stop("Zed configuration coming soon...");
305
- }
306
- }
307
- async function confirmAction(message) {
308
- const result = await confirm({ message });
309
- if (isCancel(result)) throw new Error("Operation cancelled");
310
- return result;
311
- }
312
- async function installDependencies(options) {
313
- const s = spinner();
314
- s.start("Installing dependencies...");
315
- try {
316
- await addDevDependency("adamantite");
317
- const biomeVersion = biome.version;
318
- await addDevDependency(`@biomejs/biome@${biomeVersion}`);
319
- if (options?.monorepo) await addDevDependency(`sherif@${sherif.version}`);
320
- s.stop("Dependencies installed successfully");
321
- } catch (error) {
322
- s.stop("Failed to install dependencies");
323
- throw new Error(`Failed to install dependencies: ${error instanceof Error ? error.message : "Unknown error"}`);
324
- }
325
- }
326
- var init_default = defineCommand({
327
- command: "init",
328
- describe: "Initialize Adamantite in the current directory",
329
- builder: (yargs$1) => yargs$1,
330
- handler: async () => {
331
- intro(getTitle());
332
- try {
333
- const isMonorepo = await checkIsMonorepo();
334
- const installScripts = await confirmAction("Do you want to add the `check` and `fix` scripts to your `package.json`?");
335
- const installMonorepoScript = isMonorepo ? await confirmAction("We've detected a monorepo setup in your project. Would you like to install monorepo linting scripts?") : false;
336
- const installTypeScript = await confirmAction("Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to install it?");
337
- const selectedEditors = await selectEditorConfig();
338
- await installDependencies({ monorepo: installMonorepoScript });
339
- await setupBiomeConfig();
340
- if (installScripts || installMonorepoScript) await setupScripts({
341
- check: installScripts,
342
- fix: installScripts,
343
- monorepo: installMonorepoScript
344
- });
345
- if (installTypeScript) await setupTsConfig();
346
- await setupEditorConfig(selectedEditors);
347
- outro("💠 Adamantite initialized successfully!");
348
- } catch (error) {
349
- log.error(`${error instanceof Error ? error.message : "Unknown error"}`);
350
- cancel("Failed to initialize Adamantite");
351
- }
352
- }
353
- });
354
-
355
- //#endregion
356
- //#region src/commands/monorepo.ts
357
- var monorepo_default = defineCommand({
358
- command: "monorepo",
359
- describe: "Lint and automatically fix monorepo-specific issues using Sherif",
360
- builder: (yargs$1) => yargs$1,
361
- handler: async () => {
362
- try {
363
- execSync(dlxCommand(await getPackageManagerName(), "sherif", { args: ["--fix"] }), { stdio: "inherit" });
364
- } catch (error) {
365
- handleCommandError(error);
366
- }
367
- }
368
- });
369
-
370
- //#endregion
371
- //#region src/commands/update.ts
372
- async function detectUpdatesNeeded() {
373
- const updates = [];
374
- try {
375
- const packageJson = await readPackageJson();
376
- const biomeDep = packageJson.devDependencies?.["@biomejs/biome"];
377
- if (biomeDep && biomeDep !== biome.version) updates.push({
378
- name: "@biomejs/biome",
379
- currentVersion: biomeDep,
380
- targetVersion: biome.version,
381
- isDevDependency: true
382
- });
383
- const sherifDep = packageJson.devDependencies?.sherif;
384
- if (sherifDep && sherifDep !== sherif.version) updates.push({
385
- name: "sherif",
386
- currentVersion: sherifDep,
387
- targetVersion: sherif.version,
388
- isDevDependency: true
389
- });
390
- return updates;
391
- } catch (error) {
392
- throw new Error(`Failed to read package.json: ${error instanceof Error ? error.message : "Unknown error"}`);
393
- }
394
- }
395
- async function updateDependencies(updates) {
396
- const s = spinner();
397
- s.start("Updating dependencies...");
398
- try {
399
- const tasks = updates.map((dep) => addDevDependency(`${dep.name}@${dep.targetVersion}`));
400
- const results = await Promise.allSettled(tasks);
401
- const failures = [];
402
- const successes = [];
403
- for (const [index, result] of results.entries()) {
404
- const dep = updates[index];
405
- if (!dep) continue;
406
- const depName = dep.name;
407
- if (result.status === "fulfilled") successes.push(depName);
408
- else failures.push(`${depName}: ${result.reason?.message || "Unknown error"}`);
409
- }
410
- if (failures.length === 0) s.stop("Dependencies updated successfully");
411
- else if (successes.length === 0) {
412
- s.stop("Failed to update dependencies");
413
- throw new Error(`All dependency updates failed:\n${failures.join("\n")}`);
414
- } else {
415
- s.stop("Partial update completed");
416
- log.warn("Some dependencies failed to update:");
417
- for (const failure of failures) log.warn(` ${failure}`);
418
- log.success(`Successfully updated: ${successes.join(", ")}`);
419
- }
420
- } catch (error) {
421
- s.stop("Failed to update dependencies");
422
- throw error;
423
- }
424
- }
425
- async function confirmUpdate(updates) {
426
- log.message("The following dependencies will be updated:");
427
- log.message("");
428
- for (const dep of updates) log.message(` ${dep.name}: ${dep.currentVersion} → ${dep.targetVersion}`);
429
- log.message("");
430
- const result = await confirm({ message: "Do you want to proceed with these updates?" });
431
- if (isCancel(result)) throw new Error("Operation cancelled");
432
- return result;
433
- }
434
- var update_default = defineCommand({
435
- command: "update",
436
- describe: "Update adamantite dependencies to latest compatible versions",
437
- builder: (yargs$1) => yargs$1,
438
- handler: async () => {
439
- intro(getTitle());
440
- try {
441
- const updates = await detectUpdatesNeeded();
442
- if (updates.length === 0) {
443
- log.success("All adamantite dependencies are already up to date!");
444
- outro("💠 No updates needed");
445
- return;
446
- }
447
- if (!await confirmUpdate(updates)) {
448
- outro("💠 Update cancelled");
449
- return;
450
- }
451
- await updateDependencies(updates);
452
- outro("💠 Dependencies updated successfully!");
453
- } catch (error) {
454
- handleCommandError(error);
455
- }
456
- }
457
- });
458
-
459
- //#endregion
460
- //#region src/version.ts
461
- function getPackageVersion() {
462
- return JSON.parse(readFileSync(join(process.cwd(), "package.json"), "utf-8")).version;
463
- }
464
- const version = getPackageVersion();
465
- var version_default = version;
466
-
467
- //#endregion
468
- //#region src/index.ts
469
- yargs(hideBin(process.argv)).scriptName("adamantite").version(version_default).command(check_default).command(ci_default).command(fix_default).command(init_default).command(monorepo_default).command(update_default).demandCommand(1).strict().help().parse();
470
-
471
- //#endregion
472
- export { };
File without changes