@arcgis/codemod 6.0.0-next.4 → 6.0.0-next.41

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