@nmakarov/cli-toolkit 0.36.0 → 0.39.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/cli-runner.cjs +54 -15
- package/dist/cli-runner.cjs.map +1 -1
- package/dist/cli-runner.js +54 -15
- package/dist/cli-runner.js.map +1 -1
- package/dist/db.cjs +23 -2
- package/dist/db.cjs.map +1 -1
- package/dist/db.js +23 -2
- package/dist/db.js.map +1 -1
- package/dist/index.cjs +54 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +54 -15
- package/dist/index.js.map +1 -1
- package/dist/init.cjs +31 -13
- package/dist/init.cjs.map +1 -1
- package/dist/init.js +31 -13
- package/dist/init.js.map +1 -1
- package/dist/params.cjs +31 -13
- package/dist/params.cjs.map +1 -1
- package/dist/params.js +31 -13
- package/dist/params.js.map +1 -1
- package/package.json +1 -1
package/dist/cli-runner.cjs
CHANGED
|
@@ -1879,11 +1879,14 @@ var Params = class _Params {
|
|
|
1879
1879
|
* Attribution rules:
|
|
1880
1880
|
* - entries figured from an explicit input (cli/env/options/…) are left
|
|
1881
1881
|
* untouched — the component merely confirmed them, the origin stands;
|
|
1882
|
-
* -
|
|
1883
|
-
*
|
|
1882
|
+
* - "default" entries (Params had nothing) and earlier reports are
|
|
1883
|
+
* replaced by the report;
|
|
1884
1884
|
* - keys never seen by Params are appended as new entries.
|
|
1885
|
-
*
|
|
1886
|
-
*
|
|
1885
|
+
* The LATEST report wins — a component may resolve the same key several
|
|
1886
|
+
* times with increasing specificity (e.g. a blueprint re-merged for a
|
|
1887
|
+
* concrete resource) and the dump should show what it settled on.
|
|
1888
|
+
* Later params.get() probes that find nothing ("default") never shadow a
|
|
1889
|
+
* reported value — see {@link getFiguredByModule}.
|
|
1887
1890
|
*
|
|
1888
1891
|
* @param {string} key
|
|
1889
1892
|
* @param {*} value - the value the component actually uses
|
|
@@ -1893,17 +1896,20 @@ var Params = class _Params {
|
|
|
1893
1896
|
reportResolved(key, value, source = "discovered", moduleName) {
|
|
1894
1897
|
const mod = moduleName ?? this._currentModule;
|
|
1895
1898
|
const mine = this.trackedParams.filter((e) => e.key === key && e.module === mod);
|
|
1896
|
-
if (mine.some((e) => e.source !== "default")) {
|
|
1899
|
+
if (mine.some((e) => e.source !== "default" && !e.reported)) {
|
|
1897
1900
|
return;
|
|
1898
1901
|
}
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1902
|
+
this.trackedParams = this.trackedParams.filter(
|
|
1903
|
+
(e) => !(e.key === key && e.module === mod)
|
|
1904
|
+
);
|
|
1905
|
+
this.trackedParams.push({
|
|
1906
|
+
key,
|
|
1907
|
+
definition: "reported",
|
|
1908
|
+
value,
|
|
1909
|
+
source,
|
|
1910
|
+
module: mod,
|
|
1911
|
+
reported: true
|
|
1912
|
+
});
|
|
1907
1913
|
}
|
|
1908
1914
|
/**
|
|
1909
1915
|
* Get all tracked parameters (for --stopAfter=init)
|
|
@@ -1929,12 +1935,24 @@ var Params = class _Params {
|
|
|
1929
1935
|
/**
|
|
1930
1936
|
* Get figured parameters grouped by module name.
|
|
1931
1937
|
* Same param can appear in multiple modules (e.g. source, resource).
|
|
1938
|
+
* Last occurrence per key wins, EXCEPT that an empty probe — a
|
|
1939
|
+
* params.get() that found nothing ("default", undefined) — never shadows
|
|
1940
|
+
* a value reported via {@link reportResolved}: components probe for
|
|
1941
|
+
* overrides on every resolution cycle, and those misses say nothing about
|
|
1942
|
+
* the value the component actually uses.
|
|
1932
1943
|
*/
|
|
1933
1944
|
getFiguredByModule() {
|
|
1945
|
+
const reported = /* @__PURE__ */ new Set();
|
|
1946
|
+
for (const param of this.trackedParams) {
|
|
1947
|
+
if (param.reported) reported.add(`${param.module}\0${param.key}`);
|
|
1948
|
+
}
|
|
1934
1949
|
const byModule = {};
|
|
1935
1950
|
for (const param of this.trackedParams) {
|
|
1936
1951
|
const mod = param.module;
|
|
1937
1952
|
if (!byModule[mod]) byModule[mod] = {};
|
|
1953
|
+
if (!param.reported && param.source === "default" && reported.has(`${mod}\0${param.key}`)) {
|
|
1954
|
+
continue;
|
|
1955
|
+
}
|
|
1938
1956
|
byModule[mod][param.key] = { value: param.value, source: param.source };
|
|
1939
1957
|
}
|
|
1940
1958
|
return byModule;
|
|
@@ -3245,11 +3263,31 @@ var Db = class _Db {
|
|
|
3245
3263
|
}
|
|
3246
3264
|
this.queriesLog = [];
|
|
3247
3265
|
this.knexInstance.queriesLog = this.queriesLog;
|
|
3266
|
+
const startsByConnection = /* @__PURE__ */ new Map();
|
|
3267
|
+
const pushStart = (query) => {
|
|
3268
|
+
const uid = query?.__knexUid ?? "";
|
|
3269
|
+
if (!startsByConnection.has(uid)) {
|
|
3270
|
+
startsByConnection.set(uid, []);
|
|
3271
|
+
}
|
|
3272
|
+
startsByConnection.get(uid).push(process.hrtime());
|
|
3273
|
+
};
|
|
3274
|
+
const popStart = (query) => {
|
|
3275
|
+
const uid = query?.__knexUid ?? "";
|
|
3276
|
+
const stack = startsByConnection.get(uid);
|
|
3277
|
+
if (!stack?.length) {
|
|
3278
|
+
return null;
|
|
3279
|
+
}
|
|
3280
|
+
return stack.pop();
|
|
3281
|
+
};
|
|
3248
3282
|
this.knexInstance.on("query", (query) => {
|
|
3249
|
-
query
|
|
3283
|
+
pushStart(query);
|
|
3250
3284
|
});
|
|
3251
3285
|
this.knexInstance.on("query-response", (_response, query) => {
|
|
3252
|
-
const
|
|
3286
|
+
const start = popStart(query);
|
|
3287
|
+
if (!start) {
|
|
3288
|
+
return;
|
|
3289
|
+
}
|
|
3290
|
+
const [seconds, nanoseconds] = process.hrtime(start);
|
|
3253
3291
|
const executionTimeMs = (seconds * 1e3 + nanoseconds / 1e6).toFixed(2);
|
|
3254
3292
|
const logEntry = {
|
|
3255
3293
|
sql: query.sql,
|
|
@@ -3260,6 +3298,7 @@ var Db = class _Db {
|
|
|
3260
3298
|
this.logger.debug?.(`[Db] Query: ${query.sql} | Duration: ${executionTimeMs}ms`);
|
|
3261
3299
|
});
|
|
3262
3300
|
this.knexInstance.on("query-error", (error, query) => {
|
|
3301
|
+
popStart(query);
|
|
3263
3302
|
this.logger.error?.(`[Db] Query failed: ${query.sql}`, error);
|
|
3264
3303
|
});
|
|
3265
3304
|
}
|