fix scripts

This commit is contained in:
2025-07-01 15:13:23 +03:00
parent 9c19d63121
commit 032c9a54a2
5 changed files with 192 additions and 2 deletions

View File

@@ -1,13 +1,32 @@
#!/bin/bash
set -e
name="$1"
if [ -z "$name" ]; then
echo "Usage: ./monorepo-cargo-new.sh <project_name>"
echo "Usage: ./monorepo-cargo-new.sh <project_name>"
exit 1
fi
# Step 1: Create new cargo project without initializing Git
cargo new "$name" --vcs none
echo " \"$name\"," >> Cargo.toml
# Step 2: Insert the project into the [workspace] members list in Cargo.toml
if grep -q "^\[workspace\]" Cargo.toml; then
# Avoid duplicate entries
if grep -q "\"$name\"" Cargo.toml; then
echo "⚠️ Project '$name' already exists in workspace members. Skipping insertion."
else
echo "📦 Adding '$name' to workspace members..."
# Insert before the closing bracket of members array
sed -i "/members\s*=\s*\[/,/]/ s/^\(\s*\)\]/ \"$name\",\n\1]/" Cargo.toml
fi
else
echo "❌ No [workspace] section found in Cargo.toml."
exit 1
fi
echo "✅ Project '$name' created and added to workspace!"