@arcgis/codemod 5.2.0-next.122 → 5.2.0-next.124
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/{actions-LEFiI8Xk.js → actions-C2O2Yihz.js} +1 -1
- package/dist/cli-BKh8oci8.js +380 -0
- package/dist/cli.js +1 -1
- package/dist/{codemod-YgioOfc7.js → codemod-B77zhGUg.js} +3 -3
- package/dist/{codemod-DTsG5_YU.js → codemod-BIUlczaa.js} +3 -3
- package/dist/{codemod-lZGspJIz.js → codemod-CV8s2kNe.js} +3 -3
- package/dist/{codemod-HRcnKq-i.js → codemod-CZfrjoI-.js} +3 -3
- package/dist/{codemod-BpcMVaZX.js → codemod-ChBRJ-aq.js} +2 -2
- package/dist/{codemod-DryX37eS.js → codemod-CwSdzblS.js} +3 -3
- package/dist/{codemod-DHO2ieDH.js → codemod-GSxZDuDJ.js} +1 -1
- package/dist/{codemod-eprC1jEo.js → codemod-eFToTK3L.js} +2 -2
- package/dist/format-D_FrLFG7.js +255 -0
- package/dist/index-By51mdF7.js +403 -0
- package/dist/{index-DomCHjnu.js → index-i6wMrws7.js} +2 -2
- package/dist/sync-Bm7WIvtr.js +165 -0
- package/dist/{useProjectInstance-DtWpxhlT.js → useProjectInstance-1xXeoSCI.js} +11 -8
- package/package.json +4 -4
- package/dist/cli-DfAgo-jb.js +0 -326
- package/dist/config-BP6HDIQa.js +0 -19
- package/dist/index-2_o7gSlk.js +0 -313
- package/dist/sync-e0pgnEOM.js +0 -240
package/dist/index-2_o7gSlk.js
DELETED
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
var k = (t, n) => (n = Symbol[t]) ? n : /* @__PURE__ */ Symbol.for("Symbol." + t), I = (t) => {
|
|
2
|
-
throw TypeError(t);
|
|
3
|
-
};
|
|
4
|
-
var C = (t, n, e) => {
|
|
5
|
-
if (n != null) {
|
|
6
|
-
typeof n != "object" && typeof n != "function" && I("Object expected");
|
|
7
|
-
var o, r;
|
|
8
|
-
e && (o = n[k("asyncDispose")]), o === void 0 && (o = n[k("dispose")], e && (r = o)), typeof o != "function" && I("Object not disposable"), r && (o = function() {
|
|
9
|
-
try {
|
|
10
|
-
r.call(this);
|
|
11
|
-
} catch (a) {
|
|
12
|
-
return Promise.reject(a);
|
|
13
|
-
}
|
|
14
|
-
}), t.push([e, o, n]);
|
|
15
|
-
} else e && t.push([e]);
|
|
16
|
-
return n;
|
|
17
|
-
}, J = (t, n, e) => {
|
|
18
|
-
var o = typeof SuppressedError == "function" ? SuppressedError : function(i, s, m, d) {
|
|
19
|
-
return d = Error(m), d.name = "SuppressedError", d.error = i, d.suppressed = s, d;
|
|
20
|
-
}, r = (i) => n = e ? new o(i, n, "An error was suppressed during disposal") : (e = !0, i), a = (i) => {
|
|
21
|
-
for (; i = t.pop(); )
|
|
22
|
-
try {
|
|
23
|
-
var s = i[1] && i[1].call(i[2]);
|
|
24
|
-
if (i[0]) return Promise.resolve(s).then(a, (m) => (r(m), a()));
|
|
25
|
-
} catch (m) {
|
|
26
|
-
r(m);
|
|
27
|
-
}
|
|
28
|
-
if (e) throw n;
|
|
29
|
-
};
|
|
30
|
-
return a();
|
|
31
|
-
};
|
|
32
|
-
import { c as j } from "./useProjectInstance-DtWpxhlT.js";
|
|
33
|
-
import { r as U } from "./cli-DfAgo-jb.js";
|
|
34
|
-
import { f as h } from "./log-B76HBvov.js";
|
|
35
|
-
import { path as g, toPosixPathSeparators as W } from "@arcgis/node-toolkit/path";
|
|
36
|
-
import { log as S } from "@arcgis/toolkit/log";
|
|
37
|
-
import l from "typescript";
|
|
38
|
-
import { g as F, l as z, a as _, s as Q, p as q, b as B, c as G, d as H } from "./codeowners-CarwYwHK.js";
|
|
39
|
-
import { i as K } from "./config-BP6HDIQa.js";
|
|
40
|
-
import { styleText as $ } from "node:util";
|
|
41
|
-
function V(t, n) {
|
|
42
|
-
if (n) {
|
|
43
|
-
const e = F();
|
|
44
|
-
process.stdout.write(`${X(t, z(), e)}
|
|
45
|
-
`);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
for (const [e, o] of T(t)) {
|
|
49
|
-
S("info", $("red", e), `${o.length} deprecated API usage${o.length === 1 ? "" : "s"}`);
|
|
50
|
-
for (const { sourceFileName: r, usage: a } of o) {
|
|
51
|
-
const i = $("blue", `${h(r)}:${a.line}:${a.column}`), s = a.reason === void 0 || a.reason === "" ? `\`${a.name}\` is deprecated.` : `\`${a.name}\` is deprecated. ${a.reason}`;
|
|
52
|
-
S("warn", i, s);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function T(t) {
|
|
57
|
-
return [...t].sort(([n], [e]) => n.localeCompare(e));
|
|
58
|
-
}
|
|
59
|
-
function X(t, n, e = F()) {
|
|
60
|
-
const o = {
|
|
61
|
-
kind: "usages",
|
|
62
|
-
repository: e.repository,
|
|
63
|
-
ref: e.ref,
|
|
64
|
-
findings: T(t).flatMap(
|
|
65
|
-
([r, a]) => a.map(({ sourceFileName: i, usage: s }) => ({
|
|
66
|
-
package: r,
|
|
67
|
-
api: s.name,
|
|
68
|
-
reason: s.reason ?? null,
|
|
69
|
-
file: _(i, e.repositoryRoot),
|
|
70
|
-
line: s.line,
|
|
71
|
-
column: s.column,
|
|
72
|
-
codeowners: n?.getOwners(i) ?? []
|
|
73
|
-
}))
|
|
74
|
-
)
|
|
75
|
-
};
|
|
76
|
-
return JSON.stringify(o, void 0, 2);
|
|
77
|
-
}
|
|
78
|
-
async function Pe(t, n, e) {
|
|
79
|
-
await U(
|
|
80
|
-
{
|
|
81
|
-
meta: {
|
|
82
|
-
needsTypeInformation: !0,
|
|
83
|
-
needsFooter: !1
|
|
84
|
-
},
|
|
85
|
-
run(o) {
|
|
86
|
-
Y(o, n, e);
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
"deprecations audit-usages",
|
|
90
|
-
t
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
function Y(t, n, e) {
|
|
94
|
-
const o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), a = [
|
|
95
|
-
...new Map(
|
|
96
|
-
t.flatMap(({ packageJson: c }) => {
|
|
97
|
-
const f = c === void 0 ? void 0 : g.dirname(c.filePath), v = c?.contents.name;
|
|
98
|
-
return f !== void 0 && v !== void 0 && N(f, process.cwd()) ? [[f, { root: f, name: v }]] : [];
|
|
99
|
-
})
|
|
100
|
-
).values()
|
|
101
|
-
].toSorted((c, f) => f.root.length - c.root.length);
|
|
102
|
-
for (const c of t) {
|
|
103
|
-
var s = [];
|
|
104
|
-
try {
|
|
105
|
-
if (Q(c.packageJson?.contents.name)) {
|
|
106
|
-
const p = c.packageJson?.filePath;
|
|
107
|
-
p !== void 0 && !r.has(p) && (r.add(p), S(
|
|
108
|
-
"warn",
|
|
109
|
-
h(p),
|
|
110
|
-
`Skipping excluded package \`${c.packageJson?.contents.name ?? c.cwd}\`.`
|
|
111
|
-
));
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
const f = C(s, j(c, !1));
|
|
115
|
-
const v = f.tsMorph.getLanguageService().compilerObject;
|
|
116
|
-
const y = v.getProgram()?.getTypeChecker();
|
|
117
|
-
if (y === void 0)
|
|
118
|
-
continue;
|
|
119
|
-
const x = c.packageJson === void 0 ? void 0 : g.dirname(c.packageJson.filePath);
|
|
120
|
-
for (const p of f.getCodemodFiles()) {
|
|
121
|
-
const A = p.compilerNode;
|
|
122
|
-
for (const w of Z(
|
|
123
|
-
A,
|
|
124
|
-
v,
|
|
125
|
-
y,
|
|
126
|
-
x,
|
|
127
|
-
n
|
|
128
|
-
)) {
|
|
129
|
-
const D = ce(w.originFileNames, a, x), b = o.get(D) ?? [];
|
|
130
|
-
b.push({ sourceFileName: A.fileName, usage: w }), o.set(D, b);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
} catch (m) {
|
|
134
|
-
var d = m, u = !0;
|
|
135
|
-
} finally {
|
|
136
|
-
J(s, d, u);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
V(o, e);
|
|
140
|
-
const i = [...o.values()].flat();
|
|
141
|
-
q(
|
|
142
|
-
"usages",
|
|
143
|
-
i.length,
|
|
144
|
-
new Set(i.map(({ sourceFileName: c }) => c)).size,
|
|
145
|
-
o.size
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
function Z(t, n, e, o, r = !1) {
|
|
149
|
-
const a = /* @__PURE__ */ new Map();
|
|
150
|
-
for (const i of n.getSuggestionDiagnostics(t.fileName)) {
|
|
151
|
-
if (i.reportsDeprecated === void 0)
|
|
152
|
-
continue;
|
|
153
|
-
const s = ie(t, i.start, i.start + i.length);
|
|
154
|
-
if (
|
|
155
|
-
// Don't report for imports, only for usages
|
|
156
|
-
l.findAncestor(s, l.isImportDeclaration) !== void 0 || // Don't report closing JSX - only for opening
|
|
157
|
-
l.findAncestor(s, l.isJsxClosingElement) !== void 0
|
|
158
|
-
)
|
|
159
|
-
continue;
|
|
160
|
-
const m = te(
|
|
161
|
-
s,
|
|
162
|
-
e,
|
|
163
|
-
n,
|
|
164
|
-
t.fileName,
|
|
165
|
-
i.start
|
|
166
|
-
);
|
|
167
|
-
R(m, r, o) && E(a, t, {
|
|
168
|
-
start: i.start,
|
|
169
|
-
length: i.length,
|
|
170
|
-
name: oe(s, e, n, t.fileName, i.start) ?? ae(s),
|
|
171
|
-
originFileNames: m,
|
|
172
|
-
reason: re(n, t.fileName, i.start) ?? se(s, e)
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
return ee(t, e, a, o, r), [...a.values()].toSorted((i, s) => i.start - s.start);
|
|
176
|
-
}
|
|
177
|
-
function ee(t, n, e, o, r) {
|
|
178
|
-
function a(i) {
|
|
179
|
-
if (l.isJsxAttribute(i) && l.isIdentifier(i.name)) {
|
|
180
|
-
const s = i.parent.parent;
|
|
181
|
-
if (l.isJsxOpeningElement(s) || l.isJsxSelfClosingElement(s)) {
|
|
182
|
-
const d = n.getContextualType(s.tagName)?.getProperty(i.name.text), u = P(d, n), c = L(d);
|
|
183
|
-
u !== void 0 && R(c, r, o) && E(e, t, {
|
|
184
|
-
start: i.name.getStart(t),
|
|
185
|
-
length: i.name.getWidth(t),
|
|
186
|
-
name: i.name.text,
|
|
187
|
-
originFileNames: c,
|
|
188
|
-
reason: u
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
l.forEachChild(i, a);
|
|
193
|
-
}
|
|
194
|
-
a(t);
|
|
195
|
-
}
|
|
196
|
-
function te(t, n, e, o, r) {
|
|
197
|
-
const a = ne(t, n);
|
|
198
|
-
return a.length > 0 ? a : [...new Set(e.getDefinitionAtPosition(o, r)?.map(({ fileName: i }) => i))];
|
|
199
|
-
}
|
|
200
|
-
function L(t) {
|
|
201
|
-
return [...new Set(t?.declarations?.map((n) => n.getSourceFile().fileName))];
|
|
202
|
-
}
|
|
203
|
-
function ne(t, n) {
|
|
204
|
-
let e = n.getSymbolAtLocation(t);
|
|
205
|
-
for (; e !== void 0 && (e.flags & l.SymbolFlags.Alias) !== 0; ) {
|
|
206
|
-
if (P(e, n) !== void 0)
|
|
207
|
-
return L(e);
|
|
208
|
-
e = e.declarations === void 0 ? void 0 : n.getImmediateAliasedSymbol(e);
|
|
209
|
-
}
|
|
210
|
-
return [];
|
|
211
|
-
}
|
|
212
|
-
function oe(t, n, e, o, r) {
|
|
213
|
-
let a = n.getSymbolAtLocation(t);
|
|
214
|
-
for (; a !== void 0 && (a.flags & l.SymbolFlags.Alias) !== 0; ) {
|
|
215
|
-
if (P(a, n) !== void 0)
|
|
216
|
-
return a.getName();
|
|
217
|
-
a = a.declarations === void 0 ? void 0 : n.getImmediateAliasedSymbol(a);
|
|
218
|
-
}
|
|
219
|
-
return e.getDefinitionAtPosition(o, r)?.[0]?.name;
|
|
220
|
-
}
|
|
221
|
-
function N(t, n) {
|
|
222
|
-
const e = g.relative(n, t);
|
|
223
|
-
return e !== "" && !e.startsWith("../") && !g.isAbsolute(e) && e !== "node_modules" && !e.startsWith("node_modules/");
|
|
224
|
-
}
|
|
225
|
-
function ie(t, n, e) {
|
|
226
|
-
let o = t;
|
|
227
|
-
for (; ; ) {
|
|
228
|
-
let r;
|
|
229
|
-
if (l.forEachChild(o, (a) => {
|
|
230
|
-
r === void 0 && a.getStart(t) <= n && a.getEnd() >= e && (r = a);
|
|
231
|
-
}), r === void 0)
|
|
232
|
-
return o;
|
|
233
|
-
o = r;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
function ae(t) {
|
|
237
|
-
return l.isIdentifier(t) || l.isPrivateIdentifier(t) || l.isStringLiteralLike(t) || l.isNumericLiteral(t) ? t.text : t.getText();
|
|
238
|
-
}
|
|
239
|
-
function M(t) {
|
|
240
|
-
const n = t?.find(({ name: e }) => e === "deprecated");
|
|
241
|
-
return n === void 0 ? void 0 : H(n.text);
|
|
242
|
-
}
|
|
243
|
-
function re(t, n, e) {
|
|
244
|
-
try {
|
|
245
|
-
return M(t.getQuickInfoAtPosition(n, e)?.tags);
|
|
246
|
-
} catch {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
function P(t, n) {
|
|
251
|
-
try {
|
|
252
|
-
return M(t?.getJsDocTags(n));
|
|
253
|
-
} catch {
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
function se(t, n) {
|
|
258
|
-
let e = n.getSymbolAtLocation(t);
|
|
259
|
-
for (; e !== void 0 && (e.flags & l.SymbolFlags.Alias) !== 0; ) {
|
|
260
|
-
const o = P(e, n);
|
|
261
|
-
if (o !== void 0)
|
|
262
|
-
return o;
|
|
263
|
-
e = e.declarations === void 0 ? void 0 : n.getImmediateAliasedSymbol(e);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
function E(t, n, e) {
|
|
267
|
-
if (G(e.name, e.reason))
|
|
268
|
-
return;
|
|
269
|
-
const { line: o, character: r } = n.getLineAndCharacterOfPosition(e.start);
|
|
270
|
-
t.set(`${e.start}:${e.length}`, {
|
|
271
|
-
...e,
|
|
272
|
-
line: o + 1,
|
|
273
|
-
column: r + 1
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
function R(t, n, e) {
|
|
277
|
-
return t.some((o) => e !== void 0 && N(o, e)) ? !1 : !n || t.some((o) => {
|
|
278
|
-
const r = O(o);
|
|
279
|
-
return r === void 0 ? e === void 0 || !N(o, e) : K(r);
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
function O(t) {
|
|
283
|
-
const n = W(t), e = "/node_modules/", o = n.lastIndexOf(e);
|
|
284
|
-
if (o === -1)
|
|
285
|
-
return;
|
|
286
|
-
const [r, a] = n.slice(o + e.length).split("/");
|
|
287
|
-
return r.startsWith("@") ? `${r}/${a}` : r;
|
|
288
|
-
}
|
|
289
|
-
function ce(t, n = [], e) {
|
|
290
|
-
const o = t[0];
|
|
291
|
-
if (o === void 0)
|
|
292
|
-
return "unknown package";
|
|
293
|
-
const r = O(o);
|
|
294
|
-
if (r !== void 0)
|
|
295
|
-
return r;
|
|
296
|
-
const a = n.find(({ root: c }) => N(o, c));
|
|
297
|
-
if (a !== void 0)
|
|
298
|
-
return a.name;
|
|
299
|
-
const i = g.dirname(h(o)), s = B(g.dirname(o), i);
|
|
300
|
-
if (s !== i)
|
|
301
|
-
return s;
|
|
302
|
-
if (e === void 0)
|
|
303
|
-
return i;
|
|
304
|
-
const d = g.relative(e, o).split("/"), u = d.findIndex((c) => c !== "..");
|
|
305
|
-
return u < 1 ? g.dirname(h(o)) : d.slice(0, u * 2).join("/");
|
|
306
|
-
}
|
|
307
|
-
export {
|
|
308
|
-
Pe as auditDeprecatedUsages,
|
|
309
|
-
Z as collectDeprecatedApiUsages,
|
|
310
|
-
ce as getDeprecationOriginLabel,
|
|
311
|
-
O as getNodeModulesPackageName,
|
|
312
|
-
R as shouldIncludeDeprecation
|
|
313
|
-
};
|
package/dist/sync-e0pgnEOM.js
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { readFile as E } from "node:fs/promises";
|
|
2
|
-
import { log as w } from "@arcgis/toolkit/log";
|
|
3
|
-
import { a as T, b as h, c as P, d as j, e as A, f as y } from "./config-BP6HDIQa.js";
|
|
4
|
-
import { collectOutput as m } from "@arcgis/node-toolkit/shell";
|
|
5
|
-
const C = `<!-- ${h} -->`, O = `<!-- ${h}`, M = 65536;
|
|
6
|
-
function b(n) {
|
|
7
|
-
const e = /* @__PURE__ */ new Map();
|
|
8
|
-
for (const t of n.findings) {
|
|
9
|
-
const o = f(t.codeowners), s = o.join(","), i = e.get(s) ?? [];
|
|
10
|
-
i.push({ ...t, codeowners: o }), e.set(s, i);
|
|
11
|
-
}
|
|
12
|
-
return [...e.entries()].map(([t, o]) => {
|
|
13
|
-
const s = t === "" ? [] : t.split(","), i = B(n, o);
|
|
14
|
-
return {
|
|
15
|
-
title: T[n.kind],
|
|
16
|
-
owners: s,
|
|
17
|
-
assignees: s.filter((r) => /^@[^/@\s]+$/u.test(r)).map((r) => r.slice(1)),
|
|
18
|
-
chunks: N(i, M, R(s))
|
|
19
|
-
};
|
|
20
|
-
}).sort((t, o) => t.title.localeCompare(o.title));
|
|
21
|
-
}
|
|
22
|
-
function B(n, e) {
|
|
23
|
-
const t = P[n.kind], o = f(e.flatMap((a) => a.codeowners)).filter(
|
|
24
|
-
(a) => /^@[^/@\s]+\/[^@\s]+$/u.test(a)
|
|
25
|
-
), s = o.length === 0 ? "" : `
|
|
26
|
-
|
|
27
|
-
CODEOWNERS: ${o.join(", ")}`, r = [...Map.groupBy(e, (a) => a.package).entries()].sort(([a], [p]) => a.localeCompare(p)).map(([a, p]) => {
|
|
28
|
-
const S = [...Map.groupBy(p, (u) => D(n.kind, u)).entries()].sort(([u], [l]) => u.localeCompare(l)).map(([, u]) => {
|
|
29
|
-
const [{ api: l }] = u, $ = [
|
|
30
|
-
...new Set(
|
|
31
|
-
u.map(({ reason: c }) => c).filter((c) => c !== null && c !== "")
|
|
32
|
-
)
|
|
33
|
-
], x = $.length === 0 ? "" : ` - ${$.map(G).join(" ")}`, d = [
|
|
34
|
-
...new Set(
|
|
35
|
-
u.toSorted((c, g) => c.file.localeCompare(g.file) || c.line - g.line).map((c) => J(n.repository, n.ref, c.file, c.line))
|
|
36
|
-
)
|
|
37
|
-
], v = d.length === 1 ? ` ${d[0]}` : d.map((c) => ` - ${c}`).join(`
|
|
38
|
-
`);
|
|
39
|
-
return `- [ ] \`${l}\`${x}
|
|
40
|
-
${v}`;
|
|
41
|
-
});
|
|
42
|
-
return `#### ${a}'s deprecations
|
|
43
|
-
|
|
44
|
-
${S.join(`
|
|
45
|
-
`)}`;
|
|
46
|
-
});
|
|
47
|
-
return `${t}${s}
|
|
48
|
-
|
|
49
|
-
${j}
|
|
50
|
-
|
|
51
|
-
${r.join(`
|
|
52
|
-
|
|
53
|
-
`)}`;
|
|
54
|
-
}
|
|
55
|
-
function N(n, e = M, t = C) {
|
|
56
|
-
const o = `${t}
|
|
57
|
-
`, s = e - o.length;
|
|
58
|
-
if (s < 1)
|
|
59
|
-
throw new Error("Issue content limit is too small for the managed marker.");
|
|
60
|
-
const i = [];
|
|
61
|
-
let r = n;
|
|
62
|
-
for (; r.length > s; ) {
|
|
63
|
-
const a = r.lastIndexOf(`
|
|
64
|
-
`, s), p = a > 0 ? a : s;
|
|
65
|
-
i.push(o + r.slice(0, p)), r = r.slice(p + (a > 0 ? 1 : 0));
|
|
66
|
-
}
|
|
67
|
-
return i.push(o + r), i;
|
|
68
|
-
}
|
|
69
|
-
function R(n) {
|
|
70
|
-
return n.length === 0 ? C : `<!-- ${h} ${f(n).join(",")} -->`;
|
|
71
|
-
}
|
|
72
|
-
function f(n) {
|
|
73
|
-
return [...new Set(n)].sort((e, t) => e.localeCompare(t));
|
|
74
|
-
}
|
|
75
|
-
function D(n, e) {
|
|
76
|
-
return n === "definitions" ? `${e.api}\0${L(e.file)}` : e.api;
|
|
77
|
-
}
|
|
78
|
-
function L(n) {
|
|
79
|
-
const e = "/src/", t = "/dist/", o = n.lastIndexOf(e), s = n.lastIndexOf(t), i = Math.max(o, s), r = s > o ? t : e;
|
|
80
|
-
return (i === -1 ? n : n.slice(i + r.length)).replace(/\.(?:d\.)?(?:[cm]?ts|tsx)$/u, "");
|
|
81
|
-
}
|
|
82
|
-
function G(n) {
|
|
83
|
-
const e = [], t = (i) => `\0${e.push(i) - 1}\0`, s = n.replaceAll(`\r
|
|
84
|
-
`, `
|
|
85
|
-
`).replaceAll("\r", `
|
|
86
|
-
`).replace(
|
|
87
|
-
/\[([^\]\n]+)\]\((https?:\/\/(?:[^()\s]|\([^()\s]*\))+?)\)/gu,
|
|
88
|
-
(i, r, a) => t(`[${I(r)}](${a})`)
|
|
89
|
-
).replace(/https?:\/\/[^\s<>()]+/gu, (i) => {
|
|
90
|
-
const r = /[.,;:!?]+$/u.exec(i)?.[0] ?? "";
|
|
91
|
-
return `${t(i.slice(0, -r.length || void 0))}${r}`;
|
|
92
|
-
});
|
|
93
|
-
return I(s).replace(/\0(\d+)\0/gu, (i, r) => e[Number(r)]).replaceAll(`
|
|
94
|
-
`, `
|
|
95
|
-
`);
|
|
96
|
-
}
|
|
97
|
-
function I(n) {
|
|
98
|
-
return n.replace(/^(\s*)(#{1,6})(?=\s)/gmu, "$1\\$2").replace(/#(?=\d)/gu, "# ");
|
|
99
|
-
}
|
|
100
|
-
function J(n, e, t, o) {
|
|
101
|
-
const s = e.split("/").map(encodeURIComponent).join("/"), i = t.split("/").map(encodeURIComponent).join("/");
|
|
102
|
-
return `https://${n}/blob/${s}/${i}#L${o}`;
|
|
103
|
-
}
|
|
104
|
-
class z {
|
|
105
|
-
#s;
|
|
106
|
-
#e;
|
|
107
|
-
constructor(e) {
|
|
108
|
-
const [t, o, s, ...i] = e.split("/");
|
|
109
|
-
if (t === void 0 || o === void 0 || s === void 0 || i.length > 0)
|
|
110
|
-
throw new Error(`Invalid repository: ${e}`);
|
|
111
|
-
this.#s = t, this.#e = `${o}/${s}`;
|
|
112
|
-
}
|
|
113
|
-
async #t(e, t, o) {
|
|
114
|
-
if (process.env.VITEST !== void 0)
|
|
115
|
-
throw new Error("GitHub requests are disabled while running Vitest.");
|
|
116
|
-
const s = await m(
|
|
117
|
-
"gh",
|
|
118
|
-
["api", "--hostname", this.#s, "--method", e, t, ...o === void 0 ? [] : ["--input", "-"]],
|
|
119
|
-
o === void 0 ? {} : { input: JSON.stringify(o) }
|
|
120
|
-
);
|
|
121
|
-
return s === "" ? void 0 : JSON.parse(s);
|
|
122
|
-
}
|
|
123
|
-
async listOpenIssues(e) {
|
|
124
|
-
const t = await m("gh", [
|
|
125
|
-
"api",
|
|
126
|
-
"--hostname",
|
|
127
|
-
this.#s,
|
|
128
|
-
"--method",
|
|
129
|
-
"GET",
|
|
130
|
-
"--paginate",
|
|
131
|
-
"--slurp",
|
|
132
|
-
"-f",
|
|
133
|
-
`q="${e}" in:title repo:${this.#e} is:issue is:open`,
|
|
134
|
-
"-f",
|
|
135
|
-
"per_page=100",
|
|
136
|
-
"/search/issues"
|
|
137
|
-
]);
|
|
138
|
-
return JSON.parse(t).flatMap(({ items: o }) => o);
|
|
139
|
-
}
|
|
140
|
-
async createIssue(e, t, o, s) {
|
|
141
|
-
return await this.#t("POST", `/repos/${this.#e}/issues`, {
|
|
142
|
-
title: e,
|
|
143
|
-
body: t,
|
|
144
|
-
assignees: o,
|
|
145
|
-
labels: s,
|
|
146
|
-
type: A
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
async updateIssueBody(e, t) {
|
|
150
|
-
await this.#t("PATCH", `/repos/${this.#e}/issues/${e}`, { body: t });
|
|
151
|
-
}
|
|
152
|
-
async listComments(e) {
|
|
153
|
-
const t = await m("gh", [
|
|
154
|
-
"api",
|
|
155
|
-
"--hostname",
|
|
156
|
-
this.#s,
|
|
157
|
-
"--method",
|
|
158
|
-
"GET",
|
|
159
|
-
"--paginate",
|
|
160
|
-
"--slurp",
|
|
161
|
-
`/repos/${this.#e}/issues/${e}/comments?per_page=100`
|
|
162
|
-
]);
|
|
163
|
-
return JSON.parse(t).flat();
|
|
164
|
-
}
|
|
165
|
-
async createComment(e, t) {
|
|
166
|
-
await this.#t("POST", `/repos/${this.#e}/issues/${e}/comments`, { body: t });
|
|
167
|
-
}
|
|
168
|
-
async updateComment(e, t) {
|
|
169
|
-
await this.#t("PATCH", `/repos/${this.#e}/issues/comments/${e}`, { body: t });
|
|
170
|
-
}
|
|
171
|
-
async deleteComment(e) {
|
|
172
|
-
await this.#t("DELETE", `/repos/${this.#e}/issues/comments/${e}`);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
async function Z(n, e, t = 0, o, s = []) {
|
|
176
|
-
const i = W(await E(n, "utf8")), r = H(b(i), t, o);
|
|
177
|
-
if (e) {
|
|
178
|
-
process.stdout.write(`${_(r)}
|
|
179
|
-
`);
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
const a = new z(i.repository);
|
|
183
|
-
await U(r, a, s);
|
|
184
|
-
}
|
|
185
|
-
function H(n, e, t) {
|
|
186
|
-
return n.slice(e, t === void 0 ? void 0 : e + t);
|
|
187
|
-
}
|
|
188
|
-
async function U(n, e, t = []) {
|
|
189
|
-
const o = /* @__PURE__ */ new Map();
|
|
190
|
-
for (const s of n) {
|
|
191
|
-
let i = o.get(s.title);
|
|
192
|
-
i === void 0 && (i = await e.listOpenIssues(s.title), o.set(s.title, i));
|
|
193
|
-
const r = q(i, s);
|
|
194
|
-
let a;
|
|
195
|
-
r === void 0 ? (a = (await e.createIssue(s.title, s.chunks[0], s.assignees, t)).number, w("info", y, `Created issue #${a}: ${s.title}`)) : (a = r.number, r.body !== s.chunks[0] && (await e.updateIssueBody(a, s.chunks[0]), w("info", y, `Updated issue #${a}: ${s.title}`))), await V(e, a, s.chunks.slice(1));
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
function W(n) {
|
|
199
|
-
const e = JSON.parse(n);
|
|
200
|
-
if (e.kind !== "usages" && e.kind !== "definitions" || typeof e.repository != "string" || typeof e.ref != "string" || !Array.isArray(e.findings))
|
|
201
|
-
throw new Error("Invalid deprecation audit JSON.");
|
|
202
|
-
return e;
|
|
203
|
-
}
|
|
204
|
-
function _(n) {
|
|
205
|
-
return n.map(
|
|
206
|
-
(e) => `CODEOWNERS: ${e.owners.length === 0 ? "unowned" : e.owners.join(", ")}
|
|
207
|
-
ASSIGNEES: ${e.assignees.length === 0 ? "none" : e.assignees.join(", ")}
|
|
208
|
-
TITLE: ${e.title}
|
|
209
|
-
|
|
210
|
-
${e.chunks.map((t, o) => `--- ${o === 0 ? "BODY" : "COMMENT"} (${o + 1}/${e.chunks.length}) ---
|
|
211
|
-
${t}`).join(`
|
|
212
|
-
|
|
213
|
-
`)}`
|
|
214
|
-
).join(`
|
|
215
|
-
|
|
216
|
-
`);
|
|
217
|
-
}
|
|
218
|
-
function q(n, e) {
|
|
219
|
-
const t = k(e.chunks[0]);
|
|
220
|
-
return n.find((o) => o.title === e.title && k(o.body) === t);
|
|
221
|
-
}
|
|
222
|
-
function k(n) {
|
|
223
|
-
const e = n?.split(`
|
|
224
|
-
`, 1)[0];
|
|
225
|
-
return e?.startsWith(O) === !0 ? e : void 0;
|
|
226
|
-
}
|
|
227
|
-
async function V(n, e, t) {
|
|
228
|
-
const o = (await n.listComments(e)).filter(({ body: s }) => s.startsWith(O));
|
|
229
|
-
for (const [s, i] of t.entries()) {
|
|
230
|
-
const r = o[s];
|
|
231
|
-
r === void 0 ? await n.createComment(e, i) : r.body !== i && await n.updateComment(r.id, i);
|
|
232
|
-
}
|
|
233
|
-
for (const s of o.slice(t.length))
|
|
234
|
-
await n.deleteComment(s.id);
|
|
235
|
-
}
|
|
236
|
-
export {
|
|
237
|
-
H as sliceIssuePlans,
|
|
238
|
-
Z as syncDeprecationIssues,
|
|
239
|
-
U as synchronizeIssuePlans
|
|
240
|
-
};
|