@famgia/omnify-cli 0.0.5 → 0.0.7

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
@@ -1,14 +1,159 @@
1
- #!/usr/bin/env node
2
-
3
- // src/index.ts
4
- import { existsSync as existsSync4 } from "fs";
5
- import { resolve as resolve6 } from "path";
6
- import { Command } from "commander";
7
- import { OmnifyError as OmnifyError5 } from "@famgia/omnify-core";
1
+ // src/config/loader.ts
2
+ import { existsSync } from "fs";
3
+ import { resolve, dirname } from "path";
4
+ import { createJiti } from "jiti";
5
+ import { configError, configNotFoundError } from "@famgia/omnify-core";
6
+ var CONFIG_FILES = [
7
+ "omnify.config.ts",
8
+ "omnify.config.js",
9
+ "omnify.config.mjs",
10
+ "omnify.config.cjs"
11
+ ];
12
+ function findConfigFile(startDir) {
13
+ const cwd = resolve(startDir);
14
+ for (const filename of CONFIG_FILES) {
15
+ const configPath = resolve(cwd, filename);
16
+ if (existsSync(configPath)) {
17
+ return configPath;
18
+ }
19
+ }
20
+ return null;
21
+ }
22
+ async function loadConfigFile(configPath) {
23
+ const jiti = createJiti(configPath, {
24
+ interopDefault: true,
25
+ moduleCache: false
26
+ });
27
+ try {
28
+ const module = await jiti.import(configPath);
29
+ const config = module;
30
+ if ("default" in config) {
31
+ return config.default;
32
+ }
33
+ return config;
34
+ } catch (error) {
35
+ const message = error instanceof Error ? error.message : String(error);
36
+ throw configError(
37
+ `Failed to load config file: ${message}. Check your omnify.config.ts for syntax errors.`,
38
+ "E002"
39
+ );
40
+ }
41
+ }
42
+ async function resolvePlugins(plugins, configPath) {
43
+ if (!plugins || plugins.length === 0) {
44
+ return [];
45
+ }
46
+ const resolved = [];
47
+ const configDir = configPath ? dirname(configPath) : process.cwd();
48
+ for (const plugin of plugins) {
49
+ if (typeof plugin === "string") {
50
+ const jiti = createJiti(configDir, {
51
+ interopDefault: true,
52
+ moduleCache: false
53
+ });
54
+ try {
55
+ const module = await jiti.import(plugin);
56
+ const loadedPlugin = module.default ?? module;
57
+ resolved.push(loadedPlugin);
58
+ } catch (error) {
59
+ const message = error instanceof Error ? error.message : String(error);
60
+ throw configError(
61
+ `Failed to load plugin '${plugin}': ${message}. Ensure the plugin is installed: npm install ${plugin}`,
62
+ "E301"
63
+ );
64
+ }
65
+ } else {
66
+ resolved.push(plugin);
67
+ }
68
+ }
69
+ return resolved;
70
+ }
71
+ async function resolveConfig(userConfig, configPath) {
72
+ const plugins = await resolvePlugins(userConfig.plugins, configPath);
73
+ const databaseConfig = {
74
+ driver: userConfig.database.driver,
75
+ enableFieldComments: userConfig.database.enableFieldComments ?? false
76
+ };
77
+ const database = userConfig.database.devUrl !== void 0 ? { ...databaseConfig, devUrl: userConfig.database.devUrl } : databaseConfig;
78
+ const laravelConfig = {
79
+ migrationsPath: userConfig.output?.laravel?.migrationsPath ?? "database/migrations"
80
+ };
81
+ const laravel = buildLaravelConfig(laravelConfig, userConfig.output?.laravel);
82
+ const typescript = {
83
+ path: userConfig.output?.typescript?.path ?? "types",
84
+ singleFile: userConfig.output?.typescript?.singleFile ?? true,
85
+ generateEnums: userConfig.output?.typescript?.generateEnums ?? true,
86
+ generateRelationships: userConfig.output?.typescript?.generateRelationships ?? true
87
+ };
88
+ const result = {
89
+ schemasDir: userConfig.schemasDir ?? "./schemas",
90
+ database,
91
+ output: {
92
+ laravel,
93
+ typescript
94
+ },
95
+ plugins,
96
+ verbose: userConfig.verbose ?? false,
97
+ lockFilePath: userConfig.lockFilePath ?? ".omnify.lock"
98
+ };
99
+ return result;
100
+ }
101
+ function buildLaravelConfig(base, userLaravel) {
102
+ const config = { ...base };
103
+ if (userLaravel?.modelsPath !== void 0) {
104
+ config.modelsPath = userLaravel.modelsPath;
105
+ }
106
+ if (userLaravel?.modelsNamespace !== void 0) {
107
+ config.modelsNamespace = userLaravel.modelsNamespace;
108
+ }
109
+ if (userLaravel?.factoriesPath !== void 0) {
110
+ config.factoriesPath = userLaravel.factoriesPath;
111
+ }
112
+ if (userLaravel?.enumsPath !== void 0) {
113
+ config.enumsPath = userLaravel.enumsPath;
114
+ }
115
+ if (userLaravel?.enumsNamespace !== void 0) {
116
+ config.enumsNamespace = userLaravel.enumsNamespace;
117
+ }
118
+ return config;
119
+ }
120
+ function validateConfig(config, rootDir) {
121
+ const schemaPath = resolve(rootDir, config.schemasDir);
122
+ if (!existsSync(schemaPath)) {
123
+ throw configError(
124
+ `Schema directory not found: ${schemaPath}. Create the '${config.schemasDir}' directory or update schemasDir in config.`,
125
+ "E002"
126
+ );
127
+ }
128
+ }
129
+ function requireDevUrl(config) {
130
+ if (!config.database.devUrl) {
131
+ throw configError(
132
+ `database.devUrl is required for diff and generate operations. Add devUrl to your database config, e.g., "mysql://root@localhost:3306/omnify_dev"`,
133
+ "E003"
134
+ );
135
+ }
136
+ }
137
+ async function loadConfig(startDir = process.cwd()) {
138
+ const cwd = resolve(startDir);
139
+ const configPath = findConfigFile(cwd);
140
+ if (configPath) {
141
+ const userConfig = await loadConfigFile(configPath);
142
+ const config = await resolveConfig(userConfig, configPath);
143
+ return {
144
+ config,
145
+ configPath
146
+ };
147
+ }
148
+ throw configNotFoundError(resolve(cwd, "omnify.config.ts"));
149
+ }
150
+ function defineConfig(config) {
151
+ return config;
152
+ }
8
153
 
9
154
  // src/commands/init.ts
10
- import { existsSync, mkdirSync, writeFileSync } from "fs";
11
- import { resolve } from "path";
155
+ import { existsSync as existsSync2, mkdirSync, writeFileSync } from "fs";
156
+ import { resolve as resolve2 } from "path";
12
157
  import { select, confirm, input } from "@inquirer/prompts";
13
158
 
14
159
  // src/output/logger.ts
@@ -222,8 +367,8 @@ async function runInit(options) {
222
367
  const cwd = process.cwd();
223
368
  logger.header("Omnify Project Setup");
224
369
  logger.newline();
225
- const configPath2 = resolve(cwd, "omnify.config.ts");
226
- if (existsSync(configPath2) && !options.force) {
370
+ const configPath = resolve2(cwd, "omnify.config.ts");
371
+ if (existsSync2(configPath) && !options.force) {
227
372
  logger.warn("omnify.config.ts already exists. Use --force to overwrite.");
228
373
  return;
229
374
  }
@@ -299,18 +444,18 @@ async function runInit(options) {
299
444
  }
300
445
  logger.newline();
301
446
  logger.step("Creating project files...");
302
- const schemasDir = resolve(cwd, config.schemasDir);
303
- if (!existsSync(schemasDir)) {
447
+ const schemasDir = resolve2(cwd, config.schemasDir);
448
+ if (!existsSync2(schemasDir)) {
304
449
  mkdirSync(schemasDir, { recursive: true });
305
450
  logger.debug(`Created ${config.schemasDir}/ directory`);
306
451
  }
307
- const examplePath = resolve(schemasDir, "User.yaml");
308
- if (!existsSync(examplePath) || options.force) {
452
+ const examplePath = resolve2(schemasDir, "User.yaml");
453
+ if (!existsSync2(examplePath) || options.force) {
309
454
  writeFileSync(examplePath, EXAMPLE_SCHEMA);
310
455
  logger.debug("Created example schema: User.yaml");
311
456
  }
312
457
  const configContent = generateConfig(config);
313
- writeFileSync(configPath2, configContent);
458
+ writeFileSync(configPath, configContent);
314
459
  logger.debug("Created omnify.config.ts");
315
460
  logger.newline();
316
461
  logger.success("Project initialized!");
@@ -337,8 +482,8 @@ async function runInit(options) {
337
482
  logger.info(" npx omnify generate");
338
483
  logger.newline();
339
484
  }
340
- function registerInitCommand(program2) {
341
- program2.command("init").description("Initialize a new omnify project").option("-f, --force", "Overwrite existing files").option("-y, --yes", "Use default configuration (skip prompts)").action(async (options) => {
485
+ function registerInitCommand(program) {
486
+ program.command("init").description("Initialize a new omnify project").option("-f, --force", "Overwrite existing files").option("-y, --yes", "Use default configuration (skip prompts)").action(async (options) => {
342
487
  try {
343
488
  await runInit(options);
344
489
  } catch (error) {
@@ -358,169 +503,14 @@ function registerInitCommand(program2) {
358
503
  // src/commands/validate.ts
359
504
  import { resolve as resolve3, dirname as dirname2 } from "path";
360
505
  import { loadSchemas, validateSchemas, OmnifyError as OmnifyError2 } from "@famgia/omnify-core";
361
-
362
- // src/config/loader.ts
363
- import { existsSync as existsSync2 } from "fs";
364
- import { resolve as resolve2, dirname } from "path";
365
- import { createJiti } from "jiti";
366
- import { configError, configNotFoundError } from "@famgia/omnify-core";
367
- var CONFIG_FILES = [
368
- "omnify.config.ts",
369
- "omnify.config.js",
370
- "omnify.config.mjs",
371
- "omnify.config.cjs"
372
- ];
373
- function findConfigFile(startDir) {
374
- const cwd = resolve2(startDir);
375
- for (const filename of CONFIG_FILES) {
376
- const configPath2 = resolve2(cwd, filename);
377
- if (existsSync2(configPath2)) {
378
- return configPath2;
379
- }
380
- }
381
- return null;
382
- }
383
- async function loadConfigFile(configPath2) {
384
- const jiti = createJiti(configPath2, {
385
- interopDefault: true,
386
- moduleCache: false
387
- });
388
- try {
389
- const module = await jiti.import(configPath2);
390
- const config = module;
391
- if ("default" in config) {
392
- return config.default;
393
- }
394
- return config;
395
- } catch (error) {
396
- const message = error instanceof Error ? error.message : String(error);
397
- throw configError(
398
- `Failed to load config file: ${message}. Check your omnify.config.ts for syntax errors.`,
399
- "E002"
400
- );
401
- }
402
- }
403
- async function resolvePlugins(plugins, configPath2) {
404
- if (!plugins || plugins.length === 0) {
405
- return [];
406
- }
407
- const resolved = [];
408
- const configDir = configPath2 ? dirname(configPath2) : process.cwd();
409
- for (const plugin of plugins) {
410
- if (typeof plugin === "string") {
411
- const jiti = createJiti(configDir, {
412
- interopDefault: true,
413
- moduleCache: false
414
- });
415
- try {
416
- const module = await jiti.import(plugin);
417
- const loadedPlugin = module.default ?? module;
418
- resolved.push(loadedPlugin);
419
- } catch (error) {
420
- const message = error instanceof Error ? error.message : String(error);
421
- throw configError(
422
- `Failed to load plugin '${plugin}': ${message}. Ensure the plugin is installed: npm install ${plugin}`,
423
- "E301"
424
- );
425
- }
426
- } else {
427
- resolved.push(plugin);
428
- }
429
- }
430
- return resolved;
431
- }
432
- async function resolveConfig(userConfig, configPath2) {
433
- const plugins = await resolvePlugins(userConfig.plugins, configPath2);
434
- const databaseConfig = {
435
- driver: userConfig.database.driver,
436
- enableFieldComments: userConfig.database.enableFieldComments ?? false
437
- };
438
- const database = userConfig.database.devUrl !== void 0 ? { ...databaseConfig, devUrl: userConfig.database.devUrl } : databaseConfig;
439
- const laravelConfig = {
440
- migrationsPath: userConfig.output?.laravel?.migrationsPath ?? "database/migrations"
441
- };
442
- const laravel = buildLaravelConfig(laravelConfig, userConfig.output?.laravel);
443
- const typescript = {
444
- path: userConfig.output?.typescript?.path ?? "types",
445
- singleFile: userConfig.output?.typescript?.singleFile ?? true,
446
- generateEnums: userConfig.output?.typescript?.generateEnums ?? true,
447
- generateRelationships: userConfig.output?.typescript?.generateRelationships ?? true
448
- };
449
- const result = {
450
- schemasDir: userConfig.schemasDir ?? "./schemas",
451
- database,
452
- output: {
453
- laravel,
454
- typescript
455
- },
456
- plugins,
457
- verbose: userConfig.verbose ?? false,
458
- lockFilePath: userConfig.lockFilePath ?? ".omnify.lock"
459
- };
460
- return result;
461
- }
462
- function buildLaravelConfig(base, userLaravel) {
463
- const config = { ...base };
464
- if (userLaravel?.modelsPath !== void 0) {
465
- config.modelsPath = userLaravel.modelsPath;
466
- }
467
- if (userLaravel?.modelsNamespace !== void 0) {
468
- config.modelsNamespace = userLaravel.modelsNamespace;
469
- }
470
- if (userLaravel?.factoriesPath !== void 0) {
471
- config.factoriesPath = userLaravel.factoriesPath;
472
- }
473
- if (userLaravel?.enumsPath !== void 0) {
474
- config.enumsPath = userLaravel.enumsPath;
475
- }
476
- if (userLaravel?.enumsNamespace !== void 0) {
477
- config.enumsNamespace = userLaravel.enumsNamespace;
478
- }
479
- return config;
480
- }
481
- function validateConfig(config, rootDir) {
482
- const schemaPath = resolve2(rootDir, config.schemasDir);
483
- if (!existsSync2(schemaPath)) {
484
- throw configError(
485
- `Schema directory not found: ${schemaPath}. Create the '${config.schemasDir}' directory or update schemasDir in config.`,
486
- "E002"
487
- );
488
- }
489
- }
490
- function requireDevUrl(config) {
491
- if (!config.database.devUrl) {
492
- throw configError(
493
- `database.devUrl is required for diff and generate operations. Add devUrl to your database config, e.g., "mysql://root@localhost:3306/omnify_dev"`,
494
- "E003"
495
- );
496
- }
497
- }
498
- async function loadConfig(startDir = process.cwd()) {
499
- const cwd = resolve2(startDir);
500
- const configPath2 = findConfigFile(cwd);
501
- if (configPath2) {
502
- const userConfig = await loadConfigFile(configPath2);
503
- const config = await resolveConfig(userConfig, configPath2);
504
- return {
505
- config,
506
- configPath: configPath2
507
- };
508
- }
509
- throw configNotFoundError(resolve2(cwd, "omnify.config.ts"));
510
- }
511
- function defineConfig(config) {
512
- return config;
513
- }
514
-
515
- // src/commands/validate.ts
516
506
  async function runValidate(options) {
517
507
  logger.setVerbose(options.verbose ?? false);
518
508
  logger.header("Validating Schemas");
519
509
  logger.debug("Loading configuration...");
520
510
  logger.timing("Config load start");
521
- const { config, configPath: configPath2 } = await loadConfig();
511
+ const { config, configPath } = await loadConfig();
522
512
  logger.timing("Config loaded");
523
- const rootDir = configPath2 ? dirname2(configPath2) : process.cwd();
513
+ const rootDir = configPath ? dirname2(configPath) : process.cwd();
524
514
  validateConfig(config, rootDir);
525
515
  const schemaPath = resolve3(rootDir, config.schemasDir);
526
516
  logger.step(`Loading schemas from ${schemaPath}`);
@@ -550,8 +540,8 @@ async function runValidate(options) {
550
540
  process.exit(2);
551
541
  }
552
542
  }
553
- function registerValidateCommand(program2) {
554
- program2.command("validate").description("Validate schema files").option("-v, --verbose", "Show detailed output").action(async (options) => {
543
+ function registerValidateCommand(program) {
544
+ program.command("validate").description("Validate schema files").option("-v, --verbose", "Show detailed output").action(async (options) => {
555
545
  try {
556
546
  await runValidate(options);
557
547
  } catch (error) {
@@ -602,8 +592,8 @@ async function runDiff(options) {
602
592
  logger.setVerbose(options.verbose ?? false);
603
593
  logger.header("Checking for Schema Changes");
604
594
  logger.debug("Loading configuration...");
605
- const { config, configPath: configPath2 } = await loadConfig();
606
- const rootDir = configPath2 ? dirname3(configPath2) : process.cwd();
595
+ const { config, configPath } = await loadConfig();
596
+ const rootDir = configPath ? dirname3(configPath) : process.cwd();
607
597
  validateConfig(config, rootDir);
608
598
  requireDevUrl(config);
609
599
  const schemaPath = resolve4(rootDir, config.schemasDir);
@@ -654,8 +644,8 @@ async function runDiff(options) {
654
644
  logger.newline();
655
645
  logger.info('Run "omnify generate" to create migrations');
656
646
  }
657
- function registerDiffCommand(program2) {
658
- program2.command("diff").description("Show pending schema changes").option("-v, --verbose", "Show detailed output").option("--check", "Exit with code 1 if changes exist (for CI)").action(async (options) => {
647
+ function registerDiffCommand(program) {
648
+ program.command("diff").description("Show pending schema changes").option("-v, --verbose", "Show detailed output").option("--check", "Exit with code 1 if changes exist (for CI)").action(async (options) => {
659
649
  try {
660
650
  await runDiff(options);
661
651
  } catch (error) {
@@ -680,7 +670,13 @@ import {
680
670
  OmnifyError as OmnifyError4,
681
671
  PluginManager
682
672
  } from "@famgia/omnify-core";
683
- import { updateLockFile } from "@famgia/omnify-atlas";
673
+ import {
674
+ writeLockFile,
675
+ readLockFile,
676
+ updateLockFile,
677
+ buildSchemaHashes,
678
+ compareSchemas
679
+ } from "@famgia/omnify-atlas";
684
680
  import { generateMigrations, generateTypeScript } from "@famgia/omnify-laravel";
685
681
  function hasPluginGenerators(plugins) {
686
682
  return plugins.some((p) => p.generators && p.generators.length > 0);
@@ -728,7 +724,7 @@ async function runPluginGeneration(plugins, schemas, rootDir, verbose) {
728
724
  function runDirectGeneration(schemas, config, rootDir, options) {
729
725
  let migrationsGenerated = 0;
730
726
  let typesGenerated = 0;
731
- if (!options.typesOnly) {
727
+ if (!options.typesOnly && config.output.laravel) {
732
728
  logger.step("Generating Laravel migrations...");
733
729
  const migrationsDir = resolve5(rootDir, config.output.laravel.migrationsPath);
734
730
  if (!existsSync3(migrationsDir)) {
@@ -744,7 +740,7 @@ function runDirectGeneration(schemas, config, rootDir, options) {
744
740
  }
745
741
  logger.success(`Generated ${migrationsGenerated} migration(s)`);
746
742
  }
747
- if (!options.migrationsOnly) {
743
+ if (!options.migrationsOnly && config.output.typescript) {
748
744
  logger.step("Generating TypeScript types...");
749
745
  const typesDir = resolve5(rootDir, config.output.typescript.path);
750
746
  if (!existsSync3(typesDir)) {
@@ -768,10 +764,9 @@ async function runGenerate(options) {
768
764
  logger.setVerbose(options.verbose ?? false);
769
765
  logger.header("Generating Outputs");
770
766
  logger.debug("Loading configuration...");
771
- const { config, configPath: configPath2 } = await loadConfig();
772
- const rootDir = configPath2 ? dirname4(configPath2) : process.cwd();
767
+ const { config, configPath } = await loadConfig();
768
+ const rootDir = configPath ? dirname4(configPath) : process.cwd();
773
769
  validateConfig(config, rootDir);
774
- requireDevUrl(config);
775
770
  const schemaPath = resolve5(rootDir, config.schemasDir);
776
771
  logger.step(`Loading schemas from ${schemaPath}`);
777
772
  const schemas = await loadSchemas3(schemaPath);
@@ -793,17 +788,19 @@ async function runGenerate(options) {
793
788
  }
794
789
  logger.step("Checking for changes...");
795
790
  const lockPath = resolve5(rootDir, config.lockFilePath);
796
- const diffResult = await runDiffOperation({
797
- schemas,
798
- devUrl: config.database.devUrl,
799
- lockFilePath: lockPath,
800
- driver: config.database.driver,
801
- workDir: rootDir
802
- });
803
- if (!diffResult.hasChanges && !options.force) {
791
+ const existingLock = await readLockFile(lockPath);
792
+ const currentHashes = await buildSchemaHashes(schemas);
793
+ const comparison = compareSchemas(currentHashes, existingLock);
794
+ if (!comparison.hasChanges && !options.force) {
804
795
  logger.success("No changes to generate");
805
796
  return;
806
797
  }
798
+ if (comparison.hasChanges) {
799
+ logger.debug(`Detected ${comparison.changes.length} change(s)`);
800
+ for (const change of comparison.changes) {
801
+ logger.debug(` ${change.changeType}: ${change.schemaName}`);
802
+ }
803
+ }
807
804
  let migrationsGenerated = 0;
808
805
  let typesGenerated = 0;
809
806
  const usePlugins = hasPluginGenerators(config.plugins);
@@ -832,19 +829,20 @@ async function runGenerate(options) {
832
829
  typesGenerated = counts.types;
833
830
  }
834
831
  logger.step("Updating lock file...");
835
- await updateLockFile(lockPath, schemas);
832
+ const newLockFile = updateLockFile(existingLock, currentHashes, config.database.driver);
833
+ await writeLockFile(lockPath, newLockFile);
836
834
  logger.debug(`Updated: ${config.lockFilePath}`);
837
835
  logger.newline();
838
836
  logger.success("Generation complete!");
839
- if (migrationsGenerated > 0) {
837
+ if (migrationsGenerated > 0 && config.output.laravel) {
840
838
  logger.info(` Migrations: ${config.output.laravel.migrationsPath}/`);
841
839
  }
842
- if (typesGenerated > 0) {
840
+ if (typesGenerated > 0 && config.output.typescript) {
843
841
  logger.info(` Types: ${config.output.typescript.path}/`);
844
842
  }
845
843
  }
846
- function registerGenerateCommand(program2) {
847
- program2.command("generate").description("Generate Laravel migrations and TypeScript types").option("-v, --verbose", "Show detailed output").option("--migrations-only", "Only generate migrations").option("--types-only", "Only generate TypeScript types").option("-f, --force", "Generate even if no changes detected").action(async (options) => {
844
+ function registerGenerateCommand(program) {
845
+ program.command("generate").description("Generate Laravel migrations and TypeScript types").option("-v, --verbose", "Show detailed output").option("--migrations-only", "Only generate migrations").option("--types-only", "Only generate TypeScript types").option("-f, --force", "Generate even if no changes detected").action(async (options) => {
848
846
  try {
849
847
  await runGenerate(options);
850
848
  } catch (error) {
@@ -859,57 +857,14 @@ function registerGenerateCommand(program2) {
859
857
  }
860
858
  });
861
859
  }
862
-
863
- // src/index.ts
864
- var VERSION = "0.0.1";
865
- var program = new Command();
866
- program.name("omnify").description("Schema-first database migrations for Laravel and TypeScript").version(VERSION);
867
- registerInitCommand(program);
868
- registerValidateCommand(program);
869
- registerDiffCommand(program);
870
- registerGenerateCommand(program);
871
- process.on("uncaughtException", (error) => {
872
- if (error instanceof OmnifyError5) {
873
- logger.formatError(error);
874
- process.exit(logger.getExitCode(error));
875
- } else {
876
- logger.error(error.message);
877
- process.exit(1);
878
- }
879
- });
880
- process.on("unhandledRejection", (reason) => {
881
- if (reason instanceof OmnifyError5) {
882
- logger.formatError(reason);
883
- process.exit(logger.getExitCode(reason));
884
- } else if (reason instanceof Error) {
885
- logger.error(reason.message);
886
- } else {
887
- logger.error(String(reason));
888
- }
889
- process.exit(1);
890
- });
891
- var args = process.argv.slice(2);
892
- var firstArg = args[0];
893
- var hasCommand = firstArg !== void 0 && !firstArg.startsWith("-");
894
- var configPath = resolve6(process.cwd(), "omnify.config.ts");
895
- var hasConfig = existsSync4(configPath);
896
- if (!hasCommand && !hasConfig) {
897
- runInit({}).catch((error) => {
898
- if (error instanceof Error) {
899
- if (error.message.includes("User force closed")) {
900
- logger.newline();
901
- logger.info("Setup cancelled.");
902
- process.exit(0);
903
- }
904
- logger.error(error.message);
905
- }
906
- process.exit(1);
907
- });
908
- } else {
909
- program.parse();
910
- }
911
860
  export {
912
861
  defineConfig,
913
- loadConfig
862
+ loadConfig,
863
+ logger,
864
+ registerDiffCommand,
865
+ registerGenerateCommand,
866
+ registerInitCommand,
867
+ registerValidateCommand,
868
+ runInit
914
869
  };
915
870
  //# sourceMappingURL=index.js.map