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