Skip to content

Commit

Permalink
refactor: rename FlagsConfigType enum values
Browse files Browse the repository at this point in the history
  • Loading branch information
maliroteh-sf committed Jun 3, 2024
1 parent dbea3db commit e4f7c8e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/cli/commands/force/lightning/local/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
16 changes: 8 additions & 8 deletions src/common/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ export enum Platform {
}

export enum FlagsConfigType {
PlatformType,
ApiLevel,
LogLevel,
Json
PlatformFlag,
ApiLevelFlag,
LogLevelFlag,
JsonFlag
}

export class CommandLineUtils {
Expand Down Expand Up @@ -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',
Expand All @@ -129,7 +129,7 @@ export class CommandLineUtils {
validate: CommandLineUtils.validateApiLevelFlag
})
};
case FlagsConfigType.PlatformType:
case FlagsConfigType.PlatformFlag:
return {
platform: Flags.option({
char: 'p',
Expand All @@ -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'),
Expand All @@ -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'),
Expand Down
8 changes: 4 additions & 4 deletions test/unit/common/Common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ 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'
);

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'
Expand All @@ -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(
Expand All @@ -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'
Expand Down

0 comments on commit e4f7c8e

Please sign in to comment.