@arcgis/codemod 6.0.0-next.6 → 6.0.0-next.8

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.
@@ -0,0 +1,44 @@
1
+ import { findPath as a } from "@arcgis/node-toolkit/file";
2
+ import { path as n, toPosixPathSeparators as c } from "@arcgis/node-toolkit/path";
3
+ import { collectOutputSync as s } from "@arcgis/node-toolkit/shell";
4
+ import "node:fs";
5
+ const l = "6.0.0-next.7";
6
+ function g(r) {
7
+ const t = JSON.parse(r);
8
+ if (typeof t != "object" || t === null || !("auditKind" in t) || t.auditKind !== "usages" && t.auditKind !== "definitions")
9
+ throw new Error("Invalid deprecation audit JSON.");
10
+ return t;
11
+ }
12
+ function w() {
13
+ const r = a(".git");
14
+ if (r === void 0)
15
+ throw new Error("Unable to find a Git repository for the deprecation audit.");
16
+ const t = n.dirname(r), e = s("git", ["remote", "get-url", "origin"], { cwd: t }), o = s("git", ["rev-parse", "HEAD"], { cwd: t }), i = process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF_NAME || s("git", ["branch", "--show-current"], { cwd: t });
17
+ return { repository: p(e), repositoryRoot: t, ref: o, branch: i };
18
+ }
19
+ function $(r, t) {
20
+ return c(n.relative(t, r));
21
+ }
22
+ function m(r, t, e, o) {
23
+ const i = r === "usages" ? "usage" : "definition";
24
+ process.stderr.write(
25
+ `Deprecations: ${t} ${i}${t === 1 ? "" : "s"} across ${e} file${e === 1 ? "" : "s"} from ${o} package${o === 1 ? "" : "s"}.
26
+ `
27
+ );
28
+ }
29
+ function p(r) {
30
+ const t = r.replace(/\.git$/u, "");
31
+ if (t.startsWith("http://") || t.startsWith("https://"))
32
+ return new URL(t).href.replace(/^https?:\/\//u, "").replace(/\/$/u, "");
33
+ const e = /^(?:ssh:\/\/)?git@([^/:]+)[:/](.+)$/u.exec(t);
34
+ if (e !== null)
35
+ return `${e[1]}/${e[2]}`;
36
+ throw new Error(`Unsupported Git remote URL: ${r}`);
37
+ }
38
+ export {
39
+ $ as a,
40
+ g as b,
41
+ w as g,
42
+ m as p,
43
+ l as s
44
+ };
@@ -1,95 +1,66 @@
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")
10
- throw new Error("Invalid deprecation audit JSON.");
11
- return t;
12
- }
13
- function G() {
14
- const e = S(".git");
15
- if (e === void 0)
16
- 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 };
19
- }
20
- function J(e, t) {
21
- return h(g.relative(t, e));
22
- }
23
- function K(e, t, r, i) {
24
- const n = e === "usages" ? "usage" : "definition";
25
- process.stderr.write(
26
- `Deprecations: ${t} ${n}${t === 1 ? "" : "s"} across ${r} file${r === 1 ? "" : "s"} from ${i} package${i === 1 ? "" : "s"}.
27
- `
28
- );
29
- }
30
- 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]}`;
37
- throw new Error(`Unsupported Git remote URL: ${e}`);
38
- }
1
+ import i from "typescript";
2
+ import { findPath as w } from "@arcgis/node-toolkit/file";
3
+ import { toPosixPathSeparators as y, path as f } from "@arcgis/node-toolkit/path";
4
+ import { retrievePackageJson as k } from "@arcgis/node-toolkit/packageJson";
5
+ import { b as O, d as v } from "./cli.js";
39
6
  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;
7
+ if (e.kind === "css-property")
8
+ return e.name;
9
+ if (e.kind === "element")
10
+ return `<${e.name}>`;
11
+ if (e.memberOf !== void 0) {
12
+ if (e.kind === "css-part")
13
+ return `${e.memberOf}::part(${e.name})`;
14
+ if (e.kind === "css-state")
15
+ return `${e.memberOf}:state(${e.name})`;
16
+ if (e.kind === "slot")
17
+ return `${e.memberOf} > [slot="${e.name}"]`;
18
+ if (e.kind === "attribute")
19
+ return `${e.memberOf}[${e.name}]`;
20
+ }
21
+ const r = e.memberOf === void 0 ? e.name : `${e.memberOf}.${e.name}`;
22
+ return e.kind === "method" || e.kind === "function" ? `${r}()` : r;
42
23
  }
43
- function H(e, t = "dash") {
44
- return e === void 0 || e === "property" || e === "method" || e === "function" ? "" : t === "parentheses" ? ` (${e})` : ` - ${e}`;
24
+ function G(e, r = "dash") {
25
+ return e === void 0 || e === "field" || e === "method" || e === "function" ? "" : r === "parentheses" ? ` (${e})` : ` - ${e}`;
45
26
  }
46
- function U(e) {
27
+ function J(e) {
47
28
  if (e === void 0)
48
29
  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);
30
+ const r = P(e), o = e.parent, t = o !== void 0 && (i.isClassLike(o) || i.isInterfaceDeclaration(o)) ? o : o !== void 0 && i.isTypeLiteralNode(o) && i.isTypeAliasDeclaration(o.parent) ? o.parent : void 0, s = t?.name === void 0 ? void 0 : L(t, t.name.text);
50
31
  return {
51
- ...t === void 0 ? {} : { apiKind: t },
52
- ...n === void 0 ? {} : { memberOf: n }
32
+ ...r === void 0 ? {} : { kind: r },
33
+ ...s === void 0 ? {} : { memberOf: s }
53
34
  };
54
35
  }
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);
36
+ function L(e, r) {
37
+ const o = [];
38
+ for (let t = e?.parent; t !== void 0; t = t.parent) {
39
+ if (i.isClassLike(t) || i.isInterfaceDeclaration(t) || i.isTypeLiteralNode(t))
40
+ return r;
41
+ i.isModuleDeclaration(t) && i.isIdentifier(t.name) && o.unshift(t.name.text);
61
42
  }
62
- return [...r, t].join(".");
43
+ return [...o, r].join(".");
63
44
  }
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))
45
+ function P(e) {
46
+ if (i.isPropertyDeclaration(e) || i.isPropertySignature(e) || i.isGetAccessorDeclaration(e) || i.isSetAccessorDeclaration(e))
47
+ return "field";
48
+ if (i.isMethodDeclaration(e) || i.isMethodSignature(e))
68
49
  return "method";
69
- if (s.isClassLike(e))
50
+ if (i.isClassLike(e))
70
51
  return "class";
71
- if (s.isInterfaceDeclaration(e))
52
+ if (i.isInterfaceDeclaration(e))
72
53
  return "interface";
73
- if (s.isTypeAliasDeclaration(e))
54
+ if (i.isTypeAliasDeclaration(e))
74
55
  return "type";
75
- if (s.isFunctionDeclaration(e))
56
+ if (i.isFunctionDeclaration(e))
76
57
  return "function";
77
- if (s.isVariableDeclaration(e))
58
+ if (i.isVariableDeclaration(e))
78
59
  return "variable";
79
- if (s.isModuleDeclaration(e))
60
+ if (i.isModuleDeclaration(e))
80
61
  return "namespace";
81
62
  }
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([
63
+ const C = /* @__PURE__ */ new Map([
93
64
  ["MapView", "arcgis-map"],
94
65
  ["SceneView", "arcgis-scene"],
95
66
  ["LinkChartView", "arcgis-link-chart"],
@@ -101,7 +72,7 @@ const $ = /* @__PURE__ */ new Map([
101
72
  "messageBundle",
102
73
  "normalizeMessageBundleLocale",
103
74
  "registerMessageBundleLoader"
104
- ]), R = /* @__PURE__ */ new Set([
75
+ ]), $ = /* @__PURE__ */ new Set([
105
76
  "AreaMeasurement2D",
106
77
  "AreaMeasurement3D",
107
78
  "BasemapGallery",
@@ -144,14 +115,14 @@ const $ = /* @__PURE__ */ new Map([
144
115
  ]);
145
116
  function B({
146
117
  package: e,
147
- api: t,
148
- category: r,
149
- memberOf: i,
150
- module: n,
151
- reason: l
118
+ name: r,
119
+ category: o,
120
+ memberOf: t,
121
+ module: s,
122
+ deprecated: u
152
123
  }) {
153
- const a = e.toLowerCase(), o = l?.toLowerCase() ?? "";
154
- return e === "@arcgis/core" && r === "coreViews" && $.has(t) || e === "@arcgis/core" && t === "ui" && [
124
+ const c = e.toLowerCase(), n = typeof u == "string" ? u.toLowerCase() : "";
125
+ return e === "@arcgis/core" && o === "coreViews" && C.has(r) || e === "@arcgis/core" && r === "ui" && [
155
126
  "DOMContainer",
156
127
  "DOMContainerProperties",
157
128
  "MapView",
@@ -162,71 +133,71 @@ function B({
162
133
  "LinkChartViewProperties",
163
134
  "VideoView",
164
135
  "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";
136
+ ].includes(t?.replace(/^__esri\./u, "") ?? "") ? "coreViews" : e === "@arcgis/core" && ($.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" && (V.has(r) || n.includes("widget translations")) ? "coreIntl" : c.includes("calcite") ? "calcite" : /^@arcgis\/.+components/u.test(c) ? "arcgisComponents" : e === "@arcgis/core" ? "arcgisCore" : c.startsWith("@arcgis/") ? "arcgisSupport" : O(e) ? "otherEsri" : "nonEsri";
166
137
  }
167
- function te(e, t) {
168
- return x(E(e, t));
138
+ function H(e, r) {
139
+ return A(x(e, r));
169
140
  }
170
- function x(e) {
141
+ function A(e) {
171
142
  return e?.replace(/^(components?\/[^/]+-[^/]+)\/customElement$/u, "$1");
172
143
  }
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, "");
144
+ const S = /^(?:src|dist)\//u;
145
+ function x(e, r) {
146
+ const o = `/node_modules/${r}/`, t = e.map(y).sort((s, u) => Number(u.includes(o)) - Number(s.includes(o)));
147
+ for (const s of t) {
148
+ const u = s.lastIndexOf(o);
149
+ if (u !== -1)
150
+ return s.slice(u + o.length).replace(S, "").replace(g, "");
151
+ const c = [...s.matchAll(/\/(?:src|dist)(?=\/)/gu)];
152
+ if (c.length === 1) {
153
+ const d = c[0];
154
+ return s.slice(d.index + d[0].length + 1).replace(g, "");
183
155
  }
184
- const o = S("package.json", g.dirname(n));
185
- if (o === void 0)
156
+ const n = w("package.json", f.dirname(s));
157
+ if (n === void 0)
186
158
  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, "");
159
+ const a = f.dirname(n);
160
+ if (k(a).name === r)
161
+ return y(f.relative(a, s)).replace(S, "").replace(g, "");
190
162
  }
191
163
  }
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);
197
- if (n === void 0)
164
+ const g = /\.(?:d\.)?(?:[cm]?ts|tsx)$/u;
165
+ function I(e, r) {
166
+ const o = Map.groupBy(e, (t) => B(r(t)));
167
+ return Object.keys(v).flatMap((t) => {
168
+ const s = o.get(t);
169
+ if (s === void 0)
198
170
  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 };
171
+ const c = [...Map.groupBy(s, (n) => {
172
+ const a = r(n);
173
+ return T(a.package, a.module);
174
+ })].map(([n, a]) => {
175
+ const d = r(a[0]).package, h = [...Map.groupBy(a, (l) => {
176
+ const m = r(l);
177
+ return JSON.stringify([m.name, m.memberOf, m.kind]);
178
+ }).values()].map((l) => {
179
+ const m = r(l[0]).name, D = l.map((p) => r(p).deprecated).filter((p) => typeof p == "string" && p !== ""), M = [...new Set(D)].sort((p, b) => p.localeCompare(b));
180
+ return { name: m, reasons: M, items: l };
206
181
  });
207
- return y.sort((u, p) => p.items.length - u.items.length || u.api.localeCompare(p.api)), { packageName: o, count: c.length, apis: y };
182
+ return h.sort((l, m) => m.items.length - l.items.length || l.name.localeCompare(m.name)), { packageName: d, displayName: n, count: a.length, apis: h };
208
183
  });
209
- return a.sort((o, c) => c.count - o.count || o.packageName.localeCompare(c.packageName)), [{ categoryName: i, count: n.length, packages: a }];
184
+ return c.sort((n, a) => a.count - n.count || n.packageName.localeCompare(a.packageName)), [{ categoryName: t, count: s.length, packages: c }];
210
185
  });
211
186
  }
187
+ function T(e, r) {
188
+ return E(e, r) ? "DOM / Web platform" : e;
189
+ }
190
+ function E(e, r) {
191
+ return e === "typescript" && /^lib\/lib\.dom(?:$|[./])/u.test(r ?? "");
192
+ }
212
193
  export {
213
- _ as a,
214
- H as b,
215
- re as c,
216
- te as d,
194
+ H as a,
195
+ _ as b,
196
+ B as c,
197
+ G as d,
217
198
  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
199
+ L as f,
200
+ I as g,
201
+ C as h,
202
+ T as i
232
203
  };