Build expiration date
Add the buildExpiration config and add it to the renderer's config object. Use grunt to write the build expiration to config/local-production.json which will override the default value (no expiration) in production. Finally, run this grunt task as part of the build process. // FREEBIE
This commit is contained in:
parent
d0fc2f7e71
commit
e7e030a5e2
5 changed files with 20 additions and 2 deletions
|
@ -242,10 +242,19 @@ module.exports = function(grunt) {
|
|||
});
|
||||
});
|
||||
|
||||
grunt.registerTask('getExpireTime', function() {
|
||||
var gitinfo = grunt.config.get('gitinfo');
|
||||
var commited = gitinfo.local.branch.current.lastCommitTime;
|
||||
var time = Date.parse(commited) + 1000 * 60 * 60 * 24 * 90;
|
||||
grunt.file.write('config/local-production.json',
|
||||
JSON.stringify({ buildExpiration: time }) + '\n');
|
||||
});
|
||||
|
||||
grunt.registerTask('tx', ['exec:tx-pull', 'locale-patch']);
|
||||
grunt.registerTask('dev', ['default', 'connect', 'watch']);
|
||||
grunt.registerTask('test', ['jshint', 'jscs', 'connect', 'saucelabs-mocha']);
|
||||
grunt.registerTask('copy_dist', ['gitinfo', 'copy']);
|
||||
grunt.registerTask('date', ['gitinfo', 'getExpireTime']);
|
||||
grunt.registerTask('default', ['concat', 'sass', 'copy_dist']);
|
||||
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"disableAutoUpdate": false,
|
||||
"openDevTools": false
|
||||
"openDevTools": false,
|
||||
"buildExpiration": 0
|
||||
}
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
;(function() {
|
||||
'use strict';
|
||||
var BUILD_EXPIRATION = 0;
|
||||
try {
|
||||
BUILD_EXPIRATION = parseInt(window.config.buildExpiration);
|
||||
if (BUILD_EXPIRATION) {
|
||||
console.log("Build expires: ", new Date(BUILD_EXPIRATION).toISOString());
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
window.extension = window.extension || {};
|
||||
|
||||
|
|
1
main.js
1
main.js
|
@ -68,6 +68,7 @@ function createWindow () {
|
|||
query: {
|
||||
locale: locale,
|
||||
version: package_json.version,
|
||||
buildExpiration: config.get('buildExpiration'),
|
||||
serverUrl: config.get('serverUrl'),
|
||||
NODE_ENV: process.env.NODE_ENV
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
"test": "grunt test",
|
||||
"lint": "grunt jshint",
|
||||
"start": "electron .",
|
||||
"dist": "build --em.environment=$NODE_ENV",
|
||||
"dist": "grunt && build --em.environment=$NODE_ENV",
|
||||
"pack": "npm run dist -- --dir",
|
||||
"pack-staging": "NODE_ENV=staging npm run pack",
|
||||
"dist-staging": "NODE_ENV=staging npm run dist",
|
||||
|
@ -74,6 +74,7 @@
|
|||
"package.json",
|
||||
"config/default.json",
|
||||
"config/${env.NODE_ENV}.json",
|
||||
"config/local-${env.NODE_ENV}.json",
|
||||
"background.html",
|
||||
"_locales/**",
|
||||
"protos/*",
|
||||
|
|
Loading…
Add table
Reference in a new issue