From 33c607bbdc8211cd32232bf50cdcf7eafbaf48a7 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 27 Feb 2022 12:55:13 -0400 Subject: warn specifically about referenced aliases --- src/upd8.js | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/upd8.js b/src/upd8.js index e903d6af..eb2da684 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -2879,7 +2879,14 @@ async function main() { if (!thing[property]) continue; if (findFnKey === '_contrib') { thing[property] = filter(thing[property], - decorateErrorWithIndex(({ who }) => boundFind.artist(who)), + decorateErrorWithIndex(({ who }) => { + const alias = find.artist(who, wikiData.artistAliasData, {mode: 'quiet'}); + if (alias) { + const original = find.artist(alias.aliasedArtistRef, wikiData.artistData, {mode: 'quiet'}); + throw new Error(`Reference ${color.red(who)} is to an alias, should be ${color.green(original.name)}`); + } + return boundFind.artist(who); + }), {message: `Reference errors in contributions ${color.green(property)}`}); continue; } @@ -2928,6 +2935,18 @@ async function main() { // appropriate. linkDataArrays(); + WD.artistAliasData = wikiData.artistData.flatMap(artist => { + const origRef = Thing.getReference(artist); + return (artist.aliasNames?.map(name => { + const alias = new Artist(); + alias.name = name; + alias.isAlias = true; + alias.aliasedArtistRef = origRef; + alias.artistData = WD.artistData; + return alias; + }) ?? []); + }); + // Filter out any reference errors throughout the data, warning about them // too. filterAndShowReferenceErrors(); @@ -2984,18 +3003,6 @@ async function main() { WD.justEverythingSortedByArtDateMan = sortByArtDate(WD.justEverythingMan.slice()); // console.log(JSON.stringify(justEverythingSortedByArtDateMan.map(toAnythingMan), null, 2)); - WD.artistAliasData = wikiData.artistData.flatMap(artist => { - const origRef = Thing.getReference(artist); - return (artist.aliasNames?.map(name => { - const alias = new Artist(); - alias.name = name; - alias.isAlias = true; - alias.aliasedArtistRef = origRef; - alias.artistData = WD.artistData; - return alias; - }) ?? []); - }); - { const directories = []; for (const { directory, name } of WD.albumData) { -- cgit 1.3.0-6-gf8a5