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

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,48 @@
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.20";
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")
12
+ throw new Error("Invalid deprecation audit JSON.");
13
+ return e;
14
+ }
15
+ function h() {
16
+ const o = c(".git");
17
+ if (o === void 0)
18
+ throw new Error("Unable to find a Git repository for the deprecation audit.");
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 };
21
+ }
22
+ function g(o, e) {
23
+ return p(s.relative(e, o));
24
+ }
25
+ function v(o, e, r, n) {
26
+ const a = o === "usages" ? "usage" : "definition";
27
+ process.stderr.write(
28
+ `Deprecations: ${e} ${a}${e === 1 ? "" : "s"} across ${r} file${r === 1 ? "" : "s"} from ${n} package${n === 1 ? "" : "s"}.
29
+ `
30
+ );
31
+ }
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}`);
40
+ }
41
+ export {
42
+ g as a,
43
+ $ as b,
44
+ w as c,
45
+ h as g,
46
+ v as p,
47
+ f as s
48
+ };
@@ -0,0 +1,222 @@
1
+ import t from "typescript";
2
+ import { findPath as k } from "@arcgis/node-toolkit/file";
3
+ import { toPosixPathSeparators as y, path as h } from "@arcgis/node-toolkit/path";
4
+ import { retrievePackageJson as v } from "@arcgis/node-toolkit/packageJson";
5
+ import { b as C, d as P } from "./cli.js";
6
+ function j(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 _(e, r = "dash") {
25
+ return e === void 0 || e === "field" || e === "method" || e === "function" ? "" : r === "parentheses" ? ` (${e})` : ` - ${e}`;
26
+ }
27
+ function G(e) {
28
+ if (e === void 0)
29
+ return {};
30
+ const r = w(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, s = i?.name === void 0 ? void 0 : O(i, i.name.text);
31
+ return {
32
+ ...r === void 0 ? {} : { kind: r },
33
+ ...s === void 0 ? {} : { memberOf: s }
34
+ };
35
+ }
36
+ function O(e, r) {
37
+ const o = [];
38
+ for (let i = e?.parent; i !== void 0; i = i.parent) {
39
+ if (t.isClassLike(i) || t.isInterfaceDeclaration(i) || t.isTypeLiteralNode(i))
40
+ return r;
41
+ t.isModuleDeclaration(i) && t.isIdentifier(i.name) && o.unshift(i.name.text);
42
+ }
43
+ return [...o, r].join(".");
44
+ }
45
+ function w(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))
49
+ return "field";
50
+ if (t.isMethodDeclaration(e) || t.isMethodSignature(e))
51
+ return "method";
52
+ if (t.isClassLike(e))
53
+ return "class";
54
+ if (t.isInterfaceDeclaration(e))
55
+ return "interface";
56
+ if (t.isTypeAliasDeclaration(e))
57
+ return "type";
58
+ if (t.isFunctionDeclaration(e))
59
+ return "function";
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))
63
+ return "namespace";
64
+ }
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 J = /* @__PURE__ */ new Map([
69
+ ["MapView", "arcgis-map"],
70
+ ["SceneView", "arcgis-scene"],
71
+ ["LinkChartView", "arcgis-link-chart"],
72
+ ["VideoView", "arcgis-video"]
73
+ ]), L = /* @__PURE__ */ new Set([
74
+ "MessageBundleLoader",
75
+ "createJSONLoader",
76
+ "fetchMessageBundle",
77
+ "messageBundle",
78
+ "normalizeMessageBundleLocale",
79
+ "registerMessageBundleLoader"
80
+ ]), A = /* @__PURE__ */ new Set([
81
+ "AreaMeasurement2D",
82
+ "AreaMeasurement3D",
83
+ "BasemapGallery",
84
+ "BasemapToggle",
85
+ "BatchAttributeForm",
86
+ "BinaryColorSizeSlider",
87
+ "ClassedColorSlider",
88
+ "ColorSlider",
89
+ "ColorSizeSlider",
90
+ "CoordinateConversion",
91
+ "Daylight",
92
+ "DirectLineMeasurement3D",
93
+ "DistanceMeasurement2D",
94
+ "Editor",
95
+ "FeatureForm",
96
+ "FeatureTable",
97
+ "GridControls",
98
+ "HeatmapSlider",
99
+ "Home",
100
+ "HistogramRangeSlider",
101
+ "LayerList",
102
+ "Legend",
103
+ "LineOfSight",
104
+ "Locate",
105
+ "NavigationToggle",
106
+ "OpacitySlider",
107
+ "OrientedImageryViewer",
108
+ "Print",
109
+ "ScaleBar",
110
+ "Search",
111
+ "Sketch",
112
+ "SketchLabelOptions",
113
+ "SketchTooltipOptions",
114
+ "Slice",
115
+ "SizeSlider",
116
+ "Slider",
117
+ "SnappingOptions",
118
+ "TableList",
119
+ "useLegacyCreateTools"
120
+ ]);
121
+ function $({
122
+ package: e,
123
+ name: r,
124
+ category: o,
125
+ memberOf: i,
126
+ module: s,
127
+ deprecated: u
128
+ }) {
129
+ if (o !== void 0)
130
+ return o;
131
+ const a = e.toLowerCase(), n = typeof u == "string" ? u.toLowerCase() : "";
132
+ return e === "@arcgis/core" && r === "ui" && [
133
+ "DOMContainer",
134
+ "DOMContainerProperties",
135
+ "MapView",
136
+ "MapViewProperties",
137
+ "SceneView",
138
+ "SceneViewProperties",
139
+ "LinkChartView",
140
+ "LinkChartViewProperties",
141
+ "VideoView",
142
+ "VideoViewProperties"
143
+ ].includes(i?.replace(/^__esri\./u, "") ?? "") ? "coreViews" : e === "@arcgis/core" && (A.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" && (L.has(r) || n.includes("widget translations")) ? "coreIntl" : a.includes("calcite") ? "calcite" : /^@arcgis\/.+components/u.test(a) ? "arcgisComponents" : e === "@arcgis/core" ? "arcgisCore" : a.startsWith("@arcgis/") ? "arcgisSupport" : C(e) ? "otherEsri" : "nonEsri";
144
+ }
145
+ function H(e, r) {
146
+ const o = `/node_modules/${r}/`, i = e.map(y).sort(
147
+ (s, u) => Number(u.includes(o)) - Number(s.includes(o)) || s.localeCompare(u)
148
+ );
149
+ for (const s of i) {
150
+ const u = s.lastIndexOf(o);
151
+ let a;
152
+ if (u !== -1)
153
+ a = s.slice(u + o.length);
154
+ else {
155
+ const n = [...s.matchAll(/\/(?:src|dist)(?=\/)/gu)];
156
+ if (n.length === 1)
157
+ a = s.slice(n[0].index + 1);
158
+ else {
159
+ const c = k("package.json", h.dirname(s));
160
+ if (c === void 0)
161
+ continue;
162
+ const d = h.dirname(c);
163
+ if (v(d).name !== r)
164
+ continue;
165
+ a = y(h.relative(d, s));
166
+ }
167
+ }
168
+ return a.startsWith("src/") ? V(a) : B(a);
169
+ }
170
+ }
171
+ function V(e) {
172
+ return y(e).replace(/^src\//u, "").replace(D, "");
173
+ }
174
+ function B(e) {
175
+ return y(e).replace(/^dist\//u, "").replace(D, "").replace(/^(components?\/[^/]+-[^/]+)\/customElement$/u, "$1");
176
+ }
177
+ const D = /\.(?:d\.)?(?:[cm]?ts|tsx)$/u;
178
+ function K(e, r) {
179
+ const o = Map.groupBy(e, (i) => $(r(i)));
180
+ return Object.keys(P).flatMap((i) => {
181
+ const s = o.get(i);
182
+ if (s === void 0)
183
+ return [];
184
+ const a = [...Map.groupBy(s, (n) => {
185
+ const c = r(n);
186
+ return T(c.package, c.module);
187
+ })].map(([n, c]) => {
188
+ const d = r(c[0]).package, S = [...Map.groupBy(c, (m) => {
189
+ const l = r(m);
190
+ return JSON.stringify([l.name, l.memberOf, l.kind]);
191
+ }).values()].map((m) => {
192
+ 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, b) => p.localeCompare(b));
193
+ return { name: l, reasons: g, items: m };
194
+ });
195
+ return S.sort((m, l) => {
196
+ const f = r(m.items[0]), g = r(l.items[0]);
197
+ return l.items.length - m.items.length || m.name.localeCompare(l.name) || (f.memberOf ?? "").localeCompare(g.memberOf ?? "") || (f.kind ?? "").localeCompare(g.kind ?? "");
198
+ }), { packageName: d, displayName: n, count: c.length, apis: S };
199
+ });
200
+ return a.sort(
201
+ (n, c) => c.count - n.count || n.packageName.localeCompare(c.packageName) || n.displayName.localeCompare(c.displayName)
202
+ ), [{ categoryName: i, count: s.length, packages: a }];
203
+ });
204
+ }
205
+ function T(e, r) {
206
+ return x(e, r) ? "DOM / Web platform" : e;
207
+ }
208
+ function x(e, r) {
209
+ return e === "typescript" && /^lib\/lib\.dom(?:$|[./])/u.test(r ?? "");
210
+ }
211
+ export {
212
+ H as a,
213
+ j as b,
214
+ $ as c,
215
+ _ as d,
216
+ G as e,
217
+ O as f,
218
+ K as g,
219
+ J as h,
220
+ T as i,
221
+ V as s
222
+ };