@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.js
CHANGED
|
@@ -1863,11 +1863,14 @@ var Params = class _Params {
|
|
|
1863
1863
|
* Attribution rules:
|
|
1864
1864
|
* - entries figured from an explicit input (cli/env/options/…) are left
|
|
1865
1865
|
* untouched — the component merely confirmed them, the origin stands;
|
|
1866
|
-
* -
|
|
1867
|
-
*
|
|
1866
|
+
* - "default" entries (Params had nothing) and earlier reports are
|
|
1867
|
+
* replaced by the report;
|
|
1868
1868
|
* - keys never seen by Params are appended as new entries.
|
|
1869
|
-
*
|
|
1870
|
-
*
|
|
1869
|
+
* The LATEST report wins — a component may resolve the same key several
|
|
1870
|
+
* times with increasing specificity (e.g. a blueprint re-merged for a
|
|
1871
|
+
* concrete resource) and the dump should show what it settled on.
|
|
1872
|
+
* Later params.get() probes that find nothing ("default") never shadow a
|
|
1873
|
+
* reported value — see {@link getFiguredByModule}.
|
|
1871
1874
|
*
|
|
1872
1875
|
* @param {string} key
|
|
1873
1876
|
* @param {*} value - the value the component actually uses
|
|
@@ -1877,17 +1880,20 @@ var Params = class _Params {
|
|
|
1877
1880
|
reportResolved(key, value, source = "discovered", moduleName) {
|
|
1878
1881
|
const mod = moduleName ?? this._currentModule;
|
|
1879
1882
|
const mine = this.trackedParams.filter((e) => e.key === key && e.module === mod);
|
|
1880
|
-
if (mine.some((e) => e.source !== "default")) {
|
|
1883
|
+
if (mine.some((e) => e.source !== "default" && !e.reported)) {
|
|
1881
1884
|
return;
|
|
1882
1885
|
}
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1886
|
+
this.trackedParams = this.trackedParams.filter(
|
|
1887
|
+
(e) => !(e.key === key && e.module === mod)
|
|
1888
|
+
);
|
|
1889
|
+
this.trackedParams.push({
|
|
1890
|
+
key,
|
|
1891
|
+
definition: "reported",
|
|
1892
|
+
value,
|
|
1893
|
+
source,
|
|
1894
|
+
module: mod,
|
|
1895
|
+
reported: true
|
|
1896
|
+
});
|
|
1891
1897
|
}
|
|
1892
1898
|
/**
|
|
1893
1899
|
* Get all tracked parameters (for --stopAfter=init)
|
|
@@ -1913,12 +1919,24 @@ var Params = class _Params {
|
|
|
1913
1919
|
/**
|
|
1914
1920
|
* Get figured parameters grouped by module name.
|
|
1915
1921
|
* Same param can appear in multiple modules (e.g. source, resource).
|
|
1922
|
+
* Last occurrence per key wins, EXCEPT that an empty probe — a
|
|
1923
|
+
* params.get() that found nothing ("default", undefined) — never shadows
|
|
1924
|
+
* a value reported via {@link reportResolved}: components probe for
|
|
1925
|
+
* overrides on every resolution cycle, and those misses say nothing about
|
|
1926
|
+
* the value the component actually uses.
|
|
1916
1927
|
*/
|
|
1917
1928
|
getFiguredByModule() {
|
|
1929
|
+
const reported = /* @__PURE__ */ new Set();
|
|
1930
|
+
for (const param of this.trackedParams) {
|
|
1931
|
+
if (param.reported) reported.add(`${param.module}\0${param.key}`);
|
|
1932
|
+
}
|
|
1918
1933
|
const byModule = {};
|
|
1919
1934
|
for (const param of this.trackedParams) {
|
|
1920
1935
|
const mod = param.module;
|
|
1921
1936
|
if (!byModule[mod]) byModule[mod] = {};
|
|
1937
|
+
if (!param.reported && param.source === "default" && reported.has(`${mod}\0${param.key}`)) {
|
|
1938
|
+
continue;
|
|
1939
|
+
}
|
|
1922
1940
|
byModule[mod][param.key] = { value: param.value, source: param.source };
|
|
1923
1941
|
}
|
|
1924
1942
|
return byModule;
|
|
@@ -3229,11 +3247,31 @@ var Db = class _Db {
|
|
|
3229
3247
|
}
|
|
3230
3248
|
this.queriesLog = [];
|
|
3231
3249
|
this.knexInstance.queriesLog = this.queriesLog;
|
|
3250
|
+
const startsByConnection = /* @__PURE__ */ new Map();
|
|
3251
|
+
const pushStart = (query) => {
|
|
3252
|
+
const uid = query?.__knexUid ?? "";
|
|
3253
|
+
if (!startsByConnection.has(uid)) {
|
|
3254
|
+
startsByConnection.set(uid, []);
|
|
3255
|
+
}
|
|
3256
|
+
startsByConnection.get(uid).push(process.hrtime());
|
|
3257
|
+
};
|
|
3258
|
+
const popStart = (query) => {
|
|
3259
|
+
const uid = query?.__knexUid ?? "";
|
|
3260
|
+
const stack = startsByConnection.get(uid);
|
|
3261
|
+
if (!stack?.length) {
|
|
3262
|
+
return null;
|
|
3263
|
+
}
|
|
3264
|
+
return stack.pop();
|
|
3265
|
+
};
|
|
3232
3266
|
this.knexInstance.on("query", (query) => {
|
|
3233
|
-
query
|
|
3267
|
+
pushStart(query);
|
|
3234
3268
|
});
|
|
3235
3269
|
this.knexInstance.on("query-response", (_response, query) => {
|
|
3236
|
-
const
|
|
3270
|
+
const start = popStart(query);
|
|
3271
|
+
if (!start) {
|
|
3272
|
+
return;
|
|
3273
|
+
}
|
|
3274
|
+
const [seconds, nanoseconds] = process.hrtime(start);
|
|
3237
3275
|
const executionTimeMs = (seconds * 1e3 + nanoseconds / 1e6).toFixed(2);
|
|
3238
3276
|
const logEntry = {
|
|
3239
3277
|
sql: query.sql,
|
|
@@ -3244,6 +3282,7 @@ var Db = class _Db {
|
|
|
3244
3282
|
this.logger.debug?.(`[Db] Query: ${query.sql} | Duration: ${executionTimeMs}ms`);
|
|
3245
3283
|
});
|
|
3246
3284
|
this.knexInstance.on("query-error", (error, query) => {
|
|
3285
|
+
popStart(query);
|
|
3247
3286
|
this.logger.error?.(`[Db] Query failed: ${query.sql}`, error);
|
|
3248
3287
|
});
|
|
3249
3288
|
}
|