refactor: move server rs workspace entries into crates
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
param(
|
||||
[Alias("h")]
|
||||
[switch]$Help,
|
||||
[string]$Package = ""
|
||||
[Alias("Package")]
|
||||
[string]$Crate = ""
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
@@ -11,12 +12,12 @@ function Write-Usage {
|
||||
@(
|
||||
'Usage:'
|
||||
' ./server-rs/scripts/check.ps1'
|
||||
' ./server-rs/scripts/check.ps1 -Package api-server'
|
||||
' ./server-rs/scripts/check.ps1 -Crate api-server'
|
||||
''
|
||||
'Notes:'
|
||||
' 1. Run cargo fmt --all --check for the whole server-rs workspace'
|
||||
' 2. Run clippy/check/test for the whole workspace by default'
|
||||
' 3. Use -Package to target one workspace package for clippy/check/test'
|
||||
' 3. Use -Crate to target one workspace crate for clippy/check/test'
|
||||
) -join [Environment]::NewLine
|
||||
}
|
||||
|
||||
@@ -40,7 +41,7 @@ Push-Location $serverRsDir
|
||||
try {
|
||||
cargo fmt --all --check --manifest-path $manifestPath
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($Package)) {
|
||||
if ([string]::IsNullOrWhiteSpace($Crate)) {
|
||||
Write-Host "[server-rs:check] step: cargo clippy --workspace --all-targets --all-features -D warnings"
|
||||
cargo clippy --workspace --manifest-path $manifestPath --all-targets --all-features -- -D warnings
|
||||
|
||||
@@ -51,15 +52,15 @@ try {
|
||||
cargo test --workspace --manifest-path $manifestPath
|
||||
}
|
||||
else {
|
||||
Write-Host "[server-rs:check] target package: $Package"
|
||||
Write-Host "[server-rs:check] step: cargo clippy -p $Package --all-targets --all-features -D warnings"
|
||||
cargo clippy -p $Package --manifest-path $manifestPath --all-targets --all-features -- -D warnings
|
||||
Write-Host "[server-rs:check] target crate: $Crate"
|
||||
Write-Host "[server-rs:check] step: cargo clippy -p $Crate --all-targets --all-features -D warnings"
|
||||
cargo clippy -p $Crate --manifest-path $manifestPath --all-targets --all-features -- -D warnings
|
||||
|
||||
Write-Host "[server-rs:check] step: cargo check -p $Package"
|
||||
cargo check -p $Package --manifest-path $manifestPath
|
||||
Write-Host "[server-rs:check] step: cargo check -p $Crate"
|
||||
cargo check -p $Crate --manifest-path $manifestPath
|
||||
|
||||
Write-Host "[server-rs:check] step: cargo test -p $Package"
|
||||
cargo test -p $Package --manifest-path $manifestPath
|
||||
Write-Host "[server-rs:check] step: cargo test -p $Crate"
|
||||
cargo test -p $Crate --manifest-path $manifestPath
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -8,13 +8,13 @@ usage() {
|
||||
cat <<'EOF'
|
||||
用法:
|
||||
./server-rs/scripts/check.sh
|
||||
SERVER_RS_CHECK_PACKAGE=api-server ./server-rs/scripts/check.sh
|
||||
SERVER_RS_CHECK_CRATE=api-server ./server-rs/scripts/check.sh
|
||||
|
||||
说明:
|
||||
1. 先执行整个 `server-rs` workspace 的 `cargo fmt --all --check`
|
||||
2. 默认继续执行整个 workspace 的 `cargo clippy`、`cargo check`、`cargo test`
|
||||
3. 可通过 `SERVER_RS_CHECK_PACKAGE` 将 clippy/check/test 收窄到单个 package
|
||||
4. `cargo fmt --all --check` 始终覆盖整个 workspace,避免多 package 下格式口径漂移
|
||||
3. 可通过 `SERVER_RS_CHECK_CRATE` 将 clippy/check/test 收窄到单个 crate
|
||||
4. `cargo fmt --all --check` 始终覆盖整个 workspace,避免多 crate 下格式口径漂移
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -38,16 +38,18 @@ echo "[server-rs:check] 步骤: cargo fmt --all --check"
|
||||
cd "${SERVER_RS_DIR}"
|
||||
cargo fmt --all --check --manifest-path "${MANIFEST_PATH}"
|
||||
|
||||
if [[ -n "${SERVER_RS_CHECK_PACKAGE:-}" ]]; then
|
||||
echo "[server-rs:check] 目标 package: ${SERVER_RS_CHECK_PACKAGE}"
|
||||
echo "[server-rs:check] 步骤: cargo clippy -p ${SERVER_RS_CHECK_PACKAGE} --all-targets --all-features -D warnings"
|
||||
cargo clippy -p "${SERVER_RS_CHECK_PACKAGE}" --manifest-path "${MANIFEST_PATH}" --all-targets --all-features -- -D warnings
|
||||
TARGET_CRATE="${SERVER_RS_CHECK_CRATE:-${SERVER_RS_CHECK_PACKAGE:-}}"
|
||||
|
||||
echo "[server-rs:check] 步骤: cargo check -p ${SERVER_RS_CHECK_PACKAGE}"
|
||||
cargo check -p "${SERVER_RS_CHECK_PACKAGE}" --manifest-path "${MANIFEST_PATH}"
|
||||
if [[ -n "${TARGET_CRATE}" ]]; then
|
||||
echo "[server-rs:check] 目标 crate: ${TARGET_CRATE}"
|
||||
echo "[server-rs:check] 步骤: cargo clippy -p ${TARGET_CRATE} --all-targets --all-features -D warnings"
|
||||
cargo clippy -p "${TARGET_CRATE}" --manifest-path "${MANIFEST_PATH}" --all-targets --all-features -- -D warnings
|
||||
|
||||
echo "[server-rs:check] 步骤: cargo test -p ${SERVER_RS_CHECK_PACKAGE}"
|
||||
cargo test -p "${SERVER_RS_CHECK_PACKAGE}" --manifest-path "${MANIFEST_PATH}"
|
||||
echo "[server-rs:check] 步骤: cargo check -p ${TARGET_CRATE}"
|
||||
cargo check -p "${TARGET_CRATE}" --manifest-path "${MANIFEST_PATH}"
|
||||
|
||||
echo "[server-rs:check] 步骤: cargo test -p ${TARGET_CRATE}"
|
||||
cargo test -p "${TARGET_CRATE}" --manifest-path "${MANIFEST_PATH}"
|
||||
else
|
||||
echo "[server-rs:check] 步骤: cargo clippy --workspace --all-targets --all-features -D warnings"
|
||||
cargo clippy --workspace --manifest-path "${MANIFEST_PATH}" --all-targets --all-features -- -D warnings
|
||||
|
||||
@@ -34,8 +34,8 @@ if ([string]::IsNullOrWhiteSpace($RootDir)) {
|
||||
$RootDir = Join-Path $serverRsDir ".spacetimedb\local"
|
||||
}
|
||||
|
||||
if (-not (Test-Path (Join-Path $serverRsDir "apps\spacetime-module\README.md"))) {
|
||||
throw "Missing server-rs/apps/spacetime-module/README.md, cannot start SpacetimeDB local dev script."
|
||||
if (-not (Test-Path (Join-Path $serverRsDir "crates\spacetime-module\README.md"))) {
|
||||
throw "Missing server-rs/crates/spacetime-module/README.md, cannot start SpacetimeDB local dev script."
|
||||
}
|
||||
|
||||
$spacetimeCommand = Get-Command spacetime -ErrorAction SilentlyContinue
|
||||
@@ -56,7 +56,7 @@ Write-Host "[server-rs:spacetime-dev] working dir: $serverRsDir"
|
||||
Write-Host "[server-rs:spacetime-dev] root dir: $RootDir"
|
||||
Write-Host "[server-rs:spacetime-dev] listen addr: $listenAddress"
|
||||
Write-Host "[server-rs:spacetime-dev] mode: standalone"
|
||||
Write-Host "[server-rs:spacetime-dev] note: module publish is deferred until apps/spacetime-module scaffold lands"
|
||||
Write-Host "[server-rs:spacetime-dev] note: module publish is deferred until crates/spacetime-module scaffold lands"
|
||||
|
||||
Push-Location $serverRsDir
|
||||
try {
|
||||
|
||||
@@ -13,7 +13,7 @@ usage() {
|
||||
说明:
|
||||
1. 启动 Genarrative Rust 后端使用的本地 standalone SpacetimeDB
|
||||
2. 默认把本地数据目录放到 `server-rs/.spacetimedb/local`
|
||||
3. 当前阶段只负责启动 standalone server,暂不自动 publish `apps/spacetime-module`
|
||||
3. 当前阶段只负责启动 standalone server,暂不自动 publish `crates/spacetime-module`
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ LISTEN_HOST="${GENARRATIVE_SPACETIME_HOST:-127.0.0.1}"
|
||||
PORT="${GENARRATIVE_SPACETIME_PORT:-3001}"
|
||||
ROOT_DIR="${GENARRATIVE_SPACETIME_ROOT_DIR:-${SERVER_RS_DIR}/.spacetimedb/local}"
|
||||
|
||||
if [[ ! -f "${SERVER_RS_DIR}/apps/spacetime-module/README.md" ]]; then
|
||||
echo "[server-rs:spacetime-dev] 未找到 apps/spacetime-module/README.md,无法启动本地 SpacetimeDB 脚本。" >&2
|
||||
if [[ ! -f "${SERVER_RS_DIR}/crates/spacetime-module/README.md" ]]; then
|
||||
echo "[server-rs:spacetime-dev] 未找到 crates/spacetime-module/README.md,无法启动本地 SpacetimeDB 脚本。" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -46,7 +46,7 @@ echo "[server-rs:spacetime-dev] 工作目录: ${SERVER_RS_DIR}"
|
||||
echo "[server-rs:spacetime-dev] 数据目录: ${ROOT_DIR}"
|
||||
echo "[server-rs:spacetime-dev] 监听地址: ${LISTEN_HOST}:${PORT}"
|
||||
echo "[server-rs:spacetime-dev] 模式: standalone"
|
||||
echo "[server-rs:spacetime-dev] 说明: 当前阶段暂不自动 publish apps/spacetime-module"
|
||||
echo "[server-rs:spacetime-dev] 说明: 当前阶段暂不自动 publish crates/spacetime-module"
|
||||
|
||||
cd "${SERVER_RS_DIR}"
|
||||
spacetime --root-dir "${ROOT_DIR}" start --edition standalone --listen-addr "${LISTEN_HOST}:${PORT}"
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
param(
|
||||
[Alias("h")]
|
||||
[switch]$Help,
|
||||
[string]$Package = ""
|
||||
[Alias("Package")]
|
||||
[string]$Crate = ""
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
@@ -11,11 +12,11 @@ function Write-Usage {
|
||||
@(
|
||||
'Usage:'
|
||||
' ./server-rs/scripts/test.ps1'
|
||||
' ./server-rs/scripts/test.ps1 -Package api-server'
|
||||
' ./server-rs/scripts/test.ps1 -Crate api-server'
|
||||
''
|
||||
'Notes:'
|
||||
' 1. Run cargo test for the server-rs workspace by default'
|
||||
' 2. Use -Package to target one workspace package only'
|
||||
' 2. Use -Crate to target one workspace crate only'
|
||||
) -join [Environment]::NewLine
|
||||
}
|
||||
|
||||
@@ -36,12 +37,12 @@ Write-Host "[server-rs:test] working dir: $serverRsDir"
|
||||
|
||||
Push-Location $serverRsDir
|
||||
try {
|
||||
if ([string]::IsNullOrWhiteSpace($Package)) {
|
||||
if ([string]::IsNullOrWhiteSpace($Crate)) {
|
||||
cargo test --manifest-path $manifestPath
|
||||
}
|
||||
else {
|
||||
Write-Host "[server-rs:test] target package: $Package"
|
||||
cargo test -p $Package --manifest-path $manifestPath
|
||||
Write-Host "[server-rs:test] target crate: $Crate"
|
||||
cargo test -p $Crate --manifest-path $manifestPath
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -6,11 +6,11 @@ usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./server-rs/scripts/test.sh
|
||||
SERVER_RS_TEST_PACKAGE=api-server ./server-rs/scripts/test.sh
|
||||
SERVER_RS_TEST_CRATE=api-server ./server-rs/scripts/test.sh
|
||||
|
||||
Notes:
|
||||
1. Run cargo test for the server-rs workspace by default
|
||||
2. Use SERVER_RS_TEST_PACKAGE to target one workspace package only
|
||||
2. Use SERVER_RS_TEST_CRATE to target one workspace crate only
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -32,9 +32,11 @@ echo "[server-rs:test] working dir: ${SERVER_RS_DIR}"
|
||||
|
||||
cd "${SERVER_RS_DIR}"
|
||||
|
||||
if [[ -n "${SERVER_RS_TEST_PACKAGE:-}" ]]; then
|
||||
echo "[server-rs:test] target package: ${SERVER_RS_TEST_PACKAGE}"
|
||||
cargo test -p "${SERVER_RS_TEST_PACKAGE}" --manifest-path "${MANIFEST_PATH}"
|
||||
TARGET_CRATE="${SERVER_RS_TEST_CRATE:-${SERVER_RS_TEST_PACKAGE:-}}"
|
||||
|
||||
if [[ -n "${TARGET_CRATE}" ]]; then
|
||||
echo "[server-rs:test] target crate: ${TARGET_CRATE}"
|
||||
cargo test -p "${TARGET_CRATE}" --manifest-path "${MANIFEST_PATH}"
|
||||
else
|
||||
cargo test --manifest-path "${MANIFEST_PATH}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user