@dpuse/dpuse-development 0.3.813 → 0.3.815
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/README.md +17 -17
- package/dist/dpuse-development.es.js +226 -200
- package/dist/dpuse-development.es.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { A as e, C as t, D as n, E as r, S as i, T as a, _ as o, a as s, b as c, c as l, d as u, f as d, g as f, h as p, i as m, k as h, l as g, m as _, n as ee, o as te, p as v, r as ne, s as re, t as ie, u as y, v as b, w as x, x as S, y as C } from "./utilities-CQ2h3IWL.js";
|
|
2
2
|
import { SHIPPED_PACKAGES_FILE_NAME as ae } from "./vite.es.js";
|
|
3
|
-
import { existsSync as oe
|
|
3
|
+
import { existsSync as oe } from "node:fs";
|
|
4
4
|
import w from "node:path";
|
|
5
|
-
import { promisify as
|
|
6
|
-
import { execFile as
|
|
7
|
-
import { fileURLToPath as
|
|
8
|
-
import { run as
|
|
9
|
-
import { init as
|
|
5
|
+
import { promisify as se } from "node:util";
|
|
6
|
+
import { execFile as ce } from "node:child_process";
|
|
7
|
+
import { fileURLToPath as le } from "node:url";
|
|
8
|
+
import { run as ue } from "npm-check-updates";
|
|
9
|
+
import { init as de } from "license-checker-rseidelsohn";
|
|
10
10
|
//#region src/actions/auditDependencies.ts
|
|
11
|
-
async function
|
|
11
|
+
async function fe() {
|
|
12
12
|
try {
|
|
13
13
|
f("Audit Dependencies"), await x("1️⃣ Check shipped dependencies for any vulnerability", "npm", ["audit", "--omit=dev"]), await x("2️⃣ Check all dependencies for high or critical vulnerabilities", "npm", ["audit", "--audit-level=high"]), o("Dependencies audited");
|
|
14
14
|
} catch (e) {
|
|
@@ -17,27 +17,27 @@ async function pe() {
|
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/actions/buildProject.ts
|
|
20
|
-
var
|
|
21
|
-
async function
|
|
20
|
+
var pe = "build:wasm";
|
|
21
|
+
async function me() {
|
|
22
22
|
try {
|
|
23
|
-
f("Build Project"), await
|
|
23
|
+
f("Build Project"), await he("1️⃣ ", await c("package.json")), o("Project built");
|
|
24
24
|
} catch (e) {
|
|
25
25
|
console.error("❌ Error building project", e), process.exit(1);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
async function
|
|
29
|
-
t.scripts?.[
|
|
28
|
+
async function he(e, t) {
|
|
29
|
+
t.scripts?.[pe] != null && await x(`${e} Build WebAssembly`, "npm", ["run", pe]), await x(`${e} Bundle project`, "vite", ["build"]);
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region src/actions/checkConfigFiles.ts
|
|
33
|
-
var
|
|
33
|
+
var T = "@dpuse/dpuse-development/prettierrc", ge = "dpuse-development";
|
|
34
34
|
async function _e() {
|
|
35
35
|
try {
|
|
36
36
|
f("Check configuration files"), b("1️⃣ Check individual files");
|
|
37
|
-
let e = await c("config.json"), t = await c("package.json"), n = t.private === !0, r = _(e.id), a = w.dirname(
|
|
38
|
-
await
|
|
37
|
+
let e = await c("config.json"), t = await c("package.json"), n = t.private === !0, r = _(e.id), a = w.dirname(le(import.meta.url));
|
|
38
|
+
await E(a, ".editorconfig"), await E(a, ".gitattributes"), await E(a, ".gitignore", [".gitignore_default"]), await E(a, ".markdownlint.json"), await E(a, ".ncurc.json"), await ve(r, a), await E(a, "LICENSE"), await be(r, a), await xe(r, a), await Se(r, a), await we(r, a), ye(r, t);
|
|
39
39
|
let s = await i(l) !== null;
|
|
40
|
-
s && await
|
|
40
|
+
s && await E(a, "rust-toolchain.toml"), await E(a, ".github/dependabot.yml", [`.github/dependabot${n ? ".private" : ""}${s ? ".rust" : ""}.yml`]), n ? console.info("ℹ️ GitHub workflows and file 'SECURITY.md' are NOT required by this project") : (await Ce(a), await E(a, "SECURITY.md", [], (t) => t.replaceAll(ge, () => e.id))), o("Configuration files checked");
|
|
41
41
|
} catch (e) {
|
|
42
42
|
console.error("❌ Error checking configuration files", e), process.exit(1);
|
|
43
43
|
}
|
|
@@ -48,10 +48,10 @@ async function ve(e, t) {
|
|
|
48
48
|
"api",
|
|
49
49
|
"development",
|
|
50
50
|
"eslint"
|
|
51
|
-
].includes(e.typeId) ? console.info("⚠️ File 'eslint.config.js' is UNIQUE to this project") : await
|
|
51
|
+
].includes(e.typeId) ? console.info("⚠️ File 'eslint.config.js' is UNIQUE to this project") : await E(t, "eslint.config.js", ["eslint.config.default.js"]);
|
|
52
52
|
}
|
|
53
53
|
function ye(e, t) {
|
|
54
|
-
e.typeId === "development" ? console.info("ℹ️ File '.prettierrc.json' is the template") : e.typeId === "app" ? console.info("⚠️ File '.prettierrc.json' is UNIQUE to this project") : t.prettier ===
|
|
54
|
+
e.typeId === "development" ? console.info("ℹ️ File '.prettierrc.json' is the template") : e.typeId === "app" ? console.info("⚠️ File '.prettierrc.json' is UNIQUE to this project") : t.prettier === T ? console.info(`ℹ️ Prettier configuration is '${T}'`) : console.info(`❌ Prettier configuration is NOT '${T}'`);
|
|
55
55
|
}
|
|
56
56
|
async function be(e, t) {
|
|
57
57
|
["github"].includes(e.typeId) ? console.info("ℹ️ File 'tsconfig.json' is NOT required by this project") : [
|
|
@@ -62,10 +62,10 @@ async function be(e, t) {
|
|
|
62
62
|
"presenter",
|
|
63
63
|
"shared",
|
|
64
64
|
"tool"
|
|
65
|
-
].includes(e.typeId) ? await
|
|
65
|
+
].includes(e.typeId) ? await E(t, "tsconfig.json") : console.info("⚠️ File 'tsconfig.json' is UNIQUE to this project");
|
|
66
66
|
}
|
|
67
67
|
async function xe(e, t) {
|
|
68
|
-
["github"].includes(e.typeId) ? console.info("ℹ️ File 'scripts/tsconfig.json' is NOT required by this project") : await
|
|
68
|
+
["github"].includes(e.typeId) ? console.info("ℹ️ File 'scripts/tsconfig.json' is NOT required by this project") : await E(t, "scripts/tsconfig.json");
|
|
69
69
|
}
|
|
70
70
|
async function Se(e, t) {
|
|
71
71
|
if ([
|
|
@@ -90,11 +90,11 @@ async function Se(e, t) {
|
|
|
90
90
|
break;
|
|
91
91
|
default: n = ["vite.config.default.ts"];
|
|
92
92
|
}
|
|
93
|
-
await
|
|
93
|
+
await E(t, "vite.config.ts", n);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
async function Ce(e) {
|
|
97
|
-
await
|
|
97
|
+
await E(e, ".github/workflows/ci.yml"), await E(e, ".github/workflows/codeql.yml"), await E(e, ".github/workflows/publish.yml"), await E(e, ".github/workflows/scorecard.yml");
|
|
98
98
|
}
|
|
99
99
|
async function we(e, t) {
|
|
100
100
|
[
|
|
@@ -103,9 +103,9 @@ async function we(e, t) {
|
|
|
103
103
|
"eslint",
|
|
104
104
|
"github",
|
|
105
105
|
"kb"
|
|
106
|
-
].includes(e.typeId) ? console.info("ℹ️ File 'vitest.config.ts' is NOT required by this project") : await
|
|
106
|
+
].includes(e.typeId) ? console.info("ℹ️ File 'vitest.config.ts' is NOT required by this project") : await E(t, "vitest.config.ts");
|
|
107
107
|
}
|
|
108
|
-
async function
|
|
108
|
+
async function E(e, t, n = [], r = (e) => e) {
|
|
109
109
|
let i = w.resolve(process.cwd(), t), a = n.length > 0 ? n : [t], o;
|
|
110
110
|
try {
|
|
111
111
|
o = await S(i);
|
|
@@ -136,7 +136,7 @@ async function Te() {
|
|
|
136
136
|
} catch (e) {
|
|
137
137
|
if (e.code !== "ENOENT") throw e;
|
|
138
138
|
}
|
|
139
|
-
await
|
|
139
|
+
await ue({
|
|
140
140
|
interactive: !0,
|
|
141
141
|
upgrade: !0,
|
|
142
142
|
dep: "dev,prod,peer,optional",
|
|
@@ -237,59 +237,77 @@ This project is licensed under the MIT License, permitting free use, modificatio
|
|
|
237
237
|
}
|
|
238
238
|
//#endregion
|
|
239
239
|
//#region src/actions/documentDependencies.ts
|
|
240
|
-
var
|
|
241
|
-
async function
|
|
240
|
+
var D = "<!-- DEPENDENCY_LICENSES_START -->", O = "<!-- DEPENDENCY_LICENSES_END -->", k = "## Dependency Licenses", Re = `bundle-analysis-reports/${ae}`, A = "licenses/licenseTree.json", j = "Packages flagged ❗ have a newer version available; ⚠️ indicates a package that hasn't been updated in the last 6 months or longer. Neither flag necessarily indicates a problem: we let new releases stabilise before upgrading, and some packages are mature and stable (have limited or no dependencies), so they require no active development.", ze = `The dependency tree below lists every package in this project — direct and transitive — along with its installed version, release date, and update status. ${j}`, Be = `The dependency tree below shows how each package in the table above is reached — direct and transitive — along with its installed version, release date, and update status. A package that does not ship itself, such as one whose parts are bundled separately, is left out and what ships beneath it is shown in its place. ${j}`;
|
|
241
|
+
async function Ve(e = "MIT") {
|
|
242
242
|
try {
|
|
243
243
|
f("Document Dependencies");
|
|
244
244
|
let t = await c("package.json");
|
|
245
245
|
if (t.name === "@dpuse/dpuse-development" || t.name === "@dpuse/eslint-config-dpuse") {
|
|
246
|
-
await
|
|
246
|
+
await He(t.name), o("Dependencies documented");
|
|
247
247
|
return;
|
|
248
248
|
}
|
|
249
249
|
await u("1️⃣ Clear downloaded licenses", "licenses/downloads");
|
|
250
|
-
let n = await
|
|
250
|
+
let n = await Ke(), r = await qe();
|
|
251
251
|
if (r === null) {
|
|
252
|
-
let r =
|
|
252
|
+
let r = Ze(n);
|
|
253
253
|
await N("2️⃣ Identify production licenses", e, [t.name ?? "", ...r], !0), await a("3️⃣ Identify transitive dependencies", "npm", [
|
|
254
254
|
"ls",
|
|
255
255
|
"--all",
|
|
256
256
|
"--json",
|
|
257
257
|
"--omit=dev"
|
|
258
|
-
],
|
|
258
|
+
], A), await Ue("4️⃣ ", e, new Set(r));
|
|
259
259
|
} else {
|
|
260
|
-
let i =
|
|
261
|
-
await N("2️⃣ Identify shipped licenses", e, [t.name ?? "", ...
|
|
260
|
+
let i = Je(r, n), o = Ye(n), s = o.filter((e) => !i.has(e));
|
|
261
|
+
await N("2️⃣ Identify shipped licenses", e, [t.name ?? "", ...s], !1), Xe(i, new Set(o)), await a("3️⃣ Identify transitive dependencies", "npm", [
|
|
262
|
+
"ls",
|
|
263
|
+
"--all",
|
|
264
|
+
"--json"
|
|
265
|
+
], A, !0), await We("4️⃣ ", e, i, Ge(t));
|
|
262
266
|
}
|
|
263
267
|
o("Dependencies documented");
|
|
264
268
|
} catch (e) {
|
|
265
269
|
console.error("❌ Error documenting dependencies", e), process.exit(1);
|
|
266
270
|
}
|
|
267
271
|
}
|
|
268
|
-
async function
|
|
272
|
+
async function He(e) {
|
|
269
273
|
b(`1️⃣ Skip: ${e} is a development-only tool and is never part of a production release.`);
|
|
270
274
|
let t = `> [!WARNING]\n> Dependency licenses are not documented here: ${e} is a development-only tool and is never part of a production release.`;
|
|
271
|
-
await n(`${
|
|
275
|
+
await n(`${k}\n\n${t}`, D, O);
|
|
272
276
|
}
|
|
273
|
-
async function
|
|
277
|
+
async function Ue(e, t, r) {
|
|
274
278
|
b(`${e} Insert licenses into 'README.md'`);
|
|
275
|
-
let i = await c(
|
|
276
|
-
for (let e of a.values()) o +=
|
|
279
|
+
let i = await c(A), a = await M(), o = `${L(t, !1)}\n\n|Dependency|Version|License(s)|Document|\n|:-|:-:|:-|:-|\n`;
|
|
280
|
+
for (let e of a.values()) o += R(e);
|
|
277
281
|
let s = [];
|
|
278
|
-
i.dependencies != null &&
|
|
282
|
+
i.dependencies != null && z(i.dependencies, a, r, s, 0);
|
|
279
283
|
let l = `${ze}\n\n${s.join("\n")}`;
|
|
280
|
-
await n(`${
|
|
284
|
+
await n(`${k}\n\n${o.trimEnd()}\n\n### Dependency Tree\n\n${l}`, D, O);
|
|
281
285
|
}
|
|
282
|
-
async function
|
|
286
|
+
async function We(e, t, r, i) {
|
|
283
287
|
b(`${e} Insert licenses into 'README.md'`);
|
|
284
|
-
let
|
|
285
|
-
for (let e of
|
|
286
|
-
await
|
|
288
|
+
let a = await M(), o = a.values().toArray().toSorted((e, t) => e.name.localeCompare(t.name, "en") || e.installedVersion.localeCompare(t.installedVersion, "en")), s = `${L(t, !0)}\n\n|Dependency|Version|License(s)|Document|\n|:-|:-:|:-|:-|\n`;
|
|
289
|
+
for (let e of o) s += R(e);
|
|
290
|
+
let l = await c(A), u = Object.entries(l.dependencies ?? {}).toSorted(([e], [t]) => Number(!i.has(e)) - Number(!i.has(t))), d = [];
|
|
291
|
+
B(u, {
|
|
292
|
+
licensesByKey: a,
|
|
293
|
+
shippedKeys: r,
|
|
294
|
+
shownKeys: /* @__PURE__ */ new Set()
|
|
295
|
+
}, d, 0, !1);
|
|
296
|
+
let f = `${Be}\n\n${d.join("\n")}`;
|
|
297
|
+
await n(`${k}\n\n${s.trimEnd()}\n\n### Dependency Tree\n\n${f}`, D, O);
|
|
298
|
+
}
|
|
299
|
+
function Ge(e) {
|
|
300
|
+
return /* @__PURE__ */ new Set([
|
|
301
|
+
...Object.keys(e.dependencies ?? {}),
|
|
302
|
+
...Object.keys(e.optionalDependencies ?? {}),
|
|
303
|
+
...Object.keys(e.peerDependencies ?? {})
|
|
304
|
+
]);
|
|
287
305
|
}
|
|
288
306
|
async function M() {
|
|
289
307
|
let e = await c("licenses/licenses.json"), t = /* @__PURE__ */ new Map();
|
|
290
|
-
for (let [n, r] of Object.entries(e)) t.set(n,
|
|
308
|
+
for (let [n, r] of Object.entries(e)) t.set(n, et(n, r));
|
|
291
309
|
return await Promise.all(t.values().map(async (e) => {
|
|
292
|
-
let t = await
|
|
310
|
+
let t = await tt(e.name, e.installedVersion);
|
|
293
311
|
e.latestVersion = t.latestVersion, e.latestPublishedDate = t.latestPublishedDate, e.publishedDate = t.publishedDate;
|
|
294
312
|
})), t;
|
|
295
313
|
}
|
|
@@ -306,20 +324,20 @@ async function N(e, t, n, r) {
|
|
|
306
324
|
excludePackages: n.join(";"),
|
|
307
325
|
out: "licenses/licenses.json"
|
|
308
326
|
};
|
|
309
|
-
|
|
327
|
+
de(a, (t) => {
|
|
310
328
|
t == null ? e() : i(t);
|
|
311
329
|
});
|
|
312
330
|
});
|
|
313
331
|
}
|
|
314
|
-
async function
|
|
332
|
+
async function Ke() {
|
|
315
333
|
let e = await i("package-lock.json");
|
|
316
334
|
return e === null ? {} : JSON.parse(e).packages ?? {};
|
|
317
335
|
}
|
|
318
|
-
async function
|
|
336
|
+
async function qe() {
|
|
319
337
|
let e = await i(Re);
|
|
320
338
|
return e === null ? null : JSON.parse(e);
|
|
321
339
|
}
|
|
322
|
-
function
|
|
340
|
+
function Je(e, t) {
|
|
323
341
|
let n = new Set(e.packages);
|
|
324
342
|
for (let r of e.external) {
|
|
325
343
|
let e = I(t, "", r);
|
|
@@ -330,19 +348,19 @@ function Ke(e, t) {
|
|
|
330
348
|
}
|
|
331
349
|
return n;
|
|
332
350
|
}
|
|
333
|
-
function
|
|
351
|
+
function Ye(e) {
|
|
334
352
|
let t = /* @__PURE__ */ new Set();
|
|
335
353
|
for (let [n, r] of Object.entries(e)) n !== "" && r.version !== void 0 && t.add(P(n, r));
|
|
336
354
|
return [...t];
|
|
337
355
|
}
|
|
338
|
-
function
|
|
356
|
+
function Xe(e, t) {
|
|
339
357
|
let n = [...e.difference(t)];
|
|
340
358
|
n.length > 0 && console.warn(`⚠️ Not installed, so not checked; rebuild to refresh the record: ${n.join(", ")}`);
|
|
341
359
|
}
|
|
342
360
|
function P(e, t) {
|
|
343
361
|
return `${t.name ?? e.slice(e.lastIndexOf("node_modules/") + 13)}@${String(t.version)}`;
|
|
344
362
|
}
|
|
345
|
-
function
|
|
363
|
+
function Ze(e) {
|
|
346
364
|
let t = F(e, ""), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
347
365
|
for (let [i, a] of Object.entries(e)) {
|
|
348
366
|
if (i === "" || a.version === void 0) continue;
|
|
@@ -355,14 +373,14 @@ function F(e, t) {
|
|
|
355
373
|
let n = /* @__PURE__ */ new Set(), r = [t];
|
|
356
374
|
for (; r.length > 0;) {
|
|
357
375
|
let t = r.pop() ?? "", i = e[t];
|
|
358
|
-
if (i !== void 0) for (let a of
|
|
376
|
+
if (i !== void 0) for (let a of Qe(i)) {
|
|
359
377
|
let i = I(e, t, a);
|
|
360
378
|
i === void 0 || n.has(i) || (n.add(i), r.push(i));
|
|
361
379
|
}
|
|
362
380
|
}
|
|
363
381
|
return n;
|
|
364
382
|
}
|
|
365
|
-
function
|
|
383
|
+
function Qe(e) {
|
|
366
384
|
let t = Object.keys(e.peerDependencies ?? {}).filter((t) => e.peerDependenciesMeta?.[t]?.optional !== !0);
|
|
367
385
|
return [
|
|
368
386
|
...Object.keys(e.dependencies ?? {}),
|
|
@@ -381,13 +399,13 @@ function I(e, t, n) {
|
|
|
381
399
|
}
|
|
382
400
|
}
|
|
383
401
|
function L(e, t) {
|
|
384
|
-
let n =
|
|
402
|
+
let n = $e(e.split(";"));
|
|
385
403
|
return `License data is updated each time \`npm run document\` is run, using [license-checker](https://github.com/RSeidelsohn/license-checker-rseidelsohn). ${t ? "The following table lists every package whose code, styles or assets are included in this project's build, as recorded by the build itself. Modules loaded at run time are not included; each documents its own." : "The following table lists all production dependencies. This project has no build record, so the list is taken from its declared dependencies."} These dependencies have been checked and confirmed to use ${n}, all of which allow commercial use. All are used unmodified, so any licence conditions that apply only to modified versions are not triggered. Developers cloning this repository should independently verify development dependencies.`;
|
|
386
404
|
}
|
|
387
|
-
function
|
|
405
|
+
function $e(e) {
|
|
388
406
|
return e.length === 1 ? e[0] ?? "" : e.length === 2 ? `${String(e[0])} or ${String(e[1])}` : `${e.slice(0, -1).join(", ")}, or ${String(e.at(-1))}`;
|
|
389
407
|
}
|
|
390
|
-
function
|
|
408
|
+
function et(e, t) {
|
|
391
409
|
let n = e.lastIndexOf("@"), r = n > 0 ? e.slice(0, n) : e, i = n > 0 ? e.slice(n + 1) : "";
|
|
392
410
|
return {
|
|
393
411
|
name: r,
|
|
@@ -401,7 +419,7 @@ function Qe(e, t) {
|
|
|
401
419
|
...t.licenseFile != null && { licenseFileLink: t.licenseFile }
|
|
402
420
|
};
|
|
403
421
|
}
|
|
404
|
-
async function
|
|
422
|
+
async function tt(e, t) {
|
|
405
423
|
try {
|
|
406
424
|
let n = await fetch(`https://registry.npmjs.org/${encodeURIComponent(e)}`);
|
|
407
425
|
if (n.ok) {
|
|
@@ -419,32 +437,40 @@ async function $e(e, t) {
|
|
|
419
437
|
publishedDate: ""
|
|
420
438
|
};
|
|
421
439
|
}
|
|
422
|
-
function
|
|
440
|
+
function R(e) {
|
|
423
441
|
let t = e.licenseFileLink == null || e.licenseFileLink === "" ? "⚠️ No license file" : `[LICENSE](licenses/${e.licenseFileLink})`;
|
|
424
442
|
return `|[${e.name}](${e.repository})|${e.installedVersion}|${e.licenseTypes}|${t}|\n`;
|
|
425
443
|
}
|
|
426
|
-
function
|
|
427
|
-
let t = e.licenseFileLink == null || e.licenseFileLink === "" ? "⚠️ No license file" : `[LICENSE](licenses/${e.licenseFileLink})`;
|
|
428
|
-
return `|[${e.name}](${e.repository})|${e.installedVersion}|${z(e).replace(/^ — /, "")}|${e.licenseTypes}|${t}|\n`;
|
|
429
|
-
}
|
|
430
|
-
function R(e, t, n, r, i) {
|
|
444
|
+
function z(e, t, n, r, i) {
|
|
431
445
|
let a = " ".repeat(i);
|
|
432
446
|
for (let [o, s] of Object.entries(e)) {
|
|
433
447
|
if (s.version === void 0) continue;
|
|
434
448
|
let e = s.version;
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
449
|
+
n.has(`${o}@${e}`) || (r.push(V(o, e, t.get(`${o}@${e}`), a)), s.dependencies != null && z(s.dependencies, t, n, r, i + 1));
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
function B(e, t, n, r, i) {
|
|
453
|
+
for (let [a, o] of e) {
|
|
454
|
+
if (o.version === void 0) continue;
|
|
455
|
+
let e = `${a}@${o.version}`, s = Object.entries(o.dependencies ?? {});
|
|
456
|
+
if (!t.shippedKeys.has(e)) {
|
|
457
|
+
B(s, t, n, r, !0);
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
i && t.shownKeys.has(e) || (t.shownKeys.add(e), n.push(V(a, o.version, t.licensesByKey.get(e), " ".repeat(r))), B(s, t, n, r + 1, !1));
|
|
438
461
|
}
|
|
439
462
|
}
|
|
440
|
-
function
|
|
463
|
+
function V(e, t, n, r) {
|
|
464
|
+
return `${r}- **${n == null ? e : `[${e}](${n.repository})`}** ${t}${nt(n)}`;
|
|
465
|
+
}
|
|
466
|
+
function nt(e) {
|
|
441
467
|
if (e == null) return "";
|
|
442
|
-
let t = e.publishedDate ?
|
|
468
|
+
let t = e.publishedDate ? H(e.publishedDate.split("T", 1)[0]) : "";
|
|
443
469
|
if (e.latestVersion === "" || e.latestVersion === e.installedVersion) return t === "" ? "" : ` — ${t}`;
|
|
444
|
-
let n = e.latestPublishedDate ?
|
|
470
|
+
let n = e.latestPublishedDate ? H(e.latestPublishedDate.split("T", 1)[0]) : "", r = n === "" ? `**latest**: ${e.latestVersion} ❗` : `**latest**: ${e.latestVersion} — ${n} ❗`;
|
|
445
471
|
return t === "" ? ` — → ${r}` : ` — ${t} → ${r}`;
|
|
446
472
|
}
|
|
447
|
-
function
|
|
473
|
+
function H(e) {
|
|
448
474
|
if (e == null || e === "") return "n/a";
|
|
449
475
|
let t = e.split("T", 1)[0];
|
|
450
476
|
if (t == null || t === "") return "n/a";
|
|
@@ -453,31 +479,31 @@ function B(e) {
|
|
|
453
479
|
}
|
|
454
480
|
//#endregion
|
|
455
481
|
//#region src/actions/documentOpening.ts
|
|
456
|
-
var
|
|
457
|
-
async function
|
|
482
|
+
var rt = "<!-- OPENING_START -->", it = "<!-- OPENING_END -->";
|
|
483
|
+
async function at() {
|
|
458
484
|
try {
|
|
459
485
|
f("Document Opening"), b("1️⃣ Insert opening content into 'README.md'");
|
|
460
|
-
let e = await c("package.json"), r = await c("config.json"), { owner: i, repo: a } = t(e, "document opening"), s =
|
|
461
|
-
await n(u,
|
|
486
|
+
let e = await c("package.json"), r = await c("config.json"), { owner: i, repo: a } = t(e, "document opening"), s = ot(e), l = ct(r), u = lt(i, a, s, _(r.id).publishedTo === "npm" ? st(e) : void 0, e.description, l);
|
|
487
|
+
await n(u, rt, it), o("Opening documented");
|
|
462
488
|
} catch (e) {
|
|
463
489
|
console.error("❌ Error documenting opening", e), process.exit(1);
|
|
464
490
|
}
|
|
465
491
|
}
|
|
466
|
-
function
|
|
492
|
+
function ot(e) {
|
|
467
493
|
let t = e.license;
|
|
468
494
|
if (t == null || t === "") throw Error("package.json 'license' field is required to document opening.");
|
|
469
495
|
return t;
|
|
470
496
|
}
|
|
471
|
-
function
|
|
497
|
+
function st(e) {
|
|
472
498
|
let t = e.name;
|
|
473
499
|
if (t == null || t === "") throw Error("package.json 'name' field is required to document opening.");
|
|
474
500
|
return t;
|
|
475
501
|
}
|
|
476
|
-
function
|
|
502
|
+
function ct(e) {
|
|
477
503
|
let t = e.description.en?.trim();
|
|
478
504
|
return t === void 0 || t === "" ? void 0 : t;
|
|
479
505
|
}
|
|
480
|
-
function
|
|
506
|
+
function lt(e, t, n, r, i, a) {
|
|
481
507
|
let o = `https://github.com/${e}/${t}`;
|
|
482
508
|
return `[}-blue.svg)](./LICENSE)
|
|
483
509
|
[](${o}/releases/latest)${r === void 0 ? "" : `\n[](https://www.npmjs.com/package/${r})`}
|
|
@@ -499,31 +525,31 @@ In addition, DPUse provides [Tools](https://www.dpuse.app) used by the applicati
|
|
|
499
525
|
}
|
|
500
526
|
//#endregion
|
|
501
527
|
//#region src/actions/documentQualitySecurity.ts
|
|
502
|
-
var
|
|
528
|
+
var ut = {
|
|
503
529
|
"Branch-Protection": 3,
|
|
504
530
|
"Code-Review": 0,
|
|
505
531
|
Contributors: 0
|
|
506
|
-
},
|
|
532
|
+
}, dt = /* @__PURE__ */ new Set(["CII-Best-Practices"]), ft = "coverage/coverage-final.json", pt = "coverage/coverage-summary.json", mt = 80, ht = 60, gt = "code-health-reports/vitest/badge.json", _t = {
|
|
507
533
|
actions: "GitHub Actions",
|
|
508
534
|
"javascript-typescript": "JavaScript/TypeScript",
|
|
509
535
|
rust: "Rust"
|
|
510
|
-
},
|
|
536
|
+
}, vt = {
|
|
511
537
|
A: "brightgreen",
|
|
512
538
|
B: "green",
|
|
513
539
|
C: "yellow",
|
|
514
540
|
D: "orange",
|
|
515
541
|
F: "red"
|
|
516
|
-
},
|
|
517
|
-
async function
|
|
542
|
+
}, yt = `${m}/health.json`, bt = se(ce);
|
|
543
|
+
async function xt() {
|
|
518
544
|
try {
|
|
519
545
|
f("Document Quality & Security");
|
|
520
|
-
let e = await c("package.json"), r = await
|
|
546
|
+
let e = await c("package.json"), r = await St(e), i = await wt(e, r === void 0 ? [] : ["--coverage", ft]), { owner: a, repo: s } = t(e, "document quality and security");
|
|
521
547
|
b("4️⃣ Read security checks and settings");
|
|
522
|
-
let l = await
|
|
548
|
+
let l = await Et(a, s, e);
|
|
523
549
|
b("5️⃣ Look up OpenSSF Best Practices badge and Scorecard results");
|
|
524
|
-
let [u, d] = await Promise.all([
|
|
550
|
+
let [u, d] = await Promise.all([Dt(`https://github.com/${a}/${s}`), Ot(`github.com/${a}/${s}`)]);
|
|
525
551
|
b("6️⃣ Insert quality and security content into 'README.md'");
|
|
526
|
-
let p =
|
|
552
|
+
let p = Nt(a, s, {
|
|
527
553
|
coveragePercent: r,
|
|
528
554
|
fallowHealth: i,
|
|
529
555
|
securitySettings: l
|
|
@@ -533,7 +559,7 @@ async function vt() {
|
|
|
533
559
|
console.error("❌ Error documenting quality and security", e), process.exit(1);
|
|
534
560
|
}
|
|
535
561
|
}
|
|
536
|
-
async function
|
|
562
|
+
async function St(e) {
|
|
537
563
|
if (e.devDependencies?.["@vitest/coverage-v8"] == null) {
|
|
538
564
|
b("1️⃣ Test coverage NOT measured, as '@vitest/coverage-v8' is not installed");
|
|
539
565
|
return;
|
|
@@ -543,25 +569,25 @@ async function yt(e) {
|
|
|
543
569
|
"--passWithNoTests",
|
|
544
570
|
"--coverage"
|
|
545
571
|
]);
|
|
546
|
-
let t = await i(
|
|
572
|
+
let t = await i(pt);
|
|
547
573
|
if (t === null) return;
|
|
548
574
|
let n = JSON.parse(t).total.lines.pct;
|
|
549
|
-
return await
|
|
575
|
+
return await Ct(n), n;
|
|
550
576
|
}
|
|
551
|
-
async function
|
|
577
|
+
async function Ct(e) {
|
|
552
578
|
let t = [
|
|
553
579
|
"red",
|
|
554
580
|
"yellow",
|
|
555
581
|
"brightgreen"
|
|
556
|
-
], n = Number(e >=
|
|
557
|
-
await r(
|
|
582
|
+
], n = Number(e >= ht) + Number(e >= mt);
|
|
583
|
+
await r(gt, {
|
|
558
584
|
schemaVersion: 1,
|
|
559
585
|
label: "coverage",
|
|
560
586
|
message: `${e.toFixed(1)}%`,
|
|
561
587
|
color: t[n]
|
|
562
588
|
});
|
|
563
589
|
}
|
|
564
|
-
async function
|
|
590
|
+
async function wt(e, t) {
|
|
565
591
|
if (e.devDependencies?.fallow == null) {
|
|
566
592
|
b("2️⃣ Code health NOT measured, as Fallow is not installed"), b("3️⃣ Code health report NOT required");
|
|
567
593
|
return;
|
|
@@ -572,20 +598,20 @@ async function xt(e, t) {
|
|
|
572
598
|
"--format",
|
|
573
599
|
"json",
|
|
574
600
|
...t
|
|
575
|
-
],
|
|
576
|
-
let n = await c(
|
|
577
|
-
return await
|
|
601
|
+
], yt), await a("3️⃣ Write code health report", "fallow", ["--format", "markdown"], s, !0);
|
|
602
|
+
let n = await c(yt);
|
|
603
|
+
return await Tt(n), n;
|
|
578
604
|
}
|
|
579
|
-
async function
|
|
605
|
+
async function Tt(e) {
|
|
580
606
|
let { score: t, grade: n } = e.health_score;
|
|
581
607
|
await r(ne, {
|
|
582
608
|
schemaVersion: 1,
|
|
583
609
|
label: "fallow",
|
|
584
610
|
message: `${n} (${String(Math.round(t))})`,
|
|
585
|
-
color:
|
|
611
|
+
color: vt[n] ?? "lightgrey"
|
|
586
612
|
});
|
|
587
613
|
}
|
|
588
|
-
async function
|
|
614
|
+
async function Et(e, t, n) {
|
|
589
615
|
let [r, a, o, s] = await Promise.all([
|
|
590
616
|
i(".github/workflows/ci.yml"),
|
|
591
617
|
i(".github/workflows/codeql.yml"),
|
|
@@ -598,7 +624,7 @@ async function Ct(e, t, n) {
|
|
|
598
624
|
U(`repos/${e}/${t}/commits/main/check-runs?per_page=100`)
|
|
599
625
|
]), p = c === void 0 ? void 0 : JSON.parse(c).security_and_analysis, m = (e) => p?.[e] === void 0 ? void 0 : p[e].status === "enabled", h = new Set((f === void 0 ? [] : JSON.parse(f).check_runs).map((e) => e.app?.slug)), g = o?.match(/package-ecosystem:/g)?.length ?? 0, _ = o?.match(/open-pull-requests-limit: 0\b/g)?.length ?? 0;
|
|
600
626
|
return {
|
|
601
|
-
codeQLLanguages: (a ?? "").matchAll(/- language: ([\w-]+)/g).filter(([, e]) => e !== "rust" || s !== null).map(([, e = ""]) =>
|
|
627
|
+
codeQLLanguages: (a ?? "").matchAll(/- language: ([\w-]+)/g).filter(([, e]) => e !== "rust" || s !== null).map(([, e = ""]) => _t[e] ?? e).toArray(),
|
|
602
628
|
codeQLQueries: /queries: ([\w-]+)/.exec(a ?? "")?.[1],
|
|
603
629
|
dependabotAlerts: d !== void 0,
|
|
604
630
|
dependabotSecurityUpdates: m("dependabot_security_updates"),
|
|
@@ -617,29 +643,29 @@ async function Ct(e, t, n) {
|
|
|
617
643
|
}
|
|
618
644
|
async function U(e) {
|
|
619
645
|
try {
|
|
620
|
-
let { stdout: t } = await
|
|
646
|
+
let { stdout: t } = await bt("gh", ["api", e]);
|
|
621
647
|
return t;
|
|
622
648
|
} catch (e) {
|
|
623
649
|
if (String(e.stderr).includes("HTTP 404")) return;
|
|
624
650
|
throw e;
|
|
625
651
|
}
|
|
626
652
|
}
|
|
627
|
-
async function
|
|
653
|
+
async function Dt(e) {
|
|
628
654
|
let t = await fetch(`https://www.bestpractices.dev/projects.json?url=${encodeURIComponent(e)}`);
|
|
629
655
|
if (!t.ok) throw Error(`OpenSSF Best Practices lookup failed with status ${String(t.status)}.`);
|
|
630
656
|
return (await t.json()).find((t) => t.repo_url === e)?.id;
|
|
631
657
|
}
|
|
632
|
-
async function
|
|
658
|
+
async function Ot(e) {
|
|
633
659
|
let t = await fetch(`https://api.scorecard.dev/projects/${e}`);
|
|
634
660
|
if (t.status !== 404) {
|
|
635
661
|
if (!t.ok) throw Error(`OpenSSF Scorecard lookup failed with status ${String(t.status)}.`);
|
|
636
662
|
return await t.json();
|
|
637
663
|
}
|
|
638
664
|
}
|
|
639
|
-
function
|
|
640
|
-
return e.checks.every(({ name: e, score: t }) => t === -1 || t === 10 ||
|
|
665
|
+
function kt(e) {
|
|
666
|
+
return e.checks.every(({ name: e, score: t }) => t === -1 || t === 10 || dt.has(e) || ut[e] !== void 0 && t >= ut[e]);
|
|
641
667
|
}
|
|
642
|
-
function
|
|
668
|
+
function At(e) {
|
|
643
669
|
return e === !1 ? " These are handled manually." : "";
|
|
644
670
|
}
|
|
645
671
|
function W(e) {
|
|
@@ -654,10 +680,10 @@ ${t.map((e) => `|${e.join("|")}|`).join("\n")}
|
|
|
654
680
|
|
|
655
681
|
`;
|
|
656
682
|
}
|
|
657
|
-
function
|
|
683
|
+
function jt(e, t, n, r) {
|
|
658
684
|
return `})`;
|
|
659
685
|
}
|
|
660
|
-
function
|
|
686
|
+
function Mt(e, t, { coveragePercent: n, fallowHealth: r, securitySettings: i }) {
|
|
661
687
|
let a = `https://github.com/${e}/${t}`, o = (e) => e ? ` Part of the [CI workflow](${a}/actions/workflows/ci.yml) on every push and pull request to \`main\`.` : "", c = [[
|
|
662
688
|
"Unit tests",
|
|
663
689
|
W(i.testsInCI),
|
|
@@ -670,7 +696,7 @@ function kt(e, t, { coveragePercent: n, fallowHealth: r, securitySettings: i })
|
|
|
670
696
|
n !== void 0 && c.push([
|
|
671
697
|
"Test coverage",
|
|
672
698
|
W(!0),
|
|
673
|
-
`${
|
|
699
|
+
`${jt(e, t, "Coverage", gt)} [Vitest's V8 coverage](https://vitest.dev/guide/coverage) measures the share of source lines the unit tests run. The target is ${String(mt)}%.`
|
|
674
700
|
]);
|
|
675
701
|
let l = `[](https://sonarcloud.io/summary/new_code?id=${e}_${t}) `, u = [[
|
|
676
702
|
"Code analysis",
|
|
@@ -684,7 +710,7 @@ function kt(e, t, { coveragePercent: n, fallowHealth: r, securitySettings: i })
|
|
|
684
710
|
r !== void 0 && u.unshift([
|
|
685
711
|
"Code health",
|
|
686
712
|
W(!0),
|
|
687
|
-
`[${
|
|
713
|
+
`[${jt(e, t, "Fallow code health", ne)}](./${s}) [Fallow](https://github.com/fallow-rs/fallow) finds unused code, duplication, complexity and dependency problems.`
|
|
688
714
|
]);
|
|
689
715
|
let d = i.codeQLLanguages.length > 0, f = `[](${a}/security/code-scanning) `, p = i.codeQLQueries === "security-extended" ? "using the extended security queries" : "using the default queries", m = d ? ` ${i.codeQLLanguages.join(" and ")}` : "", h = [
|
|
690
716
|
[
|
|
@@ -721,23 +747,23 @@ function kt(e, t, { coveragePercent: n, fallowHealth: r, securitySettings: i })
|
|
|
721
747
|
[
|
|
722
748
|
"Security updates",
|
|
723
749
|
W(i.dependabotSecurityUpdates),
|
|
724
|
-
`${g} opens pull requests that update vulnerable dependencies.${
|
|
750
|
+
`${g} opens pull requests that update vulnerable dependencies.${At(i.dependabotSecurityUpdates)}`
|
|
725
751
|
],
|
|
726
752
|
[
|
|
727
753
|
"Version updates",
|
|
728
754
|
W(i.dependabotVersionUpdates),
|
|
729
|
-
`${g} opens pull requests for new dependency versions.${
|
|
755
|
+
`${g} opens pull requests for new dependency versions.${At(i.dependabotVersionUpdates)}`
|
|
730
756
|
]
|
|
731
757
|
];
|
|
732
758
|
return `This section is updated each time \`npm run document\` is run. Settings come from the repository's workflow files and GitHub. Test coverage and the Fallow score are measured at the same time.
|
|
733
759
|
|
|
734
760
|
${G("Testing", c)}${G("Code Quality", u)}${G("Security Analysis", h)}${G("Dependencies", _)}`;
|
|
735
761
|
}
|
|
736
|
-
function
|
|
737
|
-
let a = `https://github.com/${e}/${t}`, o = `github.com/${e}/${t}`, s = `https://www.bestpractices.dev/projects/${String(r)}`, c = i !== void 0 &&
|
|
762
|
+
function Nt(e, t, n, r, i) {
|
|
763
|
+
let a = `https://github.com/${e}/${t}`, o = `github.com/${e}/${t}`, s = `https://www.bestpractices.dev/projects/${String(r)}`, c = i !== void 0 && kt(i) ? "\n\n> [!NOTE]\n> Apart from the Best Practices badge above, the remaining Scorecard gaps need multi-person review or a pull-request workflow, which this solo-maintained project doesn't use." : "", l = r === void 0 ? "" : `[](${s})\n`, u = n.securitySettings.privateVulnerabilityReporting === !0 ? `Use [GitHub private vulnerability reporting](${a}/security/advisories/new) instead. See [SECURITY.md](./SECURITY.md) for the full disclosure policy, contact details, and expected response times.` : "See [SECURITY.md](./SECURITY.md) for how to report one privately, the full disclosure policy, and expected response times.";
|
|
738
764
|
return `## Quality & Security
|
|
739
765
|
|
|
740
|
-
${
|
|
766
|
+
${Mt(e, t, n)}### OpenSSF 🚧
|
|
741
767
|
|
|
742
768
|
${l}[](https://scorecard.dev/viewer/?uri=${o})
|
|
743
769
|
|
|
@@ -749,26 +775,26 @@ Please do not open public GitHub issues for security vulnerabilities. ${u}`;
|
|
|
749
775
|
}
|
|
750
776
|
//#endregion
|
|
751
777
|
//#region src/actions/documentUsage.ts
|
|
752
|
-
var
|
|
778
|
+
var Pt = "<!-- USAGE_START -->", Ft = "<!-- USAGE_END -->", It = /* @__PURE__ */ new Set([
|
|
753
779
|
"connector",
|
|
754
780
|
"cookbook",
|
|
755
781
|
"presenter"
|
|
756
|
-
]),
|
|
757
|
-
async function
|
|
782
|
+
]), Lt = /* @__PURE__ */ new Set(["development", "eslint"]), Rt = "> [!WARNING]\n> This project is not designed for general use. It is custom built for the DPUse CI/CD process. You are welcome to clone and customise it for your own purposes, but you will need to adapt it to your own project structure and tooling.", zt = "This repository manages itself using the actions it implements.", Bt = "This repository is managed using the common set of actions provided by [@dpuse/dpuse-development](https://github.com/dpuse/dpuse-development).";
|
|
783
|
+
async function Vt() {
|
|
758
784
|
try {
|
|
759
785
|
f("Document Usage"), b("1️⃣ Insert usage content into 'README.md'");
|
|
760
|
-
let [e, t] = await Promise.all([c("package.json"), c("config.json")]), r =
|
|
761
|
-
await n(p,
|
|
786
|
+
let [e, t] = await Promise.all([c("package.json"), c("config.json")]), r = Ht(e), i = Ut(r), a = K(e.engines?.node), s = K(e.engines?.npm), l = K(e.devDependencies?.typescript), u = Wt(_(t.id), e.name), d = `${r.replace(/\.git$/, "")}/blob/main/package.json`, p = Gt(u, r, i, a, s, l, `${e.name === "@dpuse/dpuse-development" ? zt : Bt} See the \`scripts\` block in [package.json](${d}) for details.`);
|
|
787
|
+
await n(p, Pt, Ft), o("Usage documented");
|
|
762
788
|
} catch (e) {
|
|
763
789
|
console.error("❌ Error documenting usage", e), process.exit(1);
|
|
764
790
|
}
|
|
765
791
|
}
|
|
766
|
-
function
|
|
792
|
+
function Ht(e) {
|
|
767
793
|
let t = e.repository, n = typeof t == "string" ? t : t?.url;
|
|
768
794
|
if (n == null || n === "") throw Error("package.json 'repository' field is required to document usage.");
|
|
769
795
|
return n.replace(/^git\+/, "");
|
|
770
796
|
}
|
|
771
|
-
function
|
|
797
|
+
function Ut(e) {
|
|
772
798
|
return (e.split("/").at(-1) ?? "").replace(/\.git$/, "");
|
|
773
799
|
}
|
|
774
800
|
function K(e) {
|
|
@@ -777,9 +803,9 @@ function K(e) {
|
|
|
777
803
|
if (t == null) throw Error(`Unable to parse version from '${e}'.`);
|
|
778
804
|
return t[0];
|
|
779
805
|
}
|
|
780
|
-
function
|
|
806
|
+
function Wt(e, t) {
|
|
781
807
|
let { typeId: n } = e;
|
|
782
|
-
if (
|
|
808
|
+
if (It.has(n)) return `This ${n} is automatically uploaded to the DPUse Engine cloud once released and becomes instantly available to all new browser app instances, with existing instances notified of the update.
|
|
783
809
|
|
|
784
810
|
You may view or clone this repository for your own purposes, such as building a new, similar ${n}, though there is currently no process to accept third-party ${n}s into DPUse at this stage.`;
|
|
785
811
|
if (e.publishedTo === "npm") {
|
|
@@ -790,11 +816,11 @@ You may view or clone this repository for your own purposes, such as building a
|
|
|
790
816
|
npm install ${t}
|
|
791
817
|
\`\`\`
|
|
792
818
|
|
|
793
|
-
${
|
|
819
|
+
${Lt.has(n) ? `${Rt}\n\n` : ""}To work on the source instead, clone this repository.`;
|
|
794
820
|
}
|
|
795
821
|
return "You may view or clone this repository for your own purposes.";
|
|
796
822
|
}
|
|
797
|
-
function
|
|
823
|
+
function Gt(e, t, n, r, i, a, o) {
|
|
798
824
|
return `## Usage
|
|
799
825
|
|
|
800
826
|
${e}
|
|
@@ -812,7 +838,7 @@ ${o}`;
|
|
|
812
838
|
//#endregion
|
|
813
839
|
//#region src/actions/documentApiReference.ts
|
|
814
840
|
var q = "API_REFERENCE.md";
|
|
815
|
-
async function
|
|
841
|
+
async function Kt() {
|
|
816
842
|
try {
|
|
817
843
|
f("Document API Reference");
|
|
818
844
|
let { writeAPIReference: e } = await import("./apiReference-Fj5_02JP.js");
|
|
@@ -823,90 +849,90 @@ async function Ut() {
|
|
|
823
849
|
}
|
|
824
850
|
//#endregion
|
|
825
851
|
//#region src/actions/documentBundleSizes.ts
|
|
826
|
-
var
|
|
827
|
-
async function
|
|
852
|
+
var qt = "bundle-analysis-reports/sonda/index.json", Jt = "<!-- BUNDLE_START -->", Yt = "<!-- BUNDLE_END -->", J = " ", Y = 20, Xt = "█", Zt = "▒", Qt = 100 / Y / 2, $t = 100 / Y, en = "This report is updated with each release, from the bundle the release builds, using [Sonda](https://sonda.dev/), which analyses final source maps to reveal the actual effects of tree-shaking and minification rather than relying on pre-build estimates.\n\n_Note: Sonda's Vite reports currently exclude CSS files, since Vite does not generate source maps for CSS._", tn = "Bars show each row's share of its output file.", nn = "↳ rows are part of the row above.", X = "(bundler output, whitespace & JSON)", rn = `${X} = bytes Sonda can't trace to a source file: whitespace (indentation and line breaks), code the bundler generates (region comments, the combined import/export lines, its small runtime helper and wrappers), and imported JSON such as \`config.json\`, which the bundler doesn't map. The JSON and the generated code are real bytes that ship; the whitespace mostly disappears once compressed.`;
|
|
853
|
+
async function an(e) {
|
|
828
854
|
try {
|
|
829
855
|
f("Document Bundle Sizes"), b("1️⃣ Read bundle analysis report");
|
|
830
|
-
let t = await c(
|
|
856
|
+
let t = await c(qt);
|
|
831
857
|
b("2️⃣ Insert table into 'README.md'");
|
|
832
|
-
let r =
|
|
833
|
-
await n(`## Bundle Analysis\n\n${
|
|
858
|
+
let r = on(t, e?.moduleLevel ?? !1), i = r.includes("↳") ? `${tn} ${nn}` : tn;
|
|
859
|
+
await n(`## Bundle Analysis\n\n${en}\n\n${r}\n\n${i}\n\n${rn}`, Jt, Yt), o("Bundle sizes documented");
|
|
834
860
|
} catch (e) {
|
|
835
861
|
console.error("❌ Error documenting bundle sizes", e), process.exit(1);
|
|
836
862
|
}
|
|
837
863
|
}
|
|
838
|
-
function
|
|
839
|
-
let n =
|
|
864
|
+
function on(e, t) {
|
|
865
|
+
let n = pn(e), r = n.values().flatMap((e) => e.values().toArray()).reduce((e, t) => e + t.sizes.uncompressed, 0), i = e.resources.filter((e) => e.kind === "asset").map((e) => [e.name, vn(e)]).toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), a = ["|Chunk/Module/File|Composition|", "|:------ |:-----------|"];
|
|
840
866
|
for (let [e, o] of i) {
|
|
841
|
-
let i = [...n.get(e) ?? /* @__PURE__ */ new Map()].toSorted(
|
|
842
|
-
a.push(`| **${e}** | ${
|
|
867
|
+
let i = [...n.get(e) ?? /* @__PURE__ */ new Map()].toSorted(sn), s = i.reduce((e, [, t]) => e + t.sizes.uncompressed, 0), c = s > 0 && r > 0 ? ` · ${Sn(s, r)} of the build` : "";
|
|
868
|
+
a.push(`| **${e}** | ${yn(o)}${c} |`, ...cn(i, s, t));
|
|
843
869
|
}
|
|
844
870
|
return a.join("\n");
|
|
845
871
|
}
|
|
846
|
-
function
|
|
872
|
+
function sn(e, t) {
|
|
847
873
|
return e[0] === X == (t[0] === X) ? t[1].sizes.uncompressed - e[1].sizes.uncompressed : e[0] === X ? 1 : -1;
|
|
848
874
|
}
|
|
849
|
-
function
|
|
875
|
+
function cn(e, t, n) {
|
|
850
876
|
let r = [];
|
|
851
877
|
for (let [i, { sizes: a, files: o }] of e) {
|
|
852
878
|
if (o.size === 1) {
|
|
853
|
-
let e =
|
|
854
|
-
r.push(`| ${J}${
|
|
879
|
+
let e = fn(o);
|
|
880
|
+
r.push(`| ${J}${dn(i, e)} | ${Z(a.uncompressed, t)} |`);
|
|
855
881
|
continue;
|
|
856
882
|
}
|
|
857
|
-
r.push(`| ${J}${i} | ${Z(a.uncompressed, t)} |`), n || r.push(...
|
|
883
|
+
r.push(`| ${J}${i} | ${Z(a.uncompressed, t)} |`), n || r.push(...ln(o, t));
|
|
858
884
|
}
|
|
859
885
|
return r;
|
|
860
886
|
}
|
|
861
|
-
function
|
|
862
|
-
let n = [...e].toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), r =
|
|
887
|
+
function ln(e, t) {
|
|
888
|
+
let n = [...e].toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), r = un(n, t), i = (r > 0 ? n.slice(0, -r) : n).map(([e, n]) => `| ${J}${J}↳ ${e} | ${Z(n.uncompressed, t, Zt)} |`);
|
|
863
889
|
if (r > 0) {
|
|
864
890
|
let e = n.slice(-r).reduce((e, [, t]) => e + t.uncompressed, 0);
|
|
865
|
-
i.push(`| ${J}${J}↳ ${String(r)} smaller files | ${Z(e, t,
|
|
891
|
+
i.push(`| ${J}${J}↳ ${String(r)} smaller files | ${Z(e, t, Zt)} |`);
|
|
866
892
|
}
|
|
867
893
|
return i;
|
|
868
894
|
}
|
|
869
|
-
function
|
|
895
|
+
function un(e, t) {
|
|
870
896
|
if (t <= 0) return 0;
|
|
871
897
|
let n = 0, r = 0;
|
|
872
898
|
for (let [, i] of e.toReversed()) {
|
|
873
|
-
let e = i.uncompressed / t * 100 <
|
|
899
|
+
let e = i.uncompressed / t * 100 < Qt, a = (r + i.uncompressed) / t * 100 <= $t;
|
|
874
900
|
if (!e || !a) break;
|
|
875
901
|
n++, r += i.uncompressed;
|
|
876
902
|
}
|
|
877
903
|
return n >= 2 ? n : 0;
|
|
878
904
|
}
|
|
879
|
-
function Z(e, t, n =
|
|
880
|
-
return `${
|
|
905
|
+
function Z(e, t, n = Xt) {
|
|
906
|
+
return `${bn(t > 0 ? e / t * 100 : 0, n)} · ${$(e)}`;
|
|
881
907
|
}
|
|
882
|
-
function
|
|
908
|
+
function dn(e, t) {
|
|
883
909
|
return t === "" ? e : `${e} → ${t}`;
|
|
884
910
|
}
|
|
885
|
-
function
|
|
911
|
+
function fn(e) {
|
|
886
912
|
let [t] = e.keys();
|
|
887
913
|
if (t === void 0) throw Error("Expected exactly one file");
|
|
888
914
|
return t;
|
|
889
915
|
}
|
|
890
|
-
function
|
|
891
|
-
let t =
|
|
916
|
+
function pn(e) {
|
|
917
|
+
let t = mn(e.dependencies), n = /* @__PURE__ */ new Map();
|
|
892
918
|
for (let r of e.resources) {
|
|
893
919
|
if (r.kind !== "chunk" || !r.parent) continue;
|
|
894
|
-
let { group: e, file: i } =
|
|
920
|
+
let { group: e, file: i } = hn(r.name, t), a = vn(r), o = n.get(r.parent) ?? /* @__PURE__ */ new Map();
|
|
895
921
|
n.set(r.parent, o);
|
|
896
922
|
let s = o.get(e) ?? {
|
|
897
|
-
sizes:
|
|
923
|
+
sizes: Q(),
|
|
898
924
|
files: /* @__PURE__ */ new Map()
|
|
899
925
|
};
|
|
900
|
-
o.set(e, s),
|
|
901
|
-
let c = s.files.get(i) ??
|
|
902
|
-
s.files.set(i, c),
|
|
926
|
+
o.set(e, s), xn(s.sizes, a);
|
|
927
|
+
let c = s.files.get(i) ?? Q();
|
|
928
|
+
s.files.set(i, c), xn(c, a);
|
|
903
929
|
}
|
|
904
930
|
return n;
|
|
905
931
|
}
|
|
906
|
-
function
|
|
932
|
+
function mn(e) {
|
|
907
933
|
return e.flatMap((e) => e.paths.map((t) => [t, e.name])).toSorted((e, t) => t[0].length - e[0].length);
|
|
908
934
|
}
|
|
909
|
-
function
|
|
935
|
+
function hn(e, t) {
|
|
910
936
|
let n = t.find(([t]) => e === t || e.startsWith(`${t}/`));
|
|
911
937
|
if (n) {
|
|
912
938
|
let [t, r] = n;
|
|
@@ -923,55 +949,55 @@ function fn(e, t) {
|
|
|
923
949
|
file: e.slice(1)
|
|
924
950
|
} : e.startsWith("rust/") ? {
|
|
925
951
|
group: "wasm",
|
|
926
|
-
file:
|
|
952
|
+
file: gn(e)
|
|
927
953
|
} : {
|
|
928
954
|
group: "src",
|
|
929
|
-
file:
|
|
955
|
+
file: _n(e)
|
|
930
956
|
};
|
|
931
957
|
}
|
|
932
|
-
function
|
|
933
|
-
let t = e.split("/", 2)[1] ?? "", n =
|
|
958
|
+
function gn(e) {
|
|
959
|
+
let t = e.split("/", 2)[1] ?? "", n = _n(e);
|
|
934
960
|
return t !== "" && n.startsWith(t) ? `…${n.slice(t.length)}` : n;
|
|
935
961
|
}
|
|
936
|
-
function
|
|
962
|
+
function _n(e) {
|
|
937
963
|
return e.split("/").at(-1) ?? e;
|
|
938
964
|
}
|
|
939
|
-
function
|
|
965
|
+
function vn(e) {
|
|
940
966
|
return {
|
|
941
967
|
uncompressed: e.uncompressed,
|
|
942
968
|
gzip: e.gzip ?? 0
|
|
943
969
|
};
|
|
944
970
|
}
|
|
945
|
-
function
|
|
946
|
-
return `${
|
|
971
|
+
function yn(e) {
|
|
972
|
+
return `${$(e.uncompressed)} · gzip ${$(e.gzip)}`;
|
|
947
973
|
}
|
|
948
|
-
function
|
|
974
|
+
function bn(e, t = Xt) {
|
|
949
975
|
let n = Math.round(e / 100 * Y);
|
|
950
976
|
return `\`${t.repeat(n)}${"░".repeat(Y - n)}\` ${e.toFixed(1)}%`;
|
|
951
977
|
}
|
|
952
|
-
function
|
|
978
|
+
function Q() {
|
|
953
979
|
return {
|
|
954
980
|
uncompressed: 0,
|
|
955
981
|
gzip: 0
|
|
956
982
|
};
|
|
957
983
|
}
|
|
958
|
-
function
|
|
984
|
+
function xn(e, t) {
|
|
959
985
|
e.uncompressed += t.uncompressed, e.gzip += t.gzip;
|
|
960
986
|
}
|
|
961
|
-
function
|
|
987
|
+
function Sn(e, t) {
|
|
962
988
|
return `${(e / t * 100).toFixed(1)}%`;
|
|
963
989
|
}
|
|
964
|
-
function
|
|
990
|
+
function $(e) {
|
|
965
991
|
return e < 1024 ? `${String(e)} B` : `${(e / 1024).toFixed(1)} kB`;
|
|
966
992
|
}
|
|
967
993
|
//#endregion
|
|
968
994
|
//#region src/actions/documentProject.ts
|
|
969
|
-
async function
|
|
995
|
+
async function Cn(e = "MIT", t = !1) {
|
|
970
996
|
try {
|
|
971
997
|
let n = await c("config.json"), r = _(n.id).typeId === "connector";
|
|
972
|
-
await
|
|
998
|
+
await at(), r && await Ne(), await Vt(), await Ve(e), await i("bundle-analysis-reports/sonda/index.json") === null ? b(`ℹ️ Bundle sizes NOT documented, as there is no '${qt}' yet. Build the project first.`) : await an({ moduleLevel: t }), await xt(), await Pe();
|
|
973
999
|
let a = await i(q) !== null;
|
|
974
|
-
a ? await
|
|
1000
|
+
a ? await Kt() : b(`ℹ️ '${q}' NOT required by this project`), await x("ℹ️ Format generated files", "prettier", [
|
|
975
1001
|
"--write",
|
|
976
1002
|
"README.md",
|
|
977
1003
|
...a ? [q] : []
|
|
@@ -982,7 +1008,7 @@ async function xn(e = "MIT", t = !1) {
|
|
|
982
1008
|
}
|
|
983
1009
|
//#endregion
|
|
984
1010
|
//#region src/actions/formatCode.ts
|
|
985
|
-
async function
|
|
1011
|
+
async function wn() {
|
|
986
1012
|
try {
|
|
987
1013
|
f("Format Code");
|
|
988
1014
|
let e = [
|
|
@@ -1003,7 +1029,7 @@ async function Sn() {
|
|
|
1003
1029
|
}
|
|
1004
1030
|
//#endregion
|
|
1005
1031
|
//#region src/actions/lintCode.ts
|
|
1006
|
-
async function
|
|
1032
|
+
async function Tn() {
|
|
1007
1033
|
try {
|
|
1008
1034
|
f("Lint Code"), await x("1️⃣ Lint", "eslint", ["."]), o("Code linted");
|
|
1009
1035
|
} catch (e) {
|
|
@@ -1012,7 +1038,7 @@ async function Cn() {
|
|
|
1012
1038
|
}
|
|
1013
1039
|
//#endregion
|
|
1014
1040
|
//#region src/utilities/cloudflare.ts
|
|
1015
|
-
async function
|
|
1041
|
+
async function En() {
|
|
1016
1042
|
let e = await c("config.json"), t = {
|
|
1017
1043
|
body: JSON.stringify(e),
|
|
1018
1044
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1020,7 +1046,7 @@ async function wn() {
|
|
|
1020
1046
|
}, n = await fetch(`https://api.dpuse.app/configs/${e.id}`, t);
|
|
1021
1047
|
if (!n.ok) throw Error(await n.text());
|
|
1022
1048
|
}
|
|
1023
|
-
async function
|
|
1049
|
+
async function Dn(e, t) {
|
|
1024
1050
|
async function n(e, t, r) {
|
|
1025
1051
|
for (let i of r) {
|
|
1026
1052
|
let r = `${e}/${i}`, a = `${t}/${i}`;
|
|
@@ -1038,7 +1064,7 @@ async function Tn(e, t) {
|
|
|
1038
1064
|
let r = await v(`${e}/${t}/`);
|
|
1039
1065
|
await n(`${e}/${t}`, t, r);
|
|
1040
1066
|
}
|
|
1041
|
-
async function
|
|
1067
|
+
async function On(e) {
|
|
1042
1068
|
let t = e.id, n = {
|
|
1043
1069
|
body: JSON.stringify(e),
|
|
1044
1070
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1046,7 +1072,7 @@ async function En(e) {
|
|
|
1046
1072
|
}, r = await fetch(`https://api.dpuse.app/configs/${t}`, n);
|
|
1047
1073
|
if (!r.ok) throw Error(await r.text());
|
|
1048
1074
|
}
|
|
1049
|
-
async function
|
|
1075
|
+
async function kn(e, t) {
|
|
1050
1076
|
let n = `v${e.version ?? "unknown"}`;
|
|
1051
1077
|
async function r(e, r = "") {
|
|
1052
1078
|
let i = await v(e, { withFileTypes: !0 });
|
|
@@ -1070,34 +1096,34 @@ async function Dn(e, t) {
|
|
|
1070
1096
|
}
|
|
1071
1097
|
//#endregion
|
|
1072
1098
|
//#region src/actions/publishProject.ts
|
|
1073
|
-
async function
|
|
1099
|
+
async function An() {
|
|
1074
1100
|
try {
|
|
1075
1101
|
f("Publish Project");
|
|
1076
1102
|
let e = await c("package.json"), t = await c("config.json"), n = _(t.id);
|
|
1077
|
-
n.publishedTo === "npm" ? await x("1️⃣ Publish to npm", "npm", ["publish", "--provenance"]) : b("1️⃣ Publishing to npm NOT required"), await
|
|
1103
|
+
n.publishedTo === "npm" ? await x("1️⃣ Publish to npm", "npm", ["publish", "--provenance"]) : b("1️⃣ Publishing to npm NOT required"), await jn("2️⃣ ", e, t, n), o(`Project version '${e.version ?? "unknown"}' published.`);
|
|
1078
1104
|
} catch (e) {
|
|
1079
1105
|
console.error("❌ Error publishing project", e), process.exit(1);
|
|
1080
1106
|
}
|
|
1081
1107
|
}
|
|
1082
|
-
async function
|
|
1083
|
-
if (r.typeId === "app") b(`${e} Register module`), await
|
|
1084
|
-
else if (r.typeId === "engine") b(`${e} Register module`), await
|
|
1108
|
+
async function jn(e, t, n, r) {
|
|
1109
|
+
if (r.typeId === "app") b(`${e} Register module`), await En();
|
|
1110
|
+
else if (r.typeId === "engine") b(`${e} Register module`), await kn(t, `dpuse-engine-eu/${r.uploadGroupName ?? "unknown"}`), await On(n);
|
|
1085
1111
|
else if (r.uploadGroupName === void 0) b(`${e} Registration NOT required`);
|
|
1086
1112
|
else {
|
|
1087
1113
|
b(`${e} Register module`);
|
|
1088
1114
|
let i = n.id.split("-").slice(2).join("-");
|
|
1089
|
-
await
|
|
1115
|
+
await kn(t, `dpuse-engine-eu/${r.uploadGroupName}/${i}`), await On(n);
|
|
1090
1116
|
}
|
|
1091
1117
|
}
|
|
1092
1118
|
//#endregion
|
|
1093
1119
|
//#region src/actions/releaseProject.ts
|
|
1094
|
-
async function
|
|
1120
|
+
async function Mn(e = "MIT", t = !1) {
|
|
1095
1121
|
try {
|
|
1096
1122
|
f("Release Project");
|
|
1097
1123
|
let n = await c("package.json"), r = await c("config.json"), i = _(r.id);
|
|
1098
1124
|
await y("1️⃣ ", n);
|
|
1099
1125
|
let a = await g("2️⃣ ", n, i);
|
|
1100
|
-
if (await
|
|
1126
|
+
if (await he("3️⃣ ", n), b("4️⃣ Regenerate README"), await Cn(e, t), await d("5️⃣ Stage changes", "git", ["add", "."]), await d("6️⃣ Commit changes", "git", [
|
|
1101
1127
|
"commit",
|
|
1102
1128
|
"-m",
|
|
1103
1129
|
`v${n.version ?? "unknown"}`
|
|
@@ -1105,7 +1131,7 @@ async function kn(e = "MIT", t = !1) {
|
|
|
1105
1131
|
"push",
|
|
1106
1132
|
"origin",
|
|
1107
1133
|
"main:main"
|
|
1108
|
-
]), await
|
|
1134
|
+
]), await jn("8️⃣ ", n, a, i), i.publishedTo === "npm") {
|
|
1109
1135
|
let e = `v${n.version ?? "unknown"}`;
|
|
1110
1136
|
await x("9️⃣ Create GitHub release", "gh", [
|
|
1111
1137
|
"release",
|
|
@@ -1124,7 +1150,7 @@ async function kn(e = "MIT", t = !1) {
|
|
|
1124
1150
|
}
|
|
1125
1151
|
//#endregion
|
|
1126
1152
|
//#region src/actions/syncProjectWithGitHub.ts
|
|
1127
|
-
async function
|
|
1153
|
+
async function Nn() {
|
|
1128
1154
|
try {
|
|
1129
1155
|
f("Synchronise Project with GitHub");
|
|
1130
1156
|
let e = await c("package.json"), t = await c("config.json"), n = _(t.id);
|
|
@@ -1143,12 +1169,12 @@ async function An() {
|
|
|
1143
1169
|
}
|
|
1144
1170
|
//#endregion
|
|
1145
1171
|
//#region src/actions/testProject.ts
|
|
1146
|
-
var
|
|
1172
|
+
var Pn = [
|
|
1147
1173
|
"1️⃣ ",
|
|
1148
1174
|
"2️⃣ ",
|
|
1149
1175
|
"3️⃣ ",
|
|
1150
1176
|
"4️⃣ "
|
|
1151
|
-
],
|
|
1177
|
+
], Fn = [{
|
|
1152
1178
|
id: "unit",
|
|
1153
1179
|
label: "Run unit tests",
|
|
1154
1180
|
command: "vitest",
|
|
@@ -1161,13 +1187,13 @@ var jn = [
|
|
|
1161
1187
|
arguments: ["test", "--pass-with-no-tests"],
|
|
1162
1188
|
configFileName: "playwright.config.ts"
|
|
1163
1189
|
}];
|
|
1164
|
-
async function
|
|
1190
|
+
async function In(e = ["unit"]) {
|
|
1165
1191
|
try {
|
|
1166
1192
|
f("Test Project");
|
|
1167
1193
|
let t = 0;
|
|
1168
|
-
for (let n of
|
|
1194
|
+
for (let n of Fn) {
|
|
1169
1195
|
if (!e.includes(n.id) || await i(n.configFileName) === null) continue;
|
|
1170
|
-
let r = `${
|
|
1196
|
+
let r = `${Pn[t] ?? ""} ${n.label}`;
|
|
1171
1197
|
await x(r, n.command, n.arguments), t += 1;
|
|
1172
1198
|
}
|
|
1173
1199
|
if (t === 0) {
|
|
@@ -1180,4 +1206,4 @@ async function Nn(e = ["unit"]) {
|
|
|
1180
1206
|
}
|
|
1181
1207
|
}
|
|
1182
1208
|
//#endregion
|
|
1183
|
-
export {
|
|
1209
|
+
export { fe as auditDependencies, me as buildProject, De as checkProject, Cn as documentProject, wn as formatCode, Tn as lintCode, An as publishProject, Mn as releaseProject, Nn as syncProjectWithGitHub, In as testProject, Dn as uploadDirectoryToR2 };
|