@arcgis/codemod 5.2.0-next.129 → 5.2.0-next.130
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.
- package/dist/chunks/hardcodedBehavior.js +93 -0
- package/dist/chunks/index.js +15 -14
- package/dist/chunks/index2.js +6 -5
- package/package.json +4 -5
- package/dist/chunks/codeowners.js +0 -118
|
@@ -0,0 +1,93 @@
|
|
|
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(
|
|
40
|
+
/\{@link(?:code|plain)?\s+([\s\S]*?)\}/gu,
|
|
41
|
+
(e, o) => p(o)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
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);
|
|
47
|
+
}
|
|
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;
|
|
54
|
+
}
|
|
55
|
+
function R(t, e) {
|
|
56
|
+
const o = a("package.json", t);
|
|
57
|
+
return o === void 0 ? e : g(s.dirname(o)).name ?? e;
|
|
58
|
+
}
|
|
59
|
+
const r = {
|
|
60
|
+
excludedPackageNames: /* @__PURE__ */ new Set([
|
|
61
|
+
"@arcgis/charts-components-react",
|
|
62
|
+
"@arcgis/coding-components-react",
|
|
63
|
+
"@arcgis/components-build-utils",
|
|
64
|
+
"@arcgis/map-components-react",
|
|
65
|
+
"@arcgis/portal-components-react",
|
|
66
|
+
"@arcgis-test/lit-components-react"
|
|
67
|
+
]),
|
|
68
|
+
excludedDefinitionPathFragments: ["test-package"],
|
|
69
|
+
ignoreDeprecatedApis: ["getReactWrapperOptions"],
|
|
70
|
+
ignoredDeprecationsByIncludes: ["React wrappers are not needed in React 19 or above"]
|
|
71
|
+
};
|
|
72
|
+
function J(t) {
|
|
73
|
+
return t !== void 0 && r.excludedPackageNames.has(t);
|
|
74
|
+
}
|
|
75
|
+
function T(t) {
|
|
76
|
+
return r.excludedDefinitionPathFragments.some(
|
|
77
|
+
(e) => t.includes(e)
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
function E(t, e) {
|
|
81
|
+
return r.ignoreDeprecatedApis.some((o) => o === t) || e != null && r.ignoredDeprecationsByIncludes.some((o) => e.includes(o));
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
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
|
|
93
|
+
};
|
package/dist/chunks/index.js
CHANGED
|
@@ -35,13 +35,14 @@ import { f as y } from "./log.js";
|
|
|
35
35
|
import { path as d, toPosixPathSeparators as H } from "@arcgis/node-toolkit/path";
|
|
36
36
|
import { log as q } from "@arcgis/toolkit/log";
|
|
37
37
|
import f from "typescript";
|
|
38
|
-
import { g as D,
|
|
39
|
-
import { f as
|
|
38
|
+
import { g as D, a as G, s as K, p as V, b as X, c as Y, d as Z } from "./hardcodedBehavior.js";
|
|
39
|
+
import { f as B, c as T, g as ee, i as te } from "./format.js";
|
|
40
40
|
import { styleText as w } from "node:util";
|
|
41
|
+
import { loadCodeowners as oe } from "@arcgis/node-toolkit/codeowners";
|
|
41
42
|
function ne(t, o) {
|
|
42
43
|
if (o === "json") {
|
|
43
44
|
const e = D();
|
|
44
|
-
process.stdout.write(`${le(t,
|
|
45
|
+
process.stdout.write(`${le(t, oe(), e)}
|
|
45
46
|
`);
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
@@ -82,7 +83,7 @@ function L(t) {
|
|
|
82
83
|
const o = [...t].flatMap(
|
|
83
84
|
([e, n]) => n.map((r) => ({ ...r, packageName: e }))
|
|
84
85
|
);
|
|
85
|
-
return
|
|
86
|
+
return ee(o, ({ packageName: e, usage: n }) => ({
|
|
86
87
|
packageName: e,
|
|
87
88
|
api: n.name,
|
|
88
89
|
reason: n.reason
|
|
@@ -114,7 +115,7 @@ function le(t, o, e = D()) {
|
|
|
114
115
|
return JSON.stringify(E(t, o, e), void 0, 2);
|
|
115
116
|
}
|
|
116
117
|
function ue(t, o = D()) {
|
|
117
|
-
return
|
|
118
|
+
return B(E(t, void 0, o));
|
|
118
119
|
}
|
|
119
120
|
function E(t, o, e) {
|
|
120
121
|
const n = L(t);
|
|
@@ -144,7 +145,7 @@ function E(t, o, e) {
|
|
|
144
145
|
package: a,
|
|
145
146
|
api: s.usage.name,
|
|
146
147
|
reason: s.usage.reason ?? null,
|
|
147
|
-
file:
|
|
148
|
+
file: G(s.sourceFileName, e.repositoryRoot),
|
|
148
149
|
line: s.usage.line,
|
|
149
150
|
column: s.usage.column,
|
|
150
151
|
codeowners: o?.getOwners(s.sourceFileName) ?? []
|
|
@@ -152,7 +153,7 @@ function E(t, o, e) {
|
|
|
152
153
|
)
|
|
153
154
|
};
|
|
154
155
|
}
|
|
155
|
-
async function
|
|
156
|
+
async function Me(t, o) {
|
|
156
157
|
await Q(
|
|
157
158
|
{
|
|
158
159
|
meta: {
|
|
@@ -179,7 +180,7 @@ function fe(t, o) {
|
|
|
179
180
|
for (const c of t) {
|
|
180
181
|
var s = [];
|
|
181
182
|
try {
|
|
182
|
-
if (
|
|
183
|
+
if (K(c.packageJson?.contents.name)) {
|
|
183
184
|
const N = c.packageJson?.filePath;
|
|
184
185
|
N !== void 0 && !n.has(N) && (n.add(N), q(
|
|
185
186
|
"warn",
|
|
@@ -216,7 +217,7 @@ function fe(t, o) {
|
|
|
216
217
|
const a = me(e, o);
|
|
217
218
|
ne(a, o.outputFormat);
|
|
218
219
|
const i = [...a.values()].flat();
|
|
219
|
-
|
|
220
|
+
V(
|
|
220
221
|
"usages",
|
|
221
222
|
i.length,
|
|
222
223
|
new Set(i.map(({ sourceFileName: c }) => c)).size,
|
|
@@ -328,7 +329,7 @@ function ye(t) {
|
|
|
328
329
|
}
|
|
329
330
|
function O(t) {
|
|
330
331
|
const o = t?.find(({ name: e }) => e === "deprecated");
|
|
331
|
-
return o === void 0 ? void 0 :
|
|
332
|
+
return o === void 0 ? void 0 : Z(o.text);
|
|
332
333
|
}
|
|
333
334
|
function ke(t, o, e) {
|
|
334
335
|
try {
|
|
@@ -354,7 +355,7 @@ function Se(t, o) {
|
|
|
354
355
|
}
|
|
355
356
|
}
|
|
356
357
|
function z(t, o, e) {
|
|
357
|
-
if (
|
|
358
|
+
if (Y(e.name, e.reason))
|
|
358
359
|
return;
|
|
359
360
|
const { line: n, character: r } = o.getLineAndCharacterOfPosition(e.start);
|
|
360
361
|
t.set(`${e.start}:${e.length}`, {
|
|
@@ -366,7 +367,7 @@ function z(t, o, e) {
|
|
|
366
367
|
function U(t, o, e) {
|
|
367
368
|
return t.some((n) => e !== void 0 && k(n, e)) ? !1 : !o || t.some((n) => {
|
|
368
369
|
const r = W(n);
|
|
369
|
-
return r === void 0 ? e === void 0 || !k(n, e) :
|
|
370
|
+
return r === void 0 ? e === void 0 || !k(n, e) : te(r);
|
|
370
371
|
});
|
|
371
372
|
}
|
|
372
373
|
function W(t) {
|
|
@@ -386,7 +387,7 @@ function Pe(t, o = [], e) {
|
|
|
386
387
|
const a = o.find(({ root: c }) => k(n, c));
|
|
387
388
|
if (a !== void 0)
|
|
388
389
|
return a.name;
|
|
389
|
-
const i = d.dirname(y(n)), s =
|
|
390
|
+
const i = d.dirname(y(n)), s = X(d.dirname(n), i);
|
|
390
391
|
if (s !== i)
|
|
391
392
|
return s;
|
|
392
393
|
if (e === void 0)
|
|
@@ -395,7 +396,7 @@ function Pe(t, o = [], e) {
|
|
|
395
396
|
return p < 1 ? d.dirname(y(n)) : u.slice(0, p * 2).join("/");
|
|
396
397
|
}
|
|
397
398
|
export {
|
|
398
|
-
|
|
399
|
+
Me as auditDeprecatedUsages,
|
|
399
400
|
pe as collectDeprecatedApiUsages,
|
|
400
401
|
Pe as getDeprecationOriginLabel,
|
|
401
402
|
W as getNodeModulesPackageName,
|
package/dist/chunks/index2.js
CHANGED
|
@@ -36,8 +36,9 @@ import P from "typescript";
|
|
|
36
36
|
import { f as g } from "./log.js";
|
|
37
37
|
import { r as v } from "./cli.js";
|
|
38
38
|
import { c as x } from "./useProjectInstance.js";
|
|
39
|
-
import { g as C, s as T, e as R, a as y, b, p as j,
|
|
40
|
-
|
|
39
|
+
import { g as C, s as T, e as R, a as y, b, p as j, f as E } from "./hardcodedBehavior.js";
|
|
40
|
+
import { loadCodeowners as F } from "@arcgis/node-toolkit/codeowners";
|
|
41
|
+
async function V(e, o) {
|
|
41
42
|
await v(
|
|
42
43
|
{
|
|
43
44
|
meta: { needsTypeInformation: !0, needsFooter: !1 },
|
|
@@ -105,7 +106,7 @@ function z(e, o) {
|
|
|
105
106
|
a.set(`${p}:${n.getWidth(e)}`, {
|
|
106
107
|
package: o,
|
|
107
108
|
name: n.getText(e),
|
|
108
|
-
reason: c.comment === void 0 ? void 0 :
|
|
109
|
+
reason: c.comment === void 0 ? void 0 : E(c.comment),
|
|
109
110
|
sourceFileName: e.fileName,
|
|
110
111
|
line: r + 1,
|
|
111
112
|
column: m + 1
|
|
@@ -119,7 +120,7 @@ function A(e) {
|
|
|
119
120
|
return e.name;
|
|
120
121
|
}
|
|
121
122
|
function I(e, o) {
|
|
122
|
-
const a =
|
|
123
|
+
const a = F(), s = {
|
|
123
124
|
kind: "definitions",
|
|
124
125
|
repository: o.repository,
|
|
125
126
|
ref: o.ref,
|
|
@@ -137,6 +138,6 @@ function I(e, o) {
|
|
|
137
138
|
`);
|
|
138
139
|
}
|
|
139
140
|
export {
|
|
140
|
-
|
|
141
|
+
V as auditDeprecatedDefinitions,
|
|
141
142
|
z as collectDeprecatedApiDefinitions
|
|
142
143
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/codemod",
|
|
3
|
-
"version": "5.2.0-next.
|
|
3
|
+
"version": "5.2.0-next.130",
|
|
4
4
|
"description": "A codemod toolkit for updating and modernizing ArcGIS Maps SDK for JavaScript codebases.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -11,12 +11,11 @@
|
|
|
11
11
|
],
|
|
12
12
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@arcgis/api-extractor": "5.2.0-next.
|
|
15
|
-
"@arcgis/node-toolkit": "5.2.0-next.
|
|
16
|
-
"@arcgis/toolkit": "5.2.0-next.
|
|
14
|
+
"@arcgis/api-extractor": "5.2.0-next.130",
|
|
15
|
+
"@arcgis/node-toolkit": "5.2.0-next.130",
|
|
16
|
+
"@arcgis/toolkit": "5.2.0-next.130",
|
|
17
17
|
"@commander-js/extra-typings": "^15.0.0",
|
|
18
18
|
"commander": "^15.0.0",
|
|
19
|
-
"picomatch": "^4.0.4",
|
|
20
19
|
"tinyglobby": "~0.2.17",
|
|
21
20
|
"ts-morph": "^28.0.0",
|
|
22
21
|
"tslib": "^2.8.1",
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { findPath as u } from "@arcgis/node-toolkit/file";
|
|
2
|
-
import { path as s, toPosixPathSeparators as l } from "@arcgis/node-toolkit/path";
|
|
3
|
-
import { collectOutputSync as d } from "@arcgis/node-toolkit/shell";
|
|
4
|
-
import m from "typescript";
|
|
5
|
-
import { retrievePackageJson as f } from "@arcgis/node-toolkit/packageJson";
|
|
6
|
-
import { readFileSync as h } from "node:fs";
|
|
7
|
-
import x from "picomatch";
|
|
8
|
-
function E() {
|
|
9
|
-
const e = u(".git");
|
|
10
|
-
if (e === void 0)
|
|
11
|
-
throw new Error("Unable to find a Git repository for the deprecation audit.");
|
|
12
|
-
const t = s.dirname(e), r = d("git", ["remote", "get-url", "origin"], { cwd: t }), n = d("git", ["rev-parse", "HEAD"], { cwd: t });
|
|
13
|
-
return { repository: S(r), repositoryRoot: t, ref: n };
|
|
14
|
-
}
|
|
15
|
-
function O(e, t) {
|
|
16
|
-
return l(s.relative(t, e));
|
|
17
|
-
}
|
|
18
|
-
function W(e, t, r, n) {
|
|
19
|
-
const o = e === "usages" ? "usage" : "definition";
|
|
20
|
-
process.stderr.write(
|
|
21
|
-
`Deprecations: ${t} ${o}${t === 1 ? "" : "s"} across ${r} file${r === 1 ? "" : "s"} from ${n} package${n === 1 ? "" : "s"}.
|
|
22
|
-
`
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
function S(e) {
|
|
26
|
-
const t = e.replace(/\.git$/u, "");
|
|
27
|
-
if (t.startsWith("http://") || t.startsWith("https://"))
|
|
28
|
-
return new URL(t).href.replace(/^https?:\/\//u, "").replace(/\/$/u, "");
|
|
29
|
-
const r = /^(?:ssh:\/\/)?git@([^/:]+)[:/](.+)$/u.exec(t);
|
|
30
|
-
if (r !== null)
|
|
31
|
-
return `${r[1]}/${r[2]}`;
|
|
32
|
-
throw new Error(`Unsupported Git remote URL: ${e}`);
|
|
33
|
-
}
|
|
34
|
-
function b(e) {
|
|
35
|
-
return typeof e == "string" ? e : e.map((t) => t.kind === m.SyntaxKind.JSDocText ? t.text : w(t.getText())).join("");
|
|
36
|
-
}
|
|
37
|
-
function F(e) {
|
|
38
|
-
return e === void 0 ? void 0 : $(m.displayPartsToString([...e]));
|
|
39
|
-
}
|
|
40
|
-
function $(e) {
|
|
41
|
-
return e.replace(
|
|
42
|
-
/\{@link(?:code|plain)?\s+([\s\S]*?)\}/gu,
|
|
43
|
-
(t, r) => g(r)
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
function w(e) {
|
|
47
|
-
const t = /^\{@link(?:code|plain)?\s+([\s\S]*?)\}$/u.exec(e)?.[1];
|
|
48
|
-
return t === void 0 ? e : g(t);
|
|
49
|
-
}
|
|
50
|
-
function g(e) {
|
|
51
|
-
const t = e.trim().replace(/^(\S+)\s+([/:#!.])/u, "$1$2"), r = t.indexOf("|");
|
|
52
|
-
if (r !== -1)
|
|
53
|
-
return t.slice(r + 1).trim() || t.slice(0, r).trim();
|
|
54
|
-
const [n, ...o] = t.split(/\s+/u);
|
|
55
|
-
return o.join(" ") || n;
|
|
56
|
-
}
|
|
57
|
-
function L(e, t) {
|
|
58
|
-
const r = u("package.json", e);
|
|
59
|
-
return r === void 0 ? t : f(s.dirname(r)).name ?? t;
|
|
60
|
-
}
|
|
61
|
-
const c = {
|
|
62
|
-
excludedPackageNames: /* @__PURE__ */ new Set([
|
|
63
|
-
"@arcgis/charts-components-react",
|
|
64
|
-
"@arcgis/coding-components-react",
|
|
65
|
-
"@arcgis/components-build-utils",
|
|
66
|
-
"@arcgis/map-components-react",
|
|
67
|
-
"@arcgis/portal-components-react",
|
|
68
|
-
"@arcgis-test/lit-components-react"
|
|
69
|
-
]),
|
|
70
|
-
excludedDefinitionPathFragments: ["test-package"],
|
|
71
|
-
ignoreDeprecatedApis: ["getReactWrapperOptions"],
|
|
72
|
-
ignoredDeprecationsByIncludes: ["React wrappers are not needed in React 19 or above"]
|
|
73
|
-
};
|
|
74
|
-
function U(e) {
|
|
75
|
-
return e !== void 0 && c.excludedPackageNames.has(e);
|
|
76
|
-
}
|
|
77
|
-
function C(e) {
|
|
78
|
-
return c.excludedDefinitionPathFragments.some(
|
|
79
|
-
(t) => e.includes(t)
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
function I(e, t) {
|
|
83
|
-
return c.ignoreDeprecatedApis.some((r) => r === e) || t != null && c.ignoredDeprecationsByIncludes.some((r) => t.includes(r));
|
|
84
|
-
}
|
|
85
|
-
function j() {
|
|
86
|
-
const e = u(".github/CODEOWNERS");
|
|
87
|
-
return e === void 0 ? void 0 : v(h(e, "utf8"), s.dirname(s.dirname(e)));
|
|
88
|
-
}
|
|
89
|
-
function v(e, t) {
|
|
90
|
-
const r = e.split(/\r?\n/u).map((n) => n.trim()).filter((n) => n !== "" && !n.startsWith("#")).map((n) => {
|
|
91
|
-
const [o, ...a] = n.split(/\s+/u), i = o.startsWith("/") ? o.slice(1) : o, p = i.includes("/") ? i : `**/${i}`;
|
|
92
|
-
return {
|
|
93
|
-
matches: x([p, `${p.replace(/\/$/u, "")}/**`], { dot: !0 }),
|
|
94
|
-
owners: a
|
|
95
|
-
};
|
|
96
|
-
});
|
|
97
|
-
return {
|
|
98
|
-
getOwners(n) {
|
|
99
|
-
const o = l(s.relative(t, n));
|
|
100
|
-
let a = [];
|
|
101
|
-
for (const i of r)
|
|
102
|
-
i.matches(o) && (a = i.owners);
|
|
103
|
-
return a;
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
export {
|
|
108
|
-
O as a,
|
|
109
|
-
L as b,
|
|
110
|
-
I as c,
|
|
111
|
-
F as d,
|
|
112
|
-
C as e,
|
|
113
|
-
b as f,
|
|
114
|
-
E as g,
|
|
115
|
-
j as l,
|
|
116
|
-
W as p,
|
|
117
|
-
U as s
|
|
118
|
-
};
|