@arcgis/codemod 5.2.0-next.12 → 5.2.0-next.121
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/LICENSE.md +4 -2
- package/README.md +113 -27
- package/dist/actions-LEFiI8Xk.js +395 -0
- package/dist/cli-DfAgo-jb.js +326 -0
- package/dist/cli.js +4 -3
- package/dist/{codemod-CNOYHe74.js → codemod-BpcMVaZX.js} +6 -6
- package/dist/codemod-DHO2ieDH.js +240 -0
- package/dist/codemod-DTsG5_YU.js +417 -0
- package/dist/codemod-DryX37eS.js +88 -0
- package/dist/codemod-HRcnKq-i.js +74 -0
- package/dist/codemod-YgioOfc7.js +108 -0
- package/dist/codemod-eprC1jEo.js +311 -0
- package/dist/{codemod-CGfWoOzy.js → codemod-lZGspJIz.js} +19 -18
- package/dist/codeowners-CarwYwHK.js +118 -0
- package/dist/config-BP6HDIQa.js +19 -0
- package/dist/index-2_o7gSlk.js +313 -0
- package/dist/index-DomCHjnu.js +142 -0
- package/dist/log-B76HBvov.js +11 -0
- package/dist/packageJson-sf04hyfN.js +39 -0
- package/dist/sync-e0pgnEOM.js +240 -0
- package/dist/useProjectInstance-DtWpxhlT.js +48 -0
- package/package.json +12 -9
- package/dist/actions-D3MzXcqP.js +0 -354
- package/dist/cli-C2S8UH1H.js +0 -262
- package/dist/codemod-gk646ODy.js +0 -157
- package/dist/useProjectInstance-BUOw6lga.js +0 -50
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { log as y } from "@arcgis/toolkit/log";
|
|
2
|
+
import { Command as V, InvalidArgumentError as Q } from "@commander-js/extra-typings";
|
|
3
|
+
import { stat as U, realpath as K } from "node:fs/promises";
|
|
4
|
+
import { getCwd as E, path as n, toPosixPathSeparators as M } from "@arcgis/node-toolkit/path";
|
|
5
|
+
import { existsAsync as N, asyncFindPath as T } from "@arcgis/node-toolkit/file";
|
|
6
|
+
import "ts-morph";
|
|
7
|
+
import d from "typescript";
|
|
8
|
+
import { asyncRetrievePackageJson as _ } from "@arcgis/node-toolkit/packageJson";
|
|
9
|
+
import { glob as q } from "tinyglobby";
|
|
10
|
+
import { gitIgnoreFileToGlobs as B } from "@arcgis/node-toolkit/glob";
|
|
11
|
+
import { identity as G } from "@arcgis/toolkit/function";
|
|
12
|
+
import { styleText as I } from "node:util";
|
|
13
|
+
const X = (t, e, s) => {
|
|
14
|
+
const o = t[e];
|
|
15
|
+
return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((a, u) => {
|
|
16
|
+
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(u.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + e + (e.split("/").length !== s ? ". Note that variables only represent file names one level deep." : ""))));
|
|
17
|
+
});
|
|
18
|
+
}, xe = {
|
|
19
|
+
allowImportingTsExtensions: !0,
|
|
20
|
+
allowJs: !0,
|
|
21
|
+
allowArbitraryExtensions: !0,
|
|
22
|
+
allowSyntheticDefaultImports: !0,
|
|
23
|
+
checkJs: !0,
|
|
24
|
+
experimentalDecorators: !0,
|
|
25
|
+
forceConsistentCasingInFileNames: !1,
|
|
26
|
+
isolatedModules: !1,
|
|
27
|
+
isolatedDeclarations: !1,
|
|
28
|
+
jsx: d.JsxEmit.Preserve,
|
|
29
|
+
lib: ["lib.esnext.d.ts", "lib.dom.d.ts"],
|
|
30
|
+
module: d.ModuleKind.ESNext,
|
|
31
|
+
moduleResolution: d.ModuleResolutionKind.Bundler,
|
|
32
|
+
moduleDetection: d.ModuleDetectionKind.Auto,
|
|
33
|
+
strict: !1,
|
|
34
|
+
target: d.ScriptTarget.ESNext,
|
|
35
|
+
resolveJsonModule: !0,
|
|
36
|
+
esModuleInterop: !0
|
|
37
|
+
}, v = {
|
|
38
|
+
codemod: void 0,
|
|
39
|
+
codemodName: void 0,
|
|
40
|
+
projectsData: void 0,
|
|
41
|
+
project: void 0
|
|
42
|
+
};
|
|
43
|
+
async function Y() {
|
|
44
|
+
const { ignorePatterns: t, globRoot: e } = await Z(), s = await ee(e);
|
|
45
|
+
return t.push(...s), { ignorePatterns: t, globRoot: e };
|
|
46
|
+
}
|
|
47
|
+
async function Z() {
|
|
48
|
+
const t = [];
|
|
49
|
+
let e, s = E(), o = n.dirname(s);
|
|
50
|
+
do {
|
|
51
|
+
e = o;
|
|
52
|
+
const a = n.join(e, ".gitignore");
|
|
53
|
+
if (await N(a)) {
|
|
54
|
+
s = n.dirname(a);
|
|
55
|
+
const P = n.relative(s, E()).split("/"), j = B(a);
|
|
56
|
+
for (const l of j) {
|
|
57
|
+
const g = l.startsWith("!") ? l.slice(1) : l, h = g.search(/[*?[]/u), p = h === -1 ? g : g.slice(0, h), w = p.split("/"), x = h !== -1 && !p.endsWith("/");
|
|
58
|
+
let i = !0;
|
|
59
|
+
const c = Math.min(P.length, w.length);
|
|
60
|
+
for (let r = 0; r < c; r++) {
|
|
61
|
+
const m = w[r];
|
|
62
|
+
if (!(x && r === w.length - 1 ? P[r].startsWith(m) : P[r] === m) && m !== "") {
|
|
63
|
+
i = !1;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
i && (l.startsWith("!") || t.push(l));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
o = n.dirname(e);
|
|
71
|
+
} while (o !== e);
|
|
72
|
+
return { ignorePatterns: t, globRoot: s };
|
|
73
|
+
}
|
|
74
|
+
async function ee(t) {
|
|
75
|
+
return (await q("**/.gitignore", {
|
|
76
|
+
cwd: E(),
|
|
77
|
+
// Gitignore files are unlikely to be symbolic links
|
|
78
|
+
followSymbolicLinks: !1,
|
|
79
|
+
// Don't look for ignore files in these places for speed:
|
|
80
|
+
ignore: [
|
|
81
|
+
// Hardcoded ignores in TypeScript
|
|
82
|
+
"**/node_modules/**",
|
|
83
|
+
"**/bower_components/**",
|
|
84
|
+
"**/jspm_packages/**",
|
|
85
|
+
// Default build output folder in bundlers
|
|
86
|
+
"**/dist/**"
|
|
87
|
+
],
|
|
88
|
+
// Not applicable for our glob pattern
|
|
89
|
+
expandDirectories: !1
|
|
90
|
+
})).flatMap((s) => {
|
|
91
|
+
const o = n.relative(t, n.dirname(s)), a = B(s), u = [];
|
|
92
|
+
for (const P of a)
|
|
93
|
+
P.startsWith("!") || u.push(n.join(o, P));
|
|
94
|
+
return u;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
const te = ["js", "jsx", "mjs", "cjs"], oe = ["ts", "tsx", "mts", "cts"], se = ["json"], ne = `**/*.{${[...te, ...oe, ...se].join(",")}}`;
|
|
98
|
+
async function ie(t) {
|
|
99
|
+
const e = await Y(), s = n.join(process.cwd(), ne), o = n.join(n.resolve(e.globRoot), "/"), a = (await q(s, {
|
|
100
|
+
cwd: e.globRoot,
|
|
101
|
+
ignore: e.ignorePatterns,
|
|
102
|
+
// The files we are looking for are unlikely to be symbolic links
|
|
103
|
+
followSymbolicLinks: !1,
|
|
104
|
+
// Not applicable for our glob pattern
|
|
105
|
+
expandDirectories: !1
|
|
106
|
+
// Files and folders starting with . are excluded (matches TypeScript's
|
|
107
|
+
// default behavior). If any tsconfig.json explicitly includes such files,
|
|
108
|
+
// they will still be codemodded.
|
|
109
|
+
})).filter(
|
|
110
|
+
(i) => i.endsWith(".json") || t === void 0 || o + i === t
|
|
111
|
+
);
|
|
112
|
+
let u = n.relative(e.globRoot, process.cwd());
|
|
113
|
+
u !== "" && (u += "/");
|
|
114
|
+
const P = o.length + u.length, j = [], l = [], g = /* @__PURE__ */ new Set();
|
|
115
|
+
for (const i of a) {
|
|
116
|
+
const c = o + i;
|
|
117
|
+
if (i.endsWith(".json")) {
|
|
118
|
+
const r = n.basename(i);
|
|
119
|
+
r === "package.json" ? j.push(c) : (r.startsWith("tsconfig.") || r.startsWith("jsconfig.")) && l.push(c);
|
|
120
|
+
} else {
|
|
121
|
+
const r = i.slice(u.length);
|
|
122
|
+
g.add(r);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
let h = await T("tsconfig.json", n.dirname(process.cwd()));
|
|
126
|
+
h !== void 0 && (h = M(h), l.push(h)), l.sort((i, c) => {
|
|
127
|
+
const r = c.split("/").length - i.split("/").length;
|
|
128
|
+
if (r !== 0)
|
|
129
|
+
return r;
|
|
130
|
+
const m = n.basename(i), f = n.basename(c);
|
|
131
|
+
return m === f ? 0 : m.endsWith("tsconfig.json") ? -1 : f.endsWith("tsconfig.json") ? 1 : m.endsWith("tsconfig.build.json") ? -1 : f.endsWith("tsconfig.build.json") ? 1 : m.localeCompare(f);
|
|
132
|
+
});
|
|
133
|
+
let p = await T("package.json");
|
|
134
|
+
p !== void 0 && (p = M(p));
|
|
135
|
+
const w = [], x = /* @__PURE__ */ new Set();
|
|
136
|
+
if (await Promise.all(
|
|
137
|
+
l.map(async (i) => {
|
|
138
|
+
const c = n.relative(process.cwd(), i), r = d.readConfigFile(i, d.sys.readFile);
|
|
139
|
+
if (r.error !== void 0) {
|
|
140
|
+
y(
|
|
141
|
+
"error",
|
|
142
|
+
c,
|
|
143
|
+
d.formatDiagnosticsWithColorAndContext([r.error], {
|
|
144
|
+
getCanonicalFileName: G,
|
|
145
|
+
getCurrentDirectory: d.sys.getCurrentDirectory,
|
|
146
|
+
getNewLine: () => d.sys.newLine
|
|
147
|
+
})
|
|
148
|
+
);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const m = n.basename(c), f = d.parseJsonConfigFileContent(
|
|
152
|
+
r.config,
|
|
153
|
+
d.sys,
|
|
154
|
+
n.dirname(i),
|
|
155
|
+
void 0,
|
|
156
|
+
m
|
|
157
|
+
), O = 18003;
|
|
158
|
+
f.errors.filter((b) => b.code !== O).length > 0 && y(
|
|
159
|
+
"warn",
|
|
160
|
+
c,
|
|
161
|
+
d.formatDiagnosticsWithColorAndContext(f.errors, {
|
|
162
|
+
getCanonicalFileName: G,
|
|
163
|
+
getCurrentDirectory: d.sys.getCurrentDirectory,
|
|
164
|
+
getNewLine: () => d.sys.newLine
|
|
165
|
+
})
|
|
166
|
+
);
|
|
167
|
+
const W = i === h, z = c === m, A = f.fileNames.filter((b) => {
|
|
168
|
+
if (t !== void 0 && b !== t)
|
|
169
|
+
return !1;
|
|
170
|
+
const S = b.slice(P);
|
|
171
|
+
return g.delete(S) ? (x.add(S), !0) : x.has(S) || S.endsWith(".json") || b.includes("node_modules") ? !1 : !W;
|
|
172
|
+
});
|
|
173
|
+
if (A.length === 0)
|
|
174
|
+
return;
|
|
175
|
+
l.length === 1 && (W || z) && g.clear();
|
|
176
|
+
const F = n.dirname(i);
|
|
177
|
+
let C = F, D = p;
|
|
178
|
+
do {
|
|
179
|
+
const b = n.join(C, "package.json");
|
|
180
|
+
if (j.includes(b)) {
|
|
181
|
+
D = b;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
} while (C !== e.globRoot && (C = n.dirname(C)));
|
|
185
|
+
const L = D === void 0 ? void 0 : { filePath: D, contents: await _(n.dirname(D)) }, H = {
|
|
186
|
+
typeScriptConfig: {
|
|
187
|
+
filePath: i,
|
|
188
|
+
compilerOptions: f.options
|
|
189
|
+
},
|
|
190
|
+
packageJson: L,
|
|
191
|
+
logName: I("blue", L?.contents?.name ?? F),
|
|
192
|
+
cwd: F,
|
|
193
|
+
filePaths: A
|
|
194
|
+
};
|
|
195
|
+
w.push(H);
|
|
196
|
+
})
|
|
197
|
+
), g.size > 0) {
|
|
198
|
+
const i = p === void 0 ? void 0 : {
|
|
199
|
+
filePath: p,
|
|
200
|
+
contents: await _(n.dirname(p))
|
|
201
|
+
};
|
|
202
|
+
w.push({
|
|
203
|
+
typeScriptConfig: void 0,
|
|
204
|
+
packageJson: i,
|
|
205
|
+
cwd: process.cwd(),
|
|
206
|
+
logName: I("blue", i?.contents?.name ?? process.cwd()),
|
|
207
|
+
filePaths: Array.from(g).map((c) => n.join(process.cwd(), c))
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
return w.sort((i, c) => i.cwd.localeCompare(c.cwd)), v.projectsData = w, w;
|
|
211
|
+
}
|
|
212
|
+
function re() {
|
|
213
|
+
v.codemod.meta.needsFooter && (v.codemod.meta.needsFooter = !1, process.exitCode !== void 0 && process.exitCode !== 0 ? y(
|
|
214
|
+
"warn",
|
|
215
|
+
v.codemodName,
|
|
216
|
+
"One or more exceptions occurred during the codemod run. Please review the output above."
|
|
217
|
+
) : y(
|
|
218
|
+
"info",
|
|
219
|
+
v.codemodName,
|
|
220
|
+
`${I("green", "Codemod completed successfully.")} Recommended next steps:
|
|
221
|
+
- Review the codemod changes.
|
|
222
|
+
- If your project uses ESLint, run ESLint autofix on the changed files.
|
|
223
|
+
- If your project uses Prettier, run Prettier on the changed files.
|
|
224
|
+
- If your project uses TypeScript, run type checking to ensure there are no type errors.`
|
|
225
|
+
));
|
|
226
|
+
}
|
|
227
|
+
async function ae(t, e, s) {
|
|
228
|
+
v.codemod = t, v.codemodName = e;
|
|
229
|
+
const o = await ie(s);
|
|
230
|
+
if (o.length === 0) {
|
|
231
|
+
y("error", e, `Failed to find any .js or .ts files in ${process.cwd()} to run the codemod on.`), process.exitCode = 1;
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
await t.run(o), re();
|
|
235
|
+
}
|
|
236
|
+
const k = new V();
|
|
237
|
+
k.name("@arcgis/codemod").description("Codemod for migrating or refactoring usages of ArcGIS Maps SDK for JavaScript");
|
|
238
|
+
k.command("run").description("Run a single codemod").argument("<codemodName>", "Name of the transform").argument("[path]", "Directory to transform", process.cwd()).action(async (t, e) => {
|
|
239
|
+
const s = await J(e);
|
|
240
|
+
let o;
|
|
241
|
+
try {
|
|
242
|
+
o = await X(/* @__PURE__ */ Object.assign({ "./codemods/api-extractor-strict-mode/codemod.ts": () => import("./codemod-BpcMVaZX.js"), "./codemods/geometry-operator-renames/codemod.ts": () => import("./codemod-DTsG5_YU.js"), "./codemods/lumina-component-extras-improvements/codemod.ts": () => import("./codemod-eprC1jEo.js"), "./codemods/lumina-toolkit/codemod.ts": () => import("./codemod-DryX37eS.js"), "./codemods/node-toolkit/codemod.ts": () => import("./codemod-YgioOfc7.js"), "./codemods/normalize-calcite-icon-names/codemod.ts": () => import("./codemod-DHO2ieDH.js"), "./codemods/refactor-out-esri-namespace/codemod.ts": () => import("./codemod-lZGspJIz.js"), "./codemods/toolkit-5.2-renames/codemod.ts": () => import("./codemod-HRcnKq-i.js") }), `./codemods/${t}/codemod.ts`, 4);
|
|
243
|
+
} catch (a) {
|
|
244
|
+
if (
|
|
245
|
+
// direct Node execution
|
|
246
|
+
typeof a == "object" && a !== null && "code" in a && a.code === "ERR_MODULE_NOT_FOUND" && "url" in a && typeof a.url == "string" && a.url.endsWith(`/${t}/codemod.ts`) || // Vite build execution
|
|
247
|
+
String(a).includes("Unknown variable dynamic import:")
|
|
248
|
+
) {
|
|
249
|
+
y("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
250
|
+
return;
|
|
251
|
+
} else
|
|
252
|
+
throw a;
|
|
253
|
+
}
|
|
254
|
+
if (typeof o.codemod != "object" || o.codemod === null) {
|
|
255
|
+
y("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
await ae(o.codemod, I("blue", t), s);
|
|
259
|
+
});
|
|
260
|
+
const R = k.command("deprecations").description("Audit and report deprecated APIs");
|
|
261
|
+
R.command("audit-usages").description("Report deprecated API usages").argument("[path]", "Directory to audit", process.cwd()).option("--esri-only", "Only report usages of deprecated APIs from Esri and ArcGIS packages", !1).option(
|
|
262
|
+
"--json",
|
|
263
|
+
"Output results as JSON. Example: npx @arcgis/codemod deprecations audit-usages --json > usages.json",
|
|
264
|
+
!1
|
|
265
|
+
).action(async (t, e) => {
|
|
266
|
+
const s = await J(t), { auditDeprecatedUsages: o } = await import("./index-2_o7gSlk.js");
|
|
267
|
+
await o(s, e.esriOnly, e.json);
|
|
268
|
+
});
|
|
269
|
+
R.command("audit-definitions").description("Report exported APIs marked as deprecated").argument("[path]", "Directory to audit", process.cwd()).option(
|
|
270
|
+
"--json",
|
|
271
|
+
"Output results as JSON. Example: npx @arcgis/codemod deprecations audit-definitions --json > definitions.json",
|
|
272
|
+
!1
|
|
273
|
+
).action(async (t, e) => {
|
|
274
|
+
const s = await J(t), { auditDeprecatedDefinitions: o } = await import("./index-DomCHjnu.js");
|
|
275
|
+
await o(s, e.json);
|
|
276
|
+
});
|
|
277
|
+
R.command("sync-issues").description(
|
|
278
|
+
`Create or update deprecation audit issues. Requires authenticated gh cli.
|
|
279
|
+
|
|
280
|
+
Existing open issues are updated if out of date (matched by title and invisible comment inside).
|
|
281
|
+
Otherwise, a new issue is created. Assignees are determined based on CODEOWNERS.`
|
|
282
|
+
).argument(
|
|
283
|
+
"<audit-json>",
|
|
284
|
+
"Path to the JSON file as output by the --json flag in the audit-usages or audit-definitions CLI"
|
|
285
|
+
).option("--dry-run", "Print issue contents without changing GitHub", !1).option("--offset <number>", "Skip the first number of issue plans", $, 0).option("--limit <number>", "Process at most this many issue plans", $).option(
|
|
286
|
+
"--label <label>",
|
|
287
|
+
"Label to add to newly created issues. Can be specified multiple times.",
|
|
288
|
+
ce,
|
|
289
|
+
[]
|
|
290
|
+
).action(async (t, e) => {
|
|
291
|
+
const s = n.resolve(t);
|
|
292
|
+
if (!await N(s) || !(await U(s)).isFile()) {
|
|
293
|
+
y("error", "@arcgis/codemod", `Failed to find the audit JSON file: ${t}`), process.exitCode = 1;
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const { syncDeprecationIssues: o } = await import("./sync-e0pgnEOM.js");
|
|
297
|
+
await o(
|
|
298
|
+
await K(s),
|
|
299
|
+
e.dryRun,
|
|
300
|
+
e.offset,
|
|
301
|
+
e.limit,
|
|
302
|
+
e.label
|
|
303
|
+
);
|
|
304
|
+
});
|
|
305
|
+
function ce(t, e) {
|
|
306
|
+
return [...e, t];
|
|
307
|
+
}
|
|
308
|
+
function $(t) {
|
|
309
|
+
const e = Number(t);
|
|
310
|
+
if (!Number.isSafeInteger(e) || e < 0)
|
|
311
|
+
throw new Q("Expected a non-negative integer.");
|
|
312
|
+
return e;
|
|
313
|
+
}
|
|
314
|
+
async function J(t) {
|
|
315
|
+
const e = n.resolve(t);
|
|
316
|
+
await N(e) || (y("error", "@arcgis/codemod", `Failed to find the target path: ${t}`), process.exit(1));
|
|
317
|
+
const s = await K(e), o = (await U(s)).isFile();
|
|
318
|
+
return process.chdir(o ? n.dirname(s) : s), o ? s : void 0;
|
|
319
|
+
}
|
|
320
|
+
k.parse();
|
|
321
|
+
export {
|
|
322
|
+
xe as d,
|
|
323
|
+
v as g,
|
|
324
|
+
re as p,
|
|
325
|
+
ae as r
|
|
326
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import "./cli-
|
|
1
|
+
import "./cli-DfAgo-jb.js";
|
|
2
2
|
import "@arcgis/toolkit/log";
|
|
3
3
|
import "@commander-js/extra-typings";
|
|
4
|
-
import "node:fs";
|
|
5
|
-
import "@arcgis/
|
|
4
|
+
import "node:fs/promises";
|
|
5
|
+
import "@arcgis/node-toolkit/path";
|
|
6
|
+
import "@arcgis/node-toolkit/file";
|
|
6
7
|
import "node:util";
|
|
@@ -30,12 +30,12 @@ var D = (n, e, i) => {
|
|
|
30
30
|
return s();
|
|
31
31
|
};
|
|
32
32
|
import { log as y } from "@arcgis/toolkit/log";
|
|
33
|
-
import { c as V } from "./useProjectInstance-
|
|
33
|
+
import { c as V } from "./useProjectInstance-DtWpxhlT.js";
|
|
34
34
|
import { mergeApiExtractorConfigs as O, loadApiExtractorConfig as _ } from "@arcgis/api-extractor/extractor/config";
|
|
35
|
-
import { g as F } from "./cli-
|
|
35
|
+
import { g as F } from "./cli-DfAgo-jb.js";
|
|
36
36
|
import { writeFile as I, readFile as j } from "node:fs/promises";
|
|
37
37
|
import { join as W, relative as Q } from "node:path";
|
|
38
|
-
import { existsAsync as U } from "@arcgis/
|
|
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";
|
|
41
41
|
import { getApiMemberName as q } from "@arcgis/api-extractor/utils/apiHelpers";
|
|
@@ -127,7 +127,7 @@ function M(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://"))
|
|
130
|
-
return c ? `[${c}](${t})
|
|
130
|
+
return c ? `[${c}](${t})` : t;
|
|
131
131
|
if (t.includes("!"))
|
|
132
132
|
return i;
|
|
133
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);
|
|
@@ -182,7 +182,7 @@ ${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 te = "
|
|
185
|
+
const te = "1.0.0-0", ne = {
|
|
186
186
|
version: te
|
|
187
187
|
};
|
|
188
188
|
async function oe(n) {
|
|
@@ -382,7 +382,7 @@ async function re(n) {
|
|
|
382
382
|
r.length > 0 && y(
|
|
383
383
|
"warn",
|
|
384
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/
|
|
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
386
|
`
|
|
387
387
|
);
|
|
388
388
|
}
|
|
@@ -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-DtWpxhlT.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
|
+
};
|