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