It’s been awhile, so let’s upgrade!

Oh how the time flies. Personally projects sometimes need to take a back burner. That’s ok but once we get back at it we should make sure that all our libraries we are using are up-to-date. The biggest news is that ember-cli finally released a 2.0 version. Luckily they have an easy to follow set up steps to upgrade. Unfortunately it can take some time and you have to rebuild all your node_modules and there is no guarantee that everything will work. You can find the steps repeated from the ember release site. You might also want to upgrade bower while at it.

npm install -g bower

####Setup

  1. npm uninstall -g ember-cli – Remove old global ember-cli
  2. npm cache clean – Clear NPM cache
  3. bower cache clean – Clear Bower cache
  4. npm install -g ember-cli@2.2.0-beta.3 – Install new global ember-cli

####Project Update

  1. rm -rf node_modules bower_components dist tmp – Delete temporary development folders.
  2. npm install –save-dev ember-cli@2.2.0-beta.3 – Update project’s package.json to use latest version.
  3. npm install – Reinstall NPM dependencies.
  4. bower install – Reinstall bower dependencies.
  5. ember init – This runs the new project blueprint on your projects directory. Please follow the prompts, and review all changes (tip: you can see a diff by pressing d). The most common source of upgrade pain is missing changes in this step.Setup

When getting to the last step I said Y to all the prompts asking to overwrite files. Your strategy may vary. I also had to reinstall ember-simple-auth as it had disappeared. The same is true for coffeescript.

ember install ember-simple-auth
ember install ember-cli-coffeescript

It also added back an app.js and router.js files. We are using coffescript so these files need to be deleted.

This also overwrote my ember-cli-build.js file where we import font awesome and bootstrap. This needed to change back to the following

var EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  var app = new EmberApp(defaults, {
    // Add options here
    emberCliFontAwesome: {
      useScss: true
    }
  });

  app.import('bower_components/bootstrap/dist/css/bootstrap.css');
  app.import('bower_components/bootstrap/dist/css/bootstrap-theme.css');
  app.import('bower_components/bootstrap/dist/js/bootstrap.js');

  // Use `app.import` to add additional libraries to the generated
  // output files.
  //
  // If you need to use different assets in different
  // environments, specify an object as the first parameter. That
  // object's keys should be the environment name and the values
  // should be the asset to use in that environment.
  //
  // If the library that you are including contains AMD or ES6
  // modules that you would like to import into your application
  // please specify an object with the list of modules as keys
  // along with the exports of each module as its value.

  return app.toTree();
};
As well as our ember-simple-auth section for you environment.js files
ENV['ember-simple-auth'] = {
  store: 'session-store:local-storage'
}

Whew! Once all of the things I accidentally deleted were put back in place I have a working app again.

Comments