@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.js CHANGED
@@ -1852,11 +1852,14 @@ var Params = class _Params {
1852
1852
  * Attribution rules:
1853
1853
  * - entries figured from an explicit input (cli/env/options/…) are left
1854
1854
  * untouched — the component merely confirmed them, the origin stands;
1855
- * - entries whose source is "default" (Params had nothing) are upgraded
1856
- * in place to the reported value and source;
1855
+ * - "default" entries (Params had nothing) and earlier reports are
1856
+ * replaced by the report;
1857
1857
  * - keys never seen by Params are appended as new entries.
1858
- * First report wins: once upgraded, later reports for the same key/module
1859
- * are ignored (the source is no longer "default").
1858
+ * The LATEST report wins a component may resolve the same key several
1859
+ * times with increasing specificity (e.g. a blueprint re-merged for a
1860
+ * concrete resource) and the dump should show what it settled on.
1861
+ * Later params.get() probes that find nothing ("default") never shadow a
1862
+ * reported value — see {@link getFiguredByModule}.
1860
1863
  *
1861
1864
  * @param {string} key
1862
1865
  * @param {*} value - the value the component actually uses
@@ -1866,17 +1869,20 @@ var Params = class _Params {
1866
1869
  reportResolved(key, value, source = "discovered", moduleName) {
1867
1870
  const mod = moduleName ?? this._currentModule;
1868
1871
  const mine = this.trackedParams.filter((e) => e.key === key && e.module === mod);
1869
- if (mine.some((e) => e.source !== "default")) {
1872
+ if (mine.some((e) => e.source !== "default" && !e.reported)) {
1870
1873
  return;
1871
1874
  }
1872
- if (mine.length === 0) {
1873
- this.trackParam(key, "reported", value, source, mod);
1874
- return;
1875
- }
1876
- for (const entry of mine) {
1877
- entry.value = value;
1878
- entry.source = source;
1879
- }
1875
+ this.trackedParams = this.trackedParams.filter(
1876
+ (e) => !(e.key === key && e.module === mod)
1877
+ );
1878
+ this.trackedParams.push({
1879
+ key,
1880
+ definition: "reported",
1881
+ value,
1882
+ source,
1883
+ module: mod,
1884
+ reported: true
1885
+ });
1880
1886
  }
1881
1887
  /**
1882
1888
  * Get all tracked parameters (for --stopAfter=init)
@@ -1902,12 +1908,24 @@ var Params = class _Params {
1902
1908
  /**
1903
1909
  * Get figured parameters grouped by module name.
1904
1910
  * Same param can appear in multiple modules (e.g. source, resource).
1911
+ * Last occurrence per key wins, EXCEPT that an empty probe — a
1912
+ * params.get() that found nothing ("default", undefined) — never shadows
1913
+ * a value reported via {@link reportResolved}: components probe for
1914
+ * overrides on every resolution cycle, and those misses say nothing about
1915
+ * the value the component actually uses.
1905
1916
  */
1906
1917
  getFiguredByModule() {
1918
+ const reported = /* @__PURE__ */ new Set();
1919
+ for (const param of this.trackedParams) {
1920
+ if (param.reported) reported.add(`${param.module}\0${param.key}`);
1921
+ }
1907
1922
  const byModule = {};
1908
1923
  for (const param of this.trackedParams) {
1909
1924
  const mod = param.module;
1910
1925
  if (!byModule[mod]) byModule[mod] = {};
1926
+ if (!param.reported && param.source === "default" && reported.has(`${mod}\0${param.key}`)) {
1927
+ continue;
1928
+ }
1911
1929
  byModule[mod][param.key] = { value: param.value, source: param.source };
1912
1930
  }
1913
1931
  return byModule;