refactor: create virtual rust workspace in the repository root
Co-authored-by: sup39 <dev@sup39.dev>
This commit is contained in:
parent
3fe8ace571
commit
0491e11a9e
11 changed files with 85 additions and 54 deletions
|
@ -10,7 +10,8 @@ node_modules
|
|||
report.*.json
|
||||
|
||||
# Rust
|
||||
packages/backend-rs/target
|
||||
/packages/backend-rs/target
|
||||
/target
|
||||
|
||||
# Coverage
|
||||
coverage
|
||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -14,6 +14,9 @@ packages/backend/.idea/vcs.xml
|
|||
node_modules
|
||||
report.*.json
|
||||
|
||||
# Cargo
|
||||
/target
|
||||
|
||||
# Cypress
|
||||
cypress/screenshots
|
||||
cypress/videos
|
||||
|
|
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"rust-analyzer.linkedProjects": [
|
||||
"packages/backend-rs/Cargo.toml"
|
||||
]
|
||||
}
|
0
packages/backend-rs/Cargo.lock → Cargo.lock
generated
0
packages/backend-rs/Cargo.lock → Cargo.lock
generated
28
Cargo.toml
Normal file
28
Cargo.toml
Normal file
|
@ -0,0 +1,28 @@
|
|||
[workspace]
|
||||
members = ["packages/backend-rs"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.dependencies]
|
||||
napi = { version = "2.16.2", default-features = false }
|
||||
napi-derive = "2.16.2"
|
||||
napi-build = "2.1.2"
|
||||
|
||||
async-trait = "0.1.79"
|
||||
basen = "0.1.0"
|
||||
cfg-if = "1.0.0"
|
||||
chrono = "0.4.37"
|
||||
cuid2 = "0.1.2"
|
||||
jsonschema = "0.17.1"
|
||||
once_cell = "1.19.0"
|
||||
parse-display = "0.9.0"
|
||||
pretty_assertions = "1.4.0"
|
||||
rand = "0.8.5"
|
||||
schemars = "0.8.16"
|
||||
sea-orm = "0.12.15"
|
||||
serde = "1.0.197"
|
||||
serde_json = "1.0.115"
|
||||
thiserror = "1.0.58"
|
||||
tokio = "1.37.0"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
|
@ -8,8 +8,9 @@ RUN curl --proto '=https' --tlsv1.2 --silent --show-error --fail https://sh.rust
|
|||
ENV PATH="/root/.cargo/bin:${PATH}"
|
||||
|
||||
# Copy only the cargo dependency-related files first, to cache efficiently
|
||||
COPY Cargo.toml Cargo.toml
|
||||
COPY Cargo.lock Cargo.lock
|
||||
COPY packages/backend-rs/Cargo.toml packages/backend-rs/Cargo.toml
|
||||
COPY packages/backend-rs/Cargo.lock packages/backend-rs/Cargo.lock
|
||||
COPY packages/backend-rs/src/lib.rs packages/backend-rs/src/
|
||||
|
||||
# Install cargo dependencies
|
||||
|
|
|
@ -19,7 +19,11 @@ The number of posts stored on your database can be found at `https://yourserver.
|
|||
|
||||
### For systemd/pm2 users
|
||||
|
||||
Please do not terminate `pnpm run migrate` even if it appears to be frozen.
|
||||
- You can remove `packages/backend-rs/target`.
|
||||
```sh
|
||||
rm --recursive --force packages/backend-rs/target
|
||||
```
|
||||
- Please do not terminate `pnpm run migrate` even if it appears to be frozen.
|
||||
|
||||
### For Docker/Podman users
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
"format": "pnpm -r --parallel run format",
|
||||
"clean": "pnpm node ./scripts/clean-built.mjs",
|
||||
"clean-npm": "pnpm node ./scripts/clean-npm.mjs",
|
||||
"clean-cargo": "pnpm node ./scripts/clean-cargo.mjs",
|
||||
"clean-cargo": "cargo clean",
|
||||
"clean-all": "pnpm run clean && pnpm run clean-cargo && pnpm run clean-npm"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
@ -12,31 +12,27 @@ napi = ["dep:napi", "dep:napi-derive"]
|
|||
crate-type = ["cdylib", "lib"]
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1.79"
|
||||
cfg-if = "1.0.0"
|
||||
chrono = "0.4.37"
|
||||
cuid2 = "0.1.2"
|
||||
jsonschema = "0.17.1"
|
||||
once_cell = "1.19.0"
|
||||
parse-display = "0.9.0"
|
||||
rand = "0.8.5"
|
||||
schemars = { version = "0.8.16", features = ["chrono"] }
|
||||
sea-orm = { version = "0.12.15", features = ["sqlx-postgres", "runtime-tokio-rustls"] }
|
||||
serde = { version = "1.0.197", features = ["derive"] }
|
||||
serde_json = "1.0.115"
|
||||
thiserror = "1.0.58"
|
||||
tokio = { version = "1.37.0", features = ["full"] }
|
||||
napi = { workspace = true, optional = true, default-features = false, features = ["napi9", "tokio_rt", "chrono_date", "serde-json"] }
|
||||
napi-derive = { workspace = true, optional = true }
|
||||
|
||||
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
|
||||
napi = { version = "2.16.2", default-features = false, features = ["napi9", "tokio_rt", "chrono_date", "serde-json"], optional = true }
|
||||
napi-derive = { version = "2.16.2", optional = true }
|
||||
basen = "0.1.0"
|
||||
async-trait = { workspace = true }
|
||||
basen = { workspace = true }
|
||||
cfg-if = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
cuid2 = { workspace = true }
|
||||
jsonschema = { workspace = true }
|
||||
once_cell = { workspace = true }
|
||||
parse-display = { workspace = true }
|
||||
rand = { workspace = true }
|
||||
schemars = { workspace = true, features = ["chrono"] }
|
||||
sea-orm = { workspace = true, features = ["sqlx-postgres", "runtime-tokio-rustls"] }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
tokio = { workspace = true, features = ["full"] }
|
||||
|
||||
[dev-dependencies]
|
||||
pretty_assertions = "1.4.0"
|
||||
pretty_assertions = { workspace = true }
|
||||
|
||||
[build-dependencies]
|
||||
napi-build = "2.1.2"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
napi-build = { workspace = true }
|
||||
|
|
|
@ -224,17 +224,32 @@ switch (platform) {
|
|||
}
|
||||
break
|
||||
case 'arm':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'backend-rs.linux-arm-gnueabihf.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./backend-rs.linux-arm-gnueabihf.node')
|
||||
} else {
|
||||
nativeBinding = require('backend-rs-linux-arm-gnueabihf')
|
||||
if (isMusl()) {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'backend-rs.linux-arm-musleabihf.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./backend-rs.linux-arm-musleabihf.node')
|
||||
} else {
|
||||
nativeBinding = require('backend-rs-linux-arm-musleabihf')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
} else {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'backend-rs.linux-arm-gnueabihf.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./backend-rs.linux-arm-gnueabihf.node')
|
||||
} else {
|
||||
nativeBinding = require('backend-rs-linux-arm-gnueabihf')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'riscv64':
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
import path, { join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { execa } from "execa";
|
||||
|
||||
(async () => {
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
execa("cargo", ["clean"], {
|
||||
cwd: join(__dirname, "/../packages/backend-rs"),
|
||||
stdio: "inherit",
|
||||
});
|
||||
})();
|
Loading…
Reference in a new issue