@arcgis/codemod 6.0.0-next.12 → 6.0.0-next.13

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