Skip to content

Commit 3aca7b6

Browse files
committed
build: rspack
1 parent 4f77862 commit 3aca7b6

37 files changed

Lines changed: 6742 additions & 1549 deletions

.github/RELEASE-TEMPLATE.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### 🆕 New Features
2+
* none
3+
4+
### 🛠️ Bug Fixes
5+
* none
6+
7+
### 🔣 Dependencies
8+
* none
9+
10+
### ‼️ Breaking Changes
11+
* none
12+
13+
### 🔄 Other Changes
14+
* none

.github/workflows/build.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build
2+
on:
3+
workflow_call:
4+
workflow_dispatch:
5+
6+
permissions:
7+
actions: read
8+
contents: read
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@main
16+
with:
17+
submodules: recursive
18+
token: ${{ secrets.SUBMODULE_TOKEN }}
19+
- name: Set up Node.js
20+
uses: actions/setup-node@main
21+
with:
22+
node-version: 'latest'
23+
cache: 'npm'
24+
- name: Install dependencies
25+
run: npm install
26+
- name: Update local package.json version from release tag
27+
if: github.ref_type == 'tag'
28+
uses: BellCubeDev/update-package-version-by-release-tag@v2
29+
with:
30+
version: ${{ github.ref_name }}
31+
keep-v: "false" # If set to "true", will not remove any 'v' prefix from the version number.
32+
ignore-semver-check: "false" # If set to "true", will not check if the version number is a valid semver version.
33+
- name: Build scripts
34+
run: npm run build
35+
- name: Generate modules
36+
run: npm run build:args
37+
- name: Upload artifact
38+
uses: actions/upload-artifact@master
39+
with:
40+
name: artifact
41+
path: |
42+
CHANGELOG.md
43+
rulesets
44+
dist

.github/workflows/deploy.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Deploy
2+
on:
3+
push:
4+
# Sequence of patterns matched against refs/heads
5+
branches:
6+
- dev
7+
8+
permissions:
9+
actions: read
10+
contents: read
11+
12+
jobs:
13+
debug:
14+
uses: ./.github/workflows/dev.yml
15+
secrets: inherit
16+
deploy:
17+
needs: debug
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Download artifact
21+
uses: actions/download-artifact@master
22+
with:
23+
name: artifact
24+
- name: Deploy
25+
uses: exuanbo/actions-deploy-gist@main
26+
with:
27+
token: ${{ secrets.GIST_TOKEN }}
28+
gist_id: c7d70898da568b0a3bbee5bfd3c07f95
29+
gist_description: "🍿️ DualSubs: ➕ AddOn (Microsoft Translate)"
30+
file_path: dist/Microsoft.Translate.bundle.js

.github/workflows/dev.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Dev
2+
on:
3+
workflow_call:
4+
workflow_dispatch:
5+
6+
permissions:
7+
actions: read
8+
contents: read
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@main
16+
with:
17+
submodules: recursive
18+
token: ${{ secrets.SUBMODULE_TOKEN }}
19+
ref: dev
20+
- name: Set up Node.js
21+
uses: actions/setup-node@main
22+
with:
23+
node-version: 'latest'
24+
cache: 'npm'
25+
- name: Install dependencies
26+
run: npm install
27+
- name: Build
28+
run: npm run build:dev
29+
- name: Upload artifact
30+
uses: actions/upload-artifact@master
31+
with:
32+
name: artifact
33+
path: |
34+
CHANGELOG.md
35+
rulesets
36+
dist

.github/workflows/draft.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Draft
2+
on:
3+
push:
4+
# Sequence of patterns matched against refs/heads
5+
branches:
6+
- main
7+
8+
permissions:
9+
actions: read
10+
contents: write
11+
12+
jobs:
13+
build:
14+
uses: ./.github/workflows/build.yml
15+
secrets: inherit
16+
draft:
17+
needs: build
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Download artifact
21+
uses: actions/download-artifact@master
22+
with:
23+
name: artifact
24+
- name: Publish Draft
25+
uses: softprops/action-gh-release@v2
26+
with:
27+
body_path: CHANGELOG.md
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
files: |
30+
rulesets/*
31+
dist/*
32+
draft: true

.github/workflows/pre-release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Pre-Release
2+
on:
3+
push:
4+
# Sequence of patterns matched against refs/tags
5+
tags:
6+
- v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+
7+
- v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+
8+
9+
permissions:
10+
actions: read
11+
contents: write
12+
13+
jobs:
14+
build:
15+
uses: ./.github/workflows/build.yml
16+
secrets: inherit
17+
pre-release:
18+
needs: build
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Download artifact
22+
uses: actions/download-artifact@master
23+
with:
24+
name: artifact
25+
- name: Publish Pre-Release
26+
uses: softprops/action-gh-release@v2
27+
with:
28+
body_path: CHANGELOG.md
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
files: |
31+
rulesets/*
32+
dist/*
33+
prerelease: true

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Release
2+
on:
3+
push:
4+
# Sequence of patterns matched against refs/tags
5+
tags:
6+
- v[0-9]+.[0-9]+.[0-9]+
7+
8+
permissions:
9+
actions: read
10+
contents: write
11+
12+
jobs:
13+
build:
14+
uses: ./.github/workflows/build.yml
15+
secrets: inherit
16+
release:
17+
needs: build
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Download artifact
21+
uses: actions/download-artifact@master
22+
with:
23+
name: artifact
24+
- name: Publish Release
25+
uses: softprops/action-gh-release@v2
26+
with:
27+
body_path: CHANGELOG.md
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
files: |
30+
rulesets/*
31+
dist/*
32+
make_latest: "true"

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### 🔄 Other Changes
2+
* 打包器由 `rollup` 更改为 `rspack`

arguments-builder.config.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { defineConfig } from "@iringo/arguments-builder";
2+
3+
export default defineConfig({
4+
output: {
5+
surge: {
6+
path: "./dist/Microsoft.Translate.sgmodule",
7+
},
8+
loon: {
9+
path: "./dist/Microsoft.Translate.plugin",
10+
},
11+
customItems: [
12+
{
13+
path: "./dist/Microsoft.Translate.stoverride",
14+
template: "./template/stash.handlebars",
15+
},
16+
{
17+
path: "./dist/Microsoft.Translate.yaml",
18+
template: "./template/egern.handlebars",
19+
},
20+
],
21+
dts: {
22+
isExported: true,
23+
path: "./src/types.d.ts",
24+
},
25+
boxjsSettings: {
26+
path: "./template/boxjs.settings.json",
27+
scope: "@DualSubs.AddOn.Settings",
28+
},
29+
},
30+
args: [
31+
{
32+
key: "Switch",
33+
name: "总功能开关",
34+
defaultValue: true,
35+
type: "boolean",
36+
description: "是否启用此APP修改",
37+
exclude: ["surge", "loon"],
38+
},
39+
],
40+
});

biome.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"files": {
4+
"ignore": [
5+
"**/*.bundle.js"
6+
],
7+
"ignoreUnknown": false
8+
},
9+
"formatter": {
10+
"enabled": true,
11+
"indentStyle": "tab",
12+
"indentWidth": 2,
13+
"lineEnding": "lf",
14+
"lineWidth": 240
15+
},
16+
"javascript": {
17+
"formatter": {
18+
"arrowParentheses": "asNeeded",
19+
"bracketSameLine": true,
20+
"quoteStyle": "double"
21+
}
22+
},
23+
"json": {
24+
"parser": {
25+
"allowComments": true,
26+
"allowTrailingCommas": true
27+
}
28+
},
29+
"linter": {
30+
"enabled": true,
31+
"rules": {
32+
"complexity": {
33+
"noForEach": "off",
34+
"noStaticOnlyClass": "off",
35+
"noUselessSwitchCase": "off",
36+
"useArrowFunction": "info",
37+
"useFlatMap": "off",
38+
"useLiteralKeys": "info"
39+
},
40+
"correctness": {
41+
"noInnerDeclarations": "info",
42+
"noSelfAssign": "off",
43+
"noSwitchDeclarations": "info"
44+
},
45+
"recommended": true,
46+
"style": {
47+
"noNegationElse": "off",
48+
"noParameterAssign": "off",
49+
"noUselessElse": "off",
50+
"noVar": "info",
51+
"useDefaultParameterLast": "info",
52+
"useForOf": "error",
53+
"useNodejsImportProtocol": "error",
54+
"useNumberNamespace": "error",
55+
"useSingleVarDeclarator": "off"
56+
},
57+
"suspicious": {
58+
"noAssignInExpressions": "info",
59+
"noFallthroughSwitchClause": "info",
60+
"useDefaultSwitchClauseLast": "off"
61+
}
62+
}
63+
},
64+
"organizeImports": {
65+
"enabled": true
66+
},
67+
"vcs": {
68+
"clientKind": "git",
69+
"enabled": true,
70+
"useIgnoreFile": true
71+
}
72+
}

0 commit comments

Comments
 (0)