@dpuse/dpuse-development 1.0.117 → 1.0.120
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 -15
- package/dist/dpuse-development.es.js +230 -215
- 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,62 @@ ${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.", Vn = "+ n more = the row also holds n more files from the same package or folder, each no larger than the one named. A package can appear under several output files, each holding different files, never the same file twice.", G = "(bundler output, whitespace & JSON)", K = "(inlined worker)", Hn = `${K} = 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.`, q = "(Rust WebAssembly as base64", Un = `${q}…) = the compiled Rust code, embedded as base64 text, about a third larger than the binary it decodes to, which is the size given.`, Wn = `${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.`;
|
|
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
|
|
1081
|
-
o.includes(
|
|
1082
|
-
|
|
1088
|
+
o.includes("↳") ? `${zn} ${Bn}` : zn,
|
|
1089
|
+
/ \+ \d+ more \|/.test(o) ? Vn : "",
|
|
1090
|
+
o.includes(K) ? Hn : "",
|
|
1091
|
+
o.includes(q) ? 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 = sr(e), o = i === void 0 ? void 0 : sr(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, fr(e)]).toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), l = ["|Chunk/Module/File|Composition|", "|:------ |:-----------|"];
|
|
1096
1106
|
for (let [e, t] of c) {
|
|
1097
|
-
let n = [...a.get(e) ?? /* @__PURE__ */ new Map()].toSorted(
|
|
1098
|
-
l.push(`| **${e}** | ${
|
|
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 ? ` · ${gr(i, s)} of the build` : "";
|
|
1108
|
+
l.push(`| **${e}** | ${pr(t)}${o} |`, ...nr(n, i, r));
|
|
1099
1109
|
}
|
|
1100
1110
|
return l.join("\n");
|
|
1101
1111
|
}
|
|
1102
|
-
function
|
|
1103
|
-
let r =
|
|
1104
|
-
|
|
1112
|
+
function qn(e, t, n) {
|
|
1113
|
+
let r = Jn(t), i = Yn(r ?? ""), a = Yn(t);
|
|
1114
|
+
Zn(e, {
|
|
1105
1115
|
bytes: a.bytes - i.bytes,
|
|
1106
1116
|
binaryBytes: a.binaryBytes - i.binaryBytes
|
|
1107
|
-
}), r !== void 0 &&
|
|
1117
|
+
}), r !== void 0 && Qn(e, Buffer.byteLength(r), i, n);
|
|
1108
1118
|
}
|
|
1109
|
-
function
|
|
1119
|
+
function Jn(e) {
|
|
1110
1120
|
if (!e.includes("new Worker(")) return;
|
|
1111
1121
|
let t = /encodeURIComponent\((\w+)\)/.exec(e)?.[1];
|
|
1112
1122
|
if (t === void 0) return;
|
|
@@ -1116,30 +1126,30 @@ function Gn(e) {
|
|
|
1116
1126
|
for (; a < e.length && e[a] !== r;) a += e[a] === "\\" ? 2 : 1;
|
|
1117
1127
|
return e.slice(i, a);
|
|
1118
1128
|
}
|
|
1119
|
-
function
|
|
1129
|
+
function Yn(e) {
|
|
1120
1130
|
let t = {
|
|
1121
1131
|
bytes: 0,
|
|
1122
1132
|
binaryBytes: 0
|
|
1123
1133
|
};
|
|
1124
1134
|
for (let n of e.matchAll(/data:application\/wasm;base64,([A-Za-z\d+/]*={0,2})/g)) {
|
|
1125
1135
|
let e = n[1] ?? "";
|
|
1126
|
-
t.bytes += n[0].length, t.binaryBytes += Math.floor(e.length * 3 / 4) -
|
|
1136
|
+
t.bytes += n[0].length, t.binaryBytes += Math.floor(e.length * 3 / 4) - Xn(e);
|
|
1127
1137
|
}
|
|
1128
1138
|
return t;
|
|
1129
1139
|
}
|
|
1130
|
-
function
|
|
1140
|
+
function Xn(e) {
|
|
1131
1141
|
return e.endsWith("==") ? 2 : +!!e.endsWith("=");
|
|
1132
1142
|
}
|
|
1133
|
-
function
|
|
1143
|
+
function Zn(e, t) {
|
|
1134
1144
|
if (t.bytes <= 0) return;
|
|
1135
|
-
let n = [e.get("wasm"), e.get(
|
|
1145
|
+
let n = [e.get("wasm"), e.get(G)].flatMap((e) => e === void 0 ? [] : e.files.entries().map(([t, n]) => ({
|
|
1136
1146
|
group: e,
|
|
1137
1147
|
fileName: t,
|
|
1138
1148
|
sizes: n
|
|
1139
1149
|
})).toArray()).find(({ sizes: e }) => e.uncompressed >= t.bytes);
|
|
1140
1150
|
if (n === void 0) return;
|
|
1141
|
-
|
|
1142
|
-
let r = `${
|
|
1151
|
+
er(e, n.group, n.fileName, n.sizes, t.bytes);
|
|
1152
|
+
let r = `${q}, ${Z(t.binaryBytes)} binary)`;
|
|
1143
1153
|
e.set(r, {
|
|
1144
1154
|
sizes: {
|
|
1145
1155
|
uncompressed: t.bytes,
|
|
@@ -1151,15 +1161,15 @@ function Jn(e, t) {
|
|
|
1151
1161
|
}]])
|
|
1152
1162
|
});
|
|
1153
1163
|
}
|
|
1154
|
-
function
|
|
1155
|
-
let i = e.get(
|
|
1164
|
+
function Qn(e, t, n, r) {
|
|
1165
|
+
let i = e.get(G), a = i?.files.get("");
|
|
1156
1166
|
if (i === void 0 || a === void 0 || a.uncompressed < t) return;
|
|
1157
|
-
|
|
1167
|
+
er(e, i, "", a, t);
|
|
1158
1168
|
let o = r === void 0 ? /* @__PURE__ */ new Map([["", {
|
|
1159
1169
|
uncompressed: t,
|
|
1160
1170
|
gzip: 0
|
|
1161
|
-
}]]) :
|
|
1162
|
-
e.set(
|
|
1171
|
+
}]]) : $n(r, t, n);
|
|
1172
|
+
e.set(K, {
|
|
1163
1173
|
sizes: {
|
|
1164
1174
|
uncompressed: t,
|
|
1165
1175
|
gzip: 0
|
|
@@ -1167,84 +1177,89 @@ function Yn(e, t, n, r) {
|
|
|
1167
1177
|
files: o
|
|
1168
1178
|
});
|
|
1169
1179
|
}
|
|
1170
|
-
function
|
|
1171
|
-
|
|
1180
|
+
function $n(e, t, n) {
|
|
1181
|
+
Zn(e, n);
|
|
1172
1182
|
let r = /* @__PURE__ */ new Map();
|
|
1173
1183
|
for (let [t, n] of e) if (t === "src") for (let [e, t] of n.files) r.set(e, { ...t });
|
|
1174
1184
|
else {
|
|
1175
|
-
let e = n.files.size === 1 ?
|
|
1185
|
+
let e = n.files.size === 1 ? Y(t, or(n.files)) : t;
|
|
1176
1186
|
r.set(e, { ...n.sizes });
|
|
1177
1187
|
}
|
|
1178
|
-
let i = r.values().reduce((e, t) => e + t.uncompressed, 0), a = r.get(
|
|
1179
|
-
return a.uncompressed += Math.max(0, t - i), a.uncompressed > 0 && r.set(
|
|
1188
|
+
let i = r.values().reduce((e, t) => e + t.uncompressed, 0), a = r.get(G) ?? X();
|
|
1189
|
+
return a.uncompressed += Math.max(0, t - i), a.uncompressed > 0 && r.set(G, a), r;
|
|
1180
1190
|
}
|
|
1181
|
-
function
|
|
1191
|
+
function er(e, t, n, r, i) {
|
|
1182
1192
|
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
1193
|
}
|
|
1184
|
-
function
|
|
1185
|
-
return e[0] ===
|
|
1194
|
+
function tr(e, t) {
|
|
1195
|
+
return e[0] === G == (t[0] === G) ? t[1].sizes.uncompressed - e[1].sizes.uncompressed : e[0] === G ? 1 : -1;
|
|
1186
1196
|
}
|
|
1187
|
-
function
|
|
1197
|
+
function nr(e, t, n) {
|
|
1188
1198
|
let r = [];
|
|
1189
1199
|
for (let [i, { sizes: a, files: o }] of e) {
|
|
1190
1200
|
if (o.size === 1) {
|
|
1191
|
-
let e =
|
|
1192
|
-
r.push(`| ${
|
|
1201
|
+
let e = or(o);
|
|
1202
|
+
r.push(`| ${U}${Y(i, e)} | ${J(a.uncompressed, t)} |`);
|
|
1193
1203
|
continue;
|
|
1194
1204
|
}
|
|
1195
|
-
r.push(`| ${
|
|
1205
|
+
r.push(`| ${U}${ar(i, o)} | ${J(a.uncompressed, t)} |`), n || r.push(...rr(o, t));
|
|
1196
1206
|
}
|
|
1197
1207
|
return r;
|
|
1198
1208
|
}
|
|
1199
|
-
function
|
|
1200
|
-
let n = [...e].toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), r =
|
|
1209
|
+
function rr(e, t) {
|
|
1210
|
+
let n = [...e].toSorted((e, t) => t[1].uncompressed - e[1].uncompressed), r = ir(n, t), i = (r > 0 ? n.slice(0, -r) : n).map(([e, n]) => `| ${U}${U}↳ ${e} | ${J(n.uncompressed, t, Fn)} |`);
|
|
1201
1211
|
if (r > 0) {
|
|
1202
1212
|
let e = n.slice(-r).reduce((e, [, t]) => e + t.uncompressed, 0);
|
|
1203
|
-
i.push(`| ${
|
|
1213
|
+
i.push(`| ${U}${U}↳ ${String(r)} smaller files | ${J(e, t, Fn)} |`);
|
|
1204
1214
|
}
|
|
1205
1215
|
return i;
|
|
1206
1216
|
}
|
|
1207
|
-
function
|
|
1217
|
+
function ir(e, t) {
|
|
1208
1218
|
if (t <= 0) return 0;
|
|
1209
1219
|
let n = 0, r = 0;
|
|
1210
1220
|
for (let [, i] of e.toReversed()) {
|
|
1211
|
-
let e = i.uncompressed / t * 100 <
|
|
1221
|
+
let e = i.uncompressed / t * 100 < In, a = (r + i.uncompressed) / t * 100 <= Ln;
|
|
1212
1222
|
if (!e || !a) break;
|
|
1213
1223
|
n++, r += i.uncompressed;
|
|
1214
1224
|
}
|
|
1215
1225
|
return n >= 2 ? n : 0;
|
|
1216
1226
|
}
|
|
1217
|
-
function
|
|
1218
|
-
return `${
|
|
1227
|
+
function J(e, t, n = Pn) {
|
|
1228
|
+
return `${mr(t > 0 ? e / t * 100 : 0, n)} · ${Z(e)}`;
|
|
1219
1229
|
}
|
|
1220
|
-
function
|
|
1230
|
+
function Y(e, t) {
|
|
1221
1231
|
return t === "" ? e : `${e} → ${t}`;
|
|
1222
1232
|
}
|
|
1223
|
-
function
|
|
1233
|
+
function ar(e, t) {
|
|
1234
|
+
if (e === K) return e;
|
|
1235
|
+
let [n] = [...t].toSorted((e, t) => t[1].uncompressed - e[1].uncompressed)[0] ?? [""];
|
|
1236
|
+
return `${Y(e, n)} + ${String(t.size - 1)} more`;
|
|
1237
|
+
}
|
|
1238
|
+
function or(e) {
|
|
1224
1239
|
let [t] = e.keys();
|
|
1225
1240
|
if (t === void 0) throw Error("Expected exactly one file");
|
|
1226
1241
|
return t;
|
|
1227
1242
|
}
|
|
1228
|
-
function
|
|
1229
|
-
let t =
|
|
1243
|
+
function sr(e) {
|
|
1244
|
+
let t = cr(e.dependencies), n = /* @__PURE__ */ new Map();
|
|
1230
1245
|
for (let r of e.resources) {
|
|
1231
1246
|
if (r.kind !== "chunk" || !r.parent) continue;
|
|
1232
|
-
let { group: e, file: i } =
|
|
1247
|
+
let { group: e, file: i } = lr(r.name, t), a = fr(r), o = n.get(r.parent) ?? /* @__PURE__ */ new Map();
|
|
1233
1248
|
n.set(r.parent, o);
|
|
1234
1249
|
let s = o.get(e) ?? {
|
|
1235
1250
|
sizes: X(),
|
|
1236
1251
|
files: /* @__PURE__ */ new Map()
|
|
1237
1252
|
};
|
|
1238
|
-
o.set(e, s),
|
|
1253
|
+
o.set(e, s), hr(s.sizes, a);
|
|
1239
1254
|
let c = s.files.get(i) ?? X();
|
|
1240
|
-
s.files.set(i, c),
|
|
1255
|
+
s.files.set(i, c), hr(c, a);
|
|
1241
1256
|
}
|
|
1242
1257
|
return n;
|
|
1243
1258
|
}
|
|
1244
|
-
function
|
|
1259
|
+
function cr(e) {
|
|
1245
1260
|
return e.flatMap((e) => e.paths.map((t) => [t, e.name])).toSorted((e, t) => t[0].length - e[0].length);
|
|
1246
1261
|
}
|
|
1247
|
-
function
|
|
1262
|
+
function lr(e, t) {
|
|
1248
1263
|
let n = t.find(([t]) => e === t || e.startsWith(`${t}/`));
|
|
1249
1264
|
if (n) {
|
|
1250
1265
|
let [t, r] = n;
|
|
@@ -1254,38 +1269,38 @@ function or(e, t) {
|
|
|
1254
1269
|
};
|
|
1255
1270
|
}
|
|
1256
1271
|
return e === "[unassigned]" ? {
|
|
1257
|
-
group:
|
|
1272
|
+
group: G,
|
|
1258
1273
|
file: ""
|
|
1259
1274
|
} : e.startsWith("\0") ? {
|
|
1260
1275
|
group: "(runtime)",
|
|
1261
1276
|
file: e.slice(1)
|
|
1262
1277
|
} : e.startsWith("rust/") ? {
|
|
1263
1278
|
group: "wasm",
|
|
1264
|
-
file:
|
|
1279
|
+
file: ur(e)
|
|
1265
1280
|
} : {
|
|
1266
1281
|
group: "src",
|
|
1267
|
-
file:
|
|
1282
|
+
file: dr(e)
|
|
1268
1283
|
};
|
|
1269
1284
|
}
|
|
1270
|
-
function
|
|
1271
|
-
let t = e.split("/", 2)[1] ?? "", n =
|
|
1285
|
+
function ur(e) {
|
|
1286
|
+
let t = e.split("/", 2)[1] ?? "", n = dr(e);
|
|
1272
1287
|
return t !== "" && n.startsWith(t) ? `…${n.slice(t.length)}` : n;
|
|
1273
1288
|
}
|
|
1274
|
-
function
|
|
1289
|
+
function dr(e) {
|
|
1275
1290
|
return e.split("/").at(-1) ?? e;
|
|
1276
1291
|
}
|
|
1277
|
-
function
|
|
1292
|
+
function fr(e) {
|
|
1278
1293
|
return {
|
|
1279
1294
|
uncompressed: e.uncompressed,
|
|
1280
1295
|
gzip: e.gzip ?? 0
|
|
1281
1296
|
};
|
|
1282
1297
|
}
|
|
1283
|
-
function
|
|
1284
|
-
return `${
|
|
1298
|
+
function pr(e) {
|
|
1299
|
+
return `${Z(e.uncompressed)} · gzip ${Z(e.gzip)}`;
|
|
1285
1300
|
}
|
|
1286
|
-
function
|
|
1287
|
-
let n = Math.round(e / 100 *
|
|
1288
|
-
return `\`${t.repeat(n)}${"░".repeat(
|
|
1301
|
+
function mr(e, t = Pn) {
|
|
1302
|
+
let n = Math.round(e / 100 * W);
|
|
1303
|
+
return `\`${t.repeat(n)}${"░".repeat(W - n)}\` ${e.toFixed(1)}%`;
|
|
1289
1304
|
}
|
|
1290
1305
|
function X() {
|
|
1291
1306
|
return {
|
|
@@ -1293,26 +1308,26 @@ function X() {
|
|
|
1293
1308
|
gzip: 0
|
|
1294
1309
|
};
|
|
1295
1310
|
}
|
|
1296
|
-
function
|
|
1311
|
+
function hr(e, t) {
|
|
1297
1312
|
e.uncompressed += t.uncompressed, e.gzip += t.gzip;
|
|
1298
1313
|
}
|
|
1299
|
-
function
|
|
1314
|
+
function gr(e, t) {
|
|
1300
1315
|
return `${(e / t * 100).toFixed(1)}%`;
|
|
1301
1316
|
}
|
|
1302
|
-
function
|
|
1317
|
+
function Z(e) {
|
|
1303
1318
|
return e < 1024 ? `${String(e)} B` : `${(e / 1024).toFixed(1)} kB`;
|
|
1304
1319
|
}
|
|
1305
1320
|
//#endregion
|
|
1306
1321
|
//#region src/actions/documentProject.ts
|
|
1307
|
-
async function
|
|
1322
|
+
async function _r(t = "MIT", n = !1) {
|
|
1308
1323
|
try {
|
|
1309
1324
|
let r = await S("config.json"), i = m(r.id).typeId === "connector";
|
|
1310
|
-
await
|
|
1311
|
-
let a = await e(
|
|
1312
|
-
a ? await
|
|
1325
|
+
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();
|
|
1326
|
+
let a = await e(H) !== null;
|
|
1327
|
+
a ? await kn() : C(`ℹ️ '${H}' NOT required by this project`), await o("ℹ️ Format generated files", "prettier", [
|
|
1313
1328
|
"--write",
|
|
1314
1329
|
"README.md",
|
|
1315
|
-
...a ? [
|
|
1330
|
+
...a ? [H] : []
|
|
1316
1331
|
]);
|
|
1317
1332
|
} catch (e) {
|
|
1318
1333
|
console.error("❌ Error documenting project", e), process.exit(1);
|
|
@@ -1320,7 +1335,7 @@ async function pr(t = "MIT", n = !1) {
|
|
|
1320
1335
|
}
|
|
1321
1336
|
//#endregion
|
|
1322
1337
|
//#region src/actions/formatCode.ts
|
|
1323
|
-
async function
|
|
1338
|
+
async function vr() {
|
|
1324
1339
|
try {
|
|
1325
1340
|
s("Format Code");
|
|
1326
1341
|
let e = [
|
|
@@ -1341,7 +1356,7 @@ async function mr() {
|
|
|
1341
1356
|
}
|
|
1342
1357
|
//#endregion
|
|
1343
1358
|
//#region src/actions/lintCode.ts
|
|
1344
|
-
async function
|
|
1359
|
+
async function yr() {
|
|
1345
1360
|
try {
|
|
1346
1361
|
s("Lint Code"), await o("1️⃣ Lint", "eslint", ["."]), b("Code linted");
|
|
1347
1362
|
} catch (e) {
|
|
@@ -1350,7 +1365,7 @@ async function hr() {
|
|
|
1350
1365
|
}
|
|
1351
1366
|
//#endregion
|
|
1352
1367
|
//#region src/utilities/cloudflare.ts
|
|
1353
|
-
var
|
|
1368
|
+
var br = "dpuse-sample-data-eu", xr = {
|
|
1354
1369
|
bin: "application/octet-stream",
|
|
1355
1370
|
csv: "text/csv",
|
|
1356
1371
|
json: "application/json",
|
|
@@ -1361,7 +1376,7 @@ var gr = "dpuse-sample-data-eu", _r = {
|
|
|
1361
1376
|
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
1362
1377
|
xml: "application/xml"
|
|
1363
1378
|
};
|
|
1364
|
-
async function
|
|
1379
|
+
async function Sr() {
|
|
1365
1380
|
let e = await S("config.json"), t = {
|
|
1366
1381
|
body: JSON.stringify(e),
|
|
1367
1382
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1369,12 +1384,12 @@ async function vr() {
|
|
|
1369
1384
|
}, n = await fetch(`https://api.dpuse.app/configs/${e.id}`, t);
|
|
1370
1385
|
if (!n.ok) throw Error(await n.text());
|
|
1371
1386
|
}
|
|
1372
|
-
async function
|
|
1373
|
-
let n = await
|
|
1374
|
-
for (let [e, t] of r) await
|
|
1387
|
+
async function Q(e, t) {
|
|
1388
|
+
let n = await Er(`${e}/${t}`, t), r = Map.groupBy(n, ({ key: e }) => Dr(e));
|
|
1389
|
+
for (let [e, t] of r) await Tr(t, ["--content-type", e]);
|
|
1375
1390
|
}
|
|
1376
|
-
async function
|
|
1377
|
-
await
|
|
1391
|
+
async function Cr(e) {
|
|
1392
|
+
await Q(e, "application"), await Q(e, "fileStore"), await Tr(["applicationIndex.json", "fileStoreIndex.json"].map((t) => ({
|
|
1378
1393
|
file: `${e}/${t}`,
|
|
1379
1394
|
key: t
|
|
1380
1395
|
})), [
|
|
@@ -1384,7 +1399,7 @@ async function yr(e) {
|
|
|
1384
1399
|
"no-cache"
|
|
1385
1400
|
]);
|
|
1386
1401
|
}
|
|
1387
|
-
async function
|
|
1402
|
+
async function $(e) {
|
|
1388
1403
|
let t = e.id, n = {
|
|
1389
1404
|
body: JSON.stringify(e),
|
|
1390
1405
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1392,7 +1407,7 @@ async function br(e) {
|
|
|
1392
1407
|
}, r = await fetch(`https://api.dpuse.app/configs/${t}`, n);
|
|
1393
1408
|
if (!r.ok) throw Error(await r.text());
|
|
1394
1409
|
}
|
|
1395
|
-
async function
|
|
1410
|
+
async function wr(e, t) {
|
|
1396
1411
|
let n = `v${e.version ?? "unknown"}`;
|
|
1397
1412
|
async function r(e, r = "") {
|
|
1398
1413
|
let i = await ee(e, { withFileTypes: !0 });
|
|
@@ -1414,7 +1429,7 @@ async function xr(e, t) {
|
|
|
1414
1429
|
}
|
|
1415
1430
|
await r("dist");
|
|
1416
1431
|
}
|
|
1417
|
-
async function
|
|
1432
|
+
async function Tr(e, t) {
|
|
1418
1433
|
if (e.length === 0) return;
|
|
1419
1434
|
let n = await w.mkdtemp(T.join(ge.tmpdir(), "dpuse-r2-bulk-")), r = T.join(n, "files.json");
|
|
1420
1435
|
try {
|
|
@@ -1422,7 +1437,7 @@ async function Sr(e, t) {
|
|
|
1422
1437
|
"r2",
|
|
1423
1438
|
"bulk",
|
|
1424
1439
|
"put",
|
|
1425
|
-
|
|
1440
|
+
br,
|
|
1426
1441
|
"--filename",
|
|
1427
1442
|
r,
|
|
1428
1443
|
...t,
|
|
@@ -1436,28 +1451,28 @@ async function Sr(e, t) {
|
|
|
1436
1451
|
});
|
|
1437
1452
|
}
|
|
1438
1453
|
}
|
|
1439
|
-
async function
|
|
1454
|
+
async function Er(e, t) {
|
|
1440
1455
|
let n = await ee(e), r = [];
|
|
1441
1456
|
for (let i of n) {
|
|
1442
1457
|
if (i.startsWith(".")) continue;
|
|
1443
1458
|
let n = `${e}/${i}`, a = `${t}/${i}`;
|
|
1444
|
-
(await p(n)).isDirectory() ? r.push(...await
|
|
1459
|
+
(await p(n)).isDirectory() ? r.push(...await Er(n, a)) : r.push({
|
|
1445
1460
|
file: n,
|
|
1446
1461
|
key: a
|
|
1447
1462
|
});
|
|
1448
1463
|
}
|
|
1449
1464
|
return r;
|
|
1450
1465
|
}
|
|
1451
|
-
function
|
|
1466
|
+
function Dr(e) {
|
|
1452
1467
|
let t = e.slice(e.lastIndexOf("/") + 1), n = t.lastIndexOf(".");
|
|
1453
1468
|
if (n === -1) return t === "LICENSE" ? "text/plain" : "application/octet-stream";
|
|
1454
|
-
let r =
|
|
1469
|
+
let r = xr[t.slice(n + 1).toLowerCase()];
|
|
1455
1470
|
if (r === void 0) throw Error(`No content type for '${e}'. Add its extension to 'SAMPLE_DATA_CONTENT_TYPES'.`);
|
|
1456
1471
|
return r;
|
|
1457
1472
|
}
|
|
1458
1473
|
//#endregion
|
|
1459
1474
|
//#region src/actions/publishProject.ts
|
|
1460
|
-
async function
|
|
1475
|
+
async function Or() {
|
|
1461
1476
|
try {
|
|
1462
1477
|
s("Publish Project");
|
|
1463
1478
|
let e = await S("package.json"), t = await S("config.json"), n = m(t.id);
|
|
@@ -1467,30 +1482,30 @@ async function Tr() {
|
|
|
1467
1482
|
"app",
|
|
1468
1483
|
"kb"
|
|
1469
1484
|
].includes(n.publishedTo);
|
|
1470
|
-
r && await o("2️⃣ Deploy", "npm", ["run", "deploy"]), await
|
|
1485
|
+
r && await o("2️⃣ Deploy", "npm", ["run", "deploy"]), await kr(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
1486
|
} catch (e) {
|
|
1472
1487
|
console.error("❌ Error publishing project", e), process.exit(1);
|
|
1473
1488
|
}
|
|
1474
1489
|
}
|
|
1475
|
-
async function
|
|
1476
|
-
if (r.typeId === "app") C(`${e} Register module`), await
|
|
1477
|
-
else if (r.typeId === "engine") C(`${e} Register module`), await
|
|
1490
|
+
async function kr(e, t, n, r) {
|
|
1491
|
+
if (r.typeId === "app") C(`${e} Register module`), await Sr();
|
|
1492
|
+
else if (r.typeId === "engine") C(`${e} Register module`), await wr(t, `dpuse-engine-eu/${r.uploadGroupName ?? "unknown"}`), await $(n);
|
|
1478
1493
|
else if (r.uploadGroupName === void 0) C(`${e} Registration NOT required`);
|
|
1479
1494
|
else {
|
|
1480
1495
|
C(`${e} Register module`);
|
|
1481
1496
|
let i = n.id.split("-").slice(2).join("-");
|
|
1482
|
-
await
|
|
1497
|
+
await wr(t, `dpuse-engine-eu/${r.uploadGroupName}/${i}`), await $(n);
|
|
1483
1498
|
}
|
|
1484
1499
|
}
|
|
1485
1500
|
//#endregion
|
|
1486
1501
|
//#region src/actions/releaseProject.ts
|
|
1487
|
-
async function
|
|
1502
|
+
async function Ar(e = "MIT", t = !1) {
|
|
1488
1503
|
try {
|
|
1489
1504
|
s("Release Project");
|
|
1490
1505
|
let n = await S("package.json"), r = await S("config.json"), i = m(r.id);
|
|
1491
1506
|
await d("1️⃣ ", n);
|
|
1492
1507
|
let a = await oe("2️⃣ ", n, i);
|
|
1493
|
-
if (await Ee("3️⃣ ", n), C("4️⃣ Regenerate README"), await
|
|
1508
|
+
if (await Ee("3️⃣ ", n), C("4️⃣ Regenerate README"), await _r(e, t), await y("5️⃣ Stage changes", "git", ["add", "."]), await y("6️⃣ Commit changes", "git", [
|
|
1494
1509
|
"commit",
|
|
1495
1510
|
"-m",
|
|
1496
1511
|
`v${n.version ?? "unknown"}`
|
|
@@ -1498,7 +1513,7 @@ async function Dr(e = "MIT", t = !1) {
|
|
|
1498
1513
|
"push",
|
|
1499
1514
|
"origin",
|
|
1500
1515
|
"main:main"
|
|
1501
|
-
]), await
|
|
1516
|
+
]), await kr("8️⃣ ", n, a, i), i.publishedTo === "npm") {
|
|
1502
1517
|
let e = `v${n.version ?? "unknown"}`;
|
|
1503
1518
|
await o("9️⃣ Trigger GitHub release", "gh", [
|
|
1504
1519
|
"release",
|
|
@@ -1517,7 +1532,7 @@ async function Dr(e = "MIT", t = !1) {
|
|
|
1517
1532
|
}
|
|
1518
1533
|
//#endregion
|
|
1519
1534
|
//#region src/actions/syncProjectWithGitHub.ts
|
|
1520
|
-
async function
|
|
1535
|
+
async function jr() {
|
|
1521
1536
|
try {
|
|
1522
1537
|
s("Synchronise Project with GitHub");
|
|
1523
1538
|
let e = await S("package.json"), t = await S("config.json"), n = m(t.id);
|
|
@@ -1536,12 +1551,12 @@ async function Or() {
|
|
|
1536
1551
|
}
|
|
1537
1552
|
//#endregion
|
|
1538
1553
|
//#region src/actions/testProject.ts
|
|
1539
|
-
var
|
|
1554
|
+
var Mr = [
|
|
1540
1555
|
"1️⃣ ",
|
|
1541
1556
|
"2️⃣ ",
|
|
1542
1557
|
"3️⃣ ",
|
|
1543
1558
|
"4️⃣ "
|
|
1544
|
-
],
|
|
1559
|
+
], Nr = [{
|
|
1545
1560
|
id: "unit",
|
|
1546
1561
|
label: "Run unit tests",
|
|
1547
1562
|
command: "vitest",
|
|
@@ -1554,13 +1569,13 @@ var kr = [
|
|
|
1554
1569
|
arguments: ["test", "--pass-with-no-tests"],
|
|
1555
1570
|
configFileName: "playwright.config.ts"
|
|
1556
1571
|
}];
|
|
1557
|
-
async function
|
|
1572
|
+
async function Pr(t = ["unit"]) {
|
|
1558
1573
|
try {
|
|
1559
1574
|
s("Test Project");
|
|
1560
1575
|
let n = 0;
|
|
1561
|
-
for (let r of
|
|
1576
|
+
for (let r of Nr) {
|
|
1562
1577
|
if (!t.includes(r.id) || await e(r.configFileName) === null) continue;
|
|
1563
|
-
let i = `${
|
|
1578
|
+
let i = `${Mr[n] ?? ""} ${r.label}`;
|
|
1564
1579
|
await o(i, r.command, r.arguments), n += 1;
|
|
1565
1580
|
}
|
|
1566
1581
|
if (n === 0) {
|
|
@@ -1574,7 +1589,7 @@ async function jr(t = ["unit"]) {
|
|
|
1574
1589
|
}
|
|
1575
1590
|
//#endregion
|
|
1576
1591
|
//#region src/actions/triggerGitHubRelease.ts
|
|
1577
|
-
async function
|
|
1592
|
+
async function Fr() {
|
|
1578
1593
|
try {
|
|
1579
1594
|
s("Trigger GitHub Release");
|
|
1580
1595
|
let e = `v${(await S("package.json")).version ?? "unknown"}`;
|
|
@@ -1592,4 +1607,4 @@ async function Mr() {
|
|
|
1592
1607
|
}
|
|
1593
1608
|
}
|
|
1594
1609
|
//#endregion
|
|
1595
|
-
export { ye as auditDependencies, Te as buildProject, ze as checkProject,
|
|
1610
|
+
export { ye as auditDependencies, Te as buildProject, ze as checkProject, _r as documentProject, vr as formatCode, yr as lintCode, Or as publishProject, Ar as releaseProject, jr as syncProjectWithGitHub, Pr as testProject, Fr as triggerGitHubRelease, Q as uploadDirectoryToR2 };
|