@rtorcato/js-tooling 2.1.2 → 2.2.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/commands/doctor.js +40 -0
- package/package.json +1 -1
|
@@ -2,6 +2,45 @@ import chalk from 'chalk';
|
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
const PACKAGE = '@rtorcato/js-tooling';
|
|
5
|
+
const NODE_MIN_MAJOR = 22;
|
|
6
|
+
const NODE_LTS_REQUIREMENTS = {
|
|
7
|
+
22: { minor: 22, patch: 2 },
|
|
8
|
+
24: { minor: 15, patch: 0 },
|
|
9
|
+
};
|
|
10
|
+
function parseNodeVersion(version) {
|
|
11
|
+
const clean = version.replace(/^v/, '').split('-')[0] ?? '';
|
|
12
|
+
const [maj, min, pat] = clean.split('.').map((n) => Number.parseInt(n, 10) || 0);
|
|
13
|
+
return [maj ?? 0, min ?? 0, pat ?? 0];
|
|
14
|
+
}
|
|
15
|
+
export function evaluateNodeVersion(version) {
|
|
16
|
+
const [major, minor, patch] = parseNodeVersion(version);
|
|
17
|
+
const display = `v${major}.${minor}.${patch}`;
|
|
18
|
+
if (major < NODE_MIN_MAJOR) {
|
|
19
|
+
return {
|
|
20
|
+
check: 'Node',
|
|
21
|
+
status: 'missing',
|
|
22
|
+
detail: `${display} is below required Node ${NODE_MIN_MAJOR}+`,
|
|
23
|
+
hint: `Install Node ${NODE_MIN_MAJOR} LTS or newer (https://nodejs.org)`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const lts = NODE_LTS_REQUIREMENTS[major];
|
|
27
|
+
if (lts) {
|
|
28
|
+
const meets = minor > lts.minor || (minor === lts.minor && patch >= lts.patch);
|
|
29
|
+
if (!meets) {
|
|
30
|
+
return {
|
|
31
|
+
check: 'Node',
|
|
32
|
+
status: 'drift',
|
|
33
|
+
detail: `${display} — npm may emit EBADENGINE warnings from transitive deps`,
|
|
34
|
+
hint: `Upgrade to Node ${major}.${lts.minor}.${lts.patch}+ (or 26+) to silence transitive engine warnings`,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
check: 'Node',
|
|
40
|
+
status: 'ok',
|
|
41
|
+
detail: display,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
5
44
|
const FILE_CHECKS = [
|
|
6
45
|
{
|
|
7
46
|
check: 'TypeScript',
|
|
@@ -103,6 +142,7 @@ async function checkPackageJson(dir) {
|
|
|
103
142
|
export async function runDoctor(dir) {
|
|
104
143
|
const targetDir = path.resolve(dir);
|
|
105
144
|
const results = [];
|
|
145
|
+
results.push(evaluateNodeVersion(process.version));
|
|
106
146
|
results.push(await checkPackageJson(targetDir));
|
|
107
147
|
for (const spec of FILE_CHECKS) {
|
|
108
148
|
results.push(await checkFile(targetDir, spec));
|