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