@arcgis/codemod 6.0.0-next.36 → 6.0.0-next.38

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,6 +1,6 @@
1
1
  import { readFile as E } from "node:fs/promises";
2
- import { n as M, d as h, b as j, e as C, f as k, o as J, h as A } from "./classification.js";
3
- import { e as z, b, d as N } from "./cli.js";
2
+ import { n as M, d as h, b as j, e as C, f as k, o as J, h as b } from "./classification.js";
3
+ import { a as z, e as A, d as N } from "./cli.js";
4
4
  async function B(e = {}) {
5
5
  const n = new URL(e.url ?? z);
6
6
  for (const s of e.repositories ?? [])
@@ -85,7 +85,7 @@ function V(e, n) {
85
85
  };
86
86
  }
87
87
  function P(e, n) {
88
- return (!n.esriOnly || b(e.package)) && (n.category === void 0 || e.category === n.category) && (n.packageName === void 0 || e.package === n.packageName);
88
+ return (!n.esriOnly || A(e.package)) && (n.category === void 0 || e.category === n.category) && (n.packageName === void 0 || e.package === n.packageName);
89
89
  }
90
90
  function S(e) {
91
91
  const n = [...Map.groupBy(e, ({ finding: a }) => a.package)].map(([a, i]) => {
@@ -128,7 +128,7 @@ function S(e) {
128
128
  ), { package: a, count: s.reduce((t, r) => t + r.count, 0), modules: s };
129
129
  });
130
130
  return n.sort(
131
- (a, i) => Number(b(i.package)) - Number(b(a.package)) || i.count - a.count || a.package.localeCompare(i.package)
131
+ (a, i) => Number(A(i.package)) - Number(A(a.package)) || i.count - a.count || a.package.localeCompare(i.package)
132
132
  ), n;
133
133
  }
134
134
  function K(e, n, a) {
@@ -281,11 +281,11 @@ function H(e, n, a) {
281
281
  return i;
282
282
  }
283
283
  function x(e, n, a = "") {
284
- const i = `${k(e)}${A(e.kind)}`, s = e.repositories.map(
284
+ const i = `${k(e)}${b(e.kind)}`, s = e.repositories.map(
285
285
  ({ repository: t, count: r }) => `${a} ${n ? `- \`${t}\`` : t} (${r})`
286
286
  );
287
287
  return n ? [
288
- `${a}- \`${k(e)}\`${A(e.kind)}${m(e.count)}`,
288
+ `${a}- \`${k(e)}\`${b(e.kind)}${m(e.count)}`,
289
289
  ...s
290
290
  ] : [`${a}${i}${m(e.count)}`, ...s];
291
291
  }
@@ -1,147 +1,147 @@
1
- var P = (a, o) => (o = Symbol[a]) ? o : /* @__PURE__ */ Symbol.for("Symbol." + a), S = (a) => {
1
+ var y = (a, o) => (o = Symbol[a]) ? o : /* @__PURE__ */ Symbol.for("Symbol." + a), S = (a) => {
2
2
  throw TypeError(a);
3
3
  };
4
- var b = (a, o, s) => {
4
+ var b = (a, o, i) => {
5
5
  if (o != null) {
6
6
  typeof o != "object" && typeof o != "function" && S("Object expected");
7
- var n, i;
8
- s && (n = o[P("asyncDispose")]), n === void 0 && (n = o[P("dispose")], s && (i = n)), typeof n != "function" && S("Object not disposable"), i && (n = function() {
7
+ var n, s;
8
+ i && (n = o[y("asyncDispose")]), n === void 0 && (n = o[y("dispose")], i && (s = n)), typeof n != "function" && S("Object not disposable"), s && (n = function() {
9
9
  try {
10
- i.call(this);
11
- } catch (p) {
12
- return Promise.reject(p);
10
+ s.call(this);
11
+ } catch (r) {
12
+ return Promise.reject(r);
13
13
  }
14
- }), a.push([s, n, o]);
15
- } else s && a.push([s]);
14
+ }), a.push([i, n, o]);
15
+ } else i && a.push([i]);
16
16
  return o;
17
- }, $ = (a, o, s) => {
18
- var n = typeof SuppressedError == "function" ? SuppressedError : function(c, e, r, m) {
19
- return m = Error(r), m.name = "SuppressedError", m.error = c, m.suppressed = e, m;
20
- }, i = (c) => o = s ? new n(c, o, "An error was suppressed during disposal") : (s = !0, c), p = (c) => {
17
+ }, $ = (a, o, i) => {
18
+ var n = typeof SuppressedError == "function" ? SuppressedError : function(c, e, m, p) {
19
+ return p = Error(m), p.name = "SuppressedError", p.error = c, p.suppressed = e, p;
20
+ }, s = (c) => o = i ? new n(c, o, "An error was suppressed during disposal") : (i = !0, c), r = (c) => {
21
21
  for (; c = a.pop(); )
22
22
  try {
23
23
  var e = c[1] && c[1].call(c[2]);
24
- if (c[0]) return Promise.resolve(e).then(p, (r) => (i(r), p()));
25
- } catch (r) {
26
- i(r);
24
+ if (c[0]) return Promise.resolve(e).then(r, (m) => (s(m), r()));
25
+ } catch (m) {
26
+ s(m);
27
27
  }
28
- if (s) throw o;
28
+ if (i) throw o;
29
29
  };
30
- return p();
30
+ return r();
31
31
  };
32
- import { log as J } from "@arcgis/toolkit/log";
32
+ import { log as C } from "@arcgis/toolkit/log";
33
33
  import { path as x } from "@arcgis/node-toolkit/path";
34
34
  import { styleText as j } from "node:util";
35
- import O from "typescript";
36
- import { f as N } from "./log.js";
37
- import { r as I, i as L } from "./cli.js";
38
- import { c as z } from "./useProjectInstance.js";
39
- import { a as R, i as E, g as h, f as K, h as Q, p as V, c as W, d as q, s as B, j as G, k as H } from "./classification.js";
40
- import { loadCodeowners as U } from "@arcgis/node-toolkit/codeowners";
41
- import { f as C, a as X, b as Y, d as Z } from "./componentAudit.js";
42
- async function ue(a, o, s = []) {
43
- const n = !a && s.length === 0 && process.cwd() === R().repositoryRoot;
44
- await I(
35
+ import J from "typescript";
36
+ import { r as I, f as v } from "./log.js";
37
+ import { r as L, b as z, i as E } from "./cli.js";
38
+ import { c as K } from "./useProjectInstance.js";
39
+ import { a as F, i as Q, g as h, f as V, h as W, p as q, c as B, d as G, s as H, j as U, k as X } from "./classification.js";
40
+ import { loadCodeowners as Y } from "@arcgis/node-toolkit/codeowners";
41
+ import { f as O, a as Z, e as _, b as ee } from "./componentAudit.js";
42
+ async function he(a, { json: o, exclude: i }) {
43
+ const n = await L(a), s = !n && i.length === 0 && process.cwd() === F().repositoryRoot;
44
+ await z(
45
45
  {
46
46
  meta: { needsTypeInformation: !0, needsFooter: !1, includeComponentFiles: !0 },
47
- async run(i) {
48
- await _(i, o, n, s);
47
+ async run(r) {
48
+ await oe(r, o, s, i);
49
49
  }
50
50
  },
51
51
  "deprecations audit-definitions",
52
- a
53
- );
52
+ n
53
+ ), I(s);
54
54
  }
55
- async function _(a, o, s, n) {
56
- const i = [], p = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Set(), r = Y("throw"), m = R(), l = E(n), g = (t) => L(t) && l(t) && !C(h(t, m.repositoryRoot));
55
+ async function oe(a, o, i, n) {
56
+ const s = [], r = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Set(), m = _("throw"), p = F(), f = Q(n), u = (t) => E(t) && f(t) && !O(h(t, p.repositoryRoot));
57
57
  for (const t of a) {
58
- var v = [];
58
+ var N = [];
59
59
  try {
60
60
  const d = t.packageJson?.filePath;
61
- if (d !== void 0 && C(h(d, m.repositoryRoot))) {
62
- d !== void 0 && !c.has(d) && (c.add(d), J(
61
+ if (d !== void 0 && O(h(d, p.repositoryRoot))) {
62
+ d !== void 0 && !c.has(d) && (c.add(d), C(
63
63
  "warn",
64
- N(d),
64
+ v(d),
65
65
  `Skipping excluded package \`${t.packageJson?.contents.name ?? t.cwd}\`.`
66
66
  ));
67
67
  continue;
68
68
  }
69
- const u = d === void 0 ? void 0 : await r(d);
70
- d !== void 0 && !e.has(d) && (e.add(d), u !== void 0 && i.push(...u.definitions));
71
- if (!t.filePaths.some(g))
69
+ const g = d === void 0 ? void 0 : await m(d);
70
+ d !== void 0 && !e.has(d) && (e.add(d), g !== void 0 && s.push(...g.definitions));
71
+ if (!t.filePaths.some(u))
72
72
  continue;
73
- const k = b(v, z(t, !1));
74
- const T = t.packageJson?.contents.name ?? N(t.cwd);
73
+ const k = b(N, K(t, !1));
74
+ const M = t.packageJson?.contents.name ?? v(t.cwd);
75
75
  for (const w of k.getCodemodFiles()) {
76
- if (!g(w.compilerNode.fileName))
76
+ if (!u(w.compilerNode.fileName))
77
77
  continue;
78
- const D = x.dirname(w.compilerNode.fileName), y = p.get(D) ?? X(D, T);
79
- p.set(D, y), i.push(
80
- ...ee(w.compilerNode, y, u?.modulePaths)
78
+ const D = x.dirname(w.compilerNode.fileName), P = r.get(D) ?? Z(D, M);
79
+ r.set(D, P), s.push(
80
+ ...te(w.compilerNode, P, g?.modulePaths)
81
81
  );
82
82
  }
83
83
  } catch (A) {
84
- var F = A, M = !0;
84
+ var R = A, T = !0;
85
85
  } finally {
86
- $(v, F, M);
86
+ $(N, R, T);
87
87
  }
88
88
  }
89
- const f = i.filter(({ sourceFileName: t }) => l(t));
89
+ const l = s.filter(({ sourceFileName: t }) => f(t));
90
90
  if (o)
91
- te(f, m, s, n);
91
+ ne(l, p, i, n);
92
92
  else
93
- for (const t of f) {
93
+ for (const t of l) {
94
94
  const d = j(
95
95
  "blue",
96
- `${N(t.sourceFileName)}:${t.line}:${t.column}`
97
- ), u = K({
96
+ `${v(t.sourceFileName)}:${t.line}:${t.column}`
97
+ ), g = V({
98
98
  name: t.name,
99
99
  memberOf: t.memberOf,
100
100
  kind: t.kind
101
- }), k = Q(t.kind, "parentheses");
102
- J("warn", d, `\`${u}\`${k} is deprecated.${t.reason ? ` ${t.reason}` : ""}`);
101
+ }), k = W(t.kind, "parentheses");
102
+ C("warn", d, `\`${g}\`${k} is deprecated.${t.reason ? ` ${t.reason}` : ""}`);
103
103
  }
104
- V(
104
+ q(
105
105
  "definitions",
106
- f.length,
107
- new Set(f.map(({ sourceFileName: t }) => t)).size,
108
- new Set(f.map(({ package: t }) => t)).size
106
+ l.length,
107
+ new Set(l.map(({ sourceFileName: t }) => t)).size,
108
+ new Set(l.map(({ package: t }) => t)).size
109
109
  );
110
110
  }
111
- function ee(a, o, s) {
112
- const n = /* @__PURE__ */ new Map(), i = W([a.fileName], o), p = i === void 0 ? void 0 : s?.get(i) ?? i;
111
+ function te(a, o, i) {
112
+ const n = /* @__PURE__ */ new Map(), s = B([a.fileName], o), r = s === void 0 ? void 0 : i?.get(s) ?? s;
113
113
  function c(e) {
114
- const r = O.getJSDocDeprecatedTag(e), m = oe(e);
115
- if (r !== void 0 && m !== void 0) {
116
- const l = m.getStart(a), { line: g, character: f } = a.getLineAndCharacterOfPosition(l);
117
- n.set(`${l}:${m.getWidth(a)}`, {
114
+ const m = J.getJSDocDeprecatedTag(e), p = ae(e);
115
+ if (m !== void 0 && p !== void 0) {
116
+ const f = p.getStart(a), { line: u, character: l } = a.getLineAndCharacterOfPosition(f);
117
+ n.set(`${f}:${p.getWidth(a)}`, {
118
118
  package: o,
119
- module: p,
120
- name: H(e, m.getText(a)),
121
- ...G(e),
122
- reason: r.comment === void 0 ? void 0 : Z(r.comment),
119
+ module: r,
120
+ name: X(e, p.getText(a)),
121
+ ...U(e),
122
+ reason: m.comment === void 0 ? void 0 : ee(m.comment),
123
123
  sourceFileName: a.fileName,
124
- line: g + 1,
125
- column: f + 1
124
+ line: u + 1,
125
+ column: l + 1
126
126
  });
127
127
  }
128
- O.forEachChild(e, c);
128
+ J.forEachChild(e, c);
129
129
  }
130
- return c(a), [...n.values()].sort((e, r) => e.line - r.line || e.column - r.column);
130
+ return c(a), [...n.values()].sort((e, m) => e.line - m.line || e.column - m.column);
131
131
  }
132
- function oe(a) {
132
+ function ae(a) {
133
133
  return a.name;
134
134
  }
135
- function te(a, o, s, n) {
136
- const i = U(), p = h(process.cwd(), o.repositoryRoot), c = {
135
+ function ne(a, o, i, n) {
136
+ const s = Y(), r = h(process.cwd(), o.repositoryRoot), c = {
137
137
  auditKind: "definitions",
138
138
  repository: o.repository,
139
139
  ref: o.ref,
140
140
  branch: o.branch,
141
- scannerVersion: B,
141
+ scannerVersion: H,
142
142
  scanDate: Date.now(),
143
- complete: s,
144
- ...p === "" ? {} : { cwd: p },
143
+ complete: i,
144
+ ...r === "" ? {} : { cwd: r },
145
145
  ...n.length === 0 ? {} : { excludedPaths: n },
146
146
  findings: a.map((e) => ({
147
147
  package: e.package,
@@ -150,7 +150,7 @@ function te(a, o, s, n) {
150
150
  kind: e.kind,
151
151
  memberOf: e.memberOf,
152
152
  provenance: e.provenance,
153
- category: q({
153
+ category: G({
154
154
  package: e.package,
155
155
  name: e.name,
156
156
  memberOf: e.memberOf,
@@ -161,13 +161,13 @@ function te(a, o, s, n) {
161
161
  file: h(e.sourceFileName, o.repositoryRoot),
162
162
  line: e.line,
163
163
  column: e.column,
164
- codeowners: i?.getOwners(e.sourceFileName) ?? []
164
+ codeowners: s?.getOwners(e.sourceFileName) ?? []
165
165
  }))
166
166
  };
167
167
  process.stdout.write(`${JSON.stringify(c, void 0, 2)}
168
168
  `);
169
169
  }
170
170
  export {
171
- ue as auditDeprecatedDefinitions,
172
- ee as collectDeprecatedApiDefinitions
171
+ he as auditDeprecatedDefinitions,
172
+ te as collectDeprecatedApiDefinitions
173
173
  };