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