roneoREADME.md

ee892817f152551895f8482d4db15cefa51ef865

At commit ee89281

184 lines · 7.8 KiBPreviewCodeRaw
  1. <p align="center">
  2. <img src="assets/logo.svg" alt="Ronéo" width="96" height="96" />
  3. </p>
  4. # Ronéo (`roneo`)
  5. > A fast, standalone Rust port of [Copier](https://github.com/copier-org/copier) — scaffold and update projects from Jinja2 templates with no Python runtime.
  6. The name **Ronéo** comes from the classic stencil duplicator (*"passer à la ronéo"*): reproducing project templates cleanly, quickly, and without friction.
  7. ## Installation
  8. ### Via `mise` (recommended)
  9. ```bash
  10. mise plugins install forge https://code.cleyrop.tech/mise.git
  11. mise use -g forge:roneo@latest
  12. ```
  13. Or declare it in `mise.toml`:
  14. ```toml
  15. [plugins]
  16. forge = "https://code.cleyrop.tech/mise.git"
  17. [tools]
  18. "forge:roneo" = "latest"
  19. ```
  20. Upgrade later with:
  21. ```bash
  22. mise upgrade forge:roneo
  23. ```
  24. ### Via install script (macOS & Linux, SHA-256 verified)
  25. ```bash
  26. curl -fsSL https://code.cleyrop.tech/roneo/raw/main/install.sh | sh
  27. ```
  28. ### From source (`cargo`, Rust `1.100+`)
  29. ```bash
  30. cargo install --path crates/roneo-cli
  31. ```
  32. ## Benchmarks
  33. Measured on Apple M3 Pro (macOS, `hyperfine`, release build of `roneo 0.1.0` vs. `copier 9.15.1` on `examples/starter-template`):
  34. | Operation | `roneo` | `copier` | Speedup | Peak RAM (`roneo` / `copier`) |
  35. | --- | ---: | ---: | ---: | ---: |
  36. | `--version` (CLI startup) | **3.0 ms** | 365.0 ms | **121x** | **2.5 MiB** / 55.4 MiB |
  37. | `copy --defaults` | **4.3 ms** | 412.7 ms | **96x** | **5.0 MiB** / 55.9 MiB |
  38. | `copy --defaults --pretend` | **3.5 ms** | 370.4 ms | **107x** | **5.1 MiB** / 55.9 MiB |
  39. | `inspect` | **2.5 ms** | — | — | **3.4 MiB** / — |
  40. Reproduce locally:
  41. ```bash
  42. cargo build --release
  43. hyperfine --warmup 2 \
  44. "./target/release/roneo copy ./examples/starter-template /tmp/out-r --defaults --overwrite" \
  45. "copier copy ./examples/starter-template /tmp/out-c --defaults --overwrite"
  46. ```
  47. ## Ronéo vs. Copier
  48. | Aspect | Ronéo (`roneo`) | Copier (`copier`) |
  49. | --- | --- | --- |
  50. | Distribution | Single native binary (~5.8 MB) | Python package (`pipx` / `uvx` / virtualenv) |
  51. | Runtime dependency | None (static musl on Linux, notarised arm64 on macOS) | Python 3.9+ and dependencies |
  52. | Template format | `copier.yml` / `copier.yaml` / `roneo.yml` | `copier.yml` / `copier.yaml` |
  53. | Answers file | Interoperable `.copier-answers.yml` (auto-written if omitted) | `.copier-answers.yml` |
  54. | Template engine | `minijinja` + `pycompat` (Python methods) | Jinja2 (Python) |
  55. | Extensions | Sandboxed WebAssembly (`wasmi`, no disk/network) | Arbitrary Python Jinja extensions (`--trust`) |
  56. | Extra CLI tools | `inspect` (`--json`), `diff`, `plugin`, `completions` | — |
  57. | Library reuse | `roneo-core` crate (`Prompter` / `Reporter` traits) | Python API |
  58. ## Quick Start
  59. ```bash
  60. # Inspect a template's questions, settings, and tasks
  61. roneo inspect ./examples/starter-template
  62. # Dry-run without writing any files
  63. roneo copy ./examples/starter-template /tmp/my-project --defaults --pretend
  64. # Scaffold interactively
  65. roneo copy ./examples/starter-template /tmp/my-project
  66. # Non-interactive with variable overrides
  67. roneo copy ./examples/starter-template /tmp/my-project \
  68. --defaults \
  69. -d project_name=super-api \
  70. -d license=Apache-2.0
  71. ```
  72. ## CLI Reference
  73. ### Commands
  74. | Command | Purpose |
  75. | --- | --- |
  76. | `roneo copy <template> [dest]` | Scaffold a project from a local path, Git URL, `gh:owner/repo`, or `gl:owner/repo`. |
  77. | `roneo update [dest]` | Update a Git-tracked project via 3-way merge (`--conflict inline\|rej`), keeping local edits. |
  78. | `roneo diff [dest]` | Preview the colored 3-way diff of `roneo update` without modifying files. |
  79. | `roneo check-update [dest]` | Check for newer template versions (`--output-format plain\|json`, `-q` exits `2` if outdated). |
  80. | `roneo recopy [dest]` | Re-apply a template using saved `.copier-answers.yml` answers (no 3-way diff). |
  81. | `roneo inspect <template>` | Print metadata, settings, `--trust` tasks, and questions (`--json` supported). |
  82. | `roneo plugin <subcmd>` | Manage local `.wasm` plugins (`install`, `list`, `inspect`, `remove`). |
  83. | `roneo completions <shell>` | Generate shell completions (`bash`, `zsh`, `fish`). |
  84. ### Key Flags
  85. | Flag | Scope | Effect |
  86. | --- | --- | --- |
  87. | `-r, --vcs-ref REF` | `copy`, `update`, `diff` | Target branch, tag, commit, or `:current:` |
  88. | `-d, --data KEY=VAL` / `--data-file PATH` | `copy`, `update`, `recopy` | Supply or override answers (`-d` repeatable) |
  89. | `-l, --defaults` / `--ask Q` | `copy`, `update`, `recopy` | Skip prompts, or force a prompt for specific questions |
  90. | `-A, --skip-answered` | `update`, `recopy` | Reuse existing answers without prompting |
  91. | `-n, --pretend` | `copy`, `update`, `recopy` | Dry-run (no writes, no tasks) |
  92. | `-w, --overwrite` / `-f, --force` | `copy` | Overwrite files (`-f` = `--defaults --overwrite`) |
  93. | `-o, --conflict inline\|rej` / `-c N` | `update`, `diff` | Conflict markers or `.rej` files; diff context lines |
  94. | `-s, --skip PATTERN` / `-g, --prereleases` | `copy`, `update`, `check-update` | Skip matching paths; allow PEP 440 pre-releases |
  95. | `--trust` (`--UNSAFE`) / `-T, --skip-tasks` | `copy`, `update`, `recopy` | Allow or skip shell `_tasks` and `_migrations` |
  96. | `--plugin PATH_OR_NAME` | `copy`, `update`, `recopy` | Load a `.wasm` plugin by path or installed alias |
  97. ## Copier Compatibility
  98. Targets **Copier 9.19.1** (`_min_copier_version` enforced):
  99. | Area | Supported Features |
  100. | --- | --- |
  101. | Configuration | `copier.yml` / `copier.yaml`, multi-document YAML, list merging, `!include` + globs, `_external_data`, `settings.yml` |
  102. | Questions | `str`, `int`, `float`, `bool`, `yaml`, `json`; Jinja `type`, `default`, `choices` (list/map), `multiselect`, `when`, `ask`, `validator`, `multiline`, `secret` |
  103. | Templates & paths | Jinja2 (`minijinja` + `pycompat`, `_envops`), path confinement, dynamic paths, conditional dirs, `{% yield %}` loops, `_subdirectory`, `_templates_suffix`, `_preserve_symlinks` |
  104. | Built-in filters | `to_nice_yaml`, `from_yaml`, `from_json`, `to_nice_json`, `slugify`, `to_snake`/`to_camel`/`to_pascal`/`to_kebab`, `b64encode`/`b64decode`, `to_bool`, `pathjoin`, `now()`, `UNSET` |
  105. | Lifecycle & updates | 3-way Git merge (`--3way` / `--reject` + squash-safe `git merge-file` fallback), `.gitignore` & `_skip_if_exists` guards, PEP 440 downgrade guard, `_answers_file` rename cleanup |
  106. | VCS & caching | Local dirs, Git URLs, `gh:` / `gl:`, monorepo subdirectories, `.bundle`, submodules, local mirror cache (`~/.cache/roneo/repos`) |
  107. | Tasks & migrations | `_tasks` and `_migrations` (`before` / `after`, `_stage`, `extra_env`, `COPIER_OPERATION`) behind `--trust` |
  108. | Extensions | Sandboxed WebAssembly plugins via `roneo-plugin-sdk`, `roneo plugin`, and `_roneo_plugins` |
  109. ## WebAssembly Plugins (`roneo-plugin-sdk`)
  110. `roneo` stays 100% generic: no domain-specific extension is compiled into the binary. Write extensions in an independent Rust crate targeting `wasm32-unknown-unknown`, executed in a `wasmi` sandbox without disk or network access:
  111. ```bash
  112. # Build a WASM plugin depending on roneo-plugin-sdk
  113. cd my-plugin && cargo build --release --target wasm32-unknown-unknown
  114. # Install it under ~/.config/roneo/plugins/my-plugin.wasm
  115. roneo plugin install target/wasm32-unknown-unknown/release/my_plugin.wasm
  116. # Run with the plugin alias
  117. roneo copy --trust --defaults --plugin my-plugin <template> <dest>
  118. ```
  119. Templates can also bundle a `.wasm` file and declare `_roneo_plugins: [template/extensions/my-plugin.wasm]` in `copier.yml` / `roneo.yml` for automatic loading.
  120. ## User Settings (`settings.yml`)
  121. Read automatically in priority order from `$RONEO_SETTINGS_PATH`, `$COPIER_SETTINGS_PATH`, `~/.config/roneo/settings.yml`, or `~/.config/copier/settings.yml`:
  122. ```yaml
  123. defaults:
  124. author_name: Alice
  125. trust:
  126. - /srv/trusted-templates/
  127. - https://code.cleyrop.tech/
  128. ```
  129. ## Development
  130. ```bash
  131. cargo test --workspace
  132. cargo clippy --workspace --all-targets -- -D warnings
  133. cargo build --release
  134. ```
  135. ## License
  136. MIT — see [LICENSE](LICENSE).