@tarileo/avileo-catalog-cli 0.3.5 → 0.3.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.js CHANGED
@@ -6,7 +6,8 @@ var __export = (target, all) => {
6
6
  };
7
7
 
8
8
  // src/program.ts
9
- import { Command, CommanderError } from "commander";
9
+ import { readFileSync as readFileSync2 } from "fs";
10
+ import { Command } from "commander";
10
11
 
11
12
  // ../../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/external.js
12
13
  var external_exports = {};
@@ -17109,6 +17110,12 @@ function registerAuthCommands(root, options) {
17109
17110
  }
17110
17111
 
17111
17112
  // src/program.ts
17113
+ var CliVersionRequested = class extends Error {
17114
+ constructor() {
17115
+ super("version requested");
17116
+ this.name = "CliVersionRequested";
17117
+ }
17118
+ };
17112
17119
  function createProgram(options = {}) {
17113
17120
  const program = new Command();
17114
17121
  let client;
@@ -17119,10 +17126,15 @@ function createProgram(options = {}) {
17119
17126
  });
17120
17127
  return client;
17121
17128
  });
17122
- program.name("avileo").description("CLI seguro para el cat\xE1logo de un negocio Avileo").option("--json", "Emite la envoltura JSON versionada para automatizaci\xF3n");
17129
+ const packageJson = JSON.parse(
17130
+ readFileSync2(new URL("../package.json", import.meta.url), "utf8")
17131
+ );
17132
+ const cliVersion = typeof packageJson === "object" && packageJson !== null && "version" in packageJson && typeof packageJson.version === "string" ? packageJson.version : "0.0.0";
17133
+ program.name("avileo").description("CLI seguro para el cat\xE1logo de un negocio Avileo").version(cliVersion, "--version", "Muestra la versi\xF3n del paquete publicado").option("--json", "Emite la envoltura JSON versionada para automatizaci\xF3n");
17123
17134
  program.configureOutput({ writeErr: () => void 0 });
17124
17135
  program.exitOverride((error51) => {
17125
17136
  if (error51.code === "commander.helpDisplayed") return;
17137
+ if (error51.code === "commander.version") throw new CliVersionRequested();
17126
17138
  throw new CliProtocolError("CLI_USAGE_ERROR", error51.message);
17127
17139
  });
17128
17140
  registerAuthCommands(program, {
@@ -17161,7 +17173,9 @@ function createProgram(options = {}) {
17161
17173
  try {
17162
17174
  return await parseAsync3(...args);
17163
17175
  } catch (error51) {
17164
- if (error51 instanceof CommanderError && error51.code === "commander.helpDisplayed")
17176
+ if (error51 instanceof CliVersionRequested) return program;
17177
+ const errorCode = typeof error51 === "object" && error51 !== null && "code" in error51 ? String(error51.code) : "";
17178
+ if (errorCode === "commander.helpDisplayed" || errorCode === "commander.version")
17165
17179
  return program;
17166
17180
  emitFailure(toFailure(error51));
17167
17181
  process.exitCode = exitCodeFor(error51);