Skip to content

Commit

Permalink
feat: Always create the version file
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The version file is always created, you must opt out now instead of opt in, see the README

The way to opt out of this behavior is to include a VERSION.txt in the
app, otherwise the file will be created automatically. When a
VERSION.txt file exists the treeForPublic build step won't overwrite it.

Co-authored-by: Ilya Radchenko <knownasilya@gmail.com>
  • Loading branch information
jrjohnson and knownasilya committed Dec 15, 2021
1 parent 2fe8486 commit da01a6f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ module.exports = function (environment) {
versionFileName: 'VERSION.txt',
updateInterval: 60000,
firstCheckInterval: 0,
createVersionFileAutomatically: false,
enableInTests: false,
maxCountInTesting: 10,
},
Expand All @@ -56,18 +55,13 @@ module.exports = function (environment) {
* `versionFileName` - the name of the file on the server to check **default: /VERSION.txt**
* `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**
* `enableInTests` - Shoud the version checking run in test environments? **default: false**
* `enableInTests` - Should the version checking run in test environments? **default: false**
* `maxCountInTesting` - How many times to check for a new version in tests. **default: 10**
* `createVersionFileAutomatically` - 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`:
```js
let app = new EmberApp(defaults, {
newVersion: {
enabled: true
}
});
```
This will result in `dist/VERSION.txt` being created.


## Automatic Version File Creation ##
If no `VERSION.txt` file exists it will be automatically generated during the build process
with the value of `currentVersion` or the `version` from `package.json`.

### Supports `ember-cli-app-version`

Expand All @@ -77,7 +71,6 @@ All you have to do is install `ember-cli-app-version`.

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

### Notifier Configuration and Interface ###
----
* `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.
Expand Down
12 changes: 4 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module.exports = {
updateInterval: 60000,
enableInTests: false,
maxCountInTesting: 10,
createVersionFileAutomatically: false,
};

baseConfig.newVersion = Object.assign(
Expand All @@ -43,13 +42,10 @@ module.exports = {
* Write version file
*/
treeForPublic() {
const { currentVersion, createVersionFileAutomatically, versionFileName } =
this._config;
if (currentVersion && createVersionFileAutomatically) {
const fileName = versionFileName;

this.ui.writeLine(`Created ${fileName} with ${currentVersion}`);
return writeFile(fileName, currentVersion);
const { currentVersion, versionFileName } = this._config;
if (currentVersion) {
this.ui.writeLine(`Created ${versionFileName} with ${currentVersion}`);
return writeFile(versionFileName, currentVersion);
}
},
};
3 changes: 0 additions & 3 deletions tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ module.exports = function (environment) {
'ember-cli-mirage': {
enabled: false,
},
newVersion: {
createVersionFileAutomatically: true,
},
};

if (environment === 'development') {
Expand Down

0 comments on commit da01a6f

Please sign in to comment.