diff --git a/README.md b/README.md index 0d710d2..3f6d91a 100644 --- a/README.md +++ b/README.md @@ -43,18 +43,43 @@ addressing a single deprecation at a time, and prevents backsliding ### Getting started -The initial steps needed to get started: +#### Normal setup routine 1. Install the ember-cli-deprecation-workflow addon (`ember install ember-cli-deprecation-workflow`). -3. Run your test suite\* with `ember test --server`. -4. Navigate to your tests (default: http://localhost:7357/) -5. Run `deprecationWorkflow.flushDeprecations()` from your browsers console. -6. Copy the string output into `app/deprecation-workflow.js` in your project. -7. In your `app/app.js`, do: +2. Run your test suite\* with `ember test --server`. +3. Navigate to your tests (default: http://localhost:7357/) +4. Run `deprecationWorkflow.flushDeprecations()` from your browsers console. +5. Copy the string output into a new `app/deprecation-workflow.js` file in your project. +6. In your `app/app.js`, do: + + ```js + import './deprecation-workflow'; + ``` + +#### Setup routine for Embroider in strict mode + +1. Install the ember-cli-deprecation-workflow addon (`ember install ember-cli-deprecation-workflow`). +2. Create an `app/deprecation-workflow.js` file with the following content: + + ```js + import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; + + setupDeprecationWorkflow(); + ``` + +3. In your `app/app.js`, do: + ```js import './deprecation-workflow'; ``` +4. Run your test suite\* with `ember test --server`. +5. Navigate to your tests (default: http://localhost:7357/) +6. Run `deprecationWorkflow.flushDeprecations()` in your browsers console. +7. Copy the string output and overwrite the content of `app/deprecation-workflow.js`. + + In Chrome, use right click → "Copy string contents" to avoid escape characters. + Once this initial setup is completed the "deprecation spew" should be largely "fixed". Only unhandled deprecations will be displayed in your console. diff --git a/index.js b/index.js index 0ca063d..37839ab 100644 --- a/index.js +++ b/index.js @@ -2,4 +2,54 @@ module.exports = { name: require('./package').name, + + _shouldInclude() { + // the presence of `this.app.tests` shows that we are in one of: + // + // * running non-production build + // * running tests against production + // + var app = this.app || this._findHost(); + let addonOptions = app.options['ember-cli-deprecation-workflow']; + + if (addonOptions) { + return addonOptions.enabled; + } else { + return app.tests; + } + }, + + included() { + // From https://github.com/rwjblue/ember-debug-handlers-polyfill/blob/master/index.js + var app = this.app || this._findHost(); + + if (this._shouldInclude()) { + app.import( + 'vendor/ember-cli-deprecation-workflow/deprecation-workflow.js', + ); + app.import('vendor/ember-cli-deprecation-workflow/main.js'); + } + }, + + treeForVendor(tree) { + var root = process.env._DUMMY_CONFIG_ROOT_PATH || this.project.root; + var configDir = '/config'; + + if ( + this.project.pkg['ember-addon'] && + this.project.pkg['ember-addon']['configPath'] + ) { + configDir = '/' + this.project.pkg['ember-addon']['configPath']; + } + + var mergeTrees = require('broccoli-merge-trees'); + var Funnel = require('broccoli-funnel'); + var configTree = new Funnel(root + configDir, { + include: ['deprecation-workflow.js'], + + destDir: 'ember-cli-deprecation-workflow', + }); + + return mergeTrees([tree, configTree], { overwrite: true }); + }, }; diff --git a/vendor/ember-cli-deprecation-workflow/main.js b/vendor/ember-cli-deprecation-workflow/main.js index 7369a05..080b90f 100644 --- a/vendor/ember-cli-deprecation-workflow/main.js +++ b/vendor/ember-cli-deprecation-workflow/main.js @@ -1,103 +1,5 @@ -/* eslint-disable ember/new-module-imports, prettier/prettier */ -/* global require Ember */ - -const LOG_LIMIT = 100; - -(function(){ - self.deprecationWorkflow = self.deprecationWorkflow || {}; - self.deprecationWorkflow.deprecationLog = { - messages: { } - }; - self.deprecationWorkflow.logCounts = {}; - - function detectWorkflow(config, message, options) { - if (!config || !config.workflow) { - return; - } - - let i, workflow, matcher, idMatcher; - for (i=0; i