@arcgis/codemod 6.0.0-next.1 → 6.0.0-next.10

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,44 @@
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.10";
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")
9
+ throw new Error("Invalid deprecation audit JSON.");
10
+ return t;
11
+ }
12
+ function w() {
13
+ const r = a(".git");
14
+ if (r === void 0)
15
+ 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 };
18
+ }
19
+ function $(r, t) {
20
+ return c(n.relative(t, r));
21
+ }
22
+ function m(r, t, e, o) {
23
+ const i = r === "usages" ? "usage" : "definition";
24
+ process.stderr.write(
25
+ `Deprecations: ${t} ${i}${t === 1 ? "" : "s"} across ${e} file${e === 1 ? "" : "s"} from ${o} package${o === 1 ? "" : "s"}.
26
+ `
27
+ );
28
+ }
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}`);
37
+ }
38
+ export {
39
+ $ as a,
40
+ g as b,
41
+ w as g,
42
+ m as p,
43
+ l as s
44
+ };
@@ -0,0 +1,203 @@
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";
6
+ function _(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;
23
+ }
24
+ function G(e, r = "dash") {
25
+ return e === void 0 || e === "field" || e === "method" || e === "function" ? "" : r === "parentheses" ? ` (${e})` : ` - ${e}`;
26
+ }
27
+ function J(e) {
28
+ if (e === void 0)
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);
31
+ return {
32
+ ...r === void 0 ? {} : { kind: r },
33
+ ...s === void 0 ? {} : { memberOf: s }
34
+ };
35
+ }
36
+ function L(e, r) {
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))
40
+ return r;
41
+ i.isModuleDeclaration(t) && i.isIdentifier(t.name) && o.unshift(t.name.text);
42
+ }
43
+ return [...o, r].join(".");
44
+ }
45
+ function P(e) {
46
+ if (i.isPropertyDeclaration(e) || i.isPropertySignature(e) || i.isGetAccessorDeclaration(e) || i.isSetAccessorDeclaration(e))
47
+ return "field";
48
+ if (i.isMethodDeclaration(e) || i.isMethodSignature(e))
49
+ return "method";
50
+ if (i.isClassLike(e))
51
+ return "class";
52
+ if (i.isInterfaceDeclaration(e))
53
+ return "interface";
54
+ if (i.isTypeAliasDeclaration(e))
55
+ return "type";
56
+ if (i.isFunctionDeclaration(e))
57
+ return "function";
58
+ if (i.isVariableDeclaration(e))
59
+ return "variable";
60
+ if (i.isModuleDeclaration(e))
61
+ return "namespace";
62
+ }
63
+ const C = /* @__PURE__ */ new Map([
64
+ ["MapView", "arcgis-map"],
65
+ ["SceneView", "arcgis-scene"],
66
+ ["LinkChartView", "arcgis-link-chart"],
67
+ ["VideoView", "arcgis-video"]
68
+ ]), V = /* @__PURE__ */ new Set([
69
+ "MessageBundleLoader",
70
+ "createJSONLoader",
71
+ "fetchMessageBundle",
72
+ "messageBundle",
73
+ "normalizeMessageBundleLocale",
74
+ "registerMessageBundleLoader"
75
+ ]), $ = /* @__PURE__ */ new Set([
76
+ "AreaMeasurement2D",
77
+ "AreaMeasurement3D",
78
+ "BasemapGallery",
79
+ "BasemapToggle",
80
+ "BatchAttributeForm",
81
+ "BinaryColorSizeSlider",
82
+ "ClassedColorSlider",
83
+ "ColorSlider",
84
+ "ColorSizeSlider",
85
+ "CoordinateConversion",
86
+ "Daylight",
87
+ "DirectLineMeasurement3D",
88
+ "DistanceMeasurement2D",
89
+ "Editor",
90
+ "FeatureForm",
91
+ "FeatureTable",
92
+ "GridControls",
93
+ "HeatmapSlider",
94
+ "Home",
95
+ "HistogramRangeSlider",
96
+ "LayerList",
97
+ "Legend",
98
+ "LineOfSight",
99
+ "Locate",
100
+ "NavigationToggle",
101
+ "OpacitySlider",
102
+ "OrientedImageryViewer",
103
+ "Print",
104
+ "ScaleBar",
105
+ "Search",
106
+ "Sketch",
107
+ "SketchLabelOptions",
108
+ "SketchTooltipOptions",
109
+ "Slice",
110
+ "SizeSlider",
111
+ "Slider",
112
+ "SnappingOptions",
113
+ "TableList",
114
+ "useLegacyCreateTools"
115
+ ]);
116
+ function B({
117
+ package: e,
118
+ name: r,
119
+ category: o,
120
+ memberOf: t,
121
+ module: s,
122
+ deprecated: u
123
+ }) {
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" && [
126
+ "DOMContainer",
127
+ "DOMContainerProperties",
128
+ "MapView",
129
+ "MapViewProperties",
130
+ "SceneView",
131
+ "SceneViewProperties",
132
+ "LinkChartView",
133
+ "LinkChartViewProperties",
134
+ "VideoView",
135
+ "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";
137
+ }
138
+ function H(e, r) {
139
+ return A(x(e, r));
140
+ }
141
+ function A(e) {
142
+ return e?.replace(/^(components?\/[^/]+-[^/]+)\/customElement$/u, "$1");
143
+ }
144
+ const S = /^(?:src|dist)\//u;
145
+ 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, "");
155
+ }
156
+ const n = w("package.json", f.dirname(s));
157
+ if (n === void 0)
158
+ continue;
159
+ const a = f.dirname(n);
160
+ if (k(a).name === r)
161
+ return y(f.relative(a, s)).replace(S, "").replace(g, "");
162
+ }
163
+ }
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)
170
+ return [];
171
+ const c = [...Map.groupBy(s, (n) => {
172
+ const a = r(n);
173
+ 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 };
181
+ });
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 };
183
+ });
184
+ return c.sort((n, a) => a.count - n.count || n.packageName.localeCompare(a.packageName)), [{ categoryName: t, count: s.length, packages: c }];
185
+ });
186
+ }
187
+ function T(e, r) {
188
+ return E(e, r) ? "DOM / Web platform" : e;
189
+ }
190
+ function E(e, r) {
191
+ return e === "typescript" && /^lib\/lib\.dom(?:$|[./])/u.test(r ?? "");
192
+ }
193
+ export {
194
+ H as a,
195
+ _ as b,
196
+ B as c,
197
+ G as d,
198
+ J as e,
199
+ L as f,
200
+ I as g,
201
+ C as h,
202
+ T as i
203
+ };