trello-cli-unofficial 0.11.0 → 0.11.1

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.11.1](https://github.com/JaegerCaiser/trello-cli-unofficial/compare/v0.11.0...v0.11.1) (2025-11-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * use static import for Commander to fix cross-platform compatibility ([9796c57](https://github.com/JaegerCaiser/trello-cli-unofficial/commit/9796c57b2f24638a652b4bf989e798fccbc9ea76))
7
+
1
8
  # [0.11.0](https://github.com/JaegerCaiser/trello-cli-unofficial/compare/v0.10.8...v0.11.0) (2025-11-14)
2
9
 
3
10
 
package/dist/main.js CHANGED
@@ -28841,390 +28841,121 @@ var init_repositories = __esm(() => {
28841
28841
  init_TrelloApiRepository();
28842
28842
  });
28843
28843
 
28844
- // src/shared/ErrorHandler.ts
28845
- class ErrorHandler {
28846
- static handle(error, context) {
28847
- if (error instanceof TrelloCliError) {
28848
- this.handleTrelloError(error, context);
28849
- } else if (error instanceof Error) {
28850
- this.handleGenericError(error, context);
28851
- } else {
28852
- this.handleUnknownError(error, context);
28844
+ // node_modules/commander/lib/error.js
28845
+ var require_error = __commonJS((exports) => {
28846
+ class CommanderError extends Error {
28847
+ constructor(exitCode, code, message) {
28848
+ super(message);
28849
+ Error.captureStackTrace(this, this.constructor);
28850
+ this.name = this.constructor.name;
28851
+ this.code = code;
28852
+ this.exitCode = exitCode;
28853
+ this.nestedError = undefined;
28853
28854
  }
28854
28855
  }
28855
- static handleTrelloError(error, context) {
28856
- const prefix = context ? `[${context}] ` : "";
28857
- switch (error.code) {
28858
- case "AUTH_ERROR":
28859
- console.error(t2("errors.authFailed", { message: error.message }));
28860
- console.error(t2("errors.trySetup"));
28861
- break;
28862
- case "API_ERROR":
28863
- console.error(t2("errors.apiError", { statusCode: error.statusCode, message: error.message }));
28864
- if (error instanceof ApiError && error.endpoint) {
28865
- console.error(t2("errors.endpoint", { endpoint: error.endpoint }));
28866
- }
28867
- break;
28868
- case "VALIDATION_ERROR":
28869
- console.error(t2("errors.validationError", { message: error.message }));
28870
- if (error instanceof ValidationError2 && error.field) {
28871
- console.error(t2("errors.field", { field: error.field }));
28872
- }
28873
- break;
28874
- case "NOT_FOUND_ERROR":
28875
- console.error(t2("errors.notFound", { message: error.message }));
28876
- if (error instanceof NotFoundError) {
28877
- if (error.resourceType) {
28878
- console.error(t2("errors.resourceType", { resourceType: error.resourceType }));
28879
- }
28880
- if (error.resourceId) {
28881
- console.error(t2("errors.resourceId", { resourceId: error.resourceId }));
28882
- }
28883
- }
28884
- break;
28885
- case "CONFIG_ERROR":
28886
- console.error(t2("errors.configError", { message: error.message }));
28887
- console.error(t2("errors.checkConfig"));
28888
- break;
28889
- case "NETWORK_ERROR":
28890
- console.error(t2("errors.networkError", { message: error.message }));
28891
- console.error(t2("errors.checkConnection"));
28892
- break;
28893
- default:
28894
- console.error(`\u274C ${prefix}${error.message}`);
28856
+
28857
+ class InvalidArgumentError extends CommanderError {
28858
+ constructor(message) {
28859
+ super(1, "commander.invalidArgument", message);
28860
+ Error.captureStackTrace(this, this.constructor);
28861
+ this.name = this.constructor.name;
28895
28862
  }
28896
- process.exit(error.statusCode || 1);
28897
28863
  }
28898
- static handleGenericError(error, _context) {
28899
- console.error(t2("errors.unexpectedError", { message: error.message }));
28900
- if (true) {
28901
- console.error(t2("errors.stackTrace"), error.stack);
28864
+ exports.CommanderError = CommanderError;
28865
+ exports.InvalidArgumentError = InvalidArgumentError;
28866
+ });
28867
+
28868
+ // node_modules/commander/lib/argument.js
28869
+ var require_argument = __commonJS((exports) => {
28870
+ var { InvalidArgumentError } = require_error();
28871
+
28872
+ class Argument {
28873
+ constructor(name, description) {
28874
+ this.description = description || "";
28875
+ this.variadic = false;
28876
+ this.parseArg = undefined;
28877
+ this.defaultValue = undefined;
28878
+ this.defaultValueDescription = undefined;
28879
+ this.argChoices = undefined;
28880
+ switch (name[0]) {
28881
+ case "<":
28882
+ this.required = true;
28883
+ this._name = name.slice(1, -1);
28884
+ break;
28885
+ case "[":
28886
+ this.required = false;
28887
+ this._name = name.slice(1, -1);
28888
+ break;
28889
+ default:
28890
+ this.required = true;
28891
+ this._name = name;
28892
+ break;
28893
+ }
28894
+ if (this._name.endsWith("...")) {
28895
+ this.variadic = true;
28896
+ this._name = this._name.slice(0, -3);
28897
+ }
28902
28898
  }
28903
- process.exit(1);
28904
- }
28905
- static handleUnknownError(error, _context) {
28906
- console.error(t2("errors.unknownError"), error);
28907
- process.exit(1);
28908
- }
28909
- static async withErrorHandling(operation, context) {
28910
- try {
28911
- return await operation();
28912
- } catch (error) {
28913
- this.handle(error, context);
28914
- throw error;
28899
+ name() {
28900
+ return this._name;
28915
28901
  }
28916
- }
28917
- static fromApiResponse(response, endpoint) {
28918
- const statusCode = response.status || response.statusCode || 500;
28919
- const message = response.message || response.error || t2("api.unknownApiError");
28920
- switch (statusCode) {
28921
- case 401:
28922
- return new AuthenticationError(t2("api.invalidToken"));
28923
- case 403:
28924
- return new AuthenticationError("Access denied");
28925
- case 404:
28926
- return new NotFoundError(t2("api.resourceNotFound"), "unknown");
28927
- case 400:
28928
- return new ValidationError2(message);
28929
- case 429:
28930
- return new ApiError(t2("api.rateLimitExceeded"), statusCode, endpoint);
28931
- case 500:
28932
- return new ApiError(t2("api.internalServerError"), statusCode, endpoint);
28933
- default:
28934
- return new ApiError(message, statusCode, endpoint);
28902
+ _collectValue(value, previous) {
28903
+ if (previous === this.defaultValue || !Array.isArray(previous)) {
28904
+ return [value];
28905
+ }
28906
+ previous.push(value);
28907
+ return previous;
28935
28908
  }
28936
- }
28937
- }
28938
- var TrelloCliError, AuthenticationError, ApiError, ValidationError2, NotFoundError;
28939
- var init_ErrorHandler = __esm(() => {
28940
- init_i18n();
28941
- TrelloCliError = class TrelloCliError extends Error {
28942
- code;
28943
- statusCode;
28944
- constructor(message, code, statusCode) {
28945
- super(message);
28946
- this.code = code;
28947
- this.statusCode = statusCode;
28948
- this.name = this.constructor.name;
28909
+ default(value, description) {
28910
+ this.defaultValue = value;
28911
+ this.defaultValueDescription = description;
28912
+ return this;
28949
28913
  }
28950
- };
28951
- AuthenticationError = class AuthenticationError extends TrelloCliError {
28952
- constructor(message = "Authentication failed") {
28953
- super(message, "AUTH_ERROR", 401);
28914
+ argParser(fn) {
28915
+ this.parseArg = fn;
28916
+ return this;
28954
28917
  }
28955
- };
28956
- ApiError = class ApiError extends TrelloCliError {
28957
- statusCode;
28958
- endpoint;
28959
- constructor(message, statusCode, endpoint) {
28960
- super(message, "API_ERROR", statusCode);
28961
- this.statusCode = statusCode;
28962
- this.endpoint = endpoint;
28918
+ choices(values) {
28919
+ this.argChoices = values.slice();
28920
+ this.parseArg = (arg, previous) => {
28921
+ if (!this.argChoices.includes(arg)) {
28922
+ throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
28923
+ }
28924
+ if (this.variadic) {
28925
+ return this._collectValue(arg, previous);
28926
+ }
28927
+ return arg;
28928
+ };
28929
+ return this;
28963
28930
  }
28964
- };
28965
- ValidationError2 = class ValidationError2 extends TrelloCliError {
28966
- field;
28967
- constructor(message, field) {
28968
- super(message, "VALIDATION_ERROR", 400);
28969
- this.field = field;
28931
+ argRequired() {
28932
+ this.required = true;
28933
+ return this;
28970
28934
  }
28971
- };
28972
- NotFoundError = class NotFoundError extends TrelloCliError {
28973
- resourceType;
28974
- resourceId;
28975
- constructor(message, resourceType, resourceId) {
28976
- super(message, "NOT_FOUND_ERROR", 404);
28977
- this.resourceType = resourceType;
28978
- this.resourceId = resourceId;
28935
+ argOptional() {
28936
+ this.required = false;
28937
+ return this;
28979
28938
  }
28980
- };
28981
- });
28982
-
28983
- // src/shared/OutputFormatter.ts
28984
- class OutputFormatter {
28985
- format;
28986
- constructor(format = "table") {
28987
- this.format = format;
28988
28939
  }
28989
- setFormat(format) {
28990
- this.format = format;
28940
+ function humanReadableArgName(arg) {
28941
+ const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
28942
+ return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
28991
28943
  }
28992
- output(data, options) {
28993
- const format = options?.format || this.format;
28994
- switch (format) {
28995
- case "json":
28996
- this.outputJson(data);
28997
- break;
28998
- case "csv":
28999
- this.outputCsv(data, options);
29000
- break;
29001
- case "table":
29002
- default:
29003
- this.outputTable(data, options);
29004
- break;
29005
- }
29006
- }
29007
- outputJson(data) {
29008
- console.log(JSON.stringify(data, null, 2));
29009
- }
29010
- outputCsv(data, options) {
29011
- if (!Array.isArray(data) || data.length === 0) {
29012
- console.log(t2("common.noData"));
29013
- return;
29014
- }
29015
- const firstItem = data[0];
29016
- if (!firstItem) {
29017
- console.log(t2("common.noData"));
29018
- return;
29019
- }
29020
- const plainItem = this.toPlainObject(firstItem);
29021
- const fields = options?.fields || Object.keys(plainItem);
29022
- const headers = options?.headers || fields;
29023
- console.log(headers.join(","));
29024
- for (const item of data) {
29025
- const plainObject = this.toPlainObject(item);
29026
- const row = fields.map((field) => {
29027
- const value = plainObject[field];
29028
- const stringValue = String(value || "");
29029
- if (stringValue.includes(",") || stringValue.includes('"') || stringValue.includes(`
29030
- `)) {
29031
- return `"${stringValue.replace(/"/g, '""')}"`;
29032
- }
29033
- return stringValue;
29034
- });
29035
- console.log(row.join(","));
29036
- }
29037
- }
29038
- outputTable(data, options) {
29039
- if (!Array.isArray(data) || data.length === 0) {
29040
- console.log(t2("common.noData"));
29041
- return;
29042
- }
29043
- const firstItem = data[0];
29044
- if (!firstItem) {
29045
- console.log(t2("common.noData"));
29046
- return;
29047
- }
29048
- const plainItem = this.toPlainObject(firstItem);
29049
- const fields = options?.fields || Object.keys(plainItem);
29050
- const headers = options?.headers || fields;
29051
- const columnWidths = headers.map((header, index) => {
29052
- const field = fields[index];
29053
- const headerWidth = header.length;
29054
- const maxDataWidth = Math.max(...data.map((item) => {
29055
- const plainObject = this.toPlainObject(item);
29056
- return String(plainObject[field] || "").length;
29057
- }));
29058
- return Math.max(headerWidth, maxDataWidth);
29059
- });
29060
- const headerRow = headers.map((header, index) => header.padEnd(columnWidths[index])).join(" | ");
29061
- console.log(headerRow);
29062
- const separator = columnWidths.map((width) => "-".repeat(width)).join("-+-");
29063
- console.log(separator);
29064
- for (const item of data) {
29065
- const plainObject = this.toPlainObject(item);
29066
- const row = fields.map((field, index) => {
29067
- const value = String(plainObject[field] || "");
29068
- return value.padEnd(columnWidths[index]);
29069
- }).join(" | ");
29070
- console.log(row);
29071
- }
29072
- }
29073
- toPlainObject(obj) {
29074
- if (obj === null || obj === undefined) {
29075
- return {};
29076
- }
29077
- if (typeof obj === "object" && obj.constructor !== Object) {
29078
- const plain = {};
29079
- for (const key of Object.keys(obj)) {
29080
- plain[key] = obj[key];
29081
- }
29082
- return plain;
29083
- }
29084
- return obj;
29085
- }
29086
- message(message) {
29087
- console.log(message);
29088
- }
29089
- error(message) {
29090
- console.error(`\u274C ${message}`);
29091
- }
29092
- success(message) {
29093
- console.log(`\u2705 ${message}`);
29094
- }
29095
- warning(message) {
29096
- console.log(`\u26A0\uFE0F ${message}`);
29097
- }
29098
- info(message) {
29099
- console.log(`\u2139\uFE0F ${message}`);
29100
- }
29101
- }
29102
- var init_OutputFormatter = __esm(() => {
29103
- init_i18n();
29104
- });
29105
-
29106
- // src/shared/index.ts
29107
- var init_shared = __esm(() => {
29108
- init_ErrorHandler();
29109
- init_OutputFormatter();
29110
- init_types();
29111
- });
29112
-
29113
- // node_modules/commander/lib/error.js
29114
- var require_error = __commonJS((exports) => {
29115
- class CommanderError extends Error {
29116
- constructor(exitCode, code, message) {
29117
- super(message);
29118
- Error.captureStackTrace(this, this.constructor);
29119
- this.name = this.constructor.name;
29120
- this.code = code;
29121
- this.exitCode = exitCode;
29122
- this.nestedError = undefined;
29123
- }
29124
- }
29125
-
29126
- class InvalidArgumentError extends CommanderError {
29127
- constructor(message) {
29128
- super(1, "commander.invalidArgument", message);
29129
- Error.captureStackTrace(this, this.constructor);
29130
- this.name = this.constructor.name;
29131
- }
29132
- }
29133
- exports.CommanderError = CommanderError;
29134
- exports.InvalidArgumentError = InvalidArgumentError;
29135
- });
29136
-
29137
- // node_modules/commander/lib/argument.js
29138
- var require_argument = __commonJS((exports) => {
29139
- var { InvalidArgumentError } = require_error();
29140
-
29141
- class Argument {
29142
- constructor(name, description) {
29143
- this.description = description || "";
29144
- this.variadic = false;
29145
- this.parseArg = undefined;
29146
- this.defaultValue = undefined;
29147
- this.defaultValueDescription = undefined;
29148
- this.argChoices = undefined;
29149
- switch (name[0]) {
29150
- case "<":
29151
- this.required = true;
29152
- this._name = name.slice(1, -1);
29153
- break;
29154
- case "[":
29155
- this.required = false;
29156
- this._name = name.slice(1, -1);
29157
- break;
29158
- default:
29159
- this.required = true;
29160
- this._name = name;
29161
- break;
29162
- }
29163
- if (this._name.endsWith("...")) {
29164
- this.variadic = true;
29165
- this._name = this._name.slice(0, -3);
29166
- }
29167
- }
29168
- name() {
29169
- return this._name;
29170
- }
29171
- _collectValue(value, previous) {
29172
- if (previous === this.defaultValue || !Array.isArray(previous)) {
29173
- return [value];
29174
- }
29175
- previous.push(value);
29176
- return previous;
29177
- }
29178
- default(value, description) {
29179
- this.defaultValue = value;
29180
- this.defaultValueDescription = description;
29181
- return this;
29182
- }
29183
- argParser(fn) {
29184
- this.parseArg = fn;
29185
- return this;
29186
- }
29187
- choices(values) {
29188
- this.argChoices = values.slice();
29189
- this.parseArg = (arg, previous) => {
29190
- if (!this.argChoices.includes(arg)) {
29191
- throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
29192
- }
29193
- if (this.variadic) {
29194
- return this._collectValue(arg, previous);
29195
- }
29196
- return arg;
29197
- };
29198
- return this;
29199
- }
29200
- argRequired() {
29201
- this.required = true;
29202
- return this;
29203
- }
29204
- argOptional() {
29205
- this.required = false;
29206
- return this;
29207
- }
29208
- }
29209
- function humanReadableArgName(arg) {
29210
- const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
29211
- return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
29212
- }
29213
- exports.Argument = Argument;
29214
- exports.humanReadableArgName = humanReadableArgName;
29215
- });
29216
-
29217
- // node_modules/commander/lib/help.js
29218
- var require_help = __commonJS((exports) => {
29219
- var { humanReadableArgName } = require_argument();
29220
-
29221
- class Help {
29222
- constructor() {
29223
- this.helpWidth = undefined;
29224
- this.minWidthToWrap = 40;
29225
- this.sortSubcommands = false;
29226
- this.sortOptions = false;
29227
- this.showGlobalOptions = false;
28944
+ exports.Argument = Argument;
28945
+ exports.humanReadableArgName = humanReadableArgName;
28946
+ });
28947
+
28948
+ // node_modules/commander/lib/help.js
28949
+ var require_help = __commonJS((exports) => {
28950
+ var { humanReadableArgName } = require_argument();
28951
+
28952
+ class Help {
28953
+ constructor() {
28954
+ this.helpWidth = undefined;
28955
+ this.minWidthToWrap = 40;
28956
+ this.sortSubcommands = false;
28957
+ this.sortOptions = false;
28958
+ this.showGlobalOptions = false;
29228
28959
  }
29229
28960
  prepareContext(contextOptions) {
29230
28961
  this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
@@ -31048,192 +30779,447 @@ Expecting one of '${allowedValues.join("', '")}'`);
31048
30779
  };
31049
30780
  return { error, write, hasColors, helpWidth };
31050
30781
  }
31051
- outputHelp(contextOptions) {
31052
- let deprecatedCallback;
31053
- if (typeof contextOptions === "function") {
31054
- deprecatedCallback = contextOptions;
31055
- contextOptions = undefined;
31056
- }
31057
- const outputContext = this._getOutputContext(contextOptions);
31058
- const eventContext = {
31059
- error: outputContext.error,
31060
- write: outputContext.write,
31061
- command: this
31062
- };
31063
- this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
31064
- this.emit("beforeHelp", eventContext);
31065
- let helpInformation = this.helpInformation({ error: outputContext.error });
31066
- if (deprecatedCallback) {
31067
- helpInformation = deprecatedCallback(helpInformation);
31068
- if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
31069
- throw new Error("outputHelp callback must return a string or a Buffer");
31070
- }
31071
- }
31072
- outputContext.write(helpInformation);
31073
- if (this._getHelpOption()?.long) {
31074
- this.emit(this._getHelpOption().long);
31075
- }
31076
- this.emit("afterHelp", eventContext);
31077
- this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", eventContext));
30782
+ outputHelp(contextOptions) {
30783
+ let deprecatedCallback;
30784
+ if (typeof contextOptions === "function") {
30785
+ deprecatedCallback = contextOptions;
30786
+ contextOptions = undefined;
30787
+ }
30788
+ const outputContext = this._getOutputContext(contextOptions);
30789
+ const eventContext = {
30790
+ error: outputContext.error,
30791
+ write: outputContext.write,
30792
+ command: this
30793
+ };
30794
+ this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
30795
+ this.emit("beforeHelp", eventContext);
30796
+ let helpInformation = this.helpInformation({ error: outputContext.error });
30797
+ if (deprecatedCallback) {
30798
+ helpInformation = deprecatedCallback(helpInformation);
30799
+ if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
30800
+ throw new Error("outputHelp callback must return a string or a Buffer");
30801
+ }
30802
+ }
30803
+ outputContext.write(helpInformation);
30804
+ if (this._getHelpOption()?.long) {
30805
+ this.emit(this._getHelpOption().long);
30806
+ }
30807
+ this.emit("afterHelp", eventContext);
30808
+ this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", eventContext));
30809
+ }
30810
+ helpOption(flags, description) {
30811
+ if (typeof flags === "boolean") {
30812
+ if (flags) {
30813
+ if (this._helpOption === null)
30814
+ this._helpOption = undefined;
30815
+ if (this._defaultOptionGroup) {
30816
+ this._initOptionGroup(this._getHelpOption());
30817
+ }
30818
+ } else {
30819
+ this._helpOption = null;
30820
+ }
30821
+ return this;
30822
+ }
30823
+ this._helpOption = this.createOption(flags ?? "-h, --help", description ?? "display help for command");
30824
+ if (flags || description)
30825
+ this._initOptionGroup(this._helpOption);
30826
+ return this;
30827
+ }
30828
+ _getHelpOption() {
30829
+ if (this._helpOption === undefined) {
30830
+ this.helpOption(undefined, undefined);
30831
+ }
30832
+ return this._helpOption;
30833
+ }
30834
+ addHelpOption(option) {
30835
+ this._helpOption = option;
30836
+ this._initOptionGroup(option);
30837
+ return this;
30838
+ }
30839
+ help(contextOptions) {
30840
+ this.outputHelp(contextOptions);
30841
+ let exitCode = Number(process4.exitCode ?? 0);
30842
+ if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
30843
+ exitCode = 1;
30844
+ }
30845
+ this._exit(exitCode, "commander.help", "(outputHelp)");
30846
+ }
30847
+ addHelpText(position, text) {
30848
+ const allowedValues = ["beforeAll", "before", "after", "afterAll"];
30849
+ if (!allowedValues.includes(position)) {
30850
+ throw new Error(`Unexpected value for position to addHelpText.
30851
+ Expecting one of '${allowedValues.join("', '")}'`);
30852
+ }
30853
+ const helpEvent = `${position}Help`;
30854
+ this.on(helpEvent, (context) => {
30855
+ let helpStr;
30856
+ if (typeof text === "function") {
30857
+ helpStr = text({ error: context.error, command: context.command });
30858
+ } else {
30859
+ helpStr = text;
30860
+ }
30861
+ if (helpStr) {
30862
+ context.write(`${helpStr}
30863
+ `);
30864
+ }
30865
+ });
30866
+ return this;
30867
+ }
30868
+ _outputHelpIfRequested(args) {
30869
+ const helpOption = this._getHelpOption();
30870
+ const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
30871
+ if (helpRequested) {
30872
+ this.outputHelp();
30873
+ this._exit(0, "commander.helpDisplayed", "(outputHelp)");
30874
+ }
30875
+ }
30876
+ }
30877
+ function incrementNodeInspectorPort(args) {
30878
+ return args.map((arg) => {
30879
+ if (!arg.startsWith("--inspect")) {
30880
+ return arg;
30881
+ }
30882
+ let debugOption;
30883
+ let debugHost = "127.0.0.1";
30884
+ let debugPort = "9229";
30885
+ let match;
30886
+ if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
30887
+ debugOption = match[1];
30888
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
30889
+ debugOption = match[1];
30890
+ if (/^\d+$/.test(match[3])) {
30891
+ debugPort = match[3];
30892
+ } else {
30893
+ debugHost = match[3];
30894
+ }
30895
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
30896
+ debugOption = match[1];
30897
+ debugHost = match[3];
30898
+ debugPort = match[4];
30899
+ }
30900
+ if (debugOption && debugPort !== "0") {
30901
+ return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
30902
+ }
30903
+ return arg;
30904
+ });
30905
+ }
30906
+ function useColor() {
30907
+ if (process4.env.NO_COLOR || process4.env.FORCE_COLOR === "0" || process4.env.FORCE_COLOR === "false")
30908
+ return false;
30909
+ if (process4.env.FORCE_COLOR || process4.env.CLICOLOR_FORCE !== undefined)
30910
+ return true;
30911
+ return;
30912
+ }
30913
+ exports.Command = Command;
30914
+ exports.useColor = useColor;
30915
+ });
30916
+
30917
+ // node_modules/commander/index.js
30918
+ var require_commander = __commonJS((exports) => {
30919
+ var { Argument } = require_argument();
30920
+ var { Command } = require_command();
30921
+ var { CommanderError, InvalidArgumentError } = require_error();
30922
+ var { Help } = require_help();
30923
+ var { Option } = require_option();
30924
+ exports.program = new Command;
30925
+ exports.createCommand = (name) => new Command(name);
30926
+ exports.createOption = (flags, description) => new Option(flags, description);
30927
+ exports.createArgument = (name, description) => new Argument(name, description);
30928
+ exports.Command = Command;
30929
+ exports.Option = Option;
30930
+ exports.Argument = Argument;
30931
+ exports.Help = Help;
30932
+ exports.CommanderError = CommanderError;
30933
+ exports.InvalidArgumentError = InvalidArgumentError;
30934
+ exports.InvalidOptionArgumentError = InvalidArgumentError;
30935
+ });
30936
+
30937
+ // node_modules/commander/esm.mjs
30938
+ var import__, program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help;
30939
+ var init_esm17 = __esm(() => {
30940
+ import__ = __toESM(require_commander(), 1);
30941
+ ({
30942
+ program,
30943
+ createCommand,
30944
+ createArgument,
30945
+ createOption,
30946
+ CommanderError,
30947
+ InvalidArgumentError,
30948
+ InvalidOptionArgumentError,
30949
+ Command,
30950
+ Argument,
30951
+ Option,
30952
+ Help
30953
+ } = import__.default);
30954
+ });
30955
+
30956
+ // src/shared/ErrorHandler.ts
30957
+ class ErrorHandler {
30958
+ static handle(error, context) {
30959
+ if (error instanceof TrelloCliError) {
30960
+ this.handleTrelloError(error, context);
30961
+ } else if (error instanceof Error) {
30962
+ this.handleGenericError(error, context);
30963
+ } else {
30964
+ this.handleUnknownError(error, context);
30965
+ }
30966
+ }
30967
+ static handleTrelloError(error, context) {
30968
+ const prefix = context ? `[${context}] ` : "";
30969
+ switch (error.code) {
30970
+ case "AUTH_ERROR":
30971
+ console.error(t2("errors.authFailed", { message: error.message }));
30972
+ console.error(t2("errors.trySetup"));
30973
+ break;
30974
+ case "API_ERROR":
30975
+ console.error(t2("errors.apiError", { statusCode: error.statusCode, message: error.message }));
30976
+ if (error instanceof ApiError && error.endpoint) {
30977
+ console.error(t2("errors.endpoint", { endpoint: error.endpoint }));
30978
+ }
30979
+ break;
30980
+ case "VALIDATION_ERROR":
30981
+ console.error(t2("errors.validationError", { message: error.message }));
30982
+ if (error instanceof ValidationError2 && error.field) {
30983
+ console.error(t2("errors.field", { field: error.field }));
30984
+ }
30985
+ break;
30986
+ case "NOT_FOUND_ERROR":
30987
+ console.error(t2("errors.notFound", { message: error.message }));
30988
+ if (error instanceof NotFoundError) {
30989
+ if (error.resourceType) {
30990
+ console.error(t2("errors.resourceType", { resourceType: error.resourceType }));
30991
+ }
30992
+ if (error.resourceId) {
30993
+ console.error(t2("errors.resourceId", { resourceId: error.resourceId }));
30994
+ }
30995
+ }
30996
+ break;
30997
+ case "CONFIG_ERROR":
30998
+ console.error(t2("errors.configError", { message: error.message }));
30999
+ console.error(t2("errors.checkConfig"));
31000
+ break;
31001
+ case "NETWORK_ERROR":
31002
+ console.error(t2("errors.networkError", { message: error.message }));
31003
+ console.error(t2("errors.checkConnection"));
31004
+ break;
31005
+ default:
31006
+ console.error(`\u274C ${prefix}${error.message}`);
31007
+ }
31008
+ process.exit(error.statusCode || 1);
31009
+ }
31010
+ static handleGenericError(error, _context) {
31011
+ console.error(t2("errors.unexpectedError", { message: error.message }));
31012
+ if (true) {
31013
+ console.error(t2("errors.stackTrace"), error.stack);
31014
+ }
31015
+ process.exit(1);
31016
+ }
31017
+ static handleUnknownError(error, _context) {
31018
+ console.error(t2("errors.unknownError"), error);
31019
+ process.exit(1);
31020
+ }
31021
+ static async withErrorHandling(operation, context) {
31022
+ try {
31023
+ return await operation();
31024
+ } catch (error) {
31025
+ this.handle(error, context);
31026
+ throw error;
31027
+ }
31028
+ }
31029
+ static fromApiResponse(response, endpoint) {
31030
+ const statusCode = response.status || response.statusCode || 500;
31031
+ const message = response.message || response.error || t2("api.unknownApiError");
31032
+ switch (statusCode) {
31033
+ case 401:
31034
+ return new AuthenticationError(t2("api.invalidToken"));
31035
+ case 403:
31036
+ return new AuthenticationError("Access denied");
31037
+ case 404:
31038
+ return new NotFoundError(t2("api.resourceNotFound"), "unknown");
31039
+ case 400:
31040
+ return new ValidationError2(message);
31041
+ case 429:
31042
+ return new ApiError(t2("api.rateLimitExceeded"), statusCode, endpoint);
31043
+ case 500:
31044
+ return new ApiError(t2("api.internalServerError"), statusCode, endpoint);
31045
+ default:
31046
+ return new ApiError(message, statusCode, endpoint);
31047
+ }
31048
+ }
31049
+ }
31050
+ var TrelloCliError, AuthenticationError, ApiError, ValidationError2, NotFoundError;
31051
+ var init_ErrorHandler = __esm(() => {
31052
+ init_i18n();
31053
+ TrelloCliError = class TrelloCliError extends Error {
31054
+ code;
31055
+ statusCode;
31056
+ constructor(message, code, statusCode) {
31057
+ super(message);
31058
+ this.code = code;
31059
+ this.statusCode = statusCode;
31060
+ this.name = this.constructor.name;
31061
+ }
31062
+ };
31063
+ AuthenticationError = class AuthenticationError extends TrelloCliError {
31064
+ constructor(message = "Authentication failed") {
31065
+ super(message, "AUTH_ERROR", 401);
31066
+ }
31067
+ };
31068
+ ApiError = class ApiError extends TrelloCliError {
31069
+ statusCode;
31070
+ endpoint;
31071
+ constructor(message, statusCode, endpoint) {
31072
+ super(message, "API_ERROR", statusCode);
31073
+ this.statusCode = statusCode;
31074
+ this.endpoint = endpoint;
31075
+ }
31076
+ };
31077
+ ValidationError2 = class ValidationError2 extends TrelloCliError {
31078
+ field;
31079
+ constructor(message, field) {
31080
+ super(message, "VALIDATION_ERROR", 400);
31081
+ this.field = field;
31082
+ }
31083
+ };
31084
+ NotFoundError = class NotFoundError extends TrelloCliError {
31085
+ resourceType;
31086
+ resourceId;
31087
+ constructor(message, resourceType, resourceId) {
31088
+ super(message, "NOT_FOUND_ERROR", 404);
31089
+ this.resourceType = resourceType;
31090
+ this.resourceId = resourceId;
31091
+ }
31092
+ };
31093
+ });
31094
+
31095
+ // src/shared/OutputFormatter.ts
31096
+ class OutputFormatter {
31097
+ format;
31098
+ constructor(format = "table") {
31099
+ this.format = format;
31100
+ }
31101
+ setFormat(format) {
31102
+ this.format = format;
31103
+ }
31104
+ output(data, options) {
31105
+ const format = options?.format || this.format;
31106
+ switch (format) {
31107
+ case "json":
31108
+ this.outputJson(data);
31109
+ break;
31110
+ case "csv":
31111
+ this.outputCsv(data, options);
31112
+ break;
31113
+ case "table":
31114
+ default:
31115
+ this.outputTable(data, options);
31116
+ break;
31117
+ }
31118
+ }
31119
+ outputJson(data) {
31120
+ console.log(JSON.stringify(data, null, 2));
31121
+ }
31122
+ outputCsv(data, options) {
31123
+ if (!Array.isArray(data) || data.length === 0) {
31124
+ console.log(t2("common.noData"));
31125
+ return;
31078
31126
  }
31079
- helpOption(flags, description) {
31080
- if (typeof flags === "boolean") {
31081
- if (flags) {
31082
- if (this._helpOption === null)
31083
- this._helpOption = undefined;
31084
- if (this._defaultOptionGroup) {
31085
- this._initOptionGroup(this._getHelpOption());
31086
- }
31087
- } else {
31088
- this._helpOption = null;
31127
+ const firstItem = data[0];
31128
+ if (!firstItem) {
31129
+ console.log(t2("common.noData"));
31130
+ return;
31131
+ }
31132
+ const plainItem = this.toPlainObject(firstItem);
31133
+ const fields = options?.fields || Object.keys(plainItem);
31134
+ const headers = options?.headers || fields;
31135
+ console.log(headers.join(","));
31136
+ for (const item of data) {
31137
+ const plainObject = this.toPlainObject(item);
31138
+ const row = fields.map((field) => {
31139
+ const value = plainObject[field];
31140
+ const stringValue = String(value || "");
31141
+ if (stringValue.includes(",") || stringValue.includes('"') || stringValue.includes(`
31142
+ `)) {
31143
+ return `"${stringValue.replace(/"/g, '""')}"`;
31089
31144
  }
31090
- return this;
31091
- }
31092
- this._helpOption = this.createOption(flags ?? "-h, --help", description ?? "display help for command");
31093
- if (flags || description)
31094
- this._initOptionGroup(this._helpOption);
31095
- return this;
31145
+ return stringValue;
31146
+ });
31147
+ console.log(row.join(","));
31096
31148
  }
31097
- _getHelpOption() {
31098
- if (this._helpOption === undefined) {
31099
- this.helpOption(undefined, undefined);
31100
- }
31101
- return this._helpOption;
31149
+ }
31150
+ outputTable(data, options) {
31151
+ if (!Array.isArray(data) || data.length === 0) {
31152
+ console.log(t2("common.noData"));
31153
+ return;
31102
31154
  }
31103
- addHelpOption(option) {
31104
- this._helpOption = option;
31105
- this._initOptionGroup(option);
31106
- return this;
31155
+ const firstItem = data[0];
31156
+ if (!firstItem) {
31157
+ console.log(t2("common.noData"));
31158
+ return;
31107
31159
  }
31108
- help(contextOptions) {
31109
- this.outputHelp(contextOptions);
31110
- let exitCode = Number(process4.exitCode ?? 0);
31111
- if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
31112
- exitCode = 1;
31113
- }
31114
- this._exit(exitCode, "commander.help", "(outputHelp)");
31160
+ const plainItem = this.toPlainObject(firstItem);
31161
+ const fields = options?.fields || Object.keys(plainItem);
31162
+ const headers = options?.headers || fields;
31163
+ const columnWidths = headers.map((header, index) => {
31164
+ const field = fields[index];
31165
+ const headerWidth = header.length;
31166
+ const maxDataWidth = Math.max(...data.map((item) => {
31167
+ const plainObject = this.toPlainObject(item);
31168
+ return String(plainObject[field] || "").length;
31169
+ }));
31170
+ return Math.max(headerWidth, maxDataWidth);
31171
+ });
31172
+ const headerRow = headers.map((header, index) => header.padEnd(columnWidths[index])).join(" | ");
31173
+ console.log(headerRow);
31174
+ const separator = columnWidths.map((width) => "-".repeat(width)).join("-+-");
31175
+ console.log(separator);
31176
+ for (const item of data) {
31177
+ const plainObject = this.toPlainObject(item);
31178
+ const row = fields.map((field, index) => {
31179
+ const value = String(plainObject[field] || "");
31180
+ return value.padEnd(columnWidths[index]);
31181
+ }).join(" | ");
31182
+ console.log(row);
31115
31183
  }
31116
- addHelpText(position, text) {
31117
- const allowedValues = ["beforeAll", "before", "after", "afterAll"];
31118
- if (!allowedValues.includes(position)) {
31119
- throw new Error(`Unexpected value for position to addHelpText.
31120
- Expecting one of '${allowedValues.join("', '")}'`);
31121
- }
31122
- const helpEvent = `${position}Help`;
31123
- this.on(helpEvent, (context) => {
31124
- let helpStr;
31125
- if (typeof text === "function") {
31126
- helpStr = text({ error: context.error, command: context.command });
31127
- } else {
31128
- helpStr = text;
31129
- }
31130
- if (helpStr) {
31131
- context.write(`${helpStr}
31132
- `);
31133
- }
31134
- });
31135
- return this;
31184
+ }
31185
+ toPlainObject(obj) {
31186
+ if (obj === null || obj === undefined) {
31187
+ return {};
31136
31188
  }
31137
- _outputHelpIfRequested(args) {
31138
- const helpOption = this._getHelpOption();
31139
- const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
31140
- if (helpRequested) {
31141
- this.outputHelp();
31142
- this._exit(0, "commander.helpDisplayed", "(outputHelp)");
31189
+ if (typeof obj === "object" && obj.constructor !== Object) {
31190
+ const plain = {};
31191
+ for (const key of Object.keys(obj)) {
31192
+ plain[key] = obj[key];
31143
31193
  }
31194
+ return plain;
31144
31195
  }
31196
+ return obj;
31145
31197
  }
31146
- function incrementNodeInspectorPort(args) {
31147
- return args.map((arg) => {
31148
- if (!arg.startsWith("--inspect")) {
31149
- return arg;
31150
- }
31151
- let debugOption;
31152
- let debugHost = "127.0.0.1";
31153
- let debugPort = "9229";
31154
- let match;
31155
- if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
31156
- debugOption = match[1];
31157
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
31158
- debugOption = match[1];
31159
- if (/^\d+$/.test(match[3])) {
31160
- debugPort = match[3];
31161
- } else {
31162
- debugHost = match[3];
31163
- }
31164
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
31165
- debugOption = match[1];
31166
- debugHost = match[3];
31167
- debugPort = match[4];
31168
- }
31169
- if (debugOption && debugPort !== "0") {
31170
- return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
31171
- }
31172
- return arg;
31173
- });
31198
+ message(message) {
31199
+ console.log(message);
31174
31200
  }
31175
- function useColor() {
31176
- if (process4.env.NO_COLOR || process4.env.FORCE_COLOR === "0" || process4.env.FORCE_COLOR === "false")
31177
- return false;
31178
- if (process4.env.FORCE_COLOR || process4.env.CLICOLOR_FORCE !== undefined)
31179
- return true;
31180
- return;
31201
+ error(message) {
31202
+ console.error(`\u274C ${message}`);
31181
31203
  }
31182
- exports.Command = Command;
31183
- exports.useColor = useColor;
31184
- });
31185
-
31186
- // node_modules/commander/index.js
31187
- var require_commander = __commonJS((exports) => {
31188
- var { Argument } = require_argument();
31189
- var { Command } = require_command();
31190
- var { CommanderError, InvalidArgumentError } = require_error();
31191
- var { Help } = require_help();
31192
- var { Option } = require_option();
31193
- exports.program = new Command;
31194
- exports.createCommand = (name) => new Command(name);
31195
- exports.createOption = (flags, description) => new Option(flags, description);
31196
- exports.createArgument = (name, description) => new Argument(name, description);
31197
- exports.Command = Command;
31198
- exports.Option = Option;
31199
- exports.Argument = Argument;
31200
- exports.Help = Help;
31201
- exports.CommanderError = CommanderError;
31202
- exports.InvalidArgumentError = InvalidArgumentError;
31203
- exports.InvalidOptionArgumentError = InvalidArgumentError;
31204
+ success(message) {
31205
+ console.log(`\u2705 ${message}`);
31206
+ }
31207
+ warning(message) {
31208
+ console.log(`\u26A0\uFE0F ${message}`);
31209
+ }
31210
+ info(message) {
31211
+ console.log(`\u2139\uFE0F ${message}`);
31212
+ }
31213
+ }
31214
+ var init_OutputFormatter = __esm(() => {
31215
+ init_i18n();
31204
31216
  });
31205
31217
 
31206
- // node_modules/commander/esm.mjs
31207
- var exports_esm = {};
31208
- __export(exports_esm, {
31209
- program: () => program,
31210
- createOption: () => createOption,
31211
- createCommand: () => createCommand,
31212
- createArgument: () => createArgument,
31213
- Option: () => Option,
31214
- InvalidOptionArgumentError: () => InvalidOptionArgumentError,
31215
- InvalidArgumentError: () => InvalidArgumentError,
31216
- Help: () => Help,
31217
- CommanderError: () => CommanderError,
31218
- Command: () => Command,
31219
- Argument: () => Argument
31220
- });
31221
- var import__, program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help;
31222
- var init_esm17 = __esm(() => {
31223
- import__ = __toESM(require_commander(), 1);
31224
- ({
31225
- program,
31226
- createCommand,
31227
- createArgument,
31228
- createOption,
31229
- CommanderError,
31230
- InvalidArgumentError,
31231
- InvalidOptionArgumentError,
31232
- Command,
31233
- Argument,
31234
- Option,
31235
- Help
31236
- } = import__.default);
31218
+ // src/shared/index.ts
31219
+ var init_shared = __esm(() => {
31220
+ init_ErrorHandler();
31221
+ init_OutputFormatter();
31222
+ init_types();
31237
31223
  });
31238
31224
 
31239
31225
  // src/presentation/cli/TrelloCliController.ts
@@ -31297,8 +31283,7 @@ class CommandController {
31297
31283
  return;
31298
31284
  }
31299
31285
  try {
31300
- const { Command: Command2 } = await Promise.resolve().then(() => (init_esm17(), exports_esm));
31301
- this.program = new Command2;
31286
+ this.program = new Command;
31302
31287
  } catch (error) {
31303
31288
  console.error(t2("menu.errors.commanderInitError"), error);
31304
31289
  throw new Error(t2("menu.errors.commanderInitFailed"));
@@ -31516,6 +31501,7 @@ class CommandController {
31516
31501
  var init_CommandController = __esm(() => {
31517
31502
  init_services();
31518
31503
  init_repositories();
31504
+ init_esm17();
31519
31505
  init_i18n();
31520
31506
  init_shared();
31521
31507
  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.11.0",
4
+ "version": "0.11.1",
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/)",
@@ -1,4 +1,3 @@
1
- import type { Command } from 'commander';
2
1
  import type { OutputFormat } from '@/shared';
3
2
  import { readFileSync } from 'node:fs';
4
3
  import { join } from 'node:path';
@@ -8,6 +7,7 @@ import {
8
7
  FileConfigRepository,
9
8
  TrelloApiRepository,
10
9
  } from '@infrastructure/repositories';
10
+ import { Command } from 'commander';
11
11
 
12
12
  import { t } from '@/i18n';
13
13
  import { ErrorHandler, OutputFormatter } from '@/shared';
@@ -33,7 +33,7 @@ export class CommandController {
33
33
  }
34
34
 
35
35
  try {
36
- const { Command } = await import('commander');
36
+ // Use static import - Commander is already imported at the top
37
37
  this.program = new Command();
38
38
  } catch (error) {
39
39
  console.error(t('menu.errors.commanderInitError'), error);