@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.cjs CHANGED
@@ -1117,7 +1117,6 @@ __export(src_exports, {
1117
1117
  dbInit: () => dbInit,
1118
1118
  defaultFileSynopsisFunction: () => defaultFileSynopsisFunction,
1119
1119
  defaultVersionSynopsisFunction: () => defaultVersionSynopsisFunction,
1120
- fileDatabaseInit: () => fileDatabaseInit,
1121
1120
  getArgsInstance: () => getArgsInstance,
1122
1121
  h: () => import_react5.createElement,
1123
1122
  joiEdateType: () => joiEdateType,
@@ -1160,20 +1159,31 @@ var Args = class _Args {
1160
1159
  configValues = {};
1161
1160
  configsLoaded = [];
1162
1161
  env = "local";
1163
- constructor(config2 = {}) {
1162
+ constructor(contextOrConfig = {}, config2) {
1163
+ const hasContext = config2 !== void 0;
1164
+ const configToUse = hasContext ? config2 ?? {} : contextOrConfig ?? {};
1165
+ const context = hasContext ? contextOrConfig : void 0;
1164
1166
  this.aliases = {};
1165
1167
  this.overrides = {};
1166
1168
  this.defaults = {};
1167
1169
  this.prefixes = ["not", "no"];
1168
- if (Object.keys(config2).length > 0) {
1169
- this.configure(config2);
1170
+ if (Object.keys(configToUse).length > 0) {
1171
+ this.configure(configToUse);
1170
1172
  }
1171
- const args = config2.args || process.argv.slice(2);
1173
+ const args = configToUse.args || process.argv.slice(2);
1172
1174
  this.parseArgs(args);
1173
1175
  this.env = this.get("env")?.toLowerCase() || "local";
1174
1176
  this.loadDotEnv();
1175
1177
  this.loadConfigFiles();
1176
1178
  this.checkConflicts();
1179
+ if (context && typeof context.registerCleanup === "function") {
1180
+ context.registerCleanup((ctx) => {
1181
+ const unusedArgs = ctx.args.getUnused();
1182
+ if (unusedArgs.length > 0) {
1183
+ ctx.logger.warn("Unused CLI args:", unusedArgs.join(", "));
1184
+ }
1185
+ });
1186
+ }
1177
1187
  }
1178
1188
  /**
1179
1189
  * Configure Args options
@@ -1195,12 +1205,15 @@ var Args = class _Args {
1195
1205
  }
1196
1206
  }
1197
1207
  /**
1198
- * Initialize Args instance
1199
- * Note: Args is special - it's initialized first, so it can't take context
1200
- * This static method is for consistency with other components
1208
+ * Initialize Args instance.
1209
+ * Args.init(context, config) when used from init/setup: context has registerCleanup, Args registers unused-args cleanup.
1210
+ * Args.init(config) for standalone use (no cleanup).
1201
1211
  */
1202
- static init(config2 = {}) {
1203
- return new _Args(config2);
1212
+ static init(contextOrConfig, config2) {
1213
+ if (config2 !== void 0) {
1214
+ return new _Args(contextOrConfig, config2);
1215
+ }
1216
+ return new _Args(contextOrConfig ?? {});
1204
1217
  }
1205
1218
  /**
1206
1219
  * Parse command line arguments
@@ -1380,6 +1393,32 @@ var Args = class _Args {
1380
1393
  }
1381
1394
  return void 0;
1382
1395
  }
1396
+ /**
1397
+ * Return which layer provided the value for get(key): overrides, cli, config, env, or default.
1398
+ * Does not add key to usedKeys. Use after get(key) when you need the origin.
1399
+ */
1400
+ getSource(key) {
1401
+ const resolvedKey = this.aliases[key] || key;
1402
+ const lcKey = resolvedKey.toLowerCase();
1403
+ const overrideKey = Object.keys(this.overrides).find((k) => k.toLowerCase() === lcKey);
1404
+ if (overrideKey !== void 0) return "overrides";
1405
+ const lcKeyWithEnv = `${lcKey}${this.env ? `_${this.env.toLowerCase()}` : ""}`;
1406
+ if (this.env && this.args[lcKeyWithEnv] !== void 0) return "cli";
1407
+ if (this.args[lcKey] !== void 0) return "cli";
1408
+ const configKey = Object.keys(this.configValues).find((k) => k.toLowerCase() === lcKey);
1409
+ if (configKey !== void 0) return "config";
1410
+ const envKey = this.toEnvKey(resolvedKey);
1411
+ const envKeyWithEnv = `${envKey}${this.env ? `_${this.env.toUpperCase()}` : ""}`;
1412
+ const envSpecificKey = Object.keys(process.env).find((k) => this.env && k.toUpperCase() === envKeyWithEnv);
1413
+ const envKeyFound = Object.keys(process.env).find((k) => k.toUpperCase() === envKey);
1414
+ const envKeyAlt = envKey.replace(/_([0-9])/g, "$1");
1415
+ const envKeyAltFound = !envKeyFound ? Object.keys(process.env).find((k) => k.toUpperCase() === envKeyAlt) : null;
1416
+ if (envSpecificKey || envKeyFound || envKeyAltFound) return "env";
1417
+ const defaultKey = Object.keys(this.defaults).find((k) => k.toLowerCase() === lcKey);
1418
+ if (defaultKey !== void 0) return "default";
1419
+ if (lcKey === "env" && process.env.NODE_ENV !== void 0) return "env";
1420
+ return void 0;
1421
+ }
1383
1422
  /**
1384
1423
  * Set a value (for testing/internal use)
1385
1424
  */
@@ -1605,6 +1644,12 @@ var ParamError = class extends FrameworkError {
1605
1644
  this.name = "ParamError";
1606
1645
  }
1607
1646
  };
1647
+ var FileDatabaseError = class extends FrameworkError {
1648
+ constructor(message) {
1649
+ super(message);
1650
+ this.name = "FileDatabaseError";
1651
+ }
1652
+ };
1608
1653
 
1609
1654
  // src/params/custom-types.ts
1610
1655
  var joiEdateType = (value, helpers) => {
@@ -1730,17 +1775,53 @@ var Params = class _Params {
1730
1775
  context;
1731
1776
  // Partial context during initialization
1732
1777
  params = {};
1778
+ paramSources = {};
1733
1779
  definitions = {};
1734
1780
  args;
1735
1781
  paramSetters = [];
1736
1782
  paramGetters = [];
1737
1783
  trackedParams = [];
1784
+ _currentModule = "script";
1785
+ /** Resolved early in constructor so cleanup does not read params lazily */
1786
+ _showUsedParams = false;
1738
1787
  constructor(context, options = {}) {
1739
1788
  this.context = context;
1740
1789
  this.args = context.args;
1741
1790
  if (Object.keys(options).length > 0) {
1742
1791
  this.configure(options);
1743
1792
  }
1793
+ this._showUsedParams = this.get("showUsedParams", "boolean default false");
1794
+ if (context && typeof context.registerCleanup === "function") {
1795
+ context.registerCleanup((ctx) => {
1796
+ if (!ctx.params.getShowUsedParams()) return;
1797
+ const byModule = ctx.params.getFiguredByModule();
1798
+ const modules = Object.keys(byModule).sort();
1799
+ if (modules.length === 0) return;
1800
+ const logger = ctx.logger;
1801
+ logger.debug("[Params]: list of used params:");
1802
+ if (typeof logger.highlight !== "function") {
1803
+ for (const mod of modules) {
1804
+ logger.debug(` [${mod}]`);
1805
+ for (const [key, entry] of Object.entries(byModule[mod])) {
1806
+ logger.debug(` ${key}: ${JSON.stringify(entry.value)} (${entry.source})`);
1807
+ }
1808
+ }
1809
+ return;
1810
+ }
1811
+ for (const mod of modules) {
1812
+ logger.debug(` [${mod}]`);
1813
+ for (const [key, entry] of Object.entries(byModule[mod])) {
1814
+ const valueStr = JSON.stringify(entry.value);
1815
+ const display = entry.source === "default" ? valueStr : logger.highlight(valueStr);
1816
+ logger.debug(` ${key}: ${display} (${entry.source})`);
1817
+ }
1818
+ }
1819
+ });
1820
+ }
1821
+ }
1822
+ /** Whether --showUsedParams was requested (resolved in constructor). */
1823
+ getShowUsedParams() {
1824
+ return this._showUsedParams;
1744
1825
  }
1745
1826
  /**
1746
1827
  * Configure parameters
@@ -1759,14 +1840,15 @@ var Params = class _Params {
1759
1840
  return new _Params(context, options || {});
1760
1841
  }
1761
1842
  /**
1762
- * Track a parameter request for --stopAfter=init feature
1843
+ * Track a parameter request for --stopAfter=init and --showUsedParams
1763
1844
  */
1764
- trackParam(key, definition, value, source) {
1845
+ trackParam(key, definition, value, source, moduleName) {
1765
1846
  this.trackedParams.push({
1766
1847
  key,
1767
1848
  definition,
1768
1849
  value,
1769
- source
1850
+ source,
1851
+ module: moduleName ?? this._currentModule
1770
1852
  });
1771
1853
  }
1772
1854
  /**
@@ -1776,7 +1858,7 @@ var Params = class _Params {
1776
1858
  return [...this.trackedParams];
1777
1859
  }
1778
1860
  /**
1779
- * Get all figured parameters as a record
1861
+ * Get all figured parameters as a record (flat, last occurrence per key)
1780
1862
  * Returns all parameters that were collected during initialization,
1781
1863
  * whether from CLI args, options, or defaults
1782
1864
  */
@@ -1790,6 +1872,19 @@ var Params = class _Params {
1790
1872
  }
1791
1873
  return result;
1792
1874
  }
1875
+ /**
1876
+ * Get figured parameters grouped by module name.
1877
+ * Same param can appear in multiple modules (e.g. source, resource).
1878
+ */
1879
+ getFiguredByModule() {
1880
+ const byModule = {};
1881
+ for (const param of this.trackedParams) {
1882
+ const mod = param.module;
1883
+ if (!byModule[mod]) byModule[mod] = {};
1884
+ byModule[mod][param.key] = { value: param.value, source: param.source };
1885
+ }
1886
+ return byModule;
1887
+ }
1793
1888
  /**
1794
1889
  * Clear tracked parameters
1795
1890
  */
@@ -1908,14 +2003,19 @@ var Params = class _Params {
1908
2003
  source = "options";
1909
2004
  } else if (valFromArgs !== void 0 && valFromArgs !== null) {
1910
2005
  value = this.validate(key, valFromArgs, def);
1911
- source = "cli";
2006
+ const argsSource = this.args.getSource?.(key);
2007
+ if (argsSource === "overrides") source = "options";
2008
+ else if (argsSource === "cli" || argsSource === "env" || argsSource === "config") source = argsSource;
2009
+ else if (argsSource === "default") source = "default";
2010
+ else source = "cli";
1912
2011
  } else if (valFromParams !== void 0 && valFromParams !== null) {
1913
2012
  value = this.validate(key, valFromParams, def);
1914
- source = "options";
2013
+ source = this.paramSources[key] ?? "options";
1915
2014
  } else {
1916
2015
  value = this.validate(key, void 0, def);
1917
2016
  source = "default";
1918
2017
  }
2018
+ this.paramSources[key] = source;
1919
2019
  this.trackParam(key, definition || "string", value, source);
1920
2020
  if (value !== void 0 && def.values && !def.values.includes(value)) {
1921
2021
  throw new ParamError(`key ${key} should be one of ${def.values}`);
@@ -1936,19 +2036,63 @@ var Params = class _Params {
1936
2036
  }
1937
2037
  }
1938
2038
  /**
1939
- * Get all parameters from definitions
1940
- * Processes parameters left-to-right to support cross-parameter references
2039
+ * Get all parameters from definitions (main script).
2040
+ * Same as getAllForModule("script", defs). Processes left-to-right for cross-parameter references.
1941
2041
  */
1942
2042
  getAll(defs) {
1943
- const res = {};
1944
- for (const [k, def] of Object.entries(defs)) {
1945
- const value = this.get(k, def);
1946
- res[k] = value;
1947
- if (value !== void 0) {
1948
- this.params[k] = value;
2043
+ return this.getAllForModule("script", defs);
2044
+ }
2045
+ /**
2046
+ * Get all parameters from definitions for a given module name.
2047
+ * Figured params are grouped by module when using --showUsedParams.
2048
+ * Processes parameters left-to-right to support cross-parameter references.
2049
+ * If moduleName is omitted, it is inferred from the caller's file path (directory name under src/).
2050
+ */
2051
+ getAllForModule(moduleNameOrDefs, defs) {
2052
+ let moduleName;
2053
+ let definitions;
2054
+ if (defs !== void 0) {
2055
+ moduleName = moduleNameOrDefs;
2056
+ definitions = defs;
2057
+ } else {
2058
+ definitions = moduleNameOrDefs;
2059
+ moduleName = this._inferModuleNameFromStack();
2060
+ }
2061
+ const prev = this._currentModule;
2062
+ this._currentModule = moduleName;
2063
+ try {
2064
+ const res = {};
2065
+ for (const [k, def] of Object.entries(definitions)) {
2066
+ const value = this.get(k, def);
2067
+ res[k] = value;
2068
+ if (value !== void 0) {
2069
+ this.params[k] = value;
2070
+ }
1949
2071
  }
2072
+ return res;
2073
+ } finally {
2074
+ this._currentModule = prev;
1950
2075
  }
1951
- return res;
2076
+ }
2077
+ /**
2078
+ * Infer module name from call stack: first caller outside params/index gives path like .../src/<moduleName>/...
2079
+ */
2080
+ _inferModuleNameFromStack() {
2081
+ const stack = new Error().stack;
2082
+ if (!stack) return "script";
2083
+ const lines = stack.split("\n");
2084
+ const paramsIndexPath = "params" + (typeof process !== "undefined" && process.platform === "win32" ? "\\" : "/") + "index.";
2085
+ for (const line of lines) {
2086
+ const parenMatch = line.match(/\(([^)]+)\)/);
2087
+ if (!parenMatch) continue;
2088
+ const parts = parenMatch[1].split(":");
2089
+ if (parts.length < 3) continue;
2090
+ const path4 = parts.slice(0, -2).join(":").replace(/^file:\/\//, "");
2091
+ if (!path4 || path4.includes(paramsIndexPath)) continue;
2092
+ const srcMatch = path4.match(/[/\\]src[/\\]([^/\\]+)(?:[/\\]|$)/);
2093
+ if (srcMatch) return srcMatch[1];
2094
+ }
2095
+ return "script";
1952
2096
  }
1953
2097
  /**
1954
2098
  * Run all registered getters for a key
@@ -2170,13 +2314,7 @@ function defaultVersionSynopsisFunction(metadata) {
2170
2314
  }
2171
2315
 
2172
2316
  // src/filedatabase/index.ts
2173
- var FileDatabaseError = class extends Error {
2174
- constructor(message) {
2175
- super(message);
2176
- this.name = "FileDatabaseError";
2177
- }
2178
- };
2179
- var FileDatabase = class {
2317
+ var FileDatabase = class _FileDatabase {
2180
2318
  basePath;
2181
2319
  namespace;
2182
2320
  tableName = null;
@@ -2213,18 +2351,8 @@ var FileDatabase = class {
2213
2351
  maxVersions: "number default 5",
2214
2352
  pageSize: "number default 5000"
2215
2353
  };
2216
- const paramsConfig = context.params.getAll(defs);
2217
- config2 = {
2218
- basePath: opts.basePath ?? paramsConfig.basePath,
2219
- namespace: opts.namespace ?? paramsConfig.namespace,
2220
- tableName: opts.tableName ?? paramsConfig.tableName ?? null,
2221
- versioned: opts.versioned ?? true,
2222
- maxVersions: opts.maxVersions ?? paramsConfig.maxVersions,
2223
- pageSize: opts.pageSize ?? paramsConfig.pageSize,
2224
- useMetadata: opts.useMetadata ?? true,
2225
- freeSpaceThreshold: opts.freeSpaceThreshold ?? 100 * 1024 * 1024,
2226
- logger: context.logger
2227
- };
2354
+ const discovered = context.params.getAllForModule(defs);
2355
+ config2 = { ...discovered, ...opts, logger: context.logger };
2228
2356
  } else {
2229
2357
  config2 = contextOrConfig;
2230
2358
  }
@@ -2242,6 +2370,13 @@ var FileDatabase = class {
2242
2370
  this.logger = config2.logger || console;
2243
2371
  this.metadata = this.getDefaultMetadata();
2244
2372
  }
2373
+ /**
2374
+ * Initialize FileDatabase from context and options.
2375
+ * Params are read via getAllForModule("filedatabase", defs) for --showUsedParams grouping.
2376
+ */
2377
+ static init(context, options) {
2378
+ return new _FileDatabase(context, options ?? {});
2379
+ }
2245
2380
  /**
2246
2381
  * Get default metadata structure
2247
2382
  */
@@ -3107,9 +3242,6 @@ function listSources(basePath) {
3107
3242
  return [];
3108
3243
  }
3109
3244
  }
3110
- function fileDatabaseInit(context, options = {}) {
3111
- return new FileDatabase(context, options);
3112
- }
3113
3245
 
3114
3246
  // src/db/index.ts
3115
3247
  var import_knex = __toESM(require("knex"), 1);
@@ -3408,6 +3540,13 @@ var Db = class {
3408
3540
  isConnectedToDb() {
3409
3541
  return this.isConnected && this.knexInstance !== null;
3410
3542
  }
3543
+ /**
3544
+ * Initialize Db with context (connects and registers disconnect cleanup).
3545
+ * Params are read via getAllForModule("db", defs). Same as dbInit(context, dbNameOrConnectionString).
3546
+ */
3547
+ static async init(context, dbNameOrConnectionString) {
3548
+ return dbFindAndConnect(context, dbNameOrConnectionString);
3549
+ }
3411
3550
  };
3412
3551
  function capitalizeFirstLetter(str) {
3413
3552
  return str.charAt(0).toUpperCase() + str.slice(1);
@@ -3421,7 +3560,7 @@ async function dbConnect(context, connectionString, name, dbProfile) {
3421
3560
  acquireConnectionTimeout: "number default 10000",
3422
3561
  sslRejectUnauthorized: "boolean default false"
3423
3562
  };
3424
- const paramsConfig = context.params.getAll(defs);
3563
+ const paramsConfig = context.params.getAllForModule(defs);
3425
3564
  const config2 = {
3426
3565
  connectionString,
3427
3566
  name: paramsConfig.name || name || "default",
@@ -3471,7 +3610,7 @@ async function dbFindAndConnect(context, dbNameOrConnectionString) {
3471
3610
  dbConnectionString: "string",
3472
3611
  dbProfile: "boolean default false"
3473
3612
  };
3474
- const paramsConfig = context.params.getAll(defs);
3613
+ const paramsConfig = context.params.getAllForModule(defs);
3475
3614
  dbName = paramsConfig.dbName;
3476
3615
  dbConnectionString = paramsConfig.dbConnectionString;
3477
3616
  dbProfile = paramsConfig.dbProfile;
@@ -3563,8 +3702,7 @@ var Logger = class _Logger {
3563
3702
  this.updateTransport();
3564
3703
  }
3565
3704
  /**
3566
- * Configure logger options
3567
- * Only parameters present in options are updated
3705
+ * Configure logger options. Accepts both LoggerOptions shape and flat param names (levels string, progressWithTimes, progressThrottleMs).
3568
3706
  */
3569
3707
  configure(options) {
3570
3708
  if (options.mode !== void 0) {
@@ -3574,32 +3712,24 @@ var Logger = class _Logger {
3574
3712
  this.options.route = options.route;
3575
3713
  this.updateTransport();
3576
3714
  }
3577
- if (options.prefix !== void 0) {
3578
- this.options.prefix = options.prefix;
3579
- }
3580
- if (options.silent !== void 0) {
3581
- this.options.silent = options.silent;
3582
- }
3583
- if (options.showLevel !== void 0) {
3584
- this.options.showLevel = options.showLevel;
3585
- }
3586
- if (options.timestamp !== void 0) {
3587
- this.options.timestamp = options.timestamp;
3588
- }
3715
+ if (options.prefix !== void 0) this.options.prefix = options.prefix;
3716
+ if (options.silent !== void 0) this.options.silent = options.silent;
3717
+ if (options.showLevel !== void 0) this.options.showLevel = options.showLevel;
3718
+ if (options.timestamp !== void 0) this.options.timestamp = options.timestamp;
3589
3719
  if (options.levels !== void 0) {
3590
- this.options.levels = this.normalizeLevels(options.levels);
3720
+ const levels = typeof options.levels === "string" ? options.levels.split(",") : options.levels;
3721
+ this.options.levels = this.normalizeLevels(levels);
3591
3722
  }
3592
3723
  if (options.progress !== void 0) {
3593
- if (options.progress.withTimes !== void 0) {
3594
- this.options.progressTimes = options.progress.withTimes;
3595
- }
3596
- if (options.progress.throttleMs !== void 0) {
3597
- this.options.progressThrottle = options.progress.throttleMs;
3598
- }
3724
+ if (options.progress.withTimes !== void 0) this.options.progressTimes = options.progress.withTimes;
3725
+ if (options.progress.throttleMs !== void 0) this.options.progressThrottle = options.progress.throttleMs;
3599
3726
  }
3727
+ const flat = options;
3728
+ if (flat.progressWithTimes !== void 0) this.options.progressTimes = flat.progressWithTimes;
3729
+ if (flat.progressThrottleMs !== void 0) this.options.progressThrottle = flat.progressThrottleMs;
3600
3730
  }
3601
3731
  /**
3602
- * Initialize logger from context and CLI parameters
3732
+ * Initialize logger from context and CLI parameters. Whatever is in options goes (after discovered params).
3603
3733
  */
3604
3734
  static init(context, options) {
3605
3735
  const paramDefs = {
@@ -3613,20 +3743,8 @@ var Logger = class _Logger {
3613
3743
  progressWithTimes: "boolean default false",
3614
3744
  progressThrottleMs: "number"
3615
3745
  };
3616
- const cliParams = context.params.getAll(paramDefs);
3617
- const config2 = {
3618
- mode: options?.mode ?? cliParams.mode,
3619
- route: options?.route ?? cliParams.route,
3620
- prefix: options?.prefix ?? cliParams.prefix,
3621
- silent: options?.silent ?? cliParams.silent,
3622
- showLevel: options?.showLevel ?? cliParams.showLevel,
3623
- timestamp: options?.timestamp ?? cliParams.timestamp,
3624
- levels: options?.levels ?? (cliParams.levels ? cliParams.levels.split(",") : void 0),
3625
- progress: options?.progress ?? {
3626
- withTimes: cliParams.progressWithTimes,
3627
- throttleMs: cliParams.progressThrottleMs
3628
- }
3629
- };
3746
+ const discovered = context.params.getAllForModule(paramDefs);
3747
+ const config2 = { ...discovered, ...options };
3630
3748
  const logger = new _Logger(context, config2);
3631
3749
  context.logger = logger;
3632
3750
  return logger;
@@ -3653,6 +3771,10 @@ var Logger = class _Logger {
3653
3771
  }
3654
3772
  this.options.mode = mode;
3655
3773
  }
3774
+ /** Returns a styled string (bright white) for highlighting; keeps chalk inside logger. */
3775
+ highlight(text) {
3776
+ return import_chalk.default.whiteBright(text);
3777
+ }
3656
3778
  debug(message, ...chunks) {
3657
3779
  this.out({ level: "debug", message, chunks });
3658
3780
  }
@@ -3828,12 +3950,7 @@ function extractComponentOptions(opts, componentName) {
3828
3950
  return componentOptions;
3829
3951
  }
3830
3952
  function setup(opts = {}) {
3831
- const args = Args.init({
3832
- overrides: opts.overrides || {},
3833
- defaults: opts.defaults || {}
3834
- });
3835
3953
  const partialContext = {
3836
- args,
3837
3954
  emitter: new import_events.EventEmitter(),
3838
3955
  isStop: () => false,
3839
3956
  cleanupFunctions: [],
@@ -3841,6 +3958,11 @@ function setup(opts = {}) {
3841
3958
  partialContext.cleanupFunctions.push(fn);
3842
3959
  }
3843
3960
  };
3961
+ const args = Args.init(partialContext, {
3962
+ overrides: opts.overrides || {},
3963
+ defaults: opts.defaults || {}
3964
+ });
3965
+ partialContext.args = args;
3844
3966
  const params = Params.init(partialContext, opts.overrides || {});
3845
3967
  partialContext.params = params;
3846
3968
  const loggerOptions = extractComponentOptions(opts, "logger");
@@ -3894,7 +4016,6 @@ function setupContext(opts = {}) {
3894
4016
  dbInit,
3895
4017
  defaultFileSynopsisFunction,
3896
4018
  defaultVersionSynopsisFunction,
3897
- fileDatabaseInit,
3898
4019
  getArgsInstance,
3899
4020
  h,
3900
4021
  joiEdateType,