trello-cli-unofficial 0.10.7 → 0.10.8

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.10.8](https://github.com/JaegerCaiser/trello-cli-unofficial/compare/v0.10.7...v0.10.8) (2025-11-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * use dynamic import for Commander initialization ([0810a65](https://github.com/JaegerCaiser/trello-cli-unofficial/commit/0810a65526ea55f4b6082d0f6964eed62f1eddf6))
7
+
1
8
  ## [0.10.7](https://github.com/JaegerCaiser/trello-cli-unofficial/compare/v0.10.6...v0.10.7) (2025-11-14)
2
9
 
3
10
 
package/dist/main.js CHANGED
@@ -2501,7 +2501,9 @@ var require_en = __commonJS((exports, module) => {
2501
2501
  errors: {
2502
2502
  loadConfig: "Error loading configuration:",
2503
2503
  saveConfig: "Error saving configuration:",
2504
- programNotInitialized: "Commander program not initialized"
2504
+ programNotInitialized: "Commander program not initialized",
2505
+ commanderInitFailed: "Failed to initialize Commander. Check if Commander.js is installed correctly.",
2506
+ commanderInitError: "Error initializing Commander:"
2505
2507
  },
2506
2508
  selectBoard: "Select a board:",
2507
2509
  selectList: "Select a list:",
@@ -2773,7 +2775,9 @@ var require_pt_BR = __commonJS((exports, module) => {
2773
2775
  errors: {
2774
2776
  loadConfig: "Erro ao carregar configura\xE7\xE3o:",
2775
2777
  saveConfig: "Erro ao salvar configura\xE7\xE3o:",
2776
- programNotInitialized: "Programa Commander n\xE3o inicializado"
2778
+ programNotInitialized: "Programa Commander n\xE3o inicializado",
2779
+ commanderInitFailed: "Falha na inicializa\xE7\xE3o do Commander. Verifique se o Commander.js est\xE1 instalado.",
2780
+ commanderInitError: "Erro ao inicializar Commander:"
2777
2781
  },
2778
2782
  selectBoard: "Selecione um board:",
2779
2783
  selectList: "Selecione uma lista:",
@@ -28835,130 +28839,399 @@ var init_repositories = __esm(() => {
28835
28839
  init_TrelloApiRepository();
28836
28840
  });
28837
28841
 
28838
- // node_modules/commander/lib/error.js
28839
- var require_error = __commonJS((exports) => {
28840
- class CommanderError extends Error {
28841
- constructor(exitCode, code, message) {
28842
- super(message);
28843
- Error.captureStackTrace(this, this.constructor);
28844
- this.name = this.constructor.name;
28845
- this.code = code;
28846
- this.exitCode = exitCode;
28847
- this.nestedError = undefined;
28842
+ // src/shared/ErrorHandler.ts
28843
+ class ErrorHandler {
28844
+ static handle(error, context) {
28845
+ if (error instanceof TrelloCliError) {
28846
+ this.handleTrelloError(error, context);
28847
+ } else if (error instanceof Error) {
28848
+ this.handleGenericError(error, context);
28849
+ } else {
28850
+ this.handleUnknownError(error, context);
28848
28851
  }
28849
28852
  }
28850
-
28851
- class InvalidArgumentError extends CommanderError {
28852
- constructor(message) {
28853
- super(1, "commander.invalidArgument", message);
28854
- Error.captureStackTrace(this, this.constructor);
28855
- this.name = this.constructor.name;
28853
+ static handleTrelloError(error, context) {
28854
+ const prefix = context ? `[${context}] ` : "";
28855
+ switch (error.code) {
28856
+ case "AUTH_ERROR":
28857
+ console.error(t2("errors.authFailed", { message: error.message }));
28858
+ console.error(t2("errors.trySetup"));
28859
+ break;
28860
+ case "API_ERROR":
28861
+ console.error(t2("errors.apiError", { statusCode: error.statusCode, message: error.message }));
28862
+ if (error instanceof ApiError && error.endpoint) {
28863
+ console.error(t2("errors.endpoint", { endpoint: error.endpoint }));
28864
+ }
28865
+ break;
28866
+ case "VALIDATION_ERROR":
28867
+ console.error(t2("errors.validationError", { message: error.message }));
28868
+ if (error instanceof ValidationError2 && error.field) {
28869
+ console.error(t2("errors.field", { field: error.field }));
28870
+ }
28871
+ break;
28872
+ case "NOT_FOUND_ERROR":
28873
+ console.error(t2("errors.notFound", { message: error.message }));
28874
+ if (error instanceof NotFoundError) {
28875
+ if (error.resourceType) {
28876
+ console.error(t2("errors.resourceType", { resourceType: error.resourceType }));
28877
+ }
28878
+ if (error.resourceId) {
28879
+ console.error(t2("errors.resourceId", { resourceId: error.resourceId }));
28880
+ }
28881
+ }
28882
+ break;
28883
+ case "CONFIG_ERROR":
28884
+ console.error(t2("errors.configError", { message: error.message }));
28885
+ console.error(t2("errors.checkConfig"));
28886
+ break;
28887
+ case "NETWORK_ERROR":
28888
+ console.error(t2("errors.networkError", { message: error.message }));
28889
+ console.error(t2("errors.checkConnection"));
28890
+ break;
28891
+ default:
28892
+ console.error(`\u274C ${prefix}${error.message}`);
28856
28893
  }
28894
+ process.exit(error.statusCode || 1);
28857
28895
  }
28858
- exports.CommanderError = CommanderError;
28859
- exports.InvalidArgumentError = InvalidArgumentError;
28860
- });
28861
-
28862
- // node_modules/commander/lib/argument.js
28863
- var require_argument = __commonJS((exports) => {
28864
- var { InvalidArgumentError } = require_error();
28865
-
28866
- class Argument {
28867
- constructor(name, description) {
28868
- this.description = description || "";
28869
- this.variadic = false;
28870
- this.parseArg = undefined;
28871
- this.defaultValue = undefined;
28872
- this.defaultValueDescription = undefined;
28873
- this.argChoices = undefined;
28874
- switch (name[0]) {
28875
- case "<":
28876
- this.required = true;
28877
- this._name = name.slice(1, -1);
28878
- break;
28879
- case "[":
28880
- this.required = false;
28881
- this._name = name.slice(1, -1);
28882
- break;
28883
- default:
28884
- this.required = true;
28885
- this._name = name;
28886
- break;
28887
- }
28888
- if (this._name.endsWith("...")) {
28889
- this.variadic = true;
28890
- this._name = this._name.slice(0, -3);
28891
- }
28896
+ static handleGenericError(error, _context) {
28897
+ console.error(t2("errors.unexpectedError", { message: error.message }));
28898
+ if (true) {
28899
+ console.error(t2("errors.stackTrace"), error.stack);
28892
28900
  }
28893
- name() {
28894
- return this._name;
28901
+ process.exit(1);
28902
+ }
28903
+ static handleUnknownError(error, _context) {
28904
+ console.error(t2("errors.unknownError"), error);
28905
+ process.exit(1);
28906
+ }
28907
+ static async withErrorHandling(operation, context) {
28908
+ try {
28909
+ return await operation();
28910
+ } catch (error) {
28911
+ this.handle(error, context);
28912
+ throw error;
28895
28913
  }
28896
- _collectValue(value, previous) {
28897
- if (previous === this.defaultValue || !Array.isArray(previous)) {
28898
- return [value];
28899
- }
28900
- previous.push(value);
28901
- return previous;
28914
+ }
28915
+ static fromApiResponse(response, endpoint) {
28916
+ const statusCode = response.status || response.statusCode || 500;
28917
+ const message = response.message || response.error || t2("api.unknownApiError");
28918
+ switch (statusCode) {
28919
+ case 401:
28920
+ return new AuthenticationError(t2("api.invalidToken"));
28921
+ case 403:
28922
+ return new AuthenticationError("Access denied");
28923
+ case 404:
28924
+ return new NotFoundError(t2("api.resourceNotFound"), "unknown");
28925
+ case 400:
28926
+ return new ValidationError2(message);
28927
+ case 429:
28928
+ return new ApiError(t2("api.rateLimitExceeded"), statusCode, endpoint);
28929
+ case 500:
28930
+ return new ApiError(t2("api.internalServerError"), statusCode, endpoint);
28931
+ default:
28932
+ return new ApiError(message, statusCode, endpoint);
28902
28933
  }
28903
- default(value, description) {
28904
- this.defaultValue = value;
28905
- this.defaultValueDescription = description;
28906
- return this;
28934
+ }
28935
+ }
28936
+ var TrelloCliError, AuthenticationError, ApiError, ValidationError2, NotFoundError;
28937
+ var init_ErrorHandler = __esm(() => {
28938
+ init_i18n();
28939
+ TrelloCliError = class TrelloCliError extends Error {
28940
+ code;
28941
+ statusCode;
28942
+ constructor(message, code, statusCode) {
28943
+ super(message);
28944
+ this.code = code;
28945
+ this.statusCode = statusCode;
28946
+ this.name = this.constructor.name;
28907
28947
  }
28908
- argParser(fn) {
28909
- this.parseArg = fn;
28910
- return this;
28948
+ };
28949
+ AuthenticationError = class AuthenticationError extends TrelloCliError {
28950
+ constructor(message = "Authentication failed") {
28951
+ super(message, "AUTH_ERROR", 401);
28911
28952
  }
28912
- choices(values) {
28913
- this.argChoices = values.slice();
28914
- this.parseArg = (arg, previous) => {
28915
- if (!this.argChoices.includes(arg)) {
28916
- throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
28917
- }
28918
- if (this.variadic) {
28919
- return this._collectValue(arg, previous);
28920
- }
28921
- return arg;
28922
- };
28923
- return this;
28953
+ };
28954
+ ApiError = class ApiError extends TrelloCliError {
28955
+ statusCode;
28956
+ endpoint;
28957
+ constructor(message, statusCode, endpoint) {
28958
+ super(message, "API_ERROR", statusCode);
28959
+ this.statusCode = statusCode;
28960
+ this.endpoint = endpoint;
28924
28961
  }
28925
- argRequired() {
28926
- this.required = true;
28927
- return this;
28962
+ };
28963
+ ValidationError2 = class ValidationError2 extends TrelloCliError {
28964
+ field;
28965
+ constructor(message, field) {
28966
+ super(message, "VALIDATION_ERROR", 400);
28967
+ this.field = field;
28928
28968
  }
28929
- argOptional() {
28930
- this.required = false;
28931
- return this;
28969
+ };
28970
+ NotFoundError = class NotFoundError extends TrelloCliError {
28971
+ resourceType;
28972
+ resourceId;
28973
+ constructor(message, resourceType, resourceId) {
28974
+ super(message, "NOT_FOUND_ERROR", 404);
28975
+ this.resourceType = resourceType;
28976
+ this.resourceId = resourceId;
28932
28977
  }
28933
- }
28934
- function humanReadableArgName(arg) {
28935
- const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
28936
- return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
28937
- }
28938
- exports.Argument = Argument;
28939
- exports.humanReadableArgName = humanReadableArgName;
28978
+ };
28940
28979
  });
28941
28980
 
28942
- // node_modules/commander/lib/help.js
28943
- var require_help = __commonJS((exports) => {
28944
- var { humanReadableArgName } = require_argument();
28945
-
28946
- class Help {
28947
- constructor() {
28948
- this.helpWidth = undefined;
28949
- this.minWidthToWrap = 40;
28950
- this.sortSubcommands = false;
28951
- this.sortOptions = false;
28952
- this.showGlobalOptions = false;
28953
- }
28954
- prepareContext(contextOptions) {
28955
- this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
28981
+ // src/shared/OutputFormatter.ts
28982
+ class OutputFormatter {
28983
+ format;
28984
+ constructor(format = "table") {
28985
+ this.format = format;
28986
+ }
28987
+ setFormat(format) {
28988
+ this.format = format;
28989
+ }
28990
+ output(data, options) {
28991
+ const format = options?.format || this.format;
28992
+ switch (format) {
28993
+ case "json":
28994
+ this.outputJson(data);
28995
+ break;
28996
+ case "csv":
28997
+ this.outputCsv(data, options);
28998
+ break;
28999
+ case "table":
29000
+ default:
29001
+ this.outputTable(data, options);
29002
+ break;
28956
29003
  }
28957
- visibleCommands(cmd) {
28958
- const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
28959
- const helpCommand = cmd._getHelpCommand();
28960
- if (helpCommand && !helpCommand._hidden) {
28961
- visibleCommands.push(helpCommand);
29004
+ }
29005
+ outputJson(data) {
29006
+ console.log(JSON.stringify(data, null, 2));
29007
+ }
29008
+ outputCsv(data, options) {
29009
+ if (!Array.isArray(data) || data.length === 0) {
29010
+ console.log(t2("common.noData"));
29011
+ return;
29012
+ }
29013
+ const firstItem = data[0];
29014
+ if (!firstItem) {
29015
+ console.log(t2("common.noData"));
29016
+ return;
29017
+ }
29018
+ const plainItem = this.toPlainObject(firstItem);
29019
+ const fields = options?.fields || Object.keys(plainItem);
29020
+ const headers = options?.headers || fields;
29021
+ console.log(headers.join(","));
29022
+ for (const item of data) {
29023
+ const plainObject = this.toPlainObject(item);
29024
+ const row = fields.map((field) => {
29025
+ const value = plainObject[field];
29026
+ const stringValue = String(value || "");
29027
+ if (stringValue.includes(",") || stringValue.includes('"') || stringValue.includes(`
29028
+ `)) {
29029
+ return `"${stringValue.replace(/"/g, '""')}"`;
29030
+ }
29031
+ return stringValue;
29032
+ });
29033
+ console.log(row.join(","));
29034
+ }
29035
+ }
29036
+ outputTable(data, options) {
29037
+ if (!Array.isArray(data) || data.length === 0) {
29038
+ console.log(t2("common.noData"));
29039
+ return;
29040
+ }
29041
+ const firstItem = data[0];
29042
+ if (!firstItem) {
29043
+ console.log(t2("common.noData"));
29044
+ return;
29045
+ }
29046
+ const plainItem = this.toPlainObject(firstItem);
29047
+ const fields = options?.fields || Object.keys(plainItem);
29048
+ const headers = options?.headers || fields;
29049
+ const columnWidths = headers.map((header, index) => {
29050
+ const field = fields[index];
29051
+ const headerWidth = header.length;
29052
+ const maxDataWidth = Math.max(...data.map((item) => {
29053
+ const plainObject = this.toPlainObject(item);
29054
+ return String(plainObject[field] || "").length;
29055
+ }));
29056
+ return Math.max(headerWidth, maxDataWidth);
29057
+ });
29058
+ const headerRow = headers.map((header, index) => header.padEnd(columnWidths[index])).join(" | ");
29059
+ console.log(headerRow);
29060
+ const separator = columnWidths.map((width) => "-".repeat(width)).join("-+-");
29061
+ console.log(separator);
29062
+ for (const item of data) {
29063
+ const plainObject = this.toPlainObject(item);
29064
+ const row = fields.map((field, index) => {
29065
+ const value = String(plainObject[field] || "");
29066
+ return value.padEnd(columnWidths[index]);
29067
+ }).join(" | ");
29068
+ console.log(row);
29069
+ }
29070
+ }
29071
+ toPlainObject(obj) {
29072
+ if (obj === null || obj === undefined) {
29073
+ return {};
29074
+ }
29075
+ if (typeof obj === "object" && obj.constructor !== Object) {
29076
+ const plain = {};
29077
+ for (const key of Object.keys(obj)) {
29078
+ plain[key] = obj[key];
29079
+ }
29080
+ return plain;
29081
+ }
29082
+ return obj;
29083
+ }
29084
+ message(message) {
29085
+ console.log(message);
29086
+ }
29087
+ error(message) {
29088
+ console.error(`\u274C ${message}`);
29089
+ }
29090
+ success(message) {
29091
+ console.log(`\u2705 ${message}`);
29092
+ }
29093
+ warning(message) {
29094
+ console.log(`\u26A0\uFE0F ${message}`);
29095
+ }
29096
+ info(message) {
29097
+ console.log(`\u2139\uFE0F ${message}`);
29098
+ }
29099
+ }
29100
+ var init_OutputFormatter = __esm(() => {
29101
+ init_i18n();
29102
+ });
29103
+
29104
+ // src/shared/index.ts
29105
+ var init_shared = __esm(() => {
29106
+ init_ErrorHandler();
29107
+ init_OutputFormatter();
29108
+ init_types();
29109
+ });
29110
+
29111
+ // node_modules/commander/lib/error.js
29112
+ var require_error = __commonJS((exports) => {
29113
+ class CommanderError extends Error {
29114
+ constructor(exitCode, code, message) {
29115
+ super(message);
29116
+ Error.captureStackTrace(this, this.constructor);
29117
+ this.name = this.constructor.name;
29118
+ this.code = code;
29119
+ this.exitCode = exitCode;
29120
+ this.nestedError = undefined;
29121
+ }
29122
+ }
29123
+
29124
+ class InvalidArgumentError extends CommanderError {
29125
+ constructor(message) {
29126
+ super(1, "commander.invalidArgument", message);
29127
+ Error.captureStackTrace(this, this.constructor);
29128
+ this.name = this.constructor.name;
29129
+ }
29130
+ }
29131
+ exports.CommanderError = CommanderError;
29132
+ exports.InvalidArgumentError = InvalidArgumentError;
29133
+ });
29134
+
29135
+ // node_modules/commander/lib/argument.js
29136
+ var require_argument = __commonJS((exports) => {
29137
+ var { InvalidArgumentError } = require_error();
29138
+
29139
+ class Argument {
29140
+ constructor(name, description) {
29141
+ this.description = description || "";
29142
+ this.variadic = false;
29143
+ this.parseArg = undefined;
29144
+ this.defaultValue = undefined;
29145
+ this.defaultValueDescription = undefined;
29146
+ this.argChoices = undefined;
29147
+ switch (name[0]) {
29148
+ case "<":
29149
+ this.required = true;
29150
+ this._name = name.slice(1, -1);
29151
+ break;
29152
+ case "[":
29153
+ this.required = false;
29154
+ this._name = name.slice(1, -1);
29155
+ break;
29156
+ default:
29157
+ this.required = true;
29158
+ this._name = name;
29159
+ break;
29160
+ }
29161
+ if (this._name.endsWith("...")) {
29162
+ this.variadic = true;
29163
+ this._name = this._name.slice(0, -3);
29164
+ }
29165
+ }
29166
+ name() {
29167
+ return this._name;
29168
+ }
29169
+ _collectValue(value, previous) {
29170
+ if (previous === this.defaultValue || !Array.isArray(previous)) {
29171
+ return [value];
29172
+ }
29173
+ previous.push(value);
29174
+ return previous;
29175
+ }
29176
+ default(value, description) {
29177
+ this.defaultValue = value;
29178
+ this.defaultValueDescription = description;
29179
+ return this;
29180
+ }
29181
+ argParser(fn) {
29182
+ this.parseArg = fn;
29183
+ return this;
29184
+ }
29185
+ choices(values) {
29186
+ this.argChoices = values.slice();
29187
+ this.parseArg = (arg, previous) => {
29188
+ if (!this.argChoices.includes(arg)) {
29189
+ throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
29190
+ }
29191
+ if (this.variadic) {
29192
+ return this._collectValue(arg, previous);
29193
+ }
29194
+ return arg;
29195
+ };
29196
+ return this;
29197
+ }
29198
+ argRequired() {
29199
+ this.required = true;
29200
+ return this;
29201
+ }
29202
+ argOptional() {
29203
+ this.required = false;
29204
+ return this;
29205
+ }
29206
+ }
29207
+ function humanReadableArgName(arg) {
29208
+ const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
29209
+ return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
29210
+ }
29211
+ exports.Argument = Argument;
29212
+ exports.humanReadableArgName = humanReadableArgName;
29213
+ });
29214
+
29215
+ // node_modules/commander/lib/help.js
29216
+ var require_help = __commonJS((exports) => {
29217
+ var { humanReadableArgName } = require_argument();
29218
+
29219
+ class Help {
29220
+ constructor() {
29221
+ this.helpWidth = undefined;
29222
+ this.minWidthToWrap = 40;
29223
+ this.sortSubcommands = false;
29224
+ this.sortOptions = false;
29225
+ this.showGlobalOptions = false;
29226
+ }
29227
+ prepareContext(contextOptions) {
29228
+ this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
29229
+ }
29230
+ visibleCommands(cmd) {
29231
+ const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
29232
+ const helpCommand = cmd._getHelpCommand();
29233
+ if (helpCommand && !helpCommand._hidden) {
29234
+ visibleCommands.push(helpCommand);
28962
29235
  }
28963
29236
  if (this.sortSubcommands) {
28964
29237
  visibleCommands.sort((a, b) => {
@@ -30764,456 +31037,201 @@ Expecting one of '${allowedValues.join("', '")}'`);
30764
31037
  } else {
30765
31038
  baseWrite = (str) => this._outputConfiguration.writeOut(str);
30766
31039
  hasColors = this._outputConfiguration.getOutHasColors();
30767
- helpWidth = this._outputConfiguration.getOutHelpWidth();
30768
- }
30769
- const write = (str) => {
30770
- if (!hasColors)
30771
- str = this._outputConfiguration.stripColor(str);
30772
- return baseWrite(str);
30773
- };
30774
- return { error, write, hasColors, helpWidth };
30775
- }
30776
- outputHelp(contextOptions) {
30777
- let deprecatedCallback;
30778
- if (typeof contextOptions === "function") {
30779
- deprecatedCallback = contextOptions;
30780
- contextOptions = undefined;
30781
- }
30782
- const outputContext = this._getOutputContext(contextOptions);
30783
- const eventContext = {
30784
- error: outputContext.error,
30785
- write: outputContext.write,
30786
- command: this
30787
- };
30788
- this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
30789
- this.emit("beforeHelp", eventContext);
30790
- let helpInformation = this.helpInformation({ error: outputContext.error });
30791
- if (deprecatedCallback) {
30792
- helpInformation = deprecatedCallback(helpInformation);
30793
- if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
30794
- throw new Error("outputHelp callback must return a string or a Buffer");
30795
- }
30796
- }
30797
- outputContext.write(helpInformation);
30798
- if (this._getHelpOption()?.long) {
30799
- this.emit(this._getHelpOption().long);
30800
- }
30801
- this.emit("afterHelp", eventContext);
30802
- this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", eventContext));
30803
- }
30804
- helpOption(flags, description) {
30805
- if (typeof flags === "boolean") {
30806
- if (flags) {
30807
- if (this._helpOption === null)
30808
- this._helpOption = undefined;
30809
- if (this._defaultOptionGroup) {
30810
- this._initOptionGroup(this._getHelpOption());
30811
- }
30812
- } else {
30813
- this._helpOption = null;
30814
- }
30815
- return this;
30816
- }
30817
- this._helpOption = this.createOption(flags ?? "-h, --help", description ?? "display help for command");
30818
- if (flags || description)
30819
- this._initOptionGroup(this._helpOption);
30820
- return this;
30821
- }
30822
- _getHelpOption() {
30823
- if (this._helpOption === undefined) {
30824
- this.helpOption(undefined, undefined);
30825
- }
30826
- return this._helpOption;
30827
- }
30828
- addHelpOption(option) {
30829
- this._helpOption = option;
30830
- this._initOptionGroup(option);
30831
- return this;
30832
- }
30833
- help(contextOptions) {
30834
- this.outputHelp(contextOptions);
30835
- let exitCode = Number(process4.exitCode ?? 0);
30836
- if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
30837
- exitCode = 1;
30838
- }
30839
- this._exit(exitCode, "commander.help", "(outputHelp)");
30840
- }
30841
- addHelpText(position, text) {
30842
- const allowedValues = ["beforeAll", "before", "after", "afterAll"];
30843
- if (!allowedValues.includes(position)) {
30844
- throw new Error(`Unexpected value for position to addHelpText.
30845
- Expecting one of '${allowedValues.join("', '")}'`);
30846
- }
30847
- const helpEvent = `${position}Help`;
30848
- this.on(helpEvent, (context) => {
30849
- let helpStr;
30850
- if (typeof text === "function") {
30851
- helpStr = text({ error: context.error, command: context.command });
30852
- } else {
30853
- helpStr = text;
30854
- }
30855
- if (helpStr) {
30856
- context.write(`${helpStr}
30857
- `);
30858
- }
30859
- });
30860
- return this;
30861
- }
30862
- _outputHelpIfRequested(args) {
30863
- const helpOption = this._getHelpOption();
30864
- const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
30865
- if (helpRequested) {
30866
- this.outputHelp();
30867
- this._exit(0, "commander.helpDisplayed", "(outputHelp)");
30868
- }
30869
- }
30870
- }
30871
- function incrementNodeInspectorPort(args) {
30872
- return args.map((arg) => {
30873
- if (!arg.startsWith("--inspect")) {
30874
- return arg;
30875
- }
30876
- let debugOption;
30877
- let debugHost = "127.0.0.1";
30878
- let debugPort = "9229";
30879
- let match;
30880
- if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
30881
- debugOption = match[1];
30882
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
30883
- debugOption = match[1];
30884
- if (/^\d+$/.test(match[3])) {
30885
- debugPort = match[3];
30886
- } else {
30887
- debugHost = match[3];
30888
- }
30889
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
30890
- debugOption = match[1];
30891
- debugHost = match[3];
30892
- debugPort = match[4];
30893
- }
30894
- if (debugOption && debugPort !== "0") {
30895
- return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
30896
- }
30897
- return arg;
30898
- });
30899
- }
30900
- function useColor() {
30901
- if (process4.env.NO_COLOR || process4.env.FORCE_COLOR === "0" || process4.env.FORCE_COLOR === "false")
30902
- return false;
30903
- if (process4.env.FORCE_COLOR || process4.env.CLICOLOR_FORCE !== undefined)
30904
- return true;
30905
- return;
30906
- }
30907
- exports.Command = Command;
30908
- exports.useColor = useColor;
30909
- });
30910
-
30911
- // node_modules/commander/index.js
30912
- var require_commander = __commonJS((exports) => {
30913
- var { Argument } = require_argument();
30914
- var { Command } = require_command();
30915
- var { CommanderError, InvalidArgumentError } = require_error();
30916
- var { Help } = require_help();
30917
- var { Option } = require_option();
30918
- exports.program = new Command;
30919
- exports.createCommand = (name) => new Command(name);
30920
- exports.createOption = (flags, description) => new Option(flags, description);
30921
- exports.createArgument = (name, description) => new Argument(name, description);
30922
- exports.Command = Command;
30923
- exports.Option = Option;
30924
- exports.Argument = Argument;
30925
- exports.Help = Help;
30926
- exports.CommanderError = CommanderError;
30927
- exports.InvalidArgumentError = InvalidArgumentError;
30928
- exports.InvalidOptionArgumentError = InvalidArgumentError;
30929
- });
30930
-
30931
- // node_modules/commander/esm.mjs
30932
- var import__, program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help;
30933
- var init_esm17 = __esm(() => {
30934
- import__ = __toESM(require_commander(), 1);
30935
- ({
30936
- program,
30937
- createCommand,
30938
- createArgument,
30939
- createOption,
30940
- CommanderError,
30941
- InvalidArgumentError,
30942
- InvalidOptionArgumentError,
30943
- Command,
30944
- Argument,
30945
- Option,
30946
- Help
30947
- } = import__.default);
30948
- });
30949
-
30950
- // src/shared/ErrorHandler.ts
30951
- class ErrorHandler {
30952
- static handle(error, context) {
30953
- if (error instanceof TrelloCliError) {
30954
- this.handleTrelloError(error, context);
30955
- } else if (error instanceof Error) {
30956
- this.handleGenericError(error, context);
30957
- } else {
30958
- this.handleUnknownError(error, context);
30959
- }
30960
- }
30961
- static handleTrelloError(error, context) {
30962
- const prefix = context ? `[${context}] ` : "";
30963
- switch (error.code) {
30964
- case "AUTH_ERROR":
30965
- console.error(t2("errors.authFailed", { message: error.message }));
30966
- console.error(t2("errors.trySetup"));
30967
- break;
30968
- case "API_ERROR":
30969
- console.error(t2("errors.apiError", { statusCode: error.statusCode, message: error.message }));
30970
- if (error instanceof ApiError && error.endpoint) {
30971
- console.error(t2("errors.endpoint", { endpoint: error.endpoint }));
30972
- }
30973
- break;
30974
- case "VALIDATION_ERROR":
30975
- console.error(t2("errors.validationError", { message: error.message }));
30976
- if (error instanceof ValidationError2 && error.field) {
30977
- console.error(t2("errors.field", { field: error.field }));
30978
- }
30979
- break;
30980
- case "NOT_FOUND_ERROR":
30981
- console.error(t2("errors.notFound", { message: error.message }));
30982
- if (error instanceof NotFoundError) {
30983
- if (error.resourceType) {
30984
- console.error(t2("errors.resourceType", { resourceType: error.resourceType }));
30985
- }
30986
- if (error.resourceId) {
30987
- console.error(t2("errors.resourceId", { resourceId: error.resourceId }));
30988
- }
30989
- }
30990
- break;
30991
- case "CONFIG_ERROR":
30992
- console.error(t2("errors.configError", { message: error.message }));
30993
- console.error(t2("errors.checkConfig"));
30994
- break;
30995
- case "NETWORK_ERROR":
30996
- console.error(t2("errors.networkError", { message: error.message }));
30997
- console.error(t2("errors.checkConnection"));
30998
- break;
30999
- default:
31000
- console.error(`\u274C ${prefix}${error.message}`);
31001
- }
31002
- process.exit(error.statusCode || 1);
31003
- }
31004
- static handleGenericError(error, _context) {
31005
- console.error(t2("errors.unexpectedError", { message: error.message }));
31006
- if (true) {
31007
- console.error(t2("errors.stackTrace"), error.stack);
31008
- }
31009
- process.exit(1);
31010
- }
31011
- static handleUnknownError(error, _context) {
31012
- console.error(t2("errors.unknownError"), error);
31013
- process.exit(1);
31014
- }
31015
- static async withErrorHandling(operation, context) {
31016
- try {
31017
- return await operation();
31018
- } catch (error) {
31019
- this.handle(error, context);
31020
- throw error;
31021
- }
31022
- }
31023
- static fromApiResponse(response, endpoint) {
31024
- const statusCode = response.status || response.statusCode || 500;
31025
- const message = response.message || response.error || t2("api.unknownApiError");
31026
- switch (statusCode) {
31027
- case 401:
31028
- return new AuthenticationError(t2("api.invalidToken"));
31029
- case 403:
31030
- return new AuthenticationError("Access denied");
31031
- case 404:
31032
- return new NotFoundError(t2("api.resourceNotFound"), "unknown");
31033
- case 400:
31034
- return new ValidationError2(message);
31035
- case 429:
31036
- return new ApiError(t2("api.rateLimitExceeded"), statusCode, endpoint);
31037
- case 500:
31038
- return new ApiError(t2("api.internalServerError"), statusCode, endpoint);
31039
- default:
31040
- return new ApiError(message, statusCode, endpoint);
31041
- }
31042
- }
31043
- }
31044
- var TrelloCliError, AuthenticationError, ApiError, ValidationError2, NotFoundError;
31045
- var init_ErrorHandler = __esm(() => {
31046
- init_i18n();
31047
- TrelloCliError = class TrelloCliError extends Error {
31048
- code;
31049
- statusCode;
31050
- constructor(message, code, statusCode) {
31051
- super(message);
31052
- this.code = code;
31053
- this.statusCode = statusCode;
31054
- this.name = this.constructor.name;
31055
- }
31056
- };
31057
- AuthenticationError = class AuthenticationError extends TrelloCliError {
31058
- constructor(message = "Authentication failed") {
31059
- super(message, "AUTH_ERROR", 401);
31060
- }
31061
- };
31062
- ApiError = class ApiError extends TrelloCliError {
31063
- statusCode;
31064
- endpoint;
31065
- constructor(message, statusCode, endpoint) {
31066
- super(message, "API_ERROR", statusCode);
31067
- this.statusCode = statusCode;
31068
- this.endpoint = endpoint;
31069
- }
31070
- };
31071
- ValidationError2 = class ValidationError2 extends TrelloCliError {
31072
- field;
31073
- constructor(message, field) {
31074
- super(message, "VALIDATION_ERROR", 400);
31075
- this.field = field;
31076
- }
31077
- };
31078
- NotFoundError = class NotFoundError extends TrelloCliError {
31079
- resourceType;
31080
- resourceId;
31081
- constructor(message, resourceType, resourceId) {
31082
- super(message, "NOT_FOUND_ERROR", 404);
31083
- this.resourceType = resourceType;
31084
- this.resourceId = resourceId;
31085
- }
31086
- };
31087
- });
31088
-
31089
- // src/shared/OutputFormatter.ts
31090
- class OutputFormatter {
31091
- format;
31092
- constructor(format = "table") {
31093
- this.format = format;
31094
- }
31095
- setFormat(format) {
31096
- this.format = format;
31097
- }
31098
- output(data, options) {
31099
- const format = options?.format || this.format;
31100
- switch (format) {
31101
- case "json":
31102
- this.outputJson(data);
31103
- break;
31104
- case "csv":
31105
- this.outputCsv(data, options);
31106
- break;
31107
- case "table":
31108
- default:
31109
- this.outputTable(data, options);
31110
- break;
31111
- }
31112
- }
31113
- outputJson(data) {
31114
- console.log(JSON.stringify(data, null, 2));
31115
- }
31116
- outputCsv(data, options) {
31117
- if (!Array.isArray(data) || data.length === 0) {
31118
- console.log(t2("common.noData"));
31119
- return;
31040
+ helpWidth = this._outputConfiguration.getOutHelpWidth();
31041
+ }
31042
+ const write = (str) => {
31043
+ if (!hasColors)
31044
+ str = this._outputConfiguration.stripColor(str);
31045
+ return baseWrite(str);
31046
+ };
31047
+ return { error, write, hasColors, helpWidth };
31120
31048
  }
31121
- const firstItem = data[0];
31122
- if (!firstItem) {
31123
- console.log(t2("common.noData"));
31124
- return;
31049
+ outputHelp(contextOptions) {
31050
+ let deprecatedCallback;
31051
+ if (typeof contextOptions === "function") {
31052
+ deprecatedCallback = contextOptions;
31053
+ contextOptions = undefined;
31054
+ }
31055
+ const outputContext = this._getOutputContext(contextOptions);
31056
+ const eventContext = {
31057
+ error: outputContext.error,
31058
+ write: outputContext.write,
31059
+ command: this
31060
+ };
31061
+ this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
31062
+ this.emit("beforeHelp", eventContext);
31063
+ let helpInformation = this.helpInformation({ error: outputContext.error });
31064
+ if (deprecatedCallback) {
31065
+ helpInformation = deprecatedCallback(helpInformation);
31066
+ if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
31067
+ throw new Error("outputHelp callback must return a string or a Buffer");
31068
+ }
31069
+ }
31070
+ outputContext.write(helpInformation);
31071
+ if (this._getHelpOption()?.long) {
31072
+ this.emit(this._getHelpOption().long);
31073
+ }
31074
+ this.emit("afterHelp", eventContext);
31075
+ this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", eventContext));
31125
31076
  }
31126
- const plainItem = this.toPlainObject(firstItem);
31127
- const fields = options?.fields || Object.keys(plainItem);
31128
- const headers = options?.headers || fields;
31129
- console.log(headers.join(","));
31130
- for (const item of data) {
31131
- const plainObject = this.toPlainObject(item);
31132
- const row = fields.map((field) => {
31133
- const value = plainObject[field];
31134
- const stringValue = String(value || "");
31135
- if (stringValue.includes(",") || stringValue.includes('"') || stringValue.includes(`
31136
- `)) {
31137
- return `"${stringValue.replace(/"/g, '""')}"`;
31077
+ helpOption(flags, description) {
31078
+ if (typeof flags === "boolean") {
31079
+ if (flags) {
31080
+ if (this._helpOption === null)
31081
+ this._helpOption = undefined;
31082
+ if (this._defaultOptionGroup) {
31083
+ this._initOptionGroup(this._getHelpOption());
31084
+ }
31085
+ } else {
31086
+ this._helpOption = null;
31138
31087
  }
31139
- return stringValue;
31140
- });
31141
- console.log(row.join(","));
31088
+ return this;
31089
+ }
31090
+ this._helpOption = this.createOption(flags ?? "-h, --help", description ?? "display help for command");
31091
+ if (flags || description)
31092
+ this._initOptionGroup(this._helpOption);
31093
+ return this;
31142
31094
  }
31143
- }
31144
- outputTable(data, options) {
31145
- if (!Array.isArray(data) || data.length === 0) {
31146
- console.log(t2("common.noData"));
31147
- return;
31095
+ _getHelpOption() {
31096
+ if (this._helpOption === undefined) {
31097
+ this.helpOption(undefined, undefined);
31098
+ }
31099
+ return this._helpOption;
31148
31100
  }
31149
- const firstItem = data[0];
31150
- if (!firstItem) {
31151
- console.log(t2("common.noData"));
31152
- return;
31101
+ addHelpOption(option) {
31102
+ this._helpOption = option;
31103
+ this._initOptionGroup(option);
31104
+ return this;
31153
31105
  }
31154
- const plainItem = this.toPlainObject(firstItem);
31155
- const fields = options?.fields || Object.keys(plainItem);
31156
- const headers = options?.headers || fields;
31157
- const columnWidths = headers.map((header, index) => {
31158
- const field = fields[index];
31159
- const headerWidth = header.length;
31160
- const maxDataWidth = Math.max(...data.map((item) => {
31161
- const plainObject = this.toPlainObject(item);
31162
- return String(plainObject[field] || "").length;
31163
- }));
31164
- return Math.max(headerWidth, maxDataWidth);
31165
- });
31166
- const headerRow = headers.map((header, index) => header.padEnd(columnWidths[index])).join(" | ");
31167
- console.log(headerRow);
31168
- const separator = columnWidths.map((width) => "-".repeat(width)).join("-+-");
31169
- console.log(separator);
31170
- for (const item of data) {
31171
- const plainObject = this.toPlainObject(item);
31172
- const row = fields.map((field, index) => {
31173
- const value = String(plainObject[field] || "");
31174
- return value.padEnd(columnWidths[index]);
31175
- }).join(" | ");
31176
- console.log(row);
31106
+ help(contextOptions) {
31107
+ this.outputHelp(contextOptions);
31108
+ let exitCode = Number(process4.exitCode ?? 0);
31109
+ if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
31110
+ exitCode = 1;
31111
+ }
31112
+ this._exit(exitCode, "commander.help", "(outputHelp)");
31177
31113
  }
31178
- }
31179
- toPlainObject(obj) {
31180
- if (obj === null || obj === undefined) {
31181
- return {};
31114
+ addHelpText(position, text) {
31115
+ const allowedValues = ["beforeAll", "before", "after", "afterAll"];
31116
+ if (!allowedValues.includes(position)) {
31117
+ throw new Error(`Unexpected value for position to addHelpText.
31118
+ Expecting one of '${allowedValues.join("', '")}'`);
31119
+ }
31120
+ const helpEvent = `${position}Help`;
31121
+ this.on(helpEvent, (context) => {
31122
+ let helpStr;
31123
+ if (typeof text === "function") {
31124
+ helpStr = text({ error: context.error, command: context.command });
31125
+ } else {
31126
+ helpStr = text;
31127
+ }
31128
+ if (helpStr) {
31129
+ context.write(`${helpStr}
31130
+ `);
31131
+ }
31132
+ });
31133
+ return this;
31182
31134
  }
31183
- if (typeof obj === "object" && obj.constructor !== Object) {
31184
- const plain = {};
31185
- for (const key of Object.keys(obj)) {
31186
- plain[key] = obj[key];
31135
+ _outputHelpIfRequested(args) {
31136
+ const helpOption = this._getHelpOption();
31137
+ const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
31138
+ if (helpRequested) {
31139
+ this.outputHelp();
31140
+ this._exit(0, "commander.helpDisplayed", "(outputHelp)");
31187
31141
  }
31188
- return plain;
31189
31142
  }
31190
- return obj;
31191
- }
31192
- message(message) {
31193
- console.log(message);
31194
- }
31195
- error(message) {
31196
- console.error(`\u274C ${message}`);
31197
31143
  }
31198
- success(message) {
31199
- console.log(`\u2705 ${message}`);
31200
- }
31201
- warning(message) {
31202
- console.log(`\u26A0\uFE0F ${message}`);
31144
+ function incrementNodeInspectorPort(args) {
31145
+ return args.map((arg) => {
31146
+ if (!arg.startsWith("--inspect")) {
31147
+ return arg;
31148
+ }
31149
+ let debugOption;
31150
+ let debugHost = "127.0.0.1";
31151
+ let debugPort = "9229";
31152
+ let match;
31153
+ if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
31154
+ debugOption = match[1];
31155
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
31156
+ debugOption = match[1];
31157
+ if (/^\d+$/.test(match[3])) {
31158
+ debugPort = match[3];
31159
+ } else {
31160
+ debugHost = match[3];
31161
+ }
31162
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
31163
+ debugOption = match[1];
31164
+ debugHost = match[3];
31165
+ debugPort = match[4];
31166
+ }
31167
+ if (debugOption && debugPort !== "0") {
31168
+ return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
31169
+ }
31170
+ return arg;
31171
+ });
31203
31172
  }
31204
- info(message) {
31205
- console.log(`\u2139\uFE0F ${message}`);
31173
+ function useColor() {
31174
+ if (process4.env.NO_COLOR || process4.env.FORCE_COLOR === "0" || process4.env.FORCE_COLOR === "false")
31175
+ return false;
31176
+ if (process4.env.FORCE_COLOR || process4.env.CLICOLOR_FORCE !== undefined)
31177
+ return true;
31178
+ return;
31206
31179
  }
31207
- }
31208
- var init_OutputFormatter = __esm(() => {
31209
- init_i18n();
31180
+ exports.Command = Command;
31181
+ exports.useColor = useColor;
31210
31182
  });
31211
31183
 
31212
- // src/shared/index.ts
31213
- var init_shared = __esm(() => {
31214
- init_ErrorHandler();
31215
- init_OutputFormatter();
31216
- init_types();
31184
+ // node_modules/commander/index.js
31185
+ var require_commander = __commonJS((exports) => {
31186
+ var { Argument } = require_argument();
31187
+ var { Command } = require_command();
31188
+ var { CommanderError, InvalidArgumentError } = require_error();
31189
+ var { Help } = require_help();
31190
+ var { Option } = require_option();
31191
+ exports.program = new Command;
31192
+ exports.createCommand = (name) => new Command(name);
31193
+ exports.createOption = (flags, description) => new Option(flags, description);
31194
+ exports.createArgument = (name, description) => new Argument(name, description);
31195
+ exports.Command = Command;
31196
+ exports.Option = Option;
31197
+ exports.Argument = Argument;
31198
+ exports.Help = Help;
31199
+ exports.CommanderError = CommanderError;
31200
+ exports.InvalidArgumentError = InvalidArgumentError;
31201
+ exports.InvalidOptionArgumentError = InvalidArgumentError;
31202
+ });
31203
+
31204
+ // node_modules/commander/esm.mjs
31205
+ var exports_esm = {};
31206
+ __export(exports_esm, {
31207
+ program: () => program,
31208
+ createOption: () => createOption,
31209
+ createCommand: () => createCommand,
31210
+ createArgument: () => createArgument,
31211
+ Option: () => Option,
31212
+ InvalidOptionArgumentError: () => InvalidOptionArgumentError,
31213
+ InvalidArgumentError: () => InvalidArgumentError,
31214
+ Help: () => Help,
31215
+ CommanderError: () => CommanderError,
31216
+ Command: () => Command,
31217
+ Argument: () => Argument
31218
+ });
31219
+ var import__, program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help;
31220
+ var init_esm17 = __esm(() => {
31221
+ import__ = __toESM(require_commander(), 1);
31222
+ ({
31223
+ program,
31224
+ createCommand,
31225
+ createArgument,
31226
+ createOption,
31227
+ CommanderError,
31228
+ InvalidArgumentError,
31229
+ InvalidOptionArgumentError,
31230
+ Command,
31231
+ Argument,
31232
+ Option,
31233
+ Help
31234
+ } = import__.default);
31217
31235
  });
31218
31236
 
31219
31237
  // src/presentation/cli/TrelloCliController.ts
@@ -31265,19 +31283,23 @@ class CommandController {
31265
31283
  authController;
31266
31284
  boardController;
31267
31285
  cardController;
31268
- program;
31286
+ program = null;
31269
31287
  outputFormatter;
31270
31288
  constructor() {
31271
31289
  const configRepository = new FileConfigRepository;
31272
31290
  this.authController = new AuthController(configRepository);
31273
- this.program = new Command;
31274
31291
  this.outputFormatter = new OutputFormatter;
31275
- this.initializeProgram();
31276
- this.setupCommands();
31277
31292
  }
31278
- initializeProgram() {
31279
- if (!this.program) {
31280
- this.program = new Command;
31293
+ async initializeProgram() {
31294
+ if (this.program) {
31295
+ return;
31296
+ }
31297
+ try {
31298
+ const { Command: Command2 } = await Promise.resolve().then(() => (init_esm17(), exports_esm));
31299
+ this.program = new Command2;
31300
+ } catch (error) {
31301
+ console.error(t2("menu.errors.commanderInitError"), error);
31302
+ throw new Error(t2("menu.errors.commanderInitFailed"));
31281
31303
  }
31282
31304
  }
31283
31305
  async initializeTrelloControllers() {
@@ -31288,7 +31310,7 @@ class CommandController {
31288
31310
  this.boardController = new BoardController(trelloRepository, this.outputFormatter);
31289
31311
  this.cardController = new CardController(trelloRepository, this.boardController, this.outputFormatter);
31290
31312
  }
31291
- setupCommands() {
31313
+ async setupCommands() {
31292
31314
  if (!this.program) {
31293
31315
  throw new Error(t2("errors.programNotInitialized"));
31294
31316
  }
@@ -31476,10 +31498,8 @@ class CommandController {
31476
31498
  });
31477
31499
  }
31478
31500
  async run() {
31479
- if (!this.program) {
31480
- this.initializeProgram();
31481
- this.setupCommands();
31482
- }
31501
+ await this.initializeProgram();
31502
+ await this.setupCommands();
31483
31503
  if (process.argv.length === 2) {
31484
31504
  const configRepository = new FileConfigRepository;
31485
31505
  const cli = new (await Promise.resolve().then(() => (init_TrelloCliController(), exports_TrelloCliController))).TrelloCliController(configRepository, this.outputFormatter);
@@ -31492,7 +31512,6 @@ class CommandController {
31492
31512
  var init_CommandController = __esm(() => {
31493
31513
  init_services();
31494
31514
  init_repositories();
31495
- init_esm17();
31496
31515
  init_i18n();
31497
31516
  init_shared();
31498
31517
  init_cli();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trello-cli-unofficial",
3
3
  "type": "module",
4
- "version": "0.10.7",
4
+ "version": "0.10.8",
5
5
  "private": false,
6
6
  "description": "Unofficial Trello CLI using Power-Up authentication, built with Bun for maximum performance",
7
7
  "author": "Matheus Caiser <matheus.kaiser@gmail.com> (https://www.mrdeveloper.com.br/)",
@@ -40,7 +40,9 @@
40
40
  "errors": {
41
41
  "loadConfig": "Error loading configuration:",
42
42
  "saveConfig": "Error saving configuration:",
43
- "programNotInitialized": "Commander program not initialized"
43
+ "programNotInitialized": "Commander program not initialized",
44
+ "commanderInitFailed": "Failed to initialize Commander. Check if Commander.js is installed correctly.",
45
+ "commanderInitError": "Error initializing Commander:"
44
46
  },
45
47
  "selectBoard": "Select a board:",
46
48
  "selectList": "Select a list:",
@@ -40,7 +40,9 @@
40
40
  "errors": {
41
41
  "loadConfig": "Erro ao carregar configuração:",
42
42
  "saveConfig": "Erro ao salvar configuração:",
43
- "programNotInitialized": "Programa Commander não inicializado"
43
+ "programNotInitialized": "Programa Commander não inicializado",
44
+ "commanderInitFailed": "Falha na inicialização do Commander. Verifique se o Commander.js está instalado.",
45
+ "commanderInitError": "Erro ao inicializar Commander:"
44
46
  },
45
47
  "selectBoard": "Selecione um board:",
46
48
  "selectList": "Selecione uma lista:",
@@ -1,3 +1,4 @@
1
+ import type { Command } from 'commander';
1
2
  import type { OutputFormat } from '@/shared';
2
3
  import { readFileSync } from 'node:fs';
3
4
  import { join } from 'node:path';
@@ -7,7 +8,6 @@ import {
7
8
  FileConfigRepository,
8
9
  TrelloApiRepository,
9
10
  } from '@infrastructure/repositories';
10
- import { Command } from 'commander';
11
11
 
12
12
  import { t } from '@/i18n';
13
13
  import { ErrorHandler, OutputFormatter } from '@/shared';
@@ -17,22 +17,27 @@ export class CommandController {
17
17
  private authController: AuthController;
18
18
  private boardController!: BoardController;
19
19
  private cardController!: CardController;
20
- private program: Command;
20
+ private program: Command | null = null;
21
21
  private outputFormatter: OutputFormatter;
22
22
 
23
23
  constructor() {
24
24
  const configRepository = new FileConfigRepository();
25
25
  this.authController = new AuthController(configRepository);
26
- this.program = new Command();
27
26
  this.outputFormatter = new OutputFormatter();
28
- this.initializeProgram();
29
- this.setupCommands();
27
+ // Commander will be initialized lazily in initializeProgram
30
28
  }
31
29
 
32
- private initializeProgram(): void {
33
- // Ensure program is properly initialized
34
- if (!this.program) {
30
+ private async initializeProgram(): Promise<void> {
31
+ if (this.program) {
32
+ return;
33
+ }
34
+
35
+ try {
36
+ const { Command } = await import('commander');
35
37
  this.program = new Command();
38
+ } catch (error) {
39
+ console.error(t('menu.errors.commanderInitError'), error);
40
+ throw new Error(t('menu.errors.commanderInitFailed'));
36
41
  }
37
42
  }
38
43
 
@@ -57,8 +62,8 @@ export class CommandController {
57
62
  );
58
63
  }
59
64
 
60
- private setupCommands(): void {
61
- // Ensure program is initialized
65
+ private async setupCommands(): Promise<void> {
66
+ // Program should be initialized by now
62
67
  if (!this.program) {
63
68
  throw new Error(t('errors.programNotInitialized'));
64
69
  }
@@ -440,10 +445,8 @@ export class CommandController {
440
445
 
441
446
  async run(): Promise<void> {
442
447
  // Ensure program is initialized before parsing
443
- if (!this.program) {
444
- this.initializeProgram();
445
- this.setupCommands();
446
- }
448
+ await this.initializeProgram();
449
+ await this.setupCommands();
447
450
 
448
451
  // Fallback to interactive mode if no command specified
449
452
  if (process.argv.length === 2) {
@@ -453,7 +456,7 @@ export class CommandController {
453
456
  ).TrelloCliController(configRepository, this.outputFormatter);
454
457
  await cli.run();
455
458
  } else {
456
- this.program.parse();
459
+ this.program!.parse();
457
460
  }
458
461
  }
459
462
  }