@dpuse/dpuse-development 0.3.815 → 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 +422 -253
- 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);
|
|
298
428
|
}
|
|
299
|
-
function
|
|
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);
|
|
445
|
+
}
|
|
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,40 +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
|
|
594
|
+
function vt(e, t, n, r, i) {
|
|
445
595
|
let a = " ".repeat(i);
|
|
446
596
|
for (let [o, s] of Object.entries(e)) {
|
|
447
597
|
if (s.version === void 0) continue;
|
|
448
598
|
let e = s.version;
|
|
449
|
-
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));
|
|
450
600
|
}
|
|
451
601
|
}
|
|
452
|
-
function
|
|
602
|
+
function V(e, t, n, r, i) {
|
|
453
603
|
for (let [a, o] of e) {
|
|
454
604
|
if (o.version === void 0) continue;
|
|
455
605
|
let e = `${a}@${o.version}`, s = Object.entries(o.dependencies ?? {});
|
|
456
606
|
if (!t.shippedKeys.has(e)) {
|
|
457
|
-
|
|
607
|
+
V(s, t, n, r, !0);
|
|
458
608
|
continue;
|
|
459
609
|
}
|
|
460
|
-
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));
|
|
461
611
|
}
|
|
462
612
|
}
|
|
463
|
-
function
|
|
464
|
-
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)}`;
|
|
465
615
|
}
|
|
466
|
-
function
|
|
616
|
+
function yt(e) {
|
|
467
617
|
if (e == null) return "";
|
|
468
|
-
let t = e.publishedDate ?
|
|
618
|
+
let t = e.publishedDate ? bt(e.publishedDate.split("T", 1)[0]) : "";
|
|
469
619
|
if (e.latestVersion === "" || e.latestVersion === e.installedVersion) return t === "" ? "" : ` — ${t}`;
|
|
470
|
-
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} ❗`;
|
|
471
621
|
return t === "" ? ` — → ${r}` : ` — ${t} → ${r}`;
|
|
472
622
|
}
|
|
473
|
-
function
|
|
623
|
+
function bt(e) {
|
|
474
624
|
if (e == null || e === "") return "n/a";
|
|
475
625
|
let t = e.split("T", 1)[0];
|
|
476
626
|
if (t == null || t === "") return "n/a";
|
|
@@ -479,31 +629,31 @@ function H(e) {
|
|
|
479
629
|
}
|
|
480
630
|
//#endregion
|
|
481
631
|
//#region src/actions/documentOpening.ts
|
|
482
|
-
var
|
|
483
|
-
async function
|
|
632
|
+
var xt = "<!-- OPENING_START -->", St = "<!-- OPENING_END -->";
|
|
633
|
+
async function Ct() {
|
|
484
634
|
try {
|
|
485
635
|
f("Document Opening"), b("1️⃣ Insert opening content into 'README.md'");
|
|
486
|
-
let e = await c("package.json"), r = await c("config.json"), { owner: i, repo: a } = t(e, "document opening"), s =
|
|
487
|
-
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");
|
|
488
638
|
} catch (e) {
|
|
489
639
|
console.error("❌ Error documenting opening", e), process.exit(1);
|
|
490
640
|
}
|
|
491
641
|
}
|
|
492
|
-
function
|
|
642
|
+
function wt(e) {
|
|
493
643
|
let t = e.license;
|
|
494
644
|
if (t == null || t === "") throw Error("package.json 'license' field is required to document opening.");
|
|
495
645
|
return t;
|
|
496
646
|
}
|
|
497
|
-
function
|
|
647
|
+
function Tt(e) {
|
|
498
648
|
let t = e.name;
|
|
499
649
|
if (t == null || t === "") throw Error("package.json 'name' field is required to document opening.");
|
|
500
650
|
return t;
|
|
501
651
|
}
|
|
502
|
-
function
|
|
652
|
+
function Et(e) {
|
|
503
653
|
let t = e.description.en?.trim();
|
|
504
654
|
return t === void 0 || t === "" ? void 0 : t;
|
|
505
655
|
}
|
|
506
|
-
function
|
|
656
|
+
function Dt(e, t, n, r, i, a) {
|
|
507
657
|
let o = `https://github.com/${e}/${t}`;
|
|
508
658
|
return `[}-blue.svg)](./LICENSE)
|
|
509
659
|
[](${o}/releases/latest)${r === void 0 ? "" : `\n[](https://www.npmjs.com/package/${r})`}
|
|
@@ -525,41 +675,41 @@ In addition, DPUse provides [Tools](https://www.dpuse.app) used by the applicati
|
|
|
525
675
|
}
|
|
526
676
|
//#endregion
|
|
527
677
|
//#region src/actions/documentQualitySecurity.ts
|
|
528
|
-
var
|
|
678
|
+
var Ot = {
|
|
529
679
|
"Branch-Protection": 3,
|
|
530
680
|
"Code-Review": 0,
|
|
531
681
|
Contributors: 0
|
|
532
|
-
},
|
|
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 = {
|
|
533
683
|
actions: "GitHub Actions",
|
|
534
684
|
"javascript-typescript": "JavaScript/TypeScript",
|
|
535
685
|
rust: "Rust"
|
|
536
|
-
},
|
|
686
|
+
}, It = {
|
|
537
687
|
A: "brightgreen",
|
|
538
688
|
B: "green",
|
|
539
689
|
C: "yellow",
|
|
540
690
|
D: "orange",
|
|
541
691
|
F: "red"
|
|
542
|
-
},
|
|
543
|
-
async function
|
|
692
|
+
}, Lt = `${m}/health.json`, Rt = se(ce);
|
|
693
|
+
async function zt() {
|
|
544
694
|
try {
|
|
545
695
|
f("Document Quality & Security");
|
|
546
|
-
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");
|
|
547
697
|
b("4️⃣ Read security checks and settings");
|
|
548
|
-
let l = await
|
|
698
|
+
let l = await Wt(a, s, e);
|
|
549
699
|
b("5️⃣ Look up OpenSSF Best Practices badge and Scorecard results");
|
|
550
|
-
let [u, d] = await Promise.all([
|
|
700
|
+
let [u, d] = await Promise.all([Gt(`https://github.com/${a}/${s}`), Kt(`github.com/${a}/${s}`)]);
|
|
551
701
|
b("6️⃣ Insert quality and security content into 'README.md'");
|
|
552
|
-
let p =
|
|
702
|
+
let p = Zt(a, s, {
|
|
553
703
|
coveragePercent: r,
|
|
554
704
|
fallowHealth: i,
|
|
555
705
|
securitySettings: l
|
|
556
706
|
}, u, d);
|
|
557
|
-
await C(), await n(p,
|
|
707
|
+
await C(), await n(p, ne, te), o("Quality & security documented");
|
|
558
708
|
} catch (e) {
|
|
559
709
|
console.error("❌ Error documenting quality and security", e), process.exit(1);
|
|
560
710
|
}
|
|
561
711
|
}
|
|
562
|
-
async function
|
|
712
|
+
async function Bt(e) {
|
|
563
713
|
if (e.devDependencies?.["@vitest/coverage-v8"] == null) {
|
|
564
714
|
b("1️⃣ Test coverage NOT measured, as '@vitest/coverage-v8' is not installed");
|
|
565
715
|
return;
|
|
@@ -569,25 +719,25 @@ async function St(e) {
|
|
|
569
719
|
"--passWithNoTests",
|
|
570
720
|
"--coverage"
|
|
571
721
|
]);
|
|
572
|
-
let t = await i(
|
|
722
|
+
let t = await i(jt);
|
|
573
723
|
if (t === null) return;
|
|
574
724
|
let n = JSON.parse(t).total.lines.pct;
|
|
575
|
-
return await
|
|
725
|
+
return await Vt(n), n;
|
|
576
726
|
}
|
|
577
|
-
async function
|
|
727
|
+
async function Vt(e) {
|
|
578
728
|
let t = [
|
|
579
729
|
"red",
|
|
580
730
|
"yellow",
|
|
581
731
|
"brightgreen"
|
|
582
|
-
], n = Number(e >=
|
|
583
|
-
await r(
|
|
732
|
+
], n = Number(e >= Nt) + Number(e >= Mt);
|
|
733
|
+
await r(Pt, {
|
|
584
734
|
schemaVersion: 1,
|
|
585
735
|
label: "coverage",
|
|
586
736
|
message: `${e.toFixed(1)}%`,
|
|
587
737
|
color: t[n]
|
|
588
738
|
});
|
|
589
739
|
}
|
|
590
|
-
async function
|
|
740
|
+
async function Ht(e, t) {
|
|
591
741
|
if (e.devDependencies?.fallow == null) {
|
|
592
742
|
b("2️⃣ Code health NOT measured, as Fallow is not installed"), b("3️⃣ Code health report NOT required");
|
|
593
743
|
return;
|
|
@@ -598,20 +748,20 @@ async function wt(e, t) {
|
|
|
598
748
|
"--format",
|
|
599
749
|
"json",
|
|
600
750
|
...t
|
|
601
|
-
],
|
|
602
|
-
let n = await c(
|
|
603
|
-
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;
|
|
604
754
|
}
|
|
605
|
-
async function
|
|
755
|
+
async function Ut(e) {
|
|
606
756
|
let { score: t, grade: n } = e.health_score;
|
|
607
|
-
await r(
|
|
757
|
+
await r(y, {
|
|
608
758
|
schemaVersion: 1,
|
|
609
759
|
label: "fallow",
|
|
610
760
|
message: `${n} (${String(Math.round(t))})`,
|
|
611
|
-
color:
|
|
761
|
+
color: It[n] ?? "lightgrey"
|
|
612
762
|
});
|
|
613
763
|
}
|
|
614
|
-
async function
|
|
764
|
+
async function Wt(e, t, n) {
|
|
615
765
|
let [r, a, o, s] = await Promise.all([
|
|
616
766
|
i(".github/workflows/ci.yml"),
|
|
617
767
|
i(".github/workflows/codeql.yml"),
|
|
@@ -624,7 +774,7 @@ async function Et(e, t, n) {
|
|
|
624
774
|
U(`repos/${e}/${t}/commits/main/check-runs?per_page=100`)
|
|
625
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;
|
|
626
776
|
return {
|
|
627
|
-
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(),
|
|
628
778
|
codeQLQueries: /queries: ([\w-]+)/.exec(a ?? "")?.[1],
|
|
629
779
|
dependabotAlerts: d !== void 0,
|
|
630
780
|
dependabotSecurityUpdates: m("dependabot_security_updates"),
|
|
@@ -643,29 +793,29 @@ async function Et(e, t, n) {
|
|
|
643
793
|
}
|
|
644
794
|
async function U(e) {
|
|
645
795
|
try {
|
|
646
|
-
let { stdout: t } = await
|
|
796
|
+
let { stdout: t } = await Rt("gh", ["api", e]);
|
|
647
797
|
return t;
|
|
648
798
|
} catch (e) {
|
|
649
799
|
if (String(e.stderr).includes("HTTP 404")) return;
|
|
650
800
|
throw e;
|
|
651
801
|
}
|
|
652
802
|
}
|
|
653
|
-
async function
|
|
803
|
+
async function Gt(e) {
|
|
654
804
|
let t = await fetch(`https://www.bestpractices.dev/projects.json?url=${encodeURIComponent(e)}`);
|
|
655
805
|
if (!t.ok) throw Error(`OpenSSF Best Practices lookup failed with status ${String(t.status)}.`);
|
|
656
806
|
return (await t.json()).find((t) => t.repo_url === e)?.id;
|
|
657
807
|
}
|
|
658
|
-
async function
|
|
808
|
+
async function Kt(e) {
|
|
659
809
|
let t = await fetch(`https://api.scorecard.dev/projects/${e}`);
|
|
660
810
|
if (t.status !== 404) {
|
|
661
811
|
if (!t.ok) throw Error(`OpenSSF Scorecard lookup failed with status ${String(t.status)}.`);
|
|
662
812
|
return await t.json();
|
|
663
813
|
}
|
|
664
814
|
}
|
|
665
|
-
function
|
|
666
|
-
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]);
|
|
667
817
|
}
|
|
668
|
-
function
|
|
818
|
+
function Jt(e) {
|
|
669
819
|
return e === !1 ? " These are handled manually." : "";
|
|
670
820
|
}
|
|
671
821
|
function W(e) {
|
|
@@ -680,10 +830,10 @@ ${t.map((e) => `|${e.join("|")}|`).join("\n")}
|
|
|
680
830
|
|
|
681
831
|
`;
|
|
682
832
|
}
|
|
683
|
-
function
|
|
833
|
+
function Yt(e, t, n, r) {
|
|
684
834
|
return `})`;
|
|
685
835
|
}
|
|
686
|
-
function
|
|
836
|
+
function Xt(e, t, { coveragePercent: n, fallowHealth: r, securitySettings: i }) {
|
|
687
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 = [[
|
|
688
838
|
"Unit tests",
|
|
689
839
|
W(i.testsInCI),
|
|
@@ -696,7 +846,7 @@ function Mt(e, t, { coveragePercent: n, fallowHealth: r, securitySettings: i })
|
|
|
696
846
|
n !== void 0 && c.push([
|
|
697
847
|
"Test coverage",
|
|
698
848
|
W(!0),
|
|
699
|
-
`${
|
|
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)}%.`
|
|
700
850
|
]);
|
|
701
851
|
let l = `[](https://sonarcloud.io/summary/new_code?id=${e}_${t}) `, u = [[
|
|
702
852
|
"Code analysis",
|
|
@@ -710,7 +860,7 @@ function Mt(e, t, { coveragePercent: n, fallowHealth: r, securitySettings: i })
|
|
|
710
860
|
r !== void 0 && u.unshift([
|
|
711
861
|
"Code health",
|
|
712
862
|
W(!0),
|
|
713
|
-
`[${
|
|
863
|
+
`[${Yt(e, t, "Fallow code health", y)}](./${s}) [Fallow](https://github.com/fallow-rs/fallow) finds unused code, duplication, complexity and dependency problems.`
|
|
714
864
|
]);
|
|
715
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 = [
|
|
716
866
|
[
|
|
@@ -747,23 +897,23 @@ function Mt(e, t, { coveragePercent: n, fallowHealth: r, securitySettings: i })
|
|
|
747
897
|
[
|
|
748
898
|
"Security updates",
|
|
749
899
|
W(i.dependabotSecurityUpdates),
|
|
750
|
-
`${g} opens pull requests that update vulnerable dependencies.${
|
|
900
|
+
`${g} opens pull requests that update vulnerable dependencies.${Jt(i.dependabotSecurityUpdates)}`
|
|
751
901
|
],
|
|
752
902
|
[
|
|
753
903
|
"Version updates",
|
|
754
904
|
W(i.dependabotVersionUpdates),
|
|
755
|
-
`${g} opens pull requests for new dependency versions.${
|
|
905
|
+
`${g} opens pull requests for new dependency versions.${Jt(i.dependabotVersionUpdates)}`
|
|
756
906
|
]
|
|
757
907
|
];
|
|
758
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.
|
|
759
909
|
|
|
760
910
|
${G("Testing", c)}${G("Code Quality", u)}${G("Security Analysis", h)}${G("Dependencies", _)}`;
|
|
761
911
|
}
|
|
762
|
-
function
|
|
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 &&
|
|
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.";
|
|
764
914
|
return `## Quality & Security
|
|
765
915
|
|
|
766
|
-
${
|
|
916
|
+
${Xt(e, t, n)}### OpenSSF 🚧
|
|
767
917
|
|
|
768
918
|
${l}[](https://scorecard.dev/viewer/?uri=${o})
|
|
769
919
|
|
|
@@ -775,26 +925,26 @@ Please do not open public GitHub issues for security vulnerabilities. ${u}`;
|
|
|
775
925
|
}
|
|
776
926
|
//#endregion
|
|
777
927
|
//#region src/actions/documentUsage.ts
|
|
778
|
-
var
|
|
928
|
+
var Qt = "<!-- USAGE_START -->", $t = "<!-- USAGE_END -->", en = /* @__PURE__ */ new Set([
|
|
779
929
|
"connector",
|
|
780
930
|
"cookbook",
|
|
781
931
|
"presenter"
|
|
782
|
-
]),
|
|
783
|
-
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() {
|
|
784
934
|
try {
|
|
785
935
|
f("Document Usage"), b("1️⃣ Insert usage content into 'README.md'");
|
|
786
|
-
let [e, t] = await Promise.all([c("package.json"), c("config.json")]), r =
|
|
787
|
-
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");
|
|
788
938
|
} catch (e) {
|
|
789
939
|
console.error("❌ Error documenting usage", e), process.exit(1);
|
|
790
940
|
}
|
|
791
941
|
}
|
|
792
|
-
function
|
|
942
|
+
function sn(e) {
|
|
793
943
|
let t = e.repository, n = typeof t == "string" ? t : t?.url;
|
|
794
944
|
if (n == null || n === "") throw Error("package.json 'repository' field is required to document usage.");
|
|
795
945
|
return n.replace(/^git\+/, "");
|
|
796
946
|
}
|
|
797
|
-
function
|
|
947
|
+
function cn(e) {
|
|
798
948
|
return (e.split("/").at(-1) ?? "").replace(/\.git$/, "");
|
|
799
949
|
}
|
|
800
950
|
function K(e) {
|
|
@@ -803,9 +953,9 @@ function K(e) {
|
|
|
803
953
|
if (t == null) throw Error(`Unable to parse version from '${e}'.`);
|
|
804
954
|
return t[0];
|
|
805
955
|
}
|
|
806
|
-
function
|
|
956
|
+
function ln(e, t) {
|
|
807
957
|
let { typeId: n } = e;
|
|
808
|
-
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.
|
|
809
959
|
|
|
810
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.`;
|
|
811
961
|
if (e.publishedTo === "npm") {
|
|
@@ -816,11 +966,11 @@ You may view or clone this repository for your own purposes, such as building a
|
|
|
816
966
|
npm install ${t}
|
|
817
967
|
\`\`\`
|
|
818
968
|
|
|
819
|
-
${
|
|
969
|
+
${tn.has(n) ? `${nn}\n\n` : ""}To work on the source instead, clone this repository.`;
|
|
820
970
|
}
|
|
821
971
|
return "You may view or clone this repository for your own purposes.";
|
|
822
972
|
}
|
|
823
|
-
function
|
|
973
|
+
function un(e, t, n, r, i, a, o) {
|
|
824
974
|
return `## Usage
|
|
825
975
|
|
|
826
976
|
${e}
|
|
@@ -838,7 +988,7 @@ ${o}`;
|
|
|
838
988
|
//#endregion
|
|
839
989
|
//#region src/actions/documentApiReference.ts
|
|
840
990
|
var q = "API_REFERENCE.md";
|
|
841
|
-
async function
|
|
991
|
+
async function dn() {
|
|
842
992
|
try {
|
|
843
993
|
f("Document API Reference");
|
|
844
994
|
let { writeAPIReference: e } = await import("./apiReference-Fj5_02JP.js");
|
|
@@ -849,90 +999,90 @@ async function Kt() {
|
|
|
849
999
|
}
|
|
850
1000
|
//#endregion
|
|
851
1001
|
//#region src/actions/documentBundleSizes.ts
|
|
852
|
-
var
|
|
853
|
-
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) {
|
|
854
1004
|
try {
|
|
855
1005
|
f("Document Bundle Sizes"), b("1️⃣ Read bundle analysis report");
|
|
856
|
-
let t = await c(
|
|
1006
|
+
let t = await c(fn);
|
|
857
1007
|
b("2️⃣ Insert table into 'README.md'");
|
|
858
|
-
let r =
|
|
859
|
-
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");
|
|
860
1010
|
} catch (e) {
|
|
861
1011
|
console.error("❌ Error documenting bundle sizes", e), process.exit(1);
|
|
862
1012
|
}
|
|
863
1013
|
}
|
|
864
|
-
function
|
|
865
|
-
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|", "|:------ |:-----------|"];
|
|
866
1016
|
for (let [e, o] of i) {
|
|
867
|
-
let i = [...n.get(e) ?? /* @__PURE__ */ new Map()].toSorted(
|
|
868
|
-
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));
|
|
869
1019
|
}
|
|
870
1020
|
return a.join("\n");
|
|
871
1021
|
}
|
|
872
|
-
function
|
|
1022
|
+
function Tn(e, t) {
|
|
873
1023
|
return e[0] === X == (t[0] === X) ? t[1].sizes.uncompressed - e[1].sizes.uncompressed : e[0] === X ? 1 : -1;
|
|
874
1024
|
}
|
|
875
|
-
function
|
|
1025
|
+
function En(e, t, n) {
|
|
876
1026
|
let r = [];
|
|
877
1027
|
for (let [i, { sizes: a, files: o }] of e) {
|
|
878
1028
|
if (o.size === 1) {
|
|
879
|
-
let e =
|
|
880
|
-
r.push(`| ${J}${
|
|
1029
|
+
let e = An(o);
|
|
1030
|
+
r.push(`| ${J}${kn(i, e)} | ${Z(a.uncompressed, t)} |`);
|
|
881
1031
|
continue;
|
|
882
1032
|
}
|
|
883
|
-
r.push(`| ${J}${i} | ${Z(a.uncompressed, t)} |`), n || r.push(...
|
|
1033
|
+
r.push(`| ${J}${i} | ${Z(a.uncompressed, t)} |`), n || r.push(...Dn(o, t));
|
|
884
1034
|
}
|
|
885
1035
|
return r;
|
|
886
1036
|
}
|
|
887
|
-
function
|
|
888
|
-
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)} |`);
|
|
889
1039
|
if (r > 0) {
|
|
890
1040
|
let e = n.slice(-r).reduce((e, [, t]) => e + t.uncompressed, 0);
|
|
891
|
-
i.push(`| ${J}${J}↳ ${String(r)} smaller files | ${Z(e, t,
|
|
1041
|
+
i.push(`| ${J}${J}↳ ${String(r)} smaller files | ${Z(e, t, gn)} |`);
|
|
892
1042
|
}
|
|
893
1043
|
return i;
|
|
894
1044
|
}
|
|
895
|
-
function
|
|
1045
|
+
function On(e, t) {
|
|
896
1046
|
if (t <= 0) return 0;
|
|
897
1047
|
let n = 0, r = 0;
|
|
898
1048
|
for (let [, i] of e.toReversed()) {
|
|
899
|
-
let e = i.uncompressed / t * 100 <
|
|
1049
|
+
let e = i.uncompressed / t * 100 < _n, a = (r + i.uncompressed) / t * 100 <= vn;
|
|
900
1050
|
if (!e || !a) break;
|
|
901
1051
|
n++, r += i.uncompressed;
|
|
902
1052
|
}
|
|
903
1053
|
return n >= 2 ? n : 0;
|
|
904
1054
|
}
|
|
905
|
-
function Z(e, t, n =
|
|
906
|
-
return `${
|
|
1055
|
+
function Z(e, t, n = hn) {
|
|
1056
|
+
return `${Rn(t > 0 ? e / t * 100 : 0, n)} · ${Q(e)}`;
|
|
907
1057
|
}
|
|
908
|
-
function
|
|
1058
|
+
function kn(e, t) {
|
|
909
1059
|
return t === "" ? e : `${e} → ${t}`;
|
|
910
1060
|
}
|
|
911
|
-
function
|
|
1061
|
+
function An(e) {
|
|
912
1062
|
let [t] = e.keys();
|
|
913
1063
|
if (t === void 0) throw Error("Expected exactly one file");
|
|
914
1064
|
return t;
|
|
915
1065
|
}
|
|
916
|
-
function
|
|
917
|
-
let t =
|
|
1066
|
+
function jn(e) {
|
|
1067
|
+
let t = Mn(e.dependencies), n = /* @__PURE__ */ new Map();
|
|
918
1068
|
for (let r of e.resources) {
|
|
919
1069
|
if (r.kind !== "chunk" || !r.parent) continue;
|
|
920
|
-
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();
|
|
921
1071
|
n.set(r.parent, o);
|
|
922
1072
|
let s = o.get(e) ?? {
|
|
923
|
-
sizes:
|
|
1073
|
+
sizes: zn(),
|
|
924
1074
|
files: /* @__PURE__ */ new Map()
|
|
925
1075
|
};
|
|
926
|
-
o.set(e, s),
|
|
927
|
-
let c = s.files.get(i) ??
|
|
928
|
-
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);
|
|
929
1079
|
}
|
|
930
1080
|
return n;
|
|
931
1081
|
}
|
|
932
|
-
function
|
|
1082
|
+
function Mn(e) {
|
|
933
1083
|
return e.flatMap((e) => e.paths.map((t) => [t, e.name])).toSorted((e, t) => t[0].length - e[0].length);
|
|
934
1084
|
}
|
|
935
|
-
function
|
|
1085
|
+
function Nn(e, t) {
|
|
936
1086
|
let n = t.find(([t]) => e === t || e.startsWith(`${t}/`));
|
|
937
1087
|
if (n) {
|
|
938
1088
|
let [t, r] = n;
|
|
@@ -949,55 +1099,55 @@ function hn(e, t) {
|
|
|
949
1099
|
file: e.slice(1)
|
|
950
1100
|
} : e.startsWith("rust/") ? {
|
|
951
1101
|
group: "wasm",
|
|
952
|
-
file:
|
|
1102
|
+
file: Pn(e)
|
|
953
1103
|
} : {
|
|
954
1104
|
group: "src",
|
|
955
|
-
file:
|
|
1105
|
+
file: Fn(e)
|
|
956
1106
|
};
|
|
957
1107
|
}
|
|
958
|
-
function
|
|
959
|
-
let t = e.split("/", 2)[1] ?? "", n =
|
|
1108
|
+
function Pn(e) {
|
|
1109
|
+
let t = e.split("/", 2)[1] ?? "", n = Fn(e);
|
|
960
1110
|
return t !== "" && n.startsWith(t) ? `…${n.slice(t.length)}` : n;
|
|
961
1111
|
}
|
|
962
|
-
function
|
|
1112
|
+
function Fn(e) {
|
|
963
1113
|
return e.split("/").at(-1) ?? e;
|
|
964
1114
|
}
|
|
965
|
-
function
|
|
1115
|
+
function In(e) {
|
|
966
1116
|
return {
|
|
967
1117
|
uncompressed: e.uncompressed,
|
|
968
1118
|
gzip: e.gzip ?? 0
|
|
969
1119
|
};
|
|
970
1120
|
}
|
|
971
|
-
function
|
|
972
|
-
return `${
|
|
1121
|
+
function Ln(e) {
|
|
1122
|
+
return `${Q(e.uncompressed)} · gzip ${Q(e.gzip)}`;
|
|
973
1123
|
}
|
|
974
|
-
function
|
|
1124
|
+
function Rn(e, t = hn) {
|
|
975
1125
|
let n = Math.round(e / 100 * Y);
|
|
976
1126
|
return `\`${t.repeat(n)}${"░".repeat(Y - n)}\` ${e.toFixed(1)}%`;
|
|
977
1127
|
}
|
|
978
|
-
function
|
|
1128
|
+
function zn() {
|
|
979
1129
|
return {
|
|
980
1130
|
uncompressed: 0,
|
|
981
1131
|
gzip: 0
|
|
982
1132
|
};
|
|
983
1133
|
}
|
|
984
|
-
function
|
|
1134
|
+
function Bn(e, t) {
|
|
985
1135
|
e.uncompressed += t.uncompressed, e.gzip += t.gzip;
|
|
986
1136
|
}
|
|
987
|
-
function
|
|
1137
|
+
function Vn(e, t) {
|
|
988
1138
|
return `${(e / t * 100).toFixed(1)}%`;
|
|
989
1139
|
}
|
|
990
|
-
function
|
|
1140
|
+
function Q(e) {
|
|
991
1141
|
return e < 1024 ? `${String(e)} B` : `${(e / 1024).toFixed(1)} kB`;
|
|
992
1142
|
}
|
|
993
1143
|
//#endregion
|
|
994
1144
|
//#region src/actions/documentProject.ts
|
|
995
|
-
async function
|
|
1145
|
+
async function Hn(e = "MIT", t = !1) {
|
|
996
1146
|
try {
|
|
997
1147
|
let n = await c("config.json"), r = _(n.id).typeId === "connector";
|
|
998
|
-
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();
|
|
999
1149
|
let a = await i(q) !== null;
|
|
1000
|
-
a ? await
|
|
1150
|
+
a ? await dn() : b(`ℹ️ '${q}' NOT required by this project`), await x("ℹ️ Format generated files", "prettier", [
|
|
1001
1151
|
"--write",
|
|
1002
1152
|
"README.md",
|
|
1003
1153
|
...a ? [q] : []
|
|
@@ -1008,7 +1158,7 @@ async function Cn(e = "MIT", t = !1) {
|
|
|
1008
1158
|
}
|
|
1009
1159
|
//#endregion
|
|
1010
1160
|
//#region src/actions/formatCode.ts
|
|
1011
|
-
async function
|
|
1161
|
+
async function Un() {
|
|
1012
1162
|
try {
|
|
1013
1163
|
f("Format Code");
|
|
1014
1164
|
let e = [
|
|
@@ -1029,7 +1179,7 @@ async function wn() {
|
|
|
1029
1179
|
}
|
|
1030
1180
|
//#endregion
|
|
1031
1181
|
//#region src/actions/lintCode.ts
|
|
1032
|
-
async function
|
|
1182
|
+
async function Wn() {
|
|
1033
1183
|
try {
|
|
1034
1184
|
f("Lint Code"), await x("1️⃣ Lint", "eslint", ["."]), o("Code linted");
|
|
1035
1185
|
} catch (e) {
|
|
@@ -1038,7 +1188,7 @@ async function Tn() {
|
|
|
1038
1188
|
}
|
|
1039
1189
|
//#endregion
|
|
1040
1190
|
//#region src/utilities/cloudflare.ts
|
|
1041
|
-
async function
|
|
1191
|
+
async function Gn() {
|
|
1042
1192
|
let e = await c("config.json"), t = {
|
|
1043
1193
|
body: JSON.stringify(e),
|
|
1044
1194
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1046,7 +1196,7 @@ async function En() {
|
|
|
1046
1196
|
}, n = await fetch(`https://api.dpuse.app/configs/${e.id}`, t);
|
|
1047
1197
|
if (!n.ok) throw Error(await n.text());
|
|
1048
1198
|
}
|
|
1049
|
-
async function
|
|
1199
|
+
async function Kn(e, t) {
|
|
1050
1200
|
async function n(e, t, r) {
|
|
1051
1201
|
for (let i of r) {
|
|
1052
1202
|
let r = `${e}/${i}`, a = `${t}/${i}`;
|
|
@@ -1064,7 +1214,7 @@ async function Dn(e, t) {
|
|
|
1064
1214
|
let r = await v(`${e}/${t}/`);
|
|
1065
1215
|
await n(`${e}/${t}`, t, r);
|
|
1066
1216
|
}
|
|
1067
|
-
async function
|
|
1217
|
+
async function qn(e) {
|
|
1068
1218
|
let t = e.id, n = {
|
|
1069
1219
|
body: JSON.stringify(e),
|
|
1070
1220
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1072,7 +1222,7 @@ async function On(e) {
|
|
|
1072
1222
|
}, r = await fetch(`https://api.dpuse.app/configs/${t}`, n);
|
|
1073
1223
|
if (!r.ok) throw Error(await r.text());
|
|
1074
1224
|
}
|
|
1075
|
-
async function
|
|
1225
|
+
async function Jn(e, t) {
|
|
1076
1226
|
let n = `v${e.version ?? "unknown"}`;
|
|
1077
1227
|
async function r(e, r = "") {
|
|
1078
1228
|
let i = await v(e, { withFileTypes: !0 });
|
|
@@ -1096,34 +1246,34 @@ async function kn(e, t) {
|
|
|
1096
1246
|
}
|
|
1097
1247
|
//#endregion
|
|
1098
1248
|
//#region src/actions/publishProject.ts
|
|
1099
|
-
async function
|
|
1249
|
+
async function Yn() {
|
|
1100
1250
|
try {
|
|
1101
1251
|
f("Publish Project");
|
|
1102
1252
|
let e = await c("package.json"), t = await c("config.json"), n = _(t.id);
|
|
1103
|
-
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.`);
|
|
1104
1254
|
} catch (e) {
|
|
1105
1255
|
console.error("❌ Error publishing project", e), process.exit(1);
|
|
1106
1256
|
}
|
|
1107
1257
|
}
|
|
1108
|
-
async function
|
|
1109
|
-
if (r.typeId === "app") b(`${e} Register module`), await
|
|
1110
|
-
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);
|
|
1111
1261
|
else if (r.uploadGroupName === void 0) b(`${e} Registration NOT required`);
|
|
1112
1262
|
else {
|
|
1113
1263
|
b(`${e} Register module`);
|
|
1114
1264
|
let i = n.id.split("-").slice(2).join("-");
|
|
1115
|
-
await
|
|
1265
|
+
await Jn(t, `dpuse-engine-eu/${r.uploadGroupName}/${i}`), await qn(n);
|
|
1116
1266
|
}
|
|
1117
1267
|
}
|
|
1118
1268
|
//#endregion
|
|
1119
1269
|
//#region src/actions/releaseProject.ts
|
|
1120
|
-
async function
|
|
1270
|
+
async function Xn(e = "MIT", t = !1) {
|
|
1121
1271
|
try {
|
|
1122
1272
|
f("Release Project");
|
|
1123
1273
|
let n = await c("package.json"), r = await c("config.json"), i = _(r.id);
|
|
1124
|
-
await
|
|
1274
|
+
await ie("1️⃣ ", n);
|
|
1125
1275
|
let a = await g("2️⃣ ", n, i);
|
|
1126
|
-
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", [
|
|
1127
1277
|
"commit",
|
|
1128
1278
|
"-m",
|
|
1129
1279
|
`v${n.version ?? "unknown"}`
|
|
@@ -1131,7 +1281,7 @@ async function Mn(e = "MIT", t = !1) {
|
|
|
1131
1281
|
"push",
|
|
1132
1282
|
"origin",
|
|
1133
1283
|
"main:main"
|
|
1134
|
-
]), await
|
|
1284
|
+
]), await $("8️⃣ ", n, a, i), i.publishedTo === "npm") {
|
|
1135
1285
|
let e = `v${n.version ?? "unknown"}`;
|
|
1136
1286
|
await x("9️⃣ Create GitHub release", "gh", [
|
|
1137
1287
|
"release",
|
|
@@ -1150,11 +1300,11 @@ async function Mn(e = "MIT", t = !1) {
|
|
|
1150
1300
|
}
|
|
1151
1301
|
//#endregion
|
|
1152
1302
|
//#region src/actions/syncProjectWithGitHub.ts
|
|
1153
|
-
async function
|
|
1303
|
+
async function Zn() {
|
|
1154
1304
|
try {
|
|
1155
1305
|
f("Synchronise Project with GitHub");
|
|
1156
1306
|
let e = await c("package.json"), t = await c("config.json"), n = _(t.id);
|
|
1157
|
-
await
|
|
1307
|
+
await ie("1️⃣ ", e), await g("2️⃣ ", e, n), await d("3️⃣ Stage changes", "git", ["add", "."]), await d("4️⃣ Commit changes", "git", [
|
|
1158
1308
|
"commit",
|
|
1159
1309
|
"-m",
|
|
1160
1310
|
`v${e.version ?? "unknown"}`
|
|
@@ -1169,12 +1319,12 @@ async function Nn() {
|
|
|
1169
1319
|
}
|
|
1170
1320
|
//#endregion
|
|
1171
1321
|
//#region src/actions/testProject.ts
|
|
1172
|
-
var
|
|
1322
|
+
var Qn = [
|
|
1173
1323
|
"1️⃣ ",
|
|
1174
1324
|
"2️⃣ ",
|
|
1175
1325
|
"3️⃣ ",
|
|
1176
1326
|
"4️⃣ "
|
|
1177
|
-
],
|
|
1327
|
+
], $n = [{
|
|
1178
1328
|
id: "unit",
|
|
1179
1329
|
label: "Run unit tests",
|
|
1180
1330
|
command: "vitest",
|
|
@@ -1187,13 +1337,13 @@ var Pn = [
|
|
|
1187
1337
|
arguments: ["test", "--pass-with-no-tests"],
|
|
1188
1338
|
configFileName: "playwright.config.ts"
|
|
1189
1339
|
}];
|
|
1190
|
-
async function
|
|
1340
|
+
async function er(e = ["unit"]) {
|
|
1191
1341
|
try {
|
|
1192
1342
|
f("Test Project");
|
|
1193
1343
|
let t = 0;
|
|
1194
|
-
for (let n of
|
|
1344
|
+
for (let n of $n) {
|
|
1195
1345
|
if (!e.includes(n.id) || await i(n.configFileName) === null) continue;
|
|
1196
|
-
let r = `${
|
|
1346
|
+
let r = `${Qn[t] ?? ""} ${n.label}`;
|
|
1197
1347
|
await x(r, n.command, n.arguments), t += 1;
|
|
1198
1348
|
}
|
|
1199
1349
|
if (t === 0) {
|
|
@@ -1206,4 +1356,23 @@ async function In(e = ["unit"]) {
|
|
|
1206
1356
|
}
|
|
1207
1357
|
}
|
|
1208
1358
|
//#endregion
|
|
1209
|
-
|
|
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 };
|