@arcgis/codemod 6.0.0-next.30 → 6.0.0-next.31
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 +146 -94
- package/dist/chunks/cli.js +181 -180
- package/dist/chunks/componentAudit.js +115 -101
- package/dist/chunks/format.js +94 -70
- package/dist/chunks/index.js +857 -693
- package/dist/chunks/index2.js +109 -109
- package/dist/chunks/index3.js +48 -39
- package/dist/chunks/legacyCompatibility.js +210 -0
- package/dist/chunks/sync.js +143 -41
- package/dist/chunks/syncMarkdown.js +28 -18
- package/package.json +5 -4
- package/dist/chunks/artifact.js +0 -48
- package/dist/chunks/github.js +0 -124
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { collectOutput as u } from "@arcgis/node-toolkit/shell";
|
|
2
|
+
import { l as m, f as l, j as p } from "./cli.js";
|
|
3
|
+
import { log as f } from "@arcgis/toolkit/log";
|
|
4
|
+
const g = /^( (?:- )?https:\/\/[^/\s]+\/[^/\s]+\/[^/\s]+\/blob\/)[a-f0-9]{40}(\/\S+#L\d+)$/gmu;
|
|
5
|
+
class v {
|
|
6
|
+
constructor(s, t = !1) {
|
|
7
|
+
this.changes = [], this.#i = /* @__PURE__ */ new Map(), this.#n = -1;
|
|
8
|
+
const [e, i, o, ...a] = s.split("/");
|
|
9
|
+
if (e === void 0 || i === void 0 || o === void 0 || a.length > 0)
|
|
10
|
+
throw new Error(`Invalid repository: ${s}`);
|
|
11
|
+
this.#e = e, this.#s = `${i}/${o}`, this.dryRun = t;
|
|
12
|
+
}
|
|
13
|
+
#e;
|
|
14
|
+
#s;
|
|
15
|
+
#i;
|
|
16
|
+
#n;
|
|
17
|
+
async #t(s, t, e) {
|
|
18
|
+
if (process.env.VITEST !== void 0)
|
|
19
|
+
throw new Error("GitHub requests are disabled while running Vitest.");
|
|
20
|
+
const i = await u(
|
|
21
|
+
"gh",
|
|
22
|
+
["api", "--hostname", this.#e, "--method", s, t, ...e === void 0 ? [] : ["--input", "-"]],
|
|
23
|
+
e === void 0 ? {} : { input: JSON.stringify(e) }
|
|
24
|
+
);
|
|
25
|
+
return i === "" ? void 0 : JSON.parse(i);
|
|
26
|
+
}
|
|
27
|
+
async listOpenIssues(s) {
|
|
28
|
+
const t = await u("gh", [
|
|
29
|
+
"api",
|
|
30
|
+
"--hostname",
|
|
31
|
+
this.#e,
|
|
32
|
+
"--method",
|
|
33
|
+
"GET",
|
|
34
|
+
"--paginate",
|
|
35
|
+
"--slurp",
|
|
36
|
+
"-f",
|
|
37
|
+
`q="${s}" in:body repo:${this.#s} is:issue is:open`,
|
|
38
|
+
"-f",
|
|
39
|
+
"per_page=100",
|
|
40
|
+
"/search/issues"
|
|
41
|
+
]), e = JSON.parse(t);
|
|
42
|
+
if (e.some(
|
|
43
|
+
({ incomplete_results: i, total_count: o }) => i || o > 1e3
|
|
44
|
+
))
|
|
45
|
+
throw new Error(`Incomplete issue search for ${s}; refusing to synchronize issues.`);
|
|
46
|
+
return e.flatMap(({ items: i }) => i);
|
|
47
|
+
}
|
|
48
|
+
async readLabelerConfig(s) {
|
|
49
|
+
const t = await this.#t(
|
|
50
|
+
"GET",
|
|
51
|
+
`/repos/${this.#s}/contents/.github?ref=${encodeURIComponent(s)}`
|
|
52
|
+
), e = t.find(({ name: o }) => o === "labeler.yml") ?? t.find(({ name: o }) => o === "labeler.yaml");
|
|
53
|
+
if (e === void 0)
|
|
54
|
+
return;
|
|
55
|
+
const { content: i } = await this.#t(
|
|
56
|
+
"GET",
|
|
57
|
+
`/repos/${this.#s}/contents/.github/${e.name}?ref=${encodeURIComponent(s)}`
|
|
58
|
+
);
|
|
59
|
+
return Buffer.from(i, "base64").toString("utf8");
|
|
60
|
+
}
|
|
61
|
+
async listLabels() {
|
|
62
|
+
const s = await u("gh", [
|
|
63
|
+
"api",
|
|
64
|
+
"--hostname",
|
|
65
|
+
this.#e,
|
|
66
|
+
"--method",
|
|
67
|
+
"GET",
|
|
68
|
+
"--paginate",
|
|
69
|
+
"--slurp",
|
|
70
|
+
`/repos/${this.#s}/labels?per_page=100`
|
|
71
|
+
]);
|
|
72
|
+
return JSON.parse(s).flat().map(({ name: t }) => t);
|
|
73
|
+
}
|
|
74
|
+
async addLabels(s, t) {
|
|
75
|
+
if (this.dryRun) {
|
|
76
|
+
this.changes.push(`ADD labels to issue #${s}: ${t.join(", ")}`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
await this.#t("POST", `/repos/${this.#s}/issues/${s}/labels`, { labels: t });
|
|
80
|
+
}
|
|
81
|
+
async createIssue(s, t, e, i) {
|
|
82
|
+
if (this.dryRun) {
|
|
83
|
+
const o = this.#n--;
|
|
84
|
+
return this.#i.set(o, s), this.changes.push(`CREATE issue: ${s}`), {
|
|
85
|
+
number: o,
|
|
86
|
+
title: s,
|
|
87
|
+
body: t,
|
|
88
|
+
assignees: e.map((a) => ({ login: a })),
|
|
89
|
+
labels: i.map((a) => ({ name: a }))
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return await this.#t("POST", `/repos/${this.#s}/issues`, {
|
|
93
|
+
title: s,
|
|
94
|
+
body: t,
|
|
95
|
+
assignees: e,
|
|
96
|
+
labels: i,
|
|
97
|
+
type: m
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
async updateIssueBody(s, t) {
|
|
101
|
+
if (this.dryRun) {
|
|
102
|
+
this.changes.push(`UPDATE issue #${s} body`);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
await this.#t("PATCH", `/repos/${this.#s}/issues/${s}`, { body: t });
|
|
106
|
+
}
|
|
107
|
+
async closeIssue(s) {
|
|
108
|
+
if (this.dryRun) {
|
|
109
|
+
this.changes.push(`CLOSE issue #${s}`);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
await this.#t("PATCH", `/repos/${this.#s}/issues/${s}`, { state: "closed" });
|
|
113
|
+
}
|
|
114
|
+
async listComments(s) {
|
|
115
|
+
if (this.#i.has(s))
|
|
116
|
+
return [];
|
|
117
|
+
const t = await u("gh", [
|
|
118
|
+
"api",
|
|
119
|
+
"--hostname",
|
|
120
|
+
this.#e,
|
|
121
|
+
"--method",
|
|
122
|
+
"GET",
|
|
123
|
+
"--paginate",
|
|
124
|
+
"--slurp",
|
|
125
|
+
`/repos/${this.#s}/issues/${s}/comments?per_page=100`
|
|
126
|
+
]);
|
|
127
|
+
return JSON.parse(t).flat();
|
|
128
|
+
}
|
|
129
|
+
async createComment(s, t) {
|
|
130
|
+
if (this.dryRun) {
|
|
131
|
+
const e = this.#i.get(s), i = e === void 0 ? `issue #${s}` : `new issue: ${e}`;
|
|
132
|
+
this.changes.push(`ADD comment to ${i}`);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
await this.#t("POST", `/repos/${this.#s}/issues/${s}/comments`, { body: t });
|
|
136
|
+
}
|
|
137
|
+
async updateComment(s, t) {
|
|
138
|
+
if (this.dryRun) {
|
|
139
|
+
this.changes.push(`UPDATE comment #${s}`);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
await this.#t("PATCH", `/repos/${this.#s}/issues/comments/${s}`, { body: t });
|
|
143
|
+
}
|
|
144
|
+
async deleteComment(s) {
|
|
145
|
+
if (this.dryRun) {
|
|
146
|
+
this.changes.push(`REMOVE comment #${s}`);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
await this.#t("DELETE", `/repos/${this.#s}/issues/comments/${s}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async function E(n, s, t, e) {
|
|
153
|
+
const i = (await n.listComments(s)).filter(({ body: o }) => e(o));
|
|
154
|
+
for (const [o, a] of t.entries()) {
|
|
155
|
+
const r = i[o];
|
|
156
|
+
r === void 0 ? await n.createComment(s, a) : d(r.body) !== d(a) && await n.updateComment(r.id, a);
|
|
157
|
+
}
|
|
158
|
+
for (const o of i.slice(t.length))
|
|
159
|
+
await n.deleteComment(o.id);
|
|
160
|
+
}
|
|
161
|
+
function d(n) {
|
|
162
|
+
return n?.replace(g, "$1<sha>$2");
|
|
163
|
+
}
|
|
164
|
+
const c = "@arcgis/codemod", y = `<!-- ${c} -->`;
|
|
165
|
+
async function T(n) {
|
|
166
|
+
const s = await n.listOpenIssues(c);
|
|
167
|
+
for (const t of s) {
|
|
168
|
+
const e = h(t.body);
|
|
169
|
+
e !== void 0 && e.kind === void 0 && f(
|
|
170
|
+
"warn",
|
|
171
|
+
l,
|
|
172
|
+
`Cannot determine audit kind for legacy issue #${t.number}; leaving it unchanged.`
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
return s;
|
|
176
|
+
}
|
|
177
|
+
function h(n) {
|
|
178
|
+
const s = n?.split(`
|
|
179
|
+
`, 1)[0], t = s === void 0 ? null : /^<!-- (\S+)(?: (@[^\s,]+(?:,@[^\s,]+)*))? -->$/u.exec(s);
|
|
180
|
+
if (t?.[1] !== c)
|
|
181
|
+
return;
|
|
182
|
+
const e = n?.split(`
|
|
183
|
+
`, 2)[1], i = e === p.usages ? "usages" : e === p.definitions ? "definitions" : void 0, o = t[2] === void 0 ? [] : [...new Set(t[2].split(","))].sort((a, r) => a.localeCompare(r));
|
|
184
|
+
return { kind: i, owners: o };
|
|
185
|
+
}
|
|
186
|
+
function I(n, s) {
|
|
187
|
+
const t = h(n.body);
|
|
188
|
+
if (t !== void 0 && t.kind === void 0 && t.owners.join(",") === s.join(","))
|
|
189
|
+
throw new Error(
|
|
190
|
+
`Cannot determine audit kind for legacy issue #${n.number}. Restore its generated introduction before synchronizing.`
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
function S(n, s) {
|
|
194
|
+
const t = h(n);
|
|
195
|
+
return t !== void 0 && (t.owners.length === 0 || t.owners.join(",") === s.join(","));
|
|
196
|
+
}
|
|
197
|
+
function b(n) {
|
|
198
|
+
return n.split(`
|
|
199
|
+
`, 1)[0] === y;
|
|
200
|
+
}
|
|
201
|
+
export {
|
|
202
|
+
v as G,
|
|
203
|
+
I as a,
|
|
204
|
+
b,
|
|
205
|
+
S as i,
|
|
206
|
+
T as l,
|
|
207
|
+
d as n,
|
|
208
|
+
h as p,
|
|
209
|
+
E as s
|
|
210
|
+
};
|
package/dist/chunks/sync.js
CHANGED
|
@@ -1,66 +1,168 @@
|
|
|
1
|
-
import { readFile as
|
|
1
|
+
import { readFile as E } from "node:fs/promises";
|
|
2
2
|
import { log as f } from "@arcgis/toolkit/log";
|
|
3
|
-
import {
|
|
4
|
-
import { f as d
|
|
5
|
-
import { c as
|
|
6
|
-
import { G as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import { n as A } from "./classification.js";
|
|
4
|
+
import { f as d } from "./cli.js";
|
|
5
|
+
import { c as j, a as M, p as I, b as $ } from "./format.js";
|
|
6
|
+
import { G as x, l as O, n as L, s as N, p as R, a as T, i as z } from "./legacyCompatibility.js";
|
|
7
|
+
import B from "picomatch";
|
|
8
|
+
import { parse as D } from "yaml";
|
|
9
|
+
function G(s) {
|
|
10
|
+
const e = D(s);
|
|
11
|
+
if (typeof e != "object" || e === null || Array.isArray(e))
|
|
12
|
+
throw new Error("Expected a label-to-rule mapping in the labeler config.");
|
|
13
|
+
const r = [];
|
|
14
|
+
for (const [n, t] of Object.entries(e))
|
|
15
|
+
try {
|
|
16
|
+
r.push({ label: n, matches: S(t) });
|
|
17
|
+
} catch (o) {
|
|
18
|
+
f("warn", d, `Skipping labeler rule for ${n}: ${String(o)}`);
|
|
19
|
+
}
|
|
20
|
+
return (n) => r.filter(({ matches: t }) => n.some(t)).map(({ label: t }) => t);
|
|
21
|
+
}
|
|
22
|
+
function S(s, e = !1) {
|
|
23
|
+
if (typeof s == "string") {
|
|
24
|
+
const n = B(s, { dot: !0 });
|
|
25
|
+
return (t) => n(t);
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(s))
|
|
28
|
+
return h(s, e);
|
|
29
|
+
if (typeof s != "object" || s === null || Object.keys(s).length === 0)
|
|
30
|
+
throw new Error("Expected a glob or a match object.");
|
|
31
|
+
const r = Object.entries(s).map(([n, t]) => {
|
|
32
|
+
switch (n) {
|
|
33
|
+
case "any":
|
|
34
|
+
return h(t, Array.isArray(t) && t.every((o) => typeof o == "string"));
|
|
35
|
+
case "all":
|
|
36
|
+
return h(t, !0);
|
|
37
|
+
case "changed-files":
|
|
38
|
+
return h(t, e);
|
|
39
|
+
case "any-glob-to-any-file":
|
|
40
|
+
return h(t, !1);
|
|
41
|
+
default:
|
|
42
|
+
throw new Error(`Unsupported labeler condition: ${n}.`);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return (n) => r.every((t) => t(n));
|
|
46
|
+
}
|
|
47
|
+
function h(s, e) {
|
|
48
|
+
const r = Array.isArray(s) ? s : [s];
|
|
49
|
+
if (r.length === 0)
|
|
50
|
+
throw new Error("Expected a nonempty rule list.");
|
|
51
|
+
const n = r.map((t) => S(t, e));
|
|
52
|
+
return (t) => e ? n.every((o) => o(t)) : n.some((o) => o(t));
|
|
53
|
+
}
|
|
54
|
+
async function se(s, e, r = 0, n, t = {}) {
|
|
55
|
+
const { labels: o = [], closeResolved: c = !1 } = t, p = A(await E(s, "utf8")), g = c && U(p, r, n), m = new x(p.repository, e), a = await P(m, p.ref), i = q(j(p, a), r, n), u = await F(i, m, o, g ? p.auditKind : void 0);
|
|
56
|
+
e && process.stdout.write(`${[H(i), ...u].filter(Boolean).join(`
|
|
10
57
|
`)}
|
|
11
58
|
`);
|
|
12
59
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
60
|
+
async function P(s, e) {
|
|
61
|
+
try {
|
|
62
|
+
const r = await s.readLabelerConfig(e);
|
|
63
|
+
return r === void 0 ? void 0 : G(r);
|
|
64
|
+
} catch (r) {
|
|
65
|
+
f("warn", d, `Skipping labeling based on .github/labeler.yml due to an error: ${String(r)}`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function U(s, e, r) {
|
|
70
|
+
if (e !== 0 || r !== void 0)
|
|
15
71
|
throw new Error("--close-resolved cannot be used with --offset or --limit.");
|
|
16
|
-
return
|
|
72
|
+
return s.complete !== !0 ? (f(
|
|
17
73
|
"warn",
|
|
18
74
|
d,
|
|
19
75
|
"Skipping --close-resolved: the report is not a complete, unfiltered repository-root audit. Issue creation and updates will continue."
|
|
20
76
|
), !1) : !0;
|
|
21
77
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
78
|
+
function q(s, e, r) {
|
|
79
|
+
return s.slice(e, r === void 0 ? void 0 : e + r);
|
|
24
80
|
}
|
|
25
|
-
async function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
81
|
+
async function F(s, e, r = [], n) {
|
|
82
|
+
await W(s, e, r);
|
|
83
|
+
const t = n ?? b(s[0]?.chunks[0] ?? null)?.kind, o = t === void 0 ? [] : [...await e.listOpenIssues(M[t]), ...await O(e)], c = [...new Map(o.map((a) => [a.number, a])).values()], p = n === void 0 ? [] : c.filter((a) => b(a.body)?.kind === n), g = s.map((a) => ({ plan: a, issues: Y(c, a) })), m = /* @__PURE__ */ new Set();
|
|
84
|
+
for (const a of g) {
|
|
85
|
+
const { plan: i } = a;
|
|
86
|
+
let u = a.issues[0];
|
|
87
|
+
u === void 0 ? (u = await e.createIssue(i.title, i.chunks[0], i.assignees, []), e.dryRun || f("info", d, `Created issue #${u.number}: ${i.title}`)) : L(u.body) !== L(i.chunks[0]) && (await e.updateIssueBody(u.number, i.chunks[0]), e.dryRun || f("info", d, `Updated issue #${u.number}: ${i.title}`));
|
|
88
|
+
const w = u.number, v = b(i.chunks[0]);
|
|
89
|
+
await N(e, w, i.chunks.slice(1), (l) => {
|
|
90
|
+
const k = I(l);
|
|
91
|
+
return k?.kind === v?.kind && k?.owners.join(",") === i.owners.join(",") || z(l, i.owners);
|
|
92
|
+
});
|
|
93
|
+
const C = new Set(u.labels.map(({ name: l }) => l.toLowerCase())), y = i.labels.filter((l) => !C.has(l.toLowerCase()));
|
|
94
|
+
if (y.length > 0)
|
|
95
|
+
try {
|
|
96
|
+
await e.addLabels(w, y);
|
|
97
|
+
} catch (l) {
|
|
98
|
+
f("warn", d, `Unable to add labels to issue #${w}: ${String(l)}`);
|
|
99
|
+
}
|
|
100
|
+
m.add(w);
|
|
101
|
+
for (const l of a.issues)
|
|
102
|
+
m.add(l.number);
|
|
103
|
+
i.changes.push(...e.changes.splice(0));
|
|
31
104
|
}
|
|
32
|
-
for (const
|
|
33
|
-
|
|
34
|
-
return
|
|
105
|
+
for (const a of p)
|
|
106
|
+
m.has(a.number) || (await e.closeIssue(a.number), e.dryRun || f("info", d, `Closed stale issue #${a.number}: ${a.title}`));
|
|
107
|
+
return e.changes.splice(0);
|
|
35
108
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
38
|
-
(
|
|
109
|
+
function H(s) {
|
|
110
|
+
return s.map(
|
|
111
|
+
(e) => `ACTIONS: ${e.changes.length === 0 ? "No changes" : e.changes.join("; ")}
|
|
39
112
|
|
|
40
|
-
CODEOWNERS: ${
|
|
41
|
-
ASSIGNEES: ${
|
|
42
|
-
|
|
113
|
+
CODEOWNERS: ${e.owners.length === 0 ? "unowned" : e.owners.join(", ")}
|
|
114
|
+
ASSIGNEES: ${e.assignees.length === 0 ? "none" : e.assignees.join(", ")}
|
|
115
|
+
LABELS: ${e.labels.length === 0 ? "none" : e.labels.join(", ")}
|
|
116
|
+
TITLE: ${e.title}
|
|
43
117
|
|
|
44
|
-
${
|
|
45
|
-
${
|
|
118
|
+
${e.chunks.map((r, n) => `--- ${n === 0 ? "BODY" : "COMMENT"} (${n + 1}/${e.chunks.length}) ---
|
|
119
|
+
${r}`).join(`
|
|
46
120
|
|
|
47
121
|
`)}`
|
|
48
122
|
).join(`
|
|
49
123
|
|
|
50
124
|
`);
|
|
51
125
|
}
|
|
52
|
-
function
|
|
53
|
-
const
|
|
54
|
-
|
|
126
|
+
async function W(s, e, r) {
|
|
127
|
+
const n = new Set(s.flatMap((t) => [...r, ...t.labels]));
|
|
128
|
+
if (n.size !== 0)
|
|
129
|
+
try {
|
|
130
|
+
const t = new Map((await e.listLabels()).map((o) => [o.toLowerCase(), o]));
|
|
131
|
+
for (const o of n)
|
|
132
|
+
t.has(o.toLowerCase()) || f(
|
|
133
|
+
"warn",
|
|
134
|
+
d,
|
|
135
|
+
`.github/labeler.yml specifies a label that doesn't exist in the repository. Skipping: ${o}`
|
|
136
|
+
);
|
|
137
|
+
for (const o of s)
|
|
138
|
+
o.labels = [
|
|
139
|
+
...new Set([...r, ...o.labels].flatMap((c) => t.get(c.toLowerCase()) ?? []))
|
|
140
|
+
];
|
|
141
|
+
} catch (t) {
|
|
142
|
+
f("warn", d, `Skipping labels: unable to read repository labels: ${String(t)}`);
|
|
143
|
+
for (const o of s)
|
|
144
|
+
o.labels = [];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function Y(s, e) {
|
|
148
|
+
const r = b(e.chunks[0]);
|
|
149
|
+
if (r === void 0)
|
|
150
|
+
throw new Error("Expected an audit marker in issue plan.");
|
|
151
|
+
const n = $(r.owners, r.kind);
|
|
152
|
+
for (const o of s)
|
|
153
|
+
T(o, r.owners);
|
|
154
|
+
return s.filter((o) => {
|
|
155
|
+
const c = b(o.body);
|
|
156
|
+
return c !== void 0 && $(c.owners, c.kind) === n;
|
|
157
|
+
}).sort((o, c) => o.number - c.number);
|
|
55
158
|
}
|
|
56
|
-
function
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
return s?.startsWith(g) === !0 ? s : void 0;
|
|
159
|
+
function b(s) {
|
|
160
|
+
const e = I(s) ?? R(s);
|
|
161
|
+
return e?.kind === void 0 ? void 0 : { kind: e.kind, owners: e.owners };
|
|
60
162
|
}
|
|
61
163
|
export {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
164
|
+
H as formatDryRun,
|
|
165
|
+
q as sliceIssuePlans,
|
|
166
|
+
se as syncDeprecationIssues,
|
|
167
|
+
F as synchronizeIssuePlans
|
|
66
168
|
};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import { readFile as
|
|
2
|
-
import { markdownTextLimit as
|
|
3
|
-
import { G as
|
|
4
|
-
|
|
5
|
-
async function
|
|
6
|
-
const { repository:
|
|
7
|
-
await
|
|
8
|
-
|
|
1
|
+
import { readFile as m } from "node:fs/promises";
|
|
2
|
+
import { markdownTextLimit as u, splitMarkdown as p } from "@arcgis/node-toolkit/markdown";
|
|
3
|
+
import { G as f, s as w, b as d } from "./legacyCompatibility.js";
|
|
4
|
+
const a = "<!-- arcgisCodemodSyncMarkdown -->";
|
|
5
|
+
async function M(e, t, n = !1) {
|
|
6
|
+
const { repository: s, issueNumber: c } = h(t), r = new f(s, n), o = l(await m(e, "utf8"));
|
|
7
|
+
await w(
|
|
8
|
+
r,
|
|
9
|
+
c,
|
|
10
|
+
o,
|
|
11
|
+
(i) => k(i) || d(i)
|
|
12
|
+
), n && process.stdout.write(
|
|
13
|
+
`${r.changes.length === 0 ? "No changes" : r.changes.join(`
|
|
9
14
|
`)}
|
|
10
15
|
|
|
11
16
|
${o.join(`
|
|
@@ -14,19 +19,24 @@ ${o.join(`
|
|
|
14
19
|
`
|
|
15
20
|
);
|
|
16
21
|
}
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
throw new Error(`Expected an HTTPS GitHub issue URL: ${
|
|
21
|
-
return { repository: `${
|
|
22
|
+
function h(e) {
|
|
23
|
+
const t = new URL(e), n = /^\/([^/]+)\/([^/]+)\/issues\/([1-9]\d*)\/?$/u.exec(t.pathname);
|
|
24
|
+
if (t.protocol !== "https:" || n === null || !Number.isSafeInteger(Number(n[3])))
|
|
25
|
+
throw new Error(`Expected an HTTPS GitHub issue URL: ${e}`);
|
|
26
|
+
return { repository: `${t.host}/${n[1]}/${n[2]}`, issueNumber: Number(n[3]) };
|
|
22
27
|
}
|
|
23
|
-
function
|
|
24
|
-
const
|
|
28
|
+
function l(e, t = u) {
|
|
29
|
+
const n = `${a}
|
|
25
30
|
|
|
26
31
|
`;
|
|
27
|
-
return
|
|
32
|
+
return p(e, t - n.length).map((s) => n + s);
|
|
33
|
+
}
|
|
34
|
+
function k(e) {
|
|
35
|
+
return e.split(`
|
|
36
|
+
`, 1)[0] === a;
|
|
28
37
|
}
|
|
29
38
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
l as createMarkdownComments,
|
|
40
|
+
k as isMarkdownComment,
|
|
41
|
+
M as syncMarkdown
|
|
32
42
|
};
|
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.31",
|
|
4
4
|
"description": "A codemod toolkit for updating and modernizing ArcGIS Maps SDK for JavaScript codebases.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -11,11 +11,12 @@
|
|
|
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.31",
|
|
15
|
+
"@arcgis/node-toolkit": "6.0.0-next.31",
|
|
16
|
+
"@arcgis/toolkit": "6.0.0-next.31",
|
|
17
17
|
"@commander-js/extra-typings": "^15.0.0",
|
|
18
18
|
"commander": "^15.0.0",
|
|
19
|
+
"picomatch": "^4.0.4",
|
|
19
20
|
"semver": "^7.7.3",
|
|
20
21
|
"tinyglobby": "~0.2.17",
|
|
21
22
|
"ts-morph": "^28.0.0",
|
package/dist/chunks/artifact.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
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.30";
|
|
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
|
-
};
|
package/dist/chunks/github.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { collectOutput as h } from "@arcgis/node-toolkit/shell";
|
|
2
|
-
import { j as c } from "./cli.js";
|
|
3
|
-
const p = /^( (?:- )?https:\/\/[^/\s]+\/[^/\s]+\/[^/\s]+\/blob\/)[a-f0-9]{40}(\/\S+#L\d+)$/gmu;
|
|
4
|
-
class $ {
|
|
5
|
-
constructor(s, t = !1) {
|
|
6
|
-
this.changes = [], this.#i = /* @__PURE__ */ new Map(), this.#n = -1;
|
|
7
|
-
const [e, i, n, ...o] = s.split("/");
|
|
8
|
-
if (e === void 0 || i === void 0 || n === void 0 || o.length > 0)
|
|
9
|
-
throw new Error(`Invalid repository: ${s}`);
|
|
10
|
-
this.#e = e, this.#s = `${i}/${n}`, this.dryRun = t;
|
|
11
|
-
}
|
|
12
|
-
#e;
|
|
13
|
-
#s;
|
|
14
|
-
#i;
|
|
15
|
-
#n;
|
|
16
|
-
async #t(s, t, e) {
|
|
17
|
-
if (process.env.VITEST !== void 0)
|
|
18
|
-
throw new Error("GitHub requests are disabled while running Vitest.");
|
|
19
|
-
const i = await h(
|
|
20
|
-
"gh",
|
|
21
|
-
["api", "--hostname", this.#e, "--method", s, t, ...e === void 0 ? [] : ["--input", "-"]],
|
|
22
|
-
e === void 0 ? {} : { input: JSON.stringify(e) }
|
|
23
|
-
);
|
|
24
|
-
return i === "" ? void 0 : JSON.parse(i);
|
|
25
|
-
}
|
|
26
|
-
async listOpenIssues(s) {
|
|
27
|
-
const t = await h("gh", [
|
|
28
|
-
"api",
|
|
29
|
-
"--hostname",
|
|
30
|
-
this.#e,
|
|
31
|
-
"--method",
|
|
32
|
-
"GET",
|
|
33
|
-
"--paginate",
|
|
34
|
-
"--slurp",
|
|
35
|
-
"-f",
|
|
36
|
-
`q="${s}" in:title repo:${this.#s} is:issue is:open`,
|
|
37
|
-
"-f",
|
|
38
|
-
"per_page=100",
|
|
39
|
-
"/search/issues"
|
|
40
|
-
]);
|
|
41
|
-
return JSON.parse(t).flatMap(({ items: e }) => e);
|
|
42
|
-
}
|
|
43
|
-
async createIssue(s, t, e, i) {
|
|
44
|
-
if (this.dryRun) {
|
|
45
|
-
const n = this.#n--;
|
|
46
|
-
return this.#i.set(n, s), this.changes.push(`CREATE issue: ${s}`), { number: n, title: s, body: t, assignees: e.map((o) => ({ login: o })) };
|
|
47
|
-
}
|
|
48
|
-
return await this.#t("POST", `/repos/${this.#s}/issues`, {
|
|
49
|
-
title: s,
|
|
50
|
-
body: t,
|
|
51
|
-
assignees: e,
|
|
52
|
-
labels: i,
|
|
53
|
-
type: c
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
async updateIssueBody(s, t) {
|
|
57
|
-
if (this.dryRun) {
|
|
58
|
-
this.changes.push(`UPDATE issue #${s} body`);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
await this.#t("PATCH", `/repos/${this.#s}/issues/${s}`, { body: t });
|
|
62
|
-
}
|
|
63
|
-
async closeIssue(s) {
|
|
64
|
-
if (this.dryRun) {
|
|
65
|
-
this.changes.push(`CLOSE issue #${s}`);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
await this.#t("PATCH", `/repos/${this.#s}/issues/${s}`, { state: "closed" });
|
|
69
|
-
}
|
|
70
|
-
async listComments(s) {
|
|
71
|
-
if (this.#i.has(s))
|
|
72
|
-
return [];
|
|
73
|
-
const t = await h("gh", [
|
|
74
|
-
"api",
|
|
75
|
-
"--hostname",
|
|
76
|
-
this.#e,
|
|
77
|
-
"--method",
|
|
78
|
-
"GET",
|
|
79
|
-
"--paginate",
|
|
80
|
-
"--slurp",
|
|
81
|
-
`/repos/${this.#s}/issues/${s}/comments?per_page=100`
|
|
82
|
-
]);
|
|
83
|
-
return JSON.parse(t).flat();
|
|
84
|
-
}
|
|
85
|
-
async createComment(s, t) {
|
|
86
|
-
if (this.dryRun) {
|
|
87
|
-
const e = this.#i.get(s), i = e === void 0 ? `issue #${s}` : `new issue: ${e}`;
|
|
88
|
-
this.changes.push(`ADD comment to ${i}`);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
await this.#t("POST", `/repos/${this.#s}/issues/${s}/comments`, { body: t });
|
|
92
|
-
}
|
|
93
|
-
async updateComment(s, t) {
|
|
94
|
-
if (this.dryRun) {
|
|
95
|
-
this.changes.push(`UPDATE comment #${s}`);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
await this.#t("PATCH", `/repos/${this.#s}/issues/comments/${s}`, { body: t });
|
|
99
|
-
}
|
|
100
|
-
async deleteComment(s) {
|
|
101
|
-
if (this.dryRun) {
|
|
102
|
-
this.changes.push(`REMOVE comment #${s}`);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
await this.#t("DELETE", `/repos/${this.#s}/issues/comments/${s}`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
async function f(a, s, t, e) {
|
|
109
|
-
const i = (await a.listComments(s)).filter(({ body: n }) => e(n));
|
|
110
|
-
for (const [n, o] of t.entries()) {
|
|
111
|
-
const r = i[n];
|
|
112
|
-
r === void 0 ? await a.createComment(s, o) : u(r.body) !== u(o) && await a.updateComment(r.id, o);
|
|
113
|
-
}
|
|
114
|
-
for (const n of i.slice(t.length))
|
|
115
|
-
await a.deleteComment(n.id);
|
|
116
|
-
}
|
|
117
|
-
function u(a) {
|
|
118
|
-
return a?.replace(p, "$1<sha>$2");
|
|
119
|
-
}
|
|
120
|
-
export {
|
|
121
|
-
$ as G,
|
|
122
|
-
u as n,
|
|
123
|
-
f as s
|
|
124
|
-
};
|