-
Notifications
You must be signed in to change notification settings - Fork 43
[BREAKING] Convert to a module. Drops support for Ember < 3.28, requires manual initialization #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b1a6c1e
[BREAKING] Convert to a module, drops support for Ember < 3.28
lolmaus cc1012b
Split tests per function
lolmaus b125588
Update the scenarios run by the CI suite
mixonic 7dd704a
Fix build by moving ember-cli-babel to dependencies
lolmaus 9dab377
Fix lint
lolmaus a95e0ba
Add 3.x section to readme
mixonic 2b37d81
Add an explicit 5.4 LTS entry to CI
mixonic 594b2eb
Update getting started instructions in readme with Embroider-first path
lolmaus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.