@dpuse/dpuse-development 0.3.792 → 0.3.795
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/.gitattributes +0 -2
- package/README.md +12 -11
- package/dist/dpuse-development.es.js +154 -142
- package/dist/dpuse-development.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -127,18 +127,25 @@ async function xe() {
|
|
|
127
127
|
}), await e("3️⃣ Install updated dependencies", "npm", [
|
|
128
128
|
"install",
|
|
129
129
|
"--prefer-online",
|
|
130
|
-
"--no-strict-allow-scripts"
|
|
131
|
-
|
|
130
|
+
"--no-strict-allow-scripts",
|
|
131
|
+
"--no-audit",
|
|
132
|
+
"--no-fund"
|
|
133
|
+
]), await e("4️⃣ Fix vulnerabilities where a compatible upgrade exists", "npm", [
|
|
134
|
+
"audit",
|
|
135
|
+
"fix",
|
|
136
|
+
"--no-strict-allow-scripts",
|
|
137
|
+
"--no-fund"
|
|
138
|
+
], !0);
|
|
132
139
|
let n = await Se();
|
|
133
|
-
n.length > 0 ? await e("
|
|
140
|
+
n.length > 0 ? await e("5️⃣ Move install-script pins to installed versions", "npm", [
|
|
134
141
|
"install-scripts",
|
|
135
142
|
"approve",
|
|
136
143
|
...n
|
|
137
|
-
]) : a("
|
|
144
|
+
]) : a("5️⃣ No pinned install-script approvals to move"), process.platform === "darwin" ? await e("6️⃣ Remove unused install-script entries", "npm", ["install-scripts", "prune"]) : a("6️⃣ Skipped removing unused install-script entries (macOS only)"), n.length > 0 && await e("7️⃣ Run install scripts skipped in steps 3 and 4", "npm", [
|
|
138
145
|
"rebuild",
|
|
139
146
|
...n,
|
|
140
147
|
"--no-strict-allow-scripts"
|
|
141
|
-
]), await e("
|
|
148
|
+
]), await e("8️⃣ Confirm every install script is reviewed", "npm", [
|
|
142
149
|
"install",
|
|
143
150
|
"--strict-allow-scripts",
|
|
144
151
|
"--no-audit",
|
|
@@ -348,7 +355,7 @@ var Ge = "<!-- OPENING_START -->", Ke = "<!-- OPENING_END -->";
|
|
|
348
355
|
async function qe() {
|
|
349
356
|
try {
|
|
350
357
|
f("Document Opening"), a("1️⃣ Insert opening content into 'README.md'");
|
|
351
|
-
let e = await C("package.json"), n = await C("config.json"), { owner: i, repo: o } = r(e, "document opening"), s = Je(e), c =
|
|
358
|
+
let e = await C("package.json"), n = await C("config.json"), { owner: i, repo: o } = r(e, "document opening"), s = Je(e), c = Xe(n), l = Ze(i, o, s, v(n.id).publishedTo === "npm" ? Ye(e) : void 0, e.description, c);
|
|
352
359
|
await t(l, Ge, Ke), d("Opening documented");
|
|
353
360
|
} catch (e) {
|
|
354
361
|
console.error("❌ Error documenting opening", e), process.exit(1);
|
|
@@ -360,16 +367,21 @@ function Je(e) {
|
|
|
360
367
|
return t;
|
|
361
368
|
}
|
|
362
369
|
function Ye(e) {
|
|
370
|
+
let t = e.name;
|
|
371
|
+
if (t == null || t === "") throw Error("package.json 'name' field is required to document opening.");
|
|
372
|
+
return t;
|
|
373
|
+
}
|
|
374
|
+
function Xe(e) {
|
|
363
375
|
let t = e.description.en, n = (Array.isArray(t) ? t : [t]).filter((e) => typeof e == "string" && e !== "");
|
|
364
376
|
return n.length === 0 ? void 0 : n.join("\n\n");
|
|
365
377
|
}
|
|
366
|
-
function
|
|
367
|
-
let
|
|
378
|
+
function Ze(e, t, n, r, i, a) {
|
|
379
|
+
let o = `https://github.com/${e}/${t}`;
|
|
368
380
|
return `[}-blue.svg)](./LICENSE)
|
|
369
|
-
[](${
|
|
370
|
-
[](${o}/releases/latest)${r === void 0 ? "" : `\n[](https://www.npmjs.com/package/${r})`}
|
|
382
|
+
[](${o}/actions/workflows/ci.yml)
|
|
371
383
|
|
|
372
|
-
[DPUse](https://www.dpuse.app) · [Report a Vulnerability](${
|
|
384
|
+
[DPUse](https://www.dpuse.app) · [Report a Vulnerability](${o}/security/advisories/new) · [Open an Issue](${o}/issues)${i == null || i === "" ? "" : `\n\n${i}`}
|
|
373
385
|
|
|
374
386
|
## About DPUse
|
|
375
387
|
|
|
@@ -381,7 +393,7 @@ DPUse (Data Positioning & Use) is an in-browser application that positions your
|
|
|
381
393
|
|
|
382
394
|
**Publishing** uses a library of [Presenters](https://www.dpuse.app) to render standard [Presentations](https://www.dpuse.app) immediately using the contextualised data; additionally, [Cookbooks](https://www.dpuse.app) of [Recipes](https://www.dpuse.app) let you build Data Apps using your preferred tools.
|
|
383
395
|
|
|
384
|
-
In addition, DPUse provides [Tools](https://www.dpuse.app) used by the application, and you can use them to construct connectors and presenters.${
|
|
396
|
+
In addition, DPUse provides [Tools](https://www.dpuse.app) used by the application, and you can use them to construct connectors and presenters.${a === void 0 ? "" : `\n\n## Introduction\n\n${a}`}`;
|
|
385
397
|
}
|
|
386
398
|
//#endregion
|
|
387
399
|
//#region src/actions/documentQualitySecurity.ts
|
|
@@ -389,27 +401,27 @@ var M = {
|
|
|
389
401
|
"Branch-Protection": 3,
|
|
390
402
|
"Code-Review": 0,
|
|
391
403
|
Contributors: 0
|
|
392
|
-
},
|
|
404
|
+
}, Qe = /* @__PURE__ */ new Set(["CII-Best-Practices"]), $e = "coverage/coverage-final.json", et = "coverage/coverage-summary.json", tt = 80, nt = 60, N = "code-health-reports/vitest/badge.json", rt = {
|
|
393
405
|
actions: "GitHub Actions",
|
|
394
406
|
"javascript-typescript": "JavaScript/TypeScript",
|
|
395
407
|
rust: "Rust"
|
|
396
|
-
},
|
|
408
|
+
}, it = {
|
|
397
409
|
A: "brightgreen",
|
|
398
410
|
B: "green",
|
|
399
411
|
C: "yellow",
|
|
400
412
|
D: "orange",
|
|
401
413
|
F: "red"
|
|
402
|
-
},
|
|
403
|
-
async function
|
|
414
|
+
}, P = `${p}/health.json`, at = ae(oe);
|
|
415
|
+
async function ot() {
|
|
404
416
|
try {
|
|
405
417
|
f("Document Quality & Security");
|
|
406
|
-
let e = await C("package.json"), n = await
|
|
418
|
+
let e = await C("package.json"), n = await st(e), i = await lt(e, n === void 0 ? [] : ["--coverage", $e]), { owner: o, repo: s } = r(e, "document quality and security");
|
|
407
419
|
a("4️⃣ Read security checks and settings");
|
|
408
|
-
let c = await
|
|
420
|
+
let c = await dt(o, s, e);
|
|
409
421
|
a("5️⃣ Look up OpenSSF Best Practices badge and Scorecard results");
|
|
410
|
-
let [l, u] = await Promise.all([
|
|
422
|
+
let [l, u] = await Promise.all([ft(`https://github.com/${o}/${s}`), pt(`github.com/${o}/${s}`)]);
|
|
411
423
|
a("6️⃣ Insert quality and security content into 'README.md'");
|
|
412
|
-
let p =
|
|
424
|
+
let p = gt(o, s, {
|
|
413
425
|
coveragePercent: n,
|
|
414
426
|
fallowHealth: i,
|
|
415
427
|
securitySettings: c
|
|
@@ -419,7 +431,7 @@ async function it() {
|
|
|
419
431
|
console.error("❌ Error documenting quality and security", e), process.exit(1);
|
|
420
432
|
}
|
|
421
433
|
}
|
|
422
|
-
async function
|
|
434
|
+
async function st(t) {
|
|
423
435
|
if (t.devDependencies?.["@vitest/coverage-v8"] == null) {
|
|
424
436
|
a("1️⃣ Test coverage NOT measured, as '@vitest/coverage-v8' is not installed");
|
|
425
437
|
return;
|
|
@@ -429,25 +441,25 @@ async function at(t) {
|
|
|
429
441
|
"--passWithNoTests",
|
|
430
442
|
"--coverage"
|
|
431
443
|
]);
|
|
432
|
-
let n = await S(
|
|
444
|
+
let n = await S(et);
|
|
433
445
|
if (n === null) return;
|
|
434
446
|
let r = JSON.parse(n).total.lines.pct;
|
|
435
|
-
return await
|
|
447
|
+
return await ct(r), r;
|
|
436
448
|
}
|
|
437
|
-
async function
|
|
449
|
+
async function ct(e) {
|
|
438
450
|
let t = [
|
|
439
451
|
"red",
|
|
440
452
|
"yellow",
|
|
441
453
|
"brightgreen"
|
|
442
|
-
], n = Number(e >=
|
|
443
|
-
await i(
|
|
454
|
+
], n = Number(e >= nt) + Number(e >= tt);
|
|
455
|
+
await i(N, {
|
|
444
456
|
schemaVersion: 1,
|
|
445
457
|
label: "coverage",
|
|
446
458
|
message: `${e.toFixed(1)}%`,
|
|
447
459
|
color: t[n]
|
|
448
460
|
});
|
|
449
461
|
}
|
|
450
|
-
async function
|
|
462
|
+
async function lt(e, t) {
|
|
451
463
|
if (e.devDependencies?.fallow == null) {
|
|
452
464
|
a("2️⃣ Code health NOT measured, as Fallow is not installed"), a("3️⃣ Code health report NOT required");
|
|
453
465
|
return;
|
|
@@ -458,32 +470,32 @@ async function st(e, t) {
|
|
|
458
470
|
"--format",
|
|
459
471
|
"json",
|
|
460
472
|
...t
|
|
461
|
-
],
|
|
462
|
-
let n = await C(
|
|
463
|
-
return await
|
|
473
|
+
], P), await x("3️⃣ Write code health report", "fallow", ["--format", "markdown"], o, !0);
|
|
474
|
+
let n = await C(P);
|
|
475
|
+
return await ut(n), n;
|
|
464
476
|
}
|
|
465
|
-
async function
|
|
477
|
+
async function ut(e) {
|
|
466
478
|
let { score: t, grade: n } = e.health_score;
|
|
467
479
|
await i(y, {
|
|
468
480
|
schemaVersion: 1,
|
|
469
481
|
label: "fallow",
|
|
470
482
|
message: `${n} (${String(Math.round(t))})`,
|
|
471
|
-
color:
|
|
483
|
+
color: it[n] ?? "lightgrey"
|
|
472
484
|
});
|
|
473
485
|
}
|
|
474
|
-
async function
|
|
486
|
+
async function dt(e, t, n) {
|
|
475
487
|
let [r, i, a] = await Promise.all([
|
|
476
488
|
S(".github/workflows/ci.yml"),
|
|
477
489
|
S(".github/workflows/codeql.yml"),
|
|
478
490
|
S(".github/dependabot.yml")
|
|
479
491
|
]), [o, s, c, l] = await Promise.all([
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
492
|
+
F(`repos/${e}/${t}`),
|
|
493
|
+
F(`repos/${e}/${t}/private-vulnerability-reporting`),
|
|
494
|
+
F(`repos/${e}/${t}/vulnerability-alerts`),
|
|
495
|
+
F(`repos/${e}/${t}/commits/main/check-runs?per_page=100`)
|
|
484
496
|
]), u = o === void 0 ? void 0 : JSON.parse(o).security_and_analysis, d = (e) => u?.[e] === void 0 ? void 0 : u[e].status === "enabled", f = new Set((l === void 0 ? [] : JSON.parse(l).check_runs).map((e) => e.app?.slug)), p = a?.match(/package-ecosystem:/g)?.length ?? 0, m = a?.match(/open-pull-requests-limit: 0\b/g)?.length ?? 0;
|
|
485
497
|
return {
|
|
486
|
-
codeQLLanguages: (i ?? "").matchAll(/- language: ([\w-]+)/g).map(([, e = ""]) =>
|
|
498
|
+
codeQLLanguages: (i ?? "").matchAll(/- language: ([\w-]+)/g).map(([, e = ""]) => rt[e] ?? e).toArray(),
|
|
487
499
|
codeQLQueries: /queries: ([\w-]+)/.exec(i ?? "")?.[1],
|
|
488
500
|
dependabotAlerts: c !== void 0,
|
|
489
501
|
dependabotSecurityUpdates: d("dependabot_security_updates"),
|
|
@@ -500,37 +512,37 @@ async function lt(e, t, n) {
|
|
|
500
512
|
testsInCI: r?.includes("npm test") ?? !1
|
|
501
513
|
};
|
|
502
514
|
}
|
|
503
|
-
async function
|
|
515
|
+
async function F(e) {
|
|
504
516
|
try {
|
|
505
|
-
let { stdout: t } = await
|
|
517
|
+
let { stdout: t } = await at("gh", ["api", e]);
|
|
506
518
|
return t;
|
|
507
519
|
} catch (e) {
|
|
508
520
|
if (String(e.stderr).includes("HTTP 404")) return;
|
|
509
521
|
throw e;
|
|
510
522
|
}
|
|
511
523
|
}
|
|
512
|
-
async function
|
|
524
|
+
async function ft(e) {
|
|
513
525
|
let t = await fetch(`https://www.bestpractices.dev/projects.json?url=${encodeURIComponent(e)}`);
|
|
514
526
|
if (!t.ok) throw Error(`OpenSSF Best Practices lookup failed with status ${String(t.status)}.`);
|
|
515
527
|
return (await t.json()).find((t) => t.repo_url === e)?.id;
|
|
516
528
|
}
|
|
517
|
-
async function
|
|
529
|
+
async function pt(e) {
|
|
518
530
|
let t = await fetch(`https://api.scorecard.dev/projects/${e}`);
|
|
519
531
|
if (t.status !== 404) {
|
|
520
532
|
if (!t.ok) throw Error(`OpenSSF Scorecard lookup failed with status ${String(t.status)}.`);
|
|
521
533
|
return await t.json();
|
|
522
534
|
}
|
|
523
535
|
}
|
|
524
|
-
function
|
|
525
|
-
return e.checks.every(({ name: e, score: t }) => t === -1 || t === 10 ||
|
|
536
|
+
function mt(e) {
|
|
537
|
+
return e.checks.every(({ name: e, score: t }) => t === -1 || t === 10 || Qe.has(e) || M[e] !== void 0 && t >= M[e]);
|
|
526
538
|
}
|
|
527
|
-
function
|
|
539
|
+
function I(e) {
|
|
528
540
|
return e === !1 ? " These are handled manually." : "";
|
|
529
541
|
}
|
|
530
|
-
function
|
|
542
|
+
function L(e) {
|
|
531
543
|
return e === void 0 ? "❔ Unknown" : e ? "✅ On" : "❌ Off";
|
|
532
544
|
}
|
|
533
|
-
function
|
|
545
|
+
function R(e, t) {
|
|
534
546
|
return t.length === 0 ? "" : `### ${e}
|
|
535
547
|
|
|
536
548
|
|Check|Status|What it does|
|
|
@@ -539,90 +551,90 @@ ${t.map((e) => `|${e.join("|")}|`).join("\n")}
|
|
|
539
551
|
|
|
540
552
|
`;
|
|
541
553
|
}
|
|
542
|
-
function
|
|
554
|
+
function z(e, t, n, r) {
|
|
543
555
|
return `})`;
|
|
544
556
|
}
|
|
545
|
-
function
|
|
557
|
+
function ht(e, t, { coveragePercent: n, fallowHealth: r, securitySettings: i }) {
|
|
546
558
|
let a = `https://github.com/${e}/${t}`, s = (e) => e ? ` Part of the [CI workflow](${a}/actions/workflows/ci.yml) on every push and pull request to \`main\`.` : "", c = [[
|
|
547
559
|
"Unit tests",
|
|
548
|
-
|
|
560
|
+
L(i.testsInCI),
|
|
549
561
|
`[Vitest](https://vitest.dev) runs the unit tests.${s(i.testsInCI)}`
|
|
550
562
|
], [
|
|
551
563
|
"Property-based tests",
|
|
552
|
-
|
|
564
|
+
L(i.propertyTests),
|
|
553
565
|
`[fast-check](https://fast-check.dev) runs many random inputs per test to find edge cases, alongside the unit tests.${s(i.propertyTests && i.testsInCI)}`
|
|
554
566
|
]];
|
|
555
567
|
n !== void 0 && c.push([
|
|
556
568
|
"Test coverage",
|
|
557
|
-
|
|
558
|
-
`${
|
|
569
|
+
L(!0),
|
|
570
|
+
`${z(e, t, "Coverage", N)} [Vitest's V8 coverage](https://vitest.dev/guide/coverage) measures the share of source lines the unit tests run. The target is ${String(tt)}%.`
|
|
559
571
|
]);
|
|
560
572
|
let l = `[](https://sonarcloud.io/summary/new_code?id=${e}_${t}) `, u = [[
|
|
561
573
|
"Code analysis",
|
|
562
|
-
|
|
574
|
+
L(i.sonarCloud),
|
|
563
575
|
`${i.sonarCloud ? l : ""}[SonarCloud](https://sonarcloud.io) checks every push for bugs, code smells and vulnerabilities.`
|
|
564
576
|
], [
|
|
565
577
|
"Linting",
|
|
566
|
-
|
|
578
|
+
L(i.lintInCI),
|
|
567
579
|
`[ESLint](https://eslint.org) checks the code for errors and style problems.${s(i.lintInCI)}`
|
|
568
580
|
]];
|
|
569
581
|
r !== void 0 && u.unshift([
|
|
570
582
|
"Code health",
|
|
571
|
-
|
|
572
|
-
`[${
|
|
583
|
+
L(!0),
|
|
584
|
+
`[${z(e, t, "Fallow code health", y)}](./${o}) [Fallow](https://github.com/fallow-rs/fallow) finds unused code, duplication, complexity and dependency problems.`
|
|
573
585
|
]);
|
|
574
586
|
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 = [
|
|
575
587
|
[
|
|
576
588
|
"Push protection",
|
|
577
|
-
|
|
589
|
+
L(i.pushProtection),
|
|
578
590
|
"[GitHub push protection](https://docs.github.com/en/code-security/secret-scanning/push-protection-for-repositories-and-organizations) blocks pushes that contain credentials."
|
|
579
591
|
],
|
|
580
592
|
[
|
|
581
593
|
"Static analysis",
|
|
582
|
-
|
|
594
|
+
L(d),
|
|
583
595
|
`${d ? f : ""}[CodeQL](https://codeql.github.com) scans${m} for security vulnerabilities, ${p}, on every push and pull request to \`main\` and weekly.`
|
|
584
596
|
],
|
|
585
597
|
[
|
|
586
598
|
"Secret scanning",
|
|
587
|
-
|
|
599
|
+
L(i.secretScanning),
|
|
588
600
|
"[GitHub secret scanning](https://docs.github.com/en/code-security/secret-scanning) detects credentials, such as API keys and tokens, committed to the repository."
|
|
589
601
|
]
|
|
590
602
|
], g = "[Dependabot](https://docs.github.com/en/code-security/dependabot)", _ = [
|
|
591
603
|
[
|
|
592
604
|
"Vulnerability audit",
|
|
593
|
-
|
|
605
|
+
L(i.npmAuditInCI),
|
|
594
606
|
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.${s(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.${s(i.npmAuditInCI)}`
|
|
595
607
|
],
|
|
596
608
|
[
|
|
597
609
|
"Supply chain risk",
|
|
598
|
-
|
|
610
|
+
L(i.socket),
|
|
599
611
|
"[Socket](https://socket.dev) flags malicious packages, typosquatting and suspicious behaviour that may not yet have a CVE."
|
|
600
612
|
],
|
|
601
613
|
[
|
|
602
614
|
"Security alerts",
|
|
603
|
-
|
|
615
|
+
L(i.dependabotAlerts),
|
|
604
616
|
`${g} alerts when a dependency has a known vulnerability, using the GitHub Advisory Database.`
|
|
605
617
|
],
|
|
606
618
|
[
|
|
607
619
|
"Security updates",
|
|
608
|
-
|
|
609
|
-
`${g} opens pull requests that update vulnerable dependencies.${
|
|
620
|
+
L(i.dependabotSecurityUpdates),
|
|
621
|
+
`${g} opens pull requests that update vulnerable dependencies.${I(i.dependabotSecurityUpdates)}`
|
|
610
622
|
],
|
|
611
623
|
[
|
|
612
624
|
"Version updates",
|
|
613
|
-
|
|
614
|
-
`${g} opens pull requests for new dependency versions.${
|
|
625
|
+
L(i.dependabotVersionUpdates),
|
|
626
|
+
`${g} opens pull requests for new dependency versions.${I(i.dependabotVersionUpdates)}`
|
|
615
627
|
]
|
|
616
628
|
];
|
|
617
629
|
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.
|
|
618
630
|
|
|
619
|
-
${
|
|
631
|
+
${R("Testing", c)}${R("Code Quality", u)}${R("Security Analysis", h)}${R("Dependencies", _)}`;
|
|
620
632
|
}
|
|
621
|
-
function
|
|
622
|
-
let a = `https://github.com/${e}/${t}`, o = `github.com/${e}/${t}`, s = `https://www.bestpractices.dev/projects/${String(r)}`, c = i !== void 0 &&
|
|
633
|
+
function gt(e, t, n, r, i) {
|
|
634
|
+
let a = `https://github.com/${e}/${t}`, o = `github.com/${e}/${t}`, s = `https://www.bestpractices.dev/projects/${String(r)}`, c = i !== void 0 && mt(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.";
|
|
623
635
|
return `## Quality & Security
|
|
624
636
|
|
|
625
|
-
${
|
|
637
|
+
${ht(e, t, n)}### OpenSSF 🚧
|
|
626
638
|
|
|
627
639
|
${l}[](https://scorecard.dev/viewer/?uri=${o})
|
|
628
640
|
|
|
@@ -634,37 +646,37 @@ Please do not open public GitHub issues for security vulnerabilities. ${u}`;
|
|
|
634
646
|
}
|
|
635
647
|
//#endregion
|
|
636
648
|
//#region src/actions/documentUsage.ts
|
|
637
|
-
var
|
|
649
|
+
var _t = "<!-- USAGE_START -->", vt = "<!-- USAGE_END -->", yt = /* @__PURE__ */ new Set([
|
|
638
650
|
"connector",
|
|
639
651
|
"cookbook",
|
|
640
652
|
"presenter"
|
|
641
|
-
]),
|
|
642
|
-
async function
|
|
653
|
+
]), bt = /* @__PURE__ */ new Set(["development", "eslint"]), xt = "> [!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.", St = "This repository manages itself using the actions it implements.", Ct = "This repository is managed using the common set of actions provided by [@dpuse/dpuse-development](https://github.com/dpuse/dpuse-development).";
|
|
654
|
+
async function wt() {
|
|
643
655
|
try {
|
|
644
656
|
f("Document Usage"), a("1️⃣ Insert usage content into 'README.md'");
|
|
645
|
-
let [e, n] = await Promise.all([C("package.json"), C("config.json")]), r =
|
|
646
|
-
await t(p,
|
|
657
|
+
let [e, n] = await Promise.all([C("package.json"), C("config.json")]), r = Tt(e), i = Et(r), o = B(e.engines?.node), s = B(e.engines?.npm), c = B(e.devDependencies?.typescript), l = Dt(v(n.id), e.name), u = `${r.replace(/\.git$/, "")}/blob/main/package.json`, p = Ot(l, r, i, o, s, c, `${e.name === "@dpuse/dpuse-development" ? St : Ct} See the \`scripts\` block in [package.json](${u}) for details.`);
|
|
658
|
+
await t(p, _t, vt), d("Usage documented");
|
|
647
659
|
} catch (e) {
|
|
648
660
|
console.error("❌ Error documenting usage", e), process.exit(1);
|
|
649
661
|
}
|
|
650
662
|
}
|
|
651
|
-
function
|
|
663
|
+
function Tt(e) {
|
|
652
664
|
let t = e.repository, n = typeof t == "string" ? t : t?.url;
|
|
653
665
|
if (n == null || n === "") throw Error("package.json 'repository' field is required to document usage.");
|
|
654
666
|
return n.replace(/^git\+/, "");
|
|
655
667
|
}
|
|
656
|
-
function
|
|
668
|
+
function Et(e) {
|
|
657
669
|
return (e.split("/").at(-1) ?? "").replace(/\.git$/, "");
|
|
658
670
|
}
|
|
659
|
-
function
|
|
671
|
+
function B(e) {
|
|
660
672
|
if (e == null) throw Error("package.json version range is required to document usage.");
|
|
661
673
|
let t = /\d+(?:\.\d+)*/.exec(e);
|
|
662
674
|
if (t == null) throw Error(`Unable to parse version from '${e}'.`);
|
|
663
675
|
return t[0];
|
|
664
676
|
}
|
|
665
|
-
function
|
|
677
|
+
function Dt(e, t) {
|
|
666
678
|
let { typeId: n } = e;
|
|
667
|
-
if (
|
|
679
|
+
if (yt.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.
|
|
668
680
|
|
|
669
681
|
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.`;
|
|
670
682
|
if (e.publishedTo === "npm") {
|
|
@@ -675,11 +687,11 @@ You may view or clone this repository for your own purposes, such as building a
|
|
|
675
687
|
npm install ${t}
|
|
676
688
|
\`\`\`
|
|
677
689
|
|
|
678
|
-
${
|
|
690
|
+
${bt.has(n) ? `${xt}\n\n` : ""}To work on the source instead, clone this repository.`;
|
|
679
691
|
}
|
|
680
692
|
return "You may view or clone this repository for your own purposes.";
|
|
681
693
|
}
|
|
682
|
-
function
|
|
694
|
+
function Ot(e, t, n, r, i, a, o) {
|
|
683
695
|
return `## Usage
|
|
684
696
|
|
|
685
697
|
${e}
|
|
@@ -696,93 +708,93 @@ ${o}`;
|
|
|
696
708
|
}
|
|
697
709
|
//#endregion
|
|
698
710
|
//#region src/actions/documentApiReference.ts
|
|
699
|
-
var
|
|
700
|
-
async function
|
|
711
|
+
var V = "API_REFERENCE.md";
|
|
712
|
+
async function kt() {
|
|
701
713
|
try {
|
|
702
714
|
f("Document API Reference");
|
|
703
715
|
let { writeAPIReference: e } = await import("./apiReference-DCzx5xFp.js");
|
|
704
|
-
await e("1️⃣ ",
|
|
716
|
+
await e("1️⃣ ", V), d("API reference documented");
|
|
705
717
|
} catch (e) {
|
|
706
718
|
console.error("❌ Error documenting API reference", e), process.exit(1);
|
|
707
719
|
}
|
|
708
720
|
}
|
|
709
721
|
//#endregion
|
|
710
722
|
//#region src/actions/documentBundleSizes.ts
|
|
711
|
-
var
|
|
712
|
-
async function
|
|
723
|
+
var H = "bundle-analysis-reports/sonda/index.json", At = "<!-- BUNDLE_START -->", jt = "<!-- BUNDLE_END -->", U = " ", W = 20, Mt = "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._", G = "(bundler output, whitespace & JSON)", Nt = `${G} = 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.`;
|
|
724
|
+
async function Pt(e) {
|
|
713
725
|
try {
|
|
714
726
|
f("Document Bundle Sizes"), a("1️⃣ Read bundle analysis report");
|
|
715
|
-
let n = await C(
|
|
727
|
+
let n = await C(H);
|
|
716
728
|
a("2️⃣ Insert table into 'README.md'");
|
|
717
|
-
let r =
|
|
718
|
-
await t(`## Bundle Analysis\n\n${
|
|
729
|
+
let r = Ft(n, e?.moduleLevel ?? !1);
|
|
730
|
+
await t(`## Bundle Analysis\n\n${Mt}\n\n${r}\n\n${Nt}`, At, jt), d("Bundle sizes documented");
|
|
719
731
|
} catch (e) {
|
|
720
732
|
console.error("❌ Error documenting bundle sizes", e), process.exit(1);
|
|
721
733
|
}
|
|
722
734
|
}
|
|
723
|
-
function
|
|
724
|
-
let n =
|
|
735
|
+
function Ft(e, t) {
|
|
736
|
+
let n = zt(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, Y(e)]).toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), a = ["|Chunk/Module/File|Composition|", "|:------ |:-----------|"];
|
|
725
737
|
for (let [e, o] of i) {
|
|
726
|
-
let i = [...n.get(e) ?? /* @__PURE__ */ new Map()].toSorted((e, t) => t[1].sizes.uncompressed - e[1].sizes.uncompressed), s = i.length === 1 ?
|
|
738
|
+
let i = [...n.get(e) ?? /* @__PURE__ */ new Map()].toSorted((e, t) => t[1].sizes.uncompressed - e[1].sizes.uncompressed), s = i.length === 1 ? It(e, o, Rt(i), r, t) : Lt(e, o, i, r, t);
|
|
727
739
|
a.push(...s);
|
|
728
740
|
}
|
|
729
741
|
return a.join("\n");
|
|
730
742
|
}
|
|
731
|
-
function
|
|
743
|
+
function It(e, t, n, r, i) {
|
|
732
744
|
let [a, { sizes: o, files: s }] = n, c = r > 0 ? o.uncompressed / r * 100 : 0;
|
|
733
|
-
if (s.size === 1) return [`| ${e} → ${
|
|
734
|
-
let l = [`| ${e} → ${a} | ${
|
|
735
|
-
return i || l.push(...
|
|
745
|
+
if (s.size === 1) return [`| ${e} → ${q(a, J(s))} | ${X(t)} · ${Z(c)} |`];
|
|
746
|
+
let l = [`| ${e} → ${a} | ${X(t)} · ${Z(c)} |`];
|
|
747
|
+
return i || l.push(...K(s, U, r)), l;
|
|
736
748
|
}
|
|
737
|
-
function
|
|
738
|
-
let a = [`| ${e} | ${
|
|
749
|
+
function Lt(e, t, n, r, i) {
|
|
750
|
+
let a = [`| ${e} | ${X(t)} |`];
|
|
739
751
|
for (let [e, { sizes: t, files: o }] of n) {
|
|
740
752
|
let n = r > 0 ? t.uncompressed / r * 100 : 0;
|
|
741
753
|
if (o.size === 1) {
|
|
742
|
-
let t =
|
|
743
|
-
a.push(`| ${
|
|
754
|
+
let t = J(o);
|
|
755
|
+
a.push(`| ${U}${q(e, t)} | ${Z(n)} |`);
|
|
744
756
|
continue;
|
|
745
757
|
}
|
|
746
|
-
a.push(`| ${
|
|
758
|
+
a.push(`| ${U}${e} | ${Z(n)} |`), i || a.push(...K(o, `${U}${U}`, r));
|
|
747
759
|
}
|
|
748
760
|
return a;
|
|
749
761
|
}
|
|
750
|
-
function
|
|
751
|
-
return [...e].toSorted((e, t) => t[1].uncompressed - e[1].uncompressed).map(([e, r]) => `| ${t}${e} | ${
|
|
762
|
+
function K(e, t, n) {
|
|
763
|
+
return [...e].toSorted((e, t) => t[1].uncompressed - e[1].uncompressed).map(([e, r]) => `| ${t}${e} | ${Z(n > 0 ? r.uncompressed / n * 100 : 0)} |`);
|
|
752
764
|
}
|
|
753
|
-
function
|
|
765
|
+
function q(e, t) {
|
|
754
766
|
return t === "" ? e : `${e} → ${t}`;
|
|
755
767
|
}
|
|
756
|
-
function
|
|
768
|
+
function Rt(e) {
|
|
757
769
|
let [t] = e;
|
|
758
770
|
if (t === void 0) throw Error("Expected exactly one entry");
|
|
759
771
|
return t;
|
|
760
772
|
}
|
|
761
|
-
function
|
|
773
|
+
function J(e) {
|
|
762
774
|
let [t] = e.keys();
|
|
763
775
|
if (t === void 0) throw Error("Expected exactly one file");
|
|
764
776
|
return t;
|
|
765
777
|
}
|
|
766
|
-
function
|
|
767
|
-
let t =
|
|
778
|
+
function zt(e) {
|
|
779
|
+
let t = Bt(e.dependencies), n = /* @__PURE__ */ new Map();
|
|
768
780
|
for (let r of e.resources) {
|
|
769
781
|
if (r.kind !== "chunk" || !r.parent) continue;
|
|
770
|
-
let { group: e, file: i } =
|
|
782
|
+
let { group: e, file: i } = Vt(r.name, t), a = Y(r), o = n.get(r.parent) ?? /* @__PURE__ */ new Map();
|
|
771
783
|
n.set(r.parent, o);
|
|
772
784
|
let s = o.get(e) ?? {
|
|
773
|
-
sizes:
|
|
785
|
+
sizes: Q(),
|
|
774
786
|
files: /* @__PURE__ */ new Map()
|
|
775
787
|
};
|
|
776
|
-
o.set(e, s),
|
|
777
|
-
let c = s.files.get(i) ??
|
|
778
|
-
s.files.set(i, c),
|
|
788
|
+
o.set(e, s), $(s.sizes, a);
|
|
789
|
+
let c = s.files.get(i) ?? Q();
|
|
790
|
+
s.files.set(i, c), $(c, a);
|
|
779
791
|
}
|
|
780
792
|
return n;
|
|
781
793
|
}
|
|
782
|
-
function
|
|
794
|
+
function Bt(e) {
|
|
783
795
|
return e.flatMap((e) => e.paths.map((t) => [t, e.name])).toSorted((e, t) => t[0].length - e[0].length);
|
|
784
796
|
}
|
|
785
|
-
function
|
|
797
|
+
function Vt(e, t) {
|
|
786
798
|
let n = t.find(([t]) => e === t || e.startsWith(`${t}/`));
|
|
787
799
|
if (n) {
|
|
788
800
|
let [t, r] = n;
|
|
@@ -792,39 +804,39 @@ function zt(e, t) {
|
|
|
792
804
|
};
|
|
793
805
|
}
|
|
794
806
|
return e === "[unassigned]" ? {
|
|
795
|
-
group:
|
|
807
|
+
group: G,
|
|
796
808
|
file: ""
|
|
797
809
|
} : e.startsWith("\0") ? {
|
|
798
810
|
group: "(runtime)",
|
|
799
811
|
file: e.slice(1)
|
|
800
812
|
} : {
|
|
801
813
|
group: e.startsWith("rust/") || e.includes("vite-plugin-wasm") ? "wasm" : "src",
|
|
802
|
-
file:
|
|
814
|
+
file: Ht(e)
|
|
803
815
|
};
|
|
804
816
|
}
|
|
805
|
-
function
|
|
817
|
+
function Ht(e) {
|
|
806
818
|
return e.split("/").at(-1) ?? e;
|
|
807
819
|
}
|
|
808
|
-
function
|
|
820
|
+
function Y(e) {
|
|
809
821
|
return {
|
|
810
822
|
uncompressed: e.uncompressed,
|
|
811
823
|
gzip: e.gzip ?? 0
|
|
812
824
|
};
|
|
813
825
|
}
|
|
814
|
-
function
|
|
826
|
+
function X(e) {
|
|
815
827
|
return `${Ut(e.uncompressed)} · gzip ${Ut(e.gzip)}`;
|
|
816
828
|
}
|
|
817
|
-
function
|
|
818
|
-
let t = Math.round(e / 100 *
|
|
819
|
-
return `\`${"█".repeat(t)}${"░".repeat(
|
|
829
|
+
function Z(e) {
|
|
830
|
+
let t = Math.round(e / 100 * W);
|
|
831
|
+
return `\`${"█".repeat(t)}${"░".repeat(W - t)}\` ${e.toFixed(1)}%`;
|
|
820
832
|
}
|
|
821
|
-
function
|
|
833
|
+
function Q() {
|
|
822
834
|
return {
|
|
823
835
|
uncompressed: 0,
|
|
824
836
|
gzip: 0
|
|
825
837
|
};
|
|
826
838
|
}
|
|
827
|
-
function
|
|
839
|
+
function $(e, t) {
|
|
828
840
|
e.uncompressed += t.uncompressed, e.gzip += t.gzip;
|
|
829
841
|
}
|
|
830
842
|
function Ut(e) {
|
|
@@ -835,12 +847,12 @@ function Ut(e) {
|
|
|
835
847
|
async function Wt(t = "MIT", n = !1) {
|
|
836
848
|
try {
|
|
837
849
|
let r = await C("config.json"), i = v(r.id).typeId === "connector";
|
|
838
|
-
await qe(), i && await ke(), await
|
|
839
|
-
let o = await S(
|
|
840
|
-
o ? await
|
|
850
|
+
await qe(), i && await ke(), await wt(), await Fe(t), await S("bundle-analysis-reports/sonda/index.json") === null ? a(`ℹ️ Bundle sizes NOT documented, as there is no '${H}' yet. Build the project first.`) : await Pt({ moduleLevel: n }), await ot(), await Ae();
|
|
851
|
+
let o = await S(V) !== null;
|
|
852
|
+
o ? await kt() : a(`ℹ️ '${V}' NOT required by this project`), await e("ℹ️ Format generated files", "prettier", [
|
|
841
853
|
"--write",
|
|
842
854
|
"README.md",
|
|
843
|
-
...o ? [
|
|
855
|
+
...o ? [V] : []
|
|
844
856
|
]);
|
|
845
857
|
} catch (e) {
|
|
846
858
|
console.error("❌ Error documenting project", e), process.exit(1);
|
|
@@ -940,12 +952,12 @@ async function Zt() {
|
|
|
940
952
|
try {
|
|
941
953
|
f("Publish Project");
|
|
942
954
|
let e = await C("package.json"), t = await C("config.json");
|
|
943
|
-
await
|
|
955
|
+
await Qt("1️⃣ ", e, t, v(t.id)), d(`Project version '${e.version ?? "unknown"}' published.`);
|
|
944
956
|
} catch (e) {
|
|
945
957
|
console.error("❌ Error publishing project", e), process.exit(1);
|
|
946
958
|
}
|
|
947
959
|
}
|
|
948
|
-
async function
|
|
960
|
+
async function Qt(e, t, n, r) {
|
|
949
961
|
if (r.typeId === "app") a(`${e} Register module`), await qt();
|
|
950
962
|
else if (r.typeId === "engine") a(`${e} Register module`), await Xt(t, `dpuse-engine-eu/${r.uploadGroupName ?? "unknown"}`), await Yt(n);
|
|
951
963
|
else if (r.uploadGroupName === void 0) a(`${e} Registration NOT required`);
|
|
@@ -957,7 +969,7 @@ async function $(e, t, n, r) {
|
|
|
957
969
|
}
|
|
958
970
|
//#endregion
|
|
959
971
|
//#region src/actions/releaseProject.ts
|
|
960
|
-
async function
|
|
972
|
+
async function $t(t = "MIT", n = !1) {
|
|
961
973
|
try {
|
|
962
974
|
f("Release Project");
|
|
963
975
|
let r = await C("package.json"), i = await C("config.json"), o = v(i.id);
|
|
@@ -971,7 +983,7 @@ async function Qt(t = "MIT", n = !1) {
|
|
|
971
983
|
"push",
|
|
972
984
|
"origin",
|
|
973
985
|
"main:main"
|
|
974
|
-
]), await
|
|
986
|
+
]), await Qt("8️⃣ ", r, s, o), o.publishedTo === "npm") {
|
|
975
987
|
let t = `v${r.version ?? "unknown"}`;
|
|
976
988
|
await e("9️⃣ Create GitHub release", "gh", [
|
|
977
989
|
"release",
|
|
@@ -990,7 +1002,7 @@ async function Qt(t = "MIT", n = !1) {
|
|
|
990
1002
|
}
|
|
991
1003
|
//#endregion
|
|
992
1004
|
//#region src/actions/syncProjectWithGitHub.ts
|
|
993
|
-
async function
|
|
1005
|
+
async function en() {
|
|
994
1006
|
try {
|
|
995
1007
|
f("Synchronise Project with GitHub");
|
|
996
1008
|
let e = await C("package.json"), t = await C("config.json"), n = v(t.id);
|
|
@@ -1009,12 +1021,12 @@ async function $t() {
|
|
|
1009
1021
|
}
|
|
1010
1022
|
//#endregion
|
|
1011
1023
|
//#region src/actions/testProject.ts
|
|
1012
|
-
var
|
|
1024
|
+
var tn = [
|
|
1013
1025
|
"1️⃣ ",
|
|
1014
1026
|
"2️⃣ ",
|
|
1015
1027
|
"3️⃣ ",
|
|
1016
1028
|
"4️⃣ "
|
|
1017
|
-
],
|
|
1029
|
+
], nn = [{
|
|
1018
1030
|
id: "unit",
|
|
1019
1031
|
label: "Run unit tests",
|
|
1020
1032
|
command: "vitest",
|
|
@@ -1027,13 +1039,13 @@ var en = [
|
|
|
1027
1039
|
arguments: ["test", "--pass-with-no-tests"],
|
|
1028
1040
|
configFileName: "playwright.config.ts"
|
|
1029
1041
|
}];
|
|
1030
|
-
async function
|
|
1042
|
+
async function rn(t = ["unit"]) {
|
|
1031
1043
|
try {
|
|
1032
1044
|
f("Test Project");
|
|
1033
1045
|
let n = 0;
|
|
1034
|
-
for (let r of
|
|
1046
|
+
for (let r of nn) {
|
|
1035
1047
|
if (!t.includes(r.id) || await S(r.configFileName) === null) continue;
|
|
1036
|
-
let i = `${
|
|
1048
|
+
let i = `${tn[n] ?? ""} ${r.label}`;
|
|
1037
1049
|
await e(i, r.command, r.arguments), n += 1;
|
|
1038
1050
|
}
|
|
1039
1051
|
if (n === 0) {
|
|
@@ -1046,4 +1058,4 @@ async function nn(t = ["unit"]) {
|
|
|
1046
1058
|
}
|
|
1047
1059
|
}
|
|
1048
1060
|
//#endregion
|
|
1049
|
-
export { ue as auditDependencies, de as buildProject, Ce as checkProject, Wt as documentProject, Gt as formatCode, Kt as lintCode, Zt as publishProject,
|
|
1061
|
+
export { ue as auditDependencies, de as buildProject, Ce as checkProject, Wt as documentProject, Gt as formatCode, Kt as lintCode, Zt as publishProject, $t as releaseProject, en as syncProjectWithGitHub, rn as testProject, Jt as uploadDirectoryToR2 };
|