diff --git a/src/api.ts b/src/api.ts index baaf15b8..a65c76be 100644 --- a/src/api.ts +++ b/src/api.ts @@ -10,7 +10,7 @@ import { IConfiguration, ILDExtensionConfiguration, InstructionPatch, - LaunchDarklyAuthenticationSession, + ILaunchDarklyAuthenticationSession, NewFlag, ProjectAPI, ReleasePhase, @@ -22,6 +22,7 @@ import { LDExtensionConfiguration } from './ldExtensionConfiguration'; import { debuglog } from 'util'; import { CMD_LD_CONFIG } from './utils/commands'; import { legacyAuth } from './utils/legacyAuth'; +import { CONST_CONFIG_LD } from './utils/constants'; interface CreateOptionsParams { method?: string; @@ -48,7 +49,7 @@ axios.interceptors.response.use( originalRequest._retry = true; const session = (await authentication.getSession('launchdarkly', ['writer'], { createIfNone: false, - })) as LaunchDarklyAuthenticationSession; + })) as ILaunchDarklyAuthenticationSession; config.setSession(session); originalRequest.headers['Authorization'] = `Bearer ${session.accessToken}`; return axios(originalRequest); @@ -155,12 +156,9 @@ export class LaunchDarklyAPI { return project; } catch (err) { window - .showErrorMessage( - `[LaunchDarkly] Error getting Project: ${projectKey}\n${err}`, - 'Configure LaunchDarkly Extension', - ) + .showErrorMessage(`${CONST_CONFIG_LD} Error getting Project: ${projectKey}\n${err}`, CONST_CONFIG_LD) .then((selection) => { - if (selection === 'Configure LaunchDarkly Extension') commands.executeCommand(CMD_LD_CONFIG); + if (selection === CONST_CONFIG_LD) commands.executeCommand(CMD_LD_CONFIG); }); } } @@ -199,11 +197,11 @@ export class LaunchDarklyAPI { console.log(err); window .showErrorMessage( - `[LaunchDarkly] Error getting Project: ${projectKey} Environment: ${envKey}\n${err}`, - 'Configure LaunchDarkly Extension', + `${CONST_CONFIG_LD} Error getting Project: ${projectKey} Environment: ${envKey}\n${err}`, + CONST_CONFIG_LD, ) .then((selection) => { - if (selection === 'Configure LaunchDarkly Extension') commands.executeCommand(CMD_LD_CONFIG); + if (selection === CONST_CONFIG_LD) commands.executeCommand(CMD_LD_CONFIG); }); } } @@ -217,11 +215,11 @@ export class LaunchDarklyAPI { } catch (err) { window .showErrorMessage( - `[LaunchDarkly] Error getting Metrics for Project: ${projectKey}\n${err}`, - 'Configure LaunchDarkly Extension', + `${CONST_CONFIG_LD} Error getting Metrics for Project: ${projectKey}\n${err}`, + CONST_CONFIG_LD, ) .then((selection) => { - if (selection === 'Configure LaunchDarkly Extension') commands.executeCommand(CMD_LD_CONFIG); + if (selection === CONST_CONFIG_LD) commands.executeCommand(CMD_LD_CONFIG); }); } } diff --git a/src/commands/openLaunchDarkly.ts b/src/commands/openLaunchDarkly.ts index c649f0df..647bef09 100644 --- a/src/commands/openLaunchDarkly.ts +++ b/src/commands/openLaunchDarkly.ts @@ -1,7 +1,7 @@ import { commands, Disposable, window } from 'vscode'; import { FLAG_KEY_REGEX } from '../providers'; import { kebabCase } from 'lodash'; -import { FeatureFlagConfig, FlagStoreInterface, ILDExtensionConfiguration } from '../models'; +import { FeatureFlagConfig, IFlagStore, ILDExtensionConfiguration } from '../models'; import * as url from 'url'; import opn = require('opn'); import { CMD_LD_OPEN } from '../utils/commands'; @@ -51,7 +51,7 @@ export default function openInLdCmd(config: ILDExtensionConfiguration): Disposab return openInLdCmd; } -const openFlagInBrowser = async (config: ILDExtensionConfiguration, flagKey: string, flagStore: FlagStoreInterface) => { +const openFlagInBrowser = async (config: ILDExtensionConfiguration, flagKey: string, flagStore: IFlagStore) => { const { flag } = await flagStore.getFeatureFlag(flagKey); // Default to first environment diff --git a/src/configurationMenu.ts b/src/configurationMenu.ts index 79eeaade..270748c4 100644 --- a/src/configurationMenu.ts +++ b/src/configurationMenu.ts @@ -10,10 +10,11 @@ import { } from 'vscode'; import { MultiStepInput } from './multiStepInput'; -import { Resource, Project, Environment, LaunchDarklyAuthenticationSession, LaunchDarklyAPIInterface } from './models'; +import { Resource, Project, Environment, ILaunchDarklyAuthenticationSession, LaunchDarklyAPIInterface } from './models'; import { extensionReload } from './generalUtils'; import { logDebugMessage } from './utils/logDebugMessage'; import { LDExtensionConfiguration } from './ldExtensionConfiguration'; +import { CONST_LD_PREFIX } from './utils/constants'; interface CMState { baseUri: string; env: string; @@ -64,7 +65,7 @@ export class ConfigurationMenu { if (selection === 'Sign In') { const session = (await authentication.getSession('launchdarkly', ['writer'], { createIfNone: true, - })) as LaunchDarklyAuthenticationSession; + })) as ILaunchDarklyAuthenticationSession; this.config.setSession(session); } } @@ -171,7 +172,7 @@ export class ConfigurationMenu { window.withProgress( { location: ProgressLocation.Notification, - title: '[LaunchDarkly] Updating Configuration', + title: `${CONST_LD_PREFIX} Updating Configuration`, cancellable: false, }, () => { diff --git a/src/createFlagMenu.ts b/src/createFlagMenu.ts index f7f43cf5..ddeb48e1 100644 --- a/src/createFlagMenu.ts +++ b/src/createFlagMenu.ts @@ -4,6 +4,7 @@ import { MultiStepInput, QuickPickParameters } from './multiStepInput'; import { LaunchDarklyAPI } from './api'; import { kebabCase } from 'lodash'; import { FeatureFlag, ILDExtensionConfiguration, NewFlag, ReleasePipeline } from './models'; +import { CONST_LD_PREFIX } from './utils/constants'; export interface State { name: string; key: string; @@ -157,7 +158,7 @@ export class CreateFlagMenu { window.withProgress( { location: ProgressLocation.Notification, - title: '[LaunchDarkly] Flag: ${flag.key} created and key copied to your clipboard.', + title: `${CONST_LD_PREFIX} Flag: ${flag.key} created and key copied to your clipboard.`, cancellable: false, }, () => { @@ -174,7 +175,7 @@ export class CreateFlagMenu { } } } catch (err) { - window.showErrorMessage(`[LaunchDarkly] Creating flag ${err}`); + window.showErrorMessage(`${CONST_LD_PREFIX} Creating flag ${err}`); } } @@ -213,7 +214,7 @@ export class CreateFlagMenu { window.showInformationMessage(`Flag: ${flag.key} created and key copied to your clipboard.`); this.flag = flag; } catch (err) { - window.showErrorMessage(`[LaunchDarkly] Creating flag ${err}`); + window.showErrorMessage(`${CONST_LD_PREFIX} Creating flag ${err}`); } } } diff --git a/src/extension.ts b/src/extension.ts index 1e2fe578..46656270 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -14,7 +14,7 @@ import { LDExtensionConfiguration } from './ldExtensionConfiguration'; import * as semver from 'semver'; import { SetWorkspaceCmd } from './commands/setWorkspaceEnabled'; import { CMD_LD_CONFIG, CMD_LD_SIGNIN } from './utils/commands'; -import { LaunchDarklyAuthenticationSession } from './models'; +import { ILaunchDarklyAuthenticationSession } from './models'; export async function activate(ctx: ExtensionContext): Promise { const storedVersion = ctx.globalState.get('version', '5.0.0'); @@ -26,7 +26,7 @@ export async function activate(ctx: ExtensionContext): Promise { const session = (await authentication.getSession('launchdarkly', ['writer'], { createIfNone: false, - })) as LaunchDarklyAuthenticationSession; + })) as ILaunchDarklyAuthenticationSession; LDExtConfig.setSession(session); const validationError = await LDExtConfig.getConfig().validate(); @@ -67,7 +67,7 @@ export async function activate(ctx: ExtensionContext): Promise { commands.registerCommand(CMD_LD_SIGNIN, async () => { const session = (await authentication.getSession('launchdarkly', ['writer'], { createIfNone: true, - })) as LaunchDarklyAuthenticationSession; + })) as ILaunchDarklyAuthenticationSession; LDExtConfig.setSession(session); if (!(await LDExtConfig.getConfig().isConfigured())) { window diff --git a/src/flagStore.ts b/src/flagStore.ts index 61a69f2a..a74fcb42 100644 --- a/src/flagStore.ts +++ b/src/flagStore.ts @@ -8,13 +8,14 @@ import { debounce, Dictionary, keyBy } from 'lodash'; import { FeatureFlag, FlagConfiguration, - FlagStoreInterface, + IFlagStore, FlagWithConfiguration, ILDExtensionConfiguration, InstructionPatch, PatchComment, } from './models'; import { CMD_LD_CONFIG } from './utils/commands'; +import { CONST_CONFIG_LD, CONST_LD_PREFIX } from './utils/constants'; const DATA_KIND = { namespace: 'features' }; @@ -22,7 +23,7 @@ type FlagUpdateCallback = (flag: string) => void; type LDClientResolve = (LDClient: LDClient) => void; type LDClientReject = () => void; -export class FlagStore implements FlagStoreInterface { +export class FlagStore implements IFlagStore { private readonly config: ILDExtensionConfiguration; private readonly store: LaunchDarkly.LDFeatureStore; private flagMetadata: Dictionary; @@ -59,7 +60,7 @@ export class FlagStore implements FlagStoreInterface { await this.stop(); await this.start(); } catch (err) { - window.showErrorMessage(`[LaunchDarkly] ${err}`); + window.showErrorMessage(`${CONST_LD_PREFIX} ${err}`); } }, 200, @@ -105,9 +106,9 @@ export class FlagStore implements FlagStoreInterface { this.setLDClientBackgroundCheck(); } catch (err) { window - .showErrorMessage('[LaunchDarkly] Failed to setup LaunchDarkly client', 'Configure LaunchDarkly Extension') + .showErrorMessage(`${CONST_LD_PREFIX} Failed to setup LaunchDarkly client`, CONST_CONFIG_LD) .then((selection) => { - if (selection === 'Configure LaunchDarkly Extension') commands.executeCommand(CMD_LD_CONFIG); + if (selection === CONST_CONFIG_LD) commands.executeCommand(CMD_LD_CONFIG); }); this.rejectLDClient(); console.error(`Failed to setup client: ${err}`); @@ -193,7 +194,7 @@ export class FlagStore implements FlagStoreInterface { console.log(`${err}`); return; } - window.showErrorMessage(`[LaunchDarkly] ${errMsg}`); + window.showErrorMessage(`${CONST_LD_PREFIX} ${errMsg}`); } }, 5000, @@ -349,7 +350,7 @@ export class FlagStore implements FlagStoreInterface { return this.flagMetadata; } catch (err) { console.log(`Failed getting Metadata: ${err}`); - window.showErrorMessage(`[LaunchDarkly] ${err}`); + window.showErrorMessage(`${CONST_LD_PREFIX} ${err}`); } } else { return this.flagMetadata; diff --git a/src/generalUtils.ts b/src/generalUtils.ts index 6f6349ca..ba918f2d 100644 --- a/src/generalUtils.ts +++ b/src/generalUtils.ts @@ -27,6 +27,7 @@ import { ILDExtensionConfiguration, InstructionPatch } from './models'; import { logDebugMessage } from './utils/logDebugMessage'; import { CMD_LD_CONFIG, CMD_LD_OPEN_FLAG, CMD_LD_REFRESH_LENS, CMD_LD_TOGGLE_CMD_PROMPT } from './utils/commands'; import { registerCommand } from './utils/registerCommand'; +import { CONST_CONFIG_LD } from './utils/constants'; const cache = new ToggleCache(); @@ -85,7 +86,6 @@ export async function setupComponents(config: ILDExtensionConfiguration, reload if (config.getConfig().enableAliases) { config.setAliases(new FlagAliases(config)); - //aliases = new FlagAliases(config.getConfig(), ctx); if (config.getAliases().codeRefsVersionCheck()) { config.getAliases().setupStatusBar(); await config.getAliases().start(); @@ -181,7 +181,7 @@ async function showToggleMenu(config: ILDExtensionConfiguration) { try { flags = await config.getFlagStore().allFlagsMetadata(); } catch (err) { - window.showErrorMessage('[LaunchDarkly] Unable to retrieve flags, please check configuration.'); + window.showErrorMessage(`${CONST_CONFIG_LD} Unable to retrieve flags, please check configuration.`); return; } const items = []; diff --git a/src/ldExtensionConfiguration.ts b/src/ldExtensionConfiguration.ts index 3f2e16cb..1f1c9b70 100644 --- a/src/ldExtensionConfiguration.ts +++ b/src/ldExtensionConfiguration.ts @@ -1,13 +1,13 @@ import { ExtensionContext, StatusBarItem, TreeView } from 'vscode'; import { - FlagStoreInterface, - FlagTreeInterface, + IFlagStore, + IFlagTree, IConfiguration, IFlagAliases, ILaunchDarklyReleaseProvider, LaunchDarklyAPIInterface, - LaunchDarklyAuthenticationSession, - LaunchDarklyTreeViewProviderInterface, + ILaunchDarklyAuthenticationSession, + ILaunchDarklyTreeViewProvider, } from './models'; export class LDExtensionConfiguration { @@ -15,12 +15,12 @@ export class LDExtensionConfiguration { private config?: IConfiguration; private ctx: ExtensionContext; private api?: LaunchDarklyAPIInterface; - private flagStore?: FlagStoreInterface; - private flagTreeView: TreeView; - private flagView: LaunchDarklyTreeViewProviderInterface; + private flagStore?: IFlagStore; + private flagTreeView: TreeView; + private flagView: ILaunchDarklyTreeViewProvider; private aliases?: IFlagAliases; private releaseView?: ILaunchDarklyReleaseProvider; - private session?: LaunchDarklyAuthenticationSession; + private session?: ILaunchDarklyAuthenticationSession; private statusBar?: StatusBarItem; private constructor(ctx: ExtensionContext) { @@ -66,27 +66,27 @@ export class LDExtensionConfiguration { this.ctx = ctx; } - getFlagStore(): FlagStoreInterface | undefined { + getFlagStore(): IFlagStore | undefined { return this.flagStore; } - setFlagStore(flagStore: FlagStoreInterface): void { + setFlagStore(flagStore: IFlagStore): void { this.flagStore = flagStore; } - getFlagTreeProvider(): TreeView | undefined { + getFlagTreeProvider(): TreeView | undefined { return this.flagTreeView; } - setFlagTreeProvider(flagTreeProvider: TreeView): void { + setFlagTreeProvider(flagTreeProvider: TreeView): void { this.flagTreeView = flagTreeProvider; } - getFlagView(): LaunchDarklyTreeViewProviderInterface | undefined { + getFlagView(): ILaunchDarklyTreeViewProvider | undefined { return this.flagView; } - setFlagView(flagView: LaunchDarklyTreeViewProviderInterface): void { + setFlagView(flagView: ILaunchDarklyTreeViewProvider): void { this.flagView = flagView; } @@ -98,11 +98,11 @@ export class LDExtensionConfiguration { this.releaseView = releaseView; } - getSession(): LaunchDarklyAuthenticationSession | undefined { + getSession(): ILaunchDarklyAuthenticationSession | undefined { return this.session; } - setSession(session: LaunchDarklyAuthenticationSession): void { + setSession(session: ILaunchDarklyAuthenticationSession): void { this.session = session; } diff --git a/src/models.ts b/src/models.ts index 3d0fcb88..e7dcf780 100644 --- a/src/models.ts +++ b/src/models.ts @@ -577,7 +577,7 @@ export interface MemberTeamSummaryRep { name: string; } -export interface FlagStoreInterface { +export interface IFlagStore { storeUpdates: EventEmitter; // We fire a storeReady event because this will always exist compared to 'ready' listener on LDClient // which may be reinitialized @@ -610,9 +610,8 @@ export interface FlagStoreInterface { // Add other methods as needed... } -export interface LaunchDarklyTreeViewProviderInterface - extends TreeDataProvider { - flagNodes: Array | null; +export interface ILaunchDarklyTreeViewProvider extends TreeDataProvider { + flagNodes: Array | null; start(): void; treeLoader(): void; registerCommands(): void; @@ -621,14 +620,14 @@ export interface LaunchDarklyTreeViewProviderInterface // Add other methods as needed... } -export interface FlagTreeInterface { +export interface IFlagTree { children: unknown; command?: unknown; flagKey?: string; flagVersion?: number; } -export interface LaunchDarklyAuthenticationSession extends AuthenticationSession { +export interface ILaunchDarklyAuthenticationSession extends AuthenticationSession { refreshToken: string; baseUri: string; fullUri: string; @@ -657,16 +656,16 @@ export interface ILDExtensionConfiguration { setConfig(config: IConfiguration): void; getCtx(): ExtensionContext; setCtx(ctx: ExtensionContext): void; - getFlagStore(): FlagStoreInterface | undefined; - setFlagStore(flagStore: FlagStoreInterface): void; - getFlagTreeProvider(): TreeView | undefined; - setFlagTreeProvider(flagTreeProvider: TreeView): void; - getFlagView(): LaunchDarklyTreeViewProviderInterface | undefined; - setFlagView(flagView: LaunchDarklyTreeViewProviderInterface): void; + getFlagStore(): IFlagStore | undefined; + setFlagStore(flagStore: IFlagStore): void; + getFlagTreeProvider(): TreeView | undefined; + setFlagTreeProvider(flagTreeProvider: TreeView): void; + getFlagView(): ILaunchDarklyTreeViewProvider | undefined; + setFlagView(flagView: ILaunchDarklyTreeViewProvider): void; getReleaseView(): ILaunchDarklyReleaseProvider | undefined; setReleaseView(releaseView: ILaunchDarklyReleaseProvider): void; - getSession(): LaunchDarklyAuthenticationSession | undefined; - setSession(session: LaunchDarklyAuthenticationSession): void; + getSession(): ILaunchDarklyAuthenticationSession | undefined; + setSession(session: ILaunchDarklyAuthenticationSession): void; getStatusBar(): StatusBarItem | undefined; setStatusBar(statusBar: StatusBarItem): void; } diff --git a/src/providers/authProvider.ts b/src/providers/authProvider.ts index fcb25e9a..44176d9f 100644 --- a/src/providers/authProvider.ts +++ b/src/providers/authProvider.ts @@ -17,8 +17,9 @@ import { import { v4 as uuid } from 'uuid'; import { PromiseAdapter, promiseFromEvent } from '../utils/common'; import fetch from 'node-fetch'; -import { LaunchDarklyAuthenticationSession, Member, Team } from '../models'; +import { ILaunchDarklyAuthenticationSession, Member, Team } from '../models'; import { legacyAuth } from '../utils/legacyAuth'; +import { CONST_CONFIG_LD } from '../utils/constants'; export const AUTH_TYPE = `launchdarkly`; const AUTH_NAME = `LaunchDarkly`; @@ -69,14 +70,14 @@ export class LaunchDarklyAuthenticationProvider implements AuthenticationProvide * @param scopes * @returns */ - public async getSessions(): Promise { + public async getSessions(): Promise { try { const allSessions = await this.context.secrets.get(SESSIONS_SECRET_KEY); if (allSessions.length === 2) { return []; } - const sessions = JSON.parse(allSessions) as LaunchDarklyAuthenticationSession; + const sessions = JSON.parse(allSessions) as ILaunchDarklyAuthenticationSession; const session = sessions[0]; const useLegacy = legacyAuth(); if (session && session.refreshToken && !useLegacy) { @@ -121,7 +122,7 @@ export class LaunchDarklyAuthenticationProvider implements AuthenticationProvide fullUri, ); - const session: LaunchDarklyAuthenticationSession = { + const session: ILaunchDarklyAuthenticationSession = { id: uuid(), accessToken: access_token, refreshToken: refresh_token, @@ -316,7 +317,7 @@ export class LaunchDarklyAuthenticationProvider implements AuthenticationProvide if (res.status == 404) { return { firstName: 'Service', lastName: 'Account', email: 'none', teams: [] }; } else if (res.status !== 200 && res.status !== 201) { - window.showErrorMessage(`[LaunchDarkly] Failed to get user info: ${res.status}`); + window.showErrorMessage(`${CONST_CONFIG_LD} Failed to get user info: ${res.status}`); } return (await response.json()) as Member; } diff --git a/src/providers/codeRefs.ts b/src/providers/codeRefs.ts index 04e7fea2..02deb4d6 100644 --- a/src/providers/codeRefs.ts +++ b/src/providers/codeRefs.ts @@ -7,6 +7,7 @@ import csv from 'csv-parser'; import { CodeRefs } from '../coderefs/codeRefsVersion'; import { legacyAuth } from '../utils/legacyAuth'; import { ILDExtensionConfiguration } from '../models'; +import { CONST_LD_PREFIX } from '../utils/constants'; // eslint-disable-next-line @typescript-eslint/no-var-requires const { promises: Fs } = require('fs'); @@ -115,7 +116,7 @@ export class FlagAliases { timeout: 20 * 60000, }); if (output.stderr) { - window.showErrorMessage(`[LaunchDarkly] finding Code References failed ${output.stderr}`); + window.showErrorMessage(`${CONST_LD_PREFIX} finding Code References failed ${output.stderr}`); } } catch (err) { window.showErrorMessage(err.error); diff --git a/src/providers/completion.ts b/src/providers/completion.ts index 886df505..3c4a0e9e 100644 --- a/src/providers/completion.ts +++ b/src/providers/completion.ts @@ -1,15 +1,15 @@ import { CompletionItemProvider, TextDocument, Position, CompletionItem, CompletionItemKind, Range } from 'vscode'; import { FLAG_KEY_REGEX } from '../providers'; -import { FlagStoreInterface, IConfiguration, IFlagAliases } from '../models'; +import { IFlagStore, IConfiguration, IFlagAliases } from '../models'; export const STRING_DELIMITERS = ['"', "'", '`']; export default class LaunchDarklyCompletionItemProvider implements CompletionItemProvider { - private readonly flagStore: FlagStoreInterface; + private readonly flagStore: IFlagStore; private readonly config: IConfiguration; private readonly aliases?: IFlagAliases; - constructor(config: IConfiguration, flagStore: FlagStoreInterface, aliases?: IFlagAliases) { + constructor(config: IConfiguration, flagStore: IFlagStore, aliases?: IFlagAliases) { this.config = config; this.flagStore = flagStore; this.aliases = aliases; diff --git a/src/providers/flagListView.ts b/src/providers/flagListView.ts index afff8c53..e957a0c5 100644 --- a/src/providers/flagListView.ts +++ b/src/providers/flagListView.ts @@ -18,14 +18,14 @@ import { Configuration } from '../configuration'; import { flagToValues } from '../utils/FlagNode'; import { FlagCodeLensProvider, SimpleCodeLens } from './flagLens'; import { FlagNode } from '../utils/FlagNode'; -import { FeatureFlag, FlagTreeInterface, ILDExtensionConfiguration } from '../models'; +import { FeatureFlag, IFlagTree, ILDExtensionConfiguration } from '../models'; import { logDebugMessage } from '../utils/logDebugMessage'; import { CMD_LD_ENABLE_LENS } from '../utils/commands'; export class LaunchDarklyFlagListProvider implements TreeDataProvider { private ldConfig: ILDExtensionConfiguration; private lens: FlagCodeLensProvider; - private flagNodes: Array | null; + private flagNodes: Array | null; private _onDidChangeTreeData: EventEmitter = new EventEmitter(); readonly onDidChangeTreeData: Event = this._onDidChangeTreeData.event; private flagMap: Map = new Map(); diff --git a/src/providers/flagsView.ts b/src/providers/flagsView.ts index 3de939d2..70a2d2c9 100644 --- a/src/providers/flagsView.ts +++ b/src/providers/flagsView.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode'; -import { FeatureFlag, FlagConfiguration, FlagTreeInterface, ILDExtensionConfiguration, PatchComment } from '../models'; +import { FeatureFlag, FlagConfiguration, IFlagTree, ILDExtensionConfiguration, PatchComment } from '../models'; import { debounce, map } from 'lodash'; import checkExistingCommand from '../utils/common'; import { authentication } from 'vscode'; @@ -23,12 +23,12 @@ import { registerCommand } from '../utils/registerCommand'; const COLLAPSED = vscode.TreeItemCollapsibleState.Collapsed; const NON_COLLAPSED = vscode.TreeItemCollapsibleState.None; -export class LaunchDarklyTreeViewProvider implements vscode.TreeDataProvider { +export class LaunchDarklyTreeViewProvider implements vscode.TreeDataProvider { private readonly ldConfig: ILDExtensionConfiguration; - public flagNodes: Array | null; - private _onDidChangeTreeData: vscode.EventEmitter = - new vscode.EventEmitter(); - readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event; + public flagNodes: Array | null; + private _onDidChangeTreeData: vscode.EventEmitter = + new vscode.EventEmitter(); + readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event; private updatingTree: vscode.EventEmitter<'started' | 'error' | 'complete'> = new vscode.EventEmitter(); private lastTreeEvent: string; @@ -97,7 +97,7 @@ export class LaunchDarklyTreeViewProvider implements vscode.TreeDataProvider { + async getChildren(element?: IFlagTree): Promise { if (this.lastTreeEvent === 'started') { return Promise.resolve([ new FlagNode( @@ -305,7 +305,7 @@ export class LaunchDarklyTreeViewProvider implements vscode.TreeDataProvider { + private async flagPatch(node: IFlagTree, path: string, contextValue?: string): Promise { if (!node.flagKey) { return; } diff --git a/src/utils/constants.ts b/src/utils/constants.ts new file mode 100644 index 00000000..57abaec8 --- /dev/null +++ b/src/utils/constants.ts @@ -0,0 +1,2 @@ +export const CONST_CONFIG_LD = 'Configure LaunchDarkly Extension'; +export const CONST_LD_PREFIX = '[LaunchDarkly]'; diff --git a/test/providers.test.ts b/test/providers.test.ts index 166c174e..80903f88 100644 --- a/test/providers.test.ts +++ b/test/providers.test.ts @@ -8,7 +8,7 @@ const toMatchSnapshot = require('expect-mocha-snapshot'); expect.extend({ toMatchSnapshot }); import { generateHoverString } from '../src/utils/hover'; -import { FeatureFlag, FlagConfiguration, LaunchDarklyAuthenticationSession } from '../src/models'; +import { FeatureFlag, FlagConfiguration, ILaunchDarklyAuthenticationSession } from '../src/models'; import { isPrecedingCharStringDelimiter } from '../src/providers/completion'; import { LDExtensionConfiguration } from '../src/ldExtensionConfiguration'; import { Configuration } from '../src/configuration'; @@ -60,7 +60,7 @@ const flagConfig: FlagConfiguration = { const mockLDConfig = mock(LDExtensionConfiguration); const mockConfig = mock(Configuration); const mockCtx = mock(); -const mockSession = mock(); +const mockSession = mock(); const ctx = instance(mockCtx); const config = instance(mockConfig);