@nmakarov/cli-toolkit 0.9.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/dist/index.js CHANGED
@@ -1253,8 +1253,9 @@ var Args = class _Args {
1253
1253
  const resolvedKey = this.aliases[key] || key;
1254
1254
  const lcKey = resolvedKey.toLowerCase();
1255
1255
  this.usedKeys.add(lcKey);
1256
- if (this.overrides[resolvedKey] !== void 0) {
1257
- return this.overrides[resolvedKey];
1256
+ const overrideKey = Object.keys(this.overrides).find((k) => k.toLowerCase() === lcKey);
1257
+ if (overrideKey !== void 0) {
1258
+ return this.overrides[overrideKey];
1258
1259
  }
1259
1260
  const lcKeyWithEnv = `${lcKey}${this.env ? `_${this.env.toLowerCase()}` : ""}`;
1260
1261
  if (this.env && this.args[lcKeyWithEnv] !== void 0) {
@@ -1262,8 +1263,9 @@ var Args = class _Args {
1262
1263
  } else if (this.args[lcKey] !== void 0) {
1263
1264
  return this.args[lcKey];
1264
1265
  }
1265
- if (this.configValues[resolvedKey] !== void 0) {
1266
- return this.configValues[resolvedKey];
1266
+ const configKey = Object.keys(this.configValues).find((k) => k.toLowerCase() === lcKey);
1267
+ if (configKey !== void 0) {
1268
+ return this.configValues[configKey];
1267
1269
  }
1268
1270
  const envKey = this.toEnvKey(resolvedKey);
1269
1271
  const envKeyWithEnv = `${envKey}${this.env ? `_${this.env.toUpperCase()}` : ""}`;
@@ -1271,15 +1273,20 @@ var Args = class _Args {
1271
1273
  (k) => this.env && k.toUpperCase() === envKeyWithEnv
1272
1274
  );
1273
1275
  const envKeyFound = Object.keys(process.env).find((k) => k.toUpperCase() === envKey);
1276
+ const envKeyAlt = envKey.replace(/_([0-9])/g, "$1");
1277
+ const envKeyAltFound = !envKeyFound ? Object.keys(process.env).find((k) => k.toUpperCase() === envKeyAlt) : null;
1274
1278
  if (envSpecificKey) {
1275
1279
  return process.env[envSpecificKey];
1276
1280
  } else if (envKeyFound) {
1277
1281
  return process.env[envKeyFound];
1282
+ } else if (envKeyAltFound) {
1283
+ return process.env[envKeyAltFound];
1278
1284
  }
1279
- if (this.defaults[resolvedKey] !== void 0) {
1280
- return this.defaults[resolvedKey];
1285
+ const defaultKey = Object.keys(this.defaults).find((k) => k.toLowerCase() === lcKey);
1286
+ if (defaultKey !== void 0) {
1287
+ return this.defaults[defaultKey];
1281
1288
  }
1282
- if (resolvedKey === "env" && process.env.NODE_ENV !== void 0) {
1289
+ if (lcKey === "env" && process.env.NODE_ENV !== void 0) {
1283
1290
  return process.env.NODE_ENV;
1284
1291
  }
1285
1292
  return void 0;
@@ -1322,8 +1329,12 @@ var Args = class _Args {
1322
1329
  }
1323
1330
  /**
1324
1331
  * Convert key to environment variable format
1332
+ * Converts camelCase to SNAKE_CASE
1325
1333
  */
1326
1334
  toEnvKey(key) {
1335
+ if (key.includes("_") && key === key.toUpperCase()) {
1336
+ return key;
1337
+ }
1327
1338
  return key.replace(
1328
1339
  /[A-Z0-9]/g,
1329
1340
  (match, offset) => offset === 0 ? match : "_" + match.toLowerCase()
@@ -2097,7 +2108,37 @@ var FileDatabase = class {
2097
2108
  // Synopsis calculation functions
2098
2109
  fileSynopsisFunction = null;
2099
2110
  versionSynopsisFunction = null;
2100
- constructor(config2) {
2111
+ /**
2112
+ * Constructor - accepts context as first parameter (new pattern)
2113
+ * or config object (legacy pattern for backward compatibility)
2114
+ */
2115
+ constructor(contextOrConfig, options) {
2116
+ let config2;
2117
+ if (contextOrConfig && typeof contextOrConfig === "object" && "params" in contextOrConfig) {
2118
+ const context = contextOrConfig;
2119
+ const opts = options || {};
2120
+ const defs = {
2121
+ basePath: "string default ./data",
2122
+ namespace: "string default default",
2123
+ tableName: "string",
2124
+ maxVersions: "number default 5",
2125
+ pageSize: "number default 5000"
2126
+ };
2127
+ const paramsConfig = context.params.getAll(defs);
2128
+ config2 = {
2129
+ basePath: opts.basePath ?? paramsConfig.basePath,
2130
+ namespace: opts.namespace ?? paramsConfig.namespace,
2131
+ tableName: opts.tableName ?? paramsConfig.tableName ?? null,
2132
+ versioned: opts.versioned ?? true,
2133
+ maxVersions: opts.maxVersions ?? paramsConfig.maxVersions,
2134
+ pageSize: opts.pageSize ?? paramsConfig.pageSize,
2135
+ useMetadata: opts.useMetadata ?? true,
2136
+ freeSpaceThreshold: opts.freeSpaceThreshold ?? 100 * 1024 * 1024,
2137
+ logger: context.logger
2138
+ };
2139
+ } else {
2140
+ config2 = contextOrConfig;
2141
+ }
2101
2142
  if (!config2.basePath) {
2102
2143
  throw new ParamError("[FileDatabase] basePath is required");
2103
2144
  }
@@ -2780,6 +2821,9 @@ var FileDatabase = class {
2780
2821
  return { ...this.metadata };
2781
2822
  }
2782
2823
  };
2824
+ function fileDatabaseInit(context, options = {}) {
2825
+ return new FileDatabase(context, options);
2826
+ }
2783
2827
 
2784
2828
  // src/db/index.ts
2785
2829
  import knex from "knex";
@@ -3218,7 +3262,7 @@ var Logger = class _Logger {
3218
3262
  route: this.shouldUseIpcRoute() ? "ipc" : "console",
3219
3263
  prefix: void 0,
3220
3264
  silent: false,
3221
- showLevel: true,
3265
+ showLevel: false,
3222
3266
  timestamp: false,
3223
3267
  levels: ALL_LEVELS,
3224
3268
  progressTimes: false,
@@ -3471,6 +3515,7 @@ export {
3471
3515
  buildFooter,
3472
3516
  defaultFileSynopsisFunction,
3473
3517
  defaultVersionSynopsisFunction,
3518
+ fileDatabaseInit,
3474
3519
  getArgsInstance,
3475
3520
  createElement2 as h,
3476
3521
  joiEdateType,