Skip to content

chore: inline i18nkeys part 3 #1429

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 5 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 5 additions & 7 deletions commands/hubdb/clear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ import {
EnvironmentArgs,
} from '../../types/Yargs';

const i18nKey = 'commands.hubdb.subcommands.clear';

export const command = 'clear [table-id]';
export const describe = i18n(`${i18nKey}.describe`);
export const describe = i18n('commands.hubdb.subcommands.clear.describe');

type CombinedArgs = ConfigArgs & AccountArgs & EnvironmentArgs;
type HubdbClearArgs = CommonArgs &
Expand All @@ -48,7 +46,7 @@ export async function handler(
);
if (deletedRowCount > 0) {
logger.log(
i18n(`${i18nKey}.logs.removedRows`, {
i18n('commands.hubdb.subcommands.clear.logs.removedRows', {
deletedRowCount,
tableId,
})
Expand All @@ -57,14 +55,14 @@ export async function handler(
data: { rowCount },
} = await publishTable(derivedAccountId, tableId);
logger.log(
i18n(`${i18nKey}.logs.rowCount`, {
i18n('commands.hubdb.subcommands.clear.logs.rowCount', {
rowCount,
tableId,
})
);
} else {
logger.log(
i18n(`${i18nKey}.logs.emptyTable`, {
i18n('commands.hubdb.subcommands.clear.logs.emptyTable', {
tableId,
})
);
Expand All @@ -80,7 +78,7 @@ export function builder(yargs: Argv): Argv<HubdbClearArgs> {
addUseEnvironmentOptions(yargs);

yargs.positional('table-id', {
describe: i18n(`${i18nKey}.positionals.tableId.describe`),
describe: i18n('commands.hubdb.subcommands.clear.positionals.tableId.describe'),
type: 'string',
});

Expand Down
15 changes: 7 additions & 8 deletions commands/hubdb/create.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.hubdb.subcommands.create';

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

type CombinedArgs = ConfigArgs & AccountArgs & EnvironmentArgs;
type HubdbCreateArgs = CommonArgs & CombinedArgs & { path?: string };
Expand All @@ -33,14 +32,14 @@ function selectPathPrompt(options: HubdbCreateArgs): Promise<{ path: string }> {
return promptUser([
{
name: 'path',
message: i18n(`${i18nKey}.enterPath`),
message: i18n(`commands.hubdb.subcommands.create.enterPath`),
when: !options.path,
validate: (input: string) => {
if (!input) {
return i18n(`${i18nKey}.errors.pathRequired`);
return i18n(`commands.hubdb.subcommands.create.errors.pathRequired`);
}
if (!isValidPath(input)) {
return i18n(`${i18nKey}.errors.invalidCharacters`);
return i18n(`commands.hubdb.subcommands.create.errors.invalidCharacters`);
}
return true;
},
Expand Down Expand Up @@ -73,15 +72,15 @@ export async function handler(
path.resolve(getCwd(), filePath)
);
logger.success(
i18n(`${i18nKey}.success.create`, {
i18n(`commands.hubdb.subcommands.create.success.create`, {
accountId: derivedAccountId,
rowCount: table.rowCount,
tableId: table.tableId,
})
);
} catch (e) {
logger.error(
i18n(`${i18nKey}.errors.create`, {
i18n(`commands.hubdb.subcommands.create.errors.create`, {
filePath: filePath || '',
})
);
Expand All @@ -95,7 +94,7 @@ export function builder(yargs: Argv): Argv<HubdbCreateArgs> {
addUseEnvironmentOptions(yargs);

yargs.options('path', {
describe: i18n(`${i18nKey}.options.path.describe`),
describe: i18n(`commands.hubdb.subcommands.create.options.path.describe`),
type: 'string',
});

Expand Down
14 changes: 6 additions & 8 deletions commands/hubdb/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ import {
EnvironmentArgs,
} from '../../types/Yargs';

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

export const command = 'delete [table-id]';
export const describe = i18n(`${i18nKey}.describe`);
export const describe = i18n('commands.hubdb.subcommands.delete.describe');

type CombinedArgs = ConfigArgs & AccountArgs & EnvironmentArgs;
type HubdbDeleteArgs = CommonArgs & CombinedArgs & { tableId?: number };
Expand All @@ -47,7 +45,7 @@ export async function handler(
const { shouldDeleteTable } = await promptUser({
name: 'shouldDeleteTable',
type: 'confirm',
message: i18n(`${i18nKey}.shouldDeleteTable`, { tableId }),
message: i18n('commands.hubdb.subcommands.delete.shouldDeleteTable', { tableId }),
});

if (!shouldDeleteTable) {
Expand All @@ -57,15 +55,15 @@ export async function handler(

await deleteTable(derivedAccountId, tableId);
logger.success(
i18n(`${i18nKey}.success.delete`, {
i18n('commands.hubdb.subcommands.delete.success.delete', {
accountId: derivedAccountId,
tableId,
})
);
process.exit(EXIT_CODES.SUCCESS);
} catch (e) {
logger.error(
i18n(`${i18nKey}.errors.delete`, {
i18n('commands.hubdb.subcommands.delete.errors.delete', {
tableId: args.tableId || '',
})
);
Expand All @@ -79,12 +77,12 @@ export function builder(yargs: Argv): Argv<HubdbDeleteArgs> {
addUseEnvironmentOptions(yargs);

yargs.positional('table-id', {
describe: i18n(`${i18nKey}.positionals.tableId.describe`),
describe: i18n('commands.hubdb.subcommands.delete.positionals.tableId.describe'),
type: 'string',
});

yargs.option('force', {
describe: i18n(`${i18nKey}.options.force.describe`),
describe: i18n('commands.hubdb.subcommands.delete.options.force.describe'),
type: 'boolean',
});

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

const i18nKey = 'commands.hubdb.subcommands.fetch';

export const command = 'fetch [table-id] [dest]';
export const describe = i18n(`${i18nKey}.describe`);
export const describe = i18n('commands.hubdb.subcommands.fetch.describe');

type CombinedArgs = ConfigArgs & AccountArgs & EnvironmentArgs;
type HubdbFetchArgs = CommonArgs &
Expand Down Expand Up @@ -49,7 +47,7 @@ export async function handler(
);

logger.success(
i18n(`${i18nKey}.success.fetch`, {
i18n('commands.hubdb.subcommands.fetch.success.fetch', {
path: filePath,
tableId,
})
Expand All @@ -65,12 +63,12 @@ export function builder(yargs: Argv): Argv<HubdbFetchArgs> {
addUseEnvironmentOptions(yargs);

yargs.positional('table-id', {
describe: i18n(`${i18nKey}.positionals.tableId.describe`),
describe: i18n('commands.hubdb.subcommands.fetch.positionals.tableId.describe'),
type: 'string',
});

yargs.positional('dest', {
describe: i18n(`${i18nKey}.positionals.dest.describe`),
describe: i18n('commands.hubdb.subcommands.fetch.positionals.dest.describe'),
type: 'string',
});

Expand Down
11 changes: 5 additions & 6 deletions commands/module/marketplace-validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ const {
} = require('../../lib/marketplaceValidate');
const { i18n } = require('../../lib/lang');

const i18nKey = 'commands.module.subcommands.marketplaceValidate';

exports.command = 'marketplace-validate <src>';
exports.describe = i18n(`${i18nKey}.describe`);
exports.describe = i18n(`commands.module.subcommands.marketplaceValidate.describe`);

exports.handler = async options => {
const { src, derivedAccountId } = options;
Expand All @@ -28,7 +27,7 @@ exports.handler = async options => {
SpinniesManager.init();

SpinniesManager.add('marketplaceValidation', {
text: i18n(`${i18nKey}.logs.validatingModule`, {
text: i18n(`commands.module.subcommands.marketplaceValidate.logs.validatingModule`, {
path: src,
}),
});
Expand All @@ -47,8 +46,8 @@ exports.handler = async options => {
derivedAccountId,
validationId
);
processValidationErrors(i18nKey, validationResults);
displayValidationResults(i18nKey, validationResults);
processValidationErrors('commands.module.subcommands.marketplaceValidate', validationResults);
displayValidationResults('commands.module.subcommands.marketplaceValidate', validationResults);

process.exit();
};
Expand All @@ -59,7 +58,7 @@ exports.builder = yargs => {
addUseEnvironmentOptions(yargs);

yargs.positional('src', {
describe: i18n(`${i18nKey}.positionals.src.describe`),
describe: i18n(`commands.module.subcommands.marketplaceValidate.positionals.src.describe`),
type: 'string',
});
return yargs;
Expand Down
25 changes: 12 additions & 13 deletions commands/project/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import { EXIT_CODES } from '../../lib/enums/exitCodes';
import { CommonArgs } from '../../types/Yargs';
import { makeYargsBuilder } from '../../lib/yargsUtils';

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

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

type ProjectAddArgs = CommonArgs & {
type: string;
Expand All @@ -39,7 +38,7 @@ export async function handler(
const { projectConfig, projectDir } = await getProjectConfig();

if (!projectDir || !projectConfig) {
logger.error(i18n(`${i18nKey}.error.locationInProject`));
logger.error(i18n(`commands.project.subcommands.add.error.locationInProject`));
process.exit(EXIT_CODES.ERROR);
}

Expand All @@ -55,13 +54,13 @@ export async function handler(
}

if (projectContainsPublicApp) {
logger.error(i18n(`${i18nKey}.error.projectContainsPublicApp`));
logger.error(i18n(`commands.project.subcommands.add.error.projectContainsPublicApp`));
process.exit(EXIT_CODES.ERROR);
}

logger.log('');
logger.log(
i18n(`${i18nKey}.creatingComponent`, {
i18n(`commands.project.subcommands.add.creatingComponent`, {
projectName: projectConfig.name,
})
);
Expand All @@ -81,15 +80,15 @@ export async function handler(
}

if (!latestRepoReleaseTag) {
logger.error(i18n(`${i18nKey}.error.failedToFetchComponentList`));
logger.error(i18n(`commands.project.subcommands.add.error.failedToFetchComponentList`));
process.exit(EXIT_CODES.ERROR);
}

const components =
await getProjectComponentListFromRepo(latestRepoReleaseTag);

if (!components.length) {
logger.error(i18n(`${i18nKey}.error.failedToFetchComponentList`));
logger.error(i18n(`commands.project.subcommands.add.error.failedToFetchComponentList`));
process.exit(EXIT_CODES.ERROR);
}

Expand All @@ -115,13 +114,13 @@ export async function handler(

logger.log('');
logger.success(
i18n(`${i18nKey}.success`, {
i18n(`commands.project.subcommands.add.success`, {
componentName: projectAddPromptResponse.name,
})
);
} catch (error) {
debugError(error);
logger.error(i18n(`${i18nKey}.error.failedToDownloadComponent`));
logger.error(i18n(`commands.project.subcommands.add.error.failedToDownloadComponent`));
process.exit(EXIT_CODES.ERROR);
}
process.exit(EXIT_CODES.SUCCESS);
Expand All @@ -130,20 +129,20 @@ export async function handler(
function projectAddBuilder(yargs: Argv): Argv<ProjectAddArgs> {
yargs.options({
type: {
describe: i18n(`${i18nKey}.options.type.describe`),
describe: i18n(`commands.project.subcommands.add.options.type.describe`),
type: 'string',
},
name: {
describe: i18n(`${i18nKey}.options.name.describe`),
describe: i18n(`commands.project.subcommands.add.options.name.describe`),
type: 'string',
},
});

yargs.example([['$0 project add', i18n(`${i18nKey}.examples.default`)]]);
yargs.example([['$0 project add', i18n(`commands.project.subcommands.add.examples.default`)]]);
yargs.example([
[
'$0 project add --name="my-component" --type="components/example-app"',
i18n(`${i18nKey}.examples.withFlags`),
i18n(`commands.project.subcommands.add.examples.withFlags`),
],
]);

Expand Down
Loading