MOBILE-2607 settings: Display last commit in about page
parent
a6b6d28d40
commit
b1ffb5237d
99
gulpfile.js
99
gulpfile.js
|
@ -9,6 +9,7 @@ var gulp = require('gulp'),
|
||||||
flatten = require('gulp-flatten'),
|
flatten = require('gulp-flatten'),
|
||||||
npmPath = require('path'),
|
npmPath = require('path'),
|
||||||
File = gutil.File,
|
File = gutil.File,
|
||||||
|
exec = require('child_process').exec,
|
||||||
license = '' +
|
license = '' +
|
||||||
'// (C) Copyright 2015 Martin Dougiamas\n' +
|
'// (C) Copyright 2015 Martin Dougiamas\n' +
|
||||||
'//\n' +
|
'//\n' +
|
||||||
|
@ -75,7 +76,8 @@ function treatMergedData(data) {
|
||||||
var mergedOrdered = {};
|
var mergedOrdered = {};
|
||||||
|
|
||||||
for (var filepath in data) {
|
for (var filepath in data) {
|
||||||
var pathSplit = filepath.split('/');
|
var pathSplit = filepath.split('/'),
|
||||||
|
prefix;
|
||||||
|
|
||||||
pathSplit.pop();
|
pathSplit.pop();
|
||||||
|
|
||||||
|
@ -230,56 +232,67 @@ gulp.task('lang', function(done) {
|
||||||
|
|
||||||
// Convert config.json into a TypeScript class.
|
// Convert config.json into a TypeScript class.
|
||||||
gulp.task('config', function(done) {
|
gulp.task('config', function(done) {
|
||||||
gulp.src(paths.config)
|
// Get the last commit.
|
||||||
.pipe(through(function(file) {
|
exec('git log -1 --pretty=format:"%H"', function (err, commit, stderr) {
|
||||||
// Convert the contents of the file into a TypeScript class.
|
if (err) {
|
||||||
// Disable the rule variable-name in the file.
|
console.error('An error occurred while getting the last commit: ' + err);
|
||||||
var config = JSON.parse(file.contents.toString()),
|
} else if (stderr) {
|
||||||
contents = license + '// tslint:disable: variable-name\n' + 'export class CoreConfigConstants {\n';
|
console.error('An error occurred while getting the last commit: ' + stderr);
|
||||||
|
}
|
||||||
|
|
||||||
for (var key in config) {
|
gulp.src(paths.config)
|
||||||
var value = config[key];
|
.pipe(through(function(file) {
|
||||||
if (typeof value == 'string') {
|
// Convert the contents of the file into a TypeScript class.
|
||||||
// Wrap the string in ' .
|
// Disable the rule variable-name in the file.
|
||||||
value = "'" + value + "'";
|
var config = JSON.parse(file.contents.toString()),
|
||||||
} else if (typeof value != 'number' && typeof value != 'boolean') {
|
contents = license + '// tslint:disable: variable-name\n' + 'export class CoreConfigConstants {\n',
|
||||||
// Stringify with 4 spaces of indentation, and then add 4 more spaces in each line.
|
that = this;
|
||||||
value = JSON.stringify(value, null, 4).replace(/^(?: )/gm, ' ').replace(/^(?:})/gm, ' }');
|
|
||||||
// Replace " by ' in values.
|
|
||||||
value = value.replace(/: "([^"]*)"/g, ": '$1'");
|
|
||||||
|
|
||||||
// Check if the keys have "-" in it.
|
for (var key in config) {
|
||||||
var matches = value.match(/"([^"]*\-[^"]*)":/g);
|
var value = config[key];
|
||||||
if (matches) {
|
if (typeof value == 'string') {
|
||||||
// Replace " by ' in keys. We cannot remove them because keys have chars like '-'.
|
// Wrap the string in ' .
|
||||||
value = value.replace(/"([^"]*)":/g, "'$1':");
|
value = "'" + value + "'";
|
||||||
} else {
|
} else if (typeof value != 'number' && typeof value != 'boolean') {
|
||||||
// Remove ' in keys.
|
// Stringify with 4 spaces of indentation, and then add 4 more spaces in each line.
|
||||||
value = value.replace(/"([^"]*)":/g, "$1:");
|
value = JSON.stringify(value, null, 4).replace(/^(?: )/gm, ' ').replace(/^(?:})/gm, ' }');
|
||||||
|
// Replace " by ' in values.
|
||||||
|
value = value.replace(/: "([^"]*)"/g, ": '$1'");
|
||||||
|
|
||||||
|
// Check if the keys have "-" in it.
|
||||||
|
var matches = value.match(/"([^"]*\-[^"]*)":/g);
|
||||||
|
if (matches) {
|
||||||
|
// Replace " by ' in keys. We cannot remove them because keys have chars like '-'.
|
||||||
|
value = value.replace(/"([^"]*)":/g, "'$1':");
|
||||||
|
} else {
|
||||||
|
// Remove ' in keys.
|
||||||
|
value = value.replace(/"([^"]*)":/g, "$1:");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add type any to the key.
|
||||||
|
key = key + ': any';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add type any to the key.
|
// If key has quotation marks, remove them.
|
||||||
key = key + ': any';
|
if (key[0] == '"') {
|
||||||
|
key = key.substr(1, key.length - 2);
|
||||||
|
}
|
||||||
|
contents += ' static ' + key + ' = ' + value + ';\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
// If key has quotation marks, remove them.
|
// Add compilation info.
|
||||||
if (key[0] == '"') {
|
contents += ' static compilationtime = ' + Date.now() + ';\n';
|
||||||
key = key.substr(1, key.length - 2);
|
contents += ' static lastcommit = \'' + commit + '\';\n';
|
||||||
}
|
|
||||||
contents += ' static ' + key + ' = ' + value + ';\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add compilation time.
|
contents += '}\n';
|
||||||
contents += ' static compilationtime = ' + Date.now() + ';\n';
|
|
||||||
|
|
||||||
contents += '}\n';
|
file.contents = new Buffer(contents);
|
||||||
|
this.emit('data', file);
|
||||||
file.contents = new Buffer(contents);
|
}))
|
||||||
this.emit('data', file);
|
.pipe(rename('configconstants.ts'))
|
||||||
}))
|
.pipe(gulp.dest(paths.src))
|
||||||
.pipe(rename('configconstants.ts'))
|
.on('end', done);
|
||||||
.pipe(gulp.dest(paths.src))
|
});
|
||||||
.on('end', done);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('default', gulp.parallel('lang', 'config'));
|
gulp.task('default', gulp.parallel('lang', 'config'));
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"appready": "App ready",
|
"appready": "App ready",
|
||||||
"cannotsyncoffline": "Cannot synchronise offline.",
|
"cannotsyncoffline": "Cannot synchronise offline.",
|
||||||
"cannotsyncwithoutwifi": "Cannot synchronise because the current settings only allow to synchronise when connected to Wi-Fi. Please connect to a Wi-Fi network.",
|
"cannotsyncwithoutwifi": "Cannot synchronise because the current settings only allow to synchronise when connected to Wi-Fi. Please connect to a Wi-Fi network.",
|
||||||
"compilationtime": "Compilation time",
|
"compilationinfo": "Compilation info",
|
||||||
"cordovadevicemodel": "Cordova device model",
|
"cordovadevicemodel": "Cordova device model",
|
||||||
"cordovadeviceosversion": "Cordova device OS version",
|
"cordovadeviceosversion": "Cordova device OS version",
|
||||||
"cordovadeviceplatform": "Cordova device platform",
|
"cordovadeviceplatform": "Cordova device platform",
|
||||||
|
|
|
@ -36,9 +36,10 @@
|
||||||
<h2>{{ 'core.settings.versioncode' | translate}}</h2>
|
<h2>{{ 'core.settings.versioncode' | translate}}</h2>
|
||||||
<p>{{ versionCode }}</p>
|
<p>{{ versionCode }}</p>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ion-item text-wrap *ngIf="compilationTime">
|
<ion-item text-wrap *ngIf="compilationTime || lastCommit">
|
||||||
<h2>{{ 'core.settings.compilationtime' | translate }}</h2>
|
<h2>{{ 'core.settings.compilationinfo' | translate }}</h2>
|
||||||
<p>{{ compilationTime | coreFormatDate: "LLL Z" }}</p>
|
<p *ngIf="compilationTime">{{ compilationTime | coreFormatDate: "LLL Z" }}</p>
|
||||||
|
<p *ngIf="lastCommit">{{ lastCommit }}</p>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ion-item text-wrap *ngIf="fileSystemRoot">
|
<ion-item text-wrap *ngIf="fileSystemRoot">
|
||||||
<h2>{{ 'core.settings.filesystemroot' | translate}}</h2>
|
<h2>{{ 'core.settings.filesystemroot' | translate}}</h2>
|
||||||
|
|
|
@ -37,6 +37,7 @@ export class CoreSettingsAboutPage {
|
||||||
versionName: string;
|
versionName: string;
|
||||||
versionCode: number;
|
versionCode: number;
|
||||||
compilationTime: number;
|
compilationTime: number;
|
||||||
|
lastCommit: string;
|
||||||
privacyPolicy: string;
|
privacyPolicy: string;
|
||||||
navigator: Navigator;
|
navigator: Navigator;
|
||||||
locationHref: string;
|
locationHref: string;
|
||||||
|
@ -63,6 +64,7 @@ export class CoreSettingsAboutPage {
|
||||||
this.versionName = CoreConfigConstants.versionname;
|
this.versionName = CoreConfigConstants.versionname;
|
||||||
this.versionCode = CoreConfigConstants.versioncode;
|
this.versionCode = CoreConfigConstants.versioncode;
|
||||||
this.compilationTime = CoreConfigConstants.compilationtime;
|
this.compilationTime = CoreConfigConstants.compilationtime;
|
||||||
|
this.lastCommit = CoreConfigConstants.lastcommit;
|
||||||
|
|
||||||
// Calculate the privacy policy to use.
|
// Calculate the privacy policy to use.
|
||||||
this.privacyPolicy = currentSite.getStoredConfig('tool_mobile_apppolicy') || currentSite.getStoredConfig('sitepolicy') ||
|
this.privacyPolicy = currentSite.getStoredConfig('tool_mobile_apppolicy') || currentSite.getStoredConfig('sitepolicy') ||
|
||||||
|
|
Loading…
Reference in New Issue