Ember Addons and bower dependencies versioning

156 views Asked by At

(related, very similar, but not the same as this question, as my question is looking for the scenario where node_modules is lost and re-fetched through npm install and on the topic of keeping deps current in general.)

Let A be an addon in version a1, and let B be a bower dependency of that addon in version b1. The addon installs its bower package through the default blueprint like

afterInstall: function() {
    // b1 is the version.
    return this.addBowerPackageToProject('B', 'b1');
}

Now let C be an application consuming A. When A is installed using ember install A

The bower package is actually installed in C. Up to here, things are fine. Now A is updated to version a2, including B in version b2. In C,

rm -R node_modules
npm cache clean
npm install

(checking out C with no node_modules and running npm install will run into a similar problem if the bower.json is old) will fetch A.a2.

  • Should A.a2's default blueprint run and cause C to install B.b2 as well? (this is the actual question asked here)

if the blueprint is run manually, B.b2 actually gets prompted for, that is, you get to see that the project has a bower conflict now and are asked how to resolve it.

I tried it out now, it doesn't work. If I specify a postinstall script for npm (ember g testaddon), it doesn't work either (because npm tries to install the packages in a different order and ember-cli isn't installed when the postinstall script runs).

What good is it to have blueprints propagate bower dependencies if one does have to check them manually anyway? Am I understanding this wrongly? Is this intended behaviour?

1

There are 1 answers

0
Gaurav On

I totally agree. ember-cli currently does nothing on upgrade or uninstall of an npm package, and this is a problem for addons. Addons should be able to specify blueprints that run on version upgrade and uninstall. Alternatively, there should be an 'ember upgrade' and 'ember uninstall' commands that run such blueprints if available.

The addon could then in the upgrade blueprint cause C to install B.b2 if it is not already installed.

Anyone who would like to formally propose this, the way to do so is opening a pull request at https://github.com/ember-cli/rfcs