Code Monkey home page Code Monkey logo

ember-cli-new-version's Introduction

ember-cli-new-version

Build Status

A convention-based version update notifier. Use it to notify users already on the page that a new version has been deployed.

Compatibility

  • Ember.js v3.20 or above
  • Ember CLI v3.20 or above
  • Node.js v12 or above

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:
<NewVersionNotifier/>

voila!

Options


  • updateInterval - the amount of time, in milliseconds, to wait between version checks default: 60000
  • firstCheckInterval - the amount of time, in milliseconds, to wait before the first version check is run after booting the application default: 0
  • 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
  • reloadButtonText - Sets the text for the default reload button. default: "Reload"
  • onNewVersion(newVersion, oldVersion) - a closure action that is called whenever a new version is detected. You can use this to track the version status elsewhere in your app (outside the component).
  • updateNeeded(oldVersion, newVersion) - a function that is called to check if an update message should be shown. For example, a function could be passed that only shows a message on major version changes. default: Always show message on any version change
<NewVersionNotifier
  @versionFileName="/version"
  @updateMessage="A new version was released: {newVersion}"
  @updateInterval={{150000}}
  @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.

<NewVersionNotifier 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>
</NewVersionNotifier>

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:

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

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

To override the version filename:

let app = new EmberApp(defaults, {
  newVersion: {
    enabled: true,
    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.

Supports ember-cli-app-version

Since version 1.2.0 this addons is able to use the version string provided by ember-cli-app-version.

All you have to do is install ember-cli-app-version and enable a flag in ember-cli-build.js.

Then an update is triggered based on full version strings with build metadata such as 1.0.0-beta-2-e1dffe1.

let app = new EmberApp(defaults, {
  newVersion: {
    enabled: true,
    useAppVersion: true
  }
});

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

ember-cli-new-version's People

Contributors

amilkey avatar barelyknown avatar basz avatar bgentry avatar colenso avatar ctjhoa avatar dependabot[bot] avatar devotox avatar elidupuis avatar hoyaboya avatar initram avatar jakesjews avatar jrjohnson avatar knownasilya avatar medokin avatar pbernery avatar pgengler avatar sethwebster avatar shijistar avatar st-h avatar subtletree avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.