├── .changelogrc.js ├── .commitlintrc.js ├── .editorconfig ├── .eslintrc.js ├── .github └── workflows │ └── release.yml ├── .gitignore ├── .husky ├── commit-msg └── pre-commit ├── .npmrc ├── .prettierignore ├── .prettierrc.js ├── .releaserc.js ├── .stylelintrc.js ├── CHANGELOG.md ├── LICENSE ├── README.md ├── config └── config.ts ├── package.json ├── public └── logo │ ├── logo@128.png │ ├── logo@16.png │ ├── logo@32.png │ └── logo@48.png ├── scripts └── zip.ts ├── src ├── background │ └── index.ts ├── contentScripts │ └── all │ │ ├── index.tsx │ │ └── style.less ├── pages │ ├── options │ │ ├── App.less │ │ └── index.tsx │ └── popup │ │ ├── index.tsx │ │ └── style.less └── utils │ ├── env.ts │ └── index.ts ├── tsconfig-check.json ├── tsconfig.json └── types └── index.d.ts /.changelogrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | scopeDisplayName: { 3 | '*': '杂项', 4 | script: '脚本', 5 | scripts: '脚本', 6 | changelog: '日志', 7 | config: '配置', 8 | release: '自动发布', 9 | types: '类型', 10 | readme: '说明文档', 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /.commitlintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['gitmoji'], 3 | }; 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [Makefile] 16 | indent_style = tab 17 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [require.resolve('@umijs/max/eslint')], 3 | ignorePatterns: ['*.js'], 4 | }; 5 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release CI 2 | on: 3 | push: 4 | branches: 5 | - master 6 | 7 | jobs: 8 | release: 9 | name: Release 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | 14 | - name: Install pnpm 15 | uses: pnpm/action-setup@v2 16 | with: 17 | version: 7 18 | 19 | - name: Setup Node.js environment 20 | uses: actions/setup-node@v3 21 | with: 22 | node-version: '16' 23 | 24 | - name: Install deps 25 | run: pnpm install 26 | 27 | - name: Lint 28 | run: pnpm run lint && pnpm run tsc 29 | 30 | - name: release 31 | run: pnpm run release 32 | env: 33 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 4 | 5 | # dependencies 6 | node_modules 7 | /.pnp 8 | .pnp.js 9 | 10 | # testing 11 | /coverage 12 | 13 | # production 14 | /build 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | 28 | # production 29 | **/dist 30 | /.vscode 31 | /es 32 | /lib 33 | 34 | # misc 35 | .DS_Store 36 | storybook-static 37 | npm-debug.log* 38 | yarn-error.log 39 | 40 | /coverage 41 | .idea 42 | yarn.lock 43 | package-lock.json 44 | *bak 45 | .vscode 46 | 47 | # visual studio code 48 | .history 49 | *.log 50 | functions/* 51 | lambda/mock/index.js 52 | .temp/** 53 | 54 | # umi 55 | .umi 56 | .umi-production 57 | 58 | # screenshot 59 | screenshot 60 | .firebase 61 | example/.temp/* 62 | .eslintcache 63 | 64 | dev 65 | 66 | dist* 67 | 68 | *.zip 69 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npx --no-install commitlint --edit $1 5 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npx --no-install lint-staged 5 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | strict-peer-dependencies=false 2 | lockfile=false 3 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | **/*.svg 2 | **/*.ejs 3 | **/*.html 4 | .umi 5 | .umi-production 6 | .umi-test 7 | package.json 8 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = require.resolve('@umijs/max/prettier'); 2 | -------------------------------------------------------------------------------- /.releaserc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | //负责解析 commit 4 | [ 5 | '@semantic-release/commit-analyzer', 6 | { 7 | // 自定义配置,如果不填则是默认的 conventional-changelog-angular 8 | config: 'conventional-changelog-gitmoji-config', 9 | }, 10 | ], 11 | [ 12 | '@semantic-release/release-notes-generator', //此处生成 github-release 的日志 13 | { 14 | //指定配置,这里才是负责生成日志的,也就是说,如果自定义了writerOpts,只有在这里写才会生效 15 | config: 'conventional-changelog-gitmoji-config', 16 | }, 17 | ], 18 | [ 19 | '@semantic-release/changelog', //此处会调用上一个插件生成的新增日志,然后合并到原有日志中 20 | { 21 | changelogFile: 'CHANGELOG.md', 22 | changelogTitle: '# umi-chrome-extensions-template 更新日志', 23 | }, 24 | ], 25 | '@semantic-release/npm', //如果是npm包会自动更新版本号并发布 26 | [ 27 | '@semantic-release/exec', 28 | { 29 | prepareCmd: 'pnpm run zip', 30 | }, 31 | ], 32 | [ 33 | '@semantic-release/github', 34 | { 35 | assets: ['release'], 36 | }, 37 | ], // 推送代码回到GitHub 38 | [ 39 | '@semantic-release/git', //发布release 40 | { 41 | assets: [ 42 | // 这里的 assets 配置的是要重新 push 回去的东西 43 | // 如果不列的话会将全部内容都合并到 release 中 44 | 'CHANGELOG.md', 45 | 'package.json', 46 | ], 47 | message: ':bookmark: chore(release): v${nextRelease.version} [skip ci]', 48 | }, 49 | ], 50 | ], 51 | }; 52 | -------------------------------------------------------------------------------- /.stylelintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = require('@umijs/max/stylelint'); 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # umi-chrome-extensions-template 更新日志 2 | 3 | # [1.5.0](https://github.com/arvinxx/umi-chrome-extensions-template/compare/v1.4.1...v1.5.0) (2022-11-27) 4 | 5 | 6 | ### ✨ Features 7 | 8 | * **杂项**: 升级到 antd v5 ([6299167](https://github.com/arvinxx/umi-chrome-extensions-template/commit/6299167)) 9 | * **杂项**: 升级到 umi4 ([c9bb7de](https://github.com/arvinxx/umi-chrome-extensions-template/commit/c9bb7de)) 10 | 11 | 12 | ### 🎫 Chores 13 | 14 | * **杂项**: 升级 lint 配置 ([7383e54](https://github.com/arvinxx/umi-chrome-extensions-template/commit/7383e54)) 15 | * **杂项**: 升级到 react18 ([b04152e](https://github.com/arvinxx/umi-chrome-extensions-template/commit/b04152e)) 16 | * **杂项**: 移除 less ([4619564](https://github.com/arvinxx/umi-chrome-extensions-template/commit/4619564)) 17 | * **杂项**: 移除 pnpm lock ([a0ed40f](https://github.com/arvinxx/umi-chrome-extensions-template/commit/a0ed40f)) 18 | 19 | ## [1.4.1](https://github.com/arvinxx/umi-chrome-extensions-template/compare/v1.4.0...v1.4.1) (2022-08-27) 20 | 21 | 22 | ### 🐛 Bug Fixes 23 | 24 | * **杂项**: 修正发布之后的解压文件夹目录 ([d0ba634](https://github.com/arvinxx/umi-chrome-extensions-template/commit/d0ba634)) 25 | 26 | # [1.4.0](https://github.com/arvinxx/umi-chrome-extensions-template/compare/v1.3.0...v1.4.0) (2022-08-27) 27 | 28 | 29 | ### ✨ Features 30 | 31 | * **杂项**: 优化发布链路 ([14ac2c0](https://github.com/arvinxx/umi-chrome-extensions-template/commit/14ac2c0)) 32 | * **杂项**: 优化发布链路 ([4d4b4b9](https://github.com/arvinxx/umi-chrome-extensions-template/commit/4d4b4b9)) 33 | 34 | # [1.3.0](https://github.com/arvinxx/umi-chrome-extensions-template/compare/v1.2.0...v1.3.0) (2022-08-13) 35 | 36 | 37 | ### ✨ Features 38 | 39 | * **杂项**: 使用 umi4 的 lint 与 prettier 规则 ([28c089b](https://github.com/arvinxx/umi-chrome-extensions-template/commit/28c089b)) 40 | 41 | 42 | ### 🔧 Continuous Integration 43 | 44 | * **杂项**: fix ci ([a89cb72](https://github.com/arvinxx/umi-chrome-extensions-template/commit/a89cb72)) 45 | 46 | # [1.2.0](https://github.com/arvinxx/umi-chrome-extensions-template/compare/v1.1.0...v1.2.0) (2022-08-13) 47 | 48 | 49 | ### ✨ Features 50 | 51 | * **杂项**: 更新基础设施 ([7a03f1d](https://github.com/arvinxx/umi-chrome-extensions-template/commit/7a03f1d)) 52 | 53 | 54 | ### 🎫 Chores 55 | 56 | * **ci**: 添加自动合并依赖 ci ([5ebfccb](https://github.com/arvinxx/umi-chrome-extensions-template/commit/5ebfccb)) 57 | * **杂项**: 升级依赖并修正类型问题 ([80005c9](https://github.com/arvinxx/umi-chrome-extensions-template/commit/80005c9)) 58 | * **杂项**: 清理无用模块 ([bf70662](https://github.com/arvinxx/umi-chrome-extensions-template/commit/bf70662)) 59 | 60 | 61 | ### 🐛 Bug Fixes 62 | 63 | * **杂项**: 修正 pnpm 安装模式下会找不到依赖的问题 ([07e0dc4](https://github.com/arvinxx/umi-chrome-extensions-template/commit/07e0dc4)) 64 | * **杂项**: 修正 release 脚本问题 ([4d49172](https://github.com/arvinxx/umi-chrome-extensions-template/commit/4d49172)) 65 | 66 | 67 | ### 📝 Documentation 68 | 69 | * **说明文档**: 更新说明文档 ([39e6f1a](https://github.com/arvinxx/umi-chrome-extensions-template/commit/39e6f1a)) 70 | 71 | 72 | ### 🔧 Continuous Integration 73 | 74 | * **杂项**: fix ci ([981c1c9](https://github.com/arvinxx/umi-chrome-extensions-template/commit/981c1c9)) 75 | * **杂项**: fix ci ([6369328](https://github.com/arvinxx/umi-chrome-extensions-template/commit/6369328)) 76 | * **杂项**: 修正 ci 自动更新 ([53359d7](https://github.com/arvinxx/umi-chrome-extensions-template/commit/53359d7)) 77 | 78 | # [1.1.0](https://github.com/arvinxx/umi-chrome-extensions-template/compare/v1.0.0...v1.1.0) (2021-01-19) 79 | 80 | 81 | ### ✨ Features | 新特性 82 | 83 | * **(日志)**: 补充日志文本内容 ([95a4cee](https://github.com/arvinxx/umi-chrome-extensions-template/commit/95a4cee)) 84 | 85 | 86 | ### 🐛 Bug Fixes | 修复 87 | 88 | * **(日志)**: 修正自动生成日志的内容 ([3dc7e85](https://github.com/arvinxx/umi-chrome-extensions-template/commit/3dc7e85)) 89 | 90 | 91 | ### 📝 Documentation | 文档 92 | 93 | * **(license)**: 添加协议 ([2e70a60](https://github.com/arvinxx/umi-chrome-extensions-template/commit/2e70a60)) 94 | * **(说明文档)**: 更新说明文档 ([f603f58](https://github.com/arvinxx/umi-chrome-extensions-template/commit/f603f58)) 95 | 96 | # 1.0.0 (2021-01-19) 97 | 98 | ### ✨ Features | 新特性 99 | 100 | - **(日志)**: 优化生成的日志内容 ([cc2bf70](https://github.com/arvinxx/umi-chrome-extensions-template/commit/cc2bf70)) 101 | - **(配置)**: 添加 auto 自动发布 配置项 ([6ba0e1c](https://github.com/arvinxx/umi-chrome-extensions-template/commit/6ba0e1c)) 102 | - **(配置)**: 添加自动打包脚本 ([f11eed7](https://github.com/arvinxx/umi-chrome-extensions-template/commit/f11eed7)) 103 | - **(杂项)**: 1.0.0 ([1481d83](https://github.com/arvinxx/umi-chrome-extensions-template/commit/1481d83)) 104 | - **(杂项)**: 完成脚手架制作 ([57b05b4](https://github.com/arvinxx/umi-chrome-extensions-template/commit/57b05b4)) 105 | 106 | ### 🎫 Chores 107 | 108 | - **(配置)**: 排除部分 js 配置文件的 lint ([a5dbe54](https://github.com/arvinxx/umi-chrome-extensions-template/commit/a5dbe54)) 109 | - **(杂项)**: minor change ([9c4e9bc](https://github.com/arvinxx/umi-chrome-extensions-template/commit/9c4e9bc)) 110 | - **(杂项)**: minor change ([90219d8](https://github.com/arvinxx/umi-chrome-extensions-template/commit/90219d8)) 111 | - **(杂项)**: minor change ([c840b2d](https://github.com/arvinxx/umi-chrome-extensions-template/commit/c840b2d)) 112 | 113 | ### 🐛 Bug Fixes | 修复 114 | 115 | - **(配置)**: 优化 prettier 配置项 ([5e46c01](https://github.com/arvinxx/umi-chrome-extensions-template/commit/5e46c01)) 116 | - **(配置)**: 忽略生成的 dist 和 zip 文件 ([3e99847](https://github.com/arvinxx/umi-chrome-extensions-template/commit/3e99847)) 117 | - **(自动发布)**: 修复没有 自动发布 配置项的 bug ([762d830](https://github.com/arvinxx/umi-chrome-extensions-template/commit/762d830)) 118 | - **(自动发布)**: 修复没有 semantic-自动发布 模块的 bug ([08a2175](https://github.com/arvinxx/umi-chrome-extensions-template/commit/08a2175)) 119 | - **(类型定义)**: 优化类型定义文件 ([eb81e2b](https://github.com/arvinxx/umi-chrome-extensions-template/commit/eb81e2b)) 120 | - **(脚本)**: 修正 lint 脚本配置 ([2f2bce0](https://github.com/arvinxx/umi-chrome-extensions-template/commit/2f2bce0)) 121 | 122 | ### 📝 Documentation | 文档 123 | 124 | - **(杂项)**: 更新文档 ([39bb86c](https://github.com/arvinxx/umi-chrome-extensions-template/commit/39bb86c)) 125 | - **(杂项)**: 更新文档 ([9ead1cf](https://github.com/arvinxx/umi-chrome-extensions-template/commit/9ead1cf)) 126 | - **(杂项)**: 更新文档 ([0109bae](https://github.com/arvinxx/umi-chrome-extensions-template/commit/0109bae)) 127 | - **(杂项)**: 更新文档 ([ba732f6](https://github.com/arvinxx/umi-chrome-extensions-template/commit/ba732f6)) 128 | - **(杂项)**: 更新文档 ([b0466f6](https://github.com/arvinxx/umi-chrome-extensions-template/commit/b0466f6)) 129 | - **(杂项)**: 更新文档 ([be72db5](https://github.com/arvinxx/umi-chrome-extensions-template/commit/be72db5)) 130 | - **(杂项)**: 更新文档 ([3af4a54](https://github.com/arvinxx/umi-chrome-extensions-template/commit/3af4a54)) 131 | - **(杂项)**: 更新文档 ([b8e9728](https://github.com/arvinxx/umi-chrome-extensions-template/commit/b8e9728)) 132 | - **(杂项)**: 更新文档 ([d446b41](https://github.com/arvinxx/umi-chrome-extensions-template/commit/d446b41)) 133 | - **(杂项)**: 更新文档 ([15b1fd5](https://github.com/arvinxx/umi-chrome-extensions-template/commit/15b1fd5)) 134 | - **(杂项)**: 更新文档 ([e851674](https://github.com/arvinxx/umi-chrome-extensions-template/commit/e851674)) 135 | - **(杂项)**: 更新文档 ([96cab0e](https://github.com/arvinxx/umi-chrome-extensions-template/commit/96cab0e)) 136 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Arvin Xu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Umi Chrome Extensions Template 2 | 3 | ![][version-url] [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) ![][license-url] 4 | 5 | [version-url]: https://img.shields.io/github/v/release/arvinxx/umi-chrome-extensions-template 6 | [license-url]: https://img.shields.io/github/license/arvinxx/umi-chrome-extensions-template 7 | 8 | 基于 Umi 的 Chrome 插件开发脚手架。 9 | 10 | ## ✨ 特性 11 | 12 | - 🌋 **企业级框架**:基于 umi 和 umi 插件 [umi-plugin-extension](https://github.com/arvinxx/umi-plugin-extensions) 构建,享受 umi 生态的全部技术能力; 13 | - 📦 **开箱即用**:脚手架中已经配置 Chrome 插件开发常用的设置项; 14 | - 🔥 **热更新**: 开发时 `options` 和 `popup` 页面支持 `react hot reload` 和 `react devtools`; 15 | - ♻️ **自动重载**: 开发时 `contentScipts` 和 `background` 支持自动刷新; 16 | - 🔧 **配置收敛**:直接在 `.umi.ts` 或 `config.ts` 设置插件配置; 17 | - ⛑ **类型安全**: 脚手架由 Typescript 编写,已集成 Chrome 插件的类型定义文件。 18 | - 🚀 **版本发布**: 使用 `semantic release` 实现语义化版本管理与自动发布流 19 | 20 | ## 📦 使用 21 | 22 | 克隆模板 23 | 24 | ``` 25 | git clone https://github.com/arvinxx/umi-chrome-extension-template.git 26 | ``` 27 | 28 | 安装依赖,推荐使用 pnpm 29 | 30 | ``` 31 | pnpm i 32 | ``` 33 | 34 | ## 🛠️ 开发 35 | 36 | 🔔 请确保你对 Chrome 插件开发已经有基本的了解,入门推荐:[Chrome 插件(扩展)开发全攻略](https://umi-plugin-extensions.vercel.app/tutorial)。 37 | 38 | 如果你对项目的配置有疑问,请查阅 umi-plugin-extension 配置项文档。 ➡️ [传送门](https://arvinxx.github.io/umi-plugin-extensions/#/api) 39 | 40 | ### 启动 41 | 42 | ``` 43 | pnpm start 44 | ``` 45 | 46 | ## 👷 打包 47 | 48 | 构建生产产物直接运行: 49 | 50 | ``` 51 | pnpm run build 52 | ``` 53 | 54 | ## 🤝 贡献 [![PRs Welcome](https://camo.githubusercontent.com/0ff11ed110cfa69f703ef0dcca3cee6141c0a8ef465e8237221ae245de3deb3d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](http://makeapullrequest.com/) 55 | 56 | 欢迎提交 PRs 和 issues。 57 | 58 | ## License 59 | 60 | [MIT](./LICENSE) ® Arvin Xu 61 | -------------------------------------------------------------------------------- /config/config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from '@umijs/max'; 2 | 3 | export default defineConfig({ 4 | plugins: [require.resolve('umi-plugin-extensions')], 5 | extensions: { 6 | name: 'Umi Chrome Extension Template', 7 | description: '基于 Umi 的 Chrome 插件开发脚手架', 8 | optionsUI: { 9 | page: '@/pages/options', 10 | openInTab: true, 11 | }, 12 | background: { service_worker: '@/background/index' }, 13 | popupUI: '@/pages/popup', 14 | contentScripts: [ 15 | { matches: ['https://github.com/*'], entries: ['@/contentScripts/all'] }, 16 | ], 17 | icons: { 18 | 16: 'logo/logo@16.png', 19 | 32: 'logo/logo@32.png', 20 | 48: 'logo/logo@48.png', 21 | 128: 'logo/logo@128.png', 22 | }, 23 | }, 24 | }); 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "umi-chrome-extensions-template", 3 | "version": "1.5.0", 4 | "private": true, 5 | "description": "a template for chrome extensions development based on umi", 6 | "homepage": "https://github.com/arvinxx/umi-chrome-extensions-template#readme", 7 | "bugs": { 8 | "url": "https://github.com/arvinxx/umi-chrome-extensions-template/issues" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+ssh://git@github.com/arvinxx/umi-chrome-extensions-template.git" 13 | }, 14 | "license": "MIT", 15 | "author": "Arvin Xu", 16 | "scripts": { 17 | "start": "max dev", 18 | "build": "max build", 19 | "zip": "pnpm run build && pnpm run zip:only", 20 | "zip:only": "ts-node ./scripts/zip", 21 | "--------- ": "", 22 | "test": "jest", 23 | "test:update": "UPDATE=1 umi-test --update-snapshot", 24 | "test:coverage": "umi-test --coverage", 25 | "--------- ": "", 26 | "changelog": "conventional-changelog -p gitmoji-config -i CHANGELOG.md -s -r 0", 27 | "release": "semantic-release", 28 | "--------- ": "", 29 | "clean": "rm -rf es lib dist build coverage e2e/dist packages/.umi .eslintcache", 30 | "postinstall": "max setup", 31 | "lint": "max lint", 32 | "tsc": "tsc -p tsconfig-check.json", 33 | "lint-staged": "lint-staged", 34 | "prettier": "prettier -c --write \"**/**\"" 35 | }, 36 | "lint-staged": { 37 | "*.{ts,tsx,js}": [ 38 | "eslint -c .eslintrc.js" 39 | ], 40 | "*.{css,less,scss}": [ 41 | "stylelint --fix" 42 | ], 43 | "*.{ts,tsx,json,js,css,less,scss,md}": [ 44 | "prettier --write" 45 | ] 46 | }, 47 | "dependencies": { 48 | "antd": "^5", 49 | "react": "^18", 50 | "react-dom": "^18", 51 | "umi-plugin-extensions": "^1.0.0" 52 | }, 53 | "devDependencies": { 54 | "@commitlint/cli": "^17", 55 | "@semantic-release/changelog": "^5", 56 | "@semantic-release/exec": "^5", 57 | "@semantic-release/git": "^9", 58 | "@semantic-release/release-notes-generator": "^9", 59 | "@types/archiver": "^5.3.1", 60 | "@types/chrome": "latest", 61 | "@types/node": "^18", 62 | "@types/react": "^18", 63 | "@types/react-dom": "^18", 64 | "@umijs/max": "^4", 65 | "@umijs/test": "^4", 66 | "archiver": "^5.3.1", 67 | "commitlint-config-gitmoji": "^2", 68 | "conventional-changelog-cli": "^2", 69 | "conventional-changelog-gitmoji-config": "^1", 70 | "cross-env": "^7.0.3", 71 | "eslint": "^8", 72 | "husky": "^8", 73 | "lint-staged": "^13", 74 | "prettier": "^2", 75 | "semantic-release": "^19", 76 | "ts-node": "^10", 77 | "typescript": "^4" 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /public/logo/logo@128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arvinxx/umi-chrome-extensions-template/5e1bb13fc01c60c9757fa571bff0eb3165ca8428/public/logo/logo@128.png -------------------------------------------------------------------------------- /public/logo/logo@16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arvinxx/umi-chrome-extensions-template/5e1bb13fc01c60c9757fa571bff0eb3165ca8428/public/logo/logo@16.png -------------------------------------------------------------------------------- /public/logo/logo@32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arvinxx/umi-chrome-extensions-template/5e1bb13fc01c60c9757fa571bff0eb3165ca8428/public/logo/logo@32.png -------------------------------------------------------------------------------- /public/logo/logo@48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arvinxx/umi-chrome-extensions-template/5e1bb13fc01c60c9757fa571bff0eb3165ca8428/public/logo/logo@48.png -------------------------------------------------------------------------------- /scripts/zip.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ts-node 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const archiver = require('archiver'); 6 | 7 | const pkg = require('../package.json'); 8 | 9 | const DEST_DIR = path.join(__dirname, '../dist'); 10 | const DEST_ZIP_DIR = path.join(__dirname, '../release'); 11 | 12 | const extractExtensionData = () => { 13 | return { 14 | name: pkg.name, 15 | version: pkg.version, 16 | }; 17 | }; 18 | 19 | const makeDestZipDirIfNotExists = () => { 20 | if (!fs.existsSync(DEST_ZIP_DIR)) { 21 | fs.mkdirSync(DEST_ZIP_DIR); 22 | } 23 | }; 24 | 25 | const buildZip = ( 26 | src: string, 27 | dist: string, 28 | folderName: string, 29 | zipFilename: string, 30 | ) => { 31 | console.info(`📦 Building ${zipFilename}...`); 32 | 33 | const archive = archiver('zip', { zlib: { level: 9 } }); 34 | const stream = fs.createWriteStream(path.join(dist, zipFilename)); 35 | 36 | return new Promise((resolve, reject) => { 37 | archive 38 | .directory(src, folderName) 39 | .on('error', (err: any) => reject(err)) 40 | .pipe(stream); 41 | 42 | stream.on('close', () => resolve()); 43 | archive.finalize().then(); 44 | }); 45 | }; 46 | 47 | const main = () => { 48 | const { name, version } = extractExtensionData(); 49 | const zipFilename = `${name}.v${version}.zip`; 50 | 51 | makeDestZipDirIfNotExists(); 52 | 53 | buildZip(DEST_DIR, DEST_ZIP_DIR, name, zipFilename) 54 | .then(() => console.info('✅ Build Done!')) 55 | .catch(console.error); 56 | }; 57 | 58 | main(); 59 | -------------------------------------------------------------------------------- /src/background/index.ts: -------------------------------------------------------------------------------- 1 | console.log('This is background page!'); 2 | -------------------------------------------------------------------------------- /src/contentScripts/all/index.tsx: -------------------------------------------------------------------------------- 1 | import './style.less'; 2 | 3 | console.log(`Current page's url must be prefixed with https://github.com`); 4 | -------------------------------------------------------------------------------- /src/contentScripts/all/style.less: -------------------------------------------------------------------------------- 1 | // the style will be applied to all pages 2 | .js-header-wrapper > header { 3 | background-color: lightseagreen; 4 | } 5 | -------------------------------------------------------------------------------- /src/pages/options/App.less: -------------------------------------------------------------------------------- 1 | .app { 2 | width: 100vw; 3 | height: 100vh; 4 | 5 | .title { 6 | text-align: center; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/pages/options/index.tsx: -------------------------------------------------------------------------------- 1 | import './App.less'; 2 | 3 | const App = () => { 4 | return ( 5 |
6 |

options page

7 |
8 | ); 9 | }; 10 | 11 | export default App; 12 | -------------------------------------------------------------------------------- /src/pages/popup/index.tsx: -------------------------------------------------------------------------------- 1 | import styles from './style.less'; 2 | 3 | const Popup = () => { 4 | return ( 5 |
6 |

popup page

7 |
8 | ); 9 | }; 10 | 11 | export default Popup; 12 | -------------------------------------------------------------------------------- /src/pages/popup/style.less: -------------------------------------------------------------------------------- 1 | .app { 2 | width: 480px; 3 | height: 240px; 4 | 5 | .title { 6 | text-align: center; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/utils/env.ts: -------------------------------------------------------------------------------- 1 | export const isDev = process.env.NODE_ENV === 'development'; 2 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './env'; 2 | -------------------------------------------------------------------------------- /tsconfig-check.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src", "types", "config", "scripts"], 3 | "compilerOptions": { 4 | /* Basic Options */ 5 | "jsx": "react-jsx", 6 | 7 | /* Strict Type-Checking Options */ 8 | "strict": true, 9 | 10 | /* Additional Checks */ 11 | "noUnusedLocals": true, 12 | "noUnusedParameters": true, 13 | "noImplicitReturns": true, 14 | "noFallthroughCasesInSwitch": true, 15 | 16 | /* Module Resolution Options */ 17 | "moduleResolution": "node", 18 | "esModuleInterop": true, 19 | "resolveJsonModule": true, 20 | 21 | /* Experimental Options */ 22 | "experimentalDecorators": true, 23 | "emitDecoratorMetadata": true, 24 | 25 | /* Advanced Options */ 26 | "forceConsistentCasingInFileNames": true, 27 | "skipLibCheck": true, 28 | 29 | // 下面这些选项对 babel 编译 TypeScript 没有作用但是可以让 VSCode 等编辑器正确提示错误 30 | "target": "ES2020", 31 | "module": "ESNext", 32 | // Alias 路径 33 | "baseUrl": ".", 34 | "paths": { 35 | "@/*": ["src/*"], 36 | "@@/*": ["src/.umi/*"] 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /types/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.css'; 2 | declare module '*.less'; 3 | declare module '*.png'; 4 | declare module '*.svg'; 5 | --------------------------------------------------------------------------------