@nmakarov/cli-toolkit 0.8.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/init.cjs CHANGED
@@ -1321,19 +1321,21 @@ var Args = class _Args {
1321
1321
  */
1322
1322
  get(key) {
1323
1323
  const resolvedKey = this.aliases[key] || key;
1324
- this.usedKeys.add(resolvedKey);
1325
- if (this.overrides[resolvedKey] !== void 0) {
1326
- return this.overrides[resolvedKey];
1327
- }
1328
1324
  const lcKey = resolvedKey.toLowerCase();
1325
+ this.usedKeys.add(lcKey);
1326
+ const overrideKey = Object.keys(this.overrides).find((k) => k.toLowerCase() === lcKey);
1327
+ if (overrideKey !== void 0) {
1328
+ return this.overrides[overrideKey];
1329
+ }
1329
1330
  const lcKeyWithEnv = `${lcKey}${this.env ? `_${this.env.toLowerCase()}` : ""}`;
1330
1331
  if (this.env && this.args[lcKeyWithEnv] !== void 0) {
1331
1332
  return this.args[lcKeyWithEnv];
1332
1333
  } else if (this.args[lcKey] !== void 0) {
1333
1334
  return this.args[lcKey];
1334
1335
  }
1335
- if (this.configValues[resolvedKey] !== void 0) {
1336
- return this.configValues[resolvedKey];
1336
+ const configKey = Object.keys(this.configValues).find((k) => k.toLowerCase() === lcKey);
1337
+ if (configKey !== void 0) {
1338
+ return this.configValues[configKey];
1337
1339
  }
1338
1340
  const envKey = this.toEnvKey(resolvedKey);
1339
1341
  const envKeyWithEnv = `${envKey}${this.env ? `_${this.env.toUpperCase()}` : ""}`;
@@ -1341,15 +1343,20 @@ var Args = class _Args {
1341
1343
  (k) => this.env && k.toUpperCase() === envKeyWithEnv
1342
1344
  );
1343
1345
  const envKeyFound = Object.keys(process.env).find((k) => k.toUpperCase() === envKey);
1346
+ const envKeyAlt = envKey.replace(/_([0-9])/g, "$1");
1347
+ const envKeyAltFound = !envKeyFound ? Object.keys(process.env).find((k) => k.toUpperCase() === envKeyAlt) : null;
1344
1348
  if (envSpecificKey) {
1345
1349
  return process.env[envSpecificKey];
1346
1350
  } else if (envKeyFound) {
1347
1351
  return process.env[envKeyFound];
1352
+ } else if (envKeyAltFound) {
1353
+ return process.env[envKeyAltFound];
1348
1354
  }
1349
- if (this.defaults[resolvedKey] !== void 0) {
1350
- return this.defaults[resolvedKey];
1355
+ const defaultKey = Object.keys(this.defaults).find((k) => k.toLowerCase() === lcKey);
1356
+ if (defaultKey !== void 0) {
1357
+ return this.defaults[defaultKey];
1351
1358
  }
1352
- if (resolvedKey === "env" && process.env.NODE_ENV !== void 0) {
1359
+ if (lcKey === "env" && process.env.NODE_ENV !== void 0) {
1353
1360
  return process.env.NODE_ENV;
1354
1361
  }
1355
1362
  return void 0;
@@ -1392,8 +1399,12 @@ var Args = class _Args {
1392
1399
  }
1393
1400
  /**
1394
1401
  * Convert key to environment variable format
1402
+ * Converts camelCase to SNAKE_CASE
1395
1403
  */
1396
1404
  toEnvKey(key) {
1405
+ if (key.includes("_") && key === key.toUpperCase()) {
1406
+ return key;
1407
+ }
1397
1408
  return key.replace(
1398
1409
  /[A-Z0-9]/g,
1399
1410
  (match, offset) => offset === 0 ? match : "_" + match.toLowerCase()
@@ -2104,7 +2115,7 @@ var Logger = class _Logger {
2104
2115
  route: this.shouldUseIpcRoute() ? "ipc" : "console",
2105
2116
  prefix: void 0,
2106
2117
  silent: false,
2107
- showLevel: true,
2118
+ showLevel: false,
2108
2119
  timestamp: false,
2109
2120
  levels: ALL_LEVELS,
2110
2121
  progressTimes: false,