« get me outta code hell

data, yaml: save() -> connect(), Thing.wikiData & friends - 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>2025-11-20 15:51:14 -0400
committer(quasar) nebula <qznebula@protonmail.com>2025-11-25 07:06:49 -0400
commitf44b69b6079c80da98aafe9022cb68923e52a03c (patch)
treef5899a51a4dba595a031b7a40c3e0ebd1a468380 /src/upd8.js
parent03142771e556f9e115709832a98d81942528f10a (diff)
data, yaml: save() -> connect(), Thing.wikiData & friends
HOLY GUACAMOLE
Diffstat (limited to 'src/upd8.js')
-rwxr-xr-xsrc/upd8.js26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/upd8.js b/src/upd8.js
index 0bceea8d..7ffcc406 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -105,7 +105,8 @@ import {
   linkWikiDataArrays,
   loadYAMLDocumentsFromDataSteps,
   processThingsFromDataSteps,
-  saveThingsFromDataSteps,
+  connectThingsFromDataSteps,
+  makeWikiDataFromDataSteps,
   sortWikiDataArrays,
 } from '#yaml';
 
@@ -1499,7 +1500,8 @@ async function main() {
 
     let loadAggregate, loadResult;
     let processAggregate, processResult;
-    let saveAggregate, saveResult;
+    let connectAggregate;
+    let makeWikiDataResult;
 
     const dataSteps = getAllDataSteps();
 
@@ -1549,21 +1551,29 @@ async function main() {
     }
 
     try {
-      ({aggregate: saveAggregate, result: saveResult} =
-          saveThingsFromDataSteps(
+      ({aggregate: connectAggregate} =
+          connectThingsFromDataSteps(
             processResult,
             dataSteps));
 
-      saveAggregate.close();
-      saveAggregate = undefined;
+      connectAggregate.close();
     } catch (error) {
       return whoops(error, `finalizing data files`);
     }
 
+    try {
+      makeWikiDataResult =
+        makeWikiDataFromDataSteps(
+          processResult,
+          dataSteps);
+    } catch (error) {
+      return whoops(error, 'preparing wikiData object');
+    }
+
     yamlDataSteps = dataSteps;
     yamlDocumentProcessingAggregate = processAggregate;
 
-    Object.assign(wikiData, saveResult);
+    Object.assign(wikiData, makeWikiDataResult);
   }
 
   {
@@ -1798,7 +1808,7 @@ async function main() {
       if (!paragraph) console.log('');
       niceShowAggregate(aggregate);
 
-      if (aggregate.errors.find(err => err.message.toLowerCase().includes('duplicate'))) {
+      if (aggregate.errors?.find(err => err.message.toLowerCase().includes('duplicate'))) {
         logWarn`The above duplicate directories were detected while reviewing data files.`;
         logWarn`Since it's impossible to automatically determine which one's directory is`;
         logWarn`correct, the build can't continue. Specify unique 'Directory' fields in`;