Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove global --version flag + remove --debug option from hs help #1262

Merged
merged 13 commits into from
Nov 25, 2024
6 changes: 0 additions & 6 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,6 @@ const argv = yargs
])
.exitProcess(false)
.fail(handleFailure)
.option('debug', {
alias: 'd',
default: false,
describe: 'Set log level to debug',
type: 'boolean',
})
.option('noHyperlinks', {
default: false,
describe: 'prevent hyperlinks from displaying in the ui',
Expand Down
2 changes: 1 addition & 1 deletion commands/__tests__/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('commands/create', () => {
it('should support the correct options', () => {
createCommand.builder(yargs);

expect(yargs.option).toHaveBeenCalledTimes(1);
expect(yargs.option).toHaveBeenCalledTimes(2);
expect(yargs.option).toHaveBeenCalledWith(
'internal',
expect.objectContaining({ type: 'boolean', hidden: true })
Expand Down
3 changes: 2 additions & 1 deletion commands/__tests__/doctor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('doctor', () => {

mockYargs = {
option: jest.fn(() => mockYargs),
version: jest.fn(() => mockYargs),
};
});

Expand All @@ -60,7 +61,7 @@ describe('doctor', () => {
describe('builder', () => {
it('should apply the correct options', () => {
builder(mockYargs);
expect(mockYargs.option).toHaveBeenCalledTimes(1);
expect(mockYargs.option).toHaveBeenCalledTimes(2);
expect(mockYargs.option).toHaveBeenCalledWith('output-dir', {
describe: 'Directory to save a detailed diagnosis JSON file in',
type: 'string',
Expand Down
3 changes: 3 additions & 0 deletions commands/accounts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @ts-nocheck
const { addGlobalOptions } = require('../lib/commonOpts');
const { i18n } = require('../lib/lang');
const list = require('./accounts/list');
const rename = require('./accounts/rename');
Expand All @@ -13,6 +14,8 @@ exports.command = ['account', 'accounts'];
exports.describe = i18n(`${i18nKey}.describe`);

exports.builder = yargs => {
addGlobalOptions(yargs);

yargs
.command(list)
.command(rename)
Expand Down
2 changes: 2 additions & 0 deletions commands/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const {
setLogLevel,
getAccountId,
addTestingOptions,
addGlobalOptions,
} = require('../lib/commonOpts');
const { trackAuthAction, trackCommandUsage } = require('../lib/usageTracking');
const { authenticateWithOauth } = require('../lib/oauth');
Expand Down Expand Up @@ -231,6 +232,7 @@ exports.builder = yargs => {

addConfigOptions(yargs);
addTestingOptions(yargs);
addGlobalOptions(yargs);

return yargs;
};
7 changes: 6 additions & 1 deletion commands/cms.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// @ts-nocheck
const { i18n } = require('../lib/lang');
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
const {
addConfigOptions,
addAccountOptions,
addGlobalOptions,
} = require('../lib/commonOpts');
const lighthouseScore = require('./cms/lighthouseScore');
const convertFields = require('./cms/convertFields');
const reactModules = require('./cms/reactModules');
Expand All @@ -13,6 +17,7 @@ exports.describe = i18n(`${i18nKey}.describe`);
exports.builder = yargs => {
addConfigOptions(yargs);
addAccountOptions(yargs);
addGlobalOptions(yargs);

yargs
.command(lighthouseScore)
Expand Down
5 changes: 3 additions & 2 deletions commands/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @ts-nocheck
const { addConfigOptions } = require('../lib/commonOpts');

const { addConfigOptions, addGlobalOptions } = require('../lib/commonOpts');
const { i18n } = require('../lib/lang');
const set = require('./config/set');

Expand All @@ -11,6 +10,8 @@ exports.describe = i18n(`${i18nKey}.describe`);

exports.builder = yargs => {
addConfigOptions(yargs);
addGlobalOptions(yargs);

yargs.command(set).demandCommand(1, '');

return yargs;
Expand Down
4 changes: 3 additions & 1 deletion commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
const fs = require('fs-extra');
const { logError } = require('../lib/errorHandlers/index');
const { logger } = require('@hubspot/local-dev-lib/logger');
const { setLogLevel } = require('../lib/commonOpts');
const { setLogLevel, addGlobalOptions } = require('../lib/commonOpts');
const { resolveLocalPath } = require('../lib/filesystem');
const { trackCommandUsage } = require('../lib/usageTracking');
const assets = require('./create/index');
Expand Down Expand Up @@ -117,5 +117,7 @@ exports.builder = yargs => {
hidden: true,
});

addGlobalOptions(yargs);

return yargs;
};
7 changes: 6 additions & 1 deletion commands/customObject.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// @ts-nocheck
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
const {
addConfigOptions,
addAccountOptions,
addGlobalOptions,
} = require('../lib/commonOpts');
const schemaCommand = require('./customObject/schema');
const createCommand = require('./customObject/create');
const { i18n } = require('../lib/lang');
Expand All @@ -25,6 +29,7 @@ const logBetaMessage = () => {
exports.builder = yargs => {
addConfigOptions(yargs);
addAccountOptions(yargs);
addGlobalOptions(yargs);

yargs
.middleware([logBetaMessage])
Expand Down
2 changes: 2 additions & 0 deletions commands/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { EXIT_CODES } from '../lib/enums/exitCodes';
import path from 'path';
import { ArgumentsCamelCase, BuilderCallback, Options } from 'yargs';
import { getCwd } from '@hubspot/local-dev-lib/path';
import { addGlobalOptions } from '../lib/commonOpts';
const { i18n } = require('../lib/lang');

export interface DoctorOptions {
Expand Down Expand Up @@ -78,4 +79,5 @@ export const builder: BuilderCallback<DoctorOptions, DoctorOptions> = yargs => {
describe: i18n(`${i18nKey}.options.outputDir`),
type: 'string',
});
addGlobalOptions(yargs);
};
3 changes: 3 additions & 0 deletions commands/feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const open = require('open');
const { i18n } = require('../lib/lang');
const { logger } = require('@hubspot/local-dev-lib/logger');
const { confirmPrompt, listPrompt } = require('../lib/prompts/promptUtils');
const { addGlobalOptions } = require('../lib/commonOpts');

const i18nKey = 'commands.project.subcommands.feedback';

Expand Down Expand Up @@ -54,4 +55,6 @@ exports.builder = yargs => {
type: 'boolean',
},
});

addGlobalOptions(yargs);
};
14 changes: 8 additions & 6 deletions commands/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
addOverwriteOptions,
addModeOptions,
addUseEnvironmentOptions,
addGlobalOptions,
getMode,
} = require('../lib/commonOpts');
const { resolveLocalPath } = require('../lib/filesystem');
Expand Down Expand Up @@ -56,12 +57,6 @@ exports.handler = async options => {
};

exports.builder = yargs => {
addConfigOptions(yargs);
addAccountOptions(yargs);
addOverwriteOptions(yargs);
addModeOptions(yargs, { read: true });
addUseEnvironmentOptions(yargs);

yargs.positional('src', {
describe: i18n(`${i18nKey}.positionals.src.describe`),
type: 'string',
Expand All @@ -88,5 +83,12 @@ exports.builder = yargs => {
},
});

addConfigOptions(yargs);
addAccountOptions(yargs);
addOverwriteOptions(yargs);
addModeOptions(yargs, { read: true });
addUseEnvironmentOptions(yargs);
addGlobalOptions(yargs);

return yargs;
};
2 changes: 2 additions & 0 deletions commands/filemanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const {
addConfigOptions,
addAccountOptions,
addOverwriteOptions,
addGlobalOptions,
} = require('../lib/commonOpts');
const upload = require('./filemanager/upload');
const fetch = require('./filemanager/fetch');
Expand All @@ -17,6 +18,7 @@ exports.builder = yargs => {
addOverwriteOptions(yargs);
addConfigOptions(yargs);
addAccountOptions(yargs);
addGlobalOptions(yargs);

yargs
.command(upload)
Expand Down
2 changes: 2 additions & 0 deletions commands/function.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @ts-nocheck
const { addGlobalOptions } = require('../lib/commonOpts');
const list = require('./function/list');
const deploy = require('./function/deploy');
const server = require('./function/server');
Expand All @@ -10,6 +11,7 @@ exports.command = ['function', 'functions'];
exports.describe = i18n(`${i18nKey}.describe`);

exports.builder = yargs => {
addGlobalOptions(yargs);
yargs
.command(list)
.command(deploy)
Expand Down
7 changes: 6 additions & 1 deletion commands/hubdb.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// @ts-nocheck
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
const {
addConfigOptions,
addAccountOptions,
addGlobalOptions,
} = require('../lib/commonOpts');
const createCommand = require('./hubdb/create');
const fetchCommand = require('./hubdb/fetch');
const deleteCommand = require('./hubdb/delete');
Expand All @@ -14,6 +18,7 @@ exports.describe = i18n(`${i18nKey}.describe`);
exports.builder = yargs => {
addConfigOptions(yargs);
addAccountOptions(yargs);
addGlobalOptions(yargs);

yargs
.command(clearCommand)
Expand Down
3 changes: 2 additions & 1 deletion commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {
loadConfig,
configFileExists,
} = require('@hubspot/local-dev-lib/config');
const { addConfigOptions } = require('../lib/commonOpts');
const { addConfigOptions, addGlobalOptions } = require('../lib/commonOpts');
const { handleExit } = require('../lib/process');
const {
checkAndAddConfigToGitignore,
Expand Down Expand Up @@ -240,6 +240,7 @@ exports.builder = yargs => {

addConfigOptions(yargs);
addTestingOptions(yargs);
addGlobalOptions(yargs);

return yargs;
};
7 changes: 6 additions & 1 deletion commands/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
Validation,
} from '@hubspot/local-dev-lib/types/HublValidation';
const { logError } = require('../lib/errorHandlers/index');
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
const {
addConfigOptions,
addAccountOptions,
addGlobalOptions,
} = require('../lib/commonOpts');
const { resolveLocalPath } = require('../lib/filesystem');
const { trackCommandUsage } = require('../lib/usageTracking');
const { loadAndValidateOptions } = require('../lib/validation');
Expand Down Expand Up @@ -92,6 +96,7 @@ export const handler = async options => {
export const builder = yargs => {
addConfigOptions(yargs);
addAccountOptions(yargs);
addGlobalOptions(yargs);
yargs.positional('path', {
describe: i18n(`${i18nKey}.positionals.path.describe`),
type: 'string',
Expand Down
2 changes: 2 additions & 0 deletions commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const chalk = require('chalk');
const {
addAccountOptions,
addConfigOptions,
addGlobalOptions,
addUseEnvironmentOptions,
} = require('../lib/commonOpts');
const { trackCommandUsage } = require('../lib/usageTracking');
Expand Down Expand Up @@ -90,6 +91,7 @@ exports.builder = yargs => {
addConfigOptions(yargs);
addAccountOptions(yargs);
addUseEnvironmentOptions(yargs);
addGlobalOptions(yargs);

return yargs;
};
Expand Down
2 changes: 2 additions & 0 deletions commands/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const {
addAccountOptions,
addConfigOptions,
addUseEnvironmentOptions,
addGlobalOptions,
} = require('../lib/commonOpts');
const { trackCommandUsage } = require('../lib/usageTracking');
const { logger } = require('@hubspot/local-dev-lib/logger');
Expand Down Expand Up @@ -155,6 +156,7 @@ exports.builder = yargs => {
addConfigOptions(yargs);
addAccountOptions(yargs);
addUseEnvironmentOptions(yargs);
addGlobalOptions(yargs);

return yargs;
};
7 changes: 6 additions & 1 deletion commands/module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// @ts-nocheck
const marketplaceValidate = require('./module/marketplace-validate');
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
const {
addConfigOptions,
addAccountOptions,
addGlobalOptions,
} = require('../lib/commonOpts');
// const { i18n } = require('../lib/lang');

// const i18nKey = 'commands.module';
Expand All @@ -11,6 +15,7 @@ exports.describe = false; //i18n(`${i18nKey}.describe`);
exports.builder = yargs => {
addConfigOptions(yargs);
addAccountOptions(yargs);
addGlobalOptions(yargs);

yargs.command(marketplaceValidate).demandCommand(1, '');

Expand Down
9 changes: 6 additions & 3 deletions commands/mv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
addConfigOptions,
addAccountOptions,
addUseEnvironmentOptions,
addGlobalOptions,
} = require('../lib/commonOpts');
const { trackCommandUsage } = require('../lib/usageTracking');
const { isPathFolder } = require('../lib/filesystem');
Expand Down Expand Up @@ -77,9 +78,6 @@ exports.handler = async options => {
};

exports.builder = yargs => {
addConfigOptions(yargs);
addAccountOptions(yargs);
addUseEnvironmentOptions(yargs);
yargs.positional('srcPath', {
describe: 'Remote hubspot path',
type: 'string',
Expand All @@ -88,5 +86,10 @@ exports.builder = yargs => {
describe: 'Remote hubspot path',
type: 'string',
});

addConfigOptions(yargs);
addAccountOptions(yargs);
addUseEnvironmentOptions(yargs);
addGlobalOptions(yargs);
return yargs;
};
2 changes: 2 additions & 0 deletions commands/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
addAccountOptions,
addConfigOptions,
addUseEnvironmentOptions,
addGlobalOptions,
} = require('../lib/commonOpts');
const { trackCommandUsage } = require('../lib/usageTracking');
const { logSiteLinks, getSiteLinksAsArray, openLink } = require('../lib/links');
Expand Down Expand Up @@ -70,6 +71,7 @@ exports.builder = yargs => {
addConfigOptions(yargs);
addAccountOptions(yargs);
addUseEnvironmentOptions(yargs);
addGlobalOptions(yargs);

return yargs;
};
Loading