@arcgis/codemod 5.2.0-next.9 → 5.2.0-next.91
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-Cc94nYsB.js} +2 -2
- package/dist/cli-DJQ7NdBK.js +269 -0
- package/dist/cli.js +2 -2
- package/dist/codemod-ByVDKNVh.js +140 -0
- package/dist/{codemod-mhjHtX3y.js → codemod-CDDi4e40.js} +3 -3
- package/dist/codemod-CPBSioID.js +311 -0
- package/dist/{codemod-AVvtg1JZ.js → codemod-CUdF3oIK.js} +5 -5
- package/dist/codemod-DgA0GL73.js +74 -0
- package/dist/codemod-TKeUnFf8.js +240 -0
- package/dist/{useProjectInstance-CiX-mY1O.js → useProjectInstance-PcBD3mbo.js} +13 -16
- package/package.json +11 -9
- package/dist/cli-DPzs7oKq.js +0 -262
- package/dist/codemod-Cv6_nCqP.js +0 -157
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Project as
|
|
2
|
-
import { log as
|
|
3
|
-
import { path as
|
|
4
|
-
import { g as t, d } from "./cli-
|
|
1
|
+
import { Project as p } from "ts-morph";
|
|
2
|
+
import { log as d } from "@arcgis/toolkit/log";
|
|
3
|
+
import { path as f } from "@arcgis/node-toolkit/path";
|
|
4
|
+
import { g as t, d as m } from "./cli-DJQ7NdBK.js";
|
|
5
5
|
import { styleText as s } from "node:util";
|
|
6
|
-
function
|
|
6
|
+
function y(e) {
|
|
7
7
|
if (t.project !== void 0)
|
|
8
8
|
throw Error(
|
|
9
9
|
"A different ts-morph Project is already in use. Dispose of it before creating a new one. Example: using project = createProjectInstance(...)"
|
|
10
10
|
);
|
|
11
|
-
const i = t.codemod.meta.needsTypeInformation, o = new
|
|
11
|
+
const i = t.codemod.meta.needsTypeInformation, o = new p({
|
|
12
12
|
// If tsconfig is missing, or project is untyped, use a permissive and
|
|
13
13
|
// compatible default config
|
|
14
14
|
compilerOptions: e.typeScriptConfig?.compilerOptions ?? {
|
|
15
|
-
...
|
|
15
|
+
...m,
|
|
16
16
|
// Read types from JSDoc annotations if present
|
|
17
17
|
checkJs: i
|
|
18
18
|
},
|
|
@@ -23,12 +23,10 @@ function P(e) {
|
|
|
23
23
|
// We call this manually if needed below.
|
|
24
24
|
skipFileDependencyResolution: !0,
|
|
25
25
|
skipLoadingLibFiles: !i
|
|
26
|
-
});
|
|
27
|
-
for (const n of e.filePaths)
|
|
28
|
-
o.addSourceFileAtPath(n);
|
|
26
|
+
}), l = e.filePaths.map((n) => o.addSourceFileAtPath(n));
|
|
29
27
|
i && o.resolveSourceFileDependencies();
|
|
30
|
-
const r =
|
|
31
|
-
process.stdout.write(""),
|
|
28
|
+
const r = f.relative(process.cwd(), e.cwd);
|
|
29
|
+
process.stdout.write(""), d(
|
|
32
30
|
"info",
|
|
33
31
|
s("blue", r === "" ? process.cwd() : r),
|
|
34
32
|
`Running the codemod on ${s("blue", String(e.filePaths.length))} file${e.filePaths.length !== 1 ? "s" : ""}${e.packageJson?.contents.name === void 0 ? "" : ` from ${s("blue", e.packageJson.contents.name)}`}`
|
|
@@ -38,13 +36,12 @@ function P(e) {
|
|
|
38
36
|
o.saveSync(), o.getRootDirectories().forEach((n) => n.forget()), t.project = void 0;
|
|
39
37
|
},
|
|
40
38
|
projectData: e,
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
getCodemodFiles: () => o.getSourceFiles().slice(0, e.filePaths.length),
|
|
39
|
+
// Resolved dependencies support type checking but are not codemod targets.
|
|
40
|
+
getCodemodFiles: () => l,
|
|
44
41
|
tsMorph: o
|
|
45
42
|
};
|
|
46
43
|
return t.project = c, c;
|
|
47
44
|
}
|
|
48
45
|
export {
|
|
49
|
-
|
|
46
|
+
y as c
|
|
50
47
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/codemod",
|
|
3
|
-
"version": "5.2.0-next.
|
|
3
|
+
"version": "5.2.0-next.91",
|
|
4
4
|
"description": "A codemod toolkit for updating and modernizing ArcGIS Maps SDK for JavaScript codebases.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -9,17 +9,19 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/"
|
|
11
11
|
],
|
|
12
|
-
"bin": "./bin/cli.js",
|
|
13
12
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
14
13
|
"dependencies": {
|
|
15
|
-
"@
|
|
16
|
-
"
|
|
17
|
-
"
|
|
14
|
+
"@arcgis/api-extractor": "5.2.0-next.91",
|
|
15
|
+
"@arcgis/node-toolkit": "5.2.0-next.91",
|
|
16
|
+
"@arcgis/toolkit": "5.2.0-next.91",
|
|
17
|
+
"@commander-js/extra-typings": "^15.0.0",
|
|
18
|
+
"commander": "^15.0.0",
|
|
19
|
+
"tinyglobby": "~0.2.17",
|
|
18
20
|
"ts-morph": "^28.0.0",
|
|
19
21
|
"tslib": "^2.8.1",
|
|
20
|
-
"typescript": "~6.0.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
22
|
+
"typescript": "~6.0.3"
|
|
23
|
+
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"codemod": "./bin/cli.js"
|
|
24
26
|
}
|
|
25
27
|
}
|
package/dist/cli-DPzs7oKq.js
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
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 E, path as e, existsAsync as B, gitIgnoreFileToGlobs as T, asyncFindPath as J, toPosixPathSeparators as W, asyncRetrievePackageJson as M } from "@arcgis/components-build-utils";
|
|
5
|
-
import "ts-morph";
|
|
6
|
-
import a from "typescript";
|
|
7
|
-
import { glob as $ } from "tinyglobby";
|
|
8
|
-
import { identity as L } from "@arcgis/toolkit/function";
|
|
9
|
-
import { styleText as S } from "node:util";
|
|
10
|
-
const q = (t, o, n) => {
|
|
11
|
-
const r = t[o];
|
|
12
|
-
return r ? typeof r == "function" ? r() : Promise.resolve(r) : new Promise((c, i) => {
|
|
13
|
-
(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
|
-
});
|
|
15
|
-
}, ge = {
|
|
16
|
-
allowImportingTsExtensions: !0,
|
|
17
|
-
allowJs: !0,
|
|
18
|
-
allowArbitraryExtensions: !0,
|
|
19
|
-
allowSyntheticDefaultImports: !0,
|
|
20
|
-
checkJs: !0,
|
|
21
|
-
experimentalDecorators: !0,
|
|
22
|
-
forceConsistentCasingInFileNames: !1,
|
|
23
|
-
isolatedModules: !1,
|
|
24
|
-
isolatedDeclarations: !1,
|
|
25
|
-
jsx: a.JsxEmit.Preserve,
|
|
26
|
-
lib: ["lib.esnext.d.ts", "lib.dom.d.ts"],
|
|
27
|
-
module: a.ModuleKind.ESNext,
|
|
28
|
-
moduleResolution: a.ModuleResolutionKind.Bundler,
|
|
29
|
-
moduleDetection: a.ModuleDetectionKind.Auto,
|
|
30
|
-
strict: !1,
|
|
31
|
-
target: a.ScriptTarget.ESNext,
|
|
32
|
-
resolveJsonModule: !0,
|
|
33
|
-
esModuleInterop: !0
|
|
34
|
-
}, j = {
|
|
35
|
-
codemod: void 0,
|
|
36
|
-
codemodName: void 0,
|
|
37
|
-
projectsData: void 0,
|
|
38
|
-
project: void 0
|
|
39
|
-
};
|
|
40
|
-
async function z() {
|
|
41
|
-
const { ignorePatterns: t, globRoot: o } = await H(), n = await Q(o);
|
|
42
|
-
return t.push(...n), { ignorePatterns: t, globRoot: o };
|
|
43
|
-
}
|
|
44
|
-
async function H() {
|
|
45
|
-
const t = [];
|
|
46
|
-
let o, n = E(), r = e.dirname(n);
|
|
47
|
-
do {
|
|
48
|
-
o = r;
|
|
49
|
-
const c = e.join(o, ".gitignore");
|
|
50
|
-
if (await B(c)) {
|
|
51
|
-
n = e.dirname(c);
|
|
52
|
-
const w = e.relative(n, E()).split("/"), y = T(c);
|
|
53
|
-
for (const f of y) {
|
|
54
|
-
const m = (f.startsWith("!") ? f.slice(1) : f).split("*")[0].split("/");
|
|
55
|
-
let p = !0;
|
|
56
|
-
for (let g = 0; g < m.length; g++)
|
|
57
|
-
if (w[g] !== m[g] && m[g] !== "") {
|
|
58
|
-
p = !1;
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
p && (f.startsWith("!") || t.push(f));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
r = e.dirname(o);
|
|
65
|
-
} while (r !== o);
|
|
66
|
-
return { ignorePatterns: t, globRoot: n };
|
|
67
|
-
}
|
|
68
|
-
async function Q(t) {
|
|
69
|
-
return (await $("**/.gitignore", {
|
|
70
|
-
// Gitignore files are unlikely to be symbolic links
|
|
71
|
-
followSymbolicLinks: !1,
|
|
72
|
-
// Don't look for ignore files in these places for speed:
|
|
73
|
-
ignore: [
|
|
74
|
-
// Hardcoded ignores in TypeScript
|
|
75
|
-
"**/node_modules/**",
|
|
76
|
-
"**/bower_components/**",
|
|
77
|
-
"**/jspm_packages/**",
|
|
78
|
-
// Default build output folder in bundlers
|
|
79
|
-
"**/dist/**"
|
|
80
|
-
],
|
|
81
|
-
// Not applicable for our glob pattern
|
|
82
|
-
expandDirectories: !1
|
|
83
|
-
})).flatMap((n) => {
|
|
84
|
-
const r = e.relative(t, e.dirname(n)), c = T(n), i = [];
|
|
85
|
-
for (const w of c)
|
|
86
|
-
w.startsWith("!") || i.push(e.join(r, w));
|
|
87
|
-
return i;
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
const V = ["js", "jsx", "mjs", "cjs"], X = ["ts", "tsx", "mts", "cts"], Y = ["json"], Z = `**/*.{${[...V, ...X, ...Y].join(",")}}`;
|
|
91
|
-
async function ee() {
|
|
92
|
-
const t = await z(), o = e.join(process.cwd(), Z), n = await $(o, {
|
|
93
|
-
cwd: t.globRoot,
|
|
94
|
-
ignore: t.ignorePatterns,
|
|
95
|
-
// The files we are looking for are unlikely to be symbolic links
|
|
96
|
-
followSymbolicLinks: !1,
|
|
97
|
-
// Not applicable for our glob pattern
|
|
98
|
-
expandDirectories: !1
|
|
99
|
-
// Files and folders starting with . are excluded (matches TypeScript's
|
|
100
|
-
// default behavior). If any tsconfig.json explicitly includes such files,
|
|
101
|
-
// they will still be codemodded.
|
|
102
|
-
});
|
|
103
|
-
let r = e.relative(t.globRoot, process.cwd());
|
|
104
|
-
r !== "" && (r += "/");
|
|
105
|
-
const c = e.join(e.resolve(t.globRoot), "/"), i = c.length + r.length, w = [], y = [], f = /* @__PURE__ */ new Set();
|
|
106
|
-
for (const s of n) {
|
|
107
|
-
const l = c + s;
|
|
108
|
-
if (s.endsWith(".json")) {
|
|
109
|
-
const d = e.basename(s);
|
|
110
|
-
d === "package.json" ? w.push(l) : (d.startsWith("tsconfig.") || d.startsWith("jsconfig.")) && y.push(l);
|
|
111
|
-
} else {
|
|
112
|
-
const d = s.slice(r.length);
|
|
113
|
-
f.add(d);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
let v = await J("tsconfig.json", e.dirname(process.cwd()));
|
|
117
|
-
v !== void 0 && (v = W(v), y.push(v)), y.sort((s, l) => {
|
|
118
|
-
const d = l.split("/").length - s.split("/").length;
|
|
119
|
-
if (d !== 0)
|
|
120
|
-
return d;
|
|
121
|
-
const b = e.basename(s), u = e.basename(l);
|
|
122
|
-
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
|
-
});
|
|
124
|
-
let m = await J("package.json");
|
|
125
|
-
m !== void 0 && (m = W(m));
|
|
126
|
-
const p = [], g = /* @__PURE__ */ new Set();
|
|
127
|
-
if (await Promise.all(
|
|
128
|
-
y.map(async (s) => {
|
|
129
|
-
const l = e.relative(process.cwd(), s), d = a.readConfigFile(s, a.sys.readFile);
|
|
130
|
-
if (d.error !== void 0) {
|
|
131
|
-
h(
|
|
132
|
-
"error",
|
|
133
|
-
l,
|
|
134
|
-
a.formatDiagnosticsWithColorAndContext([d.error], {
|
|
135
|
-
getCanonicalFileName: L,
|
|
136
|
-
getCurrentDirectory: a.sys.getCurrentDirectory,
|
|
137
|
-
getNewLine: () => a.sys.newLine
|
|
138
|
-
})
|
|
139
|
-
);
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const b = e.basename(l), u = a.parseJsonConfigFileContent(
|
|
143
|
-
d.config,
|
|
144
|
-
a.sys,
|
|
145
|
-
e.dirname(s),
|
|
146
|
-
void 0,
|
|
147
|
-
b
|
|
148
|
-
), A = 18003;
|
|
149
|
-
u.errors.filter((P) => P.code !== A).length > 0 && h(
|
|
150
|
-
"warn",
|
|
151
|
-
l,
|
|
152
|
-
a.formatDiagnosticsWithColorAndContext(u.errors, {
|
|
153
|
-
getCanonicalFileName: L,
|
|
154
|
-
getCurrentDirectory: a.sys.getCurrentDirectory,
|
|
155
|
-
getNewLine: () => a.sys.newLine
|
|
156
|
-
})
|
|
157
|
-
);
|
|
158
|
-
const R = s === v, G = l === b, I = u.fileNames.filter((P) => {
|
|
159
|
-
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 : !R;
|
|
161
|
-
});
|
|
162
|
-
if (I.length === 0)
|
|
163
|
-
return;
|
|
164
|
-
y.length === 1 && (R || G) && f.clear();
|
|
165
|
-
const F = e.dirname(s);
|
|
166
|
-
let C = F, x = m;
|
|
167
|
-
do {
|
|
168
|
-
const P = e.join(C, "package.json");
|
|
169
|
-
if (w.includes(P)) {
|
|
170
|
-
x = P;
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
} while (C !== t.globRoot && (C = e.dirname(C)));
|
|
174
|
-
const N = x === void 0 ? void 0 : { filePath: x, contents: await M(e.dirname(x)) }, O = {
|
|
175
|
-
typeScriptConfig: {
|
|
176
|
-
filePath: s,
|
|
177
|
-
compilerOptions: u.options
|
|
178
|
-
},
|
|
179
|
-
packageJson: N,
|
|
180
|
-
logName: S("blue", N?.contents?.name ?? F),
|
|
181
|
-
cwd: F,
|
|
182
|
-
filePaths: I
|
|
183
|
-
};
|
|
184
|
-
p.push(O);
|
|
185
|
-
})
|
|
186
|
-
), f.size > 0) {
|
|
187
|
-
const s = m === void 0 ? void 0 : {
|
|
188
|
-
filePath: m,
|
|
189
|
-
contents: await M(e.dirname(m))
|
|
190
|
-
};
|
|
191
|
-
p.push({
|
|
192
|
-
typeScriptConfig: void 0,
|
|
193
|
-
packageJson: s,
|
|
194
|
-
cwd: process.cwd(),
|
|
195
|
-
logName: S("blue", s?.contents?.name ?? process.cwd()),
|
|
196
|
-
filePaths: Array.from(f).map((l) => e.join(process.cwd(), l))
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
return p.sort((s, l) => s.cwd.localeCompare(l.cwd)), j.projectsData = p, p;
|
|
200
|
-
}
|
|
201
|
-
let _ = !1;
|
|
202
|
-
function te() {
|
|
203
|
-
_ || (_ = !0, process.exitCode !== void 0 && process.exitCode !== 0 ? h(
|
|
204
|
-
"warn",
|
|
205
|
-
j.codemodName,
|
|
206
|
-
"One or more exceptions occurred during the codemod run. Please review the output above."
|
|
207
|
-
) : h(
|
|
208
|
-
"info",
|
|
209
|
-
j.codemodName,
|
|
210
|
-
`${S("green", "Codemod completed successfully.")} Recommended next steps:
|
|
211
|
-
- Review the codemod changes.
|
|
212
|
-
- If your project uses ESLint, run ESLint autofix on the changed files.
|
|
213
|
-
- If your project uses Prettier, run Prettier on the changed files.
|
|
214
|
-
- If your project uses TypeScript, run type checking to ensure there are no type errors.`
|
|
215
|
-
));
|
|
216
|
-
}
|
|
217
|
-
async function oe(t, o) {
|
|
218
|
-
j.codemod = t, j.codemodName = o;
|
|
219
|
-
const n = await ee();
|
|
220
|
-
if (n.length === 0) {
|
|
221
|
-
h("error", o, `Failed to find any .js or .ts files in ${process.cwd()} to run the codemod on.`), process.exitCode = 1;
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
await t.run(n), te();
|
|
225
|
-
}
|
|
226
|
-
const k = new K();
|
|
227
|
-
k.name("@arcgis/codemod").description("Codemod for migrating or refactoring usages of ArcGIS Maps SDK for JavaScript");
|
|
228
|
-
k.command("run").description("Run a single codemod").argument("<codemodName>", "Name of the transform").argument("[path]", "Directory to transform", process.cwd()).action(ne);
|
|
229
|
-
async function ne(t, o) {
|
|
230
|
-
const n = U(o, { throwIfNoEntry: !1 });
|
|
231
|
-
if (n === void 0) {
|
|
232
|
-
h("error", "@arcgis/codemod", `Failed to find the target path: ${o}`), process.exitCode = 1;
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
const r = n.isFile();
|
|
236
|
-
process.chdir(r ? e.dirname(o) : o);
|
|
237
|
-
let c;
|
|
238
|
-
try {
|
|
239
|
-
c = await q(/* @__PURE__ */ Object.assign({ "./codemods/api-extractor-strict-mode/codemod.ts": () => import("./codemod-AVvtg1JZ.js"), "./codemods/arcgis-toolkit/codemod.ts": () => import("./codemod-Cv6_nCqP.js"), "./codemods/refactor-out-esri-namespace/codemod.ts": () => import("./codemod-mhjHtX3y.js") }), `./codemods/${t}/codemod.ts`, 4);
|
|
240
|
-
} catch (i) {
|
|
241
|
-
if (
|
|
242
|
-
// direct Node execution
|
|
243
|
-
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
|
|
244
|
-
String(i).includes("Unknown variable dynamic import:")
|
|
245
|
-
) {
|
|
246
|
-
h("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
247
|
-
return;
|
|
248
|
-
} else
|
|
249
|
-
throw i;
|
|
250
|
-
}
|
|
251
|
-
if (typeof c.codemod != "object" || c.codemod === null) {
|
|
252
|
-
h("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
await oe(c.codemod, S("blue", t));
|
|
256
|
-
}
|
|
257
|
-
k.parse();
|
|
258
|
-
export {
|
|
259
|
-
ge as d,
|
|
260
|
-
j as g,
|
|
261
|
-
te as p
|
|
262
|
-
};
|
package/dist/codemod-Cv6_nCqP.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
var m = (o, i) => (i = Symbol[o]) ? i : /* @__PURE__ */ Symbol.for("Symbol." + o), d = (o) => {
|
|
2
|
-
throw TypeError(o);
|
|
3
|
-
};
|
|
4
|
-
var p = (o, i, r) => {
|
|
5
|
-
if (i != null) {
|
|
6
|
-
typeof i != "object" && typeof i != "function" && d("Object expected");
|
|
7
|
-
var a, t;
|
|
8
|
-
r && (a = i[m("asyncDispose")]), a === void 0 && (a = i[m("dispose")], r && (t = a)), typeof a != "function" && d("Object not disposable"), t && (a = function() {
|
|
9
|
-
try {
|
|
10
|
-
t.call(this);
|
|
11
|
-
} catch (s) {
|
|
12
|
-
return Promise.reject(s);
|
|
13
|
-
}
|
|
14
|
-
}), o.push([r, a, i]);
|
|
15
|
-
} else r && o.push([r]);
|
|
16
|
-
return i;
|
|
17
|
-
}, f = (o, i, r) => {
|
|
18
|
-
var a = typeof SuppressedError == "function" ? SuppressedError : function(e, n, c, l) {
|
|
19
|
-
return l = Error(c), l.name = "SuppressedError", l.error = e, l.suppressed = n, l;
|
|
20
|
-
}, t = (e) => i = r ? new a(e, i, "An error was suppressed during disposal") : (r = !0, e), s = (e) => {
|
|
21
|
-
for (; e = o.pop(); )
|
|
22
|
-
try {
|
|
23
|
-
var n = e[1] && e[1].call(e[2]);
|
|
24
|
-
if (e[0]) return Promise.resolve(n).then(s, (c) => (t(c), s()));
|
|
25
|
-
} catch (c) {
|
|
26
|
-
t(c);
|
|
27
|
-
}
|
|
28
|
-
if (r) throw i;
|
|
29
|
-
};
|
|
30
|
-
return s();
|
|
31
|
-
};
|
|
32
|
-
import { f as k, p as u } from "./actions-BBxr-9ge.js";
|
|
33
|
-
import { log as g } from "@arcgis/toolkit/log";
|
|
34
|
-
import { writeFile as E } from "node:fs/promises";
|
|
35
|
-
import { c as b } from "./useProjectInstance-CiX-mY1O.js";
|
|
36
|
-
import { p as h, g as y } from "./cli-DPzs7oKq.js";
|
|
37
|
-
async function L(o, i) {
|
|
38
|
-
const r = /* @__PURE__ */ new Set();
|
|
39
|
-
for (const a of o) {
|
|
40
|
-
const t = a.packageJson;
|
|
41
|
-
if (t === void 0 || r.has(t.filePath))
|
|
42
|
-
continue;
|
|
43
|
-
r.add(t.filePath);
|
|
44
|
-
const s = t.contents;
|
|
45
|
-
try {
|
|
46
|
-
const e = await i(s, t.filePath);
|
|
47
|
-
s !== e && await E(t.filePath, `${JSON.stringify(e, null, 2)}
|
|
48
|
-
`, "utf8");
|
|
49
|
-
} catch (e) {
|
|
50
|
-
process.exitCode = 1, g(
|
|
51
|
-
"error",
|
|
52
|
-
k(t.filePath),
|
|
53
|
-
`Error occurred while migrating: ${String(e)}`,
|
|
54
|
-
typeof e == "object" && e !== null && "stack" in e ? { detail: { stack: e.stack } } : void 0
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function P(o, i) {
|
|
60
|
-
for (const r of ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]) {
|
|
61
|
-
const a = o[r];
|
|
62
|
-
if (a) {
|
|
63
|
-
const t = i(a, r);
|
|
64
|
-
t !== a && (o = { ...o, [r]: t });
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return o;
|
|
68
|
-
}
|
|
69
|
-
const F = {
|
|
70
|
-
meta: {
|
|
71
|
-
needsTypeInformation: !1
|
|
72
|
-
},
|
|
73
|
-
async run(o) {
|
|
74
|
-
await L(
|
|
75
|
-
o,
|
|
76
|
-
(s) => P(
|
|
77
|
-
s,
|
|
78
|
-
(e) => e["@arcgis/components-utils"] ? {
|
|
79
|
-
...e,
|
|
80
|
-
"@arcgis/components-utils": void 0,
|
|
81
|
-
"@arcgis/toolkit": e["@arcgis/components-utils"]
|
|
82
|
-
} : e
|
|
83
|
-
)
|
|
84
|
-
);
|
|
85
|
-
for (const s of o) {
|
|
86
|
-
var i = [];
|
|
87
|
-
try {
|
|
88
|
-
const e = p(i, b(s));
|
|
89
|
-
for (const n of e.getCodemodFiles())
|
|
90
|
-
u(n, {
|
|
91
|
-
"@arcgis/components-utils": {
|
|
92
|
-
// Deprecated
|
|
93
|
-
setFocusOnElement: [{ do: "deprecate" }, { do: "rename", specifier: "@arcgis/toolkit/dom" }],
|
|
94
|
-
setValuesInString: [{ do: "deprecate" }, { do: "rename", specifier: "@arcgis/toolkit/string" }],
|
|
95
|
-
IHandle: [{ do: "deprecate" }, { do: "rename", specifier: "@arcgis/toolkit/type" }],
|
|
96
|
-
Deferred: [{ do: "deprecate" }, { do: "rename", specifier: "@arcgis/toolkit/promise" }],
|
|
97
|
-
// Renamed
|
|
98
|
-
addLTRMark: { do: "rename", specifier: "@arcgis/toolkit/string", name: "addLtrMark" },
|
|
99
|
-
getElementTheme: { do: "rename", specifier: "@arcgis/toolkit/dom", name: "unsafeGetCalciteModeName" },
|
|
100
|
-
getElementDir: { do: "rename", specifier: "@arcgis/toolkit/dom", name: "unsafeGetElementDirection" },
|
|
101
|
-
unsafeGetModeName: { do: "rename", specifier: "@arcgis/toolkit/dom", name: "unsafeGetCalciteModeName" },
|
|
102
|
-
getElementLocales: { do: "rename", specifier: "@arcgis/toolkit/intl", name: "getElementLocale" },
|
|
103
|
-
LocaleObserver: { do: "rename", specifier: "@arcgis/toolkit/intl", name: "LocaleObserverResult" },
|
|
104
|
-
Nil: { do: "rename", specifier: "@arcgis/toolkit/type", name: "nil" },
|
|
105
|
-
closestElement: { do: "rename", specifier: "@arcgis/toolkit/dom", name: "getClosestElement" },
|
|
106
|
-
extractMinorVersion: { do: "rename", specifier: "@arcgis/toolkit/string", name: "getMinorVersion" },
|
|
107
|
-
isURL: { do: "rename", specifier: "@arcgis/toolkit/string", name: "isUrl" },
|
|
108
|
-
mappedFind: { do: "rename", specifier: "@arcgis/toolkit/array" },
|
|
109
|
-
classes: { do: "rename", specifier: "@arcgis/toolkit/dom" },
|
|
110
|
-
// Relocated
|
|
111
|
-
observeAncestorsMutation: { do: "rename", specifier: "@arcgis/toolkit/dom" },
|
|
112
|
-
getElementAttribute: { do: "rename", specifier: "@arcgis/toolkit/dom" },
|
|
113
|
-
FocusableElement: { do: "rename", specifier: "@arcgis/toolkit/dom" },
|
|
114
|
-
focusElement: { do: "rename", specifier: "@arcgis/toolkit/dom" },
|
|
115
|
-
devToolsAwareTimeout: { do: "rename", specifier: "@arcgis/toolkit/promise" },
|
|
116
|
-
isEsriInternalEnv: { do: "rename", specifier: "@arcgis/toolkit/error" },
|
|
117
|
-
safeCall: { do: "rename", specifier: "@arcgis/toolkit/error" },
|
|
118
|
-
safeAsyncCall: { do: "rename", specifier: "@arcgis/toolkit/error" },
|
|
119
|
-
generateGuid: { do: "rename", specifier: "@arcgis/toolkit/string" },
|
|
120
|
-
getPreamble: { do: "rename", specifier: "@arcgis/toolkit/string" },
|
|
121
|
-
quoteString: { do: "rename", specifier: "@arcgis/toolkit/string" },
|
|
122
|
-
createFilterExpression: { do: "rename", specifier: "@arcgis/toolkit/string" },
|
|
123
|
-
kebabToPascal: { do: "rename", specifier: "@arcgis/toolkit/string" },
|
|
124
|
-
camelToKebab: { do: "rename", specifier: "@arcgis/toolkit/string" },
|
|
125
|
-
camelToHuman: { do: "rename", specifier: "@arcgis/toolkit/string" },
|
|
126
|
-
capitalize: { do: "rename", specifier: "@arcgis/toolkit/string" },
|
|
127
|
-
uncapitalize: { do: "rename", specifier: "@arcgis/toolkit/string" },
|
|
128
|
-
GenericT9nStrings: { do: "rename", specifier: "@arcgis/toolkit/intl" },
|
|
129
|
-
supportedLocales: { do: "rename", specifier: "@arcgis/toolkit/intl" },
|
|
130
|
-
SupportedLocale: { do: "rename", specifier: "@arcgis/toolkit/intl" },
|
|
131
|
-
defaultLocale: { do: "rename", specifier: "@arcgis/toolkit/intl" },
|
|
132
|
-
fetchT9nStringsBundle: { do: "rename", specifier: "@arcgis/toolkit/intl" },
|
|
133
|
-
normalizeLocale: { do: "rename", specifier: "@arcgis/toolkit/intl" },
|
|
134
|
-
startLocaleObserver: { do: "rename", specifier: "@arcgis/toolkit/intl" },
|
|
135
|
-
isNotNull: { do: "rename", specifier: "@arcgis/toolkit/predicate" },
|
|
136
|
-
isNotUndefined: { do: "rename", specifier: "@arcgis/toolkit/predicate" },
|
|
137
|
-
debounce: { do: "rename", specifier: "@arcgis/toolkit/function" },
|
|
138
|
-
identity: { do: "rename", specifier: "@arcgis/toolkit/function" },
|
|
139
|
-
hasSameOrigin: { do: "rename", specifier: "@arcgis/toolkit/url" }
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
} catch (r) {
|
|
143
|
-
var a = r, t = !0;
|
|
144
|
-
} finally {
|
|
145
|
-
f(i, a, t);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
h(), g(
|
|
149
|
-
"info",
|
|
150
|
-
y.codemodName,
|
|
151
|
-
"Next step: run npm install/pnpm install/yarn install to get @arcgis/toolkit package installed."
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
export {
|
|
156
|
-
F as codemod
|
|
157
|
-
};
|