@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/index.js
CHANGED
|
@@ -1810,11 +1810,14 @@ var Params = class _Params {
|
|
|
1810
1810
|
* Attribution rules:
|
|
1811
1811
|
* - entries figured from an explicit input (cli/env/options/…) are left
|
|
1812
1812
|
* untouched — the component merely confirmed them, the origin stands;
|
|
1813
|
-
* -
|
|
1814
|
-
*
|
|
1813
|
+
* - "default" entries (Params had nothing) and earlier reports are
|
|
1814
|
+
* replaced by the report;
|
|
1815
1815
|
* - keys never seen by Params are appended as new entries.
|
|
1816
|
-
*
|
|
1817
|
-
*
|
|
1816
|
+
* The LATEST report wins — a component may resolve the same key several
|
|
1817
|
+
* times with increasing specificity (e.g. a blueprint re-merged for a
|
|
1818
|
+
* concrete resource) and the dump should show what it settled on.
|
|
1819
|
+
* Later params.get() probes that find nothing ("default") never shadow a
|
|
1820
|
+
* reported value — see {@link getFiguredByModule}.
|
|
1818
1821
|
*
|
|
1819
1822
|
* @param {string} key
|
|
1820
1823
|
* @param {*} value - the value the component actually uses
|
|
@@ -1824,17 +1827,20 @@ var Params = class _Params {
|
|
|
1824
1827
|
reportResolved(key, value, source = "discovered", moduleName) {
|
|
1825
1828
|
const mod = moduleName ?? this._currentModule;
|
|
1826
1829
|
const mine = this.trackedParams.filter((e) => e.key === key && e.module === mod);
|
|
1827
|
-
if (mine.some((e) => e.source !== "default")) {
|
|
1830
|
+
if (mine.some((e) => e.source !== "default" && !e.reported)) {
|
|
1828
1831
|
return;
|
|
1829
1832
|
}
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1833
|
+
this.trackedParams = this.trackedParams.filter(
|
|
1834
|
+
(e) => !(e.key === key && e.module === mod)
|
|
1835
|
+
);
|
|
1836
|
+
this.trackedParams.push({
|
|
1837
|
+
key,
|
|
1838
|
+
definition: "reported",
|
|
1839
|
+
value,
|
|
1840
|
+
source,
|
|
1841
|
+
module: mod,
|
|
1842
|
+
reported: true
|
|
1843
|
+
});
|
|
1838
1844
|
}
|
|
1839
1845
|
/**
|
|
1840
1846
|
* Get all tracked parameters (for --stopAfter=init)
|
|
@@ -1860,12 +1866,24 @@ var Params = class _Params {
|
|
|
1860
1866
|
/**
|
|
1861
1867
|
* Get figured parameters grouped by module name.
|
|
1862
1868
|
* Same param can appear in multiple modules (e.g. source, resource).
|
|
1869
|
+
* Last occurrence per key wins, EXCEPT that an empty probe — a
|
|
1870
|
+
* params.get() that found nothing ("default", undefined) — never shadows
|
|
1871
|
+
* a value reported via {@link reportResolved}: components probe for
|
|
1872
|
+
* overrides on every resolution cycle, and those misses say nothing about
|
|
1873
|
+
* the value the component actually uses.
|
|
1863
1874
|
*/
|
|
1864
1875
|
getFiguredByModule() {
|
|
1876
|
+
const reported = /* @__PURE__ */ new Set();
|
|
1877
|
+
for (const param of this.trackedParams) {
|
|
1878
|
+
if (param.reported) reported.add(`${param.module}\0${param.key}`);
|
|
1879
|
+
}
|
|
1865
1880
|
const byModule = {};
|
|
1866
1881
|
for (const param of this.trackedParams) {
|
|
1867
1882
|
const mod = param.module;
|
|
1868
1883
|
if (!byModule[mod]) byModule[mod] = {};
|
|
1884
|
+
if (!param.reported && param.source === "default" && reported.has(`${mod}\0${param.key}`)) {
|
|
1885
|
+
continue;
|
|
1886
|
+
}
|
|
1869
1887
|
byModule[mod][param.key] = { value: param.value, source: param.source };
|
|
1870
1888
|
}
|
|
1871
1889
|
return byModule;
|
|
@@ -3902,11 +3920,31 @@ var Db = class _Db {
|
|
|
3902
3920
|
}
|
|
3903
3921
|
this.queriesLog = [];
|
|
3904
3922
|
this.knexInstance.queriesLog = this.queriesLog;
|
|
3923
|
+
const startsByConnection = /* @__PURE__ */ new Map();
|
|
3924
|
+
const pushStart = (query) => {
|
|
3925
|
+
const uid = query?.__knexUid ?? "";
|
|
3926
|
+
if (!startsByConnection.has(uid)) {
|
|
3927
|
+
startsByConnection.set(uid, []);
|
|
3928
|
+
}
|
|
3929
|
+
startsByConnection.get(uid).push(process.hrtime());
|
|
3930
|
+
};
|
|
3931
|
+
const popStart = (query) => {
|
|
3932
|
+
const uid = query?.__knexUid ?? "";
|
|
3933
|
+
const stack = startsByConnection.get(uid);
|
|
3934
|
+
if (!stack?.length) {
|
|
3935
|
+
return null;
|
|
3936
|
+
}
|
|
3937
|
+
return stack.pop();
|
|
3938
|
+
};
|
|
3905
3939
|
this.knexInstance.on("query", (query) => {
|
|
3906
|
-
query
|
|
3940
|
+
pushStart(query);
|
|
3907
3941
|
});
|
|
3908
3942
|
this.knexInstance.on("query-response", (_response, query) => {
|
|
3909
|
-
const
|
|
3943
|
+
const start = popStart(query);
|
|
3944
|
+
if (!start) {
|
|
3945
|
+
return;
|
|
3946
|
+
}
|
|
3947
|
+
const [seconds, nanoseconds] = process.hrtime(start);
|
|
3910
3948
|
const executionTimeMs = (seconds * 1e3 + nanoseconds / 1e6).toFixed(2);
|
|
3911
3949
|
const logEntry = {
|
|
3912
3950
|
sql: query.sql,
|
|
@@ -3917,6 +3955,7 @@ var Db = class _Db {
|
|
|
3917
3955
|
this.logger.debug?.(`[Db] Query: ${query.sql} | Duration: ${executionTimeMs}ms`);
|
|
3918
3956
|
});
|
|
3919
3957
|
this.knexInstance.on("query-error", (error, query) => {
|
|
3958
|
+
popStart(query);
|
|
3920
3959
|
this.logger.error?.(`[Db] Query failed: ${query.sql}`, error);
|
|
3921
3960
|
});
|
|
3922
3961
|
}
|