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