Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions commands/cms/__tests__/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ describe('commands/cms/fetch', () => {
});
expect(optionsSpy).toHaveBeenCalledWith({
assetVersion: expect.objectContaining({ type: 'number' }),
quiet: expect.objectContaining({
type: 'boolean',
default: false,
}),
});

expect(addConfigOptions).toHaveBeenCalledTimes(1);
Expand Down
24 changes: 24 additions & 0 deletions commands/cms/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
addOverwriteOptions,
getCmsPublishMode,
} from '../../lib/commonOpts.js';
import { LOG_LEVEL, setLogLevel } from '@hubspot/local-dev-lib/logger';
import { resolveLocalPath } from '../../lib/filesystem.js';
import { validateCmsPublishMode } from '../../lib/validation.js';
import { trackCommandUsage } from '../../lib/usageTracking.js';
Expand All @@ -30,6 +31,7 @@ export type FetchCommandArgs = {
staging?: boolean;
assetVersion?: number;
overwrite?: boolean;
quiet?: boolean;
} & ConfigArgs &
AccountArgs &
EnvironmentArgs &
Expand All @@ -54,6 +56,14 @@ async function handler(

const { derivedAccountId } = options;
const cmsPublishMode = getCmsPublishMode(options);
const shouldQuiet = options.quiet;
const shouldDebug =
Boolean((options as { debug?: boolean }).debug) ||
Boolean((options as { networkDebug?: boolean }).networkDebug);
const logLevelToRestore = shouldDebug ? LOG_LEVEL.DEBUG : LOG_LEVEL.LOG;
if (shouldQuiet) {
setLogLevel(LOG_LEVEL.ERROR);
}

trackCommandUsage('fetch', { mode: cmsPublishMode }, derivedAccountId);

Expand All @@ -72,6 +82,15 @@ async function handler(
overwrite,
}
);
if (shouldQuiet) {
setLogLevel(logLevelToRestore);
uiLogger.success(
commands.cms.subcommands.fetch.success.completed(
src,
resolveLocalPath(dest)
)
);
}
} catch (err) {
logError(err);
process.exit(EXIT_CODES.ERROR);
Expand Down Expand Up @@ -103,6 +122,11 @@ const fetchBuilder = (yargs: Argv): Argv<FetchCommandArgs> => {
type: 'number',
describe: commands.cms.subcommands.fetch.options.assetVersion.describe,
},
quiet: {
type: 'boolean',
describe: commands.cms.subcommands.fetch.options.quiet.describe,
default: false,
},
});

addCmsPublishModeOptions(yargs, { read: true });
Expand Down
5 changes: 5 additions & 0 deletions commands/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ function deprecatedCmsFetchBuilder(yargs: Argv): Argv<FetchCommandArgs> {
type: 'number',
describe: commands.cms.subcommands.fetch.options.assetVersion.describe,
},
quiet: {
type: 'boolean',
describe: commands.cms.subcommands.fetch.options.quiet.describe,
default: false,
},
});

addCmsPublishModeOptions(yargs, { read: true });
Expand Down
7 changes: 7 additions & 0 deletions lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,20 @@ export const commands = {
errors: {
sourceRequired: 'A source to fetch is required.',
},
success: {
completed: (src: string, dest: string) =>
`Completed fetch of "${src}" to "${dest}" from the Design Manager`,
},
options: {
staging: {
describe: 'Retrieve staged changes for project',
},
assetVersion: {
describe: 'Specify what version of a default asset to fetch',
},
quiet: {
describe: 'reduce fetch output to errors only',
},
},
positionals: {
dest: {
Expand Down