@arcgis/codemod 6.0.0-next.30 → 6.0.0-next.32

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,9 +1,54 @@
1
- import t from "typescript";
2
- import { findPath as k } from "@arcgis/node-toolkit/file";
3
- import { toPosixPathSeparators as y, path as h } from "@arcgis/node-toolkit/path";
4
- import { retrievePackageJson as v } from "@arcgis/node-toolkit/packageJson";
1
+ import { findPath as b } from "@arcgis/node-toolkit/file";
2
+ import { path as d, toPosixPathSeparators as f } from "@arcgis/node-toolkit/path";
3
+ import { collectOutputSync as v } from "@arcgis/node-toolkit/shell";
4
+ import $ from "picomatch";
5
+ import i from "typescript";
6
+ import { retrievePackageJson as O } from "@arcgis/node-toolkit/packageJson";
5
7
  import { b as C, d as P } from "./cli.js";
6
- function j(e) {
8
+ const K = "6.0.0-next.32";
9
+ function I(e, r) {
10
+ return e.package.localeCompare(r.package) || e.file.localeCompare(r.file) || e.line - r.line || e.column - r.column || g(e.module, r.module) || g(e.memberOf, r.memberOf) || e.name.localeCompare(r.name) || g(e.kind, r.kind) || g(e.category, r.category) || g(e.provenance, r.provenance) || String(e.deprecated).localeCompare(String(r.deprecated));
11
+ }
12
+ const g = (e, r) => (e ?? "").localeCompare(r ?? "");
13
+ function q(e) {
14
+ const r = JSON.parse(e);
15
+ if (typeof r != "object" || r === null || !("auditKind" in r) || r.auditKind !== "usages" && r.auditKind !== "definitions")
16
+ throw new Error("Invalid deprecation audit JSON.");
17
+ return r;
18
+ }
19
+ function Q() {
20
+ const e = b(".git");
21
+ if (e === void 0)
22
+ throw new Error("Unable to find a Git repository for the deprecation audit.");
23
+ const r = d.dirname(e), t = v("git", ["remote", "get-url", "origin"], { cwd: r }), o = v("git", ["rev-parse", "HEAD"], { cwd: r }), n = process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF_NAME || v("git", ["branch", "--show-current"], { cwd: r });
24
+ return { repository: A(t), repositoryRoot: r, ref: o, branch: n };
25
+ }
26
+ function X(e, r) {
27
+ return f(d.relative(r, e));
28
+ }
29
+ function Y(e, r = process.cwd()) {
30
+ if (e.length === 0)
31
+ return () => !0;
32
+ const t = $([...e], { dot: !0 });
33
+ return (o) => !t(f(d.relative(r, o)));
34
+ }
35
+ function Z(e, r, t, o) {
36
+ const n = e === "usages" ? "usage" : "definition";
37
+ process.stderr.write(
38
+ `Deprecations: ${r} ${n}${r === 1 ? "" : "s"} across ${t} file${t === 1 ? "" : "s"} from ${o} package${o === 1 ? "" : "s"}.
39
+ `
40
+ );
41
+ }
42
+ function A(e) {
43
+ const r = e.replace(/\.git$/u, "");
44
+ if (r.startsWith("http://") || r.startsWith("https://"))
45
+ return new URL(r).href.replace(/^https?:\/\//u, "").replace(/\/$/u, "");
46
+ const t = /^(?:ssh:\/\/)?git@([^/:]+)[:/](.+)$/u.exec(r);
47
+ if (t !== null)
48
+ return `${t[1]}/${t[2]}`;
49
+ throw new Error(`Unsupported Git remote URL: ${e}`);
50
+ }
51
+ function ee(e) {
7
52
  if (e.kind === "css-property")
8
53
  return e.name;
9
54
  if (e.kind === "element")
@@ -21,63 +66,63 @@ function j(e) {
21
66
  const r = e.memberOf === void 0 ? e.name : `${e.memberOf}.${e.name}`;
22
67
  return e.kind === "method" || e.kind === "function" ? `${r}()` : r;
23
68
  }
24
- function _(e, r = "dash") {
69
+ function re(e, r = "dash") {
25
70
  return e === void 0 || e === "field" || e === "method" || e === "function" ? "" : r === "parentheses" ? ` (${e})` : ` - ${e}`;
26
71
  }
27
- function G(e) {
72
+ function te(e) {
28
73
  if (e === void 0)
29
74
  return {};
30
- const r = w(e), o = e.parent, i = o !== void 0 && (t.isClassLike(o) || t.isInterfaceDeclaration(o)) ? o : o !== void 0 && t.isTypeLiteralNode(o) && t.isTypeAliasDeclaration(o.parent) ? o.parent : void 0, s = i?.name === void 0 ? void 0 : O(i, i.name.text);
75
+ const r = B(e), t = e.parent, o = t !== void 0 && (i.isClassLike(t) || i.isInterfaceDeclaration(t)) ? t : t !== void 0 && i.isTypeLiteralNode(t) && i.isTypeAliasDeclaration(t.parent) ? t.parent : void 0, n = o?.name === void 0 ? void 0 : L(o, o.name.text);
31
76
  return {
32
77
  ...r === void 0 ? {} : { kind: r },
33
- ...s === void 0 ? {} : { memberOf: s }
78
+ ...n === void 0 ? {} : { memberOf: n }
34
79
  };
35
80
  }
36
- function O(e, r) {
37
- const o = [];
38
- for (let i = e?.parent; i !== void 0; i = i.parent) {
39
- if (t.isClassLike(i) || t.isInterfaceDeclaration(i) || t.isTypeLiteralNode(i))
81
+ function L(e, r) {
82
+ const t = [];
83
+ for (let o = e?.parent; o !== void 0; o = o.parent) {
84
+ if (i.isClassLike(o) || i.isInterfaceDeclaration(o) || i.isTypeLiteralNode(o))
40
85
  return r;
41
- t.isModuleDeclaration(i) && t.isIdentifier(i.name) && o.unshift(i.name.text);
86
+ i.isModuleDeclaration(o) && i.isIdentifier(o.name) && t.unshift(o.name.text);
42
87
  }
43
- return [...o, r].join(".");
88
+ return [...t, r].join(".");
44
89
  }
45
- function w(e) {
46
- if (t.isPropertyDeclaration(e) || t.isPropertySignature(e))
47
- return (t.getCombinedModifierFlags(e) & t.ModifierFlags.Readonly) !== 0 && M(e) ? "method" : "field";
48
- if (t.isGetAccessorDeclaration(e) || t.isSetAccessorDeclaration(e))
90
+ function B(e) {
91
+ if (i.isPropertyDeclaration(e) || i.isPropertySignature(e))
92
+ return (i.getCombinedModifierFlags(e) & i.ModifierFlags.Readonly) !== 0 && D(e) ? "method" : "field";
93
+ if (i.isGetAccessorDeclaration(e) || i.isSetAccessorDeclaration(e))
49
94
  return "field";
50
- if (t.isMethodDeclaration(e) || t.isMethodSignature(e))
95
+ if (i.isMethodDeclaration(e) || i.isMethodSignature(e))
51
96
  return "method";
52
- if (t.isClassLike(e))
97
+ if (i.isClassLike(e))
53
98
  return "class";
54
- if (t.isInterfaceDeclaration(e))
99
+ if (i.isInterfaceDeclaration(e))
55
100
  return "interface";
56
- if (t.isTypeAliasDeclaration(e))
101
+ if (i.isTypeAliasDeclaration(e))
57
102
  return "type";
58
- if (t.isFunctionDeclaration(e))
103
+ if (i.isFunctionDeclaration(e))
59
104
  return "function";
60
- if (t.isVariableDeclaration(e))
61
- return M(e) && (e.type !== void 0 || (e.parent.flags & t.NodeFlags.Const) !== 0) ? "function" : "variable";
62
- if (t.isModuleDeclaration(e))
105
+ if (i.isVariableDeclaration(e))
106
+ return D(e) && (e.type !== void 0 || (e.parent.flags & i.NodeFlags.Const) !== 0) ? "function" : "variable";
107
+ if (i.isModuleDeclaration(e))
63
108
  return "namespace";
64
109
  }
65
- function M(e) {
66
- return e.type !== void 0 ? t.isFunctionTypeNode(e.type) : !t.isPropertySignature(e) && e.initializer !== void 0 && t.isArrowFunction(e.initializer);
110
+ function D(e) {
111
+ return e.type !== void 0 ? i.isFunctionTypeNode(e.type) : !i.isPropertySignature(e) && e.initializer !== void 0 && i.isArrowFunction(e.initializer);
67
112
  }
68
- const J = /* @__PURE__ */ new Map([
113
+ const oe = /* @__PURE__ */ new Map([
69
114
  ["MapView", "arcgis-map"],
70
115
  ["SceneView", "arcgis-scene"],
71
116
  ["LinkChartView", "arcgis-link-chart"],
72
117
  ["VideoView", "arcgis-video"]
73
- ]), L = /* @__PURE__ */ new Set([
118
+ ]), V = /* @__PURE__ */ new Set([
74
119
  "MessageBundleLoader",
75
120
  "createJSONLoader",
76
121
  "fetchMessageBundle",
77
122
  "messageBundle",
78
123
  "normalizeMessageBundleLocale",
79
124
  "registerMessageBundleLoader"
80
- ]), A = /* @__PURE__ */ new Set([
125
+ ]), E = /* @__PURE__ */ new Set([
81
126
  "AreaMeasurement2D",
82
127
  "AreaMeasurement3D",
83
128
  "BasemapGallery",
@@ -118,17 +163,17 @@ const J = /* @__PURE__ */ new Map([
118
163
  "TableList",
119
164
  "useLegacyCreateTools"
120
165
  ]);
121
- function $({
166
+ function F({
122
167
  package: e,
123
168
  name: r,
124
- category: o,
125
- memberOf: i,
126
- module: s,
169
+ category: t,
170
+ memberOf: o,
171
+ module: n,
127
172
  deprecated: u
128
173
  }) {
129
- if (o !== void 0)
130
- return o;
131
- const a = e.toLowerCase(), n = typeof u == "string" ? u.toLowerCase() : "";
174
+ if (t !== void 0)
175
+ return t;
176
+ const a = e.toLowerCase(), s = typeof u == "string" ? u.toLowerCase() : "";
132
177
  return e === "@arcgis/core" && r === "ui" && [
133
178
  "DOMContainer",
134
179
  "DOMContainerProperties",
@@ -140,83 +185,90 @@ function $({
140
185
  "LinkChartViewProperties",
141
186
  "VideoView",
142
187
  "VideoViewProperties"
143
- ].includes(i?.replace(/^__esri\./u, "") ?? "") ? "coreViews" : e === "@arcgis/core" && (A.has(r) || n.includes("components-transition-plan")) ? "coreWidgets" : e === "@arcgis/core" && (/^(?:__esri\.)?(?:geometryEngine(?:Async)?|projection)(?:\.|$)/u.test(r) || r === "extendedSpatialReferenceInfo" || s?.startsWith("geometry/geometryEngine") || s?.startsWith("geometry/projection")) ? "coreGeometryEngine" : /\bcodemod\b/iu.test(n) ? "codemod" : e === "@arcgis/core" && (L.has(r) || n.includes("widget translations")) ? "coreIntl" : a.includes("calcite") ? "calcite" : /^@arcgis\/.+components/u.test(a) ? "arcgisComponents" : e === "@arcgis/core" ? "arcgisCore" : a.startsWith("@arcgis/") ? "arcgisSupport" : C(e) ? "otherEsri" : "nonEsri";
188
+ ].includes(o?.replace(/^__esri\./u, "") ?? "") ? "coreViews" : e === "@arcgis/core" && (E.has(r) || s.includes("components-transition-plan")) ? "coreWidgets" : e === "@arcgis/core" && (/^(?:__esri\.)?(?:geometryEngine(?:Async)?|projection)(?:\.|$)/u.test(r) || r === "extendedSpatialReferenceInfo" || n?.startsWith("geometry/geometryEngine") || n?.startsWith("geometry/projection")) ? "coreGeometryEngine" : /\bcodemod\b/iu.test(s) ? "codemod" : e === "@arcgis/core" && (V.has(r) || s.includes("widget translations")) ? "coreIntl" : a.includes("calcite") ? "calcite" : /^@arcgis\/.+components/u.test(a) ? "arcgisComponents" : e === "@arcgis/core" ? "arcgisCore" : a.startsWith("@arcgis/") ? "arcgisSupport" : C(e) ? "otherEsri" : "nonEsri";
144
189
  }
145
- function H(e, r) {
146
- const o = `/node_modules/${r}/`, i = e.map(y).sort(
147
- (s, u) => Number(u.includes(o)) - Number(s.includes(o)) || s.localeCompare(u)
190
+ function ie(e, r) {
191
+ const t = `/node_modules/${r}/`, o = e.map(f).sort(
192
+ (n, u) => Number(u.includes(t)) - Number(n.includes(t)) || n.localeCompare(u)
148
193
  );
149
- for (const s of i) {
150
- const u = s.lastIndexOf(o);
194
+ for (const n of o) {
195
+ const u = n.lastIndexOf(t);
151
196
  let a;
152
197
  if (u !== -1)
153
- a = s.slice(u + o.length);
198
+ a = n.slice(u + t.length);
154
199
  else {
155
- const n = [...s.matchAll(/\/(?:src|dist)(?=\/)/gu)];
156
- if (n.length === 1)
157
- a = s.slice(n[0].index + 1);
200
+ const s = [...n.matchAll(/\/(?:src|dist)(?=\/)/gu)];
201
+ if (s.length === 1)
202
+ a = n.slice(s[0].index + 1);
158
203
  else {
159
- const c = k("package.json", h.dirname(s));
204
+ const c = b("package.json", d.dirname(n));
160
205
  if (c === void 0)
161
206
  continue;
162
- const d = h.dirname(c);
163
- if (v(d).name !== r)
207
+ const y = d.dirname(c);
208
+ if (O(y).name !== r)
164
209
  continue;
165
- a = y(h.relative(d, s));
210
+ a = f(d.relative(y, n));
166
211
  }
167
212
  }
168
- return a.startsWith("src/") ? V(a) : B(a);
213
+ return a.startsWith("src/") ? T(a) : R(a);
169
214
  }
170
215
  }
171
- function V(e) {
172
- return y(e).replace(/^src\//u, "").replace(D, "");
216
+ function T(e) {
217
+ return f(e).replace(/^src\//u, "").replace(k, "");
173
218
  }
174
- function B(e) {
175
- return y(e).replace(/^dist\//u, "").replace(D, "").replace(/^(components?\/[^/]+-[^/]+)\/customElement$/u, "$1");
176
- }
177
- const D = /\.(?:d\.)?(?:[cm]?ts|tsx)$/u;
178
- function K(e, r) {
179
- const o = Map.groupBy(e, (i) => $(r(i)));
180
- return Object.keys(P).flatMap((i) => {
181
- const s = o.get(i);
182
- if (s === void 0)
219
+ function R(e) {
220
+ return f(e).replace(/^dist\//u, "").replace(k, "").replace(/^(components?\/[^/]+-[^/]+)\/customElement$/u, "$1");
221
+ }
222
+ const k = /\.(?:d\.)?(?:[cm]?ts|tsx)$/u;
223
+ function ne(e, r) {
224
+ const t = Map.groupBy(e, (o) => F(r(o)));
225
+ return Object.keys(P).flatMap((o) => {
226
+ const n = t.get(o);
227
+ if (n === void 0)
183
228
  return [];
184
- const a = [...Map.groupBy(s, (n) => {
185
- const c = r(n);
186
- return T(c.package, c.module);
187
- })].map(([n, c]) => {
188
- const d = r(c[0]).package, S = [...Map.groupBy(c, (m) => {
189
- const l = r(m);
190
- return JSON.stringify([l.name, l.memberOf, l.kind]);
191
- }).values()].map((m) => {
192
- const l = r(m[0]).name, f = m.map((p) => r(p).deprecated).filter((p) => typeof p == "string" && p !== ""), g = [...new Set(f)].sort((p, b) => p.localeCompare(b));
193
- return { name: l, reasons: g, items: m };
229
+ const a = [...Map.groupBy(n, (s) => {
230
+ const c = r(s);
231
+ return x(c.package, c.module);
232
+ })].map(([s, c]) => {
233
+ const y = r(c[0]).package, w = [...Map.groupBy(c, (p) => {
234
+ const m = r(p);
235
+ return JSON.stringify([m.name, m.memberOf, m.kind]);
236
+ }).values()].map((p) => {
237
+ const m = r(p[0]).name, h = p.map((l) => r(l).deprecated).filter((l) => typeof l == "string" && l !== ""), S = [...new Set(h)].sort((l, M) => l.localeCompare(M));
238
+ return { name: m, reasons: S, items: p };
194
239
  });
195
- return S.sort((m, l) => {
196
- const f = r(m.items[0]), g = r(l.items[0]);
197
- return l.items.length - m.items.length || m.name.localeCompare(l.name) || (f.memberOf ?? "").localeCompare(g.memberOf ?? "") || (f.kind ?? "").localeCompare(g.kind ?? "");
198
- }), { packageName: d, displayName: n, count: c.length, apis: S };
240
+ return w.sort((p, m) => {
241
+ const h = r(p.items[0]), S = r(m.items[0]);
242
+ return m.items.length - p.items.length || p.name.localeCompare(m.name) || (h.memberOf ?? "").localeCompare(S.memberOf ?? "") || (h.kind ?? "").localeCompare(S.kind ?? "");
243
+ }), { packageName: y, displayName: s, count: c.length, apis: w };
199
244
  });
200
245
  return a.sort(
201
- (n, c) => c.count - n.count || n.packageName.localeCompare(c.packageName) || n.displayName.localeCompare(c.displayName)
202
- ), [{ categoryName: i, count: s.length, packages: a }];
246
+ (s, c) => c.count - s.count || s.packageName.localeCompare(c.packageName) || s.displayName.localeCompare(c.displayName)
247
+ ), [{ categoryName: o, count: n.length, packages: a }];
203
248
  });
204
249
  }
205
- function T(e, r) {
206
- return x(e, r) ? "DOM / Web platform" : e;
207
- }
208
250
  function x(e, r) {
251
+ return N(e, r) ? "DOM / Web platform" : e;
252
+ }
253
+ function N(e, r) {
209
254
  return e === "typescript" && /^lib\/lib\.dom(?:$|[./])/u.test(r ?? "");
210
255
  }
211
256
  export {
212
- H as a,
213
- j as b,
214
- $ as c,
215
- _ as d,
216
- G as e,
217
- O as f,
218
- K as g,
219
- J as h,
220
- T as i,
221
- V as s
257
+ Q as a,
258
+ ne as b,
259
+ ie as c,
260
+ F as d,
261
+ I as e,
262
+ ee as f,
263
+ X as g,
264
+ re as h,
265
+ Y as i,
266
+ te as j,
267
+ L as k,
268
+ oe as l,
269
+ T as m,
270
+ q as n,
271
+ x as o,
272
+ Z as p,
273
+ K as s
222
274
  };