diff --git a/extensions/defaults.json b/extensions/defaults.json index 5abd0c1..a65b07f 100644 --- a/extensions/defaults.json +++ b/extensions/defaults.json @@ -17,6 +17,10 @@ "Teal": "#80CBC4", "Yellow": "#FFA000" }, + "changelog": { + "lastversion": "", + "stopShowingChangelog": false + }, "icons": { "theme": { "iconDefinitions": { diff --git a/extensions/helpers/changelog.ts b/extensions/helpers/changelog.ts new file mode 100644 index 0000000..6608923 --- /dev/null +++ b/extensions/helpers/changelog.ts @@ -0,0 +1,39 @@ +import * as path from 'path'; + +import { getDefaultValues, getPackageJSON, writeFile } from "./fs"; +import { PATHS } from "../consts/paths"; + + +function splitVersion(input: string): { major: number, minor: number, patch: number } { + let [ major, minor, patch ] = input.split('.').map(i => parseInt(i)); + return { major, minor, patch }; +} + +export function showChangelog(): void { + +} + +export function shouldShowChangelog(): boolean { + let defaults = getDefaultValues(); + let out: boolean; + let packageJSON = getPackageJSON(); + + if (defaults.changelog == undefined || (defaults.changelog !== undefined && typeof defaults.changelog.lastversion !== 'string')) { + defaults.changelog = { + lastversion: packageJSON.version, + stopShowingChangelog: false + } + out = true; + } else { + let versionCurrent = splitVersion(packageJSON.version); + let versionOld = splitVersion(defaults.changelog.lastversion); + + out = versionCurrent.major !== versionOld.major || versionCurrent.minor !== versionOld.minor || versionCurrent.patch !== versionOld.patch; + + defaults.changelog.lastversion = packageJSON.version; + } + + writeFile(path.join(PATHS.VSIX_DIR, './extensions/defaults.json'), JSON.stringify(defaults, null, 2)); + + return out; +} \ No newline at end of file diff --git a/extensions/interfaces/idefaults.ts b/extensions/interfaces/idefaults.ts index 87826cf..9b6b29e 100644 --- a/extensions/interfaces/idefaults.ts +++ b/extensions/interfaces/idefaults.ts @@ -1,5 +1,6 @@ export interface IDefaults { accents: IAccents; + changelog: IChangelog; icons: IDefaultsThemeIcons; themeVariants: IDefaultsThemeVariant; themeVariantsColours: IDefaultsThemeVariantColours; @@ -11,6 +12,11 @@ export interface IAccents { [index: string]: string; } +export interface IChangelog { + lastversion: string; + stopShowingChangelog: boolean; +} + export interface IDefaultsThemeIcons { theme: { iconDefinitions: { diff --git a/extensions/material.theme.config.ts b/extensions/material.theme.config.ts index db511b3..44d9124 100644 --- a/extensions/material.theme.config.ts +++ b/extensions/material.theme.config.ts @@ -3,6 +3,7 @@ import * as vscode from 'vscode'; import { IGenericObject } from "./interfaces/igeneric-object"; import { THEME_ACCENTS_SETTER } from "./commands/accents-setter/index"; import { THEME_VARIANT } from "./commands/theme-variant/index"; +import { shouldShowChangelog, showChangelog } from './helpers/changelog'; enum Commands { ACCENTS, @@ -19,6 +20,10 @@ export function activate(context: vscode.ExtensionContext) { vscode.workspace.getConfiguration().update('materialTheme.cache.workbench.accent', undefined, true); } + if (shouldShowChangelog()) { + showChangelog(); + } + // registering the command let command = vscode.commands.registerCommand('material.theme.config', () => { // the user is going to choose what aspect of theme to config