Herocode Herolib Rust Repository
Overview
This repository contains the Herocode Herolib Rust library and a collection of scripts, examples, and utilities for building, testing, and publishing the SAL (System Abstraction Layer) crates. The repository includes:
- Rust crates for various system components (e.g., os,process,text,git,vault,kubernetes, etc.).
- Rhai scripts and test suites for each crate.
- Utility scripts to automate common development tasks.
Scripts
The repository provides three primary helper scripts located in the repository root:
| Script | Description | Typical Usage | 
|---|---|---|
| scripts/publish-all.sh | Publishes all SAL crates to crates.io in the correct dependency order. Handles version bumping, dependency updates, dry‑run mode, and rate‑limiting. | ./scripts/publish-all.sh [--dry-run] [--wait <seconds>] [--version <ver>] | 
| build_herodo.sh | Builds the herodobinary from theherodopackage and optionally runs a specified Rhai script. | ./build_herodo.sh [script_name] | 
| run_rhai_tests.sh | Executes all Rhai test suites across the repository, logging results and providing a summary. | ./run_rhai_tests.sh | 
Below are detailed usage instructions for each script.
1. scripts/publish-all.sh
Purpose
- Publishes each SAL crate in the correct dependency order.
- Updates crate versions (if --versionis supplied).
- Updates path dependencies to version dependencies before publishing.
- Supports dry‑run mode to preview actions without publishing.
- Handles rate‑limiting between crate publishes.
Options
| Option | Description | 
|---|---|
| --dry-run | Shows what would be published without actually publishing. | 
| --wait <seconds> | Wait time between publishes (default: 15 s). | 
| --version <ver> | Set a new version for all crates (updates Cargo.tomlfiles). | 
| -h, --help | Show help message. | 
Example Usage
# Dry run – no crates will be published
./scripts/publish-all.sh --dry-run
# Publish with a custom wait time and version bump
./scripts/publish-all.sh --wait 30 --version 1.2.3
# Normal publish (no dry‑run)
./scripts/publish-all.sh
Notes
- Must be run from the repository root (where Cargo.tomllives).
- Requires cargoand a logged‑incargosession (cargo login).
- The script automatically updates dependencies in each crate’s Cargo.tomlto use the new version before publishing.
2. build_herodo.sh
Purpose
- Builds the herodobinary from theherodopackage.
- Copies the binary to a system‑wide location (/usr/local/bin) if run as root, otherwise to~/hero/bin.
- Optionally runs a specified Rhai script after building.
Usage
# Build only
./build_herodo.sh
# Build and run a specific Rhai script (e.g., `example`):
./build_herodo.sh example
Details
- The script changes to its own directory, builds the herodocrate (cargo build), and copies the binary.
- If a script name is provided, it looks for the script in:
- src/rhaiexamples/<name>.rhai
- src/herodo/scripts/<name>.rhai
 
- If the script is not found, the script exits with an error.
3. run_rhai_tests.sh
Purpose
- Runs all Rhai test suites across the repository.
- Supports both the legacy rhai_testsdirectory and the newer*/tests/rhailayout.
- Logs output to run_rhai_tests.logand prints a summary.
Usage
# Run all tests
./run_rhai_tests.sh
Output
- Colored console output for readability.
- Log file (run_rhai_tests.log) contains full output for later review.
- Summary includes total modules, passed, and failed counts.
- Exit code 0if all tests pass,1otherwise.
General Development Workflow
- Build: Use build_herodo.shto compile theherodobinary.
- Test: Run run_rhai_tests.shto ensure all Rhai scripts pass.
- Publish: When ready to release, use scripts/publish-all.sh(with--dry-runfirst to verify).
Prerequisites
- Rust toolchain (cargo,rustc) installed.
- Rhai interpreter (herodo) built and available.
- Git for version control.
- Cargo login for publishing to crates.io.
License
See LICENSE for details.
Happy coding!
Description
				
					Languages
				
				
								
								
									Rust
								
								98.4%
							
						
							
								
								
									Shell
								
								1.3%
							
						
							
								
								
									CSS
								
								0.2%