@arcgis/codemod 6.0.0-next.43 → 6.0.0-next.45

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,128 +1,20 @@
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";
7
- import { e as C, d as P } from "./cli.js";
8
- const K = "6.0.0-next.43";
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) {
52
- if (e.kind === "css-property")
53
- return e.name;
54
- if (e.kind === "element")
55
- return `<${e.name}>`;
56
- if (e.memberOf !== void 0) {
57
- if (e.kind === "css-part")
58
- return `${e.memberOf}::part(${e.name})`;
59
- if (e.kind === "css-state")
60
- return `${e.memberOf}:state(${e.name})`;
61
- if (e.kind === "slot")
62
- return `${e.memberOf} > [slot="${e.name}"]`;
63
- if (e.kind === "attribute")
64
- return `${e.memberOf}[${e.name}]`;
65
- }
66
- const r = e.memberOf === void 0 ? e.name : `${e.memberOf}.${e.name}`;
67
- return e.kind === "method" || e.kind === "function" ? `${r}()` : r;
68
- }
69
- function re(e, r = "dash") {
70
- return e === void 0 || e === "field" || e === "method" || e === "function" ? "" : r === "parentheses" ? ` (${e})` : ` - ${e}`;
71
- }
72
- function te(e) {
73
- if (e === void 0)
74
- return {};
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);
76
- return {
77
- ...r === void 0 ? {} : { kind: r },
78
- ...n === void 0 ? {} : { memberOf: n }
79
- };
80
- }
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))
85
- return r;
86
- i.isModuleDeclaration(o) && i.isIdentifier(o.name) && t.unshift(o.name.text);
87
- }
88
- return [...t, r].join(".");
89
- }
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))
94
- return "field";
95
- if (i.isMethodDeclaration(e) || i.isMethodSignature(e))
96
- return "method";
97
- if (i.isClassLike(e))
98
- return "class";
99
- if (i.isInterfaceDeclaration(e))
100
- return "interface";
101
- if (i.isTypeAliasDeclaration(e))
102
- return "type";
103
- if (i.isFunctionDeclaration(e))
104
- return "function";
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))
108
- return "namespace";
109
- }
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);
112
- }
113
- const oe = /* @__PURE__ */ new Map([
1
+ import { findPath as P } from "@arcgis/node-toolkit/file";
2
+ import { toPosixPathSeparators as f, path as h } from "@arcgis/node-toolkit/path";
3
+ import { retrievePackageJson as w } from "@arcgis/node-toolkit/packageJson";
4
+ import { e as k, d as C } from "./cli.js";
5
+ const z = /* @__PURE__ */ new Map([
114
6
  ["MapView", "arcgis-map"],
115
7
  ["SceneView", "arcgis-scene"],
116
8
  ["LinkChartView", "arcgis-link-chart"],
117
9
  ["VideoView", "arcgis-video"]
118
- ]), V = /* @__PURE__ */ new Set([
10
+ ]), B = /* @__PURE__ */ new Set([
119
11
  "MessageBundleLoader",
120
12
  "createJSONLoader",
121
13
  "fetchMessageBundle",
122
14
  "messageBundle",
123
15
  "normalizeMessageBundleLocale",
124
16
  "registerMessageBundleLoader"
125
- ]), E = /* @__PURE__ */ new Set([
17
+ ]), L = /* @__PURE__ */ new Set([
126
18
  "AreaMeasurement2D",
127
19
  "AreaMeasurement3D",
128
20
  "BasemapGallery",
@@ -163,18 +55,18 @@ const oe = /* @__PURE__ */ new Map([
163
55
  "TableList",
164
56
  "useLegacyCreateTools"
165
57
  ]);
166
- function F({
167
- package: e,
168
- name: r,
169
- category: t,
170
- memberOf: o,
171
- module: n,
172
- deprecated: u
58
+ function V({
59
+ package: r,
60
+ name: e,
61
+ category: s,
62
+ memberOf: u,
63
+ module: t,
64
+ deprecated: a
173
65
  }) {
174
- if (t !== void 0)
175
- return t;
176
- const a = e.toLowerCase(), s = typeof u == "string" ? u.toLowerCase() : "";
177
- return e === "@arcgis/core" && r === "ui" && [
66
+ if (s !== void 0)
67
+ return s;
68
+ const i = r.toLowerCase(), o = typeof a == "string" ? a.toLowerCase() : "";
69
+ return r === "@arcgis/core" && e === "ui" && [
178
70
  "DOMContainer",
179
71
  "DOMContainerProperties",
180
72
  "MapView",
@@ -185,90 +77,79 @@ function F({
185
77
  "LinkChartViewProperties",
186
78
  "VideoView",
187
79
  "VideoViewProperties"
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";
80
+ ].includes(u?.replace(/^__esri\./u, "") ?? "") ? "coreViews" : r === "@arcgis/core" && (L.has(e) || o.includes("components-transition-plan")) ? "coreWidgets" : r === "@arcgis/core" && (/^(?:__esri\.)?(?:geometryEngine(?:Async)?|projection)(?:\.|$)/u.test(e) || e === "extendedSpatialReferenceInfo" || t?.startsWith("geometry/geometryEngine") || t?.startsWith("geometry/projection")) ? "coreGeometryEngine" : /\bcodemod\b/iu.test(o) ? "codemod" : r === "@arcgis/core" && (B.has(e) || o.includes("widget translations")) ? "coreIntl" : i.includes("calcite") ? "calcite" : /^@arcgis\/.+components/u.test(i) ? "arcgisComponents" : r === "@arcgis/core" ? "arcgisCore" : i.startsWith("@arcgis/") ? "arcgisSupport" : k(r) ? "otherEsri" : "nonEsri";
189
81
  }
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)
82
+ function $(r, e) {
83
+ const s = `/node_modules/${e}/`, u = r.map(f).sort(
84
+ (t, a) => Number(a.includes(s)) - Number(t.includes(s)) || t.localeCompare(a)
193
85
  );
194
- for (const n of o) {
195
- const u = n.lastIndexOf(t);
196
- let a;
197
- if (u !== -1)
198
- a = n.slice(u + t.length);
86
+ for (const t of u) {
87
+ const a = t.lastIndexOf(s);
88
+ let i;
89
+ if (a !== -1)
90
+ i = t.slice(a + s.length);
199
91
  else {
200
- const s = [...n.matchAll(/\/(?:src|dist)(?=\/)/gu)];
201
- if (s.length === 1)
202
- a = n.slice(s[0].index + 1);
92
+ const o = [...t.matchAll(/\/(?:src|dist)(?=\/)/gu)];
93
+ if (o.length === 1)
94
+ i = t.slice(o[0].index + 1);
203
95
  else {
204
- const c = b("package.json", d.dirname(n));
205
- if (c === void 0)
96
+ const n = P("package.json", h.dirname(t));
97
+ if (n === void 0)
206
98
  continue;
207
- const y = d.dirname(c);
208
- if (O(y).name !== r)
99
+ const m = h.dirname(n);
100
+ if (w(m).name !== e)
209
101
  continue;
210
- a = f(d.relative(y, n));
102
+ i = f(h.relative(m, t));
211
103
  }
212
104
  }
213
- return a.startsWith("src/") ? T(a) : R(a);
105
+ return i.startsWith("src/") ? O(i) : b(i);
214
106
  }
215
107
  }
216
- function T(e) {
217
- return f(e).replace(/^src\//u, "").replace(k, "");
108
+ function O(r) {
109
+ return f(r).replace(/^src\//u, "").replace(S, "");
218
110
  }
219
- function R(e) {
220
- return f(e).replace(/^dist\//u, "").replace(k, "").replace(/^(components?\/[^/]+-[^/]+)\/customElement$/u, "$1");
111
+ function b(r) {
112
+ return f(r).replace(/^dist\//u, "").replace(S, "").replace(/^(components?\/[^/]+-[^/]+)\/customElement$/u, "$1");
221
113
  }
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)
114
+ const S = /\.(?:d\.)?(?:[cm]?ts|tsx)$/u;
115
+ function R(r, e) {
116
+ const s = Map.groupBy(r, (u) => V(e(u)));
117
+ return Object.keys(C).flatMap((u) => {
118
+ const t = s.get(u);
119
+ if (t === void 0)
228
120
  return [];
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 };
121
+ const i = [...Map.groupBy(t, (o) => {
122
+ const n = e(o);
123
+ return D(n.package, n.module);
124
+ })].map(([o, n]) => {
125
+ const m = e(n[0]).package, y = [...Map.groupBy(n, (c) => {
126
+ const l = e(c);
127
+ return JSON.stringify([l.name, l.memberOf, l.kind]);
128
+ }).values()].map((c) => {
129
+ const l = e(c[0]).name, d = c.map((p) => e(p).deprecated).filter((p) => typeof p == "string" && p !== ""), g = [...new Set(d)].sort((p, M) => p.localeCompare(M));
130
+ return { name: l, reasons: g, items: c };
239
131
  });
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 };
132
+ return y.sort((c, l) => {
133
+ const d = e(c.items[0]), g = e(l.items[0]);
134
+ return l.items.length - c.items.length || c.name.localeCompare(l.name) || (d.memberOf ?? "").localeCompare(g.memberOf ?? "") || (d.kind ?? "").localeCompare(g.kind ?? "");
135
+ }), { packageName: m, displayName: o, count: n.length, apis: y };
244
136
  });
245
- return a.sort(
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 }];
137
+ return i.sort(
138
+ (o, n) => n.count - o.count || o.packageName.localeCompare(n.packageName) || o.displayName.localeCompare(n.displayName)
139
+ ), [{ categoryName: u, count: t.length, packages: i }];
248
140
  });
249
141
  }
250
- function x(e, r) {
251
- return N(e, r) ? "DOM / Web platform" : e;
142
+ function D(r, e) {
143
+ return A(r, e) ? "DOM / Web platform" : r;
252
144
  }
253
- function N(e, r) {
254
- return e === "typescript" && /^lib\/lib\.dom(?:$|[./])/u.test(r ?? "");
145
+ function A(r, e) {
146
+ return r === "typescript" && /^lib\/lib\.dom(?:$|[./])/u.test(e ?? "");
255
147
  }
256
148
  export {
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
149
+ $ as a,
150
+ z as b,
151
+ V as c,
152
+ D as d,
153
+ R as g,
154
+ O as s
274
155
  };