2018-04-30 09:55:47 +02:00
|
|
|
import {
|
|
|
|
workspace as Workspace,
|
2018-08-29 21:30:40 +02:00
|
|
|
commands as Commands,
|
|
|
|
ExtensionContext
|
2018-04-30 09:55:47 +02:00
|
|
|
} from 'vscode';
|
2018-04-20 20:07:36 +02:00
|
|
|
|
2018-05-18 13:47:22 +02:00
|
|
|
import * as ThemeCommands from './commands';
|
2018-11-25 15:05:10 +01:00
|
|
|
import {setCustomSetting, updateAccent} from './helpers/settings';
|
2018-05-18 13:47:22 +02:00
|
|
|
import {onChangeConfiguration} from './helpers/configuration-change';
|
2018-08-12 19:09:36 +02:00
|
|
|
import {changelogMessage, installationMessage} from './helpers/messages';
|
|
|
|
import checkInstallation from './helpers/check-installation';
|
|
|
|
import writeChangelog from './helpers/write-changelog';
|
2018-08-30 08:52:34 +02:00
|
|
|
import {ReleaseNotesWebview} from './webviews/ReleaseNotes';
|
2018-04-21 18:17:20 +02:00
|
|
|
|
2018-08-29 21:30:40 +02:00
|
|
|
export async function activate(context: ExtensionContext) {
|
2018-04-30 09:55:47 +02:00
|
|
|
const config = Workspace.getConfiguration();
|
2018-08-12 19:09:36 +02:00
|
|
|
const installationType = checkInstallation();
|
2018-08-29 21:30:40 +02:00
|
|
|
const releaseNotesView = new ReleaseNotesWebview(context);
|
2018-08-12 19:09:36 +02:00
|
|
|
|
|
|
|
writeChangelog();
|
2018-04-20 20:07:36 +02:00
|
|
|
|
2018-04-30 09:55:47 +02:00
|
|
|
// Listen on set theme: when the theme is Material Theme, just adjust icon and accent.
|
2018-05-18 13:47:22 +02:00
|
|
|
Workspace.onDidChangeConfiguration(onChangeConfiguration);
|
2018-04-21 18:17:20 +02:00
|
|
|
|
2018-04-30 09:55:47 +02:00
|
|
|
// Delete old configuration, must remove with next major release
|
|
|
|
if (config.has('materialTheme.cache.workbench')) {
|
|
|
|
config.update('materialTheme.cache.workbench', undefined, true);
|
|
|
|
}
|
|
|
|
|
2018-08-12 19:09:36 +02:00
|
|
|
if (installationType.isFirstInstall) {
|
|
|
|
const enableAutoApply = await installationMessage();
|
|
|
|
await setCustomSetting('autoApplyIcons', enableAutoApply);
|
|
|
|
// Set true always on new installation
|
|
|
|
await setCustomSetting('showReloadNotification', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
const shouldShowChangelog = (installationType.isFirstInstall || installationType.isUpdate) && await changelogMessage();
|
|
|
|
if (shouldShowChangelog) {
|
2018-08-29 21:30:40 +02:00
|
|
|
releaseNotesView.show();
|
2018-04-20 20:07:36 +02:00
|
|
|
}
|
|
|
|
|
2018-04-30 09:55:47 +02:00
|
|
|
// Registering commands
|
2018-05-18 13:47:22 +02:00
|
|
|
Commands.registerCommand('materialTheme.setAccent', async () => {
|
2018-11-25 15:05:10 +01:00
|
|
|
const accentPicked = await ThemeCommands.accentsQuickPick();
|
|
|
|
await updateAccent(accentPicked);
|
2018-05-18 13:47:22 +02:00
|
|
|
});
|
|
|
|
Commands.registerCommand('materialTheme.fixIcons', () => ThemeCommands.fixIcons());
|
|
|
|
Commands.registerCommand('materialTheme.toggleApplyIcons', () => ThemeCommands.toggleApplyIcons());
|
2018-08-29 21:30:40 +02:00
|
|
|
|
|
|
|
Commands.registerCommand('materialTheme.showReleaseNotes', () => releaseNotesView.show());
|
2018-04-20 20:07:36 +02:00
|
|
|
}
|