mirror of
https://github.com/Silentely/eSIM-Tools.git
synced 2026-09-03 06:24:20 +08:00
♻️ refactor: 调整提交信息校验逻辑并增强运行时变量兜底保护
- 更新 commit-msg 校验脚本,移除 emoji 与 type 的强制配对要求,仅验证两者合法性 - 同步更新中英文 README 文档说明,明确 emoji 与 type 不再强制匹配 - 在 Simyo eSIM HTML 文件中添加全局变量兜底逻辑,防止 iOS WebView 因未定义 currentInset、CONFIG 导致崩溃 - 扩展 Sentry 错误过滤规则,新增对 currentInset 和 CONFIG 相关报错信息的忽略处理
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* commit-msg 校验:
|
||||
* 1. 首段必须为 emoji(或 :shortcode:);
|
||||
* 2. 后续遵循 Conventional Commits 头部格式;
|
||||
* 3. emoji 与 type 必须匹配;
|
||||
* 3. emoji 与 type 仅要求分别合法,不再强制一一匹配;
|
||||
* 4. 描述必须包含中文字符。
|
||||
*
|
||||
* 格式:<emoji> <type>(optional-scope): <中文描述>
|
||||
@@ -68,7 +68,7 @@ function fail(message) {
|
||||
console.error(` ${message}\n`);
|
||||
console.error('期望格式:');
|
||||
console.error(' <emoji> <type>(optional-scope): <中文描述>');
|
||||
console.error('\nemoji 与 type 对应关系:');
|
||||
console.error('\n支持的 emoji(推荐对应关系如下,非强制):');
|
||||
console.error(` ${ALLOWED_PAIRS_HELP}`);
|
||||
console.error('\n示例:');
|
||||
console.error(' ✨ feat(auth): 新增登录态自动续期');
|
||||
@@ -96,19 +96,13 @@ function isEmojiToken(token) {
|
||||
return TOKEN_TO_TYPES.has(key);
|
||||
}
|
||||
|
||||
function validateEmojiTypePair(emojiToken, type) {
|
||||
function validateEmojiToken(emojiToken) {
|
||||
const key = emojiToken.startsWith(':')
|
||||
? emojiToken.toLowerCase()
|
||||
: emojiToken.replace(/\uFE0F/g, '');
|
||||
const allowedTypes = TOKEN_TO_TYPES.get(key);
|
||||
|
||||
if (!allowedTypes || allowedTypes.length === 0) {
|
||||
if (!TOKEN_TO_TYPES.has(key)) {
|
||||
fail(`不支持的 emoji:${emojiToken}`);
|
||||
}
|
||||
|
||||
if (!allowedTypes.includes(type)) {
|
||||
fail(`emoji ${emojiToken} 与 type ${type} 不匹配。`);
|
||||
}
|
||||
}
|
||||
|
||||
function validateCommitHeader(header) {
|
||||
@@ -132,6 +126,7 @@ function validateCommitHeader(header) {
|
||||
if (!isEmojiToken(emojiToken)) {
|
||||
fail('提交标题需要以受支持的 emoji(或 :shortcode:)开头。');
|
||||
}
|
||||
validateEmojiToken(emojiToken);
|
||||
|
||||
const matched = conventionalHeader.match(HEADER_PATTERN);
|
||||
if (!matched) {
|
||||
@@ -142,9 +137,6 @@ function validateCommitHeader(header) {
|
||||
);
|
||||
}
|
||||
|
||||
const type = matched[1];
|
||||
validateEmojiTypePair(emojiToken, type);
|
||||
|
||||
const subject = matched[3].trim();
|
||||
if (!/[\u3400-\u9FFF]/u.test(subject)) {
|
||||
fail('提交描述必须包含中文字符。');
|
||||
|
||||
Reference in New Issue
Block a user