@arcgis/codemod 6.0.0-next.3 → 6.0.0-next.30
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/artifact.js +48 -0
- package/dist/chunks/classification.js +131 -141
- package/dist/chunks/cli.js +388 -223
- package/dist/chunks/codemod5.js +0 -1
- package/dist/chunks/codemod7.js +1214 -1232
- package/dist/chunks/componentAudit.js +258 -0
- package/dist/chunks/format.js +109 -105
- package/dist/chunks/github.js +124 -0
- package/dist/chunks/index.js +919 -308
- package/dist/chunks/index2.js +116 -103
- package/dist/chunks/index3.js +342 -0
- package/dist/chunks/sync.js +44 -142
- package/dist/chunks/syncMarkdown.js +32 -0
- package/dist/chunks/useProjectInstance.js +27 -24
- package/package.json +7 -5
- package/dist/chunks/hardcodedBehavior.js +0 -63
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import k from "typescript";
|
|
2
|
+
import { findPath as S, asyncFindPath as y } from "@arcgis/node-toolkit/file";
|
|
3
|
+
import { path as p } from "@arcgis/node-toolkit/path";
|
|
4
|
+
import { retrievePackageJson as v, asyncRetrievePackageJson as E } from "@arcgis/node-toolkit/packageJson";
|
|
5
|
+
import { log as b } from "@arcgis/toolkit/log";
|
|
6
|
+
import { realpath as h, readFile as x, readdir as j } from "node:fs/promises";
|
|
7
|
+
import { f as D } from "./log.js";
|
|
8
|
+
import { b as $ } from "./cli.js";
|
|
9
|
+
import { s as M } from "./classification.js";
|
|
10
|
+
function V(e) {
|
|
11
|
+
return typeof e == "string" ? e : e.map((n) => n.kind === k.SyntaxKind.JSDocText ? n.text : O(n.getText())).join("");
|
|
12
|
+
}
|
|
13
|
+
function W(e) {
|
|
14
|
+
return e === void 0 ? void 0 : N(k.displayPartsToString([...e]));
|
|
15
|
+
}
|
|
16
|
+
function N(e) {
|
|
17
|
+
return e.replace(
|
|
18
|
+
/\{@link(?:code|plain)?\s+([\s\S]*?)\}/gu,
|
|
19
|
+
(n, s) => P(s)
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
function O(e) {
|
|
23
|
+
const n = /^\{@link(?:code|plain)?\s+([\s\S]*?)\}$/u.exec(e)?.[1];
|
|
24
|
+
return n === void 0 ? e : P(n);
|
|
25
|
+
}
|
|
26
|
+
function P(e) {
|
|
27
|
+
const n = e.trim().replace(/^(\S+)\s+([/:#!.])/u, "$1$2"), s = n.indexOf("|");
|
|
28
|
+
if (s !== -1)
|
|
29
|
+
return n.slice(s + 1).trim() || n.slice(0, s).trim();
|
|
30
|
+
const [a, ...i] = n.split(/\s+/u);
|
|
31
|
+
return i.join(" ") || a;
|
|
32
|
+
}
|
|
33
|
+
function q(e, n) {
|
|
34
|
+
const s = S("package.json", e);
|
|
35
|
+
return s === void 0 ? n : v(p.dirname(s)).name ?? n;
|
|
36
|
+
}
|
|
37
|
+
const m = {
|
|
38
|
+
docsLegacyDependencyLocations: /* @__PURE__ */ new Map([
|
|
39
|
+
["@arcgis/coding-components", "packages/coding-packages/coding-components"],
|
|
40
|
+
["@arcgis/core", "packages/core-packages/core/output/npm/esm"],
|
|
41
|
+
["@arcgis/lumina", "packages/support-packages/lit"],
|
|
42
|
+
["@arcgis/map-components", "packages/map-packages/map-components"],
|
|
43
|
+
["@arcgis/toolkit", "packages/support-packages/toolkit"],
|
|
44
|
+
["@esri/calcite-components", "packages/map-packages/map-components/node_modules/@esri/calcite-components"],
|
|
45
|
+
["@esri/calcite-components-react", "packages/docs/app/node_modules/@esri/calcite-components-react"],
|
|
46
|
+
["monaco-editor", "packages/docs/app/node_modules/monaco-editor"]
|
|
47
|
+
]),
|
|
48
|
+
excludedPackageNames: /* @__PURE__ */ new Set(),
|
|
49
|
+
excludedPathFragments: ["/.astro/"],
|
|
50
|
+
excludedDefinitionPathFragments: ["test-package", "packages/docs/lumina-code-samples/", "packages/starter-packages/"],
|
|
51
|
+
ignoreDeprecatedApis: [],
|
|
52
|
+
ignoredDeprecationsByIncludes: []
|
|
53
|
+
};
|
|
54
|
+
function G(e) {
|
|
55
|
+
const n = /* @__PURE__ */ new Map(), s = {};
|
|
56
|
+
if (e?.contents.name !== "@webgis/docs")
|
|
57
|
+
return { packages: n, paths: s };
|
|
58
|
+
const a = p.dirname(e.filePath), i = p.resolve(a, "../../..");
|
|
59
|
+
if (p.relative(i, a) !== "packages/docs/app" || !k.sys.fileExists(p.join(i, "pnpm-workspace.yaml")))
|
|
60
|
+
return { packages: n, paths: s };
|
|
61
|
+
const o = new Set(
|
|
62
|
+
Object.entries({
|
|
63
|
+
...e.contents.dependencies,
|
|
64
|
+
...e.contents.devDependencies,
|
|
65
|
+
...e.contents.peerDependencies,
|
|
66
|
+
...e.contents.optionalDependencies
|
|
67
|
+
}).filter(([, t]) => t === "catalog:legacyStarshipDeps").map(([t]) => t)
|
|
68
|
+
);
|
|
69
|
+
if (o.size === 0)
|
|
70
|
+
throw Error(
|
|
71
|
+
"Didn't find any catalog:legacyStarshipDeps in @webgis/docs. Update special handling in @arcgis/codemod"
|
|
72
|
+
);
|
|
73
|
+
for (const t of o) {
|
|
74
|
+
const r = m.docsLegacyDependencyLocations.get(t);
|
|
75
|
+
if (r === void 0)
|
|
76
|
+
throw new Error(
|
|
77
|
+
`Unmapped legacy dependency ${t} in @webgis/docs. Update special handling in @arcgis/codemod.`
|
|
78
|
+
);
|
|
79
|
+
const c = p.join(i, r), d = p.join(c, "package.json");
|
|
80
|
+
if (!k.sys.fileExists(d))
|
|
81
|
+
throw new Error(
|
|
82
|
+
`Missing audit dependency ${t} at ${d}. Install dependencies and build workspace packages before auditing usages.`
|
|
83
|
+
);
|
|
84
|
+
const u = v(c);
|
|
85
|
+
n.set(t, d);
|
|
86
|
+
for (const [f, l] of Object.entries(
|
|
87
|
+
u.exports ?? { ".": u.types ?? "./index.d.ts", "./*": "./*" }
|
|
88
|
+
)) {
|
|
89
|
+
const w = typeof l == "string" ? l : l.types;
|
|
90
|
+
w !== void 0 && (s[f === "." ? t : `${t}/${f.slice(2)}`] = [p.resolve(c, w)]);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return { packages: n, paths: s };
|
|
94
|
+
}
|
|
95
|
+
function H(e) {
|
|
96
|
+
return e !== void 0 && m.excludedPackageNames.has(e);
|
|
97
|
+
}
|
|
98
|
+
function T(e) {
|
|
99
|
+
return m.excludedPathFragments.some((n) => `/${e}`.includes(n));
|
|
100
|
+
}
|
|
101
|
+
function Q(e) {
|
|
102
|
+
return T(e) || m.excludedDefinitionPathFragments.some((n) => e.includes(n));
|
|
103
|
+
}
|
|
104
|
+
function X(e, n) {
|
|
105
|
+
return m.ignoreDeprecatedApis.some((s) => s === e) || n != null && m.ignoredDeprecationsByIncludes.some((s) => n.includes(s));
|
|
106
|
+
}
|
|
107
|
+
function C(e, n, s) {
|
|
108
|
+
const a = JSON.parse(e), i = { modulePaths: /* @__PURE__ */ new Map(), definitions: [], components: /* @__PURE__ */ new Set() };
|
|
109
|
+
for (const o of a.modules) {
|
|
110
|
+
o.sourcePath !== void 0 && i.modulePaths.set(M(o.sourcePath), o.path);
|
|
111
|
+
for (const t of o.declarations ?? []) {
|
|
112
|
+
let r = function(d, u, f, l) {
|
|
113
|
+
f !== !0 && typeof f != "string" || i.definitions.push({
|
|
114
|
+
package: s,
|
|
115
|
+
module: o.path,
|
|
116
|
+
name: l ?? d,
|
|
117
|
+
kind: l === void 0 ? u : "field",
|
|
118
|
+
memberOf: l === void 0 ? u === "element" ? void 0 : c : t.name,
|
|
119
|
+
...l === void 0 ? {} : { attribute: { tagName: c, name: d } },
|
|
120
|
+
provenance: "manifest",
|
|
121
|
+
reason: typeof f == "string" ? f : void 0,
|
|
122
|
+
sourceFileName: n,
|
|
123
|
+
line: 1,
|
|
124
|
+
column: 1
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
if (!("tagName" in t) || t.tagName === void 0)
|
|
128
|
+
continue;
|
|
129
|
+
const c = t.tagName;
|
|
130
|
+
i.components.add(c), r(c, "element", t.deprecated);
|
|
131
|
+
for (const [d, u] of [
|
|
132
|
+
["cssProperties", "css-property"],
|
|
133
|
+
["cssParts", "css-part"],
|
|
134
|
+
["cssStates", "css-state"],
|
|
135
|
+
["slots", "slot"]
|
|
136
|
+
])
|
|
137
|
+
for (const f of t[d] ?? [])
|
|
138
|
+
d === "slots" && f.name === "" || r(f.name, u, f.deprecated);
|
|
139
|
+
for (const d of t.attributes ?? [])
|
|
140
|
+
r(d.name, "attribute", d.deprecated, d.fieldName);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return i;
|
|
144
|
+
}
|
|
145
|
+
function Y(e) {
|
|
146
|
+
const n = e.flatMap((o) => o.definitions), s = /* @__PURE__ */ new Map();
|
|
147
|
+
for (const o of e)
|
|
148
|
+
for (const t of o.components) {
|
|
149
|
+
const r = s.get(t) ?? [];
|
|
150
|
+
r.push(o), s.set(t, r);
|
|
151
|
+
}
|
|
152
|
+
const a = /* @__PURE__ */ new Map(), i = Map.groupBy(
|
|
153
|
+
n.filter(({ kind: o }) => o === "css-property"),
|
|
154
|
+
({ name: o }) => o
|
|
155
|
+
);
|
|
156
|
+
for (const [o, t] of i)
|
|
157
|
+
new Set(t.map((r) => r.package)).size === 1 && a.set(o, t[0]);
|
|
158
|
+
return { hasDeprecatedApis: n.length > 0, components: s, cssVariables: a };
|
|
159
|
+
}
|
|
160
|
+
function Z(e = "warn", n) {
|
|
161
|
+
const s = /* @__PURE__ */ new Map();
|
|
162
|
+
return async (a) => {
|
|
163
|
+
const i = await h(a);
|
|
164
|
+
let o = s.get(i);
|
|
165
|
+
return o === void 0 && (o = F(i, n).catch((t) => {
|
|
166
|
+
if (n?.(), e === "throw")
|
|
167
|
+
throw new Error(
|
|
168
|
+
`Unable to read component manifest for ${i}. Build the package before auditing definitions.`,
|
|
169
|
+
{ cause: t }
|
|
170
|
+
);
|
|
171
|
+
b("warn", D(i), `Unable to read component manifest: ${String(t)}`);
|
|
172
|
+
}), s.set(i, o)), await o;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
async function ee(e, n, s, a) {
|
|
176
|
+
const i = /* @__PURE__ */ new Set([
|
|
177
|
+
...Object.keys(e.contents.dependencies ?? {}),
|
|
178
|
+
...Object.keys(e.contents.devDependencies ?? {}),
|
|
179
|
+
...Object.keys(e.contents.peerDependencies ?? {}),
|
|
180
|
+
...Object.keys(e.contents.optionalDependencies ?? {})
|
|
181
|
+
]), o = await Promise.all(
|
|
182
|
+
[...i].filter((t) => t !== e.contents.name && (!s || $(t))).map(async (t) => {
|
|
183
|
+
const r = a?.get(t) ?? await y(p.join("node_modules", t, "package.json"), p.dirname(e.filePath));
|
|
184
|
+
if (r === void 0)
|
|
185
|
+
return [];
|
|
186
|
+
const c = await n(r), d = t === "@esri/calcite-components" ? await y(
|
|
187
|
+
"node_modules/@esri/calcite-design-tokens/package.json",
|
|
188
|
+
p.dirname(await h(r))
|
|
189
|
+
) : void 0;
|
|
190
|
+
return [c, d === void 0 ? void 0 : await n(d)];
|
|
191
|
+
})
|
|
192
|
+
);
|
|
193
|
+
return [...new Set(o.flat().filter((t) => t !== void 0))];
|
|
194
|
+
}
|
|
195
|
+
async function F(e, n) {
|
|
196
|
+
const s = p.dirname(e), a = await E(s);
|
|
197
|
+
if (a.name === "@esri/calcite-design-tokens")
|
|
198
|
+
try {
|
|
199
|
+
return await L(s, a.name);
|
|
200
|
+
} catch (t) {
|
|
201
|
+
n?.(), b("error", D(s), `Calcite design tokens integration is out of date: ${String(t)}`);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const i = typeof a.customElements == "string" ? a.customElements : a.customElements?.[0];
|
|
205
|
+
if (i === void 0)
|
|
206
|
+
return;
|
|
207
|
+
const o = await h(p.resolve(s, i));
|
|
208
|
+
return C(await x(o, "utf8"), o, a.name);
|
|
209
|
+
}
|
|
210
|
+
async function L(e, n) {
|
|
211
|
+
const s = p.join(e, "dist/docs"), a = /* @__PURE__ */ new Map(), i = (await j(s)).filter((o) => o.endsWith(".json")).sort();
|
|
212
|
+
if (i.length === 0)
|
|
213
|
+
throw new Error(`Missing token documentation JSON files in ${s}`);
|
|
214
|
+
for (const o of i) {
|
|
215
|
+
const t = await h(p.join(s, o)), r = JSON.parse(await x(t, "utf8"));
|
|
216
|
+
if (!g(r) || !Array.isArray(r.tokens))
|
|
217
|
+
throw new Error(`Expected a tokens array in ${t}`);
|
|
218
|
+
for (const c of r.tokens) {
|
|
219
|
+
if (!g(c) || !g(c.attributes) || c.attributes.docs !== void 0 && typeof c.attributes.docs != "string" || c.attributes.status !== void 0 && typeof c.attributes.status != "string" || !g(c.attributes.names) || typeof c.attributes.names.css != "string" || !/^var\(--[-\w]+\)$/u.test(c.attributes.names.css))
|
|
220
|
+
throw new Error(`Expected token attributes.docs/status and attributes.names.css in ${t}`);
|
|
221
|
+
if (c.attributes.docs !== "deprecated" && c.attributes.status !== "deprecated")
|
|
222
|
+
continue;
|
|
223
|
+
const d = c.$description ?? c.description;
|
|
224
|
+
if (typeof d != "string")
|
|
225
|
+
throw new Error(`Expected a deprecated token's $description or description in ${t}`);
|
|
226
|
+
const u = c.attributes.names.css.slice(4, -1);
|
|
227
|
+
a.has(u) || a.set(u, {
|
|
228
|
+
package: n,
|
|
229
|
+
name: u,
|
|
230
|
+
kind: "css-property",
|
|
231
|
+
provenance: "manifest",
|
|
232
|
+
reason: d,
|
|
233
|
+
sourceFileName: t,
|
|
234
|
+
line: 1,
|
|
235
|
+
column: 1
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (a.size === 0)
|
|
240
|
+
throw new Error(`Expected tokens marked with attributes.docs or attributes.status = "deprecated" in ${s}`);
|
|
241
|
+
return { modulePaths: /* @__PURE__ */ new Map(), definitions: [...a.values()], components: /* @__PURE__ */ new Set() };
|
|
242
|
+
}
|
|
243
|
+
function g(e) {
|
|
244
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
245
|
+
}
|
|
246
|
+
export {
|
|
247
|
+
T as a,
|
|
248
|
+
X as b,
|
|
249
|
+
Y as c,
|
|
250
|
+
q as d,
|
|
251
|
+
Z as e,
|
|
252
|
+
V as f,
|
|
253
|
+
G as g,
|
|
254
|
+
W as h,
|
|
255
|
+
Q as i,
|
|
256
|
+
ee as l,
|
|
257
|
+
H as s
|
|
258
|
+
};
|
package/dist/chunks/format.js
CHANGED
|
@@ -1,70 +1,71 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { h as D, k as d, l as b, m as v, d as w } from "./cli.js";
|
|
2
|
+
import { g as B, i as K, b as $, d as k } from "./classification.js";
|
|
3
|
+
import { markdownTextLimit as y, splitMarkdown as O } from "@arcgis/node-toolkit/markdown";
|
|
4
|
+
const M = `<!-- ${d} -->`, X = `<!-- ${d}`;
|
|
5
|
+
function Y(n) {
|
|
6
|
+
const e = j(n, n.findings);
|
|
7
|
+
return `${e.summary.trim().replace(/^### /u, "## ")}
|
|
7
8
|
|
|
8
|
-
${
|
|
9
|
+
${e.details}`;
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
for (const o of
|
|
13
|
-
const
|
|
14
|
-
t.push({ ...o, codeowners:
|
|
11
|
+
function Z(n) {
|
|
12
|
+
const e = /* @__PURE__ */ new Map();
|
|
13
|
+
for (const o of n.findings) {
|
|
14
|
+
const s = f(o.codeowners), r = s.join(","), t = e.get(r) ?? [];
|
|
15
|
+
t.push({ ...o, codeowners: s }), e.set(r, t);
|
|
15
16
|
}
|
|
16
|
-
return [...
|
|
17
|
-
const
|
|
17
|
+
return [...e.entries()].map(([o, s]) => {
|
|
18
|
+
const r = o === "" ? [] : o.split(","), t = L(n, s);
|
|
18
19
|
return {
|
|
19
20
|
changes: [],
|
|
20
|
-
title:
|
|
21
|
-
owners:
|
|
22
|
-
assignees:
|
|
23
|
-
chunks:
|
|
21
|
+
title: D[n.auditKind],
|
|
22
|
+
owners: r,
|
|
23
|
+
assignees: r.filter((a) => /^@[^/@\s]+$/u.test(a)).map((a) => a.slice(1)),
|
|
24
|
+
chunks: _(t, y, G(r))
|
|
24
25
|
};
|
|
25
|
-
}).sort((o,
|
|
26
|
+
}).sort((o, s) => o.owners.join(",").localeCompare(s.owners.join(",")));
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
-
const o =
|
|
29
|
-
(
|
|
30
|
-
),
|
|
28
|
+
function L(n, e) {
|
|
29
|
+
const o = f(e.flatMap((r) => r.codeowners)).filter(
|
|
30
|
+
(r) => /^@[^/@\s]+\/[^@\s]+$/u.test(r)
|
|
31
|
+
), s = o.length === 0 ? "" : `
|
|
31
32
|
|
|
32
33
|
CODEOWNERS: ${o.join(", ")}`;
|
|
33
|
-
return
|
|
34
|
+
return U(n, e, s);
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
-
const
|
|
37
|
-
return `${
|
|
36
|
+
function U(n, e, o) {
|
|
37
|
+
const s = b[n.auditKind], r = j(n, e);
|
|
38
|
+
return `${s}${o}${r.summary}
|
|
38
39
|
|
|
39
|
-
${
|
|
40
|
+
${v}
|
|
40
41
|
|
|
41
|
-
${
|
|
42
|
+
${r.details}`;
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
-
return
|
|
44
|
+
function j(n, e) {
|
|
45
|
+
return n.auditKind === "usages" ? z(n, e) : E(n, e);
|
|
45
46
|
}
|
|
46
|
-
function
|
|
47
|
-
const o =
|
|
48
|
-
const u =
|
|
47
|
+
function z(n, e) {
|
|
48
|
+
const o = x(e, "usages"), s = B(e, (a) => a), r = s.map(({ categoryName: a, count: c, packages: m }) => {
|
|
49
|
+
const u = m.map(({ displayName: p, count: i }) => ` - \`${p}\`: ${i}`).join(`
|
|
49
50
|
`);
|
|
50
|
-
return `- **${
|
|
51
|
+
return `- **${w[a].label}**: ${c}
|
|
51
52
|
${u}`;
|
|
52
53
|
}).join(`
|
|
53
|
-
`), t =
|
|
54
|
-
const u =
|
|
55
|
-
const
|
|
56
|
-
({ items: R }) =>
|
|
54
|
+
`), t = s.map(({ categoryName: a, count: c, packages: m }) => {
|
|
55
|
+
const u = m.map(({ displayName: l, count: A, apis: C }) => {
|
|
56
|
+
const P = C.flatMap(
|
|
57
|
+
({ items: R }) => I(n, R, "usages", o)
|
|
57
58
|
);
|
|
58
|
-
return `#### ${
|
|
59
|
+
return `#### ${l} (${A})
|
|
59
60
|
|
|
60
|
-
${
|
|
61
|
+
${P.join(`
|
|
61
62
|
`)}`;
|
|
62
63
|
}).join(`
|
|
63
64
|
|
|
64
|
-
`), p =
|
|
65
|
+
`), p = w[a], i = "description" in p ? `
|
|
65
66
|
|
|
66
67
|
${p.description}` : "";
|
|
67
|
-
return `### ${p.label} (${c})${
|
|
68
|
+
return `### ${p.label} (${c})${i}
|
|
68
69
|
|
|
69
70
|
${u}`;
|
|
70
71
|
}).join(`
|
|
@@ -75,24 +76,27 @@ ${u}`;
|
|
|
75
76
|
|
|
76
77
|
### Deprecation summary
|
|
77
78
|
|
|
78
|
-
${
|
|
79
|
+
${r}`,
|
|
79
80
|
details: `## Deprecation details
|
|
80
81
|
|
|
81
82
|
${t}`
|
|
82
83
|
};
|
|
83
84
|
}
|
|
84
|
-
function
|
|
85
|
+
function x(n, e) {
|
|
85
86
|
const o = /* @__PURE__ */ new Map();
|
|
86
|
-
for (const
|
|
87
|
-
const
|
|
88
|
-
t.add(`${
|
|
87
|
+
for (const s of n) {
|
|
88
|
+
const r = $(s), t = o.get(r) ?? /* @__PURE__ */ new Set();
|
|
89
|
+
t.add(`${s.package}\0${S(e, s)}`), o.set(r, t);
|
|
89
90
|
}
|
|
90
|
-
return new Set([...o].filter(([,
|
|
91
|
-
}
|
|
92
|
-
function
|
|
93
|
-
const o =
|
|
94
|
-
return { summary: "", details: [...Map.groupBy(
|
|
95
|
-
|
|
91
|
+
return new Set([...o].filter(([, s]) => s.size > 1).map(([s]) => s));
|
|
92
|
+
}
|
|
93
|
+
function E(n, e) {
|
|
94
|
+
const o = x(e, "definitions");
|
|
95
|
+
return { summary: "", details: [...Map.groupBy(
|
|
96
|
+
e,
|
|
97
|
+
(t) => K(t.package, t.module ?? g("definitions", t))
|
|
98
|
+
).entries()].sort(([t], [a]) => t.localeCompare(a)).map(([t, a]) => {
|
|
99
|
+
const c = I(n, a, "definitions", o);
|
|
96
100
|
return `#### ${t}'s deprecations
|
|
97
101
|
|
|
98
102
|
${c.join(`
|
|
@@ -101,84 +105,84 @@ ${c.join(`
|
|
|
101
105
|
|
|
102
106
|
`) };
|
|
103
107
|
}
|
|
104
|
-
function
|
|
105
|
-
const
|
|
106
|
-
return
|
|
107
|
-
const
|
|
108
|
-
return
|
|
108
|
+
function I(n, e, o, s) {
|
|
109
|
+
const r = [...Map.groupBy(e, (t) => S(o, t))];
|
|
110
|
+
return r.sort(([t], [a]) => t.localeCompare(a)), r.map(([, t]) => {
|
|
111
|
+
const a = $(t[0]), c = g(o, t[0]), m = c !== void 0 && s.has(a) ? `${c} ${a}` : a, u = T(t);
|
|
112
|
+
return u.sort((p, i) => p.localeCompare(i)), N(n, m, u, t, o);
|
|
109
113
|
});
|
|
110
114
|
}
|
|
111
|
-
function
|
|
112
|
-
const
|
|
115
|
+
function N(n, e, o, s, r) {
|
|
116
|
+
const t = o.length === 0 ? "" : ` - ${o.map(q).join(" ")}`, a = [
|
|
117
|
+
...new Set(
|
|
118
|
+
s.filter((i) => r === "usages" || i.provenance !== "manifest").toSorted((i, l) => i.file.localeCompare(l.file) || i.line - l.line).map((i) => H(n.repository, n.ref, i.file, i.line))
|
|
119
|
+
)
|
|
120
|
+
], c = a.length === 1 ? ` ${a[0]}` : a.map((i) => ` - ${i}`).join(`
|
|
121
|
+
`), m = s[0].kind, u = [
|
|
113
122
|
...new Set(
|
|
114
|
-
|
|
123
|
+
s.filter(
|
|
124
|
+
(i) => r === "definitions" && i.provenance === "manifest" && i.kind === "css-property"
|
|
125
|
+
).flatMap(({ memberOf: i }) => i === void 0 ? [] : [i])
|
|
115
126
|
)
|
|
116
|
-
],
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
${s}`;
|
|
127
|
+
].sort(), p = u.length === 0 ? "" : ` (components: ${u.map((i) => `\`<${i}>\``).join(", ")})`;
|
|
128
|
+
return `- [ ] \`${e}\`${k(m)}${p}${t}${c === "" ? "" : `
|
|
129
|
+
${c}`}`;
|
|
120
130
|
}
|
|
121
|
-
function T(
|
|
131
|
+
function T(n) {
|
|
122
132
|
return [
|
|
123
133
|
...new Set(
|
|
124
|
-
|
|
134
|
+
n.map(({ deprecated: e }) => e).filter((e) => typeof e == "string" && e !== "")
|
|
125
135
|
)
|
|
126
136
|
];
|
|
127
137
|
}
|
|
128
|
-
function
|
|
129
|
-
const
|
|
130
|
-
`,
|
|
131
|
-
if (
|
|
138
|
+
function _(n, e = y, o = M) {
|
|
139
|
+
const s = `${o}
|
|
140
|
+
`, r = e - s.length;
|
|
141
|
+
if (r < 1)
|
|
132
142
|
throw new Error("Issue content limit is too small for the managed marker.");
|
|
133
|
-
|
|
134
|
-
let s = e;
|
|
135
|
-
for (; s.length > i; ) {
|
|
136
|
-
const c = s.lastIndexOf(`
|
|
137
|
-
`, i), a = c > 0 ? c : i;
|
|
138
|
-
t.push(r + s.slice(0, a)), s = s.slice(a + (c > 0 ? 1 : 0));
|
|
139
|
-
}
|
|
140
|
-
return t.push(r + s), t;
|
|
143
|
+
return O(n, r).map((t) => s + t);
|
|
141
144
|
}
|
|
142
|
-
function
|
|
143
|
-
return
|
|
145
|
+
function G(n) {
|
|
146
|
+
return n.length === 0 ? M : `<!-- ${d} ${f(n).join(",")} -->`;
|
|
144
147
|
}
|
|
145
|
-
function
|
|
146
|
-
return [...new Set(
|
|
148
|
+
function f(n) {
|
|
149
|
+
return [...new Set(n)].sort((e, o) => e.localeCompare(o));
|
|
147
150
|
}
|
|
148
|
-
function
|
|
149
|
-
return `${
|
|
151
|
+
function S(n, e) {
|
|
152
|
+
return `${$(e)}${k(e.kind)}\0${g(n, e) ?? ""}`;
|
|
150
153
|
}
|
|
151
|
-
function
|
|
152
|
-
return
|
|
154
|
+
function g(n, e) {
|
|
155
|
+
return n === "definitions" && e.provenance !== "manifest" ? W(e.file) : e.module;
|
|
153
156
|
}
|
|
154
|
-
function
|
|
155
|
-
const
|
|
156
|
-
return (t === -1 ?
|
|
157
|
+
function W(n) {
|
|
158
|
+
const e = "/src/", o = "/dist/", s = n.lastIndexOf(e), r = n.lastIndexOf(o), t = Math.max(s, r), a = r > s ? o : e;
|
|
159
|
+
return (t === -1 ? n : n.slice(t + a.length)).replace(/\.(?:d\.)?(?:[cm]?ts|tsx)$/u, "");
|
|
157
160
|
}
|
|
158
|
-
function q(
|
|
159
|
-
const
|
|
161
|
+
function q(n) {
|
|
162
|
+
const e = [], o = (t) => `\0${e.push(t) - 1}\0`, r = n.replaceAll(`\r
|
|
160
163
|
`, `
|
|
161
164
|
`).replaceAll("\r", `
|
|
162
165
|
`).replace(
|
|
163
166
|
/\[([^\]\n]+)\]\((https?:\/\/(?:[^()\s]|\([^()\s]*\))+?)\)/gu,
|
|
164
|
-
(t,
|
|
167
|
+
(t, a, c) => o(`[${h(a)}](${c})`)
|
|
165
168
|
).replace(/https?:\/\/[^\s<>()]+/gu, (t) => {
|
|
166
|
-
const
|
|
167
|
-
return `${o(t.slice(0, -
|
|
169
|
+
const a = /[.,;:!?]+$/u.exec(t)?.[0] ?? "";
|
|
170
|
+
return `${o(t.slice(0, -a.length || void 0))}${a}`;
|
|
168
171
|
});
|
|
169
|
-
return
|
|
172
|
+
return h(r).replace(/\0(\d+)\0/gu, (t, a) => e[Number(a)]).replaceAll(`
|
|
170
173
|
`, `
|
|
171
174
|
`);
|
|
172
175
|
}
|
|
173
|
-
function
|
|
174
|
-
return
|
|
176
|
+
function h(n) {
|
|
177
|
+
return n.replace(/^(\s*)(#{1,6})(?=\s)/gmu, "$1\\$2").replace(/#(?=\d)/gu, "# ");
|
|
175
178
|
}
|
|
176
|
-
function
|
|
177
|
-
const
|
|
178
|
-
return `https://${
|
|
179
|
+
function H(n, e, o, s) {
|
|
180
|
+
const r = e.split("/").map(encodeURIComponent).join("/"), t = o.split("/").map(encodeURIComponent).join("/");
|
|
181
|
+
return `https://${n}/blob/${r}/${t}#L${s}`;
|
|
179
182
|
}
|
|
180
183
|
export {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
+
M as a,
|
|
185
|
+
Z as c,
|
|
186
|
+
Y as f,
|
|
187
|
+
X as i
|
|
184
188
|
};
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
};
|