Skip to main content

Reusable pre-commit hooks for OpenSCAD projects

Project description

🔧 Pre-commit Hooks

Reusable pre-commit hooks for OpenSCAD projects.

Published on PyPI as kellerlab-pre-commit-hooks.

📌 What

Two hooks for OpenSCAD-based 3D printing projects:

Hook Description
flatten-validate Runs scadm flatten --all and fails if flattened files have uncommitted changes
optimize-images Resizes oversized JPEGs, compresses them, and strips EXIF data (privacy)

🔧 Usage

Add to your .pre-commit-config.yaml:

- repo: https://github.com/kellerlabs/pre-commit-hooks
  rev: v0.1.0  # use latest tag
  hooks:
    - id: flatten-validate
    - id: optimize-images

flatten-validate

Flattens OpenSCAD files via scadm and validates that the output is committed. Reads flatten config from scadm.json automatically.

- id: flatten-validate
  # Override trigger pattern (default: always_run)
  always_run: false
  files: '^(scadm\.json|models/.*\.scad)'

Options:

Arg Default Description
--flatten-dir Read from scadm.json Override flatten output dirs (list of paths/globs)

optimize-images

Resizes JPEGs exceeding max width, compresses to target quality, and strips EXIF metadata (removes GPS coordinates from real-life photos).

- id: optimize-images
  args: [--max-width=1920, --quality=85]

Options:

Arg Default Description
--max-width 1920 Maximum image width in pixels
--quality 85 JPEG compression quality (1-95)

Both hooks fail when files are modified, printing instructions to git add the changes. Re-run git commit after staging.

🏗️ Used In

🤝 Contributing

See CONTRIBUTING.md.

📜 License

MIT

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

kellerlab_pre_commit_hooks-0.2.2.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

kellerlab_pre_commit_hooks-0.2.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file kellerlab_pre_commit_hooks-0.2.2.tar.gz.

File metadata

File hashes

Hashes for kellerlab_pre_commit_hooks-0.2.2.tar.gz
Algorithm Hash digest
SHA256 073b542fbe4124160e76dcd97c227976a95a5ea9ad9d287fd0749096aa5d420e
MD5 e087a66053feb672afde6a0d551f61b3
BLAKE2b-256 2546e0394d772dbba851b9ede4227ff4f2624d7296a545277b268139b5d9d55d

See more details on using hashes here.

Provenance

The following attestation bundles were made for kellerlab_pre_commit_hooks-0.2.2.tar.gz:

Publisher: publish.yml on kellerlabs/pre-commit-hooks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kellerlab_pre_commit_hooks-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for kellerlab_pre_commit_hooks-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 00a58ec0841192a2344bf6056d8f1a8fb14c866a592e3bc0ac097c7c7c19a63c
MD5 cda796ea5d89a9fee8214cb6cffa42e4
BLAKE2b-256 fa67a50a9cbd13e516aa3443328580cb9e2684111940f578b67a65c0dbac0036

See more details on using hashes here.

Provenance

The following attestation bundles were made for kellerlab_pre_commit_hooks-0.2.2-py3-none-any.whl:

Publisher: publish.yml on kellerlabs/pre-commit-hooks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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