Tools for building step-by-step tutorials that are easy to contribute to and easy to render as clean, commit-based Gitorials.
This CLI helps you move between two tutorial representations:
master(or your workshop branch): mdBook-friendly, contributor-friendly structuregitorial: commit-driven tutorial flow (section,action,template,solution)
npm install -g gitorial-cliFor local development in this repo:
npm installGenerate a gitorial branch from your mdBook workshop branch.
gitorial-cli build-gitorial -r /path/to/repo -i master -o gitorial -s src --forceOptions:
-r, --repo <path>repo path (default: current directory)-i, --input <branch>workshop branch (default:master)-o, --output <branch>gitorial branch (default:gitorial)-s, --source <dir>mdBook source directory in input branch (default:src)--forcerecreate output branch if it exists--verboseverbose logs
Behavior:
- Rebuilds
outputas a fresh orphan branch. - Rewrites commit history on the output branch by design.
- Copies full step snapshots per commit, so output branch content is tutorial snapshot content.
Generate or update an mdBook workshop branch from a gitorial branch.
gitorial-cli build-mdbook -r /path/to/repo -i gitorial -o master -s srcOptions:
-r, --repo <path>repo path (default: current directory)-i, --input <branch>gitorial branch (default:gitorial)-o, --output <branch>workshop branch (default:master)-s, --source <dir>output mdBook source directory (default:src)--forceaccepted but ignored (history is preserved)--verboseverbose logs
Behavior:
- Preserves output branch history.
- Replaces only the
sourcedirectory content (for examplesrc/orexample/src/). - Leaves files outside that directory untouched.
Install a standard CI set for mdBook tutorials.
gitorial-cli install-workflows -r /path/to/repo -i master -o gitorial -s src --forceOptions:
-r, --repo <path>repo path (default: current directory)-i, --input <branch>mdBook/workshop branch (default:master)-o, --output <branch>gitorial branch (default:gitorial)-s, --source <dir>mdBook source directory (default:src)--forceoverwrite existing workflow files--commitcommit generated workflow files--verboseverbose logs
Behavior:
- Writes
.github/workflows/check.yml. - Writes
.github/workflows/deploy.yml. - Writes
.github/workflows/gitorial-sync.yml. - Replaces placeholders with your selected branch/source settings.
A gitorial step must map to one of these types:
section: intro/context step, README onlyaction: non-template operational steptemplate: TODO step, must be followed by asolutionsolution: working result of preceding template
Declare type in markdown using a hidden comment:
<!-- gitorial: action -->Supported forms:
<!-- gitorial: section --><!-- gitorial: action --><!-- gitorial: template --><!-- gitorial: solution -->
Expected source layout:
src/
SUMMARY.md
0/
README.md # section-only step (optional)
1/
README.md # generated step page with Monaco
source/
README.md # action/section source content
...
2/
README.md # generated step page with Monaco
template/
README.md
...
solution/
README.md
...
_gitorial/
monaco-setup.js
monaco-setup.css
Notes:
README.mdinside each step folder is the rendered page shell.files.jsonis generated per interactive step to drive Monaco file selection.- Section-only steps are represented as numbered folders with only
README.md.
- Run commands from a clean working tree.
- Commands switch branches in the target repo.
- Use dedicated branches for workshop and gitorial.
Workflow templates:
templates/check.ymltemplates/deploy.ymltemplates/gitorial-sync.yml
This repo also includes a concrete workflow:
.github/workflows/sync-gitorial.yml- Builds
gitorialfromexample/srcon pushes tomaster
See example/ for a complete fixture with all step types.
Round-trip commands for this repo:
node src/index.js build-gitorial -r . -i master -o gitorial -s example/src --force
node src/index.js build-mdbook -r . -i gitorial -o master -s example/src