From 9bf95d472d7160a3d4f983447fe61d6f77fc3867 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Wed, 16 Nov 2022 11:07:58 +0100 Subject: [PATCH] DEV: Move `shouldLoadPluginTestJs()` (#19045) A first step in the effort to depend only on explicitly declared dependencies in package.json. --- app/assets/javascripts/discourse-plugins/index.js | 5 +++++ app/assets/javascripts/discourse-plugins/package.json | 1 + app/assets/javascripts/discourse/lib/bootstrap-json/.npmrc | 1 - .../javascripts/discourse/lib/bootstrap-json/index.js | 2 +- app/assets/javascripts/discourse/lib/plugin-js.js | 7 ------- .../javascripts/discourse/lib/site-settings-plugin.js | 2 +- app/assets/javascripts/discourse/lib/translation-plugin.js | 2 +- app/assets/javascripts/discourse/testem.js | 2 +- 8 files changed, 10 insertions(+), 12 deletions(-) delete mode 100644 app/assets/javascripts/discourse/lib/bootstrap-json/.npmrc delete mode 100644 app/assets/javascripts/discourse/lib/plugin-js.js diff --git a/app/assets/javascripts/discourse-plugins/index.js b/app/assets/javascripts/discourse-plugins/index.js index 4b5ed201fb6..74fea7f45f3 100644 --- a/app/assets/javascripts/discourse-plugins/index.js +++ b/app/assets/javascripts/discourse-plugins/index.js @@ -8,6 +8,7 @@ const fs = require("fs"); const concat = require("broccoli-concat"); const RawHandlebarsCompiler = require("discourse-hbr/raw-handlebars-compiler"); const DiscoursePluginColocatedTemplateProcessor = require("./colocated-template-compiler"); +const EmberApp = require("ember-cli/lib/broccoli/ember-app"); function fixLegacyExtensions(tree) { return new Funnel(tree, { @@ -217,4 +218,8 @@ module.exports = { // This addon doesn't contribute any 'real' trees to the app return; }, + + shouldLoadPluginTestJs() { + return EmberApp.env() === "development" || process.env.LOAD_PLUGINS === "1"; + }, }; diff --git a/app/assets/javascripts/discourse-plugins/package.json b/app/assets/javascripts/discourse-plugins/package.json index b3ea492b986..9dfeac50209 100644 --- a/app/assets/javascripts/discourse-plugins/package.json +++ b/app/assets/javascripts/discourse-plugins/package.json @@ -11,6 +11,7 @@ "dependencies": { "discourse-widget-hbs": "1.0.0", "ember-auto-import": "^2.4.3", + "ember-cli": "~3.28.5", "ember-cli-babel": "^7.26.10", "ember-cli-htmlbars": "^6.1.1" }, diff --git a/app/assets/javascripts/discourse/lib/bootstrap-json/.npmrc b/app/assets/javascripts/discourse/lib/bootstrap-json/.npmrc deleted file mode 100644 index c42da845b44..00000000000 --- a/app/assets/javascripts/discourse/lib/bootstrap-json/.npmrc +++ /dev/null @@ -1 +0,0 @@ -engine-strict = true diff --git a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js b/app/assets/javascripts/discourse/lib/bootstrap-json/index.js index 1c778d80a02..3730db1157f 100644 --- a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js +++ b/app/assets/javascripts/discourse/lib/bootstrap-json/index.js @@ -8,7 +8,7 @@ const path = require("path"); const fs = require("fs"); const fsPromises = fs.promises; const { JSDOM } = require("jsdom"); -const { shouldLoadPluginTestJs } = require("discourse/lib/plugin-js"); +const { shouldLoadPluginTestJs } = require("discourse-plugins"); const { Buffer } = require("node:buffer"); const { cwd, env } = require("node:process"); diff --git a/app/assets/javascripts/discourse/lib/plugin-js.js b/app/assets/javascripts/discourse/lib/plugin-js.js deleted file mode 100644 index 5d741fc4ffe..00000000000 --- a/app/assets/javascripts/discourse/lib/plugin-js.js +++ /dev/null @@ -1,7 +0,0 @@ -const EmberApp = require("ember-cli/lib/broccoli/ember-app"); - -module.exports = { - shouldLoadPluginTestJs() { - return EmberApp.env() === "development" || process.env.LOAD_PLUGINS === "1"; - }, -}; diff --git a/app/assets/javascripts/discourse/lib/site-settings-plugin.js b/app/assets/javascripts/discourse/lib/site-settings-plugin.js index c576eee53d7..1ebdfbcb2ab 100644 --- a/app/assets/javascripts/discourse/lib/site-settings-plugin.js +++ b/app/assets/javascripts/discourse/lib/site-settings-plugin.js @@ -5,7 +5,7 @@ const concat = require("broccoli-concat"); const mergeTrees = require("broccoli-merge-trees"); const deepmerge = require("deepmerge"); const glob = require("glob"); -const { shouldLoadPluginTestJs } = require("discourse/lib/plugin-js"); +const { shouldLoadPluginTestJs } = require("discourse-plugins"); let built = false; diff --git a/app/assets/javascripts/discourse/lib/translation-plugin.js b/app/assets/javascripts/discourse/lib/translation-plugin.js index 3f23e8116ae..29fd1299590 100644 --- a/app/assets/javascripts/discourse/lib/translation-plugin.js +++ b/app/assets/javascripts/discourse/lib/translation-plugin.js @@ -6,7 +6,7 @@ const mergeTrees = require("broccoli-merge-trees"); const MessageFormat = require("messageformat"); const deepmerge = require("deepmerge"); const glob = require("glob"); -const { shouldLoadPluginTestJs } = require("discourse/lib/plugin-js"); +const { shouldLoadPluginTestJs } = require("discourse-plugins"); let built = false; diff --git a/app/assets/javascripts/discourse/testem.js b/app/assets/javascripts/discourse/testem.js index 922a6da9059..6f0bc0382e3 100644 --- a/app/assets/javascripts/discourse/testem.js +++ b/app/assets/javascripts/discourse/testem.js @@ -1,5 +1,5 @@ const TapReporter = require("testem/lib/reporters/tap_reporter"); -const { shouldLoadPluginTestJs } = require("discourse/lib/plugin-js"); +const { shouldLoadPluginTestJs } = require("discourse-plugins"); const fs = require("fs"); class Reporter {