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