Skip to content

chore: Inline i18n pt4 #1430

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

Open
wants to merge 1 commit into
base: jy/inline-i18n-pt3
Choose a base branch
from
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
21 changes: 10 additions & 11 deletions commands/sandbox/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ import {
} from '../../types/Yargs';
import { SandboxSyncTask } from '../../types/Sandboxes';

const i18nKey = 'commands.sandbox.subcommands.create';

export const command = 'create';
export const describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);
export const describe = uiBetaTag(i18n(`commands.sandbox.subcommands.create.describe`), false);

type CombinedArgs = ConfigArgs & AccountArgs & EnvironmentArgs & TestingArgs;
type SandboxCreateArgs = CommonArgs &
Expand All @@ -69,7 +68,7 @@ export async function handler(
// Check if account config exists
if (!accountConfig) {
logger.error(
i18n(`${i18nKey}.failure.noAccountConfig`, {
i18n(`commands.sandbox.subcommands.create.failure.noAccountConfig`, {
accountId: derivedAccountId,
authCommand: uiCommandReference('hs auth'),
})
Expand All @@ -83,7 +82,7 @@ export async function handler(
accountConfig.accountType !== HUBSPOT_ACCOUNT_TYPES.STANDARD
) {
logger.error(
i18n(`${i18nKey}.failure.invalidAccountType`, {
i18n(`commands.sandbox.subcommands.create.failure.invalidAccountType`, {
accountType:
HUBSPOT_ACCOUNT_TYPE_STRINGS[
HUBSPOT_ACCOUNT_TYPES[accountConfig.accountType]
Expand All @@ -101,7 +100,7 @@ export async function handler(
if (!force) {
typePrompt = await sandboxTypePrompt();
} else {
logger.error(i18n(`${i18nKey}.failure.optionMissing.type`));
logger.error(i18n(`commands.sandbox.subcommands.create.failure.optionMissing.type`));
process.exit(EXIT_CODES.ERROR);
}
}
Expand Down Expand Up @@ -138,7 +137,7 @@ export async function handler(
if (!force) {
namePrompt = await hubspotAccountNamePrompt({ accountType: sandboxType });
} else {
logger.error(i18n(`${i18nKey}.failure.optionMissing.name`));
logger.error(i18n(`commands.sandbox.subcommands.create.failure.optionMissing.name`));
process.exit(EXIT_CODES.ERROR);
}
}
Expand Down Expand Up @@ -175,7 +174,7 @@ export async function handler(
// Check if sandbox account config exists
if (!sandboxAccountConfig) {
logger.error(
i18n(`${i18nKey}.failure.noSandboxAccountConfig`, {
i18n(`commands.sandbox.subcommands.create.failure.noSandboxAccountConfig`, {
accountId: result.sandbox.sandboxHubId,
authCommand: uiCommandReference('hs auth'),
})
Expand Down Expand Up @@ -225,21 +224,21 @@ export function builder(yargs: Argv): Argv<SandboxCreateArgs> {
yargs.option('force', {
type: 'boolean',
alias: 'f',
describe: i18n(`${i18nKey}.options.force.describe`),
describe: i18n(`commands.sandbox.subcommands.create.options.force.describe`),
});
yargs.option('name', {
describe: i18n(`${i18nKey}.options.name.describe`),
describe: i18n(`commands.sandbox.subcommands.create.options.name.describe`),
type: 'string',
});
yargs.option('type', {
describe: i18n(`${i18nKey}.options.type.describe`),
describe: i18n(`commands.sandbox.subcommands.create.options.type.describe`),
choices: Object.keys(SANDBOX_TYPE_MAP),
});

yargs.example([
[
'$0 sandbox create --name=MySandboxAccount --type=STANDARD',
i18n(`${i18nKey}.examples.default`),
i18n(`commands.sandbox.subcommands.create.examples.default`),
],
]);

Expand Down
37 changes: 18 additions & 19 deletions commands/sandbox/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ import {
TestingArgs,
} from '../../types/Yargs';

const i18nKey = 'commands.sandbox.subcommands.delete';

export const command = 'delete';
export const describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);
export const describe = uiBetaTag(i18n(`commands.sandbox.subcommands.delete.describe`), false);

type CombinedArgs = ConfigArgs & AccountArgs & EnvironmentArgs & TestingArgs;
type SandboxDeleteArgs = CommonArgs &
Expand All @@ -62,13 +61,13 @@ export async function handler(
} else {
// Account is required, throw error if force flag is present and no account is specified
logger.log('');
logger.error(i18n(`${i18nKey}.failure.noAccount`));
logger.error(i18n(`commands.sandbox.subcommands.delete.failure.noAccount`));
process.exit(EXIT_CODES.ERROR);
}
if (!accountPrompt) {
logger.log('');
logger.error(
i18n(`${i18nKey}.failure.noSandboxAccounts`, {
i18n(`commands.sandbox.subcommands.delete.failure.noSandboxAccounts`, {
authCommand: uiCommandReference('hs auth'),
})
);
Expand All @@ -81,7 +80,7 @@ export async function handler(
);

if (!sandboxAccountId) {
logger.error(i18n(`${i18nKey}.failure.noSandboxAccountId`));
logger.error(i18n(`commands.sandbox.subcommands.delete.failure.noSandboxAccountId`));
process.exit(EXIT_CODES.ERROR);
}

Expand All @@ -102,7 +101,7 @@ export async function handler(
const parentAccountPrompt = await deleteSandboxPrompt(true);
if (!parentAccountPrompt) {
logger.error(
i18n(`${i18nKey}.failure.noParentAccount`, {
i18n(`commands.sandbox.subcommands.delete.failure.noParentAccount`, {
authCommand: uiCommandReference('hs auth'),
})
);
Expand All @@ -111,7 +110,7 @@ export async function handler(
parentAccountId = getAccountId(parentAccountPrompt.account);
} else {
logger.error(
i18n(`${i18nKey}.failure.noParentAccount`, {
i18n(`commands.sandbox.subcommands.delete.failure.noParentAccount`, {
authCommand: uiCommandReference('hs auth'),
})
);
Expand All @@ -128,7 +127,7 @@ export async function handler(
if (parentAccountId && !getAccountId(parentAccountId)) {
logger.log('');
logger.error(
i18n(`${i18nKey}.failure.noParentPortalAvailable`, {
i18n(`commands.sandbox.subcommands.delete.failure.noParentPortalAvailable`, {
parentAccountId,
url,
command,
Expand All @@ -139,14 +138,14 @@ export async function handler(
}

logger.debug(
i18n(`${i18nKey}.debug.deleting`, {
i18n(`commands.sandbox.subcommands.delete.debug.deleting`, {
account: uiAccountDescription(sandboxAccountId),
})
);

if (isDefaultAccount) {
logger.info(
i18n(`${i18nKey}.defaultAccountWarning`, {
i18n(`commands.sandbox.subcommands.delete.defaultAccountWarning`, {
account: uiAccountDescription(sandboxAccountId),
})
);
Expand All @@ -159,7 +158,7 @@ export async function handler(
{
name: 'confirmSandboxDeletePrompt',
type: 'confirm',
message: i18n(`${i18nKey}.confirm`, {
message: i18n(`commands.sandbox.subcommands.delete.confirm`, {
account: uiAccountDescription(sandboxAccountId),
}),
},
Expand All @@ -172,8 +171,8 @@ export async function handler(
await deleteSandbox(parentAccountId!, sandboxAccountId);

const deleteKey = isDefaultAccount
? `${i18nKey}.success.deleteDefault`
: `${i18nKey}.success.delete`;
? `commands.sandbox.subcommands.delete.success.deleteDefault`
: `commands.sandbox.subcommands.delete.success.delete`;
logger.log('');
logger.success(
i18n(deleteKey, {
Expand Down Expand Up @@ -201,7 +200,7 @@ export async function handler(
// This command uses the parent portal PAK to delete a sandbox, so we must specify which account needs a new key
logger.log('');
logger.error(
i18n(`${i18nKey}.failure.invalidKey`, {
i18n(`commands.sandbox.subcommands.delete.failure.invalidKey`, {
account: uiAccountDescription(parentAccountId),
authCommand: uiCommandReference('hs auth'),
})
Expand All @@ -215,7 +214,7 @@ export async function handler(
) {
logger.log('');
logger.error(
i18n(`${i18nKey}.failure.invalidUser`, {
i18n(`commands.sandbox.subcommands.delete.failure.invalidUser`, {
accountName: uiAccountDescription(sandboxAccountId),
parentAccountName: uiAccountDescription(parentAccountId),
})
Expand All @@ -230,7 +229,7 @@ export async function handler(
) {
logger.log('');
logger.warn(
i18n(`${i18nKey}.failure.objectNotFound`, {
i18n(`commands.sandbox.subcommands.delete.failure.objectNotFound`, {
account: uiAccountDescription(sandboxAccountId),
})
);
Expand All @@ -255,19 +254,19 @@ export async function handler(

export function builder(yargs: Argv): Argv<SandboxDeleteArgs> {
yargs.option('account', {
describe: i18n(`${i18nKey}.options.account.describe`),
describe: i18n(`commands.sandbox.subcommands.delete.options.account.describe`),
type: 'string',
});
yargs.option('force', {
type: 'boolean',
alias: 'f',
describe: i18n(`${i18nKey}.options.force.describe`),
describe: i18n(`commands.sandbox.subcommands.delete.options.force.describe`),
});

yargs.example([
[
'$0 sandbox delete --account=MySandboxAccount',
i18n(`${i18nKey}.examples.default`),
i18n(`commands.sandbox.subcommands.delete.examples.default`),
],
]);

Expand Down
11 changes: 5 additions & 6 deletions commands/secret/addSecret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import {
EnvironmentArgs,
} from '../../types/Yargs';

const i18nKey = 'commands.secret.subcommands.add';

export const command = 'add [name]';
export const describe = i18n(`${i18nKey}.describe`);
export const describe = i18n(`commands.secret.subcommands.add.describe`);

type CombinedArgs = ConfigArgs & AccountArgs & EnvironmentArgs;
type AddSecretArgs = CommonArgs & CombinedArgs & { name?: string };
Expand All @@ -52,7 +51,7 @@ export async function handler(

if (secrets.includes(secretName)) {
logger.error(
i18n(`${i18nKey}.errors.alreadyExists`, {
i18n(`commands.secret.subcommands.add.errors.alreadyExists`, {
secretName,
command: uiCommandReference('hs secret update'),
})
Expand All @@ -64,14 +63,14 @@ export async function handler(

await addSecret(derivedAccountId, secretName, secretValue);
logger.success(
i18n(`${i18nKey}.success.add`, {
i18n(`commands.secret.subcommands.add.success.add`, {
accountIdentifier: uiAccountDescription(derivedAccountId),
secretName,
})
);
} catch (err) {
logger.error(
i18n(`${i18nKey}.errors.add`, {
i18n(`commands.secret.subcommands.add.errors.add`, {
secretName: secretName || '',
})
);
Expand All @@ -91,7 +90,7 @@ export function builder(yargs: Argv): Argv<AddSecretArgs> {
addUseEnvironmentOptions(yargs);

yargs.positional('name', {
describe: i18n(`${i18nKey}.positionals.name.describe`),
describe: i18n(`commands.secret.subcommands.add.positionals.name.describe`),
type: 'string',
});

Expand Down
17 changes: 8 additions & 9 deletions commands/secret/deleteSecret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ import {
EnvironmentArgs,
} from '../../types/Yargs';

const i18nKey = 'commands.secret.subcommands.delete';

export const command = 'delete [name]';
export const describe = i18n(`${i18nKey}.describe`);
export const describe = i18n(`commands.secret.subcommands.delete.describe`);

type CombinedArgs = ConfigArgs & AccountArgs & EnvironmentArgs;
type DeleteSecretArgs = CommonArgs &
Expand All @@ -44,40 +43,40 @@ export async function handler(
} = await fetchSecrets(derivedAccountId);

if (secretName && !secrets.includes(secretName)) {
logger.error(i18n(`${i18nKey}.errors.noSecret`, { secretName }));
logger.error(i18n(`commands.secret.subcommands.delete.errors.noSecret`, { secretName }));
process.exit(EXIT_CODES.ERROR);
}

if (!secretName) {
const { secretToModify } = await secretListPrompt(
secrets,
i18n(`${i18nKey}.selectSecret`)
i18n(`commands.secret.subcommands.delete.selectSecret`)
);
secretName = secretToModify;
}

const confirmDelete =
force ||
(await confirmPrompt(i18n(`${i18nKey}.confirmDelete`, { secretName }), {
(await confirmPrompt(i18n(`commands.secret.subcommands.delete.confirmDelete`, { secretName }), {
defaultAnswer: false,
}));

if (!confirmDelete) {
logger.success(i18n(`${i18nKey}.deleteCanceled`));
logger.success(i18n(`commands.secret.subcommands.delete.deleteCanceled`));
process.exit(EXIT_CODES.SUCCESS);
}

await deleteSecret(derivedAccountId, secretName);
logger.success(
i18n(`${i18nKey}.success.delete`, {
i18n(`commands.secret.subcommands.delete.success.delete`, {
accountIdentifier: uiAccountDescription(derivedAccountId),
secretName,
})
);
} catch (err) {
if (secretName) {
logger.error(
i18n(`${i18nKey}.errors.delete`, {
i18n(`commands.secret.subcommands.delete.errors.delete`, {
secretName,
})
);
Expand All @@ -99,7 +98,7 @@ export function builder(yargs: Argv): Argv<DeleteSecretArgs> {

yargs
.positional('name', {
describe: i18n(`${i18nKey}.positionals.name.describe`),
describe: i18n(`commands.secret.subcommands.delete.positionals.name.describe`),
type: 'string',
})
.options('force', {
Expand Down
7 changes: 3 additions & 4 deletions commands/secret/listSecret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import {
EnvironmentArgs,
} from '../../types/Yargs';

const i18nKey = 'commands.secret.subcommands.list';

export const command = 'list';
export const describe = i18n(`${i18nKey}.describe`);
export const describe = i18n(`commands.secret.subcommands.list.describe`);

type CombinedArgs = ConfigArgs & AccountArgs & EnvironmentArgs;
type ListSecretArgs = CommonArgs & CombinedArgs;
Expand All @@ -36,14 +35,14 @@ export async function handler(
const {
data: { results },
} = await fetchSecrets(derivedAccountId);
const groupLabel = i18n(`${i18nKey}.groupLabel`, {
const groupLabel = i18n(`commands.secret.subcommands.list.groupLabel`, {
accountIdentifier: uiAccountDescription(derivedAccountId),
});
logger.group(groupLabel);
results.forEach(secret => logger.log(secret));
logger.groupEnd();
} catch (err) {
logger.error(i18n(`${i18nKey}.errors.list`));
logger.error(i18n(`commands.secret.subcommands.list.errors.list`));
logError(
err,
new ApiErrorContext({
Expand Down
Loading