Skip to content

GreyViperTooth/draftcraft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

draftcraft

Generate a draft snapcraft.yaml by pointing a tool at your project — not by filling in a template.

snapcraft init gives you a static template full of placeholders. draftcraft inspects your project instead: it reads your pyproject.toml, finds your name, version, entry points and dependencies, maps known dependencies to the snap interfaces and stage packages they need, and writes a snapcraft.yaml that is already mostly correct.

Honest by design

A generator can't know everything, so draftcraft never presents a guess as a fact. Every value in the generated file carries its confidence:

  • values read directly from your project's own metadata render as clean YAML;
  • heuristic inferences are marked # verify: ... with the evidence they came from;
  • placeholders you must fill in are marked # TODO: ....
name: hello-cli  # verify: normalized from 'hello_cli' in pyproject.toml [project] name
version: '1.2.0'
summary: Say hello from the command line
base: core24 # verify: defaulted to the current LTS base
apps:
  hello:
    command: bin/hello  # verify: console script 'hello' in pyproject.toml, installed by the python plugin
    plugs:
      - network  # verify: from dependency 'requests'
parts:
  hello-cli:
    plugin: python  # verify: Python project detected via pyproject.toml
    source: . # verify: assumed the project root
    stage-packages:
      - libpq5  # verify: runtime library for 'psycopg2'

Usage

draftcraft init                # generate snapcraft.yaml for the current directory
draftcraft init path/to/proj   # ... or for another directory
draftcraft detect              # show detected facts, confidence and evidence, write nothing

Install

sudo snap install draftcraft

draftcraft is live on the Snap Store

Fittingly, snap/snapcraft.yaml started life as draftcraft's own output — draftcraft init run on this repository — with hand-tuning on top (longer description, license, interface plugs, staged Python runtime).

What it detects today

Ecosystem Manifest Extracted
Python (PEP 621) pyproject.toml [project] name, version, summary, console scripts, dependencies
Python (Poetry) pyproject.toml [tool.poetry] name, version, summary, scripts, dependencies
Node.js package.json name (scopes stripped), version, summary, bin commands, runtime dependencies
Go go.mod name and binary from the module path, direct (non-indirect) requirements
Rust Cargo.toml name, version, summary, [[bin]] targets, dependencies

In a polyglot repository, detectors are tried in the order above and the first match wins.

Dependency knowledge — which snap interfaces, build packages and stage packages a dependency implies (e.g. psycopg2libpq-dev at build time, libpq5 staged, network plugged) — lives in plain YAML data files under src/draftcraft/data/, namespaced per ecosystem. Extending coverage is a data change, not a code change.

Development

Requires uv.

make setup    # install project + dev dependencies
make test     # run the test suite
make lint     # ruff format check, ruff lint, mypy (strict)
make format   # auto-format and auto-fix

Generated output is locked down by golden-file tests (tests/goldens/) against fixture projects (tests/fixtures/), and every golden file is verified to parse cleanly through real snapcraft's project schema.

Roadmap

  • Growing the dependency knowledge base (contributions are data-only: edit the YAML under src/draftcraft/data/)
  • Build-testing generated files end-to-end with snapcraft pack in CI

License

GPL-3.0, matching the craft ecosystem it serves.

About

Auto-generate snapcraft.yaml from your project metadata

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages