https://github.com/a145789/lockfile-sync-check
A command-line tool to check if your package manager's lockfile is in sync with the latest changes in your Git repository.
https://github.com/a145789/lockfile-sync-check
git npm pnpm yarn
Last synced: 5 months ago
JSON representation
A command-line tool to check if your package manager's lockfile is in sync with the latest changes in your Git repository.
- Host: GitHub
- URL: https://github.com/a145789/lockfile-sync-check
- Owner: a145789
- License: mit
- Created: 2025-03-05T09:45:31.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-02T08:35:04.000Z (about 1 year ago)
- Last Synced: 2025-06-04T18:55:42.069Z (about 1 year ago)
- Topics: git, npm, pnpm, yarn
- Language: TypeScript
- Homepage:
- Size: 59.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# lockfile-sync-check
[中文文档](https://github.com/a145789/lockfile-sync-check/blob/main/README.zh-CN.md)
A command-line tool to check if your package manager's lockfile is in sync with the latest changes in your Git repository.
## Features
- Supports multiple package managers (npm, yarn, pnpm)
- Optional automatic dependency installation
- Easy integration with Git hooks
## Installation
```bash
npm install -D lockfile-sync-check
# or
yarn add -D lockfile-sync-check
# or
pnpm add -D lockfile-sync-check
```
## Usage
```bash
lockfile-sync-check [package-manager] [--install]
```
### Options
- `package-manager`: Optional. Specify the package manager to use ("npm", "yarn", or "pnpm"). If not provided, default `pnpm`.
- `--install`: Optional. Automatically install dependencies if the lockfile is out of sync.
### Example
```bash
# Check if lockfile is in sync, using default package manager (pnpm)
lockfile-sync-check
# Check using specific package manager
lockfile-sync-check npm
# Check and auto-install if out of sync
lockfile-sync-check npm --install
```
## Git Hook Integration
### Using simple-git-hooks
1. Install simple-git-hooks:
```bash
npm install -D simple-git-hooks
# or
yarn add -D simple-git-hooks
# or
pnpm add -D simple-git-hooks
```
2. Add configuration to your package.json:
```json
{
"simple-git-hooks": {
"post-merge": "lockfile-sync-check --install",
"post-rewrite": "lockfile-sync-check --install"
}
}
```
3. Initialize git hooks:
```bash
npx simple-git-hooks
```
### Using Husky
1. Install Husky:
```bash
npm install -D husky
# or
yarn add -D husky
# or
pnpm add -D husky
```
2. Initialize Husky:
```bash
npx husky install
```
3. Add hooks:
```bash
npx husky add .husky/post-merge "lockfile-sync-check --install"
npx husky add .husky/post-rewrite "lockfile-sync-check --install"
```
### Manual Setup
Alternatively, you can manually add the script to your `.git/hooks/post-merge` or `.git/hooks/post-rewrite`: