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