@igniter-js/cli 0.4.0 → 0.4.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/dist/index.mjs CHANGED
@@ -148,7 +148,7 @@ function registerHandlebarsHelpers() {
148
148
  });
149
149
  handlebars.registerHelper("filterPlugins", function(plugins = []) {
150
150
  if (!Array.isArray(plugins)) return [];
151
- return plugins.filter((p12) => p12 !== "next-cookies");
151
+ return plugins.filter((p13) => p13 !== "next-cookies");
152
152
  });
153
153
  handlebars.registerHelper(
154
154
  "generatePluginImports",
@@ -162,7 +162,7 @@ function registerHandlebarsHelpers() {
162
162
  if (str === "open-api") return "openAPI";
163
163
  return str.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
164
164
  };
165
- const regularPlugins = plugins.filter((p12) => p12 !== "next-cookies").map(camelCase);
165
+ const regularPlugins = plugins.filter((p13) => p13 !== "next-cookies").map(camelCase);
166
166
  const hasNextCookies = plugins.includes("next-cookies");
167
167
  const importStatements = [];
168
168
  if (regularPlugins.length > 0) {
@@ -3144,6 +3144,7 @@ import { build } from "esbuild";
3144
3144
  import zodToJsonSchema from "zod-to-json-schema";
3145
3145
  import { createRequire } from "module";
3146
3146
  import nodeExternals from "esbuild-node-externals";
3147
+ import * as p8 from "@clack/prompts";
3147
3148
  var RouterLoadError = class extends Error {
3148
3149
  constructor(message, originalError) {
3149
3150
  super(message);
@@ -3218,6 +3219,7 @@ var RouterInstrospector = class _RouterInstrospector {
3218
3219
  ${errorMessages}`;
3219
3220
  throw new RouterLoadError(detailedMessage, error);
3220
3221
  }
3222
+ p8.log.error(error);
3221
3223
  throw new RouterLoadError(`Failed to load router from ${routerPath}`, error);
3222
3224
  }
3223
3225
  }
@@ -3267,7 +3269,7 @@ ${errorMessages}`;
3267
3269
  };
3268
3270
 
3269
3271
  // src/commands/generate/docs/action.ts
3270
- import * as p8 from "@clack/prompts";
3272
+ import * as p9 from "@clack/prompts";
3271
3273
  import * as fs5 from "fs";
3272
3274
  import * as path19 from "path";
3273
3275
  async function generateDocsWatchMode(routerPath, outputDir) {
@@ -3300,18 +3302,18 @@ async function generateDocsWatchMode(routerPath, outputDir) {
3300
3302
  }
3301
3303
  async function handleGenerateDocsAction(options) {
3302
3304
  try {
3303
- p8.intro("Generate OpenAPI documentation");
3304
- const spinner7 = p8.spinner();
3305
+ p9.intro("Generate OpenAPI documentation");
3306
+ const spinner7 = p9.spinner();
3305
3307
  spinner7.start("Generating OpenAPI documentation...");
3306
3308
  const result = await generateDocsWatchMode(options.router, options.output);
3307
3309
  spinner7.stop("OpenAPI documentation generated successfully.");
3308
- p8.log.success(
3310
+ p9.log.success(
3309
3311
  `Docs generated in ${(result.durationMs / 1e3).toFixed(2)}s (${result.sizeKb.toFixed(1)} KB)`
3310
3312
  );
3311
- p8.log.info("Test your API on Igniter Studio at: http://localhost:3000/api/v1/docs");
3313
+ p9.log.info("Test your API on Igniter Studio at: http://localhost:3000/api/v1/docs");
3312
3314
  process.exit(0);
3313
3315
  } catch (error) {
3314
- p8.log.error(error instanceof Error ? error.message : String(error));
3316
+ p9.log.error(error instanceof Error ? error.message : String(error));
3315
3317
  process.exit(1);
3316
3318
  }
3317
3319
  }
@@ -3326,7 +3328,7 @@ import { Command as Command4 } from "commander";
3326
3328
  import * as fs6 from "fs";
3327
3329
  import * as path20 from "path";
3328
3330
  import * as handlebars5 from "handlebars";
3329
- import * as p9 from "@clack/prompts";
3331
+ import * as p10 from "@clack/prompts";
3330
3332
  async function generateSchemaWatchMode(routerPath, outputPath) {
3331
3333
  const startTime = Date.now();
3332
3334
  const routerInstrospector = RouterInstrospector.create();
@@ -3350,19 +3352,19 @@ async function generateSchemaWatchMode(routerPath, outputPath) {
3350
3352
  }
3351
3353
  async function handleGenerateSchemaAction({ router: routerPath, output: outputPath }) {
3352
3354
  try {
3353
- p9.intro("Generate Igniter.js Client Schema");
3354
- const spinner7 = p9.spinner();
3355
+ p10.intro("Generate Igniter.js Client Schema");
3356
+ const spinner7 = p10.spinner();
3355
3357
  spinner7.start("Generating schema...");
3356
3358
  const result = await generateSchemaWatchMode(routerPath, outputPath);
3357
3359
  spinner7.stop("Schema generated successfully.");
3358
- p9.log.success(
3360
+ p10.log.success(
3359
3361
  `Schema generated in ${(result.durationMs / 1e3).toFixed(2)}s (${result.controllers} controllers, ${result.actions} actions).`
3360
3362
  );
3361
- p9.outro("All done!");
3363
+ p10.outro("All done!");
3362
3364
  process.exit(0);
3363
3365
  } catch (error) {
3364
3366
  const errorMessage = error instanceof Error ? error.message : String(error);
3365
- p9.log.error(`Failed to generate schema: ${errorMessage}`);
3367
+ p10.log.error(`Failed to generate schema: ${errorMessage}`);
3366
3368
  process.exit(1);
3367
3369
  }
3368
3370
  }
@@ -3375,7 +3377,7 @@ import { Command as Command5 } from "commander";
3375
3377
 
3376
3378
  // src/commands/generate/controller/action.ts
3377
3379
  import * as path21 from "path";
3378
- import * as p10 from "@clack/prompts";
3380
+ import * as p11 from "@clack/prompts";
3379
3381
 
3380
3382
  // src/utils/try-catch.ts
3381
3383
  async function tryCatch(promise) {
@@ -3389,7 +3391,7 @@ async function tryCatch(promise) {
3389
3391
 
3390
3392
  // src/commands/generate/controller/action.ts
3391
3393
  async function handleGenerateControllerAction(name, options) {
3392
- p10.intro("Generate Controller");
3394
+ p11.intro("Generate Controller");
3393
3395
  let controllerInput = name;
3394
3396
  if (!controllerInput) {
3395
3397
  controllerInput = await FeaturePrompts.askForEntityName({
@@ -3406,7 +3408,7 @@ async function handleGenerateControllerAction(name, options) {
3406
3408
  options.feature
3407
3409
  ));
3408
3410
  if (selectedFeature.error) {
3409
- p10.log.error(`Controller generation failed: ${selectedFeature.error.message}`);
3411
+ p11.log.error(`Controller generation failed: ${selectedFeature.error.message}`);
3410
3412
  process.exit(1);
3411
3413
  }
3412
3414
  const featureSlug = Casing.toKebabCase(selectedFeature.data);
@@ -3418,7 +3420,7 @@ async function handleGenerateControllerAction(name, options) {
3418
3420
  `${controllerSlug}.controller.ts`
3419
3421
  );
3420
3422
  if (await FeatureWorkspace.fileExists(controllerPath)) {
3421
- p10.log.error(
3423
+ p11.log.error(
3422
3424
  `Controller '${controllerSlug}' already exists at ${path21.relative(process.cwd(), controllerPath)}.`
3423
3425
  );
3424
3426
  process.exit(1);
@@ -3429,7 +3431,7 @@ async function handleGenerateControllerAction(name, options) {
3429
3431
  "feature",
3430
3432
  "empty.controller.hbs"
3431
3433
  );
3432
- const spinner7 = p10.spinner();
3434
+ const spinner7 = p11.spinner();
3433
3435
  spinner7.start(
3434
3436
  `Creating controller '${controllerSlug}' inside feature '${featureSlug}'...`
3435
3437
  );
@@ -3444,14 +3446,14 @@ async function handleGenerateControllerAction(name, options) {
3444
3446
  controllerPath
3445
3447
  );
3446
3448
  spinner7.stop("Controller created successfully!");
3447
- p10.log.success(
3449
+ p11.log.success(
3448
3450
  `Created controller '${controllerSlug}' in feature '${featureSlug}'.`
3449
3451
  );
3450
- p10.outro("Controller generation complete!");
3452
+ p11.outro("Controller generation complete!");
3451
3453
  } catch (error) {
3452
3454
  spinner7.stop("Failed to create the controller.");
3453
3455
  const message = error instanceof Error ? error.message : String(error);
3454
- p10.log.error(`Controller generation failed: ${message}`);
3456
+ p11.log.error(`Controller generation failed: ${message}`);
3455
3457
  process.exit(1);
3456
3458
  }
3457
3459
  }
@@ -3464,10 +3466,10 @@ import { Command as Command6 } from "commander";
3464
3466
 
3465
3467
  // src/commands/generate/procedure/action.ts
3466
3468
  import * as path22 from "path";
3467
- import * as p11 from "@clack/prompts";
3469
+ import * as p12 from "@clack/prompts";
3468
3470
  import { rm as rm2 } from "fs/promises";
3469
3471
  async function handleGenerateProcedureAction(name, options) {
3470
- p11.intro("Generate Procedure");
3472
+ p12.intro("Generate Procedure");
3471
3473
  let procedureInput = name;
3472
3474
  if (!procedureInput) {
3473
3475
  procedureInput = await FeaturePrompts.askForEntityName({
@@ -3484,7 +3486,7 @@ async function handleGenerateProcedureAction(name, options) {
3484
3486
  options.feature
3485
3487
  ));
3486
3488
  if (selectedFeature.error) {
3487
- p11.log.error(`Procedure generation failed: ${selectedFeature.error.message}`);
3489
+ p12.log.error(`Procedure generation failed: ${selectedFeature.error.message}`);
3488
3490
  process.exit(1);
3489
3491
  }
3490
3492
  const featureSlug = Casing.toKebabCase(selectedFeature.data);
@@ -3496,7 +3498,7 @@ async function handleGenerateProcedureAction(name, options) {
3496
3498
  `${procedureSlug}.procedure.ts`
3497
3499
  );
3498
3500
  if (await FeatureWorkspace.fileExists(procedurePath)) {
3499
- p11.log.error(
3501
+ p12.log.error(
3500
3502
  `Procedure '${procedureSlug}' already exists at ${path22.relative(process.cwd(), procedurePath)}.`
3501
3503
  );
3502
3504
  process.exit(1);
@@ -3507,7 +3509,7 @@ async function handleGenerateProcedureAction(name, options) {
3507
3509
  "feature",
3508
3510
  "procedure.hbs"
3509
3511
  );
3510
- const spinner7 = p11.spinner();
3512
+ const spinner7 = p12.spinner();
3511
3513
  spinner7.start(
3512
3514
  `Creating procedure '${procedureSlug}' inside feature '${featureSlug}'...`
3513
3515
  );
@@ -3525,14 +3527,14 @@ async function handleGenerateProcedureAction(name, options) {
3525
3527
  procedurePath
3526
3528
  );
3527
3529
  spinner7.stop("Procedure created successfully!");
3528
- p11.log.success(
3530
+ p12.log.success(
3529
3531
  `Created procedure '${procedureSlug}' in feature '${featureSlug}'.`
3530
3532
  );
3531
- p11.outro("Procedure generation complete!");
3533
+ p12.outro("Procedure generation complete!");
3532
3534
  } catch (error) {
3533
3535
  spinner7.stop("Failed to create the procedure.");
3534
3536
  const message = error instanceof Error ? error.message : String(error);
3535
- p11.log.error(`Procedure generation failed: ${message}`);
3537
+ p12.log.error(`Procedure generation failed: ${message}`);
3536
3538
  process.exit(1);
3537
3539
  }
3538
3540
  }
@@ -3583,14 +3585,14 @@ function DevUI({ igniterLogs, appLogs, onExit }) {
3583
3585
  };
3584
3586
  const renderLogs = (logs, maxLines = 50) => {
3585
3587
  const visibleLogs = logs.slice(-maxLines);
3586
- return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column" }, visibleLogs.length === 0 ? /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "No logs yet...") : visibleLogs.map((log10, index) => {
3588
+ return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column" }, visibleLogs.length === 0 ? /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "No logs yet...") : visibleLogs.map((log11, index) => {
3587
3589
  const color2 = {
3588
3590
  info: "cyan",
3589
3591
  success: "green",
3590
3592
  error: "red",
3591
3593
  warn: "yellow"
3592
- }[log10.type];
3593
- return /* @__PURE__ */ React.createElement(Text, { key: `${log10.timestamp.getTime()}-${index}`, color: color2 }, formatLogEntry(log10));
3594
+ }[log11.type];
3595
+ return /* @__PURE__ */ React.createElement(Text, { key: `${log11.timestamp.getTime()}-${index}`, color: color2 }, formatLogEntry(log11));
3594
3596
  }));
3595
3597
  };
3596
3598
  return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column" }, /* @__PURE__ */ React.createElement(Box, { marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { bold: true }, "Igniter.js Development Mode")), /* @__PURE__ */ React.createElement(Box, { flexDirection: "row" }, /* @__PURE__ */ React.createElement(
@@ -3663,8 +3665,8 @@ async function handleDevAction(options) {
3663
3665
  const igniterLogs = [];
3664
3666
  const appLogs = [];
3665
3667
  let rerenderFn = null;
3666
- const addIgniterLog = (log10) => {
3667
- igniterLogs.push(log10);
3668
+ const addIgniterLog = (log11) => {
3669
+ igniterLogs.push(log11);
3668
3670
  if (igniterLogs.length > 1e3) {
3669
3671
  igniterLogs.shift();
3670
3672
  }
@@ -3672,8 +3674,8 @@ async function handleDevAction(options) {
3672
3674
  rerenderFn();
3673
3675
  }
3674
3676
  };
3675
- const addAppLog = (log10) => {
3676
- appLogs.push(log10);
3677
+ const addAppLog = (log11) => {
3678
+ appLogs.push(log11);
3677
3679
  if (appLogs.length > 1e3) {
3678
3680
  appLogs.shift();
3679
3681
  }
@@ -3709,7 +3711,7 @@ async function handleDevAction(options) {
3709
3711
  // Watch router file directly
3710
3712
  featuresDir
3711
3713
  // Watch features directory recursively
3712
- ].filter((p12) => fs7.existsSync(p12));
3714
+ ].filter((p13) => fs7.existsSync(p13));
3713
3715
  if (watchPaths.length === 0) {
3714
3716
  addIgniterLog({
3715
3717
  type: "warn",
@@ -3720,7 +3722,7 @@ async function handleDevAction(options) {
3720
3722
  }
3721
3723
  addIgniterLog({
3722
3724
  type: "info",
3723
- message: `Watching for changes in: ${watchPaths.map((p12) => path23.relative(process.cwd(), p12)).join(", ")}`,
3725
+ message: `Watching for changes in: ${watchPaths.map((p13) => path23.relative(process.cwd(), p13)).join(", ")}`,
3724
3726
  timestamp: /* @__PURE__ */ new Date()
3725
3727
  });
3726
3728
  let regenerateTimeout = null;