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

Set bowerDirectory for project #2287

Merged
merged 1 commit into from
Oct 15, 2014
Merged

Set bowerDirectory for project #2287

merged 1 commit into from
Oct 15, 2014

Conversation

quaertym
Copy link
Contributor

I need this for this addon https://github.com/quaertym/ember-cli-dependency-checker, but might be useful in other places. Project can know its bowerDirectory, right?

@stefanpenner
Copy link
Contributor

mind adding a quick test

@quaertym
Copy link
Contributor Author

Sure.

@quaertym
Copy link
Contributor Author

@stefanpenner done.

@rwjblue
Copy link
Member

rwjblue commented Oct 10, 2014

Not sure here. Seems like we should just put the logic to determine the default bowerDirectory into the project....

@rwjblue
Copy link
Member

rwjblue commented Oct 10, 2014

My concern is that if we only add it to the project in the broccoli build, many many other hooks do not have access to it.

I generally do not like having the same model (project) that has inconsistent properties.

@quaertym
Copy link
Contributor Author

@rwjblue do you think that bowerDirectory belongs to the project rather than the app?

@quaertym
Copy link
Contributor Author

@rwjblue I will close this PR and move bowerDirectory logic inside project, then set it for the app when in app's constructor, are you OK with that?

@rwjblue
Copy link
Member

rwjblue commented Oct 12, 2014

@quaertym - The changes sound good, but you do not need to close the PR. You can just amend your current commit and force push.

@quaertym
Copy link
Contributor Author

@rwjblue @stefanpenner Can you guys review this?
Some points:

@@ -19,6 +19,13 @@ function Project(root, pkg) {
this.pkg = pkg;
this.addonPackages = {};
this.liveReloadFilterPatterns = [];

var bowerrcPath = path.join(this.root, '.bowerrc');
Copy link
Member

Choose a reason for hiding this comment

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

Can you move this into a function (perhaps setupBowerDirectory or something) that is called from here instead of inlining it?

@rwjblue
Copy link
Member

rwjblue commented Oct 12, 2014

@quaertym - Looking good, we will also need some unit tests for this.

@quaertym quaertym force-pushed the patch-13 branch 2 times, most recently from 4f8722f to a5798b7 Compare October 12, 2014 20:16
@quaertym
Copy link
Contributor Author

@rwjblue Tests are in. I think it is good to merge.

@quaertym
Copy link
Contributor Author

@rwjblue @stefanpenner Can you merge this? Travis is happy, appveyor is not.

@@ -14,11 +14,21 @@ var forOwn = require('lodash-node/modern/objects/forOwn');

var emberCLIVersion = require('../utilities/ember-cli-version');

Project.prototype.setupBowerDirectory = function() {
Copy link
Member

Choose a reason for hiding this comment

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

While it is perfectly valid to put this method above the constructor, it is odd. Can you move it below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests do not run when it is below.

@rwjblue
Copy link
Member

rwjblue commented Oct 13, 2014

I'd like to see a few more project unit tests for the following scenarios:

  • No .bowerrc
  • .bowerrc with invalid JSON
  • .bowerrc without a directory property

You can use fixtures to setup the project under test with a custom root with the needed files from above.

@ahacking
Copy link

Will the bower directory be made available within the Brocfile so you can app.import your bower components from whatever path has been configured?

It would also allow addons to do imports for you without making assumptions unless you already have this figured out.

@quaertym
Copy link
Contributor Author

@ahacking You can still access it using app.bowerDirectory as before in Brocfile, see https://github.com/quaertym/ember-cli/blob/patch-13/lib/broccoli/ember-app.js#L76

@ahacking
Copy link

Sweet! I just read another issue with someone using an old version of ember CLI and they were importing using an assumed location so I wasn't sure if the bower directory was available or not.

This is good, I'm wondering if there would be value in say a bowerImport helper to save some string munging in our Brocfiles?

@quaertym
Copy link
Contributor Author

Not in this PR, but I liked the idea. It can transform the code from this:

app.import(app.bowerDirectory + '/modernizr/modernizr.js');

to this:

app.bowerImport('/modernizr/modernizr.js');

@quaertym
Copy link
Contributor Author

@rwjblue Can you review this PR one more time?

rwjblue added a commit that referenced this pull request Oct 15, 2014
Set bowerDirectory for project
@rwjblue rwjblue merged commit cf5f8ed into ember-cli:master Oct 15, 2014
@rwjblue
Copy link
Member

rwjblue commented Oct 15, 2014

Beautiful!! Thanks @quaertym!

@quaertym
Copy link
Contributor Author

👍

@rwjblue What is your opinion on bowerImport method suggested above by @ahacking? I can implement this.

@rwjblue
Copy link
Member

rwjblue commented Oct 15, 2014

I'd say probably not. I do not want more public API for importing things (app.import is crazy enough).

Rules seem simple (we can publish them on the website or something), but here you go:

  • in your Brocfile, use the path that the file exists on disk
  • in an addon, use app.bowerDirectory or project.bowerDirectory to ensure you are not tied to the specific location.

@jakecraige jakecraige mentioned this pull request Jan 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants