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