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