@famgia/omnify-cli 0.0.5 → 0.0.6

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.cjs CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env node
2
1
  "use strict";
3
2
  var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
@@ -32,22 +31,177 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
32
31
  var index_exports = {};
33
32
  __export(index_exports, {
34
33
  defineConfig: () => defineConfig,
35
- loadConfig: () => loadConfig
34
+ loadConfig: () => loadConfig,
35
+ logger: () => logger,
36
+ registerDiffCommand: () => registerDiffCommand,
37
+ registerGenerateCommand: () => registerGenerateCommand,
38
+ registerInitCommand: () => registerInitCommand,
39
+ registerValidateCommand: () => registerValidateCommand,
40
+ runInit: () => runInit
36
41
  });
37
42
  module.exports = __toCommonJS(index_exports);
38
- var import_node_fs4 = require("fs");
39
- var import_node_path6 = require("path");
40
- var import_commander = require("commander");
41
- var import_omnify_core6 = require("@famgia/omnify-core");
42
43
 
43
- // src/commands/init.ts
44
+ // src/config/loader.ts
44
45
  var import_node_fs = require("fs");
45
46
  var import_node_path = require("path");
47
+ var import_jiti = require("jiti");
48
+ var import_omnify_core = require("@famgia/omnify-core");
49
+ var CONFIG_FILES = [
50
+ "omnify.config.ts",
51
+ "omnify.config.js",
52
+ "omnify.config.mjs",
53
+ "omnify.config.cjs"
54
+ ];
55
+ function findConfigFile(startDir) {
56
+ const cwd = (0, import_node_path.resolve)(startDir);
57
+ for (const filename of CONFIG_FILES) {
58
+ const configPath = (0, import_node_path.resolve)(cwd, filename);
59
+ if ((0, import_node_fs.existsSync)(configPath)) {
60
+ return configPath;
61
+ }
62
+ }
63
+ return null;
64
+ }
65
+ async function loadConfigFile(configPath) {
66
+ const jiti = (0, import_jiti.createJiti)(configPath, {
67
+ interopDefault: true,
68
+ moduleCache: false
69
+ });
70
+ try {
71
+ const module2 = await jiti.import(configPath);
72
+ const config = module2;
73
+ if ("default" in config) {
74
+ return config.default;
75
+ }
76
+ return config;
77
+ } catch (error) {
78
+ const message = error instanceof Error ? error.message : String(error);
79
+ throw (0, import_omnify_core.configError)(
80
+ `Failed to load config file: ${message}. Check your omnify.config.ts for syntax errors.`,
81
+ "E002"
82
+ );
83
+ }
84
+ }
85
+ async function resolvePlugins(plugins, configPath) {
86
+ if (!plugins || plugins.length === 0) {
87
+ return [];
88
+ }
89
+ const resolved = [];
90
+ const configDir = configPath ? (0, import_node_path.dirname)(configPath) : process.cwd();
91
+ for (const plugin of plugins) {
92
+ if (typeof plugin === "string") {
93
+ const jiti = (0, import_jiti.createJiti)(configDir, {
94
+ interopDefault: true,
95
+ moduleCache: false
96
+ });
97
+ try {
98
+ const module2 = await jiti.import(plugin);
99
+ const loadedPlugin = module2.default ?? module2;
100
+ resolved.push(loadedPlugin);
101
+ } catch (error) {
102
+ const message = error instanceof Error ? error.message : String(error);
103
+ throw (0, import_omnify_core.configError)(
104
+ `Failed to load plugin '${plugin}': ${message}. Ensure the plugin is installed: npm install ${plugin}`,
105
+ "E301"
106
+ );
107
+ }
108
+ } else {
109
+ resolved.push(plugin);
110
+ }
111
+ }
112
+ return resolved;
113
+ }
114
+ async function resolveConfig(userConfig, configPath) {
115
+ const plugins = await resolvePlugins(userConfig.plugins, configPath);
116
+ const databaseConfig = {
117
+ driver: userConfig.database.driver,
118
+ enableFieldComments: userConfig.database.enableFieldComments ?? false
119
+ };
120
+ const database = userConfig.database.devUrl !== void 0 ? { ...databaseConfig, devUrl: userConfig.database.devUrl } : databaseConfig;
121
+ const laravelConfig = {
122
+ migrationsPath: userConfig.output?.laravel?.migrationsPath ?? "database/migrations"
123
+ };
124
+ const laravel = buildLaravelConfig(laravelConfig, userConfig.output?.laravel);
125
+ const typescript = {
126
+ path: userConfig.output?.typescript?.path ?? "types",
127
+ singleFile: userConfig.output?.typescript?.singleFile ?? true,
128
+ generateEnums: userConfig.output?.typescript?.generateEnums ?? true,
129
+ generateRelationships: userConfig.output?.typescript?.generateRelationships ?? true
130
+ };
131
+ const result = {
132
+ schemasDir: userConfig.schemasDir ?? "./schemas",
133
+ database,
134
+ output: {
135
+ laravel,
136
+ typescript
137
+ },
138
+ plugins,
139
+ verbose: userConfig.verbose ?? false,
140
+ lockFilePath: userConfig.lockFilePath ?? ".omnify.lock"
141
+ };
142
+ return result;
143
+ }
144
+ function buildLaravelConfig(base, userLaravel) {
145
+ const config = { ...base };
146
+ if (userLaravel?.modelsPath !== void 0) {
147
+ config.modelsPath = userLaravel.modelsPath;
148
+ }
149
+ if (userLaravel?.modelsNamespace !== void 0) {
150
+ config.modelsNamespace = userLaravel.modelsNamespace;
151
+ }
152
+ if (userLaravel?.factoriesPath !== void 0) {
153
+ config.factoriesPath = userLaravel.factoriesPath;
154
+ }
155
+ if (userLaravel?.enumsPath !== void 0) {
156
+ config.enumsPath = userLaravel.enumsPath;
157
+ }
158
+ if (userLaravel?.enumsNamespace !== void 0) {
159
+ config.enumsNamespace = userLaravel.enumsNamespace;
160
+ }
161
+ return config;
162
+ }
163
+ function validateConfig(config, rootDir) {
164
+ const schemaPath = (0, import_node_path.resolve)(rootDir, config.schemasDir);
165
+ if (!(0, import_node_fs.existsSync)(schemaPath)) {
166
+ throw (0, import_omnify_core.configError)(
167
+ `Schema directory not found: ${schemaPath}. Create the '${config.schemasDir}' directory or update schemasDir in config.`,
168
+ "E002"
169
+ );
170
+ }
171
+ }
172
+ function requireDevUrl(config) {
173
+ if (!config.database.devUrl) {
174
+ throw (0, import_omnify_core.configError)(
175
+ `database.devUrl is required for diff and generate operations. Add devUrl to your database config, e.g., "mysql://root@localhost:3306/omnify_dev"`,
176
+ "E003"
177
+ );
178
+ }
179
+ }
180
+ async function loadConfig(startDir = process.cwd()) {
181
+ const cwd = (0, import_node_path.resolve)(startDir);
182
+ const configPath = findConfigFile(cwd);
183
+ if (configPath) {
184
+ const userConfig = await loadConfigFile(configPath);
185
+ const config = await resolveConfig(userConfig, configPath);
186
+ return {
187
+ config,
188
+ configPath
189
+ };
190
+ }
191
+ throw (0, import_omnify_core.configNotFoundError)((0, import_node_path.resolve)(cwd, "omnify.config.ts"));
192
+ }
193
+ function defineConfig(config) {
194
+ return config;
195
+ }
196
+
197
+ // src/commands/init.ts
198
+ var import_node_fs2 = require("fs");
199
+ var import_node_path2 = require("path");
46
200
  var import_prompts = require("@inquirer/prompts");
47
201
 
48
202
  // src/output/logger.ts
49
203
  var import_picocolors = __toESM(require("picocolors"), 1);
50
- var import_omnify_core = require("@famgia/omnify-core");
204
+ var import_omnify_core2 = require("@famgia/omnify-core");
51
205
  var Logger = class {
52
206
  _verbose;
53
207
  _quiet;
@@ -156,14 +310,14 @@ var Logger = class {
156
310
  * Format and log an OmnifyError.
157
311
  */
158
312
  formatError(error) {
159
- const formatted = (0, import_omnify_core.formatError)(error, { color: true });
313
+ const formatted = (0, import_omnify_core2.formatError)(error, { color: true });
160
314
  console.error(formatted);
161
315
  }
162
316
  /**
163
317
  * Get exit code for an error.
164
318
  */
165
319
  getExitCode(error) {
166
- return (0, import_omnify_core.getExitCode)(error);
320
+ return (0, import_omnify_core2.getExitCode)(error);
167
321
  }
168
322
  };
169
323
  var logger = new Logger();
@@ -256,8 +410,8 @@ async function runInit(options) {
256
410
  const cwd = process.cwd();
257
411
  logger.header("Omnify Project Setup");
258
412
  logger.newline();
259
- const configPath2 = (0, import_node_path.resolve)(cwd, "omnify.config.ts");
260
- if ((0, import_node_fs.existsSync)(configPath2) && !options.force) {
413
+ const configPath = (0, import_node_path2.resolve)(cwd, "omnify.config.ts");
414
+ if ((0, import_node_fs2.existsSync)(configPath) && !options.force) {
261
415
  logger.warn("omnify.config.ts already exists. Use --force to overwrite.");
262
416
  return;
263
417
  }
@@ -333,18 +487,18 @@ async function runInit(options) {
333
487
  }
334
488
  logger.newline();
335
489
  logger.step("Creating project files...");
336
- const schemasDir = (0, import_node_path.resolve)(cwd, config.schemasDir);
337
- if (!(0, import_node_fs.existsSync)(schemasDir)) {
338
- (0, import_node_fs.mkdirSync)(schemasDir, { recursive: true });
490
+ const schemasDir = (0, import_node_path2.resolve)(cwd, config.schemasDir);
491
+ if (!(0, import_node_fs2.existsSync)(schemasDir)) {
492
+ (0, import_node_fs2.mkdirSync)(schemasDir, { recursive: true });
339
493
  logger.debug(`Created ${config.schemasDir}/ directory`);
340
494
  }
341
- const examplePath = (0, import_node_path.resolve)(schemasDir, "User.yaml");
342
- if (!(0, import_node_fs.existsSync)(examplePath) || options.force) {
343
- (0, import_node_fs.writeFileSync)(examplePath, EXAMPLE_SCHEMA);
495
+ const examplePath = (0, import_node_path2.resolve)(schemasDir, "User.yaml");
496
+ if (!(0, import_node_fs2.existsSync)(examplePath) || options.force) {
497
+ (0, import_node_fs2.writeFileSync)(examplePath, EXAMPLE_SCHEMA);
344
498
  logger.debug("Created example schema: User.yaml");
345
499
  }
346
500
  const configContent = generateConfig(config);
347
- (0, import_node_fs.writeFileSync)(configPath2, configContent);
501
+ (0, import_node_fs2.writeFileSync)(configPath, configContent);
348
502
  logger.debug("Created omnify.config.ts");
349
503
  logger.newline();
350
504
  logger.success("Project initialized!");
@@ -371,8 +525,8 @@ async function runInit(options) {
371
525
  logger.info(" npx omnify generate");
372
526
  logger.newline();
373
527
  }
374
- function registerInitCommand(program2) {
375
- 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) => {
528
+ function registerInitCommand(program) {
529
+ 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) => {
376
530
  try {
377
531
  await runInit(options);
378
532
  } catch (error) {
@@ -392,169 +546,14 @@ function registerInitCommand(program2) {
392
546
  // src/commands/validate.ts
393
547
  var import_node_path3 = require("path");
394
548
  var import_omnify_core3 = require("@famgia/omnify-core");
395
-
396
- // src/config/loader.ts
397
- var import_node_fs2 = require("fs");
398
- var import_node_path2 = require("path");
399
- var import_jiti = require("jiti");
400
- var import_omnify_core2 = require("@famgia/omnify-core");
401
- var CONFIG_FILES = [
402
- "omnify.config.ts",
403
- "omnify.config.js",
404
- "omnify.config.mjs",
405
- "omnify.config.cjs"
406
- ];
407
- function findConfigFile(startDir) {
408
- const cwd = (0, import_node_path2.resolve)(startDir);
409
- for (const filename of CONFIG_FILES) {
410
- const configPath2 = (0, import_node_path2.resolve)(cwd, filename);
411
- if ((0, import_node_fs2.existsSync)(configPath2)) {
412
- return configPath2;
413
- }
414
- }
415
- return null;
416
- }
417
- async function loadConfigFile(configPath2) {
418
- const jiti = (0, import_jiti.createJiti)(configPath2, {
419
- interopDefault: true,
420
- moduleCache: false
421
- });
422
- try {
423
- const module2 = await jiti.import(configPath2);
424
- const config = module2;
425
- if ("default" in config) {
426
- return config.default;
427
- }
428
- return config;
429
- } catch (error) {
430
- const message = error instanceof Error ? error.message : String(error);
431
- throw (0, import_omnify_core2.configError)(
432
- `Failed to load config file: ${message}. Check your omnify.config.ts for syntax errors.`,
433
- "E002"
434
- );
435
- }
436
- }
437
- async function resolvePlugins(plugins, configPath2) {
438
- if (!plugins || plugins.length === 0) {
439
- return [];
440
- }
441
- const resolved = [];
442
- const configDir = configPath2 ? (0, import_node_path2.dirname)(configPath2) : process.cwd();
443
- for (const plugin of plugins) {
444
- if (typeof plugin === "string") {
445
- const jiti = (0, import_jiti.createJiti)(configDir, {
446
- interopDefault: true,
447
- moduleCache: false
448
- });
449
- try {
450
- const module2 = await jiti.import(plugin);
451
- const loadedPlugin = module2.default ?? module2;
452
- resolved.push(loadedPlugin);
453
- } catch (error) {
454
- const message = error instanceof Error ? error.message : String(error);
455
- throw (0, import_omnify_core2.configError)(
456
- `Failed to load plugin '${plugin}': ${message}. Ensure the plugin is installed: npm install ${plugin}`,
457
- "E301"
458
- );
459
- }
460
- } else {
461
- resolved.push(plugin);
462
- }
463
- }
464
- return resolved;
465
- }
466
- async function resolveConfig(userConfig, configPath2) {
467
- const plugins = await resolvePlugins(userConfig.plugins, configPath2);
468
- const databaseConfig = {
469
- driver: userConfig.database.driver,
470
- enableFieldComments: userConfig.database.enableFieldComments ?? false
471
- };
472
- const database = userConfig.database.devUrl !== void 0 ? { ...databaseConfig, devUrl: userConfig.database.devUrl } : databaseConfig;
473
- const laravelConfig = {
474
- migrationsPath: userConfig.output?.laravel?.migrationsPath ?? "database/migrations"
475
- };
476
- const laravel = buildLaravelConfig(laravelConfig, userConfig.output?.laravel);
477
- const typescript = {
478
- path: userConfig.output?.typescript?.path ?? "types",
479
- singleFile: userConfig.output?.typescript?.singleFile ?? true,
480
- generateEnums: userConfig.output?.typescript?.generateEnums ?? true,
481
- generateRelationships: userConfig.output?.typescript?.generateRelationships ?? true
482
- };
483
- const result = {
484
- schemasDir: userConfig.schemasDir ?? "./schemas",
485
- database,
486
- output: {
487
- laravel,
488
- typescript
489
- },
490
- plugins,
491
- verbose: userConfig.verbose ?? false,
492
- lockFilePath: userConfig.lockFilePath ?? ".omnify.lock"
493
- };
494
- return result;
495
- }
496
- function buildLaravelConfig(base, userLaravel) {
497
- const config = { ...base };
498
- if (userLaravel?.modelsPath !== void 0) {
499
- config.modelsPath = userLaravel.modelsPath;
500
- }
501
- if (userLaravel?.modelsNamespace !== void 0) {
502
- config.modelsNamespace = userLaravel.modelsNamespace;
503
- }
504
- if (userLaravel?.factoriesPath !== void 0) {
505
- config.factoriesPath = userLaravel.factoriesPath;
506
- }
507
- if (userLaravel?.enumsPath !== void 0) {
508
- config.enumsPath = userLaravel.enumsPath;
509
- }
510
- if (userLaravel?.enumsNamespace !== void 0) {
511
- config.enumsNamespace = userLaravel.enumsNamespace;
512
- }
513
- return config;
514
- }
515
- function validateConfig(config, rootDir) {
516
- const schemaPath = (0, import_node_path2.resolve)(rootDir, config.schemasDir);
517
- if (!(0, import_node_fs2.existsSync)(schemaPath)) {
518
- throw (0, import_omnify_core2.configError)(
519
- `Schema directory not found: ${schemaPath}. Create the '${config.schemasDir}' directory or update schemasDir in config.`,
520
- "E002"
521
- );
522
- }
523
- }
524
- function requireDevUrl(config) {
525
- if (!config.database.devUrl) {
526
- throw (0, import_omnify_core2.configError)(
527
- `database.devUrl is required for diff and generate operations. Add devUrl to your database config, e.g., "mysql://root@localhost:3306/omnify_dev"`,
528
- "E003"
529
- );
530
- }
531
- }
532
- async function loadConfig(startDir = process.cwd()) {
533
- const cwd = (0, import_node_path2.resolve)(startDir);
534
- const configPath2 = findConfigFile(cwd);
535
- if (configPath2) {
536
- const userConfig = await loadConfigFile(configPath2);
537
- const config = await resolveConfig(userConfig, configPath2);
538
- return {
539
- config,
540
- configPath: configPath2
541
- };
542
- }
543
- throw (0, import_omnify_core2.configNotFoundError)((0, import_node_path2.resolve)(cwd, "omnify.config.ts"));
544
- }
545
- function defineConfig(config) {
546
- return config;
547
- }
548
-
549
- // src/commands/validate.ts
550
549
  async function runValidate(options) {
551
550
  logger.setVerbose(options.verbose ?? false);
552
551
  logger.header("Validating Schemas");
553
552
  logger.debug("Loading configuration...");
554
553
  logger.timing("Config load start");
555
- const { config, configPath: configPath2 } = await loadConfig();
554
+ const { config, configPath } = await loadConfig();
556
555
  logger.timing("Config loaded");
557
- const rootDir = configPath2 ? (0, import_node_path3.dirname)(configPath2) : process.cwd();
556
+ const rootDir = configPath ? (0, import_node_path3.dirname)(configPath) : process.cwd();
558
557
  validateConfig(config, rootDir);
559
558
  const schemaPath = (0, import_node_path3.resolve)(rootDir, config.schemasDir);
560
559
  logger.step(`Loading schemas from ${schemaPath}`);
@@ -584,8 +583,8 @@ async function runValidate(options) {
584
583
  process.exit(2);
585
584
  }
586
585
  }
587
- function registerValidateCommand(program2) {
588
- program2.command("validate").description("Validate schema files").option("-v, --verbose", "Show detailed output").action(async (options) => {
586
+ function registerValidateCommand(program) {
587
+ program.command("validate").description("Validate schema files").option("-v, --verbose", "Show detailed output").action(async (options) => {
589
588
  try {
590
589
  await runValidate(options);
591
590
  } catch (error) {
@@ -633,8 +632,8 @@ async function runDiff(options) {
633
632
  logger.setVerbose(options.verbose ?? false);
634
633
  logger.header("Checking for Schema Changes");
635
634
  logger.debug("Loading configuration...");
636
- const { config, configPath: configPath2 } = await loadConfig();
637
- const rootDir = configPath2 ? (0, import_node_path4.dirname)(configPath2) : process.cwd();
635
+ const { config, configPath } = await loadConfig();
636
+ const rootDir = configPath ? (0, import_node_path4.dirname)(configPath) : process.cwd();
638
637
  validateConfig(config, rootDir);
639
638
  requireDevUrl(config);
640
639
  const schemaPath = (0, import_node_path4.resolve)(rootDir, config.schemasDir);
@@ -685,8 +684,8 @@ async function runDiff(options) {
685
684
  logger.newline();
686
685
  logger.info('Run "omnify generate" to create migrations');
687
686
  }
688
- function registerDiffCommand(program2) {
689
- 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) => {
687
+ function registerDiffCommand(program) {
688
+ 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) => {
690
689
  try {
691
690
  await runDiff(options);
692
691
  } catch (error) {
@@ -754,7 +753,7 @@ async function runPluginGeneration(plugins, schemas, rootDir, verbose) {
754
753
  function runDirectGeneration(schemas, config, rootDir, options) {
755
754
  let migrationsGenerated = 0;
756
755
  let typesGenerated = 0;
757
- if (!options.typesOnly) {
756
+ if (!options.typesOnly && config.output.laravel) {
758
757
  logger.step("Generating Laravel migrations...");
759
758
  const migrationsDir = (0, import_node_path5.resolve)(rootDir, config.output.laravel.migrationsPath);
760
759
  if (!(0, import_node_fs3.existsSync)(migrationsDir)) {
@@ -770,7 +769,7 @@ function runDirectGeneration(schemas, config, rootDir, options) {
770
769
  }
771
770
  logger.success(`Generated ${migrationsGenerated} migration(s)`);
772
771
  }
773
- if (!options.migrationsOnly) {
772
+ if (!options.migrationsOnly && config.output.typescript) {
774
773
  logger.step("Generating TypeScript types...");
775
774
  const typesDir = (0, import_node_path5.resolve)(rootDir, config.output.typescript.path);
776
775
  if (!(0, import_node_fs3.existsSync)(typesDir)) {
@@ -794,8 +793,8 @@ async function runGenerate(options) {
794
793
  logger.setVerbose(options.verbose ?? false);
795
794
  logger.header("Generating Outputs");
796
795
  logger.debug("Loading configuration...");
797
- const { config, configPath: configPath2 } = await loadConfig();
798
- const rootDir = configPath2 ? (0, import_node_path5.dirname)(configPath2) : process.cwd();
796
+ const { config, configPath } = await loadConfig();
797
+ const rootDir = configPath ? (0, import_node_path5.dirname)(configPath) : process.cwd();
799
798
  validateConfig(config, rootDir);
800
799
  requireDevUrl(config);
801
800
  const schemaPath = (0, import_node_path5.resolve)(rootDir, config.schemasDir);
@@ -858,19 +857,22 @@ async function runGenerate(options) {
858
857
  typesGenerated = counts.types;
859
858
  }
860
859
  logger.step("Updating lock file...");
861
- await (0, import_omnify_atlas2.updateLockFile)(lockPath, schemas);
860
+ const existingLock = await (0, import_omnify_atlas2.readLockFile)(lockPath);
861
+ const schemaHashes = await (0, import_omnify_atlas2.buildSchemaHashes)(schemas);
862
+ const newLockFile = (0, import_omnify_atlas2.updateLockFile)(existingLock, schemaHashes, config.database.driver);
863
+ await (0, import_omnify_atlas2.writeLockFile)(lockPath, newLockFile);
862
864
  logger.debug(`Updated: ${config.lockFilePath}`);
863
865
  logger.newline();
864
866
  logger.success("Generation complete!");
865
- if (migrationsGenerated > 0) {
867
+ if (migrationsGenerated > 0 && config.output.laravel) {
866
868
  logger.info(` Migrations: ${config.output.laravel.migrationsPath}/`);
867
869
  }
868
- if (typesGenerated > 0) {
870
+ if (typesGenerated > 0 && config.output.typescript) {
869
871
  logger.info(` Types: ${config.output.typescript.path}/`);
870
872
  }
871
873
  }
872
- function registerGenerateCommand(program2) {
873
- 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) => {
874
+ function registerGenerateCommand(program) {
875
+ 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) => {
874
876
  try {
875
877
  await runGenerate(options);
876
878
  } catch (error) {
@@ -885,58 +887,15 @@ function registerGenerateCommand(program2) {
885
887
  }
886
888
  });
887
889
  }
888
-
889
- // src/index.ts
890
- var VERSION = "0.0.1";
891
- var program = new import_commander.Command();
892
- program.name("omnify").description("Schema-first database migrations for Laravel and TypeScript").version(VERSION);
893
- registerInitCommand(program);
894
- registerValidateCommand(program);
895
- registerDiffCommand(program);
896
- registerGenerateCommand(program);
897
- process.on("uncaughtException", (error) => {
898
- if (error instanceof import_omnify_core6.OmnifyError) {
899
- logger.formatError(error);
900
- process.exit(logger.getExitCode(error));
901
- } else {
902
- logger.error(error.message);
903
- process.exit(1);
904
- }
905
- });
906
- process.on("unhandledRejection", (reason) => {
907
- if (reason instanceof import_omnify_core6.OmnifyError) {
908
- logger.formatError(reason);
909
- process.exit(logger.getExitCode(reason));
910
- } else if (reason instanceof Error) {
911
- logger.error(reason.message);
912
- } else {
913
- logger.error(String(reason));
914
- }
915
- process.exit(1);
916
- });
917
- var args = process.argv.slice(2);
918
- var firstArg = args[0];
919
- var hasCommand = firstArg !== void 0 && !firstArg.startsWith("-");
920
- var configPath = (0, import_node_path6.resolve)(process.cwd(), "omnify.config.ts");
921
- var hasConfig = (0, import_node_fs4.existsSync)(configPath);
922
- if (!hasCommand && !hasConfig) {
923
- runInit({}).catch((error) => {
924
- if (error instanceof Error) {
925
- if (error.message.includes("User force closed")) {
926
- logger.newline();
927
- logger.info("Setup cancelled.");
928
- process.exit(0);
929
- }
930
- logger.error(error.message);
931
- }
932
- process.exit(1);
933
- });
934
- } else {
935
- program.parse();
936
- }
937
890
  // Annotate the CommonJS export names for ESM import in node:
938
891
  0 && (module.exports = {
939
892
  defineConfig,
940
- loadConfig
893
+ loadConfig,
894
+ logger,
895
+ registerDiffCommand,
896
+ registerGenerateCommand,
897
+ registerInitCommand,
898
+ registerValidateCommand,
899
+ runInit
941
900
  });
942
901
  //# sourceMappingURL=index.cjs.map