From b1a6c1e06bb0c316803f9dc8fc2b0a017734293a Mon Sep 17 00:00:00 2001 From: "Andrey Mikhaylov (lolmaus)" Date: Mon, 23 Oct 2023 20:17:53 +0300 Subject: [PATCH 1/8] [BREAKING] Convert to a module, drops support for Ember < 3.28 --- README.md | 12 +- addon/index.js | 114 +++ index.js | 50 -- tests/dummy/app/app.js | 1 + .../{config => app}/deprecation-workflow.js | 8 +- tests/unit/deprecation-collector-test.js | 652 +++++++++++------- .../deprecation-workflow.js | 1 - 7 files changed, 526 insertions(+), 312 deletions(-) create mode 100644 addon/index.js rename tests/dummy/{config => app}/deprecation-workflow.js (87%) delete mode 100644 vendor/ember-cli-deprecation-workflow/deprecation-workflow.js diff --git a/README.md b/README.md index f4844ac..860e97c 100644 --- a/README.md +++ b/README.md @@ -40,10 +40,14 @@ addressing a single deprecation at a time, and prevents backsliding The initial steps needed to get started: 1. Install the ember-cli-deprecation-workflow addon (`ember install ember-cli-deprecation-workflow`). -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 `config/deprecation-workflow.js` in your project. +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: + ```js + import './deprecation-workflow'; + ``` 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/addon/index.js b/addon/index.js new file mode 100644 index 0000000..e7bb632 --- /dev/null +++ b/addon/index.js @@ -0,0 +1,114 @@ +import { registerDeprecationHandler } from '@ember/debug'; + +const LOG_LIMIT = 100; + +export default function setupDeprecationWorkflow(config) { + self.deprecationWorkflow = self.deprecationWorkflow || {}; + self.deprecationWorkflow.deprecationLog = { + messages: {}, + }; + + registerDeprecationHandler((message, options, next) => + handleDeprecationWorkflow(config, message, options, next) + ); + + registerDeprecationHandler(deprecationCollector); + + self.deprecationWorkflow.flushDeprecations = flushDeprecations; +} + +let preamble = `import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; + +setupDeprecationWorkflow({ + workflow: [ +`; + +let postamble = ` ] +});`; + +export function detectWorkflow(config, message, options) { + if (!config || !config.workflow) { + return; + } + + let i, workflow, matcher, idMatcher; + for (i = 0; i < config.workflow.length; i++) { + workflow = config.workflow[i]; + matcher = workflow.matchMessage; + idMatcher = workflow.matchId; + + if (typeof idMatcher === 'string' && options && idMatcher === options.id) { + return workflow; + } else if (typeof matcher === 'string' && matcher === message) { + return workflow; + } else if (matcher instanceof RegExp && matcher.exec(message)) { + return workflow; + } + } +} + +export function flushDeprecations() { + let messages = self.deprecationWorkflow.deprecationLog.messages; + let logs = []; + + for (let message in messages) { + logs.push(messages[message]); + } + + let deprecations = logs.join(',\n') + '\n'; + + return preamble + deprecations + postamble; +} + +export function handleDeprecationWorkflow(config, message, options, next) { + let matchingWorkflow = detectWorkflow(config, message, options); + if (!matchingWorkflow) { + if (config && config.throwOnUnhandled) { + throw new Error(message); + } else { + next(message, options); + } + } else { + switch (matchingWorkflow.handler) { + case 'silence': + // no-op + break; + case 'log': { + let key = (options && options.id) || message; + + if (!self.deprecationWorkflow.logCounts) { + self.deprecationWorkflow.logCounts = {}; + } + + let count = self.deprecationWorkflow.logCounts[key] || 0; + self.deprecationWorkflow.logCounts[key] = ++count; + + if (count <= LOG_LIMIT) { + console.warn('DEPRECATION: ' + message); + if (count === LOG_LIMIT) { + console.warn( + 'To avoid console overflow, this deprecation will not be logged any more in this run.' + ); + } + } + + break; + } + case 'throw': + throw new Error(message); + default: + next(message, options); + break; + } + } +} + +export function deprecationCollector(message, options, next) { + let key = (options && options.id) || message; + let matchKey = options && key === options.id ? 'matchId' : 'matchMessage'; + + self.deprecationWorkflow.deprecationLog.messages[key] = + ' { handler: "silence", ' + matchKey + ': ' + JSON.stringify(key) + ' }'; + + next(message, options); +} diff --git a/index.js b/index.js index 37839ab..0ca063d 100644 --- a/index.js +++ b/index.js @@ -2,54 +2,4 @@ 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/tests/dummy/app/app.js b/tests/dummy/app/app.js index 523bad6..7c73522 100644 --- a/tests/dummy/app/app.js +++ b/tests/dummy/app/app.js @@ -2,6 +2,7 @@ import Application from '@ember/application'; import Resolver from 'ember-resolver'; import loadInitializers from 'ember-load-initializers'; import config from 'dummy/config/environment'; +import './deprecation-workflow'; export default class App extends Application { modulePrefix = config.modulePrefix; diff --git a/tests/dummy/config/deprecation-workflow.js b/tests/dummy/app/deprecation-workflow.js similarity index 87% rename from tests/dummy/config/deprecation-workflow.js rename to tests/dummy/app/deprecation-workflow.js index 27cf616..29c90a4 100644 --- a/tests/dummy/config/deprecation-workflow.js +++ b/tests/dummy/app/deprecation-workflow.js @@ -1,6 +1,6 @@ -/* globals self */ -self.deprecationWorkflow = self.deprecationWorkflow || {}; -self.deprecationWorkflow.config = { +import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; + +setupDeprecationWorkflow({ throwOnUnhandled: true, workflow: [ /* @@ -26,4 +26,4 @@ self.deprecationWorkflow.config = { { matchMessage: 'throw-strict', handler: 'throw' }, ], -}; +}); diff --git a/tests/unit/deprecation-collector-test.js b/tests/unit/deprecation-collector-test.js index 285ae72..e40c681 100644 --- a/tests/unit/deprecation-collector-test.js +++ b/tests/unit/deprecation-collector-test.js @@ -1,21 +1,29 @@ /* eslint-disable qunit/require-expect */ /* eslint no-console: 0 */ -import { deprecate } from '@ember/debug'; import { module } from 'qunit'; import test from '../helpers/debug-test'; +import { + flushDeprecations, + deprecationCollector, + handleDeprecationWorkflow, +} from 'ember-cli-deprecation-workflow'; let originalWarn, originalConfig; -module('deprecation collector', function (hooks) { +module('Unit tests', function (hooks) { hooks.beforeEach(function () { originalWarn = console.warn; /* * Clear config for these tests */ - originalConfig = self.deprecationWorkflow.config; - self.deprecationWorkflow.config = null; + originalConfig = self.deprecationWorkflow = { + config: null, + deprecationLog: { + messages: [], + }, + }; }); hooks.afterEach(function () { @@ -24,309 +32,447 @@ module('deprecation collector', function (hooks) { console.warn = originalWarn; }); - test('calling flushDeprecations returns string of deprecations', function (assert) { - deprecate('First deprecation', false, { - id: 'first', - since: 'the beginning', - until: 'forever', - for: 'testing', - }); - deprecate('Second deprecation', false, { - id: 'second', - since: 'the beginning', - until: 'forever', - for: 'testing', - }); - let deprecationsPayload = self.deprecationWorkflow.flushDeprecations(); - assert.strictEqual( - deprecationsPayload, - `self.deprecationWorkflow = self.deprecationWorkflow || {}; -self.deprecationWorkflow.config = { + module('deprecationCollector', function () { + test('calling flushDeprecations returns string of deprecations', function (assert) { + deprecationCollector( + 'First deprecation', + { + id: 'first', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + deprecationCollector( + 'Second deprecation', + { + id: 'second', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + let deprecationsPayload = flushDeprecations(); + assert.strictEqual( + deprecationsPayload, + `import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; + +setupDeprecationWorkflow({ workflow: [ { handler: "silence", matchId: "first" }, { handler: "silence", matchId: "second" } ] -};`, - ); - }); - - test('deprecations are not duplicated', function (assert) { - deprecate('First deprecation', false, { - id: 'first', - since: 'the beginning', - until: 'forever', - for: 'testing', - }); - deprecate('Second deprecation', false, { - id: 'second', - since: 'the beginning', - until: 'forever', - for: 'testing', +});` + ); }); - // do it again - deprecate('First deprecation', false, { - id: 'first', - since: 'the beginning', - until: 'forever', - for: 'testing', - }); - deprecate('Second deprecation', false, { - id: 'second', - since: 'the beginning', - until: 'forever', - for: 'testing', + test('should call next', function (assert) { + assert.expect(1); + + function next() { + assert.ok(true, 'next has been called'); + } + + deprecationCollector( + 'First deprecation', + { + id: 'first', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + next + ); }); - let deprecationsPayload = self.deprecationWorkflow.flushDeprecations(); - assert.strictEqual( - deprecationsPayload, - `self.deprecationWorkflow = self.deprecationWorkflow || {}; -self.deprecationWorkflow.config = { + test('deprecations are not duplicated', function (assert) { + deprecationCollector( + 'First deprecation', + { + id: 'first', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + deprecationCollector( + 'Second deprecation', + { + id: 'second', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + + // do it again + deprecationCollector( + 'First deprecation', + { + id: 'first', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + deprecationCollector( + 'Second deprecation', + { + id: 'second', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + + let deprecationsPayload = flushDeprecations(); + assert.strictEqual( + deprecationsPayload, + `import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; + +setupDeprecationWorkflow({ workflow: [ { handler: "silence", matchId: "first" }, { handler: "silence", matchId: "second" } ] -};`, - ); +});` + ); + }); }); - test('specifying `throwOnUnhandled` as true raises', function (assert) { - assert.expect(2); - - self.deprecationWorkflow.config = { - throwOnUnhandled: true, - workflow: [{ handler: 'silence', matchMessage: 'Sshhhhh!!' }], - }; + module('handleDeprecationWorkflow', function () { + test('specifying `throwOnUnhandled` as true raises', function (assert) { + assert.expect(2); + + const config = { + throwOnUnhandled: true, + workflow: [{ handler: 'silence', matchMessage: 'Sshhhhh!!' }], + }; + + assert.throws( + function () { + handleDeprecationWorkflow( + config, + 'Foobarrrzzzz', + { + since: 'the beginning', + until: 'forever', + id: 'foobar', + for: 'testing', + }, + () => {} + ); + }, + /Foobarrrzzzz/, + 'setting raiseOnUnhandled throws for unknown workflows' + ); - assert.throws( - function () { - deprecate('Foobarrrzzzz', false, { + handleDeprecationWorkflow( + config, + 'Sshhhhh!!', + { + id: 'quiet', since: 'the beginning', until: 'forever', - id: 'foobar', for: 'testing', - }); - }, - /Foobarrrzzzz/, - 'setting raiseOnUnhandled throws for unknown workflows', - ); - - deprecate('Sshhhhh!!', false, { - id: 'quiet', - since: 'the beginning', - until: 'forever', - for: 'testing', + }, + () => {} + ); + assert.ok(true, 'did not throw when silenced'); }); - assert.ok(true, 'did not throw when silenced'); - }); - test('specifying `throwOnUnhandled` as false does nothing', function (assert) { - assert.expect(1); + test('specifying `throwOnUnhandled` as false does nothing', function (assert) { + assert.expect(1); - self.deprecationWorkflow.config = { - throwOnUnhandled: false, - }; + const config = { + throwOnUnhandled: false, + }; - deprecate('Sshhhhh!!', false, { - id: 'quiet', - since: 'the beginning', - until: 'forever', - for: 'testing', - }); - assert.ok(true, 'does not die when throwOnUnhandled is false'); - }); + handleDeprecationWorkflow( + config, + 'Sshhhhh!!', + { + id: 'quiet', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); - test('deprecation silenced with string matcher', function (assert) { - self.deprecationWorkflow.config = { - workflow: [{ matchMessage: 'Interesting', handler: 'silence' }], - }; - deprecate('Interesting', false, { - id: 'interesting', - since: 'the beginning', - until: 'forever', - for: 'testing', + assert.ok(true, 'does not die when throwOnUnhandled is false'); }); - assert.ok(true, 'Deprecation did not raise'); - }); - - test('deprecation logs with string matcher', function (assert) { - assert.expect(1); - let message = 'Interesting'; - console.warn = function (passedMessage) { - assert.strictEqual( - passedMessage.indexOf('DEPRECATION: ' + message), - 0, - 'deprecation logs', - ); - }; - self.deprecationWorkflow.config = { - workflow: [{ matchMessage: message, handler: 'log' }], - }; - deprecate(message, false, { - since: 'the beginning', - until: 'forever', - id: 'interesting', - for: 'testing', - }); - }); + test('deprecation silenced with string matcher', function (assert) { + const config = { + workflow: [{ matchMessage: 'Interesting', handler: 'silence' }], + }; - test('deprecation thrown with string matcher', function (assert) { - self.deprecationWorkflow.config = { - workflow: [{ matchMessage: 'Interesting', handler: 'throw' }], - }; - assert.throws(function () { - deprecate('Interesting', false, { + handleDeprecationWorkflow(config, 'Interesting', { id: 'interesting', since: 'the beginning', until: 'forever', for: 'testing', }); - }, 'deprecation throws'); - }); + assert.ok(true, 'Deprecation did not raise'); + }); - test('deprecation silenced with regex matcher', function (assert) { - self.deprecationWorkflow.config = { - workflow: [{ matchMessage: /Inter/, handler: 'silence' }], - }; - deprecate('Interesting', false, { - id: 'interesting', - since: 'the beginning', - until: 'forever', - for: 'testing', + test('deprecation logs with string matcher', function (assert) { + assert.expect(1); + + let message = 'Interesting'; + console.warn = function (passedMessage) { + assert.strictEqual( + passedMessage.indexOf('DEPRECATION: ' + message), + 0, + 'deprecation logs' + ); + }; + + const config = { + workflow: [{ matchMessage: message, handler: 'log' }], + }; + + handleDeprecationWorkflow( + config, + message, + { + since: 'the beginning', + until: 'forever', + id: 'interesting', + for: 'testing', + }, + () => {} + ); }); - assert.ok(true, 'Deprecation did not raise'); - }); - test('deprecation logs with regex matcher', function (assert) { - assert.expect(1); + test('deprecation thrown with string matcher', function (assert) { + const config = { + workflow: [{ matchMessage: 'Interesting', handler: 'throw' }], + }; + + assert.throws(function () { + handleDeprecationWorkflow( + config, + 'Interesting', + { + id: 'interesting', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + }, 'deprecation throws'); + }); - let message = 'Interesting'; - console.warn = function (passedMessage) { - assert.strictEqual( - passedMessage, - 'DEPRECATION: ' + message, - 'deprecation logs', + test('deprecation silenced with regex matcher', function (assert) { + const config = { + workflow: [{ matchMessage: /Inter/, handler: 'silence' }], + }; + + handleDeprecationWorkflow( + config, + 'Interesting', + { + id: 'interesting', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} ); - }; - self.deprecationWorkflow.config = { - workflow: [{ matchMessage: /Inter/, handler: 'log' }], - }; - deprecate(message, false, { - id: 'interesting', - since: 'the beginning', - until: 'forever', - for: 'testing', + + assert.ok(true, 'Deprecation did not raise'); }); - }); - test('deprecation thrown with regex matcher', function (assert) { - self.deprecationWorkflow.config = { - workflow: [{ matchMessage: /Inter/, handler: 'throw' }], - }; - assert.throws(function () { - deprecate('Interesting', false, { - id: 'interesting', - since: 'the beginning', - until: 'forever', - for: 'testing', - }); - }, 'deprecation throws'); - }); + test('deprecation logs with regex matcher', function (assert) { + assert.expect(1); - test('deprecation thrown with string matcher with parens', function (assert) { - let message = - 'Some string that includes (). If treated like a regexp this will not match.'; + let message = 'Interesting'; - self.deprecationWorkflow.config = { - workflow: [{ matchMessage: message, handler: 'throw' }], - }; + console.warn = function (passedMessage) { + assert.strictEqual( + passedMessage, + 'DEPRECATION: ' + message, + 'deprecation logs' + ); + }; - assert.throws(function () { - deprecate(message, false, { - id: 'throws', - since: 'the beginning', - until: 'forever', - for: 'testing', - }); - }, 'deprecation throws'); - }); + const config = { + workflow: [{ matchMessage: /Inter/, handler: 'log' }], + }; - test('deprecation silenced with id matcher', function (assert) { - self.deprecationWorkflow.config = { - workflow: [{ matchId: 'ember.deprecation-workflow', handler: 'silence' }], - }; - deprecate('Slightly interesting', false, { - id: 'ember.deprecation-workflow', - since: 'the beginning', - until: '3.0.0', - for: 'testing', + handleDeprecationWorkflow( + config, + message, + { + id: 'interesting', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); }); - assert.ok(true, 'Deprecation did not raise'); - }); - test('deprecation logs with id matcher', function (assert) { - assert.expect(1); + test('deprecation thrown with regex matcher', function (assert) { + const config = { + workflow: [{ matchMessage: /Inter/, handler: 'throw' }], + }; + + assert.throws(function () { + handleDeprecationWorkflow( + config, + 'Interesting', + { + id: 'interesting', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + }, 'deprecation throws'); + }); - let message = 'Slightly interesting'; - console.warn = function (passedMessage) { - assert.strictEqual( - passedMessage, - 'DEPRECATION: ' + message, - 'deprecation logs', + test('deprecation thrown with string matcher with parens', function (assert) { + let message = + 'Some string that includes (). If treated like a regexp this will not match.'; + + const config = { + workflow: [{ matchMessage: message, handler: 'throw' }], + }; + + assert.throws(function () { + handleDeprecationWorkflow( + config, + message, + { + id: 'throws', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + }, 'deprecation throws'); + }); + + test('deprecation silenced with id matcher', function (assert) { + const config = { + workflow: [ + { matchId: 'ember.deprecation-workflow', handler: 'silence' }, + ], + }; + + handleDeprecationWorkflow( + config, + 'Slightly interesting', + { + id: 'ember.deprecation-workflow', + since: 'the beginning', + until: '3.0.0', + for: 'testing', + }, + () => {} ); - }; - self.deprecationWorkflow.config = { - workflow: [{ matchId: 'ember.deprecation-workflow', handler: 'log' }], - }; - deprecate('Slightly interesting', false, { - id: 'ember.deprecation-workflow', - since: 'the beginning', - until: '3.0.0', - for: 'testing', + + assert.ok(true, 'Deprecation did not raise'); }); - }); - test('deprecation thrown with id matcher', function (assert) { - self.deprecationWorkflow.config = { - workflow: [{ matchId: 'ember.deprecation-workflow', handler: 'throw' }], - }; - assert.throws(function () { - deprecate('Slightly interesting', false, { - id: 'ember.deprecation-workflow', - since: 'the beginning', - until: '3.0.0', - for: 'testing', - }); - }, 'deprecation throws'); + test('deprecation logs with id matcher', function (assert) { + assert.expect(1); + + let message = 'Slightly interesting'; + + console.warn = function (passedMessage) { + assert.strictEqual( + passedMessage, + 'DEPRECATION: ' + message, + 'deprecation logs' + ); + }; + + const config = { + workflow: [{ matchId: 'ember.deprecation-workflow', handler: 'log' }], + }; + + handleDeprecationWorkflow( + config, + 'Slightly interesting', + { + id: 'ember.deprecation-workflow', + since: 'the beginning', + until: '3.0.0', + for: 'testing', + }, + () => {} + ); + }); + + test('deprecation thrown with id matcher', function (assert) { + const config = { + workflow: [{ matchId: 'ember.deprecation-workflow', handler: 'throw' }], + }; + assert.throws(function () { + handleDeprecationWorkflow( + config, + 'Slightly interesting', + { + id: 'ember.deprecation-workflow', + since: 'the beginning', + until: '3.0.0', + for: 'testing', + }, + () => {} + ); + }, 'deprecation throws'); + }); }); - test('deprecation logging happens even if `throwOnUnhandled` is true', function (assert) { - assert.expect(2); + module( + 'composing handleDeprecationWorkflow and deprecationCollector', + function () { + test('deprecation logging happens even if `throwOnUnhandled` is true', function (assert) { + assert.expect(2); - self.deprecationWorkflow.config = { - throwOnUnhandled: true, - }; + const config = { + throwOnUnhandled: true, + }; - assert.throws( - function () { - deprecate('Foobarrrzzzz', false, { + const message = 'Foobarrrzzzz'; + + const options = { id: 'foobar', since: 'the beginning', until: 'forever', for: 'testing', - }); - }, - /Foobarrrzzzz/, - 'setting raiseOnUnhandled throws for unknown workflows', - ); - - let result = self.deprecationWorkflow.flushDeprecations(); - - assert.ok( - /foobar/.exec(result), - 'unhandled deprecation was added to the deprecationLog', - ); - }); + }; + + assert.throws( + function () { + deprecationCollector(message, options, () => + handleDeprecationWorkflow(config, message, options, () => {}) + ); + }, + /Foobarrrzzzz/, + 'setting raiseOnUnhandled throws for unknown workflows' + ); + + let result = flushDeprecations(); + + assert.ok( + /foobar/.exec(result), + 'unhandled deprecation was added to the deprecationLog' + ); + }); + } + ); }); diff --git a/vendor/ember-cli-deprecation-workflow/deprecation-workflow.js b/vendor/ember-cli-deprecation-workflow/deprecation-workflow.js deleted file mode 100644 index 06ce268..0000000 --- a/vendor/ember-cli-deprecation-workflow/deprecation-workflow.js +++ /dev/null @@ -1 +0,0 @@ -// default config/deprecation-workflow.js From cc1012b9ea290bcdc1d9cad51483eda1df1e74d6 Mon Sep 17 00:00:00 2001 From: "Andrey Mikhaylov (lolmaus)" Date: Thu, 26 Oct 2023 15:03:13 +0300 Subject: [PATCH 2/8] Split tests per function --- tests/acceptance/flush-deprecations-test.js | 67 +++ tests/index.html | 7 + tests/unit/deprecation-collector-test.js | 523 +++--------------- tests/unit/flush-deprecations-test.js | 49 ++ .../unit/handle-deprecation-workflow-test.js | 316 +++++++++++ 5 files changed, 525 insertions(+), 437 deletions(-) create mode 100644 tests/acceptance/flush-deprecations-test.js create mode 100644 tests/unit/flush-deprecations-test.js create mode 100644 tests/unit/handle-deprecation-workflow-test.js diff --git a/tests/acceptance/flush-deprecations-test.js b/tests/acceptance/flush-deprecations-test.js new file mode 100644 index 0000000..639fc9f --- /dev/null +++ b/tests/acceptance/flush-deprecations-test.js @@ -0,0 +1,67 @@ +import { deprecate } from '@ember/debug'; +import { module } from 'qunit'; +import test from '../helpers/debug-test'; + +let originalWarn; + +module('flushDeprecations', function (hooks) { + hooks.beforeEach(function () { + originalWarn = window.Testem.handleConsoleMessage; + }); + + hooks.afterEach(function () { + window.deprecationWorkflow.deprecationLog = { messages: {} }; + window.Testem.handleConsoleMessage = originalWarn; + }); + + test('works', function (assert) { + deprecate('silence-strict', false, { + since: '2.0.0', + until: 'forever', + id: 'test', + for: 'testing', + }); + + deprecate('log-strict', false, { + since: '2.0.0', + until: 'forever', + id: 'test', + for: 'testing', + }); + + deprecate(' foo log-match foo', false, { + since: 'now', + until: 'forever', + id: 'test', + for: 'testing', + }); + + deprecate(' foo foo', false, { + since: 'now', + until: 'forever', + id: 'log-strict', + for: 'testing', + }); + + deprecate('arbitrary-unmatched-message', false, { + id: 'log-strict', + since: '2.0.0', + until: '3.0.0', + for: 'testing', + }); + + const deprecationsPayload = self.deprecationWorkflow.flushDeprecations(); + + assert.strictEqual( + deprecationsPayload, + `import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; + +setupDeprecationWorkflow({ + workflow: [ + { handler: "silence", matchId: "test" }, + { handler: "silence", matchId: "log-strict" } + ] +});` + ); + }); +}); diff --git a/tests/index.html b/tests/index.html index 8b41ac9..b74fc8b 100644 --- a/tests/index.html +++ b/tests/index.html @@ -20,6 +20,13 @@ {{content-for "body"}} {{content-for "test-body"}} +
+
+
+
+
+
+ diff --git a/tests/unit/deprecation-collector-test.js b/tests/unit/deprecation-collector-test.js index e40c681..f050ed8 100644 --- a/tests/unit/deprecation-collector-test.js +++ b/tests/unit/deprecation-collector-test.js @@ -3,15 +3,11 @@ import { module } from 'qunit'; import test from '../helpers/debug-test'; -import { - flushDeprecations, - deprecationCollector, - handleDeprecationWorkflow, -} from 'ember-cli-deprecation-workflow'; +import { deprecationCollector } from 'ember-cli-deprecation-workflow'; let originalWarn, originalConfig; -module('Unit tests', function (hooks) { +module('deprecationCollector', function (hooks) { hooks.beforeEach(function () { originalWarn = console.warn; @@ -21,7 +17,7 @@ module('Unit tests', function (hooks) { originalConfig = self.deprecationWorkflow = { config: null, deprecationLog: { - messages: [], + messages: {}, }, }; }); @@ -32,447 +28,100 @@ module('Unit tests', function (hooks) { console.warn = originalWarn; }); - module('deprecationCollector', function () { - test('calling flushDeprecations returns string of deprecations', function (assert) { - deprecationCollector( - 'First deprecation', - { - id: 'first', - since: 'the beginning', - until: 'forever', - for: 'testing', - }, - () => {} - ); - deprecationCollector( - 'Second deprecation', - { - id: 'second', - since: 'the beginning', - until: 'forever', - for: 'testing', - }, - () => {} - ); - let deprecationsPayload = flushDeprecations(); - assert.strictEqual( - deprecationsPayload, - `import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; - -setupDeprecationWorkflow({ - workflow: [ - { handler: "silence", matchId: "first" }, - { handler: "silence", matchId: "second" } - ] -});` - ); - }); - - test('should call next', function (assert) { - assert.expect(1); - - function next() { - assert.ok(true, 'next has been called'); - } - - deprecationCollector( - 'First deprecation', - { - id: 'first', - since: 'the beginning', - until: 'forever', - for: 'testing', - }, - next - ); - }); - - test('deprecations are not duplicated', function (assert) { - deprecationCollector( - 'First deprecation', - { - id: 'first', - since: 'the beginning', - until: 'forever', - for: 'testing', - }, - () => {} - ); - deprecationCollector( - 'Second deprecation', - { - id: 'second', - since: 'the beginning', - until: 'forever', - for: 'testing', - }, - () => {} - ); - - // do it again - deprecationCollector( - 'First deprecation', - { - id: 'first', - since: 'the beginning', - until: 'forever', - for: 'testing', - }, - () => {} - ); - deprecationCollector( - 'Second deprecation', - { - id: 'second', - since: 'the beginning', - until: 'forever', - for: 'testing', - }, - () => {} - ); - - let deprecationsPayload = flushDeprecations(); - assert.strictEqual( - deprecationsPayload, - `import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; + test('it collects deprecations', function (assert) { + deprecationCollector( + 'First deprecation', + { + id: 'first', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + deprecationCollector( + 'Second deprecation', + { + id: 'second', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); -setupDeprecationWorkflow({ - workflow: [ - { handler: "silence", matchId: "first" }, - { handler: "silence", matchId: "second" } - ] -});` - ); + assert.deepEqual(self.deprecationWorkflow.deprecationLog.messages, { + first: ' { handler: "silence", matchId: "first" }', + second: ' { handler: "silence", matchId: "second" }', }); }); - module('handleDeprecationWorkflow', function () { - test('specifying `throwOnUnhandled` as true raises', function (assert) { - assert.expect(2); - - const config = { - throwOnUnhandled: true, - workflow: [{ handler: 'silence', matchMessage: 'Sshhhhh!!' }], - }; - - assert.throws( - function () { - handleDeprecationWorkflow( - config, - 'Foobarrrzzzz', - { - since: 'the beginning', - until: 'forever', - id: 'foobar', - for: 'testing', - }, - () => {} - ); - }, - /Foobarrrzzzz/, - 'setting raiseOnUnhandled throws for unknown workflows' - ); - - handleDeprecationWorkflow( - config, - 'Sshhhhh!!', - { - id: 'quiet', - since: 'the beginning', - until: 'forever', - for: 'testing', - }, - () => {} - ); - assert.ok(true, 'did not throw when silenced'); - }); - - test('specifying `throwOnUnhandled` as false does nothing', function (assert) { - assert.expect(1); + test('should call next', function (assert) { + assert.expect(1); - const config = { - throwOnUnhandled: false, - }; - - handleDeprecationWorkflow( - config, - 'Sshhhhh!!', - { - id: 'quiet', - since: 'the beginning', - until: 'forever', - for: 'testing', - }, - () => {} - ); - - assert.ok(true, 'does not die when throwOnUnhandled is false'); - }); - - test('deprecation silenced with string matcher', function (assert) { - const config = { - workflow: [{ matchMessage: 'Interesting', handler: 'silence' }], - }; + function next() { + assert.ok(true, 'next has been called'); + } - handleDeprecationWorkflow(config, 'Interesting', { - id: 'interesting', + deprecationCollector( + 'First deprecation', + { + id: 'first', since: 'the beginning', until: 'forever', for: 'testing', - }); - assert.ok(true, 'Deprecation did not raise'); - }); - - test('deprecation logs with string matcher', function (assert) { - assert.expect(1); - - let message = 'Interesting'; - console.warn = function (passedMessage) { - assert.strictEqual( - passedMessage.indexOf('DEPRECATION: ' + message), - 0, - 'deprecation logs' - ); - }; - - const config = { - workflow: [{ matchMessage: message, handler: 'log' }], - }; - - handleDeprecationWorkflow( - config, - message, - { - since: 'the beginning', - until: 'forever', - id: 'interesting', - for: 'testing', - }, - () => {} - ); - }); - - test('deprecation thrown with string matcher', function (assert) { - const config = { - workflow: [{ matchMessage: 'Interesting', handler: 'throw' }], - }; - - assert.throws(function () { - handleDeprecationWorkflow( - config, - 'Interesting', - { - id: 'interesting', - since: 'the beginning', - until: 'forever', - for: 'testing', - }, - () => {} - ); - }, 'deprecation throws'); - }); - - test('deprecation silenced with regex matcher', function (assert) { - const config = { - workflow: [{ matchMessage: /Inter/, handler: 'silence' }], - }; - - handleDeprecationWorkflow( - config, - 'Interesting', - { - id: 'interesting', - since: 'the beginning', - until: 'forever', - for: 'testing', - }, - () => {} - ); - - assert.ok(true, 'Deprecation did not raise'); - }); - - test('deprecation logs with regex matcher', function (assert) { - assert.expect(1); - - let message = 'Interesting'; - - console.warn = function (passedMessage) { - assert.strictEqual( - passedMessage, - 'DEPRECATION: ' + message, - 'deprecation logs' - ); - }; - - const config = { - workflow: [{ matchMessage: /Inter/, handler: 'log' }], - }; - - handleDeprecationWorkflow( - config, - message, - { - id: 'interesting', - since: 'the beginning', - until: 'forever', - for: 'testing', - }, - () => {} - ); - }); - - test('deprecation thrown with regex matcher', function (assert) { - const config = { - workflow: [{ matchMessage: /Inter/, handler: 'throw' }], - }; - - assert.throws(function () { - handleDeprecationWorkflow( - config, - 'Interesting', - { - id: 'interesting', - since: 'the beginning', - until: 'forever', - for: 'testing', - }, - () => {} - ); - }, 'deprecation throws'); - }); - - test('deprecation thrown with string matcher with parens', function (assert) { - let message = - 'Some string that includes (). If treated like a regexp this will not match.'; - - const config = { - workflow: [{ matchMessage: message, handler: 'throw' }], - }; - - assert.throws(function () { - handleDeprecationWorkflow( - config, - message, - { - id: 'throws', - since: 'the beginning', - until: 'forever', - for: 'testing', - }, - () => {} - ); - }, 'deprecation throws'); - }); - - test('deprecation silenced with id matcher', function (assert) { - const config = { - workflow: [ - { matchId: 'ember.deprecation-workflow', handler: 'silence' }, - ], - }; - - handleDeprecationWorkflow( - config, - 'Slightly interesting', - { - id: 'ember.deprecation-workflow', - since: 'the beginning', - until: '3.0.0', - for: 'testing', - }, - () => {} - ); - - assert.ok(true, 'Deprecation did not raise'); - }); - - test('deprecation logs with id matcher', function (assert) { - assert.expect(1); - - let message = 'Slightly interesting'; - - console.warn = function (passedMessage) { - assert.strictEqual( - passedMessage, - 'DEPRECATION: ' + message, - 'deprecation logs' - ); - }; - - const config = { - workflow: [{ matchId: 'ember.deprecation-workflow', handler: 'log' }], - }; + }, + next + ); + }); - handleDeprecationWorkflow( - config, - 'Slightly interesting', - { - id: 'ember.deprecation-workflow', - since: 'the beginning', - until: '3.0.0', - for: 'testing', - }, - () => {} - ); - }); + test('deprecations are not duplicated', function (assert) { + deprecationCollector( + 'First deprecation', + { + id: 'first', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + deprecationCollector( + 'Second deprecation', + { + id: 'second', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + + // do it again + deprecationCollector( + 'First deprecation', + { + id: 'first', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + deprecationCollector( + 'Second deprecation', + { + id: 'second', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); - test('deprecation thrown with id matcher', function (assert) { - const config = { - workflow: [{ matchId: 'ember.deprecation-workflow', handler: 'throw' }], - }; - assert.throws(function () { - handleDeprecationWorkflow( - config, - 'Slightly interesting', - { - id: 'ember.deprecation-workflow', - since: 'the beginning', - until: '3.0.0', - for: 'testing', - }, - () => {} - ); - }, 'deprecation throws'); + assert.deepEqual(self.deprecationWorkflow.deprecationLog.messages, { + first: ' { handler: "silence", matchId: "first" }', + second: ' { handler: "silence", matchId: "second" }', }); }); - - module( - 'composing handleDeprecationWorkflow and deprecationCollector', - function () { - test('deprecation logging happens even if `throwOnUnhandled` is true', function (assert) { - assert.expect(2); - - const config = { - throwOnUnhandled: true, - }; - - const message = 'Foobarrrzzzz'; - - const options = { - id: 'foobar', - since: 'the beginning', - until: 'forever', - for: 'testing', - }; - - assert.throws( - function () { - deprecationCollector(message, options, () => - handleDeprecationWorkflow(config, message, options, () => {}) - ); - }, - /Foobarrrzzzz/, - 'setting raiseOnUnhandled throws for unknown workflows' - ); - - let result = flushDeprecations(); - - assert.ok( - /foobar/.exec(result), - 'unhandled deprecation was added to the deprecationLog' - ); - }); - } - ); }); diff --git a/tests/unit/flush-deprecations-test.js b/tests/unit/flush-deprecations-test.js new file mode 100644 index 0000000..ff3d394 --- /dev/null +++ b/tests/unit/flush-deprecations-test.js @@ -0,0 +1,49 @@ +/* eslint no-console: 0 */ + +import { module } from 'qunit'; +import test from '../helpers/debug-test'; +import { flushDeprecations } from 'ember-cli-deprecation-workflow'; + +let originalWarn, originalConfig; + +module('flushDeprecations', function (hooks) { + hooks.beforeEach(function () { + originalWarn = console.warn; + + /* + * Clear config for these tests + */ + originalConfig = self.deprecationWorkflow = { + config: null, + deprecationLog: { + messages: [], + }, + }; + }); + + hooks.afterEach(function () { + self.deprecationWorkflow.config = originalConfig; + self.deprecationWorkflow.deprecationLog = { messages: {} }; + console.warn = originalWarn; + }); + + test('calling flushDeprecations returns string of deprecations', function (assert) { + self.deprecationWorkflow.deprecationLog.messages = { + first: ' { handler: "silence", matchId: "first" }', + second: ' { handler: "silence", matchId: "second" }', + }; + + let deprecationsPayload = flushDeprecations(); + assert.strictEqual( + deprecationsPayload, + `import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; + +setupDeprecationWorkflow({ + workflow: [ + { handler: "silence", matchId: "first" }, + { handler: "silence", matchId: "second" } + ] +});` + ); + }); +}); diff --git a/tests/unit/handle-deprecation-workflow-test.js b/tests/unit/handle-deprecation-workflow-test.js new file mode 100644 index 0000000..d27beca --- /dev/null +++ b/tests/unit/handle-deprecation-workflow-test.js @@ -0,0 +1,316 @@ +/* eslint no-console: 0 */ + +import { module } from 'qunit'; +import test from '../helpers/debug-test'; +import { handleDeprecationWorkflow } from 'ember-cli-deprecation-workflow'; + +let originalWarn, originalConfig; + +module('handleDeprecationWorkflow', function (hooks) { + hooks.beforeEach(function () { + originalWarn = console.warn; + + /* + * Clear config for these tests + */ + originalConfig = self.deprecationWorkflow = { + config: null, + deprecationLog: { + messages: {}, + }, + }; + }); + + hooks.afterEach(function () { + self.deprecationWorkflow.config = originalConfig; + self.deprecationWorkflow.deprecationLog = { messages: {} }; + console.warn = originalWarn; + }); + + test('specifying `throwOnUnhandled` as true raises', function (assert) { + assert.expect(2); + + const config = { + throwOnUnhandled: true, + workflow: [{ handler: 'silence', matchMessage: 'Sshhhhh!!' }], + }; + + assert.throws( + function () { + handleDeprecationWorkflow( + config, + 'Foobarrrzzzz', + { + since: 'the beginning', + until: 'forever', + id: 'foobar', + for: 'testing', + }, + () => {} + ); + }, + /Foobarrrzzzz/, + 'setting raiseOnUnhandled throws for unknown workflows' + ); + + handleDeprecationWorkflow( + config, + 'Sshhhhh!!', + { + id: 'quiet', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + assert.ok(true, 'did not throw when silenced'); + }); + + test('specifying `throwOnUnhandled` as false does nothing', function (assert) { + assert.expect(1); + + const config = { + throwOnUnhandled: false, + }; + + handleDeprecationWorkflow( + config, + 'Sshhhhh!!', + { + id: 'quiet', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + + assert.ok(true, 'does not die when throwOnUnhandled is false'); + }); + + test('deprecation silenced with string matcher', function (assert) { + const config = { + workflow: [{ matchMessage: 'Interesting', handler: 'silence' }], + }; + + handleDeprecationWorkflow(config, 'Interesting', { + id: 'interesting', + since: 'the beginning', + until: 'forever', + for: 'testing', + }); + assert.ok(true, 'Deprecation did not raise'); + }); + + test('deprecation logs with string matcher', function (assert) { + assert.expect(1); + + let message = 'Interesting'; + console.warn = function (passedMessage) { + assert.strictEqual( + passedMessage.indexOf('DEPRECATION: ' + message), + 0, + 'deprecation logs' + ); + }; + + const config = { + workflow: [{ matchMessage: message, handler: 'log' }], + }; + + handleDeprecationWorkflow( + config, + message, + { + since: 'the beginning', + until: 'forever', + id: 'interesting', + for: 'testing', + }, + () => {} + ); + }); + + test('deprecation thrown with string matcher', function (assert) { + const config = { + workflow: [{ matchMessage: 'Interesting', handler: 'throw' }], + }; + + assert.throws(function () { + handleDeprecationWorkflow( + config, + 'Interesting', + { + id: 'interesting', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + }, 'deprecation throws'); + }); + + test('deprecation silenced with regex matcher', function (assert) { + const config = { + workflow: [{ matchMessage: /Inter/, handler: 'silence' }], + }; + + handleDeprecationWorkflow( + config, + 'Interesting', + { + id: 'interesting', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + + assert.ok(true, 'Deprecation did not raise'); + }); + + test('deprecation logs with regex matcher', function (assert) { + assert.expect(1); + + let message = 'Interesting'; + + console.warn = function (passedMessage) { + assert.equal( + passedMessage, + 'DEPRECATION: ' + message, + 'deprecation logs' + ); + }; + + const config = { + workflow: [{ matchMessage: /Inter/, handler: 'log' }], + }; + + handleDeprecationWorkflow( + config, + message, + { + id: 'interesting', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + }); + + test('deprecation thrown with regex matcher', function (assert) { + const config = { + workflow: [{ matchMessage: /Inter/, handler: 'throw' }], + }; + + assert.throws(function () { + handleDeprecationWorkflow( + config, + 'Interesting', + { + id: 'interesting', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + }, 'deprecation throws'); + }); + + test('deprecation thrown with string matcher with parens', function (assert) { + let message = + 'Some string that includes (). If treated like a regexp this will not match.'; + + const config = { + workflow: [{ matchMessage: message, handler: 'throw' }], + }; + + assert.throws(function () { + handleDeprecationWorkflow( + config, + message, + { + id: 'throws', + since: 'the beginning', + until: 'forever', + for: 'testing', + }, + () => {} + ); + }, 'deprecation throws'); + }); + + test('deprecation silenced with id matcher', function (assert) { + const config = { + workflow: [{ matchId: 'ember.deprecation-workflow', handler: 'silence' }], + }; + + handleDeprecationWorkflow( + config, + 'Slightly interesting', + { + id: 'ember.deprecation-workflow', + since: 'the beginning', + until: '3.0.0', + for: 'testing', + }, + () => {} + ); + + assert.ok(true, 'Deprecation did not raise'); + }); + + test('deprecation logs with id matcher', function (assert) { + assert.expect(1); + + let message = 'Slightly interesting'; + + console.warn = function (passedMessage) { + assert.equal( + passedMessage, + 'DEPRECATION: ' + message, + 'deprecation logs' + ); + }; + + const config = { + workflow: [{ matchId: 'ember.deprecation-workflow', handler: 'log' }], + }; + + handleDeprecationWorkflow( + config, + 'Slightly interesting', + { + id: 'ember.deprecation-workflow', + since: 'the beginning', + until: '3.0.0', + for: 'testing', + }, + () => {} + ); + }); + + test('deprecation thrown with id matcher', function (assert) { + const config = { + workflow: [{ matchId: 'ember.deprecation-workflow', handler: 'throw' }], + }; + assert.throws(function () { + handleDeprecationWorkflow( + config, + 'Slightly interesting', + { + id: 'ember.deprecation-workflow', + since: 'the beginning', + until: '3.0.0', + for: 'testing', + }, + () => {} + ); + }, 'deprecation throws'); + }); +}); From b1255887a990c37eb34d95206c8623b11dc5c289 Mon Sep 17 00:00:00 2001 From: Matthew Beale Date: Wed, 1 Nov 2023 16:47:13 -0400 Subject: [PATCH 3/8] Update the scenarios run by the CI suite --- .github/workflows/ci.yml | 8 ++-- tests/dummy/config/ember-try.js | 67 --------------------------------- 2 files changed, 3 insertions(+), 72 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2fa05d2..150f781 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,11 +62,6 @@ jobs: matrix: try-scenario: [ - ember-lts-2.12, - ember-lts-2.18, - ember-lts-3.16, - ember-lts-3.20, - ember-lts-3.24, ember-lts-3.28, ember-lts-4.4, ember-lts-4.8, @@ -77,6 +72,9 @@ jobs: ember-3.28-with-jquery, ember-3.28-classic, ] + include: + - ember-try-scenario: ember-canary + allow-failure: true steps: - name: Checkout diff --git a/tests/dummy/config/ember-try.js b/tests/dummy/config/ember-try.js index 9bf7607..9c64151 100644 --- a/tests/dummy/config/ember-try.js +++ b/tests/dummy/config/ember-try.js @@ -7,73 +7,6 @@ module.exports = async function () { let emberReleaseVersion = await getChannelURL('release'); return { scenarios: [ - { - name: 'ember-lts-2.12', - npm: { - devDependencies: { - '@ember/test-helpers': '^1.7.3', - 'ember-qunit': '^4.6.0', - 'ember-source': '~2.12.0', - qunit: null, - 'ember-cli': '^4.12.0', - 'ember-resolver': '8.1.0', - 'ember-page-title': '^7.0.0', - }, - }, - }, - { - name: 'ember-lts-2.18', - npm: { - devDependencies: { - '@ember/test-helpers': '^1.7.3', - 'ember-qunit': '^4.6.0', - 'ember-source': '~2.18.0', - qunit: null, - 'ember-cli': '^4.12.0', - 'ember-resolver': '8.1.0', - 'ember-page-title': '^7.0.0', - }, - }, - }, - { - name: 'ember-lts-3.16', - npm: { - devDependencies: { - 'ember-source': '~3.16.0', - 'ember-resolver': '8.1.0', - '@ember/test-helpers': '2.2.9', - 'ember-qunit': '~5.0.0', - 'ember-cli': '^4.12.0', - 'ember-page-title': '^7.0.0', - }, - }, - }, - { - name: 'ember-lts-3.20', - npm: { - devDependencies: { - 'ember-source': '~3.20.5', - 'ember-resolver': '8.1.0', - '@ember/test-helpers': '2.2.9', - 'ember-qunit': '~5.0.0', - 'ember-cli': '^4.12.0', - 'ember-page-title': '^7.0.0', - }, - }, - }, - { - name: 'ember-lts-3.24', - npm: { - devDependencies: { - 'ember-source': '~3.24.3', - 'ember-resolver': '8.1.0', - '@ember/test-helpers': '2.2.9', - 'ember-qunit': '~5.0.0', - 'ember-cli': '^4.12.0', - 'ember-page-title': '^7.0.0', - }, - }, - }, { name: 'ember-lts-3.28', npm: { From 7dd704af405c17624916c0580e5e0c36f0ff98d8 Mon Sep 17 00:00:00 2001 From: "Andrey Mikhaylov (lolmaus)" Date: Thu, 23 Nov 2023 12:46:59 +0300 Subject: [PATCH 4/8] Fix build by moving ember-cli-babel to dependencies --- package-lock.json | 38 +++----------------------------------- package.json | 4 ++-- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/package-lock.json b/package-lock.json index ea939df..68544c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,8 @@ "@ember/string": "^3.0.0", "broccoli-funnel": "^3.0.3", "broccoli-merge-trees": "^4.2.0", - "broccoli-plugin": "^4.0.5" + "broccoli-plugin": "^4.0.5", + "ember-cli-babel": "^8.2.0" }, "devDependencies": { "@babel/eslint-parser": "^7.22.15", @@ -27,7 +28,6 @@ "concurrently": "^8.2.2", "ember-auto-import": "^2.6.3", "ember-cli": "~5.4.1", - "ember-cli-babel": "^8.2.0", "ember-cli-clean-css": "^3.0.0", "ember-cli-dependency-checker": "^3.3.2", "ember-cli-htmlbars": "^6.3.0", @@ -6314,7 +6314,6 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/babel-plugin-module-resolver/-/babel-plugin-module-resolver-5.0.0.tgz", "integrity": "sha512-g0u+/ChLSJ5+PzYwLwP8Rp8Rcfowz58TJNCe+L/ui4rpzE/mg//JVX0EWBUYoxaextqnwuGHzfGp2hh0PPV25Q==", - "dev": true, "dependencies": { "find-babel-config": "^2.0.0", "glob": "^8.0.3", @@ -6330,7 +6329,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, "dependencies": { "balanced-match": "^1.0.0" } @@ -6339,7 +6337,6 @@ "version": "8.1.0", "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", - "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -6358,7 +6355,6 @@ "version": "5.1.6", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "dev": true, "dependencies": { "brace-expansion": "^2.0.1" }, @@ -6890,7 +6886,6 @@ "version": "8.0.0", "resolved": "https://registry.npmjs.org/broccoli-babel-transpiler/-/broccoli-babel-transpiler-8.0.0.tgz", "integrity": "sha512-3HEp3flvasUKJGWERcrPgM1SWvHJ0O/fmbEtY9L4kDyMSnqjY6hTYvNvgWCIgbwXAYAUlZP0vjAQsmyLNGLwFw==", - "dev": true, "dependencies": { "broccoli-persistent-filter": "^3.0.0", "clone": "^2.1.2", @@ -6912,7 +6907,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/async-disk-cache/-/async-disk-cache-2.1.0.tgz", "integrity": "sha512-iH+boep2xivfD9wMaZWkywYIURSmsL96d6MoqrC94BnGSvXE4Quf8hnJiHGFYhw/nLeIa1XyRaf4vvcvkwAefg==", - "dev": true, "dependencies": { "debug": "^4.1.1", "heimdalljs": "^0.2.3", @@ -6930,7 +6924,6 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/broccoli-persistent-filter/-/broccoli-persistent-filter-3.1.3.tgz", "integrity": "sha512-Q+8iezprZzL9voaBsDY3rQVl7c7H5h+bvv8SpzCZXPZgfBFCbx7KFQ2c3rZR6lW5k4Kwoqt7jG+rZMUg67Gwxw==", - "dev": true, "dependencies": { "async-disk-cache": "^2.0.0", "async-promise-queue": "^1.0.3", @@ -6952,7 +6945,6 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/editions/-/editions-2.3.1.tgz", "integrity": "sha512-ptGvkwTvGdGfC0hfhKg0MT+TRLRKGtUiWGBInxOm5pz7ssADezahjCUaYuZ8Dr+C05FW0AECIIPt4WBxVINEhA==", - "dev": true, "dependencies": { "errlop": "^2.0.0", "semver": "^6.3.0" @@ -6968,7 +6960,6 @@ "version": "2.6.0", "resolved": "https://registry.npmjs.org/istextorbinary/-/istextorbinary-2.6.0.tgz", "integrity": "sha512-+XRlFseT8B3L9KyjxxLjfXSLMuErKDsd8DBNrsaxoViABMEZlOSCstwmw0qpoFX3+U6yWU1yhLudAe6/lETGGA==", - "dev": true, "dependencies": { "binaryextensions": "^2.1.2", "editions": "^2.2.0", @@ -6985,7 +6976,6 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, "dependencies": { "glob": "^7.1.3" }, @@ -7000,7 +6990,6 @@ "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, "bin": { "semver": "bin/semver.js" } @@ -7009,7 +6998,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/sync-disk-cache/-/sync-disk-cache-2.1.0.tgz", "integrity": "sha512-vngT2JmkSapgq0z7uIoYtB9kWOOzMihAAYq/D3Pjm/ODOGMgS4r++B+OZ09U4hWR6EaOdy9eqQ7/8ygbH3wehA==", - "dev": true, "dependencies": { "debug": "^4.1.1", "heimdalljs": "^0.2.6", @@ -7646,7 +7634,6 @@ }, "node_modules/broccoli-source": { "version": "3.0.1", - "dev": true, "license": "MIT", "dependencies": { "broccoli-node-api": "^1.6.0" @@ -10154,7 +10141,6 @@ "version": "8.2.0", "resolved": "https://registry.npmjs.org/ember-cli-babel/-/ember-cli-babel-8.2.0.tgz", "integrity": "sha512-8H4+jQElCDo6tA7CamksE66NqBXWs7VNpS3a738L9pZCjg2kXIX4zoyHzkORUqCtr0Au7YsCnrlAMi1v2ALo7A==", - "dev": true, "dependencies": { "@babel/helper-compilation-targets": "^7.20.7", "@babel/plugin-proposal-class-properties": "^7.16.5", @@ -10200,7 +10186,6 @@ }, "node_modules/ember-cli-babel/node_modules/@babel/runtime": { "version": "7.12.18", - "dev": true, "license": "MIT", "dependencies": { "regenerator-runtime": "^0.13.4" @@ -10210,7 +10195,6 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/resolve-package-path/-/resolve-package-path-4.0.3.tgz", "integrity": "sha512-SRpNAPW4kewOaNUt8VPqhJ0UMxawMwzJD8V7m1cJfdSTK9ieZwS6K7Dabsm4bmLFM96Z5Y/UznrpG5kt1im8yA==", - "dev": true, "dependencies": { "path-root": "^0.1.1" }, @@ -11203,7 +11187,6 @@ }, "node_modules/ember-cli-version-checker": { "version": "5.1.2", - "dev": true, "license": "MIT", "dependencies": { "resolve-package-path": "^3.1.0", @@ -13943,7 +13926,6 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/errlop/-/errlop-2.2.0.tgz", "integrity": "sha512-e64Qj9+4aZzjzzFpZC7p5kmm/ccCrbLhAJplhsDXQFs87XTsXwOpH4s1Io2s90Tau/8r2j9f4l/thhDevRjzxw==", - "dev": true, "engines": { "node": ">=0.8" }, @@ -15241,7 +15223,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/find-babel-config/-/find-babel-config-2.0.0.tgz", "integrity": "sha512-dOKT7jvF3hGzlW60Gc3ONox/0rRZ/tz7WCil0bqA1In/3I8f1BctpXahRnEKDySZqci7u+dqq93sZST9fOJpFw==", - "dev": true, "dependencies": { "json5": "^2.1.1", "path-exists": "^4.0.0" @@ -20363,7 +20344,6 @@ }, "node_modules/p-limit": { "version": "2.3.0", - "dev": true, "license": "MIT", "dependencies": { "p-try": "^2.0.0" @@ -20416,7 +20396,6 @@ }, "node_modules/p-try": { "version": "2.2.0", - "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -20724,7 +20703,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, "engines": { "node": ">=8" } @@ -20846,7 +20824,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-3.1.0.tgz", "integrity": "sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==", - "dev": true, "dependencies": { "find-up": "^3.0.0" }, @@ -20858,7 +20835,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, "dependencies": { "locate-path": "^3.0.0" }, @@ -20870,7 +20846,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, "dependencies": { "p-locate": "^3.0.0", "path-exists": "^3.0.0" @@ -20883,7 +20858,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, "dependencies": { "p-limit": "^2.0.0" }, @@ -20895,7 +20869,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", - "dev": true, "engines": { "node": ">=4" } @@ -22850,8 +22823,7 @@ "node_modules/reselect": { "version": "4.1.8", "resolved": "https://registry.npmjs.org/reselect/-/reselect-4.1.8.tgz", - "integrity": "sha512-ab9EmR80F/zQTMNeneUr4cv+jSwPJgIlvEmVwLerwrWVbpLlBuls9XHzIeTFy4cegU2NHBp3va0LKOzU5qFEYQ==", - "dev": true + "integrity": "sha512-ab9EmR80F/zQTMNeneUr4cv+jSwPJgIlvEmVwLerwrWVbpLlBuls9XHzIeTFy4cegU2NHBp3va0LKOzU5qFEYQ==" }, "node_modules/resolve": { "version": "1.22.8", @@ -23318,7 +23290,6 @@ }, "node_modules/semver": { "version": "7.5.4", - "dev": true, "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" @@ -23347,7 +23318,6 @@ }, "node_modules/semver/node_modules/lru-cache": { "version": "6.0.0", - "dev": true, "license": "ISC", "dependencies": { "yallist": "^4.0.0" @@ -26234,7 +26204,6 @@ }, "node_modules/workerpool": { "version": "6.5.1", - "dev": true, "license": "Apache-2.0" }, "node_modules/wrap-ansi": { @@ -26337,7 +26306,6 @@ }, "node_modules/yallist": { "version": "4.0.0", - "dev": true, "license": "ISC" }, "node_modules/yam": { diff --git a/package.json b/package.json index fc29953..1474cf8 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "@ember/string": "^3.0.0", "broccoli-funnel": "^3.0.3", "broccoli-merge-trees": "^4.2.0", - "broccoli-plugin": "^4.0.5" + "broccoli-plugin": "^4.0.5", + "ember-cli-babel": "^8.2.0" }, "devDependencies": { "@babel/eslint-parser": "^7.22.15", @@ -47,7 +48,6 @@ "concurrently": "^8.2.2", "ember-auto-import": "^2.6.3", "ember-cli": "~5.4.1", - "ember-cli-babel": "^8.2.0", "ember-cli-clean-css": "^3.0.0", "ember-cli-dependency-checker": "^3.3.2", "ember-cli-htmlbars": "^6.3.0", From 9dab377ad0549ef2de106aec5503bfdbe20a1dd6 Mon Sep 17 00:00:00 2001 From: "Andrey Mikhaylov (lolmaus)" Date: Thu, 23 Nov 2023 14:09:54 +0300 Subject: [PATCH 5/8] Fix lint --- addon/index.js | 4 +- tests/acceptance/flush-deprecations-test.js | 2 +- tests/unit/deprecation-collector-test.js | 14 +++--- tests/unit/flush-deprecations-test.js | 2 +- .../unit/handle-deprecation-workflow-test.js | 43 +++++++++---------- 5 files changed, 32 insertions(+), 33 deletions(-) diff --git a/addon/index.js b/addon/index.js index e7bb632..edb8dac 100644 --- a/addon/index.js +++ b/addon/index.js @@ -9,7 +9,7 @@ export default function setupDeprecationWorkflow(config) { }; registerDeprecationHandler((message, options, next) => - handleDeprecationWorkflow(config, message, options, next) + handleDeprecationWorkflow(config, message, options, next), ); registerDeprecationHandler(deprecationCollector); @@ -87,7 +87,7 @@ export function handleDeprecationWorkflow(config, message, options, next) { console.warn('DEPRECATION: ' + message); if (count === LOG_LIMIT) { console.warn( - 'To avoid console overflow, this deprecation will not be logged any more in this run.' + 'To avoid console overflow, this deprecation will not be logged any more in this run.', ); } } diff --git a/tests/acceptance/flush-deprecations-test.js b/tests/acceptance/flush-deprecations-test.js index 639fc9f..f407068 100644 --- a/tests/acceptance/flush-deprecations-test.js +++ b/tests/acceptance/flush-deprecations-test.js @@ -61,7 +61,7 @@ setupDeprecationWorkflow({ { handler: "silence", matchId: "test" }, { handler: "silence", matchId: "log-strict" } ] -});` +});`, ); }); }); diff --git a/tests/unit/deprecation-collector-test.js b/tests/unit/deprecation-collector-test.js index f050ed8..2ddae2e 100644 --- a/tests/unit/deprecation-collector-test.js +++ b/tests/unit/deprecation-collector-test.js @@ -37,7 +37,7 @@ module('deprecationCollector', function (hooks) { until: 'forever', for: 'testing', }, - () => {} + () => {}, ); deprecationCollector( 'Second deprecation', @@ -47,7 +47,7 @@ module('deprecationCollector', function (hooks) { until: 'forever', for: 'testing', }, - () => {} + () => {}, ); assert.deepEqual(self.deprecationWorkflow.deprecationLog.messages, { @@ -71,7 +71,7 @@ module('deprecationCollector', function (hooks) { until: 'forever', for: 'testing', }, - next + next, ); }); @@ -84,7 +84,7 @@ module('deprecationCollector', function (hooks) { until: 'forever', for: 'testing', }, - () => {} + () => {}, ); deprecationCollector( 'Second deprecation', @@ -94,7 +94,7 @@ module('deprecationCollector', function (hooks) { until: 'forever', for: 'testing', }, - () => {} + () => {}, ); // do it again @@ -106,7 +106,7 @@ module('deprecationCollector', function (hooks) { until: 'forever', for: 'testing', }, - () => {} + () => {}, ); deprecationCollector( 'Second deprecation', @@ -116,7 +116,7 @@ module('deprecationCollector', function (hooks) { until: 'forever', for: 'testing', }, - () => {} + () => {}, ); assert.deepEqual(self.deprecationWorkflow.deprecationLog.messages, { diff --git a/tests/unit/flush-deprecations-test.js b/tests/unit/flush-deprecations-test.js index ff3d394..15d74e9 100644 --- a/tests/unit/flush-deprecations-test.js +++ b/tests/unit/flush-deprecations-test.js @@ -43,7 +43,7 @@ setupDeprecationWorkflow({ { handler: "silence", matchId: "first" }, { handler: "silence", matchId: "second" } ] -});` +});`, ); }); }); diff --git a/tests/unit/handle-deprecation-workflow-test.js b/tests/unit/handle-deprecation-workflow-test.js index d27beca..dd1fb6e 100644 --- a/tests/unit/handle-deprecation-workflow-test.js +++ b/tests/unit/handle-deprecation-workflow-test.js @@ -28,8 +28,6 @@ module('handleDeprecationWorkflow', function (hooks) { }); test('specifying `throwOnUnhandled` as true raises', function (assert) { - assert.expect(2); - const config = { throwOnUnhandled: true, workflow: [{ handler: 'silence', matchMessage: 'Sshhhhh!!' }], @@ -46,11 +44,11 @@ module('handleDeprecationWorkflow', function (hooks) { id: 'foobar', for: 'testing', }, - () => {} + () => {}, ); }, /Foobarrrzzzz/, - 'setting raiseOnUnhandled throws for unknown workflows' + 'setting raiseOnUnhandled throws for unknown workflows', ); handleDeprecationWorkflow( @@ -62,14 +60,12 @@ module('handleDeprecationWorkflow', function (hooks) { until: 'forever', for: 'testing', }, - () => {} + () => {}, ); assert.ok(true, 'did not throw when silenced'); }); test('specifying `throwOnUnhandled` as false does nothing', function (assert) { - assert.expect(1); - const config = { throwOnUnhandled: false, }; @@ -83,7 +79,7 @@ module('handleDeprecationWorkflow', function (hooks) { until: 'forever', for: 'testing', }, - () => {} + () => {}, ); assert.ok(true, 'does not die when throwOnUnhandled is false'); @@ -103,6 +99,7 @@ module('handleDeprecationWorkflow', function (hooks) { assert.ok(true, 'Deprecation did not raise'); }); + // eslint-disable-next-line qunit/require-expect test('deprecation logs with string matcher', function (assert) { assert.expect(1); @@ -111,7 +108,7 @@ module('handleDeprecationWorkflow', function (hooks) { assert.strictEqual( passedMessage.indexOf('DEPRECATION: ' + message), 0, - 'deprecation logs' + 'deprecation logs', ); }; @@ -128,7 +125,7 @@ module('handleDeprecationWorkflow', function (hooks) { id: 'interesting', for: 'testing', }, - () => {} + () => {}, ); }); @@ -147,7 +144,7 @@ module('handleDeprecationWorkflow', function (hooks) { until: 'forever', for: 'testing', }, - () => {} + () => {}, ); }, 'deprecation throws'); }); @@ -166,22 +163,23 @@ module('handleDeprecationWorkflow', function (hooks) { until: 'forever', for: 'testing', }, - () => {} + () => {}, ); assert.ok(true, 'Deprecation did not raise'); }); + // eslint-disable-next-line qunit/require-expect test('deprecation logs with regex matcher', function (assert) { assert.expect(1); let message = 'Interesting'; console.warn = function (passedMessage) { - assert.equal( + assert.strictEqual( passedMessage, 'DEPRECATION: ' + message, - 'deprecation logs' + 'deprecation logs', ); }; @@ -198,7 +196,7 @@ module('handleDeprecationWorkflow', function (hooks) { until: 'forever', for: 'testing', }, - () => {} + () => {}, ); }); @@ -217,7 +215,7 @@ module('handleDeprecationWorkflow', function (hooks) { until: 'forever', for: 'testing', }, - () => {} + () => {}, ); }, 'deprecation throws'); }); @@ -240,7 +238,7 @@ module('handleDeprecationWorkflow', function (hooks) { until: 'forever', for: 'testing', }, - () => {} + () => {}, ); }, 'deprecation throws'); }); @@ -259,22 +257,23 @@ module('handleDeprecationWorkflow', function (hooks) { until: '3.0.0', for: 'testing', }, - () => {} + () => {}, ); assert.ok(true, 'Deprecation did not raise'); }); + // eslint-disable-next-line qunit/require-expect test('deprecation logs with id matcher', function (assert) { assert.expect(1); let message = 'Slightly interesting'; console.warn = function (passedMessage) { - assert.equal( + assert.strictEqual( passedMessage, 'DEPRECATION: ' + message, - 'deprecation logs' + 'deprecation logs', ); }; @@ -291,7 +290,7 @@ module('handleDeprecationWorkflow', function (hooks) { until: '3.0.0', for: 'testing', }, - () => {} + () => {}, ); }); @@ -309,7 +308,7 @@ module('handleDeprecationWorkflow', function (hooks) { until: '3.0.0', for: 'testing', }, - () => {} + () => {}, ); }, 'deprecation throws'); }); From a95e0ba67c797e504e1f531f432b7245511acbca Mon Sep 17 00:00:00 2001 From: Matthew Beale Date: Sun, 24 Dec 2023 09:08:57 -0500 Subject: [PATCH 6/8] Add 3.x section to readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 860e97c..0d710d2 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,12 @@ addressing a single deprecation at a time, and prevents backsliding ### Compatibility +3.x + +- Ember.js 3.28 until at least 5.4 +- Ember CLI 4.12 or above +- Node.js 16 or above + 2.x - Ember.js 2.12 until at least 4.12 From 2b37d81cb304160d071522cb1a67beab9e2eb176 Mon Sep 17 00:00:00 2001 From: Matthew Beale Date: Sun, 24 Dec 2023 09:11:12 -0500 Subject: [PATCH 7/8] Add an explicit 5.4 LTS entry to CI --- .github/workflows/ci.yml | 1 + tests/dummy/config/ember-try.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 150f781..98209b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,6 +66,7 @@ jobs: ember-lts-4.4, ember-lts-4.8, ember-lts-4.12, + ember-lts-5.4, ember-release, ember-beta, ember-canary, diff --git a/tests/dummy/config/ember-try.js b/tests/dummy/config/ember-try.js index 9c64151..726f53d 100644 --- a/tests/dummy/config/ember-try.js +++ b/tests/dummy/config/ember-try.js @@ -47,6 +47,14 @@ module.exports = async function () { }, }, }, + { + name: 'ember-lts-5.4', + npm: { + devDependencies: { + 'ember-source': '~5.4.0', + }, + }, + }, { name: 'ember-release', npm: { From 594b2ebe9b35f6dc910dbe560cbf19e9265a96c1 Mon Sep 17 00:00:00 2001 From: "Andrey Mikhaylov (lolmaus)" Date: Thu, 25 Jan 2024 14:37:18 +0300 Subject: [PATCH 8/8] 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