@smallpen/cli 0.1.0-alpha.1
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/bin/help.mjs +620 -0
- package/bin/smallpen-check.cjs +30 -0
- package/bin/smallpen.mjs +2509 -0
- package/bin/warning-output.mjs +64 -0
- package/package.json +26 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Presentation only: the core warning list and mutation semantics stay unchanged.
|
|
2
|
+
export function warningOutput(warnings, detail, { confirmUnmatched = false } = {}) {
|
|
3
|
+
const rank = (warning) => warning.match === "exact"
|
|
4
|
+
? 0
|
|
5
|
+
: warning.suggestions.length > 0 ? 1 : 2;
|
|
6
|
+
const counts = {
|
|
7
|
+
actionableExact: 0,
|
|
8
|
+
unmatchedWithSuggestions: 0,
|
|
9
|
+
unmatchedWithoutSuggestions: 0,
|
|
10
|
+
};
|
|
11
|
+
const countKeys = Object.keys(counts);
|
|
12
|
+
for (const warning of warnings) counts[countKeys[rank(warning)]] += 1;
|
|
13
|
+
// All advice in one batch comes from the same context search index.
|
|
14
|
+
const warningSummary = {
|
|
15
|
+
detail,
|
|
16
|
+
total: warnings.length,
|
|
17
|
+
counts,
|
|
18
|
+
contextScope: warnings[0]?.contextScope,
|
|
19
|
+
};
|
|
20
|
+
if (detail === "full") {
|
|
21
|
+
return {
|
|
22
|
+
warningSummary,
|
|
23
|
+
warnings: confirmUnmatched
|
|
24
|
+
? warnings.map((warning) =>
|
|
25
|
+
warning.code === "design_token_value_unmatched"
|
|
26
|
+
? { ...warning, confirmed: true }
|
|
27
|
+
: warning,
|
|
28
|
+
)
|
|
29
|
+
: warnings,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const groups = new Map();
|
|
34
|
+
for (const [warningIndex, warning] of warnings.entries()) {
|
|
35
|
+
const { nodeId, operationIndex, value, contextScope, ...shared } = warning;
|
|
36
|
+
const key = JSON.stringify(shared);
|
|
37
|
+
let group = groups.get(key);
|
|
38
|
+
if (!group) {
|
|
39
|
+
group = { ...shared, count: 0, locations: [] };
|
|
40
|
+
groups.set(key, group);
|
|
41
|
+
}
|
|
42
|
+
group.count += 1;
|
|
43
|
+
group.locations.push({ warningIndex, operationIndex, nodeId, value });
|
|
44
|
+
}
|
|
45
|
+
const grouped = [...groups.values()].sort(
|
|
46
|
+
(left, right) => rank(left) - rank(right),
|
|
47
|
+
);
|
|
48
|
+
return {
|
|
49
|
+
warningSummary: confirmUnmatched
|
|
50
|
+
? {
|
|
51
|
+
...warningSummary,
|
|
52
|
+
unmatchedConfirmed: counts.unmatchedWithSuggestions +
|
|
53
|
+
counts.unmatchedWithoutSuggestions,
|
|
54
|
+
}
|
|
55
|
+
: warningSummary,
|
|
56
|
+
warnings: confirmUnmatched
|
|
57
|
+
? grouped.map((group) =>
|
|
58
|
+
group.code === "design_token_value_unmatched"
|
|
59
|
+
? { ...group, confirmed: true }
|
|
60
|
+
: group,
|
|
61
|
+
)
|
|
62
|
+
: grouped,
|
|
63
|
+
};
|
|
64
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@smallpen/cli",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./launcher": "./bin/smallpen-check.cjs"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"smallpen": "./bin/smallpen-check.cjs"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"bin"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@smallpen/core": "0.1.0-alpha.1",
|
|
19
|
+
"@smallpen/local-package": "0.1.0-alpha.1"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/SmallRaw/SmallPen.git",
|
|
24
|
+
"directory": "smallpen/apps/cli"
|
|
25
|
+
}
|
|
26
|
+
}
|