Skip to content
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

Deprecate funnel and pickfiles #3681

Merged
merged 1 commit into from
Mar 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 40 additions & 17 deletions lib/models/addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ var AddonsFactory = require('../models/addons-factory');
var CoreObject = require('core-object');
var Project = require('./project');

var mergeTrees = require('broccoli-merge-trees');
var Funnel = require('broccoli-funnel');
var walkSync = require('walk-sync');

/**
Root class for an Addon. If your addon module exports an Object this
will be extended from this base class. If you export a constructor (function),
Expand Down Expand Up @@ -103,25 +107,44 @@ Addon.prototype.hintingEnabled = function() {
@private
@method _requireBuildPackages
*/

Addon.prototype._requireBuildPackages = function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this now does nothing should we deprecate it also?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i need it actually to get good error messages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I don't see that in this pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

been running this on several apps at work, and working hard to make nice deprecation output (and catching other cases i didn't think of)

I think i got them all now

if (this._didRequiredBuildPackages === true) {
return;
} else {
this._didRequiredBuildPackages = true;
}

this.transpileModules = this.transpileModules || require('broccoli-es6modules');
this.transpileModules = deprecatedAddonFilters(this, 'this.transpileModules', 'broccoli-es6modules', function(tree, options) {
return new (require('broccoli-es6modules'))(tree, options);
});

this.mergeTrees = this.mergeTrees || require('broccoli-merge-trees');
this.Funnel = this.Funnel || require('broccoli-funnel');
this.walkSync = this.walkSync || require('walk-sync');
this.pickFiles = deprecatedAddonFilters(this, 'this.pickFiles', 'broccoli-funnel', function(tree, options) {
return new Funnel(tree, options);
});


this.Funnel = deprecatedAddonFilters(this, 'new this.Funnel(..)', 'broccoli-funnel', function(tree, options) {
return new Funnel(tree, options);
});

this.pickFiles = function(tree, options) {
this.ui.writeLine('[Deprecated] this.pickFiles(..) is deprecated in-favour of new this.Funnel(..) [addon: ' + this.name + ']');
return new this.Funnel(tree, options);
}.bind(this);
this.mergeTrees = deprecatedAddonFilters(this, 'this.mergeTrees', 'broccoli-merge-trees', mergeTrees);
this.walkSync = deprecatedAddonFilters(this, 'this.walkSync', 'node-walk-sync', walkSync);
};

function deprecatedAddonFilters(addon, name, insteadUse, fn) {
return function(tree, options) {
var message = '[Deprecated] ' + name + ' is deprecated, please use ' + insteadUse + ' directly instead [addon: ' + addon.name + ']';
this.ui && this.ui.writeLine(message);

if (!this.ui) {
console.warn(message);
}

return fn(tree, options);
};
}

/**
Shorthand method for [broccoli-sourcemap-concat](https://github.com/ef4/broccoli-sourcemap-concat)

Expand Down Expand Up @@ -267,7 +290,7 @@ Addon.prototype.treeFor = function treeFor(name) {
trees.push(this.jshintAddonTree());
}

return this.mergeTrees(trees.filter(Boolean), {
return mergeTrees(trees.filter(Boolean), {
overwrite: true,
description: 'Addon#treeFor (' + this.name + ' - ' + name + ')'
});
Expand Down Expand Up @@ -368,7 +391,7 @@ Addon.prototype.treeForPublic = function(tree) {
return tree;
}

return new this.Funnel(tree, {
return new Funnel(tree, {
srcDir: '/',
destDir: '/' + this.moduleName()
});
Expand All @@ -392,7 +415,7 @@ Addon.prototype.treeForAddon = function(tree) {
var addonTree = this.compileAddon(tree);
var stylesTree = this.compileStyles(this._treeFor('addon-styles'));

return this.mergeTrees([addonTree, stylesTree].filter(Boolean));
return mergeTrees([addonTree, stylesTree].filter(Boolean));
};

/**
Expand Down Expand Up @@ -435,7 +458,7 @@ Addon.prototype.compileTemplates = function(tree) {
'`' + this.name + '`\'s `package.json`.');
}

var standardTemplates = new this.Funnel(tree, {
var standardTemplates = new Funnel(tree, {
srcDir: '/',
destDir: 'modules/' + this.name + '/templates'
});
Expand All @@ -444,13 +467,13 @@ Addon.prototype.compileTemplates = function(tree) {
return new RegExp('template.' + extension + '$');
});

var podTemplates = new this.Funnel(tree, {
var podTemplates = new Funnel(tree, {
include: includePatterns,
destDir: 'modules/' + this.name + '/',
description: 'Funnel: Addon Pod Templates'
});

return preprocessTemplates(this.mergeTrees([standardTemplates, podTemplates]), {
return preprocessTemplates(mergeTrees([standardTemplates, podTemplates]), {
registry: this.registry
});
}
Expand All @@ -476,7 +499,7 @@ Addon.prototype.compileAddon = function(tree) {
var reexported = reexport(this.name, this.name + '.js');
var trees = [addonJs, templatesTree, reexported].filter(Boolean);

return this.mergeTrees(trees);
return mergeTrees(trees);
};

/**
Expand All @@ -498,7 +521,7 @@ Addon.prototype.jshintAddonTree = function() {
var addonJs = this.addonJsFiles(addonPath);
var jshintedAddon = this.app.addonLintTree('addon', addonJs);

return new this.Funnel(jshintedAddon, {
return new Funnel(jshintedAddon, {
srcDir: '/',
destDir: this.name + '/tests/'
});
Expand All @@ -518,7 +541,7 @@ Addon.prototype.addonJsFiles = function(tree) {
return new RegExp(extension + '$');
});

return new this.Funnel(tree, {
return new Funnel(tree, {
include: includePatterns,
destDir: 'modules/' + this.moduleName(),
description: 'Funnel: Addon JS'
Expand Down