Ember

Salt

If your Django site has an Ember front end, then add ember: True to your sites file:

# sites/my.sls
sites:
  www.hatherleigh.info:
    package: hatherleigh_info
    profile: django
    ember: True

The default path for your Django app will be /back/ and the default path for your Ember app will be /. If you want to override this, then you can set the ember_path and django_path as follows:

# sites/my.sls
sites:
  www.hatherleigh.info:
    package: hatherleigh_info
    profile: django
    ember: True
    ember_path: front
    django_path: back

Note

Don’t append or prepend a / to the ember_path or django_path. The Salt state files will take care of the /.

If you set an ember_path (other than /), set the rootURL in the production environment (config/environment.js):

if (environment === "production") {
  ENV.rootURL = "/front/"
}

Installation

Prerequisites

To install node and npm (from https://github.com/nodesource/distributions):

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt install -y nodejs

Older notes

Ember-cli is installed using npm. It’s quite tempermental about which version of node to use - you can use nvm to get the latest version (see digital ocean tutorial)

sudo apt update
sudo apt-get install build-essential libssl-dev
# check https://github.com/creationix/nvm for the latest version and replace
# check
# https://github.com/nvm-sh/nvm#installing-and-updating for the latest version
# and replace v0.35.3 in the line below with the latest version

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

# either log out or run the following
source ~/.profile
# Install the latest version
nvm install
# check which version you have installed
nvm ls

Ember will use a global version of bower if it is installed:

npm install -g bower

Install watchman (better then nodewatcher):

npm install -g watchman

Install PhantomJS (for testing):

npm install -g phantomjs-prebuilt

Installing Ember-cli

npm install -g ember-cli

Creating a project

Run the following commands to create a project e.g. ember-first:

ember new ember-first
cd ember-first
ember server

Cloning an existing project

To clone an existing project e.g. ember-first:

git clone git@gitlab.com:proj-owner/ember-first.git
cd ember-first
npm install
bower install
ember server

Packages

To update one package (e.g kb-base-ember-addons):

npm i @kbsoftware/kb-base-ember-addons@latest

Use ncu (npm-check-updates) to finalise versions before releasing for deployment. Run all the tests and check it by running on a local server.

https://www.npmjs.com/package/npm-check-updates:

npm i -g npm-check-updates

Then type:

ncu

… inside a folder with a package.json.

This shows you what is out of date. And typing:

ncu -u

… will update all the versions in the package.json file.

So you then run:

npm i

… which will upgrade as per the new package.json

Testing

Note

We don’t need to define Mirage models, Auto-discovery of Ember Data models