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
- kellerlabs/homeracker — HomeRacker Core
- kellerlabs/homeracker-exclusive — HomeRacker MakerWorld models
🤝 Contributing
See CONTRIBUTING.md.
📜 License
MIT
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 kellerlab_pre_commit_hooks-0.3.2.tar.gz.
File metadata
- Download URL: kellerlab_pre_commit_hooks-0.3.2.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3be0fb2a4a635ba0016195c063dc475c75b61e999f167c041a959bdbdc73c891
|
|
| MD5 |
3a84a351d2edb65ef41abc386082de39
|
|
| BLAKE2b-256 |
f3717836b34d9626cce910f0daccf587dd03c12f44ce7a1eae021e2989f468e7
|
Provenance
The following attestation bundles were made for kellerlab_pre_commit_hooks-0.3.2.tar.gz:
Publisher:
publish.yml on kellerlabs/pre-commit-hooks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kellerlab_pre_commit_hooks-0.3.2.tar.gz -
Subject digest:
3be0fb2a4a635ba0016195c063dc475c75b61e999f167c041a959bdbdc73c891 - Sigstore transparency entry: 1505035172
- Sigstore integration time:
-
Permalink:
kellerlabs/pre-commit-hooks@d7ff3a4316d1b388c35d68381f883beb80a2f1c2 -
Branch / Tag:
refs/tags/pre-commit-hooks-v0.3.2 - Owner: https://github.com/kellerlabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d7ff3a4316d1b388c35d68381f883beb80a2f1c2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file kellerlab_pre_commit_hooks-0.3.2-py3-none-any.whl.
File metadata
- Download URL: kellerlab_pre_commit_hooks-0.3.2-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd82eac23416dfd90f4a142ad80d750f7f847889e46107420ff3259d37702ede
|
|
| MD5 |
7d2ffa029f0bab9f9d5f6aeeb179a3f4
|
|
| BLAKE2b-256 |
5a4849aa77bdafbe9b9322631ebf2c474f39f9869960f2c3e1bddb6a52f0d00a
|
Provenance
The following attestation bundles were made for kellerlab_pre_commit_hooks-0.3.2-py3-none-any.whl:
Publisher:
publish.yml on kellerlabs/pre-commit-hooks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kellerlab_pre_commit_hooks-0.3.2-py3-none-any.whl -
Subject digest:
bd82eac23416dfd90f4a142ad80d750f7f847889e46107420ff3259d37702ede - Sigstore transparency entry: 1505035365
- Sigstore integration time:
-
Permalink:
kellerlabs/pre-commit-hooks@d7ff3a4316d1b388c35d68381f883beb80a2f1c2 -
Branch / Tag:
refs/tags/pre-commit-hooks-v0.3.2 - Owner: https://github.com/kellerlabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d7ff3a4316d1b388c35d68381f883beb80a2f1c2 -
Trigger Event:
release
-
Statement type: