Skip to content

Commit

Permalink
refactor: build
Browse files Browse the repository at this point in the history
Co-authored-by: lainio24 <[email protected]>
  • Loading branch information
WakelessSloth56 and lainio24 committed Jul 16, 2024
1 parent b2899df commit bde81e4
Show file tree
Hide file tree
Showing 27 changed files with 2,490 additions and 644 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml]
indent_size = 2
28 changes: 20 additions & 8 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,39 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Pages
uses: actions/configure-pages@v3
uses: actions/configure-pages@v4

- name: Build
- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install and Build
run: |
chmod +x ./build.sh
./build.sh
pnpm install
pnpm run build
- name: Archive Artifact
shell: sh
run: |
tar \
--dereference --hard-dereference \
--directory "./public" \
--directory "./build" \
-cvf "$RUNNER_TEMP/artifact.tar" \
.
- name: Upload Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: github-pages
path: ${{ runner.temp }}/artifact.tar
Expand All @@ -55,4 +67,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ temp

node_modules

public/lib
src/lib
src/lib/*
!src/lib/*.d.ts

public/*.js
public/*.js.map
public
build
7 changes: 4 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
src/lib/*
assets/lib/*
assets/dist/*
src/lib/*.js
src/lib/*.css
public/*
build/*
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"cSpell.words": ["danmaku", "danmakuload", "stime"],
"cSpell.words": ["assjs", "danmaku", "danmakuload", "stime"],
"conventionalCommits.scopes": ["repo", "utils", "player", "pages", "start"],
"prettier.printWidth": 120,
"markdownlint.config": {
Expand Down
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,32 @@
## 关于

使用 TypeScript 重构并开源了很早之前 PCC-Studio 编写与内部使用的项目。
> ~~LainIO24:早期的雪山代码并没有得到重构,反而堆得更高力(悲~~

自提交 `9eddaae4` 起加入了更多的新功能。
<details>

## 使用
<summary>🏔</summary>

早期的雪山代码并没有得到重构,反而堆得更高力(悲

- [网站版](https://hi.auioc.org/BilibiliLocalPlayerH5)
- [单文件版](https://hi.auioc.org/BilibiliLocalPlayerH5/aio.html):使用“另存为……”可保存为单个 HTML 文件到本地离线使用。
</details>

两版本功能完全相同。
## 使用

- <https://hi.auioc.org/BilibiliLocalPlayerH5>

## 开发

1. 克隆项目到本地
2. 下载 [`CommentCoreLibrary.js`](https://github.com/jabbany/CommentCoreLibrary/raw/19db2962ed0ce637a2b99facdf8634d51bb1b503/dist/CommentCoreLibrary.js)[`ass.js`](https://github.com/weizhenye/ASS/raw/e6a3605a2343655d9ef80bdd7e9fe92f92edca22/dist/ass.js)`src/lib`
3. 运行 `tsc` 指令构建 `public/player.js`
4. 浏览器打开 `public/index.html` 即可使用或调试
2. `pnpm install`
3. 下载 `CommentCoreLibrary``src/lib`[^1]

- [`CommentCoreLibrary.js`](https://unpkg.com/[email protected]/dist/CommentCoreLibrary.js)
- [`CommentCoreLibrary.css`](https://unpkg.com/[email protected]/dist/css/style.css)

注意事项:
4. 运行 `pnpm run build:dev`
5. 浏览器打开 `public/index.html`

- 本项目构建不需要项目级别的 NPM 包,需要的只有用于编译 TypeScript 的全局包 `typescript`
- `build.sh` 脚本用于持续集成自动构建,开发时一般不需要使用,在本地使用可能会破坏项目结构!
[^1]: <https://github.com/jabbany/CommentCoreLibrary/issues/94>

## 致谢

Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh

mkdir temp
mkdir public
mkdir build

# NPM
npm install -g typescript
Expand Down
61 changes: 61 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"name": "bilibili-local-player-h5",
"version": "2.0.0",
"description": "bilibili-local-player-h5",
"main": "index.js",
"type": "module",
"scripts": {
"dev:html": "cross-env NODE_ENV=development node scripts/build-html.cjs",
"dev:script": "cross-env NODE_ENV=development rollup -c --bundleConfigAsCjs",
"dev:style": "cross-env NODE_ENV=development node scripts/build-style.cjs",
"prod:html": "cross-env NODE_ENV=production node scripts/build-html.cjs",
"prod:script": "cross-env NODE_ENV=production rollup -c --bundleConfigAsCjs",
"prod:style": "cross-env NODE_ENV=production node scripts/build-style.cjs",
"watch:html": "onchange -i \"src/html/*\" -- pnpm run dev:html",
"watch:script": "rollup -c rollup.config.js --bundleConfigAsCjs --watch",
"watch:style": "onchange -i \"src/style/*\" -- pnpm run dev:style",
"build:dev": "pnpm run dev:html && pnpm run dev:style && pnpm run dev:script",
"build": "pnpm run prod:html && pnpm run prod:style && pnpm run prod:script"
},
"keywords": [],
"homepage": "https://hi.auioc.org/BilibiliLocalPlayerH5/",
"author": {
"name": "PCC-Studio",
"url": "https://www.pccstudio.com"
},
"contributors": [
{
"name": "LainIO24",
"email": "[email protected]",
"url": "https://github.com/lainio24"
},
{
"name": "WakelessSloth56",
"url": "https://github.com/WakelessSloth56"
},
{
"name": "AUIOC",
"url": "https://www.auioc.org"
}
],
"license": "AGPL-3.0-or-later",
"dependencies": {
"assjs": "^0.0.11"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-legacy": "^3.0.2",
"@rollup/plugin-replace": "^5.0.7",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@types/node": "^20.14.10",
"cross-env": "^7.0.3",
"html-minifier-terser": "^7.2.0",
"node-html-parser": "^6.1.13",
"onchange": "^7.1.0",
"rollup": "^4.18.1",
"terser": "^5.31.2",
"tslib": "^2.6.3",
"typescript": "^5.5.3"
}
}
Loading

0 comments on commit bde81e4

Please sign in to comment.