« get me outta code hell

web-routes, upd8, write: integrate web routes with url-spec - 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-05-01 19:57:48 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-05-01 20:20:29 -0300
commitc8c9c465b241062570cc3955c01fb5d59d20d888 (patch)
treef81207bf154c81d28eee6b445d4d3cb1d7c2ae58 /src/upd8.js
parente9eb08953d9ff25c23d67168d7b9d47599425f42 (diff)
web-routes, upd8, write: integrate web routes with url-spec
[Note: due to a fantastical Rebase Fail Moment, this commit
 accidentally reintroduced some bad imports in upd8.js that
 are meant to be factored into #import-heck. So this commit
 is rewritten to not do that, but it means the commits in
 pull requests #442 and #479 don't line up with main history
 like they should. Oops.]
Diffstat (limited to 'src/upd8.js')
-rwxr-xr-xsrc/upd8.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/upd8.js b/src/upd8.js
index a1ef292..4b5064a 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -40,7 +40,7 @@ import {fileURLToPath} from 'node:url';
 
 import wrap from 'word-wrap';
 
-import {showAggregate} from '#aggregate';
+import {mapAggregate, showAggregate} from '#aggregate';
 import CacheableObject from '#cacheable-object';
 import {displayCompositeCacheAnalysis} from '#composite';
 import {bindFind, getAllFindSpecs} from '#find';
@@ -1788,13 +1788,27 @@ async function main() {
       timeStart: Date.now(),
     });
 
+    const fromRoot = urls.from('shared.root');
+
     try {
-      webRoutes = await identifyAllWebRoutes({
+      const webRouteSources = await identifyAllWebRoutes({
         mediaCachePath,
         mediaPath,
       });
+
+      const {aggregate, result} =
+        mapAggregate(
+          webRouteSources,
+          ({to, ...rest}) => ({
+            ...rest,
+            to: fromRoot.to(...to),
+          }),
+          {message: `Errors computing effective web route paths`},);
+
+      aggregate.close();
+      webRoutes = result;
     } catch (error) {
-      console.error(error);
+      niceShowAggregate(error);
 
       logError`There was an issue identifying web routes!`;
       fileIssue();