@arcgis/codemod 5.2.0-next.91 → 5.2.0-next.94

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,6 +1,6 @@
1
1
  import { path as T } from "@arcgis/node-toolkit/path";
2
2
  import { SyntaxKind as g } from "ts-morph";
3
- import { g as x } from "./cli-DJQ7NdBK.js";
3
+ import { g as x } from "./cli-BzG3c735.js";
4
4
  import { ModuleResolutionKind as D } from "typescript";
5
5
  import { capitalize as S } from "@arcgis/toolkit/string";
6
6
  import { log as q } from "@arcgis/toolkit/log";
@@ -6,14 +6,14 @@ import "ts-morph";
6
6
  import c from "typescript";
7
7
  import { existsAsync as q, asyncFindPath as M } from "@arcgis/node-toolkit/file";
8
8
  import { asyncRetrievePackageJson as L } from "@arcgis/node-toolkit/packageJson";
9
- import { glob as $ } from "tinyglobby";
10
- import { gitIgnoreFileToGlobs as A } from "@arcgis/node-toolkit/glob";
9
+ import { glob as A } from "tinyglobby";
10
+ import { gitIgnoreFileToGlobs as G } from "@arcgis/node-toolkit/glob";
11
11
  import { identity as _ } from "@arcgis/toolkit/function";
12
12
  import { styleText as F } from "node:util";
13
- const z = (t, o, n) => {
13
+ const z = (t, o, s) => {
14
14
  const r = t[o];
15
15
  return r ? typeof r == "function" ? r() : Promise.resolve(r) : new Promise((l, 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." : ""))));
16
+ (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(i.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + o + (o.split("/").length !== s ? ". Note that variables only represent file names one level deep." : ""))));
17
17
  });
18
18
  }, ye = {
19
19
  allowImportingTsExtensions: !0,
@@ -41,25 +41,25 @@ const z = (t, o, n) => {
41
41
  project: void 0
42
42
  };
43
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 };
44
+ const { ignorePatterns: t, globRoot: o } = await Q(), s = await V(o);
45
+ return t.push(...s), { ignorePatterns: t, globRoot: o };
46
46
  }
47
47
  async function Q() {
48
48
  const t = [];
49
- let o, n = k(), r = e.dirname(n);
49
+ let o, s = k(), r = e.dirname(s);
50
50
  do {
51
51
  o = r;
52
52
  const l = e.join(o, ".gitignore");
53
53
  if (await q(l)) {
54
- n = e.dirname(l);
55
- const g = e.relative(n, k()).split("/"), P = A(l);
54
+ s = e.dirname(l);
55
+ const g = e.relative(s, k()).split("/"), P = G(l);
56
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("/");
57
+ const h = u.startsWith("!") ? u.slice(1) : u, p = h.search(/[*?[]/u), w = p === -1 ? h : h.slice(0, p), v = w.split("/"), n = p !== -1 && !w.endsWith("/");
58
58
  let a = !0;
59
59
  const d = Math.min(g.length, v.length);
60
60
  for (let m = 0; m < d; m++) {
61
61
  const f = v[m];
62
- if (!(s && m === v.length - 1 ? g[m].startsWith(f) : g[m] === f) && f !== "") {
62
+ if (!(n && m === v.length - 1 ? g[m].startsWith(f) : g[m] === f) && f !== "") {
63
63
  a = !1;
64
64
  break;
65
65
  }
@@ -69,10 +69,10 @@ async function Q() {
69
69
  }
70
70
  r = e.dirname(o);
71
71
  } while (r !== o);
72
- return { ignorePatterns: t, globRoot: n };
72
+ return { ignorePatterns: t, globRoot: s };
73
73
  }
74
74
  async function V(t) {
75
- return (await $("**/.gitignore", {
75
+ return (await A("**/.gitignore", {
76
76
  cwd: k(),
77
77
  // Gitignore files are unlikely to be symbolic links
78
78
  followSymbolicLinks: !1,
@@ -87,8 +87,8 @@ async function V(t) {
87
87
  ],
88
88
  // Not applicable for our glob pattern
89
89
  expandDirectories: !1
90
- })).flatMap((n) => {
91
- const r = e.relative(t, e.dirname(n)), l = A(n), i = [];
90
+ })).flatMap((s) => {
91
+ const r = e.relative(t, e.dirname(s)), l = G(s), i = [];
92
92
  for (const g of l)
93
93
  g.startsWith("!") || i.push(e.join(r, g));
94
94
  return i;
@@ -96,7 +96,7 @@ async function V(t) {
96
96
  }
97
97
  const X = ["js", "jsx", "mjs", "cjs"], Y = ["ts", "tsx", "mts", "cts"], Z = ["json"], ee = `**/*.{${[...X, ...Y, ...Z].join(",")}}`;
98
98
  async function te() {
99
- const t = await H(), o = e.join(process.cwd(), ee), n = await $(o, {
99
+ const t = await H(), o = e.join(process.cwd(), ee), s = await A(o, {
100
100
  cwd: t.globRoot,
101
101
  ignore: t.ignorePatterns,
102
102
  // The files we are looking for are unlikely to be symbolic links
@@ -110,30 +110,30 @@ async function te() {
110
110
  let r = e.relative(t.globRoot, process.cwd());
111
111
  r !== "" && (r += "/");
112
112
  const l = e.join(e.resolve(t.globRoot), "/"), i = l.length + r.length, g = [], P = [], u = /* @__PURE__ */ new Set();
113
- for (const s of n) {
114
- const a = l + s;
115
- if (s.endsWith(".json")) {
116
- const d = e.basename(s);
113
+ for (const n of s) {
114
+ const a = l + n;
115
+ if (n.endsWith(".json")) {
116
+ const d = e.basename(n);
117
117
  d === "package.json" ? g.push(a) : (d.startsWith("tsconfig.") || d.startsWith("jsconfig.")) && P.push(a);
118
118
  } else {
119
- const d = s.slice(r.length);
119
+ const d = n.slice(r.length);
120
120
  u.add(d);
121
121
  }
122
122
  }
123
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 d = a.split("/").length - s.split("/").length;
124
+ h !== void 0 && (h = W(h), P.push(h)), P.sort((n, a) => {
125
+ const d = a.split("/").length - n.split("/").length;
126
126
  if (d !== 0)
127
127
  return d;
128
- const m = e.basename(s), f = e.basename(a);
128
+ const m = e.basename(n), f = e.basename(a);
129
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
130
  });
131
131
  let p = await M("package.json");
132
132
  p !== void 0 && (p = W(p));
133
133
  const w = [], v = /* @__PURE__ */ new Set();
134
134
  if (await Promise.all(
135
- P.map(async (s) => {
136
- const a = e.relative(process.cwd(), s), d = c.readConfigFile(s, c.sys.readFile);
135
+ P.map(async (n) => {
136
+ const a = e.relative(process.cwd(), n), d = c.readConfigFile(n, c.sys.readFile);
137
137
  if (d.error !== void 0) {
138
138
  y(
139
139
  "error",
@@ -149,7 +149,7 @@ async function te() {
149
149
  const m = e.basename(a), f = c.parseJsonConfigFileContent(
150
150
  d.config,
151
151
  c.sys,
152
- e.dirname(s),
152
+ e.dirname(n),
153
153
  void 0,
154
154
  m
155
155
  ), R = 18003;
@@ -162,14 +162,14 @@ async function te() {
162
162
  getNewLine: () => c.sys.newLine
163
163
  })
164
164
  );
165
- const E = s === h, O = a === m, N = f.fileNames.filter((b) => {
165
+ const E = n === h, $ = a === m, N = f.fileNames.filter((b) => {
166
166
  const D = b.slice(i);
167
167
  return u.delete(D) ? (v.add(D), !0) : v.has(D) || D.endsWith(".json") || b.includes("node_modules") ? !1 : !E;
168
168
  });
169
169
  if (N.length === 0)
170
170
  return;
171
- P.length === 1 && (E || O) && u.clear();
172
- const S = e.dirname(s);
171
+ P.length === 1 && (E || $) && u.clear();
172
+ const S = e.dirname(n);
173
173
  let x = S, C = p;
174
174
  do {
175
175
  const b = e.join(x, "package.json");
@@ -180,7 +180,7 @@ async function te() {
180
180
  } while (x !== t.globRoot && (x = e.dirname(x)));
181
181
  const J = C === void 0 ? void 0 : { filePath: C, contents: await L(e.dirname(C)) }, K = {
182
182
  typeScriptConfig: {
183
- filePath: s,
183
+ filePath: n,
184
184
  compilerOptions: f.options
185
185
  },
186
186
  packageJson: J,
@@ -191,19 +191,19 @@ async function te() {
191
191
  w.push(K);
192
192
  })
193
193
  ), u.size > 0) {
194
- const s = p === void 0 ? void 0 : {
194
+ const n = p === void 0 ? void 0 : {
195
195
  filePath: p,
196
196
  contents: await L(e.dirname(p))
197
197
  };
198
198
  w.push({
199
199
  typeScriptConfig: void 0,
200
- packageJson: s,
200
+ packageJson: n,
201
201
  cwd: process.cwd(),
202
- logName: F("blue", s?.contents?.name ?? process.cwd()),
202
+ logName: F("blue", n?.contents?.name ?? process.cwd()),
203
203
  filePaths: Array.from(u).map((a) => e.join(process.cwd(), a))
204
204
  });
205
205
  }
206
- return w.sort((s, a) => s.cwd.localeCompare(a.cwd)), j.projectsData = w, w;
206
+ return w.sort((n, a) => n.cwd.localeCompare(a.cwd)), j.projectsData = w, w;
207
207
  }
208
208
  let T = !1;
209
209
  function oe() {
@@ -221,33 +221,33 @@ function oe() {
221
221
  - If your project uses TypeScript, run type checking to ensure there are no type errors.`
222
222
  ));
223
223
  }
224
- async function se(t, o) {
224
+ async function ne(t, o) {
225
225
  j.codemod = t, j.codemodName = o;
226
- const n = await te();
227
- if (n.length === 0) {
226
+ const s = await te();
227
+ if (s.length === 0) {
228
228
  y("error", o, `Failed to find any .js or .ts files in ${process.cwd()} to run the codemod on.`), process.exitCode = 1;
229
229
  return;
230
230
  }
231
- await t.run(n), oe();
231
+ await t.run(s), oe();
232
232
  }
233
233
  const I = new U();
234
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) {
235
+ I.command("run").description("Run a single codemod").argument("<codemodName>", "Name of the transform").argument("[path]", "Directory to transform", process.cwd()).action(se);
236
+ async function se(t, o) {
237
+ const s = B(o, { throwIfNoEntry: !1 });
238
+ if (s === void 0) {
239
239
  y("error", "@arcgis/codemod", `Failed to find the target path: ${o}`), process.exitCode = 1;
240
240
  return;
241
241
  }
242
- const r = n.isFile();
242
+ const r = s.isFile();
243
243
  process.chdir(r ? e.dirname(o) : o);
244
244
  let l;
245
245
  try {
246
- l = await z(/* @__PURE__ */ Object.assign({ "./codemods/api-extractor-strict-mode/codemod.ts": () => import("./codemod-CUdF3oIK.js"), "./codemods/lumina-component-extras-improvements/codemod.ts": () => import("./codemod-CPBSioID.js"), "./codemods/node-toolkit/codemod.ts": () => import("./codemod-ByVDKNVh.js"), "./codemods/normalize-calcite-icon-names/codemod.ts": () => import("./codemod-TKeUnFf8.js"), "./codemods/refactor-out-esri-namespace/codemod.ts": () => import("./codemod-CDDi4e40.js"), "./codemods/toolkit-5.2-renames/codemod.ts": () => import("./codemod-DgA0GL73.js") }), `./codemods/${t}/codemod.ts`, 4);
246
+ l = await z(/* @__PURE__ */ Object.assign({ "./codemods/api-extractor-strict-mode/codemod.ts": () => import("./codemod-DvxMqyjF.js"), "./codemods/lumina-component-extras-improvements/codemod.ts": () => import("./codemod-DKGGUmp7.js"), "./codemods/node-toolkit/codemod.ts": () => import("./codemod-BBVZQTCI.js"), "./codemods/normalize-calcite-icon-names/codemod.ts": () => import("./codemod-CLpYeFPx.js"), "./codemods/refactor-out-esri-namespace/codemod.ts": () => import("./codemod-BtfCwWHO.js"), "./codemods/toolkit-5.2-renames/codemod.ts": () => import("./codemod-C5PdcOsm.js") }), `./codemods/${t}/codemod.ts`, 4);
247
247
  } catch (i) {
248
248
  if (
249
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(`${e.sep}${t}${e.sep}codemod.ts`) || // Vite build 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
251
  String(i).includes("Unknown variable dynamic import:")
252
252
  ) {
253
253
  y("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
@@ -259,7 +259,7 @@ async function ne(t, o) {
259
259
  y("error", "@arcgis/codemod", `Can't find codemod by name "${t}".`), process.exitCode = 1;
260
260
  return;
261
261
  }
262
- await se(l.codemod, F("blue", t));
262
+ await ne(l.codemod, F("blue", t));
263
263
  }
264
264
  I.parse();
265
265
  export {
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./cli-DJQ7NdBK.js";
1
+ import "./cli-BzG3c735.js";
2
2
  import "@arcgis/toolkit/log";
3
3
  import "@commander-js/extra-typings";
4
4
  import "node:fs";
@@ -29,11 +29,11 @@ var g = (i, o, a) => {
29
29
  };
30
30
  return r();
31
31
  };
32
- import { f as h, p as P } from "./actions-Cc94nYsB.js";
32
+ import { f as h, p as P } from "./actions-BH4cN_p7.js";
33
33
  import { log as k } from "@arcgis/toolkit/log";
34
34
  import { writeFile as u } from "node:fs/promises";
35
- import { c as y } from "./useProjectInstance-PcBD3mbo.js";
36
- import { p as x, g as J } from "./cli-DJQ7NdBK.js";
35
+ import { c as y } from "./useProjectInstance-9qPLRrHD.js";
36
+ import { p as x, g as J } from "./cli-BzG3c735.js";
37
37
  async function v(i, o) {
38
38
  const a = /* @__PURE__ */ new Set();
39
39
  for (const n of i) {