@arcgis/codemod 6.0.0-next.44 → 6.0.0-next.45
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/README.md +73 -6
- package/dist/chunks/actions.js +261 -249
- package/dist/chunks/aggregateUsages.js +11 -10
- package/dist/chunks/apiName.js +123 -0
- package/dist/chunks/auditDefinitions.js +49 -47
- package/dist/chunks/auditUsages.js +649 -647
- package/dist/chunks/classification.js +73 -192
- package/dist/chunks/cli.js +52 -52
- package/dist/chunks/codemod.js +46 -46
- package/dist/chunks/codemod10.js +6039 -63
- package/dist/chunks/codemod11.js +54 -45
- package/dist/chunks/codemod12.js +74 -0
- package/dist/chunks/codemod9.js +218 -6017
- package/dist/chunks/componentAudit.js +141 -216
- package/dist/chunks/format.js +8 -7
- package/dist/chunks/hardcodedBehavior.js +96 -0
- package/dist/chunks/sync.js +1 -1
- package/package.json +4 -4
|
@@ -1,128 +1,20 @@
|
|
|
1
|
-
import { findPath as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import { retrievePackageJson as O } from "@arcgis/node-toolkit/packageJson";
|
|
7
|
-
import { e as C, d as P } from "./cli.js";
|
|
8
|
-
const K = "6.0.0-next.44";
|
|
9
|
-
function I(e, r) {
|
|
10
|
-
return e.package.localeCompare(r.package) || e.file.localeCompare(r.file) || e.line - r.line || e.column - r.column || g(e.module, r.module) || g(e.memberOf, r.memberOf) || e.name.localeCompare(r.name) || g(e.kind, r.kind) || g(e.category, r.category) || g(e.provenance, r.provenance) || String(e.deprecated).localeCompare(String(r.deprecated));
|
|
11
|
-
}
|
|
12
|
-
const g = (e, r) => (e ?? "").localeCompare(r ?? "");
|
|
13
|
-
function q(e) {
|
|
14
|
-
const r = JSON.parse(e);
|
|
15
|
-
if (typeof r != "object" || r === null || !("auditKind" in r) || r.auditKind !== "usages" && r.auditKind !== "definitions")
|
|
16
|
-
throw new Error("Invalid deprecation audit JSON.");
|
|
17
|
-
return r;
|
|
18
|
-
}
|
|
19
|
-
function Q() {
|
|
20
|
-
const e = b(".git");
|
|
21
|
-
if (e === void 0)
|
|
22
|
-
throw new Error("Unable to find a Git repository for the deprecation audit.");
|
|
23
|
-
const r = d.dirname(e), t = v("git", ["remote", "get-url", "origin"], { cwd: r }), o = v("git", ["rev-parse", "HEAD"], { cwd: r }), n = process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF_NAME || v("git", ["branch", "--show-current"], { cwd: r });
|
|
24
|
-
return { repository: A(t), repositoryRoot: r, ref: o, branch: n };
|
|
25
|
-
}
|
|
26
|
-
function X(e, r) {
|
|
27
|
-
return f(d.relative(r, e));
|
|
28
|
-
}
|
|
29
|
-
function Y(e, r = process.cwd()) {
|
|
30
|
-
if (e.length === 0)
|
|
31
|
-
return () => !0;
|
|
32
|
-
const t = $([...e], { dot: !0 });
|
|
33
|
-
return (o) => !t(f(d.relative(r, o)));
|
|
34
|
-
}
|
|
35
|
-
function Z(e, r, t, o) {
|
|
36
|
-
const n = e === "usages" ? "usage" : "definition";
|
|
37
|
-
process.stderr.write(
|
|
38
|
-
`Deprecations: ${r} ${n}${r === 1 ? "" : "s"} across ${t} file${t === 1 ? "" : "s"} from ${o} package${o === 1 ? "" : "s"}.
|
|
39
|
-
`
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
function A(e) {
|
|
43
|
-
const r = e.replace(/\.git$/u, "");
|
|
44
|
-
if (r.startsWith("http://") || r.startsWith("https://"))
|
|
45
|
-
return new URL(r).href.replace(/^https?:\/\//u, "").replace(/\/$/u, "");
|
|
46
|
-
const t = /^(?:ssh:\/\/)?git@([^/:]+)[:/](.+)$/u.exec(r);
|
|
47
|
-
if (t !== null)
|
|
48
|
-
return `${t[1]}/${t[2]}`;
|
|
49
|
-
throw new Error(`Unsupported Git remote URL: ${e}`);
|
|
50
|
-
}
|
|
51
|
-
function ee(e) {
|
|
52
|
-
if (e.kind === "css-property")
|
|
53
|
-
return e.name;
|
|
54
|
-
if (e.kind === "element")
|
|
55
|
-
return `<${e.name}>`;
|
|
56
|
-
if (e.memberOf !== void 0) {
|
|
57
|
-
if (e.kind === "css-part")
|
|
58
|
-
return `${e.memberOf}::part(${e.name})`;
|
|
59
|
-
if (e.kind === "css-state")
|
|
60
|
-
return `${e.memberOf}:state(${e.name})`;
|
|
61
|
-
if (e.kind === "slot")
|
|
62
|
-
return `${e.memberOf} > [slot="${e.name}"]`;
|
|
63
|
-
if (e.kind === "attribute")
|
|
64
|
-
return `${e.memberOf}[${e.name}]`;
|
|
65
|
-
}
|
|
66
|
-
const r = e.memberOf === void 0 ? e.name : `${e.memberOf}.${e.name}`;
|
|
67
|
-
return e.kind === "method" || e.kind === "function" ? `${r}()` : r;
|
|
68
|
-
}
|
|
69
|
-
function re(e, r = "dash") {
|
|
70
|
-
return e === void 0 || e === "field" || e === "method" || e === "function" ? "" : r === "parentheses" ? ` (${e})` : ` - ${e}`;
|
|
71
|
-
}
|
|
72
|
-
function te(e) {
|
|
73
|
-
if (e === void 0)
|
|
74
|
-
return {};
|
|
75
|
-
const r = B(e), t = e.parent, o = t !== void 0 && (i.isClassLike(t) || i.isInterfaceDeclaration(t)) ? t : t !== void 0 && i.isTypeLiteralNode(t) && i.isTypeAliasDeclaration(t.parent) ? t.parent : void 0, n = o?.name === void 0 ? void 0 : L(o, o.name.text);
|
|
76
|
-
return {
|
|
77
|
-
...r === void 0 ? {} : { kind: r },
|
|
78
|
-
...n === void 0 ? {} : { memberOf: n }
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function L(e, r) {
|
|
82
|
-
const t = [];
|
|
83
|
-
for (let o = e?.parent; o !== void 0; o = o.parent) {
|
|
84
|
-
if (i.isClassLike(o) || i.isInterfaceDeclaration(o) || i.isTypeLiteralNode(o))
|
|
85
|
-
return r;
|
|
86
|
-
i.isModuleDeclaration(o) && i.isIdentifier(o.name) && t.unshift(o.name.text);
|
|
87
|
-
}
|
|
88
|
-
return [...t, r].join(".");
|
|
89
|
-
}
|
|
90
|
-
function B(e) {
|
|
91
|
-
if (i.isPropertyDeclaration(e) || i.isPropertySignature(e))
|
|
92
|
-
return (i.getCombinedModifierFlags(e) & i.ModifierFlags.Readonly) !== 0 && D(e) ? "method" : "field";
|
|
93
|
-
if (i.isGetAccessorDeclaration(e) || i.isSetAccessorDeclaration(e))
|
|
94
|
-
return "field";
|
|
95
|
-
if (i.isMethodDeclaration(e) || i.isMethodSignature(e))
|
|
96
|
-
return "method";
|
|
97
|
-
if (i.isClassLike(e))
|
|
98
|
-
return "class";
|
|
99
|
-
if (i.isInterfaceDeclaration(e))
|
|
100
|
-
return "interface";
|
|
101
|
-
if (i.isTypeAliasDeclaration(e))
|
|
102
|
-
return "type";
|
|
103
|
-
if (i.isFunctionDeclaration(e))
|
|
104
|
-
return "function";
|
|
105
|
-
if (i.isVariableDeclaration(e))
|
|
106
|
-
return D(e) && (e.type !== void 0 || (e.parent.flags & i.NodeFlags.Const) !== 0) ? "function" : "variable";
|
|
107
|
-
if (i.isModuleDeclaration(e))
|
|
108
|
-
return "namespace";
|
|
109
|
-
}
|
|
110
|
-
function D(e) {
|
|
111
|
-
return e.type !== void 0 ? i.isFunctionTypeNode(e.type) : !i.isPropertySignature(e) && e.initializer !== void 0 && i.isArrowFunction(e.initializer);
|
|
112
|
-
}
|
|
113
|
-
const oe = /* @__PURE__ */ new Map([
|
|
1
|
+
import { findPath as P } from "@arcgis/node-toolkit/file";
|
|
2
|
+
import { toPosixPathSeparators as f, path as h } from "@arcgis/node-toolkit/path";
|
|
3
|
+
import { retrievePackageJson as w } from "@arcgis/node-toolkit/packageJson";
|
|
4
|
+
import { e as k, d as C } from "./cli.js";
|
|
5
|
+
const z = /* @__PURE__ */ new Map([
|
|
114
6
|
["MapView", "arcgis-map"],
|
|
115
7
|
["SceneView", "arcgis-scene"],
|
|
116
8
|
["LinkChartView", "arcgis-link-chart"],
|
|
117
9
|
["VideoView", "arcgis-video"]
|
|
118
|
-
]),
|
|
10
|
+
]), B = /* @__PURE__ */ new Set([
|
|
119
11
|
"MessageBundleLoader",
|
|
120
12
|
"createJSONLoader",
|
|
121
13
|
"fetchMessageBundle",
|
|
122
14
|
"messageBundle",
|
|
123
15
|
"normalizeMessageBundleLocale",
|
|
124
16
|
"registerMessageBundleLoader"
|
|
125
|
-
]),
|
|
17
|
+
]), L = /* @__PURE__ */ new Set([
|
|
126
18
|
"AreaMeasurement2D",
|
|
127
19
|
"AreaMeasurement3D",
|
|
128
20
|
"BasemapGallery",
|
|
@@ -163,18 +55,18 @@ const oe = /* @__PURE__ */ new Map([
|
|
|
163
55
|
"TableList",
|
|
164
56
|
"useLegacyCreateTools"
|
|
165
57
|
]);
|
|
166
|
-
function
|
|
167
|
-
package:
|
|
168
|
-
name:
|
|
169
|
-
category:
|
|
170
|
-
memberOf:
|
|
171
|
-
module:
|
|
172
|
-
deprecated:
|
|
58
|
+
function V({
|
|
59
|
+
package: r,
|
|
60
|
+
name: e,
|
|
61
|
+
category: s,
|
|
62
|
+
memberOf: u,
|
|
63
|
+
module: t,
|
|
64
|
+
deprecated: a
|
|
173
65
|
}) {
|
|
174
|
-
if (
|
|
175
|
-
return
|
|
176
|
-
const
|
|
177
|
-
return
|
|
66
|
+
if (s !== void 0)
|
|
67
|
+
return s;
|
|
68
|
+
const i = r.toLowerCase(), o = typeof a == "string" ? a.toLowerCase() : "";
|
|
69
|
+
return r === "@arcgis/core" && e === "ui" && [
|
|
178
70
|
"DOMContainer",
|
|
179
71
|
"DOMContainerProperties",
|
|
180
72
|
"MapView",
|
|
@@ -185,90 +77,79 @@ function F({
|
|
|
185
77
|
"LinkChartViewProperties",
|
|
186
78
|
"VideoView",
|
|
187
79
|
"VideoViewProperties"
|
|
188
|
-
].includes(
|
|
80
|
+
].includes(u?.replace(/^__esri\./u, "") ?? "") ? "coreViews" : r === "@arcgis/core" && (L.has(e) || o.includes("components-transition-plan")) ? "coreWidgets" : r === "@arcgis/core" && (/^(?:__esri\.)?(?:geometryEngine(?:Async)?|projection)(?:\.|$)/u.test(e) || e === "extendedSpatialReferenceInfo" || t?.startsWith("geometry/geometryEngine") || t?.startsWith("geometry/projection")) ? "coreGeometryEngine" : /\bcodemod\b/iu.test(o) ? "codemod" : r === "@arcgis/core" && (B.has(e) || o.includes("widget translations")) ? "coreIntl" : i.includes("calcite") ? "calcite" : /^@arcgis\/.+components/u.test(i) ? "arcgisComponents" : r === "@arcgis/core" ? "arcgisCore" : i.startsWith("@arcgis/") ? "arcgisSupport" : k(r) ? "otherEsri" : "nonEsri";
|
|
189
81
|
}
|
|
190
|
-
function
|
|
191
|
-
const
|
|
192
|
-
(
|
|
82
|
+
function $(r, e) {
|
|
83
|
+
const s = `/node_modules/${e}/`, u = r.map(f).sort(
|
|
84
|
+
(t, a) => Number(a.includes(s)) - Number(t.includes(s)) || t.localeCompare(a)
|
|
193
85
|
);
|
|
194
|
-
for (const
|
|
195
|
-
const
|
|
196
|
-
let
|
|
197
|
-
if (
|
|
198
|
-
|
|
86
|
+
for (const t of u) {
|
|
87
|
+
const a = t.lastIndexOf(s);
|
|
88
|
+
let i;
|
|
89
|
+
if (a !== -1)
|
|
90
|
+
i = t.slice(a + s.length);
|
|
199
91
|
else {
|
|
200
|
-
const
|
|
201
|
-
if (
|
|
202
|
-
|
|
92
|
+
const o = [...t.matchAll(/\/(?:src|dist)(?=\/)/gu)];
|
|
93
|
+
if (o.length === 1)
|
|
94
|
+
i = t.slice(o[0].index + 1);
|
|
203
95
|
else {
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
96
|
+
const n = P("package.json", h.dirname(t));
|
|
97
|
+
if (n === void 0)
|
|
206
98
|
continue;
|
|
207
|
-
const
|
|
208
|
-
if (
|
|
99
|
+
const m = h.dirname(n);
|
|
100
|
+
if (w(m).name !== e)
|
|
209
101
|
continue;
|
|
210
|
-
|
|
102
|
+
i = f(h.relative(m, t));
|
|
211
103
|
}
|
|
212
104
|
}
|
|
213
|
-
return
|
|
105
|
+
return i.startsWith("src/") ? O(i) : b(i);
|
|
214
106
|
}
|
|
215
107
|
}
|
|
216
|
-
function
|
|
217
|
-
return f(
|
|
108
|
+
function O(r) {
|
|
109
|
+
return f(r).replace(/^src\//u, "").replace(S, "");
|
|
218
110
|
}
|
|
219
|
-
function
|
|
220
|
-
return f(
|
|
111
|
+
function b(r) {
|
|
112
|
+
return f(r).replace(/^dist\//u, "").replace(S, "").replace(/^(components?\/[^/]+-[^/]+)\/customElement$/u, "$1");
|
|
221
113
|
}
|
|
222
|
-
const
|
|
223
|
-
function
|
|
224
|
-
const
|
|
225
|
-
return Object.keys(
|
|
226
|
-
const
|
|
227
|
-
if (
|
|
114
|
+
const S = /\.(?:d\.)?(?:[cm]?ts|tsx)$/u;
|
|
115
|
+
function R(r, e) {
|
|
116
|
+
const s = Map.groupBy(r, (u) => V(e(u)));
|
|
117
|
+
return Object.keys(C).flatMap((u) => {
|
|
118
|
+
const t = s.get(u);
|
|
119
|
+
if (t === void 0)
|
|
228
120
|
return [];
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
return
|
|
232
|
-
})].map(([
|
|
233
|
-
const
|
|
234
|
-
const
|
|
235
|
-
return JSON.stringify([
|
|
236
|
-
}).values()].map((
|
|
237
|
-
const
|
|
238
|
-
return { name:
|
|
121
|
+
const i = [...Map.groupBy(t, (o) => {
|
|
122
|
+
const n = e(o);
|
|
123
|
+
return D(n.package, n.module);
|
|
124
|
+
})].map(([o, n]) => {
|
|
125
|
+
const m = e(n[0]).package, y = [...Map.groupBy(n, (c) => {
|
|
126
|
+
const l = e(c);
|
|
127
|
+
return JSON.stringify([l.name, l.memberOf, l.kind]);
|
|
128
|
+
}).values()].map((c) => {
|
|
129
|
+
const l = e(c[0]).name, d = c.map((p) => e(p).deprecated).filter((p) => typeof p == "string" && p !== ""), g = [...new Set(d)].sort((p, M) => p.localeCompare(M));
|
|
130
|
+
return { name: l, reasons: g, items: c };
|
|
239
131
|
});
|
|
240
|
-
return
|
|
241
|
-
const
|
|
242
|
-
return
|
|
243
|
-
}), { packageName:
|
|
132
|
+
return y.sort((c, l) => {
|
|
133
|
+
const d = e(c.items[0]), g = e(l.items[0]);
|
|
134
|
+
return l.items.length - c.items.length || c.name.localeCompare(l.name) || (d.memberOf ?? "").localeCompare(g.memberOf ?? "") || (d.kind ?? "").localeCompare(g.kind ?? "");
|
|
135
|
+
}), { packageName: m, displayName: o, count: n.length, apis: y };
|
|
244
136
|
});
|
|
245
|
-
return
|
|
246
|
-
(
|
|
247
|
-
), [{ categoryName:
|
|
137
|
+
return i.sort(
|
|
138
|
+
(o, n) => n.count - o.count || o.packageName.localeCompare(n.packageName) || o.displayName.localeCompare(n.displayName)
|
|
139
|
+
), [{ categoryName: u, count: t.length, packages: i }];
|
|
248
140
|
});
|
|
249
141
|
}
|
|
250
|
-
function
|
|
251
|
-
return
|
|
142
|
+
function D(r, e) {
|
|
143
|
+
return A(r, e) ? "DOM / Web platform" : r;
|
|
252
144
|
}
|
|
253
|
-
function
|
|
254
|
-
return
|
|
145
|
+
function A(r, e) {
|
|
146
|
+
return r === "typescript" && /^lib\/lib\.dom(?:$|[./])/u.test(e ?? "");
|
|
255
147
|
}
|
|
256
148
|
export {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
X as g,
|
|
264
|
-
re as h,
|
|
265
|
-
Y as i,
|
|
266
|
-
te as j,
|
|
267
|
-
L as k,
|
|
268
|
-
oe as l,
|
|
269
|
-
T as m,
|
|
270
|
-
q as n,
|
|
271
|
-
x as o,
|
|
272
|
-
Z as p,
|
|
273
|
-
K as s
|
|
149
|
+
$ as a,
|
|
150
|
+
z as b,
|
|
151
|
+
V as c,
|
|
152
|
+
D as d,
|
|
153
|
+
R as g,
|
|
154
|
+
O as s
|
|
274
155
|
};
|
package/dist/chunks/cli.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { log as g } from "@arcgis/toolkit/log";
|
|
2
2
|
import { Command as ce, InvalidArgumentError as A } from "@commander-js/extra-typings";
|
|
3
3
|
import { realpath as X, stat as Y } from "node:fs/promises";
|
|
4
|
-
import { path as r, getCwd as W, toPosixPathSeparators as
|
|
5
|
-
import { asyncFindPath as
|
|
4
|
+
import { path as r, getCwd as W, toPosixPathSeparators as T } from "@arcgis/node-toolkit/path";
|
|
5
|
+
import { asyncFindPath as $, existsAsync as M } from "@arcgis/node-toolkit/file";
|
|
6
6
|
import "ts-morph";
|
|
7
7
|
import d from "typescript";
|
|
8
8
|
import { asyncRetrievePackageJson as de } from "@arcgis/node-toolkit/packageJson";
|
|
9
9
|
import { glob as Z } from "tinyglobby";
|
|
10
10
|
import { gitIgnoreFileToGlobs as ee } from "@arcgis/node-toolkit/glob";
|
|
11
11
|
import { identity as q } from "@arcgis/toolkit/function";
|
|
12
|
-
import { styleText as
|
|
12
|
+
import { styleText as U } from "node:util";
|
|
13
13
|
import { randomUUID as le } from "node:crypto";
|
|
14
14
|
const me = (t, e, o) => {
|
|
15
15
|
const s = t[e];
|
|
@@ -35,7 +35,7 @@ const me = (t, e, o) => {
|
|
|
35
35
|
target: d.ScriptTarget.ESNext,
|
|
36
36
|
resolveJsonModule: !0,
|
|
37
37
|
esModuleInterop: !0
|
|
38
|
-
},
|
|
38
|
+
}, v = {
|
|
39
39
|
codemod: void 0,
|
|
40
40
|
codemodName: void 0,
|
|
41
41
|
projectsData: void 0,
|
|
@@ -55,27 +55,27 @@ async function pe() {
|
|
|
55
55
|
async function ue() {
|
|
56
56
|
const t = [];
|
|
57
57
|
let e = !1;
|
|
58
|
-
const o = await
|
|
58
|
+
const o = await $(".git"), s = o === void 0 ? void 0 : r.dirname(o);
|
|
59
59
|
let n, l = W(), f = r.dirname(l);
|
|
60
60
|
do {
|
|
61
61
|
if (n = f, s !== void 0 && n !== s && !n.startsWith(`${s}/`))
|
|
62
62
|
break;
|
|
63
63
|
const p = r.join(n, ".gitignore");
|
|
64
|
-
if (await
|
|
64
|
+
if (await M(p)) {
|
|
65
65
|
e = !0, l = r.dirname(p);
|
|
66
66
|
const h = r.relative(l, W()).split("/"), N = ee(p);
|
|
67
67
|
for (const b of N) {
|
|
68
68
|
const w = b.startsWith("!") ? b.slice(1) : b, y = w.search(/[*?[]/u), P = y === -1 ? w : w.slice(0, y), u = P.split("/"), I = y !== -1 && !P.endsWith("/");
|
|
69
|
-
let
|
|
69
|
+
let x = !0;
|
|
70
70
|
const D = Math.min(h.length, u.length);
|
|
71
71
|
for (let i = 0; i < D; i++) {
|
|
72
72
|
const a = u[i];
|
|
73
73
|
if (!(I && i === u.length - 1 ? h[i].startsWith(a) : h[i] === a) && a !== "") {
|
|
74
|
-
|
|
74
|
+
x = !1;
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
x && (b.startsWith("!") || t.push(b));
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
f = r.dirname(n);
|
|
@@ -110,7 +110,7 @@ async function we({
|
|
|
110
110
|
...se,
|
|
111
111
|
...he,
|
|
112
112
|
...e ? be : []
|
|
113
|
-
].join(",")}}`, f = r.join(process.cwd(), l), p = r.join(r.resolve(s.globRoot), "/"),
|
|
113
|
+
].join(",")}}`, f = r.join(process.cwd(), l), p = r.join(r.resolve(s.globRoot), "/"), L = (await Z(f, {
|
|
114
114
|
cwd: s.globRoot,
|
|
115
115
|
ignore: s.ignorePatterns,
|
|
116
116
|
// The files we are looking for are unlikely to be symbolic links
|
|
@@ -126,7 +126,7 @@ async function we({
|
|
|
126
126
|
let h = r.relative(s.globRoot, process.cwd());
|
|
127
127
|
h !== "" && (h += "/");
|
|
128
128
|
const N = p.length + h.length, b = [], w = [], y = /* @__PURE__ */ new Set();
|
|
129
|
-
for (const i of
|
|
129
|
+
for (const i of L) {
|
|
130
130
|
const a = p + i;
|
|
131
131
|
if (i.endsWith(".json")) {
|
|
132
132
|
const c = r.basename(i);
|
|
@@ -136,19 +136,19 @@ async function we({
|
|
|
136
136
|
y.add(c);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
let P = await
|
|
140
|
-
P !== void 0 && (P =
|
|
139
|
+
let P = await $("tsconfig.json", r.dirname(process.cwd()));
|
|
140
|
+
P !== void 0 && (P = T(P), w.push(P)), w.sort((i, a) => {
|
|
141
141
|
const c = a.split("/").length - i.split("/").length;
|
|
142
142
|
if (c !== 0)
|
|
143
143
|
return c;
|
|
144
144
|
const m = r.basename(i), S = r.basename(a);
|
|
145
145
|
return m === S ? 0 : m.endsWith("tsconfig.json") ? -1 : S.endsWith("tsconfig.json") ? 1 : m.endsWith("tsconfig.build.json") ? -1 : S.endsWith("tsconfig.build.json") ? 1 : m.localeCompare(S);
|
|
146
146
|
});
|
|
147
|
-
let u = await
|
|
148
|
-
u !== void 0 && (u =
|
|
147
|
+
let u = await $("package.json");
|
|
148
|
+
u !== void 0 && (u = T(u));
|
|
149
149
|
const I = [
|
|
150
150
|
.../* @__PURE__ */ new Set([...b, ...u === void 0 ? [] : [u]])
|
|
151
|
-
].sort((i, a) => a.length - i.length),
|
|
151
|
+
].sort((i, a) => a.length - i.length), x = [], D = /* @__PURE__ */ new Set();
|
|
152
152
|
if (await Promise.all(
|
|
153
153
|
w.map(async (i) => {
|
|
154
154
|
const a = r.relative(process.cwd(), i), c = d.readConfigFile(i, d.sys.readFile);
|
|
@@ -180,22 +180,22 @@ async function we({
|
|
|
180
180
|
getNewLine: () => d.sys.newLine
|
|
181
181
|
})
|
|
182
182
|
);
|
|
183
|
-
const
|
|
183
|
+
const K = i === P, _ = m.fileNames.filter((k) => {
|
|
184
184
|
if (t !== void 0 && k !== t)
|
|
185
185
|
return !1;
|
|
186
186
|
const E = k.slice(N);
|
|
187
|
-
return y.delete(E) ? (D.add(E), !0) : D.has(E) || E.endsWith(".json") || k.includes("node_modules") ||
|
|
187
|
+
return y.delete(E) ? (D.add(E), !0) : D.has(E) || E.endsWith(".json") || k.includes("node_modules") || K ? !1 : d.sys.fileExists(k);
|
|
188
188
|
}), re = (
|
|
189
189
|
// Scanning tsconfig.json
|
|
190
190
|
o && // Don't include tsconfig outside the scanned scope
|
|
191
|
-
!
|
|
191
|
+
!K && // If filtering by file, ensure this tsconfig is the one being targeted
|
|
192
192
|
(t === void 0 || t === i)
|
|
193
193
|
);
|
|
194
|
-
if (
|
|
194
|
+
if (_.length === 0 && !re)
|
|
195
195
|
return;
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
await B(
|
|
196
|
+
const H = r.dirname(i), ae = z(H, I) ?? u;
|
|
197
|
+
x.push(
|
|
198
|
+
await B(_, H, ae, {
|
|
199
199
|
filePath: i,
|
|
200
200
|
compilerOptions: m.options
|
|
201
201
|
})
|
|
@@ -203,15 +203,15 @@ async function we({
|
|
|
203
203
|
})
|
|
204
204
|
), y.size > 0) {
|
|
205
205
|
const i = [...y].map((c) => r.join(process.cwd(), c)), a = Map.groupBy(i, (c) => z(c, I));
|
|
206
|
-
|
|
206
|
+
x.push(
|
|
207
207
|
...await Promise.all(
|
|
208
208
|
[...a].map(async ([c, m]) => await B(m, process.cwd(), c))
|
|
209
209
|
)
|
|
210
210
|
);
|
|
211
211
|
}
|
|
212
|
-
return
|
|
212
|
+
return x.sort(
|
|
213
213
|
(i, a) => i.cwd.localeCompare(a.cwd) || (i.typeScriptConfig?.filePath ?? "").localeCompare(a.typeScriptConfig?.filePath ?? "") || (i.packageJson?.filePath ?? "").localeCompare(a.packageJson?.filePath ?? "")
|
|
214
|
-
),
|
|
214
|
+
), v.projectsData = x, x;
|
|
215
215
|
}
|
|
216
216
|
function Ue(t) {
|
|
217
217
|
const e = r.extname(t).slice(1);
|
|
@@ -233,18 +233,18 @@ async function B(t, e, o, s) {
|
|
|
233
233
|
packageJson: n,
|
|
234
234
|
cwd: e,
|
|
235
235
|
filePaths: t.sort(),
|
|
236
|
-
logName:
|
|
236
|
+
logName: U("blue", n?.contents.name ?? e)
|
|
237
237
|
};
|
|
238
238
|
}
|
|
239
239
|
function ye() {
|
|
240
|
-
|
|
240
|
+
v.codemod.meta.needsFooter && (v.codemod.meta.needsFooter = !1, process.exitCode !== void 0 && process.exitCode !== 0 ? g(
|
|
241
241
|
"warn",
|
|
242
|
-
|
|
242
|
+
v.codemodName,
|
|
243
243
|
"One or more exceptions occurred during the codemod run. Please review the output above."
|
|
244
244
|
) : g(
|
|
245
245
|
"info",
|
|
246
|
-
|
|
247
|
-
`${
|
|
246
|
+
v.codemodName,
|
|
247
|
+
`${U("green", "Codemod completed successfully.")} Recommended next steps:
|
|
248
248
|
- Review the codemod changes.
|
|
249
249
|
- If your project uses ESLint, run ESLint autofix on the changed files.
|
|
250
250
|
- If your project uses Prettier, run Prettier on the changed files.
|
|
@@ -252,7 +252,7 @@ function ye() {
|
|
|
252
252
|
));
|
|
253
253
|
}
|
|
254
254
|
async function Pe(t, e, o) {
|
|
255
|
-
|
|
255
|
+
v.codemod = t, v.codemodName = e;
|
|
256
256
|
const s = await we({
|
|
257
257
|
targetFilePath: o,
|
|
258
258
|
includeComponentFiles: t.meta.includeComponentFiles,
|
|
@@ -265,10 +265,10 @@ async function Pe(t, e, o) {
|
|
|
265
265
|
}
|
|
266
266
|
await t.run(s), ye();
|
|
267
267
|
}
|
|
268
|
-
async function
|
|
268
|
+
async function xe(t) {
|
|
269
269
|
const e = r.resolve(t);
|
|
270
|
-
await
|
|
271
|
-
const o = await X(e), s = (await Y(o)).isFile();
|
|
270
|
+
await M(e) || (g("error", "@arcgis/codemod", `Failed to find the target path: ${t}`), process.exit(1));
|
|
271
|
+
const o = T(await X(e)), s = (await Y(o)).isFile();
|
|
272
272
|
return process.chdir(s ? r.dirname(o) : o), s ? o : void 0;
|
|
273
273
|
}
|
|
274
274
|
const R = {
|
|
@@ -316,7 +316,7 @@ const R = {
|
|
|
316
316
|
label: "Non-Esri packages and web platform - low priority",
|
|
317
317
|
description: "These deprecations do not block updating Esri packages and are not tied to an ArcGIS release."
|
|
318
318
|
}
|
|
319
|
-
},
|
|
319
|
+
}, G = "https://webgis.esri.com/api/deprecations";
|
|
320
320
|
async function Le(t, e) {
|
|
321
321
|
const o = le();
|
|
322
322
|
process.stderr.write(`Submitting deprecation report (${o}).
|
|
@@ -346,7 +346,7 @@ async function Le(t, e) {
|
|
|
346
346
|
process.stderr.write(`Deprecation report submitted to ${e} (${o}).
|
|
347
347
|
`);
|
|
348
348
|
}
|
|
349
|
-
const
|
|
349
|
+
const ve = /(?:esri|arcgis)/iu, Se = ["/.astro/"], J = ["all", "repositories", "apis", "unused-apis"], Ke = {
|
|
350
350
|
usages: "Refactor-out deprecated API usages",
|
|
351
351
|
definitions: "Remove deprecated APIs in next breaking changes release"
|
|
352
352
|
}, _e = {
|
|
@@ -354,18 +354,18 @@ const xe = /(?:esri|arcgis)/iu, Se = ["/.astro/"], G = ["all", "repositories", "
|
|
|
354
354
|
definitions: "The following deprecated APIs are owned by assigned CODEOWNERS. Remove them in the next breaking changes release."
|
|
355
355
|
}, He = "This issue is autogenerated and updated regularly based on remaining items. Feel free to add comments and labels, update assignees, set milestone, or create sub-issues. Close it once completed. A new issue will be created if new findings are detected.", qe = "Task", ze = "deprecations sync-issues";
|
|
356
356
|
function Be(t) {
|
|
357
|
-
return
|
|
357
|
+
return ve.test(t);
|
|
358
358
|
}
|
|
359
359
|
function Ve(t) {
|
|
360
360
|
return Se.some((e) => `/${t}`.includes(e));
|
|
361
361
|
}
|
|
362
|
-
const F = new ce(), O = "See https://www.npmjs.com/package/@arcgis/codemod for a list of available public codemods. [Esri internal] Non-public codemods are documented at https://webgis.esri.com/references/codemod/introduction.";
|
|
362
|
+
const F = new ce(), O = "See https://www.npmjs.com/package/@arcgis/codemod for a list of available public codemods. Double check you used the correct codemod package version - try re-running with npx @arcgis/codemod@next or npx @arcgis/codemod@latest. [Esri internal] Non-public codemods are documented at https://webgis.esri.com/references/codemod/introduction.";
|
|
363
363
|
F.name("@arcgis/codemod").description("Codemod for migrating or refactoring usages of ArcGIS Maps SDK for JavaScript");
|
|
364
364
|
F.command("run").description("Run a single codemod").argument("<codemodName>", `Name of the codemod. ${O}`).argument("[path]", "Directory to transform", process.cwd()).showHelpAfterError(O).action(async (t, e) => {
|
|
365
|
-
const o = await
|
|
365
|
+
const o = await xe(e);
|
|
366
366
|
let s;
|
|
367
367
|
try {
|
|
368
|
-
s = await me(/* @__PURE__ */ Object.assign({ "./codemods/api-extractor-strict-mode/codemod.ts": () => import("./codemod.js"), "./codemods/feature-next-to-feature/codemod.ts": () => import("./codemod2.js"), "./codemods/features-next-to-features/codemod.ts": () => import("./codemod3.js"), "./codemods/geometry-operator-renames/codemod.ts": () => import("./codemod4.js"), "./codemods/lumina-component-extras-improvements/codemod.ts": () => import("./codemod5.js"), "./codemods/lumina-toolkit/codemod.ts": () => import("./codemod6.js"), "./codemods/node-toolkit/codemod.ts": () => import("./codemod7.js"), "./codemods/normalize-calcite-icon-names/codemod.ts": () => import("./codemod8.js"), "./codemods/refactor-out-esri-namespace/codemod.ts": () => import("./
|
|
368
|
+
s = await me(/* @__PURE__ */ Object.assign({ "./codemods/api-extractor-strict-mode/codemod.ts": () => import("./codemod.js"), "./codemods/feature-next-to-feature/codemod.ts": () => import("./codemod2.js"), "./codemods/features-next-to-features/codemod.ts": () => import("./codemod3.js"), "./codemods/geometry-operator-renames/codemod.ts": () => import("./codemod4.js"), "./codemods/lumina-component-extras-improvements/codemod.ts": () => import("./codemod5.js"), "./codemods/lumina-toolkit/codemod.ts": () => import("./codemod6.js"), "./codemods/node-toolkit/codemod.ts": () => import("./codemod7.js"), "./codemods/normalize-calcite-icon-names/codemod.ts": () => import("./codemod8.js"), "./codemods/refactor-component-types/codemod.ts": () => import("./codemod9.js"), "./codemods/refactor-out-esri-namespace/codemod.ts": () => import("./codemod10.js"), "./codemods/rename-next-list-components/codemod.ts": () => import("./codemod11.js"), "./codemods/toolkit-5.2-renames/codemod.ts": () => import("./codemod12.js") }), `./codemods/${t}/codemod.ts`, 4);
|
|
369
369
|
} catch (n) {
|
|
370
370
|
if (
|
|
371
371
|
// direct Node execution
|
|
@@ -381,7 +381,7 @@ F.command("run").description("Run a single codemod").argument("<codemodName>", `
|
|
|
381
381
|
g("error", "@arcgis/codemod", `Can't find codemod by name "${t}". ${O}`), process.exitCode = 1;
|
|
382
382
|
return;
|
|
383
383
|
}
|
|
384
|
-
await Pe(s.codemod,
|
|
384
|
+
await Pe(s.codemod, U("blue", t), o);
|
|
385
385
|
});
|
|
386
386
|
const C = F.command("deprecations").description(
|
|
387
387
|
`Audit and report deprecated APIs.
|
|
@@ -396,7 +396,7 @@ C.command("audit-usages").description(
|
|
|
396
396
|
ne
|
|
397
397
|
).option("--package <package-name>", "Only report usages of deprecated APIs from this package").option(
|
|
398
398
|
"--report [url]",
|
|
399
|
-
`Submit a complete repository scan to the WebGIS collector (default: ${
|
|
399
|
+
`Submit a complete repository scan to the WebGIS collector (default: ${G})`
|
|
400
400
|
).option(
|
|
401
401
|
"--json",
|
|
402
402
|
"Output results as JSON. Example: npx @arcgis/codemod deprecations audit-usages --json > usages.json",
|
|
@@ -423,12 +423,12 @@ C.command("aggregate-usages").description(
|
|
|
423
423
|
"Aggregate audit-usages reports into repository summaries and an API usage tree. Documentation: https://webgis.esri.com/references/codemod/deprecations#analyze-the-ecosystem"
|
|
424
424
|
).argument("[reports...]", "Paths to audit-usages JSON files").option(
|
|
425
425
|
"--section <section>",
|
|
426
|
-
`Reports to include in the markdown report: ${
|
|
426
|
+
`Reports to include in the markdown report: ${J.join(", ")}`,
|
|
427
427
|
ke,
|
|
428
428
|
"all"
|
|
429
429
|
).option(
|
|
430
430
|
"--remote [url]",
|
|
431
|
-
`Read the latest stored audit per repository from the WebGIS collector (default: ${
|
|
431
|
+
`Read the latest stored audit per repository from the WebGIS collector (default: ${G})`
|
|
432
432
|
).option(
|
|
433
433
|
"--repository <repository>",
|
|
434
434
|
"Select a remote repository (host/owner/repo); repeat to select multiple",
|
|
@@ -464,7 +464,7 @@ C.command("aggregate-usages").description(
|
|
|
464
464
|
},
|
|
465
465
|
e.definitions,
|
|
466
466
|
e.remote ? {
|
|
467
|
-
url: e.remote === !0 ?
|
|
467
|
+
url: e.remote === !0 ? G : e.remote,
|
|
468
468
|
repositories: e.repository,
|
|
469
469
|
branch: e.branch,
|
|
470
470
|
since: e.since,
|
|
@@ -473,10 +473,10 @@ C.command("aggregate-usages").description(
|
|
|
473
473
|
);
|
|
474
474
|
});
|
|
475
475
|
function ke(t) {
|
|
476
|
-
const e =
|
|
476
|
+
const e = J.find((o) => o === t);
|
|
477
477
|
if (e !== void 0)
|
|
478
478
|
return e;
|
|
479
|
-
throw new A(`Expected one of: ${
|
|
479
|
+
throw new A(`Expected one of: ${J.join(", ")}.`);
|
|
480
480
|
}
|
|
481
481
|
C.command("sync-issues").description(
|
|
482
482
|
`Create or update deprecation audit issues. Requires authenticated gh cli.
|
|
@@ -493,7 +493,7 @@ Otherwise, a new issue is created. Assignees are determined based on CODEOWNERS.
|
|
|
493
493
|
[]
|
|
494
494
|
).action(async (t, e) => {
|
|
495
495
|
const o = r.resolve(t);
|
|
496
|
-
if (!await
|
|
496
|
+
if (!await M(o) || !(await Y(o)).isFile()) {
|
|
497
497
|
g("error", "@arcgis/codemod", `Failed to find the audit JSON file: ${t}`), process.exitCode = 1;
|
|
498
498
|
return;
|
|
499
499
|
}
|
|
@@ -531,13 +531,13 @@ C.command("sync-markdown").description(
|
|
|
531
531
|
});
|
|
532
532
|
F.parse();
|
|
533
533
|
export {
|
|
534
|
-
|
|
534
|
+
G as a,
|
|
535
535
|
Pe as b,
|
|
536
536
|
Le as c,
|
|
537
537
|
R as d,
|
|
538
538
|
Be as e,
|
|
539
539
|
Me as f,
|
|
540
|
-
|
|
540
|
+
v as g,
|
|
541
541
|
ze as h,
|
|
542
542
|
Ue as i,
|
|
543
543
|
Ke as j,
|
|
@@ -545,6 +545,6 @@ export {
|
|
|
545
545
|
He as l,
|
|
546
546
|
qe as m,
|
|
547
547
|
ye as p,
|
|
548
|
-
|
|
548
|
+
xe as r,
|
|
549
549
|
Ve as s
|
|
550
550
|
};
|