@dpuse/dpuse-development 0.3.814 → 0.3.816
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 +22 -21
- package/dist/dpuse-development.es.js +453 -288
- package/dist/dpuse-development.es.js.map +1 -1
- package/dist/types/src/actions/triggerGitHubRelease.d.ts +2 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/utilities/rustCrates.d.ts +29 -0
- package/package.json +3 -1
|
@@ -1,14 +1,16 @@
|
|
|
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
|
|
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 y, s as ne, t as re, u as ie, 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 } from "node:fs";
|
|
4
|
-
import
|
|
3
|
+
import { existsSync as oe, promises as w } from "node:fs";
|
|
4
|
+
import T from "node:path";
|
|
5
5
|
import { promisify as se } from "node:util";
|
|
6
6
|
import { execFile as ce } from "node:child_process";
|
|
7
7
|
import { fileURLToPath as le } from "node:url";
|
|
8
8
|
import { run as ue } from "npm-check-updates";
|
|
9
9
|
import { init as de } from "license-checker-rseidelsohn";
|
|
10
|
+
import { setTimeout as fe } from "node:timers/promises";
|
|
11
|
+
import pe from "spdx-satisfies";
|
|
10
12
|
//#region src/actions/auditDependencies.ts
|
|
11
|
-
async function
|
|
13
|
+
async function me() {
|
|
12
14
|
try {
|
|
13
15
|
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
16
|
} catch (e) {
|
|
@@ -17,43 +19,43 @@ async function fe() {
|
|
|
17
19
|
}
|
|
18
20
|
//#endregion
|
|
19
21
|
//#region src/actions/buildProject.ts
|
|
20
|
-
var
|
|
21
|
-
async function
|
|
22
|
+
var he = "build:wasm";
|
|
23
|
+
async function ge() {
|
|
22
24
|
try {
|
|
23
|
-
f("Build Project"), await
|
|
25
|
+
f("Build Project"), await _e("1️⃣ ", await c("package.json")), o("Project built");
|
|
24
26
|
} catch (e) {
|
|
25
27
|
console.error("❌ Error building project", e), process.exit(1);
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
|
-
async function
|
|
29
|
-
t.scripts?.[
|
|
30
|
+
async function _e(e, t) {
|
|
31
|
+
t.scripts?.[he] != null && await x(`${e} Build WebAssembly`, "npm", ["run", he]), await x(`${e} Bundle project`, "vite", ["build"]);
|
|
30
32
|
}
|
|
31
33
|
//#endregion
|
|
32
34
|
//#region src/actions/checkConfigFiles.ts
|
|
33
|
-
var
|
|
34
|
-
async function
|
|
35
|
+
var E = "@dpuse/dpuse-development/prettierrc", ve = "dpuse-development";
|
|
36
|
+
async function ye() {
|
|
35
37
|
try {
|
|
36
38
|
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 =
|
|
38
|
-
await
|
|
39
|
+
let e = await c("config.json"), t = await c("package.json"), n = t.private === !0, r = _(e.id), a = T.dirname(le(import.meta.url));
|
|
40
|
+
await D(a, ".editorconfig"), await D(a, ".gitattributes"), await D(a, ".gitignore", [".gitignore_default"]), await D(a, ".markdownlint.json"), await D(a, ".ncurc.json"), await be(r, a), await D(a, "LICENSE"), await Se(r, a), await Ce(r, a), await we(r, a), await Ee(r, a), xe(r, t);
|
|
39
41
|
let s = await i(l) !== null;
|
|
40
|
-
s && await
|
|
42
|
+
s && await D(a, "rust-toolchain.toml"), await D(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 Te(a), await D(a, "SECURITY.md", [], (t) => t.replaceAll(ve, () => e.id))), o("Configuration files checked");
|
|
41
43
|
} catch (e) {
|
|
42
44
|
console.error("❌ Error checking configuration files", e), process.exit(1);
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
|
-
async function
|
|
47
|
+
async function be(e, t) {
|
|
46
48
|
["github", "kb"].includes(e.typeId) ? console.info("ℹ️ File 'eslint.config.js' is NOT required by this project") : [
|
|
47
49
|
"app",
|
|
48
50
|
"api",
|
|
49
51
|
"development",
|
|
50
52
|
"eslint"
|
|
51
|
-
].includes(e.typeId) ? console.info("⚠️ File 'eslint.config.js' is UNIQUE to this project") : await
|
|
53
|
+
].includes(e.typeId) ? console.info("⚠️ File 'eslint.config.js' is UNIQUE to this project") : await D(t, "eslint.config.js", ["eslint.config.default.js"]);
|
|
52
54
|
}
|
|
53
|
-
function
|
|
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 ===
|
|
55
|
+
function xe(e, t) {
|
|
56
|
+
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 === E ? console.info(`ℹ️ Prettier configuration is '${E}'`) : console.info(`❌ Prettier configuration is NOT '${E}'`);
|
|
55
57
|
}
|
|
56
|
-
async function
|
|
58
|
+
async function Se(e, t) {
|
|
57
59
|
["github"].includes(e.typeId) ? console.info("ℹ️ File 'tsconfig.json' is NOT required by this project") : [
|
|
58
60
|
"connector",
|
|
59
61
|
"cookbook",
|
|
@@ -62,12 +64,12 @@ async function be(e, t) {
|
|
|
62
64
|
"presenter",
|
|
63
65
|
"shared",
|
|
64
66
|
"tool"
|
|
65
|
-
].includes(e.typeId) ? await
|
|
67
|
+
].includes(e.typeId) ? await D(t, "tsconfig.json") : console.info("⚠️ File 'tsconfig.json' is UNIQUE to this project");
|
|
66
68
|
}
|
|
67
|
-
async function
|
|
68
|
-
["github"].includes(e.typeId) ? console.info("ℹ️ File 'scripts/tsconfig.json' is NOT required by this project") : await
|
|
69
|
+
async function Ce(e, t) {
|
|
70
|
+
["github"].includes(e.typeId) ? console.info("ℹ️ File 'scripts/tsconfig.json' is NOT required by this project") : await D(t, "scripts/tsconfig.json");
|
|
69
71
|
}
|
|
70
|
-
async function
|
|
72
|
+
async function we(e, t) {
|
|
71
73
|
if ([
|
|
72
74
|
"eslint",
|
|
73
75
|
"github",
|
|
@@ -90,23 +92,23 @@ async function Se(e, t) {
|
|
|
90
92
|
break;
|
|
91
93
|
default: n = ["vite.config.default.ts"];
|
|
92
94
|
}
|
|
93
|
-
await
|
|
95
|
+
await D(t, "vite.config.ts", n);
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
|
-
async function
|
|
97
|
-
await
|
|
98
|
+
async function Te(e) {
|
|
99
|
+
await D(e, ".github/workflows/ci.yml"), await D(e, ".github/workflows/codeql.yml"), await D(e, ".github/workflows/publish.yml"), await D(e, ".github/workflows/scorecard.yml");
|
|
98
100
|
}
|
|
99
|
-
async function
|
|
101
|
+
async function Ee(e, t) {
|
|
100
102
|
[
|
|
101
103
|
"app",
|
|
102
104
|
"api",
|
|
103
105
|
"eslint",
|
|
104
106
|
"github",
|
|
105
107
|
"kb"
|
|
106
|
-
].includes(e.typeId) ? console.info("ℹ️ File 'vitest.config.ts' is NOT required by this project") : await
|
|
108
|
+
].includes(e.typeId) ? console.info("ℹ️ File 'vitest.config.ts' is NOT required by this project") : await D(t, "vitest.config.ts");
|
|
107
109
|
}
|
|
108
|
-
async function
|
|
109
|
-
let i =
|
|
110
|
+
async function D(e, t, n = [], r = (e) => e) {
|
|
111
|
+
let i = T.resolve(process.cwd(), t), a = n.length > 0 ? n : [t], o;
|
|
110
112
|
try {
|
|
111
113
|
o = await S(i);
|
|
112
114
|
} catch (e) {
|
|
@@ -117,7 +119,7 @@ async function E(e, t, n = [], r = (e) => e) {
|
|
|
117
119
|
return;
|
|
118
120
|
}
|
|
119
121
|
for (let n of a) {
|
|
120
|
-
let i =
|
|
122
|
+
let i = T.resolve(e, `../${n}`), a = r(await S(i));
|
|
121
123
|
if (o === a) {
|
|
122
124
|
console.info(`ℹ️ File '${t}' is the same as '${n}'`);
|
|
123
125
|
return;
|
|
@@ -127,12 +129,12 @@ async function E(e, t, n = [], r = (e) => e) {
|
|
|
127
129
|
}
|
|
128
130
|
//#endregion
|
|
129
131
|
//#region src/actions/checkDependencies.ts
|
|
130
|
-
async function
|
|
132
|
+
async function De() {
|
|
131
133
|
try {
|
|
132
134
|
f("Check Dependencies"), await x("1️⃣ Check using 'npm outdated'", "npm", ["outdated"], !0), b("2️⃣ Check using 'npm-check-updates'");
|
|
133
135
|
let e = {};
|
|
134
136
|
try {
|
|
135
|
-
e = await c(
|
|
137
|
+
e = await c(T.resolve(process.cwd(), ".ncurc.json"));
|
|
136
138
|
} catch (e) {
|
|
137
139
|
if (e.code !== "ENOENT") throw e;
|
|
138
140
|
}
|
|
@@ -154,7 +156,7 @@ async function Te() {
|
|
|
154
156
|
"--no-strict-allow-scripts",
|
|
155
157
|
"--no-fund"
|
|
156
158
|
], !0);
|
|
157
|
-
let t = await
|
|
159
|
+
let t = await Oe();
|
|
158
160
|
t.length > 0 ? await x("5️⃣ Move install-script pins to installed versions", "npm", [
|
|
159
161
|
"install-scripts",
|
|
160
162
|
"approve",
|
|
@@ -173,56 +175,56 @@ async function Te() {
|
|
|
173
175
|
console.error("❌ Error checking dependencies", e), process.exit(1);
|
|
174
176
|
}
|
|
175
177
|
}
|
|
176
|
-
async function
|
|
177
|
-
let { allowScripts: e = {} } = await c(
|
|
178
|
+
async function Oe() {
|
|
179
|
+
let { allowScripts: e = {} } = await c(T.resolve(process.cwd(), "package.json")), t = Object.entries(e).filter(([e, t]) => t && e.lastIndexOf("@") > 0).map(([e]) => e.slice(0, e.lastIndexOf("@")));
|
|
178
180
|
return [...new Set(t)];
|
|
179
181
|
}
|
|
180
182
|
//#endregion
|
|
181
183
|
//#region src/actions/checkProject.ts
|
|
182
|
-
async function
|
|
183
|
-
await
|
|
184
|
+
async function ke() {
|
|
185
|
+
await ye(), await De();
|
|
184
186
|
}
|
|
185
187
|
//#endregion
|
|
186
188
|
//#region src/actions/documentActions.ts
|
|
187
|
-
var
|
|
189
|
+
var Ae = "<!-- SUPPORTED_ACTIONS_START -->", je = "<!-- SUPPORTED_ACTIONS_END -->", Me = "Connectors conform to a unified interface contract by implementing a specific subset of standard actions. These standardised actions allow the DPUse application to interact with any underlying data source in the same way, enabling Connectors to be built independently and loaded dynamically at runtime.", Ne = {
|
|
188
190
|
source: "This connector is a Source connector that supports only read actions. Connectors can also function as a Destination (write-only) or Bidirectional (read/write), depending on the actions they support.",
|
|
189
191
|
destination: "This connector is a Destination connector that supports only write actions. Connectors can also function as a Source (read-only) or Bidirectional (read/write), depending on the actions they support.",
|
|
190
192
|
bidirectional: "This connector is a Bidirectional connector that supports both read and write actions. Connectors can also function as a Source (read-only) or Destination (write-only), depending on the actions they support.",
|
|
191
193
|
unknown: "This connector does not yet implement any read or write actions, so its type cannot be determined. Connectors function as a Source (read-only), a Destination (write-only), or Bidirectional (read/write), depending on the actions they support."
|
|
192
|
-
},
|
|
193
|
-
async function
|
|
194
|
+
}, Pe = "The table below lists all connector actions and highlights those supported by this connector.";
|
|
195
|
+
async function Fe() {
|
|
194
196
|
try {
|
|
195
197
|
f("Document Actions"), b("1️⃣ Insert actions description and table into 'README.md'");
|
|
196
|
-
let t = (await c("config.json")).actionNames ?? [], r = h(t), i = e(t), a = `## Supported Actions\n\n${
|
|
197
|
-
await n(a,
|
|
198
|
+
let t = (await c("config.json")).actionNames ?? [], r = h(t), i = e(t), a = `## Supported Actions\n\n${Me}\n\n${Ne[r]} ${Pe}\n\n${i}`;
|
|
199
|
+
await n(a, Ae, je), o("Actions documented");
|
|
198
200
|
} catch (e) {
|
|
199
201
|
console.error("❌ Error documenting actions", e), process.exit(1);
|
|
200
202
|
}
|
|
201
203
|
}
|
|
202
204
|
//#endregion
|
|
203
205
|
//#region src/actions/documentContributingLicense.ts
|
|
204
|
-
async function
|
|
206
|
+
async function Ie() {
|
|
205
207
|
try {
|
|
206
208
|
f("Document Contributing & License");
|
|
207
|
-
let [e, r] = await Promise.all([c("package.json"), c("config.json")]), { owner: i, repo: a } = t(e, "document contributing and license"), s =
|
|
208
|
-
b("1️⃣ Insert contributing and license content into 'README.md'"), await C(), await n(
|
|
209
|
+
let [e, r] = await Promise.all([c("package.json"), c("config.json")]), { owner: i, repo: a } = t(e, "document contributing and license"), s = Le(e), l = Re(r.firstCreatedAt);
|
|
210
|
+
b("1️⃣ Insert contributing and license content into 'README.md'"), await C(), await n(ze(i, a, s, l), ee, re), o("Contributing & license documented");
|
|
209
211
|
} catch (e) {
|
|
210
212
|
console.error("❌ Error documenting contributing and license", e), process.exit(1);
|
|
211
213
|
}
|
|
212
214
|
}
|
|
213
|
-
function
|
|
215
|
+
function Le(e) {
|
|
214
216
|
let t = e.author, n = typeof t == "string" ? t : t?.name;
|
|
215
217
|
if (n == null || n === "") throw Error("package.json 'author' field is required to document contributing and license.");
|
|
216
218
|
let r = n.indexOf("<"), i = r === -1 ? -1 : n.indexOf(">", r);
|
|
217
219
|
return i === -1 ? n.trim() : [n.slice(0, r).trim(), n.slice(i + 1).trim()].filter((e) => e !== "").join(" ");
|
|
218
220
|
}
|
|
219
|
-
function
|
|
221
|
+
function Re(e) {
|
|
220
222
|
let t = (/* @__PURE__ */ new Date()).getFullYear();
|
|
221
223
|
if (e == null) return String(t);
|
|
222
224
|
let n = new Date(e).getFullYear();
|
|
223
225
|
return n === t ? String(t) : `${String(n)}-present`;
|
|
224
226
|
}
|
|
225
|
-
function
|
|
227
|
+
function ze(e, t, n, r) {
|
|
226
228
|
return `## Contributing
|
|
227
229
|
|
|
228
230
|
This repository is maintained solely by its owner and does not, at present, accept external contributions into the canonical repo. Its source is published openly under the MIT License — every DPUse project is fully open source except DPUse Engine, which remains closed and proprietary.
|
|
@@ -236,82 +238,227 @@ This project is licensed under the MIT License, permitting free use, modificatio
|
|
|
236
238
|
[MIT](./LICENSE) © ${r} ${n}`;
|
|
237
239
|
}
|
|
238
240
|
//#endregion
|
|
241
|
+
//#region src/utilities/rustCrates.ts
|
|
242
|
+
var O = "licenses/cargoMetadata.json", k = "licenses/cargoTree.txt", Be = 1e3, Ve = "dpuse-development (https://github.com/dpuse/dpuse-development)", He = /^(?:copying|licen[cs]e|unlicense)/i, A = "wasm32-unknown-unknown";
|
|
243
|
+
async function Ue(e, t) {
|
|
244
|
+
if (await i("rust/Cargo.toml") === null) return null;
|
|
245
|
+
let n = [
|
|
246
|
+
"--manifest-path",
|
|
247
|
+
l,
|
|
248
|
+
"--locked"
|
|
249
|
+
], r = [
|
|
250
|
+
"tree",
|
|
251
|
+
...n,
|
|
252
|
+
"--workspace",
|
|
253
|
+
"--edges",
|
|
254
|
+
"normal,no-proc-macro",
|
|
255
|
+
"--target",
|
|
256
|
+
A,
|
|
257
|
+
"--prefix",
|
|
258
|
+
"depth",
|
|
259
|
+
"--format",
|
|
260
|
+
"{p}|{l}|{r}"
|
|
261
|
+
];
|
|
262
|
+
await a(e, "cargo", r, k), await a(e, "cargo", [
|
|
263
|
+
"metadata",
|
|
264
|
+
...n,
|
|
265
|
+
"--format-version",
|
|
266
|
+
"1",
|
|
267
|
+
"--filter-platform",
|
|
268
|
+
A
|
|
269
|
+
], O);
|
|
270
|
+
let o = We(await S(k)), s = await c(O);
|
|
271
|
+
await w.rm(k, { force: !0 }), await w.rm(O, { force: !0 });
|
|
272
|
+
let u = /* @__PURE__ */ new Map();
|
|
273
|
+
for (let e of o) e.isOwn || u.has(`${e.name}@${e.version}`) || u.set(`${e.name}@${e.version}`, {
|
|
274
|
+
name: e.name,
|
|
275
|
+
version: e.version,
|
|
276
|
+
licenseExpression: e.licenseExpression,
|
|
277
|
+
repository: e.repository === "" ? `https://crates.io/crates/${e.name}` : e.repository,
|
|
278
|
+
licenseFiles: [],
|
|
279
|
+
publishedDate: "",
|
|
280
|
+
latestVersion: "",
|
|
281
|
+
latestPublishedDate: ""
|
|
282
|
+
});
|
|
283
|
+
let d = u.values().toArray();
|
|
284
|
+
Ge(d, t);
|
|
285
|
+
for (let e of d) e.licenseFiles = await Je(e, s);
|
|
286
|
+
return await Ye(d), {
|
|
287
|
+
crates: d,
|
|
288
|
+
treeItems: o.map(({ name: e, version: t, depth: n, isOwn: r }) => ({
|
|
289
|
+
name: e,
|
|
290
|
+
version: t,
|
|
291
|
+
depth: n,
|
|
292
|
+
isOwn: r
|
|
293
|
+
}))
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function We(e) {
|
|
297
|
+
let t = [];
|
|
298
|
+
for (let n of e.split("\n")) {
|
|
299
|
+
let [e = "", r = "", i = ""] = n.trim().split("|", 3), a = /^\d+/.exec(e)?.[0];
|
|
300
|
+
if (a === void 0) continue;
|
|
301
|
+
let [o = "", s = "", ...c] = e.slice(a.length).split(" "), l = c.join(" ").replace(/^\(/, "").replace(/\)$/, ""), u = l !== "" && !l.includes("://"), d = i.replace(/ \(\*\)$/, "");
|
|
302
|
+
t.push({
|
|
303
|
+
name: o,
|
|
304
|
+
version: s.replace(/^v/, ""),
|
|
305
|
+
depth: Number(a),
|
|
306
|
+
isOwn: u,
|
|
307
|
+
licenseExpression: r,
|
|
308
|
+
repository: d
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
return t;
|
|
312
|
+
}
|
|
313
|
+
function Ge(e, t) {
|
|
314
|
+
let n = t.split(";").filter((e) => Ke(e)), r = e.filter((e) => !qe(e.licenseExpression, n));
|
|
315
|
+
if (r.length === 0) return;
|
|
316
|
+
let i = r.map((e) => `${e.name}@${e.version} (${e.licenseExpression === "" ? "no licence" : e.licenseExpression})`).join(", ");
|
|
317
|
+
throw Error(`Rust crates with licences not allowed: ${i}.`);
|
|
318
|
+
}
|
|
319
|
+
function Ke(e) {
|
|
320
|
+
try {
|
|
321
|
+
return pe(e, [e]);
|
|
322
|
+
} catch {
|
|
323
|
+
return !1;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function qe(e, t) {
|
|
327
|
+
try {
|
|
328
|
+
return pe(e.replaceAll("/", " OR "), t);
|
|
329
|
+
} catch {
|
|
330
|
+
return !1;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
async function Je(e, t) {
|
|
334
|
+
let n = t.packages.find((t) => t.name === e.name && t.version === e.version);
|
|
335
|
+
if (n == null) return [];
|
|
336
|
+
let r = T.dirname(n.manifest_path), i = (await w.readdir(r)).filter((e) => He.test(e)).toSorted((e, t) => e.localeCompare(t, "en"));
|
|
337
|
+
await w.mkdir("licenses/downloads", { recursive: !0 });
|
|
338
|
+
let a = [];
|
|
339
|
+
for (let t of i) {
|
|
340
|
+
let n = `downloads/${e.name}@${e.version}-${t}`;
|
|
341
|
+
await w.copyFile(T.join(r, t), T.join("licenses", n)), a.push({
|
|
342
|
+
label: t,
|
|
343
|
+
path: n
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
return a;
|
|
347
|
+
}
|
|
348
|
+
async function Ye(e) {
|
|
349
|
+
for (let [t, n] of e.entries()) {
|
|
350
|
+
t > 0 && await fe(Be);
|
|
351
|
+
try {
|
|
352
|
+
let e = await fetch(`https://crates.io/api/v1/crates/${encodeURIComponent(n.name)}`, { headers: { "User-Agent": Ve } });
|
|
353
|
+
if (!e.ok) continue;
|
|
354
|
+
let t = await e.json(), r = new Map((t.versions ?? []).map((e) => [e.num, e.created_at]));
|
|
355
|
+
n.latestVersion = t.crate?.max_stable_version ?? t.crate?.max_version ?? "", n.publishedDate = r.get(n.version) ?? "", n.latestPublishedDate = n.latestVersion === n.version ? "" : r.get(n.latestVersion) ?? "";
|
|
356
|
+
} catch {}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
//#endregion
|
|
239
360
|
//#region src/actions/documentDependencies.ts
|
|
240
|
-
var
|
|
241
|
-
async function
|
|
361
|
+
var j = "<!-- DEPENDENCY_LICENSES_START -->", M = "<!-- DEPENDENCY_LICENSES_END -->", N = "## Dependency Licenses", Xe = `bundle-analysis-reports/${ae}`, P = "licenses/licenseTree.json", F = "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. ${F}`, Qe = `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. ${F}`;
|
|
362
|
+
async function $e(e = "MIT") {
|
|
242
363
|
try {
|
|
243
364
|
f("Document Dependencies");
|
|
244
365
|
let t = await c("package.json");
|
|
245
366
|
if (t.name === "@dpuse/dpuse-development" || t.name === "@dpuse/eslint-config-dpuse") {
|
|
246
|
-
await
|
|
367
|
+
await et(t.name), o("Dependencies documented");
|
|
247
368
|
return;
|
|
248
369
|
}
|
|
249
370
|
await u("1️⃣ Clear downloaded licenses", "licenses/downloads");
|
|
250
|
-
let n = await
|
|
371
|
+
let n = await ot(), r = await st();
|
|
251
372
|
if (r === null) {
|
|
252
|
-
let r =
|
|
253
|
-
await
|
|
373
|
+
let r = dt(n);
|
|
374
|
+
await L("2️⃣ Identify production licenses", e, [t.name ?? "", ...r], !0), await a("3️⃣ Identify transitive dependencies", "npm", [
|
|
254
375
|
"ls",
|
|
255
376
|
"--all",
|
|
256
377
|
"--json",
|
|
257
378
|
"--omit=dev"
|
|
258
|
-
],
|
|
379
|
+
], P), await tt("4️⃣ ", e, new Set(r));
|
|
259
380
|
} else {
|
|
260
|
-
let i =
|
|
261
|
-
await
|
|
381
|
+
let i = ct(r, n), o = lt(n), s = o.filter((e) => !i.has(e));
|
|
382
|
+
await L("2️⃣ Identify shipped licenses", e, [t.name ?? "", ...s], !1), ut(i, new Set(o)), await a("3️⃣ Identify transitive dependencies", "npm", [
|
|
262
383
|
"ls",
|
|
263
384
|
"--all",
|
|
264
385
|
"--json"
|
|
265
|
-
],
|
|
386
|
+
], P, !0);
|
|
387
|
+
let c = await Ue("4️⃣ Identify Rust crates compiled into the WebAssembly", e), l = {
|
|
388
|
+
allowedLicenses: e,
|
|
389
|
+
productionNames: at(t),
|
|
390
|
+
rustCrates: c,
|
|
391
|
+
shippedKeys: i
|
|
392
|
+
};
|
|
393
|
+
await nt(c === null ? "4️⃣ " : "5️⃣ ", l);
|
|
266
394
|
}
|
|
267
395
|
o("Dependencies documented");
|
|
268
396
|
} catch (e) {
|
|
269
397
|
console.error("❌ Error documenting dependencies", e), process.exit(1);
|
|
270
398
|
}
|
|
271
399
|
}
|
|
272
|
-
async function
|
|
400
|
+
async function et(e) {
|
|
273
401
|
b(`1️⃣ Skip: ${e} is a development-only tool and is never part of a production release.`);
|
|
274
402
|
let t = `> [!WARNING]\n> Dependency licenses are not documented here: ${e} is a development-only tool and is never part of a production release.`;
|
|
275
|
-
await n(`${
|
|
403
|
+
await n(`${N}\n\n${t}`, j, M);
|
|
276
404
|
}
|
|
277
|
-
async function
|
|
405
|
+
async function tt(e, t, r) {
|
|
278
406
|
b(`${e} Insert licenses into 'README.md'`);
|
|
279
|
-
let i = await c(
|
|
280
|
-
for (let e of a.values()) o +=
|
|
407
|
+
let i = await c(P), a = await I(), o = `${pt(t, !1)}\n\n|Dependency|Version|License(s)|Document|\n|:-|:-:|:-|:-|\n`;
|
|
408
|
+
for (let e of a.values()) o += _t(e);
|
|
281
409
|
let s = [];
|
|
282
|
-
i.dependencies != null &&
|
|
283
|
-
let l = `${
|
|
284
|
-
await n(`${
|
|
410
|
+
i.dependencies != null && vt(i.dependencies, a, r, s, 0);
|
|
411
|
+
let l = `${Ze}\n\n${s.join("\n")}`;
|
|
412
|
+
await n(`${N}\n\n${o.trimEnd()}\n\n### Dependency Tree\n\n${l}`, j, M);
|
|
285
413
|
}
|
|
286
|
-
async function
|
|
414
|
+
async function nt(e, t) {
|
|
287
415
|
b(`${e} Insert licenses into 'README.md'`);
|
|
288
|
-
let a = await
|
|
289
|
-
for (let e of
|
|
290
|
-
let
|
|
291
|
-
|
|
292
|
-
licensesByKey:
|
|
293
|
-
shippedKeys:
|
|
416
|
+
let { allowedLicenses: r, productionNames: i, rustCrates: a, shippedKeys: o } = t, s = await I(), l = new Map((a?.crates ?? []).map((e) => [`${e.name}@${e.version}`, rt(e)])), u = [...s.values(), ...l.values()].toSorted((e, t) => e.name.localeCompare(t.name, "en") || e.installedVersion.localeCompare(t.installedVersion, "en")), d = `${pt(r, !0, a !== null)}\n\n|Dependency|Version|License(s)|Document|\n|:-|:-:|:-|:-|\n`;
|
|
417
|
+
for (let e of u) d += _t(e);
|
|
418
|
+
let f = await c(P), p = Object.entries(f.dependencies ?? {}).toSorted(([e], [t]) => Number(!i.has(e)) - Number(!i.has(t))), m = [];
|
|
419
|
+
V(p, {
|
|
420
|
+
licensesByKey: s,
|
|
421
|
+
shippedKeys: o,
|
|
294
422
|
shownKeys: /* @__PURE__ */ new Set()
|
|
295
|
-
},
|
|
296
|
-
let
|
|
297
|
-
|
|
423
|
+
}, m, 0, !1);
|
|
424
|
+
let h = a?.treeItems ?? [];
|
|
425
|
+
for (let e of h) m.push(it(e, l));
|
|
426
|
+
let g = `${Qe}\n\n${m.join("\n")}`;
|
|
427
|
+
await n(`${N}\n\n${d.trimEnd()}\n\n### Dependency Tree\n\n${g}`, j, M);
|
|
428
|
+
}
|
|
429
|
+
function rt(e) {
|
|
430
|
+
return {
|
|
431
|
+
name: e.name,
|
|
432
|
+
repository: e.repository,
|
|
433
|
+
licenseTypes: e.licenseExpression,
|
|
434
|
+
installedVersion: e.version,
|
|
435
|
+
latestVersion: e.latestVersion,
|
|
436
|
+
latestPublishedDate: e.latestPublishedDate,
|
|
437
|
+
author: "",
|
|
438
|
+
publishedDate: e.publishedDate,
|
|
439
|
+
licenseFiles: e.licenseFiles
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
function it(e, t) {
|
|
443
|
+
let n = " ".repeat(e.depth);
|
|
444
|
+
return e.isOwn ? `${n}- **${e.name}** ${e.version} — this project's Rust code, compiled into its WebAssembly` : H(e.name, e.version, t.get(`${e.name}@${e.version}`), n);
|
|
298
445
|
}
|
|
299
|
-
function
|
|
446
|
+
function at(e) {
|
|
300
447
|
return /* @__PURE__ */ new Set([
|
|
301
448
|
...Object.keys(e.dependencies ?? {}),
|
|
302
449
|
...Object.keys(e.optionalDependencies ?? {}),
|
|
303
450
|
...Object.keys(e.peerDependencies ?? {})
|
|
304
451
|
]);
|
|
305
452
|
}
|
|
306
|
-
async function
|
|
453
|
+
async function I() {
|
|
307
454
|
let e = await c("licenses/licenses.json"), t = /* @__PURE__ */ new Map();
|
|
308
|
-
for (let [n, r] of Object.entries(e)) t.set(n,
|
|
455
|
+
for (let [n, r] of Object.entries(e)) t.set(n, ht(n, r));
|
|
309
456
|
return await Promise.all(t.values().map(async (e) => {
|
|
310
|
-
let t = await
|
|
457
|
+
let t = await gt(e.name, e.installedVersion);
|
|
311
458
|
e.latestVersion = t.latestVersion, e.latestPublishedDate = t.latestPublishedDate, e.publishedDate = t.publishedDate;
|
|
312
459
|
})), t;
|
|
313
460
|
}
|
|
314
|
-
async function
|
|
461
|
+
async function L(e, t, n, r) {
|
|
315
462
|
b(e), await new Promise((e, i) => {
|
|
316
463
|
let a = {
|
|
317
464
|
start: process.cwd(),
|
|
@@ -329,58 +476,58 @@ async function N(e, t, n, r) {
|
|
|
329
476
|
});
|
|
330
477
|
});
|
|
331
478
|
}
|
|
332
|
-
async function
|
|
479
|
+
async function ot() {
|
|
333
480
|
let e = await i("package-lock.json");
|
|
334
481
|
return e === null ? {} : JSON.parse(e).packages ?? {};
|
|
335
482
|
}
|
|
336
|
-
async function
|
|
337
|
-
let e = await i(
|
|
483
|
+
async function st() {
|
|
484
|
+
let e = await i(Xe);
|
|
338
485
|
return e === null ? null : JSON.parse(e);
|
|
339
486
|
}
|
|
340
|
-
function
|
|
487
|
+
function ct(e, t) {
|
|
341
488
|
let n = new Set(e.packages);
|
|
342
489
|
for (let r of e.external) {
|
|
343
|
-
let e =
|
|
344
|
-
if (e !== void 0) for (let r of [e, ...
|
|
490
|
+
let e = B(t, "", r);
|
|
491
|
+
if (e !== void 0) for (let r of [e, ...z(t, e)]) {
|
|
345
492
|
let e = t[r];
|
|
346
|
-
e?.version !== void 0 && n.add(
|
|
493
|
+
e?.version !== void 0 && n.add(R(r, e));
|
|
347
494
|
}
|
|
348
495
|
}
|
|
349
496
|
return n;
|
|
350
497
|
}
|
|
351
|
-
function
|
|
498
|
+
function lt(e) {
|
|
352
499
|
let t = /* @__PURE__ */ new Set();
|
|
353
|
-
for (let [n, r] of Object.entries(e)) n !== "" && r.version !== void 0 && t.add(
|
|
500
|
+
for (let [n, r] of Object.entries(e)) n !== "" && r.version !== void 0 && t.add(R(n, r));
|
|
354
501
|
return [...t];
|
|
355
502
|
}
|
|
356
|
-
function
|
|
503
|
+
function ut(e, t) {
|
|
357
504
|
let n = [...e.difference(t)];
|
|
358
505
|
n.length > 0 && console.warn(`⚠️ Not installed, so not checked; rebuild to refresh the record: ${n.join(", ")}`);
|
|
359
506
|
}
|
|
360
|
-
function
|
|
507
|
+
function R(e, t) {
|
|
361
508
|
return `${t.name ?? e.slice(e.lastIndexOf("node_modules/") + 13)}@${String(t.version)}`;
|
|
362
509
|
}
|
|
363
|
-
function
|
|
364
|
-
let t =
|
|
510
|
+
function dt(e) {
|
|
511
|
+
let t = z(e, ""), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
365
512
|
for (let [i, a] of Object.entries(e)) {
|
|
366
513
|
if (i === "" || a.version === void 0) continue;
|
|
367
|
-
let e =
|
|
514
|
+
let e = R(i, a);
|
|
368
515
|
t.has(i) ? n.add(e) : r.add(e);
|
|
369
516
|
}
|
|
370
517
|
return r.values().filter((e) => !n.has(e)).toArray();
|
|
371
518
|
}
|
|
372
|
-
function
|
|
519
|
+
function z(e, t) {
|
|
373
520
|
let n = /* @__PURE__ */ new Set(), r = [t];
|
|
374
521
|
for (; r.length > 0;) {
|
|
375
522
|
let t = r.pop() ?? "", i = e[t];
|
|
376
|
-
if (i !== void 0) for (let a of
|
|
377
|
-
let i =
|
|
523
|
+
if (i !== void 0) for (let a of ft(i)) {
|
|
524
|
+
let i = B(e, t, a);
|
|
378
525
|
i === void 0 || n.has(i) || (n.add(i), r.push(i));
|
|
379
526
|
}
|
|
380
527
|
}
|
|
381
528
|
return n;
|
|
382
529
|
}
|
|
383
|
-
function
|
|
530
|
+
function ft(e) {
|
|
384
531
|
let t = Object.keys(e.peerDependencies ?? {}).filter((t) => e.peerDependenciesMeta?.[t]?.optional !== !0);
|
|
385
532
|
return [
|
|
386
533
|
...Object.keys(e.dependencies ?? {}),
|
|
@@ -388,7 +535,7 @@ function Qe(e) {
|
|
|
388
535
|
...t
|
|
389
536
|
];
|
|
390
537
|
}
|
|
391
|
-
function
|
|
538
|
+
function B(e, t, n) {
|
|
392
539
|
let r = t;
|
|
393
540
|
for (;;) {
|
|
394
541
|
let t = r === "" ? `node_modules/${n}` : `${r}/node_modules/${n}`, i = e[t];
|
|
@@ -398,14 +545,14 @@ function I(e, t, n) {
|
|
|
398
545
|
r = a === -1 ? "" : r.slice(0, a);
|
|
399
546
|
}
|
|
400
547
|
}
|
|
401
|
-
function
|
|
402
|
-
let
|
|
403
|
-
return `License data is updated each time \`npm run document\` is run, using
|
|
548
|
+
function pt(e, t, n = !1) {
|
|
549
|
+
let r = mt(e.split(";")), i = n ? "[license-checker](https://github.com/RSeidelsohn/license-checker-rseidelsohn) and [cargo tree](https://doc.rust-lang.org/cargo/commands/cargo-tree.html)" : "[license-checker](https://github.com/RSeidelsohn/license-checker-rseidelsohn)", a = "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.";
|
|
550
|
+
return `License data is updated each time \`npm run document\` is run, using ${i}. ${t ? n ? `${a} It also lists every Rust crate compiled into its WebAssembly, as resolved by Cargo; macros and other crates used only while compiling put none of their code in it, so are left out.` : a : "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 ${r}, 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.`;
|
|
404
551
|
}
|
|
405
|
-
function
|
|
552
|
+
function mt(e) {
|
|
406
553
|
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))}`;
|
|
407
554
|
}
|
|
408
|
-
function
|
|
555
|
+
function ht(e, t) {
|
|
409
556
|
let n = e.lastIndexOf("@"), r = n > 0 ? e.slice(0, n) : e, i = n > 0 ? e.slice(n + 1) : "";
|
|
410
557
|
return {
|
|
411
558
|
name: r,
|
|
@@ -416,10 +563,13 @@ function et(e, t) {
|
|
|
416
563
|
latestVersion: "",
|
|
417
564
|
latestPublishedDate: "",
|
|
418
565
|
publishedDate: "",
|
|
419
|
-
|
|
566
|
+
licenseFiles: t.licenseFile == null ? [] : [{
|
|
567
|
+
label: "LICENSE",
|
|
568
|
+
path: t.licenseFile
|
|
569
|
+
}]
|
|
420
570
|
};
|
|
421
571
|
}
|
|
422
|
-
async function
|
|
572
|
+
async function gt(e, t) {
|
|
423
573
|
try {
|
|
424
574
|
let n = await fetch(`https://registry.npmjs.org/${encodeURIComponent(e)}`);
|
|
425
575
|
if (n.ok) {
|
|
@@ -437,44 +587,40 @@ async function tt(e, t) {
|
|
|
437
587
|
publishedDate: ""
|
|
438
588
|
};
|
|
439
589
|
}
|
|
440
|
-
function
|
|
441
|
-
let t = e.
|
|
590
|
+
function _t(e) {
|
|
591
|
+
let t = e.licenseFiles.length === 0 ? "⚠️ No license file" : e.licenseFiles.map((e) => `[${e.label}](licenses/${e.path})`).join(" ");
|
|
442
592
|
return `|[${e.name}](${e.repository})|${e.installedVersion}|${e.licenseTypes}|${t}|\n`;
|
|
443
593
|
}
|
|
444
|
-
function
|
|
445
|
-
let t = e.licenseFileLink == null || e.licenseFileLink === "" ? "⚠️ No license file" : `[LICENSE](licenses/${e.licenseFileLink})`;
|
|
446
|
-
return `|[${e.name}](${e.repository})|${e.installedVersion}|${V(e).replace(/^ — /, "")}|${e.licenseTypes}|${t}|\n`;
|
|
447
|
-
}
|
|
448
|
-
function R(e, t, n, r, i) {
|
|
594
|
+
function vt(e, t, n, r, i) {
|
|
449
595
|
let a = " ".repeat(i);
|
|
450
596
|
for (let [o, s] of Object.entries(e)) {
|
|
451
597
|
if (s.version === void 0) continue;
|
|
452
598
|
let e = s.version;
|
|
453
|
-
n.has(`${o}@${e}`) || (r.push(
|
|
599
|
+
n.has(`${o}@${e}`) || (r.push(H(o, e, t.get(`${o}@${e}`), a)), s.dependencies != null && vt(s.dependencies, t, n, r, i + 1));
|
|
454
600
|
}
|
|
455
601
|
}
|
|
456
|
-
function
|
|
602
|
+
function V(e, t, n, r, i) {
|
|
457
603
|
for (let [a, o] of e) {
|
|
458
604
|
if (o.version === void 0) continue;
|
|
459
605
|
let e = `${a}@${o.version}`, s = Object.entries(o.dependencies ?? {});
|
|
460
606
|
if (!t.shippedKeys.has(e)) {
|
|
461
|
-
|
|
607
|
+
V(s, t, n, r, !0);
|
|
462
608
|
continue;
|
|
463
609
|
}
|
|
464
|
-
i && t.shownKeys.has(e) || (t.shownKeys.add(e), n.push(
|
|
610
|
+
i && t.shownKeys.has(e) || (t.shownKeys.add(e), n.push(H(a, o.version, t.licensesByKey.get(e), " ".repeat(r))), V(s, t, n, r + 1, !1));
|
|
465
611
|
}
|
|
466
612
|
}
|
|
467
|
-
function
|
|
468
|
-
return `${r}- **${n == null ? e : `[${e}](${n.repository})`}** ${t}${
|
|
613
|
+
function H(e, t, n, r) {
|
|
614
|
+
return `${r}- **${n == null ? e : `[${e}](${n.repository})`}** ${t}${yt(n)}`;
|
|
469
615
|
}
|
|
470
|
-
function
|
|
616
|
+
function yt(e) {
|
|
471
617
|
if (e == null) return "";
|
|
472
|
-
let t = e.publishedDate ?
|
|
618
|
+
let t = e.publishedDate ? bt(e.publishedDate.split("T", 1)[0]) : "";
|
|
473
619
|
if (e.latestVersion === "" || e.latestVersion === e.installedVersion) return t === "" ? "" : ` — ${t}`;
|
|
474
|
-
let n = e.latestPublishedDate ?
|
|
620
|
+
let n = e.latestPublishedDate ? bt(e.latestPublishedDate.split("T", 1)[0]) : "", r = n === "" ? `**latest**: ${e.latestVersion} ❗` : `**latest**: ${e.latestVersion} — ${n} ❗`;
|
|
475
621
|
return t === "" ? ` — → ${r}` : ` — ${t} → ${r}`;
|
|
476
622
|
}
|
|
477
|
-
function
|
|
623
|
+
function bt(e) {
|
|
478
624
|
if (e == null || e === "") return "n/a";
|
|
479
625
|
let t = e.split("T", 1)[0];
|
|
480
626
|
if (t == null || t === "") return "n/a";
|
|
@@ -483,31 +629,31 @@ function H(e) {
|
|
|
483
629
|
}
|
|
484
630
|
//#endregion
|
|
485
631
|
//#region src/actions/documentOpening.ts
|
|
486
|
-
var
|
|
487
|
-
async function
|
|
632
|
+
var xt = "<!-- OPENING_START -->", St = "<!-- OPENING_END -->";
|
|
633
|
+
async function Ct() {
|
|
488
634
|
try {
|
|
489
635
|
f("Document Opening"), b("1️⃣ Insert opening content into 'README.md'");
|
|
490
|
-
let e = await c("package.json"), r = await c("config.json"), { owner: i, repo: a } = t(e, "document opening"), s =
|
|
491
|
-
await n(u,
|
|
636
|
+
let e = await c("package.json"), r = await c("config.json"), { owner: i, repo: a } = t(e, "document opening"), s = wt(e), l = Et(r), u = Dt(i, a, s, _(r.id).publishedTo === "npm" ? Tt(e) : void 0, e.description, l);
|
|
637
|
+
await n(u, xt, St), o("Opening documented");
|
|
492
638
|
} catch (e) {
|
|
493
639
|
console.error("❌ Error documenting opening", e), process.exit(1);
|
|
494
640
|
}
|
|
495
641
|
}
|
|
496
|
-
function
|
|
642
|
+
function wt(e) {
|
|
497
643
|
let t = e.license;
|
|
498
644
|
if (t == null || t === "") throw Error("package.json 'license' field is required to document opening.");
|
|
499
645
|
return t;
|
|
500
646
|
}
|
|
501
|
-
function
|
|
647
|
+
function Tt(e) {
|
|
502
648
|
let t = e.name;
|
|
503
649
|
if (t == null || t === "") throw Error("package.json 'name' field is required to document opening.");
|
|
504
650
|
return t;
|
|
505
651
|
}
|
|
506
|
-
function
|
|
652
|
+
function Et(e) {
|
|
507
653
|
let t = e.description.en?.trim();
|
|
508
654
|
return t === void 0 || t === "" ? void 0 : t;
|
|
509
655
|
}
|
|
510
|
-
function
|
|
656
|
+
function Dt(e, t, n, r, i, a) {
|
|
511
657
|
let o = `https://github.com/${e}/${t}`;
|
|
512
658
|
return `[}-blue.svg)](./LICENSE)
|
|
513
659
|
[](${o}/releases/latest)${r === void 0 ? "" : `\n[](https://www.npmjs.com/package/${r})`}
|
|
@@ -529,41 +675,41 @@ In addition, DPUse provides [Tools](https://www.dpuse.app) used by the applicati
|
|
|
529
675
|
}
|
|
530
676
|
//#endregion
|
|
531
677
|
//#region src/actions/documentQualitySecurity.ts
|
|
532
|
-
var
|
|
678
|
+
var Ot = {
|
|
533
679
|
"Branch-Protection": 3,
|
|
534
680
|
"Code-Review": 0,
|
|
535
681
|
Contributors: 0
|
|
536
|
-
},
|
|
682
|
+
}, kt = /* @__PURE__ */ new Set(["CII-Best-Practices"]), At = "coverage/coverage-final.json", jt = "coverage/coverage-summary.json", Mt = 80, Nt = 60, Pt = "code-health-reports/vitest/badge.json", Ft = {
|
|
537
683
|
actions: "GitHub Actions",
|
|
538
684
|
"javascript-typescript": "JavaScript/TypeScript",
|
|
539
685
|
rust: "Rust"
|
|
540
|
-
},
|
|
686
|
+
}, It = {
|
|
541
687
|
A: "brightgreen",
|
|
542
688
|
B: "green",
|
|
543
689
|
C: "yellow",
|
|
544
690
|
D: "orange",
|
|
545
691
|
F: "red"
|
|
546
|
-
},
|
|
547
|
-
async function
|
|
692
|
+
}, Lt = `${m}/health.json`, Rt = se(ce);
|
|
693
|
+
async function zt() {
|
|
548
694
|
try {
|
|
549
695
|
f("Document Quality & Security");
|
|
550
|
-
let e = await c("package.json"), r = await
|
|
696
|
+
let e = await c("package.json"), r = await Bt(e), i = await Ht(e, r === void 0 ? [] : ["--coverage", At]), { owner: a, repo: s } = t(e, "document quality and security");
|
|
551
697
|
b("4️⃣ Read security checks and settings");
|
|
552
|
-
let l = await
|
|
698
|
+
let l = await Wt(a, s, e);
|
|
553
699
|
b("5️⃣ Look up OpenSSF Best Practices badge and Scorecard results");
|
|
554
|
-
let [u, d] = await Promise.all([
|
|
700
|
+
let [u, d] = await Promise.all([Gt(`https://github.com/${a}/${s}`), Kt(`github.com/${a}/${s}`)]);
|
|
555
701
|
b("6️⃣ Insert quality and security content into 'README.md'");
|
|
556
|
-
let p =
|
|
702
|
+
let p = Zt(a, s, {
|
|
557
703
|
coveragePercent: r,
|
|
558
704
|
fallowHealth: i,
|
|
559
705
|
securitySettings: l
|
|
560
706
|
}, u, d);
|
|
561
|
-
await C(), await n(p,
|
|
707
|
+
await C(), await n(p, ne, te), o("Quality & security documented");
|
|
562
708
|
} catch (e) {
|
|
563
709
|
console.error("❌ Error documenting quality and security", e), process.exit(1);
|
|
564
710
|
}
|
|
565
711
|
}
|
|
566
|
-
async function
|
|
712
|
+
async function Bt(e) {
|
|
567
713
|
if (e.devDependencies?.["@vitest/coverage-v8"] == null) {
|
|
568
714
|
b("1️⃣ Test coverage NOT measured, as '@vitest/coverage-v8' is not installed");
|
|
569
715
|
return;
|
|
@@ -573,25 +719,25 @@ async function St(e) {
|
|
|
573
719
|
"--passWithNoTests",
|
|
574
720
|
"--coverage"
|
|
575
721
|
]);
|
|
576
|
-
let t = await i(
|
|
722
|
+
let t = await i(jt);
|
|
577
723
|
if (t === null) return;
|
|
578
724
|
let n = JSON.parse(t).total.lines.pct;
|
|
579
|
-
return await
|
|
725
|
+
return await Vt(n), n;
|
|
580
726
|
}
|
|
581
|
-
async function
|
|
727
|
+
async function Vt(e) {
|
|
582
728
|
let t = [
|
|
583
729
|
"red",
|
|
584
730
|
"yellow",
|
|
585
731
|
"brightgreen"
|
|
586
|
-
], n = Number(e >=
|
|
587
|
-
await r(
|
|
732
|
+
], n = Number(e >= Nt) + Number(e >= Mt);
|
|
733
|
+
await r(Pt, {
|
|
588
734
|
schemaVersion: 1,
|
|
589
735
|
label: "coverage",
|
|
590
736
|
message: `${e.toFixed(1)}%`,
|
|
591
737
|
color: t[n]
|
|
592
738
|
});
|
|
593
739
|
}
|
|
594
|
-
async function
|
|
740
|
+
async function Ht(e, t) {
|
|
595
741
|
if (e.devDependencies?.fallow == null) {
|
|
596
742
|
b("2️⃣ Code health NOT measured, as Fallow is not installed"), b("3️⃣ Code health report NOT required");
|
|
597
743
|
return;
|
|
@@ -602,33 +748,33 @@ async function wt(e, t) {
|
|
|
602
748
|
"--format",
|
|
603
749
|
"json",
|
|
604
750
|
...t
|
|
605
|
-
],
|
|
606
|
-
let n = await c(
|
|
607
|
-
return await
|
|
751
|
+
], Lt), await a("3️⃣ Write code health report", "fallow", ["--format", "markdown"], s, !0);
|
|
752
|
+
let n = await c(Lt);
|
|
753
|
+
return await Ut(n), n;
|
|
608
754
|
}
|
|
609
|
-
async function
|
|
755
|
+
async function Ut(e) {
|
|
610
756
|
let { score: t, grade: n } = e.health_score;
|
|
611
|
-
await r(
|
|
757
|
+
await r(y, {
|
|
612
758
|
schemaVersion: 1,
|
|
613
759
|
label: "fallow",
|
|
614
760
|
message: `${n} (${String(Math.round(t))})`,
|
|
615
|
-
color:
|
|
761
|
+
color: It[n] ?? "lightgrey"
|
|
616
762
|
});
|
|
617
763
|
}
|
|
618
|
-
async function
|
|
764
|
+
async function Wt(e, t, n) {
|
|
619
765
|
let [r, a, o, s] = await Promise.all([
|
|
620
766
|
i(".github/workflows/ci.yml"),
|
|
621
767
|
i(".github/workflows/codeql.yml"),
|
|
622
768
|
i(".github/dependabot.yml"),
|
|
623
769
|
i(l)
|
|
624
770
|
]), [c, u, d, f] = await Promise.all([
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
771
|
+
U(`repos/${e}/${t}`),
|
|
772
|
+
U(`repos/${e}/${t}/private-vulnerability-reporting`),
|
|
773
|
+
U(`repos/${e}/${t}/vulnerability-alerts`),
|
|
774
|
+
U(`repos/${e}/${t}/commits/main/check-runs?per_page=100`)
|
|
629
775
|
]), 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;
|
|
630
776
|
return {
|
|
631
|
-
codeQLLanguages: (a ?? "").matchAll(/- language: ([\w-]+)/g).filter(([, e]) => e !== "rust" || s !== null).map(([, e = ""]) =>
|
|
777
|
+
codeQLLanguages: (a ?? "").matchAll(/- language: ([\w-]+)/g).filter(([, e]) => e !== "rust" || s !== null).map(([, e = ""]) => Ft[e] ?? e).toArray(),
|
|
632
778
|
codeQLQueries: /queries: ([\w-]+)/.exec(a ?? "")?.[1],
|
|
633
779
|
dependabotAlerts: d !== void 0,
|
|
634
780
|
dependabotSecurityUpdates: m("dependabot_security_updates"),
|
|
@@ -645,37 +791,37 @@ async function Et(e, t, n) {
|
|
|
645
791
|
testsInCI: r?.includes("npm test") ?? !1
|
|
646
792
|
};
|
|
647
793
|
}
|
|
648
|
-
async function
|
|
794
|
+
async function U(e) {
|
|
649
795
|
try {
|
|
650
|
-
let { stdout: t } = await
|
|
796
|
+
let { stdout: t } = await Rt("gh", ["api", e]);
|
|
651
797
|
return t;
|
|
652
798
|
} catch (e) {
|
|
653
799
|
if (String(e.stderr).includes("HTTP 404")) return;
|
|
654
800
|
throw e;
|
|
655
801
|
}
|
|
656
802
|
}
|
|
657
|
-
async function
|
|
803
|
+
async function Gt(e) {
|
|
658
804
|
let t = await fetch(`https://www.bestpractices.dev/projects.json?url=${encodeURIComponent(e)}`);
|
|
659
805
|
if (!t.ok) throw Error(`OpenSSF Best Practices lookup failed with status ${String(t.status)}.`);
|
|
660
806
|
return (await t.json()).find((t) => t.repo_url === e)?.id;
|
|
661
807
|
}
|
|
662
|
-
async function
|
|
808
|
+
async function Kt(e) {
|
|
663
809
|
let t = await fetch(`https://api.scorecard.dev/projects/${e}`);
|
|
664
810
|
if (t.status !== 404) {
|
|
665
811
|
if (!t.ok) throw Error(`OpenSSF Scorecard lookup failed with status ${String(t.status)}.`);
|
|
666
812
|
return await t.json();
|
|
667
813
|
}
|
|
668
814
|
}
|
|
669
|
-
function
|
|
670
|
-
return e.checks.every(({ name: e, score: t }) => t === -1 || t === 10 ||
|
|
815
|
+
function qt(e) {
|
|
816
|
+
return e.checks.every(({ name: e, score: t }) => t === -1 || t === 10 || kt.has(e) || Ot[e] !== void 0 && t >= Ot[e]);
|
|
671
817
|
}
|
|
672
|
-
function
|
|
818
|
+
function Jt(e) {
|
|
673
819
|
return e === !1 ? " These are handled manually." : "";
|
|
674
820
|
}
|
|
675
|
-
function
|
|
821
|
+
function W(e) {
|
|
676
822
|
return e === void 0 ? "❔ Unknown" : e ? "✅ On" : "❌ Off";
|
|
677
823
|
}
|
|
678
|
-
function
|
|
824
|
+
function G(e, t) {
|
|
679
825
|
return t.length === 0 ? "" : `### ${e}
|
|
680
826
|
|
|
681
827
|
|Check|Status|What it does|
|
|
@@ -684,90 +830,90 @@ ${t.map((e) => `|${e.join("|")}|`).join("\n")}
|
|
|
684
830
|
|
|
685
831
|
`;
|
|
686
832
|
}
|
|
687
|
-
function
|
|
833
|
+
function Yt(e, t, n, r) {
|
|
688
834
|
return `})`;
|
|
689
835
|
}
|
|
690
|
-
function
|
|
836
|
+
function Xt(e, t, { coveragePercent: n, fallowHealth: r, securitySettings: i }) {
|
|
691
837
|
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 = [[
|
|
692
838
|
"Unit tests",
|
|
693
|
-
|
|
839
|
+
W(i.testsInCI),
|
|
694
840
|
`[Vitest](https://vitest.dev) runs the unit tests.${o(i.testsInCI)}`
|
|
695
841
|
], [
|
|
696
842
|
"Property-based tests",
|
|
697
|
-
|
|
843
|
+
W(i.propertyTests),
|
|
698
844
|
`[fast-check](https://fast-check.dev) runs many random inputs per test to find edge cases, alongside the unit tests.${o(i.propertyTests && i.testsInCI)}`
|
|
699
845
|
]];
|
|
700
846
|
n !== void 0 && c.push([
|
|
701
847
|
"Test coverage",
|
|
702
|
-
|
|
703
|
-
`${
|
|
848
|
+
W(!0),
|
|
849
|
+
`${Yt(e, t, "Coverage", Pt)} [Vitest's V8 coverage](https://vitest.dev/guide/coverage) measures the share of source lines the unit tests run. The target is ${String(Mt)}%.`
|
|
704
850
|
]);
|
|
705
851
|
let l = `[](https://sonarcloud.io/summary/new_code?id=${e}_${t}) `, u = [[
|
|
706
852
|
"Code analysis",
|
|
707
|
-
|
|
853
|
+
W(i.sonarCloud),
|
|
708
854
|
`${i.sonarCloud ? l : ""}[SonarCloud](https://sonarcloud.io) checks every push for bugs, code smells and vulnerabilities.`
|
|
709
855
|
], [
|
|
710
856
|
"Linting",
|
|
711
|
-
|
|
857
|
+
W(i.lintInCI),
|
|
712
858
|
`[ESLint](https://eslint.org) checks the code for errors and style problems.${o(i.lintInCI)}`
|
|
713
859
|
]];
|
|
714
860
|
r !== void 0 && u.unshift([
|
|
715
861
|
"Code health",
|
|
716
|
-
|
|
717
|
-
`[${
|
|
862
|
+
W(!0),
|
|
863
|
+
`[${Yt(e, t, "Fallow code health", y)}](./${s}) [Fallow](https://github.com/fallow-rs/fallow) finds unused code, duplication, complexity and dependency problems.`
|
|
718
864
|
]);
|
|
719
865
|
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 = [
|
|
720
866
|
[
|
|
721
867
|
"Push protection",
|
|
722
|
-
|
|
868
|
+
W(i.pushProtection),
|
|
723
869
|
"[GitHub push protection](https://docs.github.com/en/code-security/secret-scanning/push-protection-for-repositories-and-organizations) blocks pushes that contain credentials."
|
|
724
870
|
],
|
|
725
871
|
[
|
|
726
872
|
"Static analysis",
|
|
727
|
-
|
|
873
|
+
W(d),
|
|
728
874
|
`${d ? f : ""}[CodeQL](https://codeql.github.com) scans${m} for security vulnerabilities, ${p}, on every push and pull request to \`main\` and weekly.`
|
|
729
875
|
],
|
|
730
876
|
[
|
|
731
877
|
"Secret scanning",
|
|
732
|
-
|
|
878
|
+
W(i.secretScanning),
|
|
733
879
|
"[GitHub secret scanning](https://docs.github.com/en/code-security/secret-scanning) detects credentials, such as API keys and tokens, committed to the repository."
|
|
734
880
|
]
|
|
735
881
|
], g = "[Dependabot](https://docs.github.com/en/code-security/dependabot)", _ = [
|
|
736
882
|
[
|
|
737
883
|
"Vulnerability audit",
|
|
738
|
-
|
|
884
|
+
W(i.npmAuditInCI),
|
|
739
885
|
i.npmAuditLevel === void 0 ? `[npm audit](https://docs.npmjs.com/cli/commands/npm-audit) fails when a shipped dependency has any known vulnerability, or a development dependency has a high or critical one.${o(i.npmAuditInCI)}` : `[npm audit](https://docs.npmjs.com/cli/commands/npm-audit) fails when a dependency has a known vulnerability of ${i.npmAuditLevel} severity or above.${o(i.npmAuditInCI)}`
|
|
740
886
|
],
|
|
741
887
|
[
|
|
742
888
|
"Supply chain risk",
|
|
743
|
-
|
|
889
|
+
W(i.socket),
|
|
744
890
|
"[Socket](https://socket.dev) flags malicious packages, typosquatting and suspicious behaviour that may not yet have a CVE."
|
|
745
891
|
],
|
|
746
892
|
[
|
|
747
893
|
"Security alerts",
|
|
748
|
-
|
|
894
|
+
W(i.dependabotAlerts),
|
|
749
895
|
`${g} alerts when a dependency has a known vulnerability, using the GitHub Advisory Database.`
|
|
750
896
|
],
|
|
751
897
|
[
|
|
752
898
|
"Security updates",
|
|
753
|
-
|
|
754
|
-
`${g} opens pull requests that update vulnerable dependencies.${
|
|
899
|
+
W(i.dependabotSecurityUpdates),
|
|
900
|
+
`${g} opens pull requests that update vulnerable dependencies.${Jt(i.dependabotSecurityUpdates)}`
|
|
755
901
|
],
|
|
756
902
|
[
|
|
757
903
|
"Version updates",
|
|
758
|
-
|
|
759
|
-
`${g} opens pull requests for new dependency versions.${
|
|
904
|
+
W(i.dependabotVersionUpdates),
|
|
905
|
+
`${g} opens pull requests for new dependency versions.${Jt(i.dependabotVersionUpdates)}`
|
|
760
906
|
]
|
|
761
907
|
];
|
|
762
908
|
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.
|
|
763
909
|
|
|
764
|
-
${
|
|
910
|
+
${G("Testing", c)}${G("Code Quality", u)}${G("Security Analysis", h)}${G("Dependencies", _)}`;
|
|
765
911
|
}
|
|
766
|
-
function
|
|
767
|
-
let a = `https://github.com/${e}/${t}`, o = `github.com/${e}/${t}`, s = `https://www.bestpractices.dev/projects/${String(r)}`, c = i !== void 0 &&
|
|
912
|
+
function Zt(e, t, n, r, i) {
|
|
913
|
+
let a = `https://github.com/${e}/${t}`, o = `github.com/${e}/${t}`, s = `https://www.bestpractices.dev/projects/${String(r)}`, c = i !== void 0 && qt(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.";
|
|
768
914
|
return `## Quality & Security
|
|
769
915
|
|
|
770
|
-
${
|
|
916
|
+
${Xt(e, t, n)}### OpenSSF 🚧
|
|
771
917
|
|
|
772
918
|
${l}[](https://scorecard.dev/viewer/?uri=${o})
|
|
773
919
|
|
|
@@ -779,37 +925,37 @@ Please do not open public GitHub issues for security vulnerabilities. ${u}`;
|
|
|
779
925
|
}
|
|
780
926
|
//#endregion
|
|
781
927
|
//#region src/actions/documentUsage.ts
|
|
782
|
-
var
|
|
928
|
+
var Qt = "<!-- USAGE_START -->", $t = "<!-- USAGE_END -->", en = /* @__PURE__ */ new Set([
|
|
783
929
|
"connector",
|
|
784
930
|
"cookbook",
|
|
785
931
|
"presenter"
|
|
786
|
-
]),
|
|
787
|
-
async function
|
|
932
|
+
]), tn = /* @__PURE__ */ new Set(["development", "eslint"]), nn = "> [!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.", rn = "This repository manages itself using the actions it implements.", an = "This repository is managed using the common set of actions provided by [@dpuse/dpuse-development](https://github.com/dpuse/dpuse-development).";
|
|
933
|
+
async function on() {
|
|
788
934
|
try {
|
|
789
935
|
f("Document Usage"), b("1️⃣ Insert usage content into 'README.md'");
|
|
790
|
-
let [e, t] = await Promise.all([c("package.json"), c("config.json")]), r =
|
|
791
|
-
await n(p,
|
|
936
|
+
let [e, t] = await Promise.all([c("package.json"), c("config.json")]), r = sn(e), i = cn(r), a = K(e.engines?.node), s = K(e.engines?.npm), l = K(e.devDependencies?.typescript), u = ln(_(t.id), e.name), d = `${r.replace(/\.git$/, "")}/blob/main/package.json`, p = un(u, r, i, a, s, l, `${e.name === "@dpuse/dpuse-development" ? rn : an} See the \`scripts\` block in [package.json](${d}) for details.`);
|
|
937
|
+
await n(p, Qt, $t), o("Usage documented");
|
|
792
938
|
} catch (e) {
|
|
793
939
|
console.error("❌ Error documenting usage", e), process.exit(1);
|
|
794
940
|
}
|
|
795
941
|
}
|
|
796
|
-
function
|
|
942
|
+
function sn(e) {
|
|
797
943
|
let t = e.repository, n = typeof t == "string" ? t : t?.url;
|
|
798
944
|
if (n == null || n === "") throw Error("package.json 'repository' field is required to document usage.");
|
|
799
945
|
return n.replace(/^git\+/, "");
|
|
800
946
|
}
|
|
801
|
-
function
|
|
947
|
+
function cn(e) {
|
|
802
948
|
return (e.split("/").at(-1) ?? "").replace(/\.git$/, "");
|
|
803
949
|
}
|
|
804
|
-
function
|
|
950
|
+
function K(e) {
|
|
805
951
|
if (e == null) throw Error("package.json version range is required to document usage.");
|
|
806
952
|
let t = /\d+(?:\.\d+)*/.exec(e);
|
|
807
953
|
if (t == null) throw Error(`Unable to parse version from '${e}'.`);
|
|
808
954
|
return t[0];
|
|
809
955
|
}
|
|
810
|
-
function
|
|
956
|
+
function ln(e, t) {
|
|
811
957
|
let { typeId: n } = e;
|
|
812
|
-
if (
|
|
958
|
+
if (en.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.
|
|
813
959
|
|
|
814
960
|
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.`;
|
|
815
961
|
if (e.publishedTo === "npm") {
|
|
@@ -820,11 +966,11 @@ You may view or clone this repository for your own purposes, such as building a
|
|
|
820
966
|
npm install ${t}
|
|
821
967
|
\`\`\`
|
|
822
968
|
|
|
823
|
-
${
|
|
969
|
+
${tn.has(n) ? `${nn}\n\n` : ""}To work on the source instead, clone this repository.`;
|
|
824
970
|
}
|
|
825
971
|
return "You may view or clone this repository for your own purposes.";
|
|
826
972
|
}
|
|
827
|
-
function
|
|
973
|
+
function un(e, t, n, r, i, a, o) {
|
|
828
974
|
return `## Usage
|
|
829
975
|
|
|
830
976
|
${e}
|
|
@@ -841,102 +987,102 @@ ${o}`;
|
|
|
841
987
|
}
|
|
842
988
|
//#endregion
|
|
843
989
|
//#region src/actions/documentApiReference.ts
|
|
844
|
-
var
|
|
845
|
-
async function
|
|
990
|
+
var q = "API_REFERENCE.md";
|
|
991
|
+
async function dn() {
|
|
846
992
|
try {
|
|
847
993
|
f("Document API Reference");
|
|
848
994
|
let { writeAPIReference: e } = await import("./apiReference-Fj5_02JP.js");
|
|
849
|
-
await e("1️⃣ ",
|
|
995
|
+
await e("1️⃣ ", q), o("API reference documented");
|
|
850
996
|
} catch (e) {
|
|
851
997
|
console.error("❌ Error documenting API reference", e), process.exit(1);
|
|
852
998
|
}
|
|
853
999
|
}
|
|
854
1000
|
//#endregion
|
|
855
1001
|
//#region src/actions/documentBundleSizes.ts
|
|
856
|
-
var
|
|
857
|
-
async function
|
|
1002
|
+
var fn = "bundle-analysis-reports/sonda/index.json", pn = "<!-- BUNDLE_START -->", mn = "<!-- BUNDLE_END -->", J = " ", Y = 20, hn = "█", gn = "▒", _n = 100 / Y / 2, vn = 100 / Y, yn = "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._", bn = "Bars show each row's share of its output file.", xn = "↳ rows are part of the row above.", X = "(bundler output, whitespace & JSON)", Sn = `${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.`;
|
|
1003
|
+
async function Cn(e) {
|
|
858
1004
|
try {
|
|
859
1005
|
f("Document Bundle Sizes"), b("1️⃣ Read bundle analysis report");
|
|
860
|
-
let t = await c(
|
|
1006
|
+
let t = await c(fn);
|
|
861
1007
|
b("2️⃣ Insert table into 'README.md'");
|
|
862
|
-
let r =
|
|
863
|
-
await n(`## Bundle Analysis\n\n${
|
|
1008
|
+
let r = wn(t, e?.moduleLevel ?? !1), i = r.includes("↳") ? `${bn} ${xn}` : bn;
|
|
1009
|
+
await n(`## Bundle Analysis\n\n${yn}\n\n${r}\n\n${i}\n\n${Sn}`, pn, mn), o("Bundle sizes documented");
|
|
864
1010
|
} catch (e) {
|
|
865
1011
|
console.error("❌ Error documenting bundle sizes", e), process.exit(1);
|
|
866
1012
|
}
|
|
867
1013
|
}
|
|
868
|
-
function
|
|
869
|
-
let n =
|
|
1014
|
+
function wn(e, t) {
|
|
1015
|
+
let n = jn(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, In(e)]).toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), a = ["|Chunk/Module/File|Composition|", "|:------ |:-----------|"];
|
|
870
1016
|
for (let [e, o] of i) {
|
|
871
|
-
let i = [...n.get(e) ?? /* @__PURE__ */ new Map()].toSorted(
|
|
872
|
-
a.push(`| **${e}** | ${
|
|
1017
|
+
let i = [...n.get(e) ?? /* @__PURE__ */ new Map()].toSorted(Tn), s = i.reduce((e, [, t]) => e + t.sizes.uncompressed, 0), c = s > 0 && r > 0 ? ` · ${Vn(s, r)} of the build` : "";
|
|
1018
|
+
a.push(`| **${e}** | ${Ln(o)}${c} |`, ...En(i, s, t));
|
|
873
1019
|
}
|
|
874
1020
|
return a.join("\n");
|
|
875
1021
|
}
|
|
876
|
-
function
|
|
877
|
-
return e[0] ===
|
|
1022
|
+
function Tn(e, t) {
|
|
1023
|
+
return e[0] === X == (t[0] === X) ? t[1].sizes.uncompressed - e[1].sizes.uncompressed : e[0] === X ? 1 : -1;
|
|
878
1024
|
}
|
|
879
|
-
function
|
|
1025
|
+
function En(e, t, n) {
|
|
880
1026
|
let r = [];
|
|
881
1027
|
for (let [i, { sizes: a, files: o }] of e) {
|
|
882
1028
|
if (o.size === 1) {
|
|
883
|
-
let e =
|
|
884
|
-
r.push(`| ${
|
|
1029
|
+
let e = An(o);
|
|
1030
|
+
r.push(`| ${J}${kn(i, e)} | ${Z(a.uncompressed, t)} |`);
|
|
885
1031
|
continue;
|
|
886
1032
|
}
|
|
887
|
-
r.push(`| ${
|
|
1033
|
+
r.push(`| ${J}${i} | ${Z(a.uncompressed, t)} |`), n || r.push(...Dn(o, t));
|
|
888
1034
|
}
|
|
889
1035
|
return r;
|
|
890
1036
|
}
|
|
891
|
-
function
|
|
892
|
-
let n = [...e].toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), r =
|
|
1037
|
+
function Dn(e, t) {
|
|
1038
|
+
let n = [...e].toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), r = On(n, t), i = (r > 0 ? n.slice(0, -r) : n).map(([e, n]) => `| ${J}${J}↳ ${e} | ${Z(n.uncompressed, t, gn)} |`);
|
|
893
1039
|
if (r > 0) {
|
|
894
1040
|
let e = n.slice(-r).reduce((e, [, t]) => e + t.uncompressed, 0);
|
|
895
|
-
i.push(`| ${
|
|
1041
|
+
i.push(`| ${J}${J}↳ ${String(r)} smaller files | ${Z(e, t, gn)} |`);
|
|
896
1042
|
}
|
|
897
1043
|
return i;
|
|
898
1044
|
}
|
|
899
|
-
function
|
|
1045
|
+
function On(e, t) {
|
|
900
1046
|
if (t <= 0) return 0;
|
|
901
1047
|
let n = 0, r = 0;
|
|
902
1048
|
for (let [, i] of e.toReversed()) {
|
|
903
|
-
let e = i.uncompressed / t * 100 <
|
|
1049
|
+
let e = i.uncompressed / t * 100 < _n, a = (r + i.uncompressed) / t * 100 <= vn;
|
|
904
1050
|
if (!e || !a) break;
|
|
905
1051
|
n++, r += i.uncompressed;
|
|
906
1052
|
}
|
|
907
1053
|
return n >= 2 ? n : 0;
|
|
908
1054
|
}
|
|
909
|
-
function
|
|
910
|
-
return `${
|
|
1055
|
+
function Z(e, t, n = hn) {
|
|
1056
|
+
return `${Rn(t > 0 ? e / t * 100 : 0, n)} · ${Q(e)}`;
|
|
911
1057
|
}
|
|
912
|
-
function
|
|
1058
|
+
function kn(e, t) {
|
|
913
1059
|
return t === "" ? e : `${e} → ${t}`;
|
|
914
1060
|
}
|
|
915
|
-
function
|
|
1061
|
+
function An(e) {
|
|
916
1062
|
let [t] = e.keys();
|
|
917
1063
|
if (t === void 0) throw Error("Expected exactly one file");
|
|
918
1064
|
return t;
|
|
919
1065
|
}
|
|
920
|
-
function
|
|
921
|
-
let t =
|
|
1066
|
+
function jn(e) {
|
|
1067
|
+
let t = Mn(e.dependencies), n = /* @__PURE__ */ new Map();
|
|
922
1068
|
for (let r of e.resources) {
|
|
923
1069
|
if (r.kind !== "chunk" || !r.parent) continue;
|
|
924
|
-
let { group: e, file: i } =
|
|
1070
|
+
let { group: e, file: i } = Nn(r.name, t), a = In(r), o = n.get(r.parent) ?? /* @__PURE__ */ new Map();
|
|
925
1071
|
n.set(r.parent, o);
|
|
926
1072
|
let s = o.get(e) ?? {
|
|
927
|
-
sizes:
|
|
1073
|
+
sizes: zn(),
|
|
928
1074
|
files: /* @__PURE__ */ new Map()
|
|
929
1075
|
};
|
|
930
|
-
o.set(e, s),
|
|
931
|
-
let c = s.files.get(i) ??
|
|
932
|
-
s.files.set(i, c),
|
|
1076
|
+
o.set(e, s), Bn(s.sizes, a);
|
|
1077
|
+
let c = s.files.get(i) ?? zn();
|
|
1078
|
+
s.files.set(i, c), Bn(c, a);
|
|
933
1079
|
}
|
|
934
1080
|
return n;
|
|
935
1081
|
}
|
|
936
|
-
function
|
|
1082
|
+
function Mn(e) {
|
|
937
1083
|
return e.flatMap((e) => e.paths.map((t) => [t, e.name])).toSorted((e, t) => t[0].length - e[0].length);
|
|
938
1084
|
}
|
|
939
|
-
function
|
|
1085
|
+
function Nn(e, t) {
|
|
940
1086
|
let n = t.find(([t]) => e === t || e.startsWith(`${t}/`));
|
|
941
1087
|
if (n) {
|
|
942
1088
|
let [t, r] = n;
|
|
@@ -946,65 +1092,65 @@ function hn(e, t) {
|
|
|
946
1092
|
};
|
|
947
1093
|
}
|
|
948
1094
|
return e === "[unassigned]" ? {
|
|
949
|
-
group:
|
|
1095
|
+
group: X,
|
|
950
1096
|
file: ""
|
|
951
1097
|
} : e.startsWith("\0") ? {
|
|
952
1098
|
group: "(runtime)",
|
|
953
1099
|
file: e.slice(1)
|
|
954
1100
|
} : e.startsWith("rust/") ? {
|
|
955
1101
|
group: "wasm",
|
|
956
|
-
file:
|
|
1102
|
+
file: Pn(e)
|
|
957
1103
|
} : {
|
|
958
1104
|
group: "src",
|
|
959
|
-
file:
|
|
1105
|
+
file: Fn(e)
|
|
960
1106
|
};
|
|
961
1107
|
}
|
|
962
|
-
function
|
|
963
|
-
let t = e.split("/", 2)[1] ?? "", n =
|
|
1108
|
+
function Pn(e) {
|
|
1109
|
+
let t = e.split("/", 2)[1] ?? "", n = Fn(e);
|
|
964
1110
|
return t !== "" && n.startsWith(t) ? `…${n.slice(t.length)}` : n;
|
|
965
1111
|
}
|
|
966
|
-
function
|
|
1112
|
+
function Fn(e) {
|
|
967
1113
|
return e.split("/").at(-1) ?? e;
|
|
968
1114
|
}
|
|
969
|
-
function
|
|
1115
|
+
function In(e) {
|
|
970
1116
|
return {
|
|
971
1117
|
uncompressed: e.uncompressed,
|
|
972
1118
|
gzip: e.gzip ?? 0
|
|
973
1119
|
};
|
|
974
1120
|
}
|
|
975
|
-
function
|
|
976
|
-
return `${
|
|
1121
|
+
function Ln(e) {
|
|
1122
|
+
return `${Q(e.uncompressed)} · gzip ${Q(e.gzip)}`;
|
|
977
1123
|
}
|
|
978
|
-
function
|
|
979
|
-
let n = Math.round(e / 100 *
|
|
980
|
-
return `\`${t.repeat(n)}${"░".repeat(
|
|
1124
|
+
function Rn(e, t = hn) {
|
|
1125
|
+
let n = Math.round(e / 100 * Y);
|
|
1126
|
+
return `\`${t.repeat(n)}${"░".repeat(Y - n)}\` ${e.toFixed(1)}%`;
|
|
981
1127
|
}
|
|
982
|
-
function
|
|
1128
|
+
function zn() {
|
|
983
1129
|
return {
|
|
984
1130
|
uncompressed: 0,
|
|
985
1131
|
gzip: 0
|
|
986
1132
|
};
|
|
987
1133
|
}
|
|
988
|
-
function
|
|
1134
|
+
function Bn(e, t) {
|
|
989
1135
|
e.uncompressed += t.uncompressed, e.gzip += t.gzip;
|
|
990
1136
|
}
|
|
991
|
-
function
|
|
1137
|
+
function Vn(e, t) {
|
|
992
1138
|
return `${(e / t * 100).toFixed(1)}%`;
|
|
993
1139
|
}
|
|
994
|
-
function
|
|
1140
|
+
function Q(e) {
|
|
995
1141
|
return e < 1024 ? `${String(e)} B` : `${(e / 1024).toFixed(1)} kB`;
|
|
996
1142
|
}
|
|
997
1143
|
//#endregion
|
|
998
1144
|
//#region src/actions/documentProject.ts
|
|
999
|
-
async function
|
|
1145
|
+
async function Hn(e = "MIT", t = !1) {
|
|
1000
1146
|
try {
|
|
1001
1147
|
let n = await c("config.json"), r = _(n.id).typeId === "connector";
|
|
1002
|
-
await
|
|
1003
|
-
let a = await i(
|
|
1004
|
-
a ? await
|
|
1148
|
+
await Ct(), r && await Fe(), await on(), await $e(e), await i("bundle-analysis-reports/sonda/index.json") === null ? b(`ℹ️ Bundle sizes NOT documented, as there is no '${fn}' yet. Build the project first.`) : await Cn({ moduleLevel: t }), await zt(), await Ie();
|
|
1149
|
+
let a = await i(q) !== null;
|
|
1150
|
+
a ? await dn() : b(`ℹ️ '${q}' NOT required by this project`), await x("ℹ️ Format generated files", "prettier", [
|
|
1005
1151
|
"--write",
|
|
1006
1152
|
"README.md",
|
|
1007
|
-
...a ? [
|
|
1153
|
+
...a ? [q] : []
|
|
1008
1154
|
]);
|
|
1009
1155
|
} catch (e) {
|
|
1010
1156
|
console.error("❌ Error documenting project", e), process.exit(1);
|
|
@@ -1012,7 +1158,7 @@ async function wn(e = "MIT", t = !1) {
|
|
|
1012
1158
|
}
|
|
1013
1159
|
//#endregion
|
|
1014
1160
|
//#region src/actions/formatCode.ts
|
|
1015
|
-
async function
|
|
1161
|
+
async function Un() {
|
|
1016
1162
|
try {
|
|
1017
1163
|
f("Format Code");
|
|
1018
1164
|
let e = [
|
|
@@ -1033,7 +1179,7 @@ async function Tn() {
|
|
|
1033
1179
|
}
|
|
1034
1180
|
//#endregion
|
|
1035
1181
|
//#region src/actions/lintCode.ts
|
|
1036
|
-
async function
|
|
1182
|
+
async function Wn() {
|
|
1037
1183
|
try {
|
|
1038
1184
|
f("Lint Code"), await x("1️⃣ Lint", "eslint", ["."]), o("Code linted");
|
|
1039
1185
|
} catch (e) {
|
|
@@ -1042,7 +1188,7 @@ async function En() {
|
|
|
1042
1188
|
}
|
|
1043
1189
|
//#endregion
|
|
1044
1190
|
//#region src/utilities/cloudflare.ts
|
|
1045
|
-
async function
|
|
1191
|
+
async function Gn() {
|
|
1046
1192
|
let e = await c("config.json"), t = {
|
|
1047
1193
|
body: JSON.stringify(e),
|
|
1048
1194
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1050,7 +1196,7 @@ async function Dn() {
|
|
|
1050
1196
|
}, n = await fetch(`https://api.dpuse.app/configs/${e.id}`, t);
|
|
1051
1197
|
if (!n.ok) throw Error(await n.text());
|
|
1052
1198
|
}
|
|
1053
|
-
async function
|
|
1199
|
+
async function Kn(e, t) {
|
|
1054
1200
|
async function n(e, t, r) {
|
|
1055
1201
|
for (let i of r) {
|
|
1056
1202
|
let r = `${e}/${i}`, a = `${t}/${i}`;
|
|
@@ -1068,7 +1214,7 @@ async function On(e, t) {
|
|
|
1068
1214
|
let r = await v(`${e}/${t}/`);
|
|
1069
1215
|
await n(`${e}/${t}`, t, r);
|
|
1070
1216
|
}
|
|
1071
|
-
async function
|
|
1217
|
+
async function qn(e) {
|
|
1072
1218
|
let t = e.id, n = {
|
|
1073
1219
|
body: JSON.stringify(e),
|
|
1074
1220
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1076,7 +1222,7 @@ async function kn(e) {
|
|
|
1076
1222
|
}, r = await fetch(`https://api.dpuse.app/configs/${t}`, n);
|
|
1077
1223
|
if (!r.ok) throw Error(await r.text());
|
|
1078
1224
|
}
|
|
1079
|
-
async function
|
|
1225
|
+
async function Jn(e, t) {
|
|
1080
1226
|
let n = `v${e.version ?? "unknown"}`;
|
|
1081
1227
|
async function r(e, r = "") {
|
|
1082
1228
|
let i = await v(e, { withFileTypes: !0 });
|
|
@@ -1100,34 +1246,34 @@ async function An(e, t) {
|
|
|
1100
1246
|
}
|
|
1101
1247
|
//#endregion
|
|
1102
1248
|
//#region src/actions/publishProject.ts
|
|
1103
|
-
async function
|
|
1249
|
+
async function Yn() {
|
|
1104
1250
|
try {
|
|
1105
1251
|
f("Publish Project");
|
|
1106
1252
|
let e = await c("package.json"), t = await c("config.json"), n = _(t.id);
|
|
1107
|
-
n.publishedTo === "npm" ? await x("1️⃣ Publish to npm", "npm", ["publish", "--provenance"]) : b("1️⃣ Publishing to npm NOT required"), await
|
|
1253
|
+
n.publishedTo === "npm" ? await x("1️⃣ Publish to npm", "npm", ["publish", "--provenance"]) : b("1️⃣ Publishing to npm NOT required"), await $("2️⃣ ", e, t, n), o(`Project version '${e.version ?? "unknown"}' published.`);
|
|
1108
1254
|
} catch (e) {
|
|
1109
1255
|
console.error("❌ Error publishing project", e), process.exit(1);
|
|
1110
1256
|
}
|
|
1111
1257
|
}
|
|
1112
|
-
async function
|
|
1113
|
-
if (r.typeId === "app") b(`${e} Register module`), await
|
|
1114
|
-
else if (r.typeId === "engine") b(`${e} Register module`), await
|
|
1258
|
+
async function $(e, t, n, r) {
|
|
1259
|
+
if (r.typeId === "app") b(`${e} Register module`), await Gn();
|
|
1260
|
+
else if (r.typeId === "engine") b(`${e} Register module`), await Jn(t, `dpuse-engine-eu/${r.uploadGroupName ?? "unknown"}`), await qn(n);
|
|
1115
1261
|
else if (r.uploadGroupName === void 0) b(`${e} Registration NOT required`);
|
|
1116
1262
|
else {
|
|
1117
1263
|
b(`${e} Register module`);
|
|
1118
1264
|
let i = n.id.split("-").slice(2).join("-");
|
|
1119
|
-
await
|
|
1265
|
+
await Jn(t, `dpuse-engine-eu/${r.uploadGroupName}/${i}`), await qn(n);
|
|
1120
1266
|
}
|
|
1121
1267
|
}
|
|
1122
1268
|
//#endregion
|
|
1123
1269
|
//#region src/actions/releaseProject.ts
|
|
1124
|
-
async function
|
|
1270
|
+
async function Xn(e = "MIT", t = !1) {
|
|
1125
1271
|
try {
|
|
1126
1272
|
f("Release Project");
|
|
1127
1273
|
let n = await c("package.json"), r = await c("config.json"), i = _(r.id);
|
|
1128
|
-
await
|
|
1274
|
+
await ie("1️⃣ ", n);
|
|
1129
1275
|
let a = await g("2️⃣ ", n, i);
|
|
1130
|
-
if (await
|
|
1276
|
+
if (await _e("3️⃣ ", n), b("4️⃣ Regenerate README"), await Hn(e, t), await d("5️⃣ Stage changes", "git", ["add", "."]), await d("6️⃣ Commit changes", "git", [
|
|
1131
1277
|
"commit",
|
|
1132
1278
|
"-m",
|
|
1133
1279
|
`v${n.version ?? "unknown"}`
|
|
@@ -1135,7 +1281,7 @@ async function Nn(e = "MIT", t = !1) {
|
|
|
1135
1281
|
"push",
|
|
1136
1282
|
"origin",
|
|
1137
1283
|
"main:main"
|
|
1138
|
-
]), await
|
|
1284
|
+
]), await $("8️⃣ ", n, a, i), i.publishedTo === "npm") {
|
|
1139
1285
|
let e = `v${n.version ?? "unknown"}`;
|
|
1140
1286
|
await x("9️⃣ Create GitHub release", "gh", [
|
|
1141
1287
|
"release",
|
|
@@ -1154,11 +1300,11 @@ async function Nn(e = "MIT", t = !1) {
|
|
|
1154
1300
|
}
|
|
1155
1301
|
//#endregion
|
|
1156
1302
|
//#region src/actions/syncProjectWithGitHub.ts
|
|
1157
|
-
async function
|
|
1303
|
+
async function Zn() {
|
|
1158
1304
|
try {
|
|
1159
1305
|
f("Synchronise Project with GitHub");
|
|
1160
1306
|
let e = await c("package.json"), t = await c("config.json"), n = _(t.id);
|
|
1161
|
-
await
|
|
1307
|
+
await ie("1️⃣ ", e), await g("2️⃣ ", e, n), await d("3️⃣ Stage changes", "git", ["add", "."]), await d("4️⃣ Commit changes", "git", [
|
|
1162
1308
|
"commit",
|
|
1163
1309
|
"-m",
|
|
1164
1310
|
`v${e.version ?? "unknown"}`
|
|
@@ -1173,12 +1319,12 @@ async function Pn() {
|
|
|
1173
1319
|
}
|
|
1174
1320
|
//#endregion
|
|
1175
1321
|
//#region src/actions/testProject.ts
|
|
1176
|
-
var
|
|
1322
|
+
var Qn = [
|
|
1177
1323
|
"1️⃣ ",
|
|
1178
1324
|
"2️⃣ ",
|
|
1179
1325
|
"3️⃣ ",
|
|
1180
1326
|
"4️⃣ "
|
|
1181
|
-
],
|
|
1327
|
+
], $n = [{
|
|
1182
1328
|
id: "unit",
|
|
1183
1329
|
label: "Run unit tests",
|
|
1184
1330
|
command: "vitest",
|
|
@@ -1191,13 +1337,13 @@ var Fn = [
|
|
|
1191
1337
|
arguments: ["test", "--pass-with-no-tests"],
|
|
1192
1338
|
configFileName: "playwright.config.ts"
|
|
1193
1339
|
}];
|
|
1194
|
-
async function
|
|
1340
|
+
async function er(e = ["unit"]) {
|
|
1195
1341
|
try {
|
|
1196
1342
|
f("Test Project");
|
|
1197
1343
|
let t = 0;
|
|
1198
|
-
for (let n of
|
|
1344
|
+
for (let n of $n) {
|
|
1199
1345
|
if (!e.includes(n.id) || await i(n.configFileName) === null) continue;
|
|
1200
|
-
let r = `${
|
|
1346
|
+
let r = `${Qn[t] ?? ""} ${n.label}`;
|
|
1201
1347
|
await x(r, n.command, n.arguments), t += 1;
|
|
1202
1348
|
}
|
|
1203
1349
|
if (t === 0) {
|
|
@@ -1210,4 +1356,23 @@ async function Ln(e = ["unit"]) {
|
|
|
1210
1356
|
}
|
|
1211
1357
|
}
|
|
1212
1358
|
//#endregion
|
|
1213
|
-
|
|
1359
|
+
//#region src/actions/triggerGitHubRelease.ts
|
|
1360
|
+
async function tr() {
|
|
1361
|
+
try {
|
|
1362
|
+
f("Trigger GitHub Release");
|
|
1363
|
+
let e = `v${(await c("package.json")).version ?? "unknown"}`;
|
|
1364
|
+
await x("1️⃣ Create GitHub release", "gh", [
|
|
1365
|
+
"release",
|
|
1366
|
+
"create",
|
|
1367
|
+
e,
|
|
1368
|
+
"--target",
|
|
1369
|
+
"main",
|
|
1370
|
+
"--generate-notes",
|
|
1371
|
+
"--latest"
|
|
1372
|
+
]), o(`GitHub release '${e}' created.`);
|
|
1373
|
+
} catch (e) {
|
|
1374
|
+
console.error("❌ Error triggering GitHub release", e), process.exit(1);
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
//#endregion
|
|
1378
|
+
export { me as auditDependencies, ge as buildProject, ke as checkProject, Hn as documentProject, Un as formatCode, Wn as lintCode, Yn as publishProject, Xn as releaseProject, Zn as syncProjectWithGitHub, er as testProject, tr as triggerGitHubRelease, Kn as uploadDirectoryToR2 };
|