chore(merge): Merge Soybean branch main into dev

This commit is contained in:
xlsea
2026-05-23 10:07:48 +08:00
23 changed files with 1617 additions and 1598 deletions
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@sa/scripts",
"version": "2.1.0",
"version": "2.2.0",
"bin": {
"sa": "./bin.ts"
},
@@ -15,15 +15,15 @@
".": "./src/index.ts"
},
"devDependencies": {
"@soybeanjs/changelog": "0.4.5",
"bumpp": "11.0.1",
"c12": "3.3.3",
"@soybeanjs/changelog": "0.4.7",
"bumpp": "11.1.0",
"c12": "3.3.4",
"cac": "7.0.0",
"consola": "3.4.2",
"enquirer": "2.4.1",
"execa": "9.6.1",
"kolorist": "1.8.0",
"npm-check-updates": "19.6.6",
"npm-check-updates": "22.2.0",
"picomatch": "4.0.4",
"rimraf": "6.1.3"
}
+42 -19
View File
@@ -17,7 +17,14 @@ interface PromptObject {
* @param lang
*/
export async function gitCommit(lang: Lang = 'en-us') {
const { gitCommitMessages, gitCommitTypes, gitCommitScopes } = locales[lang];
const { gitCommitMessages, gitCommitNoStaged, gitCommitTypes, gitCommitScopes } = locales[lang];
const stagedFiles = await execCommand('git', ['diff', '--cached', '--name-only']);
if (!stagedFiles) {
console.error(gitCommitNoStaged);
process.exit(1);
}
const typesChoices = gitCommitTypes.map(([value, msg]) => {
const nameWithSuffix = `${value}:`;
@@ -35,25 +42,41 @@ export async function gitCommit(lang: Lang = 'en-us') {
message: `${value.padEnd(30)} (${msg})`
}));
const result = await prompt<PromptObject>([
{
name: 'types',
type: 'select',
message: gitCommitMessages.types,
choices: typesChoices
},
{
name: 'scopes',
type: 'select',
message: gitCommitMessages.scopes,
choices: scopesChoices
},
{
name: 'description',
type: 'text',
message: gitCommitMessages.description
// Suppress ERR_USE_AFTER_CLOSE thrown by enquirer's readline cleanup on Ctrl+C (Node.js v24+)
const errorHandler = (error: NodeJS.ErrnoException) => {
if (error.code === 'ERR_USE_AFTER_CLOSE') {
process.exit(0);
}
]);
};
process.on('uncaughtException', errorHandler);
let result: PromptObject;
try {
result = await prompt<PromptObject>([
{
name: 'types',
type: 'select',
message: gitCommitMessages.types,
choices: typesChoices
},
{
name: 'scopes',
type: 'select',
message: gitCommitMessages.scopes,
choices: scopesChoices
},
{
name: 'description',
type: 'text',
message: gitCommitMessages.description
}
]);
} catch {
process.exit(0);
} finally {
process.off('uncaughtException', errorHandler);
}
const breaking = result.description.startsWith('!') ? '!' : '';
+2
View File
@@ -37,6 +37,7 @@ export const locales = {
['release', '发布项目新版本'],
['other', '其他的变更']
] as [string, string][],
gitCommitNoStaged: `${bgRed(' 错误 ')} ${red('暂存区没有文件,请先使用 git add 添加文件后再提交!')}`,
gitCommitVerify: `${bgRed(' 错误 ')} ${red('git 提交信息必须符合 Conventional Commits 标准!')}\n\n${green(
'推荐使用命令 `pnpm commit` 生成符合 Conventional Commits 标准的提交信息。\n获取有关 Conventional Commits 的更多信息,请访问此链接: https://conventionalcommits.org'
)}`
@@ -75,6 +76,7 @@ export const locales = {
['release', 'release project'],
['other', 'other changes']
] as [string, string][],
gitCommitNoStaged: `${bgRed(' ERROR ')} ${red('No files in staging area, please use git add to stage files first!')}`,
gitCommitVerify: `${bgRed(' ERROR ')} ${red('git commit message must match the Conventional Commits standard!')}\n\n${green(
'Recommended to use the command `pnpm commit` to generate Conventional Commits compliant commit information.\nGet more info about Conventional Commits, follow this link: https://conventionalcommits.org'
)}`