An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

# lockfile-sync-check


NPM Version
License

[中文文档](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`: