mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-18 09:35:20 +02:00
84 lines
2.2 KiB
TypeScript
84 lines
2.2 KiB
TypeScript
import { _ } from './locale';
|
|
import Setting from './models/Setting';
|
|
import { reg } from './registry';
|
|
import { Plugins } from './services/plugins/PluginService';
|
|
import PluginService from './services/plugins/PluginService';
|
|
|
|
interface PluginList {
|
|
completeList: string;
|
|
summary: string;
|
|
}
|
|
|
|
function getPluginLists(plugins: Plugins): PluginList {
|
|
const pluginList = [];
|
|
const pluginSettings = PluginService.instance().unserializePluginSettings(Setting.value('plugins.states'));
|
|
const enabledPlugins = Object.fromEntries(Object.entries(plugins).filter((p) => pluginSettings[p[0]] && pluginSettings[p[0]].enabled === true));
|
|
|
|
if (Object.keys(enabledPlugins).length > 0) {
|
|
for (const pluginId in enabledPlugins) {
|
|
pluginList.push(`${enabledPlugins[pluginId].manifest.name}: ${enabledPlugins[pluginId].manifest.version}`);
|
|
}
|
|
}
|
|
|
|
pluginList.sort();
|
|
|
|
let completeList = '';
|
|
let summary = '';
|
|
if (pluginList.length > 0) {
|
|
completeList = ['\n', ...pluginList].join('\n');
|
|
|
|
if (pluginList.length > 20) {
|
|
summary = [
|
|
'\n',
|
|
...[...pluginList].filter((_, index) => index < 20),
|
|
'...',
|
|
].join('\n');
|
|
} else {
|
|
summary = completeList;
|
|
}
|
|
}
|
|
|
|
return {
|
|
completeList,
|
|
summary,
|
|
};
|
|
}
|
|
|
|
export default function versionInfo(packageInfo: any, plugins: Plugins) {
|
|
const p = packageInfo;
|
|
let gitInfo = '';
|
|
if ('git' in p) {
|
|
gitInfo = _('Revision: %s (%s)', p.git.hash, p.git.branch);
|
|
if (p.git.branch === 'HEAD') gitInfo = gitInfo.slice(0, -7);
|
|
}
|
|
const copyrightText = 'Copyright © 2016-YYYY Laurent Cozic';
|
|
const now = new Date();
|
|
|
|
const header = [
|
|
p.description,
|
|
'',
|
|
copyrightText.replace('YYYY', `${now.getFullYear()}`),
|
|
];
|
|
|
|
const body = [
|
|
_('%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')),
|
|
];
|
|
|
|
if (gitInfo) {
|
|
body.push(`\n${gitInfo}`);
|
|
}
|
|
|
|
const pluginList = getPluginLists(plugins);
|
|
|
|
return {
|
|
header: header.join('\n'),
|
|
body: body.join('\n').concat(pluginList.completeList),
|
|
message: header.concat(body).join('\n').concat(pluginList.summary),
|
|
};
|
|
}
|