@arcgis/codemod 6.0.0-next.12 → 6.0.0-next.14

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