Skip to content

chore: Inline the remaining files #1470

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

Merged
merged 3 commits into from
Apr 30, 2025
Merged
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
2 changes: 1 addition & 1 deletion commands/cms/lighthouseScore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const DEFAULT_TABLE_HEADER = [
];

exports.command = 'lighthouse-score [--theme]';
exports.describe = false; // i18n(`${i18nKey}.describe`);
exports.describe = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can unhide this command now. Maybe check with @brandenrodgers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last time this came up, the answer was to let the CMS team determine the future of the commands. I'm not sure where they landed on it


const selectTheme = async accountId => {
const { theme: selectedTheme } = await promptUser([
Expand Down
10 changes: 4 additions & 6 deletions lib/buildAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,11 @@ export async function buildDeveloperTestAccount(
env: Environment,
portalLimit: number
): Promise<number> {
const i18nKey = 'lib.developerTestAccount.create.loading';

const id = getAccountIdentifier(parentAccountConfig);
const parentAccountId = getAccountId(id);

if (!parentAccountId) {
throw new Error(i18n(`${i18nKey}.fail`));
throw new Error(i18n(`lib.developerTestAccount.create.loading.fail`));
}

SpinniesManager.init({
Expand All @@ -106,7 +104,7 @@ export async function buildDeveloperTestAccount(

logger.log('');
SpinniesManager.add('buildDeveloperTestAccount', {
text: i18n(`${i18nKey}.add`, {
text: i18n(`lib.developerTestAccount.create.loading.add`, {
accountName: testAccountName,
}),
});
Expand All @@ -124,7 +122,7 @@ export async function buildDeveloperTestAccount(
developerTestAccountPersonalAccessKey = data.personalAccessKey;

SpinniesManager.succeed('buildDeveloperTestAccount', {
text: i18n(`${i18nKey}.succeed`, {
text: i18n(`lib.developerTestAccount.create.loading.succeed`, {
accountName: testAccountName,
accountId: developerTestAccountId,
}),
Expand All @@ -133,7 +131,7 @@ export async function buildDeveloperTestAccount(
debugError(e);

SpinniesManager.fail('buildDeveloperTestAccount', {
text: i18n(`${i18nKey}.fail`, {
text: i18n(`lib.developerTestAccount.create.loading.fail`, {
accountName: testAccountName,
}),
});
Expand Down
16 changes: 7 additions & 9 deletions lib/commonOpts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ import { debugError } from './errorHandlers';
import { EXIT_CODES } from './enums/exitCodes';
import { uiCommandReference } from './ui';

const i18nKey = 'lib.commonOpts';

export function addGlobalOptions(yargs: Argv) {
yargs.version(false);
yargs.option('debug', {
alias: 'd',
default: false,
describe: i18n(`${i18nKey}.options.debug.describe`),
describe: i18n(`lib.commonOpts.options.debug.describe`),
type: 'boolean',
});
yargs.option('network-debug', {
Expand All @@ -42,23 +40,23 @@ export function addGlobalOptions(yargs: Argv) {
export function addAccountOptions(yargs: Argv): Argv {
return yargs.option('account', {
alias: 'a',
describe: i18n(`${i18nKey}.options.account.describe`),
describe: i18n(`lib.commonOpts.options.account.describe`),
type: 'string',
});
}

export function addConfigOptions(yargs: Argv): Argv<ConfigArgs> {
return yargs.option<keyof ConfigArgs, StringArgType>('config', {
alias: 'c',
describe: i18n(`${i18nKey}.options.config.describe`),
describe: i18n(`lib.commonOpts.options.config.describe`),
type: 'string',
});
}

export function addOverwriteOptions(yargs: Argv): Argv {
return yargs.option('overwrite', {
alias: 'o',
describe: i18n(`${i18nKey}.options.overwrite.describe`),
describe: i18n(`lib.commonOpts.options.overwrite.describe`),
type: 'boolean',
default: false,
});
Expand All @@ -73,7 +71,7 @@ export function addCmsPublishModeOptions(
return yargs.option('cms-publish-mode', {
alias: 'm',
describe: i18n(
`${i18nKey}.options.modes.describe.${
`lib.commonOpts.options.modes.describe.${
read ? 'read' : write ? 'write' : 'default'
}`,
{ modes: cmsPublishModes }
Expand All @@ -84,7 +82,7 @@ export function addCmsPublishModeOptions(

export function addTestingOptions(yargs: Argv): Argv {
return yargs.option('qa', {
describe: i18n(`${i18nKey}.options.qa.describe`),
describe: i18n(`lib.commonOpts.options.qa.describe`),
type: 'boolean',
default: false,
hidden: true,
Expand All @@ -93,7 +91,7 @@ export function addTestingOptions(yargs: Argv): Argv {

export function addUseEnvironmentOptions(yargs: Argv): Argv {
yargs.option('use-env', {
describe: i18n(`${i18nKey}.options.useEnv.describe`),
describe: i18n(`lib.commonOpts.options.useEnv.describe`),
type: 'boolean',
});
yargs.conflicts('use-env', 'account');
Expand Down
32 changes: 21 additions & 11 deletions lib/configOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,26 @@ import { trackCommandUsage } from './usageTracking';
import { promptUser } from './prompts/promptUtils';
import { i18n } from '../lib/lang';

const i18nKey = 'commands.config.subcommands.set.options';

async function enableOrDisableUsageTracking(): Promise<boolean> {
const { isEnabled } = await promptUser<{ isEnabled: boolean }>([
{
type: 'list',
name: 'isEnabled',
pageSize: 20,
message: i18n(`${i18nKey}.allowUsageTracking.promptMessage`),
message: i18n(
`commands.config.subcommands.set.options.allowUsageTracking.promptMessage`
),
choices: [
{
name: i18n(`${i18nKey}.allowUsageTracking.labels.enabled`),
name: i18n(
`commands.config.subcommands.set.options.allowUsageTracking.labels.enabled`
),
value: true,
},
{
name: i18n(`${i18nKey}.allowUsageTracking.labels.disabled`),
name: i18n(
`commands.config.subcommands.set.options.allowUsageTracking.labels.disabled`
),
value: false,
},
],
Expand Down Expand Up @@ -57,7 +61,7 @@ export async function setAllowUsageTracking({
updateAllowUsageTracking(isEnabled);

logger.success(
i18n(`${i18nKey}.allowUsageTracking.success`, {
i18n(`commands.config.subcommands.set.options.allowUsageTracking.success`, {
isEnabled: isEnabled.toString(),
})
);
Expand All @@ -73,7 +77,9 @@ async function selectCmsPublishMode(): Promise<CmsPublishMode> {
type: 'list',
name: 'cmsPublishMode',
pageSize: 20,
message: i18n(`${i18nKey}.defaultMode.promptMessage`),
message: i18n(
`commands.config.subcommands.set.options.defaultMode.promptMessage`
),
choices: ALL_CMS_PUBLISH_MODES,
default: CMS_PUBLISH_MODE.publish,
},
Expand Down Expand Up @@ -102,7 +108,7 @@ export async function setDefaultCmsPublishMode({
newDefault = defaultCmsPublishMode;
} else {
logger.error(
i18n(`${i18nKey}.defaultMode.error`, {
i18n(`commands.config.subcommands.set.options.defaultMode.error`, {
validModes: commaSeparatedValues(ALL_CMS_PUBLISH_MODES),
})
);
Expand All @@ -112,7 +118,7 @@ export async function setDefaultCmsPublishMode({
updateDefaultCmsPublishMode(newDefault);

logger.success(
i18n(`${i18nKey}.defaultMode.success`, {
i18n(`commands.config.subcommands.set.options.defaultMode.success`, {
mode: newDefault,
})
);
Expand All @@ -122,7 +128,9 @@ async function enterTimeout(): Promise<string> {
const { timeout } = await promptUser<{ timeout: string }>([
{
name: 'timeout',
message: i18n(`${i18nKey}.httpTimeout.promptMessage`),
message: i18n(
`commands.config.subcommands.set.options.httpTimeout.promptMessage`
),
type: 'input',
default: 30000,
},
Expand Down Expand Up @@ -151,6 +159,8 @@ export async function setHttpTimeout({
updateHttpTimeout(newHttpTimeout);

logger.success(
i18n(`${i18nKey}.httpTimeout.success`, { timeout: newHttpTimeout })
i18n(`commands.config.subcommands.set.options.httpTimeout.success`, {
timeout: newHttpTimeout,
})
);
}
22 changes: 10 additions & 12 deletions lib/doctor/Diagnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ interface DiagnosisCategories {
defaultAccountOverrideFile: DiagnosisCategory;
}

const i18nKey = `lib.doctor.diagnosis`;

export class Diagnosis {
private readonly prefixes: prefixes;
private readonly diagnosis: DiagnosisCategories;
Expand All @@ -53,24 +51,24 @@ export class Diagnosis {

this.diagnosis = {
cli: {
header: i18n(`${i18nKey}.cli.header`),
header: i18n(`lib.doctor.diagnosis.cli.header`),
sections: [],
},
cliConfig: {
header: i18n(`${i18nKey}.cliConfig.header`),
header: i18n(`lib.doctor.diagnosis.cliConfig.header`),
sections: [],
},
defaultAccountOverrideFile: {
header: i18n(`${i18nKey}.defaultAccountOverrideFile.header`),
header: i18n(`lib.doctor.diagnosis.defaultAccountOverrideFile.header`),
sections: [],
},
project: {
header: i18n(`${i18nKey}.projectConfig.header`),
header: i18n(`lib.doctor.diagnosis.projectConfig.header`),
subheaders: [
i18n(`${i18nKey}.projectConfig.projectDirSubHeader`, {
i18n(`lib.doctor.diagnosis.projectConfig.projectDirSubHeader`, {
projectDir: diagnosticInfo.project?.config?.projectDir,
}),
i18n(`${i18nKey}.projectConfig.projectNameSubHeader`, {
i18n(`lib.doctor.diagnosis.projectConfig.projectNameSubHeader`, {
projectName: diagnosticInfo.project?.config?.projectConfig?.name,
}),
],
Expand All @@ -80,10 +78,10 @@ export class Diagnosis {

if (diagnosticInfo.config) {
this.diagnosis.cliConfig.subheaders = [
i18n(`${i18nKey}.cliConfig.configFileSubHeader`, {
i18n(`lib.doctor.diagnosis.cliConfig.configFileSubHeader`, {
filename: diagnosticInfo.config,
}),
i18n(`${i18nKey}.cliConfig.defaultAccountSubHeader`, {
i18n(`lib.doctor.diagnosis.cliConfig.defaultAccountSubHeader`, {
accountDetails: uiAccountDescription(accountId!),
}),
];
Expand Down Expand Up @@ -129,12 +127,12 @@ export class Diagnosis {

output.push('');
output.push(
i18n(`${i18nKey}.counts.errors`, {
i18n(`lib.doctor.diagnosis.counts.errors`, {
count: this.errorCount,
})
);
output.push(
i18n(`${i18nKey}.counts.warnings`, {
i18n(`lib.doctor.diagnosis.counts.warnings`, {
count: this.warningCount,
})
);
Expand Down
Loading