@heroiclands/package-build 17.0.0 → 17.1.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # @heroiclands/package-build
2
2
 
3
+ ## 17.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 9d6a52f: **New: `package-build labels check`.** The issue-label registry has two faces
8
+ that must agree — `.github/labels.yml`, which is synced to GitHub, and the §3
9
+ table in `.github/ISSUE_REPORTING.md`, which is what a person reads. Neither
10
+ derives from the other, so either can drift, and nothing notices until an issue
11
+ is filed against a label that does not exist or the sync pushes one the
12
+ documentation never mentions.
13
+
14
+ It arrives here because **every repository wants it and only the paths ever
15
+ differed** — it was a `utils/check-labels.mjs` copied per repository, which is
16
+ the shape a shared check takes just before its copies start disagreeing. Same
17
+ argument that moved the no-attribution check to a shared action.
18
+
19
+ Two things improve in the move:
20
+
21
+ - **Findings are compiler-parseable and located.** The original printed prose
22
+ to stderr; this reports `.github/labels.yml:73:9: error: …` against the file
23
+ each finding belongs to, so a missing row is located in the documentation and
24
+ a missing entry in the registry.
25
+ - **The documentation path is an option.** `--doc` defaults to
26
+ `.github/ISSUE_REPORTING.md`; `Song-of-Heroic-Lands-FoundryVTT` keeps its at
27
+ `kb/dev-docs/how-to/issue-reporting.md` and now needs no separate script.
28
+ `--registry` likewise.
29
+
30
+ A missing §3 is reported once, as its own failure, rather than as every label
31
+ having drifted. An over-long description is caught here too — GitHub answers a
32
+ bare 422 naming neither the label nor the limit.
33
+
34
+ Verified against every repository that has a registry: `sohl-thalorna` (12),
35
+ `sohl-kethira-basic` (11), `harn-adventures` (11), `harn-ensemble` (12) and
36
+ `Song-of-Heroic-Lands-FoundryVTT` (16) all agree — and it found real drift in
37
+ `HarnMaster-3-FoundryVTT`, where `good first issue` and `help wanted` are in
38
+ the registry and absent from §3.
39
+
3
40
  ## 17.0.0
4
41
 
5
42
  ### Major Changes
@@ -83,6 +83,7 @@ import { cleanBuildArtifacts, stageAssets } from "../stage.mjs";
83
83
  import { buildSchemaArtifact } from "../engine/schema-extract.mjs";
84
84
  import { SCHEMA_ARTIFACT_FILE } from "../engine/foreign-catalog.mjs";
85
85
  import { validateLangSource } from "../lang.mjs";
86
+ import { checkLabelRegistry } from "../labels.mjs";
86
87
  import {
87
88
  analyzeCoverage,
88
89
  collectScriptReferences,
@@ -712,6 +713,77 @@ function langHardcoded(config) {
712
713
  *
713
714
  * @returns {object} The yargs command module.
714
715
  */
716
+ /**
717
+ * `labels check` — do the machine registry and the documented table agree?
718
+ *
719
+ * `.github/labels.yml` is synced to GitHub and the §3 table in
720
+ * `.github/ISSUE_REPORTING.md` is what a person reads. Neither derives from the
721
+ * other, so either can drift, and nothing notices until an issue is filed
722
+ * against a label that does not exist.
723
+ *
724
+ * Every repository wants this and only the paths ever differed, which is why it
725
+ * is here rather than copied into each as a `utils/` script.
726
+ *
727
+ * @returns {object} The yargs command module.
728
+ */
729
+ function labelsCommand() {
730
+ return {
731
+ command: "labels <action>",
732
+ describe: "Issue-label registry checks",
733
+ builder: (y) =>
734
+ y
735
+ .positional("action", {
736
+ choices: ["check"],
737
+ describe: "check: the registry and the documented table name the same labels",
738
+ })
739
+ .option("registry", {
740
+ type: "string",
741
+ default: ".github/labels.yml",
742
+ describe: "The machine registry synced to GitHub",
743
+ })
744
+ .option("doc", {
745
+ type: "string",
746
+ default: ".github/ISSUE_REPORTING.md",
747
+ describe: "The documented reference whose §3 table lists the same labels",
748
+ }),
749
+ handler: handler(async (args) => labelsCheck(args)),
750
+ };
751
+ }
752
+
753
+ /**
754
+ * Read both faces of the registry and report where they disagree.
755
+ *
756
+ * Findings are reported against the file each belongs to, so a missing row is
757
+ * located in the documentation and a missing entry in the registry, rather than
758
+ * both being attributed to whichever file was read first.
759
+ *
760
+ * @param {object} args - Parsed CLI arguments.
761
+ */
762
+ function labelsCheck(args) {
763
+ for (const target of [args.registry, args.doc]) {
764
+ if (!fs.existsSync(target)) die(`labels check: ${target} does not exist.`);
765
+ }
766
+ const registryText = fs.readFileSync(args.registry, "utf8");
767
+ const docText = fs.readFileSync(args.doc, "utf8");
768
+
769
+ const { registry, doc, count } = checkLabelRegistry({
770
+ registryText,
771
+ docText,
772
+ docPath: args.doc,
773
+ });
774
+
775
+ const errors =
776
+ reportFindings(registry, { file: args.registry }) + reportFindings(doc, { file: args.doc });
777
+ if (errors) {
778
+ console.error(
779
+ `\nThe registry and ${args.doc} §3 are edited together — ` +
780
+ `change one and change the other.`,
781
+ );
782
+ process.exit(1);
783
+ }
784
+ console.log(`package-build: registry and §3 agree (${count} labels).`);
785
+ }
786
+
715
787
  function langCommand() {
716
788
  return {
717
789
  command: "lang <action>",
@@ -992,6 +1064,7 @@ yargs(hideBin(process.argv))
992
1064
  .command(manifestCommand())
993
1065
  .command(schemaCommand())
994
1066
  .command(langCommand())
1067
+ .command(labelsCommand())
995
1068
  .command(bundleCommand())
996
1069
  .command(releaseCommand())
997
1070
  .command(deployCommand())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heroiclands/package-build",
3
- "version": "17.0.0",
3
+ "version": "17.1.0",
4
4
  "description": "Shared toolchain for building and shipping a HeroicLands Foundry VTT package — content compilation, manifest, localization, staging, bundle, release and deployment.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "type": "module",