Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hank Chan committed Nov 15, 2018
2 parents ecd42f9 + 863d023 commit 083bb18
Show file tree
Hide file tree
Showing 10 changed files with 326 additions and 64 deletions.
152 changes: 152 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# API

`npl`'s API is made available in Promise, which is also accessible with async/await.

## Install

```bash
$ npm install @hankchanocd/npmlist
```

## Import

Import only what you need. I'm listing all of the available imports here for sheer laziness.

```js
const {
npmDependencies,
npmScripts,
npmRegistry,
npmRecent,
npmGlobal
} = require("@hankchanocd/npmlist");

const { npmList } = npmDependencies;
```

## npmDependencies()

Used by `npl` - list module's dependencies.

- With color

```js
npmList()
.raw()
.then(i => yourFunction)
.catch(err => console.log(err));
```

- Without color

```js
npmList()
.rawNoColor()
.then(i => yourFunction)
.catch(err => console.log(err));
```

- Async/await with color

Since ES7, anything written in Promise can also be written in async/await. Async/await code in the following APIs is very similar to this one, so I won't repeat it.

```js
async () => {
try {
let result = await npmList().raw();
yourFunction(result);
} catch (err) {
console.log(err);
}
};
```

## npmRecent()

Used by `npl -t` - list recent global installs.

- With color

```js
npmRecent()
.all()
.then(i => i.raw())
.then(i => yourFunction)
.catch(err => console.log(err));
```

- Without color

```js
npmRecent()
.all()
.then(i => i.rawNoColor())
.then(i => yourFunction)
.catch(err => console.log(err));
```

## npmGlobal()

Used by `npl -g` - list global installs.

- With color

```js
npmGlobal()
.then(i => i.simple().raw())
.then(i => yourFunction)
.catch(err => console.log(err));
```

- Without color

```js
npmGlobal()
.then(i => i.simple().rawNoColor())
.then(i => yourFunction)
.catch(err => console.log(err));
```

## npmScripts()

Used by `npl -s` - return a list of scripts.

- With color

```js
npmScripts()
.raw()
.then(i => yourFunction)
.catch(err => console.log(err));
```

- Without color

```js
npmScripts()
.rawNoColor()
.then(i => yourFunction)
.catch(err => console.log(err));
```

## npmRegistry()

Used by `npl module` - fetch package dependencies from npm registry.

- With color

```js
npmRegistry(moduleString) // i.e. moduleString = 'express'
.then(i => i.simple().raw())
.then(i => yourFunction)
.catch(err => console.log(err));
```

- Without color

```js
npmRegistry(moduleString)
.then(i => i.simple().rawNoColor())
.then(i => yourFunction)
.catch(err => console.log(err));
```
104 changes: 55 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# npmlist    [![npm](https://img.shields.io/npm/v/@hankchanocd/npmlist.svg)](https://www.npmjs.com/package/@hankchanocd/npmlist) [![Build Status](https://travis-ci.org/hankchanocd/npmlist.svg?branch=master)](https://travis-ci.org/hankchanocd/npmlist) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![Known Vulnerabilities](https://snyk.io/test/github/hankchanocd/npmlist/badge.svg?targetFile=package.json)](https://snyk.io/test/github/hankchanocd/npmlist?targetFile=package.json) [![Github issues](https://img.shields.io/github/issues/hankchanocd/npmlist.svg)](https://github.com/hankchanocd/npmlist/issues)

> Fuzzy list anything with npm package, i.e. dependencies, installs, scripts, profile.
> Fuzzy search npm modules' dependencies, and others, i.e. global installs, scripts, profile.
<br />
<br />
Expand All @@ -18,7 +18,7 @@
5. A replacement for `npm list --depth=0 --local` and other annoyingly long `npm list --@#$%` commands with assumed configurations
6. No need to leave terminal just for glancing at a package's npm profile

## Install
## CLI

```bash
$ npm install -g @hankchanocd/npmlist
Expand All @@ -29,7 +29,7 @@ $ npm install -g @hankchanocd/npmlist
```
Usage: npl [option] [name]
Fuzzy list anything with npm package
Fuzzy search npm modules' dependencies
Options:
Expand All @@ -56,98 +56,104 @@ $ npl -g
? (Use arrow keys or type to search)
├── @angular/cli@6.2.4
├── aerobatic-cli@1.1.4
```
```

### Recent added global modules
### Recent global installs

A quick refresher on what the heck it's installed/upgraded globally in the recent past
A quick refresher on what the heck it's installed/upgraded globally in the recent past

```bash
$ npl -t
```bash
$ npl -t

? (Use arrow keys or type to search)
@hankchanocd/npmlist 10-5 21:29
semantic-release 10-5 8:5
```
@hankchanocd/npmlist 10-5 21:29
semantic-release 10-5 8:5
```

### Execute module's npm scripts

Somewhat similar to [`ntl`](https://github.com/ruyadorno/ntl)
Somewhat similar to [`ntl`](https://github.com/ruyadorno/ntl)

```bash
$ npl -s
```bash
$ npl -s

express@4.16.4
express@4.16.4
? run (Use arrow keys or type to search)
build: babel src/ -d build/ --quiet
test: mocha
```
build: babel src/ -d build/ --quiet
test: mocha
```

### Fetch from NPM registry

`npl` fetches the module's latest version by default, unless a version is specified
`npl` fetches the module's latest version by default, unless a version is specified

```bash
$ npl express
```bash
$ npl express

express@4.16.4 Dependencies:
express@4.16.4 Dependencies:
? (Use arrow keys or type to search)
├── accepts@1.3.5
├── array-flatten@1.1.1
```
├── accepts@1.3.5
├── array-flatten@1.1.1
```

### Turn off fuzzy mode

Fuzzy mode is turned on in most cases, except for `--details`, where fuzzy is not optimal for multi-line text. You can also opt for `--no-fuzzy` to turn off the default fuzzy mode.
Fuzzy mode is turned on in most cases, except for `--details`, where fuzzy is not optimal for multi-line text. You can also opt for `--no-fuzzy` to turn off the default fuzzy mode.

```bash
$ npl -t --no-fuzzy
$ npl -g --no-fuzzy
$ npl -s --no-fuzzy
```
```bash
$ npl -t --no-fuzzy
$ npl -g --no-fuzzy
$ npl -s --no-fuzzy
```

<p align="center"><img src="https://github.com/hankchanocd/npmlist/blob/master/images/no-fuzzy-demo.png" width="650"></p>
<p align="center"><img src="https://github.com/hankchanocd/npmlist/blob/master/images/no-fuzzy-demo.png" width="800"></p>

### Details flag

Applied to both local dependencies and global installs
Applied to both local dependencies and global installs

```
$ npl --details
$ npl -g --details
```
```
$ npl --details
$ npl -g --details
```

<p align="center"><img src="https://github.com/hankchanocd/npmlist/blob/master/images/details-flag-demo.png" width="650"></p>
<p align="center"><img src="https://github.com/hankchanocd/npmlist/blob/master/images/details-flag-demo.png" width="800"></p>

## API

Build a Web or CLI tool on top of `npl`'s [API](https://github.com/hankchanocd/npmlist/wiki/API).
Build a Web or CLI tool on top of `npl`'s API. Read [API doc](https://github.com/hankchanocd/npmlist/wiki/API) for more info.

## Tests

To perform unit tests and integration tests, simply run `npm test`.
To perform unit tests and integration tests, simply run `npm test`.

## Changelog

**2018-Oct-16:** Fuzzy mode is now enabled by default. It can be turned off by `--no-fuzzy`.
**2018-Oct-16:** Fuzzy mode is now enabled by default. It can be turned off by `--no-fuzzy`.

**2018-Oct-18:** Give up on trying to pipe output to `less`. Nodejs simply does not have good control of TTY.
**2018-Oct-18:** Give up on trying to pipe output to `less`. Nodejs simply does not have good control of TTY.

**2018-Oct-19:** Speed up `npmlist -g` 10x than `npm list -g`
**2018-Oct-19:** Speed up `npmlist -g` 10x than `npm list -g`

**2018-Oct-20:** `npmlist` can also be accessed via `npl`
**2018-Oct-20:** `npmlist` can also be accessed via `npl`

**2018-Oct-21:** The first official [API](https://github.com/hankchanocd/npmlist/wiki/API) guide released.
**2018-Oct-21:** The first official [API](https://github.com/hankchanocd/npmlist/wiki/API) guide released.

**2018-Oct-29:** Add autocomplete.
**2018-Oct-29:** Add autocomplete.

**2018-Nov-14:** [`npm-fzf`](https://github.com/hankchanocd/npm-fzf) uses `npmlist` as dependencies.

## Contribution

`npl` started off as a bunch of CLI aliases on top of `npm list` and `npm info`, but grew larger quickly. It's now very effective at checking a package's dependencies and global installs. This is to say we are not afraid of expanding `npl` features beyond the current realm.
`npl` started off as a bunch of CLI aliases on top of `npm list` and `npm info`, but grew larger quickly. It's now very effective at checking a package's dependencies and global installs. This is to say we are not afraid of expanding `npl` features beyond the current realm.

The roadmap for `npl` now focuses on presenting a quick and concise report on terminal with minimal commands (it means no sub-commands), freeing developers from the burden of constant switching between terminal and browser. See [Wiki](https://github.com/hankchanocd/npmlist/wiki/Wiki) for `npl`'s code architecture, developments rules, and styles. See [here](./CONTRIBUTING.md) on how to contribute.

If you like the idea of fuzzy list, check out ruyadorno's [`ipt`](https://github.com/ruyadorno/ipt#readme).

The roadmap for `npl` now focuses on presenting a quick and concise report on terminal with minimal commands (it means no sub-commands), freeing developers from the burden of constant switching between terminal and browser. See [Wiki](https://github.com/hankchanocd/npmlist/wiki/Wiki) for `npl`'s code architecture, developments rules, and styles. See [here](./CONTRIBUTING.md) on how to contribute.
## Others

If you like the idea of fuzzy list, check out ruyadorno's [`ipt`](https://github.com/ruyadorno/ipt#readme).
[`npm-fzf`](https://github.com/hankchanocd/npm-fzf) - Fuzzy search npm modules with [`fzf`](https://github.com/junegunn/fzf)

## License

Expand Down
2 changes: 1 addition & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const {
program
.version('7.0.0', '-v, --version')
.usage(`[option] [name]`)
.description('Fuzzy list anything listable with npm package')
.description(`Fuzzy search npm modules' dependencies`)

// Five main features:
.option('-l, --local', 'list local dependencies, which is also the default feature')
Expand Down
25 changes: 16 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 083bb18

Please sign in to comment.