« get me outta code hell

data-checks, upd8: report content string reference & key errors - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/upd8.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-02-16 18:07:04 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-02-17 17:09:19 -0400
commit08b7810729678e2c41c02fff569c322f15e76e07 (patch)
tree3958a773f3db0c80bad781770741fa189ce799bb /src/upd8.js
parent693fa5da156f7879bf63327fc54fb5e4f1e57e6c (diff)
data-checks, upd8: report content string reference & key errors
Diffstat (limited to 'src/upd8.js')
-rwxr-xr-xsrc/upd8.js41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/upd8.js b/src/upd8.js
index 24fba6b..836ff6b 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -42,8 +42,11 @@ import wrap from 'word-wrap';
 // order. This obviously needs fixing up.
 
 /* precede #find */
-import {filterReferenceErrors, reportDuplicateDirectories}
-  from '#data-checks';
+import {
+  filterReferenceErrors,
+  reportDuplicateDirectories,
+  reportContentTextErrors,
+} from '#data-checks';
 
 import {bindFind, getAllFindSpecs} from '#find';
 
@@ -138,11 +141,14 @@ async function main() {
       {...defaultStepStatus, name: `precache common data`},
 
     reportDuplicateDirectories:
-      {...defaultStepStatus, name: `filter duplicate directories`},
+      {...defaultStepStatus, name: `report duplicate directories`},
 
     filterReferenceErrors:
       {...defaultStepStatus, name: `filter reference errors`},
 
+    reportContentTextErrors:
+      {...defaultStepStatus, name: `report content text errors`},
+
     sortWikiDataArrays:
       {...defaultStepStatus, name: `sort wiki data arrays`},
 
@@ -1184,6 +1190,35 @@ async function main() {
     }
   }
 
+  if (stepStatusSummary.reportContentTextErrors.status === STATUS_NOT_STARTED) {
+    Object.assign(stepStatusSummary.reportContentTextErrors, {
+      status: STATUS_STARTED_NOT_DONE,
+      timeStart: Date.now(),
+    });
+
+    try {
+      reportContentTextErrors(wikiData, {bindFind});
+      logInfo`All content text validated without any errors - nice!`;
+
+      Object.assign(stepStatusSummary.reportContentTextErrors, {
+        status: STATUS_DONE_CLEAN,
+        timeEnd: Date.now(),
+      });
+    } catch (error) {
+      niceShowAggregate(error);
+
+      logWarn`The above errors were detected while processing content text in data files.`;
+      logWarn`The wiki will still build, but placeholders will be displayed in these spots.`;
+      logWarn`Resolve the errors for more complete output.`;
+
+      Object.assign(stepStatusSummary.reportContentTextErrors, {
+        status: STATUS_HAS_WARNINGS,
+        annotation: `view log for details`,
+        timeEnd: Date.now(),
+      });
+    }
+  }
+
   // Sort data arrays so that they're all in order! This may use properties
   // which are only available after the initial linking.