Skip to content

Commit

Permalink
Remove all instances of loadAndValidateOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
kemmerle committed Dec 18, 2024
1 parent 273b804 commit ad5b50d
Show file tree
Hide file tree
Showing 54 changed files with 15 additions and 197 deletions.
2 changes: 0 additions & 2 deletions commands/account/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const {

const { trackCommandUsage } = require('../../lib/usageTracking');
const { i18n } = require('../../lib/lang');
const { loadAndValidateOptions } = require('../../lib/validation');
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
const { addTestingOptions, addConfigOptions } = require('../../lib/commonOpts');
const { promptUser } = require('../../lib/prompts/promptUtils');
Expand All @@ -29,7 +28,6 @@ exports.describe = i18n(`${i18nKey}.describe`);

exports.handler = async options => {
const { qa } = options;
await loadAndValidateOptions(options, false);

trackCommandUsage('accounts-clean', null);

Expand Down
3 changes: 0 additions & 3 deletions commands/account/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const { logger } = require('@hubspot/local-dev-lib/logger');
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
const { getAccessToken } = require('@hubspot/local-dev-lib/personalAccessKey');
const { addConfigOptions } = require('../../lib/commonOpts');
const { loadAndValidateOptions } = require('../../lib/validation');
const { i18n } = require('../../lib/lang');
const { getTableContents } = require('../../lib/ui/table');

Expand All @@ -13,8 +12,6 @@ exports.describe = i18n(`${i18nKey}.describe`);
exports.command = 'info [account]';

exports.handler = async options => {
await loadAndValidateOptions(options);

const { derivedAccountId } = options;
const config = getAccountConfig(derivedAccountId);
// check if the provided account is using a personal access key, if not, show an error
Expand Down
3 changes: 0 additions & 3 deletions commands/account/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const { addConfigOptions } = require('../../lib/commonOpts');
const { getTableContents, getTableHeader } = require('../../lib/ui/table');

const { trackCommandUsage } = require('../../lib/usageTracking');
const { loadAndValidateOptions } = require('../../lib/validation');
const { isSandbox, isDeveloperTestAccount } = require('../../lib/accountTypes');

const { i18n } = require('../../lib/lang');
Expand Down Expand Up @@ -81,8 +80,6 @@ const getPortalData = mappedPortalData => {
};

exports.handler = async options => {
await loadAndValidateOptions(options, false);

const { derivedAccountId } = options;

trackCommandUsage('accounts-list', null, derivedAccountId);
Expand Down
2 changes: 0 additions & 2 deletions commands/account/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ const {
const { trackCommandUsage } = require('../../lib/usageTracking');
const { i18n } = require('../../lib/lang');
const { selectAccountFromConfig } = require('../../lib/prompts/accountsPrompt');
const { loadAndValidateOptions } = require('../../lib/validation');

const i18nKey = 'commands.account.subcommands.remove';

exports.command = 'remove [account]';
exports.describe = i18n(`${i18nKey}.describe`);

exports.handler = async options => {
await loadAndValidateOptions(options, false);
const { account } = options;
let accountToRemove = account;

Expand Down
3 changes: 0 additions & 3 deletions commands/account/rename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const { renameAccount } = require('@hubspot/local-dev-lib/config');

const { addConfigOptions, addAccountOptions } = require('../../lib/commonOpts');
const { trackCommandUsage } = require('../../lib/usageTracking');
const { loadAndValidateOptions } = require('../../lib/validation');
const { i18n } = require('../../lib/lang');

const i18nKey = 'commands.account.subcommands.rename';
Expand All @@ -13,8 +12,6 @@ exports.command = 'rename <accountName> <newName>';
exports.describe = i18n(`${i18nKey}.describe`);

exports.handler = async options => {
loadAndValidateOptions(options);

const { accountName, newName, derivedAccountId } = options;

trackCommandUsage('accounts-rename', null, derivedAccountId);
Expand Down
3 changes: 0 additions & 3 deletions commands/account/use.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ const {
const { trackCommandUsage } = require('../../lib/usageTracking');
const { i18n } = require('../../lib/lang');
const { selectAccountFromConfig } = require('../../lib/prompts/accountsPrompt');
const { loadAndValidateOptions } = require('../../lib/validation');

const i18nKey = 'commands.account.subcommands.use';

exports.command = 'use [account]';
exports.describe = i18n(`${i18nKey}.describe`);

exports.handler = async options => {
await loadAndValidateOptions(options, false);

let newDefaultAccount = options.account;

if (!newDefaultAccount) {
Expand Down
2 changes: 0 additions & 2 deletions commands/cms/lighthouseScore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const {
} = require('../../lib/commonOpts');
const { logger } = require('@hubspot/local-dev-lib/logger');
const { getTableContents, getTableHeader } = require('../../lib/ui/table');
const { loadAndValidateOptions } = require('../../lib/validation');
const { promptUser } = require('../../lib/prompts/promptUtils');
const { i18n } = require('../../lib/lang');
const { fetchThemes } = require('@hubspot/local-dev-lib/api/designManager');
Expand Down Expand Up @@ -67,7 +66,6 @@ const selectTheme = async accountId => {
};

exports.handler = async options => {
await loadAndValidateOptions(options);
const { target, verbose, theme, derivedAccountId } = options;

const includeDesktopScore = target === 'desktop' || !verbose;
Expand Down
3 changes: 0 additions & 3 deletions commands/config/set.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-nocheck
const { loadAndValidateOptions } = require('../../lib/validation');
const { i18n } = require('../../lib/lang');
const { trackCommandUsage } = require('../../lib/usageTracking');
const { promptUser } = require('../../lib/prompts/promptUtils');
Expand Down Expand Up @@ -55,8 +54,6 @@ const handleConfigUpdate = async (accountId, options) => {
};

exports.handler = async options => {
await loadAndValidateOptions(options);

const { derivedAccountId } = options;

trackCommandUsage('config-set', null, derivedAccountId);
Expand Down
7 changes: 1 addition & 6 deletions commands/customObject/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import { inputPrompt } from '../../lib/prompts/promptUtils';
const { logger } = require('@hubspot/local-dev-lib/logger');
const { logError } = require('../../lib/errorHandlers/index');
const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
const {
checkAndConvertToJson,
loadAndValidateOptions,
} = require('../../lib/validation');
const { checkAndConvertToJson } = require('../../lib/validation');
const { trackCommandUsage } = require('../../lib/usageTracking');
const {
batchCreateObjects,
Expand All @@ -24,8 +21,6 @@ exports.handler = async options => {
const { path, name: providedName, derivedAccountId } = options;
let definitionPath = path;

await loadAndValidateOptions(options);

trackCommandUsage('custom-object-batch-create', null, derivedAccountId);

if (!definitionPath) {
Expand Down
7 changes: 1 addition & 6 deletions commands/customObject/schema/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
const { logger } = require('@hubspot/local-dev-lib/logger');
const { logError } = require('../../../lib/errorHandlers/index');
const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
const {
checkAndConvertToJson,
loadAndValidateOptions,
} = require('../../../lib/validation');
const { checkAndConvertToJson } = require('../../../lib/validation');
const { trackCommandUsage } = require('../../../lib/usageTracking');
const { addTestingOptions } = require('../../../lib/commonOpts');
const {
Expand Down Expand Up @@ -34,8 +31,6 @@ exports.describe = i18n(`${i18nKey}.describe`);
exports.handler = async options => {
const { path, derivedAccountId } = options;

await loadAndValidateOptions(options);

trackCommandUsage('custom-object-schema-create', null, derivedAccountId);

const filePath = getAbsoluteFilePath(path);
Expand Down
3 changes: 0 additions & 3 deletions commands/customObject/schema/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { confirmPrompt, listPrompt } from '../../../lib/prompts/promptUtils';
import { fetchObjectSchemas } from '@hubspot/local-dev-lib/api/customObjects';

const { logger } = require('@hubspot/local-dev-lib/logger');
const { loadAndValidateOptions } = require('../../../lib/validation');
const { trackCommandUsage } = require('../../../lib/usageTracking');
const {
deleteObjectSchema,
Expand All @@ -20,8 +19,6 @@ exports.describe = i18n(`${i18nKey}.describe`);
exports.handler = async options => {
const { name: providedName, force, derivedAccountId } = options;

await loadAndValidateOptions(options);

trackCommandUsage('custom-object-schema-delete', null, derivedAccountId);

let name;
Expand Down
3 changes: 0 additions & 3 deletions commands/customObject/schema/fetch-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { inputPrompt } from '../../../lib/prompts/promptUtils';

const { logger } = require('@hubspot/local-dev-lib/logger');
const { loadAndValidateOptions } = require('../../../lib/validation');
const { trackCommandUsage } = require('../../../lib/usageTracking');
const {
downloadSchemas,
Expand All @@ -18,8 +17,6 @@ exports.command = 'fetch-all [dest]';
exports.describe = i18n(`${i18nKey}.describe`);

exports.handler = async options => {
await loadAndValidateOptions(options);

const { derivedAccountId, dest: providedDest } = options;

trackCommandUsage('custom-object-schema-fetch-all', null, derivedAccountId);
Expand Down
3 changes: 0 additions & 3 deletions commands/customObject/schema/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const {
const { fetchSchema } = require('@hubspot/local-dev-lib/api/fileTransport');
const { getCwd } = require('@hubspot/local-dev-lib/path');

const { loadAndValidateOptions } = require('../../../lib/validation');
const { trackCommandUsage } = require('../../../lib/usageTracking');
const { i18n } = require('../../../lib/lang');
const { logError } = require('../../../lib/errorHandlers');
Expand All @@ -26,8 +25,6 @@ exports.describe = i18n(`${i18nKey}.describe`);
exports.handler = async options => {
const { name: providedName, dest: providedDest, derivedAccountId } = options;

await loadAndValidateOptions(options);

trackCommandUsage('custom-object-schema-fetch', null, derivedAccountId);
let name;

Expand Down
3 changes: 0 additions & 3 deletions commands/customObject/schema/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
const { logger } = require('@hubspot/local-dev-lib/logger');
const { logError } = require('../../../lib/errorHandlers/index');

const { loadAndValidateOptions } = require('../../../lib/validation');
const { trackCommandUsage } = require('../../../lib/usageTracking');
const { listSchemas } = require('../../../lib/schema');
const { i18n } = require('../../../lib/lang');
Expand All @@ -13,8 +12,6 @@ exports.command = 'list';
exports.describe = i18n(`${i18nKey}.describe`);

exports.handler = async options => {
await loadAndValidateOptions(options);

const { derivedAccountId } = options;

trackCommandUsage('custom-object-schema-list', null, derivedAccountId);
Expand Down
7 changes: 1 addition & 6 deletions commands/customObject/schema/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
const {
ENVIRONMENTS,
} = require('@hubspot/local-dev-lib/constants/environments');
const {
checkAndConvertToJson,
loadAndValidateOptions,
} = require('../../../lib/validation');
const { checkAndConvertToJson } = require('../../../lib/validation');
const { trackCommandUsage } = require('../../../lib/usageTracking');
const { addTestingOptions } = require('../../../lib/commonOpts');
const { CONFIG_FLAGS } = require('../../../lib/constants');
Expand All @@ -37,8 +34,6 @@ exports.describe = i18n(`${i18nKey}.describe`);
exports.handler = async options => {
const { path, name: providedName, derivedAccountId } = options;

await loadAndValidateOptions(options);

trackCommandUsage('custom-object-schema-update', null, derivedAccountId);

const filePath = getAbsoluteFilePath(path);
Expand Down
7 changes: 1 addition & 6 deletions commands/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ const {
addGlobalOptions,
} = require('../lib/commonOpts');
const { resolveLocalPath } = require('../lib/filesystem');
const {
validateCmsPublishMode,
loadAndValidateOptions,
} = require('../lib/validation');
const { validateCmsPublishMode } = require('../lib/validation');
const { trackCommandUsage } = require('../lib/usageTracking');
const { i18n } = require('../lib/lang');

Expand All @@ -28,8 +25,6 @@ exports.describe = i18n(`${i18nKey}.describe`);
exports.handler = async options => {
const { src, dest } = options;

await loadAndValidateOptions(options);

if (!validateCmsPublishMode(options)) {
process.exit(EXIT_CODES.ERROR);
}
Expand Down
3 changes: 0 additions & 3 deletions commands/filemanager/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const {
addGlobalOptions,
addUseEnvironmentOptions,
} = require('../../lib/commonOpts');
const { loadAndValidateOptions } = require('../../lib/validation');
const { trackCommandUsage } = require('../../lib/usageTracking');
const { i18n } = require('../../lib/lang');

Expand All @@ -23,8 +22,6 @@ exports.describe = i18n(`${i18nKey}.describe`);
exports.handler = async options => {
const { src, includeArchived, derivedAccountId, overwrite } = options;

await loadAndValidateOptions(options);

if (typeof src !== 'string') {
logger.error(i18n(`${i18nKey}.errors.sourceRequired`));
process.exit(EXIT_CODES.ERROR);
Expand Down
3 changes: 0 additions & 3 deletions commands/filemanager/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const {
addAccountOptions,
addUseEnvironmentOptions,
} = require('../../lib/commonOpts');
const { loadAndValidateOptions } = require('../../lib/validation');
const { trackCommandUsage } = require('../../lib/usageTracking');
const { i18n } = require('../../lib/lang');

Expand All @@ -31,8 +30,6 @@ exports.describe = i18n(`${i18nKey}.describe`);
exports.handler = async options => {
const { src, dest, derivedAccountId } = options;

await loadAndValidateOptions(options);

const absoluteSrcPath = path.resolve(getCwd(), src);

let stats;
Expand Down
3 changes: 0 additions & 3 deletions commands/function/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const {
buildPackage,
getBuildStatus,
} = require('@hubspot/local-dev-lib/api/functions');
const { loadAndValidateOptions } = require('../../lib/validation');
const { outputBuildLog } = require('../../lib/serverlessLogs');
const { i18n } = require('../../lib/lang');
const { isHubSpotHttpError } = require('@hubspot/local-dev-lib/errors/index');
Expand All @@ -25,8 +24,6 @@ exports.command = 'deploy <path>';
exports.describe = false;

exports.handler = async options => {
await loadAndValidateOptions(options);

const { path: functionPath, derivedAccountId } = options;
const splitFunctionPath = functionPath.split('.');

Expand Down
3 changes: 0 additions & 3 deletions commands/function/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const {
addUseEnvironmentOptions,
} = require('../../lib/commonOpts');
const { trackCommandUsage } = require('../../lib/usageTracking');
const { loadAndValidateOptions } = require('../../lib/validation');
const { i18n } = require('../../lib/lang');

const i18nKey = 'commands.function.subcommands.list';
Expand All @@ -20,8 +19,6 @@ exports.command = ['list', 'ls'];
exports.describe = i18n(`${i18nKey}.describe`);

exports.handler = async options => {
loadAndValidateOptions(options);

const { derivedAccountId } = options;

trackCommandUsage('functions-list', null, derivedAccountId);
Expand Down
3 changes: 0 additions & 3 deletions commands/function/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const {
const { trackCommandUsage } = require('../../lib/usageTracking');
const { logger } = require('@hubspot/local-dev-lib/logger');
const { start: startTestServer } = require('@hubspot/serverless-dev-runtime');
const { loadAndValidateOptions } = require('../../lib/validation');
const { i18n } = require('../../lib/lang');

const i18nKey = 'commands.function.subcommands.server';
Expand All @@ -16,8 +15,6 @@ exports.command = 'server <path>';
exports.describe = false;

exports.handler = async options => {
await loadAndValidateOptions(options);

const { path: functionPath, derivedAccountId } = options;

trackCommandUsage('functions-server', null, derivedAccountId);
Expand Down
3 changes: 0 additions & 3 deletions commands/hubdb/clear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const { publishTable } = require('@hubspot/local-dev-lib/api/hubdb');
const {
selectHubDBTablePrompt,
} = require('../../lib/prompts/selectHubDBTablePrompt');
const { loadAndValidateOptions } = require('../../lib/validation');
const { trackCommandUsage } = require('../../lib/usageTracking');
const {
addConfigOptions,
Expand All @@ -23,8 +22,6 @@ exports.describe = i18n(`${i18nKey}.describe`);
exports.handler = async options => {
const { derivedAccountId } = options;

await loadAndValidateOptions(options);

trackCommandUsage('hubdb-clear', null, derivedAccountId);

try {
Expand Down
Loading

0 comments on commit ad5b50d

Please sign in to comment.