@arcgis/codemod 6.0.0-next.43 → 6.0.0-next.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +158 -7
- package/dist/chunks/actions.js +261 -249
- package/dist/chunks/aggregateUsages.js +11 -10
- package/dist/chunks/apiName.js +123 -0
- package/dist/chunks/auditDefinitions.js +49 -47
- package/dist/chunks/auditUsages.js +649 -647
- package/dist/chunks/classification.js +73 -192
- package/dist/chunks/cli.js +79 -79
- package/dist/chunks/codemod.js +46 -46
- package/dist/chunks/codemod10.js +6059 -0
- package/dist/chunks/codemod11.js +83 -0
- package/dist/chunks/codemod12.js +74 -0
- package/dist/chunks/codemod2.js +180 -400
- package/dist/chunks/codemod3.js +77 -292
- package/dist/chunks/codemod4.js +398 -69
- package/dist/chunks/codemod5.js +292 -88
- package/dist/chunks/codemod6.js +71 -223
- package/dist/chunks/codemod7.js +89 -6041
- package/dist/chunks/codemod8.js +215 -49
- package/dist/chunks/codemod9.js +260 -0
- package/dist/chunks/componentAudit.js +141 -216
- package/dist/chunks/format.js +8 -7
- package/dist/chunks/hardcodedBehavior.js +96 -0
- package/dist/chunks/sync.js +1 -1
- package/package.json +4 -4
package/dist/chunks/cli.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { log as g } from "@arcgis/toolkit/log";
|
|
2
2
|
import { Command as ce, InvalidArgumentError as A } from "@commander-js/extra-typings";
|
|
3
3
|
import { realpath as X, stat as Y } from "node:fs/promises";
|
|
4
|
-
import { path as r, getCwd as W, toPosixPathSeparators as
|
|
5
|
-
import { asyncFindPath as
|
|
4
|
+
import { path as r, getCwd as W, toPosixPathSeparators as T } from "@arcgis/node-toolkit/path";
|
|
5
|
+
import { asyncFindPath as $, existsAsync as M } from "@arcgis/node-toolkit/file";
|
|
6
6
|
import "ts-morph";
|
|
7
7
|
import d from "typescript";
|
|
8
8
|
import { asyncRetrievePackageJson as de } from "@arcgis/node-toolkit/packageJson";
|
|
9
9
|
import { glob as Z } from "tinyglobby";
|
|
10
10
|
import { gitIgnoreFileToGlobs as ee } from "@arcgis/node-toolkit/glob";
|
|
11
11
|
import { identity as q } from "@arcgis/toolkit/function";
|
|
12
|
-
import { styleText as
|
|
12
|
+
import { styleText as U } from "node:util";
|
|
13
13
|
import { randomUUID as le } from "node:crypto";
|
|
14
|
-
const
|
|
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." : ""))));
|
|
@@ -35,7 +35,7 @@ const pe = (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,
|
|
@@ -48,34 +48,34 @@ const pe = (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
|
|
51
|
+
async function pe() {
|
|
52
|
+
const { ignorePatterns: t, globRoot: e, hasIgnoreFiles: o } = await ue(), s = await ge(e);
|
|
53
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
|
|
58
|
+
const o = await $(".git"), s = o === void 0 ? void 0 : r.dirname(o);
|
|
59
59
|
let n, l = W(), f = r.dirname(l);
|
|
60
60
|
do {
|
|
61
61
|
if (n = f, s !== void 0 && n !== s && !n.startsWith(`${s}/`))
|
|
62
62
|
break;
|
|
63
|
-
const
|
|
64
|
-
if (await
|
|
65
|
-
e = !0, l = r.dirname(
|
|
66
|
-
const h = r.relative(l, W()).split("/"), N = ee(
|
|
63
|
+
const p = r.join(n, ".gitignore");
|
|
64
|
+
if (await M(p)) {
|
|
65
|
+
e = !0, l = r.dirname(p);
|
|
66
|
+
const h = r.relative(l, W()).split("/"), N = ee(p);
|
|
67
67
|
for (const b of N) {
|
|
68
|
-
const w = b.startsWith("!") ? b.slice(1) : b, y = w.search(/[*?[]/u), P = y === -1 ? w : w.slice(0, y),
|
|
69
|
-
let
|
|
70
|
-
const D = Math.min(h.length,
|
|
68
|
+
const w = b.startsWith("!") ? b.slice(1) : b, y = w.search(/[*?[]/u), P = y === -1 ? w : w.slice(0, y), u = P.split("/"), I = y !== -1 && !P.endsWith("/");
|
|
69
|
+
let x = !0;
|
|
70
|
+
const D = Math.min(h.length, u.length);
|
|
71
71
|
for (let i = 0; i < D; i++) {
|
|
72
|
-
const a =
|
|
73
|
-
if (!(I && i ===
|
|
74
|
-
|
|
72
|
+
const a = u[i];
|
|
73
|
+
if (!(I && i === u.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);
|
|
@@ -94,8 +94,8 @@ async function ge(t) {
|
|
|
94
94
|
});
|
|
95
95
|
return { ignorePatterns: e.flatMap((s) => {
|
|
96
96
|
const n = r.relative(t, r.dirname(s)), l = ee(s), f = [];
|
|
97
|
-
for (const
|
|
98
|
-
|
|
97
|
+
for (const p of l)
|
|
98
|
+
p.startsWith("!") || f.push(r.join(n, p));
|
|
99
99
|
return f;
|
|
100
100
|
}), hasIgnoreFiles: e.length > 0 };
|
|
101
101
|
}
|
|
@@ -105,12 +105,12 @@ async function we({
|
|
|
105
105
|
includeComponentFiles: e = !1,
|
|
106
106
|
includeTsConfigFiles: o = !1
|
|
107
107
|
} = {}) {
|
|
108
|
-
const s = await
|
|
108
|
+
const s = await pe(), l = `**/*.{${[
|
|
109
109
|
...oe,
|
|
110
110
|
...se,
|
|
111
111
|
...he,
|
|
112
112
|
...e ? be : []
|
|
113
|
-
].join(",")}}`, f = r.join(process.cwd(), l),
|
|
113
|
+
].join(",")}}`, f = r.join(process.cwd(), l), p = r.join(r.resolve(s.globRoot), "/"), L = (await Z(f, {
|
|
114
114
|
cwd: s.globRoot,
|
|
115
115
|
ignore: s.ignorePatterns,
|
|
116
116
|
// The files we are looking for are unlikely to be symbolic links
|
|
@@ -121,13 +121,13 @@ async function we({
|
|
|
121
121
|
// default behavior). If any tsconfig.json explicitly includes such files,
|
|
122
122
|
// they will still be codemodded.
|
|
123
123
|
})).filter(
|
|
124
|
-
(i) => i.endsWith(".json") || t === void 0 ||
|
|
124
|
+
(i) => i.endsWith(".json") || t === void 0 || p + i === t
|
|
125
125
|
);
|
|
126
126
|
let h = r.relative(s.globRoot, process.cwd());
|
|
127
127
|
h !== "" && (h += "/");
|
|
128
|
-
const N =
|
|
129
|
-
for (const i of
|
|
130
|
-
const a =
|
|
128
|
+
const N = p.length + h.length, b = [], w = [], y = /* @__PURE__ */ new Set();
|
|
129
|
+
for (const i of L) {
|
|
130
|
+
const a = p + i;
|
|
131
131
|
if (i.endsWith(".json")) {
|
|
132
132
|
const c = r.basename(i);
|
|
133
133
|
c === "package.json" ? b.push(a) : (c.startsWith("tsconfig.") || c.startsWith("jsconfig.")) && w.push(a);
|
|
@@ -136,19 +136,19 @@ async function we({
|
|
|
136
136
|
y.add(c);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
let P = await
|
|
140
|
-
P !== void 0 && (P =
|
|
139
|
+
let P = await $("tsconfig.json", r.dirname(process.cwd()));
|
|
140
|
+
P !== void 0 && (P = T(P), w.push(P)), w.sort((i, a) => {
|
|
141
141
|
const c = a.split("/").length - i.split("/").length;
|
|
142
142
|
if (c !== 0)
|
|
143
143
|
return c;
|
|
144
|
-
const
|
|
145
|
-
return
|
|
144
|
+
const m = r.basename(i), S = r.basename(a);
|
|
145
|
+
return m === S ? 0 : m.endsWith("tsconfig.json") ? -1 : S.endsWith("tsconfig.json") ? 1 : m.endsWith("tsconfig.build.json") ? -1 : S.endsWith("tsconfig.build.json") ? 1 : m.localeCompare(S);
|
|
146
146
|
});
|
|
147
|
-
let
|
|
148
|
-
|
|
147
|
+
let u = await $("package.json");
|
|
148
|
+
u !== void 0 && (u = T(u));
|
|
149
149
|
const I = [
|
|
150
|
-
.../* @__PURE__ */ new Set([...b, ...
|
|
151
|
-
].sort((i, a) => a.length - i.length),
|
|
150
|
+
.../* @__PURE__ */ new Set([...b, ...u === void 0 ? [] : [u]])
|
|
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);
|
|
@@ -164,54 +164,54 @@ async function we({
|
|
|
164
164
|
);
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
|
-
const
|
|
167
|
+
const m = 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
|
+
m.errors.filter((k) => k.code !== S).length > 0 && g(
|
|
175
175
|
"warn",
|
|
176
176
|
a,
|
|
177
|
-
d.formatDiagnosticsWithColorAndContext(
|
|
177
|
+
d.formatDiagnosticsWithColorAndContext(m.errors, {
|
|
178
178
|
getCanonicalFileName: q,
|
|
179
179
|
getCurrentDirectory: d.sys.getCurrentDirectory,
|
|
180
180
|
getNewLine: () => d.sys.newLine
|
|
181
181
|
})
|
|
182
182
|
);
|
|
183
|
-
const
|
|
183
|
+
const K = i === P, _ = m.fileNames.filter((k) => {
|
|
184
184
|
if (t !== void 0 && k !== t)
|
|
185
185
|
return !1;
|
|
186
186
|
const E = k.slice(N);
|
|
187
|
-
return y.delete(E) ? (D.add(E), !0) : D.has(E) || E.endsWith(".json") || k.includes("node_modules") ||
|
|
187
|
+
return y.delete(E) ? (D.add(E), !0) : D.has(E) || E.endsWith(".json") || k.includes("node_modules") || K ? !1 : d.sys.fileExists(k);
|
|
188
188
|
}), re = (
|
|
189
189
|
// Scanning tsconfig.json
|
|
190
190
|
o && // Don't include tsconfig outside the scanned scope
|
|
191
|
-
!
|
|
191
|
+
!K && // If filtering by file, ensure this tsconfig is the one being targeted
|
|
192
192
|
(t === void 0 || t === i)
|
|
193
193
|
);
|
|
194
|
-
if (
|
|
194
|
+
if (_.length === 0 && !re)
|
|
195
195
|
return;
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
await B(
|
|
196
|
+
const H = r.dirname(i), ae = z(H, I) ?? u;
|
|
197
|
+
x.push(
|
|
198
|
+
await B(_, H, ae, {
|
|
199
199
|
filePath: i,
|
|
200
|
-
compilerOptions:
|
|
200
|
+
compilerOptions: m.options
|
|
201
201
|
})
|
|
202
202
|
);
|
|
203
203
|
})
|
|
204
204
|
), y.size > 0) {
|
|
205
205
|
const i = [...y].map((c) => r.join(process.cwd(), c)), a = Map.groupBy(i, (c) => z(c, I));
|
|
206
|
-
|
|
206
|
+
x.push(
|
|
207
207
|
...await Promise.all(
|
|
208
|
-
[...a].map(async ([c,
|
|
208
|
+
[...a].map(async ([c, m]) => await B(m, process.cwd(), c))
|
|
209
209
|
)
|
|
210
210
|
);
|
|
211
211
|
}
|
|
212
|
-
return
|
|
212
|
+
return x.sort(
|
|
213
213
|
(i, a) => i.cwd.localeCompare(a.cwd) || (i.typeScriptConfig?.filePath ?? "").localeCompare(a.typeScriptConfig?.filePath ?? "") || (i.packageJson?.filePath ?? "").localeCompare(a.packageJson?.filePath ?? "")
|
|
214
|
-
),
|
|
214
|
+
), v.projectsData = x, x;
|
|
215
215
|
}
|
|
216
216
|
function Ue(t) {
|
|
217
217
|
const e = r.extname(t).slice(1);
|
|
@@ -233,18 +233,18 @@ async function B(t, e, o, s) {
|
|
|
233
233
|
packageJson: n,
|
|
234
234
|
cwd: e,
|
|
235
235
|
filePaths: t.sort(),
|
|
236
|
-
logName:
|
|
236
|
+
logName: U("blue", n?.contents.name ?? e)
|
|
237
237
|
};
|
|
238
238
|
}
|
|
239
239
|
function ye() {
|
|
240
|
-
|
|
240
|
+
v.codemod.meta.needsFooter && (v.codemod.meta.needsFooter = !1, process.exitCode !== void 0 && process.exitCode !== 0 ? g(
|
|
241
241
|
"warn",
|
|
242
|
-
|
|
242
|
+
v.codemodName,
|
|
243
243
|
"One or more exceptions occurred during the codemod run. Please review the output above."
|
|
244
244
|
) : g(
|
|
245
245
|
"info",
|
|
246
|
-
|
|
247
|
-
`${
|
|
246
|
+
v.codemodName,
|
|
247
|
+
`${U("green", "Codemod completed successfully.")} Recommended next steps:
|
|
248
248
|
- Review the codemod changes.
|
|
249
249
|
- If your project uses ESLint, run ESLint autofix on the changed files.
|
|
250
250
|
- If your project uses Prettier, run Prettier on the changed files.
|
|
@@ -252,7 +252,7 @@ function ye() {
|
|
|
252
252
|
));
|
|
253
253
|
}
|
|
254
254
|
async function Pe(t, e, o) {
|
|
255
|
-
|
|
255
|
+
v.codemod = t, v.codemodName = e;
|
|
256
256
|
const s = await we({
|
|
257
257
|
targetFilePath: o,
|
|
258
258
|
includeComponentFiles: t.meta.includeComponentFiles,
|
|
@@ -265,10 +265,10 @@ async function Pe(t, e, o) {
|
|
|
265
265
|
}
|
|
266
266
|
await t.run(s), ye();
|
|
267
267
|
}
|
|
268
|
-
async function
|
|
268
|
+
async function xe(t) {
|
|
269
269
|
const e = r.resolve(t);
|
|
270
|
-
await
|
|
271
|
-
const o = await X(e), s = (await Y(o)).isFile();
|
|
270
|
+
await M(e) || (g("error", "@arcgis/codemod", `Failed to find the target path: ${t}`), process.exit(1));
|
|
271
|
+
const o = T(await X(e)), s = (await Y(o)).isFile();
|
|
272
272
|
return process.chdir(s ? r.dirname(o) : o), s ? o : void 0;
|
|
273
273
|
}
|
|
274
274
|
const R = {
|
|
@@ -316,7 +316,7 @@ const R = {
|
|
|
316
316
|
label: "Non-Esri packages and web platform - low priority",
|
|
317
317
|
description: "These deprecations do not block updating Esri packages and are not tied to an ArcGIS release."
|
|
318
318
|
}
|
|
319
|
-
},
|
|
319
|
+
}, G = "https://webgis.esri.com/api/deprecations";
|
|
320
320
|
async function Le(t, e) {
|
|
321
321
|
const o = le();
|
|
322
322
|
process.stderr.write(`Submitting deprecation report (${o}).
|
|
@@ -346,7 +346,7 @@ async function Le(t, e) {
|
|
|
346
346
|
process.stderr.write(`Deprecation report submitted to ${e} (${o}).
|
|
347
347
|
`);
|
|
348
348
|
}
|
|
349
|
-
const
|
|
349
|
+
const ve = /(?:esri|arcgis)/iu, Se = ["/.astro/"], J = ["all", "repositories", "apis", "unused-apis"], Ke = {
|
|
350
350
|
usages: "Refactor-out deprecated API usages",
|
|
351
351
|
definitions: "Remove deprecated APIs in next breaking changes release"
|
|
352
352
|
}, _e = {
|
|
@@ -354,18 +354,18 @@ const Se = /(?:esri|arcgis)/iu, xe = ["/.astro/"], G = ["all", "repositories", "
|
|
|
354
354
|
definitions: "The following deprecated APIs are owned by assigned CODEOWNERS. Remove them in the next breaking changes release."
|
|
355
355
|
}, He = "This issue is autogenerated and updated regularly based on remaining items. Feel free to add comments and labels, update assignees, set milestone, or create sub-issues. Close it once completed. A new issue will be created if new findings are detected.", qe = "Task", ze = "deprecations sync-issues";
|
|
356
356
|
function Be(t) {
|
|
357
|
-
return
|
|
357
|
+
return ve.test(t);
|
|
358
358
|
}
|
|
359
359
|
function Ve(t) {
|
|
360
|
-
return
|
|
360
|
+
return Se.some((e) => `/${t}`.includes(e));
|
|
361
361
|
}
|
|
362
|
-
const F = new ce(), O = "See https://www.npmjs.com/package/@arcgis/codemod for a list of available public codemods. [Esri internal] Non-public codemods are documented at https://webgis.esri.com/references/codemod/introduction.";
|
|
362
|
+
const F = new ce(), O = "See https://www.npmjs.com/package/@arcgis/codemod for a list of available public codemods. Double check you used the correct codemod package version - try re-running with npx @arcgis/codemod@next or npx @arcgis/codemod@latest. [Esri internal] Non-public codemods are documented at https://webgis.esri.com/references/codemod/introduction.";
|
|
363
363
|
F.name("@arcgis/codemod").description("Codemod for migrating or refactoring usages of ArcGIS Maps SDK for JavaScript");
|
|
364
364
|
F.command("run").description("Run a single codemod").argument("<codemodName>", `Name of the codemod. ${O}`).argument("[path]", "Directory to transform", process.cwd()).showHelpAfterError(O).action(async (t, e) => {
|
|
365
|
-
const o = await
|
|
365
|
+
const o = await xe(e);
|
|
366
366
|
let s;
|
|
367
367
|
try {
|
|
368
|
-
s = await
|
|
368
|
+
s = await me(/* @__PURE__ */ Object.assign({ "./codemods/api-extractor-strict-mode/codemod.ts": () => import("./codemod.js"), "./codemods/feature-next-to-feature/codemod.ts": () => import("./codemod2.js"), "./codemods/features-next-to-features/codemod.ts": () => import("./codemod3.js"), "./codemods/geometry-operator-renames/codemod.ts": () => import("./codemod4.js"), "./codemods/lumina-component-extras-improvements/codemod.ts": () => import("./codemod5.js"), "./codemods/lumina-toolkit/codemod.ts": () => import("./codemod6.js"), "./codemods/node-toolkit/codemod.ts": () => import("./codemod7.js"), "./codemods/normalize-calcite-icon-names/codemod.ts": () => import("./codemod8.js"), "./codemods/refactor-component-types/codemod.ts": () => import("./codemod9.js"), "./codemods/refactor-out-esri-namespace/codemod.ts": () => import("./codemod10.js"), "./codemods/rename-next-list-components/codemod.ts": () => import("./codemod11.js"), "./codemods/toolkit-5.2-renames/codemod.ts": () => import("./codemod12.js") }), `./codemods/${t}/codemod.ts`, 4);
|
|
369
369
|
} catch (n) {
|
|
370
370
|
if (
|
|
371
371
|
// direct Node execution
|
|
@@ -381,7 +381,7 @@ F.command("run").description("Run a single codemod").argument("<codemodName>", `
|
|
|
381
381
|
g("error", "@arcgis/codemod", `Can't find codemod by name "${t}". ${O}`), process.exitCode = 1;
|
|
382
382
|
return;
|
|
383
383
|
}
|
|
384
|
-
await Pe(s.codemod,
|
|
384
|
+
await Pe(s.codemod, U("blue", t), o);
|
|
385
385
|
});
|
|
386
386
|
const C = F.command("deprecations").description(
|
|
387
387
|
`Audit and report deprecated APIs.
|
|
@@ -396,7 +396,7 @@ C.command("audit-usages").description(
|
|
|
396
396
|
ne
|
|
397
397
|
).option("--package <package-name>", "Only report usages of deprecated APIs from this package").option(
|
|
398
398
|
"--report [url]",
|
|
399
|
-
`Submit a complete repository scan to the WebGIS collector (default: ${
|
|
399
|
+
`Submit a complete repository scan to the WebGIS collector (default: ${G})`
|
|
400
400
|
).option(
|
|
401
401
|
"--json",
|
|
402
402
|
"Output results as JSON. Example: npx @arcgis/codemod deprecations audit-usages --json > usages.json",
|
|
@@ -423,12 +423,12 @@ C.command("aggregate-usages").description(
|
|
|
423
423
|
"Aggregate audit-usages reports into repository summaries and an API usage tree. Documentation: https://webgis.esri.com/references/codemod/deprecations#analyze-the-ecosystem"
|
|
424
424
|
).argument("[reports...]", "Paths to audit-usages JSON files").option(
|
|
425
425
|
"--section <section>",
|
|
426
|
-
`Reports to include in the markdown report: ${
|
|
426
|
+
`Reports to include in the markdown report: ${J.join(", ")}`,
|
|
427
427
|
ke,
|
|
428
428
|
"all"
|
|
429
429
|
).option(
|
|
430
430
|
"--remote [url]",
|
|
431
|
-
`Read the latest stored audit per repository from the WebGIS collector (default: ${
|
|
431
|
+
`Read the latest stored audit per repository from the WebGIS collector (default: ${G})`
|
|
432
432
|
).option(
|
|
433
433
|
"--repository <repository>",
|
|
434
434
|
"Select a remote repository (host/owner/repo); repeat to select multiple",
|
|
@@ -464,7 +464,7 @@ C.command("aggregate-usages").description(
|
|
|
464
464
|
},
|
|
465
465
|
e.definitions,
|
|
466
466
|
e.remote ? {
|
|
467
|
-
url: e.remote === !0 ?
|
|
467
|
+
url: e.remote === !0 ? G : e.remote,
|
|
468
468
|
repositories: e.repository,
|
|
469
469
|
branch: e.branch,
|
|
470
470
|
since: e.since,
|
|
@@ -473,10 +473,10 @@ C.command("aggregate-usages").description(
|
|
|
473
473
|
);
|
|
474
474
|
});
|
|
475
475
|
function ke(t) {
|
|
476
|
-
const e =
|
|
476
|
+
const e = J.find((o) => o === t);
|
|
477
477
|
if (e !== void 0)
|
|
478
478
|
return e;
|
|
479
|
-
throw new A(`Expected one of: ${
|
|
479
|
+
throw new A(`Expected one of: ${J.join(", ")}.`);
|
|
480
480
|
}
|
|
481
481
|
C.command("sync-issues").description(
|
|
482
482
|
`Create or update deprecation audit issues. Requires authenticated gh cli.
|
|
@@ -493,7 +493,7 @@ Otherwise, a new issue is created. Assignees are determined based on CODEOWNERS.
|
|
|
493
493
|
[]
|
|
494
494
|
).action(async (t, e) => {
|
|
495
495
|
const o = r.resolve(t);
|
|
496
|
-
if (!await
|
|
496
|
+
if (!await M(o) || !(await Y(o)).isFile()) {
|
|
497
497
|
g("error", "@arcgis/codemod", `Failed to find the audit JSON file: ${t}`), process.exitCode = 1;
|
|
498
498
|
return;
|
|
499
499
|
}
|
|
@@ -531,13 +531,13 @@ C.command("sync-markdown").description(
|
|
|
531
531
|
});
|
|
532
532
|
F.parse();
|
|
533
533
|
export {
|
|
534
|
-
|
|
534
|
+
G as a,
|
|
535
535
|
Pe as b,
|
|
536
536
|
Le as c,
|
|
537
537
|
R as d,
|
|
538
538
|
Be as e,
|
|
539
539
|
Me as f,
|
|
540
|
-
|
|
540
|
+
v as g,
|
|
541
541
|
ze as h,
|
|
542
542
|
Ue as i,
|
|
543
543
|
Ke as j,
|
|
@@ -545,6 +545,6 @@ export {
|
|
|
545
545
|
He as l,
|
|
546
546
|
qe as m,
|
|
547
547
|
ye as p,
|
|
548
|
-
|
|
548
|
+
xe as r,
|
|
549
549
|
Ve as s
|
|
550
550
|
};
|
package/dist/chunks/codemod.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
1
|
+
var L = (n, e) => (e = Symbol[n]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + n), D = (n) => {
|
|
2
2
|
throw TypeError(n);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
4
|
+
var E = (n, e, i) => {
|
|
5
5
|
if (e != null) {
|
|
6
|
-
typeof e != "object" && typeof e != "function" &&
|
|
6
|
+
typeof e != "object" && typeof e != "function" && D("Object expected");
|
|
7
7
|
var d, r;
|
|
8
|
-
i && (d = e[
|
|
8
|
+
i && (d = e[L("asyncDispose")]), d === void 0 && (d = e[L("dispose")], i && (r = d)), typeof d != "function" && D("Object not disposable"), r && (d = function() {
|
|
9
9
|
try {
|
|
10
10
|
r.call(this);
|
|
11
11
|
} catch (s) {
|
|
@@ -14,7 +14,7 @@ var D = (n, e, i) => {
|
|
|
14
14
|
}), n.push([i, d, e]);
|
|
15
15
|
} else i && n.push([i]);
|
|
16
16
|
return e;
|
|
17
|
-
},
|
|
17
|
+
}, F = (n, e, i) => {
|
|
18
18
|
var d = typeof SuppressedError == "function" ? SuppressedError : function(t, c, o, a) {
|
|
19
19
|
return a = Error(o), a.name = "SuppressedError", a.error = t, a.suppressed = c, a;
|
|
20
20
|
}, r = (t) => e = i ? new d(t, e, "An error was suppressed during disposal") : (i = !0, t), s = (t) => {
|
|
@@ -31,10 +31,10 @@ var D = (n, e, i) => {
|
|
|
31
31
|
};
|
|
32
32
|
import { log as y } from "@arcgis/toolkit/log";
|
|
33
33
|
import { c as V } from "./useProjectInstance.js";
|
|
34
|
-
import { mergeApiExtractorConfigs as
|
|
35
|
-
import { g as
|
|
36
|
-
import { writeFile as I, readFile as
|
|
37
|
-
import {
|
|
34
|
+
import { mergeApiExtractorConfigs as j, loadApiExtractorConfig as _ } from "@arcgis/api-extractor/extractor/config";
|
|
35
|
+
import { g as J } from "./cli.js";
|
|
36
|
+
import { writeFile as I, readFile as W } from "node:fs/promises";
|
|
37
|
+
import { path as K } from "@arcgis/node-toolkit/path";
|
|
38
38
|
import { existsAsync as U } from "@arcgis/node-toolkit/file";
|
|
39
39
|
import { ApiExtractor as Y } from "@arcgis/api-extractor/extractor/ApiExtractor";
|
|
40
40
|
import { SyntaxKind as f } from "ts-morph";
|
|
@@ -68,11 +68,11 @@ function A(n) {
|
|
|
68
68
|
return " (internal)";
|
|
69
69
|
return "";
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function Q(n, e) {
|
|
72
72
|
return H(n, e, "").join(`
|
|
73
73
|
`);
|
|
74
74
|
}
|
|
75
|
-
const
|
|
75
|
+
const M = {};
|
|
76
76
|
function H(n, e, i) {
|
|
77
77
|
const r = [.../* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(e)])].sort(), s = [];
|
|
78
78
|
for (let t = 0; t < r.length; ++t) {
|
|
@@ -82,7 +82,7 @@ function H(n, e, i) {
|
|
|
82
82
|
continue;
|
|
83
83
|
s.push(`${i}- ${c}`);
|
|
84
84
|
}
|
|
85
|
-
const l = H(o ??
|
|
85
|
+
const l = H(o ?? M, a ?? M, `${i} `);
|
|
86
86
|
l.length > 0 && (o !== void 0 && a !== void 0 && s.push(`${i}${c}`), s.push(...l));
|
|
87
87
|
}
|
|
88
88
|
return s;
|
|
@@ -101,10 +101,10 @@ function x(n, e, i, d) {
|
|
|
101
101
|
!t.tags.some((u) => u.tagName === "public") && !a && (s = !0, t.tags.unshift({ tagName: d ? "internal" : "public" }));
|
|
102
102
|
}
|
|
103
103
|
for (const a of t.tags) {
|
|
104
|
-
const l =
|
|
104
|
+
const l = O(a.text ?? "", i);
|
|
105
105
|
l !== a.text && (s = !0, a.text = l);
|
|
106
106
|
}
|
|
107
|
-
const o =
|
|
107
|
+
const o = X(e);
|
|
108
108
|
if (o !== void 0)
|
|
109
109
|
for (const a of o)
|
|
110
110
|
t.tags.some(
|
|
@@ -114,16 +114,16 @@ function x(n, e, i, d) {
|
|
|
114
114
|
text: a.name.startsWith("_") ? a.name.slice(1) : a.name
|
|
115
115
|
}));
|
|
116
116
|
if (t.description !== void 0) {
|
|
117
|
-
const a =
|
|
117
|
+
const a = O(t.description, i);
|
|
118
118
|
a !== t.description && (s = !0, t.description = a);
|
|
119
119
|
}
|
|
120
120
|
s && (r === void 0 ? n.addJsDoc(t) : r.set(t));
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function X(n) {
|
|
123
123
|
if (n !== void 0)
|
|
124
124
|
return "parameters" in n ? n.parameters : "kind" in n && n.kind === "interface" && n.supertypes === void 0 && n.type === void 0 && n.members?.length === 1 && (n.members[0].kind === "call-signature" || n.members[0].kind === "constructor") ? n.members[0].parameters : void 0;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function O(n, e) {
|
|
127
127
|
return n.replace(/\{@link +([^}]+)\}/gu, (i, d) => {
|
|
128
128
|
const r = d.trim(), s = r.indexOf(" "), t = s === -1 ? r : r.slice(0, s), c = s === -1 ? "" : r.slice(s + 1).trim();
|
|
129
129
|
if (t.startsWith("https://"))
|
|
@@ -151,8 +151,8 @@ function M(n, e) {
|
|
|
151
151
|
return `{@link ${T}${v === void 0 ? "" : `#${v}`}${c === "" ? "" : ` ${c}`}}`;
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
|
-
async function
|
|
155
|
-
const r = [], s =
|
|
154
|
+
async function Z(n, e, i, d) {
|
|
155
|
+
const r = [], s = j(e, {
|
|
156
156
|
strict: !0,
|
|
157
157
|
context: {
|
|
158
158
|
logger: {
|
|
@@ -172,7 +172,7 @@ ${r.join(`
|
|
|
172
172
|
`)}
|
|
173
173
|
You don't need to run the codemod again - run \`${d}\` from inside ${n.logName} to verify the fixes.`
|
|
174
174
|
);
|
|
175
|
-
const o = G(c), a =
|
|
175
|
+
const o = G(c), a = Q(i, o);
|
|
176
176
|
a.length > 0 && y(
|
|
177
177
|
"error",
|
|
178
178
|
n.logName,
|
|
@@ -182,14 +182,14 @@ ${a}
|
|
|
182
182
|
For each added declaration, remove @public from it if it is not supposed to be public. For each removed declaration, add @public JSDoc tag if it needs to remain public.`
|
|
183
183
|
);
|
|
184
184
|
}
|
|
185
|
-
const
|
|
186
|
-
version:
|
|
185
|
+
const ee = "1.0.0-0", te = {
|
|
186
|
+
version: ee
|
|
187
187
|
};
|
|
188
|
-
async function
|
|
188
|
+
async function ne(n) {
|
|
189
189
|
const e = n.contents.dependencies ?? {}, i = n.contents.devDependencies ?? {};
|
|
190
190
|
if (i["@arcgis/api-extractor"] !== void 0)
|
|
191
191
|
return;
|
|
192
|
-
const d = i["@arcgis/lumina-compiler"] ?? e["@arcgis/typescript-config"] ?? e["@arcgis/toolkit"] ?? `^${
|
|
192
|
+
const d = i["@arcgis/lumina-compiler"] ?? e["@arcgis/typescript-config"] ?? e["@arcgis/toolkit"] ?? `^${te.version}`;
|
|
193
193
|
n.contents.devDependencies = {
|
|
194
194
|
...i,
|
|
195
195
|
"@arcgis/api-extractor": d
|
|
@@ -201,19 +201,19 @@ async function oe(n) {
|
|
|
201
201
|
`
|
|
202
202
|
);
|
|
203
203
|
}
|
|
204
|
-
const
|
|
204
|
+
const be = {
|
|
205
205
|
meta: {
|
|
206
206
|
needsTypeInformation: !1
|
|
207
207
|
},
|
|
208
208
|
async run() {
|
|
209
209
|
y(
|
|
210
210
|
"warn",
|
|
211
|
-
|
|
211
|
+
J.codemodName,
|
|
212
212
|
`This codemod automates most of the changes. It may print warnings or errors for manual follow-up work - ${$(["bold", "magenta"], "Carefully review the following log messages.")}
|
|
213
213
|
`
|
|
214
214
|
);
|
|
215
215
|
const n = /* @__PURE__ */ new Set();
|
|
216
|
-
for (const e of
|
|
216
|
+
for (const e of J.projectsData) {
|
|
217
217
|
if (e.packageJson === void 0 || n.has(e.packageJson.filePath))
|
|
218
218
|
continue;
|
|
219
219
|
n.add(e.packageJson.filePath);
|
|
@@ -226,8 +226,8 @@ const we = {
|
|
|
226
226
|
);
|
|
227
227
|
continue;
|
|
228
228
|
}
|
|
229
|
-
await
|
|
230
|
-
const s =
|
|
229
|
+
await ie(e);
|
|
230
|
+
const s = K.join(e.cwd, "api-extractor.config.ts");
|
|
231
231
|
let t;
|
|
232
232
|
const c = d ? "npm run build" : "npx api-extractor run";
|
|
233
233
|
if (await U(s) && (t = await _(e.cwd, "api-extractor.config.ts"), t.strict === !0)) {
|
|
@@ -241,7 +241,7 @@ const we = {
|
|
|
241
241
|
);
|
|
242
242
|
continue;
|
|
243
243
|
}
|
|
244
|
-
const o =
|
|
244
|
+
const o = j(t ?? {}, {
|
|
245
245
|
context: {
|
|
246
246
|
cwd: e.cwd,
|
|
247
247
|
// Explicitly don't write to disk, just in case config says otherwise
|
|
@@ -253,7 +253,7 @@ const we = {
|
|
|
253
253
|
error: console.error
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
}), a = await
|
|
256
|
+
}), a = await oe(o, d, e);
|
|
257
257
|
if (a !== void 0) {
|
|
258
258
|
if (t === void 0)
|
|
259
259
|
await I(
|
|
@@ -266,7 +266,7 @@ export const config: ApiExtractorConfig = {
|
|
|
266
266
|
`
|
|
267
267
|
);
|
|
268
268
|
else {
|
|
269
|
-
const l = await
|
|
269
|
+
const l = await W(s, "utf-8"), u = l.replace(
|
|
270
270
|
/ApiExtractorConfig\s*=\s*\{\r?\n/u,
|
|
271
271
|
`ApiExtractorConfig = {
|
|
272
272
|
strict: true,
|
|
@@ -278,12 +278,12 @@ export const config: ApiExtractorConfig = {
|
|
|
278
278
|
`Could not automatically add "strict: true" option to ${s}.`
|
|
279
279
|
) : await I(s, u);
|
|
280
280
|
}
|
|
281
|
-
await
|
|
281
|
+
await ne(e.packageJson), await Z(e, o, a, c);
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
};
|
|
286
|
-
async function
|
|
286
|
+
async function oe(n, e, i) {
|
|
287
287
|
var o = [];
|
|
288
288
|
try {
|
|
289
289
|
const d = new Y(n);
|
|
@@ -301,10 +301,10 @@ async function ie(n, e, i) {
|
|
|
301
301
|
);
|
|
302
302
|
T !== void 0 && (t[T.name] = { component: T, modulePath: h.path });
|
|
303
303
|
}
|
|
304
|
-
const c =
|
|
304
|
+
const c = E(o, V(i));
|
|
305
305
|
for (const h of c.getCodemodFiles()) {
|
|
306
|
-
const T =
|
|
307
|
-
|
|
306
|
+
const T = K.relative(i.cwd, h.getFilePath());
|
|
307
|
+
re(h);
|
|
308
308
|
const v = s.get(T), N = v?.declarations.find(
|
|
309
309
|
(m) => m.kind === "class" && m.customElement === !0
|
|
310
310
|
)?.docsTags?.some((m) => m.name === "internal") ?? !1, w = v?.declarations.find((m) => m.kind === "class"), b = v === void 0 ? void 0 : new Map(v.declarations.map((m) => [m.name, m]));
|
|
@@ -316,9 +316,9 @@ async function ie(n, e, i) {
|
|
|
316
316
|
const p = m.getName(), g = b?.get(p) ?? (p.endsWith("Properties") && w?.name === p.slice(0, -10) ? w : void 0);
|
|
317
317
|
if (x(m, g, t, N), g !== void 0) {
|
|
318
318
|
const P = m.getTypeNode();
|
|
319
|
-
(P === void 0 ? [] : P.isKind(f.IntersectionType) ? P.getTypeNodes() : [P]).forEach((
|
|
320
|
-
if (
|
|
321
|
-
let k =
|
|
319
|
+
(P === void 0 ? [] : P.isKind(f.IntersectionType) ? P.getTypeNodes() : [P]).forEach((S) => {
|
|
320
|
+
if (S.isKind(f.TypeLiteral)) {
|
|
321
|
+
let k = S;
|
|
322
322
|
if (!k.getText().includes(`
|
|
323
323
|
`) && k.getMembers().length > 0) {
|
|
324
324
|
const R = k.getMembers().map((z) => ` ${z.getFullText()}`).join(`
|
|
@@ -351,14 +351,14 @@ ${R}
|
|
|
351
351
|
} catch (a) {
|
|
352
352
|
var l = a, u = !0;
|
|
353
353
|
} finally {
|
|
354
|
-
|
|
354
|
+
F(o, l, u);
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
|
-
async function
|
|
358
|
-
const e =
|
|
357
|
+
async function ie(n) {
|
|
358
|
+
const e = K.join(n.cwd, "vite.config.ts");
|
|
359
359
|
if (!await U(e))
|
|
360
360
|
return;
|
|
361
|
-
const i = await
|
|
361
|
+
const i = await W(e, "utf-8");
|
|
362
362
|
if (!i.includes("useLumina"))
|
|
363
363
|
return;
|
|
364
364
|
const r = [
|
|
@@ -386,7 +386,7 @@ async function re(n) {
|
|
|
386
386
|
`
|
|
387
387
|
);
|
|
388
388
|
}
|
|
389
|
-
function
|
|
389
|
+
function re(n) {
|
|
390
390
|
const e = n.getFullText(), i = e.indexOf("identity<typeof");
|
|
391
391
|
if (i === -1)
|
|
392
392
|
return;
|
|
@@ -432,5 +432,5 @@ function C(n, e, i, d) {
|
|
|
432
432
|
);
|
|
433
433
|
}
|
|
434
434
|
export {
|
|
435
|
-
|
|
435
|
+
be as codemod
|
|
436
436
|
};
|