1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-21 11:53:34 +00:00

Add Rust pre-commit hooks for desktop native (#17823)

This commit is contained in:
neuronull
2026-01-15 06:50:47 -08:00
committed by GitHub
parent d1be3b65f7
commit 6ef5241c29
11 changed files with 76 additions and 61 deletions

View File

@@ -128,7 +128,7 @@ jobs:
RUSTFLAGS: "-D warnings"
- name: Install cargo-sort
run: cargo install cargo-sort --locked --git https://github.com/DevinR528/cargo-sort.git --rev f5047967021cbb1f822faddc355b3b07674305a1
run: cargo install cargo-sort --locked --git https://github.com/DevinR528/cargo-sort.git --rev ac6e328faf467a39e38ab48dc60dcf4f6a46d7a5 # v2.0.2
- name: Cargo sort
working-directory: ./apps/desktop/desktop_native

View File

@@ -386,9 +386,9 @@ dependencies = [
[[package]]
name = "bitflags"
version = "2.9.0"
version = "2.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
[[package]]
name = "bitwarden-russh"
@@ -1731,19 +1731,18 @@ checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956"
[[package]]
name = "lock_api"
version = "0.4.12"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.25"
version = "0.4.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
[[package]]
name = "macos_provider"
@@ -2257,9 +2256,9 @@ checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba"
[[package]]
name = "parking_lot"
version = "0.12.3"
version = "0.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
dependencies = [
"lock_api",
"parking_lot_core",
@@ -2267,15 +2266,15 @@ dependencies = [
[[package]]
name = "parking_lot_core"
version = "0.9.10"
version = "0.9.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-targets 0.52.6",
"windows-link 0.2.1",
]
[[package]]
@@ -3010,9 +3009,9 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.15.0"
version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9"
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]]
name = "smawk"

View File

@@ -9,7 +9,7 @@ members = [
"napi",
"process_isolation",
"proxy",
"windows_plugin_authenticator"
"windows_plugin_authenticator",
]
[workspace.package]

View File

@@ -5,9 +5,6 @@ license.workspace = true
edition.workspace = true
publish.workspace = true
[dependencies]
anyhow = { workspace = true }
[target.'cfg(windows)'.dependencies]
itertools.workspace = true
mockall = "=0.14.0"
@@ -19,5 +16,8 @@ windows = { workspace = true, features = [
] }
windows-core = { workspace = true }
[dependencies]
anyhow = { workspace = true }
[lints]
workspace = true

View File

@@ -9,19 +9,19 @@ publish.workspace = true
[target.'cfg(target_os = "windows")'.dependencies]
aes-gcm = { workspace = true }
anyhow = { workspace = true }
base64 = { workspace = true }
chacha20poly1305 = { workspace = true }
chromium_importer = { path = "../chromium_importer" }
clap = { version = "=4.5.53", features = ["derive"] }
scopeguard = { workspace = true }
sysinfo = { workspace = true }
windows = { workspace = true, features = [
"Win32_System_Pipes",
] }
anyhow = { workspace = true }
base64 = { workspace = true }
tokio = { workspace = true, features = ["full"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
windows = { workspace = true, features = [
"Win32_System_Pipes",
] }
[build-dependencies]
embed-resource = "=3.0.6"

View File

@@ -16,6 +16,12 @@ rusqlite = { version = "=0.37.0", features = ["bundled"] }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
[target.'cfg(target_os = "linux")'.dependencies]
cbc = { workspace = true, features = ["alloc"] }
oo7 = { workspace = true }
pbkdf2 = "=0.12.2"
sha1 = "=0.10.6"
[target.'cfg(target_os = "macos")'.dependencies]
cbc = { workspace = true, features = ["alloc"] }
pbkdf2 = "=0.12.2"
@@ -25,20 +31,14 @@ sha1 = "=0.10.6"
[target.'cfg(target_os = "windows")'.dependencies]
aes-gcm = { workspace = true }
base64 = { workspace = true }
tokio = { workspace = true, features = ["full"] }
tracing = { workspace = true }
verifysign = "=0.2.4"
windows = { workspace = true, features = [
"Win32_Security_Cryptography",
"Win32_UI_Shell",
"Win32_UI_WindowsAndMessaging",
] }
verifysign = "=0.2.4"
tokio = { workspace = true, features = ["full"] }
tracing = { workspace = true }
[target.'cfg(target_os = "linux")'.dependencies]
cbc = { workspace = true, features = ["alloc"] }
oo7 = { workspace = true }
pbkdf2 = "=0.12.2"
sha1 = "=0.10.6"
[lints]
workspace = true

View File

@@ -13,7 +13,7 @@ default = [
"dep:security-framework",
"dep:security-framework-sys",
"dep:zbus",
"dep:zbus_polkit"
"dep:zbus_polkit",
]
manual_test = []
@@ -46,6 +46,23 @@ tracing = { workspace = true }
typenum = { workspace = true }
zeroizing-alloc = { workspace = true }
[target.'cfg(target_os = "linux")'.dependencies]
ashpd = { workspace = true }
homedir = { workspace = true }
libc = { workspace = true }
linux-keyutils = { workspace = true }
oo7 = { workspace = true }
zbus = { workspace = true, optional = true }
zbus_polkit = { workspace = true, optional = true }
[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = { workspace = true, optional = true }
desktop_objc = { path = "../objc" }
homedir = { workspace = true }
secmem-proc = { workspace = true }
security-framework = { workspace = true, optional = true }
security-framework-sys = { workspace = true, optional = true }
[target.'cfg(windows)'.dependencies]
pin-project = { workspace = true }
scopeguard = { workspace = true }
@@ -68,22 +85,5 @@ windows = { workspace = true, features = [
], optional = true }
windows-future = { workspace = true }
[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = { workspace = true, optional = true }
homedir = { workspace = true }
secmem-proc = { workspace = true }
security-framework = { workspace = true, optional = true }
security-framework-sys = { workspace = true, optional = true }
desktop_objc = { path = "../objc" }
[target.'cfg(target_os = "linux")'.dependencies]
ashpd = { workspace = true }
homedir = { workspace = true }
libc = { workspace = true }
linux-keyutils = { workspace = true }
oo7 = { workspace = true }
zbus = { workspace = true, optional = true }
zbus_polkit = { workspace = true, optional = true }
[lints]
workspace = true

View File

@@ -5,14 +5,14 @@ license = { workspace = true }
version = { workspace = true }
publish = { workspace = true }
[[bin]]
name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"
[lib]
crate-type = ["staticlib", "cdylib"]
bench = false
[[bin]]
name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"
[dependencies]
uniffi = { workspace = true, features = ["cli"] }
@@ -23,8 +23,8 @@ serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
tokio = { workspace = true, features = ["sync"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
tracing-oslog = "=0.3.0"
tracing-subscriber = { workspace = true }
[build-dependencies]
uniffi = { workspace = true, features = ["build"] }

View File

@@ -6,6 +6,7 @@ license = { workspace = true }
publish = { workspace = true }
[target.'cfg(windows)'.dependencies]
hex = { workspace = true }
windows = { workspace = true, features = [
"Win32_Foundation",
"Win32_Security",
@@ -13,7 +14,6 @@ windows = { workspace = true, features = [
"Win32_System_LibraryLoader",
] }
windows-core = { workspace = true }
hex = { workspace = true }
[lints]
workspace = true

20
lint-staged.config.mjs Normal file
View File

@@ -0,0 +1,20 @@
export default {
"*": "prettier --cache --ignore-unknown --write",
"*.ts": "eslint --cache --cache-strategy content --fix",
"apps/desktop/desktop_native/**/*.rs": (stagedFiles) => {
const relativeFiles = stagedFiles.map((f) =>
f.replace(/^.*apps\/desktop\/desktop_native\//, ""),
);
return [
`sh -c 'cd apps/desktop/desktop_native && cargo +nightly fmt -- ${relativeFiles.join(" ")}'`,
`sh -c 'cd apps/desktop/desktop_native && cargo clippy --all-features --all-targets --tests -- -D warnings'`,
];
},
"apps/desktop/desktop_native/**/Cargo.toml": () => {
return [
`sh -c 'cd apps/desktop/desktop_native && cargo sort --workspace --check'`,
`sh -c 'cd apps/desktop/desktop_native && cargo +nightly udeps --workspace --all-features --all-targets'`,
`sh -c 'cd apps/desktop/desktop_native && cargo deny --log-level error --all-features check all'`,
];
},
};

View File

@@ -221,10 +221,6 @@
"react-dom": "18.3.1",
"@types/react": "18.3.27"
},
"lint-staged": {
"*": "prettier --cache --ignore-unknown --write",
"*.ts": "eslint --cache --cache-strategy content --fix"
},
"engines": {
"node": ">=22.12.0",
"npm": "~10"