How xcodecraft/rigger-ng works
Project Type and Purpose
• rigger‑ng is an open‑source CLI framework/tool for project scaffolding, configuration management, resource packaging, and deployment.
• It is implemented in Python, driven by YAML configuration and shell scripts, and built to be extensible via “modules” and “resources.”
File Structure
• Top‑level:
• src/ (all Python code)
• demo/ (example usage and templates)
• doc/ (architecture, usage, and HOWTOs)
• test/ (unit and integration tests)
• composer.json, shell entry scripts, and config files.
• src/ breaks down into:
• core/ – core engine:
– conf/ (defines and loads dev/run configurations)
– impl/ (command implementations: rg_args, rg_cmd_*, rg_run, rg_res, etc.)
– res/ (built‑in resource handlers: file templating, shell, nodes)
– run_env.py (environment orchestration)
• etc/ – OS environment templates per distro (Ubuntu, CentOS)
• extends/ – extension point:
– moduls/ (YAML descriptions of modules)
– res/ (plug‑in resource handlers grouped by domain: check, deploy, pylon, websys)
• lib/ – public interfaces and common utilities (YAML, JSON, shell, templating engine)
• bin/ – wrapper shell scripts that invoke Python core
• Supporting files:
• tpl/ – templates for new projects
• demo/_rg and demo/conf – example runtime configs
• simple_setup.sh, setting.py – bootstrap and configuration
Readme/Doc Insights
• Although the top‑level README is minimal, the doc/ folder contains extensive guides (e.g. doc/dev_guide.md, doc/prj_conf.md) that describe the configuration schema and plugin model.
• The design follows a plugin/resource architecture: the core engine discovers commands (rg_cmd_*), loads resources (built‑in or extended), processes user YAML, then dispatches shell calls or file operations.
a. CLI Frontend
– Entry scripts (simple_setup.sh, src/bin/proc_op.sh) invoke the Python CLI launcher.
b. Core Engine
– Argument parser (rg_args)
– Command dispatcher (rg_cmd_base + rg_cmd_dev/prj/pub)
– Config loader (run_conf, dev_conf)
– Run‑time orchestrator (rg_run, run_env.py)
c. Plugin/Extension Manager
– Module loader (extends/moduls)
– Resource loader (extends/res and src/core/res)
– Interface layer (lib/interface)
d. Resource Handlers
– Built‑in: file templating, shell execution, node operations (src/core/res)
– Extended: check, deploy, websys, pylon (src/extends/res/…)
e. Utility Libraries
– YAML/JSON parsing, templating engine (lib/utls)
– Common patterns and error definitions (lib/interface/rg_err, rg_conf, etc.)
f. OS Environment Templates
– Distro‑specific scripts (src/etc/*.py)
g. Demo & Test Harness
– demo/ shows a sample end‑to‑end run
– test/ drives core and extension tests
Relationships and Interactions
• The user runs the CLI script → invokes Python core
• Core parses CLI args → loads dev/run YAML config
• Core discovers and dispatches to the requested rg_cmd_* plugin
• Command implementation requests resources by name → extension manager locates appropriate handler in src/core/res or src/extends/res
• Resource handler executes actions: file generation via templating engine, shell commands, service definitions, etc.
• OS‑specific modules supply templates or commands per environment
• Utilities (lib/utls) serve as common building blocks for file I/O, JSON/YAML, templating
Architectural Patterns & Principles
• Plugin Architecture: Commands and resources are discoverable modules
• Separation of Concerns: Core engine vs. extensions vs. utilities
• Convention over Configuration: YAML schema and directory layouts
• Dependency Injection: configs drive behavior, not hard‑coded paths
• Test‑Driven Design: extensive unit tests in test/