Skip to content

Commit d523b47

Browse files
committed
chore: update readme with automd
1 parent a7dfce7 commit d523b47

File tree

3 files changed

+78
-31
lines changed

3 files changed

+78
-31
lines changed

README.md

Lines changed: 58 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,32 @@
55
[![Github Actions][github-actions-src]][github-actions-href]
66
[![Codecov][codecov-src]][codecov-href]
77

8-
> Unified Package Manager for Node.js
9-
10-
🚧 This project is under development. Please follow [issues](https://github.com/unjs/nypm/issues) for the roadmap. 🚧
8+
> Unified Package Manager for Node.js and Bun
119
1210
## What does **nypm** do?
1311

14-
✅ Supports **npm, yarn, pnpm and bun** out of the box with a unified API
12+
✅ Supports [npm](https://docs.npmjs.com/cli/v10/commands/npm), [Yarn](https://yarnpkg.com/), [pnpm](https://pnpm.io/) and [bun](https://bun.sh/package-manager) out of the box with a unified API.
1513

16-
✅ Provides an **API interface** to interact with package managers
14+
✅ Provides an **API interface** to interact with package managers.
1715

18-
**Autodetects** project's package manager using package.json and known lockfiles
16+
**Autodetects** project's package manager using `package.json` and known lockfiles.
1917

20-
**Auto-installs and use exactly expected version** of supported package managers using [nodejs/corepack](https://github.com/nodejs/corepack)
18+
**Auto-installs and use exactly expected version** of supported package managers using [nodejs/corepack](https://github.com/nodejs/corepack) when available.
2119

22-
**Minimal** implementation
20+
**Minimal** implementation.
2321

24-
nypm, detects package manager type and version and converts command into package manager CLI arguments. It then uses corepack to execute package manager's command (and download it if necessary).
22+
nypm, detects package manager type and version and converts command into package manager CLI arguments. It then uses corepack or proper command to execute package manager's command and download it if necessary.
2523

2624
```
2725
+------------------------------------------------+
2826
| nypm |
2927
+------------------------------------------------+
30-
+-----------------------------------+
31-
| Corepack |
32-
+-----------------------------------+
33-
+---------+ +---------+ +---------+ +---------+
34-
| npm | | yarn | | pnpm | | bun |
35-
+---------+ +---------+ +---------+ +---------+
28+
+-----------------------------------+ +---------+
29+
| Corepack | | bun |
30+
+-----------------------------------+ +---------+
31+
+---------+ +---------+ +---------+
32+
| npm | | yarn | | pnpm |
33+
+---------+ +---------+ +---------+
3634
+------------------------------------------------+
3735
| Node.js project |
3836
+------------------------------------------------+
@@ -43,61 +41,92 @@ nypm, detects package manager type and version and converts command into package
4341
**Install dependencies:**
4442

4543
```sh
46-
npx nypm@latest i
44+
npx nypm i
4745
```
4846

4947
**Add a dependency:**
5048

5149
```sh
52-
npx nypm@latest add defu
50+
npx nypm add defu
5351
```
5452

5553
**Remove a dependency:**
5654

5755
```sh
58-
npx nypm@latest remove defu
56+
npx nypm remove defu
5957
```
6058

6159
## API Usage
6260

6361
Install package:
6462

63+
<!-- AUTOMD_START generator="pm-install" name="nypm" -->
64+
6565
```sh
66+
# ✨ Auto-detect
67+
npx nypm i nypm
68+
6669
# npm
6770
npm install nypm
6871

69-
# pnpm
70-
pnpm install nypm
71-
7272
# yarn
7373
yarn add nypm
7474

75+
# pnpm
76+
pnpm install nypm
77+
7578
# bun
7679
bun install nypm
7780
```
7881

82+
<!-- AUTOMD_END -->
83+
7984
Import:
8085

8186
```js
8287
// ESM
8388
import {
84-
detectPackageManager,
85-
installDependencies,
8689
addDependency,
87-
addDevDependency,
88-
removeDependency,
8990
} from "nypm";
9091

9192
// CommonJS
9293
const {
93-
detectPackageManager,
94-
installDependencies,
9594
addDependency,
96-
addDevDependency,
97-
removeDependency,
9895
} = require("nypm");
9996
```
10097

98+
<!-- AUTOMD_START generator="jsdocs" -->
99+
100+
### `addDependency(name, options)`
101+
102+
Adds dependency to the project.
103+
104+
### `addDevDependency(name, options)`
105+
106+
Adds dev dependency to the project.
107+
108+
### `detectPackageManager(cwd, options)`
109+
110+
Detect the package manager used in a directory (and up) by checking various sources:
111+
112+
1. Use `packageManager` field from package.json
113+
2. Known lock files and other files
114+
115+
### `ensureDependencyInstalled(name, options)`
116+
117+
Ensures dependency is installed.
118+
119+
### `installDependencies(options)`
120+
121+
Installs project dependencies.
122+
123+
### `removeDependency(name, options)`
124+
125+
Removes dependency from the project.
126+
127+
128+
<!-- AUTOMD_END -->
129+
101130
## 💻 Development
102131

103132
- Clone this repository

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"dist"
2424
],
2525
"scripts": {
26-
"build": "unbuild",
26+
"build": "automd && unbuild",
2727
"dev": "vitest dev",
2828
"lint": "eslint --ext .ts,.js,.mjs,.cjs . && prettier -c src test",
2929
"lint:fix": "eslint --ext .ts,.js,.mjs,.cjs . --fix && prettier -w src test",
@@ -42,6 +42,7 @@
4242
"devDependencies": {
4343
"@types/node": "^20.11.16",
4444
"@vitest/coverage-v8": "^1.2.2",
45+
"automd": "^0.1.4",
4546
"changelogen": "^0.5.5",
4647
"eslint": "^8.56.0",
4748
"eslint-config-unjs": "^0.2.1",
@@ -56,4 +57,4 @@
5657
"engines": {
5758
"node": "^14.16.0 || >=16.10.0"
5859
}
59-
}
60+
}

pnpm-lock.yaml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)