diff options
Diffstat (limited to 'src/upd8.js')
| -rwxr-xr-x | src/upd8.js | 88 |
1 files changed, 54 insertions, 34 deletions
diff --git a/src/upd8.js b/src/upd8.js index 86ecab69..7ffcc406 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -42,8 +42,9 @@ import wrap from 'word-wrap'; import {mapAggregate, openAggregate, showAggregate} from '#aggregate'; import CacheableObject from '#cacheable-object'; -import {stringifyCache} from '#cli'; +import {formatDuration, stringifyCache} from '#cli'; import {displayCompositeCacheAnalysis} from '#composite'; +import * as html from '#html'; import find, {bindFind, getAllFindSpecs} from '#find'; import {processLanguageFile, watchLanguageFile, internalDefaultStringsFile} from '#language'; @@ -104,7 +105,8 @@ import { linkWikiDataArrays, loadYAMLDocumentsFromDataSteps, processThingsFromDataSteps, - saveThingsFromDataSteps, + connectThingsFromDataSteps, + makeWikiDataFromDataSteps, sortWikiDataArrays, } from '#yaml'; @@ -117,7 +119,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)); let COMMIT; try { COMMIT = execSync('git log --format="%h %B" -n 1 HEAD', {cwd: __dirname}).toString().trim(); -} catch (error) { +} catch { COMMIT = '(failed to detect)'; } @@ -518,6 +520,11 @@ async function main() { type: 'flag', }, + 'skip-self-diagnosis': { + help: `Disable some runtime validation for the wiki's own code, which speeds up long builds, but may allow unpredicted corner cases to fail strangely and silently`, + type: 'flag', + }, + 'queue-size': { help: `Process more or fewer disk files at once to optimize performance or avoid I/O errors, unlimited if set to 0 (between 500 and 700 is usually a safe range for building HSMusic on Windows machines)\nDefaults to ${defaultQueueSize}`, type: 'value', @@ -656,7 +663,8 @@ async function main() { const thumbsOnly = cliOptions['thumbs-only'] ?? false; const noInput = cliOptions['no-input'] ?? false; - const showAggregateTraces = cliOptions['show-traces'] ?? false; + const skipSelfDiagnosis = cliOptions['skip-self-diagnosis'] ?? false; + const showTraces = cliOptions['show-traces'] ?? false; const precacheMode = cliOptions['precache-mode'] ?? 'common'; @@ -1156,6 +1164,18 @@ async function main() { return false; } + if (skipSelfDiagnosis) { + logWarn`${'Skipping code self-diagnosis.'} (--skip-self-diagnosis provided)`; + logWarn`This build should run substantially faster, but corner cases`; + logWarn`not previously predicted may fail strangely and silently.`; + + html.disableSlotValidation(); + } + + if (!showTraces) { + html.disableTagTracing(); + } + Object.assign(stepStatusSummary.determineMediaCachePath, { status: STATUS_STARTED_NOT_DONE, timeStart: Date.now(), @@ -1334,7 +1354,7 @@ async function main() { const niceShowAggregate = (error, ...opts) => { showAggregate(error, { - showTraces: showAggregateTraces, + showTraces, pathToFileURL: (f) => path.relative(__dirname, fileURLToPath(f)), ...opts, }); @@ -1480,7 +1500,8 @@ async function main() { let loadAggregate, loadResult; let processAggregate, processResult; - let saveAggregate, saveResult; + let connectAggregate; + let makeWikiDataResult; const dataSteps = getAllDataSteps(); @@ -1530,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); } { @@ -1779,10 +1808,17 @@ async function main() { if (!paragraph) console.log(''); niceShowAggregate(aggregate); - 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`; - logWarn`some or all of these data entries to resolve the errors.`; + 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`; + logWarn`some or all of these data entries to resolve the errors.`; + } else { + logWarn`The above directory errors were detected while reviewing data files.`; + logWarn`Since it's impossible to automatically fill in working directories,`; + logWarn`the build can't continue. Manually specify 'Directory' fields in`; + logWarn`some or all of these data entries to resolve the errors.`; + } console.log(''); paragraph = true; @@ -2419,7 +2455,7 @@ async function main() { }); internalDefaultLanguage = internalDefaultLanguageWatcher.language; - } catch (_error) { + } catch { // No need to display the error here - it's already printed by // watchLanguageFile. errorLoadingInternalDefaultLanguage = true; @@ -3207,6 +3243,7 @@ async function main() { developersComment, languages, missingImagePaths, + niceShowAggregate, thumbsCache, urlSpec, urls, @@ -3269,7 +3306,7 @@ async function main() { } // TODO: isMain detection isn't consistent across platforms here -/* eslint-disable-next-line no-constant-condition */ +// eslint-disable-next-line no-constant-binary-expression if (true || isMain(import.meta.url) || path.basename(process.argv[1]) === 'hsmusic') { (async () => { let result; @@ -3363,23 +3400,6 @@ if (true || isMain(import.meta.url) || path.basename(process.argv[1]) === 'hsmus })(); } -function formatDuration(timeDelta) { - const seconds = timeDelta / 1000; - - if (seconds > 90) { - const modSeconds = Math.floor(seconds % 60); - const minutes = Math.floor(seconds - seconds % 60) / 60; - return `${minutes}m${modSeconds}s`; - } - - if (seconds < 0.1) { - return 'instant'; - } - - const precision = (seconds > 1 ? 3 : 2); - return `${seconds.toPrecision(precision)}s`; -} - function showStepStatusSummary() { const longestNameLength = Math.max(... |