@arcgis/codemod 5.2.0-next.9 → 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/LICENSE.md +4 -2
- package/README.md +42 -7
- package/dist/{actions-BBxr-9ge.js → actions-ACvjOtUF.js} +2 -2
- package/dist/actions-CKBQcIhe.js +354 -0
- package/dist/actions-CakrAPrI.js +354 -0
- package/dist/actions-CtxXjpuZ.js +354 -0
- package/dist/{cli-DPzs7oKq.js → cli-3BztOTDV.js} +33 -29
- package/dist/cli-BIg5ZLTm.js +266 -0
- package/dist/cli-BJ6P_2T-.js +266 -0
- package/dist/cli-CJfbqFa-.js +266 -0
- package/dist/cli.js +2 -2
- package/dist/codemod-3QuC4SaX.js +74 -0
- package/dist/codemod-8GvQmmZV.js +140 -0
- package/dist/codemod-BD9n1ra2.js +74 -0
- package/dist/{codemod-AVvtg1JZ.js → codemod-BNhkoGgL.js} +4 -4
- package/dist/{codemod-mhjHtX3y.js → codemod-BSrbZ8nr.js} +3 -3
- package/dist/codemod-BWZBr6IZ.js +140 -0
- package/dist/codemod-Bz1NfItD.js +436 -0
- 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-Dc4LGHgd.js +6080 -0
- 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-CiX-mY1O.js → useProjectInstance-5uuenLkM.js} +2 -2
- package/dist/useProjectInstance-CGaAin_6.js +50 -0
- package/dist/useProjectInstance-DiZc_C2o.js +50 -0
- package/dist/useProjectInstance-DixfNjtt.js +50 -0
- package/package.json +11 -9
- package/dist/codemod-Cv6_nCqP.js +0 -157
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { log as h } from "@arcgis/toolkit/log";
|
|
2
2
|
import { Command as K } from "@commander-js/extra-typings";
|
|
3
3
|
import { statSync as U } from "node:fs";
|
|
4
|
-
import { getCwd as
|
|
4
|
+
import { getCwd as F, path as e, toPosixPathSeparators as J } from "@arcgis/node-toolkit/path";
|
|
5
5
|
import "ts-morph";
|
|
6
6
|
import a from "typescript";
|
|
7
|
-
import {
|
|
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";
|
|
8
11
|
import { identity as L } from "@arcgis/toolkit/function";
|
|
9
12
|
import { styleText as S } from "node:util";
|
|
10
13
|
const q = (t, o, n) => {
|
|
@@ -12,7 +15,7 @@ const q = (t, o, n) => {
|
|
|
12
15
|
return r ? typeof r == "function" ? r() : Promise.resolve(r) : new Promise((c, i) => {
|
|
13
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." : ""))));
|
|
14
17
|
});
|
|
15
|
-
},
|
|
18
|
+
}, ye = {
|
|
16
19
|
allowImportingTsExtensions: !0,
|
|
17
20
|
allowJs: !0,
|
|
18
21
|
allowArbitraryExtensions: !0,
|
|
@@ -43,13 +46,13 @@ async function z() {
|
|
|
43
46
|
}
|
|
44
47
|
async function H() {
|
|
45
48
|
const t = [];
|
|
46
|
-
let o, n =
|
|
49
|
+
let o, n = F(), r = e.dirname(n);
|
|
47
50
|
do {
|
|
48
51
|
o = r;
|
|
49
52
|
const c = e.join(o, ".gitignore");
|
|
50
53
|
if (await B(c)) {
|
|
51
54
|
n = e.dirname(c);
|
|
52
|
-
const w = e.relative(n,
|
|
55
|
+
const w = e.relative(n, F()).split("/"), y = $(c);
|
|
53
56
|
for (const f of y) {
|
|
54
57
|
const m = (f.startsWith("!") ? f.slice(1) : f).split("*")[0].split("/");
|
|
55
58
|
let p = !0;
|
|
@@ -66,7 +69,8 @@ async function H() {
|
|
|
66
69
|
return { ignorePatterns: t, globRoot: n };
|
|
67
70
|
}
|
|
68
71
|
async function Q(t) {
|
|
69
|
-
return (await
|
|
72
|
+
return (await T("**/.gitignore", {
|
|
73
|
+
cwd: F(),
|
|
70
74
|
// Gitignore files are unlikely to be symbolic links
|
|
71
75
|
followSymbolicLinks: !1,
|
|
72
76
|
// Don't look for ignore files in these places for speed:
|
|
@@ -81,7 +85,7 @@ async function Q(t) {
|
|
|
81
85
|
// Not applicable for our glob pattern
|
|
82
86
|
expandDirectories: !1
|
|
83
87
|
})).flatMap((n) => {
|
|
84
|
-
const r = e.relative(t, e.dirname(n)), c =
|
|
88
|
+
const r = e.relative(t, e.dirname(n)), c = $(n), i = [];
|
|
85
89
|
for (const w of c)
|
|
86
90
|
w.startsWith("!") || i.push(e.join(r, w));
|
|
87
91
|
return i;
|
|
@@ -89,7 +93,7 @@ async function Q(t) {
|
|
|
89
93
|
}
|
|
90
94
|
const V = ["js", "jsx", "mjs", "cjs"], X = ["ts", "tsx", "mts", "cts"], Y = ["json"], Z = `**/*.{${[...V, ...X, ...Y].join(",")}}`;
|
|
91
95
|
async function ee() {
|
|
92
|
-
const t = await z(), o = e.join(process.cwd(), Z), n = await
|
|
96
|
+
const t = await z(), o = e.join(process.cwd(), Z), n = await T(o, {
|
|
93
97
|
cwd: t.globRoot,
|
|
94
98
|
ignore: t.ignorePatterns,
|
|
95
99
|
// The files we are looking for are unlikely to be symbolic links
|
|
@@ -113,16 +117,16 @@ async function ee() {
|
|
|
113
117
|
f.add(d);
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
|
-
let v = await
|
|
117
|
-
v !== void 0 && (v =
|
|
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) => {
|
|
118
122
|
const d = l.split("/").length - s.split("/").length;
|
|
119
123
|
if (d !== 0)
|
|
120
124
|
return d;
|
|
121
125
|
const b = e.basename(s), u = e.basename(l);
|
|
122
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);
|
|
123
127
|
});
|
|
124
|
-
let m = await
|
|
125
|
-
m !== void 0 && (m =
|
|
128
|
+
let m = await W("package.json");
|
|
129
|
+
m !== void 0 && (m = J(m));
|
|
126
130
|
const p = [], g = /* @__PURE__ */ new Set();
|
|
127
131
|
if (await Promise.all(
|
|
128
132
|
y.map(async (s) => {
|
|
@@ -155,15 +159,15 @@ async function ee() {
|
|
|
155
159
|
getNewLine: () => a.sys.newLine
|
|
156
160
|
})
|
|
157
161
|
);
|
|
158
|
-
const
|
|
162
|
+
const I = s === v, G = l === b, N = u.fileNames.filter((P) => {
|
|
159
163
|
const D = P.slice(i);
|
|
160
|
-
return f.delete(D) ? (g.add(D), !0) : g.has(D) || D.endsWith(".json") || P.includes("node_modules") ? !1 : !
|
|
164
|
+
return f.delete(D) ? (g.add(D), !0) : g.has(D) || D.endsWith(".json") || P.includes("node_modules") ? !1 : !I;
|
|
161
165
|
});
|
|
162
|
-
if (
|
|
166
|
+
if (N.length === 0)
|
|
163
167
|
return;
|
|
164
|
-
y.length === 1 && (
|
|
165
|
-
const
|
|
166
|
-
let C =
|
|
168
|
+
y.length === 1 && (I || G) && f.clear();
|
|
169
|
+
const k = e.dirname(s);
|
|
170
|
+
let C = k, x = m;
|
|
167
171
|
do {
|
|
168
172
|
const P = e.join(C, "package.json");
|
|
169
173
|
if (w.includes(P)) {
|
|
@@ -171,15 +175,15 @@ async function ee() {
|
|
|
171
175
|
break;
|
|
172
176
|
}
|
|
173
177
|
} while (C !== t.globRoot && (C = e.dirname(C)));
|
|
174
|
-
const
|
|
178
|
+
const E = x === void 0 ? void 0 : { filePath: x, contents: await M(e.dirname(x)) }, O = {
|
|
175
179
|
typeScriptConfig: {
|
|
176
180
|
filePath: s,
|
|
177
181
|
compilerOptions: u.options
|
|
178
182
|
},
|
|
179
|
-
packageJson:
|
|
180
|
-
logName: S("blue",
|
|
181
|
-
cwd:
|
|
182
|
-
filePaths:
|
|
183
|
+
packageJson: E,
|
|
184
|
+
logName: S("blue", E?.contents?.name ?? k),
|
|
185
|
+
cwd: k,
|
|
186
|
+
filePaths: N
|
|
183
187
|
};
|
|
184
188
|
p.push(O);
|
|
185
189
|
})
|
|
@@ -223,9 +227,9 @@ async function oe(t, o) {
|
|
|
223
227
|
}
|
|
224
228
|
await t.run(n), te();
|
|
225
229
|
}
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
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);
|
|
229
233
|
async function ne(t, o) {
|
|
230
234
|
const n = U(o, { throwIfNoEntry: !1 });
|
|
231
235
|
if (n === void 0) {
|
|
@@ -236,7 +240,7 @@ async function ne(t, o) {
|
|
|
236
240
|
process.chdir(r ? e.dirname(o) : o);
|
|
237
241
|
let c;
|
|
238
242
|
try {
|
|
239
|
-
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-Bz1NfItD.js"), "./codemods/node-toolkit/codemod.ts": () => import("./codemod-8GvQmmZV.js"), "./codemods/refactor-out-esri-namespace/codemod.ts": () => import("./codemod-Xx_q11AP.js"), "./codemods/toolkit-5.2-renames/codemod.ts": () => import("./codemod-CzsItZhZ.js") }), `./codemods/${t}/codemod.ts`, 4);
|
|
240
244
|
} catch (i) {
|
|
241
245
|
if (
|
|
242
246
|
// direct Node execution
|
|
@@ -254,9 +258,9 @@ async function ne(t, o) {
|
|
|
254
258
|
}
|
|
255
259
|
await oe(c.codemod, S("blue", t));
|
|
256
260
|
}
|
|
257
|
-
|
|
261
|
+
R.parse();
|
|
258
262
|
export {
|
|
259
|
-
|
|
263
|
+
ye as d,
|
|
260
264
|
j as g,
|
|
261
265
|
te as p
|
|
262
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-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
|
+
} 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
|
+
};
|