@arcgis/codemod 6.0.0-next.2 → 6.0.0-next.4
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/classification.js +232 -0
- package/dist/chunks/cli.js +71 -57
- package/dist/chunks/format.js +109 -180
- package/dist/chunks/hardcodedBehavior.js +38 -68
- package/dist/chunks/index.js +340 -285
- package/dist/chunks/index2.js +110 -93
- package/dist/chunks/sync.js +39 -40
- package/package.json +4 -4
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { findPath as S } from "@arcgis/node-toolkit/file";
|
|
2
|
+
import { path as g, toPosixPathSeparators as h } from "@arcgis/node-toolkit/path";
|
|
3
|
+
import { collectOutputSync as w } from "@arcgis/node-toolkit/shell";
|
|
4
|
+
import s from "typescript";
|
|
5
|
+
import { retrievePackageJson as P } from "@arcgis/node-toolkit/packageJson";
|
|
6
|
+
import { d as b } from "./cli.js";
|
|
7
|
+
function F(e) {
|
|
8
|
+
const t = JSON.parse(e);
|
|
9
|
+
if (typeof t != "object" || t === null || !("kind" in t) || t.kind !== "usages" && t.kind !== "definitions")
|
|
10
|
+
throw new Error("Invalid deprecation audit JSON.");
|
|
11
|
+
return t;
|
|
12
|
+
}
|
|
13
|
+
function G() {
|
|
14
|
+
const e = S(".git");
|
|
15
|
+
if (e === void 0)
|
|
16
|
+
throw new Error("Unable to find a Git repository for the deprecation audit.");
|
|
17
|
+
const t = g.dirname(e), r = w("git", ["remote", "get-url", "origin"], { cwd: t }), i = w("git", ["rev-parse", "HEAD"], { cwd: t });
|
|
18
|
+
return { repository: A(r), repositoryRoot: t, ref: i };
|
|
19
|
+
}
|
|
20
|
+
function J(e, t) {
|
|
21
|
+
return h(g.relative(t, e));
|
|
22
|
+
}
|
|
23
|
+
function K(e, t, r, i) {
|
|
24
|
+
const n = e === "usages" ? "usage" : "definition";
|
|
25
|
+
process.stderr.write(
|
|
26
|
+
`Deprecations: ${t} ${n}${t === 1 ? "" : "s"} across ${r} file${r === 1 ? "" : "s"} from ${i} package${i === 1 ? "" : "s"}.
|
|
27
|
+
`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
function A(e) {
|
|
31
|
+
const t = e.replace(/\.git$/u, "");
|
|
32
|
+
if (t.startsWith("http://") || t.startsWith("https://"))
|
|
33
|
+
return new URL(t).href.replace(/^https?:\/\//u, "").replace(/\/$/u, "");
|
|
34
|
+
const r = /^(?:ssh:\/\/)?git@([^/:]+)[:/](.+)$/u.exec(t);
|
|
35
|
+
if (r !== null)
|
|
36
|
+
return `${r[1]}/${r[2]}`;
|
|
37
|
+
throw new Error(`Unsupported Git remote URL: ${e}`);
|
|
38
|
+
}
|
|
39
|
+
function _(e) {
|
|
40
|
+
const t = e.memberOf === void 0 ? e.api : `${e.memberOf}.${e.api}`;
|
|
41
|
+
return e.apiKind === "method" || e.apiKind === "function" ? `${t}()` : t;
|
|
42
|
+
}
|
|
43
|
+
function H(e, t = "dash") {
|
|
44
|
+
return e === void 0 || e === "property" || e === "method" || e === "function" ? "" : t === "parentheses" ? ` (${e})` : ` - ${e}`;
|
|
45
|
+
}
|
|
46
|
+
function U(e) {
|
|
47
|
+
if (e === void 0)
|
|
48
|
+
return {};
|
|
49
|
+
const t = O(e), r = e.parent, i = r !== void 0 && (s.isClassLike(r) || s.isInterfaceDeclaration(r)) ? r : r !== void 0 && s.isTypeLiteralNode(r) && s.isTypeAliasDeclaration(r.parent) ? r.parent : void 0, n = i?.name === void 0 ? void 0 : L(i, i.name.text);
|
|
50
|
+
return {
|
|
51
|
+
...t === void 0 ? {} : { apiKind: t },
|
|
52
|
+
...n === void 0 ? {} : { memberOf: n }
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function L(e, t) {
|
|
56
|
+
const r = [];
|
|
57
|
+
for (let i = e?.parent; i !== void 0; i = i.parent) {
|
|
58
|
+
if (s.isClassLike(i) || s.isInterfaceDeclaration(i) || s.isTypeLiteralNode(i))
|
|
59
|
+
return t;
|
|
60
|
+
s.isModuleDeclaration(i) && s.isIdentifier(i.name) && r.unshift(i.name.text);
|
|
61
|
+
}
|
|
62
|
+
return [...r, t].join(".");
|
|
63
|
+
}
|
|
64
|
+
function O(e) {
|
|
65
|
+
if (s.isPropertyDeclaration(e) || s.isPropertySignature(e) || s.isGetAccessorDeclaration(e) || s.isSetAccessorDeclaration(e))
|
|
66
|
+
return "property";
|
|
67
|
+
if (s.isMethodDeclaration(e) || s.isMethodSignature(e))
|
|
68
|
+
return "method";
|
|
69
|
+
if (s.isClassLike(e))
|
|
70
|
+
return "class";
|
|
71
|
+
if (s.isInterfaceDeclaration(e))
|
|
72
|
+
return "interface";
|
|
73
|
+
if (s.isTypeAliasDeclaration(e))
|
|
74
|
+
return "type";
|
|
75
|
+
if (s.isFunctionDeclaration(e))
|
|
76
|
+
return "function";
|
|
77
|
+
if (s.isVariableDeclaration(e))
|
|
78
|
+
return "variable";
|
|
79
|
+
if (s.isModuleDeclaration(e))
|
|
80
|
+
return "namespace";
|
|
81
|
+
}
|
|
82
|
+
const C = /(?:esri|arcgis)/iu, q = "@arcgis/codemod", Q = {
|
|
83
|
+
usages: "Refactor-out deprecated API usages",
|
|
84
|
+
definitions: "Remove deprecated APIs in next breaking changes release"
|
|
85
|
+
}, X = {
|
|
86
|
+
usages: "The following deprecated APIs are used in files owned by assigned CODEOWNERS. Refactor them before the APIs are removed.",
|
|
87
|
+
definitions: "The following deprecated APIs are owned by assigned CODEOWNERS. Remove them in the next breaking changes release."
|
|
88
|
+
}, Y = "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.", Z = "Task", ee = "deprecations sync-issues";
|
|
89
|
+
function k(e) {
|
|
90
|
+
return C.test(e);
|
|
91
|
+
}
|
|
92
|
+
const $ = /* @__PURE__ */ new Map([
|
|
93
|
+
["MapView", "arcgis-map"],
|
|
94
|
+
["SceneView", "arcgis-scene"],
|
|
95
|
+
["LinkChartView", "arcgis-link-chart"],
|
|
96
|
+
["VideoView", "arcgis-video"]
|
|
97
|
+
]), V = /* @__PURE__ */ new Set([
|
|
98
|
+
"MessageBundleLoader",
|
|
99
|
+
"createJSONLoader",
|
|
100
|
+
"fetchMessageBundle",
|
|
101
|
+
"messageBundle",
|
|
102
|
+
"normalizeMessageBundleLocale",
|
|
103
|
+
"registerMessageBundleLoader"
|
|
104
|
+
]), R = /* @__PURE__ */ new Set([
|
|
105
|
+
"AreaMeasurement2D",
|
|
106
|
+
"AreaMeasurement3D",
|
|
107
|
+
"BasemapGallery",
|
|
108
|
+
"BasemapToggle",
|
|
109
|
+
"BatchAttributeForm",
|
|
110
|
+
"BinaryColorSizeSlider",
|
|
111
|
+
"ClassedColorSlider",
|
|
112
|
+
"ColorSlider",
|
|
113
|
+
"ColorSizeSlider",
|
|
114
|
+
"CoordinateConversion",
|
|
115
|
+
"Daylight",
|
|
116
|
+
"DirectLineMeasurement3D",
|
|
117
|
+
"DistanceMeasurement2D",
|
|
118
|
+
"Editor",
|
|
119
|
+
"FeatureForm",
|
|
120
|
+
"FeatureTable",
|
|
121
|
+
"GridControls",
|
|
122
|
+
"HeatmapSlider",
|
|
123
|
+
"Home",
|
|
124
|
+
"HistogramRangeSlider",
|
|
125
|
+
"LayerList",
|
|
126
|
+
"Legend",
|
|
127
|
+
"LineOfSight",
|
|
128
|
+
"Locate",
|
|
129
|
+
"NavigationToggle",
|
|
130
|
+
"OpacitySlider",
|
|
131
|
+
"OrientedImageryViewer",
|
|
132
|
+
"Print",
|
|
133
|
+
"ScaleBar",
|
|
134
|
+
"Search",
|
|
135
|
+
"Sketch",
|
|
136
|
+
"SketchLabelOptions",
|
|
137
|
+
"SketchTooltipOptions",
|
|
138
|
+
"Slice",
|
|
139
|
+
"SizeSlider",
|
|
140
|
+
"Slider",
|
|
141
|
+
"SnappingOptions",
|
|
142
|
+
"TableList",
|
|
143
|
+
"useLegacyCreateTools"
|
|
144
|
+
]);
|
|
145
|
+
function B({
|
|
146
|
+
package: e,
|
|
147
|
+
api: t,
|
|
148
|
+
category: r,
|
|
149
|
+
memberOf: i,
|
|
150
|
+
module: n,
|
|
151
|
+
reason: l
|
|
152
|
+
}) {
|
|
153
|
+
const a = e.toLowerCase(), o = l?.toLowerCase() ?? "";
|
|
154
|
+
return e === "@arcgis/core" && r === "coreViews" && $.has(t) || e === "@arcgis/core" && t === "ui" && [
|
|
155
|
+
"DOMContainer",
|
|
156
|
+
"DOMContainerProperties",
|
|
157
|
+
"MapView",
|
|
158
|
+
"MapViewProperties",
|
|
159
|
+
"SceneView",
|
|
160
|
+
"SceneViewProperties",
|
|
161
|
+
"LinkChartView",
|
|
162
|
+
"LinkChartViewProperties",
|
|
163
|
+
"VideoView",
|
|
164
|
+
"VideoViewProperties"
|
|
165
|
+
].includes(i?.replace(/^__esri\./u, "") ?? "") ? "coreViews" : e === "@arcgis/core" && (R.has(t) || o.includes("components-transition-plan")) ? "coreWidgets" : e === "@arcgis/core" && (/^(?:__esri\.)?(?:geometryEngine(?:Async)?|projection)(?:\.|$)/u.test(t) || t === "extendedSpatialReferenceInfo" || n?.startsWith("geometry/geometryEngine") || n?.startsWith("geometry/projection")) ? "coreGeometryEngine" : /\bcodemod\b/iu.test(o) ? "codemod" : e === "@arcgis/core" && (V.has(t) || o.includes("widget translations")) ? "coreIntl" : a.includes("calcite") ? "calcite" : a.startsWith("@arcgis/") && a.includes("components") ? "arcgisComponents" : e === "@arcgis/core" ? "arcgisCore" : a.startsWith("@arcgis/") ? "arcgisSupport" : k(e) ? "otherEsri" : "nonEsri";
|
|
166
|
+
}
|
|
167
|
+
function te(e, t) {
|
|
168
|
+
return x(E(e, t));
|
|
169
|
+
}
|
|
170
|
+
function x(e) {
|
|
171
|
+
return e?.replace(/^(components?\/[^/]+-[^/]+)\/customElement$/u, "$1");
|
|
172
|
+
}
|
|
173
|
+
function E(e, t) {
|
|
174
|
+
const r = `/node_modules/${t}/`, i = e.map(h).sort((n, l) => Number(l.includes(r)) - Number(n.includes(r)));
|
|
175
|
+
for (const n of i) {
|
|
176
|
+
const l = n.lastIndexOf(r);
|
|
177
|
+
if (l !== -1)
|
|
178
|
+
return n.slice(l + r.length).replace(/^(?:src|dist)\//u, "").replace(f, "");
|
|
179
|
+
const a = [...n.matchAll(/\/(?:src|dist)(?=\/)/gu)];
|
|
180
|
+
if (a.length === 1) {
|
|
181
|
+
const m = a[0];
|
|
182
|
+
return n.slice(m.index + m[0].length + 1).replace(f, "");
|
|
183
|
+
}
|
|
184
|
+
const o = S("package.json", g.dirname(n));
|
|
185
|
+
if (o === void 0)
|
|
186
|
+
continue;
|
|
187
|
+
const c = g.dirname(o);
|
|
188
|
+
if (P(c).name === t)
|
|
189
|
+
return h(g.relative(c, n)).replace(/^(?:src|dist)\//u, "").replace(f, "");
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const f = /\.(?:d\.)?(?:[cm]?ts|tsx)$/u;
|
|
193
|
+
function re(e, t) {
|
|
194
|
+
const r = Map.groupBy(e, (i) => B(t(i)));
|
|
195
|
+
return Object.keys(b).flatMap((i) => {
|
|
196
|
+
const n = r.get(i);
|
|
197
|
+
if (n === void 0)
|
|
198
|
+
return [];
|
|
199
|
+
const a = [...Map.groupBy(n, (o) => t(o).package)].map(([o, c]) => {
|
|
200
|
+
const y = [...Map.groupBy(c, (u) => {
|
|
201
|
+
const p = t(u);
|
|
202
|
+
return JSON.stringify([p.api, p.memberOf]);
|
|
203
|
+
}).values()].map((u) => {
|
|
204
|
+
const p = t(u[0]).api, v = u.map((d) => t(d).reason).filter((d) => d != null && d !== ""), D = [...new Set(v)].sort((d, M) => d.localeCompare(M));
|
|
205
|
+
return { api: p, reasons: D, items: u };
|
|
206
|
+
});
|
|
207
|
+
return y.sort((u, p) => p.items.length - u.items.length || u.api.localeCompare(p.api)), { packageName: o, count: c.length, apis: y };
|
|
208
|
+
});
|
|
209
|
+
return a.sort((o, c) => c.count - o.count || o.packageName.localeCompare(c.packageName)), [{ categoryName: i, count: n.length, packages: a }];
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
export {
|
|
213
|
+
_ as a,
|
|
214
|
+
H as b,
|
|
215
|
+
re as c,
|
|
216
|
+
te as d,
|
|
217
|
+
J as e,
|
|
218
|
+
B as f,
|
|
219
|
+
G as g,
|
|
220
|
+
U as h,
|
|
221
|
+
k as i,
|
|
222
|
+
L as j,
|
|
223
|
+
$ as k,
|
|
224
|
+
Z as l,
|
|
225
|
+
F as m,
|
|
226
|
+
ee as n,
|
|
227
|
+
Q as o,
|
|
228
|
+
K as p,
|
|
229
|
+
q,
|
|
230
|
+
X as r,
|
|
231
|
+
Y as s
|
|
232
|
+
};
|
package/dist/chunks/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ import { identity as _ } from "@arcgis/toolkit/function";
|
|
|
12
12
|
import { styleText as D } from "node:util";
|
|
13
13
|
const X = (t, e, s) => {
|
|
14
14
|
const o = t[e];
|
|
15
|
-
return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((
|
|
15
|
+
return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((r, l) => {
|
|
16
16
|
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(l.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + e + (e.split("/").length !== s ? ". Note that variables only represent file names one level deep." : ""))));
|
|
17
17
|
});
|
|
18
18
|
}, xe = {
|
|
@@ -46,21 +46,21 @@ async function Y() {
|
|
|
46
46
|
}
|
|
47
47
|
async function Z() {
|
|
48
48
|
const t = [], e = await N(".git"), s = e === void 0 ? void 0 : i.dirname(e);
|
|
49
|
-
let o,
|
|
49
|
+
let o, r = R(), l = i.dirname(r);
|
|
50
50
|
do {
|
|
51
51
|
if (o = l, s !== void 0 && o !== s && !o.startsWith(`${s}/`))
|
|
52
52
|
break;
|
|
53
53
|
const w = i.join(o, ".gitignore");
|
|
54
54
|
if (await A(w)) {
|
|
55
|
-
|
|
56
|
-
const
|
|
55
|
+
r = i.dirname(w);
|
|
56
|
+
const b = i.relative(r, R()).split("/"), v = H(w);
|
|
57
57
|
for (const p of v) {
|
|
58
|
-
const u = p.startsWith("!") ? p.slice(1) : p, h = u.search(/[*?[]/u), x = h === -1 ? u : u.slice(0, h),
|
|
58
|
+
const u = p.startsWith("!") ? p.slice(1) : p, h = u.search(/[*?[]/u), x = h === -1 ? u : u.slice(0, h), n = x.split("/"), d = h !== -1 && !x.endsWith("/");
|
|
59
59
|
let a = !0;
|
|
60
|
-
const f = Math.min(
|
|
60
|
+
const f = Math.min(b.length, n.length);
|
|
61
61
|
for (let m = 0; m < f; m++) {
|
|
62
|
-
const C =
|
|
63
|
-
if (!(d && m ===
|
|
62
|
+
const C = n[m];
|
|
63
|
+
if (!(d && m === n.length - 1 ? b[m].startsWith(C) : b[m] === C) && C !== "") {
|
|
64
64
|
a = !1;
|
|
65
65
|
break;
|
|
66
66
|
}
|
|
@@ -70,7 +70,7 @@ async function Z() {
|
|
|
70
70
|
}
|
|
71
71
|
l = i.dirname(o);
|
|
72
72
|
} while (l !== o);
|
|
73
|
-
return { ignorePatterns: t, globRoot:
|
|
73
|
+
return { ignorePatterns: t, globRoot: r };
|
|
74
74
|
}
|
|
75
75
|
async function ee(t) {
|
|
76
76
|
return (await z("**/.gitignore", {
|
|
@@ -89,15 +89,15 @@ async function ee(t) {
|
|
|
89
89
|
// Not applicable for our glob pattern
|
|
90
90
|
expandDirectories: !1
|
|
91
91
|
})).flatMap((s) => {
|
|
92
|
-
const o = i.relative(t, i.dirname(s)),
|
|
93
|
-
for (const w of
|
|
92
|
+
const o = i.relative(t, i.dirname(s)), r = H(s), l = [];
|
|
93
|
+
for (const w of r)
|
|
94
94
|
w.startsWith("!") || l.push(i.join(o, w));
|
|
95
95
|
return l;
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
const te = ["js", "jsx", "mjs", "cjs"], oe = ["ts", "tsx", "mts", "cts"], se = ["json"], ie = `**/*.{${[...te, ...oe, ...se].join(",")}}`;
|
|
99
|
-
async function
|
|
100
|
-
const e = await Y(), s = i.join(process.cwd(), ie), o = i.join(i.resolve(e.globRoot), "/"),
|
|
99
|
+
async function ne(t) {
|
|
100
|
+
const e = await Y(), s = i.join(process.cwd(), ie), o = i.join(i.resolve(e.globRoot), "/"), r = (await z(s, {
|
|
101
101
|
cwd: e.globRoot,
|
|
102
102
|
ignore: e.ignorePatterns,
|
|
103
103
|
// The files we are looking for are unlikely to be symbolic links
|
|
@@ -108,35 +108,35 @@ async function re(t) {
|
|
|
108
108
|
// default behavior). If any tsconfig.json explicitly includes such files,
|
|
109
109
|
// they will still be codemodded.
|
|
110
110
|
})).filter(
|
|
111
|
-
(
|
|
111
|
+
(n) => n.endsWith(".json") || t === void 0 || o + n === t
|
|
112
112
|
);
|
|
113
113
|
let l = i.relative(e.globRoot, process.cwd());
|
|
114
114
|
l !== "" && (l += "/");
|
|
115
|
-
const w = o.length + l.length, E = [],
|
|
116
|
-
for (const
|
|
117
|
-
const d = o +
|
|
118
|
-
if (
|
|
119
|
-
const a = i.basename(
|
|
120
|
-
a === "package.json" ? E.push(d) : (a.startsWith("tsconfig.") || a.startsWith("jsconfig.")) &&
|
|
115
|
+
const w = o.length + l.length, E = [], b = [], v = /* @__PURE__ */ new Set();
|
|
116
|
+
for (const n of r) {
|
|
117
|
+
const d = o + n;
|
|
118
|
+
if (n.endsWith(".json")) {
|
|
119
|
+
const a = i.basename(n);
|
|
120
|
+
a === "package.json" ? E.push(d) : (a.startsWith("tsconfig.") || a.startsWith("jsconfig.")) && b.push(d);
|
|
121
121
|
} else {
|
|
122
|
-
const a =
|
|
122
|
+
const a = n.slice(l.length);
|
|
123
123
|
v.add(a);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
let p = await N("tsconfig.json", i.dirname(process.cwd()));
|
|
127
|
-
p !== void 0 && (p = T(p),
|
|
128
|
-
const a = d.split("/").length -
|
|
127
|
+
p !== void 0 && (p = T(p), b.push(p)), b.sort((n, d) => {
|
|
128
|
+
const a = d.split("/").length - n.split("/").length;
|
|
129
129
|
if (a !== 0)
|
|
130
130
|
return a;
|
|
131
|
-
const f = i.basename(
|
|
131
|
+
const f = i.basename(n), m = i.basename(d);
|
|
132
132
|
return f === m ? 0 : f.endsWith("tsconfig.json") ? -1 : m.endsWith("tsconfig.json") ? 1 : f.endsWith("tsconfig.build.json") ? -1 : m.endsWith("tsconfig.build.json") ? 1 : f.localeCompare(m);
|
|
133
133
|
});
|
|
134
134
|
let u = await N("package.json");
|
|
135
135
|
u !== void 0 && (u = T(u));
|
|
136
136
|
const h = [], x = /* @__PURE__ */ new Set();
|
|
137
137
|
if (await Promise.all(
|
|
138
|
-
|
|
139
|
-
const d = i.relative(process.cwd(),
|
|
138
|
+
b.map(async (n) => {
|
|
139
|
+
const d = i.relative(process.cwd(), n), a = c.readConfigFile(n, c.sys.readFile);
|
|
140
140
|
if (a.error !== void 0) {
|
|
141
141
|
g(
|
|
142
142
|
"error",
|
|
@@ -152,11 +152,11 @@ async function re(t) {
|
|
|
152
152
|
const f = c.parseJsonConfigFileContent(
|
|
153
153
|
a.config,
|
|
154
154
|
c.sys,
|
|
155
|
-
i.dirname(
|
|
155
|
+
i.dirname(n),
|
|
156
156
|
void 0,
|
|
157
|
-
|
|
157
|
+
n
|
|
158
158
|
), m = 18003;
|
|
159
|
-
f.errors.filter((
|
|
159
|
+
f.errors.filter((y) => y.code !== m).length > 0 && g(
|
|
160
160
|
"warn",
|
|
161
161
|
d,
|
|
162
162
|
c.formatDiagnosticsWithColorAndContext(f.errors, {
|
|
@@ -165,21 +165,21 @@ async function re(t) {
|
|
|
165
165
|
getNewLine: () => c.sys.newLine
|
|
166
166
|
})
|
|
167
167
|
);
|
|
168
|
-
const M =
|
|
169
|
-
if (t !== void 0 &&
|
|
168
|
+
const M = n === p, F = f.fileNames.filter((y) => {
|
|
169
|
+
if (t !== void 0 && y !== t)
|
|
170
170
|
return !1;
|
|
171
|
-
const S =
|
|
172
|
-
return v.delete(S) ? (x.add(S), !0) : x.has(S) || S.endsWith(".json") ||
|
|
171
|
+
const S = y.slice(w);
|
|
172
|
+
return v.delete(S) ? (x.add(S), !0) : x.has(S) || S.endsWith(".json") || y.includes("node_modules") ? !1 : !M;
|
|
173
173
|
});
|
|
174
174
|
if (F.length === 0)
|
|
175
175
|
return;
|
|
176
|
-
const O = i.dirname(
|
|
176
|
+
const O = i.dirname(n);
|
|
177
177
|
let j = O, k = u;
|
|
178
178
|
for (; j === e.globRoot || // Stop searching outside repository root
|
|
179
179
|
j.startsWith(`${e.globRoot}/`); ) {
|
|
180
|
-
const
|
|
181
|
-
if (E.includes(
|
|
182
|
-
k =
|
|
180
|
+
const y = i.join(j, "package.json");
|
|
181
|
+
if (E.includes(y)) {
|
|
182
|
+
k = y;
|
|
183
183
|
break;
|
|
184
184
|
}
|
|
185
185
|
if (j === e.globRoot)
|
|
@@ -188,7 +188,7 @@ async function re(t) {
|
|
|
188
188
|
}
|
|
189
189
|
const L = k === void 0 ? void 0 : { filePath: k, contents: await $(i.dirname(k)) }, V = {
|
|
190
190
|
typeScriptConfig: {
|
|
191
|
-
filePath:
|
|
191
|
+
filePath: n,
|
|
192
192
|
compilerOptions: f.options
|
|
193
193
|
},
|
|
194
194
|
packageJson: L,
|
|
@@ -199,21 +199,21 @@ async function re(t) {
|
|
|
199
199
|
h.push(V);
|
|
200
200
|
})
|
|
201
201
|
), v.size > 0) {
|
|
202
|
-
const
|
|
202
|
+
const n = u === void 0 ? void 0 : {
|
|
203
203
|
filePath: u,
|
|
204
204
|
contents: await $(i.dirname(u))
|
|
205
205
|
};
|
|
206
206
|
h.push({
|
|
207
207
|
typeScriptConfig: void 0,
|
|
208
|
-
packageJson:
|
|
208
|
+
packageJson: n,
|
|
209
209
|
cwd: process.cwd(),
|
|
210
|
-
logName: D("blue",
|
|
210
|
+
logName: D("blue", n?.contents?.name ?? process.cwd()),
|
|
211
211
|
filePaths: Array.from(v).map((d) => i.join(process.cwd(), d))
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
|
-
return h.sort((
|
|
214
|
+
return h.sort((n, d) => n.cwd.localeCompare(d.cwd)), P.projectsData = h, h;
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function re() {
|
|
217
217
|
P.codemod.meta.needsFooter && (P.codemod.meta.needsFooter = !1, process.exitCode !== void 0 && process.exitCode !== 0 ? g(
|
|
218
218
|
"warn",
|
|
219
219
|
P.codemodName,
|
|
@@ -230,20 +230,24 @@ function ne() {
|
|
|
230
230
|
}
|
|
231
231
|
async function ae(t, e, s) {
|
|
232
232
|
P.codemod = t, P.codemodName = e;
|
|
233
|
-
const o = await
|
|
233
|
+
const o = await ne(s);
|
|
234
234
|
if (o.length === 0) {
|
|
235
235
|
g("error", e, `Failed to find any .js or .ts files in ${process.cwd()} to run the codemod on.`), process.exitCode = 1;
|
|
236
236
|
return;
|
|
237
237
|
}
|
|
238
|
-
await t.run(o),
|
|
238
|
+
await t.run(o), re();
|
|
239
239
|
}
|
|
240
240
|
const W = {
|
|
241
|
+
coreViews: {
|
|
242
|
+
label: "@arcgis/core views and UI - highest priority",
|
|
243
|
+
description: "Use map components and slots instead. Directly constructed views will no longer include .ui (like zoom buttons) in 6.0."
|
|
244
|
+
},
|
|
241
245
|
coreWidgets: {
|
|
242
246
|
label: "@arcgis/core widgets - high priority",
|
|
243
247
|
description: "WebGIS platform priority"
|
|
244
248
|
},
|
|
245
249
|
coreGeometryEngine: {
|
|
246
|
-
label: "@arcgis/core geometry engine - high priority",
|
|
250
|
+
label: "@arcgis/core geometry engine and projection - high priority",
|
|
247
251
|
description: "WebGIS platform priority"
|
|
248
252
|
},
|
|
249
253
|
codemod: {
|
|
@@ -254,7 +258,9 @@ const W = {
|
|
|
254
258
|
label: "Calcite components",
|
|
255
259
|
description: "This does not include visual breaking changes. See complete list in https://confluencewikidev.esri.com/spaces/Calcite/pages/464553094/Calcite+6.0+-+Breaking+Change+Release+February"
|
|
256
260
|
},
|
|
257
|
-
|
|
261
|
+
arcgisCore: { label: "@arcgis/core" },
|
|
262
|
+
arcgisComponents: { label: "WebGIS SDK components" },
|
|
263
|
+
arcgisSupport: { label: "WebGIS SDK support packages" },
|
|
258
264
|
otherEsri: { label: "Other Esri and ArcGIS packages" },
|
|
259
265
|
coreIntl: {
|
|
260
266
|
label: "@arcgis/core translation utils",
|
|
@@ -271,16 +277,16 @@ I.command("run").description("Run a single codemod").argument("<codemodName>", "
|
|
|
271
277
|
let o;
|
|
272
278
|
try {
|
|
273
279
|
o = await X(/* @__PURE__ */ Object.assign({ "./codemods/api-extractor-strict-mode/codemod.ts": () => import("./codemod.js"), "./codemods/geometry-operator-renames/codemod.ts": () => import("./codemod2.js"), "./codemods/lumina-component-extras-improvements/codemod.ts": () => import("./codemod3.js"), "./codemods/lumina-toolkit/codemod.ts": () => import("./codemod4.js"), "./codemods/node-toolkit/codemod.ts": () => import("./codemod5.js"), "./codemods/normalize-calcite-icon-names/codemod.ts": () => import("./codemod6.js"), "./codemods/refactor-out-esri-namespace/codemod.ts": () => import("./codemod7.js"), "./codemods/toolkit-5.2-renames/codemod.ts": () => import("./codemod8.js") }), `./codemods/${t}/codemod.ts`, 4);
|
|
274
|
-
} catch (
|
|
280
|
+
} catch (r) {
|
|
275
281
|
if (
|
|
276
282
|
// direct Node execution
|
|
277
|
-
typeof
|
|
278
|
-
String(
|
|
283
|
+
typeof r == "object" && r !== null && "code" in r && r.code === "ERR_MODULE_NOT_FOUND" && "url" in r && typeof r.url == "string" && r.url.endsWith(`/${t}/codemod.ts`) || // Vite build execution
|
|
284
|
+
String(r).includes("Unknown variable dynamic import:")
|
|
279
285
|
) {
|
|
280
286
|
g("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
281
287
|
return;
|
|
282
288
|
} else
|
|
283
|
-
throw
|
|
289
|
+
throw r;
|
|
284
290
|
}
|
|
285
291
|
if (typeof o.codemod != "object" || o.codemod === null) {
|
|
286
292
|
g("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
@@ -288,8 +294,14 @@ I.command("run").description("Run a single codemod").argument("<codemodName>", "
|
|
|
288
294
|
}
|
|
289
295
|
await ae(o.codemod, D("blue", t), s);
|
|
290
296
|
});
|
|
291
|
-
const J = I.command("deprecations").description(
|
|
292
|
-
|
|
297
|
+
const J = I.command("deprecations").description(
|
|
298
|
+
`Audit and report deprecated APIs.
|
|
299
|
+
|
|
300
|
+
Documentation: https://webgis.esri.com/references/codemod/deprecations`
|
|
301
|
+
);
|
|
302
|
+
J.command("audit-usages").description(
|
|
303
|
+
"Report deprecated API usages. Documentation: https://webgis.esri.com/references/codemod/deprecations#audit-usages"
|
|
304
|
+
).argument("[path]", "Directory to audit", process.cwd()).option("--esri-only", "Only report usages of deprecated APIs from Esri and ArcGIS packages", !1).option(
|
|
293
305
|
"--category <category>",
|
|
294
306
|
`Only report usages in a category. Available categories: ${Object.keys(W).join(", ")}`,
|
|
295
307
|
de
|
|
@@ -306,15 +318,17 @@ J.command("audit-usages").description("Report deprecated API usages").argument("
|
|
|
306
318
|
g("error", "@arcgis/codemod", "The --json and --md options cannot be used together."), process.exitCode = 1;
|
|
307
319
|
return;
|
|
308
320
|
}
|
|
309
|
-
const s = await G(t), { auditDeprecatedUsages: o } = await import("./index.js"),
|
|
321
|
+
const s = await G(t), { auditDeprecatedUsages: o } = await import("./index.js"), r = e.md ? "md" : e.json ? "json" : "text";
|
|
310
322
|
await o(s, {
|
|
311
323
|
esriOnly: e.esriOnly,
|
|
312
|
-
outputFormat:
|
|
324
|
+
outputFormat: r,
|
|
313
325
|
category: e.category,
|
|
314
326
|
packageName: e.package
|
|
315
327
|
});
|
|
316
328
|
});
|
|
317
|
-
J.command("audit-definitions").description(
|
|
329
|
+
J.command("audit-definitions").description(
|
|
330
|
+
"Report exported APIs marked as deprecated. Documentation: https://webgis.esri.com/references/codemod/deprecations#audit-definitions"
|
|
331
|
+
).argument("[path]", "Directory to audit", process.cwd()).option(
|
|
318
332
|
"--json",
|
|
319
333
|
"Output results as JSON. Example: npx @arcgis/codemod deprecations audit-definitions --json > definitions.json",
|
|
320
334
|
!1
|
|
@@ -375,6 +389,6 @@ export {
|
|
|
375
389
|
xe as a,
|
|
376
390
|
W as d,
|
|
377
391
|
P as g,
|
|
378
|
-
|
|
392
|
+
re as p,
|
|
379
393
|
ae as r
|
|
380
394
|
};
|