From 7bbbb32bba98b587404d9da8bf05618ad8c42ad1 Mon Sep 17 00:00:00 2001 From: Bert De Block Date: Tue, 26 Oct 2021 19:10:29 +0200 Subject: [PATCH] Deprecate configuring `ember-cli-memory-leak-detector` via `config/environment.js` (#48) * Deprecate configuring `ember-cli-memory-leak-detector` via `config/environment.js` * Update `ember-cli-memory-leak-detector` version for test packages --- README.md | 23 ++++++++-------- package-lock.json | 10 +++---- .../ember-cli-memory-leak-detector/README.md | 23 ++++++++-------- .../config/environment.js | 11 +------- .../ember-cli-build.js | 5 ++++ .../ember-cli-memory-leak-detector/index.js | 27 ++++++++++++++++++- .../tests/dummy/config/environment.js | 6 ----- .../config/environment.js | 7 ----- .../ember-cli-build.js | 7 ++++- .../my-app-with-custom-port/package.json | 2 +- test-packages/my-app/config/environment.js | 6 ----- test-packages/my-app/ember-cli-build.js | 6 ++++- test-packages/my-app/package.json | 2 +- 13 files changed, 74 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 39bfe7b..183ccfd 100644 --- a/README.md +++ b/README.md @@ -101,17 +101,18 @@ Configuration ------------------------------------------------------------------------------ ```js -// config/environment.js - -'ember-cli-memory-leak-detector': { - enabled: process.env.DETECT_MEMORY_LEAKS || false, - failTests: false, - ignoreClasses: ['ExpectedLeakyClass'], - remoteDebuggingPort: '9222', - timeout: 90000, - writeSnapshot: true -} - +// ember-cli-build.js + +let app = new EmberApp(defaults, { + 'ember-cli-memory-leak-detector': { + enabled: process.env.DETECT_MEMORY_LEAKS || false, + failTests: false, + ignoreClasses: ['ExpectedLeakyClass'], + remoteDebuggingPort: '9222', + timeout: 90000, + writeSnapshot: true, + }, +}); ``` 1. `enabled` (default `true`) diff --git a/package-lock.json b/package-lock.json index 19c9b5e..a65b3ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24672,7 +24672,7 @@ } }, "packages/ember-cli-memory-leak-detector": { - "version": "0.7.0", + "version": "0.7.1", "license": "MIT", "dependencies": { "@babel/parser": "^7.12.10", @@ -24736,7 +24736,7 @@ "ember-cli-dependency-checker": "^3.2.0", "ember-cli-htmlbars": "^5.3.2", "ember-cli-inject-live-reload": "^2.0.2", - "ember-cli-memory-leak-detector": "0.7.0", + "ember-cli-memory-leak-detector": "*", "ember-cli-sri": "^2.1.1", "ember-cli-terser": "^4.0.1", "ember-data": "~3.25.0", @@ -24782,7 +24782,7 @@ "ember-cli-dependency-checker": "^3.2.0", "ember-cli-htmlbars": "^5.3.2", "ember-cli-inject-live-reload": "^2.0.2", - "ember-cli-memory-leak-detector": "0.7.0", + "ember-cli-memory-leak-detector": "*", "ember-cli-sri": "^2.1.1", "ember-cli-terser": "^4.0.1", "ember-data": "~3.25.0", @@ -41232,7 +41232,7 @@ "ember-cli-dependency-checker": "^3.2.0", "ember-cli-htmlbars": "^5.3.2", "ember-cli-inject-live-reload": "^2.0.2", - "ember-cli-memory-leak-detector": "0.7.0", + "ember-cli-memory-leak-detector": "*", "ember-cli-sri": "^2.1.1", "ember-cli-terser": "^4.0.1", "ember-data": "~3.25.0", @@ -41837,7 +41837,7 @@ "ember-cli-dependency-checker": "^3.2.0", "ember-cli-htmlbars": "^5.3.2", "ember-cli-inject-live-reload": "^2.0.2", - "ember-cli-memory-leak-detector": "0.7.0", + "ember-cli-memory-leak-detector": "*", "ember-cli-sri": "^2.1.1", "ember-cli-terser": "^4.0.1", "ember-data": "~3.25.0", diff --git a/packages/ember-cli-memory-leak-detector/README.md b/packages/ember-cli-memory-leak-detector/README.md index 087df0b..7c84517 100644 --- a/packages/ember-cli-memory-leak-detector/README.md +++ b/packages/ember-cli-memory-leak-detector/README.md @@ -99,17 +99,18 @@ Configuration ------------------------------------------------------------------------------ ```js -// config/environment.js - -'ember-cli-memory-leak-detector': { - enabled: process.env.DETECT_MEMORY_LEAKS || false, - failTests: false, - ignoreClasses: ['ExpectedLeakyClass'], - remoteDebuggingPort: '9222', - timeout: 90000, - writeSnapshot: true -} - +// ember-cli-build.js + +let app = new EmberApp(defaults, { + 'ember-cli-memory-leak-detector': { + enabled: process.env.DETECT_MEMORY_LEAKS || false, + failTests: false, + ignoreClasses: ['ExpectedLeakyClass'], + remoteDebuggingPort: '9222', + timeout: 90000, + writeSnapshot: true, + }, +}); ``` 1. `enabled` (default `true`) diff --git a/packages/ember-cli-memory-leak-detector/config/environment.js b/packages/ember-cli-memory-leak-detector/config/environment.js index ab6c850..b723858 100644 --- a/packages/ember-cli-memory-leak-detector/config/environment.js +++ b/packages/ember-cli-memory-leak-detector/config/environment.js @@ -1,14 +1,5 @@ "use strict"; module.exports = function (/* environment, appConfig */) { - return { - "ember-cli-memory-leak-detector": { - enabled: true, - failTests: true, - remoteDebuggingPort: 9222, - timeout: null, - ignoreClasses: [], - writeSnapshot: false, - }, - }; + return {}; }; diff --git a/packages/ember-cli-memory-leak-detector/ember-cli-build.js b/packages/ember-cli-memory-leak-detector/ember-cli-build.js index 95c030d..8422e25 100644 --- a/packages/ember-cli-memory-leak-detector/ember-cli-build.js +++ b/packages/ember-cli-memory-leak-detector/ember-cli-build.js @@ -4,6 +4,11 @@ const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); module.exports = function(defaults) { let app = new EmberAddon(defaults, { + 'ember-cli-memory-leak-detector': { + enabled: !process.env.DISABLE, + failTests: !process.env.NOFAIL, + ignoreClasses: ['LeakyComponent'], + }, 'ember-cli-terser': { terser: { compress: { keep_classnames: true }, diff --git a/packages/ember-cli-memory-leak-detector/index.js b/packages/ember-cli-memory-leak-detector/index.js index bb6075e..43f3128 100644 --- a/packages/ember-cli-memory-leak-detector/index.js +++ b/packages/ember-cli-memory-leak-detector/index.js @@ -1,10 +1,21 @@ "use strict"; +const deprecate = require('ember-cli/lib/utilities/deprecate'); const path = require("path"); const fs = require("fs"); const attachMiddleware = require("./lib/attach-middleware"); +const DEFAULT_CONFIG = { + enabled: true, + failTests: true, + ignoreClasses: [], + remoteDebuggingPort: 9222, + timeout: null, + writeSnapshot: false, +}; + module.exports = { + isConfigDeprecationTriggered: false, name: require("./package").name, contentFor(type) { @@ -34,7 +45,21 @@ module.exports = { }, readConfig() { - return this.project.config()[this.name]; + const hostEnvConfig = this.project.config()[this.name]; + const hostBuildConfig = this._findHost().options[this.name]; + + if (hostEnvConfig && this.isConfigDeprecationTriggered === false) { + this.isConfigDeprecationTriggered = true; + + deprecate( + 'Configuring "ember-cli-memory-leak-detector" via "config/environment.js" is deprecated. Please use "ember-cli-build.js" instead.', + true + ); + + return hostEnvConfig; + } + + return hostBuildConfig || DEFAULT_CONFIG; }, isEnabled() { diff --git a/packages/ember-cli-memory-leak-detector/tests/dummy/config/environment.js b/packages/ember-cli-memory-leak-detector/tests/dummy/config/environment.js index 288efdc..050d31b 100644 --- a/packages/ember-cli-memory-leak-detector/tests/dummy/config/environment.js +++ b/packages/ember-cli-memory-leak-detector/tests/dummy/config/environment.js @@ -21,12 +21,6 @@ module.exports = function(environment) { // Here you can pass flags/options to your application instance // when it is created }, - - "ember-cli-memory-leak-detector": { - enabled: !process.env.DISABLE, - failTests: !process.env.NOFAIL, - ignoreClasses: ["LeakyComponent"], - }, }; if (environment === 'development') { diff --git a/test-packages/my-app-with-custom-port/config/environment.js b/test-packages/my-app-with-custom-port/config/environment.js index ff108a5..591c74e 100644 --- a/test-packages/my-app-with-custom-port/config/environment.js +++ b/test-packages/my-app-with-custom-port/config/environment.js @@ -17,13 +17,6 @@ module.exports = function (environment) { }, }, - "ember-cli-memory-leak-detector": { - enabled: !process.env.DISABLE, - failTests: !process.env.NOFAIL, - ignoreClasses: ["LeakyComponent"], - remoteDebuggingPort: 9223 - }, - APP: { // Here you can pass flags/options to your application instance // when it is created diff --git a/test-packages/my-app-with-custom-port/ember-cli-build.js b/test-packages/my-app-with-custom-port/ember-cli-build.js index 48e94e9..0f0459f 100644 --- a/test-packages/my-app-with-custom-port/ember-cli-build.js +++ b/test-packages/my-app-with-custom-port/ember-cli-build.js @@ -4,7 +4,12 @@ const EmberApp = require('ember-cli/lib/broccoli/ember-app'); module.exports = function (defaults) { let app = new EmberApp(defaults, { - // Add options here + 'ember-cli-memory-leak-detector': { + enabled: !process.env.DISABLE, + failTests: !process.env.NOFAIL, + ignoreClasses: ['LeakyComponent'], + remoteDebuggingPort: 9223, + }, }); // Use `app.import` to add additional libraries to the generated diff --git a/test-packages/my-app-with-custom-port/package.json b/test-packages/my-app-with-custom-port/package.json index 48a38e3..0f91c7f 100644 --- a/test-packages/my-app-with-custom-port/package.json +++ b/test-packages/my-app-with-custom-port/package.json @@ -36,7 +36,7 @@ "ember-cli-dependency-checker": "^3.2.0", "ember-cli-htmlbars": "^5.3.2", "ember-cli-inject-live-reload": "^2.0.2", - "ember-cli-memory-leak-detector": "0.7.0", + "ember-cli-memory-leak-detector": "*", "ember-cli-sri": "^2.1.1", "ember-cli-terser": "^4.0.1", "ember-data": "~3.25.0", diff --git a/test-packages/my-app/config/environment.js b/test-packages/my-app/config/environment.js index 92eb744..5513a9a 100644 --- a/test-packages/my-app/config/environment.js +++ b/test-packages/my-app/config/environment.js @@ -17,12 +17,6 @@ module.exports = function (environment) { }, }, - "ember-cli-memory-leak-detector": { - enabled: !process.env.DISABLE, - failTests: !process.env.NOFAIL, - ignoreClasses: ["LeakyComponent"], - }, - APP: { // Here you can pass flags/options to your application instance // when it is created diff --git a/test-packages/my-app/ember-cli-build.js b/test-packages/my-app/ember-cli-build.js index 48e94e9..dce6b08 100644 --- a/test-packages/my-app/ember-cli-build.js +++ b/test-packages/my-app/ember-cli-build.js @@ -4,7 +4,11 @@ const EmberApp = require('ember-cli/lib/broccoli/ember-app'); module.exports = function (defaults) { let app = new EmberApp(defaults, { - // Add options here + 'ember-cli-memory-leak-detector': { + enabled: !process.env.DISABLE, + failTests: !process.env.NOFAIL, + ignoreClasses: ['LeakyComponent'], + }, }); // Use `app.import` to add additional libraries to the generated diff --git a/test-packages/my-app/package.json b/test-packages/my-app/package.json index 047499d..b120571 100644 --- a/test-packages/my-app/package.json +++ b/test-packages/my-app/package.json @@ -36,7 +36,7 @@ "ember-cli-dependency-checker": "^3.2.0", "ember-cli-htmlbars": "^5.3.2", "ember-cli-inject-live-reload": "^2.0.2", - "ember-cli-memory-leak-detector": "0.7.0", + "ember-cli-memory-leak-detector": "*", "ember-cli-sri": "^2.1.1", "ember-cli-terser": "^4.0.1", "ember-data": "~3.25.0",