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
|
report.*.json
|
||||||
|
|
||||||
# Rust
|
# Rust
|
||||||
packages/backend-rs/target
|
/packages/backend-rs/target
|
||||||
|
/target
|
||||||
|
|
||||||
# Coverage
|
# Coverage
|
||||||
coverage
|
coverage
|
||||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -14,6 +14,9 @@ packages/backend/.idea/vcs.xml
|
||||||
node_modules
|
node_modules
|
||||||
report.*.json
|
report.*.json
|
||||||
|
|
||||||
|
# Cargo
|
||||||
|
/target
|
||||||
|
|
||||||
# Cypress
|
# Cypress
|
||||||
cypress/screenshots
|
cypress/screenshots
|
||||||
cypress/videos
|
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}"
|
ENV PATH="/root/.cargo/bin:${PATH}"
|
||||||
|
|
||||||
# Copy only the cargo dependency-related files first, to cache efficiently
|
# 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.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/
|
COPY packages/backend-rs/src/lib.rs packages/backend-rs/src/
|
||||||
|
|
||||||
# Install cargo dependencies
|
# 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
|
### 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
|
### For Docker/Podman users
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
"format": "pnpm -r --parallel run format",
|
"format": "pnpm -r --parallel run format",
|
||||||
"clean": "pnpm node ./scripts/clean-built.mjs",
|
"clean": "pnpm node ./scripts/clean-built.mjs",
|
||||||
"clean-npm": "pnpm node ./scripts/clean-npm.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"
|
"clean-all": "pnpm run clean && pnpm run clean-cargo && pnpm run clean-npm"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -12,31 +12,27 @@ napi = ["dep:napi", "dep:napi-derive"]
|
||||||
crate-type = ["cdylib", "lib"]
|
crate-type = ["cdylib", "lib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = "0.1.79"
|
napi = { workspace = true, optional = true, default-features = false, features = ["napi9", "tokio_rt", "chrono_date", "serde-json"] }
|
||||||
cfg-if = "1.0.0"
|
napi-derive = { workspace = true, optional = true }
|
||||||
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"] }
|
|
||||||
|
|
||||||
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
|
async-trait = { workspace = true }
|
||||||
napi = { version = "2.16.2", default-features = false, features = ["napi9", "tokio_rt", "chrono_date", "serde-json"], optional = true }
|
basen = { workspace = true }
|
||||||
napi-derive = { version = "2.16.2", optional = true }
|
cfg-if = { workspace = true }
|
||||||
basen = "0.1.0"
|
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]
|
[dev-dependencies]
|
||||||
pretty_assertions = "1.4.0"
|
pretty_assertions = { workspace = true }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
napi-build = "2.1.2"
|
napi-build = { workspace = true }
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
lto = true
|
|
||||||
|
|
|
@ -224,6 +224,20 @@ switch (platform) {
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'arm':
|
case 'arm':
|
||||||
|
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(
|
localFileExisted = existsSync(
|
||||||
join(__dirname, 'backend-rs.linux-arm-gnueabihf.node')
|
join(__dirname, 'backend-rs.linux-arm-gnueabihf.node')
|
||||||
)
|
)
|
||||||
|
@ -236,6 +250,7 @@ switch (platform) {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
loadError = e
|
loadError = e
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break
|
break
|
||||||
case 'riscv64':
|
case 'riscv64':
|
||||||
if (isMusl()) {
|
if (isMusl()) {
|
||||||
|
|
|
@ -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