# @spake/npm-utils

> A library of scripts for analysing package.json files and npm output

Latest version **0.0.6** (published 2022-05-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @spake/npm-utils
pnpm add @spake/npm-utils
yarn add @spake/npm-utils
bun add @spake/npm-utils
```

Provides the command `npm-utils`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2022-05-02 |
| First published | 2022-04-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 14.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | George Spake |
| Maintainers | georgespake |
| Keywords | typescript, node, yargs, cli |

## Links

- npm: https://www.npmjs.com/package/@spake/npm-utils
- Repository: https://github.com/gpspake/npm-utils
- Homepage: https://github.com/tannerlinsley/react-query#readme
- npm.io page: https://npm.io/package/@spake/npm-utils

## Dependencies (2)

- [yargs](https://npm.io/package/yargs.md) ^17.4.1
- [json2csv](https://npm.io/package/json2csv.md) ^5.0.7

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.0.6 (latest) — 2022-05-02
- 0.0.5 — 2022-04-19
- 0.0.4 — 2022-04-19
- 0.0.3 — 2022-04-18
- 0.0.2 — 2022-04-18
- 0.0.1 — 2022-04-17

## README

# npm utils

A library of scripts for analysing package.json files and npm output

## Getting started
### install
npm
```
npm install @spake/npm-utils -g
```

yarn
```
yarn global add @spake/npm-utils
```

## Utils

### compare

compares before and after versions of a package.json file to report stats

- total dependencies before
- total dependencies after
- number of dependencies changed (version)
- number of dependencies removed
- number of dependencies added

Usage:
```
npm-utils compare <before> <after> [--csv] [--output-file]

compares before and after versions of a package.json file and reports stats

Positionals:
  before  path to package.json before changes                [string] [required]
  after   path to package.json before changes                [string] [required]

Options:
      --help         Show help                                         [boolean]
      --version      Show version number                               [boolean]
  -c, --csv          output results in csv format                      [boolean]
  -o, --output-file  provide a path to output file                     [boolean]
```

sample default output (json)
```
{
    "stats": {
        "devDependencies": {
            "dependencyType": "devDependencies",
            "versionBefore": "0.0.1",
            "versionAfter": "0.0.1",
            "countBefore": 140,
            "countAfter": 123,
            "countChanged": 49,
            "countRemoved": 22,
            "countAdded": 5
        },
        "dependencies": {
            "dependencyType": "dependencies",
            "versionBefore": "0.0.1",
            "versionAfter": "0.0.1",
            "countBefore": 77,
            "countAfter": 74,
            "countChanged": 20,
            "countRemoved": 3,
            "countAdded": 0
        },
        "total": {
            "dependencyType": "total",
            "versionBefore": "0.0.1",
            "versionAfter": "0.0.1",
            "countBefore": 214,
            "countAfter": 197,
            "countChanged": 69,
            "countRemoved": 25,
            "countAdded": 5
        }
    }
}
```
sample csv output
```
"dependencyType","versionBefore","versionAfter","countBefore","countAfter","countChanged","countRemoved","countAdded"
"devDependencies","0.0.1","0.0.1",140,123,49,22,5
"dependencies","0.0.1","0.0.1",77,74,20,3,0
"total","0.0.1","0.0.1",214,197,69,25,5
```

## Development

npm-utils is built with [Typescript](https://www.typescriptlang.org/) and [yargs](http://yargs.js.org/)

### Developing locally
```
git clone git@github.com:gpspake/npm-utils.git
cd npm-utils
yarn
yarn link
which npm-utils
```

### Adding new commands
To add a new command, create a [yargs command module](https://github.com/yargs/yargs/blob/main/docs/advanced.md#providing-a-command-module) to the `commands` directory and add it to the `commands` array in `commands/index.ts`.
Place any reusable code in the `lib` directory.

Add new ts files to `files` in `tsconfig.json`

---
_Source: https://npm.io/package/@spake/npm-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
