Make lemmy_api_common wasm-compatible (#3587)

* Fixing lemmy_api_common optionals

* Adding taplo for .toml files.

* Versioning taplo in woodpecker.

* Addressing PR comments.
This commit is contained in:
Dessalines 2023-07-14 04:45:18 -04:00 committed by GitHub
parent 39f28c1a40
commit 164f4b93d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 155 additions and 76 deletions

View file

@ -1,5 +1,5 @@
tab_spaces = 2 tab_spaces = 2
edition="2021" edition = "2021"
imports_layout="HorizontalVertical" imports_layout = "HorizontalVertical"
imports_granularity="Crate" imports_granularity = "Crate"
group_imports="One" group_imports = "One"

View file

@ -27,6 +27,11 @@ pipeline:
commands: commands:
- prettier -c . '!**/volumes' '!**/dist' '!target' '!**/translations' - prettier -c . '!**/volumes' '!**/dist' '!target' '!**/translations'
taplo_check:
image: tamasfe/taplo:0.8.1
commands:
- taplo format --check
# use minimum supported rust version for most steps # use minimum supported rust version for most steps
cargo_fmt: cargo_fmt:
image: *muslrust_image image: *muslrust_image
@ -87,6 +92,13 @@ pipeline:
- "! cargo tree -p lemmy_api_common --no-default-features -i diesel" - "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
# when: # when:
# platform: linux/amd64 # platform: linux/amd64
lemmy_api_common_works_with_wasm:
image: *muslrust_image
environment:
CARGO_HOME: .cargo
commands:
- "rustup target add wasm32-unknown-unknown"
- "cargo check --target wasm32-unknown-unknown -p lemmy_api_common"
check_defaults_hjson_updated: check_defaults_hjson_updated:
image: *muslrust_image image: *muslrust_image

36
Cargo.lock generated
View file

@ -346,7 +346,7 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
dependencies = [ dependencies = [
"getrandom 0.2.8", "getrandom 0.2.10",
"once_cell", "once_cell",
"version_check", "version_check",
] ]
@ -358,7 +358,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"getrandom 0.2.8", "getrandom 0.2.10",
"once_cell", "once_cell",
"version_check", "version_check",
] ]
@ -678,7 +678,7 @@ checksum = "28d1c9c15093eb224f0baa400f38fcd713fc1391a6f1c389d886beef146d60a3"
dependencies = [ dependencies = [
"base64 0.21.2", "base64 0.21.2",
"blowfish", "blowfish",
"getrandom 0.2.8", "getrandom 0.2.10",
"subtle", "subtle",
"zeroize", "zeroize",
] ]
@ -2045,9 +2045,9 @@ dependencies = [
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.8" version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"js-sys", "js-sys",
@ -2397,17 +2397,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "idna"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8"
dependencies = [
"matches",
"unicode-bidi",
"unicode-normalization",
]
[[package]] [[package]]
name = "idna" name = "idna"
version = "0.3.0" version = "0.3.0"
@ -2649,6 +2638,7 @@ dependencies = [
"chrono", "chrono",
"encoding", "encoding",
"futures", "futures",
"getrandom 0.2.10",
"lemmy_db_schema", "lemmy_db_schema",
"lemmy_db_views", "lemmy_db_views",
"lemmy_db_views_actor", "lemmy_db_views_actor",
@ -3162,12 +3152,6 @@ dependencies = [
"regex-automata 0.1.10", "regex-automata 0.1.10",
] ]
[[package]]
name = "matches"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]] [[package]]
name = "matchit" name = "matchit"
version = "0.5.0" version = "0.5.0"
@ -3195,7 +3179,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5736ba45bbac8f7ccc99a897f88ce85e508a18baec973a040f2514e6cdbff0d2" checksum = "5736ba45bbac8f7ccc99a897f88ce85e508a18baec973a040f2514e6cdbff0d2"
dependencies = [ dependencies = [
"idna 0.2.3", "idna 0.3.0",
"once_cell", "once_cell",
"regex", "regex",
] ]
@ -4271,7 +4255,7 @@ version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [ dependencies = [
"getrandom 0.2.8", "getrandom 0.2.10",
] ]
[[package]] [[package]]
@ -4437,7 +4421,7 @@ checksum = "1b97ad83c2fc18113346b7158d79732242002427c30f620fa817c1f32901e0a8"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
"getrandom 0.2.8", "getrandom 0.2.10",
"matchit 0.7.0", "matchit 0.7.0",
"opentelemetry 0.16.0", "opentelemetry 0.16.0",
"reqwest", "reqwest",
@ -5915,7 +5899,7 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be" checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be"
dependencies = [ dependencies = [
"getrandom 0.2.8", "getrandom 0.2.10",
"serde", "serde",
] ]

View file

@ -31,7 +31,13 @@ debug = 0
[features] [features]
embed-pictrs = ["pict-rs"] embed-pictrs = ["pict-rs"]
console = ["console-subscriber", "opentelemetry", "opentelemetry-otlp", "tracing-opentelemetry", "reqwest-tracing/opentelemetry_0_16"] console = [
"console-subscriber",
"opentelemetry",
"opentelemetry-otlp",
"tracing-opentelemetry",
"reqwest-tracing/opentelemetry_0_16",
]
json-log = ["tracing-subscriber/json"] json-log = ["tracing-subscriber/json"]
prometheus-metrics = ["prometheus", "actix-web-prom"] prometheus-metrics = ["prometheus", "actix-web-prom"]
default = [] default = []
@ -47,7 +53,7 @@ members = [
"crates/db_views", "crates/db_views",
"crates/db_views_actor", "crates/db_views_actor",
"crates/db_views_actor", "crates/db_views_actor",
"crates/routes" "crates/routes",
] ]
[workspace.dependencies] [workspace.dependencies]
@ -61,13 +67,21 @@ lemmy_routes = { version = "=0.18.1", path = "./crates/routes" }
lemmy_db_views = { version = "=0.18.1", path = "./crates/db_views" } lemmy_db_views = { version = "=0.18.1", path = "./crates/db_views" }
lemmy_db_views_actor = { version = "=0.18.1", path = "./crates/db_views_actor" } lemmy_db_views_actor = { version = "=0.18.1", path = "./crates/db_views_actor" }
lemmy_db_views_moderator = { version = "=0.18.1", path = "./crates/db_views_moderator" } lemmy_db_views_moderator = { version = "=0.18.1", path = "./crates/db_views_moderator" }
activitypub_federation = { version = "0.4.5", default-features = false, features = ["actix-web"] } activitypub_federation = { version = "0.4.5", default-features = false, features = [
"actix-web",
] }
diesel = "2.1.0" diesel = "2.1.0"
diesel_migrations = "2.1.0" diesel_migrations = "2.1.0"
diesel-async = "0.3.1" diesel-async = "0.3.1"
serde = { version = "1.0.167", features = ["derive"] } serde = { version = "1.0.167", features = ["derive"] }
serde_with = "3.0.0" serde_with = "3.0.0"
actix-web = { version = "4.3.1", default-features = false, features = ["macros", "rustls", "compress-brotli", "compress-gzip", "compress-zstd"] } actix-web = { version = "4.3.1", default-features = false, features = [
"macros",
"rustls",
"compress-brotli",
"compress-gzip",
"compress-zstd",
] }
tracing = "0.1.37" tracing = "0.1.37"
tracing-actix-web = { version = "0.7.5", default-features = false } tracing-actix-web = { version = "0.7.5", default-features = false }
tracing-error = "0.2.0" tracing-error = "0.2.0"
@ -87,7 +101,9 @@ base64 = "0.21.2"
uuid = { version = "1.4.0", features = ["serde", "v4"] } uuid = { version = "1.4.0", features = ["serde", "v4"] }
async-trait = "0.1.71" async-trait = "0.1.71"
captcha = "0.0.9" captcha = "0.0.9"
anyhow = { version = "1.0.71", features = ["backtrace"] } # backtrace is on by default on nightly, but not stable rust anyhow = { version = "1.0.71", features = [
"backtrace",
] } # backtrace is on by default on nightly, but not stable rust
diesel_ltree = "0.3.0" diesel_ltree = "0.3.0"
typed-builder = "0.15.0" typed-builder = "0.15.0"
serial_test = "2.0.0" serial_test = "2.0.0"
@ -96,7 +112,7 @@ sha2 = "0.10.7"
regex = "1.9.0" regex = "1.9.0"
once_cell = "1.18.0" once_cell = "1.18.0"
diesel-derive-newtype = "2.1.0" diesel-derive-newtype = "2.1.0"
diesel-derive-enum = {version = "2.1.0", features = ["postgres"] } diesel-derive-enum = { version = "2.1.0", features = ["postgres"] }
strum = "0.25.0" strum = "0.25.0"
strum_macros = "0.25.1" strum_macros = "0.25.1"
itertools = "0.11.0" itertools = "0.11.0"
@ -108,7 +124,7 @@ rand = "0.8.5"
opentelemetry = { version = "0.19.0", features = ["rt-tokio"] } opentelemetry = { version = "0.19.0", features = ["rt-tokio"] }
tracing-opentelemetry = { version = "0.19.0" } tracing-opentelemetry = { version = "0.19.0" }
ts-rs = { version = "6.2", features = ["serde-compat", "chrono-impl"] } ts-rs = { version = "6.2", features = ["serde-compat", "chrono-impl"] }
rustls = { version ="0.21.3", features = ["dangerous_configuration"]} rustls = { version = "0.21.3", features = ["dangerous_configuration"] }
futures-util = "0.3.28" futures-util = "0.3.28"
tokio-postgres = "0.7.8" tokio-postgres = "0.7.8"
tokio-postgres-rustls = "0.10.0" tokio-postgres-rustls = "0.10.0"

View file

@ -14,9 +14,25 @@ path = "src/lib.rs"
doctest = false doctest = false
[features] [features]
full = ["tracing", "rosetta-i18n", "chrono", "lemmy_utils", full = [
"lemmy_db_views/full", "lemmy_db_views_actor/full", "lemmy_db_views_moderator/full", "tracing",
"percent-encoding", "encoding", "reqwest-middleware", "webpage", "ts-rs"] "rosetta-i18n",
"chrono",
"lemmy_utils",
"lemmy_db_views/full",
"lemmy_db_views_actor/full",
"lemmy_db_views_moderator/full",
"percent-encoding",
"encoding",
"reqwest-middleware",
"webpage",
"ts-rs",
"tokio",
"uuid",
"reqwest",
"actix-web",
"futures",
]
[dependencies] [dependencies]
lemmy_db_views = { workspace = true } lemmy_db_views = { workspace = true }
@ -33,12 +49,15 @@ reqwest-middleware = { workspace = true, optional = true }
regex = { workspace = true } regex = { workspace = true }
rosetta-i18n = { workspace = true, optional = true } rosetta-i18n = { workspace = true, optional = true }
percent-encoding = { workspace = true, optional = true } percent-encoding = { workspace = true, optional = true }
webpage = { version = "1.6", default-features = false, features = ["serde"], optional = true } webpage = { version = "1.6", default-features = false, features = [
"serde",
], optional = true }
encoding = { version = "0.2.33", optional = true } encoding = { version = "0.2.33", optional = true }
anyhow = { workspace = true } anyhow = { workspace = true }
futures = { workspace = true } futures = { workspace = true, optional = true }
uuid = { workspace = true } uuid = { workspace = true, optional = true }
tokio = { workspace = true } tokio = { workspace = true, optional = true }
reqwest = { workspace = true } reqwest = { workspace = true, optional = true }
ts-rs = { workspace = true, optional = true } ts-rs = { workspace = true, optional = true }
actix-web = { workspace = true } actix-web = { workspace = true, optional = true }
getrandom = { version = "0.2.10", features = ["js"] }

View file

@ -25,7 +25,7 @@ chrono = { workspace = true }
serde_json = { workspace = true } serde_json = { workspace = true }
serde = { workspace = true } serde = { workspace = true }
actix-web = { workspace = true } actix-web = { workspace = true }
tokio = {workspace = true} tokio = { workspace = true }
tracing = { workspace = true } tracing = { workspace = true }
strum_macros = { workspace = true } strum_macros = { workspace = true }
url = { workspace = true } url = { workspace = true }

View file

@ -14,9 +14,27 @@ path = "src/lib.rs"
doctest = false doctest = false
[features] [features]
full = ["diesel", "diesel-derive-newtype", "diesel-derive-enum", "diesel_migrations", "bcrypt", "lemmy_utils", full = [
"activitypub_federation", "sha2", "regex", "once_cell", "serde_json", "diesel_ltree", "diesel",
"diesel-async", "deadpool", "ts-rs"] "diesel-derive-newtype",
"diesel-derive-enum",
"diesel_migrations",
"bcrypt",
"lemmy_utils",
"activitypub_federation",
"sha2",
"regex",
"once_cell",
"serde_json",
"diesel_ltree",
"diesel-async",
"deadpool",
"ts-rs",
"tokio",
"tokio-postgres",
"tokio-postgres-rustls",
"rustls",
]
[dependencies] [dependencies]
chrono = { workspace = true } chrono = { workspace = true }
@ -29,25 +47,33 @@ serde_json = { workspace = true, optional = true }
activitypub_federation = { workspace = true, optional = true } activitypub_federation = { workspace = true, optional = true }
lemmy_utils = { workspace = true, optional = true } lemmy_utils = { workspace = true, optional = true }
bcrypt = { workspace = true, optional = true } bcrypt = { workspace = true, optional = true }
diesel = { workspace = true, features = ["postgres","chrono", "serde_json", "uuid"], optional = true } diesel = { workspace = true, features = [
"postgres",
"chrono",
"serde_json",
"uuid",
], optional = true }
diesel-derive-newtype = { workspace = true, optional = true } diesel-derive-newtype = { workspace = true, optional = true }
diesel-derive-enum = { workspace = true, optional = true } diesel-derive-enum = { workspace = true, optional = true }
diesel_migrations = { workspace = true, optional = true } diesel_migrations = { workspace = true, optional = true }
diesel-async = { workspace = true, features = ["postgres", "deadpool"], optional = true } diesel-async = { workspace = true, features = [
"postgres",
"deadpool",
], optional = true }
sha2 = { workspace = true, optional = true } sha2 = { workspace = true, optional = true }
regex = { workspace = true, optional = true } regex = { workspace = true, optional = true }
once_cell = { workspace = true, optional = true } once_cell = { workspace = true, optional = true }
diesel_ltree = { workspace = true, optional = true } diesel_ltree = { workspace = true, optional = true }
typed-builder = { workspace = true } typed-builder = { workspace = true }
async-trait = { workspace = true } async-trait = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true } tracing = { workspace = true }
deadpool = { version = "0.9.5", features = ["rt_tokio_1"], optional = true } deadpool = { version = "0.9.5", features = ["rt_tokio_1"], optional = true }
ts-rs = { workspace = true, optional = true } ts-rs = { workspace = true, optional = true }
rustls = { workspace = true }
futures-util = { workspace = true } futures-util = { workspace = true }
tokio-postgres = { workspace = true } tokio = { workspace = true, optional = true }
tokio-postgres-rustls = { workspace = true } tokio-postgres = { workspace = true, optional = true }
tokio-postgres-rustls = { workspace = true, optional = true }
rustls = { workspace = true, optional = true }
uuid = { workspace = true, features = ["v4"] } uuid = { workspace = true, features = ["v4"] }
[dev-dependencies] [dev-dependencies]

View file

@ -12,13 +12,20 @@ repository.workspace = true
doctest = false doctest = false
[features] [features]
full = ["lemmy_db_schema/full", "diesel", "diesel-async", "diesel_ltree", "tracing", "ts-rs"] full = [
"lemmy_db_schema/full",
"diesel",
"diesel-async",
"diesel_ltree",
"tracing",
"ts-rs",
]
[dependencies] [dependencies]
lemmy_db_schema = { workspace = true } lemmy_db_schema = { workspace = true }
diesel = { workspace = true, optional = true } diesel = { workspace = true, optional = true }
diesel-async = { workspace = true, optional = true} diesel-async = { workspace = true, optional = true }
diesel_ltree = { workspace = true, optional = true} diesel_ltree = { workspace = true, optional = true }
serde = { workspace = true } serde = { workspace = true }
serde_with = { workspace = true } serde_with = { workspace = true }
tracing = { workspace = true, optional = true } tracing = { workspace = true, optional = true }

View file

@ -16,8 +16,15 @@ full = ["lemmy_db_schema/full", "diesel", "diesel-async", "ts-rs"]
[dependencies] [dependencies]
lemmy_db_schema = { workspace = true } lemmy_db_schema = { workspace = true }
diesel = { workspace = true, features = ["postgres","chrono","serde_json"], optional = true } diesel = { workspace = true, features = [
diesel-async = { workspace = true, features = ["postgres", "deadpool"], optional = true } "postgres",
"chrono",
"serde_json",
], optional = true }
diesel-async = { workspace = true, features = [
"postgres",
"deadpool",
], optional = true }
serde = { workspace = true } serde = { workspace = true }
serde_with = { workspace = true } serde_with = { workspace = true }
typed-builder = { workspace = true } typed-builder = { workspace = true }

View file

@ -16,8 +16,15 @@ full = ["lemmy_db_schema/full", "diesel", "diesel-async", "ts-rs"]
[dependencies] [dependencies]
lemmy_db_schema = { workspace = true } lemmy_db_schema = { workspace = true }
diesel = { workspace = true, features = ["postgres","chrono","serde_json"], optional = true } diesel = { workspace = true, features = [
diesel-async = { workspace = true, features = ["postgres", "deadpool"], optional = true } "postgres",
"chrono",
"serde_json",
], optional = true }
diesel-async = { workspace = true, features = [
"postgres",
"deadpool",
], optional = true }
serde = { workspace = true } serde = { workspace = true }
serde_with = { workspace = true } serde_with = { workspace = true }
ts-rs = { workspace = true, optional = true } ts-rs = { workspace = true, optional = true }

View file

@ -24,3 +24,4 @@ cargo clippy --workspace --features console -- \
-D clippy::indexing_slicing -D clippy::indexing_slicing
cargo +nightly fmt cargo +nightly fmt
taplo format