@produtype/core 0.61.0 → 0.62.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.
|
@@ -4,9 +4,35 @@ exports.detectObservability = detectObservability;
|
|
|
4
4
|
const detectContext_1 = require("./detectContext");
|
|
5
5
|
const textSearch_1 = require("../utils/textSearch");
|
|
6
6
|
const absenceEvidence_1 = require("./absenceEvidence");
|
|
7
|
+
const valuesFromPackage_1 = require("./structural/valuesFromPackage");
|
|
8
|
+
/**
|
|
9
|
+
* Logging packages, which the ecosystem names and the author does not.
|
|
10
|
+
*
|
|
11
|
+
* The list was four long and the search beside it read `logger.` — the author's own
|
|
12
|
+
* variable. A repository using Roarr, bound to `shout`, was reported as having no
|
|
13
|
+
* logging at all: wrong package, wrong variable, two ways to miss the same thing.
|
|
14
|
+
*
|
|
15
|
+
* A list of package names is still a list, but it is a list of names nobody in the
|
|
16
|
+
* repository being analysed chose. That is the difference the whole exercise is about.
|
|
17
|
+
*/
|
|
18
|
+
const LOGGING_PACKAGES = [
|
|
19
|
+
'winston',
|
|
20
|
+
'pino',
|
|
21
|
+
'morgan',
|
|
22
|
+
'bunyan',
|
|
23
|
+
'roarr',
|
|
24
|
+
'loglevel',
|
|
25
|
+
'signale',
|
|
26
|
+
'consola',
|
|
27
|
+
'tslog',
|
|
28
|
+
'log4js',
|
|
29
|
+
'@logtail/node',
|
|
30
|
+
'debug',
|
|
31
|
+
'npmlog',
|
|
32
|
+
];
|
|
7
33
|
async function detectObservability(ctx) {
|
|
8
34
|
const evidence = [];
|
|
9
|
-
const logDeps = (0, detectContext_1.hasAnyDep)(ctx,
|
|
35
|
+
const logDeps = (0, detectContext_1.hasAnyDep)(ctx, LOGGING_PACKAGES);
|
|
10
36
|
const sentryDeps = (0, detectContext_1.hasAnyDep)(ctx, ['@sentry/node', 'sentry-sdk']);
|
|
11
37
|
for (const d of logDeps)
|
|
12
38
|
evidence.push({ type: 'dependency', value: d, claim: 'logging' });
|
|
@@ -70,6 +96,26 @@ async function detectObservability(ctx) {
|
|
|
70
96
|
const plainLogging = await (0, textSearch_1.searchInFiles)(ctx.root, ctx.files.source, [/\berror_log\s*\(/, /\bsyslog\s*\(/, /console\.(error|warn)\s*\(/, /\bprintStackTrace\s*\(/], 10);
|
|
71
97
|
for (const m of plainLogging)
|
|
72
98
|
evidence.push({ type: 'snippet', value: m.snippet, file: m.file, line: m.line, claim: 'logging' });
|
|
99
|
+
/**
|
|
100
|
+
* Where a value from a logging package is used, whatever it was called.
|
|
101
|
+
*
|
|
102
|
+
* `const shout = Roarr.child(...)` then `shout.info(...)` is structured logging, and
|
|
103
|
+
* the text search cannot see it because `shout` is a name its author invented. The
|
|
104
|
+
* import is the anchor and the binding is the chain.
|
|
105
|
+
*
|
|
106
|
+
* Evidence, not verdict, and the distinction is measured rather than assumed. This
|
|
107
|
+
* walk can only fire where one of the packages above is imported, and a package that
|
|
108
|
+
* is imported is a package the manifest declares — workspace manifests included, as
|
|
109
|
+
* a monorepo fixture confirmed. So it never changes the answer, and the clause that
|
|
110
|
+
* pretended it might was removed rather than left to look load-bearing.
|
|
111
|
+
*
|
|
112
|
+
* What it does change is what the reader is shown: "pino is in your package.json"
|
|
113
|
+
* becomes "pino is used at server.js:8". The claim was always about the second.
|
|
114
|
+
*/
|
|
115
|
+
const boundLoggerUses = await (0, valuesFromPackage_1.readPackageValueUses)(ctx.root, ctx.files.source, LOGGING_PACKAGES);
|
|
116
|
+
for (const use of (boundLoggerUses ?? []).slice(0, 10)) {
|
|
117
|
+
evidence.push({ type: 'file', value: `a logger from ${logDeps[0] ?? 'a logging package'} is used here`, file: use.file, line: use.line, claim: 'logging' });
|
|
118
|
+
}
|
|
73
119
|
const hasStructuredLogging = logDeps.length > 0 || structuredHits.length > 0;
|
|
74
120
|
const hasAnyLogging = hasStructuredLogging || plainLogging.length > 0;
|
|
75
121
|
if (!hasHealth) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@produtype/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.62.0",
|
|
4
4
|
"description": "Deterministic CLI and library that analyzes a web application repository and reports how far it is from production-ready for the kind of product it is meant to be.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|