feat: Update SAL crate structure and documentation
Some checks failed
Test Publishing Setup / Test Publishing Setup (pull_request) Has been cancelled
Some checks failed
Test Publishing Setup / Test Publishing Setup (pull_request) Has been cancelled
- Reduced the number of SAL crates from 16 to 15. - Removed redundant core modules from README examples. - Updated README to reflect the current state of published crates. - Added `Cargo.toml.bak` to `.gitignore` to prevent accidental commits. - Improved the clarity and accuracy of the README's installation instructions. - Updated `publish-all.sh` script to handle existing crate versions and improve dependency management.
This commit is contained in:
@@ -141,56 +141,143 @@ if [ "$DRY_RUN" = false ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Function to check if a crate version is already published
|
||||
is_published() {
|
||||
local crate_name="$1"
|
||||
local version="$2"
|
||||
|
||||
# Use cargo search to check if the exact version exists
|
||||
if cargo search "sal-$crate_name" --limit 1 | grep -q "sal-$crate_name.*$version"; then
|
||||
return 0 # Already published
|
||||
else
|
||||
return 1 # Not published
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to update dependencies in a crate's Cargo.toml
|
||||
update_dependencies() {
|
||||
local crate_dir="$1"
|
||||
local version="$2"
|
||||
|
||||
if [ ! -f "$crate_dir/Cargo.toml" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Create backup
|
||||
cp "$crate_dir/Cargo.toml" "$crate_dir/Cargo.toml.bak"
|
||||
|
||||
# Update all SAL path dependencies to version dependencies
|
||||
sed -i.tmp "s|sal-text = { path = \"../text\" }|sal-text = \"$version\"|g" "$crate_dir/Cargo.toml"
|
||||
sed -i.tmp "s|sal-os = { path = \"../os\" }|sal-os = \"$version\"|g" "$crate_dir/Cargo.toml"
|
||||
sed -i.tmp "s|sal-process = { path = \"../process\" }|sal-process = \"$version\"|g" "$crate_dir/Cargo.toml"
|
||||
sed -i.tmp "s|sal-git = { path = \"../git\" }|sal-git = \"$version\"|g" "$crate_dir/Cargo.toml"
|
||||
sed -i.tmp "s|sal-vault = { path = \"../vault\" }|sal-vault = \"$version\"|g" "$crate_dir/Cargo.toml"
|
||||
sed -i.tmp "s|sal-net = { path = \"../net\" }|sal-net = \"$version\"|g" "$crate_dir/Cargo.toml"
|
||||
sed -i.tmp "s|sal-kubernetes = { path = \"../kubernetes\" }|sal-kubernetes = \"$version\"|g" "$crate_dir/Cargo.toml"
|
||||
sed -i.tmp "s|sal-redisclient = { path = \"../redisclient\" }|sal-redisclient = \"$version\"|g" "$crate_dir/Cargo.toml"
|
||||
sed -i.tmp "s|sal-postgresclient = { path = \"../postgresclient\" }|sal-postgresclient = \"$version\"|g" "$crate_dir/Cargo.toml"
|
||||
sed -i.tmp "s|sal-virt = { path = \"../virt\" }|sal-virt = \"$version\"|g" "$crate_dir/Cargo.toml"
|
||||
sed -i.tmp "s|sal-mycelium = { path = \"../mycelium\" }|sal-mycelium = \"$version\"|g" "$crate_dir/Cargo.toml"
|
||||
sed -i.tmp "s|sal-zinit-client = { path = \"../zinit_client\" }|sal-zinit-client = \"$version\"|g" "$crate_dir/Cargo.toml"
|
||||
|
||||
# Clean up temporary files
|
||||
rm -f "$crate_dir/Cargo.toml.tmp"
|
||||
}
|
||||
|
||||
# Function to restore dependencies from backup
|
||||
restore_dependencies() {
|
||||
local crate_dir="$1"
|
||||
|
||||
if [ -f "$crate_dir/Cargo.toml.bak" ]; then
|
||||
mv "$crate_dir/Cargo.toml.bak" "$crate_dir/Cargo.toml"
|
||||
fi
|
||||
}
|
||||
|
||||
# Publish individual crates
|
||||
echo -e "${BLUE}📦 Publishing individual crates...${NC}"
|
||||
echo ""
|
||||
|
||||
for crate in "${CRATES[@]}"; do
|
||||
echo -e "${YELLOW}Publishing sal-$crate...${NC}"
|
||||
|
||||
|
||||
if [ ! -d "$crate" ]; then
|
||||
echo -e "${RED} ❌ Directory $crate not found${NC}"
|
||||
continue
|
||||
fi
|
||||
|
||||
|
||||
# Check if already published
|
||||
if [ "$DRY_RUN" = false ] && is_published "$crate" "$VERSION"; then
|
||||
echo -e "${GREEN} ✅ sal-$crate@$VERSION already published, skipping${NC}"
|
||||
echo ""
|
||||
continue
|
||||
fi
|
||||
|
||||
# Update dependencies to use version numbers
|
||||
echo -e "${BLUE} 📝 Updating dependencies for sal-$crate...${NC}"
|
||||
update_dependencies "$crate" "$VERSION"
|
||||
|
||||
cd "$crate"
|
||||
|
||||
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo -e "${BLUE} 🔍 Would run: cargo publish --allow-dirty${NC}"
|
||||
if is_published "$crate" "$VERSION"; then
|
||||
echo -e "${YELLOW} 📝 Note: sal-$crate@$VERSION already exists${NC}"
|
||||
fi
|
||||
else
|
||||
if cargo publish --allow-dirty; then
|
||||
echo -e "${GREEN} ✅ sal-$crate published successfully${NC}"
|
||||
else
|
||||
echo -e "${RED} ❌ Failed to publish sal-$crate${NC}"
|
||||
cd ..
|
||||
restore_dependencies "$crate"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
cd ..
|
||||
|
||||
if [ "$DRY_RUN" = false ] && [ "$crate" != "${CRATES[-1]}" ]; then
|
||||
echo -e "${BLUE} ⏳ Waiting $WAIT_TIME seconds for crates.io to process...${NC}"
|
||||
sleep "$WAIT_TIME"
|
||||
|
||||
# Restore original dependencies
|
||||
restore_dependencies "$crate"
|
||||
|
||||
# Wait between publishes (except for the last one)
|
||||
if [ "$DRY_RUN" = false ]; then
|
||||
# Get the last element of the array
|
||||
last_crate="${CRATES[${#CRATES[@]}-1]}"
|
||||
if [ "$crate" != "$last_crate" ]; then
|
||||
echo -e "${BLUE} ⏳ Waiting $WAIT_TIME seconds for crates.io to process...${NC}"
|
||||
sleep "$WAIT_TIME"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
echo ""
|
||||
done
|
||||
|
||||
# Publish main crate
|
||||
echo -e "${BLUE}📦 Publishing main sal crate...${NC}"
|
||||
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo -e "${BLUE}🔍 Would run: cargo publish --allow-dirty${NC}"
|
||||
# Check if main crate is already published
|
||||
if [ "$DRY_RUN" = false ] && cargo search "sal" --limit 1 | grep -q "sal.*$VERSION"; then
|
||||
echo -e "${GREEN}✅ sal@$VERSION already published, skipping${NC}"
|
||||
else
|
||||
if cargo publish --allow-dirty; then
|
||||
echo -e "${GREEN}✅ Main sal crate published successfully${NC}"
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo -e "${BLUE}🔍 Would run: cargo publish --allow-dirty${NC}"
|
||||
if cargo search "sal" --limit 1 | grep -q "sal.*$VERSION"; then
|
||||
echo -e "${YELLOW}📝 Note: sal@$VERSION already exists${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}❌ Failed to publish main sal crate${NC}"
|
||||
exit 1
|
||||
if cargo publish --allow-dirty; then
|
||||
echo -e "${GREEN}✅ Main sal crate published successfully${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ Failed to publish main sal crate${NC}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Clean up any remaining backup files
|
||||
echo -e "${BLUE}🧹 Cleaning up backup files...${NC}"
|
||||
find . -name "Cargo.toml.bak" -delete 2>/dev/null || true
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}===============================================${NC}"
|
||||
echo -e "${GREEN} Publishing Complete!${NC}"
|
||||
|
Reference in New Issue
Block a user