Skip to content

Commit

Permalink
Remove duplicate mode constant, add default mode export
Browse files Browse the repository at this point in the history
  • Loading branch information
camden11 committed Oct 12, 2023
1 parent 9a40a29 commit 695deae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
12 changes: 6 additions & 6 deletions config/CLIConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
import { commaSeparatedValues } from '../lib/text';
import { ENVIRONMENTS } from '../constants/environments';
import { API_KEY_AUTH_METHOD } from '../constants/auth';
import { DEFAULT_MODES, MIN_HTTP_TIMEOUT } from '../constants/config';
import { MIN_HTTP_TIMEOUT } from '../constants/config';
import { MODE } from '../constants/files';
import { CLIConfig_NEW, Environment } from '../types/Config';
import {
CLIAccount_NEW,
Expand Down Expand Up @@ -352,9 +353,8 @@ class CLIConfiguration {
const updatedEnv = getValidEnv(
env || (currentAccountConfig && currentAccountConfig.env)
);
const updatedDefaultMode: ValueOf<typeof DEFAULT_MODES> | undefined =
defaultMode &&
(defaultMode.toLowerCase() as ValueOf<typeof DEFAULT_MODES>);
const updatedDefaultMode: ValueOf<typeof MODE> | undefined =
defaultMode && (defaultMode.toLowerCase() as ValueOf<typeof MODE>);

safelyApplyUpdates('name', name);
safelyApplyUpdates('env', updatedEnv);
Expand All @@ -366,7 +366,7 @@ class CLIConfiguration {
}
if (typeof updatedDefaultMode !== 'undefined') {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
safelyApplyUpdates('defaultMode', DEFAULT_MODES[updatedDefaultMode]);
safelyApplyUpdates('defaultMode', MODE[updatedDefaultMode]);
}
safelyApplyUpdates('personalAccessKey', personalAccessKey);
safelyApplyUpdates('sandboxAccountType', sandboxAccountType);
Expand Down Expand Up @@ -480,7 +480,7 @@ class CLIConfiguration {
if (!this.config) {
throwErrorWithMessage(`${i18nKey}.noConfigLoaded`);
}
const ALL_MODES = Object.values(DEFAULT_MODES);
const ALL_MODES = Object.values(MODE);
if (!defaultMode || !ALL_MODES.find(m => m === defaultMode)) {
throwErrorWithMessage(`${i18nKey}.updateDefaultMode`, {
defaultMode,
Expand Down
5 changes: 0 additions & 5 deletions constants/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,4 @@ export const DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = 'hubspot.config.yml';
export const HUBSPOT_CONFIGURATION_FOLDER = '.hubspot';
export const HUBSPOT_CONFIGURATION_FILE = 'config.yml';

export const DEFAULT_MODES = {
draft: 'draft',
publish: 'publish',
} as const;

export const MIN_HTTP_TIMEOUT = 3000;
2 changes: 2 additions & 0 deletions constants/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const MODE = {
publish: 'publish',
} as const;

export const DEFAULT_MODE = MODE.publish;

export const FILE_UPLOAD_RESULT_TYPES = {
SUCCESS: 'SUCCESS',
FAILURE: 'FAILURE',
Expand Down

0 comments on commit 695deae

Please sign in to comment.