@arcgis/codemod 6.0.0-next.12 → 6.0.0-next.13
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/chunks/artifact.js +36 -32
- package/dist/chunks/classification.js +83 -69
- package/dist/chunks/cli.js +237 -207
- package/dist/chunks/componentAudit.js +156 -104
- package/dist/chunks/format.js +92 -92
- package/dist/chunks/index.js +703 -465
- package/dist/chunks/index2.js +13 -13
- package/dist/chunks/index3.js +240 -205
- package/dist/chunks/useProjectInstance.js +18 -15
- package/package.json +5 -4
package/dist/chunks/index2.js
CHANGED
|
@@ -29,17 +29,17 @@ var P = (a, o, c) => {
|
|
|
29
29
|
};
|
|
30
30
|
return e();
|
|
31
31
|
};
|
|
32
|
-
import { log as
|
|
32
|
+
import { log as S } from "@arcgis/toolkit/log";
|
|
33
33
|
import { path as O } from "@arcgis/node-toolkit/path";
|
|
34
34
|
import { styleText as R } from "node:util";
|
|
35
|
-
import
|
|
35
|
+
import b from "typescript";
|
|
36
36
|
import { f as h } from "./log.js";
|
|
37
37
|
import { r as T, i as A } from "./cli.js";
|
|
38
38
|
import { c as M } from "./useProjectInstance.js";
|
|
39
39
|
import { g as $, a as w, p as j, s as E } from "./artifact.js";
|
|
40
40
|
import { loadCodeowners as F } from "@arcgis/node-toolkit/codeowners";
|
|
41
41
|
import { b as L, d as z, a as I, c as K, e as Q, f as V } from "./classification.js";
|
|
42
|
-
import { s as W,
|
|
42
|
+
import { s as W, i as J, d as q, e as B, f as G } from "./componentAudit.js";
|
|
43
43
|
async function pe(a, o) {
|
|
44
44
|
const c = !a && process.cwd() === $().repositoryRoot;
|
|
45
45
|
await T(
|
|
@@ -60,7 +60,7 @@ async function H(a, o, c) {
|
|
|
60
60
|
try {
|
|
61
61
|
const m = n.packageJson?.filePath;
|
|
62
62
|
if (W(n.packageJson?.contents.name) || m !== void 0 && J(w(m, r.repositoryRoot))) {
|
|
63
|
-
m !== void 0 && !e.has(m) && (e.add(m),
|
|
63
|
+
m !== void 0 && !e.has(m) && (e.add(m), S(
|
|
64
64
|
"warn",
|
|
65
65
|
h(m),
|
|
66
66
|
`Skipping excluded package \`${n.packageJson?.contents.name ?? n.cwd}\`.`
|
|
@@ -74,14 +74,14 @@ async function H(a, o, c) {
|
|
|
74
74
|
}
|
|
75
75
|
if (!n.filePaths.some(A))
|
|
76
76
|
continue;
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
for (const f of
|
|
77
|
+
const u = P(d, M(n, !1));
|
|
78
|
+
const g = n.packageJson?.contents.name ?? h(n.cwd);
|
|
79
|
+
for (const f of u.getCodemodFiles()) {
|
|
80
80
|
if (J(
|
|
81
81
|
w(f.compilerNode.fileName, r.repositoryRoot)
|
|
82
82
|
))
|
|
83
83
|
continue;
|
|
84
|
-
const k = O.dirname(f.compilerNode.fileName), N = i.get(k) ?? q(k,
|
|
84
|
+
const k = O.dirname(f.compilerNode.fileName), N = i.get(k) ?? q(k, g);
|
|
85
85
|
i.set(k, N), t.push(...U(f.compilerNode, N));
|
|
86
86
|
}
|
|
87
87
|
} catch (l) {
|
|
@@ -97,12 +97,12 @@ async function H(a, o, c) {
|
|
|
97
97
|
const m = R(
|
|
98
98
|
"blue",
|
|
99
99
|
`${h(n.sourceFileName)}:${n.line}:${n.column}`
|
|
100
|
-
),
|
|
100
|
+
), u = L({
|
|
101
101
|
name: n.name,
|
|
102
102
|
memberOf: n.memberOf,
|
|
103
103
|
kind: n.kind
|
|
104
|
-
}),
|
|
105
|
-
|
|
104
|
+
}), g = z(n.kind, "parentheses");
|
|
105
|
+
S("warn", m, `\`${u}\`${g} is deprecated.${n.reason ? ` ${n.reason}` : ""}`);
|
|
106
106
|
}
|
|
107
107
|
j(
|
|
108
108
|
"definitions",
|
|
@@ -114,7 +114,7 @@ async function H(a, o, c) {
|
|
|
114
114
|
function U(a, o) {
|
|
115
115
|
const c = /* @__PURE__ */ new Map(), t = I([a.fileName], o);
|
|
116
116
|
function i(e) {
|
|
117
|
-
const s =
|
|
117
|
+
const s = b.getJSDocDeprecatedTag(e), p = X(e);
|
|
118
118
|
if (s !== void 0 && p !== void 0) {
|
|
119
119
|
const r = p.getStart(a), { line: d, character: l } = a.getLineAndCharacterOfPosition(r);
|
|
120
120
|
c.set(`${r}:${p.getWidth(a)}`, {
|
|
@@ -128,7 +128,7 @@ function U(a, o) {
|
|
|
128
128
|
column: l + 1
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
b.forEachChild(e, i);
|
|
132
132
|
}
|
|
133
133
|
return i(a), [...c.values()].sort((e, s) => e.line - s.line || e.column - s.column);
|
|
134
134
|
}
|
package/dist/chunks/index3.js
CHANGED
|
@@ -1,307 +1,342 @@
|
|
|
1
|
-
import { readFile as
|
|
2
|
-
import { b } from "./artifact.js";
|
|
3
|
-
import { c as
|
|
4
|
-
import { e as
|
|
5
|
-
async function
|
|
6
|
-
const
|
|
7
|
-
for (const
|
|
8
|
-
|
|
9
|
-
for (const
|
|
10
|
-
e[
|
|
11
|
-
const
|
|
1
|
+
import { readFile as J } from "node:fs/promises";
|
|
2
|
+
import { b as C, c as D } from "./artifact.js";
|
|
3
|
+
import { c as k, g as z, b as h, i as B, d as A } from "./classification.js";
|
|
4
|
+
import { e as j, b, d as N } from "./cli.js";
|
|
5
|
+
async function F(e = {}) {
|
|
6
|
+
const s = new URL(e.url ?? j);
|
|
7
|
+
for (const r of e.repositories ?? [])
|
|
8
|
+
s.searchParams.append("repository", r);
|
|
9
|
+
for (const r of ["branch", "since", "until"])
|
|
10
|
+
e[r] !== void 0 && s.searchParams.set(r, e[r]);
|
|
11
|
+
const a = await fetch(s, {
|
|
12
12
|
signal: AbortSignal.timeout(12e4),
|
|
13
13
|
redirect: "error"
|
|
14
14
|
});
|
|
15
|
-
if (!
|
|
16
|
-
throw new Error(`Remote aggregation failed: HTTP ${
|
|
17
|
-
const
|
|
18
|
-
if (!Array.isArray(
|
|
15
|
+
if (!a.ok)
|
|
16
|
+
throw new Error(`Remote aggregation failed: HTTP ${a.status}.`);
|
|
17
|
+
const i = await a.json();
|
|
18
|
+
if (!Array.isArray(i))
|
|
19
19
|
throw new Error("Invalid collector response.");
|
|
20
|
-
return
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
20
|
+
return i.map((r) => {
|
|
21
|
+
const t = C(JSON.stringify(r));
|
|
22
|
+
if (t.auditKind !== "usages")
|
|
23
23
|
throw new Error("Expected an audit-usages report from the collector.");
|
|
24
|
-
return { ...
|
|
24
|
+
return { ...t, auditKind: "usages" };
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
async function
|
|
28
|
-
const { section:
|
|
29
|
-
Promise.all(e.map(async (l) => await
|
|
30
|
-
Promise.all(
|
|
31
|
-
|
|
32
|
-
]),
|
|
33
|
-
[...
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
), p =
|
|
27
|
+
async function Y(e, s, a = {}, i = [], r) {
|
|
28
|
+
const { section: t = "all", ...c } = a, [o, u, n] = await Promise.all([
|
|
29
|
+
Promise.all(e.map(async (l) => await M(l, "usages"))),
|
|
30
|
+
Promise.all(i.map(async (l) => await M(l, "definitions"))),
|
|
31
|
+
r === void 0 ? [] : F(r)
|
|
32
|
+
]), d = x(
|
|
33
|
+
[...o, ...n],
|
|
34
|
+
c,
|
|
35
|
+
i.length === 0 ? void 0 : u
|
|
36
|
+
), p = s === "json" ? JSON.stringify(d, void 0, 2) : L(
|
|
37
|
+
d,
|
|
38
|
+
s,
|
|
39
|
+
t,
|
|
40
|
+
[...o, ...n].flatMap(({ findings: l }) => l)
|
|
41
|
+
);
|
|
37
42
|
process.stdout.write(`${p}
|
|
38
43
|
`);
|
|
39
44
|
}
|
|
40
|
-
function
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
throw new Error(`Duplicate audit-usages report for ${
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
return
|
|
47
|
-
}),
|
|
45
|
+
function x(e, s = {}, a) {
|
|
46
|
+
const i = /* @__PURE__ */ new Set(), r = [], t = e.flatMap((o) => {
|
|
47
|
+
if (i.has(o.repository))
|
|
48
|
+
throw new Error(`Duplicate audit-usages report for ${o.repository}.`);
|
|
49
|
+
i.add(o.repository);
|
|
50
|
+
const u = o.findings.map((n) => ({ ...n, category: n.category ?? k(n) })).filter((n) => O(n, s));
|
|
51
|
+
return r.push(V(o, u)), u.map((n) => ({ finding: n, source: { repository: o.repository, ref: o.ref } }));
|
|
52
|
+
}), c = S(t);
|
|
48
53
|
return {
|
|
49
54
|
auditKind: "aggregated-usages",
|
|
50
55
|
aggregatedDate: Date.now(),
|
|
51
|
-
count:
|
|
52
|
-
repositories:
|
|
53
|
-
(
|
|
56
|
+
count: t.length,
|
|
57
|
+
repositories: r.sort(
|
|
58
|
+
(o, u) => u.count - o.count || o.repository.localeCompare(u.repository)
|
|
54
59
|
),
|
|
55
|
-
packages:
|
|
56
|
-
...
|
|
60
|
+
packages: c,
|
|
61
|
+
...a === void 0 ? {} : { unused: K(e, a, s) }
|
|
57
62
|
};
|
|
58
63
|
}
|
|
59
|
-
function
|
|
64
|
+
function V(e, s) {
|
|
60
65
|
return {
|
|
61
66
|
repository: e.repository,
|
|
62
67
|
ref: e.ref,
|
|
63
68
|
branch: e.branch,
|
|
64
69
|
scanDate: e.scanDate,
|
|
65
70
|
scannerVersion: e.scannerVersion,
|
|
66
|
-
count:
|
|
67
|
-
apiCount: new Set(
|
|
68
|
-
categories:
|
|
69
|
-
category:
|
|
70
|
-
label:
|
|
71
|
-
count:
|
|
72
|
-
packages:
|
|
73
|
-
package:
|
|
74
|
-
...
|
|
75
|
-
count:
|
|
71
|
+
count: s.length,
|
|
72
|
+
apiCount: new Set(s.map(w)).size,
|
|
73
|
+
categories: z(s, (a) => a).map(({ categoryName: a, count: i, packages: r }) => ({
|
|
74
|
+
category: a,
|
|
75
|
+
label: N[a].label,
|
|
76
|
+
count: i,
|
|
77
|
+
packages: r.map(({ packageName: t, displayName: c, count: o }) => ({
|
|
78
|
+
package: t,
|
|
79
|
+
...c === t ? {} : { displayName: c },
|
|
80
|
+
count: o
|
|
76
81
|
}))
|
|
77
82
|
}))
|
|
78
83
|
};
|
|
79
84
|
}
|
|
80
|
-
function
|
|
81
|
-
return (!
|
|
85
|
+
function O(e, s) {
|
|
86
|
+
return (!s.esriOnly || b(e.package)) && (s.category === void 0 || e.category === s.category) && (s.packageName === void 0 || e.package === s.packageName);
|
|
82
87
|
}
|
|
83
|
-
function
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const
|
|
88
|
+
function S(e) {
|
|
89
|
+
const s = [...Map.groupBy(e, ({ finding: a }) => a.package)].map(([a, i]) => {
|
|
90
|
+
const r = [...Map.groupBy(i, ({ finding: t }) => t.module)].map(([t, c]) => {
|
|
91
|
+
const o = [
|
|
87
92
|
...Map.groupBy(
|
|
88
|
-
|
|
89
|
-
({ finding:
|
|
93
|
+
c,
|
|
94
|
+
({ finding: u }) => JSON.stringify([u.category ?? k(u), w(u)])
|
|
90
95
|
)
|
|
91
|
-
].map(([,
|
|
92
|
-
const
|
|
96
|
+
].map(([, u]) => {
|
|
97
|
+
const n = u.reduce(
|
|
98
|
+
(p, { finding: l }) => D(l, p) < 0 ? l : p,
|
|
99
|
+
u[0].finding
|
|
100
|
+
), d = u.flatMap(({ source: p }) => p === void 0 ? [] : [p]);
|
|
93
101
|
return {
|
|
94
|
-
name:
|
|
95
|
-
category:
|
|
96
|
-
kind:
|
|
97
|
-
memberOf:
|
|
98
|
-
count:
|
|
99
|
-
repositories: [...Map.groupBy(
|
|
102
|
+
name: n.name,
|
|
103
|
+
category: n.category ?? k(n),
|
|
104
|
+
kind: n.kind,
|
|
105
|
+
memberOf: n.memberOf,
|
|
106
|
+
count: d.length,
|
|
107
|
+
repositories: [...Map.groupBy(d, ({ repository: p }) => p)].map(([p, l]) => ({
|
|
100
108
|
repository: U(p),
|
|
101
109
|
ref: l[0].ref,
|
|
102
110
|
count: l.length
|
|
103
|
-
})).sort(
|
|
111
|
+
})).sort(
|
|
112
|
+
(p, l) => l.count - p.count || p.repository.localeCompare(l.repository) || p.ref.localeCompare(l.ref)
|
|
113
|
+
)
|
|
104
114
|
};
|
|
105
115
|
});
|
|
106
|
-
return
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
return o.sort(
|
|
117
|
+
(u, n) => n.count - u.count || h(u).localeCompare(h(n)) || u.name.localeCompare(n.name) || (u.memberOf ?? "").localeCompare(n.memberOf ?? "") || (u.kind ?? "").localeCompare(n.kind ?? "") || u.category.localeCompare(n.category)
|
|
118
|
+
), {
|
|
119
|
+
module: t,
|
|
120
|
+
count: o.reduce((u, n) => u + n.count, 0),
|
|
121
|
+
apis: o
|
|
110
122
|
};
|
|
111
123
|
});
|
|
112
|
-
return
|
|
124
|
+
return r.sort(
|
|
125
|
+
(t, c) => c.count - t.count || +(t.module === void 0) - +(c.module === void 0) || (t.module ?? "").localeCompare(c.module ?? "")
|
|
126
|
+
), { package: a, count: r.reduce((t, c) => t + c.count, 0), modules: r };
|
|
113
127
|
});
|
|
114
|
-
return
|
|
115
|
-
(
|
|
116
|
-
),
|
|
128
|
+
return s.sort(
|
|
129
|
+
(a, i) => Number(b(i.package)) - Number(b(a.package)) || i.count - a.count || a.package.localeCompare(i.package)
|
|
130
|
+
), s;
|
|
117
131
|
}
|
|
118
|
-
function
|
|
119
|
-
const
|
|
120
|
-
for (const
|
|
121
|
-
for (const
|
|
122
|
-
if (
|
|
132
|
+
function K(e, s, a) {
|
|
133
|
+
const i = e.flatMap((c) => c.findings), r = new Set(i.map(w)), t = /* @__PURE__ */ new Map();
|
|
134
|
+
for (const c of s)
|
|
135
|
+
for (const o of c.findings) {
|
|
136
|
+
if (o.module === void 0)
|
|
123
137
|
throw new Error(
|
|
124
|
-
`Definition ${
|
|
138
|
+
`Definition ${o.package}/${o.name} has no module. Regenerate its audit-definitions report.`
|
|
125
139
|
);
|
|
126
|
-
const
|
|
127
|
-
!
|
|
140
|
+
const u = { ...o, category: o.category ?? k(o) }, n = w(u);
|
|
141
|
+
if (!r.has(n) && O(u, a)) {
|
|
142
|
+
const p = t.get(n);
|
|
143
|
+
(p === void 0 || D(u, p.finding) < 0) && t.set(n, { finding: u });
|
|
144
|
+
}
|
|
128
145
|
}
|
|
129
|
-
return { count:
|
|
146
|
+
return { count: t.size, packages: S([...t.values()]) };
|
|
130
147
|
}
|
|
131
|
-
function
|
|
148
|
+
function w(e) {
|
|
132
149
|
return e.kind === "css-property" ? JSON.stringify([e.package, e.kind, e.name]) : e.kind === "css-part" || e.kind === "css-state" || e.kind === "slot" || e.kind === "attribute" || e.kind === "element" ? JSON.stringify([e.package, e.kind, e.memberOf, e.name]) : JSON.stringify([e.package, e.module, e.name, e.memberOf]);
|
|
133
150
|
}
|
|
134
|
-
function U(e,
|
|
135
|
-
const
|
|
136
|
-
return !
|
|
151
|
+
function U(e, s = !1) {
|
|
152
|
+
const a = new URL(`https://${e}`);
|
|
153
|
+
return !s && a.hostname === "github.com" ? e : a.pathname.slice(1);
|
|
137
154
|
}
|
|
138
|
-
function
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
155
|
+
function L(e, s, a, i) {
|
|
156
|
+
const r = new Map(
|
|
157
|
+
[...Map.groupBy(i, (o) => JSON.stringify([o.package, o.module]))].map(
|
|
158
|
+
([o, u]) => [o, u.length]
|
|
159
|
+
)
|
|
160
|
+
);
|
|
161
|
+
if (a === "apis")
|
|
162
|
+
return y(e, s, r);
|
|
163
|
+
if (a === "unused-apis") {
|
|
164
|
+
if (e.unused === void 0)
|
|
165
|
+
throw new Error("The unused-apis section requires --definitions.");
|
|
166
|
+
return y(e.unused, s, r, "Deprecated APIs with zero detected usages");
|
|
167
|
+
}
|
|
168
|
+
const t = s === "md", c = [
|
|
169
|
+
t ? "# Deprecation overview" : "Deprecation overview",
|
|
143
170
|
"",
|
|
144
171
|
`${e.count} usages - ${e.repositories.length} repositories - Aggregated: ${new Date(e.aggregatedDate).toISOString().slice(0, 10)}`,
|
|
145
172
|
""
|
|
146
173
|
];
|
|
147
|
-
for (const
|
|
148
|
-
const u =
|
|
149
|
-
|
|
174
|
+
for (const o of e.repositories) {
|
|
175
|
+
const u = o.scanDate === void 0 ? "Unknown" : new Date(o.scanDate).toISOString();
|
|
176
|
+
c.push(
|
|
150
177
|
"",
|
|
151
|
-
...
|
|
178
|
+
...t ? [
|
|
152
179
|
"<details>",
|
|
153
|
-
`<summary>${
|
|
180
|
+
`<summary>${o.count} usages - ${P(U(o.repository, !0))} - ${u.slice(0, 10)}</summary>`,
|
|
154
181
|
""
|
|
155
|
-
] : [`${
|
|
156
|
-
),
|
|
182
|
+
] : [`${o.repository}: ${o.count} usages; selected scan ${u}`]
|
|
183
|
+
), c.push(
|
|
157
184
|
`> ${[
|
|
158
|
-
`Distinct APIs: ${
|
|
159
|
-
`Branch: ${
|
|
160
|
-
`Commit: ${
|
|
161
|
-
`Scanner version: ${
|
|
185
|
+
`Distinct APIs: ${o.apiCount}`,
|
|
186
|
+
`Branch: ${t ? g(o.branch ?? "Unknown") : o.branch ?? "Unknown"}`,
|
|
187
|
+
`Commit: ${t ? `[\`${o.ref.slice(0, 6)}\`](https://${o.repository}/tree/${encodeURIComponent(o.ref)})` : o.ref}`,
|
|
188
|
+
`Scanner version: ${t ? g(o.scannerVersion ?? "Unknown") : o.scannerVersion ?? "Unknown"}`
|
|
162
189
|
].join(" | ")}`,
|
|
163
190
|
""
|
|
164
|
-
),
|
|
165
|
-
for (const
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
`| **${
|
|
191
|
+
), o.categories.length === 0 ? c.push("No matching deprecated usages.") : t && c.push("| Category | Package | Usages |", "| --- | --- | ---: |");
|
|
192
|
+
for (const n of o.categories) {
|
|
193
|
+
if (t && n.packages.length === 1) {
|
|
194
|
+
c.push(
|
|
195
|
+
`| **${g(n.label)}** | ${g(n.packages[0].displayName ?? n.packages[0].package)} | **${n.count}** |`
|
|
169
196
|
);
|
|
170
197
|
continue;
|
|
171
198
|
}
|
|
172
|
-
|
|
173
|
-
|
|
199
|
+
c.push(
|
|
200
|
+
t ? `| **${g(n.label)}** | | **${n.count}** |` : ` ${n.label} (${n.count})`
|
|
174
201
|
);
|
|
175
|
-
for (const
|
|
176
|
-
|
|
177
|
-
|
|
202
|
+
for (const d of n.packages)
|
|
203
|
+
c.push(
|
|
204
|
+
t ? `| | ${g(d.displayName ?? d.package)} | ${d.count} |` : ` ${d.displayName ?? d.package} (${d.count})`
|
|
178
205
|
);
|
|
179
206
|
}
|
|
180
|
-
|
|
207
|
+
t && c.push("", "</details>");
|
|
181
208
|
}
|
|
182
|
-
return
|
|
209
|
+
return a === "all" && (c.push("", y(e, s, r)), e.unused !== void 0 && c.push(
|
|
210
|
+
"",
|
|
211
|
+
y(e.unused, s, r, "Deprecated APIs with zero detected usages")
|
|
212
|
+
)), c.join(`
|
|
183
213
|
`);
|
|
184
214
|
}
|
|
185
|
-
function
|
|
186
|
-
return
|
|
215
|
+
function g(e) {
|
|
216
|
+
return P(e).replaceAll("|", "|").replaceAll(/\r?\n/gu, " ");
|
|
187
217
|
}
|
|
188
|
-
function
|
|
218
|
+
function P(e) {
|
|
189
219
|
return e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
190
220
|
}
|
|
191
|
-
function
|
|
192
|
-
const r =
|
|
193
|
-
for (const [
|
|
194
|
-
const
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
return
|
|
221
|
+
function y(e, s, a, i = "Deprecated API usages") {
|
|
222
|
+
const r = s === "md", t = `${i}${m(e.count)}`, c = [r ? `# ${t}` : t];
|
|
223
|
+
for (const [o, { label: u }] of Object.entries(N)) {
|
|
224
|
+
const n = e.packages.flatMap((p) => {
|
|
225
|
+
const l = p.modules.flatMap(($) => {
|
|
226
|
+
const f = $.apis.filter((v) => v.category === o);
|
|
227
|
+
return f.length === 0 ? [] : [{ ...$, apis: f, count: f.reduce((v, E) => v + E.count, 0) }];
|
|
198
228
|
});
|
|
199
|
-
return
|
|
229
|
+
return l.length === 0 ? [] : [{ ...p, modules: l, count: l.reduce(($, f) => $ + f.count, 0) }];
|
|
200
230
|
});
|
|
201
|
-
if (
|
|
231
|
+
if (n.length === 0)
|
|
202
232
|
continue;
|
|
203
|
-
const
|
|
204
|
-
|
|
233
|
+
const d = n.reduce((p, l) => p + l.count, 0);
|
|
234
|
+
c.push(
|
|
205
235
|
"",
|
|
206
|
-
r ?
|
|
207
|
-
...
|
|
236
|
+
`${r ? "## " : ""}${u}${m(d)}`,
|
|
237
|
+
...T(n, r, a)
|
|
208
238
|
);
|
|
209
239
|
}
|
|
210
|
-
return
|
|
240
|
+
return c.join(`
|
|
211
241
|
`);
|
|
212
242
|
}
|
|
213
|
-
function
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
243
|
+
function m(e) {
|
|
244
|
+
return e === 0 ? "" : ` (${e})`;
|
|
245
|
+
}
|
|
246
|
+
function T(e, s, a) {
|
|
247
|
+
const i = [], r = e.flatMap(
|
|
248
|
+
(t) => [
|
|
249
|
+
...Map.groupBy(t.modules, (c) => B(t.package, c.module))
|
|
250
|
+
].map(([c, o]) => ({
|
|
251
|
+
...t,
|
|
252
|
+
displayName: c,
|
|
253
|
+
modules: o,
|
|
254
|
+
count: o.reduce((u, n) => u + n.count, 0)
|
|
222
255
|
}))
|
|
223
256
|
);
|
|
224
|
-
for (const
|
|
225
|
-
if (
|
|
257
|
+
for (const t of r) {
|
|
258
|
+
if (i.push(
|
|
226
259
|
"",
|
|
227
|
-
|
|
228
|
-
),
|
|
229
|
-
|
|
260
|
+
s ? `### ${t.displayName === t.package ? `\`${t.package}\`` : t.displayName}${m(t.count)}` : `${t.displayName}${m(t.count)}`
|
|
261
|
+
), s) {
|
|
262
|
+
i.push(...H(t.modules, t.package, a));
|
|
230
263
|
continue;
|
|
231
264
|
}
|
|
232
|
-
for (const
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
for (const
|
|
236
|
-
|
|
237
|
-
for (const { repository: c, count: i } of t.repositories)
|
|
238
|
-
o.push(` ${c} (${i})`);
|
|
239
|
-
}
|
|
265
|
+
for (const c of t.modules) {
|
|
266
|
+
const o = c.module ?? "Unknown module";
|
|
267
|
+
i.push(` ${o}${m(c.count)}`);
|
|
268
|
+
for (const u of c.apis)
|
|
269
|
+
i.push(...R(u, !1, " "));
|
|
240
270
|
}
|
|
241
271
|
}
|
|
242
|
-
return
|
|
272
|
+
return i;
|
|
243
273
|
}
|
|
244
|
-
function
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
];
|
|
274
|
+
function R(e, s, a = "") {
|
|
275
|
+
const i = `${h(e)}${A(e.kind)}`, r = e.repositories.map(
|
|
276
|
+
({ repository: t, count: c }) => `${a} ${s ? `- \`${t}\`` : t} (${c})`
|
|
277
|
+
);
|
|
278
|
+
return s ? [
|
|
279
|
+
`${a}- \`${h(e)}\`${A(e.kind)}${m(e.count)}`,
|
|
280
|
+
...r
|
|
281
|
+
] : [`${a}${i}${m(e.count)}`, ...r];
|
|
253
282
|
}
|
|
254
|
-
function
|
|
255
|
-
const
|
|
256
|
-
for (const
|
|
257
|
-
let
|
|
258
|
-
const
|
|
259
|
-
for (const [
|
|
260
|
-
let
|
|
261
|
-
|
|
283
|
+
function H(e, s, a) {
|
|
284
|
+
const i = /* @__PURE__ */ new Map();
|
|
285
|
+
for (const r of e) {
|
|
286
|
+
let t = i;
|
|
287
|
+
const c = r.module === void 0 ? [void 0] : r.module.split("/");
|
|
288
|
+
for (const [o, u] of c.entries()) {
|
|
289
|
+
let n = t.get(u);
|
|
290
|
+
n === void 0 && (n = { name: u, count: 0, usedCount: 0, children: /* @__PURE__ */ new Map(), apis: [] }, t.set(u, n)), n.count += r.count, o === c.length - 1 && (n.apis = r.apis, n.usedCount = r.count === 0 && r.module !== void 0 ? a?.get(JSON.stringify([s, r.module])) ?? 0 : 0), t = n.children;
|
|
262
291
|
}
|
|
263
292
|
}
|
|
264
|
-
return [...
|
|
293
|
+
return [...i.values()].sort((r, t) => t.count - r.count).flatMap((r) => I(r, 0));
|
|
265
294
|
}
|
|
266
|
-
function
|
|
267
|
-
let
|
|
268
|
-
for (;
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
...[...
|
|
273
|
-
count:
|
|
274
|
-
lines:
|
|
295
|
+
function I(e, s) {
|
|
296
|
+
let a = e, i = a.name ?? "Unknown module";
|
|
297
|
+
for (; a.children.size === 1 && a.apis.length === 0; )
|
|
298
|
+
a = [...a.children.values()][0], i += `/${a.name}`;
|
|
299
|
+
a.children.size > 0 && (i += "/");
|
|
300
|
+
const r = " ".repeat(s), t = [
|
|
301
|
+
...[...a.children.values()].map((o) => ({
|
|
302
|
+
count: o.count,
|
|
303
|
+
lines: I(o, s + 1)
|
|
275
304
|
})),
|
|
276
|
-
...
|
|
277
|
-
count:
|
|
278
|
-
lines:
|
|
305
|
+
...a.apis.map((o) => ({
|
|
306
|
+
count: o.count,
|
|
307
|
+
lines: R(o, !0, r)
|
|
279
308
|
}))
|
|
280
309
|
];
|
|
281
|
-
|
|
282
|
-
const
|
|
283
|
-
|
|
310
|
+
t.sort((o, u) => u.count - o.count);
|
|
311
|
+
const c = [
|
|
312
|
+
...a.usedCount === 0 ? [] : [
|
|
313
|
+
`${r}> **Warning:** Other deprecated APIs in this file still have detected usages (${a.usedCount}). Do not remove the entire file.`,
|
|
314
|
+
""
|
|
315
|
+
],
|
|
316
|
+
...t.flatMap(({ lines: o }) => o)
|
|
317
|
+
];
|
|
318
|
+
return s === 0 ? [
|
|
284
319
|
"",
|
|
285
320
|
"<details>",
|
|
286
|
-
`<summary><code>${
|
|
321
|
+
`<summary><code>${i.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">")}</code>${m(e.count)}</summary>`,
|
|
287
322
|
"",
|
|
288
|
-
...
|
|
323
|
+
...c,
|
|
289
324
|
"",
|
|
290
325
|
"</details>"
|
|
291
|
-
] : [`${" ".repeat(
|
|
326
|
+
] : [`${" ".repeat(s - 1)}- \`${i}\`${m(e.count)}`, ...c];
|
|
292
327
|
}
|
|
293
|
-
async function
|
|
294
|
-
let
|
|
328
|
+
async function M(e, s) {
|
|
329
|
+
let a;
|
|
295
330
|
try {
|
|
296
|
-
|
|
297
|
-
} catch (
|
|
298
|
-
throw new Error(`Failed to read audit-${
|
|
331
|
+
a = C(await J(e, "utf8"));
|
|
332
|
+
} catch (i) {
|
|
333
|
+
throw new Error(`Failed to read audit-${s} report: ${e}`, { cause: i });
|
|
299
334
|
}
|
|
300
|
-
if (
|
|
301
|
-
throw new Error(`Invalid audit-${
|
|
302
|
-
return
|
|
335
|
+
if (a.auditKind !== s)
|
|
336
|
+
throw new Error(`Invalid audit-${s} report: ${e}`);
|
|
337
|
+
return a;
|
|
303
338
|
}
|
|
304
339
|
export {
|
|
305
|
-
|
|
306
|
-
|
|
340
|
+
x as aggregateUsages,
|
|
341
|
+
Y as aggregateUsagesFromFiles
|
|
307
342
|
};
|