@arcgis/codemod 5.2.0-next.30 → 5.2.0-next.31

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
- import { path as T } from "@arcgis/components-build-utils";
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-xhj2LQ_o.js";
3
+ import { g as x } from "./cli-Bd8qr2gt.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";
@@ -1,10 +1,13 @@
1
1
  import { log as h } from "@arcgis/toolkit/log";
2
2
  import { Command as K } from "@commander-js/extra-typings";
3
3
  import { statSync as U } from "node:fs";
4
- import { getCwd as E, path as e, existsAsync as B, gitIgnoreFileToGlobs as T, asyncFindPath as J, toPosixPathSeparators as W, asyncRetrievePackageJson as M } from "@arcgis/components-build-utils";
4
+ import { getCwd as E, path as e, toPosixPathSeparators as J } from "@arcgis/node-toolkit/path";
5
5
  import "ts-morph";
6
6
  import a from "typescript";
7
- import { glob as $ } from "tinyglobby";
7
+ import { existsAsync as B, asyncFindPath as W } from "@arcgis/node-toolkit/file";
8
+ import { asyncRetrievePackageJson as M } from "@arcgis/node-toolkit/packageJson";
9
+ import { glob as T } from "tinyglobby";
10
+ import { gitIgnoreFileToGlobs as $ } from "@arcgis/node-toolkit/glob";
8
11
  import { identity as L } from "@arcgis/toolkit/function";
9
12
  import { styleText as S } from "node:util";
10
13
  const q = (t, o, n) => {
@@ -12,7 +15,7 @@ const q = (t, o, n) => {
12
15
  return r ? typeof r == "function" ? r() : Promise.resolve(r) : new Promise((c, i) => {
13
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." : ""))));
14
17
  });
15
- }, ge = {
18
+ }, ye = {
16
19
  allowImportingTsExtensions: !0,
17
20
  allowJs: !0,
18
21
  allowArbitraryExtensions: !0,
@@ -49,7 +52,7 @@ async function H() {
49
52
  const c = e.join(o, ".gitignore");
50
53
  if (await B(c)) {
51
54
  n = e.dirname(c);
52
- const w = e.relative(n, E()).split("/"), y = T(c);
55
+ const w = e.relative(n, E()).split("/"), y = $(c);
53
56
  for (const f of y) {
54
57
  const m = (f.startsWith("!") ? f.slice(1) : f).split("*")[0].split("/");
55
58
  let p = !0;
@@ -66,7 +69,7 @@ async function H() {
66
69
  return { ignorePatterns: t, globRoot: n };
67
70
  }
68
71
  async function Q(t) {
69
- return (await $("**/.gitignore", {
72
+ return (await T("**/.gitignore", {
70
73
  // Gitignore files are unlikely to be symbolic links
71
74
  followSymbolicLinks: !1,
72
75
  // Don't look for ignore files in these places for speed:
@@ -81,7 +84,7 @@ async function Q(t) {
81
84
  // Not applicable for our glob pattern
82
85
  expandDirectories: !1
83
86
  })).flatMap((n) => {
84
- const r = e.relative(t, e.dirname(n)), c = T(n), i = [];
87
+ const r = e.relative(t, e.dirname(n)), c = $(n), i = [];
85
88
  for (const w of c)
86
89
  w.startsWith("!") || i.push(e.join(r, w));
87
90
  return i;
@@ -89,7 +92,7 @@ async function Q(t) {
89
92
  }
90
93
  const V = ["js", "jsx", "mjs", "cjs"], X = ["ts", "tsx", "mts", "cts"], Y = ["json"], Z = `**/*.{${[...V, ...X, ...Y].join(",")}}`;
91
94
  async function ee() {
92
- const t = await z(), o = e.join(process.cwd(), Z), n = await $(o, {
95
+ const t = await z(), o = e.join(process.cwd(), Z), n = await T(o, {
93
96
  cwd: t.globRoot,
94
97
  ignore: t.ignorePatterns,
95
98
  // The files we are looking for are unlikely to be symbolic links
@@ -113,16 +116,16 @@ async function ee() {
113
116
  f.add(d);
114
117
  }
115
118
  }
116
- let v = await J("tsconfig.json", e.dirname(process.cwd()));
117
- v !== void 0 && (v = W(v), y.push(v)), y.sort((s, l) => {
119
+ let v = await W("tsconfig.json", e.dirname(process.cwd()));
120
+ v !== void 0 && (v = J(v), y.push(v)), y.sort((s, l) => {
118
121
  const d = l.split("/").length - s.split("/").length;
119
122
  if (d !== 0)
120
123
  return d;
121
124
  const b = e.basename(s), u = e.basename(l);
122
125
  return b === u ? 0 : b.endsWith("tsconfig.json") ? -1 : u.endsWith("tsconfig.json") ? 1 : b.endsWith("tsconfig.build.json") ? -1 : u.endsWith("tsconfig.build.json") ? 1 : b.localeCompare(u);
123
126
  });
124
- let m = await J("package.json");
125
- m !== void 0 && (m = W(m));
127
+ let m = await W("package.json");
128
+ m !== void 0 && (m = J(m));
126
129
  const p = [], g = /* @__PURE__ */ new Set();
127
130
  if (await Promise.all(
128
131
  y.map(async (s) => {
@@ -162,8 +165,8 @@ async function ee() {
162
165
  if (I.length === 0)
163
166
  return;
164
167
  y.length === 1 && (R || G) && f.clear();
165
- const F = e.dirname(s);
166
- let C = F, x = m;
168
+ const k = e.dirname(s);
169
+ let C = k, x = m;
167
170
  do {
168
171
  const P = e.join(C, "package.json");
169
172
  if (w.includes(P)) {
@@ -177,8 +180,8 @@ async function ee() {
177
180
  compilerOptions: u.options
178
181
  },
179
182
  packageJson: N,
180
- logName: S("blue", N?.contents?.name ?? F),
181
- cwd: F,
183
+ logName: S("blue", N?.contents?.name ?? k),
184
+ cwd: k,
182
185
  filePaths: I
183
186
  };
184
187
  p.push(O);
@@ -223,9 +226,9 @@ async function oe(t, o) {
223
226
  }
224
227
  await t.run(n), te();
225
228
  }
226
- const k = new K();
227
- k.name("@arcgis/codemod").description("Codemod for migrating or refactoring usages of ArcGIS Maps SDK for JavaScript");
228
- k.command("run").description("Run a single codemod").argument("<codemodName>", "Name of the transform").argument("[path]", "Directory to transform", process.cwd()).action(ne);
229
+ const F = new K();
230
+ F.name("@arcgis/codemod").description("Codemod for migrating or refactoring usages of ArcGIS Maps SDK for JavaScript");
231
+ F.command("run").description("Run a single codemod").argument("<codemodName>", "Name of the transform").argument("[path]", "Directory to transform", process.cwd()).action(ne);
229
232
  async function ne(t, o) {
230
233
  const n = U(o, { throwIfNoEntry: !1 });
231
234
  if (n === void 0) {
@@ -236,7 +239,7 @@ async function ne(t, o) {
236
239
  process.chdir(r ? e.dirname(o) : o);
237
240
  let c;
238
241
  try {
239
- c = await q(/* @__PURE__ */ Object.assign({ "./codemods/api-extractor-strict-mode/codemod.ts": () => import("./codemod-B8PpfzSR.js"), "./codemods/arcgis-toolkit/codemod.ts": () => import("./codemod-Bv7_agIz.js"), "./codemods/refactor-out-esri-namespace/codemod.ts": () => import("./codemod-tn0kImof.js") }), `./codemods/${t}/codemod.ts`, 4);
242
+ c = await q(/* @__PURE__ */ Object.assign({ "./codemods/api-extractor-strict-mode/codemod.ts": () => import("./codemod-DyAGLMzu.js"), "./codemods/arcgis-toolkit/codemod.ts": () => import("./codemod-DPYQ1AvG.js"), "./codemods/node-toolkit/codemod.ts": () => import("./codemod-BM-syCz5.js"), "./codemods/refactor-out-esri-namespace/codemod.ts": () => import("./codemod-Ce4JSf53.js") }), `./codemods/${t}/codemod.ts`, 4);
240
243
  } catch (i) {
241
244
  if (
242
245
  // direct Node execution
@@ -254,9 +257,9 @@ async function ne(t, o) {
254
257
  }
255
258
  await oe(c.codemod, S("blue", t));
256
259
  }
257
- k.parse();
260
+ F.parse();
258
261
  export {
259
- ge as d,
262
+ ye as d,
260
263
  j as g,
261
264
  te as p
262
265
  };
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
- import "./cli-xhj2LQ_o.js";
1
+ import "./cli-Bd8qr2gt.js";
2
2
  import "@arcgis/toolkit/log";
3
3
  import "@commander-js/extra-typings";
4
4
  import "node:fs";
5
- import "@arcgis/components-build-utils";
5
+ import "@arcgis/node-toolkit/path";
6
6
  import "node:util";
@@ -0,0 +1,106 @@
1
+ var p = (i, e) => (e = Symbol[i]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + i), g = (i) => {
2
+ throw TypeError(i);
3
+ };
4
+ var f = (i, e, t) => {
5
+ if (e != null) {
6
+ typeof e != "object" && typeof e != "function" && g("Object expected");
7
+ var a, n;
8
+ t && (a = e[p("asyncDispose")]), a === void 0 && (a = e[p("dispose")], t && (n = a)), typeof a != "function" && g("Object not disposable"), n && (a = function() {
9
+ try {
10
+ n.call(this);
11
+ } catch (r) {
12
+ return Promise.reject(r);
13
+ }
14
+ }), i.push([t, a, e]);
15
+ } else t && i.push([t]);
16
+ return e;
17
+ }, m = (i, e, t) => {
18
+ var a = typeof SuppressedError == "function" ? SuppressedError : function(o, s, c, d) {
19
+ return d = Error(c), d.name = "SuppressedError", d.error = o, d.suppressed = s, d;
20
+ }, n = (o) => e = t ? new a(o, e, "An error was suppressed during disposal") : (t = !0, o), r = (o) => {
21
+ for (; o = i.pop(); )
22
+ try {
23
+ var s = o[1] && o[1].call(o[2]);
24
+ if (o[0]) return Promise.resolve(s).then(r, (c) => (n(c), r()));
25
+ } catch (c) {
26
+ n(c);
27
+ }
28
+ if (t) throw e;
29
+ };
30
+ return r();
31
+ };
32
+ import { p as k } from "./actions-DhPreNjO.js";
33
+ import { f as P, a as h } from "./packageJson-BLIoQkL0.js";
34
+ import { c as y } from "./useProjectInstance-Cj8A3A2H.js";
35
+ import { p as u, g as x } from "./cli-Bd8qr2gt.js";
36
+ import { log as J } from "@arcgis/toolkit/log";
37
+ const l = "@arcgis/components-build-utils", v = {
38
+ [l]: {
39
+ existsAsync: { do: "rename", specifier: "@arcgis/node-toolkit/file" },
40
+ sh: { do: "rename", specifier: "@arcgis/node-toolkit/file" },
41
+ sp: { do: "rename", specifier: "@arcgis/node-toolkit/file" },
42
+ asyncSh: { do: "rename", specifier: "@arcgis/node-toolkit/file" },
43
+ findPath: { do: "rename", specifier: "@arcgis/node-toolkit/file" },
44
+ asyncFindPath: { do: "rename", specifier: "@arcgis/node-toolkit/file" },
45
+ createFileIfNotExists: { do: "rename", specifier: "@arcgis/node-toolkit/file" },
46
+ gitIgnoreFileToGlobs: { do: "rename", specifier: "@arcgis/node-toolkit/glob" },
47
+ gitIgnoreToGlob: { do: "rename", specifier: "@arcgis/node-toolkit/glob" },
48
+ isPosix: { do: "rename", specifier: "@arcgis/node-toolkit/path" },
49
+ toPosixPathSeparators: { do: "rename", specifier: "@arcgis/node-toolkit/path" },
50
+ normalizePath: { do: "rename", specifier: "@arcgis/node-toolkit/path" },
51
+ toSystemPathSeparators: { do: "rename", specifier: "@arcgis/node-toolkit/path" },
52
+ getCwd: { do: "rename", specifier: "@arcgis/node-toolkit/path" },
53
+ path: { do: "rename", specifier: "@arcgis/node-toolkit/path" },
54
+ PackageJson: { do: "rename", specifier: "@arcgis/node-toolkit/packageJson" },
55
+ retrievePackageJson: { do: "rename", specifier: "@arcgis/node-toolkit/packageJson" },
56
+ asyncRetrievePackageJson: { do: "rename", specifier: "@arcgis/node-toolkit/packageJson" },
57
+ fetchPackageLocation: { do: "rename", specifier: "@arcgis/node-toolkit/packageJson" },
58
+ detectPackageManager: { do: "rename", specifier: "@arcgis/node-toolkit/packageJson" },
59
+ DependencyManagementOptions: {
60
+ do: "rename",
61
+ specifier: "@arcgis/node-toolkit/vite/externalizeDependenciesPlugin"
62
+ },
63
+ vitePresetPlugin: { do: "rename", specifier: "@arcgis/node-toolkit/vite/presetPlugin" },
64
+ externalizeDependencies: {
65
+ do: "rename",
66
+ specifier: "@arcgis/node-toolkit/vite/externalizeDependenciesPlugin"
67
+ }
68
+ }
69
+ }, A = {
70
+ meta: {
71
+ needsTypeInformation: !1
72
+ },
73
+ async run(i) {
74
+ await P(
75
+ i,
76
+ (r) => h(
77
+ r,
78
+ (o) => o[l] ? {
79
+ ...o,
80
+ [l]: void 0,
81
+ "@arcgis/node-toolkit": o[l]
82
+ } : o
83
+ )
84
+ );
85
+ for (const r of i) {
86
+ var e = [];
87
+ try {
88
+ const o = f(e, y(r));
89
+ for (const s of o.getCodemodFiles())
90
+ k(s, v);
91
+ } catch (t) {
92
+ var a = t, n = !0;
93
+ } finally {
94
+ m(e, a, n);
95
+ }
96
+ }
97
+ u(), J(
98
+ "info",
99
+ x.codemodName,
100
+ "Next step: run npm install/pnpm install/yarn install to get @arcgis/node-toolkit package installed."
101
+ );
102
+ }
103
+ };
104
+ export {
105
+ A as codemod
106
+ };