Skip to content

Commit fcb4cc4

Browse files
committed
♻️ 重构代码,升级为manifest v3
1 parent ad5a711 commit fcb4cc4

File tree

268 files changed

+21593
-43999
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+21593
-43999
lines changed

.eslintignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

.eslintrc.cjs

Lines changed: 0 additions & 72 deletions
This file was deleted.

.github/workflows/build.yaml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ jobs:
1212
runs-on: ubuntu-latest
1313
name: Build
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
16+
- uses: pnpm/action-setup@v4
17+
1618
- name: Use Node.js
17-
uses: actions/setup-node@v3
19+
uses: actions/setup-node@v4
1820
with:
19-
node-version: 20
20-
cache: 'npm'
21+
node-version: 22
22+
cache: 'pnpm'
2123

2224
- name: Package with Node
2325
env:
@@ -26,19 +28,19 @@ jobs:
2628
mkdir dist
2729
echo "$CHROME_PEM" > ./dist/scriptcat.pem
2830
chmod 600 ./dist/scriptcat.pem
29-
npm ci
30-
npm run pack
31+
pnpm i
32+
pnpm run pack
3133
3234
- name: Archive production artifacts
33-
uses: actions/upload-artifact@v3
35+
uses: actions/upload-artifact@v4
3436
with:
3537
name: all-artifacts
3638
path: |
3739
dist/*.zip
3840
dist/*.crx
3941
4042
- name: Archive extension
41-
uses: actions/upload-artifact@v3
43+
uses: actions/upload-artifact@v4
4244
with:
4345
name: scriptcat
4446
path: |

.github/workflows/packageRelease.yml

Lines changed: 10 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
15+
- uses: pnpm/action-setup@v4
16+
1517
- name: Use Node.js
16-
uses: actions/setup-node@v3
18+
uses: actions/setup-node@v4
1719
with:
18-
node-version: 20
19-
cache: 'npm'
20+
node-version: 22
21+
cache: 'pnpm'
2022

2123
- name: Package with Node
2224
env:
@@ -25,52 +27,9 @@ jobs:
2527
mkdir dist
2628
echo "$CHROME_PEM" > ./dist/scriptcat.pem
2729
chmod 600 ./dist/scriptcat.pem
28-
npm ci
29-
npm test
30-
npm run pack
31-
32-
- name: Create Release
33-
id: create_release
34-
uses: actions/create-release@latest
35-
env:
36-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
37-
with:
38-
tag_name: ${{ github.ref }}
39-
release_name: ${{ github.ref }}
40-
body: |
41-
'no description'
42-
draft: false
43-
prerelease: false
30+
pnpm i
31+
pnpm run pack
4432
45-
- name: Upload Release Asset zip
46-
id: upload-release-asset
47-
uses: actions/upload-release-asset@v1
48-
env:
49-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50-
with:
51-
upload_url: ${{ steps.create_release.outputs.upload_url }}
52-
asset_path: ./dist/scriptcat-${{ github.ref_name }}-chrome.zip
53-
asset_name: scriptcat-${{ github.ref_name }}-chrome.zip
54-
asset_content_type: application/zip
55-
56-
- name: Upload FireFox Release Asset zip
57-
id: upload-firefox-release-asset
58-
uses: actions/upload-release-asset@v1
59-
env:
60-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61-
with:
62-
upload_url: ${{ steps.create_release.outputs.upload_url }}
63-
asset_path: ./dist/scriptcat-${{ github.ref_name }}-firefox.zip
64-
asset_name: scriptcat-${{ github.ref_name }}-firefox.zip
65-
asset_content_type: application/zip
66-
67-
- name: Upload Crx Release Asset zip
68-
id: upload-crx-release-asset
69-
uses: actions/upload-release-asset@v1
70-
env:
71-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
- uses: ncipollo/release-action@v1
7234
with:
73-
upload_url: ${{ steps.create_release.outputs.upload_url }}
74-
asset_path: ./dist/scriptcat-${{ github.ref_name }}-chrome.crx
75-
asset_name: scriptcat-${{ github.ref_name }}-chrome.crx
76-
asset_content_type: application/zip
35+
artifacts: "./dist/*.zip,./dist/*.crx"

.github/workflows/test.yaml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,27 @@ name: test
33
on:
44
push:
55
branches:
6-
- main
7-
- release/*
8-
- dev
9-
- develop/*
10-
pull_request:
6+
- disable # 暂时禁用
7+
# pull_request:
118

129
jobs:
1310
tests:
1411
runs-on: ubuntu-latest
1512
name: Run tests
1613
steps:
17-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
15+
- uses: pnpm/action-setup@v4
16+
1817
- name: Use Node.js
19-
uses: actions/setup-node@v3
18+
uses: actions/setup-node@v4
2019
with:
21-
node-version: 20
22-
cache: 'npm'
20+
node-version: 22
21+
cache: 'pnpm'
2322

2423
- name: Unit Test
2524
run: |
26-
npm ci
27-
npm test
25+
pnpm i
26+
pnpm run coverage
2827
2928
- name: Upload coverage reports to Codecov with GitHub Action
30-
uses: codecov/codecov-action@v3
29+
uses: codecov/codecov-action@v5

.prettierignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
dist/
2-
example/
1+
# Lock files
2+
package-lock.json
3+
pnpm-lock.yaml
4+
yarn.lock

.prettierrc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
"htmlWhitespaceSensitivity": "css",
77
"insertPragma": false,
88
"jsxSingleQuote": false,
9-
"printWidth": 80,
10-
"proseWrap": "preserve",
9+
"printWidth": 120,
10+
"proseWrap": "always",
1111
"quoteProps": "as-needed",
1212
"requirePragma": false,
1313
"semi": true,
1414
"singleQuote": false,
1515
"tabWidth": 2,
1616
"trailingComma": "es5",
1717
"useTabs": false,
18-
"vueIndentScriptAndStyle": false,
1918
"endOfLine": "auto"
20-
}
19+
}

CONTRIBUTING.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,21 @@ ScriptCat 引起的,欢迎提交 Issue。在提交时,请附带详细的复
2020

2121
## Pull Request
2222

23-
ScriptCat 使用 [npm](https://www.npmjs.com/) 来管理项目依赖。如果你已经安装了
23+
ScriptCat 使用 [pnpm](https://pnpm.io/) 来管理项目依赖。如果你已经安装了
2424
npm,以下的命令可以帮助你快速配置开发环境:
2525

2626
```bash
2727
# 安装 node.js 依赖
28-
npm install
28+
pnpm install
2929
```
3030

31-
我们推荐使用代理来解决 npm 的网络问题,而不是使用镜像。
31+
我们推荐使用[代理](https://pnpm.io/npmrc#https-proxy)来解决 pnpm 的网络问题,而不是使用镜像。
3232

3333
```bash
34-
# 设置代理
35-
npm config set proxy=http://127.0.0.1:1080
34+
# 设置代理(linux/mac)
35+
export HTTPS_PROXY=http://127.0.0.1:1080
36+
# 设置代理(windows)
37+
set HTTPS_PROXY=http://127.0.0.1:1080
3638
```
3739

3840
### Commit 规范
@@ -102,6 +104,7 @@ ScriptCat 的页面开发使用了以下技术:
102104
- [React](https://reactjs.org/)
103105
- UI 框架 [arco](https://arco.design)
104106
- CSS 框架 [unocss](https://unocss.dev/interactive/)
107+
- RsPack 打包工具 [rspack](https://rspack.dev/)
105108

106109
如果你想在本地运行 ScriptCat,可以使用以下命令:
107110

@@ -117,7 +120,6 @@ npm run pack
117120

118121
在打包前,请确保在`dist`目录下生成了`scriptcat.pem`文件。
119122

120-
# 注意问题
123+
## 注意问题
121124

122-
- 使用`yarn install`时可能会出现错误,最好使用`npm i`
123-
- `npm run dev`之后需要把`dist/ext`目录里面内容在浏览器扩展里面导入加载,然后开始改代码保存即可,浏览器是实时更新的
125+
- `npm run dev`之后需要把`dist/ext`目录里面内容在浏览器扩展里面导入加载,然后开始改代码保存即可,浏览器是实时更新的,但是涉及到`manifest.json``service_worker``offscreen``sandbox`的改动需要重新导入加载。

0 commit comments

Comments
 (0)