Skip to content

Commit

Permalink
Release 1.0.5 - Auto Generation of versio file (version bump for missed
Browse files Browse the repository at this point in the history
dependency)
Release 1.0.4 - Auto generation of version file

This release adds an option to have the verison file generated based on
the package.json file.

Closes #11  - thanks to @elidupuis

Add option to automatically generate a version file

Set default `versionFileName` from `ember-cli-build` configuration

Bumped package version

Moved dependency to dev
  • Loading branch information
elidupuis authored and Seth webster committed Mar 4, 2016
1 parent f91711b commit 2d72382
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 8 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,26 @@ to use a different framework, then you can define your own markup for the notifi
{{/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
Expand Down
2 changes: 1 addition & 1 deletion addon/components/new-version-notifier/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default Ember.Component.extend({
showReload: true,
showReloadButton: Ember.computed.alias("showReload"),
init: function() {
this._super();
this._super(...arguments);
this.updateVersion();
},
updateVersion() {
Expand Down
3 changes: 1 addition & 2 deletions app/components/ember-cli-new-version.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
import Ember from 'ember';
import NewVersionNotifier from 'ember-cli-new-version/components/new-version-notifier/component';
import NewVersionNotifier from './new-version-notifier';
export default NewVersionNotifier;
9 changes: 7 additions & 2 deletions app/components/new-version-notifier.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/*jshint esnext:true */

import Ember from 'ember';
import config from '../config/environment';
import NewVersionNotifier from 'ember-cli-new-version/components/new-version-notifier/component';
export default NewVersionNotifier;

let versionFileName = `/${config.newVersion.fileName}` || '/VERSION.txt';

export default NewVersionNotifier.extend({
versionFileName
});
3 changes: 3 additions & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
module.exports = function(defaults) {
var app = new EmberAddon(defaults, {
// Add options here
newVersion: {
fileName: 'MY-VERSION.txt'
}
});

/*
Expand Down
39 changes: 38 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
/* jshint node: true */
'use strict';

var writeFile = require('broccoli-file-creator');

module.exports = {
name: 'ember-cli-new-version'
name: 'ember-cli-new-version',

/*
Store config from `ember-cli-build.js`
*/
included: function(app, parentAddon) {
this.options = app.options.newVersion || {};

if (this.options === true) {
this.options = { fileName: 'VERSION.txt' };
}
},

/*
Set options on the environment configuration object so they can
be accessed via `import config from '../config/environment';`
*/
config: function(env, baseConfig) {
if (this.options && this.options.fileName) {
return { newVersion: this.options };
}
},

/*
Generate version file automatically
based on package.json of consuming application.
*/
treeForPublic: function() {
var content = this.parent.pkg.version || '';
var fileName = this.options.fileName;

if (this.options.fileName) {
this.ui.writeLine('Created ' + fileName);
return writeFile(fileName, content);
}
}
};
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-cli-new-version",
"version": "1.0.3",
"version": "1.0.5",
"description": "A convention based update notification for Ember. With this addon, you can detect a new version and notify the user to refresh the page",
"directories": {
"doc": "doc",
Expand All @@ -22,6 +22,7 @@
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "^2.2.0",
"broccoli-file-creator": "^1.1.0",
"ember-cli": "1.13.13",
"ember-cli-app-version": "^1.0.0",
"ember-cli-content-security-policy": "0.4.0",
Expand All @@ -48,7 +49,8 @@
],
"dependencies": {
"ember-cli-babel": "^5.1.5",
"ember-cli-htmlbars": "^1.0.1"
"ember-cli-htmlbars": "^1.0.1",
"broccoli-file-creator": "^1.1.0"
},
"ember-addon": {
"configPath": "tests/dummy/config"
Expand Down

0 comments on commit 2d72382

Please sign in to comment.