Skip to main content

A Terraform-inspired YAML-based directory scaffolding tool with state management

Project description

Yark ๐ŸŒณ

PyPI version License: MIT Tests

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.state file 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:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new features
  4. Ensure tests pass: pytest
  5. 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)
  • .yarkignore support
  • Remote state backends
  • Project templates library

Start structuring your projects with Yark โ€” safe, simple, and state-managed! ๐Ÿš€

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yark_scaffold-1.0.0.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yark_scaffold-1.0.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

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

Hashes for yark_scaffold-1.0.0.tar.gz
Algorithm Hash digest
SHA256 76ffdb28e1c5c43d60eb671995f046ca8e6abe0fdbbf7adf32619af54950be60
MD5 ab8288d8cfe0484111a9e2f60e094841
BLAKE2b-256 1036cb87db5147bf2f7e81a1d3b697b9d7f55a2ef83ada45a1a71fccf4d0cb23

See more details on using hashes here.

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

Hashes for yark_scaffold-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d203b6cd9c784edf7cf79aa1e2d73577ce1d35b10b4cbc40da38929d39012d61
MD5 fe140afb468ae67df24e60b03f8f9496
BLAKE2b-256 61f161f59a96e16e5822d29de538238951cbfe61f04caa38fbc804fadbf3ddc9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page