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

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,48 @@
1
+ import { findPath as c } from "@arcgis/node-toolkit/file";
2
+ import { path as s, toPosixPathSeparators as p } from "@arcgis/node-toolkit/path";
3
+ import { collectOutputSync as i } from "@arcgis/node-toolkit/shell";
4
+ const f = "6.0.0-next.30";
5
+ function w(o, e) {
6
+ return o.package.localeCompare(e.package) || o.file.localeCompare(e.file) || o.line - e.line || o.column - e.column || t(o.module, e.module) || t(o.memberOf, e.memberOf) || o.name.localeCompare(e.name) || t(o.kind, e.kind) || t(o.category, e.category) || t(o.provenance, e.provenance) || String(o.deprecated).localeCompare(String(e.deprecated));
7
+ }
8
+ const t = (o, e) => (o ?? "").localeCompare(e ?? "");
9
+ function $(o) {
10
+ const e = JSON.parse(o);
11
+ if (typeof e != "object" || e === null || !("auditKind" in e) || e.auditKind !== "usages" && e.auditKind !== "definitions")
12
+ throw new Error("Invalid deprecation audit JSON.");
13
+ return e;
14
+ }
15
+ function h() {
16
+ const o = c(".git");
17
+ if (o === void 0)
18
+ throw new Error("Unable to find a Git repository for the deprecation audit.");
19
+ const e = s.dirname(o), r = i("git", ["remote", "get-url", "origin"], { cwd: e }), n = i("git", ["rev-parse", "HEAD"], { cwd: e }), a = process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF_NAME || i("git", ["branch", "--show-current"], { cwd: e });
20
+ return { repository: u(r), repositoryRoot: e, ref: n, branch: a };
21
+ }
22
+ function g(o, e) {
23
+ return p(s.relative(e, o));
24
+ }
25
+ function v(o, e, r, n) {
26
+ const a = o === "usages" ? "usage" : "definition";
27
+ process.stderr.write(
28
+ `Deprecations: ${e} ${a}${e === 1 ? "" : "s"} across ${r} file${r === 1 ? "" : "s"} from ${n} package${n === 1 ? "" : "s"}.
29
+ `
30
+ );
31
+ }
32
+ function u(o) {
33
+ const e = o.replace(/\.git$/u, "");
34
+ if (e.startsWith("http://") || e.startsWith("https://"))
35
+ return new URL(e).href.replace(/^https?:\/\//u, "").replace(/\/$/u, "");
36
+ const r = /^(?:ssh:\/\/)?git@([^/:]+)[:/](.+)$/u.exec(e);
37
+ if (r !== null)
38
+ return `${r[1]}/${r[2]}`;
39
+ throw new Error(`Unsupported Git remote URL: ${o}`);
40
+ }
41
+ export {
42
+ g as a,
43
+ $ as b,
44
+ w as c,
45
+ h as g,
46
+ v as p,
47
+ f as s
48
+ };
@@ -1,107 +1,83 @@
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
- }
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;
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";
5
+ import { b as C, d as P } from "./cli.js";
6
+ function j(e) {
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 _(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 G(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 = 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);
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 = [];
36
+ function O(e, r) {
37
+ const o = [];
57
38
  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);
39
+ if (t.isClassLike(i) || t.isInterfaceDeclaration(i) || t.isTypeLiteralNode(i))
40
+ return r;
41
+ t.isModuleDeclaration(i) && t.isIdentifier(i.name) && o.unshift(i.name.text);
61
42
  }
62
- return [...r, t].join(".");
63
- }
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))
43
+ return [...o, r].join(".");
44
+ }
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))
49
+ return "field";
50
+ if (t.isMethodDeclaration(e) || t.isMethodSignature(e))
68
51
  return "method";
69
- if (s.isClassLike(e))
52
+ if (t.isClassLike(e))
70
53
  return "class";
71
- if (s.isInterfaceDeclaration(e))
54
+ if (t.isInterfaceDeclaration(e))
72
55
  return "interface";
73
- if (s.isTypeAliasDeclaration(e))
56
+ if (t.isTypeAliasDeclaration(e))
74
57
  return "type";
75
- if (s.isFunctionDeclaration(e))
58
+ if (t.isFunctionDeclaration(e))
76
59
  return "function";
77
- if (s.isVariableDeclaration(e))
78
- return "variable";
79
- if (s.isModuleDeclaration(e))
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))
80
63
  return "namespace";
81
64
  }
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);
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);
91
67
  }
92
- const $ = /* @__PURE__ */ new Map([
68
+ const J = /* @__PURE__ */ new Map([
93
69
  ["MapView", "arcgis-map"],
94
70
  ["SceneView", "arcgis-scene"],
95
71
  ["LinkChartView", "arcgis-link-chart"],
96
72
  ["VideoView", "arcgis-video"]
97
- ]), V = /* @__PURE__ */ new Set([
73
+ ]), L = /* @__PURE__ */ new Set([
98
74
  "MessageBundleLoader",
99
75
  "createJSONLoader",
100
76
  "fetchMessageBundle",
101
77
  "messageBundle",
102
78
  "normalizeMessageBundleLocale",
103
79
  "registerMessageBundleLoader"
104
- ]), R = /* @__PURE__ */ new Set([
80
+ ]), A = /* @__PURE__ */ new Set([
105
81
  "AreaMeasurement2D",
106
82
  "AreaMeasurement3D",
107
83
  "BasemapGallery",
@@ -142,16 +118,18 @@ const $ = /* @__PURE__ */ new Map([
142
118
  "TableList",
143
119
  "useLegacyCreateTools"
144
120
  ]);
145
- function B({
121
+ function $({
146
122
  package: e,
147
- api: t,
148
- category: r,
123
+ name: r,
124
+ category: o,
149
125
  memberOf: i,
150
- module: n,
151
- reason: l
126
+ module: s,
127
+ deprecated: u
152
128
  }) {
153
- const a = e.toLowerCase(), o = l?.toLowerCase() ?? "";
154
- return e === "@arcgis/core" && r === "coreViews" && $.has(t) || e === "@arcgis/core" && t === "ui" && [
129
+ if (o !== void 0)
130
+ return o;
131
+ const a = e.toLowerCase(), n = typeof u == "string" ? u.toLowerCase() : "";
132
+ return e === "@arcgis/core" && r === "ui" && [
155
133
  "DOMContainer",
156
134
  "DOMContainerProperties",
157
135
  "MapView",
@@ -162,71 +140,83 @@ function B({
162
140
  "LinkChartViewProperties",
163
141
  "VideoView",
164
142
  "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));
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";
169
144
  }
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, "");
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)
148
+ );
149
+ for (const s of i) {
150
+ const u = s.lastIndexOf(o);
151
+ let a;
152
+ if (u !== -1)
153
+ a = s.slice(u + o.length);
154
+ else {
155
+ const n = [...s.matchAll(/\/(?:src|dist)(?=\/)/gu)];
156
+ if (n.length === 1)
157
+ a = s.slice(n[0].index + 1);
158
+ else {
159
+ const c = k("package.json", h.dirname(s));
160
+ if (c === void 0)
161
+ continue;
162
+ const d = h.dirname(c);
163
+ if (v(d).name !== r)
164
+ continue;
165
+ a = y(h.relative(d, s));
166
+ }
183
167
  }
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, "");
168
+ return a.startsWith("src/") ? V(a) : B(a);
190
169
  }
191
170
  }
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)
171
+ function V(e) {
172
+ return y(e).replace(/^src\//u, "").replace(D, "");
173
+ }
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)
198
183
  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 };
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 };
206
194
  });
207
- return y.sort((u, p) => p.items.length - u.items.length || u.api.localeCompare(p.api)), { packageName: o, count: c.length, apis: y };
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 };
208
199
  });
209
- return a.sort((o, c) => c.count - o.count || o.packageName.localeCompare(c.packageName)), [{ categoryName: i, count: n.length, packages: a }];
200
+ 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 }];
210
203
  });
211
204
  }
205
+ function T(e, r) {
206
+ return x(e, r) ? "DOM / Web platform" : e;
207
+ }
208
+ function x(e, r) {
209
+ return e === "typescript" && /^lib\/lib\.dom(?:$|[./])/u.test(r ?? "");
210
+ }
212
211
  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
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
232
222
  };