diff --git a/README.md b/README.md index cba1cbc..9aee643 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,16 @@ # filter-npm-deps + ![npm](https://img.shields.io/npm/v/filter-npm-deps?style=flat-square) filter-npm-deps is a convenient Node.js CLI script designed to filter a given list of dependencies from your `package.json`. -It supports filtering dependencies from all three commonly used dependency fields: *dependencies*, *devDependencies*, and *optionalDependencies*. +It supports filtering dependencies from all three commonly used dependency fields: _dependencies_, _devDependencies_, and _optionalDependencies_. + +## 🎯 Motivation + +In many projects, the `package.json` file contains numerous dependencies serving different purposes. +However, certain scenarios, like CI jobs, demand only specific dependencies in particular versions. +Therefore `filter-npm-deps` can reduce or prune your package.json, to only contain the dependencies that you need. ## 🚀 Usage @@ -13,12 +20,57 @@ To use filter-npm-deps, you can easily invoke it with npx as follows: npx filter-npm-deps -d [dependencies] ``` -For example, if you want to only keep "lodash" and "axios" with the given version from your package.json, you can run: +## 🧰 Requirements + +- node.js 18 or higher + +## 📝Example + +Given the following package.json: + +```json +{ + "name": "my-app", + "description": "...", + "dependencies": { + "axios": "1.4.0", + "lodash-es": "4.17.21" + }, + "devDependencies": { + "typescript": "5.1.6" + }, + "optionalDependencies": { + "playwright": "1.36.1" + } +} +``` + +If you want to only keep `playwright` and `lodash-es` with the given version from your package.json, you can run: ```bash -npx filter-npm-deps -d "lodash, axios" +npx filter-npm-deps -d "playwright,lodash-es" +``` + +which would result in: + +```json +{ + "name": "my-app", + "description": "...", + "dependencies": { + "lodash-es": "4.17.21" + }, + "devDependencies": {}, + "optionalDependencies": { + "playwright": "1.36.1" + } +} ``` +Afterward you can install your dependencies with your package manager of choice. + +For example with npm: +`npm ci` ## 💡 Alternatives diff --git a/package.json b/package.json index 55011b7..eab5033 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "filter-npm-deps", - "version": "0.1.0", - "description": "", + "version": "0.1.1", + "description": "A convenient Node.js CLI script to filter and only keep a list of dependencies from your package.json", "engines": { "node": ">=18" }, @@ -10,7 +10,6 @@ }, "repository": "https://github.com/jase88/filter-npm-deps", "homepage": "https://github.com/jase88/filter-npm-deps#readme", - "author": "", "license": "MIT", "keywords": [ "filter",