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:
lilia 2017-04-13 10:52:12 -07:00 committed by Scott Nonnenberg
parent d0fc2f7e71
commit e7e030a5e2
No known key found for this signature in database
GPG Key ID: A4931C09644C654B
5 changed files with 20 additions and 2 deletions

View File

@ -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']);
};

View File

@ -1,4 +1,5 @@
{
"disableAutoUpdate": false,
"openDevTools": false
"openDevTools": false,
"buildExpiration": 0
}

View File

@ -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 || {};

View File

@ -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
}

View File

@ -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/*",