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

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,157 +1,72 @@
1
- import { d as h } from "./cli.js";
2
- const I = /(?:esri|arcgis)/iu, y = "@arcgis/codemod", x = {
3
- usages: "Refactor-out deprecated API usages",
4
- definitions: "Remove deprecated APIs in next breaking changes release"
5
- }, P = {
6
- usages: "The following deprecated APIs are used in files owned by assigned CODEOWNERS. Refactor them before the APIs are removed.",
7
- definitions: "The following deprecated APIs are owned by assigned CODEOWNERS. Remove them in the next breaking changes release."
8
- }, R = "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.", J = "Task", K = "deprecations sync-issues";
9
- function A(e) {
10
- return I.test(e);
11
- }
12
- const L = /* @__PURE__ */ new Set([
13
- "MessageBundleLoader",
14
- "createJSONLoader",
15
- "fetchMessageBundle",
16
- "messageBundle",
17
- "normalizeMessageBundleLocale",
18
- "registerMessageBundleLoader"
19
- ]), O = /* @__PURE__ */ new Set([
20
- "AreaMeasurement2D",
21
- "AreaMeasurement3D",
22
- "BasemapGallery",
23
- "BasemapToggle",
24
- "BatchAttributeForm",
25
- "BinaryColorSizeSlider",
26
- "ClassedColorSlider",
27
- "ColorSlider",
28
- "ColorSizeSlider",
29
- "CoordinateConversion",
30
- "Daylight",
31
- "DirectLineMeasurement3D",
32
- "DistanceMeasurement2D",
33
- "Editor",
34
- "FeatureForm",
35
- "FeatureTable",
36
- "GridControls",
37
- "HeatmapSlider",
38
- "Home",
39
- "HistogramRangeSlider",
40
- "LayerList",
41
- "Legend",
42
- "LineOfSight",
43
- "Locate",
44
- "NavigationToggle",
45
- "OpacitySlider",
46
- "OrientedImageryViewer",
47
- "Print",
48
- "ScaleBar",
49
- "Search",
50
- "Sketch",
51
- "SketchLabelOptions",
52
- "SketchTooltipOptions",
53
- "Slice",
54
- "SizeSlider",
55
- "Slider",
56
- "SnappingOptions",
57
- "TableList",
58
- "useLegacyCreateTools"
59
- ]);
60
- function D({
61
- packageName: e,
62
- api: n,
63
- reason: s
64
- }) {
65
- const r = e.toLowerCase(), t = s?.toLowerCase() ?? "";
66
- return e === "@arcgis/core" && (O.has(n) || t.includes("components-transition-plan")) ? "coreWidgets" : e === "@arcgis/core" && (n === "geometryEngine" || n === "extendedSpatialReferenceInfo" || t.includes("geometry/operators")) ? "coreGeometryEngine" : /\bcodemod\b/iu.test(t) ? "codemod" : e === "@arcgis/core" && (L.has(n) || t.includes("widget translations")) ? "coreIntl" : r.includes("calcite") ? "calcite" : e === "@arcgis/core" || r.startsWith("@arcgis/") && r.includes("components") ? "arcgisCoreComponents" : A(e) ? "otherEsri" : "nonEsri";
67
- }
68
- function j(e, n) {
69
- const s = Map.groupBy(e, (r) => D(n(r)));
70
- return Object.keys(h).flatMap((r) => {
71
- const t = s.get(r);
72
- if (t === void 0)
73
- return [];
74
- const i = [...Map.groupBy(t, (a) => n(a).packageName)].map(([a, c]) => {
75
- const p = [...Map.groupBy(c, (d) => n(d).api)].map(([d, m]) => {
76
- const g = m.map((u) => n(u).reason).filter((u) => u != null && u !== ""), f = [...new Set(g)].sort((u, $) => u.localeCompare($));
77
- return { api: d, reasons: f, items: m };
78
- });
79
- return p.sort((d, m) => m.items.length - d.items.length || d.api.localeCompare(m.api)), { packageName: a, count: c.length, apis: p };
80
- });
81
- return i.sort((a, c) => c.count - a.count || a.packageName.localeCompare(c.packageName)), [{ categoryName: r, count: t.length, packages: i }];
82
- });
83
- }
84
- const S = `<!-- ${y} -->`, V = `<!-- ${y}`, M = 65536;
1
+ import { d as f } from "./cli.js";
2
+ import { o as b, q as m, r as P, s as D, c as O, a as d, b as B } from "./classification.js";
3
+ const h = `<!-- ${m} -->`, J = `<!-- ${m}`, w = 65536;
85
4
  function Q(e) {
86
- const n = C(e, e.findings);
5
+ const n = k(e, e.findings);
87
6
  return `${n.summary.trim().replace(/^### /u, "## ")}
88
7
 
89
8
  ${n.details}`;
90
9
  }
91
- function X(e) {
10
+ function V(e) {
92
11
  const n = /* @__PURE__ */ new Map();
93
- for (const s of e.findings) {
94
- const r = k(s.codeowners), t = r.join(","), o = n.get(t) ?? [];
95
- o.push({ ...s, codeowners: r }), n.set(t, o);
12
+ for (const o of e.findings) {
13
+ const r = $(o.codeowners), i = r.join(","), t = n.get(i) ?? [];
14
+ t.push({ ...o, codeowners: r }), n.set(i, t);
96
15
  }
97
- return [...n.entries()].map(([s, r]) => {
98
- const t = s === "" ? [] : s.split(","), o = T(e, r);
16
+ return [...n.entries()].map(([o, r]) => {
17
+ const i = o === "" ? [] : o.split(","), t = K(e, r);
99
18
  return {
100
19
  changes: [],
101
- title: x[e.kind],
102
- owners: t,
103
- assignees: t.filter((i) => /^@[^/@\s]+$/u.test(i)).map((i) => i.slice(1)),
104
- chunks: F(o, M, G(t))
20
+ title: b[e.kind],
21
+ owners: i,
22
+ assignees: i.filter((s) => /^@[^/@\s]+$/u.test(s)).map((s) => s.slice(1)),
23
+ chunks: v(t, w, N(i))
105
24
  };
106
- }).sort((s, r) => s.title.localeCompare(r.title));
25
+ }).sort((o, r) => o.title.localeCompare(r.title));
107
26
  }
108
- function T(e, n) {
109
- const s = k(n.flatMap((t) => t.codeowners)).filter(
110
- (t) => /^@[^/@\s]+\/[^@\s]+$/u.test(t)
111
- ), r = s.length === 0 ? "" : `
27
+ function K(e, n) {
28
+ const o = $(n.flatMap((i) => i.codeowners)).filter(
29
+ (i) => /^@[^/@\s]+\/[^@\s]+$/u.test(i)
30
+ ), r = o.length === 0 ? "" : `
112
31
 
113
- CODEOWNERS: ${s.join(", ")}`;
114
- return E(e, n, r);
32
+ CODEOWNERS: ${o.join(", ")}`;
33
+ return L(e, n, r);
115
34
  }
116
- function E(e, n, s) {
117
- const r = P[e.kind], t = C(e, n);
118
- return `${r}${s}${t.summary}
35
+ function L(e, n, o) {
36
+ const r = P[e.kind], i = k(e, n);
37
+ return `${r}${o}${i.summary}
119
38
 
120
- ${R}
39
+ ${D}
121
40
 
122
- ${t.details}`;
123
- }
124
- function C(e, n) {
125
- return e.kind === "usages" ? v(e, n) : z(e, n);
126
- }
127
- function v(e, n) {
128
- const s = j(n, ({ package: o, api: i, reason: a }) => ({
129
- packageName: o,
130
- api: i,
131
- reason: a
132
- })), r = s.map(({ categoryName: o, count: i, packages: a }) => {
133
- const c = a.map(({ packageName: l, count: p }) => ` - \`${l}\`: ${p}`).join(`
41
+ ${i.details}`;
42
+ }
43
+ function k(e, n) {
44
+ return e.kind === "usages" ? U(e, n) : z(e, n);
45
+ }
46
+ function U(e, n) {
47
+ const o = y(n, "usages"), r = O(n, (s) => s), i = r.map(({ categoryName: s, count: c, packages: a }) => {
48
+ const u = a.map(({ packageName: p, count: l }) => ` - \`${p}\`: ${l}`).join(`
134
49
  `);
135
- return `- **${h[o].label}**: ${i}
136
- ${c}`;
50
+ return `- **${f[s].label}**: ${c}
51
+ ${u}`;
137
52
  }).join(`
138
- `), t = s.map(({ categoryName: o, count: i, packages: a }) => {
139
- const c = a.map(({ packageName: d, count: m, apis: g }) => {
140
- const f = g.map(
141
- ({ api: u, reasons: $, items: b }) => B(e, u, $, b)
53
+ `), t = r.map(({ categoryName: s, count: c, packages: a }) => {
54
+ const u = a.map(({ packageName: j, count: A, apis: S }) => {
55
+ const C = S.flatMap(
56
+ ({ items: R }) => M(e, R, "usages", o)
142
57
  );
143
- return `#### ${d} (${m})
58
+ return `#### ${j} (${A})
144
59
 
145
- ${f.join(`
60
+ ${C.join(`
146
61
  `)}`;
147
62
  }).join(`
148
63
 
149
- `), l = h[o], p = "description" in l ? `
64
+ `), p = f[s], l = "description" in p ? `
150
65
 
151
- ${l.description}` : "";
152
- return `### ${l.label} (${i})${p}
66
+ ${p.description}` : "";
67
+ return `### ${p.label} (${c})${l}
153
68
 
154
- ${c}`;
69
+ ${u}`;
155
70
  }).join(`
156
71
 
157
72
  `);
@@ -160,96 +75,110 @@ ${c}`;
160
75
 
161
76
  ### Deprecation summary
162
77
 
163
- ${r}`,
78
+ ${i}`,
164
79
  details: `## Deprecation details
165
80
 
166
81
  ${t}`
167
82
  };
168
83
  }
84
+ function y(e, n) {
85
+ const o = /* @__PURE__ */ new Map();
86
+ for (const r of e) {
87
+ const i = d(r), t = o.get(i) ?? /* @__PURE__ */ new Set();
88
+ t.add(`${r.package}\0${I(n, r)}`), o.set(i, t);
89
+ }
90
+ return new Set([...o].filter(([, r]) => r.size > 1).map(([r]) => r));
91
+ }
169
92
  function z(e, n) {
170
- return { summary: "", details: [...Map.groupBy(n, (t) => t.package).entries()].sort(([t], [o]) => t.localeCompare(o)).map(([t, o]) => {
171
- const a = [...Map.groupBy(o, (c) => N(e.kind, c)).entries()].sort(([c], [l]) => c.localeCompare(l)).map(([, c]) => B(e, c[0].api, W(c), c));
93
+ const o = y(n, "definitions");
94
+ return { summary: "", details: [...Map.groupBy(n, (t) => t.package).entries()].sort(([t], [s]) => t.localeCompare(s)).map(([t, s]) => {
95
+ const c = M(e, s, "definitions", o);
172
96
  return `#### ${t}'s deprecations
173
97
 
174
- ${a.join(`
98
+ ${c.join(`
175
99
  `)}`;
176
100
  }).join(`
177
101
 
178
102
  `) };
179
103
  }
180
- function B(e, n, s, r) {
181
- const t = s.length === 0 ? "" : ` - ${s.map(H).join(" ")}`, o = [
104
+ function M(e, n, o, r) {
105
+ const i = [...Map.groupBy(n, (t) => I(o, t))];
106
+ return o === "definitions" && i.sort(([t], [s]) => t.localeCompare(s)), i.map(([, t]) => {
107
+ const s = d(t[0]), c = x(o, t[0]), a = c !== void 0 && r.has(s) ? `${c} ${s}` : s, u = T(t);
108
+ return o === "usages" && u.sort((p, l) => p.localeCompare(l)), E(e, a, u, t);
109
+ });
110
+ }
111
+ function E(e, n, o, r) {
112
+ const i = o.length === 0 ? "" : ` - ${o.map(q).join(" ")}`, t = [
182
113
  ...new Set(
183
- r.toSorted((a, c) => a.file.localeCompare(c.file) || a.line - c.line).map((a) => _(e.repository, e.ref, a.file, a.line))
114
+ r.toSorted((a, u) => a.file.localeCompare(u.file) || a.line - u.line).map((a) => G(e.repository, e.ref, a.file, a.line))
184
115
  )
185
- ], i = o.length === 1 ? ` ${o[0]}` : o.map((a) => ` - ${a}`).join(`
186
- `);
187
- return `- [ ] \`${n}\`${t}
188
- ${i}`;
116
+ ], s = t.length === 1 ? ` ${t[0]}` : t.map((a) => ` - ${a}`).join(`
117
+ `), c = r[0].apiKind;
118
+ return `- [ ] \`${n}\`${B(c)}${i}
119
+ ${s}`;
189
120
  }
190
- function W(e) {
121
+ function T(e) {
191
122
  return [
192
123
  ...new Set(
193
124
  e.map(({ reason: n }) => n).filter((n) => n !== null && n !== "")
194
125
  )
195
126
  ];
196
127
  }
197
- function F(e, n = M, s = S) {
198
- const r = `${s}
199
- `, t = n - r.length;
200
- if (t < 1)
128
+ function v(e, n = w, o = h) {
129
+ const r = `${o}
130
+ `, i = n - r.length;
131
+ if (i < 1)
201
132
  throw new Error("Issue content limit is too small for the managed marker.");
202
- const o = [];
203
- let i = e;
204
- for (; i.length > t; ) {
205
- const a = i.lastIndexOf(`
206
- `, t), c = a > 0 ? a : t;
207
- o.push(r + i.slice(0, c)), i = i.slice(c + (a > 0 ? 1 : 0));
133
+ const t = [];
134
+ let s = e;
135
+ for (; s.length > i; ) {
136
+ const c = s.lastIndexOf(`
137
+ `, i), a = c > 0 ? c : i;
138
+ t.push(r + s.slice(0, a)), s = s.slice(a + (c > 0 ? 1 : 0));
208
139
  }
209
- return o.push(r + i), o;
140
+ return t.push(r + s), t;
141
+ }
142
+ function N(e) {
143
+ return e.length === 0 ? h : `<!-- ${m} ${$(e).join(",")} -->`;
210
144
  }
211
- function G(e) {
212
- return e.length === 0 ? S : `<!-- ${y} ${k(e).join(",")} -->`;
145
+ function $(e) {
146
+ return [...new Set(e)].sort((n, o) => n.localeCompare(o));
213
147
  }
214
- function k(e) {
215
- return [...new Set(e)].sort((n, s) => n.localeCompare(s));
148
+ function I(e, n) {
149
+ return `${d(n)}\0${x(e, n) ?? ""}`;
216
150
  }
217
- function N(e, n) {
218
- return e === "definitions" ? `${n.api}\0${U(n.file)}` : n.api;
151
+ function x(e, n) {
152
+ return e === "definitions" ? _(n.file) : n.module;
219
153
  }
220
- function U(e) {
221
- const n = "/src/", s = "/dist/", r = e.lastIndexOf(n), t = e.lastIndexOf(s), o = Math.max(r, t), i = t > r ? s : n;
222
- return (o === -1 ? e : e.slice(o + i.length)).replace(/\.(?:d\.)?(?:[cm]?ts|tsx)$/u, "");
154
+ function _(e) {
155
+ const n = "/src/", o = "/dist/", r = e.lastIndexOf(n), i = e.lastIndexOf(o), t = Math.max(r, i), s = i > r ? o : n;
156
+ return (t === -1 ? e : e.slice(t + s.length)).replace(/\.(?:d\.)?(?:[cm]?ts|tsx)$/u, "");
223
157
  }
224
- function H(e) {
225
- const n = [], s = (o) => `\0${n.push(o) - 1}\0`, t = e.replaceAll(`\r
158
+ function q(e) {
159
+ const n = [], o = (t) => `\0${n.push(t) - 1}\0`, i = e.replaceAll(`\r
226
160
  `, `
227
161
  `).replaceAll("\r", `
228
162
  `).replace(
229
163
  /\[([^\]\n]+)\]\((https?:\/\/(?:[^()\s]|\([^()\s]*\))+?)\)/gu,
230
- (o, i, a) => s(`[${w(i)}](${a})`)
231
- ).replace(/https?:\/\/[^\s<>()]+/gu, (o) => {
232
- const i = /[.,;:!?]+$/u.exec(o)?.[0] ?? "";
233
- return `${s(o.slice(0, -i.length || void 0))}${i}`;
164
+ (t, s, c) => o(`[${g(s)}](${c})`)
165
+ ).replace(/https?:\/\/[^\s<>()]+/gu, (t) => {
166
+ const s = /[.,;:!?]+$/u.exec(t)?.[0] ?? "";
167
+ return `${o(t.slice(0, -s.length || void 0))}${s}`;
234
168
  });
235
- return w(t).replace(/\0(\d+)\0/gu, (o, i) => n[Number(i)]).replaceAll(`
169
+ return g(i).replace(/\0(\d+)\0/gu, (t, s) => n[Number(s)]).replaceAll(`
236
170
  `, `
237
171
  `);
238
172
  }
239
- function w(e) {
173
+ function g(e) {
240
174
  return e.replace(/^(\s*)(#{1,6})(?=\s)/gmu, "$1\\$2").replace(/#(?=\d)/gu, "# ");
241
175
  }
242
- function _(e, n, s, r) {
243
- const t = n.split("/").map(encodeURIComponent).join("/"), o = s.split("/").map(encodeURIComponent).join("/");
244
- return `https://${e}/blob/${t}/${o}#L${r}`;
176
+ function G(e, n, o, r) {
177
+ const i = n.split("/").map(encodeURIComponent).join("/"), t = o.split("/").map(encodeURIComponent).join("/");
178
+ return `https://${e}/blob/${i}/${t}#L${r}`;
245
179
  }
246
180
  export {
247
- J as a,
248
- X as b,
249
- D as c,
250
- K as d,
251
- V as e,
181
+ V as c,
252
182
  Q as f,
253
- j as g,
254
- A as i
183
+ J as i
255
184
  };
@@ -1,62 +1,35 @@
1
- import { findPath as a } from "@arcgis/node-toolkit/file";
2
- import { path as s, toPosixPathSeparators as d } from "@arcgis/node-toolkit/path";
3
- import { collectOutputSync as c } from "@arcgis/node-toolkit/shell";
4
- import u from "typescript";
5
- import { retrievePackageJson as g } from "@arcgis/node-toolkit/packageJson";
6
- function P() {
7
- const t = a(".git");
8
- if (t === void 0)
9
- throw new Error("Unable to find a Git repository for the deprecation audit.");
10
- const e = s.dirname(t), o = c("git", ["remote", "get-url", "origin"], { cwd: e }), n = c("git", ["rev-parse", "HEAD"], { cwd: e });
11
- return { repository: l(o), repositoryRoot: e, ref: n };
12
- }
13
- function v(t, e) {
14
- return d(s.relative(e, t));
15
- }
16
- function y(t, e, o, n) {
17
- const i = t === "usages" ? "usage" : "definition";
18
- process.stderr.write(
19
- `Deprecations: ${e} ${i}${e === 1 ? "" : "s"} across ${o} file${o === 1 ? "" : "s"} from ${n} package${n === 1 ? "" : "s"}.
20
- `
21
- );
22
- }
23
- function l(t) {
24
- const e = t.replace(/\.git$/u, "");
25
- if (e.startsWith("http://") || e.startsWith("https://"))
26
- return new URL(e).href.replace(/^https?:\/\//u, "").replace(/\/$/u, "");
27
- const o = /^(?:ssh:\/\/)?git@([^/:]+)[:/](.+)$/u.exec(e);
28
- if (o !== null)
29
- return `${o[1]}/${o[2]}`;
30
- throw new Error(`Unsupported Git remote URL: ${t}`);
31
- }
32
- function w(t) {
33
- return typeof t == "string" ? t : t.map((e) => e.kind === u.SyntaxKind.JSDocText ? e.text : m(e.getText())).join("");
34
- }
35
- function k(t) {
36
- return t === void 0 ? void 0 : f(u.displayPartsToString([...t]));
37
- }
38
- function f(t) {
39
- return t.replace(
1
+ import i from "typescript";
2
+ import { findPath as s } from "@arcgis/node-toolkit/file";
3
+ import { path as d } from "@arcgis/node-toolkit/path";
4
+ import { retrievePackageJson as u } from "@arcgis/node-toolkit/packageJson";
5
+ function h(e) {
6
+ return typeof e == "string" ? e : e.map((t) => t.kind === i.SyntaxKind.JSDocText ? t.text : g(t.getText())).join("");
7
+ }
8
+ function D(e) {
9
+ return e === void 0 ? void 0 : p(i.displayPartsToString([...e]));
10
+ }
11
+ function p(e) {
12
+ return e.replace(
40
13
  /\{@link(?:code|plain)?\s+([\s\S]*?)\}/gu,
41
- (e, o) => p(o)
14
+ (t, n) => c(n)
42
15
  );
43
16
  }
44
- function m(t) {
45
- const e = /^\{@link(?:code|plain)?\s+([\s\S]*?)\}$/u.exec(t)?.[1];
46
- return e === void 0 ? t : p(e);
17
+ function g(e) {
18
+ const t = /^\{@link(?:code|plain)?\s+([\s\S]*?)\}$/u.exec(e)?.[1];
19
+ return t === void 0 ? e : c(t);
47
20
  }
48
- function p(t) {
49
- const e = t.trim().replace(/^(\S+)\s+([/:#!.])/u, "$1$2"), o = e.indexOf("|");
50
- if (o !== -1)
51
- return e.slice(o + 1).trim() || e.slice(0, o).trim();
52
- const [n, ...i] = e.split(/\s+/u);
53
- return i.join(" ") || n;
21
+ function c(e) {
22
+ const t = e.trim().replace(/^(\S+)\s+([/:#!.])/u, "$1$2"), n = t.indexOf("|");
23
+ if (n !== -1)
24
+ return t.slice(n + 1).trim() || t.slice(0, n).trim();
25
+ const [r, ...a] = t.split(/\s+/u);
26
+ return a.join(" ") || r;
54
27
  }
55
- function R(t, e) {
56
- const o = a("package.json", t);
57
- return o === void 0 ? e : g(s.dirname(o)).name ?? e;
28
+ function S(e, t) {
29
+ const n = s("package.json", e);
30
+ return n === void 0 ? t : u(d.dirname(n)).name ?? t;
58
31
  }
59
- const r = {
32
+ const o = {
60
33
  excludedPackageNames: /* @__PURE__ */ new Set([
61
34
  "@arcgis/charts-components-react",
62
35
  "@arcgis/coding-components-react",
@@ -69,25 +42,22 @@ const r = {
69
42
  ignoreDeprecatedApis: ["getReactWrapperOptions"],
70
43
  ignoredDeprecationsByIncludes: ["React wrappers are not needed in React 19 or above"]
71
44
  };
72
- function J(t) {
73
- return t !== void 0 && r.excludedPackageNames.has(t);
45
+ function k(e) {
46
+ return e !== void 0 && o.excludedPackageNames.has(e);
74
47
  }
75
- function T(t) {
76
- return r.excludedDefinitionPathFragments.some(
77
- (e) => t.includes(e)
48
+ function P(e) {
49
+ return o.excludedDefinitionPathFragments.some(
50
+ (t) => e.includes(t)
78
51
  );
79
52
  }
80
- function E(t, e) {
81
- return r.ignoreDeprecatedApis.some((o) => o === t) || e != null && r.ignoredDeprecationsByIncludes.some((o) => e.includes(o));
53
+ function v(e, t) {
54
+ return o.ignoreDeprecatedApis.some((n) => n === e) || t != null && o.ignoredDeprecationsByIncludes.some((n) => t.includes(n));
82
55
  }
83
56
  export {
84
57
  v as a,
85
- R as b,
86
- E as c,
87
- k as d,
88
- T as e,
89
- w as f,
90
- P as g,
91
- y as p,
92
- J as s
58
+ h as b,
59
+ D as c,
60
+ P as d,
61
+ S as g,
62
+ k as s
93
63
  };