@arcgis/codemod 5.2.0-next.95 → 5.2.0-next.96
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/actions-CkWwc89G.js +354 -0
- package/dist/cli-DAnuyHEr.js +269 -0
- package/dist/cli.js +6 -0
- package/dist/codemod-BCclgPFg.js +240 -0
- package/dist/codemod-CF0JIWmU.js +436 -0
- package/dist/codemod-DJtrKLN0.js +311 -0
- package/dist/codemod-qLUHpoU9.js +6080 -0
- package/dist/codemod-uvo2lksg.js +140 -0
- package/dist/codemod-wgeRWelQ.js +74 -0
- package/dist/useProjectInstance-WKJLKQxc.js +47 -0
- package/package.json +4 -4
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
var N = (t, e) => (e = Symbol[t]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + t), x = (t) => {
|
|
2
|
+
throw TypeError(t);
|
|
3
|
+
};
|
|
4
|
+
var A = (t, e, n) => {
|
|
5
|
+
if (e != null) {
|
|
6
|
+
typeof e != "object" && typeof e != "function" && x("Object expected");
|
|
7
|
+
var r, o;
|
|
8
|
+
n && (r = e[N("asyncDispose")]), r === void 0 && (r = e[N("dispose")], n && (o = r)), typeof r != "function" && x("Object not disposable"), o && (r = function() {
|
|
9
|
+
try {
|
|
10
|
+
o.call(this);
|
|
11
|
+
} catch (a) {
|
|
12
|
+
return Promise.reject(a);
|
|
13
|
+
}
|
|
14
|
+
}), t.push([n, r, e]);
|
|
15
|
+
} else n && t.push([n]);
|
|
16
|
+
return e;
|
|
17
|
+
}, y = (t, e, n) => {
|
|
18
|
+
var r = typeof SuppressedError == "function" ? SuppressedError : function(s, c, l, u) {
|
|
19
|
+
return u = Error(l), u.name = "SuppressedError", u.error = s, u.suppressed = c, u;
|
|
20
|
+
}, o = (s) => e = n ? new r(s, e, "An error was suppressed during disposal") : (n = !0, s), a = (s) => {
|
|
21
|
+
for (; s = t.pop(); )
|
|
22
|
+
try {
|
|
23
|
+
var c = s[1] && s[1].call(s[2]);
|
|
24
|
+
if (s[0]) return Promise.resolve(c).then(a, (l) => (o(l), a()));
|
|
25
|
+
} catch (l) {
|
|
26
|
+
o(l);
|
|
27
|
+
}
|
|
28
|
+
if (n) throw e;
|
|
29
|
+
};
|
|
30
|
+
return a();
|
|
31
|
+
};
|
|
32
|
+
import { SyntaxKind as d, Node as i } from "ts-morph";
|
|
33
|
+
import { c as z } from "./useProjectInstance-WKJLKQxc.js";
|
|
34
|
+
const P = /* @__PURE__ */ new Map([
|
|
35
|
+
["arcgis-survey123", "arcgis-survey-123"],
|
|
36
|
+
["arrow-double-diagonal1", "arrow-double-diagonal-1"],
|
|
37
|
+
["arrow-double-diagonal2", "arrow-double-diagonal-2"],
|
|
38
|
+
["arrow-left10", "arrow-left-10"],
|
|
39
|
+
["arrow-right10", "arrow-right-10"],
|
|
40
|
+
["battery1", "battery-1"],
|
|
41
|
+
["battery2", "battery-2"],
|
|
42
|
+
["battery3", "battery-3"],
|
|
43
|
+
["battery4", "battery-4"],
|
|
44
|
+
["graph-bar100-stacked", "graph-bar-100-stacked"],
|
|
45
|
+
["hexagon2", "hexagon-2"],
|
|
46
|
+
["hexagon2-inset-large", "hexagon-2-inset-large"],
|
|
47
|
+
["hexagon2-inset-medium", "hexagon-2-inset-medium"],
|
|
48
|
+
["hexagon2-inset-small", "hexagon-2-inset-small"],
|
|
49
|
+
["i12x", "1-2x"],
|
|
50
|
+
["i14x", "1-4x"],
|
|
51
|
+
["i18x", "1-8x"],
|
|
52
|
+
["i1x", "1x"],
|
|
53
|
+
["i2d", "2d"],
|
|
54
|
+
["i2d-explore", "2d-explore"],
|
|
55
|
+
["i2x", "2-x"],
|
|
56
|
+
["i360-view", "360-view"],
|
|
57
|
+
["i3d", "3d"],
|
|
58
|
+
["i3d-building", "3d-building"],
|
|
59
|
+
["i3d-building-parameter", "3d-building-parameter"],
|
|
60
|
+
["i3d-glasses", "3d-glasses"],
|
|
61
|
+
["i3d-search", "3d-search"],
|
|
62
|
+
["i4x", "4-x"],
|
|
63
|
+
["i8x", "8-x"],
|
|
64
|
+
["language2", "language-2"],
|
|
65
|
+
["launch2", "launch-2"],
|
|
66
|
+
["layer3d", "layer-3d"],
|
|
67
|
+
["merge2", "merge-2"],
|
|
68
|
+
["number-circle1", "number-circle-1"],
|
|
69
|
+
["number-circle1f", "number-circle-1-f"],
|
|
70
|
+
["number-circle2", "number-circle-2"],
|
|
71
|
+
["number-circle2f", "number-circle-2-f"],
|
|
72
|
+
["number-circle3", "number-circle-3"],
|
|
73
|
+
["number-circle3f", "number-circle-3-f"],
|
|
74
|
+
["number-circle4", "number-circle-4"],
|
|
75
|
+
["number-circle4f", "number-circle-4-f"],
|
|
76
|
+
["number-circle5", "number-circle-5"],
|
|
77
|
+
["number-circle5f", "number-circle-5-f"],
|
|
78
|
+
["number-circle6", "number-circle-6"],
|
|
79
|
+
["number-circle6f", "number-circle-6-f"],
|
|
80
|
+
["number-circle7", "number-circle-7"],
|
|
81
|
+
["number-circle7f", "number-circle-7-f"],
|
|
82
|
+
["number-circle8", "number-circle-8"],
|
|
83
|
+
["number-circle8f", "number-circle-8-f"],
|
|
84
|
+
["number-circle9", "number-circle-9"],
|
|
85
|
+
["number-circle9f", "number-circle-9-f"],
|
|
86
|
+
["person2", "person-2"],
|
|
87
|
+
["pop-up1", "pop-up-1"],
|
|
88
|
+
["satellite0", "satellite-0"],
|
|
89
|
+
["satellite0f", "satellite-0-f"],
|
|
90
|
+
["satellite1", "satellite-1"],
|
|
91
|
+
["satellite1f", "satellite-1-f"],
|
|
92
|
+
["satellite2", "satellite-2"],
|
|
93
|
+
["satellite2f", "satellite-2-f"],
|
|
94
|
+
["satellite3", "satellite-3"],
|
|
95
|
+
["satellite3f", "satellite-3-f"],
|
|
96
|
+
["shapes2d3d", "shapes-2d-3d"],
|
|
97
|
+
["subheading1", "subheading-1"],
|
|
98
|
+
["subheading1-rtl", "subheading-1-rtl"],
|
|
99
|
+
["subheading2", "subheading-2"],
|
|
100
|
+
["subheading2-rtl", "subheading-2-rtl"],
|
|
101
|
+
["subheading3", "subheading-3"],
|
|
102
|
+
["subheading3-rtl", "subheading-3-rtl"],
|
|
103
|
+
["subheading4", "subheading-4"],
|
|
104
|
+
["subheading4-rtl", "subheading-4-rtl"],
|
|
105
|
+
["subheading5", "subheading-5"],
|
|
106
|
+
["subheading5-rtl", "subheading-5-rtl"],
|
|
107
|
+
["summarize-center-and-dispersion1", "summarize-center-and-dispersion-1"],
|
|
108
|
+
["summarize-center-and-dispersion2", "summarize-center-and-dispersion-2"],
|
|
109
|
+
["summarize-center-and-dispersion3", "summarize-center-and-dispersion-3"]
|
|
110
|
+
]), T = /* @__PURE__ */ new Set(["icon", "icon-end", "icon-start", "iconEnd", "iconStart"]), D = /[A-Z]/u, B = /^i\d/u, L = /([A-Z]+)([A-Z][a-z])/gu, I = /([a-z\d])([A-Z])/gu;
|
|
111
|
+
function C(t) {
|
|
112
|
+
let e = t;
|
|
113
|
+
return D.test(e) && (B.test(e) && (e = e.slice(1)), e = e.replace(L, "$1-$2").replace(I, "$1-$2").toLowerCase()), P.get(e) ?? e;
|
|
114
|
+
}
|
|
115
|
+
function w(t) {
|
|
116
|
+
const e = t.getLiteralValue(), n = C(e);
|
|
117
|
+
n !== e && t.setLiteralValue(n);
|
|
118
|
+
}
|
|
119
|
+
function E(t, e) {
|
|
120
|
+
const n = t.getInitializer();
|
|
121
|
+
i.isStringLiteral(n) ? w(n) : i.isJsxExpression(n) && g(n.getExpression(), e);
|
|
122
|
+
}
|
|
123
|
+
function F(t, e) {
|
|
124
|
+
const n = t.getBody();
|
|
125
|
+
i.isExpression(n) ? g(n, e) : n?.getDescendantsOfKind(d.ReturnStatement).forEach((r) => g(r.getExpression(), e));
|
|
126
|
+
}
|
|
127
|
+
function J(t, e) {
|
|
128
|
+
for (const n of t.findReferencesAsNodes()) {
|
|
129
|
+
const r = n.getParent(), o = i.isPropertyAccessExpression(r) ? r : n, a = o.getParent();
|
|
130
|
+
i.isBinaryExpression(a) && a.getLeft() === o && a.getOperatorToken().isKind(d.EqualsToken) ? g(a.getRight(), e) : i.isJsxAttribute(a) && a.getNameNode() === n && E(a, e);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function h(t, e) {
|
|
134
|
+
if (!(t === void 0 || e.has(t))) {
|
|
135
|
+
e.add(t);
|
|
136
|
+
for (const n of t.getDeclarations())
|
|
137
|
+
if (i.isVariableDeclaration(n) || i.isPropertyDeclaration(n) || i.isParameterDeclaration(n) || i.isBindingElement(n) || i.isPropertyAssignment(n)) {
|
|
138
|
+
g(n.getInitializer(), e);
|
|
139
|
+
const r = n.getNameNode();
|
|
140
|
+
i.isIdentifier(r) && J(r, e);
|
|
141
|
+
} else (i.isFunctionDeclaration(n) || i.isMethodDeclaration(n) || i.isFunctionExpression(n) || i.isArrowFunction(n) || i.isGetAccessorDeclaration(n)) && F(n, e);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function g(t, e) {
|
|
145
|
+
if (t !== void 0)
|
|
146
|
+
if (i.isStringLiteral(t) || i.isNoSubstitutionTemplateLiteral(t))
|
|
147
|
+
w(t);
|
|
148
|
+
else if (i.isConditionalExpression(t))
|
|
149
|
+
g(t.getWhenTrue(), e), g(t.getWhenFalse(), e);
|
|
150
|
+
else if (i.isBinaryExpression(t)) {
|
|
151
|
+
const n = t.getOperatorToken().getKind();
|
|
152
|
+
(n === d.BarBarToken || n === d.QuestionQuestionToken) && (g(t.getLeft(), e), g(t.getRight(), e));
|
|
153
|
+
} else i.isParenthesizedExpression(t) || i.isAsExpression(t) || i.isSatisfiesExpression(t) || i.isTypeAssertion(t) || i.isNonNullExpression(t) || i.isAwaitExpression(t) ? g(t.getExpression(), e) : i.isArrayLiteralExpression(t) ? t.getElements().forEach((n) => {
|
|
154
|
+
i.isExpression(n) && g(n, e);
|
|
155
|
+
}) : i.isObjectLiteralExpression(t) ? t.getProperties().forEach((n) => {
|
|
156
|
+
i.isPropertyAssignment(n) ? g(n.getInitializer(), e) : i.isShorthandPropertyAssignment(n) ? h(n.getNameNode().getSymbol(), e) : i.isSpreadAssignment(n) && g(n.getExpression(), e);
|
|
157
|
+
}) : i.isCallExpression(t) ? h(t.getExpression().getSymbol(), e) : i.isElementAccessExpression(t) ? g(t.getExpression(), e) : (i.isIdentifier(t) || i.isPropertyAccessExpression(t)) && h(t.getSymbol(), e);
|
|
158
|
+
}
|
|
159
|
+
function K(t) {
|
|
160
|
+
const e = /* @__PURE__ */ new Map();
|
|
161
|
+
for (const n of t)
|
|
162
|
+
for (const r of n.getDescendantsOfKind(d.JsxAttribute)) {
|
|
163
|
+
const o = r.getFirstAncestor(
|
|
164
|
+
(u) => i.isJsxOpeningElement(u) || i.isJsxSelfClosingElement(u)
|
|
165
|
+
);
|
|
166
|
+
if (!i.isJsxOpeningElement(o) && !i.isJsxSelfClosingElement(o))
|
|
167
|
+
continue;
|
|
168
|
+
const a = o.getTagNameNode().getText(), s = r.getNameNode().getText(), c = e.get(a) ?? /* @__PURE__ */ new Map(), l = c.get(s) ?? [];
|
|
169
|
+
l.push(r), c.set(s, l), e.set(a, c);
|
|
170
|
+
}
|
|
171
|
+
return e;
|
|
172
|
+
}
|
|
173
|
+
function O(t) {
|
|
174
|
+
const e = /* @__PURE__ */ new Map();
|
|
175
|
+
for (const n of t)
|
|
176
|
+
for (const r of n.getDescendantsOfKind(d.InterfaceDeclaration))
|
|
177
|
+
if (r.getName() === "DeclareElements")
|
|
178
|
+
for (const o of r.getProperties()) {
|
|
179
|
+
const a = o.getNameNode(), s = o.getTypeNode()?.getText();
|
|
180
|
+
if (!i.isStringLiteral(a) || s === void 0)
|
|
181
|
+
continue;
|
|
182
|
+
const c = a.getLiteralValue(), l = e.get(c) ?? /* @__PURE__ */ new Set();
|
|
183
|
+
l.add(s), e.set(c, l);
|
|
184
|
+
}
|
|
185
|
+
return e;
|
|
186
|
+
}
|
|
187
|
+
function R(t, e, n) {
|
|
188
|
+
const r = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
|
|
189
|
+
for (const a of n)
|
|
190
|
+
for (const s of a.getDeclarations()) {
|
|
191
|
+
if (!i.isPropertyDeclaration(s))
|
|
192
|
+
continue;
|
|
193
|
+
const c = s.getFirstAncestorByKind(d.ClassDeclaration)?.getName();
|
|
194
|
+
if (c === void 0)
|
|
195
|
+
continue;
|
|
196
|
+
const l = s.getName(), u = `${c}.${l}`;
|
|
197
|
+
if (r.has(u))
|
|
198
|
+
continue;
|
|
199
|
+
r.add(u);
|
|
200
|
+
let m = o.get(c);
|
|
201
|
+
if (m === void 0) {
|
|
202
|
+
const b = new RegExp(`\\b${c}\\b`, "u");
|
|
203
|
+
m = [...e].filter(
|
|
204
|
+
([, f]) => [...f].some((p) => b.test(p))
|
|
205
|
+
).map(([f]) => f), o.set(c, m);
|
|
206
|
+
}
|
|
207
|
+
for (const b of m)
|
|
208
|
+
for (const f of t.get(b)?.get(l) ?? [])
|
|
209
|
+
E(f, n);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const j = {
|
|
213
|
+
meta: {
|
|
214
|
+
needsTypeInformation: !0
|
|
215
|
+
},
|
|
216
|
+
run(t) {
|
|
217
|
+
for (const a of t) {
|
|
218
|
+
var e = [];
|
|
219
|
+
try {
|
|
220
|
+
const s = A(e, z(a));
|
|
221
|
+
const c = /* @__PURE__ */ new Set();
|
|
222
|
+
const l = s.getCodemodFiles();
|
|
223
|
+
const u = K(l);
|
|
224
|
+
for (const [m, b] of u)
|
|
225
|
+
if (m.startsWith("calcite-"))
|
|
226
|
+
for (const f of T)
|
|
227
|
+
for (const p of b.get(f) ?? [])
|
|
228
|
+
E(p, c);
|
|
229
|
+
R(u, O(l), c);
|
|
230
|
+
} catch (n) {
|
|
231
|
+
var r = n, o = !0;
|
|
232
|
+
} finally {
|
|
233
|
+
y(e, r, o);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
export {
|
|
239
|
+
j as codemod
|
|
240
|
+
};
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
var S = (n, e) => (e = Symbol[n]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + n), L = (n) => {
|
|
2
|
+
throw TypeError(n);
|
|
3
|
+
};
|
|
4
|
+
var D = (n, e, i) => {
|
|
5
|
+
if (e != null) {
|
|
6
|
+
typeof e != "object" && typeof e != "function" && L("Object expected");
|
|
7
|
+
var d, r;
|
|
8
|
+
i && (d = e[S("asyncDispose")]), d === void 0 && (d = e[S("dispose")], i && (r = d)), typeof d != "function" && L("Object not disposable"), r && (d = function() {
|
|
9
|
+
try {
|
|
10
|
+
r.call(this);
|
|
11
|
+
} catch (s) {
|
|
12
|
+
return Promise.reject(s);
|
|
13
|
+
}
|
|
14
|
+
}), n.push([i, d, e]);
|
|
15
|
+
} else i && n.push([i]);
|
|
16
|
+
return e;
|
|
17
|
+
}, E = (n, e, i) => {
|
|
18
|
+
var d = typeof SuppressedError == "function" ? SuppressedError : function(t, c, o, a) {
|
|
19
|
+
return a = Error(o), a.name = "SuppressedError", a.error = t, a.suppressed = c, a;
|
|
20
|
+
}, r = (t) => e = i ? new d(t, e, "An error was suppressed during disposal") : (i = !0, t), s = (t) => {
|
|
21
|
+
for (; t = n.pop(); )
|
|
22
|
+
try {
|
|
23
|
+
var c = t[1] && t[1].call(t[2]);
|
|
24
|
+
if (t[0]) return Promise.resolve(c).then(s, (o) => (r(o), s()));
|
|
25
|
+
} catch (o) {
|
|
26
|
+
r(o);
|
|
27
|
+
}
|
|
28
|
+
if (i) throw e;
|
|
29
|
+
};
|
|
30
|
+
return s();
|
|
31
|
+
};
|
|
32
|
+
import { log as y } from "@arcgis/toolkit/log";
|
|
33
|
+
import { c as V } from "./useProjectInstance-WKJLKQxc.js";
|
|
34
|
+
import { mergeApiExtractorConfigs as O, loadApiExtractorConfig as _ } from "@arcgis/api-extractor/extractor/config";
|
|
35
|
+
import { g as F } from "./cli-DAnuyHEr.js";
|
|
36
|
+
import { writeFile as I, readFile as j } from "node:fs/promises";
|
|
37
|
+
import { join as W, relative as Q } from "node:path";
|
|
38
|
+
import { existsAsync as U } from "@arcgis/node-toolkit/file";
|
|
39
|
+
import { ApiExtractor as Y } from "@arcgis/api-extractor/extractor/ApiExtractor";
|
|
40
|
+
import { SyntaxKind as f } from "ts-morph";
|
|
41
|
+
import { getApiMemberName as q } from "@arcgis/api-extractor/utils/apiHelpers";
|
|
42
|
+
import { identity as B } from "@arcgis/toolkit/function";
|
|
43
|
+
import { styleText as $ } from "node:util";
|
|
44
|
+
function G(n) {
|
|
45
|
+
const e = {};
|
|
46
|
+
for (const i of n.modules) {
|
|
47
|
+
const d = {};
|
|
48
|
+
for (const r of i.declarations) {
|
|
49
|
+
const s = {}, t = A(r);
|
|
50
|
+
if (d[r.name + t] = s, "members" in r)
|
|
51
|
+
for (const c of r.members ?? []) {
|
|
52
|
+
const o = q(c);
|
|
53
|
+
s[o + (t || A(c))] = {};
|
|
54
|
+
}
|
|
55
|
+
if ("events" in r)
|
|
56
|
+
for (const c of r.events ?? [])
|
|
57
|
+
s[`@${c.name}${t || A(c)}`] = {};
|
|
58
|
+
}
|
|
59
|
+
e[i.path] = d;
|
|
60
|
+
}
|
|
61
|
+
return e;
|
|
62
|
+
}
|
|
63
|
+
function A(n) {
|
|
64
|
+
if (n.docsTags === void 0)
|
|
65
|
+
return "";
|
|
66
|
+
for (let e = 0; e < n.docsTags.length; ++e)
|
|
67
|
+
if (n.docsTags[e].name === "internal")
|
|
68
|
+
return " (internal)";
|
|
69
|
+
return "";
|
|
70
|
+
}
|
|
71
|
+
function X(n, e) {
|
|
72
|
+
return H(n, e, "").join(`
|
|
73
|
+
`);
|
|
74
|
+
}
|
|
75
|
+
const J = {};
|
|
76
|
+
function H(n, e, i) {
|
|
77
|
+
const r = [.../* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(e)])].sort(), s = [];
|
|
78
|
+
for (let t = 0; t < r.length; ++t) {
|
|
79
|
+
const c = r[t], o = n[c], a = e[c];
|
|
80
|
+
if (o === void 0 && s.push(`${i}+ ${c}`), a === void 0) {
|
|
81
|
+
if (c.endsWith(" (internal)") && (c.toLowerCase().includes("message") || c.toLowerCase().includes("string") || c.toLowerCase().includes("t9n")))
|
|
82
|
+
continue;
|
|
83
|
+
s.push(`${i}- ${c}`);
|
|
84
|
+
}
|
|
85
|
+
const l = H(o ?? J, a ?? J, `${i} `);
|
|
86
|
+
l.length > 0 && (o !== void 0 && a !== void 0 && s.push(`${i}${c}`), s.push(...l));
|
|
87
|
+
}
|
|
88
|
+
return s;
|
|
89
|
+
}
|
|
90
|
+
function x(n, e, i, d) {
|
|
91
|
+
const r = n.getJsDocs().at(-1);
|
|
92
|
+
let s = !1;
|
|
93
|
+
const t = r?.getStructure() ?? { description: void 0, tags: [] }, c = t.tags.findIndex((a) => a.tagName === "private");
|
|
94
|
+
if (c !== -1) {
|
|
95
|
+
if (s = !0, t.tags.splice(c, 1), t.tags.length === 0 && (t.description ?? "").trim() === "") {
|
|
96
|
+
r.remove();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
} else if (e !== void 0) {
|
|
100
|
+
const a = t.tags.some((u) => u.tagName === "internal");
|
|
101
|
+
!t.tags.some((u) => u.tagName === "public") && !a && (s = !0, t.tags.unshift({ tagName: d ? "internal" : "public" }));
|
|
102
|
+
}
|
|
103
|
+
for (const a of t.tags) {
|
|
104
|
+
const l = M(a.text ?? "", i);
|
|
105
|
+
l !== a.text && (s = !0, a.text = l);
|
|
106
|
+
}
|
|
107
|
+
const o = Z(e);
|
|
108
|
+
if (o !== void 0)
|
|
109
|
+
for (const a of o)
|
|
110
|
+
t.tags.some(
|
|
111
|
+
(u) => u.tagName === "param" && (u.text?.includes(`${a.name} `) || u.text === a.name)
|
|
112
|
+
) || (s = !0, t.tags.push({
|
|
113
|
+
tagName: "param",
|
|
114
|
+
text: a.name.startsWith("_") ? a.name.slice(1) : a.name
|
|
115
|
+
}));
|
|
116
|
+
if (t.description !== void 0) {
|
|
117
|
+
const a = M(t.description, i);
|
|
118
|
+
a !== t.description && (s = !0, t.description = a);
|
|
119
|
+
}
|
|
120
|
+
s && (r === void 0 ? n.addJsDoc(t) : r.set(t));
|
|
121
|
+
}
|
|
122
|
+
function Z(n) {
|
|
123
|
+
if (n !== void 0)
|
|
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
|
+
}
|
|
126
|
+
function M(n, e) {
|
|
127
|
+
return n.replace(/\{@link +([^}]+)\}/gu, (i, d) => {
|
|
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
|
+
if (t.startsWith("https://"))
|
|
130
|
+
return c ? `[${c}](${t})` : t;
|
|
131
|
+
if (t.includes("!"))
|
|
132
|
+
return i;
|
|
133
|
+
const o = t.indexOf("#"), a = o === -1 ? t : t.slice(0, o), l = o === -1 ? void 0 : t.slice(o + 1), u = e[a] ?? Object.values(e).find(({ modulePath: N }) => N === a);
|
|
134
|
+
if (u === void 0)
|
|
135
|
+
return i;
|
|
136
|
+
const { component: h, modulePath: T } = u;
|
|
137
|
+
let v = l;
|
|
138
|
+
if (l !== void 0) {
|
|
139
|
+
if (h.members?.find((w) => w.name === l) !== void 0)
|
|
140
|
+
v = l;
|
|
141
|
+
else if (l !== void 0) {
|
|
142
|
+
const w = h.slots?.find((b) => b.name === l);
|
|
143
|
+
if (w !== void 0)
|
|
144
|
+
v = `slot-${w.name}`;
|
|
145
|
+
else {
|
|
146
|
+
const b = h.events?.find((m) => m.name === l);
|
|
147
|
+
b !== void 0 && (v = `event-${b.name}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return `{@link ${T}${v === void 0 ? "" : `#${v}`}${c === "" ? "" : ` ${c}`}}`;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
async function ee(n, e, i, d) {
|
|
155
|
+
const r = [], s = O(e, {
|
|
156
|
+
strict: !0,
|
|
157
|
+
context: {
|
|
158
|
+
logger: {
|
|
159
|
+
info: B,
|
|
160
|
+
error(l) {
|
|
161
|
+
r.push(l);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}), t = new Y(s), { apiJson: c } = await t.run();
|
|
166
|
+
r.length > 0 && y(
|
|
167
|
+
"error",
|
|
168
|
+
n.logName,
|
|
169
|
+
// Since we remove @private tags, re-running the codemod is not entirely safe
|
|
170
|
+
`The migration is complete, but API Extractor reported errors:
|
|
171
|
+
${r.join(`
|
|
172
|
+
`)}
|
|
173
|
+
You don't need to run the codemod again - run \`${d}\` from inside ${n.logName} to verify the fixes.`
|
|
174
|
+
);
|
|
175
|
+
const o = G(c), a = X(i, o);
|
|
176
|
+
a.length > 0 && y(
|
|
177
|
+
"error",
|
|
178
|
+
n.logName,
|
|
179
|
+
`The migration is complete, but it looks like the public API surface has changed a bit:
|
|
180
|
+
${a}
|
|
181
|
+
|
|
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
|
+
);
|
|
184
|
+
}
|
|
185
|
+
const te = "5.2.0-next.96", ne = {
|
|
186
|
+
version: te
|
|
187
|
+
};
|
|
188
|
+
async function oe(n) {
|
|
189
|
+
const e = n.contents.dependencies ?? {}, i = n.contents.devDependencies ?? {};
|
|
190
|
+
if (i["@arcgis/api-extractor"] !== void 0)
|
|
191
|
+
return;
|
|
192
|
+
const d = i["@arcgis/lumina-compiler"] ?? e["@arcgis/typescript-config"] ?? e["@arcgis/toolkit"] ?? `^${ne.version}`;
|
|
193
|
+
n.contents.devDependencies = {
|
|
194
|
+
...i,
|
|
195
|
+
"@arcgis/api-extractor": d
|
|
196
|
+
}, await I(n.filePath, `${JSON.stringify(n.contents, null, 2)}
|
|
197
|
+
`), y(
|
|
198
|
+
"warn",
|
|
199
|
+
$("blue", n.contents.name),
|
|
200
|
+
`Added @arcgis/api-extractor dev dependency. Please run ${$("blue", "npm install or equivalent")}.
|
|
201
|
+
`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
const we = {
|
|
205
|
+
meta: {
|
|
206
|
+
needsTypeInformation: !1
|
|
207
|
+
},
|
|
208
|
+
async run() {
|
|
209
|
+
y(
|
|
210
|
+
"warn",
|
|
211
|
+
F.codemodName,
|
|
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
|
+
`
|
|
214
|
+
);
|
|
215
|
+
const n = /* @__PURE__ */ new Set();
|
|
216
|
+
for (const e of F.projectsData) {
|
|
217
|
+
if (e.packageJson === void 0 || n.has(e.packageJson.filePath))
|
|
218
|
+
continue;
|
|
219
|
+
n.add(e.packageJson.filePath);
|
|
220
|
+
const i = e.packageJson?.contents.devDependencies ?? {}, d = i["@arcgis/lumina-compiler"] !== void 0;
|
|
221
|
+
if (!(d || i["@arcgis/api-extractor"] !== void 0)) {
|
|
222
|
+
y(
|
|
223
|
+
"warn",
|
|
224
|
+
e.logName,
|
|
225
|
+
"This project doesn't look like a Lumina package, nor is it directly using API Extractor. This codemod only works for projects that already use API Extractor."
|
|
226
|
+
);
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
await re(e);
|
|
230
|
+
const s = W(e.cwd, "api-extractor.config.ts");
|
|
231
|
+
let t;
|
|
232
|
+
const c = d ? "npm run build" : "npx api-extractor run";
|
|
233
|
+
if (await U(s) && (t = await _(e.cwd, "api-extractor.config.ts"), t.strict === !0)) {
|
|
234
|
+
y(
|
|
235
|
+
"info",
|
|
236
|
+
e.logName,
|
|
237
|
+
$(
|
|
238
|
+
"green",
|
|
239
|
+
`This package is already in strict mode. You likely do not need to run the codemod again. Instead, run \`${c}\` to verify API Extractor emits no errors in strict mode.`
|
|
240
|
+
)
|
|
241
|
+
);
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
const o = O(t ?? {}, {
|
|
245
|
+
context: {
|
|
246
|
+
cwd: e.cwd,
|
|
247
|
+
// Explicitly don't write to disk, just in case config says otherwise
|
|
248
|
+
apiJsonEmitPath: "",
|
|
249
|
+
dtsEmitPath: "",
|
|
250
|
+
logger: {
|
|
251
|
+
info: B,
|
|
252
|
+
// eslint-disable-next-line webgis/consistent-logging
|
|
253
|
+
error: console.error
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}), a = await ie(o, d, e);
|
|
257
|
+
if (a !== void 0) {
|
|
258
|
+
if (t === void 0)
|
|
259
|
+
await I(
|
|
260
|
+
s,
|
|
261
|
+
`import type { ApiExtractorConfig } from "@arcgis/api-extractor/extractor/config";
|
|
262
|
+
|
|
263
|
+
export const config: ApiExtractorConfig = {
|
|
264
|
+
strict: true,
|
|
265
|
+
};
|
|
266
|
+
`
|
|
267
|
+
);
|
|
268
|
+
else {
|
|
269
|
+
const l = await j(s, "utf-8"), u = l.replace(
|
|
270
|
+
/ApiExtractorConfig\s*=\s*\{\r?\n/u,
|
|
271
|
+
`ApiExtractorConfig = {
|
|
272
|
+
strict: true,
|
|
273
|
+
`
|
|
274
|
+
);
|
|
275
|
+
u === l ? y(
|
|
276
|
+
"warn",
|
|
277
|
+
e.logName,
|
|
278
|
+
`Could not automatically add "strict: true" option to ${s}.`
|
|
279
|
+
) : await I(s, u);
|
|
280
|
+
}
|
|
281
|
+
await oe(e.packageJson), await ee(e, o, a, c);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
async function ie(n, e, i) {
|
|
287
|
+
var o = [];
|
|
288
|
+
try {
|
|
289
|
+
const d = new Y(n);
|
|
290
|
+
const { apiJson: r } = await d.run();
|
|
291
|
+
if (d.errorCount > 0) {
|
|
292
|
+
y("error", i.logName, "API Extractor reported errors. Please resolve them and re-run the codemod.");
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const s = new Map(r.modules.map((h) => [h.sourcePath, h]));
|
|
296
|
+
const t = {};
|
|
297
|
+
if (e)
|
|
298
|
+
for (const h of r.modules) {
|
|
299
|
+
const T = h.declarations.find(
|
|
300
|
+
(v) => v.kind === "class" && v.customElement === !0
|
|
301
|
+
);
|
|
302
|
+
T !== void 0 && (t[T.name] = { component: T, modulePath: h.path });
|
|
303
|
+
}
|
|
304
|
+
const c = D(o, V(i));
|
|
305
|
+
for (const h of c.getCodemodFiles()) {
|
|
306
|
+
const T = Q(i.cwd, h.getFilePath());
|
|
307
|
+
se(h);
|
|
308
|
+
const v = s.get(T), N = v?.declarations.find(
|
|
309
|
+
(m) => m.kind === "class" && m.customElement === !0
|
|
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]));
|
|
311
|
+
for (const m of h.getStatements())
|
|
312
|
+
if (m.isKind(f.VariableStatement)) {
|
|
313
|
+
const g = m.getDeclarations().at(0)?.getName(), P = g === void 0 ? void 0 : b?.get(g);
|
|
314
|
+
x(m, P, t, N);
|
|
315
|
+
} else if (m.isKind(f.TypeAliasDeclaration)) {
|
|
316
|
+
const p = m.getName(), g = b?.get(p) ?? (p.endsWith("Properties") && w?.name === p.slice(0, -10) ? w : void 0);
|
|
317
|
+
if (x(m, g, t, N), g !== void 0) {
|
|
318
|
+
const P = m.getTypeNode();
|
|
319
|
+
(P === void 0 ? [] : P.isKind(f.IntersectionType) ? P.getTypeNodes() : [P]).forEach((K) => {
|
|
320
|
+
if (K.isKind(f.TypeLiteral)) {
|
|
321
|
+
let k = K;
|
|
322
|
+
if (!k.getText().includes(`
|
|
323
|
+
`) && k.getMembers().length > 0) {
|
|
324
|
+
const R = k.getMembers().map((z) => ` ${z.getFullText()}`).join(`
|
|
325
|
+
`);
|
|
326
|
+
k = k.replaceWithText(`{
|
|
327
|
+
${R}
|
|
328
|
+
}`);
|
|
329
|
+
}
|
|
330
|
+
C(
|
|
331
|
+
k,
|
|
332
|
+
g,
|
|
333
|
+
t,
|
|
334
|
+
i
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
} else if (m.isKind(f.FunctionDeclaration)) {
|
|
340
|
+
const p = m.getName(), g = p === void 0 ? void 0 : b?.get(p);
|
|
341
|
+
x(m, g, t, N);
|
|
342
|
+
} else if (m.isKind(f.InterfaceDeclaration)) {
|
|
343
|
+
const p = m.getName(), g = b?.get(p) ?? (p.endsWith("Properties") && w?.name === p.slice(0, -10) ? w : void 0);
|
|
344
|
+
x(m, g, t, N), g !== void 0 && C(m, g, t, i);
|
|
345
|
+
} else if (m.isKind(f.ClassDeclaration)) {
|
|
346
|
+
const p = m.getName(), g = p === void 0 ? void 0 : b?.get(p);
|
|
347
|
+
x(m, g, t, N), g !== void 0 && C(m, g, t, i);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return G(r);
|
|
351
|
+
} catch (a) {
|
|
352
|
+
var l = a, u = !0;
|
|
353
|
+
} finally {
|
|
354
|
+
E(o, l, u);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
async function re(n) {
|
|
358
|
+
const e = W(n.cwd, "vite.config.ts");
|
|
359
|
+
if (!await U(e))
|
|
360
|
+
return;
|
|
361
|
+
const i = await j(e, "utf-8");
|
|
362
|
+
if (!i.includes("useLumina"))
|
|
363
|
+
return;
|
|
364
|
+
const r = [
|
|
365
|
+
"copyDefinitions",
|
|
366
|
+
"apiJsonFileName",
|
|
367
|
+
"publicStoryUrlPrefix",
|
|
368
|
+
"getComponentDocsUrl",
|
|
369
|
+
"getComponentDemoUrl",
|
|
370
|
+
"compilerOptions",
|
|
371
|
+
"tsconfigPath",
|
|
372
|
+
"afterDiagnostic",
|
|
373
|
+
"typeScriptInstanceCreated",
|
|
374
|
+
"declarationTextTransformers",
|
|
375
|
+
"DeclarationTextTransformer",
|
|
376
|
+
"DeclarationFile",
|
|
377
|
+
"ApiJsonOptions",
|
|
378
|
+
"afterCreate"
|
|
379
|
+
].filter(
|
|
380
|
+
(s) => i.match(new RegExp(`\\b${s}\\b`, "u"))
|
|
381
|
+
);
|
|
382
|
+
r.length > 0 && y(
|
|
383
|
+
"warn",
|
|
384
|
+
n.logName,
|
|
385
|
+
`Found deprecated options in ${e}: ${r.join(", ")}. Please refactor these out to equivalents specific in their deprecation messages (see vscode tooltips). See https://webgis.esri.com/references/api-extractor/integrations for an example api-extractor.config.ts. You do not need to re-run the codemod.
|
|
386
|
+
`
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
function se(n) {
|
|
390
|
+
const e = n.getFullText(), i = e.indexOf("identity<typeof");
|
|
391
|
+
if (i === -1)
|
|
392
|
+
return;
|
|
393
|
+
const d = e.indexOf(`
|
|
394
|
+
`, i), r = e.slice(i, d === -1 ? 20 : d).trim();
|
|
395
|
+
y(
|
|
396
|
+
"error",
|
|
397
|
+
n.getFilePath(),
|
|
398
|
+
`Found a t9n type workaround: ${r}. This is no longer necessary - you can directly use the t9n json type like \`typeof T9nStrings>\``
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
function C(n, e, i, d) {
|
|
402
|
+
const r = e.docsTags?.some((o) => o.name === "internal") ?? !1, s = new Map(e.members?.map((o) => [q(o), o]) ?? []);
|
|
403
|
+
let t, c = !1;
|
|
404
|
+
for (const o of n.getMembers())
|
|
405
|
+
if (o.isKind(f.Constructor) || o.isKind(f.ConstructSignature))
|
|
406
|
+
x(o, s.get("constructor"), i, r), c = !0;
|
|
407
|
+
else if (o.isKind(f.CallSignature))
|
|
408
|
+
x(o, s.get("call-signature"), i, r);
|
|
409
|
+
else if (o.isKind(f.MethodDeclaration) || o.isKind(f.MethodSignature) || o.isKind(f.PropertySignature)) {
|
|
410
|
+
const a = o.getNameNode().asKind(f.StringLiteral)?.getLiteralText() ?? o.getName();
|
|
411
|
+
x(o, s.get(a), i, r);
|
|
412
|
+
} else if (o.isKind(f.GetAccessor) || o.isKind(f.SetAccessor)) {
|
|
413
|
+
const a = o.getNameNode().asKind(f.StringLiteral)?.getLiteralText() ?? o.getName(), l = o.getNextSibling();
|
|
414
|
+
!(o.getJsDocs().length === 0 && l !== void 0 && (l.isKind(f.GetAccessor) || l.isKind(f.SetAccessor)) && l.getName() === o.getName()) && // Don't attach the JSDoc if we already attached to the previous node
|
|
415
|
+
t !== a && (x(o, s.get(a), i, r), t = a);
|
|
416
|
+
} else if (o.isKind(f.PropertyDeclaration)) {
|
|
417
|
+
if (o.getInitializer()?.asKind(f.CallExpression)?.getExpression().asKind(f.Identifier)?.getText() === "useT9n")
|
|
418
|
+
continue;
|
|
419
|
+
const l = o.getNameNode().asKind(f.StringLiteral)?.getLiteralText() ?? o.getName();
|
|
420
|
+
x(
|
|
421
|
+
o,
|
|
422
|
+
s.get(l) ?? ("events" in e ? e.events?.find((u) => u.name === l) : void 0),
|
|
423
|
+
i,
|
|
424
|
+
r
|
|
425
|
+
);
|
|
426
|
+
} else o.isKind(f.IndexSignature) && x(o, e, i, r);
|
|
427
|
+
!c && e.kind === "class" && e.customElement !== !0 && y(
|
|
428
|
+
"warn",
|
|
429
|
+
d.logName,
|
|
430
|
+
`${e.name} doesn't have a @public constructor, so it will appear as abstract class in the docs and public types. If you wish to expose the ability for users to construct instances of this class, add a @public constructor to it. Documentation: https://webgis.esri.com/references/api-extractor/api-node-kinds#constructor
|
|
431
|
+
`
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
export {
|
|
435
|
+
we as codemod
|
|
436
|
+
};
|