@arcgis/codemod 6.0.0-next.12 → 6.0.0-next.14
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/codemod5.js +0 -1
- package/dist/chunks/componentAudit.js +156 -111
- 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/cli.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { log as
|
|
2
|
-
import { Command as
|
|
3
|
-
import { stat as
|
|
4
|
-
import { path as
|
|
5
|
-
import { asyncFindPath as
|
|
1
|
+
import { log as u } from "@arcgis/toolkit/log";
|
|
2
|
+
import { Command as ae, InvalidArgumentError as R } from "@commander-js/extra-typings";
|
|
3
|
+
import { stat as X, realpath as Y } from "node:fs/promises";
|
|
4
|
+
import { path as r, getCwd as N, toPosixPathSeparators as q } from "@arcgis/node-toolkit/path";
|
|
5
|
+
import { asyncFindPath as T, existsAsync as $ } from "@arcgis/node-toolkit/file";
|
|
6
6
|
import "ts-morph";
|
|
7
7
|
import d from "typescript";
|
|
8
|
-
import { asyncRetrievePackageJson as
|
|
9
|
-
import { glob as
|
|
10
|
-
import { gitIgnoreFileToGlobs as
|
|
11
|
-
import { identity as
|
|
8
|
+
import { asyncRetrievePackageJson as ce } from "@arcgis/node-toolkit/packageJson";
|
|
9
|
+
import { glob as Z } from "tinyglobby";
|
|
10
|
+
import { gitIgnoreFileToGlobs as ee } from "@arcgis/node-toolkit/glob";
|
|
11
|
+
import { identity as H } from "@arcgis/toolkit/function";
|
|
12
12
|
import { styleText as J } from "node:util";
|
|
13
|
-
import { randomUUID as
|
|
14
|
-
const
|
|
13
|
+
import { randomUUID as de } from "node:crypto";
|
|
14
|
+
const le = (t, e, o) => {
|
|
15
15
|
const s = t[e];
|
|
16
|
-
return s ? typeof s == "function" ? s() : Promise.resolve(s) : new Promise((
|
|
16
|
+
return s ? typeof s == "function" ? s() : Promise.resolve(s) : new Promise((n, l) => {
|
|
17
17
|
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(l.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + e + (e.split("/").length !== o ? ". Note that variables only represent file names one level deep." : ""))));
|
|
18
18
|
});
|
|
19
|
-
},
|
|
19
|
+
}, Ge = {
|
|
20
20
|
allowImportingTsExtensions: !0,
|
|
21
21
|
allowJs: !0,
|
|
22
22
|
allowArbitraryExtensions: !0,
|
|
@@ -35,12 +35,12 @@ const ce = (t, e, o) => {
|
|
|
35
35
|
target: d.ScriptTarget.ESNext,
|
|
36
36
|
resolveJsonModule: !0,
|
|
37
37
|
esModuleInterop: !0
|
|
38
|
-
},
|
|
38
|
+
}, S = {
|
|
39
39
|
codemod: void 0,
|
|
40
40
|
codemodName: void 0,
|
|
41
41
|
projectsData: void 0,
|
|
42
42
|
project: void 0
|
|
43
|
-
},
|
|
43
|
+
}, te = [
|
|
44
44
|
// Hardcoded ignores in TypeScript
|
|
45
45
|
"**/node_modules/**",
|
|
46
46
|
"**/bower_components/**",
|
|
@@ -48,67 +48,71 @@ const ce = (t, e, o) => {
|
|
|
48
48
|
// Default build output folder in bundlers
|
|
49
49
|
"**/dist/**"
|
|
50
50
|
];
|
|
51
|
-
async function
|
|
52
|
-
const { ignorePatterns: t, globRoot: e, hasIgnoreFiles: o } = await
|
|
53
|
-
return t.push(...s.ignorePatterns), !o && !s.hasIgnoreFiles && t.push(...
|
|
51
|
+
async function me() {
|
|
52
|
+
const { ignorePatterns: t, globRoot: e, hasIgnoreFiles: o } = await ue(), s = await pe(e);
|
|
53
|
+
return t.push(...s.ignorePatterns), !o && !s.hasIgnoreFiles && t.push(...te), { ignorePatterns: t, globRoot: e };
|
|
54
54
|
}
|
|
55
|
-
async function
|
|
55
|
+
async function ue() {
|
|
56
56
|
const t = [];
|
|
57
57
|
let e = !1;
|
|
58
|
-
const o = await
|
|
59
|
-
let
|
|
58
|
+
const o = await T(".git"), s = o === void 0 ? void 0 : r.dirname(o);
|
|
59
|
+
let n, l = N(), f = r.dirname(l);
|
|
60
60
|
do {
|
|
61
|
-
if (
|
|
61
|
+
if (n = f, s !== void 0 && n !== s && !n.startsWith(`${s}/`))
|
|
62
62
|
break;
|
|
63
|
-
const
|
|
64
|
-
if (await
|
|
65
|
-
e = !0, l =
|
|
66
|
-
const
|
|
67
|
-
for (const
|
|
68
|
-
const
|
|
69
|
-
let
|
|
70
|
-
const
|
|
71
|
-
for (let
|
|
72
|
-
const a =
|
|
73
|
-
if (!(
|
|
74
|
-
|
|
63
|
+
const p = r.join(n, ".gitignore");
|
|
64
|
+
if (await $(p)) {
|
|
65
|
+
e = !0, l = r.dirname(p);
|
|
66
|
+
const h = r.relative(l, N()).split("/"), F = ee(p);
|
|
67
|
+
for (const w of F) {
|
|
68
|
+
const y = w.startsWith("!") ? w.slice(1) : w, b = y.search(/[*?[]/u), P = b === -1 ? y : y.slice(0, b), g = P.split("/"), C = b !== -1 && !P.endsWith("/");
|
|
69
|
+
let v = !0;
|
|
70
|
+
const I = Math.min(h.length, g.length);
|
|
71
|
+
for (let i = 0; i < I; i++) {
|
|
72
|
+
const a = g[i];
|
|
73
|
+
if (!(C && i === g.length - 1 ? h[i].startsWith(a) : h[i] === a) && a !== "") {
|
|
74
|
+
v = !1;
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
v && (w.startsWith("!") || t.push(w));
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
} while (
|
|
81
|
+
f = r.dirname(n);
|
|
82
|
+
} while (f !== n);
|
|
83
83
|
return { ignorePatterns: t, globRoot: l, hasIgnoreFiles: e };
|
|
84
84
|
}
|
|
85
|
-
async function
|
|
86
|
-
const e = await
|
|
85
|
+
async function pe(t) {
|
|
86
|
+
const e = await Z("**/.gitignore", {
|
|
87
87
|
cwd: N(),
|
|
88
88
|
// Gitignore files are unlikely to be symbolic links
|
|
89
89
|
followSymbolicLinks: !1,
|
|
90
90
|
// Don't look for ignore files in these places for speed:
|
|
91
|
-
ignore:
|
|
91
|
+
ignore: te,
|
|
92
92
|
// Not applicable for our glob pattern
|
|
93
93
|
expandDirectories: !1
|
|
94
94
|
});
|
|
95
95
|
return { ignorePatterns: e.flatMap((s) => {
|
|
96
|
-
const
|
|
97
|
-
for (const
|
|
98
|
-
|
|
99
|
-
return
|
|
96
|
+
const n = r.relative(t, r.dirname(s)), l = ee(s), f = [];
|
|
97
|
+
for (const p of l)
|
|
98
|
+
p.startsWith("!") || f.push(r.join(n, p));
|
|
99
|
+
return f;
|
|
100
100
|
}), hasIgnoreFiles: e.length > 0 };
|
|
101
101
|
}
|
|
102
|
-
const
|
|
103
|
-
async function
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
102
|
+
const oe = ["js", "jsx", "mjs", "cjs"], se = ["ts", "tsx", "mts", "cts"], ge = /* @__PURE__ */ new Set([...oe, ...se]), fe = ["json"], he = ["css", "scss", "sass", "html"];
|
|
103
|
+
async function we({
|
|
104
|
+
targetFilePath: t,
|
|
105
|
+
includeComponentFiles: e = !1,
|
|
106
|
+
includeTsConfigFiles: o = !1
|
|
107
|
+
} = {}) {
|
|
108
|
+
const s = await me(), l = `**/*.{${[
|
|
109
|
+
...oe,
|
|
110
|
+
...se,
|
|
111
|
+
...fe,
|
|
112
|
+
...e ? he : []
|
|
113
|
+
].join(",")}}`, f = r.join(process.cwd(), l), p = r.join(r.resolve(s.globRoot), "/"), U = (await Z(f, {
|
|
114
|
+
cwd: s.globRoot,
|
|
115
|
+
ignore: s.ignorePatterns,
|
|
112
116
|
// The files we are looking for are unlikely to be symbolic links
|
|
113
117
|
followSymbolicLinks: !1,
|
|
114
118
|
// Not applicable for our glob pattern
|
|
@@ -119,120 +123,127 @@ async function fe(t, e = !1) {
|
|
|
119
123
|
})).filter(
|
|
120
124
|
(i) => i.endsWith(".json") || t === void 0 || p + i === t
|
|
121
125
|
);
|
|
122
|
-
let
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
for (const i of
|
|
126
|
-
const
|
|
126
|
+
let h = r.relative(s.globRoot, process.cwd());
|
|
127
|
+
h !== "" && (h += "/");
|
|
128
|
+
const F = p.length + h.length, w = [], y = [], b = /* @__PURE__ */ new Set();
|
|
129
|
+
for (const i of U) {
|
|
130
|
+
const a = p + i;
|
|
127
131
|
if (i.endsWith(".json")) {
|
|
128
|
-
const
|
|
129
|
-
|
|
132
|
+
const c = r.basename(i);
|
|
133
|
+
c === "package.json" ? w.push(a) : (c.startsWith("tsconfig.") || c.startsWith("jsconfig.")) && y.push(a);
|
|
130
134
|
} else {
|
|
131
|
-
const
|
|
132
|
-
b.add(
|
|
135
|
+
const c = i.slice(h.length);
|
|
136
|
+
b.add(c);
|
|
133
137
|
}
|
|
134
138
|
}
|
|
135
|
-
let
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
if (
|
|
139
|
-
return
|
|
140
|
-
const
|
|
141
|
-
return
|
|
139
|
+
let P = await T("tsconfig.json", r.dirname(process.cwd()));
|
|
140
|
+
P !== void 0 && (P = q(P), y.push(P)), y.sort((i, a) => {
|
|
141
|
+
const c = a.split("/").length - i.split("/").length;
|
|
142
|
+
if (c !== 0)
|
|
143
|
+
return c;
|
|
144
|
+
const m = r.basename(i), k = r.basename(a);
|
|
145
|
+
return m === k ? 0 : m.endsWith("tsconfig.json") ? -1 : k.endsWith("tsconfig.json") ? 1 : m.endsWith("tsconfig.build.json") ? -1 : k.endsWith("tsconfig.build.json") ? 1 : m.localeCompare(k);
|
|
142
146
|
});
|
|
143
|
-
let
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
.../* @__PURE__ */ new Set([...
|
|
147
|
-
].sort((i,
|
|
147
|
+
let g = await T("package.json");
|
|
148
|
+
g !== void 0 && (g = q(g));
|
|
149
|
+
const C = [
|
|
150
|
+
.../* @__PURE__ */ new Set([...w, ...g === void 0 ? [] : [g]])
|
|
151
|
+
].sort((i, a) => a.length - i.length), v = [], I = /* @__PURE__ */ new Set();
|
|
148
152
|
if (await Promise.all(
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
+
y.map(async (i) => {
|
|
154
|
+
const a = r.relative(process.cwd(), i), c = d.readConfigFile(i, d.sys.readFile);
|
|
155
|
+
if (c.error !== void 0) {
|
|
156
|
+
u(
|
|
153
157
|
"error",
|
|
154
|
-
|
|
155
|
-
d.formatDiagnosticsWithColorAndContext([
|
|
156
|
-
getCanonicalFileName:
|
|
158
|
+
a,
|
|
159
|
+
d.formatDiagnosticsWithColorAndContext([c.error], {
|
|
160
|
+
getCanonicalFileName: H,
|
|
157
161
|
getCurrentDirectory: d.sys.getCurrentDirectory,
|
|
158
162
|
getNewLine: () => d.sys.newLine
|
|
159
163
|
})
|
|
160
164
|
);
|
|
161
165
|
return;
|
|
162
166
|
}
|
|
163
|
-
const
|
|
164
|
-
|
|
167
|
+
const m = d.parseJsonConfigFileContent(
|
|
168
|
+
c.config,
|
|
165
169
|
d.sys,
|
|
166
|
-
|
|
170
|
+
r.dirname(i),
|
|
167
171
|
void 0,
|
|
168
172
|
i
|
|
169
|
-
),
|
|
170
|
-
|
|
173
|
+
), k = 18003;
|
|
174
|
+
m.errors.filter((j) => j.code !== k).length > 0 && u(
|
|
171
175
|
"warn",
|
|
172
|
-
|
|
173
|
-
d.formatDiagnosticsWithColorAndContext(
|
|
174
|
-
getCanonicalFileName:
|
|
176
|
+
a,
|
|
177
|
+
d.formatDiagnosticsWithColorAndContext(m.errors, {
|
|
178
|
+
getCanonicalFileName: H,
|
|
175
179
|
getCurrentDirectory: d.sys.getCurrentDirectory,
|
|
176
180
|
getNewLine: () => d.sys.newLine
|
|
177
181
|
})
|
|
178
182
|
);
|
|
179
|
-
const
|
|
180
|
-
if (t !== void 0 &&
|
|
183
|
+
const L = i === P, K = m.fileNames.filter((j) => {
|
|
184
|
+
if (t !== void 0 && j !== t)
|
|
181
185
|
return !1;
|
|
182
|
-
const
|
|
183
|
-
return b.delete(
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
+
const D = j.slice(F);
|
|
187
|
+
return b.delete(D) ? (I.add(D), !0) : I.has(D) || D.endsWith(".json") || j.includes("node_modules") || L ? !1 : d.sys.fileExists(j);
|
|
188
|
+
}), ne = (
|
|
189
|
+
// Scanning tsconfig.json
|
|
190
|
+
o && // Don't include tsconfig outside the scanned scope
|
|
191
|
+
!L && // If filtering by file, ensure this tsconfig is the one being targeted
|
|
192
|
+
(t === void 0 || t === i)
|
|
193
|
+
);
|
|
194
|
+
if (K.length === 0 && !ne)
|
|
186
195
|
return;
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
await K
|
|
196
|
+
const _ = r.dirname(i), re = z(_, C) ?? g;
|
|
197
|
+
v.push(
|
|
198
|
+
await B(K, _, re, {
|
|
190
199
|
filePath: i,
|
|
191
|
-
compilerOptions:
|
|
200
|
+
compilerOptions: m.options
|
|
192
201
|
})
|
|
193
202
|
);
|
|
194
203
|
})
|
|
195
204
|
), b.size > 0) {
|
|
196
|
-
const i = [...b].map((
|
|
197
|
-
|
|
205
|
+
const i = [...b].map((c) => r.join(process.cwd(), c)), a = Map.groupBy(i, (c) => z(c, C));
|
|
206
|
+
v.push(
|
|
198
207
|
...await Promise.all(
|
|
199
|
-
[...
|
|
208
|
+
[...a].map(async ([c, m]) => await B(m, process.cwd(), c))
|
|
200
209
|
)
|
|
201
210
|
);
|
|
202
211
|
}
|
|
203
|
-
return
|
|
212
|
+
return v.sort(
|
|
213
|
+
(i, a) => i.cwd.localeCompare(a.cwd) || (i.typeScriptConfig?.filePath ?? "").localeCompare(a.typeScriptConfig?.filePath ?? "") || (i.packageJson?.filePath ?? "").localeCompare(a.packageJson?.filePath ?? "")
|
|
214
|
+
), S.projectsData = v, v;
|
|
204
215
|
}
|
|
205
|
-
function
|
|
206
|
-
const e =
|
|
207
|
-
return
|
|
216
|
+
function $e(t) {
|
|
217
|
+
const e = r.extname(t).slice(1);
|
|
218
|
+
return ge.has(e);
|
|
208
219
|
}
|
|
209
|
-
function
|
|
220
|
+
function z(t, e) {
|
|
210
221
|
return e.find((o) => {
|
|
211
|
-
const s =
|
|
222
|
+
const s = r.dirname(o);
|
|
212
223
|
return t === s || t.startsWith(`${s}/`);
|
|
213
224
|
});
|
|
214
225
|
}
|
|
215
|
-
async function
|
|
216
|
-
const
|
|
226
|
+
async function B(t, e, o, s) {
|
|
227
|
+
const n = o === void 0 ? void 0 : {
|
|
217
228
|
filePath: o,
|
|
218
|
-
contents: await
|
|
229
|
+
contents: await ce(r.dirname(o))
|
|
219
230
|
};
|
|
220
231
|
return {
|
|
221
232
|
typeScriptConfig: s,
|
|
222
|
-
packageJson:
|
|
233
|
+
packageJson: n,
|
|
223
234
|
cwd: e,
|
|
224
|
-
filePaths: t,
|
|
225
|
-
logName: J("blue",
|
|
235
|
+
filePaths: t.sort(),
|
|
236
|
+
logName: J("blue", n?.contents.name ?? e)
|
|
226
237
|
};
|
|
227
238
|
}
|
|
228
|
-
function
|
|
229
|
-
|
|
239
|
+
function ye() {
|
|
240
|
+
S.codemod.meta.needsFooter && (S.codemod.meta.needsFooter = !1, process.exitCode !== void 0 && process.exitCode !== 0 ? u(
|
|
230
241
|
"warn",
|
|
231
|
-
|
|
242
|
+
S.codemodName,
|
|
232
243
|
"One or more exceptions occurred during the codemod run. Please review the output above."
|
|
233
|
-
) :
|
|
244
|
+
) : u(
|
|
234
245
|
"info",
|
|
235
|
-
|
|
246
|
+
S.codemodName,
|
|
236
247
|
`${J("green", "Codemod completed successfully.")} Recommended next steps:
|
|
237
248
|
- Review the codemod changes.
|
|
238
249
|
- If your project uses ESLint, run ESLint autofix on the changed files.
|
|
@@ -240,17 +251,29 @@ function he() {
|
|
|
240
251
|
- If your project uses TypeScript, run type checking to ensure there are no type errors.`
|
|
241
252
|
));
|
|
242
253
|
}
|
|
243
|
-
async function
|
|
244
|
-
|
|
245
|
-
const s = await
|
|
254
|
+
async function be(t, e, o) {
|
|
255
|
+
S.codemod = t, S.codemodName = e;
|
|
256
|
+
const s = await we({
|
|
257
|
+
targetFilePath: o,
|
|
258
|
+
includeComponentFiles: t.meta.includeComponentFiles,
|
|
259
|
+
includeTsConfigFiles: t.meta.includeTsConfigFiles
|
|
260
|
+
});
|
|
246
261
|
if (s.length === 0) {
|
|
247
|
-
const
|
|
248
|
-
|
|
262
|
+
const n = t.meta.includeComponentFiles ? "source files or component manifests" : ".js or .ts files";
|
|
263
|
+
u("error", e, `Failed to find any ${n} in ${process.cwd()} to run the codemod on.`), process.exitCode = 1;
|
|
249
264
|
return;
|
|
250
265
|
}
|
|
251
|
-
await t.run(s),
|
|
266
|
+
await t.run(s), ye();
|
|
252
267
|
}
|
|
253
|
-
const
|
|
268
|
+
const O = {
|
|
269
|
+
outdatedDependencies: {
|
|
270
|
+
label: "Outdated SDK dependencies - highest priority",
|
|
271
|
+
description: "Out of date SDK packages hide APIs that may be deprecated in the most recent version."
|
|
272
|
+
},
|
|
273
|
+
mismatchedDependencies: {
|
|
274
|
+
label: "Mismatched SDK dependency versions",
|
|
275
|
+
description: "Web GIS SDK packages within the same package.json must use the same exact version - that is the only tested combination."
|
|
276
|
+
},
|
|
254
277
|
coreViews: {
|
|
255
278
|
label: "@arcgis/core views and UI - highest priority",
|
|
256
279
|
description: "Use map components and slots instead. Directly constructed views will no longer include .ui (like zoom buttons) in 6.0."
|
|
@@ -275,6 +298,10 @@ const E = {
|
|
|
275
298
|
arcgisComponents: { label: "WebGIS SDK components" },
|
|
276
299
|
arcgisSupport: { label: "WebGIS SDK support packages" },
|
|
277
300
|
otherEsri: { label: "Other Esri and ArcGIS packages" },
|
|
301
|
+
outdatedTypeScriptConfig: {
|
|
302
|
+
label: "Outdated TypeScript configuration",
|
|
303
|
+
description: "Legacy compiler settings and targets below the Web GIS SDK baseline are not supported in the ArcGIS ecosystem. They may cause incompatibilities with newer packages."
|
|
304
|
+
},
|
|
278
305
|
coreIntl: {
|
|
279
306
|
label: "@arcgis/core translation utils",
|
|
280
307
|
description: "Use https://webgis.esri.com/references/toolkit/intl instead."
|
|
@@ -283,9 +310,9 @@ const E = {
|
|
|
283
310
|
label: "Non-Esri packages and web platform - low priority",
|
|
284
311
|
description: "These deprecations do not block updating Esri packages and are not tied to an ArcGIS release."
|
|
285
312
|
}
|
|
286
|
-
},
|
|
287
|
-
async function
|
|
288
|
-
const o =
|
|
313
|
+
}, E = "https://webgis.esri.com/api/deprecations";
|
|
314
|
+
async function Je(t, e) {
|
|
315
|
+
const o = de();
|
|
289
316
|
process.stderr.write(`Submitting deprecation report (${o}).
|
|
290
317
|
`);
|
|
291
318
|
let s;
|
|
@@ -307,60 +334,63 @@ async function $e(t, e) {
|
|
|
307
334
|
}
|
|
308
335
|
if (!s.ok)
|
|
309
336
|
throw new Error(`Deprecation reporting failed: HTTP ${s.status}. Submission ID: ${o}`);
|
|
310
|
-
const
|
|
311
|
-
if (typeof
|
|
337
|
+
const n = await s.json();
|
|
338
|
+
if (typeof n != "object" || n === null || !("submissionId" in n) || n.submissionId !== o)
|
|
312
339
|
throw new Error(`Invalid collector acknowledgement. Check submission ${o} before retrying.`);
|
|
313
340
|
process.stderr.write(`Deprecation report submitted to ${e} (${o}).
|
|
314
341
|
`);
|
|
315
342
|
}
|
|
316
|
-
const
|
|
343
|
+
const Pe = /(?:esri|arcgis)/iu, W = ["all", "repositories", "apis", "unused-apis"], Me = "@arcgis/codemod", Ue = {
|
|
317
344
|
usages: "Refactor-out deprecated API usages",
|
|
318
345
|
definitions: "Remove deprecated APIs in next breaking changes release"
|
|
319
|
-
},
|
|
346
|
+
}, Le = {
|
|
320
347
|
usages: "The following deprecated APIs are used in files owned by assigned CODEOWNERS. Refactor them before the APIs are removed.",
|
|
321
348
|
definitions: "The following deprecated APIs are owned by assigned CODEOWNERS. Remove them in the next breaking changes release."
|
|
322
|
-
},
|
|
323
|
-
function
|
|
324
|
-
return
|
|
349
|
+
}, Ke = "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.", _e = "Task", qe = "deprecations sync-issues";
|
|
350
|
+
function He(t) {
|
|
351
|
+
return Pe.test(t);
|
|
325
352
|
}
|
|
326
|
-
const A = new
|
|
353
|
+
const A = new ae();
|
|
327
354
|
A.name("@arcgis/codemod").description("Codemod for migrating or refactoring usages of ArcGIS Maps SDK for JavaScript");
|
|
328
|
-
A.command("run").description("Run a single codemod").argument(
|
|
355
|
+
A.command("run").description("Run a single codemod").argument(
|
|
356
|
+
"<codemodName>",
|
|
357
|
+
"Name of the codemod. See https://www.npmjs.com/package/@arcgis/codemod for a list of available codemods"
|
|
358
|
+
).argument("[path]", "Directory to transform", process.cwd()).action(async (t, e) => {
|
|
329
359
|
const o = await M(e);
|
|
330
360
|
let s;
|
|
331
361
|
try {
|
|
332
|
-
s = await
|
|
333
|
-
} catch (
|
|
362
|
+
s = await le(/* @__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);
|
|
363
|
+
} catch (n) {
|
|
334
364
|
if (
|
|
335
365
|
// direct Node execution
|
|
336
|
-
typeof
|
|
337
|
-
String(
|
|
366
|
+
typeof n == "object" && n !== null && "code" in n && n.code === "ERR_MODULE_NOT_FOUND" && "url" in n && typeof n.url == "string" && n.url.endsWith(`/${t}/codemod.ts`) || // Vite build execution
|
|
367
|
+
String(n).includes("Unknown variable dynamic import:")
|
|
338
368
|
) {
|
|
339
|
-
|
|
369
|
+
u("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
340
370
|
return;
|
|
341
371
|
} else
|
|
342
|
-
throw
|
|
372
|
+
throw n;
|
|
343
373
|
}
|
|
344
374
|
if (typeof s.codemod != "object" || s.codemod === null) {
|
|
345
|
-
|
|
375
|
+
u("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
346
376
|
return;
|
|
347
377
|
}
|
|
348
|
-
await
|
|
378
|
+
await be(s.codemod, J("blue", t), o);
|
|
349
379
|
});
|
|
350
|
-
const
|
|
380
|
+
const x = A.command("deprecations").description(
|
|
351
381
|
`Audit and report deprecated APIs.
|
|
352
382
|
|
|
353
383
|
Documentation: https://webgis.esri.com/references/codemod/deprecations`
|
|
354
384
|
);
|
|
355
|
-
|
|
385
|
+
x.command("audit-usages").description(
|
|
356
386
|
"Report deprecated API usages. Documentation: https://webgis.esri.com/references/codemod/deprecations#audit-usages"
|
|
357
387
|
).argument("[path]", "Directory to audit", process.cwd()).option("--esri-only", "Only report usages of deprecated APIs from Esri and ArcGIS packages", !1).option(
|
|
358
388
|
"--category <category>",
|
|
359
|
-
`Only report usages in a category. Available categories: ${Object.keys(
|
|
360
|
-
|
|
389
|
+
`Only report usages in a category. Available categories: ${Object.keys(O).join(", ")}`,
|
|
390
|
+
ie
|
|
361
391
|
).option("--package <package-name>", "Only report usages of deprecated APIs from this package").option(
|
|
362
392
|
"--report [url]",
|
|
363
|
-
`Submit a complete repository scan to the WebGIS collector (default: ${
|
|
393
|
+
`Submit a complete repository scan to the WebGIS collector (default: ${E})`
|
|
364
394
|
).option(
|
|
365
395
|
"--json",
|
|
366
396
|
"Output results as JSON. Example: npx @arcgis/codemod deprecations audit-usages --json > usages.json",
|
|
@@ -371,19 +401,19 @@ C.command("audit-usages").description(
|
|
|
371
401
|
!1
|
|
372
402
|
).action(async (t, e) => {
|
|
373
403
|
if (e.json && e.md) {
|
|
374
|
-
|
|
404
|
+
u("error", "@arcgis/codemod", "The --json and --md options cannot be used together."), process.exitCode = 1;
|
|
375
405
|
return;
|
|
376
406
|
}
|
|
377
|
-
const o = await M(t), { auditDeprecatedUsages: s } = await import("./index.js"),
|
|
407
|
+
const o = await M(t), { auditDeprecatedUsages: s } = await import("./index.js"), n = e.md ? "md" : e.json ? "json" : "text";
|
|
378
408
|
await s(o, {
|
|
379
409
|
esriOnly: e.esriOnly,
|
|
380
|
-
outputFormat:
|
|
410
|
+
outputFormat: n,
|
|
381
411
|
category: e.category,
|
|
382
412
|
packageName: e.package,
|
|
383
|
-
reportingUrl: e.report === !0 ?
|
|
413
|
+
reportingUrl: e.report === !0 ? E : e.report || void 0
|
|
384
414
|
});
|
|
385
415
|
});
|
|
386
|
-
|
|
416
|
+
x.command("audit-definitions").description(
|
|
387
417
|
"Report exported APIs marked as deprecated. Documentation: https://webgis.esri.com/references/codemod/deprecations#audit-definitions"
|
|
388
418
|
).argument("[path]", "Directory to audit", process.cwd()).option(
|
|
389
419
|
"--json",
|
|
@@ -393,37 +423,37 @@ C.command("audit-definitions").description(
|
|
|
393
423
|
const o = await M(t), { auditDeprecatedDefinitions: s } = await import("./index2.js");
|
|
394
424
|
await s(o, e.json);
|
|
395
425
|
});
|
|
396
|
-
|
|
426
|
+
x.command("aggregate-usages").description(
|
|
397
427
|
"Aggregate audit-usages reports into repository summaries and an API usage tree. Documentation: https://webgis.esri.com/references/codemod/deprecations#analyze-the-ecosystem"
|
|
398
428
|
).argument("[reports...]", "Paths to audit-usages JSON files").option(
|
|
399
429
|
"--section <section>",
|
|
400
|
-
`Reports to include in the markdown report: ${
|
|
401
|
-
|
|
430
|
+
`Reports to include in the markdown report: ${W.join(", ")}`,
|
|
431
|
+
ve,
|
|
402
432
|
"all"
|
|
403
433
|
).option(
|
|
404
434
|
"--remote [url]",
|
|
405
|
-
`Read the latest stored audit per repository from the WebGIS collector (default: ${
|
|
435
|
+
`Read the latest stored audit per repository from the WebGIS collector (default: ${E})`
|
|
406
436
|
).option(
|
|
407
437
|
"--repository <repository>",
|
|
408
438
|
"Select a remote repository (host/owner/repo); repeat to select multiple",
|
|
409
|
-
|
|
439
|
+
G,
|
|
410
440
|
[]
|
|
411
|
-
).option("--branch <branch>", "Select remote audits from this branch").option("--since <date>", "Select remote audits on or after this ISO date",
|
|
441
|
+
).option("--branch <branch>", "Select remote audits from this branch").option("--since <date>", "Select remote audits on or after this ISO date", V).option("--until <date>", "Select remote audits on or before this ISO date", V).option(
|
|
412
442
|
"--definitions <report>",
|
|
413
443
|
"Compare an audit-definitions JSON report to list APIs with zero detected usages. Can be specified multiple times.",
|
|
414
|
-
|
|
444
|
+
G,
|
|
415
445
|
[]
|
|
416
446
|
).option("--esri-only", "Only report usages of deprecated APIs from Esri and ArcGIS packages", !1).option(
|
|
417
447
|
"--category <category>",
|
|
418
|
-
`Only report usages in a category. Available categories: ${Object.keys(
|
|
419
|
-
|
|
448
|
+
`Only report usages in a category. Available categories: ${Object.keys(O).join(", ")}`,
|
|
449
|
+
ie
|
|
420
450
|
).option("--package <package-name>", "Only report usages of deprecated APIs from this package").option("--json", "Output results as JSON", !1).option("--md", "Output results as Markdown", !1).action(async (t, e) => {
|
|
421
451
|
if (!t.length && !e.remote || !e.remote && (e.repository.length || e.branch || e.since || e.until))
|
|
422
452
|
throw new Error("Provide report files or --remote. Repository, branch, and date selection require --remote.");
|
|
423
453
|
if (e.since && e.until && e.since > e.until)
|
|
424
454
|
throw new Error("--since must not be after --until.");
|
|
425
455
|
if (e.json && e.md) {
|
|
426
|
-
|
|
456
|
+
u("error", "@arcgis/codemod", "The --json and --md options cannot be used together."), process.exitCode = 1;
|
|
427
457
|
return;
|
|
428
458
|
}
|
|
429
459
|
const { aggregateUsagesFromFiles: o } = await import("./index3.js");
|
|
@@ -438,7 +468,7 @@ C.command("aggregate-usages").description(
|
|
|
438
468
|
},
|
|
439
469
|
e.definitions,
|
|
440
470
|
e.remote ? {
|
|
441
|
-
url: e.remote === !0 ?
|
|
471
|
+
url: e.remote === !0 ? E : e.remote,
|
|
442
472
|
repositories: e.repository,
|
|
443
473
|
branch: e.branch,
|
|
444
474
|
since: e.since,
|
|
@@ -446,13 +476,13 @@ C.command("aggregate-usages").description(
|
|
|
446
476
|
} : void 0
|
|
447
477
|
);
|
|
448
478
|
});
|
|
449
|
-
function
|
|
450
|
-
const e =
|
|
479
|
+
function ve(t) {
|
|
480
|
+
const e = W.find((o) => o === t);
|
|
451
481
|
if (e !== void 0)
|
|
452
482
|
return e;
|
|
453
|
-
throw new
|
|
483
|
+
throw new R(`Expected one of: ${W.join(", ")}.`);
|
|
454
484
|
}
|
|
455
|
-
|
|
485
|
+
x.command("sync-issues").description(
|
|
456
486
|
`Create or update deprecation audit issues. Requires authenticated gh cli.
|
|
457
487
|
|
|
458
488
|
Existing open issues are updated if out of date (matched by title and invisible comment inside).
|
|
@@ -460,70 +490,70 @@ Otherwise, a new issue is created. Assignees are determined based on CODEOWNERS.
|
|
|
460
490
|
).argument(
|
|
461
491
|
"<audit-json>",
|
|
462
492
|
"Path to the JSON file as output by the --json flag in the audit-usages or audit-definitions CLI"
|
|
463
|
-
).option("--dry-run", "Print planned issue and comment changes without changing GitHub", !1).option("--close-resolved", "Close stale managed issues after a complete, unfiltered repository-root audit", !1).option("--offset <number>", "Skip the first number of issue plans",
|
|
493
|
+
).option("--dry-run", "Print planned issue and comment changes without changing GitHub", !1).option("--close-resolved", "Close stale managed issues after a complete, unfiltered repository-root audit", !1).option("--offset <number>", "Skip the first number of issue plans", Q, 0).option("--limit <number>", "Process at most this many issue plans", Q).option(
|
|
464
494
|
"--label <label>",
|
|
465
495
|
"Label to add to newly created issues. Can be specified multiple times.",
|
|
466
|
-
|
|
496
|
+
G,
|
|
467
497
|
[]
|
|
468
498
|
).action(async (t, e) => {
|
|
469
|
-
const o =
|
|
470
|
-
if (!await
|
|
471
|
-
|
|
499
|
+
const o = r.resolve(t);
|
|
500
|
+
if (!await $(o) || !(await X(o)).isFile()) {
|
|
501
|
+
u("error", "@arcgis/codemod", `Failed to find the audit JSON file: ${t}`), process.exitCode = 1;
|
|
472
502
|
return;
|
|
473
503
|
}
|
|
474
504
|
const { syncDeprecationIssues: s } = await import("./sync.js");
|
|
475
|
-
await s(await
|
|
505
|
+
await s(await Y(o), e.dryRun, e.offset, e.limit, {
|
|
476
506
|
labels: e.label,
|
|
477
507
|
closeResolved: e.closeResolved
|
|
478
508
|
});
|
|
479
509
|
});
|
|
480
|
-
function
|
|
510
|
+
function V(t) {
|
|
481
511
|
const e = new Date(t);
|
|
482
512
|
if (!Number.isFinite(e.getTime()))
|
|
483
|
-
throw new
|
|
513
|
+
throw new R("Expected an ISO date.");
|
|
484
514
|
return e.toISOString();
|
|
485
515
|
}
|
|
486
|
-
function
|
|
516
|
+
function G(t, e) {
|
|
487
517
|
return [...e, t];
|
|
488
518
|
}
|
|
489
|
-
function
|
|
519
|
+
function Q(t) {
|
|
490
520
|
const e = Number(t);
|
|
491
521
|
if (!Number.isSafeInteger(e) || e < 0)
|
|
492
|
-
throw new
|
|
522
|
+
throw new R("Expected a non-negative integer.");
|
|
493
523
|
return e;
|
|
494
524
|
}
|
|
495
|
-
function
|
|
496
|
-
if (!Object.hasOwn(
|
|
497
|
-
throw new
|
|
525
|
+
function ie(t) {
|
|
526
|
+
if (!Object.hasOwn(O, t))
|
|
527
|
+
throw new R(`Expected one of: ${Object.keys(O).join(", ")}.`);
|
|
498
528
|
return t;
|
|
499
529
|
}
|
|
500
530
|
async function M(t) {
|
|
501
|
-
const e =
|
|
502
|
-
await
|
|
503
|
-
const o = await
|
|
504
|
-
return process.chdir(s ?
|
|
531
|
+
const e = r.resolve(t);
|
|
532
|
+
await $(e) || (u("error", "@arcgis/codemod", `Failed to find the target path: ${t}`), process.exit(1));
|
|
533
|
+
const o = await Y(e), s = (await X(o)).isFile();
|
|
534
|
+
return process.chdir(s ? r.dirname(o) : o), s ? o : void 0;
|
|
505
535
|
}
|
|
506
|
-
|
|
536
|
+
x.command("sync-markdown").description(
|
|
507
537
|
"Update managed Markdown comments on an existing issue, leaving its body untouched. Requires authenticated gh cli."
|
|
508
538
|
).argument("<markdown-file>", "Path to the Markdown report").requiredOption("--issue <url>", "HTTPS URL of the existing GitHub issue").option("--dry-run", "Print planned comment changes without changing GitHub", !1).action(async (t, e) => {
|
|
509
539
|
const { syncMarkdown: o } = await import("./syncMarkdown.js");
|
|
510
|
-
await o(
|
|
540
|
+
await o(r.resolve(t), e.issue, e.dryRun);
|
|
511
541
|
});
|
|
512
542
|
A.parse();
|
|
513
543
|
export {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
544
|
+
Je as a,
|
|
545
|
+
He as b,
|
|
546
|
+
Ge as c,
|
|
547
|
+
O as d,
|
|
548
|
+
E as e,
|
|
549
|
+
qe as f,
|
|
550
|
+
S as g,
|
|
551
|
+
Ue as h,
|
|
552
|
+
$e as i,
|
|
553
|
+
_e as j,
|
|
554
|
+
Me as k,
|
|
555
|
+
Le as l,
|
|
556
|
+
Ke as m,
|
|
557
|
+
ye as p,
|
|
558
|
+
be as r
|
|
529
559
|
};
|