@arcgis/codemod 6.0.0-next.2 → 6.0.0-next.4
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/classification.js +232 -0
- package/dist/chunks/cli.js +71 -57
- package/dist/chunks/format.js +109 -180
- package/dist/chunks/hardcodedBehavior.js +38 -68
- package/dist/chunks/index.js +340 -285
- package/dist/chunks/index2.js +110 -93
- package/dist/chunks/sync.js +39 -40
- package/package.json +4 -4
package/dist/chunks/index2.js
CHANGED
|
@@ -1,143 +1,160 @@
|
|
|
1
|
-
var
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var N = (a, o) => (o = Symbol[a]) ? o : /* @__PURE__ */ Symbol.for("Symbol." + a), h = (a) => {
|
|
2
|
+
throw TypeError(a);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
4
|
+
var D = (a, o, t) => {
|
|
5
5
|
if (o != null) {
|
|
6
|
-
typeof o != "object" && typeof o != "function" &&
|
|
7
|
-
var
|
|
8
|
-
|
|
6
|
+
typeof o != "object" && typeof o != "function" && h("Object expected");
|
|
7
|
+
var c, e;
|
|
8
|
+
t && (c = o[N("asyncDispose")]), c === void 0 && (c = o[N("dispose")], t && (e = c)), typeof c != "function" && h("Object not disposable"), e && (c = function() {
|
|
9
9
|
try {
|
|
10
|
-
|
|
11
|
-
} catch (
|
|
12
|
-
return Promise.reject(
|
|
10
|
+
e.call(this);
|
|
11
|
+
} catch (i) {
|
|
12
|
+
return Promise.reject(i);
|
|
13
13
|
}
|
|
14
|
-
}),
|
|
15
|
-
} else
|
|
14
|
+
}), a.push([t, c, o]);
|
|
15
|
+
} else t && a.push([t]);
|
|
16
16
|
return o;
|
|
17
|
-
}, w = (
|
|
18
|
-
var
|
|
19
|
-
return
|
|
20
|
-
},
|
|
21
|
-
for (;
|
|
17
|
+
}, w = (a, o, t) => {
|
|
18
|
+
var c = typeof SuppressedError == "function" ? SuppressedError : function(s, r, m, d) {
|
|
19
|
+
return d = Error(m), d.name = "SuppressedError", d.error = s, d.suppressed = r, d;
|
|
20
|
+
}, e = (s) => o = t ? new c(s, o, "An error was suppressed during disposal") : (t = !0, s), i = (s) => {
|
|
21
|
+
for (; s = a.pop(); )
|
|
22
22
|
try {
|
|
23
|
-
var
|
|
24
|
-
if (
|
|
25
|
-
} catch (
|
|
26
|
-
|
|
23
|
+
var r = s[1] && s[1].call(s[2]);
|
|
24
|
+
if (s[0]) return Promise.resolve(r).then(i, (m) => (e(m), i()));
|
|
25
|
+
} catch (m) {
|
|
26
|
+
e(m);
|
|
27
27
|
}
|
|
28
|
-
if (
|
|
28
|
+
if (t) throw o;
|
|
29
29
|
};
|
|
30
|
-
return
|
|
30
|
+
return i();
|
|
31
31
|
};
|
|
32
|
-
import { log as
|
|
33
|
-
import { path as
|
|
34
|
-
import { styleText as
|
|
32
|
+
import { log as y } from "@arcgis/toolkit/log";
|
|
33
|
+
import { path as $ } from "@arcgis/node-toolkit/path";
|
|
34
|
+
import { styleText as b } from "node:util";
|
|
35
35
|
import P from "typescript";
|
|
36
|
-
import { f as
|
|
37
|
-
import { r as
|
|
38
|
-
import { c as
|
|
39
|
-
import { g as
|
|
40
|
-
import { loadCodeowners as
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
import { f as u } from "./log.js";
|
|
37
|
+
import { r as x } from "./cli.js";
|
|
38
|
+
import { c as J } from "./useProjectInstance.js";
|
|
39
|
+
import { g as O, e as S, a as v, b as C, p as T, d as A, f as K, h as R, j } from "./classification.js";
|
|
40
|
+
import { loadCodeowners as M } from "@arcgis/node-toolkit/codeowners";
|
|
41
|
+
import { s as E, d as z, g as F, b as I } from "./hardcodedBehavior.js";
|
|
42
|
+
async function oe(a, o) {
|
|
43
|
+
await x(
|
|
43
44
|
{
|
|
44
45
|
meta: { needsTypeInformation: !0, needsFooter: !1 },
|
|
45
|
-
run(
|
|
46
|
-
|
|
46
|
+
run(t) {
|
|
47
|
+
L(t, o);
|
|
47
48
|
}
|
|
48
49
|
},
|
|
49
50
|
"deprecations audit-definitions",
|
|
50
|
-
|
|
51
|
+
a
|
|
51
52
|
);
|
|
52
53
|
}
|
|
53
|
-
function
|
|
54
|
-
const
|
|
55
|
-
for (const
|
|
56
|
-
var
|
|
54
|
+
function L(a, o) {
|
|
55
|
+
const t = [], c = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Set(), i = O();
|
|
56
|
+
for (const n of a) {
|
|
57
|
+
var s = [];
|
|
57
58
|
try {
|
|
58
|
-
if (
|
|
59
|
-
const
|
|
60
|
-
|
|
59
|
+
if (E(n.packageJson?.contents.name)) {
|
|
60
|
+
const p = n.packageJson?.filePath;
|
|
61
|
+
p !== void 0 && !e.has(p) && (e.add(p), y(
|
|
61
62
|
"warn",
|
|
62
|
-
|
|
63
|
-
`Skipping excluded package \`${
|
|
63
|
+
u(p),
|
|
64
|
+
`Skipping excluded package \`${n.packageJson?.contents.name ?? n.cwd}\`.`
|
|
64
65
|
));
|
|
65
66
|
continue;
|
|
66
67
|
}
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
for (const
|
|
70
|
-
if (
|
|
71
|
-
|
|
68
|
+
const l = D(s, J(n, !1));
|
|
69
|
+
const f = n.packageJson?.contents.name ?? u(n.cwd);
|
|
70
|
+
for (const p of l.getCodemodFiles()) {
|
|
71
|
+
if (z(
|
|
72
|
+
S(p.compilerNode.fileName, i.repositoryRoot)
|
|
72
73
|
))
|
|
73
74
|
continue;
|
|
74
|
-
const
|
|
75
|
-
|
|
75
|
+
const g = $.dirname(p.compilerNode.fileName), k = c.get(g) ?? F(g, f);
|
|
76
|
+
c.set(g, k), t.push(...Q(p.compilerNode, k));
|
|
76
77
|
}
|
|
77
|
-
} catch (
|
|
78
|
-
var
|
|
78
|
+
} catch (r) {
|
|
79
|
+
var m = r, d = !0;
|
|
79
80
|
} finally {
|
|
80
|
-
w(
|
|
81
|
+
w(s, m, d);
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
if (o)
|
|
84
|
-
|
|
85
|
+
q(t, i);
|
|
85
86
|
else
|
|
86
|
-
for (const
|
|
87
|
-
const
|
|
87
|
+
for (const n of t) {
|
|
88
|
+
const l = b(
|
|
88
89
|
"blue",
|
|
89
|
-
`${
|
|
90
|
-
)
|
|
91
|
-
|
|
90
|
+
`${u(n.sourceFileName)}:${n.line}:${n.column}`
|
|
91
|
+
), f = v({
|
|
92
|
+
api: n.name,
|
|
93
|
+
memberOf: n.memberOf,
|
|
94
|
+
apiKind: n.apiKind
|
|
95
|
+
}), p = C(n.apiKind, "parentheses");
|
|
96
|
+
y("warn", l, `\`${f}\`${p} is deprecated.${n.reason ? ` ${n.reason}` : ""}`);
|
|
92
97
|
}
|
|
93
|
-
|
|
98
|
+
T(
|
|
94
99
|
"definitions",
|
|
95
|
-
|
|
96
|
-
new Set(
|
|
97
|
-
new Set(
|
|
100
|
+
t.length,
|
|
101
|
+
new Set(t.map(({ sourceFileName: n }) => n)).size,
|
|
102
|
+
new Set(t.map(({ package: n }) => n)).size
|
|
98
103
|
);
|
|
99
104
|
}
|
|
100
|
-
function
|
|
101
|
-
const
|
|
102
|
-
function
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
-
const
|
|
106
|
-
|
|
105
|
+
function Q(a, o) {
|
|
106
|
+
const t = /* @__PURE__ */ new Map(), c = A([a.fileName], o);
|
|
107
|
+
function e(i) {
|
|
108
|
+
const s = P.getJSDocDeprecatedTag(i), r = W(i);
|
|
109
|
+
if (s !== void 0 && r !== void 0) {
|
|
110
|
+
const m = r.getStart(a), { line: d, character: n } = a.getLineAndCharacterOfPosition(m);
|
|
111
|
+
t.set(`${m}:${r.getWidth(a)}`, {
|
|
107
112
|
package: o,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
module: c,
|
|
114
|
+
name: j(i, r.getText(a)),
|
|
115
|
+
...R(i),
|
|
116
|
+
reason: s.comment === void 0 ? void 0 : I(s.comment),
|
|
117
|
+
sourceFileName: a.fileName,
|
|
118
|
+
line: d + 1,
|
|
119
|
+
column: n + 1
|
|
113
120
|
});
|
|
114
121
|
}
|
|
115
|
-
P.forEachChild(
|
|
122
|
+
P.forEachChild(i, e);
|
|
116
123
|
}
|
|
117
|
-
return
|
|
124
|
+
return e(a), [...t.values()].sort((i, s) => i.line - s.line || i.column - s.column);
|
|
118
125
|
}
|
|
119
|
-
function
|
|
120
|
-
return
|
|
126
|
+
function W(a) {
|
|
127
|
+
return a.name;
|
|
121
128
|
}
|
|
122
|
-
function
|
|
123
|
-
const
|
|
129
|
+
function q(a, o) {
|
|
130
|
+
const t = M(), c = {
|
|
124
131
|
kind: "definitions",
|
|
125
132
|
repository: o.repository,
|
|
126
133
|
ref: o.ref,
|
|
127
|
-
findings:
|
|
128
|
-
package:
|
|
129
|
-
api:
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
findings: a.map((e) => ({
|
|
135
|
+
package: e.package,
|
|
136
|
+
api: e.name,
|
|
137
|
+
module: e.module,
|
|
138
|
+
apiKind: e.apiKind,
|
|
139
|
+
memberOf: e.memberOf,
|
|
140
|
+
category: K({
|
|
141
|
+
package: e.package,
|
|
142
|
+
api: e.name,
|
|
143
|
+
memberOf: e.memberOf,
|
|
144
|
+
module: e.module,
|
|
145
|
+
reason: e.reason ?? null
|
|
146
|
+
}),
|
|
147
|
+
reason: e.reason ?? null,
|
|
148
|
+
file: S(e.sourceFileName, o.repositoryRoot),
|
|
149
|
+
line: e.line,
|
|
150
|
+
column: e.column,
|
|
151
|
+
codeowners: t?.getOwners(e.sourceFileName) ?? []
|
|
135
152
|
}))
|
|
136
153
|
};
|
|
137
|
-
process.stdout.write(`${JSON.stringify(
|
|
154
|
+
process.stdout.write(`${JSON.stringify(c, void 0, 2)}
|
|
138
155
|
`);
|
|
139
156
|
}
|
|
140
157
|
export {
|
|
141
|
-
|
|
142
|
-
|
|
158
|
+
oe as auditDeprecatedDefinitions,
|
|
159
|
+
Q as collectDeprecatedApiDefinitions
|
|
143
160
|
};
|
package/dist/chunks/sync.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { readFile as
|
|
2
|
-
import { log as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { readFile as d } from "node:fs/promises";
|
|
2
|
+
import { log as c } from "@arcgis/toolkit/log";
|
|
3
|
+
import { l as $, m as l, n as p } from "./classification.js";
|
|
4
|
+
import { c as g, i as f } from "./format.js";
|
|
5
|
+
import { collectOutput as h } from "@arcgis/node-toolkit/shell";
|
|
6
|
+
class w {
|
|
6
7
|
constructor(s, e = !1) {
|
|
7
8
|
this.changes = [], this.#i = /* @__PURE__ */ new Map(), this.#n = -1;
|
|
8
|
-
const [i, t, o, ...
|
|
9
|
-
if (i === void 0 || t === void 0 || o === void 0 ||
|
|
9
|
+
const [i, t, o, ...a] = s.split("/");
|
|
10
|
+
if (i === void 0 || t === void 0 || o === void 0 || a.length > 0)
|
|
10
11
|
throw new Error(`Invalid repository: ${s}`);
|
|
11
12
|
this.#e = i, this.#s = `${t}/${o}`, this.dryRun = e;
|
|
12
13
|
}
|
|
@@ -17,7 +18,7 @@ class l {
|
|
|
17
18
|
async #t(s, e, i) {
|
|
18
19
|
if (process.env.VITEST !== void 0)
|
|
19
20
|
throw new Error("GitHub requests are disabled while running Vitest.");
|
|
20
|
-
const t = await
|
|
21
|
+
const t = await h(
|
|
21
22
|
"gh",
|
|
22
23
|
["api", "--hostname", this.#e, "--method", s, e, ...i === void 0 ? [] : ["--input", "-"]],
|
|
23
24
|
i === void 0 ? {} : { input: JSON.stringify(i) }
|
|
@@ -25,7 +26,7 @@ class l {
|
|
|
25
26
|
return t === "" ? void 0 : JSON.parse(t);
|
|
26
27
|
}
|
|
27
28
|
async listOpenIssues(s) {
|
|
28
|
-
const e = await
|
|
29
|
+
const e = await h("gh", [
|
|
29
30
|
"api",
|
|
30
31
|
"--hostname",
|
|
31
32
|
this.#e,
|
|
@@ -44,14 +45,14 @@ class l {
|
|
|
44
45
|
async createIssue(s, e, i, t) {
|
|
45
46
|
if (this.dryRun) {
|
|
46
47
|
const o = this.#n--;
|
|
47
|
-
return this.#i.set(o, s), this.changes.push(`CREATE issue: ${s}`), { number: o, title: s, body: e, assignees: i.map((
|
|
48
|
+
return this.#i.set(o, s), this.changes.push(`CREATE issue: ${s}`), { number: o, title: s, body: e, assignees: i.map((a) => ({ login: a })) };
|
|
48
49
|
}
|
|
49
50
|
return await this.#t("POST", `/repos/${this.#s}/issues`, {
|
|
50
51
|
title: s,
|
|
51
52
|
body: e,
|
|
52
53
|
assignees: i,
|
|
53
54
|
labels: t,
|
|
54
|
-
type:
|
|
55
|
+
type: $
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
58
|
async updateIssueBody(s, e) {
|
|
@@ -64,7 +65,7 @@ class l {
|
|
|
64
65
|
async listComments(s) {
|
|
65
66
|
if (this.#i.has(s))
|
|
66
67
|
return [];
|
|
67
|
-
const e = await
|
|
68
|
+
const e = await h("gh", [
|
|
68
69
|
"api",
|
|
69
70
|
"--hostname",
|
|
70
71
|
this.#e,
|
|
@@ -99,31 +100,26 @@ class l {
|
|
|
99
100
|
await this.#t("DELETE", `/repos/${this.#s}/issues/comments/${s}`);
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
await
|
|
103
|
+
const y = /^( (?:- )?https:\/\/[^/\s]+\/[^/\s]+\/[^/\s]+\/blob\/)[a-f0-9]{40}(\/\S+#L\d+)$/gmu;
|
|
104
|
+
async function A(n, s, e = 0, i, t = []) {
|
|
105
|
+
const o = l(await d(n, "utf8")), a = E(g(o), e, i), r = new w(o.repository, s);
|
|
106
|
+
await I(a, r, t), s && process.stdout.write(`${T(a)}
|
|
105
107
|
`);
|
|
106
108
|
}
|
|
107
|
-
function
|
|
109
|
+
function E(n, s, e) {
|
|
108
110
|
return n.slice(s, e === void 0 ? void 0 : s + e);
|
|
109
111
|
}
|
|
110
|
-
async function
|
|
112
|
+
async function I(n, s, e = []) {
|
|
111
113
|
const i = /* @__PURE__ */ new Map();
|
|
112
114
|
for (const t of n) {
|
|
113
115
|
let o = i.get(t.title);
|
|
114
116
|
o === void 0 && (o = await s.listOpenIssues(t.title), i.set(t.title, o));
|
|
115
|
-
const
|
|
116
|
-
let
|
|
117
|
-
|
|
117
|
+
const a = C(o, t);
|
|
118
|
+
let r;
|
|
119
|
+
a === void 0 ? (r = (await s.createIssue(t.title, t.chunks[0], t.assignees, e)).number, s.dryRun || c("info", p, `Created issue #${r}: ${t.title}`)) : (r = a.number, u(a.body) !== u(t.chunks[0]) && (await s.updateIssueBody(r, t.chunks[0]), s.dryRun || c("info", p, `Updated issue #${r}: ${t.title}`))), await v(s, r, t.chunks.slice(1)), t.changes.push(...s.changes.splice(0));
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
|
-
function
|
|
121
|
-
const s = JSON.parse(n);
|
|
122
|
-
if (s.kind !== "usages" && s.kind !== "definitions" || typeof s.repository != "string" || typeof s.ref != "string" || !Array.isArray(s.findings))
|
|
123
|
-
throw new Error("Invalid deprecation audit JSON.");
|
|
124
|
-
return s;
|
|
125
|
-
}
|
|
126
|
-
function E(n) {
|
|
122
|
+
function T(n) {
|
|
127
123
|
return n.map(
|
|
128
124
|
(s) => `ACTIONS: ${s.changes.length === 0 ? "No changes" : s.changes.join("; ")}
|
|
129
125
|
|
|
@@ -139,27 +135,30 @@ ${e}`).join(`
|
|
|
139
135
|
|
|
140
136
|
`);
|
|
141
137
|
}
|
|
142
|
-
function
|
|
143
|
-
const e =
|
|
144
|
-
return n.find((i) => i.title === s.title &&
|
|
138
|
+
function C(n, s) {
|
|
139
|
+
const e = m(s.chunks[0]);
|
|
140
|
+
return n.find((i) => i.title === s.title && m(i.body) === e);
|
|
145
141
|
}
|
|
146
|
-
function
|
|
142
|
+
function m(n) {
|
|
147
143
|
const s = n?.split(`
|
|
148
144
|
`, 1)[0];
|
|
149
|
-
return s?.startsWith(
|
|
145
|
+
return s?.startsWith(f) === !0 ? s : void 0;
|
|
146
|
+
}
|
|
147
|
+
function u(n) {
|
|
148
|
+
return n?.replace(y, "$1<sha>$2");
|
|
150
149
|
}
|
|
151
|
-
async function
|
|
152
|
-
const i = (await n.listComments(s)).filter(({ body: t }) => t.startsWith(
|
|
150
|
+
async function v(n, s, e) {
|
|
151
|
+
const i = (await n.listComments(s)).filter(({ body: t }) => t.startsWith(f));
|
|
153
152
|
for (const [t, o] of e.entries()) {
|
|
154
|
-
const
|
|
155
|
-
|
|
153
|
+
const a = i[t];
|
|
154
|
+
a === void 0 ? await n.createComment(s, o) : u(a.body) !== u(o) && await n.updateComment(a.id, o);
|
|
156
155
|
}
|
|
157
156
|
for (const t of i.slice(e.length))
|
|
158
157
|
await n.deleteComment(t.id);
|
|
159
158
|
}
|
|
160
159
|
export {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
T as formatDryRun,
|
|
161
|
+
E as sliceIssuePlans,
|
|
162
|
+
A as syncDeprecationIssues,
|
|
163
|
+
I as synchronizeIssuePlans
|
|
165
164
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/codemod",
|
|
3
|
-
"version": "6.0.0-next.
|
|
3
|
+
"version": "6.0.0-next.4",
|
|
4
4
|
"description": "A codemod toolkit for updating and modernizing ArcGIS Maps SDK for JavaScript codebases.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
],
|
|
12
12
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@arcgis/api-extractor": "6.0.0-next.
|
|
15
|
-
"@arcgis/node-toolkit": "6.0.0-next.
|
|
16
|
-
"@arcgis/toolkit": "6.0.0-next.
|
|
14
|
+
"@arcgis/api-extractor": "6.0.0-next.4",
|
|
15
|
+
"@arcgis/node-toolkit": "6.0.0-next.4",
|
|
16
|
+
"@arcgis/toolkit": "6.0.0-next.4",
|
|
17
17
|
"@commander-js/extra-typings": "^15.0.0",
|
|
18
18
|
"commander": "^15.0.0",
|
|
19
19
|
"tinyglobby": "~0.2.17",
|