poe-code 3.0.373 → 3.0.374

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-code",
3
- "version": "3.0.373",
3
+ "version": "3.0.374",
4
4
  "description": "CLI tool to configure Poe API for developer workflows.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15406,6 +15406,37 @@ function resolveOutput(resolvedFlags) {
15406
15406
  }
15407
15407
  return "rich";
15408
15408
  }
15409
+ function resolveOutputFromArgv(argv) {
15410
+ for (let index = 0; index < argv.length; index += 1) {
15411
+ const token = argv[index] ?? "";
15412
+ if (token === "--json") {
15413
+ return "json";
15414
+ }
15415
+ if (token === "--md" || token === "--markdown") {
15416
+ return "md";
15417
+ }
15418
+ if (token === "--output") {
15419
+ const value = argv[index + 1];
15420
+ if (value === "rich" || value === "md" || value === "json") {
15421
+ return value;
15422
+ }
15423
+ if (value === "markdown") {
15424
+ return "md";
15425
+ }
15426
+ continue;
15427
+ }
15428
+ if (token.startsWith("--output=")) {
15429
+ const value = token.slice("--output=".length);
15430
+ if (value === "rich" || value === "md" || value === "json") {
15431
+ return value;
15432
+ }
15433
+ if (value === "markdown") {
15434
+ return "md";
15435
+ }
15436
+ }
15437
+ }
15438
+ return "rich";
15439
+ }
15409
15440
  var DESIGN_SYSTEM_OUTPUT_BY_MODE = {
15410
15441
  rich: "terminal",
15411
15442
  md: "markdown",
@@ -16885,76 +16916,78 @@ function renderHttpError(error3, options) {
16885
16916
  `);
16886
16917
  }
16887
16918
  }
16888
- function handleRunError(error3, options) {
16919
+ async function handleRunError(error3, options) {
16889
16920
  const logger2 = createLogger();
16890
- if (error3 instanceof UserError) {
16891
- renderCliErrorPattern(
16892
- options.userErrorPattern === "usage" ? {
16893
- kind: "usage",
16894
- message: error3.message,
16895
- rootUsageName: options.rootUsageName,
16896
- commandPath: options.commandPath
16897
- } : {
16898
- kind: "runtime-user",
16899
- message: error3.message
16900
- }
16901
- );
16902
- return;
16903
- }
16904
- if (error3 instanceof Error && error3.name === "ToolcraftBugError") {
16905
- renderCliErrorPattern({
16906
- kind: "toolcraft-bug",
16907
- error: error3,
16908
- debugStackMode: options.debugStackMode
16909
- });
16910
- return;
16911
- }
16912
- if (error3 instanceof CommanderError2) {
16913
- process.exitCode = error3.exitCode;
16914
- if (error3.code === "commander.helpDisplayed" || error3.code === "commander.version") {
16921
+ await withOutputFormat2(options.output, async () => {
16922
+ if (error3 instanceof UserError) {
16923
+ renderCliErrorPattern(
16924
+ options.userErrorPattern === "usage" ? {
16925
+ kind: "usage",
16926
+ message: error3.message,
16927
+ rootUsageName: options.rootUsageName,
16928
+ commandPath: options.commandPath
16929
+ } : {
16930
+ kind: "runtime-user",
16931
+ message: error3.message
16932
+ }
16933
+ );
16915
16934
  return;
16916
16935
  }
16917
- if (error3.code === "commander.unknownCommand") {
16918
- logger2.error(
16919
- appendUsagePointer(
16920
- formatUnknownCommandError(error3, options.program, options.argv ?? process.argv),
16921
- {
16922
- rootUsageName: options.rootUsageName,
16923
- commandPath: options.commandPath
16924
- }
16925
- )
16926
- );
16936
+ if (error3 instanceof Error && error3.name === "ToolcraftBugError") {
16937
+ renderCliErrorPattern({
16938
+ kind: "toolcraft-bug",
16939
+ error: error3,
16940
+ debugStackMode: options.debugStackMode
16941
+ });
16927
16942
  return;
16928
16943
  }
16929
- if (error3.code === "commander.unknownOption") {
16930
- const argv = options.argv ?? process.argv;
16944
+ if (error3 instanceof CommanderError2) {
16945
+ process.exitCode = error3.exitCode;
16946
+ if (error3.code === "commander.helpDisplayed" || error3.code === "commander.version") {
16947
+ return;
16948
+ }
16949
+ if (error3.code === "commander.unknownCommand") {
16950
+ logger2.error(
16951
+ appendUsagePointer(
16952
+ formatUnknownCommandError(error3, options.program, options.argv ?? process.argv),
16953
+ {
16954
+ rootUsageName: options.rootUsageName,
16955
+ commandPath: options.commandPath
16956
+ }
16957
+ )
16958
+ );
16959
+ return;
16960
+ }
16961
+ if (error3.code === "commander.unknownOption") {
16962
+ const argv = options.argv ?? process.argv;
16963
+ logger2.error(
16964
+ appendUsagePointer(formatUnknownOptionError(error3, options.program, argv), {
16965
+ rootUsageName: options.rootUsageName,
16966
+ commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, argv)
16967
+ })
16968
+ );
16969
+ return;
16970
+ }
16931
16971
  logger2.error(
16932
- appendUsagePointer(formatUnknownOptionError(error3, options.program, argv), {
16972
+ appendUsagePointer(formatCommanderErrorMessage(error3), {
16933
16973
  rootUsageName: options.rootUsageName,
16934
- commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, argv)
16974
+ commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, options.argv ?? process.argv)
16935
16975
  })
16936
16976
  );
16937
16977
  return;
16938
16978
  }
16939
- logger2.error(
16940
- appendUsagePointer(formatCommanderErrorMessage(error3), {
16941
- rootUsageName: options.rootUsageName,
16942
- commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, options.argv ?? process.argv)
16943
- })
16944
- );
16945
- return;
16946
- }
16947
- if (isHttpErrorLike(error3)) {
16948
- renderHttpError(error3, options);
16949
- process.exitCode = 1;
16950
- return;
16951
- }
16952
- const message2 = error3 instanceof Error ? error3.message : String(error3);
16953
- renderCliErrorPattern({
16954
- kind: "unexpected",
16955
- message: message2,
16956
- stack: error3 instanceof Error ? error3.stack : void 0,
16957
- debugStackMode: options.debugStackMode
16979
+ if (isHttpErrorLike(error3)) {
16980
+ renderHttpError(error3, options);
16981
+ process.exitCode = 1;
16982
+ return;
16983
+ }
16984
+ const message2 = error3 instanceof Error ? error3.message : String(error3);
16985
+ renderCliErrorPattern({
16986
+ kind: "unexpected",
16987
+ message: message2,
16988
+ stack: error3 instanceof Error ? error3.stack : void 0,
16989
+ debugStackMode: options.debugStackMode
16990
+ });
16958
16991
  });
16959
16992
  }
16960
16993
  function formatCommanderErrorMessage(error3) {
@@ -17279,8 +17312,9 @@ async function runCLI(roots, options = {}) {
17279
17312
  process.stderr.write(`Saved error report to ${report.displayPath}
17280
17313
  `);
17281
17314
  }
17282
- handleRunError(error3, {
17315
+ await handleRunError(error3, {
17283
17316
  debugStackMode: resolvedFlags !== void 0 ? resolveDebugStackMode(resolvedFlags.debug) : getDebugStackModeFromArgv(process.argv),
17317
+ output: resolvedFlags !== void 0 ? resolveOutput(resolvedFlags) : resolveOutputFromArgv(process.argv),
17284
17318
  verbose: resolvedFlags ? Boolean(resolvedFlags.verbose) : process.argv.includes("--verbose"),
17285
17319
  program,
17286
17320
  argv: process.argv,