mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-09-27 13:46:41 +08:00
feat(scripts): git-commit 命令添加--lang参数,支持中文提示
This commit is contained in:
parent
a454b620f1
commit
1aa79752ef
@ -16,10 +16,12 @@ interface PromptObject {
|
||||
*
|
||||
* @param gitCommitTypes
|
||||
* @param gitCommitScopes
|
||||
* @param lang
|
||||
*/
|
||||
export async function gitCommit(
|
||||
gitCommitTypes: CliOption['gitCommitTypes'],
|
||||
gitCommitScopes: CliOption['gitCommitScopes']
|
||||
gitCommitScopes: CliOption['gitCommitScopes'],
|
||||
lang?: string
|
||||
) {
|
||||
const typesChoices = gitCommitTypes.map(([value, msg]) => {
|
||||
const nameWithSuffix = `${value}:`;
|
||||
@ -41,19 +43,22 @@ export async function gitCommit(
|
||||
{
|
||||
name: 'types',
|
||||
type: 'select',
|
||||
message: 'Please select a type',
|
||||
message: lang === 'en-us' ? 'Please select a type' : '请选择提交类型',
|
||||
choices: typesChoices
|
||||
},
|
||||
{
|
||||
name: 'scopes',
|
||||
type: 'select',
|
||||
message: 'Please select a scope',
|
||||
message: lang === 'en-us' ? 'Please select a scope' : '请选择提交范围',
|
||||
choices: scopesChoices
|
||||
},
|
||||
{
|
||||
name: 'description',
|
||||
type: 'text',
|
||||
message: `Please enter a description (add prefix ${yellow('!')} to indicate breaking change)`
|
||||
message:
|
||||
lang === 'en-us'
|
||||
? `Please enter a description (add prefix ${yellow('!')} to indicate breaking change)`
|
||||
: '请输入描述信息(!开头表示破坏性改动)'
|
||||
}
|
||||
]);
|
||||
|
||||
|
@ -18,13 +18,22 @@ interface CommandArg {
|
||||
/** Generate changelog by total tags */
|
||||
total?: boolean;
|
||||
/**
|
||||
* The glob pattern of dirs to cleanup
|
||||
* The glob pattern of dirs to clean up
|
||||
*
|
||||
* If not set, it will use the default value
|
||||
*
|
||||
* Multiple values use "," to separate them
|
||||
*/
|
||||
cleanupDir?: string;
|
||||
|
||||
/** Support for different language prompts, and the default is en-us */
|
||||
lang?: string;
|
||||
}
|
||||
|
||||
/** 支持的语言 */
|
||||
enum SaCliLanguage {
|
||||
Chinese = 'zh-cn',
|
||||
English = 'en-us'
|
||||
}
|
||||
|
||||
export async function setupCli() {
|
||||
@ -44,6 +53,10 @@ export async function setupCli() {
|
||||
'-c, --cleanupDir <dir>',
|
||||
'The glob pattern of dirs to cleanup, If not set, it will use the default value, Multiple values use "," to separate them'
|
||||
)
|
||||
.option('-l, --lang', 'Support for different language prompts, and the default is en-us', {
|
||||
default: SaCliLanguage.English,
|
||||
type: [String]
|
||||
})
|
||||
.help();
|
||||
|
||||
const commands: CommandWithAction<CommandArg> = {
|
||||
@ -61,8 +74,8 @@ export async function setupCli() {
|
||||
},
|
||||
'git-commit': {
|
||||
desc: 'git commit, generate commit message which match Conventional Commits standard',
|
||||
action: async () => {
|
||||
await gitCommit(cliOptions.gitCommitTypes, cliOptions.gitCommitScopes);
|
||||
action: async args => {
|
||||
await gitCommit(cliOptions.gitCommitTypes, cliOptions.gitCommitScopes, args?.lang);
|
||||
}
|
||||
},
|
||||
'git-commit-verify': {
|
||||
@ -98,4 +111,6 @@ export async function setupCli() {
|
||||
cli.parse();
|
||||
}
|
||||
|
||||
setupCli();
|
||||
(async () => {
|
||||
await setupCli();
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user