From 594b2ebe9b35f6dc910dbe560cbf19e9265a96c1 Mon Sep 17 00:00:00 2001 From: "Andrey Mikhaylov (lolmaus)" Date: Thu, 25 Jan 2024 14:37:18 +0300 Subject: [PATCH] Update getting started instructions in readme with Embroider-first path --- README.md | 24 ++-- index.js | 50 ++++++++ .../deprecation-workflow.js | 1 + vendor/ember-cli-deprecation-workflow/main.js | 107 +----------------- 4 files changed, 74 insertions(+), 108 deletions(-) create mode 100644 vendor/ember-cli-deprecation-workflow/deprecation-workflow.js diff --git a/README.md b/README.md index 0d710d2..af712c7 100644 --- a/README.md +++ b/README.md @@ -43,18 +43,28 @@ addressing a single deprecation at a time, and prevents backsliding ### Getting started -The initial steps needed to get started: - 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. 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/deprecation-workflow.js b/vendor/ember-cli-deprecation-workflow/deprecation-workflow.js new file mode 100644 index 0000000..06ce268 --- /dev/null +++ b/vendor/ember-cli-deprecation-workflow/deprecation-workflow.js @@ -0,0 +1 @@ +// default config/deprecation-workflow.js diff --git a/vendor/ember-cli-deprecation-workflow/main.js b/vendor/ember-cli-deprecation-workflow/main.js index 7369a05..ca15538 100644 --- a/vendor/ember-cli-deprecation-workflow/main.js +++ b/vendor/ember-cli-deprecation-workflow/main.js @@ -1,103 +1,8 @@ -/* eslint-disable ember/new-module-imports, prettier/prettier */ -/* global require Ember */ +/* eslint-disable no-empty */ +/* global require */ -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