@arcgis/codemod 6.0.0-next.44 → 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 +73 -6
- 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 +52 -52
- package/dist/chunks/codemod.js +46 -46
- package/dist/chunks/codemod10.js +6039 -63
- package/dist/chunks/codemod11.js +54 -45
- package/dist/chunks/codemod12.js +74 -0
- package/dist/chunks/codemod9.js +218 -6017
- 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/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
|
};
|