@nmakarov/cli-toolkit 0.36.0 → 0.37.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
@@ -1877,11 +1877,14 @@ var Params = class _Params {
1877
1877
  * Attribution rules:
1878
1878
  * - entries figured from an explicit input (cli/env/options/…) are left
1879
1879
  * untouched — the component merely confirmed them, the origin stands;
1880
- * - entries whose source is "default" (Params had nothing) are upgraded
1881
- * in place to the reported value and source;
1880
+ * - "default" entries (Params had nothing) and earlier reports are
1881
+ * replaced by the report;
1882
1882
  * - keys never seen by Params are appended as new entries.
1883
- * First report wins: once upgraded, later reports for the same key/module
1884
- * are ignored (the source is no longer "default").
1883
+ * The LATEST report wins a component may resolve the same key several
1884
+ * times with increasing specificity (e.g. a blueprint re-merged for a
1885
+ * concrete resource) and the dump should show what it settled on.
1886
+ * Later params.get() probes that find nothing ("default") never shadow a
1887
+ * reported value — see {@link getFiguredByModule}.
1885
1888
  *
1886
1889
  * @param {string} key
1887
1890
  * @param {*} value - the value the component actually uses
@@ -1891,17 +1894,20 @@ var Params = class _Params {
1891
1894
  reportResolved(key, value, source = "discovered", moduleName) {
1892
1895
  const mod = moduleName ?? this._currentModule;
1893
1896
  const mine = this.trackedParams.filter((e) => e.key === key && e.module === mod);
1894
- if (mine.some((e) => e.source !== "default")) {
1897
+ if (mine.some((e) => e.source !== "default" && !e.reported)) {
1895
1898
  return;
1896
1899
  }
1897
- if (mine.length === 0) {
1898
- this.trackParam(key, "reported", value, source, mod);
1899
- return;
1900
- }
1901
- for (const entry of mine) {
1902
- entry.value = value;
1903
- entry.source = source;
1904
- }
1900
+ this.trackedParams = this.trackedParams.filter(
1901
+ (e) => !(e.key === key && e.module === mod)
1902
+ );
1903
+ this.trackedParams.push({
1904
+ key,
1905
+ definition: "reported",
1906
+ value,
1907
+ source,
1908
+ module: mod,
1909
+ reported: true
1910
+ });
1905
1911
  }
1906
1912
  /**
1907
1913
  * Get all tracked parameters (for --stopAfter=init)
@@ -1927,12 +1933,24 @@ var Params = class _Params {
1927
1933
  /**
1928
1934
  * Get figured parameters grouped by module name.
1929
1935
  * Same param can appear in multiple modules (e.g. source, resource).
1936
+ * Last occurrence per key wins, EXCEPT that an empty probe — a
1937
+ * params.get() that found nothing ("default", undefined) — never shadows
1938
+ * a value reported via {@link reportResolved}: components probe for
1939
+ * overrides on every resolution cycle, and those misses say nothing about
1940
+ * the value the component actually uses.
1930
1941
  */
1931
1942
  getFiguredByModule() {
1943
+ const reported = /* @__PURE__ */ new Set();
1944
+ for (const param of this.trackedParams) {
1945
+ if (param.reported) reported.add(`${param.module}\0${param.key}`);
1946
+ }
1932
1947
  const byModule = {};
1933
1948
  for (const param of this.trackedParams) {
1934
1949
  const mod = param.module;
1935
1950
  if (!byModule[mod]) byModule[mod] = {};
1951
+ if (!param.reported && param.source === "default" && reported.has(`${mod}\0${param.key}`)) {
1952
+ continue;
1953
+ }
1936
1954
  byModule[mod][param.key] = { value: param.value, source: param.source };
1937
1955
  }
1938
1956
  return byModule;