/ember-cli-new-version

A convention based update notification for Ember. With this addon, you can detect a new version and notify the user to refresh the page

Primary LanguageJavaScriptMIT LicenseMIT

ember-cli-new-version


Codeship Status for sethwebster/ember-cli-new-version

A convention-based version update notifier.

Usage

  1. Add this add-on as you would any other:
> ember install ember-cli-new-version
  1. Add a version file to your app, eg: ./public/VERSION.txt
1.0.0
  1. Include the component in your view:
{{new-version-notifier}}

viola!

Options


  • updateInterval - the amount of time, in milliseconds, to wait between version checks default: 5000
  • versionFileName - the name of the file on the server to check default: /VERSION.txt
  • updateMessage - the message to show to users when update has been detected. There are two tokens allowed in this string: {{newVersion}} and {{oldVersion}} which will replaced with their respective values. eg. (and default). "This application has been updated from version {{oldVersion}} to {{newVersion}}. Please save any work, then refresh browser to see changes."
  • showReload - true shows a reload button the user can click to refresh. false hides the button. default: true
{{new-version-notifier updateInterval=<value> versionFileName="<value>" updateMessage="<value>" showReload=true}}

Custom Notification

By default the notification is styled as a Bootstrap Alert. If you want custom layouts or to use a different framework, then you can define your own markup for the notification.

{{#new-version-notifier as |version lastVersion reload close|}}
  <div class="custom-notification">
    Reload to update to the new version ({{version}}) of this application
    <button type="button" onclick={{action reload}}>Reload</button>
    <button type="button" onclick={{action close}}>Close</button>
  </div>
{{/new-version-notifier}}

Automatic VERSION file creation

You can opt-in to automatically generating a VERSION.txt during the build process. Opting-in means you don't need maintain a /public/VERSION.txt in your project. Simply add the following to ember-cli-build.js:

var app = new EmberApp(defaults, {
  newVersion: true
});

This will result in dist/VERSION.txt being created.

To override the version filename:

var app = new EmberApp(defaults, {
  fileName: 'MY-VERSION.txt'
});

This will result in dist/MY-VERSION.txt being created. Note that this will also update the default versionFileName attribute in the {{new-version-notifier}} component.

Contributing

  • git clone this repository
  • npm install
  • bower install

Running

For more information on using ember-cli, visit http://www.ember-cli.com/.