{"_id":"@arvid-berndtsson/cc-check","name":"@arvid-berndtsson/cc-check","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@arvid-berndtsson/cc-check","version":"0.1.0","description":"Cross-platform conventional commit checker for git commit messages","bin":{"cc-check":"bin/cc-check","postinstall":"bin/postinstall"},"scripts":{"postinstall":"postinstall"},"repository":{"type":"git","url":"git+https://github.com/arvid-berndtsson/cc-check.git"},"keywords":["conventional-commits","git","commit-msg","pre-commit","lint","commit","validator"],"author":{"name":"Arvid Berndtsson","email":"dev@arvid.tech"},"license":"MIT","engines":{"node":">=14"},"os":["darwin","linux","win32"],"cpu":["x64","arm64"],"gitHead":"28aa34519aef0b4d5076e69707cb7960fb073c5b","_id":"@arvid-berndtsson/cc-check@0.1.0","bugs":{"url":"https://github.com/arvid-berndtsson/cc-check/issues"},"homepage":"https://github.com/arvid-berndtsson/cc-check#readme","_nodeVersion":"22.16.0","_npmVersion":"11.6.3","dist":{"integrity":"sha512-N5yl5uIJe/VRW51nWUfmW6qEilDzebqDLJS28+nJ9fwVW2DGNvu0ND2p39TGGQmbEdbDVcqgVXyV2CiCgfTemg==","shasum":"dc56f90601f87440a480c3512ed8553bd2d541db","tarball":"https://registry.npmjs.org/@arvid-berndtsson/cc-check/-/cc-check-0.1.0.tgz","fileCount":10,"unpackedSize":401240,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDtyUBEUXrFUcJNU4yED3cME0miUIO+WXBRuU7TBK1KfAiAOmPTg47+lCUDt5kqqf6dI9MhdtwvBVOzVzpLEch8GTg=="}]},"_npmUser":{"name":"arvid-berndtsson","email":"npm@arvid.tech"},"directories":{},"maintainers":[{"name":"arvid-berndtsson","email":"npm@arvid.tech"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cc-check_0.1.0_1763819837465_0.5648987303446262"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-22T13:57:17.336Z","0.1.0":"2025-11-22T13:57:17.692Z","modified":"2025-11-22T13:57:18.006Z"},"maintainers":[{"name":"arvid-berndtsson","email":"npm@arvid.tech"}],"description":"Cross-platform conventional commit checker for git commit messages","homepage":"https://github.com/arvid-berndtsson/cc-check#readme","keywords":["conventional-commits","git","commit-msg","pre-commit","lint","commit","validator"],"repository":{"type":"git","url":"git+https://github.com/arvid-berndtsson/cc-check.git"},"author":{"name":"Arvid Berndtsson","email":"dev@arvid.tech"},"bugs":{"url":"https://github.com/arvid-berndtsson/cc-check/issues"},"license":"MIT","readme":"# cc-check\n\nA cross-platform Rust-based tool to validate git commit messages against the [Conventional Commits](https://www.conventionalcommits.org/) specification. This tool hooks into git's commit-msg hook to automatically validate commit messages.\n\n**Works on Windows, Linux, and macOS** - The same installation and usage works across all platforms.\n\n## Features\n\n- ✅ Validates commit message format according to Conventional Commits specification\n- ✅ Supports all standard commit types (feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert)\n- ✅ Validates optional scope\n- ✅ Detects breaking changes (via `!` or `BREAKING CHANGE:` footer)\n- ✅ Checks description length (warns if > 72 characters)\n- ✅ Integrates seamlessly with git pre-commit hooks\n- ✅ Can read from stdin or file (works with git hooks)\n- ✅ Configurable via command-line flags\n\n## Installation\n\n### Prerequisites\n\n- Rust and Cargo installed ([rustup.rs](https://rustup.rs/))\n- Git installed\n\n### Cross-Platform Support\n\n`cc-check` works on **Windows**, **Linux**, and **macOS**. The installation process is the same on all platforms.\n\n### Install the Git Hook\n\nThe easiest way to install the git hook is using the built-in install command:\n\n```bash\n# Build and install (recommended)\ncargo run --release -- install\n\n# Or if already built\ncargo build --release\n./target/release/cc-check install\n```\n\nThis will:\n- Build the Rust binary in release mode (unless `--no-build` is used)\n- Install a cross-platform commit-msg hook in your `.git/hooks/` directory\n- Backup any existing commit-msg hook\n- Work on Windows, Linux, and macOS\n\n**Note:** On Windows, the hook uses a `.bat` file if needed, but Git Bash (included with Git for Windows) can also run `.sh` hooks.\n\n## Usage\n\n### As a Git Hook (Automatic)\n\nOnce installed, the hook will automatically validate commit messages when you run `git commit`. Invalid messages will be rejected.\n\n```bash\n# ❌ This will be rejected\ngit commit -m \"invalid commit message\"\n\n# ✅ This will pass\ngit commit -m \"feat: add new feature\"\n```\n\n### As a Standalone Tool\n\nYou can also use the checker directly:\n\n```bash\n# Check a commit message file\ncc-check check .git/COMMIT_EDITMSG\n\n# Or use backward-compatible syntax (file path as first argument)\ncc-check .git/COMMIT_EDITMSG\n\n# With JSON output\ncc-check check --format json .git/COMMIT_EDITMSG\n\n# With custom types\ncc-check check --extra-types \"wip,release\" .git/COMMIT_EDITMSG\n```\n\n### Command-Line Flags\n\nUse `cc-check check --help` to see all available flags:\n\n- `--extra-types \"wip,release\"` - Add custom allowed types\n- `--max-subject 0` - Disable subject length check\n- `--no-trailing-period` - Disallow trailing period (default: true)\n- `--format json` - Machine-readable output (`{\"ok\":true}` or `{ \"ok\": false, \"error\": \"...\" }`)\n- `--allow-merge-commits` - Allow merge/revert message validation (default: true)\n\n### Commit Message Format\n\nThe tool validates the following format:\n\n```\n<type>(<scope>): <description>\n\n[optional body]\n\n[optional footer(s)]\n```\n\n**Types:**\n- `feat`: A new feature\n- `fix`: A bug fix\n- `docs`: Documentation only changes\n- `style`: Changes that do not affect the meaning of the code\n- `refactor`: A code change that neither fixes a bug nor adds a feature\n- `perf`: A code change that improves performance\n- `test`: Adding missing tests or correcting existing tests\n- `build`: Changes that affect the build system or external dependencies\n- `ci`: Changes to CI configuration files and scripts\n- `chore`: Other changes that don't modify src or test files\n- `revert`: Reverts a previous commit\n\n**Validation Rules:**\n- Subject default max length: 72 chars\n- Trailing period in subject is disallowed by default\n- Merge/Revert messages are allowed by default\n\n**Examples:**\n\n```bash\n# Simple commit\nfeat: add user authentication\n\n# With scope\nfix(api): correct error handling in endpoint\n\n# Breaking change\nfeat!: change API structure\n\n# With body\nfeat: add new feature\n\nThis feature adds support for user authentication\nwith JWT tokens.\n\n# With breaking change footer\nfeat: add new API\n\nBREAKING CHANGE: The old API endpoint is deprecated\n```\n\n## Pre-commit Integration\n\nThis repository includes a `.pre-commit-config.yaml` with hooks that run the same checks as CI:\n\n1. **Rust Format Check** - Validates code formatting with `cargo fmt --all -- --check`\n2. **Rust Clippy** - Runs linter with `cargo clippy --all-targets --all-features -- -D warnings`\n3. **Conventional Commit Check** - Validates commit message format\n\nInstall and enable pre-commit hooks:\n\n```bash\n# Install all hooks (pre-commit and commit-msg)\npre-commit install\npre-commit install --hook-type commit-msg\n```\n\nThe hooks will automatically:\n- Check Rust code formatting before commits\n- Run clippy linter to catch common issues\n- Validate commit messages follow conventional commit format\n\n**Note:** For best performance, build the release binaries:\n```bash\ncargo build --release\n```\n\nThis ensures the hooks run quickly without needing to compile on each commit. The first run may be slower as it compiles the binaries, but subsequent runs will use the cached binaries.\n\nIf formatting fails, run `cargo fmt --all` to auto-format your code, then re-stage and commit.\n\n## Building\n\n```bash\n# Debug build\ncargo build\n\n# Release build (recommended for hooks)\ncargo build --release\n\n# Run tests\ncargo test\n```\n\n## Publishing\n\nThis project is configured for multi-language distribution. See [PUBLISHING.md](PUBLISHING.md) for complete publishing instructions.\n\n### Quick Start\n\n1. **Set up GitHub Secrets**:\n   - `CARGO_REGISTRY_TOKEN` - for crates.io\n   - `NPM_TOKEN` - for npm\n   - `PYPI_API_TOKEN` - for PyPI\n\n2. **Create a release**:\n   ```bash\n   # Update versions in Cargo.toml, package.json, pyproject.toml\n   git commit -am \"chore(release): v0.1.0\"\n   git tag v0.1.0\n   git push origin main --tags\n   ```\n\n3. **GitHub Actions will automatically**:\n   - Build binaries for Windows, Linux, macOS (x86_64 and ARM64)\n   - Create GitHub Release with all binaries\n   - Publish to crates.io (Rust)\n   - Publish to npm (Node.js)\n   - Publish to PyPI (Python)\n\nSee [PUBLISHING.md](PUBLISHING.md) for detailed instructions.\n\n## Using from Different Language Ecosystems\n\n`cc-check` can be used from any language ecosystem that can execute binaries:\n\n### Rust\n\n```toml\n# Cargo.toml\n[dependencies]\ncc-check = \"0.1.0\"  # When published to crates.io\n```\n\nOr use as a binary:\n```bash\ncargo install cc-check\ncc-check check .git/COMMIT_EDITMSG\n```\n\n### Node.js / npm\n\nInstall as a binary dependency:\n```bash\nnpm install --save-dev @arvid-berndtsson/cc-check\nnpx cc-check check .git/COMMIT_EDITMSG\n```\n\nOr use in package.json scripts:\n```json\n{\n  \"scripts\": {\n    \"commit-msg\": \"cc-check check\"\n  }\n}\n```\n\n### Python\n\nInstall via pip (when available):\n```bash\npip install cc-check\ncc-check check .git/COMMIT_EDITMSG\n```\n\nOr use as a pre-commit hook:\n```yaml\n# .pre-commit-config.yaml\nrepos:\n  - repo: local\n    hooks:\n      - id: cc-check\n        name: cc-check\n        entry: cc-check check\n        language: system\n        stages: [commit-msg]\n```\n\n### Go\n\nUse as an external tool:\n```go\npackage main\n\nimport (\n    \"os/exec\"\n)\n\nfunc main() {\n    cmd := exec.Command(\"cc-check\", \"check\", \".git/COMMIT_EDITMSG\")\n    // ... handle output\n}\n```\n\n### Deno\n\n```typescript\nconst process = Deno.run({\n  cmd: [\"cc-check\", \"check\", \".git/COMMIT_EDITMSG\"],\n});\nawait process.status();\n```\n\n**Note:** For multi-language distribution, you'll need to:\n1. Build binaries for each platform (Windows, Linux, macOS)\n2. Package them appropriately for each ecosystem\n3. Publish to respective package registries (npm, PyPI, crates.io, etc.)\n\nThe core Rust implementation ensures consistent behavior across all platforms and language bindings.\n\n## Uninstallation\n\nTo remove the hook:\n\n```bash\nrm .git/hooks/commit-msg\n```\n\nIf you backed up a previous hook, you can restore it:\n\n```bash\nmv .git/hooks/commit-msg.backup .git/hooks/commit-msg\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-40f94ee82aa3251e264976e4087727de"}