Skip to content

Commit

Permalink
修改打包程序,打包时去除无用文件
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjingxyk committed Aug 1, 2022
1 parent d949743 commit a03e89c
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Zip Extension
run: npm run build
run: npm run release
- name: Browser Plugin Publish
uses: PlasmoHQ/bpp@v2
with:
artifact: "extension.zip"
artifact: "dist/extension-v3.zip"
keys: ${{ secrets.SUBMIT_KEYS }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ package-lock.json
extension/tools/venv/
extension/tools/chrome-linux.zip
extension/tools/chrome-linux/
extension/test/nohup.out
extension/test/nohup.out
dist
2 changes: 2 additions & 0 deletions extension-v2/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ chrome.webRequest.onBeforeRequest.addListener(
//"cdn.jsdelivr.net/npm/bootstrap@$1/dist/$2"
"lib.baomitu.com/twitter-bootstrap/$1/$2"
);
url = url.replace("developers.google.com", "developers.google.cn");
return { redirectUrl: url };
},
{
Expand All @@ -257,6 +258,7 @@ chrome.webRequest.onBeforeRequest.addListener(
"*://www.gravatar.com/*",
"*://maxcdn.bootstrapcdn.com/bootstrap/*",
"*://cdn.jsdelivr.net/*",
"*://developers.google.com/*",
// ...test_urls // 测试用例
],
},
Expand Down
8 changes: 4 additions & 4 deletions extension/rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
7. [jsdelivr](https://www.jsdelivr.com/)
8. [unpkg](https://unpkg.com/)
9. [cloudflare ](https://cdnjs.com/)
11. [google libraries cn](https://developers.google.cn/speed/libraries)
12. [七牛静态库](http://staticfile.org/)
13. [极客族公共加速服务](https://cdn.geekzu.org/cached.html)
14. [中科大反向代理列表如下:](https://mirrors.ustc.edu.cn/)
10. [google libraries cn](https://developers.google.cn/speed/libraries)
11. [七牛静态库](http://staticfile.org/)
12. [极客族公共加速服务](https://cdn.geekzu.org/cached.html)
13. [中科大反向代理列表如下:](https://mirrors.ustc.edu.cn/)

```text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
1. 广告拦截
2. 访问 chromium source code 等

## 使用`tools`目录下的辅助工具方便快捷
## 配合`tools`目录下的辅助工具方便快捷
File renamed without changes.
2 changes: 0 additions & 2 deletions extension/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@
4. [`cdn.jsdelivr.net` 替换为 `fastly.jsdelivr.net` 打开 `https://cdn.jsdelivr.net/` 查看结果 ](https://cdn.jsdelivr.net/)
5. [`cdnjs.cloudflare.com` 替换为 `cdnjs.loli.net` 打开 `https://cdnjs.cloudflare.com/` 查看结果 ](https://cdnjs.cloudflare.com/ajax/libs/reveal.js/4.1.2/reveal.min.css)
6. [`developers.google.com` 替换为 `developers.google.cn` 打开 `https://developers.google.cn/` 查看结果 ](https://developers.google.cn)

##
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"private": true,
"scripts": {
"fmt": "prettier --write \"extension/**/*.{ts,js}\"",
"build": "cd extension/; zip -r ../extension.zip .; cd -"
"build": "mkdir -p dist ; cd extension/; zip -r ../dist/extension-v3.zip . -x './tools/*' -x './_metadata/*' -x './test/*' -x './rules/advance-no-use/*' -x './rules/example-no-use/*'; cd -",
"release": "bash release-archive.sh"
},
"devDependencies": {
"@types/chrome": "^0.0.139",
Expand Down
46 changes: 46 additions & 0 deletions release-archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
cd ${__DIR__}

test -d dist && rm -rf dist
mkdir -p dist

test -f dist/extension-v2.zip && rm -f dist/extension-v2.zip
test -f dist/extension-v3.zip && rm -f dist/extension-v3.zip

# 打包 manifest v3
cd ${__DIR__}/extension/

zip -r ../dist/extension-v3.zip . \
-x "./tools/*" \
-x "./_metadata/*" \
-x "./test/*" \
-x "./rules/advance/*" \
-x "./rules/example-no-use/*" \
-x "./rules/README.md"


cd ${__DIR__}


# 打包 manifest v2
cd ${__DIR__}/extension-v2/

zip -r ../dist/extension-v2.zip . \
-x "./README.md"


cd ${__DIR__}



cd dist
unzip extension-v2.zip -d extension-v2
unzip extension-v3.zip -d extension-v3

cd ${__DIR__}

0 comments on commit a03e89c

Please sign in to comment.