2020-10-09 19:35:46 +02:00
|
|
|
import { _ } from 'lib/locale';
|
|
|
|
const Setting = require('lib/models/Setting').default;
|
2020-08-02 17:21:30 +02:00
|
|
|
const { reg } = require('lib/registry.js');
|
|
|
|
|
|
|
|
export default function versionInfo(packageInfo:any) {
|
|
|
|
const p = packageInfo;
|
|
|
|
let gitInfo = '';
|
|
|
|
if ('git' in p) {
|
|
|
|
gitInfo = _('Revision: %s (%s)', p.git.hash, p.git.branch);
|
|
|
|
}
|
|
|
|
const copyrightText = 'Copyright © 2016-YYYY Laurent Cozic';
|
|
|
|
const now = new Date();
|
2020-10-21 11:10:18 +02:00
|
|
|
|
|
|
|
const header = [
|
2020-08-02 17:21:30 +02:00
|
|
|
p.description,
|
|
|
|
'',
|
|
|
|
copyrightText.replace('YYYY', `${now.getFullYear()}`),
|
2020-10-21 11:10:18 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
const body = [
|
2020-08-02 17:21:30 +02:00
|
|
|
_('%s %s (%s, %s)', p.name, p.version, Setting.value('env'), process.platform),
|
|
|
|
'',
|
|
|
|
_('Client ID: %s', Setting.value('clientId')),
|
|
|
|
_('Sync Version: %s', Setting.value('syncVersion')),
|
|
|
|
_('Profile Version: %s', reg.db().version()),
|
|
|
|
_('Keychain Supported: %s', Setting.value('keychain.supported') >= 1 ? _('Yes') : _('No')),
|
|
|
|
];
|
2020-10-21 11:10:18 +02:00
|
|
|
|
2020-08-02 17:21:30 +02:00
|
|
|
if (gitInfo) {
|
2020-10-21 11:10:18 +02:00
|
|
|
body.push(`\n${gitInfo}`);
|
2020-08-02 17:21:30 +02:00
|
|
|
console.info(gitInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2020-10-21 11:10:18 +02:00
|
|
|
header: header.join('\n'),
|
|
|
|
body: body.join('\n'),
|
|
|
|
message: header.concat(body).join('\n'),
|
2020-08-02 17:21:30 +02:00
|
|
|
};
|
|
|
|
}
|