Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: auto bump deps via renovate #33

Merged
merged 12 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
extends: [
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:prettier/recommended",
],
ignorePatterns: ["index.html", "node_modules/", "dist/", "backend/**/target"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
rules: {
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"react/react-in-jsx-scope": "off",
},
settings: {
react: {
version: "detect",
},
"import/resolver": {
alias: {
map: [
["@", "./src"],
["@root", "./"],
],
extensions: [".tsx", ".ts", ".jsx", ".js", ".mjs", ".cjs"],
},
},
},
};
208 changes: 208 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
on:
pull_request:
branches: [main, dev]
push:
branches: [main, dev]

# the name of our workflow
name: CI

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Rust
run: rustup toolchain install stable --profile minimal && rustup default stable && rustup component add clippy rustfmt && rustc --version && cargo --version && rustup show
- name: Tauri dependencies
run: >-
sudo apt-get update &&
sudo apt-get install -y
libgtk-3-dev
libayatana-appindicator3-dev
libwebkit2gtk-4.0-dev
webkit2gtk-driver
xvfb
- uses: Swatinem/rust-cache@v2
with:
workspaces: "./backend/"
prefix-key: "rust-stable"
shared-key: "ci"
save-if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' }}

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

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install

- name: Prepare fronend
run: pnpm web:build # Build frontend
- name: Prepare sidecar and resources
run: pnpm check
- name: Lint
run: pnpm lint # Lint

test_unit:
name: Unit Test
needs: lint
# we want to run on the latest linux environment
runs-on: ubuntu-latest

# the steps our job runs **in order**
steps:
# checkout the code on the workflow runner
- uses: actions/checkout@v4

# install system dependencies that Tauri needs to compile on Linux.
# note the extra dependencies for `tauri-driver` to run which are: `webkit2gtk-driver` and `xvfb`
- name: Tauri dependencies
run: >-
sudo apt-get update &&
sudo apt-get install -y
libgtk-3-dev
libayatana-appindicator3-dev
libwebkit2gtk-4.0-dev
webkit2gtk-driver
xvfb

# install the latest Rust stable
- name: Rust stable
run: rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
with:
workspaces: "./backend/"
prefix-key: "rust-stable"
shared-key: "ci"
save-if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' }}

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

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install
- name: Prepare fronend
run: pnpm web:build # Build frontend
- name: Prepare sidecar and resources
run: pnpm check
- name: Test
# run: pnpm test:unit && pnpm test:backend
run: pnpm test:backend

# test_e2e:
# # the display name of the test job
# name: E2E Test
# needs: lint
# # we want to run on the latest linux environment
# runs-on: ubuntu-latest

# # the steps our job runs **in order**
# steps:
# # checkout the code on the workflow runner
# - uses: actions/checkout@v4

# # install system dependencies that Tauri needs to compile on Linux.
# # note the extra dependencies for `tauri-driver` to run which are: `webkit2gtk-driver` and `xvfb`
# - name: Tauri dependencies
# run: >-
# sudo apt-get update &&
# sudo apt-get install -y
# libgtk-3-dev
# libayatana-appindicator3-dev
# libwebkit2gtk-4.0-dev
# webkit2gtk-driver
# xvfb

# # install the latest Rust stable
# - name: Rust stable
# run: rustup toolchain install stable --profile minimal
# - uses: Swatinem/rust-cache@v2
# with:
# workspaces: "./backend/"
# prefix-key: "rust-stable"
# shared-key: "ci"
# save-if: ${{ github.ref == 'refs/heads/main' }}
# - name: Install Node.js
# uses: actions/setup-node@v4
# with:
# node-version: 20

# - uses: pnpm/action-setup@v2
# name: Install pnpm
# with:
# version: 8
# run_install: false

# - name: Get pnpm store directory
# shell: bash
# run: |
# echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

# - uses: actions/cache@v3
# name: Setup pnpm cache
# with:
# path: ${{ env.STORE_PATH }}
# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-pnpm-store-

# - name: Install dependencies
# run: pnpm install

# # install the latest version of `tauri-driver`.
# # note: the tauri-driver version is independent of any other Tauri versions
# - name: Install tauri-driver
# uses: actions-rs/cargo@v1
# with:
# command: install
# args: tauri-driver
# - name: Prepare fronend
# run: pnpm build # Build frontend
# # run the WebdriverIO test suite.
# # we run it through `xvfb-run` (the dependency we installed earlier) to have a fake
# # display server which allows our application to run headless without any changes to the code
# - name: Test
# run: xvfb-run pnpm test:e2e
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ dist-ssr
update.json
scripts/_env.sh
.vscode

.eslintcache
.stylelintcache
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm commitlint --edit ${1}
5 changes: 4 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm pretty-quick --staged
# If tty is available, apply fix from https://github.com/typicode/husky/issues/968#issuecomment-1176848345
if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then exec >/dev/tty 2>&1; fi

pnpm lint-staged
18 changes: 18 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
"*.{js,cjs,.mjs,jsx}": ["prettier --write", "eslint --cache --fix"],
"*.{ts,tsx}": [
"prettier --write",
"eslint --cache --fix",
() => "tsc -p tsconfig.json --noEmit",
],
"backend/**/*.{rs,toml}": [
() =>
"cargo clippy --manifest-path=./backend/Cargo.toml --all-targets --all-features",
() => "cargo fmt --manifest-path ./backend/Cargo.toml --all",
// () => 'cargo test --manifest-path=./backend/Cargo.toml',
() => "cargo fmt --manifest-path=./backend/Cargo.toml --all",
],
"*.{html,sass,scss,less}": ["prettier --write", "stylelint --fix"],
"package.json": ["prettier --write"],
"*.{md,json,jsonc,json5,yaml,yml,toml}": ["prettier --write"],
};
2 changes: 2 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
backend/**/target
68 changes: 68 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
module.exports = {
root: true,
defaultSeverity: "error",
plugins: [
"stylelint-scss",
"stylelint-order",
"stylelint-declaration-block-no-ignored-properties",
],
extends: [
"stylelint-config-standard",
"stylelint-config-html/html", // the shareable html config for Stylelint.
"stylelint-config-recess-order",
// 'stylelint-config-prettier'
],
rules: {
"font-family-name-quotes": null,
"font-family-no-missing-generic-family-keyword": null,
"max-nesting-depth": [
4,
{
ignore: ["blockless-at-rules", "pseudo-classes"],
},
],
"declaration-block-no-duplicate-properties": true,
"no-duplicate-selectors": true,
"no-descending-specificity": null,
"selector-class-pattern": "^([a-z][a-z0-9]*)((-|__)[a-z0-9]+)*$",
"value-no-vendor-prefix": [true, { ignoreValues: ["box"] }],
"at-rule-no-unknown": [
true,
{
ignoreAtRules: [
"tailwind",
"unocss",
"layer",
"apply",
"variants",
"responsive",
"screen",
],
},
],
},
overrides: [
{
files: ["**/*.scss", "*.scss"],
customSyntax: require("postcss-scss"),
rules: {
"at-rule-no-unknown": null,
"import-notation": null,
"scss/at-rule-no-unknown": [
true,
{
ignoreAtRules: [
"tailwind",
"unocss",
"layer",
"apply",
"variants",
"responsive",
"screen",
],
},
],
},
},
],
};
5 changes: 4 additions & 1 deletion backend/tauri/src/config/prfitem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ impl PrfItem {

// 使用软件自己的代理
if self_proxy {
let port = Config::verge().latest().verge_mixed_port.unwrap_or(Config::clash().data().get_mixed_port());
let port = Config::verge()
.latest()
.verge_mixed_port
.unwrap_or(Config::clash().data().get_mixed_port());

let proxy_scheme = format!("http://127.0.0.1:{port}");

Expand Down
8 changes: 4 additions & 4 deletions backend/tauri/src/config/verge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ pub struct IVerge {
#[serde(skip_serializing_if = "Option::is_none")]
pub window_size_position: Option<Vec<f64>>,

/// 是否启用随机端口
pub enable_random_port: Option<bool>,
/// 是否启用随机端口
pub enable_random_port: Option<bool>,

/// verge mixed port 用于覆盖 clash 的 mixed port
pub verge_mixed_port: Option<u16>,
/// verge mixed port 用于覆盖 clash 的 mixed port
pub verge_mixed_port: Option<u16>,
}

#[derive(Default, Debug, Clone, Deserialize, Serialize)]
Expand Down
Loading
Loading