@arcgis/codemod 6.0.0-next.43 → 6.0.0-next.45

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,5 +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 b } from "./classification.js";
2
+ import { i as M, c as C, b as h, d as b } from "./apiName.js";
3
+ import { c as k, g as j, d as J } from "./classification.js";
3
4
  import { a as z, e as A, d as N } from "./cli.js";
4
5
  async function B(e = {}) {
5
6
  const n = new URL(e.url ?? z);
@@ -23,7 +24,7 @@ async function B(e = {}) {
23
24
  return { ...t, auditKind: "usages" };
24
25
  });
25
26
  }
26
- async function Y(e, n, a = {}, i = [], s) {
27
+ async function Z(e, n, a = {}, i = [], s) {
27
28
  const { section: t = "all", ...r } = a, [o, c, u] = await Promise.all([
28
29
  Promise.all(e.map(async (l) => await D(l, "usages"))),
29
30
  Promise.all(i.map(async (l) => await D(l, "definitions"))),
@@ -46,7 +47,7 @@ function F(e, n = {}, a) {
46
47
  if (i.has(o.repository))
47
48
  throw new Error(`Duplicate audit-usages report for ${o.repository}.`);
48
49
  i.add(o.repository);
49
- const c = o.findings.map((u) => ({ ...u, category: u.category ?? h(u) })).filter((u) => P(u, n));
50
+ const c = o.findings.map((u) => ({ ...u, category: u.category ?? k(u) })).filter((u) => P(u, n));
50
51
  return s.push(V(o, c)), c.map((u) => ({ finding: u, source: { repository: o.repository, ref: o.ref } }));
51
52
  }), r = S(t);
52
53
  return {
@@ -93,7 +94,7 @@ function S(e) {
93
94
  const o = [
94
95
  ...Map.groupBy(
95
96
  r,
96
- ({ finding: c }) => JSON.stringify([c.category ?? h(c), w(c)])
97
+ ({ finding: c }) => JSON.stringify([c.category ?? k(c), w(c)])
97
98
  )
98
99
  ].map(([, c]) => {
99
100
  const u = c.reduce(
@@ -102,7 +103,7 @@ function S(e) {
102
103
  ), d = c.flatMap(({ source: p }) => p === void 0 ? [] : [p]);
103
104
  return {
104
105
  name: u.name,
105
- category: u.category ?? h(u),
106
+ category: u.category ?? k(u),
106
107
  kind: u.kind,
107
108
  memberOf: u.memberOf,
108
109
  count: d.length,
@@ -116,7 +117,7 @@ function S(e) {
116
117
  };
117
118
  });
118
119
  return o.sort(
119
- (c, u) => u.count - c.count || k(c).localeCompare(k(u)) || c.name.localeCompare(u.name) || (c.memberOf ?? "").localeCompare(u.memberOf ?? "") || (c.kind ?? "").localeCompare(u.kind ?? "") || c.category.localeCompare(u.category)
120
+ (c, u) => u.count - c.count || h(c).localeCompare(h(u)) || c.name.localeCompare(u.name) || (c.memberOf ?? "").localeCompare(u.memberOf ?? "") || (c.kind ?? "").localeCompare(u.kind ?? "") || c.category.localeCompare(u.category)
120
121
  ), {
121
122
  module: t,
122
123
  count: o.reduce((c, u) => c + u.count, 0),
@@ -139,7 +140,7 @@ function K(e, n, a) {
139
140
  throw new Error(
140
141
  `Definition ${o.package}/${o.name} has no module. Regenerate its audit-definitions report.`
141
142
  );
142
- const c = { ...o, category: o.category ?? h(o) }, u = w(c);
143
+ const c = { ...o, category: o.category ?? k(o) }, u = w(c);
143
144
  if (!s.has(u) && P(c, a)) {
144
145
  const p = t.get(u);
145
146
  (p === void 0 || C(c, p.finding) < 0) && t.set(u, { finding: c });
@@ -281,11 +282,11 @@ function H(e, n, a) {
281
282
  return i;
282
283
  }
283
284
  function x(e, n, a = "") {
284
- const i = `${k(e)}${b(e.kind)}`, s = e.repositories.map(
285
+ const i = `${h(e)}${b(e.kind)}`, s = e.repositories.map(
285
286
  ({ repository: t, count: r }) => `${a} ${n ? `- \`${t}\`` : t} (${r})`
286
287
  );
287
288
  return n ? [
288
- `${a}- \`${k(e)}\`${b(e.kind)}${m(e.count)}`,
289
+ `${a}- \`${h(e)}\`${b(e.kind)}${m(e.count)}`,
289
290
  ...s
290
291
  ] : [`${a}${i}${m(e.count)}`, ...s];
291
292
  }
@@ -347,5 +348,5 @@ async function D(e, n) {
347
348
  }
348
349
  export {
349
350
  F as aggregateUsages,
350
- Y as aggregateUsagesFromFiles
351
+ Z as aggregateUsagesFromFiles
351
352
  };
@@ -0,0 +1,123 @@
1
+ import { findPath as m } from "@arcgis/node-toolkit/file";
2
+ import { path as c, toPosixPathSeparators as p } from "@arcgis/node-toolkit/path";
3
+ import { collectOutputSync as a } from "@arcgis/node-toolkit/shell";
4
+ import f from "picomatch";
5
+ import r from "typescript";
6
+ const w = "6.0.0-next.45";
7
+ function A(e, t) {
8
+ return e.package.localeCompare(t.package) || e.file.localeCompare(t.file) || e.line - t.line || e.column - t.column || n(e.module, t.module) || n(e.memberOf, t.memberOf) || e.name.localeCompare(t.name) || n(e.kind, t.kind) || n(e.category, t.category) || n(e.provenance, t.provenance) || String(e.deprecated).localeCompare(String(t.deprecated));
9
+ }
10
+ const n = (e, t) => (e ?? "").localeCompare(t ?? "");
11
+ function O(e) {
12
+ const t = JSON.parse(e);
13
+ if (typeof t != "object" || t === null || !("auditKind" in t) || t.auditKind !== "usages" && t.auditKind !== "definitions")
14
+ throw new Error("Invalid deprecation audit JSON.");
15
+ return t;
16
+ }
17
+ function S() {
18
+ const e = m(".git");
19
+ if (e === void 0)
20
+ throw new Error("Unable to find a Git repository for the deprecation audit.");
21
+ const t = c.dirname(e), o = a("git", ["remote", "get-url", "origin"], { cwd: t }), i = a("git", ["rev-parse", "HEAD"], { cwd: t }), s = process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF_NAME || a("git", ["branch", "--show-current"], { cwd: t });
22
+ return { repository: l(o), repositoryRoot: t, ref: i, branch: s };
23
+ }
24
+ function k(e, t) {
25
+ return p(c.relative(t, e));
26
+ }
27
+ function F(e, t = process.cwd()) {
28
+ if (e.length === 0)
29
+ return () => !0;
30
+ const o = f([...e], { dot: !0 });
31
+ return (i) => !o(p(c.relative(t, i)));
32
+ }
33
+ function N(e, t, o, i) {
34
+ const s = e === "usages" ? "usage" : "definition";
35
+ process.stderr.write(
36
+ `Deprecations: ${t} ${s}${t === 1 ? "" : "s"} across ${o} file${o === 1 ? "" : "s"} from ${i} package${i === 1 ? "" : "s"}.
37
+ `
38
+ );
39
+ }
40
+ function l(e) {
41
+ const t = e.replace(/\.git$/u, "");
42
+ if (t.startsWith("http://") || t.startsWith("https://"))
43
+ return new URL(t).href.replace(/^https?:\/\//u, "").replace(/\/$/u, "");
44
+ const o = /^(?:ssh:\/\/)?git@([^/:]+)[:/](.+)$/u.exec(t);
45
+ if (o !== null)
46
+ return `${o[1]}/${o[2]}`;
47
+ throw new Error(`Unsupported Git remote URL: ${e}`);
48
+ }
49
+ function R(e) {
50
+ if (e.kind === "css-property")
51
+ return e.name;
52
+ if (e.kind === "element")
53
+ return `<${e.name}>`;
54
+ if (e.memberOf !== void 0) {
55
+ if (e.kind === "css-part")
56
+ return `${e.memberOf}::part(${e.name})`;
57
+ if (e.kind === "css-state")
58
+ return `${e.memberOf}:state(${e.name})`;
59
+ if (e.kind === "slot")
60
+ return `${e.memberOf} > [slot="${e.name}"]`;
61
+ if (e.kind === "attribute")
62
+ return `${e.memberOf}[${e.name}]`;
63
+ }
64
+ const t = e.memberOf === void 0 ? e.name : `${e.memberOf}.${e.name}`;
65
+ return e.kind === "method" || e.kind === "function" ? `${t}()` : t;
66
+ }
67
+ function M(e, t = "dash") {
68
+ return e === void 0 || e === "field" || e === "method" || e === "function" ? "" : t === "parentheses" ? ` (${e})` : ` - ${e}`;
69
+ }
70
+ function x(e) {
71
+ if (e === void 0)
72
+ return {};
73
+ const t = v(e), o = e.parent, i = o !== void 0 && (r.isClassLike(o) || r.isInterfaceDeclaration(o)) ? o : o !== void 0 && r.isTypeLiteralNode(o) && r.isTypeAliasDeclaration(o.parent) ? o.parent : void 0, s = i?.name === void 0 ? void 0 : d(i, i.name.text);
74
+ return {
75
+ ...t === void 0 ? {} : { kind: t },
76
+ ...s === void 0 ? {} : { memberOf: s }
77
+ };
78
+ }
79
+ function d(e, t) {
80
+ const o = [];
81
+ for (let i = e?.parent; i !== void 0; i = i.parent) {
82
+ if (r.isClassLike(i) || r.isInterfaceDeclaration(i) || r.isTypeLiteralNode(i))
83
+ return t;
84
+ r.isModuleDeclaration(i) && r.isIdentifier(i.name) && o.unshift(i.name.text);
85
+ }
86
+ return [...o, t].join(".");
87
+ }
88
+ function v(e) {
89
+ if (r.isPropertyDeclaration(e) || r.isPropertySignature(e))
90
+ return (r.getCombinedModifierFlags(e) & r.ModifierFlags.Readonly) !== 0 && u(e) ? "method" : "field";
91
+ if (r.isGetAccessorDeclaration(e) || r.isSetAccessorDeclaration(e))
92
+ return "field";
93
+ if (r.isMethodDeclaration(e) || r.isMethodSignature(e))
94
+ return "method";
95
+ if (r.isClassLike(e))
96
+ return "class";
97
+ if (r.isInterfaceDeclaration(e))
98
+ return "interface";
99
+ if (r.isTypeAliasDeclaration(e))
100
+ return "type";
101
+ if (r.isFunctionDeclaration(e))
102
+ return "function";
103
+ if (r.isVariableDeclaration(e))
104
+ return u(e) && (e.type !== void 0 || (e.parent.flags & r.NodeFlags.Const) !== 0) ? "function" : "variable";
105
+ if (r.isModuleDeclaration(e))
106
+ return "namespace";
107
+ }
108
+ function u(e) {
109
+ return e.type !== void 0 ? r.isFunctionTypeNode(e.type) : !r.isPropertySignature(e) && e.initializer !== void 0 && r.isArrowFunction(e.initializer);
110
+ }
111
+ export {
112
+ S as a,
113
+ R as b,
114
+ A as c,
115
+ M as d,
116
+ F as e,
117
+ x as f,
118
+ k as g,
119
+ d as h,
120
+ O as i,
121
+ N as p,
122
+ w as s
123
+ };
@@ -1,59 +1,61 @@
1
- var y = (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), b = (a) => {
2
2
  throw TypeError(a);
3
3
  };
4
- var b = (a, o, i) => {
4
+ var S = (a, o, s) => {
5
5
  if (o != null) {
6
- typeof o != "object" && typeof o != "function" && S("Object expected");
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() {
6
+ typeof o != "object" && typeof o != "function" && b("Object expected");
7
+ var n, i;
8
+ s && (n = o[y("asyncDispose")]), n === void 0 && (n = o[y("dispose")], s && (i = n)), typeof n != "function" && b("Object not disposable"), i && (n = function() {
9
9
  try {
10
- s.call(this);
10
+ i.call(this);
11
11
  } catch (r) {
12
12
  return Promise.reject(r);
13
13
  }
14
- }), a.push([i, n, o]);
15
- } else i && a.push([i]);
14
+ }), a.push([s, n, o]);
15
+ } else s && a.push([s]);
16
16
  return o;
17
- }, $ = (a, o, i) => {
17
+ }, $ = (a, o, s) => {
18
18
  var n = typeof SuppressedError == "function" ? SuppressedError : function(c, e, m, p) {
19
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) => {
20
+ }, i = (c) => o = s ? new n(c, o, "An error was suppressed during disposal") : (s = !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(r, (m) => (s(m), r()));
24
+ if (c[0]) return Promise.resolve(e).then(r, (m) => (i(m), r()));
25
25
  } catch (m) {
26
- s(m);
26
+ i(m);
27
27
  }
28
- if (i) throw o;
28
+ if (s) throw o;
29
29
  };
30
30
  return r();
31
31
  };
32
32
  import { log as C } from "@arcgis/toolkit/log";
33
- import { path as x } from "@arcgis/node-toolkit/path";
34
- import { styleText as j } from "node:util";
33
+ import { getCwd as x, path as j } from "@arcgis/node-toolkit/path";
34
+ import { styleText as I } from "node:util";
35
35
  import J from "typescript";
36
- import { r as I, f as v } from "./log.js";
36
+ import { f as v } from "./log.js";
37
37
  import { r as L, b as z, i as E } from "./cli.js";
38
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;
39
+ import { a as F, e as Q, g as h, b as V, d as W, p as q, s as B, f as G, h as H } from "./apiName.js";
40
+ import { loadCodeowners as U } from "@arcgis/node-toolkit/codeowners";
41
+ import { a as X, c as Y } from "./classification.js";
42
+ import { s as O, a as Z, b as _ } from "./hardcodedBehavior.js";
43
+ import { c as ee } from "./componentAudit.js";
44
+ async function we(a, { json: o, exclude: s }) {
45
+ const n = await L(a), i = !n && s.length === 0 && x() === F().repositoryRoot;
44
46
  await z(
45
47
  {
46
48
  meta: { needsTypeInformation: !0, needsFooter: !1, includeComponentFiles: !0 },
47
49
  async run(r) {
48
- await oe(r, o, s, i);
50
+ await oe(r, o, i, s);
49
51
  }
50
52
  },
51
53
  "deprecations audit-definitions",
52
54
  n
53
- ), I(s);
55
+ );
54
56
  }
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
+ async function oe(a, o, s, n) {
58
+ const i = [], r = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Set(), m = ee("throw"), p = F(), f = Q(n), u = (t) => E(t) && f(t) && !O(h(t, p.repositoryRoot));
57
59
  for (const t of a) {
58
60
  var N = [];
59
61
  try {
@@ -67,31 +69,31 @@ async function oe(a, o, i, n) {
67
69
  continue;
68
70
  }
69
71
  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));
72
+ d !== void 0 && !e.has(d) && (e.add(d), g !== void 0 && i.push(...g.definitions));
71
73
  if (!t.filePaths.some(u))
72
74
  continue;
73
- const k = b(N, K(t, !1));
75
+ const k = S(N, K(t, !1));
74
76
  const M = t.packageJson?.contents.name ?? v(t.cwd);
75
77
  for (const w of k.getCodemodFiles()) {
76
78
  if (!u(w.compilerNode.fileName))
77
79
  continue;
78
- const D = x.dirname(w.compilerNode.fileName), P = r.get(D) ?? Z(D, M);
79
- r.set(D, P), s.push(
80
+ const D = j.dirname(w.compilerNode.fileName), P = r.get(D) ?? Z(D, M);
81
+ r.set(D, P), i.push(
80
82
  ...te(w.compilerNode, P, g?.modulePaths)
81
83
  );
82
84
  }
83
- } catch (A) {
84
- var R = A, T = !0;
85
+ } catch (R) {
86
+ var T = R, A = !0;
85
87
  } finally {
86
- $(N, R, T);
88
+ $(N, T, A);
87
89
  }
88
90
  }
89
- const l = s.filter(({ sourceFileName: t }) => f(t));
91
+ const l = i.filter(({ sourceFileName: t }) => f(t));
90
92
  if (o)
91
- ne(l, p, i, n);
93
+ ne(l, p, s, n);
92
94
  else
93
95
  for (const t of l) {
94
- const d = j(
96
+ const d = I(
95
97
  "blue",
96
98
  `${v(t.sourceFileName)}:${t.line}:${t.column}`
97
99
  ), g = V({
@@ -108,8 +110,8 @@ async function oe(a, o, i, n) {
108
110
  new Set(l.map(({ package: t }) => t)).size
109
111
  );
110
112
  }
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
+ function te(a, o, s) {
114
+ const n = /* @__PURE__ */ new Map(), i = X([a.fileName], o), r = i === void 0 ? void 0 : s?.get(i) ?? i;
113
115
  function c(e) {
114
116
  const m = J.getJSDocDeprecatedTag(e), p = ae(e);
115
117
  if (m !== void 0 && p !== void 0) {
@@ -117,9 +119,9 @@ function te(a, o, i) {
117
119
  n.set(`${f}:${p.getWidth(a)}`, {
118
120
  package: o,
119
121
  module: r,
120
- name: X(e, p.getText(a)),
121
- ...U(e),
122
- reason: m.comment === void 0 ? void 0 : ee(m.comment),
122
+ name: H(e, p.getText(a)),
123
+ ...G(e),
124
+ reason: m.comment === void 0 ? void 0 : _(m.comment),
123
125
  sourceFileName: a.fileName,
124
126
  line: u + 1,
125
127
  column: l + 1
@@ -132,15 +134,15 @@ function te(a, o, i) {
132
134
  function ae(a) {
133
135
  return a.name;
134
136
  }
135
- function ne(a, o, i, n) {
136
- const s = Y(), r = h(process.cwd(), o.repositoryRoot), c = {
137
+ function ne(a, o, s, n) {
138
+ const i = U(), r = h(process.cwd(), o.repositoryRoot), c = {
137
139
  auditKind: "definitions",
138
140
  repository: o.repository,
139
141
  ref: o.ref,
140
142
  branch: o.branch,
141
- scannerVersion: H,
143
+ scannerVersion: B,
142
144
  scanDate: Date.now(),
143
- complete: i,
145
+ complete: s,
144
146
  ...r === "" ? {} : { cwd: r },
145
147
  ...n.length === 0 ? {} : { excludedPaths: n },
146
148
  findings: a.map((e) => ({
@@ -150,7 +152,7 @@ function ne(a, o, i, n) {
150
152
  kind: e.kind,
151
153
  memberOf: e.memberOf,
152
154
  provenance: e.provenance,
153
- category: G({
155
+ category: Y({
154
156
  package: e.package,
155
157
  name: e.name,
156
158
  memberOf: e.memberOf,
@@ -161,13 +163,13 @@ function ne(a, o, i, n) {
161
163
  file: h(e.sourceFileName, o.repositoryRoot),
162
164
  line: e.line,
163
165
  column: e.column,
164
- codeowners: s?.getOwners(e.sourceFileName) ?? []
166
+ codeowners: i?.getOwners(e.sourceFileName) ?? []
165
167
  }))
166
168
  };
167
169
  process.stdout.write(`${JSON.stringify(c, void 0, 2)}
168
170
  `);
169
171
  }
170
172
  export {
171
- he as auditDeprecatedDefinitions,
173
+ we as auditDeprecatedDefinitions,
172
174
  te as collectDeprecatedApiDefinitions
173
175
  };