Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
docs/** linguist-documentation
*.ps1 linguist-vendored
28 changes: 16 additions & 12 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- ".gitignore"
- ".prettierignore"
pull_request:
branches: [master]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -63,6 +64,12 @@ jobs:
uv pip list
echo "::endgroup::"

- name: "astral-sh/ruff"
if: ${{ !cancelled() }}
uses: astral-sh/ruff-action@v3
with:
version: latest

- name: "astral-sh/ty"
if: ${{ !cancelled() }}
run: |
Expand All @@ -79,23 +86,28 @@ jobs:
- name: "mypy"
if: ${{ !cancelled() }}
run: |
uv run mypy src
uvx toml-run mypy

- name: "bandit"
if: ${{ !cancelled() }}
run: |
uv run bandit -c pyproject.toml -r src
uvx toml-run bandit

- name: "validate-pyproject"
if: ${{ !cancelled() }}
run: |
uv run validate-pyproject pyproject.toml
uvx toml-run validate

- name: "tombi"
if: ${{ !cancelled() }}
run: |
uv run tombi lint

- name: "yamllint"
if: ${{ !cancelled() }}
run: |
uvx toml-run yamllint

- name: "prettier"
if: ${{ !cancelled() }}
run: |
Expand All @@ -104,17 +116,9 @@ jobs:
echo "::endgroup::"
npx prettier --check .

- name: "yamllint"
if: ${{ !cancelled() }}
run: |
echo "::group::List Files"
yamllint -c .github/yamllint.yaml --list-files .
echo "::endgroup::"
yamllint -c .github/yamllint.yaml .

- name: "actionlint"
if: ${{ !cancelled() }}
uses: cssnr/actionlint-action@master
uses: cssnr/actionlint-action@v1
with:
shellcheck_opts: -e SC2012

Expand Down
47 changes: 29 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ Install From PyPI: <https://pypi.org/p/npmstat>

```shell
pip install npmstat
```

```shell
uv tool install npmstat
```

Expand All @@ -49,11 +52,18 @@ brew install cssnr/tap/npmstat

From GitHub: https://github.com/cssnr/npmstat/releases/latest

- [windows-amd64.zip](https://github.com/cssnr/npmstat/releases/latest/download/windows-amd64.zip)
- [macos-amd64.zip](https://github.com/cssnr/npmstat/releases/latest/download/macos-amd64.zip)
- [macos-arm64.zip](https://github.com/cssnr/npmstat/releases/latest/download/macos-arm64.zip)
- [linux-amd64.zip](https://github.com/cssnr/npmstat/releases/latest/download/linux-amd64.zip)
- [linux-arm64.zip](https://github.com/cssnr/npmstat/releases/latest/download/linux-arm64.zip)
```shell
curl https://i.jpillora.com/cssnr/npmstat! | bash
```

See [jpillora/installer](https://github.com/jpillora/installer) for more details.
Alternatively, you can manually download a release for your system.

- [Windows x86_64](https://github.com/cssnr/npmstat/releases/latest/download/windows-amd64.zip) _amd64_
- [macOS Apple Intel](https://github.com/cssnr/npmstat/releases/latest/download/macos-amd64.zip) _amd64_
- [macOS Apple Silicon](https://github.com/cssnr/npmstat/releases/latest/download/macos-arm64.zip) _arm64_
- [Linux x86_64](https://github.com/cssnr/npmstat/releases/latest/download/linux-amd64.zip) _amd64_
- [Linux ARM](https://github.com/cssnr/npmstat/releases/latest/download/linux-arm64.zip) _arm64_

[![View Documentation](https://img.shields.io/badge/view_documentation-blue?style=for-the-badge&logo=googledocs&logoColor=white)](https://cssnr.github.io/npmstat/)

Expand All @@ -62,19 +72,20 @@ From GitHub: https://github.com/cssnr/npmstat/releases/latest
To use run `npmstat` from your command line.

```text
usage: npmstat [-h] [-C] [-V] [command] ...

example: npmstat stats @cssnr/vitepress-swiper

positional arguments:
[command]
info get package info
stats get download stats

options:
-h, --help show this help message and exit
-C, --clear-cache clear the request cache and exit
-V, --version show the package version and exit
Usage: npmstat [OPTIONS] COMMAND [ARGS]...

Example: npmstat -v stats @cssnr/vitepress-swiper

┌─ Options ────────────────────────────────────────────┐
│ --verbose -v Verbose Output (jq safe). │
│ --version -V Show App Version. │
│ --clear-cache -C Clear Request Cache. │
│ --help -h Show this message and exit. │
└──────────────────────────────────────────────────────┘
┌─ Commands ───────────────────────────────────────────┐
│ info Get Package Information. │
│ stats Get Package Download Stats. │
└──────────────────────────────────────────────────────┘
```

[![View Documentation](https://img.shields.io/badge/view_documentation-blue?style=for-the-badge&logo=googledocs&logoColor=white)](https://cssnr.github.io/npmstat/)
Expand Down
161 changes: 66 additions & 95 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,25 @@ To see the help use the `[COMMAND] -h` flag.
```text
Usage: npmstat [OPTIONS] COMMAND [ARGS]...

NPM Stat CLI

Example: npmstat -v stats @cssnr/vitepress-swiper

┌─ Options ──────────────────────────────────────────────────────────┐
│ --verbose -v Verbose Output (jq safe). │
│ --version -V Show App Version. │
│ --clear-cache -C Clear Request Cache. │
│ --install-completion Install completion for the │
│ current shell. │
│ --show-completion Show completion for the │
│ current shell, to copy it or │
│ customize the installation. │
│ --help -h Show this message and exit. │
└─────────────────────────────────────────────────────────────────────┘
┌─ Commands ─────────────────────────────────────────────────────────┐
│ info Get Package Information. │
│ stats Get Package Download Stats. │
└─────────────────────────────────────────────────────────────────────┘
┌─ Options ────────────────────────────────────────────┐
│ --verbose -v Verbose Output (jq safe). │
│ --version -V Show App Version. │
│ --clear-cache -C Clear Request Cache. │
│ --help -h Show this message and exit. │
└──────────────────────────────────────────────────────┘
┌─ Commands ───────────────────────────────────────────┐
│ info Get Package Information. │
│ stats Get Package Download Stats. │
└──────────────────────────────────────────────────────┘
```

To enable tab-completion follow the [Autocomplete](#autocomplete) instructions.

!!! quote "Output Format"

Currently all output is in **JSON** format and can be piped directly into `jq`.
Output format defaults to `table`. To use `JSON` add `--format json`.

## Commands

Expand All @@ -63,18 +56,20 @@ You can also view the [Examples](#examples) below.
Get package information. Without a `version` all versions are returned.

```text
Usage: npmstat info [OPTIONS] PACKAGE [VERSION]

Get Package Information.

┌─ Arguments ────────────────────────────────────────────────────────
│ * package TEXT NPM Package Name. [required] │
│ version [VERSION] Package Version │
└─────────────────────────────────────────────────────────────────────
┌─ Options ──────────────────────────────────────────────────────────
│ --indent -i INTEGER JSON Indent. [default: 2]
│ --purge -p Purge Cache for Request.
│ --force-purge -f Force Purge for Request. │
│ --help -h Show this message and exit. │
└─────────────────────────────────────────────────────────────────────
┌─ Arguments ─────────────────────────────────────────────────────┐
│ * package TEXT NPM Package Name. [required]
│ version [VERSION] Package Version
└─────────────────────────────────────────────────────────────────┘
┌─ Options ───────────────────────────────────────────────────────┐
│ --format -f [table|json] Output Format. [default: table]
│ --indent -i INTEGER JSON Indent. [default: 2]
│ --purge -p Purge Cache for Request.
│ --help -h Show this message and exit.
└─────────────────────────────────────────────────────────────────┘
```

!!! tip "In the terminal output is scaled and displays properly."
Expand All @@ -88,17 +83,17 @@ Get package stats for a `period`. The default is `last-day`.

Get Package Download Stats.

┌─ Arguments ────────────────────────────────────────────────────────
│ * package TEXT NPM Package Name. [required] │
│ period [PERIOD] Stats Period. [default: last-day] │
└─────────────────────────────────────────────────────────────────────
┌─ Options ──────────────────────────────────────────────────────────
│ --range -r Get Range. │
│ --indent -i INTEGER JSON Indent. [default: 2]
│ --purge -p Purge Cache for Request.
│ --force-purge -f Force Purge for Request. │
│ --help -h Show this message and exit. │
└─────────────────────────────────────────────────────────────────────
┌─ Arguments ─────────────────────────────────────────────────────┐
│ * package TEXT NPM Package Name. [required]
│ period [PERIOD] Stats Period. [default: last-day]
└─────────────────────────────────────────────────────────────────┘
┌─ Options ───────────────────────────────────────────────────────┐
│ --range -r Get Range.
│ --format -f [table|json] Output Format. [default: table]
│ --indent -i INTEGER JSON Indent. [default: 2]
│ --purge -p Purge Cache for Request.
│ --help -h Show this message and exit.
└─────────────────────────────────────────────────────────────────┘
```

!!! tip "In the terminal output is scaled and displays properly."
Expand All @@ -119,79 +114,55 @@ Reference: https://github.com/npm/registry/blob/main/docs/download-counts.md

## Examples

???+ abstract "`npmstat stats -v @cssnr/vitepress-swiper last-week`"
???+ abstract "`npmstat info @cssnr/vitepress-swiper`"

```shell
npmstat stats -v @cssnr/vitepress-swiper last-week
npmstat info @cssnr/vitepress-swiper
```

```shell
package: @cssnr/vitepress-swiper
period: last-week
range: False
url: https://api.npmjs.org/downloads/point/last-week/@cssnr/vitepress-swiper
from_cache: True
{
"downloads": 752,
"start": "2025-11-28",
"end": "2025-12-04",
"package": "@cssnr/vitepress-swiper"
}
@cssnr/vitepress-swiper
╭─────────────┬──────────────────────────────────────────────────────╮
│ Key │ Value │
├─────────────┼──────────────────────────────────────────────────────┤
│ Link │ https://www.npmjs.com/package/@cssnr/vitepress-swip… │
│ Description │ A VitePress Plugin to Easily add a SwiperJS Photo │
│ │ Gallery or Image Slideshow with Custom Options. │
│ License │ GPL-3.0-only │
│ Homepage │ https://vitepress-swiper.cssnr.com │
│ Issues │ https://github.com/cssnr/vitepress-swiper/issues │
│ Updated │ 2025-09-23T02:27:26.786Z │
│ Created │ 2025-08-25T06:49:25.597Z │
│ Latest │ 0.2.1 │
│ Versions │ 11 │
╰─────────────┴──────────────────────────────────────────────────────╯
```

??? abstract "`npmstat stats -v @cssnr/vitepress-swiper last-week -r`"
??? abstract "`npmstat stats @cssnr/vitepress-plugin-contributors last-week -r`"

```shell
npmstat stats -v @cssnr/vitepress-swiper last-week -r
npmstat stats @cssnr/vitepress-plugin-contributors last-week -r
```

```shell
package: @cssnr/vitepress-swiper
period: last-week
range: True
url: https://api.npmjs.org/downloads/range/last-week/@cssnr/vitepress-swiper
from_cache: True
{
"start": "2025-11-28",
"end": "2025-12-04",
"package": "@cssnr/vitepress-swiper",
"downloads": [
{
"downloads": 186,
"day": "2025-11-28"
},
{
"downloads": 6,
"day": "2025-11-29"
},
{
"downloads": 15,
"day": "2025-11-30"
},
{
"downloads": 109,
"day": "2025-12-01"
},
{
"downloads": 261,
"day": "2025-12-02"
},
{
"downloads": 118,
"day": "2025-12-03"
},
{
"downloads": 57,
"day": "2025-12-04"
}
]
}
@cssnr/vitepress-plugin-contributors
╭────────────┬───────────╮
│ Day │ Downloads │
├────────────┼───────────┤
│ 2025-12-21 │ 0 │
│ 2025-12-22 │ 9 │
│ 2025-12-23 │ 0 │
│ 2025-12-24 │ 2 │
│ 2025-12-25 │ 0 │
│ 2025-12-26 │ 1 │
│ 2025-12-27 │ 1 │
╰────────────┴───────────╯
```

??? abstract "`npmstat info @cssnr/vitepress-swiper 0.0.5 | jq '.peerDependencies'`"

```shell
npmstat info @cssnr/vitepress-swiper 0.0.5 | jq '.peerDependencies'
npmstat info @cssnr/vitepress-swiper 0.0.5 -f json | jq '.peerDependencies'
```

```json
Expand Down
Loading
Loading