Skip to content

Commit

Permalink
Deprecate configuring ember-cli-memory-leak-detector via `config/en…
Browse files Browse the repository at this point in the history
…vironment.js` (#48)

* Deprecate configuring `ember-cli-memory-leak-detector` via `config/environment.js`

* Update `ember-cli-memory-leak-detector` version for test packages
  • Loading branch information
bertdeblock authored Oct 26, 2021
1 parent 03dd8b0 commit 7bbbb32
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 61 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions packages/ember-cli-memory-leak-detector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
11 changes: 1 addition & 10 deletions packages/ember-cli-memory-leak-detector/config/environment.js
Original file line number Diff line number Diff line change
@@ -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 {};
};
5 changes: 5 additions & 0 deletions packages/ember-cli-memory-leak-detector/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
27 changes: 26 additions & 1 deletion packages/ember-cli-memory-leak-detector/index.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
7 changes: 0 additions & 7 deletions test-packages/my-app-with-custom-port/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion test-packages/my-app-with-custom-port/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test-packages/my-app-with-custom-port/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 0 additions & 6 deletions test-packages/my-app/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion test-packages/my-app/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test-packages/my-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7bbbb32

Please sign in to comment.