@dpuse/dpuse-development 1.0.110 → 1.0.112
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 +18 -18
- package/dist/{apiReference-cMfpNKxR.js → apiReference-D4xooSV0.js} +1 -1
- package/dist/{apiReference-cMfpNKxR.js.map → apiReference-D4xooSV0.js.map} +1 -1
- package/dist/dpuse-development.es.js +480 -429
- package/dist/dpuse-development.es.js.map +1 -1
- package/dist/types/src/utilities/cloudflare.d.ts +1 -0
- package/dist/{utilities-BLjGg0iM.js → utilities-CjhO3pxf.js} +1 -1
- package/dist/utilities-CjhO3pxf.js.map +1 -0
- package/package.json +2 -2
- package/dist/utilities-BLjGg0iM.js.map +0 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { C as e, D as t, E as n, M as r, O as i, S as a, T as o, _ as s, a as c, b as l, c as u, d, f, g as p, h as m, i as h, j as g, k as _, l as v, m as
|
|
2
|
-
import { SHIPPED_PACKAGES_FILE_NAME as
|
|
3
|
-
import { existsSync as
|
|
4
|
-
import
|
|
5
|
-
import { promisify as
|
|
6
|
-
import { execFile as
|
|
7
|
-
import { fileURLToPath as
|
|
8
|
-
import { run as
|
|
9
|
-
import { init as
|
|
10
|
-
import { setTimeout as
|
|
11
|
-
import
|
|
1
|
+
import { C as e, D as t, E as n, M as r, O as i, S as a, T as o, _ as s, a as c, b as l, c as u, d, f, g as p, h as m, i as h, j as g, k as _, l as v, m as ee, n as te, o as ne, p as y, r as re, s as ie, t as ae, u as oe, v as b, w as x, x as S, y as C } from "./utilities-CjhO3pxf.js";
|
|
2
|
+
import { SHIPPED_PACKAGES_FILE_NAME as se } from "./vite.es.js";
|
|
3
|
+
import { existsSync as ce, promises as w } from "node:fs";
|
|
4
|
+
import T from "node:path";
|
|
5
|
+
import { promisify as le } from "node:util";
|
|
6
|
+
import { execFile as ue } from "node:child_process";
|
|
7
|
+
import { fileURLToPath as de } from "node:url";
|
|
8
|
+
import { run as fe } from "npm-check-updates";
|
|
9
|
+
import { init as pe } from "license-checker-rseidelsohn";
|
|
10
|
+
import { setTimeout as me } from "node:timers/promises";
|
|
11
|
+
import he from "spdx-satisfies";
|
|
12
|
+
import ge from "node:os";
|
|
12
13
|
//#region src/actions/auditDependencies_.json
|
|
13
|
-
var
|
|
14
|
+
var _e = [
|
|
14
15
|
{
|
|
15
16
|
id: "GHSA-ch52-4w7c-c8xp",
|
|
16
17
|
reason: "'http-cache-semantics', used by the licence checker, which only reads the npm registry locally, with no shared cache to leak from",
|
|
@@ -26,92 +27,92 @@ var me = [
|
|
|
26
27
|
reason: "'braces', used by ESLint's file matching in dpuse-app, which only reads glob patterns from the project's own config",
|
|
27
28
|
reviewBy: "2026-12-31"
|
|
28
29
|
}
|
|
29
|
-
],
|
|
30
|
-
async function
|
|
30
|
+
], ve = /* @__PURE__ */ new Set(["critical", "high"]);
|
|
31
|
+
async function ye() {
|
|
31
32
|
try {
|
|
32
33
|
s("Audit Dependencies");
|
|
33
|
-
let e = await
|
|
34
|
-
|
|
34
|
+
let e = await S("package.json");
|
|
35
|
+
re.has(e.name ?? "") ? C(`1️⃣ Shipped dependencies NOT checked: ${e.name ?? ""} is a development-only tool`) : await o("1️⃣ Check shipped dependencies for any vulnerability", "npm", ["audit", "--omit=dev"]);
|
|
35
36
|
let t = await n("2️⃣ Check all dependencies for high or critical vulnerabilities", "npm", ["audit", "--json"]), r = JSON.parse(t);
|
|
36
37
|
if (r.error !== void 0) throw Error(r.error.summary);
|
|
37
|
-
let i =
|
|
38
|
+
let i = xe(Ce(r));
|
|
38
39
|
if (i.length > 0) throw Error(`${String(i.length)} high or critical vulnerabilities found`);
|
|
39
|
-
|
|
40
|
+
b("Dependencies audited");
|
|
40
41
|
} catch (e) {
|
|
41
42
|
console.error("❌ Error auditing dependencies", e), process.exit(1);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
async function
|
|
45
|
+
async function be(e) {
|
|
45
46
|
let t = JSON.parse(await n(e, "npm", ["audit", "--json"]));
|
|
46
47
|
if (t.error !== void 0) {
|
|
47
48
|
console.warn(`⚠️ Could not check the allow list: ${t.error.summary}`);
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
51
|
let r = 0;
|
|
51
|
-
for (let e of
|
|
52
|
-
let t =
|
|
52
|
+
for (let e of Ce(t)) {
|
|
53
|
+
let t = ve.has(e.severity) ? Se(e) : void 0;
|
|
53
54
|
t !== void 0 && (console.warn(`⚠️ ${t.id} ('${e.name}') is on the allow list, so the CI audit ignores it: ${t.reason}`), r++);
|
|
54
55
|
}
|
|
55
56
|
r === 0 && console.info("ℹ️ None of the reported advisories are on the allow list");
|
|
56
57
|
}
|
|
57
|
-
function
|
|
58
|
+
function xe(e) {
|
|
58
59
|
let t = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), n = [];
|
|
59
60
|
for (let r of e) {
|
|
60
|
-
if (!
|
|
61
|
-
let e =
|
|
61
|
+
if (!ve.has(r.severity)) continue;
|
|
62
|
+
let e = Se(r);
|
|
62
63
|
e === void 0 ? (console.error(`❌ ${r.severity} '${r.name}': ${r.title} (${r.url})`), n.push(r)) : e.reviewBy < t ? console.warn(`⚠️ Ignored ${e.id}, but its review date ${e.reviewBy} has passed: ${e.reason}`) : console.info(`ℹ️ Ignored ${e.id}: ${e.reason}`);
|
|
63
64
|
}
|
|
64
65
|
return n;
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
+
function Se(e) {
|
|
67
68
|
let t = e.url.slice(e.url.lastIndexOf("/") + 1);
|
|
68
|
-
return
|
|
69
|
+
return _e.find((e) => e.id === t);
|
|
69
70
|
}
|
|
70
|
-
function
|
|
71
|
+
function Ce(e) {
|
|
71
72
|
let t = /* @__PURE__ */ new Map(), n = Object.values(e.vulnerabilities ?? {});
|
|
72
73
|
for (let e of n) for (let n of e.via) typeof n != "string" && t.set(n.url, n);
|
|
73
74
|
return t.values().toArray();
|
|
74
75
|
}
|
|
75
76
|
//#endregion
|
|
76
77
|
//#region src/actions/buildProject.ts
|
|
77
|
-
var
|
|
78
|
-
async function
|
|
78
|
+
var we = "build:wasm";
|
|
79
|
+
async function Te() {
|
|
79
80
|
try {
|
|
80
|
-
s("Build Project"), await
|
|
81
|
+
s("Build Project"), await Ee("1️⃣ ", await S("package.json")), b("Project built");
|
|
81
82
|
} catch (e) {
|
|
82
83
|
console.error("❌ Error building project", e), process.exit(1);
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
|
-
async function
|
|
86
|
-
t.scripts?.[
|
|
86
|
+
async function Ee(e, t) {
|
|
87
|
+
t.scripts?.[we] != null && await o(`${e} Build WebAssembly`, "npm", ["run", we]), await o(`${e} Bundle project`, "vite", ["build"]);
|
|
87
88
|
}
|
|
88
89
|
//#endregion
|
|
89
90
|
//#region src/actions/checkConfigFiles.ts
|
|
90
|
-
var
|
|
91
|
-
async function
|
|
91
|
+
var E = "@dpuse/dpuse-development/prettierrc", De = "dpuse-development";
|
|
92
|
+
async function Oe() {
|
|
92
93
|
try {
|
|
93
|
-
s("Check configuration files"),
|
|
94
|
-
let t = await
|
|
95
|
-
await
|
|
94
|
+
s("Check configuration files"), C("1️⃣ Check individual files");
|
|
95
|
+
let t = await S("config.json"), n = await S("package.json"), r = n.private === !0, i = m(t.id), a = T.dirname(de(import.meta.url));
|
|
96
|
+
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 ke(i, a), await D(a, "LICENSE"), await je(i, a), await Me(i, a), await Ne(i, a), await Ie(i, a), Ae(i, n);
|
|
96
97
|
let o = await e(v) !== null;
|
|
97
|
-
o && await
|
|
98
|
+
o && await D(a, "rust-toolchain.toml"), await D(a, ".github/dependabot.yml", [`.github/dependabot${r ? ".private" : ""}${o ? ".rust" : ""}.yml`]), r ? await Pe(a) : (await Fe(a), await D(a, "SECURITY.md", [], (e) => e.replaceAll(De, () => t.id))), b("Configuration files checked");
|
|
98
99
|
} catch (e) {
|
|
99
100
|
console.error("❌ Error checking configuration files", e), process.exit(1);
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
|
-
async function
|
|
103
|
+
async function ke(e, t) {
|
|
103
104
|
["github"].includes(e.typeId) ? console.info("ℹ️ File 'eslint.config.js' is NOT required by this project") : [
|
|
104
105
|
"app",
|
|
105
106
|
"api",
|
|
106
107
|
"development",
|
|
107
108
|
"eslint",
|
|
108
109
|
"kb"
|
|
109
|
-
].includes(e.typeId) ? console.info("⚠️ File 'eslint.config.js' is UNIQUE to this project") : await
|
|
110
|
+
].includes(e.typeId) ? console.info("⚠️ File 'eslint.config.js' is UNIQUE to this project") : await D(t, "eslint.config.js", ["eslint.config.default.js"]);
|
|
110
111
|
}
|
|
111
|
-
function
|
|
112
|
-
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 ===
|
|
112
|
+
function Ae(e, t) {
|
|
113
|
+
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}'`);
|
|
113
114
|
}
|
|
114
|
-
async function
|
|
115
|
+
async function je(e, t) {
|
|
115
116
|
["github"].includes(e.typeId) ? console.info("ℹ️ File 'tsconfig.json' is NOT required by this project") : [
|
|
116
117
|
"connector",
|
|
117
118
|
"cookbook",
|
|
@@ -120,16 +121,17 @@ async function Oe(e, t) {
|
|
|
120
121
|
"presenter",
|
|
121
122
|
"shared",
|
|
122
123
|
"tool"
|
|
123
|
-
].includes(e.typeId) ? await
|
|
124
|
+
].includes(e.typeId) ? await D(t, "tsconfig.json") : console.info("⚠️ File 'tsconfig.json' is UNIQUE to this project");
|
|
124
125
|
}
|
|
125
|
-
async function
|
|
126
|
-
["github"].includes(e.typeId) ? console.info("ℹ️ File 'scripts/tsconfig.json' is NOT required by this project") : await
|
|
126
|
+
async function Me(e, t) {
|
|
127
|
+
["github"].includes(e.typeId) ? console.info("ℹ️ File 'scripts/tsconfig.json' is NOT required by this project") : await D(t, "scripts/tsconfig.json");
|
|
127
128
|
}
|
|
128
|
-
async function
|
|
129
|
+
async function Ne(e, t) {
|
|
129
130
|
if ([
|
|
130
131
|
"eslint",
|
|
131
132
|
"github",
|
|
132
|
-
"kb"
|
|
133
|
+
"kb",
|
|
134
|
+
"resources"
|
|
133
135
|
].includes(e.typeId)) console.info("ℹ️ File 'vite.config.ts' is NOT required by this project");
|
|
134
136
|
else if ([
|
|
135
137
|
"app",
|
|
@@ -148,26 +150,26 @@ async function Ae(e, t) {
|
|
|
148
150
|
break;
|
|
149
151
|
default: n = ["vite.config.default.ts"];
|
|
150
152
|
}
|
|
151
|
-
await
|
|
153
|
+
await D(t, "vite.config.ts", n);
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
|
-
async function
|
|
155
|
-
for (let n of [".github/workflows/ci.yml", ".github/workflows/publish.yml"]) await e(n) !== null && await
|
|
156
|
+
async function Pe(t) {
|
|
157
|
+
for (let n of [".github/workflows/ci.yml", ".github/workflows/publish.yml"]) await e(n) !== null && await D(t, n);
|
|
156
158
|
console.info("ℹ️ CodeQL and Scorecard workflows and file 'SECURITY.md' are NOT required by this project");
|
|
157
159
|
}
|
|
158
|
-
async function
|
|
159
|
-
await
|
|
160
|
+
async function Fe(e) {
|
|
161
|
+
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");
|
|
160
162
|
}
|
|
161
|
-
async function
|
|
163
|
+
async function Ie(e, t) {
|
|
162
164
|
[
|
|
163
165
|
"app",
|
|
164
166
|
"api",
|
|
165
167
|
"github",
|
|
166
168
|
"kb"
|
|
167
|
-
].includes(e.typeId) ? console.info("ℹ️ File 'vitest.config.ts' is NOT required by this project") : await
|
|
169
|
+
].includes(e.typeId) ? console.info("ℹ️ File 'vitest.config.ts' is NOT required by this project") : await D(t, "vitest.config.ts");
|
|
168
170
|
}
|
|
169
|
-
async function
|
|
170
|
-
let i =
|
|
171
|
+
async function D(e, t, n = [], r = (e) => e) {
|
|
172
|
+
let i = T.resolve(process.cwd(), t), o = n.length > 0 ? n : [t], s;
|
|
171
173
|
try {
|
|
172
174
|
s = await a(i);
|
|
173
175
|
} catch (e) {
|
|
@@ -178,7 +180,7 @@ async function k(e, t, n = [], r = (e) => e) {
|
|
|
178
180
|
return;
|
|
179
181
|
}
|
|
180
182
|
for (let n of o) {
|
|
181
|
-
let i =
|
|
183
|
+
let i = T.resolve(e, `../${n}`), o = r(await a(i));
|
|
182
184
|
if (s === o) {
|
|
183
185
|
console.info(`ℹ️ File '${t}' is the same as '${n}'`);
|
|
184
186
|
return;
|
|
@@ -188,16 +190,16 @@ async function k(e, t, n = [], r = (e) => e) {
|
|
|
188
190
|
}
|
|
189
191
|
//#endregion
|
|
190
192
|
//#region src/actions/checkDependencies.ts
|
|
191
|
-
async function
|
|
193
|
+
async function Le() {
|
|
192
194
|
try {
|
|
193
|
-
s("Check Dependencies"), await o("1️⃣ Check using 'npm outdated'", "npm", ["outdated"], !0),
|
|
195
|
+
s("Check Dependencies"), await o("1️⃣ Check using 'npm outdated'", "npm", ["outdated"], !0), C("2️⃣ Check using 'npm-check-updates'");
|
|
194
196
|
let e = {};
|
|
195
197
|
try {
|
|
196
|
-
e = await
|
|
198
|
+
e = await S(T.resolve(process.cwd(), ".ncurc.json"));
|
|
197
199
|
} catch (e) {
|
|
198
200
|
if (e.code !== "ENOENT") throw e;
|
|
199
201
|
}
|
|
200
|
-
await
|
|
202
|
+
await fe({
|
|
201
203
|
interactive: !0,
|
|
202
204
|
upgrade: !0,
|
|
203
205
|
dep: "dev,prod,peer,optional",
|
|
@@ -214,13 +216,13 @@ async function Pe() {
|
|
|
214
216
|
"fix",
|
|
215
217
|
"--no-strict-allow-scripts",
|
|
216
218
|
"--no-fund"
|
|
217
|
-
], !0), await
|
|
218
|
-
let t = await
|
|
219
|
+
], !0), await be("4️⃣ Name the advisories above that the CI audit ignores");
|
|
220
|
+
let t = await Re();
|
|
219
221
|
t.length > 0 ? await o("5️⃣ Move install-script pins to installed versions", "npm", [
|
|
220
222
|
"install-scripts",
|
|
221
223
|
"approve",
|
|
222
224
|
...t
|
|
223
|
-
]) :
|
|
225
|
+
]) : C("5️⃣ No pinned install-script approvals to move"), process.platform === "darwin" ? await o("6️⃣ Remove unused install-script entries", "npm", ["install-scripts", "prune"]) : C("6️⃣ Skipped removing unused install-script entries (macOS only)"), t.length > 0 && await o("7️⃣ Run install scripts skipped in steps 3 and 4", "npm", [
|
|
224
226
|
"rebuild",
|
|
225
227
|
...t,
|
|
226
228
|
"--no-strict-allow-scripts"
|
|
@@ -229,61 +231,61 @@ async function Pe() {
|
|
|
229
231
|
"--strict-allow-scripts",
|
|
230
232
|
"--no-audit",
|
|
231
233
|
"--no-fund"
|
|
232
|
-
]),
|
|
234
|
+
]), b("Dependencies checked");
|
|
233
235
|
} catch (e) {
|
|
234
236
|
console.error("❌ Error checking dependencies", e), process.exit(1);
|
|
235
237
|
}
|
|
236
238
|
}
|
|
237
|
-
async function
|
|
238
|
-
let { allowScripts: e = {} } = await
|
|
239
|
+
async function Re() {
|
|
240
|
+
let { allowScripts: e = {} } = await S(T.resolve(process.cwd(), "package.json")), t = Object.entries(e).filter(([e, t]) => t && e.lastIndexOf("@") > 0).map(([e]) => e.slice(0, e.lastIndexOf("@")));
|
|
239
241
|
return [...new Set(t)];
|
|
240
242
|
}
|
|
241
243
|
//#endregion
|
|
242
244
|
//#region src/actions/checkProject.ts
|
|
243
|
-
async function
|
|
244
|
-
await
|
|
245
|
+
async function ze() {
|
|
246
|
+
await Oe(), await Le();
|
|
245
247
|
}
|
|
246
248
|
//#endregion
|
|
247
249
|
//#region src/actions/documentActions.ts
|
|
248
|
-
var
|
|
250
|
+
var Be = "<!-- SUPPORTED_ACTIONS_START -->", Ve = "<!-- SUPPORTED_ACTIONS_END -->", He = "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.", Ue = {
|
|
249
251
|
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.",
|
|
250
252
|
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.",
|
|
251
253
|
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.",
|
|
252
254
|
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."
|
|
253
|
-
},
|
|
254
|
-
async function
|
|
255
|
+
}, We = "The table below lists all connector actions and highlights those supported by this connector.";
|
|
256
|
+
async function Ge() {
|
|
255
257
|
try {
|
|
256
|
-
s("Document Actions"),
|
|
257
|
-
let e = (await
|
|
258
|
-
await _(i,
|
|
258
|
+
s("Document Actions"), C("1️⃣ Insert actions description and table into 'README.md'");
|
|
259
|
+
let e = (await S("config.json")).actionNames ?? [], t = r(e), n = g(e), i = `## Supported Actions\n\n${He}\n\n${Ue[t]} ${We}\n\n${n}`;
|
|
260
|
+
await _(i, Be, Ve), b("Actions documented");
|
|
259
261
|
} catch (e) {
|
|
260
262
|
console.error("❌ Error documenting actions", e), process.exit(1);
|
|
261
263
|
}
|
|
262
264
|
}
|
|
263
265
|
//#endregion
|
|
264
266
|
//#region src/actions/documentContributingLicense.ts
|
|
265
|
-
async function
|
|
267
|
+
async function Ke() {
|
|
266
268
|
try {
|
|
267
269
|
s("Document Contributing & License");
|
|
268
|
-
let [e, t] = await Promise.all([
|
|
269
|
-
|
|
270
|
+
let [e, t] = await Promise.all([S("package.json"), S("config.json")]), { owner: n, repository: r } = x(e, "document contributing and license"), i = qe(e), a = Je(t.firstCreatedAt);
|
|
271
|
+
C("1️⃣ Insert contributing and license content into 'README.md'"), await l(), await _(Ye(n, r, i, a), te, ae), b("Contributing & license documented");
|
|
270
272
|
} catch (e) {
|
|
271
273
|
console.error("❌ Error documenting contributing and license", e), process.exit(1);
|
|
272
274
|
}
|
|
273
275
|
}
|
|
274
|
-
function
|
|
276
|
+
function qe(e) {
|
|
275
277
|
let t = e.author, n = typeof t == "string" ? t : t?.name;
|
|
276
278
|
if (n == null || n === "") throw Error("package.json 'author' field is required to document contributing and license.");
|
|
277
279
|
let r = n.indexOf("<"), i = r === -1 ? -1 : n.indexOf(">", r);
|
|
278
280
|
return i === -1 ? n.trim() : [n.slice(0, r).trim(), n.slice(i + 1).trim()].filter((e) => e !== "").join(" ");
|
|
279
281
|
}
|
|
280
|
-
function
|
|
282
|
+
function Je(e) {
|
|
281
283
|
let t = (/* @__PURE__ */ new Date()).getFullYear();
|
|
282
284
|
if (e == null) return String(t);
|
|
283
285
|
let n = new Date(e).getFullYear();
|
|
284
286
|
return n === t ? String(t) : `${String(n)}-present`;
|
|
285
287
|
}
|
|
286
|
-
function
|
|
288
|
+
function Ye(e, t, n, r) {
|
|
287
289
|
return `## Contributing
|
|
288
290
|
|
|
289
291
|
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.
|
|
@@ -298,8 +300,8 @@ This project is licensed under the MIT License, permitting free use, modificatio
|
|
|
298
300
|
}
|
|
299
301
|
//#endregion
|
|
300
302
|
//#region src/utilities/rustCrates.ts
|
|
301
|
-
var
|
|
302
|
-
async function
|
|
303
|
+
var O = "licenses/cargoMetadata.json", k = "licenses/cargoTree.txt", Xe = 1e3, Ze = 1e4, Qe = "dpuse-development (https://github.com/dpuse/dpuse-development)", $e = /^(?:copying|licen[cs]e|unlicense)/i, et = "wasm32-unknown-unknown";
|
|
304
|
+
async function tt(n, r) {
|
|
303
305
|
if (await e("rust/Cargo.toml") === null) return null;
|
|
304
306
|
let i = [
|
|
305
307
|
"--manifest-path",
|
|
@@ -312,22 +314,22 @@ async function Qe(n, r) {
|
|
|
312
314
|
"--edges",
|
|
313
315
|
"normal,no-proc-macro",
|
|
314
316
|
"--target",
|
|
315
|
-
|
|
317
|
+
et,
|
|
316
318
|
"--prefix",
|
|
317
319
|
"depth",
|
|
318
320
|
"--format",
|
|
319
321
|
"{p}|{l}|{r}"
|
|
320
322
|
];
|
|
321
|
-
await t(n, "cargo", o,
|
|
323
|
+
await t(n, "cargo", o, k), await t(n, "cargo", [
|
|
322
324
|
"metadata",
|
|
323
325
|
...i,
|
|
324
326
|
"--format-version",
|
|
325
327
|
"1",
|
|
326
328
|
"--filter-platform",
|
|
327
|
-
|
|
328
|
-
],
|
|
329
|
-
let s =
|
|
330
|
-
await
|
|
329
|
+
et
|
|
330
|
+
], O);
|
|
331
|
+
let s = nt(await a(k)), c = await S(O);
|
|
332
|
+
await w.rm(k, { force: !0 }), await w.rm(O, { force: !0 });
|
|
331
333
|
let l = /* @__PURE__ */ new Map();
|
|
332
334
|
for (let e of s) e.isOwn || l.has(`${e.name}@${e.version}`) || l.set(`${e.name}@${e.version}`, {
|
|
333
335
|
name: e.name,
|
|
@@ -340,9 +342,9 @@ async function Qe(n, r) {
|
|
|
340
342
|
latestPublishedDate: ""
|
|
341
343
|
});
|
|
342
344
|
let u = l.values().toArray();
|
|
343
|
-
|
|
344
|
-
for (let e of u) e.licenseFiles = await
|
|
345
|
-
return await
|
|
345
|
+
rt(u, r);
|
|
346
|
+
for (let e of u) e.licenseFiles = await ot(e, c);
|
|
347
|
+
return await st(n, u), {
|
|
346
348
|
crates: u,
|
|
347
349
|
treeItems: s.map(({ name: e, version: t, depth: n, isOwn: r }) => ({
|
|
348
350
|
name: e,
|
|
@@ -352,7 +354,7 @@ async function Qe(n, r) {
|
|
|
352
354
|
}))
|
|
353
355
|
};
|
|
354
356
|
}
|
|
355
|
-
function
|
|
357
|
+
function nt(e) {
|
|
356
358
|
let t = [];
|
|
357
359
|
for (let n of e.split("\n")) {
|
|
358
360
|
let [e = "", r = "", i = ""] = n.trim().split("|", 3), a = /^\d+/.exec(e)?.[0];
|
|
@@ -369,49 +371,49 @@ function $e(e) {
|
|
|
369
371
|
}
|
|
370
372
|
return t;
|
|
371
373
|
}
|
|
372
|
-
function
|
|
373
|
-
let n = t.split(";").filter((e) =>
|
|
374
|
+
function rt(e, t) {
|
|
375
|
+
let n = t.split(";").filter((e) => it(e)), r = e.filter((e) => !at(e.licenseExpression, n));
|
|
374
376
|
if (r.length === 0) return;
|
|
375
377
|
let i = r.map((e) => `${e.name}@${e.version} (${e.licenseExpression === "" ? "no licence" : e.licenseExpression})`).join(", ");
|
|
376
378
|
throw Error(`Rust crates with licences not allowed: ${i}.`);
|
|
377
379
|
}
|
|
378
|
-
function
|
|
380
|
+
function it(e) {
|
|
379
381
|
try {
|
|
380
|
-
return
|
|
382
|
+
return he(e, [e]);
|
|
381
383
|
} catch {
|
|
382
384
|
return !1;
|
|
383
385
|
}
|
|
384
386
|
}
|
|
385
|
-
function
|
|
387
|
+
function at(e, t) {
|
|
386
388
|
try {
|
|
387
|
-
return
|
|
389
|
+
return he(e.replaceAll("/", " OR "), t);
|
|
388
390
|
} catch {
|
|
389
391
|
return !1;
|
|
390
392
|
}
|
|
391
393
|
}
|
|
392
|
-
async function
|
|
394
|
+
async function ot(e, t) {
|
|
393
395
|
let n = t.packages.find((t) => t.name === e.name && t.version === e.version);
|
|
394
396
|
if (n == null) return [];
|
|
395
|
-
let r =
|
|
396
|
-
await
|
|
397
|
+
let r = T.dirname(n.manifest_path), i = (await w.readdir(r)).filter((e) => $e.test(e)).toSorted((e, t) => e.localeCompare(t, "en"));
|
|
398
|
+
await w.mkdir("licenses/downloads", { recursive: !0 });
|
|
397
399
|
let a = [];
|
|
398
400
|
for (let t of i) {
|
|
399
401
|
let n = `downloads/${e.name}@${e.version}-${t}`;
|
|
400
|
-
await
|
|
402
|
+
await w.copyFile(T.join(r, t), T.join("licenses", n)), a.push({
|
|
401
403
|
label: t,
|
|
402
404
|
path: n
|
|
403
405
|
});
|
|
404
406
|
}
|
|
405
407
|
return a;
|
|
406
408
|
}
|
|
407
|
-
async function
|
|
408
|
-
|
|
409
|
+
async function st(e, t) {
|
|
410
|
+
C(`${e} - fetch release dates from crates.io`);
|
|
409
411
|
for (let [e, n] of t.entries()) {
|
|
410
|
-
e > 0 && await
|
|
412
|
+
e > 0 && await me(Xe), console.info(`⚙️ Fetching '${n.name}' (${String(e + 1)} of ${String(t.length)})...`);
|
|
411
413
|
try {
|
|
412
414
|
let e = await fetch(`https://crates.io/api/v1/crates/${encodeURIComponent(n.name)}`, {
|
|
413
|
-
headers: { "User-Agent":
|
|
414
|
-
signal: AbortSignal.timeout(
|
|
415
|
+
headers: { "User-Agent": Qe },
|
|
416
|
+
signal: AbortSignal.timeout(Ze)
|
|
415
417
|
});
|
|
416
418
|
if (!e.ok) continue;
|
|
417
419
|
let t = await e.json(), r = new Map((t.versions ?? []).map((e) => [e.num, e.created_at]));
|
|
@@ -421,77 +423,77 @@ async function it(e, t) {
|
|
|
421
423
|
}
|
|
422
424
|
//#endregion
|
|
423
425
|
//#region src/actions/documentDependencies.ts
|
|
424
|
-
var
|
|
425
|
-
async function
|
|
426
|
+
var A = "<!-- DEPENDENCY_LICENSES_START -->", j = "<!-- DEPENDENCY_LICENSES_END -->", M = "## Dependency Licenses", ct = `bundle-analysis-reports/${se}`, N = "licenses/licenseTree.json", lt = "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.", ut = `The dependency tree below lists every package in this project — direct and transitive — along with its installed version, release date, and update status. ${lt}`, dt = `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. ${lt}`;
|
|
427
|
+
async function ft(e = "MIT") {
|
|
426
428
|
try {
|
|
427
429
|
s("Document Dependencies");
|
|
428
|
-
let n = await
|
|
429
|
-
if (
|
|
430
|
-
await
|
|
430
|
+
let n = await S("package.json"), r = n.name ?? "";
|
|
431
|
+
if (re.has(r)) {
|
|
432
|
+
await pt(r), b("Dependencies documented");
|
|
431
433
|
return;
|
|
432
434
|
}
|
|
433
435
|
await f("1️⃣ Clear downloaded licenses", "licenses/downloads");
|
|
434
|
-
let i = await
|
|
436
|
+
let i = await St(), a = await Ct();
|
|
435
437
|
if (a === null) {
|
|
436
|
-
let r =
|
|
437
|
-
await
|
|
438
|
+
let r = Dt(i);
|
|
439
|
+
await xt("2️⃣ Identify production licenses", e, [n.name ?? "", ...r], !0), await t("3️⃣ Identify transitive dependencies", "npm", [
|
|
438
440
|
"ls",
|
|
439
441
|
"--all",
|
|
440
442
|
"--json",
|
|
441
443
|
"--omit=dev"
|
|
442
|
-
],
|
|
444
|
+
], N), await mt("4️⃣ ", e, new Set(r));
|
|
443
445
|
} else {
|
|
444
|
-
let r =
|
|
445
|
-
await
|
|
446
|
+
let r = wt(a, i), o = Tt(i), s = o.filter((e) => !r.has(e));
|
|
447
|
+
await xt("2️⃣ Identify shipped licenses", e, [n.name ?? "", ...s], !1), Et(r, new Set(o)), await t("3️⃣ Identify transitive dependencies", "npm", [
|
|
446
448
|
"ls",
|
|
447
449
|
"--all",
|
|
448
450
|
"--json"
|
|
449
|
-
],
|
|
450
|
-
let c = await
|
|
451
|
+
], N, !0);
|
|
452
|
+
let c = await tt("4️⃣ Identify Rust crates compiled into the WebAssembly", e), l = {
|
|
451
453
|
allowedLicenses: e,
|
|
452
|
-
productionNames:
|
|
454
|
+
productionNames: yt(n),
|
|
453
455
|
rustCrates: c,
|
|
454
456
|
shippedKeys: r
|
|
455
457
|
};
|
|
456
|
-
await
|
|
458
|
+
await ht(c === null ? "4️⃣ " : "5️⃣ ", l);
|
|
457
459
|
}
|
|
458
|
-
|
|
460
|
+
b("Dependencies documented");
|
|
459
461
|
} catch (e) {
|
|
460
462
|
console.error("❌ Error documenting dependencies", e), process.exit(1);
|
|
461
463
|
}
|
|
462
464
|
}
|
|
463
|
-
async function
|
|
464
|
-
|
|
465
|
+
async function pt(e) {
|
|
466
|
+
C(`1️⃣ Skip: ${e} is a development-only tool and is never part of a production release.`);
|
|
465
467
|
let t = `> [!WARNING]\n> Dependency licenses are not documented here: ${e} is a development-only tool and is never part of a production release.`;
|
|
466
|
-
await _(`${
|
|
468
|
+
await _(`${M}\n\n${t}`, A, j);
|
|
467
469
|
}
|
|
468
|
-
async function
|
|
469
|
-
|
|
470
|
-
let r = await
|
|
471
|
-
for (let e of i.values()) a +=
|
|
470
|
+
async function mt(e, t, n) {
|
|
471
|
+
C(`${e} Insert licenses into 'README.md'`);
|
|
472
|
+
let r = await S(N), i = await bt(), a = `${jt(t, !1)}\n\n|Dependency|Version|License(s)|Document|\n|:-|:-:|:-|:-|\n`;
|
|
473
|
+
for (let e of i.values()) a += F(e);
|
|
472
474
|
let o = [];
|
|
473
|
-
r.dependencies != null &&
|
|
474
|
-
let s = `${
|
|
475
|
-
await _(`${
|
|
476
|
-
}
|
|
477
|
-
async function
|
|
478
|
-
|
|
479
|
-
let { allowedLicenses: n, productionNames: r, rustCrates: i, shippedKeys: a } = t, o = await
|
|
480
|
-
for (let e of o.values().toArray().toSorted(
|
|
481
|
-
for (let e of s.values().toArray().toSorted(
|
|
482
|
-
let d = await
|
|
483
|
-
|
|
475
|
+
r.dependencies != null && I(r.dependencies, i, n, o, 0);
|
|
476
|
+
let s = `${ut}\n\n${o.join("\n")}`;
|
|
477
|
+
await _(`${M}\n\n${a.trimEnd()}\n\n### Dependency Tree\n\n${s}`, A, j);
|
|
478
|
+
}
|
|
479
|
+
async function ht(e, t) {
|
|
480
|
+
C(`${e} Insert licenses into 'README.md'`);
|
|
481
|
+
let { allowedLicenses: n, productionNames: r, rustCrates: i, shippedKeys: a } = t, o = await bt(), s = new Map((i?.crates ?? []).map((e) => [`${e.name}@${e.version}`, _t(e)])), c = i !== null, l = c ? "|Type|Dependency|Version|License(s)|Document|\n|:-|:-|:-:|:-|:-|" : "|Dependency|Version|License(s)|Document|\n|:-|:-:|:-|:-|", u = `${jt(n, !0, c)}\n\n${l}\n`;
|
|
482
|
+
for (let e of o.values().toArray().toSorted(gt)) u += F(e, c ? "JavaScript" : void 0);
|
|
483
|
+
for (let e of s.values().toArray().toSorted(gt)) u += F(e, "Rust");
|
|
484
|
+
let d = await S(N), f = Object.entries(d.dependencies ?? {}).toSorted(([e], [t]) => Number(!r.has(e)) - Number(!r.has(t))), p = [];
|
|
485
|
+
L(f, {
|
|
484
486
|
licensesByKey: o,
|
|
485
487
|
shippedKeys: a,
|
|
486
488
|
shownKeys: /* @__PURE__ */ new Set()
|
|
487
489
|
}, p, 0, !1);
|
|
488
|
-
let m = p.length === 0 ? "None." : p.join("\n"), h = (i?.treeItems ?? []).map((e) =>
|
|
489
|
-
await _(`${
|
|
490
|
+
let m = p.length === 0 ? "None." : p.join("\n"), h = (i?.treeItems ?? []).map((e) => vt(e, s)).join("\n"), g = c ? `${dt}\n\n#### JavaScript\n\n${m}\n\n#### Rust\n\n${h}` : `${dt}\n\n${m}`;
|
|
491
|
+
await _(`${M}\n\n${u.trimEnd()}\n\n### Dependency Tree\n\n${g}`, A, j);
|
|
490
492
|
}
|
|
491
|
-
function
|
|
493
|
+
function gt(e, t) {
|
|
492
494
|
return e.name.localeCompare(t.name, "en") || e.installedVersion.localeCompare(t.installedVersion, "en");
|
|
493
495
|
}
|
|
494
|
-
function
|
|
496
|
+
function _t(e) {
|
|
495
497
|
return {
|
|
496
498
|
name: e.name,
|
|
497
499
|
repository: e.repository,
|
|
@@ -504,27 +506,27 @@ function mt(e) {
|
|
|
504
506
|
licenseFiles: e.licenseFiles
|
|
505
507
|
};
|
|
506
508
|
}
|
|
507
|
-
function
|
|
509
|
+
function vt(e, t) {
|
|
508
510
|
let n = " ".repeat(e.depth);
|
|
509
|
-
return e.isOwn ? `${n}- **${e.name}** ${e.version} — this project's Rust code, compiled into its WebAssembly` :
|
|
511
|
+
return e.isOwn ? `${n}- **${e.name}** ${e.version} — this project's Rust code, compiled into its WebAssembly` : R(e.name, e.version, t.get(`${e.name}@${e.version}`), n);
|
|
510
512
|
}
|
|
511
|
-
function
|
|
513
|
+
function yt(e) {
|
|
512
514
|
return /* @__PURE__ */ new Set([
|
|
513
515
|
...Object.keys(e.dependencies ?? {}),
|
|
514
516
|
...Object.keys(e.optionalDependencies ?? {}),
|
|
515
517
|
...Object.keys(e.peerDependencies ?? {})
|
|
516
518
|
]);
|
|
517
519
|
}
|
|
518
|
-
async function
|
|
519
|
-
let e = await
|
|
520
|
-
for (let [n, r] of Object.entries(e)) t.set(n,
|
|
520
|
+
async function bt() {
|
|
521
|
+
let e = await S("licenses/licenses.json"), t = /* @__PURE__ */ new Map();
|
|
522
|
+
for (let [n, r] of Object.entries(e)) t.set(n, Nt(n, r));
|
|
521
523
|
return await Promise.all(t.values().map(async (e) => {
|
|
522
|
-
let t = await
|
|
524
|
+
let t = await Pt(e.name, e.installedVersion);
|
|
523
525
|
e.latestVersion = t.latestVersion, e.latestPublishedDate = t.latestPublishedDate, e.publishedDate = t.publishedDate;
|
|
524
526
|
})), t;
|
|
525
527
|
}
|
|
526
|
-
async function
|
|
527
|
-
|
|
528
|
+
async function xt(e, t, n, r) {
|
|
529
|
+
C(e), await new Promise((e, i) => {
|
|
528
530
|
let a = {
|
|
529
531
|
start: process.cwd(),
|
|
530
532
|
production: r,
|
|
@@ -536,63 +538,63 @@ async function vt(e, t, n, r) {
|
|
|
536
538
|
excludePackages: n.join(";"),
|
|
537
539
|
out: "licenses/licenses.json"
|
|
538
540
|
};
|
|
539
|
-
|
|
541
|
+
pe(a, (t) => {
|
|
540
542
|
t == null ? e() : i(t);
|
|
541
543
|
});
|
|
542
544
|
});
|
|
543
545
|
}
|
|
544
|
-
async function
|
|
546
|
+
async function St() {
|
|
545
547
|
let t = await e("package-lock.json");
|
|
546
548
|
return t === null ? {} : JSON.parse(t).packages ?? {};
|
|
547
549
|
}
|
|
548
|
-
async function
|
|
549
|
-
let t = await e(
|
|
550
|
+
async function Ct() {
|
|
551
|
+
let t = await e(ct);
|
|
550
552
|
return t === null ? null : JSON.parse(t);
|
|
551
553
|
}
|
|
552
|
-
function
|
|
554
|
+
function wt(e, t) {
|
|
553
555
|
let n = new Set(e.packages);
|
|
554
556
|
for (let r of e.external) {
|
|
555
|
-
let e =
|
|
556
|
-
if (e !== void 0) for (let r of [e, ...
|
|
557
|
+
let e = At(t, "", r);
|
|
558
|
+
if (e !== void 0) for (let r of [e, ...Ot(t, e)]) {
|
|
557
559
|
let e = t[r];
|
|
558
|
-
e?.version !== void 0 && n.add(
|
|
560
|
+
e?.version !== void 0 && n.add(P(r, e));
|
|
559
561
|
}
|
|
560
562
|
}
|
|
561
563
|
return n;
|
|
562
564
|
}
|
|
563
|
-
function
|
|
565
|
+
function Tt(e) {
|
|
564
566
|
let t = /* @__PURE__ */ new Set();
|
|
565
|
-
for (let [n, r] of Object.entries(e)) n !== "" && r.version !== void 0 && t.add(
|
|
567
|
+
for (let [n, r] of Object.entries(e)) n !== "" && r.version !== void 0 && t.add(P(n, r));
|
|
566
568
|
return [...t];
|
|
567
569
|
}
|
|
568
|
-
function
|
|
570
|
+
function Et(e, t) {
|
|
569
571
|
let n = [...e.difference(t)];
|
|
570
572
|
n.length > 0 && console.warn(`⚠️ Not installed, so not checked; rebuild to refresh the record: ${n.join(", ")}`);
|
|
571
573
|
}
|
|
572
|
-
function
|
|
574
|
+
function P(e, t) {
|
|
573
575
|
return `${t.name ?? e.slice(e.lastIndexOf("node_modules/") + 13)}@${String(t.version)}`;
|
|
574
576
|
}
|
|
575
|
-
function
|
|
576
|
-
let t =
|
|
577
|
+
function Dt(e) {
|
|
578
|
+
let t = Ot(e, ""), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
577
579
|
for (let [i, a] of Object.entries(e)) {
|
|
578
580
|
if (i === "" || a.version === void 0) continue;
|
|
579
|
-
let e =
|
|
581
|
+
let e = P(i, a);
|
|
580
582
|
t.has(i) ? n.add(e) : r.add(e);
|
|
581
583
|
}
|
|
582
584
|
return r.values().filter((e) => !n.has(e)).toArray();
|
|
583
585
|
}
|
|
584
|
-
function
|
|
586
|
+
function Ot(e, t) {
|
|
585
587
|
let n = /* @__PURE__ */ new Set(), r = [t];
|
|
586
588
|
for (; r.length > 0;) {
|
|
587
589
|
let t = r.pop() ?? "", i = e[t];
|
|
588
|
-
if (i !== void 0) for (let a of
|
|
589
|
-
let i =
|
|
590
|
+
if (i !== void 0) for (let a of kt(i)) {
|
|
591
|
+
let i = At(e, t, a);
|
|
590
592
|
i === void 0 || n.has(i) || (n.add(i), r.push(i));
|
|
591
593
|
}
|
|
592
594
|
}
|
|
593
595
|
return n;
|
|
594
596
|
}
|
|
595
|
-
function
|
|
597
|
+
function kt(e) {
|
|
596
598
|
let t = Object.keys(e.peerDependencies ?? {}).filter((t) => e.peerDependenciesMeta?.[t]?.optional !== !0);
|
|
597
599
|
return [
|
|
598
600
|
...Object.keys(e.dependencies ?? {}),
|
|
@@ -600,7 +602,7 @@ function Et(e) {
|
|
|
600
602
|
...t
|
|
601
603
|
];
|
|
602
604
|
}
|
|
603
|
-
function
|
|
605
|
+
function At(e, t, n) {
|
|
604
606
|
let r = t;
|
|
605
607
|
for (;;) {
|
|
606
608
|
let t = r === "" ? `node_modules/${n}` : `${r}/node_modules/${n}`, i = e[t];
|
|
@@ -610,14 +612,14 @@ function Dt(e, t, n) {
|
|
|
610
612
|
r = a === -1 ? "" : r.slice(0, a);
|
|
611
613
|
}
|
|
612
614
|
}
|
|
613
|
-
function
|
|
614
|
-
let r =
|
|
615
|
+
function jt(e, t, n = !1) {
|
|
616
|
+
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.";
|
|
615
617
|
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.`;
|
|
616
618
|
}
|
|
617
|
-
function
|
|
619
|
+
function Mt(e) {
|
|
618
620
|
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))}`;
|
|
619
621
|
}
|
|
620
|
-
function
|
|
622
|
+
function Nt(e, t) {
|
|
621
623
|
let n = e.lastIndexOf("@"), r = n > 0 ? e.slice(0, n) : e, i = n > 0 ? e.slice(n + 1) : "";
|
|
622
624
|
return {
|
|
623
625
|
name: r,
|
|
@@ -634,7 +636,7 @@ function At(e, t) {
|
|
|
634
636
|
}]
|
|
635
637
|
};
|
|
636
638
|
}
|
|
637
|
-
async function
|
|
639
|
+
async function Pt(e, t) {
|
|
638
640
|
try {
|
|
639
641
|
let n = await fetch(`https://registry.npmjs.org/${encodeURIComponent(e)}`);
|
|
640
642
|
if (n.ok) {
|
|
@@ -652,40 +654,40 @@ async function jt(e, t) {
|
|
|
652
654
|
publishedDate: ""
|
|
653
655
|
};
|
|
654
656
|
}
|
|
655
|
-
function
|
|
657
|
+
function F(e, t) {
|
|
656
658
|
let n = e.licenseFiles.length === 0 ? "⚠️ No license file" : e.licenseFiles.map((e) => `[${e.label}](licenses/${e.path})`).join(" ");
|
|
657
659
|
return `${t === void 0 ? "" : `|${t}`}|[${e.name}](${e.repository})|${e.installedVersion}|${e.licenseTypes}|${n}|\n`;
|
|
658
660
|
}
|
|
659
|
-
function
|
|
661
|
+
function I(e, t, n, r, i) {
|
|
660
662
|
let a = " ".repeat(i);
|
|
661
663
|
for (let [o, s] of Object.entries(e)) {
|
|
662
664
|
if (s.version === void 0) continue;
|
|
663
665
|
let e = s.version;
|
|
664
|
-
n.has(`${o}@${e}`) || (r.push(
|
|
666
|
+
n.has(`${o}@${e}`) || (r.push(R(o, e, t.get(`${o}@${e}`), a)), s.dependencies != null && I(s.dependencies, t, n, r, i + 1));
|
|
665
667
|
}
|
|
666
668
|
}
|
|
667
|
-
function
|
|
669
|
+
function L(e, t, n, r, i) {
|
|
668
670
|
for (let [a, o] of e) {
|
|
669
671
|
if (o.version === void 0) continue;
|
|
670
672
|
let e = `${a}@${o.version}`, s = Object.entries(o.dependencies ?? {});
|
|
671
673
|
if (!t.shippedKeys.has(e)) {
|
|
672
|
-
|
|
674
|
+
L(s, t, n, r, !0);
|
|
673
675
|
continue;
|
|
674
676
|
}
|
|
675
|
-
i && t.shownKeys.has(e) || (t.shownKeys.add(e), n.push(
|
|
677
|
+
i && t.shownKeys.has(e) || (t.shownKeys.add(e), n.push(R(a, o.version, t.licensesByKey.get(e), " ".repeat(r))), L(s, t, n, r + 1, !1));
|
|
676
678
|
}
|
|
677
679
|
}
|
|
678
|
-
function
|
|
679
|
-
return `${r}- **${n == null ? e : `[${e}](${n.repository})`}** ${t}${
|
|
680
|
+
function R(e, t, n, r) {
|
|
681
|
+
return `${r}- **${n == null ? e : `[${e}](${n.repository})`}** ${t}${Ft(n)}`;
|
|
680
682
|
}
|
|
681
|
-
function
|
|
683
|
+
function Ft(e) {
|
|
682
684
|
if (e == null) return "";
|
|
683
|
-
let t = e.publishedDate ?
|
|
685
|
+
let t = e.publishedDate ? It(e.publishedDate.split("T", 1)[0]) : "";
|
|
684
686
|
if (e.latestVersion === "" || e.latestVersion === e.installedVersion) return t === "" ? "" : ` — ${t}`;
|
|
685
|
-
let n = e.latestPublishedDate ?
|
|
687
|
+
let n = e.latestPublishedDate ? It(e.latestPublishedDate.split("T", 1)[0]) : "", r = n === "" ? `latest: ${e.latestVersion} ❗` : `latest: ${e.latestVersion} — ${n} ❗`;
|
|
686
688
|
return t === "" ? ` — → ${r}` : ` — ${t} → ${r}`;
|
|
687
689
|
}
|
|
688
|
-
function
|
|
690
|
+
function It(e) {
|
|
689
691
|
if (e == null || e === "") return "n/a";
|
|
690
692
|
let t = e.split("T", 1)[0];
|
|
691
693
|
if (t == null || t === "") return "n/a";
|
|
@@ -694,31 +696,31 @@ function Pt(e) {
|
|
|
694
696
|
}
|
|
695
697
|
//#endregion
|
|
696
698
|
//#region src/actions/documentOpening.ts
|
|
697
|
-
var
|
|
698
|
-
async function
|
|
699
|
+
var Lt = "<!-- OPENING_START -->", Rt = "<!-- OPENING_END -->";
|
|
700
|
+
async function zt() {
|
|
699
701
|
try {
|
|
700
|
-
s("Document Opening"),
|
|
701
|
-
let e = await
|
|
702
|
-
await _(c,
|
|
702
|
+
s("Document Opening"), C("1️⃣ Insert opening content into 'README.md'");
|
|
703
|
+
let e = await S("package.json"), t = await S("config.json"), { owner: n, repository: r } = x(e, "document opening"), i = Bt(e), a = Ht(t), o = m(t.id), c = Ut(n, r, i, o.uploadGroupName === void 0 ? void 0 : t.id, o.publishedTo === "npm" ? Vt(e) : void 0, e.description, a);
|
|
704
|
+
await _(c, Lt, Rt), b("Opening documented");
|
|
703
705
|
} catch (e) {
|
|
704
706
|
console.error("❌ Error documenting opening", e), process.exit(1);
|
|
705
707
|
}
|
|
706
708
|
}
|
|
707
|
-
function
|
|
709
|
+
function Bt(e) {
|
|
708
710
|
let t = e.license;
|
|
709
711
|
if (t == null || t === "") throw Error("package.json 'license' field is required to document opening.");
|
|
710
712
|
return t;
|
|
711
713
|
}
|
|
712
|
-
function
|
|
714
|
+
function Vt(e) {
|
|
713
715
|
let t = e.name;
|
|
714
716
|
if (t == null || t === "") throw Error("package.json 'name' field is required to document opening.");
|
|
715
717
|
return t;
|
|
716
718
|
}
|
|
717
|
-
function
|
|
719
|
+
function Ht(e) {
|
|
718
720
|
let t = e.description.en?.trim();
|
|
719
721
|
return t === void 0 || t === "" ? void 0 : t;
|
|
720
722
|
}
|
|
721
|
-
function
|
|
723
|
+
function Ut(e, t, n, r, i, a, o) {
|
|
722
724
|
let s = `https://github.com/${e}/${t}`, c = n.replaceAll("-", "--"), l = encodeURIComponent(`https://api.dpuse.app/configs/${r ?? ""}`);
|
|
723
725
|
return `[](./LICENSE)${r === void 0 ? "" : `\n[](${s}/releases/latest)`}${i === void 0 ? "" : `\n[](https://www.npmjs.com/package/${i})`}
|
|
724
726
|
[](${s}/actions/workflows/ci.yml)${a == null || a === "" ? "" : `\n\n${a}`}
|
|
@@ -739,43 +741,43 @@ In addition, DPUse provides [Tools](https://www.dpuse.app) used by the applicati
|
|
|
739
741
|
}
|
|
740
742
|
//#endregion
|
|
741
743
|
//#region src/actions/documentQualitySecurity.ts
|
|
742
|
-
var
|
|
744
|
+
var Wt = {
|
|
743
745
|
"Branch-Protection": 3,
|
|
744
746
|
"Code-Review": 0,
|
|
745
747
|
Contributors: 0
|
|
746
|
-
},
|
|
748
|
+
}, Gt = /* @__PURE__ */ new Set(["CII-Best-Practices"]), Kt = "coverage/coverage-final.json", qt = "coverage/coverage-summary.json", Jt = 80, Yt = 60, Xt = "code-health-reports/vitest/badge.json", Zt = {
|
|
747
749
|
actions: "GitHub Actions",
|
|
748
750
|
"javascript-typescript": "JavaScript/TypeScript",
|
|
749
751
|
rust: "Rust"
|
|
750
|
-
},
|
|
752
|
+
}, Qt = {
|
|
751
753
|
A: "brightgreen",
|
|
752
754
|
B: "green",
|
|
753
755
|
C: "yellow",
|
|
754
756
|
D: "orange",
|
|
755
757
|
F: "red"
|
|
756
|
-
},
|
|
757
|
-
async function
|
|
758
|
+
}, $t = `${c}/health.json`, en = le(ue);
|
|
759
|
+
async function tn() {
|
|
758
760
|
try {
|
|
759
761
|
s("Document Quality & Security");
|
|
760
|
-
let e = await
|
|
761
|
-
|
|
762
|
-
let a = await
|
|
763
|
-
|
|
764
|
-
let [o, c] = await Promise.all([
|
|
765
|
-
|
|
766
|
-
let d =
|
|
762
|
+
let e = await S("package.json"), t = await nn(e), n = await an(e, t === void 0 ? [] : ["--coverage", Kt]), { owner: r, repository: i } = x(e, "document quality and security");
|
|
763
|
+
C("4️⃣ Read security checks and settings");
|
|
764
|
+
let a = await sn(r, i, e);
|
|
765
|
+
C("5️⃣ Look up OpenSSF Best Practices badge and Scorecard results");
|
|
766
|
+
let [o, c] = await Promise.all([cn(`https://github.com/${r}/${i}`), ln(`github.com/${r}/${i}`)]);
|
|
767
|
+
C("6️⃣ Insert quality and security content into 'README.md'");
|
|
768
|
+
let d = mn(r, i, {
|
|
767
769
|
coveragePercent: t,
|
|
768
770
|
fallowHealth: n,
|
|
769
771
|
securitySettings: a
|
|
770
772
|
}, o, c);
|
|
771
|
-
await l(), await _(d, u,
|
|
773
|
+
await l(), await _(d, u, ie), b("Quality & security documented");
|
|
772
774
|
} catch (e) {
|
|
773
775
|
console.error("❌ Error documenting quality and security", e), process.exit(1);
|
|
774
776
|
}
|
|
775
777
|
}
|
|
776
|
-
async function
|
|
778
|
+
async function nn(t) {
|
|
777
779
|
if (t.devDependencies?.["@vitest/coverage-v8"] == null) {
|
|
778
|
-
|
|
780
|
+
C("1️⃣ Test coverage NOT measured, as '@vitest/coverage-v8' is not installed");
|
|
779
781
|
return;
|
|
780
782
|
}
|
|
781
783
|
await o("1️⃣ Measure test coverage", "vitest", [
|
|
@@ -783,27 +785,27 @@ async function en(t) {
|
|
|
783
785
|
"--passWithNoTests",
|
|
784
786
|
"--coverage"
|
|
785
787
|
]);
|
|
786
|
-
let n = await e(
|
|
788
|
+
let n = await e(qt);
|
|
787
789
|
if (n === null) return;
|
|
788
790
|
let r = JSON.parse(n).total.lines.pct;
|
|
789
|
-
return await
|
|
791
|
+
return await rn(r), r;
|
|
790
792
|
}
|
|
791
|
-
async function
|
|
793
|
+
async function rn(e) {
|
|
792
794
|
let t = [
|
|
793
795
|
"red",
|
|
794
796
|
"yellow",
|
|
795
797
|
"brightgreen"
|
|
796
|
-
], n = Number(e >=
|
|
797
|
-
await i(
|
|
798
|
+
], n = Number(e >= Yt) + Number(e >= Jt);
|
|
799
|
+
await i(Xt, {
|
|
798
800
|
schemaVersion: 1,
|
|
799
801
|
label: "coverage",
|
|
800
802
|
message: `${e.toFixed(1)}%`,
|
|
801
803
|
color: t[n]
|
|
802
804
|
});
|
|
803
805
|
}
|
|
804
|
-
async function
|
|
806
|
+
async function an(e, n) {
|
|
805
807
|
if (e.devDependencies?.fallow == null) {
|
|
806
|
-
|
|
808
|
+
C("2️⃣ Code health NOT measured, as Fallow is not installed"), C("3️⃣ Code health report NOT required");
|
|
807
809
|
return;
|
|
808
810
|
}
|
|
809
811
|
await t("2️⃣ Measure code health", "fallow", [
|
|
@@ -812,32 +814,32 @@ async function nn(e, n) {
|
|
|
812
814
|
"--format",
|
|
813
815
|
"json",
|
|
814
816
|
...n
|
|
815
|
-
],
|
|
816
|
-
let r = await
|
|
817
|
-
return await
|
|
817
|
+
], $t), await t("3️⃣ Write code health report", "fallow", ["--format", "markdown"], ne, !0);
|
|
818
|
+
let r = await S($t);
|
|
819
|
+
return await on(r), r;
|
|
818
820
|
}
|
|
819
|
-
async function
|
|
821
|
+
async function on(e) {
|
|
820
822
|
let { score: t, grade: n } = e.health_score;
|
|
821
823
|
await i(h, {
|
|
822
824
|
schemaVersion: 1,
|
|
823
825
|
label: "fallow",
|
|
824
826
|
message: `${n} (${String(Math.round(t))})`,
|
|
825
|
-
color:
|
|
827
|
+
color: Qt[n] ?? "lightgrey"
|
|
826
828
|
});
|
|
827
829
|
}
|
|
828
|
-
async function
|
|
830
|
+
async function sn(t, n, r) {
|
|
829
831
|
let [i, a, o] = await Promise.all([
|
|
830
832
|
e(".github/workflows/ci.yml"),
|
|
831
833
|
e(".github/dependabot.yml"),
|
|
832
834
|
e(v)
|
|
833
835
|
]), s = await e(".github/workflows/codeql.yml") ?? "", [c, l, u, d] = await Promise.all([
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
836
|
+
z(`repos/${t}/${n}`),
|
|
837
|
+
z(`repos/${t}/${n}/private-vulnerability-reporting`),
|
|
838
|
+
z(`repos/${t}/${n}/vulnerability-alerts`),
|
|
839
|
+
z(`repos/${t}/${n}/commits/main/check-runs?per_page=100`)
|
|
838
840
|
]), f = c === void 0 ? void 0 : JSON.parse(c).security_and_analysis, p = (e) => f?.[e] === void 0 ? void 0 : f[e].status === "enabled", m = new Set((d === void 0 ? [] : JSON.parse(d).check_runs).map((e) => e.app?.slug)), h = a?.match(/package-ecosystem:/g)?.length ?? 0, g = a?.match(/open-pull-requests-limit: 0\b/g)?.length ?? 0;
|
|
839
841
|
return {
|
|
840
|
-
codeQLLanguages: s.matchAll(/- language: ([\w-]+)/g).filter(([, e]) => e !== "rust" || o !== null).map(([, e = ""]) =>
|
|
842
|
+
codeQLLanguages: s.matchAll(/- language: ([\w-]+)/g).filter(([, e]) => e !== "rust" || o !== null).map(([, e = ""]) => Zt[e] ?? e).toArray(),
|
|
841
843
|
codeQLQueries: /queries: ([\w-]+)/.exec(s)?.[1],
|
|
842
844
|
dependabotAlerts: u !== void 0,
|
|
843
845
|
dependabotSecurityUpdates: p("dependabot_security_updates"),
|
|
@@ -854,37 +856,37 @@ async function an(t, n, r) {
|
|
|
854
856
|
testsInCI: i?.includes("npm test") ?? !1
|
|
855
857
|
};
|
|
856
858
|
}
|
|
857
|
-
async function
|
|
859
|
+
async function z(e) {
|
|
858
860
|
try {
|
|
859
|
-
let { stdout: t } = await
|
|
861
|
+
let { stdout: t } = await en("gh", ["api", e]);
|
|
860
862
|
return t;
|
|
861
863
|
} catch (e) {
|
|
862
864
|
if (String(e.stderr).includes("HTTP 404")) return;
|
|
863
865
|
throw e;
|
|
864
866
|
}
|
|
865
867
|
}
|
|
866
|
-
async function
|
|
868
|
+
async function cn(e) {
|
|
867
869
|
let t = await fetch(`https://www.bestpractices.dev/projects.json?url=${encodeURIComponent(e)}`);
|
|
868
870
|
if (!t.ok) throw Error(`OpenSSF Best Practices lookup failed with status ${String(t.status)}.`);
|
|
869
871
|
return (await t.json()).find((t) => t.repo_url === e)?.id;
|
|
870
872
|
}
|
|
871
|
-
async function
|
|
873
|
+
async function ln(e) {
|
|
872
874
|
let t = await fetch(`https://api.scorecard.dev/projects/${e}`);
|
|
873
875
|
if (t.status !== 404) {
|
|
874
876
|
if (!t.ok) throw Error(`OpenSSF Scorecard lookup failed with status ${String(t.status)}.`);
|
|
875
877
|
return await t.json();
|
|
876
878
|
}
|
|
877
879
|
}
|
|
878
|
-
function
|
|
879
|
-
return e.checks.every(({ name: e, score: t }) => t === -1 || t === 10 ||
|
|
880
|
+
function un(e) {
|
|
881
|
+
return e.checks.every(({ name: e, score: t }) => t === -1 || t === 10 || Gt.has(e) || Wt[e] !== void 0 && t >= Wt[e]);
|
|
880
882
|
}
|
|
881
|
-
function
|
|
883
|
+
function dn(e) {
|
|
882
884
|
return e === !1 ? " These are handled manually." : "";
|
|
883
885
|
}
|
|
884
|
-
function
|
|
886
|
+
function B(e) {
|
|
885
887
|
return e === void 0 ? "❔ Unknown" : e ? "✅ On" : "❌ Off";
|
|
886
888
|
}
|
|
887
|
-
function
|
|
889
|
+
function V(e, t) {
|
|
888
890
|
return t.length === 0 ? "" : `### ${e}
|
|
889
891
|
|
|
890
892
|
|Check|Status|What it does|
|
|
@@ -893,90 +895,90 @@ ${t.map((e) => `|${e.join("|")}|`).join("\n")}
|
|
|
893
895
|
|
|
894
896
|
`;
|
|
895
897
|
}
|
|
896
|
-
function
|
|
898
|
+
function fn(e, t, n, r) {
|
|
897
899
|
return `})`;
|
|
898
900
|
}
|
|
899
|
-
function
|
|
901
|
+
function pn(e, t, { coveragePercent: n, fallowHealth: r, securitySettings: i }) {
|
|
900
902
|
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\`.` : "", s = [[
|
|
901
903
|
"Unit tests",
|
|
902
|
-
|
|
904
|
+
B(i.testsInCI),
|
|
903
905
|
`[Vitest](https://vitest.dev) runs the unit tests.${o(i.testsInCI)}`
|
|
904
906
|
], [
|
|
905
907
|
"Property-based tests",
|
|
906
|
-
|
|
908
|
+
B(i.propertyTests),
|
|
907
909
|
`[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)}`
|
|
908
910
|
]];
|
|
909
911
|
n !== void 0 && s.push([
|
|
910
912
|
"Test coverage",
|
|
911
|
-
|
|
912
|
-
`${
|
|
913
|
+
B(!0),
|
|
914
|
+
`${fn(e, t, "Coverage", Xt)} [Vitest's V8 coverage](https://vitest.dev/guide/coverage) measures the share of source lines the unit tests run. The target is ${String(Jt)}%.`
|
|
913
915
|
]);
|
|
914
916
|
let c = `[](https://sonarcloud.io/summary/new_code?id=${e}_${t}) `, l = [[
|
|
915
917
|
"Code analysis",
|
|
916
|
-
|
|
918
|
+
B(i.sonarCloud),
|
|
917
919
|
`${i.sonarCloud ? c : ""}[SonarCloud](https://sonarcloud.io) checks every push for bugs, code smells and vulnerabilities.`
|
|
918
920
|
], [
|
|
919
921
|
"Linting",
|
|
920
|
-
|
|
922
|
+
B(i.lintInCI),
|
|
921
923
|
`[ESLint](https://eslint.org) checks the code for errors and style problems.${o(i.lintInCI)}`
|
|
922
924
|
]];
|
|
923
925
|
r !== void 0 && l.unshift([
|
|
924
926
|
"Code health",
|
|
925
|
-
|
|
926
|
-
`[${
|
|
927
|
+
B(!0),
|
|
928
|
+
`[${fn(e, t, "Fallow code health", h)}](./${ne}) [Fallow](https://github.com/fallow-rs/fallow) finds unused code, duplication, complexity and dependency problems.`
|
|
927
929
|
]);
|
|
928
930
|
let u = i.codeQLLanguages.length > 0, d = `[](${a}/security/code-scanning) `, f = i.codeQLQueries === "security-extended" ? "using the extended security queries" : "using the default queries", p = u ? ` ${i.codeQLLanguages.join(" and ")}` : "", m = [
|
|
929
931
|
[
|
|
930
932
|
"Push protection",
|
|
931
|
-
|
|
933
|
+
B(i.pushProtection),
|
|
932
934
|
"[GitHub push protection](https://docs.github.com/en/code-security/secret-scanning/push-protection-for-repositories-and-organizations) blocks pushes that contain credentials."
|
|
933
935
|
],
|
|
934
936
|
[
|
|
935
937
|
"Static analysis",
|
|
936
|
-
|
|
938
|
+
B(u),
|
|
937
939
|
`${u ? d : ""}[CodeQL](https://codeql.github.com) scans${p} for security vulnerabilities, ${f}, on every push and pull request to \`main\` and weekly.`
|
|
938
940
|
],
|
|
939
941
|
[
|
|
940
942
|
"Secret scanning",
|
|
941
|
-
|
|
943
|
+
B(i.secretScanning),
|
|
942
944
|
"[GitHub secret scanning](https://docs.github.com/en/code-security/secret-scanning) detects credentials, such as API keys and tokens, committed to the repository."
|
|
943
945
|
]
|
|
944
946
|
], g = "[Dependabot](https://docs.github.com/en/code-security/dependabot)", _ = [
|
|
945
947
|
[
|
|
946
948
|
"Vulnerability audit",
|
|
947
|
-
|
|
949
|
+
B(i.npmAuditInCI),
|
|
948
950
|
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)}`
|
|
949
951
|
],
|
|
950
952
|
[
|
|
951
953
|
"Supply chain risk",
|
|
952
|
-
|
|
954
|
+
B(i.socket),
|
|
953
955
|
"[Socket](https://socket.dev) flags malicious packages, typosquatting and suspicious behaviour that may not yet have a CVE."
|
|
954
956
|
],
|
|
955
957
|
[
|
|
956
958
|
"Security alerts",
|
|
957
|
-
|
|
959
|
+
B(i.dependabotAlerts),
|
|
958
960
|
`${g} alerts when a dependency has a known vulnerability, using the GitHub Advisory Database.`
|
|
959
961
|
],
|
|
960
962
|
[
|
|
961
963
|
"Security updates",
|
|
962
|
-
|
|
963
|
-
`${g} opens pull requests that update vulnerable dependencies.${
|
|
964
|
+
B(i.dependabotSecurityUpdates),
|
|
965
|
+
`${g} opens pull requests that update vulnerable dependencies.${dn(i.dependabotSecurityUpdates)}`
|
|
964
966
|
],
|
|
965
967
|
[
|
|
966
968
|
"Version updates",
|
|
967
|
-
|
|
968
|
-
`${g} opens pull requests for new dependency versions.${
|
|
969
|
+
B(i.dependabotVersionUpdates),
|
|
970
|
+
`${g} opens pull requests for new dependency versions.${dn(i.dependabotVersionUpdates)}`
|
|
969
971
|
]
|
|
970
972
|
];
|
|
971
973
|
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.
|
|
972
974
|
|
|
973
|
-
${
|
|
975
|
+
${V("Testing", s)}${V("Code Quality", l)}${V("Security Analysis", m)}${V("Dependencies", _)}`;
|
|
974
976
|
}
|
|
975
|
-
function
|
|
976
|
-
let a = `https://github.com/${e}/${t}`, o = `github.com/${e}/${t}`, s = `https://www.bestpractices.dev/projects/${String(r)}`, c = i !== void 0 &&
|
|
977
|
+
function mn(e, t, n, r, i) {
|
|
978
|
+
let a = `https://github.com/${e}/${t}`, o = `github.com/${e}/${t}`, s = `https://www.bestpractices.dev/projects/${String(r)}`, c = i !== void 0 && un(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.";
|
|
977
979
|
return `## Quality & Security
|
|
978
980
|
|
|
979
|
-
${
|
|
981
|
+
${pn(e, t, n)}### OpenSSF 🚧
|
|
980
982
|
|
|
981
983
|
${l}[](https://scorecard.dev/viewer/?uri=${o})
|
|
982
984
|
|
|
@@ -988,37 +990,37 @@ Please do not open public GitHub issues for security vulnerabilities. ${u}`;
|
|
|
988
990
|
}
|
|
989
991
|
//#endregion
|
|
990
992
|
//#region src/actions/documentUsage.ts
|
|
991
|
-
var
|
|
993
|
+
var hn = "<!-- USAGE_START -->", gn = "<!-- USAGE_END -->", _n = /* @__PURE__ */ new Set([
|
|
992
994
|
"connector",
|
|
993
995
|
"cookbook",
|
|
994
996
|
"presenter"
|
|
995
|
-
]),
|
|
996
|
-
async function
|
|
997
|
+
]), vn = /* @__PURE__ */ new Set(["development", "eslint"]), yn = "> [!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.", bn = "This repository manages itself using the actions it implements.", xn = "This repository is managed using the common set of actions provided by [@dpuse/dpuse-development](https://github.com/dpuse/dpuse-development).";
|
|
998
|
+
async function Sn() {
|
|
997
999
|
try {
|
|
998
|
-
s("Document Usage"),
|
|
999
|
-
let [e, t] = await Promise.all([
|
|
1000
|
-
await _(u,
|
|
1000
|
+
s("Document Usage"), C("1️⃣ Insert usage content into 'README.md'");
|
|
1001
|
+
let [e, t] = await Promise.all([S("package.json"), S("config.json")]), n = Cn(e), r = wn(n), i = H(e.engines?.node), a = H(e.engines?.npm), o = H(e.devDependencies?.typescript), c = Tn(m(t.id), e.name), l = `${n.replace(/\.git$/, "")}/blob/main/package.json`, u = En(c, n, r, i, a, o, `${e.name === "@dpuse/dpuse-development" ? bn : xn} See the \`scripts\` block in [package.json](${l}) for details.`);
|
|
1002
|
+
await _(u, hn, gn), b("Usage documented");
|
|
1001
1003
|
} catch (e) {
|
|
1002
1004
|
console.error("❌ Error documenting usage", e), process.exit(1);
|
|
1003
1005
|
}
|
|
1004
1006
|
}
|
|
1005
|
-
function
|
|
1007
|
+
function Cn(e) {
|
|
1006
1008
|
let t = e.repository, n = typeof t == "string" ? t : t?.url;
|
|
1007
1009
|
if (n == null || n === "") throw Error("package.json 'repository' field is required to document usage.");
|
|
1008
1010
|
return n.replace(/^git\+/, "");
|
|
1009
1011
|
}
|
|
1010
|
-
function
|
|
1012
|
+
function wn(e) {
|
|
1011
1013
|
return (e.split("/").at(-1) ?? "").replace(/\.git$/, "");
|
|
1012
1014
|
}
|
|
1013
|
-
function
|
|
1015
|
+
function H(e) {
|
|
1014
1016
|
if (e == null) throw Error("package.json version range is required to document usage.");
|
|
1015
1017
|
let t = /\d+(?:\.\d+)*/.exec(e);
|
|
1016
1018
|
if (t == null) throw Error(`Unable to parse version from '${e}'.`);
|
|
1017
1019
|
return t[0];
|
|
1018
1020
|
}
|
|
1019
|
-
function
|
|
1021
|
+
function Tn(e, t) {
|
|
1020
1022
|
let { typeId: n } = e;
|
|
1021
|
-
if (
|
|
1023
|
+
if (_n.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.
|
|
1022
1024
|
|
|
1023
1025
|
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.`;
|
|
1024
1026
|
if (e.publishedTo === "npm") {
|
|
@@ -1029,11 +1031,11 @@ You may view or clone this repository for your own purposes, such as building a
|
|
|
1029
1031
|
npm install ${t}
|
|
1030
1032
|
\`\`\`
|
|
1031
1033
|
|
|
1032
|
-
${
|
|
1034
|
+
${vn.has(n) ? `${yn}\n\n` : ""}To work on the source instead, clone this repository.`;
|
|
1033
1035
|
}
|
|
1034
1036
|
return "You may view or clone this repository for your own purposes.";
|
|
1035
1037
|
}
|
|
1036
|
-
function
|
|
1038
|
+
function En(e, t, n, r, i, a, o) {
|
|
1037
1039
|
return `## Usage
|
|
1038
1040
|
|
|
1039
1041
|
${e}
|
|
@@ -1050,61 +1052,61 @@ ${o}`;
|
|
|
1050
1052
|
}
|
|
1051
1053
|
//#endregion
|
|
1052
1054
|
//#region src/actions/documentApiReference.ts
|
|
1053
|
-
var
|
|
1054
|
-
async function
|
|
1055
|
+
var U = "API_REFERENCE.md";
|
|
1056
|
+
async function Dn() {
|
|
1055
1057
|
try {
|
|
1056
1058
|
s("Document API Reference");
|
|
1057
|
-
let { writeAPIReference: e } = await import("./apiReference-
|
|
1058
|
-
await e("1️⃣ ",
|
|
1059
|
+
let { writeAPIReference: e } = await import("./apiReference-D4xooSV0.js");
|
|
1060
|
+
await e("1️⃣ ", U), b("API reference documented");
|
|
1059
1061
|
} catch (e) {
|
|
1060
1062
|
console.error("❌ Error documenting API reference", e), process.exit(1);
|
|
1061
1063
|
}
|
|
1062
1064
|
}
|
|
1063
1065
|
//#endregion
|
|
1064
1066
|
//#region src/actions/documentBundleSizes.ts
|
|
1065
|
-
var
|
|
1066
|
-
async function
|
|
1067
|
+
var On = "bundle-analysis-reports/sonda/index.json", kn = "bundle-analysis-reports/sonda/worker.json", An = "<!-- BUNDLE_START -->", jn = "<!-- BUNDLE_END -->", W = " ", G = 20, Mn = "█", Nn = "▒", Pn = 100 / G / 2, Fn = 100 / G, In = "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._", Ln = "Bars show each row's share of its output file.", Rn = "↳ rows are part of the row above.", K = "(bundler output, whitespace & JSON)", q = "(inlined worker)", zn = `${q} = a Web Worker built separately and embedded in its output file as text. Where the build records what it contains, its rows list that; any few bytes over are the escaping needed to embed it.`, J = "(Rust WebAssembly as base64", Bn = `${J}…) = the compiled Rust code, embedded as base64 text, about a third larger than the binary it decodes to, which is the size given.`, Vn = `${K} = 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.`;
|
|
1068
|
+
async function Hn(t) {
|
|
1067
1069
|
try {
|
|
1068
|
-
s("Document Bundle Sizes"),
|
|
1069
|
-
let n = await
|
|
1070
|
+
s("Document Bundle Sizes"), C("1️⃣ Read bundle analysis report");
|
|
1071
|
+
let n = await S(On), r = await e(kn), i = r === null ? void 0 : JSON.parse(r), a = /* @__PURE__ */ new Map();
|
|
1070
1072
|
for (let t of n.resources) t.kind === "asset" && a.set(t.name, await e(t.name));
|
|
1071
|
-
|
|
1072
|
-
let o =
|
|
1073
|
+
C("2️⃣ Insert table into 'README.md'");
|
|
1074
|
+
let o = Un(n, {
|
|
1073
1075
|
assetContents: a,
|
|
1074
1076
|
isModuleLevel: t?.moduleLevel ?? !1,
|
|
1075
1077
|
workerJson: i
|
|
1076
1078
|
}), c = [
|
|
1077
|
-
o.includes("↳") ? `${
|
|
1078
|
-
o.includes(
|
|
1079
|
-
o.includes(
|
|
1080
|
-
|
|
1079
|
+
o.includes("↳") ? `${Ln} ${Rn}` : Ln,
|
|
1080
|
+
o.includes(q) ? zn : "",
|
|
1081
|
+
o.includes(J) ? Bn : "",
|
|
1082
|
+
Vn
|
|
1081
1083
|
].filter((e) => e !== "");
|
|
1082
|
-
await _(`## Bundle Analysis\n\n${
|
|
1084
|
+
await _(`## Bundle Analysis\n\n${In}\n\n${o}\n\n${c.join("\n\n")}`, An, jn), b("Bundle sizes documented");
|
|
1083
1085
|
} catch (e) {
|
|
1084
1086
|
console.error("❌ Error documenting bundle sizes", e), process.exit(1);
|
|
1085
1087
|
}
|
|
1086
1088
|
}
|
|
1087
|
-
function
|
|
1088
|
-
let { assetContents: n, isModuleLevel: r, workerJson: i } = t, a =
|
|
1089
|
+
function Un(e, t) {
|
|
1090
|
+
let { assetContents: n, isModuleLevel: r, workerJson: i } = t, a = ir(e), o = i === void 0 ? void 0 : ir(i).values().next().value;
|
|
1089
1091
|
for (let [e, t] of a) {
|
|
1090
1092
|
let r = n.get(e);
|
|
1091
|
-
r != null &&
|
|
1093
|
+
r != null && Wn(t, r, o);
|
|
1092
1094
|
}
|
|
1093
|
-
let s = a.values().flatMap((e) => e.values().toArray()).reduce((e, t) => e + t.sizes.uncompressed, 0), c = e.resources.filter((e) => e.kind === "asset").map((e) => [e.name,
|
|
1095
|
+
let s = a.values().flatMap((e) => e.values().toArray()).reduce((e, t) => e + t.sizes.uncompressed, 0), c = e.resources.filter((e) => e.kind === "asset").map((e) => [e.name, lr(e)]).toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), l = ["|Chunk/Module/File|Composition|", "|:------ |:-----------|"];
|
|
1094
1096
|
for (let [e, t] of c) {
|
|
1095
|
-
let n = [...a.get(e) ?? /* @__PURE__ */ new Map()].toSorted(
|
|
1096
|
-
l.push(`| **${e}** | ${
|
|
1097
|
+
let n = [...a.get(e) ?? /* @__PURE__ */ new Map()].toSorted(Qn), i = n.reduce((e, [, t]) => e + t.sizes.uncompressed, 0), o = i > 0 && s > 0 ? ` · ${fr(i, s)} of the build` : "";
|
|
1098
|
+
l.push(`| **${e}** | ${ur(t)}${o} |`, ...$n(n, i, r));
|
|
1097
1099
|
}
|
|
1098
1100
|
return l.join("\n");
|
|
1099
1101
|
}
|
|
1100
|
-
function
|
|
1101
|
-
let r =
|
|
1102
|
-
|
|
1102
|
+
function Wn(e, t, n) {
|
|
1103
|
+
let r = Gn(t), i = Kn(r ?? ""), a = Kn(t);
|
|
1104
|
+
Jn(e, {
|
|
1103
1105
|
bytes: a.bytes - i.bytes,
|
|
1104
1106
|
binaryBytes: a.binaryBytes - i.binaryBytes
|
|
1105
|
-
}), r !== void 0 &&
|
|
1107
|
+
}), r !== void 0 && Yn(e, Buffer.byteLength(r), i, n);
|
|
1106
1108
|
}
|
|
1107
|
-
function
|
|
1109
|
+
function Gn(e) {
|
|
1108
1110
|
if (!e.includes("new Worker(")) return;
|
|
1109
1111
|
let t = /encodeURIComponent\((\w+)\)/.exec(e)?.[1];
|
|
1110
1112
|
if (t === void 0) return;
|
|
@@ -1114,30 +1116,30 @@ function Un(e) {
|
|
|
1114
1116
|
for (; a < e.length && e[a] !== r;) a += e[a] === "\\" ? 2 : 1;
|
|
1115
1117
|
return e.slice(i, a);
|
|
1116
1118
|
}
|
|
1117
|
-
function
|
|
1119
|
+
function Kn(e) {
|
|
1118
1120
|
let t = {
|
|
1119
1121
|
bytes: 0,
|
|
1120
1122
|
binaryBytes: 0
|
|
1121
1123
|
};
|
|
1122
1124
|
for (let n of e.matchAll(/data:application\/wasm;base64,([A-Za-z\d+/]*={0,2})/g)) {
|
|
1123
1125
|
let e = n[1] ?? "";
|
|
1124
|
-
t.bytes += n[0].length, t.binaryBytes += Math.floor(e.length * 3 / 4) -
|
|
1126
|
+
t.bytes += n[0].length, t.binaryBytes += Math.floor(e.length * 3 / 4) - qn(e);
|
|
1125
1127
|
}
|
|
1126
1128
|
return t;
|
|
1127
1129
|
}
|
|
1128
|
-
function
|
|
1130
|
+
function qn(e) {
|
|
1129
1131
|
return e.endsWith("==") ? 2 : +!!e.endsWith("=");
|
|
1130
1132
|
}
|
|
1131
|
-
function
|
|
1133
|
+
function Jn(e, t) {
|
|
1132
1134
|
if (t.bytes <= 0) return;
|
|
1133
|
-
let n = [e.get("wasm"), e.get(
|
|
1135
|
+
let n = [e.get("wasm"), e.get(K)].flatMap((e) => e === void 0 ? [] : e.files.entries().map(([t, n]) => ({
|
|
1134
1136
|
group: e,
|
|
1135
1137
|
fileName: t,
|
|
1136
1138
|
sizes: n
|
|
1137
1139
|
})).toArray()).find(({ sizes: e }) => e.uncompressed >= t.bytes);
|
|
1138
1140
|
if (n === void 0) return;
|
|
1139
|
-
|
|
1140
|
-
let r = `${
|
|
1141
|
+
Zn(e, n.group, n.fileName, n.sizes, t.bytes);
|
|
1142
|
+
let r = `${J}, ${Q(t.binaryBytes)} binary)`;
|
|
1141
1143
|
e.set(r, {
|
|
1142
1144
|
sizes: {
|
|
1143
1145
|
uncompressed: t.bytes,
|
|
@@ -1149,15 +1151,15 @@ function Kn(e, t) {
|
|
|
1149
1151
|
}]])
|
|
1150
1152
|
});
|
|
1151
1153
|
}
|
|
1152
|
-
function
|
|
1153
|
-
let i = e.get(
|
|
1154
|
+
function Yn(e, t, n, r) {
|
|
1155
|
+
let i = e.get(K), a = i?.files.get("");
|
|
1154
1156
|
if (i === void 0 || a === void 0 || a.uncompressed < t) return;
|
|
1155
|
-
|
|
1157
|
+
Zn(e, i, "", a, t);
|
|
1156
1158
|
let o = r === void 0 ? /* @__PURE__ */ new Map([["", {
|
|
1157
1159
|
uncompressed: t,
|
|
1158
1160
|
gzip: 0
|
|
1159
|
-
}]]) :
|
|
1160
|
-
e.set(
|
|
1161
|
+
}]]) : Xn(r, t, n);
|
|
1162
|
+
e.set(q, {
|
|
1161
1163
|
sizes: {
|
|
1162
1164
|
uncompressed: t,
|
|
1163
1165
|
gzip: 0
|
|
@@ -1165,84 +1167,84 @@ function qn(e, t, n, r) {
|
|
|
1165
1167
|
files: o
|
|
1166
1168
|
});
|
|
1167
1169
|
}
|
|
1168
|
-
function
|
|
1169
|
-
|
|
1170
|
+
function Xn(e, t, n) {
|
|
1171
|
+
Jn(e, n);
|
|
1170
1172
|
let r = /* @__PURE__ */ new Map();
|
|
1171
1173
|
for (let [t, n] of e) if (t === "src") for (let [e, t] of n.files) r.set(e, { ...t });
|
|
1172
1174
|
else {
|
|
1173
|
-
let e = n.files.size === 1 ?
|
|
1175
|
+
let e = n.files.size === 1 ? nr(t, rr(n.files)) : t;
|
|
1174
1176
|
r.set(e, { ...n.sizes });
|
|
1175
1177
|
}
|
|
1176
|
-
let i = r.values().reduce((e, t) => e + t.uncompressed, 0), a = r.get(
|
|
1177
|
-
return a.uncompressed += Math.max(0, t - i), a.uncompressed > 0 && r.set(
|
|
1178
|
+
let i = r.values().reduce((e, t) => e + t.uncompressed, 0), a = r.get(K) ?? X();
|
|
1179
|
+
return a.uncompressed += Math.max(0, t - i), a.uncompressed > 0 && r.set(K, a), r;
|
|
1178
1180
|
}
|
|
1179
|
-
function
|
|
1181
|
+
function Zn(e, t, n, r, i) {
|
|
1180
1182
|
if (r.uncompressed -= i, t.sizes.uncompressed -= i, r.uncompressed <= 0 && t.files.delete(n), !(t.sizes.uncompressed > 0)) for (let [n, r] of e) r === t && e.delete(n);
|
|
1181
1183
|
}
|
|
1182
|
-
function
|
|
1183
|
-
return e[0] ===
|
|
1184
|
+
function Qn(e, t) {
|
|
1185
|
+
return e[0] === K == (t[0] === K) ? t[1].sizes.uncompressed - e[1].sizes.uncompressed : e[0] === K ? 1 : -1;
|
|
1184
1186
|
}
|
|
1185
|
-
function
|
|
1187
|
+
function $n(e, t, n) {
|
|
1186
1188
|
let r = [];
|
|
1187
1189
|
for (let [i, { sizes: a, files: o }] of e) {
|
|
1188
1190
|
if (o.size === 1) {
|
|
1189
|
-
let e =
|
|
1190
|
-
r.push(`| ${
|
|
1191
|
+
let e = rr(o);
|
|
1192
|
+
r.push(`| ${W}${nr(i, e)} | ${Y(a.uncompressed, t)} |`);
|
|
1191
1193
|
continue;
|
|
1192
1194
|
}
|
|
1193
|
-
r.push(`| ${
|
|
1195
|
+
r.push(`| ${W}${i} | ${Y(a.uncompressed, t)} |`), n || r.push(...er(o, t));
|
|
1194
1196
|
}
|
|
1195
1197
|
return r;
|
|
1196
1198
|
}
|
|
1197
|
-
function
|
|
1198
|
-
let n = [...e].toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), r =
|
|
1199
|
+
function er(e, t) {
|
|
1200
|
+
let n = [...e].toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), r = tr(n, t), i = (r > 0 ? n.slice(0, -r) : n).map(([e, n]) => `| ${W}${W}↳ ${e} | ${Y(n.uncompressed, t, Nn)} |`);
|
|
1199
1201
|
if (r > 0) {
|
|
1200
1202
|
let e = n.slice(-r).reduce((e, [, t]) => e + t.uncompressed, 0);
|
|
1201
|
-
i.push(`| ${
|
|
1203
|
+
i.push(`| ${W}${W}↳ ${String(r)} smaller files | ${Y(e, t, Nn)} |`);
|
|
1202
1204
|
}
|
|
1203
1205
|
return i;
|
|
1204
1206
|
}
|
|
1205
|
-
function
|
|
1207
|
+
function tr(e, t) {
|
|
1206
1208
|
if (t <= 0) return 0;
|
|
1207
1209
|
let n = 0, r = 0;
|
|
1208
1210
|
for (let [, i] of e.toReversed()) {
|
|
1209
|
-
let e = i.uncompressed / t * 100 <
|
|
1211
|
+
let e = i.uncompressed / t * 100 < Pn, a = (r + i.uncompressed) / t * 100 <= Fn;
|
|
1210
1212
|
if (!e || !a) break;
|
|
1211
1213
|
n++, r += i.uncompressed;
|
|
1212
1214
|
}
|
|
1213
1215
|
return n >= 2 ? n : 0;
|
|
1214
1216
|
}
|
|
1215
|
-
function
|
|
1216
|
-
return `${
|
|
1217
|
+
function Y(e, t, n = Mn) {
|
|
1218
|
+
return `${dr(t > 0 ? e / t * 100 : 0, n)} · ${Q(e)}`;
|
|
1217
1219
|
}
|
|
1218
|
-
function
|
|
1220
|
+
function nr(e, t) {
|
|
1219
1221
|
return t === "" ? e : `${e} → ${t}`;
|
|
1220
1222
|
}
|
|
1221
|
-
function
|
|
1223
|
+
function rr(e) {
|
|
1222
1224
|
let [t] = e.keys();
|
|
1223
1225
|
if (t === void 0) throw Error("Expected exactly one file");
|
|
1224
1226
|
return t;
|
|
1225
1227
|
}
|
|
1226
|
-
function
|
|
1227
|
-
let t =
|
|
1228
|
+
function ir(e) {
|
|
1229
|
+
let t = ar(e.dependencies), n = /* @__PURE__ */ new Map();
|
|
1228
1230
|
for (let r of e.resources) {
|
|
1229
1231
|
if (r.kind !== "chunk" || !r.parent) continue;
|
|
1230
|
-
let { group: e, file: i } =
|
|
1232
|
+
let { group: e, file: i } = or(r.name, t), a = lr(r), o = n.get(r.parent) ?? /* @__PURE__ */ new Map();
|
|
1231
1233
|
n.set(r.parent, o);
|
|
1232
1234
|
let s = o.get(e) ?? {
|
|
1233
|
-
sizes:
|
|
1235
|
+
sizes: X(),
|
|
1234
1236
|
files: /* @__PURE__ */ new Map()
|
|
1235
1237
|
};
|
|
1236
|
-
o.set(e, s),
|
|
1237
|
-
let c = s.files.get(i) ??
|
|
1238
|
-
s.files.set(i, c),
|
|
1238
|
+
o.set(e, s), Z(s.sizes, a);
|
|
1239
|
+
let c = s.files.get(i) ?? X();
|
|
1240
|
+
s.files.set(i, c), Z(c, a);
|
|
1239
1241
|
}
|
|
1240
1242
|
return n;
|
|
1241
1243
|
}
|
|
1242
|
-
function
|
|
1244
|
+
function ar(e) {
|
|
1243
1245
|
return e.flatMap((e) => e.paths.map((t) => [t, e.name])).toSorted((e, t) => t[0].length - e[0].length);
|
|
1244
1246
|
}
|
|
1245
|
-
function
|
|
1247
|
+
function or(e, t) {
|
|
1246
1248
|
let n = t.find(([t]) => e === t || e.startsWith(`${t}/`));
|
|
1247
1249
|
if (n) {
|
|
1248
1250
|
let [t, r] = n;
|
|
@@ -1252,49 +1254,49 @@ function ir(e, t) {
|
|
|
1252
1254
|
};
|
|
1253
1255
|
}
|
|
1254
1256
|
return e === "[unassigned]" ? {
|
|
1255
|
-
group:
|
|
1257
|
+
group: K,
|
|
1256
1258
|
file: ""
|
|
1257
1259
|
} : e.startsWith("\0") ? {
|
|
1258
1260
|
group: "(runtime)",
|
|
1259
1261
|
file: e.slice(1)
|
|
1260
1262
|
} : e.startsWith("rust/") ? {
|
|
1261
1263
|
group: "wasm",
|
|
1262
|
-
file:
|
|
1264
|
+
file: sr(e)
|
|
1263
1265
|
} : {
|
|
1264
1266
|
group: "src",
|
|
1265
|
-
file:
|
|
1267
|
+
file: cr(e)
|
|
1266
1268
|
};
|
|
1267
1269
|
}
|
|
1268
|
-
function
|
|
1269
|
-
let t = e.split("/", 2)[1] ?? "", n =
|
|
1270
|
+
function sr(e) {
|
|
1271
|
+
let t = e.split("/", 2)[1] ?? "", n = cr(e);
|
|
1270
1272
|
return t !== "" && n.startsWith(t) ? `…${n.slice(t.length)}` : n;
|
|
1271
1273
|
}
|
|
1272
|
-
function
|
|
1274
|
+
function cr(e) {
|
|
1273
1275
|
return e.split("/").at(-1) ?? e;
|
|
1274
1276
|
}
|
|
1275
|
-
function
|
|
1277
|
+
function lr(e) {
|
|
1276
1278
|
return {
|
|
1277
1279
|
uncompressed: e.uncompressed,
|
|
1278
1280
|
gzip: e.gzip ?? 0
|
|
1279
1281
|
};
|
|
1280
1282
|
}
|
|
1281
|
-
function
|
|
1283
|
+
function ur(e) {
|
|
1282
1284
|
return `${Q(e.uncompressed)} · gzip ${Q(e.gzip)}`;
|
|
1283
1285
|
}
|
|
1284
|
-
function
|
|
1285
|
-
let n = Math.round(e / 100 *
|
|
1286
|
-
return `\`${t.repeat(n)}${"░".repeat(
|
|
1286
|
+
function dr(e, t = Mn) {
|
|
1287
|
+
let n = Math.round(e / 100 * G);
|
|
1288
|
+
return `\`${t.repeat(n)}${"░".repeat(G - n)}\` ${e.toFixed(1)}%`;
|
|
1287
1289
|
}
|
|
1288
|
-
function
|
|
1290
|
+
function X() {
|
|
1289
1291
|
return {
|
|
1290
1292
|
uncompressed: 0,
|
|
1291
1293
|
gzip: 0
|
|
1292
1294
|
};
|
|
1293
1295
|
}
|
|
1294
|
-
function
|
|
1296
|
+
function Z(e, t) {
|
|
1295
1297
|
e.uncompressed += t.uncompressed, e.gzip += t.gzip;
|
|
1296
1298
|
}
|
|
1297
|
-
function
|
|
1299
|
+
function fr(e, t) {
|
|
1298
1300
|
return `${(e / t * 100).toFixed(1)}%`;
|
|
1299
1301
|
}
|
|
1300
1302
|
function Q(e) {
|
|
@@ -1302,15 +1304,15 @@ function Q(e) {
|
|
|
1302
1304
|
}
|
|
1303
1305
|
//#endregion
|
|
1304
1306
|
//#region src/actions/documentProject.ts
|
|
1305
|
-
async function
|
|
1307
|
+
async function pr(t = "MIT", n = !1) {
|
|
1306
1308
|
try {
|
|
1307
|
-
let r = await
|
|
1308
|
-
await
|
|
1309
|
-
let a = await e(
|
|
1310
|
-
a ? await
|
|
1309
|
+
let r = await S("config.json"), i = m(r.id).typeId === "connector";
|
|
1310
|
+
await zt(), i && await Ge(), await Sn(), await ft(t), await e("bundle-analysis-reports/sonda/index.json") === null ? C(`ℹ️ Bundle sizes NOT documented, as there is no '${On}' yet. Build the project first.`) : await Hn({ moduleLevel: n }), await tn(), await Ke();
|
|
1311
|
+
let a = await e(U) !== null;
|
|
1312
|
+
a ? await Dn() : C(`ℹ️ '${U}' NOT required by this project`), await o("ℹ️ Format generated files", "prettier", [
|
|
1311
1313
|
"--write",
|
|
1312
1314
|
"README.md",
|
|
1313
|
-
...a ? [
|
|
1315
|
+
...a ? [U] : []
|
|
1314
1316
|
]);
|
|
1315
1317
|
} catch (e) {
|
|
1316
1318
|
console.error("❌ Error documenting project", e), process.exit(1);
|
|
@@ -1318,7 +1320,7 @@ async function fr(t = "MIT", n = !1) {
|
|
|
1318
1320
|
}
|
|
1319
1321
|
//#endregion
|
|
1320
1322
|
//#region src/actions/formatCode.ts
|
|
1321
|
-
async function
|
|
1323
|
+
async function mr() {
|
|
1322
1324
|
try {
|
|
1323
1325
|
s("Format Code");
|
|
1324
1326
|
let e = [
|
|
@@ -1330,51 +1332,59 @@ async function pr() {
|
|
|
1330
1332
|
"app",
|
|
1331
1333
|
"src",
|
|
1332
1334
|
"tests"
|
|
1333
|
-
].filter((e) =>
|
|
1335
|
+
].filter((e) => ce(e)).map((e) => `${e}/**`)
|
|
1334
1336
|
];
|
|
1335
|
-
await o("1️⃣ Format", "prettier", e),
|
|
1337
|
+
await o("1️⃣ Format", "prettier", e), b("Code formatted");
|
|
1336
1338
|
} catch (e) {
|
|
1337
1339
|
console.error("❌ Error formatting code", e), process.exit(1);
|
|
1338
1340
|
}
|
|
1339
1341
|
}
|
|
1340
1342
|
//#endregion
|
|
1341
1343
|
//#region src/actions/lintCode.ts
|
|
1342
|
-
async function
|
|
1344
|
+
async function hr() {
|
|
1343
1345
|
try {
|
|
1344
|
-
s("Lint Code"), await o("1️⃣ Lint", "eslint", ["."]),
|
|
1346
|
+
s("Lint Code"), await o("1️⃣ Lint", "eslint", ["."]), b("Code linted");
|
|
1345
1347
|
} catch (e) {
|
|
1346
1348
|
console.error("❌ Error linting code", e), process.exit(1);
|
|
1347
1349
|
}
|
|
1348
1350
|
}
|
|
1349
1351
|
//#endregion
|
|
1350
1352
|
//#region src/utilities/cloudflare.ts
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
+
var gr = "dpuse-sample-data-eu", _r = {
|
|
1354
|
+
bin: "application/octet-stream",
|
|
1355
|
+
csv: "text/csv",
|
|
1356
|
+
json: "application/json",
|
|
1357
|
+
md: "text/markdown",
|
|
1358
|
+
spss: "application/octet-stream",
|
|
1359
|
+
txt: "text/plain",
|
|
1360
|
+
xls: "application/vnd.ms-excel",
|
|
1361
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
1362
|
+
xml: "application/xml"
|
|
1363
|
+
};
|
|
1364
|
+
async function vr() {
|
|
1365
|
+
let e = await S("config.json"), t = {
|
|
1353
1366
|
body: JSON.stringify(e),
|
|
1354
1367
|
headers: { "Content-Type": "application/json" },
|
|
1355
1368
|
method: "PUT"
|
|
1356
1369
|
}, n = await fetch(`https://api.dpuse.app/configs/${e.id}`, t);
|
|
1357
1370
|
if (!n.ok) throw Error(await n.text());
|
|
1358
1371
|
}
|
|
1359
|
-
async function
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
}
|
|
1374
|
-
let r = await y(`${e}/${t}/`);
|
|
1375
|
-
await n(`${e}/${t}`, t, r);
|
|
1372
|
+
async function $(e, t) {
|
|
1373
|
+
let n = await Cr(`${e}/${t}`, t), r = Map.groupBy(n, ({ key: e }) => wr(e));
|
|
1374
|
+
for (let [e, t] of r) await Sr(t, ["--content-type", e]);
|
|
1375
|
+
}
|
|
1376
|
+
async function yr(e) {
|
|
1377
|
+
await $(e, "application"), await $(e, "fileStore"), await Sr(["applicationIndex.json", "fileStoreIndex.json"].map((t) => ({
|
|
1378
|
+
file: `${e}/${t}`,
|
|
1379
|
+
key: t
|
|
1380
|
+
})), [
|
|
1381
|
+
"--content-type",
|
|
1382
|
+
"application/json",
|
|
1383
|
+
"--cache-control",
|
|
1384
|
+
"no-cache"
|
|
1385
|
+
]);
|
|
1376
1386
|
}
|
|
1377
|
-
async function
|
|
1387
|
+
async function br(e) {
|
|
1378
1388
|
let t = e.id, n = {
|
|
1379
1389
|
body: JSON.stringify(e),
|
|
1380
1390
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1382,14 +1392,14 @@ async function $(e) {
|
|
|
1382
1392
|
}, r = await fetch(`https://api.dpuse.app/configs/${t}`, n);
|
|
1383
1393
|
if (!r.ok) throw Error(await r.text());
|
|
1384
1394
|
}
|
|
1385
|
-
async function
|
|
1395
|
+
async function xr(e, t) {
|
|
1386
1396
|
let n = `v${e.version ?? "unknown"}`;
|
|
1387
1397
|
async function r(e, r = "") {
|
|
1388
|
-
let i = await
|
|
1398
|
+
let i = await ee(e, { withFileTypes: !0 });
|
|
1389
1399
|
for (let a of i) {
|
|
1390
1400
|
if (a.isDirectory() || a.name.endsWith(".map")) continue;
|
|
1391
1401
|
let i = `${e}/${a.name}`, o = r ? `${r}/${a.name}` : a.name, s = `${t}_${n}/${o}`.replaceAll("\\", "/"), c = a.name.endsWith(".css") ? "text/css" : "application/octet-stream", l = a.name.endsWith(".js") ? "application/javascript" : c;
|
|
1392
|
-
console.info(`⚙️ Uploading '${o}' → '${s}'...`), await
|
|
1402
|
+
console.info(`⚙️ Uploading '${o}' → '${s}'...`), await y(void 0, "wrangler", [
|
|
1393
1403
|
"r2",
|
|
1394
1404
|
"object",
|
|
1395
1405
|
"put",
|
|
@@ -1404,44 +1414,85 @@ async function _r(e, t) {
|
|
|
1404
1414
|
}
|
|
1405
1415
|
await r("dist");
|
|
1406
1416
|
}
|
|
1417
|
+
async function Sr(e, t) {
|
|
1418
|
+
if (e.length === 0) return;
|
|
1419
|
+
let n = await w.mkdtemp(T.join(ge.tmpdir(), "dpuse-r2-bulk-")), r = T.join(n, "files.json");
|
|
1420
|
+
try {
|
|
1421
|
+
await i(r, e), console.info(`⚙️ Uploading ${String(e.length)} files (${t.join(" ")})...`), await y(void 0, "wrangler", [
|
|
1422
|
+
"r2",
|
|
1423
|
+
"bulk",
|
|
1424
|
+
"put",
|
|
1425
|
+
gr,
|
|
1426
|
+
"--filename",
|
|
1427
|
+
r,
|
|
1428
|
+
...t,
|
|
1429
|
+
"--jurisdiction=eu",
|
|
1430
|
+
"--remote"
|
|
1431
|
+
]);
|
|
1432
|
+
} finally {
|
|
1433
|
+
await w.rm(n, {
|
|
1434
|
+
force: !0,
|
|
1435
|
+
recursive: !0
|
|
1436
|
+
});
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
async function Cr(e, t) {
|
|
1440
|
+
let n = await ee(e), r = [];
|
|
1441
|
+
for (let i of n) {
|
|
1442
|
+
if (i.startsWith(".")) continue;
|
|
1443
|
+
let n = `${e}/${i}`, a = `${t}/${i}`;
|
|
1444
|
+
(await p(n)).isDirectory() ? r.push(...await Cr(n, a)) : r.push({
|
|
1445
|
+
file: n,
|
|
1446
|
+
key: a
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1449
|
+
return r;
|
|
1450
|
+
}
|
|
1451
|
+
function wr(e) {
|
|
1452
|
+
let t = e.slice(e.lastIndexOf("/") + 1), n = t.lastIndexOf(".");
|
|
1453
|
+
if (n === -1) return t === "LICENSE" ? "text/plain" : "application/octet-stream";
|
|
1454
|
+
let r = _r[t.slice(n + 1).toLowerCase()];
|
|
1455
|
+
if (r === void 0) throw Error(`No content type for '${e}'. Add its extension to 'SAMPLE_DATA_CONTENT_TYPES'.`);
|
|
1456
|
+
return r;
|
|
1457
|
+
}
|
|
1407
1458
|
//#endregion
|
|
1408
1459
|
//#region src/actions/publishProject.ts
|
|
1409
|
-
async function
|
|
1460
|
+
async function Tr() {
|
|
1410
1461
|
try {
|
|
1411
1462
|
s("Publish Project");
|
|
1412
|
-
let e = await
|
|
1413
|
-
n.publishedTo === "npm" ? await o("1️⃣ Publish to npm", "npm", ["publish", "--provenance"]) :
|
|
1463
|
+
let e = await S("package.json"), t = await S("config.json"), n = m(t.id);
|
|
1464
|
+
n.publishedTo === "npm" ? await o("1️⃣ Publish to npm", "npm", ["publish", "--provenance"]) : C("1️⃣ Publishing to npm NOT required"), await Er("2️⃣ ", e, t, n), n.publishedTo === "kb" ? await o("3️⃣ Deploy", "npm", ["run", "deploy"]) : n.publishedTo === "sampleData" && (C("3️⃣ Upload sample data"), await yr("public")), b(`Project version '${e.version ?? "unknown"}' published.`);
|
|
1414
1465
|
} catch (e) {
|
|
1415
1466
|
console.error("❌ Error publishing project", e), process.exit(1);
|
|
1416
1467
|
}
|
|
1417
1468
|
}
|
|
1418
|
-
async function
|
|
1419
|
-
if (r.typeId === "app")
|
|
1420
|
-
else if (r.typeId === "engine")
|
|
1421
|
-
else if (r.uploadGroupName === void 0)
|
|
1469
|
+
async function Er(e, t, n, r) {
|
|
1470
|
+
if (r.typeId === "app") C(`${e} Register module`), await vr();
|
|
1471
|
+
else if (r.typeId === "engine") C(`${e} Register module`), await xr(t, `dpuse-engine-eu/${r.uploadGroupName ?? "unknown"}`), await br(n);
|
|
1472
|
+
else if (r.uploadGroupName === void 0) C(`${e} Registration NOT required`);
|
|
1422
1473
|
else {
|
|
1423
|
-
|
|
1474
|
+
C(`${e} Register module`);
|
|
1424
1475
|
let i = n.id.split("-").slice(2).join("-");
|
|
1425
|
-
await
|
|
1476
|
+
await xr(t, `dpuse-engine-eu/${r.uploadGroupName}/${i}`), await br(n);
|
|
1426
1477
|
}
|
|
1427
1478
|
}
|
|
1428
1479
|
//#endregion
|
|
1429
1480
|
//#region src/actions/releaseProject.ts
|
|
1430
|
-
async function
|
|
1481
|
+
async function Dr(e = "MIT", t = !1) {
|
|
1431
1482
|
try {
|
|
1432
1483
|
s("Release Project");
|
|
1433
|
-
let n = await
|
|
1484
|
+
let n = await S("package.json"), r = await S("config.json"), i = m(r.id);
|
|
1434
1485
|
await d("1️⃣ ", n);
|
|
1435
|
-
let a = await
|
|
1436
|
-
if (await
|
|
1486
|
+
let a = await oe("2️⃣ ", n, i);
|
|
1487
|
+
if (await Ee("3️⃣ ", n), C("4️⃣ Regenerate README"), await pr(e, t), await y("5️⃣ Stage changes", "git", ["add", "."]), await y("6️⃣ Commit changes", "git", [
|
|
1437
1488
|
"commit",
|
|
1438
1489
|
"-m",
|
|
1439
1490
|
`v${n.version ?? "unknown"}`
|
|
1440
|
-
]), await
|
|
1491
|
+
]), await y("7️⃣ Push changes", "git", [
|
|
1441
1492
|
"push",
|
|
1442
1493
|
"origin",
|
|
1443
1494
|
"main:main"
|
|
1444
|
-
]), await
|
|
1495
|
+
]), await Er("8️⃣ ", n, a, i), i.publishedTo === "npm") {
|
|
1445
1496
|
let e = `v${n.version ?? "unknown"}`;
|
|
1446
1497
|
await o("9️⃣ Trigger GitHub release", "gh", [
|
|
1447
1498
|
"release",
|
|
@@ -1452,39 +1503,39 @@ async function br(e = "MIT", t = !1) {
|
|
|
1452
1503
|
"--generate-notes",
|
|
1453
1504
|
"--latest"
|
|
1454
1505
|
]);
|
|
1455
|
-
} else
|
|
1456
|
-
|
|
1506
|
+
} else C(`9️⃣ Publishing NOT required for package with type identifier of '${i.typeId}'.`);
|
|
1507
|
+
b(`Project version '${n.version ?? "unknown"}' released.`);
|
|
1457
1508
|
} catch (e) {
|
|
1458
1509
|
console.error("❌ Error releasing project", e), process.exit(1);
|
|
1459
1510
|
}
|
|
1460
1511
|
}
|
|
1461
1512
|
//#endregion
|
|
1462
1513
|
//#region src/actions/syncProjectWithGitHub.ts
|
|
1463
|
-
async function
|
|
1514
|
+
async function Or() {
|
|
1464
1515
|
try {
|
|
1465
1516
|
s("Synchronise Project with GitHub");
|
|
1466
|
-
let e = await
|
|
1467
|
-
await d("1️⃣ ", e), await
|
|
1517
|
+
let e = await S("package.json"), t = await S("config.json"), n = m(t.id);
|
|
1518
|
+
await d("1️⃣ ", e), await oe("2️⃣ ", e, n), await y("3️⃣ Stage changes", "git", ["add", "."]), await y("4️⃣ Commit changes", "git", [
|
|
1468
1519
|
"commit",
|
|
1469
1520
|
"-m",
|
|
1470
1521
|
`v${e.version ?? "unknown"}`
|
|
1471
|
-
]), await
|
|
1522
|
+
]), await y("5️⃣ Push changes", "git", [
|
|
1472
1523
|
"push",
|
|
1473
1524
|
"origin",
|
|
1474
1525
|
"main:main"
|
|
1475
|
-
]),
|
|
1526
|
+
]), b(`Project version '${e.version ?? "unknown"}' synchronised with GitHub.`);
|
|
1476
1527
|
} catch (e) {
|
|
1477
1528
|
console.error("❌ Error synchronising project with GitHub", e), process.exit(1);
|
|
1478
1529
|
}
|
|
1479
1530
|
}
|
|
1480
1531
|
//#endregion
|
|
1481
1532
|
//#region src/actions/testProject.ts
|
|
1482
|
-
var
|
|
1533
|
+
var kr = [
|
|
1483
1534
|
"1️⃣ ",
|
|
1484
1535
|
"2️⃣ ",
|
|
1485
1536
|
"3️⃣ ",
|
|
1486
1537
|
"4️⃣ "
|
|
1487
|
-
],
|
|
1538
|
+
], Ar = [{
|
|
1488
1539
|
id: "unit",
|
|
1489
1540
|
label: "Run unit tests",
|
|
1490
1541
|
command: "vitest",
|
|
@@ -1497,30 +1548,30 @@ var Sr = [
|
|
|
1497
1548
|
arguments: ["test", "--pass-with-no-tests"],
|
|
1498
1549
|
configFileName: "playwright.config.ts"
|
|
1499
1550
|
}];
|
|
1500
|
-
async function
|
|
1551
|
+
async function jr(t = ["unit"]) {
|
|
1501
1552
|
try {
|
|
1502
1553
|
s("Test Project");
|
|
1503
1554
|
let n = 0;
|
|
1504
|
-
for (let r of
|
|
1555
|
+
for (let r of Ar) {
|
|
1505
1556
|
if (!t.includes(r.id) || await e(r.configFileName) === null) continue;
|
|
1506
|
-
let i = `${
|
|
1557
|
+
let i = `${kr[n] ?? ""} ${r.label}`;
|
|
1507
1558
|
await o(i, r.command, r.arguments), n += 1;
|
|
1508
1559
|
}
|
|
1509
1560
|
if (n === 0) {
|
|
1510
1561
|
console.warn("\n⚠️ No tests configured for this project.\n");
|
|
1511
1562
|
return;
|
|
1512
1563
|
}
|
|
1513
|
-
|
|
1564
|
+
b("Project tested");
|
|
1514
1565
|
} catch (e) {
|
|
1515
1566
|
console.error("❌ Error testing project", e), process.exit(1);
|
|
1516
1567
|
}
|
|
1517
1568
|
}
|
|
1518
1569
|
//#endregion
|
|
1519
1570
|
//#region src/actions/triggerGitHubRelease.ts
|
|
1520
|
-
async function
|
|
1571
|
+
async function Mr() {
|
|
1521
1572
|
try {
|
|
1522
1573
|
s("Trigger GitHub Release");
|
|
1523
|
-
let e = `v${(await
|
|
1574
|
+
let e = `v${(await S("package.json")).version ?? "unknown"}`;
|
|
1524
1575
|
await o("1️⃣ Trigger GitHub release", "gh", [
|
|
1525
1576
|
"release",
|
|
1526
1577
|
"create",
|
|
@@ -1529,10 +1580,10 @@ async function Tr() {
|
|
|
1529
1580
|
"main",
|
|
1530
1581
|
"--generate-notes",
|
|
1531
1582
|
"--latest"
|
|
1532
|
-
]),
|
|
1583
|
+
]), b(`GitHub release '${e}' created.`);
|
|
1533
1584
|
} catch (e) {
|
|
1534
1585
|
console.error("❌ Error triggering GitHub release", e), process.exit(1);
|
|
1535
1586
|
}
|
|
1536
1587
|
}
|
|
1537
1588
|
//#endregion
|
|
1538
|
-
export {
|
|
1589
|
+
export { ye as auditDependencies, Te as buildProject, ze as checkProject, pr as documentProject, mr as formatCode, hr as lintCode, Tr as publishProject, Dr as releaseProject, Or as syncProjectWithGitHub, jr as testProject, Mr as triggerGitHubRelease, $ as uploadDirectoryToR2 };
|