Fix/adapt icons command (#162)

* fix(adapt-icons): added new interface and method for vsc conf theme

* fix(adapt-icons): getting theme name from vsc theme settings

* chore(cleanup): removed useless interface property

* chore(cleanup): temporary commented on useless script (for build sake)

* chore(postintall): fixing tsc build after first install (for gulp sake)
This commit is contained in:
Alessio Occhipinti 2018-04-21 13:57:08 +02:00 committed by Mattia Astorino
parent 761f426200
commit 00c85e736c
6 changed files with 30 additions and 5 deletions

View file

@ -3,7 +3,7 @@ import * as fs from 'fs';
import { getAbsolutePath, getDefaultValues, getThemeIconsByContributeID, getThemeIconsContribute, getVariantIcons } from "../../helpers/fs";
import { getCurrentThemeIconsID } from "../../helpers/vscode";
import { getCustomSettings, isAccent, isMaterialThemeIcons } from "../../helpers/settings";
import { isAccent, isMaterialThemeIcons, getThemeSettings, getCustomSettings } from "../../helpers/settings";
import { CHARSET } from "../../consts/files";
import { IPackageJSONThemeIcons } from "../../interfaces/ipackage.json";
@ -24,6 +24,17 @@ function replaceIconPathWithAccent(iconPath: string, accentName: string): string
return iconPath.replace('.svg', `.accent.${ accentName }.svg`);
}
function getVariantFromColor(color: string): string {
switch (color) {
case undefined || 'Material Theme':
return 'Default';
case 'Material Theme High Contrast':
return 'Default High Contrast';
default:
return color.replace(/Material Theme /gi, '');
}
}
export const THEME_ICONS = () => {
let deferred: any = {};
let promise = new Promise((resolve, reject) => {
@ -33,10 +44,12 @@ export const THEME_ICONS = () => {
let themeIconsID: string = getCurrentThemeIconsID();
if (isMaterialThemeIcons(themeIconsID)) {
let themeSettings = getThemeSettings();
let customSettings = getCustomSettings();
let defaults = getDefaultValues();
let accentName = customSettings.accent;
let variantName: string = customSettings.themeColours === undefined ? '' : customSettings.themeColours;
let variantName: string = getVariantFromColor(themeSettings.colorTheme);
let themeContribute: IPackageJSONThemeIcons = getThemeIconsContribute(themeIconsID);
let theme: IThemeIcons = getThemeIconsByContributeID(themeIconsID);
let themepath: string = getAbsolutePath(themeContribute.path);

View file

@ -22,7 +22,7 @@ export const THEME_VARIANT = () => {
let themepath: string = defaults.themeVariants[response];
let themeUITheme: string = defaults.themeVariantsUITheme[response];
customSettings.themeColours = response;
// customSettings.themeColours = response;
packageJSON.contributes.themes[0].path = themepath;
packageJSON.contributes.themes[0].uiTheme = themeUITheme;

View file

@ -2,8 +2,18 @@ import * as vscode from 'vscode';
import { IDefaults } from "../interfaces/idefaults";
import { IThemeCustomProperties } from "../interfaces/itheme-custom-properties";
import { IThemeSettings } from "../interfaces/itheme-settings";
import {getPackageJSON} from './fs';
/**
* Gets theme settings
* @export
* @returns {*}
*/
export function getThemeSettings(): IThemeSettings {
return vscode.workspace.getConfiguration().get<IThemeSettings>('workbench', {});
}
/**
* Gets saved accent
* @export

View file

@ -1,5 +1,4 @@
export interface IThemeCustomProperties {
accent?: string;
accentPrevious?: string;
themeColours?: string;
}

View file

@ -0,0 +1,3 @@
export interface IThemeSettings {
colorTheme?: string;
}

View file

@ -38,7 +38,7 @@
"build-icons-variants": "yarn gulp build:icons.variants",
"build-themes": "yarn gulp build:themes",
"release": "standard-version",
"postinstall": "node ./node_modules/vscode/bin/install && opencollective postinstall"
"postinstall": "node ./node_modules/vscode/bin/install && opencollective postinstall && tsc -p tsconfig.json"
},
"categories": [
"Themes",