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