@arcgis/codemod 5.2.0-next.89 → 5.2.0-next.90
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-Bb_DEEbb.js → actions-ACvjOtUF.js} +1 -1
- package/dist/{actions-WUUe1M5q.js → actions-CKBQcIhe.js} +1 -1
- package/dist/actions-CakrAPrI.js +354 -0
- package/dist/actions-CtxXjpuZ.js +354 -0
- package/dist/{cli-DllOIioe.js → cli-3BztOTDV.js} +36 -36
- package/dist/{cli-sk_fNnii.js → cli-BIg5ZLTm.js} +36 -36
- package/dist/cli-BJ6P_2T-.js +266 -0
- package/dist/cli-CJfbqFa-.js +266 -0
- package/dist/cli.js +1 -1
- package/dist/{codemod-B890VM89.js → codemod-3QuC4SaX.js} +3 -3
- package/dist/{codemod-B_q1vMhe.js → codemod-8GvQmmZV.js} +3 -3
- package/dist/{codemod-CBEff9_v.js → codemod-BD9n1ra2.js} +3 -3
- package/dist/{codemod-BO-WPlNF.js → codemod-BNhkoGgL.js} +3 -3
- package/dist/{codemod-C4uHtbD9.js → codemod-BSrbZ8nr.js} +3 -3
- package/dist/{codemod-D08yZcS_.js → codemod-BWZBr6IZ.js} +3 -3
- package/dist/{codemod-BRvc75aN.js → codemod-Bz1NfItD.js} +3 -3
- package/dist/codemod-CJvMRUCq.js +140 -0
- package/dist/codemod-CRHygcg2.js +74 -0
- package/dist/codemod-CXiJ129U.js +436 -0
- package/dist/codemod-CzsItZhZ.js +74 -0
- package/dist/codemod-DOOtgv8R.js +436 -0
- package/dist/{codemod-CrAFHyU9.js → codemod-Dc4LGHgd.js} +3 -3
- package/dist/codemod-UDMxoQjk.js +6080 -0
- package/dist/codemod-Xx_q11AP.js +6080 -0
- package/dist/codemod-urnOPYsG.js +140 -0
- package/dist/{useProjectInstance-BbuqPuaN.js → useProjectInstance-5uuenLkM.js} +16 -13
- package/dist/{useProjectInstance-DTIFNCFG.js → useProjectInstance-CGaAin_6.js} +16 -13
- package/dist/useProjectInstance-DiZc_C2o.js +50 -0
- package/dist/useProjectInstance-DixfNjtt.js +50 -0
- package/package.json +4 -4
- package/dist/codemod-DggNINhi.js +0 -240
- package/dist/codemod-OB5VGkjy.js +0 -240
|
@@ -10,10 +10,10 @@ import { glob as T } from "tinyglobby";
|
|
|
10
10
|
import { gitIgnoreFileToGlobs as $ } from "@arcgis/node-toolkit/glob";
|
|
11
11
|
import { identity as L } from "@arcgis/toolkit/function";
|
|
12
12
|
import { styleText as S } from "node:util";
|
|
13
|
-
const q = (
|
|
14
|
-
const r = o
|
|
13
|
+
const q = (t, o, n) => {
|
|
14
|
+
const r = t[o];
|
|
15
15
|
return r ? typeof r == "function" ? r() : Promise.resolve(r) : new Promise((c, i) => {
|
|
16
|
-
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(i.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " +
|
|
16
|
+
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(i.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + o + (o.split("/").length !== n ? ". Note that variables only represent file names one level deep." : ""))));
|
|
17
17
|
});
|
|
18
18
|
}, ye = {
|
|
19
19
|
allowImportingTsExtensions: !0,
|
|
@@ -41,15 +41,15 @@ const q = (o, t, n) => {
|
|
|
41
41
|
project: void 0
|
|
42
42
|
};
|
|
43
43
|
async function z() {
|
|
44
|
-
const { ignorePatterns:
|
|
45
|
-
return
|
|
44
|
+
const { ignorePatterns: t, globRoot: o } = await H(), n = await Q(o);
|
|
45
|
+
return t.push(...n), { ignorePatterns: t, globRoot: o };
|
|
46
46
|
}
|
|
47
47
|
async function H() {
|
|
48
|
-
const
|
|
49
|
-
let
|
|
48
|
+
const t = [];
|
|
49
|
+
let o, n = F(), r = e.dirname(n);
|
|
50
50
|
do {
|
|
51
|
-
|
|
52
|
-
const c = e.join(
|
|
51
|
+
o = r;
|
|
52
|
+
const c = e.join(o, ".gitignore");
|
|
53
53
|
if (await B(c)) {
|
|
54
54
|
n = e.dirname(c);
|
|
55
55
|
const w = e.relative(n, F()).split("/"), y = $(c);
|
|
@@ -61,14 +61,14 @@ async function H() {
|
|
|
61
61
|
p = !1;
|
|
62
62
|
break;
|
|
63
63
|
}
|
|
64
|
-
p && (f.startsWith("!") ||
|
|
64
|
+
p && (f.startsWith("!") || t.push(f));
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
r = e.dirname(
|
|
68
|
-
} while (r !==
|
|
69
|
-
return { ignorePatterns:
|
|
67
|
+
r = e.dirname(o);
|
|
68
|
+
} while (r !== o);
|
|
69
|
+
return { ignorePatterns: t, globRoot: n };
|
|
70
70
|
}
|
|
71
|
-
async function Q(
|
|
71
|
+
async function Q(t) {
|
|
72
72
|
return (await T("**/.gitignore", {
|
|
73
73
|
cwd: F(),
|
|
74
74
|
// Gitignore files are unlikely to be symbolic links
|
|
@@ -85,7 +85,7 @@ async function Q(o) {
|
|
|
85
85
|
// Not applicable for our glob pattern
|
|
86
86
|
expandDirectories: !1
|
|
87
87
|
})).flatMap((n) => {
|
|
88
|
-
const r = e.relative(
|
|
88
|
+
const r = e.relative(t, e.dirname(n)), c = $(n), i = [];
|
|
89
89
|
for (const w of c)
|
|
90
90
|
w.startsWith("!") || i.push(e.join(r, w));
|
|
91
91
|
return i;
|
|
@@ -93,9 +93,9 @@ async function Q(o) {
|
|
|
93
93
|
}
|
|
94
94
|
const V = ["js", "jsx", "mjs", "cjs"], X = ["ts", "tsx", "mts", "cts"], Y = ["json"], Z = `**/*.{${[...V, ...X, ...Y].join(",")}}`;
|
|
95
95
|
async function ee() {
|
|
96
|
-
const
|
|
97
|
-
cwd:
|
|
98
|
-
ignore:
|
|
96
|
+
const t = await z(), o = e.join(process.cwd(), Z), n = await T(o, {
|
|
97
|
+
cwd: t.globRoot,
|
|
98
|
+
ignore: t.ignorePatterns,
|
|
99
99
|
// The files we are looking for are unlikely to be symbolic links
|
|
100
100
|
followSymbolicLinks: !1,
|
|
101
101
|
// Not applicable for our glob pattern
|
|
@@ -104,9 +104,9 @@ async function ee() {
|
|
|
104
104
|
// default behavior). If any tsconfig.json explicitly includes such files,
|
|
105
105
|
// they will still be codemodded.
|
|
106
106
|
});
|
|
107
|
-
let r = e.relative(
|
|
107
|
+
let r = e.relative(t.globRoot, process.cwd());
|
|
108
108
|
r !== "" && (r += "/");
|
|
109
|
-
const c = e.join(e.resolve(
|
|
109
|
+
const c = e.join(e.resolve(t.globRoot), "/"), i = c.length + r.length, w = [], y = [], f = /* @__PURE__ */ new Set();
|
|
110
110
|
for (const s of n) {
|
|
111
111
|
const l = c + s;
|
|
112
112
|
if (s.endsWith(".json")) {
|
|
@@ -174,7 +174,7 @@ async function ee() {
|
|
|
174
174
|
x = P;
|
|
175
175
|
break;
|
|
176
176
|
}
|
|
177
|
-
} while (C !==
|
|
177
|
+
} while (C !== t.globRoot && (C = e.dirname(C)));
|
|
178
178
|
const E = x === void 0 ? void 0 : { filePath: x, contents: await M(e.dirname(x)) }, O = {
|
|
179
179
|
typeScriptConfig: {
|
|
180
180
|
filePath: s,
|
|
@@ -203,7 +203,7 @@ async function ee() {
|
|
|
203
203
|
return p.sort((s, l) => s.cwd.localeCompare(l.cwd)), j.projectsData = p, p;
|
|
204
204
|
}
|
|
205
205
|
let _ = !1;
|
|
206
|
-
function
|
|
206
|
+
function te() {
|
|
207
207
|
_ || (_ = !0, process.exitCode !== void 0 && process.exitCode !== 0 ? h(
|
|
208
208
|
"warn",
|
|
209
209
|
j.codemodName,
|
|
@@ -218,49 +218,49 @@ function oe() {
|
|
|
218
218
|
- If your project uses TypeScript, run type checking to ensure there are no type errors.`
|
|
219
219
|
));
|
|
220
220
|
}
|
|
221
|
-
async function
|
|
222
|
-
j.codemod =
|
|
221
|
+
async function oe(t, o) {
|
|
222
|
+
j.codemod = t, j.codemodName = o;
|
|
223
223
|
const n = await ee();
|
|
224
224
|
if (n.length === 0) {
|
|
225
|
-
h("error",
|
|
225
|
+
h("error", o, `Failed to find any .js or .ts files in ${process.cwd()} to run the codemod on.`), process.exitCode = 1;
|
|
226
226
|
return;
|
|
227
227
|
}
|
|
228
|
-
await
|
|
228
|
+
await t.run(n), te();
|
|
229
229
|
}
|
|
230
230
|
const R = new K();
|
|
231
231
|
R.name("@arcgis/codemod").description("Codemod for migrating or refactoring usages of ArcGIS Maps SDK for JavaScript");
|
|
232
232
|
R.command("run").description("Run a single codemod").argument("<codemodName>", "Name of the transform").argument("[path]", "Directory to transform", process.cwd()).action(ne);
|
|
233
|
-
async function ne(
|
|
234
|
-
const n = U(
|
|
233
|
+
async function ne(t, o) {
|
|
234
|
+
const n = U(o, { throwIfNoEntry: !1 });
|
|
235
235
|
if (n === void 0) {
|
|
236
|
-
h("error", "@arcgis/codemod", `Failed to find the target path: ${
|
|
236
|
+
h("error", "@arcgis/codemod", `Failed to find the target path: ${o}`), process.exitCode = 1;
|
|
237
237
|
return;
|
|
238
238
|
}
|
|
239
239
|
const r = n.isFile();
|
|
240
|
-
process.chdir(r ? e.dirname(
|
|
240
|
+
process.chdir(r ? e.dirname(o) : o);
|
|
241
241
|
let c;
|
|
242
242
|
try {
|
|
243
|
-
c = await q(/* @__PURE__ */ Object.assign({ "./codemods/api-extractor-strict-mode/codemod.ts": () => import("./codemod-
|
|
243
|
+
c = await q(/* @__PURE__ */ Object.assign({ "./codemods/api-extractor-strict-mode/codemod.ts": () => import("./codemod-DOOtgv8R.js"), "./codemods/node-toolkit/codemod.ts": () => import("./codemod-CJvMRUCq.js"), "./codemods/refactor-out-esri-namespace/codemod.ts": () => import("./codemod-UDMxoQjk.js"), "./codemods/toolkit-5.2-renames/codemod.ts": () => import("./codemod-BD9n1ra2.js") }), `./codemods/${t}/codemod.ts`, 4);
|
|
244
244
|
} catch (i) {
|
|
245
245
|
if (
|
|
246
246
|
// direct Node execution
|
|
247
|
-
typeof i == "object" && i !== null && "code" in i && i.code === "ERR_MODULE_NOT_FOUND" && "url" in i && typeof i.url == "string" && i.url.endsWith(`${e.sep}${
|
|
247
|
+
typeof i == "object" && i !== null && "code" in i && i.code === "ERR_MODULE_NOT_FOUND" && "url" in i && typeof i.url == "string" && i.url.endsWith(`${e.sep}${t}${e.sep}codemod.ts`) || // Vite build execution
|
|
248
248
|
String(i).includes("Unknown variable dynamic import:")
|
|
249
249
|
) {
|
|
250
|
-
h("error", "@arcgis/codemod", `Can't find codemod by name "${
|
|
250
|
+
h("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
251
251
|
return;
|
|
252
252
|
} else
|
|
253
253
|
throw i;
|
|
254
254
|
}
|
|
255
255
|
if (typeof c.codemod != "object" || c.codemod === null) {
|
|
256
|
-
h("error", "@arcgis/codemod", `Can't find codemod by name "${
|
|
256
|
+
h("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
|
-
await
|
|
259
|
+
await oe(c.codemod, S("blue", t));
|
|
260
260
|
}
|
|
261
261
|
R.parse();
|
|
262
262
|
export {
|
|
263
263
|
ye as d,
|
|
264
264
|
j as g,
|
|
265
|
-
|
|
265
|
+
te as p
|
|
266
266
|
};
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { log as h } from "@arcgis/toolkit/log";
|
|
2
|
+
import { Command as K } from "@commander-js/extra-typings";
|
|
3
|
+
import { statSync as U } from "node:fs";
|
|
4
|
+
import { getCwd as F, path as e, toPosixPathSeparators as J } from "@arcgis/node-toolkit/path";
|
|
5
|
+
import "ts-morph";
|
|
6
|
+
import a from "typescript";
|
|
7
|
+
import { existsAsync as B, asyncFindPath as W } from "@arcgis/node-toolkit/file";
|
|
8
|
+
import { asyncRetrievePackageJson as M } from "@arcgis/node-toolkit/packageJson";
|
|
9
|
+
import { glob as T } from "tinyglobby";
|
|
10
|
+
import { gitIgnoreFileToGlobs as $ } from "@arcgis/node-toolkit/glob";
|
|
11
|
+
import { identity as L } from "@arcgis/toolkit/function";
|
|
12
|
+
import { styleText as S } from "node:util";
|
|
13
|
+
const q = (t, o, n) => {
|
|
14
|
+
const r = t[o];
|
|
15
|
+
return r ? typeof r == "function" ? r() : Promise.resolve(r) : new Promise((c, i) => {
|
|
16
|
+
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(i.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + o + (o.split("/").length !== n ? ". Note that variables only represent file names one level deep." : ""))));
|
|
17
|
+
});
|
|
18
|
+
}, ye = {
|
|
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: a.JsxEmit.Preserve,
|
|
29
|
+
lib: ["lib.esnext.d.ts", "lib.dom.d.ts"],
|
|
30
|
+
module: a.ModuleKind.ESNext,
|
|
31
|
+
moduleResolution: a.ModuleResolutionKind.Bundler,
|
|
32
|
+
moduleDetection: a.ModuleDetectionKind.Auto,
|
|
33
|
+
strict: !1,
|
|
34
|
+
target: a.ScriptTarget.ESNext,
|
|
35
|
+
resolveJsonModule: !0,
|
|
36
|
+
esModuleInterop: !0
|
|
37
|
+
}, j = {
|
|
38
|
+
codemod: void 0,
|
|
39
|
+
codemodName: void 0,
|
|
40
|
+
projectsData: void 0,
|
|
41
|
+
project: void 0
|
|
42
|
+
};
|
|
43
|
+
async function z() {
|
|
44
|
+
const { ignorePatterns: t, globRoot: o } = await H(), n = await Q(o);
|
|
45
|
+
return t.push(...n), { ignorePatterns: t, globRoot: o };
|
|
46
|
+
}
|
|
47
|
+
async function H() {
|
|
48
|
+
const t = [];
|
|
49
|
+
let o, n = F(), r = e.dirname(n);
|
|
50
|
+
do {
|
|
51
|
+
o = r;
|
|
52
|
+
const c = e.join(o, ".gitignore");
|
|
53
|
+
if (await B(c)) {
|
|
54
|
+
n = e.dirname(c);
|
|
55
|
+
const w = e.relative(n, F()).split("/"), y = $(c);
|
|
56
|
+
for (const f of y) {
|
|
57
|
+
const m = (f.startsWith("!") ? f.slice(1) : f).split("*")[0].split("/");
|
|
58
|
+
let p = !0;
|
|
59
|
+
for (let g = 0; g < m.length; g++)
|
|
60
|
+
if (w[g] !== m[g] && m[g] !== "") {
|
|
61
|
+
p = !1;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
p && (f.startsWith("!") || t.push(f));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
r = e.dirname(o);
|
|
68
|
+
} while (r !== o);
|
|
69
|
+
return { ignorePatterns: t, globRoot: n };
|
|
70
|
+
}
|
|
71
|
+
async function Q(t) {
|
|
72
|
+
return (await T("**/.gitignore", {
|
|
73
|
+
cwd: F(),
|
|
74
|
+
// Gitignore files are unlikely to be symbolic links
|
|
75
|
+
followSymbolicLinks: !1,
|
|
76
|
+
// Don't look for ignore files in these places for speed:
|
|
77
|
+
ignore: [
|
|
78
|
+
// Hardcoded ignores in TypeScript
|
|
79
|
+
"**/node_modules/**",
|
|
80
|
+
"**/bower_components/**",
|
|
81
|
+
"**/jspm_packages/**",
|
|
82
|
+
// Default build output folder in bundlers
|
|
83
|
+
"**/dist/**"
|
|
84
|
+
],
|
|
85
|
+
// Not applicable for our glob pattern
|
|
86
|
+
expandDirectories: !1
|
|
87
|
+
})).flatMap((n) => {
|
|
88
|
+
const r = e.relative(t, e.dirname(n)), c = $(n), i = [];
|
|
89
|
+
for (const w of c)
|
|
90
|
+
w.startsWith("!") || i.push(e.join(r, w));
|
|
91
|
+
return i;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
const V = ["js", "jsx", "mjs", "cjs"], X = ["ts", "tsx", "mts", "cts"], Y = ["json"], Z = `**/*.{${[...V, ...X, ...Y].join(",")}}`;
|
|
95
|
+
async function ee() {
|
|
96
|
+
const t = await z(), o = e.join(process.cwd(), Z), n = await T(o, {
|
|
97
|
+
cwd: t.globRoot,
|
|
98
|
+
ignore: t.ignorePatterns,
|
|
99
|
+
// The files we are looking for are unlikely to be symbolic links
|
|
100
|
+
followSymbolicLinks: !1,
|
|
101
|
+
// Not applicable for our glob pattern
|
|
102
|
+
expandDirectories: !1
|
|
103
|
+
// Files and folders starting with . are excluded (matches TypeScript's
|
|
104
|
+
// default behavior). If any tsconfig.json explicitly includes such files,
|
|
105
|
+
// they will still be codemodded.
|
|
106
|
+
});
|
|
107
|
+
let r = e.relative(t.globRoot, process.cwd());
|
|
108
|
+
r !== "" && (r += "/");
|
|
109
|
+
const c = e.join(e.resolve(t.globRoot), "/"), i = c.length + r.length, w = [], y = [], f = /* @__PURE__ */ new Set();
|
|
110
|
+
for (const s of n) {
|
|
111
|
+
const l = c + s;
|
|
112
|
+
if (s.endsWith(".json")) {
|
|
113
|
+
const d = e.basename(s);
|
|
114
|
+
d === "package.json" ? w.push(l) : (d.startsWith("tsconfig.") || d.startsWith("jsconfig.")) && y.push(l);
|
|
115
|
+
} else {
|
|
116
|
+
const d = s.slice(r.length);
|
|
117
|
+
f.add(d);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
let v = await W("tsconfig.json", e.dirname(process.cwd()));
|
|
121
|
+
v !== void 0 && (v = J(v), y.push(v)), y.sort((s, l) => {
|
|
122
|
+
const d = l.split("/").length - s.split("/").length;
|
|
123
|
+
if (d !== 0)
|
|
124
|
+
return d;
|
|
125
|
+
const b = e.basename(s), u = e.basename(l);
|
|
126
|
+
return b === u ? 0 : b.endsWith("tsconfig.json") ? -1 : u.endsWith("tsconfig.json") ? 1 : b.endsWith("tsconfig.build.json") ? -1 : u.endsWith("tsconfig.build.json") ? 1 : b.localeCompare(u);
|
|
127
|
+
});
|
|
128
|
+
let m = await W("package.json");
|
|
129
|
+
m !== void 0 && (m = J(m));
|
|
130
|
+
const p = [], g = /* @__PURE__ */ new Set();
|
|
131
|
+
if (await Promise.all(
|
|
132
|
+
y.map(async (s) => {
|
|
133
|
+
const l = e.relative(process.cwd(), s), d = a.readConfigFile(s, a.sys.readFile);
|
|
134
|
+
if (d.error !== void 0) {
|
|
135
|
+
h(
|
|
136
|
+
"error",
|
|
137
|
+
l,
|
|
138
|
+
a.formatDiagnosticsWithColorAndContext([d.error], {
|
|
139
|
+
getCanonicalFileName: L,
|
|
140
|
+
getCurrentDirectory: a.sys.getCurrentDirectory,
|
|
141
|
+
getNewLine: () => a.sys.newLine
|
|
142
|
+
})
|
|
143
|
+
);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const b = e.basename(l), u = a.parseJsonConfigFileContent(
|
|
147
|
+
d.config,
|
|
148
|
+
a.sys,
|
|
149
|
+
e.dirname(s),
|
|
150
|
+
void 0,
|
|
151
|
+
b
|
|
152
|
+
), A = 18003;
|
|
153
|
+
u.errors.filter((P) => P.code !== A).length > 0 && h(
|
|
154
|
+
"warn",
|
|
155
|
+
l,
|
|
156
|
+
a.formatDiagnosticsWithColorAndContext(u.errors, {
|
|
157
|
+
getCanonicalFileName: L,
|
|
158
|
+
getCurrentDirectory: a.sys.getCurrentDirectory,
|
|
159
|
+
getNewLine: () => a.sys.newLine
|
|
160
|
+
})
|
|
161
|
+
);
|
|
162
|
+
const I = s === v, G = l === b, N = u.fileNames.filter((P) => {
|
|
163
|
+
const D = P.slice(i);
|
|
164
|
+
return f.delete(D) ? (g.add(D), !0) : g.has(D) || D.endsWith(".json") || P.includes("node_modules") ? !1 : !I;
|
|
165
|
+
});
|
|
166
|
+
if (N.length === 0)
|
|
167
|
+
return;
|
|
168
|
+
y.length === 1 && (I || G) && f.clear();
|
|
169
|
+
const k = e.dirname(s);
|
|
170
|
+
let C = k, x = m;
|
|
171
|
+
do {
|
|
172
|
+
const P = e.join(C, "package.json");
|
|
173
|
+
if (w.includes(P)) {
|
|
174
|
+
x = P;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
} while (C !== t.globRoot && (C = e.dirname(C)));
|
|
178
|
+
const E = x === void 0 ? void 0 : { filePath: x, contents: await M(e.dirname(x)) }, O = {
|
|
179
|
+
typeScriptConfig: {
|
|
180
|
+
filePath: s,
|
|
181
|
+
compilerOptions: u.options
|
|
182
|
+
},
|
|
183
|
+
packageJson: E,
|
|
184
|
+
logName: S("blue", E?.contents?.name ?? k),
|
|
185
|
+
cwd: k,
|
|
186
|
+
filePaths: N
|
|
187
|
+
};
|
|
188
|
+
p.push(O);
|
|
189
|
+
})
|
|
190
|
+
), f.size > 0) {
|
|
191
|
+
const s = m === void 0 ? void 0 : {
|
|
192
|
+
filePath: m,
|
|
193
|
+
contents: await M(e.dirname(m))
|
|
194
|
+
};
|
|
195
|
+
p.push({
|
|
196
|
+
typeScriptConfig: void 0,
|
|
197
|
+
packageJson: s,
|
|
198
|
+
cwd: process.cwd(),
|
|
199
|
+
logName: S("blue", s?.contents?.name ?? process.cwd()),
|
|
200
|
+
filePaths: Array.from(f).map((l) => e.join(process.cwd(), l))
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return p.sort((s, l) => s.cwd.localeCompare(l.cwd)), j.projectsData = p, p;
|
|
204
|
+
}
|
|
205
|
+
let _ = !1;
|
|
206
|
+
function te() {
|
|
207
|
+
_ || (_ = !0, process.exitCode !== void 0 && process.exitCode !== 0 ? h(
|
|
208
|
+
"warn",
|
|
209
|
+
j.codemodName,
|
|
210
|
+
"One or more exceptions occurred during the codemod run. Please review the output above."
|
|
211
|
+
) : h(
|
|
212
|
+
"info",
|
|
213
|
+
j.codemodName,
|
|
214
|
+
`${S("green", "Codemod completed successfully.")} Recommended next steps:
|
|
215
|
+
- Review the codemod changes.
|
|
216
|
+
- If your project uses ESLint, run ESLint autofix on the changed files.
|
|
217
|
+
- If your project uses Prettier, run Prettier on the changed files.
|
|
218
|
+
- If your project uses TypeScript, run type checking to ensure there are no type errors.`
|
|
219
|
+
));
|
|
220
|
+
}
|
|
221
|
+
async function oe(t, o) {
|
|
222
|
+
j.codemod = t, j.codemodName = o;
|
|
223
|
+
const n = await ee();
|
|
224
|
+
if (n.length === 0) {
|
|
225
|
+
h("error", o, `Failed to find any .js or .ts files in ${process.cwd()} to run the codemod on.`), process.exitCode = 1;
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
await t.run(n), te();
|
|
229
|
+
}
|
|
230
|
+
const R = new K();
|
|
231
|
+
R.name("@arcgis/codemod").description("Codemod for migrating or refactoring usages of ArcGIS Maps SDK for JavaScript");
|
|
232
|
+
R.command("run").description("Run a single codemod").argument("<codemodName>", "Name of the transform").argument("[path]", "Directory to transform", process.cwd()).action(ne);
|
|
233
|
+
async function ne(t, o) {
|
|
234
|
+
const n = U(o, { throwIfNoEntry: !1 });
|
|
235
|
+
if (n === void 0) {
|
|
236
|
+
h("error", "@arcgis/codemod", `Failed to find the target path: ${o}`), process.exitCode = 1;
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const r = n.isFile();
|
|
240
|
+
process.chdir(r ? e.dirname(o) : o);
|
|
241
|
+
let c;
|
|
242
|
+
try {
|
|
243
|
+
c = await q(/* @__PURE__ */ Object.assign({ "./codemods/api-extractor-strict-mode/codemod.ts": () => import("./codemod-CXiJ129U.js"), "./codemods/node-toolkit/codemod.ts": () => import("./codemod-urnOPYsG.js"), "./codemods/refactor-out-esri-namespace/codemod.ts": () => import("./codemod-BSrbZ8nr.js"), "./codemods/toolkit-5.2-renames/codemod.ts": () => import("./codemod-3QuC4SaX.js") }), `./codemods/${t}/codemod.ts`, 4);
|
|
244
|
+
} catch (i) {
|
|
245
|
+
if (
|
|
246
|
+
// direct Node execution
|
|
247
|
+
typeof i == "object" && i !== null && "code" in i && i.code === "ERR_MODULE_NOT_FOUND" && "url" in i && typeof i.url == "string" && i.url.endsWith(`${e.sep}${t}${e.sep}codemod.ts`) || // Vite build execution
|
|
248
|
+
String(i).includes("Unknown variable dynamic import:")
|
|
249
|
+
) {
|
|
250
|
+
h("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
251
|
+
return;
|
|
252
|
+
} else
|
|
253
|
+
throw i;
|
|
254
|
+
}
|
|
255
|
+
if (typeof c.codemod != "object" || c.codemod === null) {
|
|
256
|
+
h("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
await oe(c.codemod, S("blue", t));
|
|
260
|
+
}
|
|
261
|
+
R.parse();
|
|
262
|
+
export {
|
|
263
|
+
ye as d,
|
|
264
|
+
j as g,
|
|
265
|
+
te as p
|
|
266
|
+
};
|