From e4f7c8e9dbad48305fe9a5297fb48bab91bde6a3 Mon Sep 17 00:00:00 2001 From: Meisam Seyed Aliroteh Date: Mon, 3 Jun 2024 14:41:13 -0700 Subject: [PATCH] refactor: rename FlagsConfigType enum values --- src/cli/commands/force/lightning/local/setup.ts | 8 ++++---- src/common/Common.ts | 16 ++++++++-------- test/unit/common/Common.test.ts | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/cli/commands/force/lightning/local/setup.ts b/src/cli/commands/force/lightning/local/setup.ts index 12ea29b..6f3be37 100644 --- a/src/cli/commands/force/lightning/local/setup.ts +++ b/src/cli/commands/force/lightning/local/setup.ts @@ -23,10 +23,10 @@ export class Setup extends BaseCommand { public static readonly examples = messages.getMessages('examples'); public static readonly flags = { - ...CommandLineUtils.createFlag(FlagsConfigType.Json, false), - ...CommandLineUtils.createFlag(FlagsConfigType.LogLevel, false), - ...CommandLineUtils.createFlag(FlagsConfigType.ApiLevel, false), - ...CommandLineUtils.createFlag(FlagsConfigType.PlatformType, true) + ...CommandLineUtils.createFlag(FlagsConfigType.JsonFlag, false), + ...CommandLineUtils.createFlag(FlagsConfigType.LogLevelFlag, false), + ...CommandLineUtils.createFlag(FlagsConfigType.ApiLevelFlag, false), + ...CommandLineUtils.createFlag(FlagsConfigType.PlatformFlag, true) }; protected _commandName = 'force:lightning:local:setup'; diff --git a/src/common/Common.ts b/src/common/Common.ts index 2f1c736..2fb1928 100644 --- a/src/common/Common.ts +++ b/src/common/Common.ts @@ -64,10 +64,10 @@ export enum Platform { } export enum FlagsConfigType { - PlatformType, - ApiLevel, - LogLevel, - Json + PlatformFlag, + ApiLevelFlag, + LogLevelFlag, + JsonFlag } export class CommandLineUtils { @@ -120,7 +120,7 @@ export class CommandLineUtils { public static createFlag(type: FlagsConfigType, isRequired: boolean, supportsDesktop = false): any { switch (type) { - case FlagsConfigType.ApiLevel: + case FlagsConfigType.ApiLevelFlag: return { apilevel: Flags.string({ char: 'l', @@ -129,7 +129,7 @@ export class CommandLineUtils { validate: CommandLineUtils.validateApiLevelFlag }) }; - case FlagsConfigType.PlatformType: + case FlagsConfigType.PlatformFlag: return { platform: Flags.option({ char: 'p', @@ -140,7 +140,7 @@ export class CommandLineUtils { : ([Platform.ios, Platform.android] as const) })({ required: isRequired }) }; - case FlagsConfigType.LogLevel: + case FlagsConfigType.LogLevelFlag: return { loglevel: Flags.string({ description: messages.getMessage('logLevelFlagDescription'), @@ -149,7 +149,7 @@ export class CommandLineUtils { validate: (level: string) => level && (LoggerLevel as any)[level.trim().toUpperCase()] }) }; - case FlagsConfigType.Json: + case FlagsConfigType.JsonFlag: return { json: Flags.boolean({ description: messages.getMessage('jsonFlagDescription'), diff --git a/test/unit/common/Common.test.ts b/test/unit/common/Common.test.ts index 6e3c84e..26c7a7b 100644 --- a/test/unit/common/Common.test.ts +++ b/test/unit/common/Common.test.ts @@ -128,7 +128,7 @@ describe('Commons utils tests', () => { }); it('Platform flag config property returns expected flag', async () => { - let platformFlagConfig = common.CommandLineUtils.createFlag(common.FlagsConfigType.PlatformType, true); + let platformFlagConfig = common.CommandLineUtils.createFlag(common.FlagsConfigType.PlatformFlag, true); expect(platformFlagConfig.platform?.description).to.be.equal(messages.getMessage('platformFlagDescription')); let requiredKeyValuePair = Object.entries(platformFlagConfig.platform).find( (keyValuePair) => keyValuePair[0] === 'required' @@ -136,7 +136,7 @@ describe('Commons utils tests', () => { expect(requiredKeyValuePair?.[1]).to.be.true; - platformFlagConfig = common.CommandLineUtils.createFlag(common.FlagsConfigType.PlatformType, false); + platformFlagConfig = common.CommandLineUtils.createFlag(common.FlagsConfigType.PlatformFlag, false); requiredKeyValuePair = Object.entries(platformFlagConfig.platform).find( (keyValuePair) => keyValuePair[0] === 'required' @@ -146,7 +146,7 @@ describe('Commons utils tests', () => { }); it('API level flag config property returns expected flag', async () => { - let apiLevelFlagConfig = common.CommandLineUtils.createFlag(common.FlagsConfigType.ApiLevel, true); + let apiLevelFlagConfig = common.CommandLineUtils.createFlag(common.FlagsConfigType.ApiLevelFlag, true); expect(apiLevelFlagConfig.apilevel?.description).to.be.equal(messages.getMessage('apiLevelFlagDescription')); let requiredKeyValuePair = Object.entries(apiLevelFlagConfig.apilevel).find( @@ -155,7 +155,7 @@ describe('Commons utils tests', () => { expect(requiredKeyValuePair?.[1]).to.be.true; - apiLevelFlagConfig = common.CommandLineUtils.createFlag(common.FlagsConfigType.ApiLevel, false); + apiLevelFlagConfig = common.CommandLineUtils.createFlag(common.FlagsConfigType.ApiLevelFlag, false); requiredKeyValuePair = Object.entries(apiLevelFlagConfig.apilevel).find( (keyValuePair) => keyValuePair[0] === 'required'