@dpuse/dpuse-development 1.0.117 → 1.0.119
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 +17 -17
- package/dist/dpuse-development.es.js +231 -212
- package/dist/dpuse-development.es.js.map +1 -1
- package/package.json +2 -2
|
@@ -472,7 +472,7 @@ async function mt(e, t, n) {
|
|
|
472
472
|
let r = await S(N), i = await bt(), a = `${jt(t, !1)}\n\n|Dependency|Version|License(s)|Document|\n|:-|:-:|:-|:-|\n`;
|
|
473
473
|
for (let e of i.values()) a += F(e);
|
|
474
474
|
let o = [];
|
|
475
|
-
r.dependencies != null &&
|
|
475
|
+
r.dependencies != null && Ft(r.dependencies, i, n, o, 0);
|
|
476
476
|
let s = `${ut}\n\n${o.join("\n")}`;
|
|
477
477
|
await _(`${M}\n\n${a.trimEnd()}\n\n### Dependency Tree\n\n${s}`, A, j);
|
|
478
478
|
}
|
|
@@ -482,7 +482,7 @@ async function ht(e, t) {
|
|
|
482
482
|
for (let e of o.values().toArray().toSorted(gt)) u += F(e, c ? "JavaScript" : void 0);
|
|
483
483
|
for (let e of s.values().toArray().toSorted(gt)) u += F(e, "Rust");
|
|
484
484
|
let d = await S(N), f = Object.entries(d.dependencies ?? {}).toSorted(([e], [t]) => Number(!r.has(e)) - Number(!r.has(t))), p = [];
|
|
485
|
-
|
|
485
|
+
I(f, {
|
|
486
486
|
licensesByKey: o,
|
|
487
487
|
shippedKeys: a,
|
|
488
488
|
shownKeys: /* @__PURE__ */ new Set()
|
|
@@ -508,7 +508,7 @@ function _t(e) {
|
|
|
508
508
|
}
|
|
509
509
|
function vt(e, t) {
|
|
510
510
|
let n = " ".repeat(e.depth);
|
|
511
|
-
return e.isOwn ? `${n}- **${e.name}** ${e.version} — this project's Rust code, compiled into its WebAssembly` :
|
|
511
|
+
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);
|
|
512
512
|
}
|
|
513
513
|
function yt(e) {
|
|
514
514
|
return /* @__PURE__ */ new Set([
|
|
@@ -658,36 +658,36 @@ function F(e, t) {
|
|
|
658
658
|
let n = e.licenseFiles.length === 0 ? "⚠️ No license file" : e.licenseFiles.map((e) => `[${e.label}](licenses/${e.path})`).join(" ");
|
|
659
659
|
return `${t === void 0 ? "" : `|${t}`}|[${e.name}](${e.repository})|${e.installedVersion}|${e.licenseTypes}|${n}|\n`;
|
|
660
660
|
}
|
|
661
|
-
function
|
|
661
|
+
function Ft(e, t, n, r, i) {
|
|
662
662
|
let a = " ".repeat(i);
|
|
663
663
|
for (let [o, s] of Object.entries(e)) {
|
|
664
664
|
if (s.version === void 0) continue;
|
|
665
665
|
let e = s.version;
|
|
666
|
-
n.has(`${o}@${e}`) || (r.push(
|
|
666
|
+
n.has(`${o}@${e}`) || (r.push(L(o, e, t.get(`${o}@${e}`), a)), s.dependencies != null && Ft(s.dependencies, t, n, r, i + 1));
|
|
667
667
|
}
|
|
668
668
|
}
|
|
669
|
-
function
|
|
669
|
+
function I(e, t, n, r, i) {
|
|
670
670
|
for (let [a, o] of e) {
|
|
671
671
|
if (o.version === void 0) continue;
|
|
672
672
|
let e = `${a}@${o.version}`, s = Object.entries(o.dependencies ?? {});
|
|
673
673
|
if (!t.shippedKeys.has(e)) {
|
|
674
|
-
|
|
674
|
+
I(s, t, n, r, !0);
|
|
675
675
|
continue;
|
|
676
676
|
}
|
|
677
|
-
i && t.shownKeys.has(e) || (t.shownKeys.add(e), n.push(
|
|
677
|
+
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));
|
|
678
678
|
}
|
|
679
679
|
}
|
|
680
|
-
function
|
|
681
|
-
return `${r}- **${n == null ? e : `[${e}](${n.repository})`}** ${t}${
|
|
680
|
+
function L(e, t, n, r) {
|
|
681
|
+
return `${r}- **${n == null ? e : `[${e}](${n.repository})`}** ${t}${It(n)}`;
|
|
682
682
|
}
|
|
683
|
-
function
|
|
683
|
+
function It(e) {
|
|
684
684
|
if (e == null) return "";
|
|
685
|
-
let t = e.publishedDate ?
|
|
685
|
+
let t = e.publishedDate ? Lt(e.publishedDate.split("T", 1)[0]) : "";
|
|
686
686
|
if (e.latestVersion === "" || e.latestVersion === e.installedVersion) return t === "" ? "" : ` — ${t}`;
|
|
687
|
-
let n = e.latestPublishedDate ?
|
|
687
|
+
let n = e.latestPublishedDate ? Lt(e.latestPublishedDate.split("T", 1)[0]) : "", r = n === "" ? `latest: ${e.latestVersion} ❗` : `latest: ${e.latestVersion} — ${n} ❗`;
|
|
688
688
|
return t === "" ? ` — → ${r}` : ` — ${t} → ${r}`;
|
|
689
689
|
}
|
|
690
|
-
function
|
|
690
|
+
function Lt(e) {
|
|
691
691
|
if (e == null || e === "") return "n/a";
|
|
692
692
|
let t = e.split("T", 1)[0];
|
|
693
693
|
if (t == null || t === "") return "n/a";
|
|
@@ -696,36 +696,45 @@ function It(e) {
|
|
|
696
696
|
}
|
|
697
697
|
//#endregion
|
|
698
698
|
//#region src/actions/documentOpening.ts
|
|
699
|
-
var
|
|
700
|
-
async function
|
|
699
|
+
var Rt = "<!-- OPENING_START -->", zt = "<!-- OPENING_END -->";
|
|
700
|
+
async function Bt() {
|
|
701
701
|
try {
|
|
702
702
|
s("Document Opening"), C("1️⃣ Insert opening content into 'README.md'");
|
|
703
|
-
let e = await S("package.json"), t = await S("config.json"), { owner: n, repository: r } = x(e, "document opening"), i =
|
|
704
|
-
|
|
703
|
+
let e = await S("package.json"), t = await S("config.json"), { owner: n, repository: r } = x(e, "document opening"), i = Ht(e), a = Wt(t), o = m(t.id), c = o.uploadGroupName === void 0 ? void 0 : t.id, l = o.publishedTo === "npm" ? Ut(e) : void 0, u = Gt(n, r, i, {
|
|
704
|
+
description: e.description,
|
|
705
|
+
dpuseModuleId: c,
|
|
706
|
+
introduction: a,
|
|
707
|
+
npmPackageName: l,
|
|
708
|
+
version: e.version
|
|
709
|
+
});
|
|
710
|
+
await _(u, Rt, zt), b("Opening documented");
|
|
705
711
|
} catch (e) {
|
|
706
712
|
console.error("❌ Error documenting opening", e), process.exit(1);
|
|
707
713
|
}
|
|
708
714
|
}
|
|
709
|
-
function
|
|
715
|
+
function Vt(e) {
|
|
716
|
+
return e === void 0 ? "blue" : /^v?0/.test(e) || /alpha|beta|snapshot|dev|pre|rc/i.test(e) ? "orange" : "blue";
|
|
717
|
+
}
|
|
718
|
+
function Ht(e) {
|
|
710
719
|
let t = e.license;
|
|
711
720
|
if (t == null || t === "") throw Error("package.json 'license' field is required to document opening.");
|
|
712
721
|
return t;
|
|
713
722
|
}
|
|
714
|
-
function
|
|
723
|
+
function Ut(e) {
|
|
715
724
|
let t = e.name;
|
|
716
725
|
if (t == null || t === "") throw Error("package.json 'name' field is required to document opening.");
|
|
717
726
|
return t;
|
|
718
727
|
}
|
|
719
|
-
function
|
|
728
|
+
function Wt(e) {
|
|
720
729
|
let t = e.description.en?.trim();
|
|
721
730
|
return t === void 0 || t === "" ? void 0 : t;
|
|
722
731
|
}
|
|
723
|
-
function
|
|
724
|
-
let s = `https://github.com/${e}/${t}`,
|
|
725
|
-
return `[ {
|
|
733
|
+
let { description: i, dpuseModuleId: a, introduction: o, npmPackageName: s, version: c } = r, l = `https://github.com/${e}/${t}`, u = n.replaceAll("-", "--"), d = encodeURIComponent(`https://api.dpuse.app/configs/${a ?? ""}`);
|
|
734
|
+
return `[](./LICENSE)${a === void 0 ? "" : `\n[})](${l}/releases/latest)`}${s === void 0 ? "" : `\n[](https://www.npmjs.com/package/${s})`}
|
|
735
|
+
[](${l}/actions/workflows/ci.yml)${i == null || i === "" ? "" : `\n\n${i}`}
|
|
727
736
|
|
|
728
|
-
[Report a Vulnerability](${
|
|
737
|
+
[Report a Vulnerability](${l}/security/advisories/new) · [Open an Issue](${l}/issues)
|
|
729
738
|
|
|
730
739
|
## About DPUse
|
|
731
740
|
|
|
@@ -741,31 +750,31 @@ In addition, DPUse provides [Tools](https://www.dpuse.app) used by the applicati
|
|
|
741
750
|
}
|
|
742
751
|
//#endregion
|
|
743
752
|
//#region src/actions/documentQualitySecurity.ts
|
|
744
|
-
var
|
|
753
|
+
var Kt = {
|
|
745
754
|
"Branch-Protection": 3,
|
|
746
755
|
"Code-Review": 0,
|
|
747
756
|
Contributors: 0
|
|
748
|
-
},
|
|
757
|
+
}, qt = /* @__PURE__ */ new Set(["CII-Best-Practices"]), Jt = "coverage/coverage-final.json", Yt = "coverage/coverage-summary.json", Xt = 80, Zt = 60, Qt = "code-health-reports/vitest/badge.json", $t = {
|
|
749
758
|
actions: "GitHub Actions",
|
|
750
759
|
"javascript-typescript": "JavaScript/TypeScript",
|
|
751
760
|
rust: "Rust"
|
|
752
|
-
},
|
|
761
|
+
}, en = {
|
|
753
762
|
A: "brightgreen",
|
|
754
763
|
B: "green",
|
|
755
764
|
C: "yellow",
|
|
756
765
|
D: "orange",
|
|
757
766
|
F: "red"
|
|
758
|
-
},
|
|
759
|
-
async function
|
|
767
|
+
}, tn = `${c}/health.json`, nn = le(ue);
|
|
768
|
+
async function rn() {
|
|
760
769
|
try {
|
|
761
770
|
s("Document Quality & Security");
|
|
762
|
-
let e = await S("package.json"), t = await
|
|
771
|
+
let e = await S("package.json"), t = await an(e), n = await sn(e, t === void 0 ? [] : ["--coverage", Jt]), { owner: r, repository: i } = x(e, "document quality and security");
|
|
763
772
|
C("4️⃣ Read security checks and settings");
|
|
764
|
-
let a = await
|
|
773
|
+
let a = await ln(r, i, e);
|
|
765
774
|
C("5️⃣ Look up OpenSSF Best Practices badge and Scorecard results");
|
|
766
|
-
let [o, c] = await Promise.all([
|
|
775
|
+
let [o, c] = await Promise.all([un(`https://github.com/${r}/${i}`), dn(`github.com/${r}/${i}`)]);
|
|
767
776
|
C("6️⃣ Insert quality and security content into 'README.md'");
|
|
768
|
-
let d =
|
|
777
|
+
let d = gn(r, i, {
|
|
769
778
|
coveragePercent: t,
|
|
770
779
|
fallowHealth: n,
|
|
771
780
|
securitySettings: a
|
|
@@ -775,7 +784,7 @@ async function tn() {
|
|
|
775
784
|
console.error("❌ Error documenting quality and security", e), process.exit(1);
|
|
776
785
|
}
|
|
777
786
|
}
|
|
778
|
-
async function
|
|
787
|
+
async function an(t) {
|
|
779
788
|
if (t.devDependencies?.["@vitest/coverage-v8"] == null) {
|
|
780
789
|
C("1️⃣ Test coverage NOT measured, as '@vitest/coverage-v8' is not installed");
|
|
781
790
|
return;
|
|
@@ -785,25 +794,25 @@ async function nn(t) {
|
|
|
785
794
|
"--passWithNoTests",
|
|
786
795
|
"--coverage"
|
|
787
796
|
]);
|
|
788
|
-
let n = await e(
|
|
797
|
+
let n = await e(Yt);
|
|
789
798
|
if (n === null) return;
|
|
790
799
|
let r = JSON.parse(n).total.lines.pct;
|
|
791
|
-
return await
|
|
800
|
+
return await on(r), r;
|
|
792
801
|
}
|
|
793
|
-
async function
|
|
802
|
+
async function on(e) {
|
|
794
803
|
let t = [
|
|
795
804
|
"red",
|
|
796
805
|
"yellow",
|
|
797
806
|
"brightgreen"
|
|
798
|
-
], n = Number(e >=
|
|
799
|
-
await i(
|
|
807
|
+
], n = Number(e >= Zt) + Number(e >= Xt);
|
|
808
|
+
await i(Qt, {
|
|
800
809
|
schemaVersion: 1,
|
|
801
810
|
label: "coverage",
|
|
802
811
|
message: `${e.toFixed(1)}%`,
|
|
803
812
|
color: t[n]
|
|
804
813
|
});
|
|
805
814
|
}
|
|
806
|
-
async function
|
|
815
|
+
async function sn(e, n) {
|
|
807
816
|
if (e.devDependencies?.fallow == null) {
|
|
808
817
|
C("2️⃣ Code health NOT measured, as Fallow is not installed"), C("3️⃣ Code health report NOT required");
|
|
809
818
|
return;
|
|
@@ -814,32 +823,32 @@ async function an(e, n) {
|
|
|
814
823
|
"--format",
|
|
815
824
|
"json",
|
|
816
825
|
...n
|
|
817
|
-
],
|
|
818
|
-
let r = await S(
|
|
819
|
-
return await
|
|
826
|
+
], tn), await t("3️⃣ Write code health report", "fallow", ["--format", "markdown"], ne, !0);
|
|
827
|
+
let r = await S(tn);
|
|
828
|
+
return await cn(r), r;
|
|
820
829
|
}
|
|
821
|
-
async function
|
|
830
|
+
async function cn(e) {
|
|
822
831
|
let { score: t, grade: n } = e.health_score;
|
|
823
832
|
await i(h, {
|
|
824
833
|
schemaVersion: 1,
|
|
825
834
|
label: "fallow",
|
|
826
835
|
message: `${n} (${String(Math.round(t))})`,
|
|
827
|
-
color:
|
|
836
|
+
color: en[n] ?? "lightgrey"
|
|
828
837
|
});
|
|
829
838
|
}
|
|
830
|
-
async function
|
|
839
|
+
async function ln(t, n, r) {
|
|
831
840
|
let [i, a, o] = await Promise.all([
|
|
832
841
|
e(".github/workflows/ci.yml"),
|
|
833
842
|
e(".github/dependabot.yml"),
|
|
834
843
|
e(v)
|
|
835
844
|
]), s = await e(".github/workflows/codeql.yml") ?? "", [c, l, u, d] = await Promise.all([
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
845
|
+
R(`repos/${t}/${n}`),
|
|
846
|
+
R(`repos/${t}/${n}/private-vulnerability-reporting`),
|
|
847
|
+
R(`repos/${t}/${n}/vulnerability-alerts`),
|
|
848
|
+
R(`repos/${t}/${n}/commits/main/check-runs?per_page=100`)
|
|
840
849
|
]), f = c === void 0 ? void 0 : JSON.parse(c).security_and_analysis, p = (e) => f?.[e] === void 0 ? void 0 : f[e].status === "enabled", m = new Set((d === void 0 ? [] : JSON.parse(d).check_runs).map((e) => e.app?.slug)), h = a?.match(/package-ecosystem:/g)?.length ?? 0, g = a?.match(/open-pull-requests-limit: 0\b/g)?.length ?? 0;
|
|
841
850
|
return {
|
|
842
|
-
codeQLLanguages: s.matchAll(/- language: ([\w-]+)/g).filter(([, e]) => e !== "rust" || o !== null).map(([, e = ""]) =>
|
|
851
|
+
codeQLLanguages: s.matchAll(/- language: ([\w-]+)/g).filter(([, e]) => e !== "rust" || o !== null).map(([, e = ""]) => $t[e] ?? e).toArray(),
|
|
843
852
|
codeQLQueries: /queries: ([\w-]+)/.exec(s)?.[1],
|
|
844
853
|
dependabotAlerts: u !== void 0,
|
|
845
854
|
dependabotSecurityUpdates: p("dependabot_security_updates"),
|
|
@@ -856,37 +865,37 @@ async function sn(t, n, r) {
|
|
|
856
865
|
testsInCI: i?.includes("npm test") ?? !1
|
|
857
866
|
};
|
|
858
867
|
}
|
|
859
|
-
async function
|
|
868
|
+
async function R(e) {
|
|
860
869
|
try {
|
|
861
|
-
let { stdout: t } = await
|
|
870
|
+
let { stdout: t } = await nn("gh", ["api", e]);
|
|
862
871
|
return t;
|
|
863
872
|
} catch (e) {
|
|
864
873
|
if (String(e.stderr).includes("HTTP 404")) return;
|
|
865
874
|
throw e;
|
|
866
875
|
}
|
|
867
876
|
}
|
|
868
|
-
async function
|
|
877
|
+
async function un(e) {
|
|
869
878
|
let t = await fetch(`https://www.bestpractices.dev/projects.json?url=${encodeURIComponent(e)}`);
|
|
870
879
|
if (!t.ok) throw Error(`OpenSSF Best Practices lookup failed with status ${String(t.status)}.`);
|
|
871
880
|
return (await t.json()).find((t) => t.repo_url === e)?.id;
|
|
872
881
|
}
|
|
873
|
-
async function
|
|
882
|
+
async function dn(e) {
|
|
874
883
|
let t = await fetch(`https://api.scorecard.dev/projects/${e}`);
|
|
875
884
|
if (t.status !== 404) {
|
|
876
885
|
if (!t.ok) throw Error(`OpenSSF Scorecard lookup failed with status ${String(t.status)}.`);
|
|
877
886
|
return await t.json();
|
|
878
887
|
}
|
|
879
888
|
}
|
|
880
|
-
function
|
|
881
|
-
return e.checks.every(({ name: e, score: t }) => t === -1 || t === 10 ||
|
|
889
|
+
function fn(e) {
|
|
890
|
+
return e.checks.every(({ name: e, score: t }) => t === -1 || t === 10 || qt.has(e) || Kt[e] !== void 0 && t >= Kt[e]);
|
|
882
891
|
}
|
|
883
|
-
function
|
|
892
|
+
function pn(e) {
|
|
884
893
|
return e === !1 ? " These are handled manually." : "";
|
|
885
894
|
}
|
|
886
|
-
function
|
|
895
|
+
function z(e) {
|
|
887
896
|
return e === void 0 ? "❔ Unknown" : e ? "✅ On" : "❌ Off";
|
|
888
897
|
}
|
|
889
|
-
function
|
|
898
|
+
function B(e, t) {
|
|
890
899
|
return t.length === 0 ? "" : `### ${e}
|
|
891
900
|
|
|
892
901
|
|Check|Status|What it does|
|
|
@@ -895,90 +904,90 @@ ${t.map((e) => `|${e.join("|")}|`).join("\n")}
|
|
|
895
904
|
|
|
896
905
|
`;
|
|
897
906
|
}
|
|
898
|
-
function
|
|
907
|
+
function mn(e, t, n, r) {
|
|
899
908
|
return `})`;
|
|
900
909
|
}
|
|
901
|
-
function
|
|
910
|
+
function hn(e, t, { coveragePercent: n, fallowHealth: r, securitySettings: i }) {
|
|
902
911
|
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 = [[
|
|
903
912
|
"Unit tests",
|
|
904
|
-
|
|
913
|
+
z(i.testsInCI),
|
|
905
914
|
`[Vitest](https://vitest.dev) runs the unit tests.${o(i.testsInCI)}`
|
|
906
915
|
], [
|
|
907
916
|
"Property-based tests",
|
|
908
|
-
|
|
917
|
+
z(i.propertyTests),
|
|
909
918
|
`[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)}`
|
|
910
919
|
]];
|
|
911
920
|
n !== void 0 && s.push([
|
|
912
921
|
"Test coverage",
|
|
913
|
-
|
|
914
|
-
`${
|
|
922
|
+
z(!0),
|
|
923
|
+
`${mn(e, t, "Coverage", Qt)} [Vitest's V8 coverage](https://vitest.dev/guide/coverage) measures the share of source lines the unit tests run. The target is ${String(Xt)}%.`
|
|
915
924
|
]);
|
|
916
925
|
let c = `[](https://sonarcloud.io/summary/new_code?id=${e}_${t}) `, l = [[
|
|
917
926
|
"Code analysis",
|
|
918
|
-
|
|
927
|
+
z(i.sonarCloud),
|
|
919
928
|
`${i.sonarCloud ? c : ""}[SonarCloud](https://sonarcloud.io) checks every push for bugs, code smells and vulnerabilities.`
|
|
920
929
|
], [
|
|
921
930
|
"Linting",
|
|
922
|
-
|
|
931
|
+
z(i.lintInCI),
|
|
923
932
|
`[ESLint](https://eslint.org) checks the code for errors and style problems.${o(i.lintInCI)}`
|
|
924
933
|
]];
|
|
925
934
|
r !== void 0 && l.unshift([
|
|
926
935
|
"Code health",
|
|
927
|
-
|
|
928
|
-
`[${
|
|
936
|
+
z(!0),
|
|
937
|
+
`[${mn(e, t, "Fallow code health", h)}](./${ne}) [Fallow](https://github.com/fallow-rs/fallow) finds unused code, duplication, complexity and dependency problems.`
|
|
929
938
|
]);
|
|
930
939
|
let u = i.codeQLLanguages.length > 0, d = `[](${a}/security/code-scanning) `, f = i.codeQLQueries === "security-extended" ? "using the extended security queries" : "using the default queries", p = u ? ` ${i.codeQLLanguages.join(" and ")}` : "", m = [
|
|
931
940
|
[
|
|
932
941
|
"Push protection",
|
|
933
|
-
|
|
942
|
+
z(i.pushProtection),
|
|
934
943
|
"[GitHub push protection](https://docs.github.com/en/code-security/secret-scanning/push-protection-for-repositories-and-organizations) blocks pushes that contain credentials."
|
|
935
944
|
],
|
|
936
945
|
[
|
|
937
946
|
"Static analysis",
|
|
938
|
-
|
|
947
|
+
z(u),
|
|
939
948
|
`${u ? d : ""}[CodeQL](https://codeql.github.com) scans${p} for security vulnerabilities, ${f}, on every push and pull request to \`main\` and weekly.`
|
|
940
949
|
],
|
|
941
950
|
[
|
|
942
951
|
"Secret scanning",
|
|
943
|
-
|
|
952
|
+
z(i.secretScanning),
|
|
944
953
|
"[GitHub secret scanning](https://docs.github.com/en/code-security/secret-scanning) detects credentials, such as API keys and tokens, committed to the repository."
|
|
945
954
|
]
|
|
946
955
|
], g = "[Dependabot](https://docs.github.com/en/code-security/dependabot)", _ = [
|
|
947
956
|
[
|
|
948
957
|
"Vulnerability audit",
|
|
949
|
-
|
|
958
|
+
z(i.npmAuditInCI),
|
|
950
959
|
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)}`
|
|
951
960
|
],
|
|
952
961
|
[
|
|
953
962
|
"Supply chain risk",
|
|
954
|
-
|
|
963
|
+
z(i.socket),
|
|
955
964
|
"[Socket](https://socket.dev) flags malicious packages, typosquatting and suspicious behaviour that may not yet have a CVE."
|
|
956
965
|
],
|
|
957
966
|
[
|
|
958
967
|
"Security alerts",
|
|
959
|
-
|
|
968
|
+
z(i.dependabotAlerts),
|
|
960
969
|
`${g} alerts when a dependency has a known vulnerability, using the GitHub Advisory Database.`
|
|
961
970
|
],
|
|
962
971
|
[
|
|
963
972
|
"Security updates",
|
|
964
|
-
|
|
965
|
-
`${g} opens pull requests that update vulnerable dependencies.${
|
|
973
|
+
z(i.dependabotSecurityUpdates),
|
|
974
|
+
`${g} opens pull requests that update vulnerable dependencies.${pn(i.dependabotSecurityUpdates)}`
|
|
966
975
|
],
|
|
967
976
|
[
|
|
968
977
|
"Version updates",
|
|
969
|
-
|
|
970
|
-
`${g} opens pull requests for new dependency versions.${
|
|
978
|
+
z(i.dependabotVersionUpdates),
|
|
979
|
+
`${g} opens pull requests for new dependency versions.${pn(i.dependabotVersionUpdates)}`
|
|
971
980
|
]
|
|
972
981
|
];
|
|
973
982
|
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.
|
|
974
983
|
|
|
975
|
-
${
|
|
984
|
+
${B("Testing", s)}${B("Code Quality", l)}${B("Security Analysis", m)}${B("Dependencies", _)}`;
|
|
976
985
|
}
|
|
977
|
-
function
|
|
978
|
-
let a = `https://github.com/${e}/${t}`, o = `github.com/${e}/${t}`, s = `https://www.bestpractices.dev/projects/${String(r)}`, c = i !== void 0 &&
|
|
986
|
+
function gn(e, t, n, r, i) {
|
|
987
|
+
let a = `https://github.com/${e}/${t}`, o = `github.com/${e}/${t}`, s = `https://www.bestpractices.dev/projects/${String(r)}`, c = i !== void 0 && fn(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.";
|
|
979
988
|
return `## Quality & Security
|
|
980
989
|
|
|
981
|
-
${
|
|
990
|
+
${hn(e, t, n)}### OpenSSF 🚧
|
|
982
991
|
|
|
983
992
|
${l}[](https://scorecard.dev/viewer/?uri=${o})
|
|
984
993
|
|
|
@@ -990,37 +999,37 @@ Please do not open public GitHub issues for security vulnerabilities. ${u}`;
|
|
|
990
999
|
}
|
|
991
1000
|
//#endregion
|
|
992
1001
|
//#region src/actions/documentUsage.ts
|
|
993
|
-
var
|
|
1002
|
+
var _n = "<!-- USAGE_START -->", vn = "<!-- USAGE_END -->", yn = /* @__PURE__ */ new Set([
|
|
994
1003
|
"connector",
|
|
995
1004
|
"cookbook",
|
|
996
1005
|
"presenter"
|
|
997
|
-
]),
|
|
998
|
-
async function
|
|
1006
|
+
]), bn = /* @__PURE__ */ new Set(["development", "eslint"]), xn = "> [!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.", Sn = "This repository manages itself using the actions it implements.", Cn = "This repository is managed using the common set of actions provided by [@dpuse/dpuse-development](https://github.com/dpuse/dpuse-development).";
|
|
1007
|
+
async function wn() {
|
|
999
1008
|
try {
|
|
1000
1009
|
s("Document Usage"), C("1️⃣ Insert usage content into 'README.md'");
|
|
1001
|
-
let [e, t] = await Promise.all([S("package.json"), S("config.json")]), n =
|
|
1002
|
-
await _(u,
|
|
1010
|
+
let [e, t] = await Promise.all([S("package.json"), S("config.json")]), n = Tn(e), r = En(n), i = V(e.engines?.node), a = V(e.engines?.npm), o = V(e.devDependencies?.typescript), c = Dn(m(t.id), e.name), l = `${n.replace(/\.git$/, "")}/blob/main/package.json`, u = On(c, n, r, i, a, o, `${e.name === "@dpuse/dpuse-development" ? Sn : Cn} See the \`scripts\` block in [package.json](${l}) for details.`);
|
|
1011
|
+
await _(u, _n, vn), b("Usage documented");
|
|
1003
1012
|
} catch (e) {
|
|
1004
1013
|
console.error("❌ Error documenting usage", e), process.exit(1);
|
|
1005
1014
|
}
|
|
1006
1015
|
}
|
|
1007
|
-
function
|
|
1016
|
+
function Tn(e) {
|
|
1008
1017
|
let t = e.repository, n = typeof t == "string" ? t : t?.url;
|
|
1009
1018
|
if (n == null || n === "") throw Error("package.json 'repository' field is required to document usage.");
|
|
1010
1019
|
return n.replace(/^git\+/, "");
|
|
1011
1020
|
}
|
|
1012
|
-
function
|
|
1021
|
+
function En(e) {
|
|
1013
1022
|
return (e.split("/").at(-1) ?? "").replace(/\.git$/, "");
|
|
1014
1023
|
}
|
|
1015
|
-
function
|
|
1024
|
+
function V(e) {
|
|
1016
1025
|
if (e == null) throw Error("package.json version range is required to document usage.");
|
|
1017
1026
|
let t = /\d+(?:\.\d+)*/.exec(e);
|
|
1018
1027
|
if (t == null) throw Error(`Unable to parse version from '${e}'.`);
|
|
1019
1028
|
return t[0];
|
|
1020
1029
|
}
|
|
1021
|
-
function
|
|
1030
|
+
function Dn(e, t) {
|
|
1022
1031
|
let { typeId: n } = e;
|
|
1023
|
-
if (
|
|
1032
|
+
if (yn.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.
|
|
1024
1033
|
|
|
1025
1034
|
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.`;
|
|
1026
1035
|
if (e.publishedTo === "npm") {
|
|
@@ -1031,11 +1040,11 @@ You may view or clone this repository for your own purposes, such as building a
|
|
|
1031
1040
|
npm install ${t}
|
|
1032
1041
|
\`\`\`
|
|
1033
1042
|
|
|
1034
|
-
${
|
|
1043
|
+
${bn.has(n) ? `${xn}\n\n` : ""}To work on the source instead, clone this repository.`;
|
|
1035
1044
|
}
|
|
1036
1045
|
return "You may view or clone this repository for your own purposes.";
|
|
1037
1046
|
}
|
|
1038
|
-
function
|
|
1047
|
+
function On(e, t, n, r, i, a, o) {
|
|
1039
1048
|
return `## Usage
|
|
1040
1049
|
|
|
1041
1050
|
${e}
|
|
@@ -1052,61 +1061,65 @@ ${o}`;
|
|
|
1052
1061
|
}
|
|
1053
1062
|
//#endregion
|
|
1054
1063
|
//#region src/actions/documentApiReference.ts
|
|
1055
|
-
var
|
|
1056
|
-
async function
|
|
1064
|
+
var H = "API_REFERENCE.md";
|
|
1065
|
+
async function kn() {
|
|
1057
1066
|
try {
|
|
1058
1067
|
s("Document API Reference");
|
|
1059
1068
|
let { writeAPIReference: e } = await import("./apiReference-D4xooSV0.js");
|
|
1060
|
-
await e("1️⃣ ",
|
|
1069
|
+
await e("1️⃣ ", H), b("API reference documented");
|
|
1061
1070
|
} catch (e) {
|
|
1062
1071
|
console.error("❌ Error documenting API reference", e), process.exit(1);
|
|
1063
1072
|
}
|
|
1064
1073
|
}
|
|
1065
1074
|
//#endregion
|
|
1066
1075
|
//#region src/actions/documentBundleSizes.ts
|
|
1067
|
-
var
|
|
1068
|
-
async function
|
|
1076
|
+
var An = "bundle-analysis-reports/sonda/index.json", jn = "bundle-analysis-reports/sonda/worker.json", Mn = "<!-- BUNDLE_START -->", Nn = "<!-- BUNDLE_END -->", U = " ", W = 20, Pn = "█", Fn = "▒", In = 100 / W / 2, Ln = 100 / W, Rn = "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._", zn = "Bars show each row's share of its output file.", Bn = "↳ rows are part of the row above.", G = "split", Vn = `(${G} · n files) = a package whose files are divided across output files; each row lists only the files in that output file, and no file appears in more than one.`, K = "(bundler output, whitespace & JSON)", q = "(inlined worker)", Hn = `${q} = a Web Worker built separately and embedded in its output file as text. Where the build records what it contains, its rows list that; any few bytes over are the escaping needed to embed it.`, J = "(Rust WebAssembly as base64", Un = `${J}…) = the compiled Rust code, embedded as base64 text, about a third larger than the binary it decodes to, which is the size given.`, Wn = `${K} = 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.`;
|
|
1077
|
+
async function Gn(t) {
|
|
1069
1078
|
try {
|
|
1070
1079
|
s("Document Bundle Sizes"), C("1️⃣ Read bundle analysis report");
|
|
1071
|
-
let n = await S(
|
|
1080
|
+
let n = await S(An), r = await e(jn), i = r === null ? void 0 : JSON.parse(r), a = /* @__PURE__ */ new Map();
|
|
1072
1081
|
for (let t of n.resources) t.kind === "asset" && a.set(t.name, await e(t.name));
|
|
1073
1082
|
C("2️⃣ Insert table into 'README.md'");
|
|
1074
|
-
let o =
|
|
1083
|
+
let o = Kn(n, {
|
|
1075
1084
|
assetContents: a,
|
|
1076
1085
|
isModuleLevel: t?.moduleLevel ?? !1,
|
|
1077
1086
|
workerJson: i
|
|
1078
1087
|
}), c = [
|
|
1079
|
-
o.includes("↳") ? `${
|
|
1080
|
-
o.includes(
|
|
1081
|
-
o.includes(
|
|
1082
|
-
|
|
1088
|
+
o.includes("↳") ? `${zn} ${Bn}` : zn,
|
|
1089
|
+
o.includes(`(${G} · `) ? Vn : "",
|
|
1090
|
+
o.includes(q) ? Hn : "",
|
|
1091
|
+
o.includes(J) ? Un : "",
|
|
1092
|
+
Wn
|
|
1083
1093
|
].filter((e) => e !== "");
|
|
1084
|
-
await _(`## Bundle Analysis\n\n${
|
|
1094
|
+
await _(`## Bundle Analysis\n\n${Rn}\n\n${o}\n\n${c.join("\n\n")}`, Mn, Nn), b("Bundle sizes documented");
|
|
1085
1095
|
} catch (e) {
|
|
1086
1096
|
console.error("❌ Error documenting bundle sizes", e), process.exit(1);
|
|
1087
1097
|
}
|
|
1088
1098
|
}
|
|
1089
|
-
function
|
|
1090
|
-
let { assetContents: n, isModuleLevel: r, workerJson: i } = t, a =
|
|
1099
|
+
function Kn(e, t) {
|
|
1100
|
+
let { assetContents: n, isModuleLevel: r, workerJson: i } = t, a = cr(e), o = i === void 0 ? void 0 : cr(i).values().next().value;
|
|
1091
1101
|
for (let [e, t] of a) {
|
|
1092
1102
|
let r = n.get(e);
|
|
1093
|
-
r != null &&
|
|
1103
|
+
r != null && qn(t, r, o);
|
|
1094
1104
|
}
|
|
1095
|
-
let s = a.values().flatMap((e) => e.values().toArray()).reduce((e, t) => e + t.sizes.uncompressed, 0), c = e.resources.filter((e) => e.kind === "asset").map((e) => [e.name,
|
|
1105
|
+
let s = a.values().flatMap((e) => e.values().toArray()).reduce((e, t) => e + t.sizes.uncompressed, 0), c = e.resources.filter((e) => e.kind === "asset").map((e) => [e.name, pr(e)]).toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), l = nr(a, e.dependencies), u = ["|Chunk/Module/File|Composition|", "|:------ |:-----------|"];
|
|
1096
1106
|
for (let [e, t] of c) {
|
|
1097
|
-
let n = [...a.get(e) ?? /* @__PURE__ */ new Map()].toSorted(
|
|
1098
|
-
|
|
1107
|
+
let n = [...a.get(e) ?? /* @__PURE__ */ new Map()].toSorted(tr), i = n.reduce((e, [, t]) => e + t.sizes.uncompressed, 0), o = i > 0 && s > 0 ? ` · ${_r(i, s)} of the build` : "";
|
|
1108
|
+
u.push(`| **${e}** | ${mr(t)}${o} |`, ...rr(n, i, {
|
|
1109
|
+
isModuleLevel: r,
|
|
1110
|
+
splitPackages: l
|
|
1111
|
+
}));
|
|
1099
1112
|
}
|
|
1100
|
-
return
|
|
1113
|
+
return u.join("\n");
|
|
1101
1114
|
}
|
|
1102
|
-
function
|
|
1103
|
-
let r =
|
|
1104
|
-
|
|
1115
|
+
function qn(e, t, n) {
|
|
1116
|
+
let r = Jn(t), i = Yn(r ?? ""), a = Yn(t);
|
|
1117
|
+
Zn(e, {
|
|
1105
1118
|
bytes: a.bytes - i.bytes,
|
|
1106
1119
|
binaryBytes: a.binaryBytes - i.binaryBytes
|
|
1107
|
-
}), r !== void 0 &&
|
|
1120
|
+
}), r !== void 0 && Qn(e, Buffer.byteLength(r), i, n);
|
|
1108
1121
|
}
|
|
1109
|
-
function
|
|
1122
|
+
function Jn(e) {
|
|
1110
1123
|
if (!e.includes("new Worker(")) return;
|
|
1111
1124
|
let t = /encodeURIComponent\((\w+)\)/.exec(e)?.[1];
|
|
1112
1125
|
if (t === void 0) return;
|
|
@@ -1116,21 +1129,21 @@ function Gn(e) {
|
|
|
1116
1129
|
for (; a < e.length && e[a] !== r;) a += e[a] === "\\" ? 2 : 1;
|
|
1117
1130
|
return e.slice(i, a);
|
|
1118
1131
|
}
|
|
1119
|
-
function
|
|
1132
|
+
function Yn(e) {
|
|
1120
1133
|
let t = {
|
|
1121
1134
|
bytes: 0,
|
|
1122
1135
|
binaryBytes: 0
|
|
1123
1136
|
};
|
|
1124
1137
|
for (let n of e.matchAll(/data:application\/wasm;base64,([A-Za-z\d+/]*={0,2})/g)) {
|
|
1125
1138
|
let e = n[1] ?? "";
|
|
1126
|
-
t.bytes += n[0].length, t.binaryBytes += Math.floor(e.length * 3 / 4) -
|
|
1139
|
+
t.bytes += n[0].length, t.binaryBytes += Math.floor(e.length * 3 / 4) - Xn(e);
|
|
1127
1140
|
}
|
|
1128
1141
|
return t;
|
|
1129
1142
|
}
|
|
1130
|
-
function
|
|
1143
|
+
function Xn(e) {
|
|
1131
1144
|
return e.endsWith("==") ? 2 : +!!e.endsWith("=");
|
|
1132
1145
|
}
|
|
1133
|
-
function
|
|
1146
|
+
function Zn(e, t) {
|
|
1134
1147
|
if (t.bytes <= 0) return;
|
|
1135
1148
|
let n = [e.get("wasm"), e.get(K)].flatMap((e) => e === void 0 ? [] : e.files.entries().map(([t, n]) => ({
|
|
1136
1149
|
group: e,
|
|
@@ -1138,8 +1151,8 @@ function Jn(e, t) {
|
|
|
1138
1151
|
sizes: n
|
|
1139
1152
|
})).toArray()).find(({ sizes: e }) => e.uncompressed >= t.bytes);
|
|
1140
1153
|
if (n === void 0) return;
|
|
1141
|
-
|
|
1142
|
-
let r = `${J}, ${
|
|
1154
|
+
er(e, n.group, n.fileName, n.sizes, t.bytes);
|
|
1155
|
+
let r = `${J}, ${Z(t.binaryBytes)} binary)`;
|
|
1143
1156
|
e.set(r, {
|
|
1144
1157
|
sizes: {
|
|
1145
1158
|
uncompressed: t.bytes,
|
|
@@ -1151,14 +1164,14 @@ function Jn(e, t) {
|
|
|
1151
1164
|
}]])
|
|
1152
1165
|
});
|
|
1153
1166
|
}
|
|
1154
|
-
function
|
|
1167
|
+
function Qn(e, t, n, r) {
|
|
1155
1168
|
let i = e.get(K), a = i?.files.get("");
|
|
1156
1169
|
if (i === void 0 || a === void 0 || a.uncompressed < t) return;
|
|
1157
|
-
|
|
1170
|
+
er(e, i, "", a, t);
|
|
1158
1171
|
let o = r === void 0 ? /* @__PURE__ */ new Map([["", {
|
|
1159
1172
|
uncompressed: t,
|
|
1160
1173
|
gzip: 0
|
|
1161
|
-
}]]) :
|
|
1174
|
+
}]]) : $n(r, t, n);
|
|
1162
1175
|
e.set(q, {
|
|
1163
1176
|
sizes: {
|
|
1164
1177
|
uncompressed: t,
|
|
@@ -1167,84 +1180,90 @@ function Yn(e, t, n, r) {
|
|
|
1167
1180
|
files: o
|
|
1168
1181
|
});
|
|
1169
1182
|
}
|
|
1170
|
-
function
|
|
1171
|
-
|
|
1183
|
+
function $n(e, t, n) {
|
|
1184
|
+
Zn(e, n);
|
|
1172
1185
|
let r = /* @__PURE__ */ new Map();
|
|
1173
1186
|
for (let [t, n] of e) if (t === "src") for (let [e, t] of n.files) r.set(e, { ...t });
|
|
1174
1187
|
else {
|
|
1175
|
-
let e = n.files.size === 1 ?
|
|
1188
|
+
let e = n.files.size === 1 ? or(t, sr(n.files)) : t;
|
|
1176
1189
|
r.set(e, { ...n.sizes });
|
|
1177
1190
|
}
|
|
1178
1191
|
let i = r.values().reduce((e, t) => e + t.uncompressed, 0), a = r.get(K) ?? X();
|
|
1179
1192
|
return a.uncompressed += Math.max(0, t - i), a.uncompressed > 0 && r.set(K, a), r;
|
|
1180
1193
|
}
|
|
1181
|
-
function
|
|
1194
|
+
function er(e, t, n, r, i) {
|
|
1182
1195
|
if (r.uncompressed -= i, t.sizes.uncompressed -= i, r.uncompressed <= 0 && t.files.delete(n), !(t.sizes.uncompressed > 0)) for (let [n, r] of e) r === t && e.delete(n);
|
|
1183
1196
|
}
|
|
1184
|
-
function
|
|
1197
|
+
function tr(e, t) {
|
|
1185
1198
|
return e[0] === K == (t[0] === K) ? t[1].sizes.uncompressed - e[1].sizes.uncompressed : e[0] === K ? 1 : -1;
|
|
1186
1199
|
}
|
|
1187
|
-
function
|
|
1188
|
-
let r =
|
|
1189
|
-
for (let
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1200
|
+
function nr(e, t) {
|
|
1201
|
+
let n = new Set(t.map((e) => e.name)), r = /* @__PURE__ */ new Map();
|
|
1202
|
+
for (let t of e.values()) for (let e of t.keys()) n.has(e) && r.set(e, (r.get(e) ?? 0) + 1);
|
|
1203
|
+
return new Set(r.entries().filter(([, e]) => e > 1).map(([e]) => e));
|
|
1204
|
+
}
|
|
1205
|
+
function rr(e, t, n) {
|
|
1206
|
+
let { isModuleLevel: r, splitPackages: i } = n, a = [];
|
|
1207
|
+
for (let [n, { sizes: o, files: s }] of e) {
|
|
1208
|
+
if (s.size === 1) {
|
|
1209
|
+
let e = sr(s);
|
|
1210
|
+
a.push(`| ${U}${or(n, e)} | ${Y(o.uncompressed, t)} |`);
|
|
1193
1211
|
continue;
|
|
1194
1212
|
}
|
|
1195
|
-
|
|
1213
|
+
let e = i.has(n) ? `${n} (${G} · ${String(s.size)} files)` : n;
|
|
1214
|
+
a.push(`| ${U}${e} | ${Y(o.uncompressed, t)} |`), r || a.push(...ir(s, t));
|
|
1196
1215
|
}
|
|
1197
|
-
return
|
|
1216
|
+
return a;
|
|
1198
1217
|
}
|
|
1199
|
-
function
|
|
1200
|
-
let n = [...e].toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), r =
|
|
1218
|
+
function ir(e, t) {
|
|
1219
|
+
let n = [...e].toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), r = ar(n, t), i = (r > 0 ? n.slice(0, -r) : n).map(([e, n]) => `| ${U}${U}↳ ${e} | ${Y(n.uncompressed, t, Fn)} |`);
|
|
1201
1220
|
if (r > 0) {
|
|
1202
1221
|
let e = n.slice(-r).reduce((e, [, t]) => e + t.uncompressed, 0);
|
|
1203
|
-
i.push(`| ${
|
|
1222
|
+
i.push(`| ${U}${U}↳ ${String(r)} smaller files | ${Y(e, t, Fn)} |`);
|
|
1204
1223
|
}
|
|
1205
1224
|
return i;
|
|
1206
1225
|
}
|
|
1207
|
-
function
|
|
1226
|
+
function ar(e, t) {
|
|
1208
1227
|
if (t <= 0) return 0;
|
|
1209
1228
|
let n = 0, r = 0;
|
|
1210
1229
|
for (let [, i] of e.toReversed()) {
|
|
1211
|
-
let e = i.uncompressed / t * 100 <
|
|
1230
|
+
let e = i.uncompressed / t * 100 < In, a = (r + i.uncompressed) / t * 100 <= Ln;
|
|
1212
1231
|
if (!e || !a) break;
|
|
1213
1232
|
n++, r += i.uncompressed;
|
|
1214
1233
|
}
|
|
1215
1234
|
return n >= 2 ? n : 0;
|
|
1216
1235
|
}
|
|
1217
|
-
function Y(e, t, n =
|
|
1218
|
-
return `${
|
|
1236
|
+
function Y(e, t, n = Pn) {
|
|
1237
|
+
return `${hr(t > 0 ? e / t * 100 : 0, n)} · ${Z(e)}`;
|
|
1219
1238
|
}
|
|
1220
|
-
function
|
|
1239
|
+
function or(e, t) {
|
|
1221
1240
|
return t === "" ? e : `${e} → ${t}`;
|
|
1222
1241
|
}
|
|
1223
|
-
function
|
|
1242
|
+
function sr(e) {
|
|
1224
1243
|
let [t] = e.keys();
|
|
1225
1244
|
if (t === void 0) throw Error("Expected exactly one file");
|
|
1226
1245
|
return t;
|
|
1227
1246
|
}
|
|
1228
|
-
function
|
|
1229
|
-
let t =
|
|
1247
|
+
function cr(e) {
|
|
1248
|
+
let t = lr(e.dependencies), n = /* @__PURE__ */ new Map();
|
|
1230
1249
|
for (let r of e.resources) {
|
|
1231
1250
|
if (r.kind !== "chunk" || !r.parent) continue;
|
|
1232
|
-
let { group: e, file: i } =
|
|
1251
|
+
let { group: e, file: i } = ur(r.name, t), a = pr(r), o = n.get(r.parent) ?? /* @__PURE__ */ new Map();
|
|
1233
1252
|
n.set(r.parent, o);
|
|
1234
1253
|
let s = o.get(e) ?? {
|
|
1235
1254
|
sizes: X(),
|
|
1236
1255
|
files: /* @__PURE__ */ new Map()
|
|
1237
1256
|
};
|
|
1238
|
-
o.set(e, s),
|
|
1257
|
+
o.set(e, s), gr(s.sizes, a);
|
|
1239
1258
|
let c = s.files.get(i) ?? X();
|
|
1240
|
-
s.files.set(i, c),
|
|
1259
|
+
s.files.set(i, c), gr(c, a);
|
|
1241
1260
|
}
|
|
1242
1261
|
return n;
|
|
1243
1262
|
}
|
|
1244
|
-
function
|
|
1263
|
+
function lr(e) {
|
|
1245
1264
|
return e.flatMap((e) => e.paths.map((t) => [t, e.name])).toSorted((e, t) => t[0].length - e[0].length);
|
|
1246
1265
|
}
|
|
1247
|
-
function
|
|
1266
|
+
function ur(e, t) {
|
|
1248
1267
|
let n = t.find(([t]) => e === t || e.startsWith(`${t}/`));
|
|
1249
1268
|
if (n) {
|
|
1250
1269
|
let [t, r] = n;
|
|
@@ -1261,31 +1280,31 @@ function or(e, t) {
|
|
|
1261
1280
|
file: e.slice(1)
|
|
1262
1281
|
} : e.startsWith("rust/") ? {
|
|
1263
1282
|
group: "wasm",
|
|
1264
|
-
file:
|
|
1283
|
+
file: dr(e)
|
|
1265
1284
|
} : {
|
|
1266
1285
|
group: "src",
|
|
1267
|
-
file:
|
|
1286
|
+
file: fr(e)
|
|
1268
1287
|
};
|
|
1269
1288
|
}
|
|
1270
|
-
function
|
|
1271
|
-
let t = e.split("/", 2)[1] ?? "", n =
|
|
1289
|
+
function dr(e) {
|
|
1290
|
+
let t = e.split("/", 2)[1] ?? "", n = fr(e);
|
|
1272
1291
|
return t !== "" && n.startsWith(t) ? `…${n.slice(t.length)}` : n;
|
|
1273
1292
|
}
|
|
1274
|
-
function
|
|
1293
|
+
function fr(e) {
|
|
1275
1294
|
return e.split("/").at(-1) ?? e;
|
|
1276
1295
|
}
|
|
1277
|
-
function
|
|
1296
|
+
function pr(e) {
|
|
1278
1297
|
return {
|
|
1279
1298
|
uncompressed: e.uncompressed,
|
|
1280
1299
|
gzip: e.gzip ?? 0
|
|
1281
1300
|
};
|
|
1282
1301
|
}
|
|
1283
|
-
function
|
|
1284
|
-
return `${
|
|
1302
|
+
function mr(e) {
|
|
1303
|
+
return `${Z(e.uncompressed)} · gzip ${Z(e.gzip)}`;
|
|
1285
1304
|
}
|
|
1286
|
-
function
|
|
1287
|
-
let n = Math.round(e / 100 *
|
|
1288
|
-
return `\`${t.repeat(n)}${"░".repeat(
|
|
1305
|
+
function hr(e, t = Pn) {
|
|
1306
|
+
let n = Math.round(e / 100 * W);
|
|
1307
|
+
return `\`${t.repeat(n)}${"░".repeat(W - n)}\` ${e.toFixed(1)}%`;
|
|
1289
1308
|
}
|
|
1290
1309
|
function X() {
|
|
1291
1310
|
return {
|
|
@@ -1293,26 +1312,26 @@ function X() {
|
|
|
1293
1312
|
gzip: 0
|
|
1294
1313
|
};
|
|
1295
1314
|
}
|
|
1296
|
-
function
|
|
1315
|
+
function gr(e, t) {
|
|
1297
1316
|
e.uncompressed += t.uncompressed, e.gzip += t.gzip;
|
|
1298
1317
|
}
|
|
1299
|
-
function
|
|
1318
|
+
function _r(e, t) {
|
|
1300
1319
|
return `${(e / t * 100).toFixed(1)}%`;
|
|
1301
1320
|
}
|
|
1302
|
-
function
|
|
1321
|
+
function Z(e) {
|
|
1303
1322
|
return e < 1024 ? `${String(e)} B` : `${(e / 1024).toFixed(1)} kB`;
|
|
1304
1323
|
}
|
|
1305
1324
|
//#endregion
|
|
1306
1325
|
//#region src/actions/documentProject.ts
|
|
1307
|
-
async function
|
|
1326
|
+
async function Q(t = "MIT", n = !1) {
|
|
1308
1327
|
try {
|
|
1309
1328
|
let r = await S("config.json"), i = m(r.id).typeId === "connector";
|
|
1310
|
-
await
|
|
1311
|
-
let a = await e(
|
|
1312
|
-
a ? await
|
|
1329
|
+
await Bt(), i && await Ge(), await wn(), await ft(t), await e("bundle-analysis-reports/sonda/index.json") === null ? C(`ℹ️ Bundle sizes NOT documented, as there is no '${An}' yet. Build the project first.`) : await Gn({ moduleLevel: n }), await rn(), await Ke();
|
|
1330
|
+
let a = await e(H) !== null;
|
|
1331
|
+
a ? await kn() : C(`ℹ️ '${H}' NOT required by this project`), await o("ℹ️ Format generated files", "prettier", [
|
|
1313
1332
|
"--write",
|
|
1314
1333
|
"README.md",
|
|
1315
|
-
...a ? [
|
|
1334
|
+
...a ? [H] : []
|
|
1316
1335
|
]);
|
|
1317
1336
|
} catch (e) {
|
|
1318
1337
|
console.error("❌ Error documenting project", e), process.exit(1);
|
|
@@ -1320,7 +1339,7 @@ async function pr(t = "MIT", n = !1) {
|
|
|
1320
1339
|
}
|
|
1321
1340
|
//#endregion
|
|
1322
1341
|
//#region src/actions/formatCode.ts
|
|
1323
|
-
async function
|
|
1342
|
+
async function vr() {
|
|
1324
1343
|
try {
|
|
1325
1344
|
s("Format Code");
|
|
1326
1345
|
let e = [
|
|
@@ -1341,7 +1360,7 @@ async function mr() {
|
|
|
1341
1360
|
}
|
|
1342
1361
|
//#endregion
|
|
1343
1362
|
//#region src/actions/lintCode.ts
|
|
1344
|
-
async function
|
|
1363
|
+
async function yr() {
|
|
1345
1364
|
try {
|
|
1346
1365
|
s("Lint Code"), await o("1️⃣ Lint", "eslint", ["."]), b("Code linted");
|
|
1347
1366
|
} catch (e) {
|
|
@@ -1350,7 +1369,7 @@ async function hr() {
|
|
|
1350
1369
|
}
|
|
1351
1370
|
//#endregion
|
|
1352
1371
|
//#region src/utilities/cloudflare.ts
|
|
1353
|
-
var
|
|
1372
|
+
var br = "dpuse-sample-data-eu", xr = {
|
|
1354
1373
|
bin: "application/octet-stream",
|
|
1355
1374
|
csv: "text/csv",
|
|
1356
1375
|
json: "application/json",
|
|
@@ -1361,7 +1380,7 @@ var gr = "dpuse-sample-data-eu", _r = {
|
|
|
1361
1380
|
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
1362
1381
|
xml: "application/xml"
|
|
1363
1382
|
};
|
|
1364
|
-
async function
|
|
1383
|
+
async function Sr() {
|
|
1365
1384
|
let e = await S("config.json"), t = {
|
|
1366
1385
|
body: JSON.stringify(e),
|
|
1367
1386
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1370,11 +1389,11 @@ async function vr() {
|
|
|
1370
1389
|
if (!n.ok) throw Error(await n.text());
|
|
1371
1390
|
}
|
|
1372
1391
|
async function $(e, t) {
|
|
1373
|
-
let n = await
|
|
1374
|
-
for (let [e, t] of r) await
|
|
1392
|
+
let n = await Dr(`${e}/${t}`, t), r = Map.groupBy(n, ({ key: e }) => Or(e));
|
|
1393
|
+
for (let [e, t] of r) await Er(t, ["--content-type", e]);
|
|
1375
1394
|
}
|
|
1376
|
-
async function
|
|
1377
|
-
await $(e, "application"), await $(e, "fileStore"), await
|
|
1395
|
+
async function Cr(e) {
|
|
1396
|
+
await $(e, "application"), await $(e, "fileStore"), await Er(["applicationIndex.json", "fileStoreIndex.json"].map((t) => ({
|
|
1378
1397
|
file: `${e}/${t}`,
|
|
1379
1398
|
key: t
|
|
1380
1399
|
})), [
|
|
@@ -1384,7 +1403,7 @@ async function yr(e) {
|
|
|
1384
1403
|
"no-cache"
|
|
1385
1404
|
]);
|
|
1386
1405
|
}
|
|
1387
|
-
async function
|
|
1406
|
+
async function wr(e) {
|
|
1388
1407
|
let t = e.id, n = {
|
|
1389
1408
|
body: JSON.stringify(e),
|
|
1390
1409
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1392,7 +1411,7 @@ async function br(e) {
|
|
|
1392
1411
|
}, r = await fetch(`https://api.dpuse.app/configs/${t}`, n);
|
|
1393
1412
|
if (!r.ok) throw Error(await r.text());
|
|
1394
1413
|
}
|
|
1395
|
-
async function
|
|
1414
|
+
async function Tr(e, t) {
|
|
1396
1415
|
let n = `v${e.version ?? "unknown"}`;
|
|
1397
1416
|
async function r(e, r = "") {
|
|
1398
1417
|
let i = await ee(e, { withFileTypes: !0 });
|
|
@@ -1414,7 +1433,7 @@ async function xr(e, t) {
|
|
|
1414
1433
|
}
|
|
1415
1434
|
await r("dist");
|
|
1416
1435
|
}
|
|
1417
|
-
async function
|
|
1436
|
+
async function Er(e, t) {
|
|
1418
1437
|
if (e.length === 0) return;
|
|
1419
1438
|
let n = await w.mkdtemp(T.join(ge.tmpdir(), "dpuse-r2-bulk-")), r = T.join(n, "files.json");
|
|
1420
1439
|
try {
|
|
@@ -1422,7 +1441,7 @@ async function Sr(e, t) {
|
|
|
1422
1441
|
"r2",
|
|
1423
1442
|
"bulk",
|
|
1424
1443
|
"put",
|
|
1425
|
-
|
|
1444
|
+
br,
|
|
1426
1445
|
"--filename",
|
|
1427
1446
|
r,
|
|
1428
1447
|
...t,
|
|
@@ -1436,28 +1455,28 @@ async function Sr(e, t) {
|
|
|
1436
1455
|
});
|
|
1437
1456
|
}
|
|
1438
1457
|
}
|
|
1439
|
-
async function
|
|
1458
|
+
async function Dr(e, t) {
|
|
1440
1459
|
let n = await ee(e), r = [];
|
|
1441
1460
|
for (let i of n) {
|
|
1442
1461
|
if (i.startsWith(".")) continue;
|
|
1443
1462
|
let n = `${e}/${i}`, a = `${t}/${i}`;
|
|
1444
|
-
(await p(n)).isDirectory() ? r.push(...await
|
|
1463
|
+
(await p(n)).isDirectory() ? r.push(...await Dr(n, a)) : r.push({
|
|
1445
1464
|
file: n,
|
|
1446
1465
|
key: a
|
|
1447
1466
|
});
|
|
1448
1467
|
}
|
|
1449
1468
|
return r;
|
|
1450
1469
|
}
|
|
1451
|
-
function
|
|
1470
|
+
function Or(e) {
|
|
1452
1471
|
let t = e.slice(e.lastIndexOf("/") + 1), n = t.lastIndexOf(".");
|
|
1453
1472
|
if (n === -1) return t === "LICENSE" ? "text/plain" : "application/octet-stream";
|
|
1454
|
-
let r =
|
|
1473
|
+
let r = xr[t.slice(n + 1).toLowerCase()];
|
|
1455
1474
|
if (r === void 0) throw Error(`No content type for '${e}'. Add its extension to 'SAMPLE_DATA_CONTENT_TYPES'.`);
|
|
1456
1475
|
return r;
|
|
1457
1476
|
}
|
|
1458
1477
|
//#endregion
|
|
1459
1478
|
//#region src/actions/publishProject.ts
|
|
1460
|
-
async function
|
|
1479
|
+
async function kr() {
|
|
1461
1480
|
try {
|
|
1462
1481
|
s("Publish Project");
|
|
1463
1482
|
let e = await S("package.json"), t = await S("config.json"), n = m(t.id);
|
|
@@ -1467,30 +1486,30 @@ async function Tr() {
|
|
|
1467
1486
|
"app",
|
|
1468
1487
|
"kb"
|
|
1469
1488
|
].includes(n.publishedTo);
|
|
1470
|
-
r && await o("2️⃣ Deploy", "npm", ["run", "deploy"]), await
|
|
1489
|
+
r && await o("2️⃣ Deploy", "npm", ["run", "deploy"]), await Ar(r ? "3️⃣ " : "2️⃣ ", e, t, n), n.publishedTo === "sampleData" && (C("3️⃣ Upload sample data"), await Cr("public")), b(`Project version '${e.version ?? "unknown"}' published.`);
|
|
1471
1490
|
} catch (e) {
|
|
1472
1491
|
console.error("❌ Error publishing project", e), process.exit(1);
|
|
1473
1492
|
}
|
|
1474
1493
|
}
|
|
1475
|
-
async function
|
|
1476
|
-
if (r.typeId === "app") C(`${e} Register module`), await
|
|
1477
|
-
else if (r.typeId === "engine") C(`${e} Register module`), await
|
|
1494
|
+
async function Ar(e, t, n, r) {
|
|
1495
|
+
if (r.typeId === "app") C(`${e} Register module`), await Sr();
|
|
1496
|
+
else if (r.typeId === "engine") C(`${e} Register module`), await Tr(t, `dpuse-engine-eu/${r.uploadGroupName ?? "unknown"}`), await wr(n);
|
|
1478
1497
|
else if (r.uploadGroupName === void 0) C(`${e} Registration NOT required`);
|
|
1479
1498
|
else {
|
|
1480
1499
|
C(`${e} Register module`);
|
|
1481
1500
|
let i = n.id.split("-").slice(2).join("-");
|
|
1482
|
-
await
|
|
1501
|
+
await Tr(t, `dpuse-engine-eu/${r.uploadGroupName}/${i}`), await wr(n);
|
|
1483
1502
|
}
|
|
1484
1503
|
}
|
|
1485
1504
|
//#endregion
|
|
1486
1505
|
//#region src/actions/releaseProject.ts
|
|
1487
|
-
async function
|
|
1506
|
+
async function jr(e = "MIT", t = !1) {
|
|
1488
1507
|
try {
|
|
1489
1508
|
s("Release Project");
|
|
1490
1509
|
let n = await S("package.json"), r = await S("config.json"), i = m(r.id);
|
|
1491
1510
|
await d("1️⃣ ", n);
|
|
1492
1511
|
let a = await oe("2️⃣ ", n, i);
|
|
1493
|
-
if (await Ee("3️⃣ ", n), C("4️⃣ Regenerate README"), await
|
|
1512
|
+
if (await Ee("3️⃣ ", n), C("4️⃣ Regenerate README"), await Q(e, t), await y("5️⃣ Stage changes", "git", ["add", "."]), await y("6️⃣ Commit changes", "git", [
|
|
1494
1513
|
"commit",
|
|
1495
1514
|
"-m",
|
|
1496
1515
|
`v${n.version ?? "unknown"}`
|
|
@@ -1498,7 +1517,7 @@ async function Dr(e = "MIT", t = !1) {
|
|
|
1498
1517
|
"push",
|
|
1499
1518
|
"origin",
|
|
1500
1519
|
"main:main"
|
|
1501
|
-
]), await
|
|
1520
|
+
]), await Ar("8️⃣ ", n, a, i), i.publishedTo === "npm") {
|
|
1502
1521
|
let e = `v${n.version ?? "unknown"}`;
|
|
1503
1522
|
await o("9️⃣ Trigger GitHub release", "gh", [
|
|
1504
1523
|
"release",
|
|
@@ -1517,7 +1536,7 @@ async function Dr(e = "MIT", t = !1) {
|
|
|
1517
1536
|
}
|
|
1518
1537
|
//#endregion
|
|
1519
1538
|
//#region src/actions/syncProjectWithGitHub.ts
|
|
1520
|
-
async function
|
|
1539
|
+
async function Mr() {
|
|
1521
1540
|
try {
|
|
1522
1541
|
s("Synchronise Project with GitHub");
|
|
1523
1542
|
let e = await S("package.json"), t = await S("config.json"), n = m(t.id);
|
|
@@ -1536,12 +1555,12 @@ async function Or() {
|
|
|
1536
1555
|
}
|
|
1537
1556
|
//#endregion
|
|
1538
1557
|
//#region src/actions/testProject.ts
|
|
1539
|
-
var
|
|
1558
|
+
var Nr = [
|
|
1540
1559
|
"1️⃣ ",
|
|
1541
1560
|
"2️⃣ ",
|
|
1542
1561
|
"3️⃣ ",
|
|
1543
1562
|
"4️⃣ "
|
|
1544
|
-
],
|
|
1563
|
+
], Pr = [{
|
|
1545
1564
|
id: "unit",
|
|
1546
1565
|
label: "Run unit tests",
|
|
1547
1566
|
command: "vitest",
|
|
@@ -1554,13 +1573,13 @@ var kr = [
|
|
|
1554
1573
|
arguments: ["test", "--pass-with-no-tests"],
|
|
1555
1574
|
configFileName: "playwright.config.ts"
|
|
1556
1575
|
}];
|
|
1557
|
-
async function
|
|
1576
|
+
async function Fr(t = ["unit"]) {
|
|
1558
1577
|
try {
|
|
1559
1578
|
s("Test Project");
|
|
1560
1579
|
let n = 0;
|
|
1561
|
-
for (let r of
|
|
1580
|
+
for (let r of Pr) {
|
|
1562
1581
|
if (!t.includes(r.id) || await e(r.configFileName) === null) continue;
|
|
1563
|
-
let i = `${
|
|
1582
|
+
let i = `${Nr[n] ?? ""} ${r.label}`;
|
|
1564
1583
|
await o(i, r.command, r.arguments), n += 1;
|
|
1565
1584
|
}
|
|
1566
1585
|
if (n === 0) {
|
|
@@ -1574,7 +1593,7 @@ async function jr(t = ["unit"]) {
|
|
|
1574
1593
|
}
|
|
1575
1594
|
//#endregion
|
|
1576
1595
|
//#region src/actions/triggerGitHubRelease.ts
|
|
1577
|
-
async function
|
|
1596
|
+
async function Ir() {
|
|
1578
1597
|
try {
|
|
1579
1598
|
s("Trigger GitHub Release");
|
|
1580
1599
|
let e = `v${(await S("package.json")).version ?? "unknown"}`;
|
|
@@ -1592,4 +1611,4 @@ async function Mr() {
|
|
|
1592
1611
|
}
|
|
1593
1612
|
}
|
|
1594
1613
|
//#endregion
|
|
1595
|
-
export { ye as auditDependencies, Te as buildProject, ze as checkProject,
|
|
1614
|
+
export { ye as auditDependencies, Te as buildProject, ze as checkProject, Q as documentProject, vr as formatCode, yr as lintCode, kr as publishProject, jr as releaseProject, Mr as syncProjectWithGitHub, Fr as testProject, Ir as triggerGitHubRelease, $ as uploadDirectoryToR2 };
|