Book Image

Ember.js Cookbook

By : Erik Hanchett
Book Image

Ember.js Cookbook

By: Erik Hanchett

Overview of this book

Ember.js is an open source JavaScript framework that will make you more productive. It uses common idioms and practices, making it simple to create amazing single-page applications. It also lets you create code in a modular way using the latest JavaScript features. Not only that, it has a great set of APIs to get any task done. The Ember.js community is welcoming newcomers and is ready to help you when needed. This book provides in-depth explanations on how to use the Ember.js framework to take you from beginner to expert. You’ll start with some basic topics and by the end of the book, you’ll know everything you need to know to build a fully operational Ember application. We’ll begin by explaining key points on how to use the Ember.js framework and the associated tools. You’ll learn how to effectively use Ember CLI and how to create and deploy your application. We’ll take a close look at the Ember object model and templates by examining bindings and observers. We’ll then move onto Ember components, models, and Ember Data. We’ll show you examples on how to connect to RESTful databases. Next we’ll get to grips with testing with integration and acceptance tests using QUnit. We will conclude by covering authentication, services, and Ember add-ons. We’ll explore advanced topics such as services and initializers, and how to use them together to build real-time applications.
Table of Contents (18 chapters)
Ember.js Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Upgrading your project


Ember CLI is constantly being upgraded and every six weeks Ember.js has another release. It is important to keep your build tools and versions up to date. In this recipe we'll look at the best way of doing this.

How to do it...

To upgrade your Ember CLI version, you must perform the following steps:

  1. Begin by uninstalling the old ember-cli:

    $ npm uninstall –g ember-cli
    
  2. Clear the npm cache:

    $ npm cache clean
    
  3. Clear the Bower cache:

    $ bower cache clean
    
  4. Install the latest version of ember-cli:

    $ npm install –g ember-cli
    
  5. If you need, you can specify the version to use represented by X.X.X:

    $ npm install –g [email protected]
    

Updating an existing project

In some situations, you might want to take an existing project and update it to the latest version of Ember CLI. In this case, you'll need to perform the following steps:

  1. Begin by changing directories that you want to upgrade in the root of the project folder. Delete these temporary development directories:

    $ rm –rf node_modules bower_components dist tmp
    
  2. Update the package.json file with the version of Ember that we're upgrading to using this command:

    $ npm install [email protected] --save-dev
    

    X.X.X represents the version of ember-cli. The --save-dev argument will save the information in the package.json file.

  3. Install all the npm and Bower packages again:

    $ npm install
    $ bower install
    
  4. The last step is to run the init command:

    $ ember init
    

    The init command will add the default project blueprint to your directory.

    Tip

    init

    The init command will create a new application blueprint in your project directory. Follow the prompts and review all the changes. You may be asked to replace existing files. Press d to do a diff of the files and review the changes made. Create a backup of your project before you begin the upgrade process.

Keep in mind that after upgrading your project, you might have many new deprecation warnings to deal with. You will see these warnings when you run ember server. Each one will need to be addressed.

To address these deprecations, view the warnings that the applications provide. For instance, you may get a warning about Ember.View. The warning will describe that Ember.Component should be used instead. You'll then need to swap out the effected code with Ember components instead of Ember views.

How it works...

When you upgrade the tool, you are simply uninstalling the node package and reinstalling the latest one. It's a good idea to clear the Bower and Node cache as well so that Node and Bower won't have any conflicting packages.

When we update an existing project we first have to make sure that all the existing modules and packages are deleted. This is important because when we install the latest version of Ember CLI, some packages might change. After ember-cli is saved back in the package file, then you can install npm and Bower again.

Running ember init generates the application structure in the directory that you're in. This is important because some files may have changed since the last upgrade. You can always press d to diff the changes.