@arcgis/codemod 6.0.0-next.30 → 6.0.0-next.31
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 +146 -94
- package/dist/chunks/cli.js +181 -180
- package/dist/chunks/componentAudit.js +115 -101
- package/dist/chunks/format.js +94 -70
- package/dist/chunks/index.js +857 -693
- package/dist/chunks/index2.js +109 -109
- package/dist/chunks/index3.js +48 -39
- package/dist/chunks/legacyCompatibility.js +210 -0
- package/dist/chunks/sync.js +143 -41
- package/dist/chunks/syncMarkdown.js +28 -18
- package/package.json +5 -4
- package/dist/chunks/artifact.js +0 -48
- package/dist/chunks/github.js +0 -124
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 r, getCwd as
|
|
5
|
-
import { asyncFindPath as
|
|
1
|
+
import { log as m } from "@arcgis/toolkit/log";
|
|
2
|
+
import { Command as de, InvalidArgumentError as F } from "@commander-js/extra-typings";
|
|
3
|
+
import { stat as Y, realpath as Z } from "node:fs/promises";
|
|
4
|
+
import { path as r, getCwd as W, toPosixPathSeparators as q } from "@arcgis/node-toolkit/path";
|
|
5
|
+
import { asyncFindPath as $, existsAsync as J } 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
|
|
12
|
-
import { styleText as
|
|
13
|
-
import { randomUUID as
|
|
14
|
-
const
|
|
8
|
+
import { asyncRetrievePackageJson as le } from "@arcgis/node-toolkit/packageJson";
|
|
9
|
+
import { glob as ee } from "tinyglobby";
|
|
10
|
+
import { gitIgnoreFileToGlobs as te } from "@arcgis/node-toolkit/glob";
|
|
11
|
+
import { identity as z } from "@arcgis/toolkit/function";
|
|
12
|
+
import { styleText as M } from "node:util";
|
|
13
|
+
import { randomUUID as ue } from "node:crypto";
|
|
14
|
+
const me = (t, e, o) => {
|
|
15
15
|
const s = t[e];
|
|
16
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
|
+
}, Me = {
|
|
20
20
|
allowImportingTsExtensions: !0,
|
|
21
21
|
allowJs: !0,
|
|
22
22
|
allowArbitraryExtensions: !0,
|
|
@@ -35,12 +35,12 @@ const le = (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,
|
|
42
42
|
project: void 0
|
|
43
|
-
},
|
|
43
|
+
}, oe = [
|
|
44
44
|
// Hardcoded ignores in TypeScript
|
|
45
45
|
"**/node_modules/**",
|
|
46
46
|
"**/bower_components/**",
|
|
@@ -48,69 +48,69 @@ const le = (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 pe() {
|
|
52
|
+
const { ignorePatterns: t, globRoot: e, hasIgnoreFiles: o } = await ge(), s = await fe(e);
|
|
53
|
+
return t.push(...s.ignorePatterns), !o && !s.hasIgnoreFiles && t.push(...oe), { ignorePatterns: t, globRoot: e };
|
|
54
54
|
}
|
|
55
|
-
async function
|
|
55
|
+
async function ge() {
|
|
56
56
|
const t = [];
|
|
57
57
|
let e = !1;
|
|
58
|
-
const o = await
|
|
59
|
-
let n, l =
|
|
58
|
+
const o = await $(".git"), s = o === void 0 ? void 0 : r.dirname(o);
|
|
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 J(p)) {
|
|
65
65
|
e = !0, l = r.dirname(p);
|
|
66
|
-
const h = r.relative(l,
|
|
67
|
-
for (const
|
|
68
|
-
const
|
|
69
|
-
let
|
|
70
|
-
const
|
|
71
|
-
for (let i = 0; i <
|
|
66
|
+
const h = r.relative(l, W()).split("/"), T = te(p);
|
|
67
|
+
for (const b of T) {
|
|
68
|
+
const w = b.startsWith("!") ? b.slice(1) : b, y = w.search(/[*?[]/u), P = y === -1 ? w : w.slice(0, y), g = P.split("/"), I = y !== -1 && !P.endsWith("/");
|
|
69
|
+
let x = !0;
|
|
70
|
+
const D = Math.min(h.length, g.length);
|
|
71
|
+
for (let i = 0; i < D; i++) {
|
|
72
72
|
const a = g[i];
|
|
73
|
-
if (!(
|
|
74
|
-
|
|
73
|
+
if (!(I && i === g.length - 1 ? h[i].startsWith(a) : h[i] === a) && a !== "") {
|
|
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);
|
|
82
82
|
} while (f !== n);
|
|
83
83
|
return { ignorePatterns: t, globRoot: l, hasIgnoreFiles: e };
|
|
84
84
|
}
|
|
85
|
-
async function
|
|
86
|
-
const e = await
|
|
87
|
-
cwd:
|
|
85
|
+
async function fe(t) {
|
|
86
|
+
const e = await ee("**/.gitignore", {
|
|
87
|
+
cwd: W(),
|
|
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: oe,
|
|
92
92
|
// Not applicable for our glob pattern
|
|
93
93
|
expandDirectories: !1
|
|
94
94
|
});
|
|
95
95
|
return { ignorePatterns: e.flatMap((s) => {
|
|
96
|
-
const n = r.relative(t, r.dirname(s)), l =
|
|
96
|
+
const n = r.relative(t, r.dirname(s)), l = te(s), f = [];
|
|
97
97
|
for (const p of l)
|
|
98
98
|
p.startsWith("!") || f.push(r.join(n, p));
|
|
99
99
|
return f;
|
|
100
100
|
}), hasIgnoreFiles: e.length > 0 };
|
|
101
101
|
}
|
|
102
|
-
const
|
|
103
|
-
async function
|
|
102
|
+
const se = ["js", "jsx", "mjs", "cjs"], ie = ["ts", "tsx", "mts", "cts"], he = /* @__PURE__ */ new Set([...se, ...ie]), be = ["json"], we = ["css", "scss", "sass", "html"];
|
|
103
|
+
async function ye({
|
|
104
104
|
targetFilePath: t,
|
|
105
105
|
includeComponentFiles: e = !1,
|
|
106
106
|
includeTsConfigFiles: o = !1
|
|
107
107
|
} = {}) {
|
|
108
|
-
const s = await
|
|
109
|
-
...oe,
|
|
108
|
+
const s = await pe(), l = `**/*.{${[
|
|
110
109
|
...se,
|
|
111
|
-
...
|
|
112
|
-
...
|
|
113
|
-
|
|
110
|
+
...ie,
|
|
111
|
+
...be,
|
|
112
|
+
...e ? we : []
|
|
113
|
+
].join(",")}}`, f = r.join(process.cwd(), l), p = r.join(r.resolve(s.globRoot), "/"), L = (await ee(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
|
|
@@ -125,147 +125,147 @@ async function we({
|
|
|
125
125
|
);
|
|
126
126
|
let h = r.relative(s.globRoot, process.cwd());
|
|
127
127
|
h !== "" && (h += "/");
|
|
128
|
-
const
|
|
129
|
-
for (const i of
|
|
128
|
+
const T = p.length + h.length, b = [], w = [], y = /* @__PURE__ */ new Set();
|
|
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);
|
|
133
|
-
c === "package.json" ?
|
|
133
|
+
c === "package.json" ? b.push(a) : (c.startsWith("tsconfig.") || c.startsWith("jsconfig.")) && w.push(a);
|
|
134
134
|
} else {
|
|
135
135
|
const c = i.slice(h.length);
|
|
136
|
-
|
|
136
|
+
y.add(c);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
let P = await
|
|
140
|
-
P !== void 0 && (P = q(P),
|
|
139
|
+
let P = await $("tsconfig.json", r.dirname(process.cwd()));
|
|
140
|
+
P !== void 0 && (P = q(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
|
-
const
|
|
145
|
-
return
|
|
144
|
+
const u = r.basename(i), S = r.basename(a);
|
|
145
|
+
return u === S ? 0 : u.endsWith("tsconfig.json") ? -1 : S.endsWith("tsconfig.json") ? 1 : u.endsWith("tsconfig.build.json") ? -1 : S.endsWith("tsconfig.build.json") ? 1 : u.localeCompare(S);
|
|
146
146
|
});
|
|
147
|
-
let g = await
|
|
147
|
+
let g = await $("package.json");
|
|
148
148
|
g !== void 0 && (g = q(g));
|
|
149
|
-
const
|
|
150
|
-
.../* @__PURE__ */ new Set([...
|
|
151
|
-
].sort((i, a) => a.length - i.length),
|
|
149
|
+
const I = [
|
|
150
|
+
.../* @__PURE__ */ new Set([...b, ...g === void 0 ? [] : [g]])
|
|
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);
|
|
155
155
|
if (c.error !== void 0) {
|
|
156
|
-
|
|
156
|
+
m(
|
|
157
157
|
"error",
|
|
158
158
|
a,
|
|
159
159
|
d.formatDiagnosticsWithColorAndContext([c.error], {
|
|
160
|
-
getCanonicalFileName:
|
|
160
|
+
getCanonicalFileName: z,
|
|
161
161
|
getCurrentDirectory: d.sys.getCurrentDirectory,
|
|
162
162
|
getNewLine: () => d.sys.newLine
|
|
163
163
|
})
|
|
164
164
|
);
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
|
-
const
|
|
167
|
+
const u = d.parseJsonConfigFileContent(
|
|
168
168
|
c.config,
|
|
169
169
|
d.sys,
|
|
170
170
|
r.dirname(i),
|
|
171
171
|
void 0,
|
|
172
172
|
i
|
|
173
|
-
),
|
|
174
|
-
|
|
173
|
+
), S = 18003;
|
|
174
|
+
u.errors.filter((k) => k.code !== S).length > 0 && m(
|
|
175
175
|
"warn",
|
|
176
176
|
a,
|
|
177
|
-
d.formatDiagnosticsWithColorAndContext(
|
|
178
|
-
getCanonicalFileName:
|
|
177
|
+
d.formatDiagnosticsWithColorAndContext(u.errors, {
|
|
178
|
+
getCanonicalFileName: z,
|
|
179
179
|
getCurrentDirectory: d.sys.getCurrentDirectory,
|
|
180
180
|
getNewLine: () => d.sys.newLine
|
|
181
181
|
})
|
|
182
182
|
);
|
|
183
|
-
const
|
|
184
|
-
if (t !== void 0 &&
|
|
183
|
+
const K = i === P, _ = u.fileNames.filter((k) => {
|
|
184
|
+
if (t !== void 0 && k !== t)
|
|
185
185
|
return !1;
|
|
186
|
-
const
|
|
187
|
-
return
|
|
188
|
-
}),
|
|
186
|
+
const E = k.slice(T);
|
|
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
|
+
}), ae = (
|
|
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 && !ae)
|
|
195
195
|
return;
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
await
|
|
196
|
+
const H = r.dirname(i), ce = B(H, I) ?? g;
|
|
197
|
+
x.push(
|
|
198
|
+
await V(_, H, ce, {
|
|
199
199
|
filePath: i,
|
|
200
|
-
compilerOptions:
|
|
200
|
+
compilerOptions: u.options
|
|
201
201
|
})
|
|
202
202
|
);
|
|
203
203
|
})
|
|
204
|
-
),
|
|
205
|
-
const i = [...
|
|
206
|
-
|
|
204
|
+
), y.size > 0) {
|
|
205
|
+
const i = [...y].map((c) => r.join(process.cwd(), c)), a = Map.groupBy(i, (c) => B(c, I));
|
|
206
|
+
x.push(
|
|
207
207
|
...await Promise.all(
|
|
208
|
-
[...a].map(async ([c,
|
|
208
|
+
[...a].map(async ([c, u]) => await V(u, 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
|
-
function
|
|
216
|
+
function Ue(t) {
|
|
217
217
|
const e = r.extname(t).slice(1);
|
|
218
|
-
return
|
|
218
|
+
return he.has(e);
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function B(t, e) {
|
|
221
221
|
return e.find((o) => {
|
|
222
222
|
const s = r.dirname(o);
|
|
223
223
|
return t === s || t.startsWith(`${s}/`);
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
|
-
async function
|
|
226
|
+
async function V(t, e, o, s) {
|
|
227
227
|
const n = o === void 0 ? void 0 : {
|
|
228
228
|
filePath: o,
|
|
229
|
-
contents: await
|
|
229
|
+
contents: await le(r.dirname(o))
|
|
230
230
|
};
|
|
231
231
|
return {
|
|
232
232
|
typeScriptConfig: s,
|
|
233
233
|
packageJson: n,
|
|
234
234
|
cwd: e,
|
|
235
235
|
filePaths: t.sort(),
|
|
236
|
-
logName:
|
|
236
|
+
logName: M("blue", n?.contents.name ?? e)
|
|
237
237
|
};
|
|
238
238
|
}
|
|
239
|
-
function
|
|
240
|
-
|
|
239
|
+
function Pe() {
|
|
240
|
+
v.codemod.meta.needsFooter && (v.codemod.meta.needsFooter = !1, process.exitCode !== void 0 && process.exitCode !== 0 ? m(
|
|
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
|
+
) : m(
|
|
245
245
|
"info",
|
|
246
|
-
|
|
247
|
-
`${
|
|
246
|
+
v.codemodName,
|
|
247
|
+
`${M("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.
|
|
251
251
|
- If your project uses TypeScript, run type checking to ensure there are no type errors.`
|
|
252
252
|
));
|
|
253
253
|
}
|
|
254
|
-
async function
|
|
255
|
-
|
|
256
|
-
const s = await
|
|
254
|
+
async function xe(t, e, o) {
|
|
255
|
+
v.codemod = t, v.codemodName = e;
|
|
256
|
+
const s = await ye({
|
|
257
257
|
targetFilePath: o,
|
|
258
258
|
includeComponentFiles: t.meta.includeComponentFiles,
|
|
259
259
|
includeTsConfigFiles: t.meta.includeTsConfigFiles
|
|
260
260
|
});
|
|
261
261
|
if (s.length === 0) {
|
|
262
262
|
const n = t.meta.includeComponentFiles ? "source files or component manifests" : ".js or .ts files";
|
|
263
|
-
|
|
263
|
+
m("error", e, `Failed to find any ${n} in ${process.cwd()} to run the codemod on.`), process.exitCode = 1;
|
|
264
264
|
return;
|
|
265
265
|
}
|
|
266
|
-
await t.run(s),
|
|
266
|
+
await t.run(s), Pe();
|
|
267
267
|
}
|
|
268
|
-
const
|
|
268
|
+
const R = {
|
|
269
269
|
outdatedDependencies: {
|
|
270
270
|
label: "Outdated SDK dependencies - highest priority",
|
|
271
271
|
description: "Out of date SDK packages hide APIs that may be deprecated in the most recent version."
|
|
@@ -288,7 +288,7 @@ const O = {
|
|
|
288
288
|
},
|
|
289
289
|
codemod: {
|
|
290
290
|
label: "Codemod available - quick fix",
|
|
291
|
-
description: "A codemod is available to automate these migrations."
|
|
291
|
+
description: "A codemod is available to automate these migrations. See https://webgis.esri.com/references/codemod/introduction."
|
|
292
292
|
},
|
|
293
293
|
calcite: {
|
|
294
294
|
label: "Calcite design system",
|
|
@@ -310,9 +310,9 @@ const O = {
|
|
|
310
310
|
label: "Non-Esri packages and web platform - low priority",
|
|
311
311
|
description: "These deprecations do not block updating Esri packages and are not tied to an ArcGIS release."
|
|
312
312
|
}
|
|
313
|
-
},
|
|
314
|
-
async function
|
|
315
|
-
const o =
|
|
313
|
+
}, A = "https://webgis.esri.com/api/deprecations";
|
|
314
|
+
async function Le(t, e) {
|
|
315
|
+
const o = ue();
|
|
316
316
|
process.stderr.write(`Submitting deprecation report (${o}).
|
|
317
317
|
`);
|
|
318
318
|
let s;
|
|
@@ -340,57 +340,57 @@ async function Je(t, e) {
|
|
|
340
340
|
process.stderr.write(`Deprecation report submitted to ${e} (${o}).
|
|
341
341
|
`);
|
|
342
342
|
}
|
|
343
|
-
const
|
|
343
|
+
const ve = /(?:esri|arcgis)/iu, Se = ["/.astro/"], G = ["all", "repositories", "apis", "unused-apis"], Ke = {
|
|
344
344
|
usages: "Refactor-out deprecated API usages",
|
|
345
345
|
definitions: "Remove deprecated APIs in next breaking changes release"
|
|
346
|
-
},
|
|
346
|
+
}, _e = {
|
|
347
347
|
usages: "The following deprecated APIs are used in files owned by assigned CODEOWNERS. Refactor them before the APIs are removed.",
|
|
348
348
|
definitions: "The following deprecated APIs are owned by assigned CODEOWNERS. Remove them in the next breaking changes release."
|
|
349
|
-
},
|
|
350
|
-
function
|
|
351
|
-
return
|
|
349
|
+
}, 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";
|
|
350
|
+
function Be(t) {
|
|
351
|
+
return ve.test(t);
|
|
352
352
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
).argument("[path]", "Directory to transform", process.cwd()).action(async (t, e) => {
|
|
359
|
-
const o = await
|
|
353
|
+
function Ve(t) {
|
|
354
|
+
return Se.some((e) => `/${t}`.includes(e));
|
|
355
|
+
}
|
|
356
|
+
const N = new de(), 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.";
|
|
357
|
+
N.name("@arcgis/codemod").description("Codemod for migrating or refactoring usages of ArcGIS Maps SDK for JavaScript");
|
|
358
|
+
N.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) => {
|
|
359
|
+
const o = await U(e);
|
|
360
360
|
let s;
|
|
361
361
|
try {
|
|
362
|
-
s = await
|
|
362
|
+
s = await me(/* @__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
363
|
} catch (n) {
|
|
364
364
|
if (
|
|
365
365
|
// direct Node execution
|
|
366
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
367
|
String(n).includes("Unknown variable dynamic import:")
|
|
368
368
|
) {
|
|
369
|
-
|
|
369
|
+
m("error", "@arcgis/codemod", `Can't find codemod by name "${t}". ${O}`), process.exitCode = 1;
|
|
370
370
|
return;
|
|
371
371
|
} else
|
|
372
372
|
throw n;
|
|
373
373
|
}
|
|
374
374
|
if (typeof s.codemod != "object" || s.codemod === null) {
|
|
375
|
-
|
|
375
|
+
m("error", "@arcgis/codemod", `Can't find codemod by name "${t}". ${O}`), process.exitCode = 1;
|
|
376
376
|
return;
|
|
377
377
|
}
|
|
378
|
-
await
|
|
378
|
+
await xe(s.codemod, M("blue", t), o);
|
|
379
379
|
});
|
|
380
|
-
const
|
|
380
|
+
const C = N.command("deprecations").description(
|
|
381
381
|
`Audit and report deprecated APIs.
|
|
382
382
|
|
|
383
383
|
Documentation: https://webgis.esri.com/references/codemod/deprecations`
|
|
384
|
-
);
|
|
385
|
-
|
|
384
|
+
), ne = "Globs to exclude from the scan (relative to cwd). Example: deprecated-package/**. Can provide --exclude multiple times. Use this sparingly. Use cases: deprecated packages, unmaintained test apps";
|
|
385
|
+
C.command("audit-usages").description(
|
|
386
386
|
"Report deprecated API usages. Documentation: https://webgis.esri.com/references/codemod/deprecations#audit-usages"
|
|
387
|
-
).argument("[path]", "Directory to audit", process.cwd()).option("--esri-only", "Only report usages of deprecated APIs from Esri and ArcGIS packages", !1).option(
|
|
387
|
+
).argument("[path]", "Directory to audit", process.cwd()).option("--exclude <glob>", ne, j, []).option("--esri-only", "Only report usages of deprecated APIs from Esri and ArcGIS packages", !1).option(
|
|
388
388
|
"--category <category>",
|
|
389
|
-
`Only report usages in a category. Available categories: ${Object.keys(
|
|
390
|
-
|
|
389
|
+
`Only report usages in a category. Available categories: ${Object.keys(R).join(", ")}`,
|
|
390
|
+
re
|
|
391
391
|
).option("--package <package-name>", "Only report usages of deprecated APIs from this package").option(
|
|
392
392
|
"--report [url]",
|
|
393
|
-
`Submit a complete repository scan to the WebGIS collector (default: ${
|
|
393
|
+
`Submit a complete repository scan to the WebGIS collector (default: ${A})`
|
|
394
394
|
).option(
|
|
395
395
|
"--json",
|
|
396
396
|
"Output results as JSON. Example: npx @arcgis/codemod deprecations audit-usages --json > usages.json",
|
|
@@ -401,59 +401,60 @@ x.command("audit-usages").description(
|
|
|
401
401
|
!1
|
|
402
402
|
).action(async (t, e) => {
|
|
403
403
|
if (e.json && e.md) {
|
|
404
|
-
|
|
404
|
+
m("error", "@arcgis/codemod", "The --json and --md options cannot be used together."), process.exitCode = 1;
|
|
405
405
|
return;
|
|
406
406
|
}
|
|
407
|
-
const o = await
|
|
407
|
+
const o = await U(t), { auditDeprecatedUsages: s } = await import("./index.js"), n = e.md ? "md" : e.json ? "json" : "text";
|
|
408
408
|
await s(o, {
|
|
409
409
|
esriOnly: e.esriOnly,
|
|
410
410
|
outputFormat: n,
|
|
411
411
|
category: e.category,
|
|
412
412
|
packageName: e.package,
|
|
413
|
-
|
|
413
|
+
exclude: e.exclude,
|
|
414
|
+
reportingUrl: e.report === !0 ? A : e.report || void 0
|
|
414
415
|
});
|
|
415
416
|
});
|
|
416
|
-
|
|
417
|
+
C.command("audit-definitions").description(
|
|
417
418
|
"Report exported APIs marked as deprecated. Documentation: https://webgis.esri.com/references/codemod/deprecations#audit-definitions"
|
|
418
|
-
).argument("[path]", "Directory to audit", process.cwd()).option(
|
|
419
|
+
).argument("[path]", "Directory to audit", process.cwd()).option("--exclude <glob>", ne, j, []).option(
|
|
419
420
|
"--json",
|
|
420
421
|
"Output results as JSON. Example: npx @arcgis/codemod deprecations audit-definitions --json > definitions.json",
|
|
421
422
|
!1
|
|
422
423
|
).action(async (t, e) => {
|
|
423
|
-
const o = await
|
|
424
|
-
await s(o, e.json);
|
|
424
|
+
const o = await U(t), { auditDeprecatedDefinitions: s } = await import("./index2.js");
|
|
425
|
+
await s(o, e.json, e.exclude);
|
|
425
426
|
});
|
|
426
|
-
|
|
427
|
+
C.command("aggregate-usages").description(
|
|
427
428
|
"Aggregate audit-usages reports into repository summaries and an API usage tree. Documentation: https://webgis.esri.com/references/codemod/deprecations#analyze-the-ecosystem"
|
|
428
429
|
).argument("[reports...]", "Paths to audit-usages JSON files").option(
|
|
429
430
|
"--section <section>",
|
|
430
|
-
`Reports to include in the markdown report: ${
|
|
431
|
-
|
|
431
|
+
`Reports to include in the markdown report: ${G.join(", ")}`,
|
|
432
|
+
ke,
|
|
432
433
|
"all"
|
|
433
434
|
).option(
|
|
434
435
|
"--remote [url]",
|
|
435
|
-
`Read the latest stored audit per repository from the WebGIS collector (default: ${
|
|
436
|
+
`Read the latest stored audit per repository from the WebGIS collector (default: ${A})`
|
|
436
437
|
).option(
|
|
437
438
|
"--repository <repository>",
|
|
438
439
|
"Select a remote repository (host/owner/repo); repeat to select multiple",
|
|
439
|
-
|
|
440
|
+
j,
|
|
440
441
|
[]
|
|
441
|
-
).option("--branch <branch>", "Select remote audits from this branch").option("--since <date>", "Select remote audits on or after this ISO date",
|
|
442
|
+
).option("--branch <branch>", "Select remote audits from this branch").option("--since <date>", "Select remote audits on or after this ISO date", Q).option("--until <date>", "Select remote audits on or before this ISO date", Q).option(
|
|
442
443
|
"--definitions <report>",
|
|
443
444
|
"Compare an audit-definitions JSON report to list APIs with zero detected usages. Can be specified multiple times.",
|
|
444
|
-
|
|
445
|
+
j,
|
|
445
446
|
[]
|
|
446
447
|
).option("--esri-only", "Only report usages of deprecated APIs from Esri and ArcGIS packages", !1).option(
|
|
447
448
|
"--category <category>",
|
|
448
|
-
`Only report usages in a category. Available categories: ${Object.keys(
|
|
449
|
-
|
|
449
|
+
`Only report usages in a category. Available categories: ${Object.keys(R).join(", ")}`,
|
|
450
|
+
re
|
|
450
451
|
).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) => {
|
|
451
452
|
if (!t.length && !e.remote || !e.remote && (e.repository.length || e.branch || e.since || e.until))
|
|
452
453
|
throw new Error("Provide report files or --remote. Repository, branch, and date selection require --remote.");
|
|
453
454
|
if (e.since && e.until && e.since > e.until)
|
|
454
455
|
throw new Error("--since must not be after --until.");
|
|
455
456
|
if (e.json && e.md) {
|
|
456
|
-
|
|
457
|
+
m("error", "@arcgis/codemod", "The --json and --md options cannot be used together."), process.exitCode = 1;
|
|
457
458
|
return;
|
|
458
459
|
}
|
|
459
460
|
const { aggregateUsagesFromFiles: o } = await import("./index3.js");
|
|
@@ -468,7 +469,7 @@ x.command("aggregate-usages").description(
|
|
|
468
469
|
},
|
|
469
470
|
e.definitions,
|
|
470
471
|
e.remote ? {
|
|
471
|
-
url: e.remote === !0 ?
|
|
472
|
+
url: e.remote === !0 ? A : e.remote,
|
|
472
473
|
repositories: e.repository,
|
|
473
474
|
branch: e.branch,
|
|
474
475
|
since: e.since,
|
|
@@ -476,13 +477,13 @@ x.command("aggregate-usages").description(
|
|
|
476
477
|
} : void 0
|
|
477
478
|
);
|
|
478
479
|
});
|
|
479
|
-
function
|
|
480
|
-
const e =
|
|
480
|
+
function ke(t) {
|
|
481
|
+
const e = G.find((o) => o === t);
|
|
481
482
|
if (e !== void 0)
|
|
482
483
|
return e;
|
|
483
|
-
throw new
|
|
484
|
+
throw new F(`Expected one of: ${G.join(", ")}.`);
|
|
484
485
|
}
|
|
485
|
-
|
|
486
|
+
C.command("sync-issues").description(
|
|
486
487
|
`Create or update deprecation audit issues. Requires authenticated gh cli.
|
|
487
488
|
|
|
488
489
|
Existing open issues are updated if out of date (matched by title and invisible comment inside).
|
|
@@ -490,70 +491,70 @@ Otherwise, a new issue is created. Assignees are determined based on CODEOWNERS.
|
|
|
490
491
|
).argument(
|
|
491
492
|
"<audit-json>",
|
|
492
493
|
"Path to the JSON file as output by the --json flag in the audit-usages or audit-definitions CLI"
|
|
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",
|
|
494
|
+
).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", X, 0).option("--limit <number>", "Process at most this many issue plans", X).option(
|
|
494
495
|
"--label <label>",
|
|
495
|
-
"Label to add to
|
|
496
|
-
|
|
496
|
+
"Label to add to managed issues. Can be specified multiple times. .github/labeler.yml config is applied by default",
|
|
497
|
+
j,
|
|
497
498
|
[]
|
|
498
499
|
).action(async (t, e) => {
|
|
499
500
|
const o = r.resolve(t);
|
|
500
|
-
if (!await
|
|
501
|
-
|
|
501
|
+
if (!await J(o) || !(await Y(o)).isFile()) {
|
|
502
|
+
m("error", "@arcgis/codemod", `Failed to find the audit JSON file: ${t}`), process.exitCode = 1;
|
|
502
503
|
return;
|
|
503
504
|
}
|
|
504
505
|
const { syncDeprecationIssues: s } = await import("./sync.js");
|
|
505
|
-
await s(await
|
|
506
|
+
await s(await Z(o), e.dryRun, e.offset, e.limit, {
|
|
506
507
|
labels: e.label,
|
|
507
508
|
closeResolved: e.closeResolved
|
|
508
509
|
});
|
|
509
510
|
});
|
|
510
|
-
function
|
|
511
|
+
function Q(t) {
|
|
511
512
|
const e = new Date(t);
|
|
512
513
|
if (!Number.isFinite(e.getTime()))
|
|
513
|
-
throw new
|
|
514
|
+
throw new F("Expected an ISO date.");
|
|
514
515
|
return e.toISOString();
|
|
515
516
|
}
|
|
516
|
-
function
|
|
517
|
+
function j(t, e) {
|
|
517
518
|
return [...e, t];
|
|
518
519
|
}
|
|
519
|
-
function
|
|
520
|
+
function X(t) {
|
|
520
521
|
const e = Number(t);
|
|
521
522
|
if (!Number.isSafeInteger(e) || e < 0)
|
|
522
|
-
throw new
|
|
523
|
+
throw new F("Expected a non-negative integer.");
|
|
523
524
|
return e;
|
|
524
525
|
}
|
|
525
|
-
function
|
|
526
|
-
if (!Object.hasOwn(
|
|
527
|
-
throw new
|
|
526
|
+
function re(t) {
|
|
527
|
+
if (!Object.hasOwn(R, t))
|
|
528
|
+
throw new F(`Expected one of: ${Object.keys(R).join(", ")}.`);
|
|
528
529
|
return t;
|
|
529
530
|
}
|
|
530
|
-
async function
|
|
531
|
+
async function U(t) {
|
|
531
532
|
const e = r.resolve(t);
|
|
532
|
-
await
|
|
533
|
-
const o = await
|
|
533
|
+
await J(e) || (m("error", "@arcgis/codemod", `Failed to find the target path: ${t}`), process.exit(1));
|
|
534
|
+
const o = await Z(e), s = (await Y(o)).isFile();
|
|
534
535
|
return process.chdir(s ? r.dirname(o) : o), s ? o : void 0;
|
|
535
536
|
}
|
|
536
|
-
|
|
537
|
+
C.command("sync-markdown").description(
|
|
537
538
|
"Update managed Markdown comments on an existing issue, leaving its body untouched. Requires authenticated gh cli."
|
|
538
539
|
).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) => {
|
|
539
540
|
const { syncMarkdown: o } = await import("./syncMarkdown.js");
|
|
540
541
|
await o(r.resolve(t), e.issue, e.dryRun);
|
|
541
542
|
});
|
|
542
|
-
|
|
543
|
+
N.parse();
|
|
543
544
|
export {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
545
|
+
Le as a,
|
|
546
|
+
Be as b,
|
|
547
|
+
Me as c,
|
|
548
|
+
R as d,
|
|
549
|
+
A as e,
|
|
550
|
+
ze as f,
|
|
551
|
+
v as g,
|
|
552
|
+
Ke as h,
|
|
553
|
+
Ue as i,
|
|
553
554
|
_e as j,
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
555
|
+
He as k,
|
|
556
|
+
qe as l,
|
|
557
|
+
Pe as p,
|
|
558
|
+
xe as r,
|
|
559
|
+
Ve as s
|
|
559
560
|
};
|