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/PNGs, compresses them, and strips metadata (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 and PNGs exceeding max width, compresses them, and strips metadata. EXIF data (including GPS coordinates) is removed from JPEGs; text metadata chunks are removed from PNGs.

- 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, ignored for PNG)

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.3.6.tar.gz (8.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.3.6-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for kellerlab_pre_commit_hooks-0.3.6.tar.gz
Algorithm Hash digest
SHA256 7d30ed3e917ef840f05916444ed51244c706adc0d68e7c15101e75bdad988661
MD5 2789e1919509ee07a0207dc12ae320c0
BLAKE2b-256 d8a4502b9601e548dac50eea11aa187dd0d2fa28435b23b0133e642340474b57

See more details on using hashes here.

Provenance

The following attestation bundles were made for kellerlab_pre_commit_hooks-0.3.6.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.3.6-py3-none-any.whl.

File metadata

File hashes

Hashes for kellerlab_pre_commit_hooks-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ccf7ecc39bbb3cb088f859b550c5d06d2fb0021f90f4c4ac10bf5d478af5a437
MD5 feb062d0cbc3e81bfbee1db2b5ad073f
BLAKE2b-256 2c3cbcedf17823e66486aec08cd2faa0e667d028c0c93ccf12f9269a334de43c

See more details on using hashes here.

Provenance

The following attestation bundles were made for kellerlab_pre_commit_hooks-0.3.6-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