« get me outta code hell

urls, upd8: load internal url spec from yaml file - 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-01-16 09:15:50 -0400
committer(quasar) nebula <qznebula@protonmail.com>2025-01-16 09:15:50 -0400
commit38e4c4d60c411a19dbbf229bdece1833bb4eec1e (patch)
tree8160ced24f452449bc942b6fc0c92bda2bc5735b /src/upd8.js
parentdffcfd79cb7256e1f75a753dc5bafcb49e50793e (diff)
urls, upd8: load internal url spec from yaml file
Diffstat (limited to 'src/upd8.js')
-rwxr-xr-xsrc/upd8.js48
1 files changed, 45 insertions, 3 deletions
diff --git a/src/upd8.js b/src/upd8.js
index 6097f21f..b83b5171 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -50,7 +50,8 @@ import {isMain, traverse} from '#node-utils';
 import {bindReverse} from '#reverse';
 import {writeSearchData} from '#search';
 import {sortByName} from '#sort';
-import {generateURLs, urlSpec} from '#urls';
+import {internalDefaultURLSpecFile, generateURLs, processURLSpecFromFile}
+  from '#urls';
 import {identifyAllWebRoutes} from '#web-routes';
 
 import {
@@ -180,6 +181,10 @@ async function main() {
       {...defaultStepStatus, name: `precache nearly all data`,
         for: ['build']},
 
+    loadURLFiles:
+      {...defaultStepStatus, name: `load internal & custom url spec files`,
+        for: ['build']},
+
     // TODO: This should be split into load/watch steps.
     loadInternalDefaultLanguage:
       {...defaultStepStatus, name: `load internal default language`,
@@ -1627,8 +1632,6 @@ async function main() {
     });
   }
 
-  const urls = generateURLs(urlSpec);
-
   // Filter out any things with duplicate directories throughout the data,
   // warning about them too.
 
@@ -1801,6 +1804,45 @@ async function main() {
     }
   }
 
+  Object.assign(stepStatusSummary.loadURLFiles, {
+    status: STATUS_STARTED_NOT_DONE,
+    timeStart: Date.now(),
+  });
+
+  let internalURLSpec = {};
+
+  try {
+    let aggregate;
+    ({aggregate, result: internalURLSpec} =
+      await processURLSpecFromFile(internalDefaultURLSpecFile));
+
+    aggregate.close();
+  } catch (error) {
+    niceShowAggregate(error);
+    logError`Couldn't load internal default URL spec.`;
+    logError`This is required to build the wiki, so stopping here.`;
+    fileIssue();
+
+    Object.assign(stepStatusSummary.loadURLFiles, {
+      status: STATUS_FATAL_ERROR,
+      annotation: `see log for details`,
+      timeEnd: Date.now(),
+      memory: process.memoryUsage(),
+    });
+
+    return false;
+  }
+
+  const urlSpec = internalURLSpec;
+
+  Object.assign(stepStatusSummary.loadURLFiles, {
+    status: STATUS_DONE_CLEAN,
+    timeEnd: Date.now(),
+    memory: process.memoryUsage(),
+  });
+
+  const urls = generateURLs(urlSpec);
+
   const languageReloading =
     stepStatusSummary.watchLanguageFiles.status === STATUS_NOT_STARTED;