@arcgis/codemod 6.0.0-next.4 → 6.0.0-next.41
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/aggregateUsages.js +351 -0
- package/dist/chunks/auditDefinitions.js +173 -0
- package/dist/chunks/auditUsages.js +1246 -0
- package/dist/chunks/classification.js +168 -126
- package/dist/chunks/cli.js +387 -231
- package/dist/chunks/codemod5.js +0 -1
- package/dist/chunks/codemod7.js +1214 -1232
- package/dist/chunks/componentAudit.js +272 -0
- package/dist/chunks/format.js +140 -112
- package/dist/chunks/legacyCompatibility.js +210 -0
- package/dist/chunks/log.js +21 -7
- package/dist/chunks/sync.js +148 -142
- package/dist/chunks/syncMarkdown.js +42 -0
- package/dist/chunks/useProjectInstance.js +27 -24
- package/package.json +10 -7
- package/dist/chunks/hardcodedBehavior.js +0 -63
- package/dist/chunks/index.js +0 -459
- package/dist/chunks/index2.js +0 -160
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { Project as p } from "ts-morph";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { styleText as
|
|
6
|
-
function
|
|
7
|
-
if (
|
|
2
|
+
import { g as t, f as a, i as m } from "./cli.js";
|
|
3
|
+
import { log as g } from "@arcgis/toolkit/log";
|
|
4
|
+
import { path as u } from "@arcgis/node-toolkit/path";
|
|
5
|
+
import { styleText as n } from "node:util";
|
|
6
|
+
function S(e, l = !0, f) {
|
|
7
|
+
if (t.project !== void 0)
|
|
8
8
|
throw Error(
|
|
9
9
|
"A different ts-morph Project is already in use. Dispose of it before creating a new one. Example: using project = createProjectInstance(...)"
|
|
10
10
|
);
|
|
11
|
-
const
|
|
11
|
+
const s = t.codemod.meta.needsTypeInformation, i = new p({
|
|
12
12
|
// If tsconfig is missing, or project is untyped, use a permissive and
|
|
13
13
|
// compatible default config
|
|
14
|
-
compilerOptions:
|
|
15
|
-
...
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
compilerOptions: {
|
|
15
|
+
...e.typeScriptConfig?.compilerOptions ?? {
|
|
16
|
+
...a,
|
|
17
|
+
// Read types from JSDoc annotations if present
|
|
18
|
+
checkJs: s
|
|
19
|
+
},
|
|
20
|
+
...f
|
|
18
21
|
},
|
|
19
22
|
// We take care of reading the config file
|
|
20
23
|
tsConfigFilePath: void 0,
|
|
@@ -22,30 +25,30 @@ function v(e, l = !0) {
|
|
|
22
25
|
skipAddingFilesFromTsConfig: !0,
|
|
23
26
|
// We call this manually if needed below.
|
|
24
27
|
skipFileDependencyResolution: !0,
|
|
25
|
-
skipLoadingLibFiles: !
|
|
26
|
-
}),
|
|
27
|
-
const c =
|
|
28
|
+
skipLoadingLibFiles: !s
|
|
29
|
+
}), d = e.filePaths.filter(m).flatMap((o) => {
|
|
30
|
+
const c = i.addSourceFileAtPathIfExists(o);
|
|
28
31
|
return c === void 0 ? [] : [c];
|
|
29
32
|
});
|
|
30
|
-
if (
|
|
31
|
-
const o =
|
|
32
|
-
process.stdout.write(""),
|
|
33
|
+
if (s && i.resolveSourceFileDependencies(), l) {
|
|
34
|
+
const o = u.relative(process.cwd(), e.cwd);
|
|
35
|
+
process.stdout.write(""), g(
|
|
33
36
|
"info",
|
|
34
|
-
|
|
35
|
-
`Running the codemod on ${
|
|
37
|
+
n("blue", o === "" ? process.cwd() : o),
|
|
38
|
+
`Running the codemod on ${n("blue", String(e.filePaths.length))} file${e.filePaths.length !== 1 ? "s" : ""}${e.packageJson?.contents.name === void 0 ? "" : ` from ${n("blue", e.packageJson.contents.name)}`}`
|
|
36
39
|
);
|
|
37
40
|
}
|
|
38
41
|
const r = {
|
|
39
42
|
[Symbol.dispose]() {
|
|
40
|
-
|
|
43
|
+
i.saveSync(), i.getRootDirectories().forEach((o) => o.forget()), t.project = void 0;
|
|
41
44
|
},
|
|
42
45
|
projectData: e,
|
|
43
46
|
// Resolved dependencies support type checking but are not codemod targets.
|
|
44
|
-
getCodemodFiles: () =>
|
|
45
|
-
tsMorph:
|
|
47
|
+
getCodemodFiles: () => d,
|
|
48
|
+
tsMorph: i
|
|
46
49
|
};
|
|
47
|
-
return
|
|
50
|
+
return t.project = r, r;
|
|
48
51
|
}
|
|
49
52
|
export {
|
|
50
|
-
|
|
53
|
+
S as c
|
|
51
54
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/codemod",
|
|
3
|
-
"version": "6.0.0-next.
|
|
3
|
+
"version": "6.0.0-next.41",
|
|
4
4
|
"description": "A codemod toolkit for updating and modernizing ArcGIS Maps SDK for JavaScript codebases.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -11,15 +11,18 @@
|
|
|
11
11
|
],
|
|
12
12
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@arcgis/api-extractor": "6.0.0-next.
|
|
15
|
-
"@arcgis/node-toolkit": "6.0.0-next.
|
|
16
|
-
"@arcgis/toolkit": "6.0.0-next.
|
|
17
|
-
"@commander-js/extra-typings": "^15.
|
|
18
|
-
"commander": "^15.
|
|
14
|
+
"@arcgis/api-extractor": "6.0.0-next.41",
|
|
15
|
+
"@arcgis/node-toolkit": "6.0.0-next.41",
|
|
16
|
+
"@arcgis/toolkit": "6.0.0-next.41",
|
|
17
|
+
"@commander-js/extra-typings": "^15.1.0",
|
|
18
|
+
"commander": "^15.1.0",
|
|
19
|
+
"picomatch": "^4.0.4",
|
|
20
|
+
"semver": "^7.7.3",
|
|
19
21
|
"tinyglobby": "~0.2.17",
|
|
20
22
|
"ts-morph": "^28.0.0",
|
|
21
23
|
"tslib": "^2.8.1",
|
|
22
|
-
"typescript": "~6.0.3"
|
|
24
|
+
"typescript": "~6.0.3",
|
|
25
|
+
"yaml": "^2.8.3"
|
|
23
26
|
},
|
|
24
27
|
"bin": {
|
|
25
28
|
"codemod": "./bin/cli.js"
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import i from "typescript";
|
|
2
|
-
import { findPath as s } from "@arcgis/node-toolkit/file";
|
|
3
|
-
import { path as d } from "@arcgis/node-toolkit/path";
|
|
4
|
-
import { retrievePackageJson as u } from "@arcgis/node-toolkit/packageJson";
|
|
5
|
-
function h(e) {
|
|
6
|
-
return typeof e == "string" ? e : e.map((t) => t.kind === i.SyntaxKind.JSDocText ? t.text : g(t.getText())).join("");
|
|
7
|
-
}
|
|
8
|
-
function D(e) {
|
|
9
|
-
return e === void 0 ? void 0 : p(i.displayPartsToString([...e]));
|
|
10
|
-
}
|
|
11
|
-
function p(e) {
|
|
12
|
-
return e.replace(
|
|
13
|
-
/\{@link(?:code|plain)?\s+([\s\S]*?)\}/gu,
|
|
14
|
-
(t, n) => c(n)
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
function g(e) {
|
|
18
|
-
const t = /^\{@link(?:code|plain)?\s+([\s\S]*?)\}$/u.exec(e)?.[1];
|
|
19
|
-
return t === void 0 ? e : c(t);
|
|
20
|
-
}
|
|
21
|
-
function c(e) {
|
|
22
|
-
const t = e.trim().replace(/^(\S+)\s+([/:#!.])/u, "$1$2"), n = t.indexOf("|");
|
|
23
|
-
if (n !== -1)
|
|
24
|
-
return t.slice(n + 1).trim() || t.slice(0, n).trim();
|
|
25
|
-
const [r, ...a] = t.split(/\s+/u);
|
|
26
|
-
return a.join(" ") || r;
|
|
27
|
-
}
|
|
28
|
-
function S(e, t) {
|
|
29
|
-
const n = s("package.json", e);
|
|
30
|
-
return n === void 0 ? t : u(d.dirname(n)).name ?? t;
|
|
31
|
-
}
|
|
32
|
-
const o = {
|
|
33
|
-
excludedPackageNames: /* @__PURE__ */ new Set([
|
|
34
|
-
"@arcgis/charts-components-react",
|
|
35
|
-
"@arcgis/coding-components-react",
|
|
36
|
-
"@arcgis/components-build-utils",
|
|
37
|
-
"@arcgis/map-components-react",
|
|
38
|
-
"@arcgis/portal-components-react",
|
|
39
|
-
"@arcgis-test/lit-components-react"
|
|
40
|
-
]),
|
|
41
|
-
excludedDefinitionPathFragments: ["test-package"],
|
|
42
|
-
ignoreDeprecatedApis: ["getReactWrapperOptions"],
|
|
43
|
-
ignoredDeprecationsByIncludes: ["React wrappers are not needed in React 19 or above"]
|
|
44
|
-
};
|
|
45
|
-
function k(e) {
|
|
46
|
-
return e !== void 0 && o.excludedPackageNames.has(e);
|
|
47
|
-
}
|
|
48
|
-
function P(e) {
|
|
49
|
-
return o.excludedDefinitionPathFragments.some(
|
|
50
|
-
(t) => e.includes(t)
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
function v(e, t) {
|
|
54
|
-
return o.ignoreDeprecatedApis.some((n) => n === e) || t != null && o.ignoredDeprecationsByIncludes.some((n) => t.includes(n));
|
|
55
|
-
}
|
|
56
|
-
export {
|
|
57
|
-
v as a,
|
|
58
|
-
h as b,
|
|
59
|
-
D as c,
|
|
60
|
-
P as d,
|
|
61
|
-
S as g,
|
|
62
|
-
k as s
|
|
63
|
-
};
|
package/dist/chunks/index.js
DELETED
|
@@ -1,459 +0,0 @@
|
|
|
1
|
-
var M = (o, e) => (e = Symbol[o]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + o), O = (o) => {
|
|
2
|
-
throw TypeError(o);
|
|
3
|
-
};
|
|
4
|
-
var J = (o, e, t) => {
|
|
5
|
-
if (e != null) {
|
|
6
|
-
typeof e != "object" && typeof e != "function" && O("Object expected");
|
|
7
|
-
var a, i;
|
|
8
|
-
t && (a = e[M("asyncDispose")]), a === void 0 && (a = e[M("dispose")], t && (i = a)), typeof a != "function" && O("Object not disposable"), i && (a = function() {
|
|
9
|
-
try {
|
|
10
|
-
i.call(this);
|
|
11
|
-
} catch (s) {
|
|
12
|
-
return Promise.reject(s);
|
|
13
|
-
}
|
|
14
|
-
}), o.push([t, a, e]);
|
|
15
|
-
} else t && o.push([t]);
|
|
16
|
-
return e;
|
|
17
|
-
}, R = (o, e, t) => {
|
|
18
|
-
var a = typeof SuppressedError == "function" ? SuppressedError : function(n, r, m, c) {
|
|
19
|
-
return c = Error(m), c.name = "SuppressedError", c.error = n, c.suppressed = r, c;
|
|
20
|
-
}, i = (n) => e = t ? new a(n, e, "An error was suppressed during disposal") : (t = !0, n), s = (n) => {
|
|
21
|
-
for (; n = o.pop(); )
|
|
22
|
-
try {
|
|
23
|
-
var r = n[1] && n[1].call(n[2]);
|
|
24
|
-
if (n[0]) return Promise.resolve(r).then(s, (m) => (i(m), s()));
|
|
25
|
-
} catch (m) {
|
|
26
|
-
i(m);
|
|
27
|
-
}
|
|
28
|
-
if (t) throw e;
|
|
29
|
-
};
|
|
30
|
-
return s();
|
|
31
|
-
};
|
|
32
|
-
import { c as H } from "./useProjectInstance.js";
|
|
33
|
-
import { d as b, r as q } from "./cli.js";
|
|
34
|
-
import { f as x } from "./log.js";
|
|
35
|
-
import { path as v, toPosixPathSeparators as X } from "@arcgis/node-toolkit/path";
|
|
36
|
-
import { log as Y } from "@arcgis/toolkit/log";
|
|
37
|
-
import l from "typescript";
|
|
38
|
-
import { g as A, a as Z, b as ee, c as te, d as w, e as oe, f as z, p as ne, i as ae, h as D, j, k as ie } from "./classification.js";
|
|
39
|
-
import { s as se, g as W, a as re, b as ce, c as me } from "./hardcodedBehavior.js";
|
|
40
|
-
import { styleText as k } from "node:util";
|
|
41
|
-
import { loadCodeowners as le } from "@arcgis/node-toolkit/codeowners";
|
|
42
|
-
import { f as pe } from "./format.js";
|
|
43
|
-
function ue(o, e) {
|
|
44
|
-
if (e === "json") {
|
|
45
|
-
const t = A();
|
|
46
|
-
process.stdout.write(`${Ne(o, le(), t)}
|
|
47
|
-
`);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (e === "md") {
|
|
51
|
-
process.stdout.write(`${he(o)}
|
|
52
|
-
`);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
process.stdout.write(`${ge(o)}
|
|
56
|
-
`);
|
|
57
|
-
}
|
|
58
|
-
function ge(o) {
|
|
59
|
-
const e = Q(o), t = e.reduce((i, s) => i + s.count, 0), a = [U("Deprecation summary", t)];
|
|
60
|
-
for (const { categoryName: i, count: s, packages: n } of e) {
|
|
61
|
-
a.push(`${b[i].label} (${s})`);
|
|
62
|
-
for (const { packageName: r, count: m } of n)
|
|
63
|
-
a.push(` ${K(r)} (${m})`);
|
|
64
|
-
}
|
|
65
|
-
a.push("", "", U("Deprecation details", t));
|
|
66
|
-
for (const { categoryName: i, count: s, packages: n } of e) {
|
|
67
|
-
const r = b[i];
|
|
68
|
-
a.push("", `${r.label} (${s})`), "description" in r && a.push(` ${r.description}`);
|
|
69
|
-
for (const { packageName: m, count: c, apis: u } of n) {
|
|
70
|
-
a.push("", ` ${K(m)} (${c})`);
|
|
71
|
-
for (const { api: p, reasons: g, items: d } of u) {
|
|
72
|
-
const y = d[0].usage, h = Z({ api: p, memberOf: y.memberOf, apiKind: y.apiKind });
|
|
73
|
-
a.push(` ${fe(h)}${ee(y.apiKind)} (${d.length})`);
|
|
74
|
-
for (const f of g)
|
|
75
|
-
a.push(de(f, 6));
|
|
76
|
-
for (const { sourceFileName: f, usage: N } of ve(d))
|
|
77
|
-
a.push(` ${x(f)}:${N.line}:${N.column}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return a.join(`
|
|
82
|
-
`);
|
|
83
|
-
}
|
|
84
|
-
function Q(o) {
|
|
85
|
-
const e = [...o].flatMap(
|
|
86
|
-
([t, a]) => a.map((i) => ({ ...i, packageName: t }))
|
|
87
|
-
);
|
|
88
|
-
return te(e, ({ packageName: t, usage: a }) => ({
|
|
89
|
-
package: t,
|
|
90
|
-
api: a.name,
|
|
91
|
-
category: a.category,
|
|
92
|
-
memberOf: a.memberOf,
|
|
93
|
-
module: w(a.originFileNames, t),
|
|
94
|
-
reason: a.reason ?? null
|
|
95
|
-
}));
|
|
96
|
-
}
|
|
97
|
-
function U(o, e) {
|
|
98
|
-
return k(["bold", "yellow"], `${o} (${e})`);
|
|
99
|
-
}
|
|
100
|
-
function K(o) {
|
|
101
|
-
return k("blue", o);
|
|
102
|
-
}
|
|
103
|
-
function fe(o) {
|
|
104
|
-
return k(["bold", "white"], o);
|
|
105
|
-
}
|
|
106
|
-
function de(o, e) {
|
|
107
|
-
const t = " ".repeat(e);
|
|
108
|
-
return o.split(/\r?\n/u).map((a) => `${t}${a}`).join(`
|
|
109
|
-
`);
|
|
110
|
-
}
|
|
111
|
-
function ve(o) {
|
|
112
|
-
return o.toSorted(
|
|
113
|
-
(e, t) => e.sourceFileName.localeCompare(t.sourceFileName) || e.usage.line - t.usage.line || e.usage.column - t.usage.column
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
function ye(o) {
|
|
117
|
-
return [...o].sort(([e], [t]) => e.localeCompare(t));
|
|
118
|
-
}
|
|
119
|
-
function Ne(o, e, t = A()) {
|
|
120
|
-
return JSON.stringify(V(o, e, t), void 0, 2);
|
|
121
|
-
}
|
|
122
|
-
function he(o, e = A()) {
|
|
123
|
-
return pe(V(o, void 0, e));
|
|
124
|
-
}
|
|
125
|
-
function V(o, e, t) {
|
|
126
|
-
const a = Q(o);
|
|
127
|
-
return {
|
|
128
|
-
kind: "usages",
|
|
129
|
-
repository: t.repository,
|
|
130
|
-
ref: t.ref,
|
|
131
|
-
summary: {
|
|
132
|
-
total: a.reduce((s, { count: n }) => s + n, 0),
|
|
133
|
-
categories: a.map(({ categoryName: s, count: n, packages: r }) => ({
|
|
134
|
-
category: s,
|
|
135
|
-
label: b[s].label,
|
|
136
|
-
count: n,
|
|
137
|
-
packages: r.map(({ packageName: m, count: c }) => ({
|
|
138
|
-
package: m,
|
|
139
|
-
count: c
|
|
140
|
-
}))
|
|
141
|
-
}))
|
|
142
|
-
},
|
|
143
|
-
findings: xe(o, e, t)
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function xe(o, e, t) {
|
|
147
|
-
return ye(o).flatMap(
|
|
148
|
-
([a, i]) => i.map((s) => {
|
|
149
|
-
const n = w(s.usage.originFileNames, a), r = {
|
|
150
|
-
package: a,
|
|
151
|
-
api: s.usage.name,
|
|
152
|
-
category: s.usage.category,
|
|
153
|
-
memberOf: s.usage.memberOf,
|
|
154
|
-
module: n,
|
|
155
|
-
reason: s.usage.reason ?? null
|
|
156
|
-
};
|
|
157
|
-
return {
|
|
158
|
-
...r,
|
|
159
|
-
category: z(r),
|
|
160
|
-
apiKind: s.usage.apiKind,
|
|
161
|
-
memberOf: s.usage.memberOf,
|
|
162
|
-
file: oe(s.sourceFileName, t.repositoryRoot),
|
|
163
|
-
line: s.usage.line,
|
|
164
|
-
column: s.usage.column,
|
|
165
|
-
codeowners: e?.getOwners(s.sourceFileName) ?? []
|
|
166
|
-
};
|
|
167
|
-
})
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
async function We(o, e) {
|
|
171
|
-
await q(
|
|
172
|
-
{
|
|
173
|
-
meta: {
|
|
174
|
-
needsTypeInformation: !0,
|
|
175
|
-
needsFooter: !1
|
|
176
|
-
},
|
|
177
|
-
run(t) {
|
|
178
|
-
Se(t, e);
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
"deprecations audit-usages",
|
|
182
|
-
o
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
function Se(o, e) {
|
|
186
|
-
const t = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), i = [
|
|
187
|
-
...new Map(
|
|
188
|
-
o.flatMap(({ packageJson: p }) => {
|
|
189
|
-
const g = p === void 0 ? void 0 : v.dirname(p.filePath), d = p?.contents.name;
|
|
190
|
-
return g !== void 0 && d !== void 0 && S(g, process.cwd()) ? [[g, { root: g, name: d }]] : [];
|
|
191
|
-
})
|
|
192
|
-
).values()
|
|
193
|
-
].toSorted((p, g) => g.root.length - p.root.length);
|
|
194
|
-
for (const p of o) {
|
|
195
|
-
var r = [];
|
|
196
|
-
try {
|
|
197
|
-
if (se(p.packageJson?.contents.name)) {
|
|
198
|
-
const f = p.packageJson?.filePath;
|
|
199
|
-
f !== void 0 && !a.has(f) && (a.add(f), Y(
|
|
200
|
-
"warn",
|
|
201
|
-
x(f),
|
|
202
|
-
`Skipping excluded package \`${p.packageJson?.contents.name ?? p.cwd}\`.`
|
|
203
|
-
));
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
const g = J(r, H(p, !1));
|
|
207
|
-
const d = g.tsMorph.getLanguageService().compilerObject;
|
|
208
|
-
const y = d.getProgram()?.getTypeChecker();
|
|
209
|
-
if (y === void 0)
|
|
210
|
-
continue;
|
|
211
|
-
const h = p.packageJson === void 0 ? void 0 : v.dirname(p.packageJson.filePath);
|
|
212
|
-
for (const f of g.getCodemodFiles()) {
|
|
213
|
-
const N = f.compilerNode;
|
|
214
|
-
for (const I of be(
|
|
215
|
-
N,
|
|
216
|
-
d,
|
|
217
|
-
y,
|
|
218
|
-
h,
|
|
219
|
-
e.esriOnly
|
|
220
|
-
)) {
|
|
221
|
-
const T = Ee(I.originFileNames, i, h), L = t.get(T) ?? [];
|
|
222
|
-
L.push({ sourceFileName: N.fileName, usage: I }), t.set(T, L);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
} catch (m) {
|
|
226
|
-
var c = m, u = !0;
|
|
227
|
-
} finally {
|
|
228
|
-
R(r, c, u);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
const s = Pe(t, e);
|
|
232
|
-
ue(s, e.outputFormat);
|
|
233
|
-
const n = [...s.values()].flat();
|
|
234
|
-
ne(
|
|
235
|
-
"usages",
|
|
236
|
-
n.length,
|
|
237
|
-
new Set(n.map(({ sourceFileName: p }) => p)).size,
|
|
238
|
-
s.size
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
function Pe(o, e) {
|
|
242
|
-
const t = /* @__PURE__ */ new Map();
|
|
243
|
-
for (const [a, i] of o) {
|
|
244
|
-
if (e.packageName !== void 0 && a !== e.packageName)
|
|
245
|
-
continue;
|
|
246
|
-
const s = i.filter(
|
|
247
|
-
({ usage: n }) => e.category === void 0 || z({
|
|
248
|
-
package: a,
|
|
249
|
-
api: n.name,
|
|
250
|
-
category: n.category,
|
|
251
|
-
memberOf: n.memberOf,
|
|
252
|
-
module: w(n.originFileNames, a),
|
|
253
|
-
reason: n.reason ?? null
|
|
254
|
-
}) === e.category
|
|
255
|
-
);
|
|
256
|
-
s.length > 0 && t.set(a, s);
|
|
257
|
-
}
|
|
258
|
-
return t;
|
|
259
|
-
}
|
|
260
|
-
function be(o, e, t, a, i = !1) {
|
|
261
|
-
const s = /* @__PURE__ */ new Map();
|
|
262
|
-
for (const n of e.getSuggestionDiagnostics(o.fileName)) {
|
|
263
|
-
if (n.reportsDeprecated === void 0)
|
|
264
|
-
continue;
|
|
265
|
-
const r = _(o, n.start, n.start + n.length);
|
|
266
|
-
if (
|
|
267
|
-
// Don't report for imports, only for usages
|
|
268
|
-
l.findAncestor(r, l.isImportDeclaration) !== void 0 || // Don't report closing JSX - only for opening
|
|
269
|
-
l.findAncestor(r, l.isJsxClosingElement) !== void 0
|
|
270
|
-
)
|
|
271
|
-
continue;
|
|
272
|
-
const m = we(r, t), c = m.reason === void 0 ? [] : $(m.symbol), u = c.length > 0 ? void 0 : e.getDefinitionAtPosition(o.fileName, n.start), p = c.length > 0 ? c : [...new Set(u?.map(({ fileName: g }) => g))];
|
|
273
|
-
E(p, i, a) && C(s, o, {
|
|
274
|
-
start: n.start,
|
|
275
|
-
length: n.length,
|
|
276
|
-
...ke(r, m, t, e, u?.[0]),
|
|
277
|
-
originFileNames: p,
|
|
278
|
-
reason: Ce(e, o.fileName, n.start) ?? m.reason
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
return De(o, t, s, a, i), [...s.values()].toSorted((n, r) => n.start - r.start);
|
|
282
|
-
}
|
|
283
|
-
function De(o, e, t, a, i) {
|
|
284
|
-
function s(n) {
|
|
285
|
-
l.isNewExpression(n) && Ae(n, e, t, a, i);
|
|
286
|
-
let r, m;
|
|
287
|
-
if (l.isJsxAttribute(n) && l.isIdentifier(n.name)) {
|
|
288
|
-
const c = n.parent.parent;
|
|
289
|
-
(l.isJsxOpeningElement(c) || l.isJsxSelfClosingElement(c)) && (m = e.getContextualType(c.tagName)?.getProperty(n.name.text), r = n.name);
|
|
290
|
-
} else if ((l.isPropertyAssignment(n) || l.isShorthandPropertyAssignment(n) || l.isMethodDeclaration(n)) && l.isObjectLiteralExpression(n.parent)) {
|
|
291
|
-
const c = l.isComputedPropertyName(n.name) ? P(n.name.expression, e) : n.name.text, u = e.getContextualType(n.parent);
|
|
292
|
-
m = c === void 0 || u === void 0 ? void 0 : e.getNonNullableType(u).getProperty(c), r = n.name;
|
|
293
|
-
} else if (l.isPropertyAccessExpression(n))
|
|
294
|
-
m = e.getSymbolAtLocation(n.name), r = n.name;
|
|
295
|
-
else if (l.isElementAccessExpression(n)) {
|
|
296
|
-
const c = P(n.argumentExpression, e);
|
|
297
|
-
m = c === void 0 ? void 0 : e.getTypeAtLocation(n.expression).getProperty(c), r = n.argumentExpression;
|
|
298
|
-
} else if (l.isBindingElement(n) && l.isObjectBindingPattern(n.parent) && n.dotDotDotToken === void 0) {
|
|
299
|
-
const c = n.propertyName ?? (l.isIdentifier(n.name) ? n.name : void 0), u = c === void 0 ? void 0 : l.isComputedPropertyName(c) ? P(c.expression, e) : c.text;
|
|
300
|
-
m = u === void 0 ? void 0 : e.getTypeAtLocation(n.parent).getProperty(u), r = c;
|
|
301
|
-
}
|
|
302
|
-
if ((l.isPropertyAccessExpression(n) || l.isElementAccessExpression(n) || l.isBindingElement(n)) && !m?.declarations?.some(
|
|
303
|
-
(c) => l.isGetAccessorDeclaration(c) || l.isSetAccessorDeclaration(c)
|
|
304
|
-
) && (m = void 0), m !== void 0 && r !== void 0) {
|
|
305
|
-
const c = B(m, e), u = $(m);
|
|
306
|
-
c !== void 0 && E(u, i, a) && C(t, o, {
|
|
307
|
-
start: r.getStart(o),
|
|
308
|
-
length: r.getWidth(o),
|
|
309
|
-
name: m.getName(),
|
|
310
|
-
...D(m.declarations?.[0]),
|
|
311
|
-
originFileNames: u,
|
|
312
|
-
reason: c
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
l.forEachChild(n, s);
|
|
316
|
-
}
|
|
317
|
-
s(o);
|
|
318
|
-
}
|
|
319
|
-
function Ae(o, e, t, a, i) {
|
|
320
|
-
const s = e.getTypeAtLocation(o).getSymbol(), n = s?.declarations?.[0], r = n !== void 0 && (l.isClassDeclaration(n) || l.isInterfaceDeclaration(n)) ? n.name?.text : void 0, m = r === void 0 ? void 0 : ie.get(r);
|
|
321
|
-
if (m === void 0 || r === void 0)
|
|
322
|
-
return;
|
|
323
|
-
const c = $(s);
|
|
324
|
-
if (!c.some(
|
|
325
|
-
(g) => (F(g) ?? W(v.dirname(g), "")) === "@arcgis/core"
|
|
326
|
-
) || !E(c, i, a))
|
|
327
|
-
return;
|
|
328
|
-
const u = l.isPropertyAccessExpression(o.expression) ? o.expression.name : o.expression, p = o.getSourceFile();
|
|
329
|
-
C(t, p, {
|
|
330
|
-
start: u.getStart(p),
|
|
331
|
-
length: u.getWidth(p),
|
|
332
|
-
name: r,
|
|
333
|
-
apiKind: "class",
|
|
334
|
-
category: "coreViews",
|
|
335
|
-
originFileNames: c,
|
|
336
|
-
reason: `Direct construction with new ${r}() is discouraged. Use \`<${m}>\` instead. In 6.0, directly constructed views will no longer include .ui; use component slots for UI.`
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
function P(o, e) {
|
|
340
|
-
const t = e.getTypeAtLocation(o);
|
|
341
|
-
return t.isStringLiteral() || t.isNumberLiteral() ? String(t.value) : void 0;
|
|
342
|
-
}
|
|
343
|
-
function we(o, e) {
|
|
344
|
-
let t = e.getSymbolAtLocation(o);
|
|
345
|
-
for (; t !== void 0 && (t.flags & l.SymbolFlags.Alias) !== 0; ) {
|
|
346
|
-
const a = B(t, e);
|
|
347
|
-
if (a !== void 0)
|
|
348
|
-
return { symbol: t, reason: a };
|
|
349
|
-
t = t.declarations === void 0 ? void 0 : e.getImmediateAliasedSymbol(t);
|
|
350
|
-
}
|
|
351
|
-
return { symbol: t, reason: void 0 };
|
|
352
|
-
}
|
|
353
|
-
function $(o) {
|
|
354
|
-
return [...new Set(o?.declarations?.map((e) => e.getSourceFile().fileName))];
|
|
355
|
-
}
|
|
356
|
-
function ke(o, e, t, a, i) {
|
|
357
|
-
if (e.reason !== void 0)
|
|
358
|
-
return {
|
|
359
|
-
name: j(e.symbol.declarations?.[0], e.symbol.getName()),
|
|
360
|
-
...D(e.symbol.declarations?.[0])
|
|
361
|
-
};
|
|
362
|
-
const s = i === void 0 ? void 0 : a.getProgram()?.getSourceFile(i.fileName), n = i === void 0 || s === void 0 ? void 0 : _(
|
|
363
|
-
s,
|
|
364
|
-
i.textSpan.start,
|
|
365
|
-
i.textSpan.start + i.textSpan.length
|
|
366
|
-
), r = (n === void 0 ? void 0 : t.getSymbolAtLocation(n)?.declarations?.[0]) ?? e.symbol?.declarations?.[0], m = i?.name;
|
|
367
|
-
return {
|
|
368
|
-
name: m === void 0 ? $e(o) : j(r, m),
|
|
369
|
-
...D(r)
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
function S(o, e) {
|
|
373
|
-
const t = v.relative(e, o);
|
|
374
|
-
return t !== "" && !t.startsWith("../") && !v.isAbsolute(t) && t !== "node_modules" && !t.startsWith("node_modules/");
|
|
375
|
-
}
|
|
376
|
-
function _(o, e, t) {
|
|
377
|
-
let a = o;
|
|
378
|
-
for (; ; ) {
|
|
379
|
-
let i;
|
|
380
|
-
if (l.forEachChild(a, (s) => {
|
|
381
|
-
i === void 0 && s.getStart(o) <= e && s.getEnd() >= t && (i = s);
|
|
382
|
-
}), i === void 0)
|
|
383
|
-
return a;
|
|
384
|
-
a = i;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
function $e(o) {
|
|
388
|
-
return l.isIdentifier(o) || l.isPrivateIdentifier(o) || l.isStringLiteralLike(o) || l.isNumericLiteral(o) ? o.text : o.getText();
|
|
389
|
-
}
|
|
390
|
-
function G(o) {
|
|
391
|
-
const e = o?.find(({ name: t }) => t === "deprecated");
|
|
392
|
-
return e === void 0 ? void 0 : me(e.text) ?? "";
|
|
393
|
-
}
|
|
394
|
-
function Ce(o, e, t) {
|
|
395
|
-
try {
|
|
396
|
-
return G(o.getQuickInfoAtPosition(e, t)?.tags);
|
|
397
|
-
} catch {
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
function B(o, e) {
|
|
402
|
-
try {
|
|
403
|
-
const t = G(o?.getJsDocTags(e));
|
|
404
|
-
if (t !== void 0)
|
|
405
|
-
return t;
|
|
406
|
-
const a = o?.declarations?.filter((i) => l.isGetAccessorDeclaration(i) || l.isSetAccessorDeclaration(i)).map((i) => l.getJSDocDeprecatedTag(i)).find((i) => i !== void 0);
|
|
407
|
-
return a === void 0 ? void 0 : a.comment === void 0 ? "" : ce(a.comment);
|
|
408
|
-
} catch {
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
function C(o, e, t) {
|
|
413
|
-
if (re(t.name, t.reason))
|
|
414
|
-
return;
|
|
415
|
-
const { line: a, character: i } = e.getLineAndCharacterOfPosition(t.start);
|
|
416
|
-
o.set(`${t.start}:${t.length}`, {
|
|
417
|
-
...t,
|
|
418
|
-
line: a + 1,
|
|
419
|
-
column: i + 1
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
function E(o, e, t) {
|
|
423
|
-
return o.some((a) => t !== void 0 && S(a, t)) ? !1 : !e || o.some((a) => {
|
|
424
|
-
const i = F(a);
|
|
425
|
-
return i === void 0 ? t === void 0 || !S(a, t) : ae(i);
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
function F(o) {
|
|
429
|
-
const e = X(o), t = "/node_modules/", a = e.lastIndexOf(t);
|
|
430
|
-
if (a === -1)
|
|
431
|
-
return;
|
|
432
|
-
const [i, s] = e.slice(a + t.length).split("/");
|
|
433
|
-
return i.startsWith("@") ? `${i}/${s}` : i;
|
|
434
|
-
}
|
|
435
|
-
function Ee(o, e = [], t) {
|
|
436
|
-
const a = o[0];
|
|
437
|
-
if (a === void 0)
|
|
438
|
-
return "unknown package";
|
|
439
|
-
const i = F(a);
|
|
440
|
-
if (i !== void 0)
|
|
441
|
-
return i;
|
|
442
|
-
const s = e.find(({ root: p }) => S(a, p));
|
|
443
|
-
if (s !== void 0)
|
|
444
|
-
return s.name;
|
|
445
|
-
const n = v.dirname(x(a)), r = W(v.dirname(a), n);
|
|
446
|
-
if (r !== n)
|
|
447
|
-
return r;
|
|
448
|
-
if (t === void 0)
|
|
449
|
-
return n;
|
|
450
|
-
const c = v.relative(t, a).split("/"), u = c.findIndex((p) => p !== "..");
|
|
451
|
-
return u < 1 ? v.dirname(x(a)) : c.slice(0, u * 2).join("/");
|
|
452
|
-
}
|
|
453
|
-
export {
|
|
454
|
-
We as auditDeprecatedUsages,
|
|
455
|
-
be as collectDeprecatedApiUsages,
|
|
456
|
-
Ee as getDeprecationOriginLabel,
|
|
457
|
-
F as getNodeModulesPackageName,
|
|
458
|
-
E as shouldIncludeDeprecation
|
|
459
|
-
};
|