Skip to content

Commit

Permalink
Drop template deprecation gathering
Browse files Browse the repository at this point in the history
This was broken long ago by a change in ember-cli-htmlbars. There is
a plan to bring it back, but remove it for now since the codepath is not
doing anything for most codebases.
  • Loading branch information
mixonic committed Jul 3, 2021
1 parent f6cd0c4 commit 6fa5784
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 147 deletions.
54 changes: 0 additions & 54 deletions generate-deprecations-tree.js

This file was deleted.

93 changes: 0 additions & 93 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
module.exports = {
name: require('./package').name,

init() {
this._super.init && this._super.init.apply(this, arguments);

this._templateDeprecations = [];
},

_shouldInclude() {
// the presence of `this.app.tests` shows that we are in one of:
//
Expand Down Expand Up @@ -52,91 +46,4 @@ module.exports = {

return mergeTrees([tree, configTree], { overwrite: true });
},

_findHtmlbarsPreprocessor(registry) {
var plugins = registry.load('template');

return plugins.filter(function (plugin) {
return plugin.name === 'ember-cli-htmlbars';
})[0];
},

_monkeyPatch_EmberDeprecate(htmlbarsCompilerPreprocessor) {
if (!htmlbarsCompilerPreprocessor._addon) {
// not a new enough ember-cli-htmlbars to monkey patch
// we need 1.0.3
return;
}
var addonContext = this;
var originalHtmlbarsOptions =
htmlbarsCompilerPreprocessor._addon.htmlbarsOptions;
var logToNodeConsole = this.project.config(
process.env.EMBER_ENV
).logTemplateLintToConsole;

htmlbarsCompilerPreprocessor._addon.htmlbarsOptions = function () {
var options = originalHtmlbarsOptions.apply(this, arguments);
var Ember = options.templateCompiler._Ember;

if (Ember.Debug && Ember.Debug.registerDeprecationHandler) {
Ember.Debug.registerDeprecationHandler(function (
message,
options,
next
) {
addonContext._templateDeprecations.push({
message: JSON.stringify(message),
test: false,
options: JSON.stringify(options),
});

if (logToNodeConsole) {
next();
}
});
}

var originalDeprecate = options.templateCompiler._Ember.deprecate;
Ember.deprecate = function (message, test, options) {
var noDeprecation;

if (typeof test === 'function') {
noDeprecation = test();
} else {
noDeprecation = test;
}

if (!noDeprecation) {
addonContext._templateDeprecations.push({
message: JSON.stringify(message),
test: !!test,
options: JSON.stringify(options),
});
}

if (logToNodeConsole) {
return originalDeprecate.apply(this, arguments);
}
};

return options;
};
},

setupPreprocessorRegistry(type, registry) {
if (type === 'parent') {
var htmlbarsCompilerPreprocessor =
this._findHtmlbarsPreprocessor(registry);

this._monkeyPatch_EmberDeprecate(htmlbarsCompilerPreprocessor);
}
},

lintTree(type, tree) {
if (type === 'template') {
var TemplateLinter = require('./generate-deprecations-tree');

return new TemplateLinter(this, tree);
}
},
};

0 comments on commit 6fa5784

Please sign in to comment.