@arcgis/codemod 6.0.0-next.6 → 6.0.0-next.8
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/chunks/artifact.js +44 -0
- package/dist/chunks/classification.js +105 -134
- package/dist/chunks/cli.js +347 -212
- package/dist/chunks/componentAudit.js +158 -0
- package/dist/chunks/format.js +110 -106
- package/dist/chunks/github.js +124 -0
- package/dist/chunks/index.js +545 -315
- package/dist/chunks/index2.js +102 -88
- package/dist/chunks/index3.js +307 -0
- package/dist/chunks/sync.js +44 -142
- package/dist/chunks/syncMarkdown.js +32 -0
- package/dist/chunks/useProjectInstance.js +22 -22
- package/package.json +4 -4
- package/dist/chunks/hardcodedBehavior.js +0 -63
package/dist/chunks/cli.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { log as
|
|
2
|
-
import { Command as
|
|
3
|
-
import { stat as
|
|
4
|
-
import { path as
|
|
5
|
-
import { asyncFindPath as
|
|
1
|
+
import { log as m } from "@arcgis/toolkit/log";
|
|
2
|
+
import { Command as ne, InvalidArgumentError as F } from "@commander-js/extra-typings";
|
|
3
|
+
import { stat as V, realpath as Q } from "node:fs/promises";
|
|
4
|
+
import { path as n, getCwd as N, toPosixPathSeparators as _ } from "@arcgis/node-toolkit/path";
|
|
5
|
+
import { asyncFindPath as W, existsAsync as G } from "@arcgis/node-toolkit/file";
|
|
6
6
|
import "ts-morph";
|
|
7
|
-
import
|
|
8
|
-
import { asyncRetrievePackageJson as
|
|
9
|
-
import { glob as
|
|
10
|
-
import { gitIgnoreFileToGlobs as
|
|
11
|
-
import { identity as
|
|
12
|
-
import { styleText as
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
import d from "typescript";
|
|
8
|
+
import { asyncRetrievePackageJson as ie } from "@arcgis/node-toolkit/packageJson";
|
|
9
|
+
import { glob as X } from "tinyglobby";
|
|
10
|
+
import { gitIgnoreFileToGlobs as Y } from "@arcgis/node-toolkit/glob";
|
|
11
|
+
import { identity as q } from "@arcgis/toolkit/function";
|
|
12
|
+
import { styleText as J } from "node:util";
|
|
13
|
+
import { randomUUID as ae } from "node:crypto";
|
|
14
|
+
const ce = (t, e, o) => {
|
|
15
|
+
const s = t[e];
|
|
16
|
+
return s ? typeof s == "function" ? s() : Promise.resolve(s) : new Promise((r, l) => {
|
|
17
|
+
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(l.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + e + (e.split("/").length !== o ? ". Note that variables only represent file names one level deep." : ""))));
|
|
17
18
|
});
|
|
18
|
-
},
|
|
19
|
+
}, We = {
|
|
19
20
|
allowImportingTsExtensions: !0,
|
|
20
21
|
allowJs: !0,
|
|
21
22
|
allowArbitraryExtensions: !0,
|
|
@@ -25,81 +26,89 @@ const X = (t, e, s) => {
|
|
|
25
26
|
forceConsistentCasingInFileNames: !1,
|
|
26
27
|
isolatedModules: !1,
|
|
27
28
|
isolatedDeclarations: !1,
|
|
28
|
-
jsx:
|
|
29
|
+
jsx: d.JsxEmit.Preserve,
|
|
29
30
|
lib: ["lib.esnext.d.ts", "lib.dom.d.ts"],
|
|
30
|
-
module:
|
|
31
|
-
moduleResolution:
|
|
32
|
-
moduleDetection:
|
|
31
|
+
module: d.ModuleKind.ESNext,
|
|
32
|
+
moduleResolution: d.ModuleResolutionKind.Bundler,
|
|
33
|
+
moduleDetection: d.ModuleDetectionKind.Auto,
|
|
33
34
|
strict: !1,
|
|
34
|
-
target:
|
|
35
|
+
target: d.ScriptTarget.ESNext,
|
|
35
36
|
resolveJsonModule: !0,
|
|
36
37
|
esModuleInterop: !0
|
|
37
|
-
},
|
|
38
|
+
}, v = {
|
|
38
39
|
codemod: void 0,
|
|
39
40
|
codemodName: void 0,
|
|
40
41
|
projectsData: void 0,
|
|
41
42
|
project: void 0
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
}, Z = [
|
|
44
|
+
// Hardcoded ignores in TypeScript
|
|
45
|
+
"**/node_modules/**",
|
|
46
|
+
"**/bower_components/**",
|
|
47
|
+
"**/jspm_packages/**",
|
|
48
|
+
// Default build output folder in bundlers
|
|
49
|
+
"**/dist/**"
|
|
50
|
+
];
|
|
51
|
+
async function de() {
|
|
52
|
+
const { ignorePatterns: t, globRoot: e, hasIgnoreFiles: o } = await le(), s = await ue(e);
|
|
53
|
+
return t.push(...s.ignorePatterns), !o && !s.hasIgnoreFiles && t.push(...Z), { ignorePatterns: t, globRoot: e };
|
|
46
54
|
}
|
|
47
|
-
async function
|
|
48
|
-
const t = []
|
|
49
|
-
let
|
|
55
|
+
async function le() {
|
|
56
|
+
const t = [];
|
|
57
|
+
let e = !1;
|
|
58
|
+
const o = await W(".git"), s = o === void 0 ? void 0 : n.dirname(o);
|
|
59
|
+
let r, l = N(), p = n.dirname(l);
|
|
50
60
|
do {
|
|
51
|
-
if (
|
|
61
|
+
if (r = p, s !== void 0 && r !== s && !r.startsWith(`${s}/`))
|
|
52
62
|
break;
|
|
53
|
-
const w =
|
|
54
|
-
if (await
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
for (const
|
|
58
|
-
const
|
|
59
|
-
let
|
|
60
|
-
const
|
|
61
|
-
for (let
|
|
62
|
-
const
|
|
63
|
-
if (!(
|
|
64
|
-
|
|
63
|
+
const w = n.join(r, ".gitignore");
|
|
64
|
+
if (await G(w)) {
|
|
65
|
+
e = !0, l = n.dirname(w);
|
|
66
|
+
const x = n.relative(l, N()).split("/"), D = Y(w);
|
|
67
|
+
for (const g of D) {
|
|
68
|
+
const b = g.startsWith("!") ? g.slice(1) : g, f = b.search(/[*?[]/u), h = f === -1 ? b : b.slice(0, f), j = h.split("/"), y = f !== -1 && !h.endsWith("/");
|
|
69
|
+
let S = !0;
|
|
70
|
+
const i = Math.min(x.length, j.length);
|
|
71
|
+
for (let c = 0; c < i; c++) {
|
|
72
|
+
const a = j[c];
|
|
73
|
+
if (!(y && c === j.length - 1 ? x[c].startsWith(a) : x[c] === a) && a !== "") {
|
|
74
|
+
S = !1;
|
|
65
75
|
break;
|
|
66
76
|
}
|
|
67
77
|
}
|
|
68
|
-
|
|
78
|
+
S && (g.startsWith("!") || t.push(g));
|
|
69
79
|
}
|
|
70
80
|
}
|
|
71
|
-
|
|
72
|
-
} while (
|
|
73
|
-
return { ignorePatterns: t, globRoot:
|
|
81
|
+
p = n.dirname(r);
|
|
82
|
+
} while (p !== r);
|
|
83
|
+
return { ignorePatterns: t, globRoot: l, hasIgnoreFiles: e };
|
|
74
84
|
}
|
|
75
|
-
async function
|
|
76
|
-
|
|
77
|
-
cwd:
|
|
85
|
+
async function ue(t) {
|
|
86
|
+
const e = await X("**/.gitignore", {
|
|
87
|
+
cwd: N(),
|
|
78
88
|
// Gitignore files are unlikely to be symbolic links
|
|
79
89
|
followSymbolicLinks: !1,
|
|
80
90
|
// Don't look for ignore files in these places for speed:
|
|
81
|
-
ignore:
|
|
82
|
-
// Hardcoded ignores in TypeScript
|
|
83
|
-
"**/node_modules/**",
|
|
84
|
-
"**/bower_components/**",
|
|
85
|
-
"**/jspm_packages/**",
|
|
86
|
-
// Default build output folder in bundlers
|
|
87
|
-
"**/dist/**"
|
|
88
|
-
],
|
|
91
|
+
ignore: Z,
|
|
89
92
|
// Not applicable for our glob pattern
|
|
90
93
|
expandDirectories: !1
|
|
91
|
-
})).flatMap((s) => {
|
|
92
|
-
const o = i.relative(t, i.dirname(s)), r = H(s), l = [];
|
|
93
|
-
for (const w of r)
|
|
94
|
-
w.startsWith("!") || l.push(i.join(o, w));
|
|
95
|
-
return l;
|
|
96
94
|
});
|
|
95
|
+
return { ignorePatterns: e.flatMap((s) => {
|
|
96
|
+
const r = n.relative(t, n.dirname(s)), l = Y(s), p = [];
|
|
97
|
+
for (const w of l)
|
|
98
|
+
w.startsWith("!") || p.push(n.join(r, w));
|
|
99
|
+
return p;
|
|
100
|
+
}), hasIgnoreFiles: e.length > 0 };
|
|
97
101
|
}
|
|
98
|
-
const
|
|
99
|
-
async function
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
const ee = ["js", "jsx", "mjs", "cjs"], te = ["ts", "tsx", "mts", "cts"], me = /* @__PURE__ */ new Set([...ee, ...te]), pe = ["json"], ge = ["css", "scss", "sass", "html"];
|
|
103
|
+
async function fe(t, e = !1) {
|
|
104
|
+
const o = await de(), r = `**/*.{${[
|
|
105
|
+
...ee,
|
|
106
|
+
...te,
|
|
107
|
+
...pe,
|
|
108
|
+
...e ? ge : []
|
|
109
|
+
].join(",")}}`, l = n.join(process.cwd(), r), p = n.join(n.resolve(o.globRoot), "/"), w = (await X(l, {
|
|
110
|
+
cwd: o.globRoot,
|
|
111
|
+
ignore: o.ignorePatterns,
|
|
103
112
|
// The files we are looking for are unlikely to be symbolic links
|
|
104
113
|
followSymbolicLinks: !1,
|
|
105
114
|
// Not applicable for our glob pattern
|
|
@@ -108,136 +117,140 @@ async function ne(t) {
|
|
|
108
117
|
// default behavior). If any tsconfig.json explicitly includes such files,
|
|
109
118
|
// they will still be codemodded.
|
|
110
119
|
})).filter(
|
|
111
|
-
(
|
|
120
|
+
(i) => i.endsWith(".json") || t === void 0 || p + i === t
|
|
112
121
|
);
|
|
113
|
-
let
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
for (const
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
119
|
-
const a =
|
|
120
|
-
a === "package.json" ?
|
|
122
|
+
let k = n.relative(o.globRoot, process.cwd());
|
|
123
|
+
k !== "" && (k += "/");
|
|
124
|
+
const x = p.length + k.length, D = [], g = [], b = /* @__PURE__ */ new Set();
|
|
125
|
+
for (const i of w) {
|
|
126
|
+
const c = p + i;
|
|
127
|
+
if (i.endsWith(".json")) {
|
|
128
|
+
const a = n.basename(i);
|
|
129
|
+
a === "package.json" ? D.push(c) : (a.startsWith("tsconfig.") || a.startsWith("jsconfig.")) && g.push(c);
|
|
121
130
|
} else {
|
|
122
|
-
const a =
|
|
123
|
-
|
|
131
|
+
const a = i.slice(k.length);
|
|
132
|
+
b.add(a);
|
|
124
133
|
}
|
|
125
134
|
}
|
|
126
|
-
let
|
|
127
|
-
|
|
128
|
-
const a =
|
|
135
|
+
let f = await W("tsconfig.json", n.dirname(process.cwd()));
|
|
136
|
+
f !== void 0 && (f = _(f), g.push(f)), g.sort((i, c) => {
|
|
137
|
+
const a = c.split("/").length - i.split("/").length;
|
|
129
138
|
if (a !== 0)
|
|
130
139
|
return a;
|
|
131
|
-
const
|
|
132
|
-
return
|
|
140
|
+
const u = n.basename(i), P = n.basename(c);
|
|
141
|
+
return u === P ? 0 : u.endsWith("tsconfig.json") ? -1 : P.endsWith("tsconfig.json") ? 1 : u.endsWith("tsconfig.build.json") ? -1 : P.endsWith("tsconfig.build.json") ? 1 : u.localeCompare(P);
|
|
133
142
|
});
|
|
134
|
-
let
|
|
135
|
-
|
|
136
|
-
const
|
|
143
|
+
let h = await W("package.json");
|
|
144
|
+
h !== void 0 && (h = _(h));
|
|
145
|
+
const j = [
|
|
146
|
+
.../* @__PURE__ */ new Set([...D, ...h === void 0 ? [] : [h]])
|
|
147
|
+
].sort((i, c) => c.length - i.length), y = [], S = /* @__PURE__ */ new Set();
|
|
137
148
|
if (await Promise.all(
|
|
138
|
-
|
|
139
|
-
const
|
|
149
|
+
g.map(async (i) => {
|
|
150
|
+
const c = n.relative(process.cwd(), i), a = d.readConfigFile(i, d.sys.readFile);
|
|
140
151
|
if (a.error !== void 0) {
|
|
141
|
-
|
|
152
|
+
m(
|
|
142
153
|
"error",
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
getCanonicalFileName:
|
|
146
|
-
getCurrentDirectory:
|
|
147
|
-
getNewLine: () =>
|
|
154
|
+
c,
|
|
155
|
+
d.formatDiagnosticsWithColorAndContext([a.error], {
|
|
156
|
+
getCanonicalFileName: q,
|
|
157
|
+
getCurrentDirectory: d.sys.getCurrentDirectory,
|
|
158
|
+
getNewLine: () => d.sys.newLine
|
|
148
159
|
})
|
|
149
160
|
);
|
|
150
161
|
return;
|
|
151
162
|
}
|
|
152
|
-
const
|
|
163
|
+
const u = d.parseJsonConfigFileContent(
|
|
153
164
|
a.config,
|
|
154
|
-
|
|
155
|
-
|
|
165
|
+
d.sys,
|
|
166
|
+
n.dirname(i),
|
|
156
167
|
void 0,
|
|
157
|
-
|
|
158
|
-
),
|
|
159
|
-
|
|
168
|
+
i
|
|
169
|
+
), P = 18003;
|
|
170
|
+
u.errors.filter((I) => I.code !== P).length > 0 && m(
|
|
160
171
|
"warn",
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
getCanonicalFileName:
|
|
164
|
-
getCurrentDirectory:
|
|
165
|
-
getNewLine: () =>
|
|
172
|
+
c,
|
|
173
|
+
d.formatDiagnosticsWithColorAndContext(u.errors, {
|
|
174
|
+
getCanonicalFileName: q,
|
|
175
|
+
getCurrentDirectory: d.sys.getCurrentDirectory,
|
|
176
|
+
getNewLine: () => d.sys.newLine
|
|
166
177
|
})
|
|
167
178
|
);
|
|
168
|
-
const
|
|
169
|
-
if (t !== void 0 &&
|
|
179
|
+
const se = i === f, U = u.fileNames.filter((I) => {
|
|
180
|
+
if (t !== void 0 && I !== t)
|
|
170
181
|
return !1;
|
|
171
|
-
const
|
|
172
|
-
return
|
|
182
|
+
const O = I.slice(x);
|
|
183
|
+
return b.delete(O) ? (S.add(O), !0) : S.has(O) || O.endsWith(".json") || I.includes("node_modules") ? !1 : !se;
|
|
173
184
|
});
|
|
174
|
-
if (
|
|
185
|
+
if (U.length === 0)
|
|
175
186
|
return;
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
if (j === e.globRoot)
|
|
186
|
-
break;
|
|
187
|
-
j = i.dirname(j);
|
|
188
|
-
}
|
|
189
|
-
const L = k === void 0 ? void 0 : { filePath: k, contents: await $(i.dirname(k)) }, V = {
|
|
190
|
-
typeScriptConfig: {
|
|
191
|
-
filePath: n,
|
|
192
|
-
compilerOptions: f.options
|
|
193
|
-
},
|
|
194
|
-
packageJson: L,
|
|
195
|
-
logName: D("blue", L?.contents?.name ?? O),
|
|
196
|
-
cwd: O,
|
|
197
|
-
filePaths: F
|
|
198
|
-
};
|
|
199
|
-
h.push(V);
|
|
187
|
+
const L = n.dirname(i), re = H(L, j) ?? h;
|
|
188
|
+
y.push(
|
|
189
|
+
await K(U, L, re, {
|
|
190
|
+
filePath: i,
|
|
191
|
+
compilerOptions: u.options
|
|
192
|
+
})
|
|
193
|
+
);
|
|
200
194
|
})
|
|
201
|
-
),
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
packageJson: n,
|
|
209
|
-
cwd: process.cwd(),
|
|
210
|
-
logName: D("blue", n?.contents?.name ?? process.cwd()),
|
|
211
|
-
filePaths: Array.from(v).map((d) => i.join(process.cwd(), d))
|
|
212
|
-
});
|
|
195
|
+
), b.size > 0) {
|
|
196
|
+
const i = [...b].map((a) => n.join(process.cwd(), a)), c = Map.groupBy(i, (a) => H(a, j));
|
|
197
|
+
y.push(
|
|
198
|
+
...await Promise.all(
|
|
199
|
+
[...c].map(async ([a, u]) => await K(u, process.cwd(), a))
|
|
200
|
+
)
|
|
201
|
+
);
|
|
213
202
|
}
|
|
214
|
-
return
|
|
203
|
+
return y.sort((i, c) => i.cwd.localeCompare(c.cwd)), v.projectsData = y, y;
|
|
204
|
+
}
|
|
205
|
+
function Te(t) {
|
|
206
|
+
const e = n.extname(t).slice(1);
|
|
207
|
+
return me.has(e);
|
|
208
|
+
}
|
|
209
|
+
function H(t, e) {
|
|
210
|
+
return e.find((o) => {
|
|
211
|
+
const s = n.dirname(o);
|
|
212
|
+
return t === s || t.startsWith(`${s}/`);
|
|
213
|
+
});
|
|
215
214
|
}
|
|
216
|
-
function
|
|
217
|
-
|
|
215
|
+
async function K(t, e, o, s) {
|
|
216
|
+
const r = o === void 0 ? void 0 : {
|
|
217
|
+
filePath: o,
|
|
218
|
+
contents: await ie(n.dirname(o))
|
|
219
|
+
};
|
|
220
|
+
return {
|
|
221
|
+
typeScriptConfig: s,
|
|
222
|
+
packageJson: r,
|
|
223
|
+
cwd: e,
|
|
224
|
+
filePaths: t,
|
|
225
|
+
logName: J("blue", r?.contents.name ?? e)
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function he() {
|
|
229
|
+
v.codemod.meta.needsFooter && (v.codemod.meta.needsFooter = !1, process.exitCode !== void 0 && process.exitCode !== 0 ? m(
|
|
218
230
|
"warn",
|
|
219
|
-
|
|
231
|
+
v.codemodName,
|
|
220
232
|
"One or more exceptions occurred during the codemod run. Please review the output above."
|
|
221
|
-
) :
|
|
233
|
+
) : m(
|
|
222
234
|
"info",
|
|
223
|
-
|
|
224
|
-
`${
|
|
235
|
+
v.codemodName,
|
|
236
|
+
`${J("green", "Codemod completed successfully.")} Recommended next steps:
|
|
225
237
|
- Review the codemod changes.
|
|
226
238
|
- If your project uses ESLint, run ESLint autofix on the changed files.
|
|
227
239
|
- If your project uses Prettier, run Prettier on the changed files.
|
|
228
240
|
- If your project uses TypeScript, run type checking to ensure there are no type errors.`
|
|
229
241
|
));
|
|
230
242
|
}
|
|
231
|
-
async function
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
if (
|
|
235
|
-
|
|
243
|
+
async function we(t, e, o) {
|
|
244
|
+
v.codemod = t, v.codemodName = e;
|
|
245
|
+
const s = await fe(o, t.meta.includeComponentFiles);
|
|
246
|
+
if (s.length === 0) {
|
|
247
|
+
const r = t.meta.includeComponentFiles ? "source files or component manifests" : ".js or .ts files";
|
|
248
|
+
m("error", e, `Failed to find any ${r} in ${process.cwd()} to run the codemod on.`), process.exitCode = 1;
|
|
236
249
|
return;
|
|
237
250
|
}
|
|
238
|
-
await t.run(
|
|
251
|
+
await t.run(s), he();
|
|
239
252
|
}
|
|
240
|
-
const
|
|
253
|
+
const E = {
|
|
241
254
|
coreViews: {
|
|
242
255
|
label: "@arcgis/core views and UI - highest priority",
|
|
243
256
|
description: "Use map components and slots instead. Directly constructed views will no longer include .ui (like zoom buttons) in 6.0."
|
|
@@ -270,42 +283,85 @@ const W = {
|
|
|
270
283
|
label: "Non-Esri packages and web platform - low priority",
|
|
271
284
|
description: "These deprecations do not block updating Esri packages and are not tied to an ArcGIS release."
|
|
272
285
|
}
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
286
|
+
}, R = "https://webgis.esri.com/api/deprecations";
|
|
287
|
+
async function $e(t, e) {
|
|
288
|
+
const o = ae();
|
|
289
|
+
process.stderr.write(`Submitting deprecation report (${o}).
|
|
290
|
+
`);
|
|
291
|
+
let s;
|
|
292
|
+
try {
|
|
293
|
+
s = await fetch(e, {
|
|
294
|
+
method: "POST",
|
|
295
|
+
headers: { "Content-Type": "application/json" },
|
|
296
|
+
body: JSON.stringify({
|
|
297
|
+
submissionId: o,
|
|
298
|
+
report: t
|
|
299
|
+
}),
|
|
300
|
+
signal: AbortSignal.timeout(12e4),
|
|
301
|
+
redirect: "error"
|
|
302
|
+
});
|
|
303
|
+
} catch (l) {
|
|
304
|
+
throw new Error(`Deprecation reporting failed; check submission ${o} before retrying.`, {
|
|
305
|
+
cause: l
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
if (!s.ok)
|
|
309
|
+
throw new Error(`Deprecation reporting failed: HTTP ${s.status}. Submission ID: ${o}`);
|
|
310
|
+
const r = await s.json();
|
|
311
|
+
if (typeof r != "object" || r === null || !("submissionId" in r) || r.submissionId !== o)
|
|
312
|
+
throw new Error(`Invalid collector acknowledgement. Check submission ${o} before retrying.`);
|
|
313
|
+
process.stderr.write(`Deprecation report submitted to ${e} (${o}).
|
|
314
|
+
`);
|
|
315
|
+
}
|
|
316
|
+
const be = /(?:esri|arcgis)/iu, T = ["all", "repositories", "apis"], Ge = "@arcgis/codemod", Je = {
|
|
317
|
+
usages: "Refactor-out deprecated API usages",
|
|
318
|
+
definitions: "Remove deprecated APIs in next breaking changes release"
|
|
319
|
+
}, Me = {
|
|
320
|
+
usages: "The following deprecated APIs are used in files owned by assigned CODEOWNERS. Refactor them before the APIs are removed.",
|
|
321
|
+
definitions: "The following deprecated APIs are owned by assigned CODEOWNERS. Remove them in the next breaking changes release."
|
|
322
|
+
}, Ue = "This issue is autogenerated and updated regularly based on remaining items. Feel free to add comments and labels, update assignees, set milestone, or create sub-issues. Close it once completed. A new issue will be created if new findings are detected.", Le = "Task", _e = "deprecations sync-issues";
|
|
323
|
+
function qe(t) {
|
|
324
|
+
return be.test(t);
|
|
325
|
+
}
|
|
326
|
+
const A = new ne();
|
|
327
|
+
A.name("@arcgis/codemod").description("Codemod for migrating or refactoring usages of ArcGIS Maps SDK for JavaScript");
|
|
328
|
+
A.command("run").description("Run a single codemod").argument("<codemodName>", "Name of the transform").argument("[path]", "Directory to transform", process.cwd()).action(async (t, e) => {
|
|
329
|
+
const o = await M(e);
|
|
330
|
+
let s;
|
|
278
331
|
try {
|
|
279
|
-
|
|
332
|
+
s = await ce(/* @__PURE__ */ Object.assign({ "./codemods/api-extractor-strict-mode/codemod.ts": () => import("./codemod.js"), "./codemods/geometry-operator-renames/codemod.ts": () => import("./codemod2.js"), "./codemods/lumina-component-extras-improvements/codemod.ts": () => import("./codemod3.js"), "./codemods/lumina-toolkit/codemod.ts": () => import("./codemod4.js"), "./codemods/node-toolkit/codemod.ts": () => import("./codemod5.js"), "./codemods/normalize-calcite-icon-names/codemod.ts": () => import("./codemod6.js"), "./codemods/refactor-out-esri-namespace/codemod.ts": () => import("./codemod7.js"), "./codemods/toolkit-5.2-renames/codemod.ts": () => import("./codemod8.js") }), `./codemods/${t}/codemod.ts`, 4);
|
|
280
333
|
} catch (r) {
|
|
281
334
|
if (
|
|
282
335
|
// direct Node execution
|
|
283
336
|
typeof r == "object" && r !== null && "code" in r && r.code === "ERR_MODULE_NOT_FOUND" && "url" in r && typeof r.url == "string" && r.url.endsWith(`/${t}/codemod.ts`) || // Vite build execution
|
|
284
337
|
String(r).includes("Unknown variable dynamic import:")
|
|
285
338
|
) {
|
|
286
|
-
|
|
339
|
+
m("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
287
340
|
return;
|
|
288
341
|
} else
|
|
289
342
|
throw r;
|
|
290
343
|
}
|
|
291
|
-
if (typeof
|
|
292
|
-
|
|
344
|
+
if (typeof s.codemod != "object" || s.codemod === null) {
|
|
345
|
+
m("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
|
|
293
346
|
return;
|
|
294
347
|
}
|
|
295
|
-
await
|
|
348
|
+
await we(s.codemod, J("blue", t), o);
|
|
296
349
|
});
|
|
297
|
-
const
|
|
350
|
+
const C = A.command("deprecations").description(
|
|
298
351
|
`Audit and report deprecated APIs.
|
|
299
352
|
|
|
300
353
|
Documentation: https://webgis.esri.com/references/codemod/deprecations`
|
|
301
354
|
);
|
|
302
|
-
|
|
355
|
+
C.command("audit-usages").description(
|
|
303
356
|
"Report deprecated API usages. Documentation: https://webgis.esri.com/references/codemod/deprecations#audit-usages"
|
|
304
357
|
).argument("[path]", "Directory to audit", process.cwd()).option("--esri-only", "Only report usages of deprecated APIs from Esri and ArcGIS packages", !1).option(
|
|
305
358
|
"--category <category>",
|
|
306
|
-
`Only report usages in a category. Available categories: ${Object.keys(
|
|
307
|
-
|
|
359
|
+
`Only report usages in a category. Available categories: ${Object.keys(E).join(", ")}`,
|
|
360
|
+
oe
|
|
308
361
|
).option("--package <package-name>", "Only report usages of deprecated APIs from this package").option(
|
|
362
|
+
"--report [url]",
|
|
363
|
+
`Submit a complete repository scan to the WebGIS collector (default: ${R})`
|
|
364
|
+
).option(
|
|
309
365
|
"--json",
|
|
310
366
|
"Output results as JSON. Example: npx @arcgis/codemod deprecations audit-usages --json > usages.json",
|
|
311
367
|
!1
|
|
@@ -315,28 +371,88 @@ J.command("audit-usages").description(
|
|
|
315
371
|
!1
|
|
316
372
|
).action(async (t, e) => {
|
|
317
373
|
if (e.json && e.md) {
|
|
318
|
-
|
|
374
|
+
m("error", "@arcgis/codemod", "The --json and --md options cannot be used together."), process.exitCode = 1;
|
|
319
375
|
return;
|
|
320
376
|
}
|
|
321
|
-
const
|
|
322
|
-
await o
|
|
377
|
+
const o = await M(t), { auditDeprecatedUsages: s } = await import("./index.js"), r = e.md ? "md" : e.json ? "json" : "text";
|
|
378
|
+
await s(o, {
|
|
323
379
|
esriOnly: e.esriOnly,
|
|
324
380
|
outputFormat: r,
|
|
325
381
|
category: e.category,
|
|
326
|
-
packageName: e.package
|
|
382
|
+
packageName: e.package,
|
|
383
|
+
reportingUrl: e.report === !0 ? R : e.report || void 0
|
|
327
384
|
});
|
|
328
385
|
});
|
|
329
|
-
|
|
386
|
+
C.command("audit-definitions").description(
|
|
330
387
|
"Report exported APIs marked as deprecated. Documentation: https://webgis.esri.com/references/codemod/deprecations#audit-definitions"
|
|
331
388
|
).argument("[path]", "Directory to audit", process.cwd()).option(
|
|
332
389
|
"--json",
|
|
333
390
|
"Output results as JSON. Example: npx @arcgis/codemod deprecations audit-definitions --json > definitions.json",
|
|
334
391
|
!1
|
|
335
392
|
).action(async (t, e) => {
|
|
336
|
-
const
|
|
337
|
-
await o
|
|
393
|
+
const o = await M(t), { auditDeprecatedDefinitions: s } = await import("./index2.js");
|
|
394
|
+
await s(o, e.json);
|
|
338
395
|
});
|
|
339
|
-
|
|
396
|
+
C.command("aggregate-usages").description(
|
|
397
|
+
"Aggregate audit-usages reports into repository summaries and an API usage tree. Documentation: https://webgis.esri.com/references/codemod/deprecations#analyze-the-ecosystem"
|
|
398
|
+
).argument("[reports...]", "Paths to audit-usages JSON files").option(
|
|
399
|
+
"--section <section>",
|
|
400
|
+
`Reports to include in the markdown report: ${T.join(", ")}`,
|
|
401
|
+
ye,
|
|
402
|
+
"all"
|
|
403
|
+
).option(
|
|
404
|
+
"--remote [url]",
|
|
405
|
+
`Read the latest stored audit per repository from the WebGIS collector (default: ${R})`
|
|
406
|
+
).option(
|
|
407
|
+
"--repository <repository>",
|
|
408
|
+
"Select a remote repository (host/owner/repo); repeat to select multiple",
|
|
409
|
+
$,
|
|
410
|
+
[]
|
|
411
|
+
).option("--branch <branch>", "Select remote audits from this branch").option("--since <date>", "Select remote audits on or after this ISO date", z).option("--until <date>", "Select remote audits on or before this ISO date", z).option(
|
|
412
|
+
"--definitions <report>",
|
|
413
|
+
"Compare an audit-definitions JSON report to list APIs with zero detected usages. Can be specified multiple times.",
|
|
414
|
+
$,
|
|
415
|
+
[]
|
|
416
|
+
).option("--esri-only", "Only report usages of deprecated APIs from Esri and ArcGIS packages", !1).option(
|
|
417
|
+
"--category <category>",
|
|
418
|
+
`Only report usages in a category. Available categories: ${Object.keys(E).join(", ")}`,
|
|
419
|
+
oe
|
|
420
|
+
).option("--package <package-name>", "Only report usages of deprecated APIs from this package").option("--json", "Output results as JSON", !1).option("--md", "Output results as Markdown", !1).action(async (t, e) => {
|
|
421
|
+
if (!t.length && !e.remote || !e.remote && (e.repository.length || e.branch || e.since || e.until))
|
|
422
|
+
throw new Error("Provide report files or --remote. Repository, branch, and date selection require --remote.");
|
|
423
|
+
if (e.since && e.until && e.since > e.until)
|
|
424
|
+
throw new Error("--since must not be after --until.");
|
|
425
|
+
if (e.json && e.md) {
|
|
426
|
+
m("error", "@arcgis/codemod", "The --json and --md options cannot be used together."), process.exitCode = 1;
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
const { aggregateUsagesFromFiles: o } = await import("./index3.js");
|
|
430
|
+
await o(
|
|
431
|
+
t,
|
|
432
|
+
e.md ? "md" : e.json ? "json" : "text",
|
|
433
|
+
{
|
|
434
|
+
esriOnly: e.esriOnly,
|
|
435
|
+
category: e.category,
|
|
436
|
+
packageName: e.package,
|
|
437
|
+
section: e.section
|
|
438
|
+
},
|
|
439
|
+
e.definitions,
|
|
440
|
+
e.remote ? {
|
|
441
|
+
url: e.remote === !0 ? R : e.remote,
|
|
442
|
+
repositories: e.repository,
|
|
443
|
+
branch: e.branch,
|
|
444
|
+
since: e.since,
|
|
445
|
+
until: e.until
|
|
446
|
+
} : void 0
|
|
447
|
+
);
|
|
448
|
+
});
|
|
449
|
+
function ye(t) {
|
|
450
|
+
const e = T.find((o) => o === t);
|
|
451
|
+
if (e !== void 0)
|
|
452
|
+
return e;
|
|
453
|
+
throw new F(`Expected one of: ${T.join(", ")}.`);
|
|
454
|
+
}
|
|
455
|
+
C.command("sync-issues").description(
|
|
340
456
|
`Create or update deprecation audit issues. Requires authenticated gh cli.
|
|
341
457
|
|
|
342
458
|
Existing open issues are updated if out of date (matched by title and invisible comment inside).
|
|
@@ -344,51 +460,70 @@ Otherwise, a new issue is created. Assignees are determined based on CODEOWNERS.
|
|
|
344
460
|
).argument(
|
|
345
461
|
"<audit-json>",
|
|
346
462
|
"Path to the JSON file as output by the --json flag in the audit-usages or audit-definitions CLI"
|
|
347
|
-
).option("--dry-run", "Print planned issue and comment changes without changing GitHub", !1).option("--offset <number>", "Skip the first number of issue plans",
|
|
463
|
+
).option("--dry-run", "Print planned issue and comment changes without changing GitHub", !1).option("--close-resolved", "Close stale managed issues after a complete, unfiltered repository-root audit", !1).option("--offset <number>", "Skip the first number of issue plans", B, 0).option("--limit <number>", "Process at most this many issue plans", B).option(
|
|
348
464
|
"--label <label>",
|
|
349
465
|
"Label to add to newly created issues. Can be specified multiple times.",
|
|
350
|
-
|
|
466
|
+
$,
|
|
351
467
|
[]
|
|
352
468
|
).action(async (t, e) => {
|
|
353
|
-
const
|
|
354
|
-
if (!await
|
|
355
|
-
|
|
469
|
+
const o = n.resolve(t);
|
|
470
|
+
if (!await G(o) || !(await V(o)).isFile()) {
|
|
471
|
+
m("error", "@arcgis/codemod", `Failed to find the audit JSON file: ${t}`), process.exitCode = 1;
|
|
356
472
|
return;
|
|
357
473
|
}
|
|
358
|
-
const { syncDeprecationIssues:
|
|
359
|
-
await o
|
|
360
|
-
|
|
361
|
-
e.
|
|
362
|
-
|
|
363
|
-
e.limit,
|
|
364
|
-
e.label
|
|
365
|
-
);
|
|
474
|
+
const { syncDeprecationIssues: s } = await import("./sync.js");
|
|
475
|
+
await s(await Q(o), e.dryRun, e.offset, e.limit, {
|
|
476
|
+
labels: e.label,
|
|
477
|
+
closeResolved: e.closeResolved
|
|
478
|
+
});
|
|
366
479
|
});
|
|
367
|
-
function
|
|
480
|
+
function z(t) {
|
|
481
|
+
const e = new Date(t);
|
|
482
|
+
if (!Number.isFinite(e.getTime()))
|
|
483
|
+
throw new F("Expected an ISO date.");
|
|
484
|
+
return e.toISOString();
|
|
485
|
+
}
|
|
486
|
+
function $(t, e) {
|
|
368
487
|
return [...e, t];
|
|
369
488
|
}
|
|
370
|
-
function
|
|
489
|
+
function B(t) {
|
|
371
490
|
const e = Number(t);
|
|
372
491
|
if (!Number.isSafeInteger(e) || e < 0)
|
|
373
|
-
throw new
|
|
492
|
+
throw new F("Expected a non-negative integer.");
|
|
374
493
|
return e;
|
|
375
494
|
}
|
|
376
|
-
function
|
|
377
|
-
if (!Object.hasOwn(
|
|
378
|
-
throw new
|
|
495
|
+
function oe(t) {
|
|
496
|
+
if (!Object.hasOwn(E, t))
|
|
497
|
+
throw new F(`Expected one of: ${Object.keys(E).join(", ")}.`);
|
|
379
498
|
return t;
|
|
380
499
|
}
|
|
381
|
-
async function
|
|
382
|
-
const e =
|
|
383
|
-
await
|
|
384
|
-
const
|
|
385
|
-
return process.chdir(
|
|
500
|
+
async function M(t) {
|
|
501
|
+
const e = n.resolve(t);
|
|
502
|
+
await G(e) || (m("error", "@arcgis/codemod", `Failed to find the target path: ${t}`), process.exit(1));
|
|
503
|
+
const o = await Q(e), s = (await V(o)).isFile();
|
|
504
|
+
return process.chdir(s ? n.dirname(o) : o), s ? o : void 0;
|
|
386
505
|
}
|
|
387
|
-
|
|
506
|
+
C.command("sync-markdown").description(
|
|
507
|
+
"Update managed Markdown comments on an existing issue, leaving its body untouched. Requires authenticated gh cli."
|
|
508
|
+
).argument("<markdown-file>", "Path to the Markdown report").requiredOption("--issue <url>", "HTTPS URL of the existing GitHub issue").option("--dry-run", "Print planned comment changes without changing GitHub", !1).action(async (t, e) => {
|
|
509
|
+
const { syncMarkdown: o } = await import("./syncMarkdown.js");
|
|
510
|
+
await o(n.resolve(t), e.issue, e.dryRun);
|
|
511
|
+
});
|
|
512
|
+
A.parse();
|
|
388
513
|
export {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
514
|
+
$e as a,
|
|
515
|
+
qe as b,
|
|
516
|
+
We as c,
|
|
517
|
+
E as d,
|
|
518
|
+
R as e,
|
|
519
|
+
_e as f,
|
|
520
|
+
v as g,
|
|
521
|
+
Je as h,
|
|
522
|
+
Te as i,
|
|
523
|
+
Le as j,
|
|
524
|
+
Ge as k,
|
|
525
|
+
Me as l,
|
|
526
|
+
Ue as m,
|
|
527
|
+
he as p,
|
|
528
|
+
we as r
|
|
394
529
|
};
|