A Terraform-inspired YAML-based directory scaffolding tool with state management
Project description
Yark ๐ณ
A Terraform-inspired YAML-based directory scaffolding tool with state management.
Define your project structure in YAML, and Yark safely creates and updates it โ never touching files it doesn't own.
โจ Features
- ๐ YAML-defined structures - Clean, readable project definitions
- ๐ก๏ธ State management - Terraform-style tracking of managed resources
- ๐ Safe updates - Never deletes your manual files
- ๐จ Colored diff output - See what will be created/deleted with visual highlights
- ๐๏ธ Dry-run mode - Preview changes before applying
- ๐ฒ Tree visualization - Beautiful terminal output with Rich
- ๐ Idempotent - Run multiple times safely
๐ Quick Start
Installation
pip install yark-scaffold
Basic Usage
1. Define your structure in YAML:
# project-structure.yaml
project/:
- src/:
- main.py
- utils.py
- tests/:
- test_main.py
- docs/:
- README.md
- config.yaml
2. Create the structure:
yark create -f project-structure.yaml -p ./my-project
Output:
โ Structure created successfully in './my-project'
โ State file created: .yark.state (tracks 7 resources)
3. Add your own files (safely):
cd my-project
touch .env # Your file
touch local_notes.txt # Your file
Yark will never touch these files! โ
4. Update the structure:
Modify your YAML, then:
yark update -f project-structure.yaml -p ./my-project --dry-run
See colored preview:
๐ my-project/
โโโ ๐ .env (unchanged)
โโโ ๐ local_notes.txt (unchanged)
โโโ ๐ new_file.py (new) โ Green
โโโ ๐ old_file.py (deleted) โ Red
โโโ ๐ src/
โโโ ...
๐ Commands
create - Initialize new structure
Creates directories and files from YAML.
yark create -f <yaml-file> -p <target-path> [--dry-run]
Examples:
# Create in current directory
yark create -f structure.yaml
# Create in specific directory
yark create -f structure.yaml -p ./new-project
# Preview without creating
yark create -f structure.yaml -p ./new-project --dry-run
What it does:
- Creates all files and folders from YAML
- Generates
.yark.statefile to track what it created
update - Sync structure with YAML
Updates existing structure to match YAML (only touches managed files).
yark update -f <yaml-file> -p <target-path> [--dry-run]
Examples:
# Update structure
yark update -f structure.yaml -p ./my-project
# Preview changes
yark update -f structure.yaml -p ./my-project --dry-run
What it does:
- Creates new files/folders from YAML
- Deletes files/folders that were removed from YAML (only if managed)
- Ignores files not in state (your manual files are safe!)
- Updates
.yark.state
list - Show directory tree
Displays current directory structure.
yark list -p <directory>
Examples:
# List current directory
yark list
# List specific directory
yark list -p ./my-project
๐ State Management (The Key Feature)
Yark uses a Terraform-style state file (.yark.state) to track which files it manages.
How It Works:
Initial create:
yark create -f structure.yaml -p ./project
# Creates: .yark.state tracking all created files
You add your own files:
touch ./project/.env
touch ./project/notes.txt
# These are NOT in .yark.state
Update with modified YAML:
yark update -f structure.yaml -p ./project
# Only modifies files in .yark.state
# Your .env and notes.txt are IGNORED โ
Safety Guarantees:
โ
Only deletes managed files (those in .yark.state)
โ
Ignores your manual files completely
โ
Won't run update without state (prevents accidents)
โ
Clear error messages if state is missing
๐ YAML Structure Format
Basic Structure
root/:
- file1.txt
- file2.py
- subfolder/:
- nested_file.txt
Rules:
- Folders end with
/(required) - Files are strings in folder lists
- Nested folders use dict or list format
- Empty folders use empty list:
folder/: []
Examples:
Simple project:
project/:
- README.md
- main.py
- config.json
Nested structure:
webapp/:
- frontend/:
- src/:
- App.jsx
- index.js
- public/:
- index.html
- backend/:
- api/:
- routes.py
- main.py
- docker-compose.yml
Mixed format:
project/:
src/: # Dict style
- main.py
- utils.py
tests/: # List style
- test_main.py
- README.md # Root files
๐ฏ Use Cases
- Bootstrap new projects with consistent structure
- Team project templates everyone uses same layout
- Monorepo management maintain folder structure across repos
- Documentation YAML serves as structure documentation
- CI/CD automate project setup in pipelines
๐ ๏ธ Development
Setup
git clone https://github.com/youssef-abbih/yark.git
cd yark
pip install -e .
pip install -r requirements.txt
Run Tests
pytest tests/ -v
# With coverage
pytest tests/ --cov=yark --cov-report=term-missing
Project Structure
yark/
โโโ yark/ # Source code
โ โโโ cli.py # Command-line interface
โ โโโ parser.py # YAML parsing
โ โโโ builder.py # Structure creation
โ โโโ updater.py # Structure updates
โ โโโ scanner.py # Directory scanning
โ โโโ state.py # State management
โ โโโ ...
โโโ tests/ # Test suite
โ โโโ fixtures/ # Test YAML files
โ โโโ test_*.py
โโโ README.md
๐ค Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new features
- Ensure tests pass:
pytest - Submit a pull request
๐ License
MIT License - see LICENSE file for details.
๐ Acknowledgments
- Rich - Beautiful terminal output
- Inspired by Terraform's state management approach
- YAML for clean, readable configuration
๐บ๏ธ Roadmap
- File content templating
- Interactive YAML generator (
yark init) -
.yarkignoresupport - Remote state backends
- Project templates library
Start structuring your projects with Yark โ safe, simple, and state-managed! ๐
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yark_scaffold-1.0.0.tar.gz.
File metadata
- Download URL: yark_scaffold-1.0.0.tar.gz
- Upload date:
- Size: 21.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76ffdb28e1c5c43d60eb671995f046ca8e6abe0fdbbf7adf32619af54950be60
|
|
| MD5 |
ab8288d8cfe0484111a9e2f60e094841
|
|
| BLAKE2b-256 |
1036cb87db5147bf2f7e81a1d3b697b9d7f55a2ef83ada45a1a71fccf4d0cb23
|
File details
Details for the file yark_scaffold-1.0.0-py3-none-any.whl.
File metadata
- Download URL: yark_scaffold-1.0.0-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d203b6cd9c784edf7cf79aa1e2d73577ce1d35b10b4cbc40da38929d39012d61
|
|
| MD5 |
fe140afb468ae67df24e60b03f8f9496
|
|
| BLAKE2b-256 |
61f161f59a96e16e5822d29de538238951cbfe61f04caa38fbc804fadbf3ddc9
|