@nmakarov/cli-toolkit 0.14.2 → 0.16.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.
Files changed (45) hide show
  1. package/dist/args.cjs +49 -9
  2. package/dist/args.cjs.map +1 -1
  3. package/dist/args.js +49 -9
  4. package/dist/args.js.map +1 -1
  5. package/dist/db.cjs +9 -2
  6. package/dist/db.cjs.map +1 -1
  7. package/dist/db.js +9 -2
  8. package/dist/db.js.map +1 -1
  9. package/dist/errors.cjs +17 -0
  10. package/dist/errors.cjs.map +1 -1
  11. package/dist/errors.js +15 -0
  12. package/dist/errors.js.map +1 -1
  13. package/dist/filedatabase.cjs +16 -24
  14. package/dist/filedatabase.cjs.map +1 -1
  15. package/dist/filedatabase.js +16 -23
  16. package/dist/filedatabase.js.map +1 -1
  17. package/dist/http-client.cjs +44 -34
  18. package/dist/http-client.cjs.map +1 -1
  19. package/dist/http-client.js +44 -34
  20. package/dist/http-client.js.map +1 -1
  21. package/dist/http-client2.cjs +368 -0
  22. package/dist/http-client2.cjs.map +1 -0
  23. package/dist/http-client2.js +340 -0
  24. package/dist/http-client2.js.map +1 -0
  25. package/dist/index.cjs +212 -91
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.js +212 -90
  28. package/dist/index.js.map +1 -1
  29. package/dist/init.cjs +190 -76
  30. package/dist/init.cjs.map +1 -1
  31. package/dist/init.js +190 -76
  32. package/dist/init.js.map +1 -1
  33. package/dist/logger.cjs +19 -36
  34. package/dist/logger.cjs.map +1 -1
  35. package/dist/logger.js +19 -36
  36. package/dist/logger.js.map +1 -1
  37. package/dist/mock-server.cjs +13 -16
  38. package/dist/mock-server.cjs.map +1 -1
  39. package/dist/mock-server.js +13 -16
  40. package/dist/mock-server.js.map +1 -1
  41. package/dist/params.cjs +114 -15
  42. package/dist/params.cjs.map +1 -1
  43. package/dist/params.js +114 -15
  44. package/dist/params.js.map +1 -1
  45. package/package.json +9 -2
package/dist/index.js CHANGED
@@ -1073,20 +1073,31 @@ var Args = class _Args {
1073
1073
  configValues = {};
1074
1074
  configsLoaded = [];
1075
1075
  env = "local";
1076
- constructor(config2 = {}) {
1076
+ constructor(contextOrConfig = {}, config2) {
1077
+ const hasContext = config2 !== void 0;
1078
+ const configToUse = hasContext ? config2 ?? {} : contextOrConfig ?? {};
1079
+ const context = hasContext ? contextOrConfig : void 0;
1077
1080
  this.aliases = {};
1078
1081
  this.overrides = {};
1079
1082
  this.defaults = {};
1080
1083
  this.prefixes = ["not", "no"];
1081
- if (Object.keys(config2).length > 0) {
1082
- this.configure(config2);
1084
+ if (Object.keys(configToUse).length > 0) {
1085
+ this.configure(configToUse);
1083
1086
  }
1084
- const args = config2.args || process.argv.slice(2);
1087
+ const args = configToUse.args || process.argv.slice(2);
1085
1088
  this.parseArgs(args);
1086
1089
  this.env = this.get("env")?.toLowerCase() || "local";
1087
1090
  this.loadDotEnv();
1088
1091
  this.loadConfigFiles();
1089
1092
  this.checkConflicts();
1093
+ if (context && typeof context.registerCleanup === "function") {
1094
+ context.registerCleanup((ctx) => {
1095
+ const unusedArgs = ctx.args.getUnused();
1096
+ if (unusedArgs.length > 0) {
1097
+ ctx.logger.warn("Unused CLI args:", unusedArgs.join(", "));
1098
+ }
1099
+ });
1100
+ }
1090
1101
  }
1091
1102
  /**
1092
1103
  * Configure Args options
@@ -1108,12 +1119,15 @@ var Args = class _Args {
1108
1119
  }
1109
1120
  }
1110
1121
  /**
1111
- * Initialize Args instance
1112
- * Note: Args is special - it's initialized first, so it can't take context
1113
- * This static method is for consistency with other components
1122
+ * Initialize Args instance.
1123
+ * Args.init(context, config) when used from init/setup: context has registerCleanup, Args registers unused-args cleanup.
1124
+ * Args.init(config) for standalone use (no cleanup).
1114
1125
  */
1115
- static init(config2 = {}) {
1116
- return new _Args(config2);
1126
+ static init(contextOrConfig, config2) {
1127
+ if (config2 !== void 0) {
1128
+ return new _Args(contextOrConfig, config2);
1129
+ }
1130
+ return new _Args(contextOrConfig ?? {});
1117
1131
  }
1118
1132
  /**
1119
1133
  * Parse command line arguments
@@ -1293,6 +1307,32 @@ var Args = class _Args {
1293
1307
  }
1294
1308
  return void 0;
1295
1309
  }
1310
+ /**
1311
+ * Return which layer provided the value for get(key): overrides, cli, config, env, or default.
1312
+ * Does not add key to usedKeys. Use after get(key) when you need the origin.
1313
+ */
1314
+ getSource(key) {
1315
+ const resolvedKey = this.aliases[key] || key;
1316
+ const lcKey = resolvedKey.toLowerCase();
1317
+ const overrideKey = Object.keys(this.overrides).find((k) => k.toLowerCase() === lcKey);
1318
+ if (overrideKey !== void 0) return "overrides";
1319
+ const lcKeyWithEnv = `${lcKey}${this.env ? `_${this.env.toLowerCase()}` : ""}`;
1320
+ if (this.env && this.args[lcKeyWithEnv] !== void 0) return "cli";
1321
+ if (this.args[lcKey] !== void 0) return "cli";
1322
+ const configKey = Object.keys(this.configValues).find((k) => k.toLowerCase() === lcKey);
1323
+ if (configKey !== void 0) return "config";
1324
+ const envKey = this.toEnvKey(resolvedKey);
1325
+ const envKeyWithEnv = `${envKey}${this.env ? `_${this.env.toUpperCase()}` : ""}`;
1326
+ const envSpecificKey = Object.keys(process.env).find((k) => this.env && k.toUpperCase() === envKeyWithEnv);
1327
+ const envKeyFound = Object.keys(process.env).find((k) => k.toUpperCase() === envKey);
1328
+ const envKeyAlt = envKey.replace(/_([0-9])/g, "$1");
1329
+ const envKeyAltFound = !envKeyFound ? Object.keys(process.env).find((k) => k.toUpperCase() === envKeyAlt) : null;
1330
+ if (envSpecificKey || envKeyFound || envKeyAltFound) return "env";
1331
+ const defaultKey = Object.keys(this.defaults).find((k) => k.toLowerCase() === lcKey);
1332
+ if (defaultKey !== void 0) return "default";
1333
+ if (lcKey === "env" && process.env.NODE_ENV !== void 0) return "env";
1334
+ return void 0;
1335
+ }
1296
1336
  /**
1297
1337
  * Set a value (for testing/internal use)
1298
1338
  */
@@ -1518,6 +1558,12 @@ var ParamError = class extends FrameworkError {
1518
1558
  this.name = "ParamError";
1519
1559
  }
1520
1560
  };
1561
+ var FileDatabaseError = class extends FrameworkError {
1562
+ constructor(message) {
1563
+ super(message);
1564
+ this.name = "FileDatabaseError";
1565
+ }
1566
+ };
1521
1567
 
1522
1568
  // src/params/custom-types.ts
1523
1569
  var joiEdateType = (value, helpers) => {
@@ -1643,17 +1689,53 @@ var Params = class _Params {
1643
1689
  context;
1644
1690
  // Partial context during initialization
1645
1691
  params = {};
1692
+ paramSources = {};
1646
1693
  definitions = {};
1647
1694
  args;
1648
1695
  paramSetters = [];
1649
1696
  paramGetters = [];
1650
1697
  trackedParams = [];
1698
+ _currentModule = "script";
1699
+ /** Resolved early in constructor so cleanup does not read params lazily */
1700
+ _showUsedParams = false;
1651
1701
  constructor(context, options = {}) {
1652
1702
  this.context = context;
1653
1703
  this.args = context.args;
1654
1704
  if (Object.keys(options).length > 0) {
1655
1705
  this.configure(options);
1656
1706
  }
1707
+ this._showUsedParams = this.get("showUsedParams", "boolean default false");
1708
+ if (context && typeof context.registerCleanup === "function") {
1709
+ context.registerCleanup((ctx) => {
1710
+ if (!ctx.params.getShowUsedParams()) return;
1711
+ const byModule = ctx.params.getFiguredByModule();
1712
+ const modules = Object.keys(byModule).sort();
1713
+ if (modules.length === 0) return;
1714
+ const logger = ctx.logger;
1715
+ logger.debug("[Params]: list of used params:");
1716
+ if (typeof logger.highlight !== "function") {
1717
+ for (const mod of modules) {
1718
+ logger.debug(` [${mod}]`);
1719
+ for (const [key, entry] of Object.entries(byModule[mod])) {
1720
+ logger.debug(` ${key}: ${JSON.stringify(entry.value)} (${entry.source})`);
1721
+ }
1722
+ }
1723
+ return;
1724
+ }
1725
+ for (const mod of modules) {
1726
+ logger.debug(` [${mod}]`);
1727
+ for (const [key, entry] of Object.entries(byModule[mod])) {
1728
+ const valueStr = JSON.stringify(entry.value);
1729
+ const display = entry.source === "default" ? valueStr : logger.highlight(valueStr);
1730
+ logger.debug(` ${key}: ${display} (${entry.source})`);
1731
+ }
1732
+ }
1733
+ });
1734
+ }
1735
+ }
1736
+ /** Whether --showUsedParams was requested (resolved in constructor). */
1737
+ getShowUsedParams() {
1738
+ return this._showUsedParams;
1657
1739
  }
1658
1740
  /**
1659
1741
  * Configure parameters
@@ -1672,14 +1754,15 @@ var Params = class _Params {
1672
1754
  return new _Params(context, options || {});
1673
1755
  }
1674
1756
  /**
1675
- * Track a parameter request for --stopAfter=init feature
1757
+ * Track a parameter request for --stopAfter=init and --showUsedParams
1676
1758
  */
1677
- trackParam(key, definition, value, source) {
1759
+ trackParam(key, definition, value, source, moduleName) {
1678
1760
  this.trackedParams.push({
1679
1761
  key,
1680
1762
  definition,
1681
1763
  value,
1682
- source
1764
+ source,
1765
+ module: moduleName ?? this._currentModule
1683
1766
  });
1684
1767
  }
1685
1768
  /**
@@ -1689,7 +1772,7 @@ var Params = class _Params {
1689
1772
  return [...this.trackedParams];
1690
1773
  }
1691
1774
  /**
1692
- * Get all figured parameters as a record
1775
+ * Get all figured parameters as a record (flat, last occurrence per key)
1693
1776
  * Returns all parameters that were collected during initialization,
1694
1777
  * whether from CLI args, options, or defaults
1695
1778
  */
@@ -1703,6 +1786,19 @@ var Params = class _Params {
1703
1786
  }
1704
1787
  return result;
1705
1788
  }
1789
+ /**
1790
+ * Get figured parameters grouped by module name.
1791
+ * Same param can appear in multiple modules (e.g. source, resource).
1792
+ */
1793
+ getFiguredByModule() {
1794
+ const byModule = {};
1795
+ for (const param of this.trackedParams) {
1796
+ const mod = param.module;
1797
+ if (!byModule[mod]) byModule[mod] = {};
1798
+ byModule[mod][param.key] = { value: param.value, source: param.source };
1799
+ }
1800
+ return byModule;
1801
+ }
1706
1802
  /**
1707
1803
  * Clear tracked parameters
1708
1804
  */
@@ -1821,14 +1917,19 @@ var Params = class _Params {
1821
1917
  source = "options";
1822
1918
  } else if (valFromArgs !== void 0 && valFromArgs !== null) {
1823
1919
  value = this.validate(key, valFromArgs, def);
1824
- source = "cli";
1920
+ const argsSource = this.args.getSource?.(key);
1921
+ if (argsSource === "overrides") source = "options";
1922
+ else if (argsSource === "cli" || argsSource === "env" || argsSource === "config") source = argsSource;
1923
+ else if (argsSource === "default") source = "default";
1924
+ else source = "cli";
1825
1925
  } else if (valFromParams !== void 0 && valFromParams !== null) {
1826
1926
  value = this.validate(key, valFromParams, def);
1827
- source = "options";
1927
+ source = this.paramSources[key] ?? "options";
1828
1928
  } else {
1829
1929
  value = this.validate(key, void 0, def);
1830
1930
  source = "default";
1831
1931
  }
1932
+ this.paramSources[key] = source;
1832
1933
  this.trackParam(key, definition || "string", value, source);
1833
1934
  if (value !== void 0 && def.values && !def.values.includes(value)) {
1834
1935
  throw new ParamError(`key ${key} should be one of ${def.values}`);
@@ -1849,19 +1950,63 @@ var Params = class _Params {
1849
1950
  }
1850
1951
  }
1851
1952
  /**
1852
- * Get all parameters from definitions
1853
- * Processes parameters left-to-right to support cross-parameter references
1953
+ * Get all parameters from definitions (main script).
1954
+ * Same as getAllForModule("script", defs). Processes left-to-right for cross-parameter references.
1854
1955
  */
1855
1956
  getAll(defs) {
1856
- const res = {};
1857
- for (const [k, def] of Object.entries(defs)) {
1858
- const value = this.get(k, def);
1859
- res[k] = value;
1860
- if (value !== void 0) {
1861
- this.params[k] = value;
1957
+ return this.getAllForModule("script", defs);
1958
+ }
1959
+ /**
1960
+ * Get all parameters from definitions for a given module name.
1961
+ * Figured params are grouped by module when using --showUsedParams.
1962
+ * Processes parameters left-to-right to support cross-parameter references.
1963
+ * If moduleName is omitted, it is inferred from the caller's file path (directory name under src/).
1964
+ */
1965
+ getAllForModule(moduleNameOrDefs, defs) {
1966
+ let moduleName;
1967
+ let definitions;
1968
+ if (defs !== void 0) {
1969
+ moduleName = moduleNameOrDefs;
1970
+ definitions = defs;
1971
+ } else {
1972
+ definitions = moduleNameOrDefs;
1973
+ moduleName = this._inferModuleNameFromStack();
1974
+ }
1975
+ const prev = this._currentModule;
1976
+ this._currentModule = moduleName;
1977
+ try {
1978
+ const res = {};
1979
+ for (const [k, def] of Object.entries(definitions)) {
1980
+ const value = this.get(k, def);
1981
+ res[k] = value;
1982
+ if (value !== void 0) {
1983
+ this.params[k] = value;
1984
+ }
1862
1985
  }
1986
+ return res;
1987
+ } finally {
1988
+ this._currentModule = prev;
1863
1989
  }
1864
- return res;
1990
+ }
1991
+ /**
1992
+ * Infer module name from call stack: first caller outside params/index gives path like .../src/<moduleName>/...
1993
+ */
1994
+ _inferModuleNameFromStack() {
1995
+ const stack = new Error().stack;
1996
+ if (!stack) return "script";
1997
+ const lines = stack.split("\n");
1998
+ const paramsIndexPath = "params" + (typeof process !== "undefined" && process.platform === "win32" ? "\\" : "/") + "index.";
1999
+ for (const line of lines) {
2000
+ const parenMatch = line.match(/\(([^)]+)\)/);
2001
+ if (!parenMatch) continue;
2002
+ const parts = parenMatch[1].split(":");
2003
+ if (parts.length < 3) continue;
2004
+ const path4 = parts.slice(0, -2).join(":").replace(/^file:\/\//, "");
2005
+ if (!path4 || path4.includes(paramsIndexPath)) continue;
2006
+ const srcMatch = path4.match(/[/\\]src[/\\]([^/\\]+)(?:[/\\]|$)/);
2007
+ if (srcMatch) return srcMatch[1];
2008
+ }
2009
+ return "script";
1865
2010
  }
1866
2011
  /**
1867
2012
  * Run all registered getters for a key
@@ -2083,13 +2228,7 @@ function defaultVersionSynopsisFunction(metadata) {
2083
2228
  }
2084
2229
 
2085
2230
  // src/filedatabase/index.ts
2086
- var FileDatabaseError = class extends Error {
2087
- constructor(message) {
2088
- super(message);
2089
- this.name = "FileDatabaseError";
2090
- }
2091
- };
2092
- var FileDatabase = class {
2231
+ var FileDatabase = class _FileDatabase {
2093
2232
  basePath;
2094
2233
  namespace;
2095
2234
  tableName = null;
@@ -2126,18 +2265,8 @@ var FileDatabase = class {
2126
2265
  maxVersions: "number default 5",
2127
2266
  pageSize: "number default 5000"
2128
2267
  };
2129
- const paramsConfig = context.params.getAll(defs);
2130
- config2 = {
2131
- basePath: opts.basePath ?? paramsConfig.basePath,
2132
- namespace: opts.namespace ?? paramsConfig.namespace,
2133
- tableName: opts.tableName ?? paramsConfig.tableName ?? null,
2134
- versioned: opts.versioned ?? true,
2135
- maxVersions: opts.maxVersions ?? paramsConfig.maxVersions,
2136
- pageSize: opts.pageSize ?? paramsConfig.pageSize,
2137
- useMetadata: opts.useMetadata ?? true,
2138
- freeSpaceThreshold: opts.freeSpaceThreshold ?? 100 * 1024 * 1024,
2139
- logger: context.logger
2140
- };
2268
+ const discovered = context.params.getAllForModule(defs);
2269
+ config2 = { ...discovered, ...opts, logger: context.logger };
2141
2270
  } else {
2142
2271
  config2 = contextOrConfig;
2143
2272
  }
@@ -2155,6 +2284,13 @@ var FileDatabase = class {
2155
2284
  this.logger = config2.logger || console;
2156
2285
  this.metadata = this.getDefaultMetadata();
2157
2286
  }
2287
+ /**
2288
+ * Initialize FileDatabase from context and options.
2289
+ * Params are read via getAllForModule("filedatabase", defs) for --showUsedParams grouping.
2290
+ */
2291
+ static init(context, options) {
2292
+ return new _FileDatabase(context, options ?? {});
2293
+ }
2158
2294
  /**
2159
2295
  * Get default metadata structure
2160
2296
  */
@@ -3020,9 +3156,6 @@ function listSources(basePath) {
3020
3156
  return [];
3021
3157
  }
3022
3158
  }
3023
- function fileDatabaseInit(context, options = {}) {
3024
- return new FileDatabase(context, options);
3025
- }
3026
3159
 
3027
3160
  // src/db/index.ts
3028
3161
  import knex from "knex";
@@ -3321,6 +3454,13 @@ var Db = class {
3321
3454
  isConnectedToDb() {
3322
3455
  return this.isConnected && this.knexInstance !== null;
3323
3456
  }
3457
+ /**
3458
+ * Initialize Db with context (connects and registers disconnect cleanup).
3459
+ * Params are read via getAllForModule("db", defs). Same as dbInit(context, dbNameOrConnectionString).
3460
+ */
3461
+ static async init(context, dbNameOrConnectionString) {
3462
+ return dbFindAndConnect(context, dbNameOrConnectionString);
3463
+ }
3324
3464
  };
3325
3465
  function capitalizeFirstLetter(str) {
3326
3466
  return str.charAt(0).toUpperCase() + str.slice(1);
@@ -3334,7 +3474,7 @@ async function dbConnect(context, connectionString, name, dbProfile) {
3334
3474
  acquireConnectionTimeout: "number default 10000",
3335
3475
  sslRejectUnauthorized: "boolean default false"
3336
3476
  };
3337
- const paramsConfig = context.params.getAll(defs);
3477
+ const paramsConfig = context.params.getAllForModule(defs);
3338
3478
  const config2 = {
3339
3479
  connectionString,
3340
3480
  name: paramsConfig.name || name || "default",
@@ -3384,7 +3524,7 @@ async function dbFindAndConnect(context, dbNameOrConnectionString) {
3384
3524
  dbConnectionString: "string",
3385
3525
  dbProfile: "boolean default false"
3386
3526
  };
3387
- const paramsConfig = context.params.getAll(defs);
3527
+ const paramsConfig = context.params.getAllForModule(defs);
3388
3528
  dbName = paramsConfig.dbName;
3389
3529
  dbConnectionString = paramsConfig.dbConnectionString;
3390
3530
  dbProfile = paramsConfig.dbProfile;
@@ -3476,8 +3616,7 @@ var Logger = class _Logger {
3476
3616
  this.updateTransport();
3477
3617
  }
3478
3618
  /**
3479
- * Configure logger options
3480
- * Only parameters present in options are updated
3619
+ * Configure logger options. Accepts both LoggerOptions shape and flat param names (levels string, progressWithTimes, progressThrottleMs).
3481
3620
  */
3482
3621
  configure(options) {
3483
3622
  if (options.mode !== void 0) {
@@ -3487,32 +3626,24 @@ var Logger = class _Logger {
3487
3626
  this.options.route = options.route;
3488
3627
  this.updateTransport();
3489
3628
  }
3490
- if (options.prefix !== void 0) {
3491
- this.options.prefix = options.prefix;
3492
- }
3493
- if (options.silent !== void 0) {
3494
- this.options.silent = options.silent;
3495
- }
3496
- if (options.showLevel !== void 0) {
3497
- this.options.showLevel = options.showLevel;
3498
- }
3499
- if (options.timestamp !== void 0) {
3500
- this.options.timestamp = options.timestamp;
3501
- }
3629
+ if (options.prefix !== void 0) this.options.prefix = options.prefix;
3630
+ if (options.silent !== void 0) this.options.silent = options.silent;
3631
+ if (options.showLevel !== void 0) this.options.showLevel = options.showLevel;
3632
+ if (options.timestamp !== void 0) this.options.timestamp = options.timestamp;
3502
3633
  if (options.levels !== void 0) {
3503
- this.options.levels = this.normalizeLevels(options.levels);
3634
+ const levels = typeof options.levels === "string" ? options.levels.split(",") : options.levels;
3635
+ this.options.levels = this.normalizeLevels(levels);
3504
3636
  }
3505
3637
  if (options.progress !== void 0) {
3506
- if (options.progress.withTimes !== void 0) {
3507
- this.options.progressTimes = options.progress.withTimes;
3508
- }
3509
- if (options.progress.throttleMs !== void 0) {
3510
- this.options.progressThrottle = options.progress.throttleMs;
3511
- }
3638
+ if (options.progress.withTimes !== void 0) this.options.progressTimes = options.progress.withTimes;
3639
+ if (options.progress.throttleMs !== void 0) this.options.progressThrottle = options.progress.throttleMs;
3512
3640
  }
3641
+ const flat = options;
3642
+ if (flat.progressWithTimes !== void 0) this.options.progressTimes = flat.progressWithTimes;
3643
+ if (flat.progressThrottleMs !== void 0) this.options.progressThrottle = flat.progressThrottleMs;
3513
3644
  }
3514
3645
  /**
3515
- * Initialize logger from context and CLI parameters
3646
+ * Initialize logger from context and CLI parameters. Whatever is in options goes (after discovered params).
3516
3647
  */
3517
3648
  static init(context, options) {
3518
3649
  const paramDefs = {
@@ -3526,20 +3657,8 @@ var Logger = class _Logger {
3526
3657
  progressWithTimes: "boolean default false",
3527
3658
  progressThrottleMs: "number"
3528
3659
  };
3529
- const cliParams = context.params.getAll(paramDefs);
3530
- const config2 = {
3531
- mode: options?.mode ?? cliParams.mode,
3532
- route: options?.route ?? cliParams.route,
3533
- prefix: options?.prefix ?? cliParams.prefix,
3534
- silent: options?.silent ?? cliParams.silent,
3535
- showLevel: options?.showLevel ?? cliParams.showLevel,
3536
- timestamp: options?.timestamp ?? cliParams.timestamp,
3537
- levels: options?.levels ?? (cliParams.levels ? cliParams.levels.split(",") : void 0),
3538
- progress: options?.progress ?? {
3539
- withTimes: cliParams.progressWithTimes,
3540
- throttleMs: cliParams.progressThrottleMs
3541
- }
3542
- };
3660
+ const discovered = context.params.getAllForModule(paramDefs);
3661
+ const config2 = { ...discovered, ...options };
3543
3662
  const logger = new _Logger(context, config2);
3544
3663
  context.logger = logger;
3545
3664
  return logger;
@@ -3566,6 +3685,10 @@ var Logger = class _Logger {
3566
3685
  }
3567
3686
  this.options.mode = mode;
3568
3687
  }
3688
+ /** Returns a styled string (bright white) for highlighting; keeps chalk inside logger. */
3689
+ highlight(text) {
3690
+ return chalk.whiteBright(text);
3691
+ }
3569
3692
  debug(message, ...chunks) {
3570
3693
  this.out({ level: "debug", message, chunks });
3571
3694
  }
@@ -3741,12 +3864,7 @@ function extractComponentOptions(opts, componentName) {
3741
3864
  return componentOptions;
3742
3865
  }
3743
3866
  function setup(opts = {}) {
3744
- const args = Args.init({
3745
- overrides: opts.overrides || {},
3746
- defaults: opts.defaults || {}
3747
- });
3748
3867
  const partialContext = {
3749
- args,
3750
3868
  emitter: new EventEmitter(),
3751
3869
  isStop: () => false,
3752
3870
  cleanupFunctions: [],
@@ -3754,6 +3872,11 @@ function setup(opts = {}) {
3754
3872
  partialContext.cleanupFunctions.push(fn);
3755
3873
  }
3756
3874
  };
3875
+ const args = Args.init(partialContext, {
3876
+ overrides: opts.overrides || {},
3877
+ defaults: opts.defaults || {}
3878
+ });
3879
+ partialContext.args = args;
3757
3880
  const params = Params.init(partialContext, opts.overrides || {});
3758
3881
  partialContext.params = params;
3759
3882
  const loggerOptions = extractComponentOptions(opts, "logger");
@@ -3806,7 +3929,6 @@ export {
3806
3929
  dbInit,
3807
3930
  defaultFileSynopsisFunction,
3808
3931
  defaultVersionSynopsisFunction,
3809
- fileDatabaseInit,
3810
3932
  getArgsInstance,
3811
3933
  createElement2 as h,
3812
3934
  joiEdateType,