From 7cb2e02cd74d2d3c48e956bc6bf7637098d3208a Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 27 Mar 2023 14:47:41 -0400 Subject: [PATCH] fix: #11396, removal of base_templates_path variable --- src/meta/build.js | 4 ++-- src/meta/templates.js | 1 - src/meta/themes.js | 7 +++++-- src/prestart.js | 1 - 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/meta/build.js b/src/meta/build.js index 1941291020..81ce4067ca 100644 --- a/src/meta/build.js +++ b/src/meta/build.js @@ -70,7 +70,7 @@ async function beforeBuild(targets) { await plugins.prepareForBuild(targets); await mkdirp(path.join(__dirname, '../../build/public')); } catch (err) { - winston.error(`[build] Encountered error preparing for build\n${err.stack}`); + winston.error(`[build] Encountered error preparing for build`); throw err; } } @@ -197,7 +197,7 @@ exports.build = async function (targets, options) { await cacheBuster.write(); winston.info(`[build] Asset compilation successful. Completed in ${totalTime}sec.`); } catch (err) { - winston.error(`[build] Encountered error during build step\n${err.stack ? err.stack : err}`); + winston.error(`[build] Encountered error during build step`); throw err; } }; diff --git a/src/meta/templates.js b/src/meta/templates.js index 8749379bc0..3250635199 100644 --- a/src/meta/templates.js +++ b/src/meta/templates.js @@ -65,7 +65,6 @@ async function getTemplateDirs(activePlugins) { theme = themeConfig.baseTheme; } - themeTemplates.push(nconf.get('base_templates_path')); themeTemplates = _.uniq(themeTemplates.reverse()); const coreTemplatesPath = nconf.get('core_templates_path'); diff --git a/src/meta/themes.js b/src/meta/themes.js index e5d519c457..a0c42f4708 100644 --- a/src/meta/themes.js +++ b/src/meta/themes.js @@ -159,7 +159,7 @@ Themes.setupPaths = async () => { const themeObj = data.themesData.find(themeObj => themeObj.id === themeId); if (!themeObj) { - throw new Error('[[error:theme-not-found]]'); + throw new Error('theme-not-found'); } Themes.setPath(themeObj); @@ -167,13 +167,16 @@ Themes.setupPaths = async () => { Themes.setPath = function (themeObj) { // Theme's templates path - let themePath = nconf.get('base_templates_path'); + let themePath; const fallback = path.join(nconf.get('themes_path'), themeObj.id, 'templates'); if (themeObj.templates) { themePath = path.join(nconf.get('themes_path'), themeObj.id, themeObj.templates); } else if (file.existsSync(fallback)) { themePath = fallback; + } else { + winston.error('[themes] Unable to resolve this theme\'s templates. Expected to be at "templates/" or defined in the "templates" property of "theme.json"'); + throw new Error('theme-missing-templates'); } nconf.set('theme_templates_path', themePath); diff --git a/src/prestart.js b/src/prestart.js index 1af2d5ce68..bda51ad9e5 100644 --- a/src/prestart.js +++ b/src/prestart.js @@ -75,7 +75,6 @@ function loadConfig(configFile) { // Ensure themes_path is a full filepath nconf.set('themes_path', path.resolve(paths.baseDir, nconf.get('themes_path'))); nconf.set('core_templates_path', path.join(paths.baseDir, 'src/views')); - nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-harmony/templates')); nconf.set('upload_path', path.resolve(nconf.get('base_dir'), nconf.get('upload_path'))); nconf.set('upload_url', '/assets/uploads');