@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.js CHANGED
@@ -1295,19 +1295,21 @@ var Args = class _Args {
1295
1295
  */
1296
1296
  get(key) {
1297
1297
  const resolvedKey = this.aliases[key] || key;
1298
- this.usedKeys.add(resolvedKey);
1299
- if (this.overrides[resolvedKey] !== void 0) {
1300
- return this.overrides[resolvedKey];
1301
- }
1302
1298
  const lcKey = resolvedKey.toLowerCase();
1299
+ this.usedKeys.add(lcKey);
1300
+ const overrideKey = Object.keys(this.overrides).find((k) => k.toLowerCase() === lcKey);
1301
+ if (overrideKey !== void 0) {
1302
+ return this.overrides[overrideKey];
1303
+ }
1303
1304
  const lcKeyWithEnv = `${lcKey}${this.env ? `_${this.env.toLowerCase()}` : ""}`;
1304
1305
  if (this.env && this.args[lcKeyWithEnv] !== void 0) {
1305
1306
  return this.args[lcKeyWithEnv];
1306
1307
  } else if (this.args[lcKey] !== void 0) {
1307
1308
  return this.args[lcKey];
1308
1309
  }
1309
- if (this.configValues[resolvedKey] !== void 0) {
1310
- return this.configValues[resolvedKey];
1310
+ const configKey = Object.keys(this.configValues).find((k) => k.toLowerCase() === lcKey);
1311
+ if (configKey !== void 0) {
1312
+ return this.configValues[configKey];
1311
1313
  }
1312
1314
  const envKey = this.toEnvKey(resolvedKey);
1313
1315
  const envKeyWithEnv = `${envKey}${this.env ? `_${this.env.toUpperCase()}` : ""}`;
@@ -1315,15 +1317,20 @@ var Args = class _Args {
1315
1317
  (k) => this.env && k.toUpperCase() === envKeyWithEnv
1316
1318
  );
1317
1319
  const envKeyFound = Object.keys(process.env).find((k) => k.toUpperCase() === envKey);
1320
+ const envKeyAlt = envKey.replace(/_([0-9])/g, "$1");
1321
+ const envKeyAltFound = !envKeyFound ? Object.keys(process.env).find((k) => k.toUpperCase() === envKeyAlt) : null;
1318
1322
  if (envSpecificKey) {
1319
1323
  return process.env[envSpecificKey];
1320
1324
  } else if (envKeyFound) {
1321
1325
  return process.env[envKeyFound];
1326
+ } else if (envKeyAltFound) {
1327
+ return process.env[envKeyAltFound];
1322
1328
  }
1323
- if (this.defaults[resolvedKey] !== void 0) {
1324
- return this.defaults[resolvedKey];
1329
+ const defaultKey = Object.keys(this.defaults).find((k) => k.toLowerCase() === lcKey);
1330
+ if (defaultKey !== void 0) {
1331
+ return this.defaults[defaultKey];
1325
1332
  }
1326
- if (resolvedKey === "env" && process.env.NODE_ENV !== void 0) {
1333
+ if (lcKey === "env" && process.env.NODE_ENV !== void 0) {
1327
1334
  return process.env.NODE_ENV;
1328
1335
  }
1329
1336
  return void 0;
@@ -1366,8 +1373,12 @@ var Args = class _Args {
1366
1373
  }
1367
1374
  /**
1368
1375
  * Convert key to environment variable format
1376
+ * Converts camelCase to SNAKE_CASE
1369
1377
  */
1370
1378
  toEnvKey(key) {
1379
+ if (key.includes("_") && key === key.toUpperCase()) {
1380
+ return key;
1381
+ }
1371
1382
  return key.replace(
1372
1383
  /[A-Z0-9]/g,
1373
1384
  (match, offset) => offset === 0 ? match : "_" + match.toLowerCase()
@@ -2078,7 +2089,7 @@ var Logger = class _Logger {
2078
2089
  route: this.shouldUseIpcRoute() ? "ipc" : "console",
2079
2090
  prefix: void 0,
2080
2091
  silent: false,
2081
- showLevel: true,
2092
+ showLevel: false,
2082
2093
  timestamp: false,
2083
2094
  levels: ALL_LEVELS,
2084
2095
  progressTimes: false,