Skip to content

⚙️ 添加 husky pre-push hook 保护主分支#1285

Open
CodFrm wants to merge 12 commits intomainfrom
worktree-husky-pre-push
Open

⚙️ 添加 husky pre-push hook 保护主分支#1285
CodFrm wants to merge 12 commits intomainfrom
worktree-husky-pre-push

Conversation

@CodFrm
Copy link
Member

@CodFrm CodFrm commented Mar 13, 2026

Summary

  • 添加 husky + pre-push hook,推送到 mainrelease/* 分支时自动执行 lint、单元测试、build 和 e2e 测试
  • 团队成员 pnpm install 后自动生效,无需手动配置
  • 支持 SKIP_PRE_PUSH=1 git pushgit push --no-verify 跳过检查

Test plan

  • pnpm install 后确认 .husky/pre-push 被正确安装
  • 推送到 main 分支时确认 lint/test/build/e2e 依次执行
  • 推送到非 main/release 分支时确认不触发检查
  • SKIP_PRE_PUSH=1 git push 确认可跳过检查

CodFrm and others added 12 commits March 2, 2026 15:43
* 🐛 修复 脚本设置-授权管理 控制无效的问题

* 将校验逻辑放到confirm

* 修复GM cookie权限判断

* 删除directDeny

* buildCacheKey

* 整理代码

* Update src/app/service/service_worker/permission_verify.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* 🔒 使用 DOMPurify 清理公告通知的 HTML 内容 #1273

使用 DOMPurify 对服务端下发的公告 HTML 进行白名单过滤,防止潜在的
UI 注入风险。只允许基础标签和安全的 CSS 属性(颜色、字体相关)。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* code update

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: cyfung1031 <44498510+cyfung1031@users.noreply.github.com>
* 🐛 修复 include *?* 表达式处理问题 #1271

* Added error handling to avoid crash

* update globSplit

* update globSplit

* update globSplit

---------

Co-authored-by: cyfung1031 <44498510+cyfung1031@users.noreply.github.com>
* fix #1274

* Update index.ts

* Array.includes -> Set.has
Google migrated the Chrome Web Store from `chrome.google.com/webstore`
to `chromewebstore.google.com`. This updates all CWS URLs across
README files to use the new domain.

The old URLs currently redirect, but will eventually stop working.
* ✅ 添加 Playwright E2E 测试

- 新增 22 个 E2E 测试覆盖 Options、Popup、Install、Editor、Settings 页面
- 配置 Playwright 使用 --headless=new 模式加载扩展
- 在 CI workflow 中添加 E2E 测试 job

* ✅ 添加 GM API E2E 测试

新增 gm-api.spec.ts 测试三类 GM API:
- GM_ 同步 API (gm_api_test.js): 29 项测试
- GM.* 异步 API (gm_api_async_test.js): 29 项测试
- Content 注入测试 (inject_content_test.js): 11 项测试

实现要点:
- 两阶段浏览器启动:Phase 1 启用 userScriptsAccess,Phase 2 重启运行测试
- 自动审批权限确认弹窗(cookie 等需要用户授权的 API)
- 通过剪贴板注入脚本代码到 Monaco 编辑器
- 替换 jsdelivr CDN 为 unpkg 提升资源加载速度
- 去除 @require/@resource 的 SRI hash 避免校验失败

更新 utils.ts 中 installScriptByCode 增加保存失败的 fallback 检测

* 🐛 修复 GM API E2E 测试 CI 兼容性

- Phase 1 添加 --headless=new 参数,修复 CI 无 X server 环境
- 添加 eslint-disable 注释消除 Playwright use() 的误报
- prettier 格式化修正

* 🐛 修复 E2E 测试 CI 兼容性问题

- vitest.config.ts: 排除 e2e/ 目录避免 Vitest 误跑 Playwright 测试
- eslint.config.mjs: 为 e2e/ 目录关闭 react-hooks/rules-of-hooks 规则
- e2e/options.spec.ts: 菜单正则加 /i 标志修复英文环境大小写匹配
- prettier 格式化修正
* 🐛 修复其他扩展注入 chrome.runtime 导致环境误判的问题 #1280

移除 isContent 运行时检测,改为通过 CustomEventMessage.envTag 在构建入口确定环境,
避免其他扩展(如大学搜题酱)向页面注入 chrome.runtime 对象导致 inject 环境被误判为 content 环境。

* Update src/app/service/content/gm_api/gm_api.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* update

* 删除不必要的isconnect

* 将 typecheck 集成到 lint/lint-fix 脚本中

* 修复引用

* 删除test-results

---------

Co-authored-by: cyfung1031 <44498510+cyfung1031@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- 缓存 Playwright 浏览器避免重复下载
- 测试失败时上传截图/视频/报告等调试产物
- Playwright CI 环境启用 HTML+list 双 reporter、失败截图和视频
- 各工具链配置屏蔽 .claude 目录
- gm-api.spec.ts: Phase 2 重启 context 后等待 service worker 注册完成
  再交给 fixtures,避免 extensionId fixture 用 10s 全局超时等待失败
- gm-api.spec.ts: 用事件驱动 Promise 替换 500ms 轮询循环,
  console 结果一出现立即继续
- utils.ts: installScriptByCode 用 DOM 事件等待替代固定延迟:
  click 后等光标出现,粘贴后等 .view-lines 内容变化

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants