@arcgis/codemod 5.2.0-next.118 → 5.2.0-next.119
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/README.md +32 -8
- package/dist/{actions-CQZGPkk1.js → actions-pyK_bLYZ.js} +88 -95
- package/dist/cli-C-HhqWfY.js +326 -0
- package/dist/cli.js +3 -2
- package/dist/{codemod-CtDiL__8.js → codemod-BaP5d7QD.js} +1 -1
- package/dist/{codemod-v6MLU8Qq.js → codemod-BhxEZX2B.js} +10 -9
- package/dist/{codemod--z_92lWI.js → codemod-CVM-ahrt.js} +3 -3
- package/dist/{codemod-BALsil-0.js → codemod-DlxIx0fk.js} +3 -3
- package/dist/{codemod-MHr8xn-r.js → codemod-DsvACPpG.js} +2 -2
- package/dist/{codemod-DKND2-mc.js → codemod-DzUJHZc4.js} +19 -18
- package/dist/{codemod-ZwlO-Y4a.js → codemod-lXphX6G6.js} +2 -2
- package/dist/codeowners-CarwYwHK.js +118 -0
- package/dist/config-BP6HDIQa.js +19 -0
- package/dist/index-BYkl918U.js +142 -0
- package/dist/index-G3qil5yu.js +313 -0
- package/dist/log-B76HBvov.js +11 -0
- package/dist/sync-e0pgnEOM.js +240 -0
- package/dist/{useProjectInstance-Cs8LP18f.js → useProjectInstance-BqEY3afe.js} +19 -18
- package/package.json +5 -4
- package/dist/cli-BLMaWpqf.js +0 -269
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { readFile as E } from "node:fs/promises";
|
|
2
|
+
import { log as w } from "@arcgis/toolkit/log";
|
|
3
|
+
import { a as T, b as h, c as P, d as j, e as A, f as y } from "./config-BP6HDIQa.js";
|
|
4
|
+
import { collectOutput as m } from "@arcgis/node-toolkit/shell";
|
|
5
|
+
const C = `<!-- ${h} -->`, O = `<!-- ${h}`, M = 65536;
|
|
6
|
+
function b(n) {
|
|
7
|
+
const e = /* @__PURE__ */ new Map();
|
|
8
|
+
for (const t of n.findings) {
|
|
9
|
+
const o = f(t.codeowners), s = o.join(","), i = e.get(s) ?? [];
|
|
10
|
+
i.push({ ...t, codeowners: o }), e.set(s, i);
|
|
11
|
+
}
|
|
12
|
+
return [...e.entries()].map(([t, o]) => {
|
|
13
|
+
const s = t === "" ? [] : t.split(","), i = B(n, o);
|
|
14
|
+
return {
|
|
15
|
+
title: T[n.kind],
|
|
16
|
+
owners: s,
|
|
17
|
+
assignees: s.filter((r) => /^@[^/@\s]+$/u.test(r)).map((r) => r.slice(1)),
|
|
18
|
+
chunks: N(i, M, R(s))
|
|
19
|
+
};
|
|
20
|
+
}).sort((t, o) => t.title.localeCompare(o.title));
|
|
21
|
+
}
|
|
22
|
+
function B(n, e) {
|
|
23
|
+
const t = P[n.kind], o = f(e.flatMap((a) => a.codeowners)).filter(
|
|
24
|
+
(a) => /^@[^/@\s]+\/[^@\s]+$/u.test(a)
|
|
25
|
+
), s = o.length === 0 ? "" : `
|
|
26
|
+
|
|
27
|
+
CODEOWNERS: ${o.join(", ")}`, r = [...Map.groupBy(e, (a) => a.package).entries()].sort(([a], [p]) => a.localeCompare(p)).map(([a, p]) => {
|
|
28
|
+
const S = [...Map.groupBy(p, (u) => D(n.kind, u)).entries()].sort(([u], [l]) => u.localeCompare(l)).map(([, u]) => {
|
|
29
|
+
const [{ api: l }] = u, $ = [
|
|
30
|
+
...new Set(
|
|
31
|
+
u.map(({ reason: c }) => c).filter((c) => c !== null && c !== "")
|
|
32
|
+
)
|
|
33
|
+
], x = $.length === 0 ? "" : ` - ${$.map(G).join(" ")}`, d = [
|
|
34
|
+
...new Set(
|
|
35
|
+
u.toSorted((c, g) => c.file.localeCompare(g.file) || c.line - g.line).map((c) => J(n.repository, n.ref, c.file, c.line))
|
|
36
|
+
)
|
|
37
|
+
], v = d.length === 1 ? ` ${d[0]}` : d.map((c) => ` - ${c}`).join(`
|
|
38
|
+
`);
|
|
39
|
+
return `- [ ] \`${l}\`${x}
|
|
40
|
+
${v}`;
|
|
41
|
+
});
|
|
42
|
+
return `#### ${a}'s deprecations
|
|
43
|
+
|
|
44
|
+
${S.join(`
|
|
45
|
+
`)}`;
|
|
46
|
+
});
|
|
47
|
+
return `${t}${s}
|
|
48
|
+
|
|
49
|
+
${j}
|
|
50
|
+
|
|
51
|
+
${r.join(`
|
|
52
|
+
|
|
53
|
+
`)}`;
|
|
54
|
+
}
|
|
55
|
+
function N(n, e = M, t = C) {
|
|
56
|
+
const o = `${t}
|
|
57
|
+
`, s = e - o.length;
|
|
58
|
+
if (s < 1)
|
|
59
|
+
throw new Error("Issue content limit is too small for the managed marker.");
|
|
60
|
+
const i = [];
|
|
61
|
+
let r = n;
|
|
62
|
+
for (; r.length > s; ) {
|
|
63
|
+
const a = r.lastIndexOf(`
|
|
64
|
+
`, s), p = a > 0 ? a : s;
|
|
65
|
+
i.push(o + r.slice(0, p)), r = r.slice(p + (a > 0 ? 1 : 0));
|
|
66
|
+
}
|
|
67
|
+
return i.push(o + r), i;
|
|
68
|
+
}
|
|
69
|
+
function R(n) {
|
|
70
|
+
return n.length === 0 ? C : `<!-- ${h} ${f(n).join(",")} -->`;
|
|
71
|
+
}
|
|
72
|
+
function f(n) {
|
|
73
|
+
return [...new Set(n)].sort((e, t) => e.localeCompare(t));
|
|
74
|
+
}
|
|
75
|
+
function D(n, e) {
|
|
76
|
+
return n === "definitions" ? `${e.api}\0${L(e.file)}` : e.api;
|
|
77
|
+
}
|
|
78
|
+
function L(n) {
|
|
79
|
+
const e = "/src/", t = "/dist/", o = n.lastIndexOf(e), s = n.lastIndexOf(t), i = Math.max(o, s), r = s > o ? t : e;
|
|
80
|
+
return (i === -1 ? n : n.slice(i + r.length)).replace(/\.(?:d\.)?(?:[cm]?ts|tsx)$/u, "");
|
|
81
|
+
}
|
|
82
|
+
function G(n) {
|
|
83
|
+
const e = [], t = (i) => `\0${e.push(i) - 1}\0`, s = n.replaceAll(`\r
|
|
84
|
+
`, `
|
|
85
|
+
`).replaceAll("\r", `
|
|
86
|
+
`).replace(
|
|
87
|
+
/\[([^\]\n]+)\]\((https?:\/\/(?:[^()\s]|\([^()\s]*\))+?)\)/gu,
|
|
88
|
+
(i, r, a) => t(`[${I(r)}](${a})`)
|
|
89
|
+
).replace(/https?:\/\/[^\s<>()]+/gu, (i) => {
|
|
90
|
+
const r = /[.,;:!?]+$/u.exec(i)?.[0] ?? "";
|
|
91
|
+
return `${t(i.slice(0, -r.length || void 0))}${r}`;
|
|
92
|
+
});
|
|
93
|
+
return I(s).replace(/\0(\d+)\0/gu, (i, r) => e[Number(r)]).replaceAll(`
|
|
94
|
+
`, `
|
|
95
|
+
`);
|
|
96
|
+
}
|
|
97
|
+
function I(n) {
|
|
98
|
+
return n.replace(/^(\s*)(#{1,6})(?=\s)/gmu, "$1\\$2").replace(/#(?=\d)/gu, "# ");
|
|
99
|
+
}
|
|
100
|
+
function J(n, e, t, o) {
|
|
101
|
+
const s = e.split("/").map(encodeURIComponent).join("/"), i = t.split("/").map(encodeURIComponent).join("/");
|
|
102
|
+
return `https://${n}/blob/${s}/${i}#L${o}`;
|
|
103
|
+
}
|
|
104
|
+
class z {
|
|
105
|
+
#s;
|
|
106
|
+
#e;
|
|
107
|
+
constructor(e) {
|
|
108
|
+
const [t, o, s, ...i] = e.split("/");
|
|
109
|
+
if (t === void 0 || o === void 0 || s === void 0 || i.length > 0)
|
|
110
|
+
throw new Error(`Invalid repository: ${e}`);
|
|
111
|
+
this.#s = t, this.#e = `${o}/${s}`;
|
|
112
|
+
}
|
|
113
|
+
async #t(e, t, o) {
|
|
114
|
+
if (process.env.VITEST !== void 0)
|
|
115
|
+
throw new Error("GitHub requests are disabled while running Vitest.");
|
|
116
|
+
const s = await m(
|
|
117
|
+
"gh",
|
|
118
|
+
["api", "--hostname", this.#s, "--method", e, t, ...o === void 0 ? [] : ["--input", "-"]],
|
|
119
|
+
o === void 0 ? {} : { input: JSON.stringify(o) }
|
|
120
|
+
);
|
|
121
|
+
return s === "" ? void 0 : JSON.parse(s);
|
|
122
|
+
}
|
|
123
|
+
async listOpenIssues(e) {
|
|
124
|
+
const t = await m("gh", [
|
|
125
|
+
"api",
|
|
126
|
+
"--hostname",
|
|
127
|
+
this.#s,
|
|
128
|
+
"--method",
|
|
129
|
+
"GET",
|
|
130
|
+
"--paginate",
|
|
131
|
+
"--slurp",
|
|
132
|
+
"-f",
|
|
133
|
+
`q="${e}" in:title repo:${this.#e} is:issue is:open`,
|
|
134
|
+
"-f",
|
|
135
|
+
"per_page=100",
|
|
136
|
+
"/search/issues"
|
|
137
|
+
]);
|
|
138
|
+
return JSON.parse(t).flatMap(({ items: o }) => o);
|
|
139
|
+
}
|
|
140
|
+
async createIssue(e, t, o, s) {
|
|
141
|
+
return await this.#t("POST", `/repos/${this.#e}/issues`, {
|
|
142
|
+
title: e,
|
|
143
|
+
body: t,
|
|
144
|
+
assignees: o,
|
|
145
|
+
labels: s,
|
|
146
|
+
type: A
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
async updateIssueBody(e, t) {
|
|
150
|
+
await this.#t("PATCH", `/repos/${this.#e}/issues/${e}`, { body: t });
|
|
151
|
+
}
|
|
152
|
+
async listComments(e) {
|
|
153
|
+
const t = await m("gh", [
|
|
154
|
+
"api",
|
|
155
|
+
"--hostname",
|
|
156
|
+
this.#s,
|
|
157
|
+
"--method",
|
|
158
|
+
"GET",
|
|
159
|
+
"--paginate",
|
|
160
|
+
"--slurp",
|
|
161
|
+
`/repos/${this.#e}/issues/${e}/comments?per_page=100`
|
|
162
|
+
]);
|
|
163
|
+
return JSON.parse(t).flat();
|
|
164
|
+
}
|
|
165
|
+
async createComment(e, t) {
|
|
166
|
+
await this.#t("POST", `/repos/${this.#e}/issues/${e}/comments`, { body: t });
|
|
167
|
+
}
|
|
168
|
+
async updateComment(e, t) {
|
|
169
|
+
await this.#t("PATCH", `/repos/${this.#e}/issues/comments/${e}`, { body: t });
|
|
170
|
+
}
|
|
171
|
+
async deleteComment(e) {
|
|
172
|
+
await this.#t("DELETE", `/repos/${this.#e}/issues/comments/${e}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
async function Z(n, e, t = 0, o, s = []) {
|
|
176
|
+
const i = W(await E(n, "utf8")), r = H(b(i), t, o);
|
|
177
|
+
if (e) {
|
|
178
|
+
process.stdout.write(`${_(r)}
|
|
179
|
+
`);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const a = new z(i.repository);
|
|
183
|
+
await U(r, a, s);
|
|
184
|
+
}
|
|
185
|
+
function H(n, e, t) {
|
|
186
|
+
return n.slice(e, t === void 0 ? void 0 : e + t);
|
|
187
|
+
}
|
|
188
|
+
async function U(n, e, t = []) {
|
|
189
|
+
const o = /* @__PURE__ */ new Map();
|
|
190
|
+
for (const s of n) {
|
|
191
|
+
let i = o.get(s.title);
|
|
192
|
+
i === void 0 && (i = await e.listOpenIssues(s.title), o.set(s.title, i));
|
|
193
|
+
const r = q(i, s);
|
|
194
|
+
let a;
|
|
195
|
+
r === void 0 ? (a = (await e.createIssue(s.title, s.chunks[0], s.assignees, t)).number, w("info", y, `Created issue #${a}: ${s.title}`)) : (a = r.number, r.body !== s.chunks[0] && (await e.updateIssueBody(a, s.chunks[0]), w("info", y, `Updated issue #${a}: ${s.title}`))), await V(e, a, s.chunks.slice(1));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function W(n) {
|
|
199
|
+
const e = JSON.parse(n);
|
|
200
|
+
if (e.kind !== "usages" && e.kind !== "definitions" || typeof e.repository != "string" || typeof e.ref != "string" || !Array.isArray(e.findings))
|
|
201
|
+
throw new Error("Invalid deprecation audit JSON.");
|
|
202
|
+
return e;
|
|
203
|
+
}
|
|
204
|
+
function _(n) {
|
|
205
|
+
return n.map(
|
|
206
|
+
(e) => `CODEOWNERS: ${e.owners.length === 0 ? "unowned" : e.owners.join(", ")}
|
|
207
|
+
ASSIGNEES: ${e.assignees.length === 0 ? "none" : e.assignees.join(", ")}
|
|
208
|
+
TITLE: ${e.title}
|
|
209
|
+
|
|
210
|
+
${e.chunks.map((t, o) => `--- ${o === 0 ? "BODY" : "COMMENT"} (${o + 1}/${e.chunks.length}) ---
|
|
211
|
+
${t}`).join(`
|
|
212
|
+
|
|
213
|
+
`)}`
|
|
214
|
+
).join(`
|
|
215
|
+
|
|
216
|
+
`);
|
|
217
|
+
}
|
|
218
|
+
function q(n, e) {
|
|
219
|
+
const t = k(e.chunks[0]);
|
|
220
|
+
return n.find((o) => o.title === e.title && k(o.body) === t);
|
|
221
|
+
}
|
|
222
|
+
function k(n) {
|
|
223
|
+
const e = n?.split(`
|
|
224
|
+
`, 1)[0];
|
|
225
|
+
return e?.startsWith(O) === !0 ? e : void 0;
|
|
226
|
+
}
|
|
227
|
+
async function V(n, e, t) {
|
|
228
|
+
const o = (await n.listComments(e)).filter(({ body: s }) => s.startsWith(O));
|
|
229
|
+
for (const [s, i] of t.entries()) {
|
|
230
|
+
const r = o[s];
|
|
231
|
+
r === void 0 ? await n.createComment(e, i) : r.body !== i && await n.updateComment(r.id, i);
|
|
232
|
+
}
|
|
233
|
+
for (const s of o.slice(t.length))
|
|
234
|
+
await n.deleteComment(s.id);
|
|
235
|
+
}
|
|
236
|
+
export {
|
|
237
|
+
H as sliceIssuePlans,
|
|
238
|
+
Z as syncDeprecationIssues,
|
|
239
|
+
U as synchronizeIssuePlans
|
|
240
|
+
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { Project as p } from "ts-morph";
|
|
2
2
|
import { log as d } from "@arcgis/toolkit/log";
|
|
3
3
|
import { path as f } from "@arcgis/node-toolkit/path";
|
|
4
|
-
import { g as
|
|
4
|
+
import { g as i, d as m } from "./cli-C-HhqWfY.js";
|
|
5
5
|
import { styleText as s } from "node:util";
|
|
6
|
-
function y(e) {
|
|
7
|
-
if (
|
|
6
|
+
function y(e, c = !0) {
|
|
7
|
+
if (i.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
|
|
11
|
+
const n = i.codemod.meta.needsTypeInformation, t = 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
|
-
checkJs:
|
|
17
|
+
checkJs: n
|
|
18
18
|
},
|
|
19
19
|
// We take care of reading the config file
|
|
20
20
|
tsConfigFilePath: void 0,
|
|
@@ -22,25 +22,26 @@ function y(e) {
|
|
|
22
22
|
skipAddingFilesFromTsConfig: !0,
|
|
23
23
|
// We call this manually if needed below.
|
|
24
24
|
skipFileDependencyResolution: !0,
|
|
25
|
-
skipLoadingLibFiles: !
|
|
26
|
-
}), l = e.filePaths.map((
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
skipLoadingLibFiles: !n
|
|
26
|
+
}), l = e.filePaths.map((o) => t.addSourceFileAtPath(o));
|
|
27
|
+
if (n && t.resolveSourceFileDependencies(), c) {
|
|
28
|
+
const o = f.relative(process.cwd(), e.cwd);
|
|
29
|
+
process.stdout.write(""), d(
|
|
30
|
+
"info",
|
|
31
|
+
s("blue", o === "" ? process.cwd() : o),
|
|
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)}`}`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const r = {
|
|
35
36
|
[Symbol.dispose]() {
|
|
36
|
-
|
|
37
|
+
t.saveSync(), t.getRootDirectories().forEach((o) => o.forget()), i.project = void 0;
|
|
37
38
|
},
|
|
38
39
|
projectData: e,
|
|
39
40
|
// Resolved dependencies support type checking but are not codemod targets.
|
|
40
41
|
getCodemodFiles: () => l,
|
|
41
|
-
tsMorph:
|
|
42
|
+
tsMorph: t
|
|
42
43
|
};
|
|
43
|
-
return
|
|
44
|
+
return i.project = r, r;
|
|
44
45
|
}
|
|
45
46
|
export {
|
|
46
47
|
y as c
|
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.119",
|
|
4
4
|
"description": "A codemod toolkit for updating and modernizing ArcGIS Maps SDK for JavaScript codebases.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
],
|
|
12
12
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@arcgis/api-extractor": "5.2.0-next.
|
|
15
|
-
"@arcgis/node-toolkit": "5.2.0-next.
|
|
16
|
-
"@arcgis/toolkit": "5.2.0-next.
|
|
14
|
+
"@arcgis/api-extractor": "5.2.0-next.119",
|
|
15
|
+
"@arcgis/node-toolkit": "5.2.0-next.119",
|
|
16
|
+
"@arcgis/toolkit": "5.2.0-next.119",
|
|
17
17
|
"@commander-js/extra-typings": "^15.0.0",
|
|
18
18
|
"commander": "^15.0.0",
|
|
19
|
+
"picomatch": "^4.0.4",
|
|
19
20
|
"tinyglobby": "~0.2.17",
|
|
20
21
|
"ts-morph": "^28.0.0",
|
|
21
22
|
"tslib": "^2.8.1",
|
package/dist/cli-BLMaWpqf.js
DELETED
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
import { log as y } from "@arcgis/toolkit/log";
|
|
2
|
-
import { Command as U } from "@commander-js/extra-typings";
|
|
3
|
-
import { statSync as B } from "node:fs";
|
|
4
|
-
import { getCwd as k, path as e, toPosixPathSeparators as W } from "@arcgis/node-toolkit/path";
|
|
5
|
-
import "ts-morph";
|
|
6
|
-
import c from "typescript";
|
|
7
|
-
import { existsAsync as q, asyncFindPath as M } from "@arcgis/node-toolkit/file";
|
|
8
|
-
import { asyncRetrievePackageJson as L } from "@arcgis/node-toolkit/packageJson";
|
|
9
|
-
import { glob as A } from "tinyglobby";
|
|
10
|
-
import { gitIgnoreFileToGlobs as G } from "@arcgis/node-toolkit/glob";
|
|
11
|
-
import { identity as _ } from "@arcgis/toolkit/function";
|
|
12
|
-
import { styleText as F } from "node:util";
|
|
13
|
-
const z = (t, o, n) => {
|
|
14
|
-
const r = t[o];
|
|
15
|
-
return r ? typeof r == "function" ? r() : Promise.resolve(r) : new Promise((d, 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: c.JsxEmit.Preserve,
|
|
29
|
-
lib: ["lib.esnext.d.ts", "lib.dom.d.ts"],
|
|
30
|
-
module: c.ModuleKind.ESNext,
|
|
31
|
-
moduleResolution: c.ModuleResolutionKind.Bundler,
|
|
32
|
-
moduleDetection: c.ModuleDetectionKind.Auto,
|
|
33
|
-
strict: !1,
|
|
34
|
-
target: c.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 H() {
|
|
44
|
-
const { ignorePatterns: t, globRoot: o } = await Q(), n = await V(o);
|
|
45
|
-
return t.push(...n), { ignorePatterns: t, globRoot: o };
|
|
46
|
-
}
|
|
47
|
-
async function Q() {
|
|
48
|
-
const t = [];
|
|
49
|
-
let o, n = k(), r = e.dirname(n);
|
|
50
|
-
do {
|
|
51
|
-
o = r;
|
|
52
|
-
const d = e.join(o, ".gitignore");
|
|
53
|
-
if (await q(d)) {
|
|
54
|
-
n = e.dirname(d);
|
|
55
|
-
const g = e.relative(n, k()).split("/"), P = G(d);
|
|
56
|
-
for (const u of P) {
|
|
57
|
-
const h = u.startsWith("!") ? u.slice(1) : u, p = h.search(/[*?[]/u), w = p === -1 ? h : h.slice(0, p), v = w.split("/"), s = p !== -1 && !w.endsWith("/");
|
|
58
|
-
let a = !0;
|
|
59
|
-
const l = Math.min(g.length, v.length);
|
|
60
|
-
for (let m = 0; m < l; m++) {
|
|
61
|
-
const f = v[m];
|
|
62
|
-
if (!(s && m === v.length - 1 ? g[m].startsWith(f) : g[m] === f) && f !== "") {
|
|
63
|
-
a = !1;
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
a && (u.startsWith("!") || t.push(u));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
r = e.dirname(o);
|
|
71
|
-
} while (r !== o);
|
|
72
|
-
return { ignorePatterns: t, globRoot: n };
|
|
73
|
-
}
|
|
74
|
-
async function V(t) {
|
|
75
|
-
return (await A("**/.gitignore", {
|
|
76
|
-
cwd: k(),
|
|
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((n) => {
|
|
91
|
-
const r = e.relative(t, e.dirname(n)), d = G(n), i = [];
|
|
92
|
-
for (const g of d)
|
|
93
|
-
g.startsWith("!") || i.push(e.join(r, g));
|
|
94
|
-
return i;
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
const X = ["js", "jsx", "mjs", "cjs"], Y = ["ts", "tsx", "mts", "cts"], Z = ["json"], ee = `**/*.{${[...X, ...Y, ...Z].join(",")}}`;
|
|
98
|
-
async function te() {
|
|
99
|
-
const t = await H(), o = e.join(process.cwd(), ee), n = await A(o, {
|
|
100
|
-
cwd: t.globRoot,
|
|
101
|
-
ignore: t.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
|
-
});
|
|
110
|
-
let r = e.relative(t.globRoot, process.cwd());
|
|
111
|
-
r !== "" && (r += "/");
|
|
112
|
-
const d = e.join(e.resolve(t.globRoot), "/"), i = d.length + r.length, g = [], P = [], u = /* @__PURE__ */ new Set();
|
|
113
|
-
for (const s of n) {
|
|
114
|
-
const a = d + s;
|
|
115
|
-
if (s.endsWith(".json")) {
|
|
116
|
-
const l = e.basename(s);
|
|
117
|
-
l === "package.json" ? g.push(a) : (l.startsWith("tsconfig.") || l.startsWith("jsconfig.")) && P.push(a);
|
|
118
|
-
} else {
|
|
119
|
-
const l = s.slice(r.length);
|
|
120
|
-
u.add(l);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
let h = await M("tsconfig.json", e.dirname(process.cwd()));
|
|
124
|
-
h !== void 0 && (h = W(h), P.push(h)), P.sort((s, a) => {
|
|
125
|
-
const l = a.split("/").length - s.split("/").length;
|
|
126
|
-
if (l !== 0)
|
|
127
|
-
return l;
|
|
128
|
-
const m = e.basename(s), f = e.basename(a);
|
|
129
|
-
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);
|
|
130
|
-
});
|
|
131
|
-
let p = await M("package.json");
|
|
132
|
-
p !== void 0 && (p = W(p));
|
|
133
|
-
const w = [], v = /* @__PURE__ */ new Set();
|
|
134
|
-
if (await Promise.all(
|
|
135
|
-
P.map(async (s) => {
|
|
136
|
-
const a = e.relative(process.cwd(), s), l = c.readConfigFile(s, c.sys.readFile);
|
|
137
|
-
if (l.error !== void 0) {
|
|
138
|
-
y(
|
|
139
|
-
"error",
|
|
140
|
-
a,
|
|
141
|
-
c.formatDiagnosticsWithColorAndContext([l.error], {
|
|
142
|
-
getCanonicalFileName: _,
|
|
143
|
-
getCurrentDirectory: c.sys.getCurrentDirectory,
|
|
144
|
-
getNewLine: () => c.sys.newLine
|
|
145
|
-
})
|
|
146
|
-
);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
const m = e.basename(a), f = c.parseJsonConfigFileContent(
|
|
150
|
-
l.config,
|
|
151
|
-
c.sys,
|
|
152
|
-
e.dirname(s),
|
|
153
|
-
void 0,
|
|
154
|
-
m
|
|
155
|
-
), R = 18003;
|
|
156
|
-
f.errors.filter((b) => b.code !== R).length > 0 && y(
|
|
157
|
-
"warn",
|
|
158
|
-
a,
|
|
159
|
-
c.formatDiagnosticsWithColorAndContext(f.errors, {
|
|
160
|
-
getCanonicalFileName: _,
|
|
161
|
-
getCurrentDirectory: c.sys.getCurrentDirectory,
|
|
162
|
-
getNewLine: () => c.sys.newLine
|
|
163
|
-
})
|
|
164
|
-
);
|
|
165
|
-
const E = s === h, $ = a === m, N = f.fileNames.filter((b) => {
|
|
166
|
-
const D = b.slice(i);
|
|
167
|
-
return u.delete(D) ? (v.add(D), !0) : v.has(D) || D.endsWith(".json") || b.includes("node_modules") ? !1 : !E;
|
|
168
|
-
});
|
|
169
|
-
if (N.length === 0)
|
|
170
|
-
return;
|
|
171
|
-
P.length === 1 && (E || $) && u.clear();
|
|
172
|
-
const S = e.dirname(s);
|
|
173
|
-
let x = S, C = p;
|
|
174
|
-
do {
|
|
175
|
-
const b = e.join(x, "package.json");
|
|
176
|
-
if (g.includes(b)) {
|
|
177
|
-
C = b;
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
|
-
} while (x !== t.globRoot && (x = e.dirname(x)));
|
|
181
|
-
const J = C === void 0 ? void 0 : { filePath: C, contents: await L(e.dirname(C)) }, K = {
|
|
182
|
-
typeScriptConfig: {
|
|
183
|
-
filePath: s,
|
|
184
|
-
compilerOptions: f.options
|
|
185
|
-
},
|
|
186
|
-
packageJson: J,
|
|
187
|
-
logName: F("blue", J?.contents?.name ?? S),
|
|
188
|
-
cwd: S,
|
|
189
|
-
filePaths: N
|
|
190
|
-
};
|
|
191
|
-
w.push(K);
|
|
192
|
-
})
|
|
193
|
-
), u.size > 0) {
|
|
194
|
-
const s = p === void 0 ? void 0 : {
|
|
195
|
-
filePath: p,
|
|
196
|
-
contents: await L(e.dirname(p))
|
|
197
|
-
};
|
|
198
|
-
w.push({
|
|
199
|
-
typeScriptConfig: void 0,
|
|
200
|
-
packageJson: s,
|
|
201
|
-
cwd: process.cwd(),
|
|
202
|
-
logName: F("blue", s?.contents?.name ?? process.cwd()),
|
|
203
|
-
filePaths: Array.from(u).map((a) => e.join(process.cwd(), a))
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
return w.sort((s, a) => s.cwd.localeCompare(a.cwd)), j.projectsData = w, w;
|
|
207
|
-
}
|
|
208
|
-
let T = !1;
|
|
209
|
-
function oe() {
|
|
210
|
-
T || (T = !0, process.exitCode !== void 0 && process.exitCode !== 0 ? y(
|
|
211
|
-
"warn",
|
|
212
|
-
j.codemodName,
|
|
213
|
-
"One or more exceptions occurred during the codemod run. Please review the output above."
|
|
214
|
-
) : y(
|
|
215
|
-
"info",
|
|
216
|
-
j.codemodName,
|
|
217
|
-
`${F("green", "Codemod completed successfully.")} Recommended next steps:
|
|
218
|
-
- Review the codemod changes.
|
|
219
|
-
- If your project uses ESLint, run ESLint autofix on the changed files.
|
|
220
|
-
- If your project uses Prettier, run Prettier on the changed files.
|
|
221
|
-
- If your project uses TypeScript, run type checking to ensure there are no type errors.`
|
|
222
|
-
));
|
|
223
|
-
}
|
|
224
|
-
async function se(t, o) {
|
|
225
|
-
j.codemod = t, j.codemodName = o;
|
|
226
|
-
const n = await te();
|
|
227
|
-
if (n.length === 0) {
|
|
228
|
-
y("error", o, `Failed to find any .js or .ts files in ${process.cwd()} to run the codemod on.`), process.exitCode = 1;
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
await t.run(n), oe();
|
|
232
|
-
}
|
|
233
|
-
const I = new U();
|
|
234
|
-
I.name("@arcgis/codemod").description("Codemod for migrating or refactoring usages of ArcGIS Maps SDK for JavaScript");
|
|
235
|
-
I.command("run").description("Run a single codemod").argument("<codemodName>", "Name of the transform").argument("[path]", "Directory to transform", process.cwd()).action(ne);
|
|
236
|
-
async function ne(t, o) {
|
|
237
|
-
const n = B(o, { throwIfNoEntry: !1 });
|
|
238
|
-
if (n === void 0) {
|
|
239
|
-
y("error", "@arcgis/codemod", `Failed to find the target path: ${o}`), process.exitCode = 1;
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
const r = n.isFile();
|
|
243
|
-
process.chdir(r ? e.dirname(o) : o);
|
|
244
|
-
let d;
|
|
245
|
-
try {
|
|
246
|
-
d = await z(/* @__PURE__ */ Object.assign({ "./codemods/api-extractor-strict-mode/codemod.ts": () => import("./codemod-MHr8xn-r.js"), "./codemods/geometry-operator-renames/codemod.ts": () => import("./codemod--z_92lWI.js"), "./codemods/lumina-component-extras-improvements/codemod.ts": () => import("./codemod-ZwlO-Y4a.js"), "./codemods/node-toolkit/codemod.ts": () => import("./codemod-v6MLU8Qq.js"), "./codemods/normalize-calcite-icon-names/codemod.ts": () => import("./codemod-CtDiL__8.js"), "./codemods/refactor-out-esri-namespace/codemod.ts": () => import("./codemod-DKND2-mc.js"), "./codemods/toolkit-5.2-renames/codemod.ts": () => import("./codemod-BALsil-0.js") }), `./codemods/${t}/codemod.ts`, 4);
|
|
247
|
-
} catch (i) {
|
|
248
|
-
if (
|
|
249
|
-
// direct Node execution
|
|
250
|
-
typeof i == "object" && i !== null && "code" in i && i.code === "ERR_MODULE_NOT_FOUND" && "url" in i && typeof i.url == "string" && i.url.endsWith(`/${t}/codemod.ts`) || // Vite build execution
|
|
251
|
-
String(i).includes("Unknown variable dynamic import:")
|
|
252
|
-
) {
|
|
253
|
-
y("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
254
|
-
return;
|
|
255
|
-
} else
|
|
256
|
-
throw i;
|
|
257
|
-
}
|
|
258
|
-
if (typeof d.codemod != "object" || d.codemod === null) {
|
|
259
|
-
y("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
await se(d.codemod, F("blue", t));
|
|
263
|
-
}
|
|
264
|
-
I.parse();
|
|
265
|
-
export {
|
|
266
|
-
ye as d,
|
|
267
|
-
j as g,
|
|
268
|
-
oe as p
|
|
269
|
-
};
|