https://github.com/uid11/assert-package-lock-is-consistent
Assert that package-lock.json is consistent with package.json
https://github.com/uid11/assert-package-lock-is-consistent
Last synced: about 2 months ago
JSON representation
Assert that package-lock.json is consistent with package.json
- Host: GitHub
- URL: https://github.com/uid11/assert-package-lock-is-consistent
- Owner: uid11
- License: mit
- Created: 2021-07-23T02:05:32.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-23T03:12:29.000Z (about 5 years ago)
- Last Synced: 2025-10-24T04:27:28.103Z (9 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# assert-package-lock-is-consistent
[![NPM version][npm-image]][npm-url]
[![dependencies: none][dependencies-none-image]][dependencies-none-url]
[![code style: prettier][prettier-image]][prettier-url]
[![Conventional Commits][conventional-commits-image]][conventional-commits-url]
[![License MIT][license-image]][license-url]
Assert that `package-lock.json` is consistent with `package.json`, that is,
both files have the same dependencies.
## Install
Requires `node@14` or higher:
```sh
npm install assert-package-lock-is-consistent --save-dev
```
## Usage
This package verifies that `package-lock.json` and `package.json` files in your project
have the same dependencies (`dependencies`, `devDependencies`, `peerDependencies`, and
`optionalDependencies`).
If some dependency exists only in one file, or if the versions of some dependency
in these files are different, the package throws an exception with a list of all such differences
(prints a list and returns code `1` in `CLI`).
Dependency versions may difference if someone, for example, forgets to update `package-lock.json`
file or include it in a commit.
The package works with `package-lock.json` file version 2 (`npm@7` or higher).
### CLI
Assert that `package-lock.json` has the same dependencies as `package.json`:
```sh
npx assert-package-lock-is-consistent
```
### JavaScript/TypeScript API
```js
import assertPackageLockIsConsistent from 'assert-package-lock-is-consistent';
// or
import {assertPackageLockIsConsistent} from 'assert-package-lock-is-consistent';
// assert that package-lock.json has the same dependencies as package.json
assertPackageLockIsConsistent();
```
## License
[MIT][license-url]
[conventional-commits-image]: https://img.shields.io/badge/Conventional_Commits-1.0.0-yellow.svg 'Conventional Commits'
[conventional-commits-url]: https://conventionalcommits.org
[dependencies-none-image]: https://img.shields.io/badge/dependencies-none-success.svg 'No dependencies'
[dependencies-none-url]: https://github.com/uid11/assert-package-lock-is-consistent/blob/main/package.json
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg 'The MIT License'
[license-url]: https://github.com/uid11/assert-package-lock-is-consistent/blob/main/LICENSE
[npm-image]: https://img.shields.io/npm/v/assert-package-lock-is-consistent.svg 'assert-package-lock-is-consistent'
[npm-url]: https://www.npmjs.com/package/assert-package-lock-is-consistent
[prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg 'Prettier code style'
[prettier-url]: https://github.com/prettier/prettier