0

Why some npm packages for ember-cli (like ember-cli-simple-auth or ember-cli-simple-auth-token) needs to be installed with the following two statements

npm install --save-dev ember-cli-simple-auth-token
ember generate simple-auth-token

?

I don't actually understand the second one which apparently simply add a bower dependency:

bash me@imac1 ~/dev/wishhhh/ember $ ember generate simple-auth-token version: 0.1.2 installing Installing browser packages via Bower... cached git://github.com/simplabs/ember-simple-auth-component.git#0.6.7 Installed browser packages via Bower. Why do I need it?

masciugo
  • 1,113
  • 11
  • 19
  • The first one installs a blueprint, the second generates the files from the blueprint – Patsy Issa Oct 30 '14 at 16:10
  • For more info check [this section](http://www.ember-cli.com/#generators-and-blueprints) of the docs. – Patsy Issa Oct 30 '14 at 16:11
  • Ok Patsy, I can understand your explanation from a general point of view. I came from ruby world and I'm quite new to js project. Often ruby gems have generators inside which typically produce files. In this case it's not clear to me what exactly the generator does. As I said I'm kind of newbie and I have many lacks, what I really need is great article about ember-cli packages management from people coming from ruby world because it seems so different! thx a lot – masciugo Oct 30 '14 at 16:43
  • [Jump in the chat](http://chat.stackoverflow.com/rooms/63494/ember-js) ^^ – Patsy Issa Oct 30 '14 at 16:53

1 Answers1

1

You are correct in that all it does is install a bower package.

The reason this is requires is it prevents duplicate bower dependencies in your app. Early in addon development, people were installing bower components with an npm postInstall hook. While this worked, it added a lot of extra file size and possible conflicting bower dependencies.

This is the current pattern that addon developers are using to include bower dependencies in your project. This will likely be changed in the future but that is why for now.

(Answered referencing ember-cli 0.1.2)

jakecraige
  • 2,707
  • 4
  • 21
  • 25
  • I can accept your answer but what sounds convoluted to me (a rubygems user) is why not just install by using `bower install`? – masciugo Nov 03 '14 at 11:51
  • It's not a fully solved problem yet unfortunately. Manually adding by bower is fine and in this case achieves the same thing. Ideally we'd have ember-cli install it automatically but that has it's own problems. – jakecraige Nov 03 '14 at 16:39