npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aaricchen1991/n2-cli

v1.1.4

Published

CLI for server init, nginx config, and SSL certificate management

Readme

@aariccchen1991/n2-cli

服务器部署与运维 CLI(命令 n2):服务器初始化、Nginx 配置生成、SSL 证书申请/续期及日志查看。设计为在部署服务器上执行(或从本机指定配置生成文件)。

本包位于 monorepo 的 packages/cli,根目录说明见 README

功能概览

| 命令 / 子命令 | 说明 | | ------------- | ------------------------------------------------------------------------------------ | | config | 配置管理:初始化、查看、设置、删除配置项(见下方「配置管理」)。 | | init | 服务器初始化(幂等):安装 Nginx、创建目录、安装 deploy.sh、占位证书。可重复执行。 | | nginx | 根据域名配置文件生成 Nginx 配置;可选安装到系统并 reload。 | | ssl | 为配置中的全部域名申请/续期 SSL 证书(acme.sh + 阿里云 DNS),并写入统一日志。 | | ssl-logs | 查看 SSL 操作日志(创建、续期、成功、失败),支持行数、跟随、按动作/结果过滤。 |

安装与使用

在 monorepo 内

# 根目录
pnpm install
pnpm run build
pnpm run dev:cli -- <command> [options]

或进入本包:

cd packages/cli
pnpm install
pnpm run build
pnpm run cli -- <command> [options]

默认从 ~/.n2/cli/config.yaml 读取配置,也可通过 -c, --config 指定路径。

发布为 npm 包后

npx @aariccchen1991/n2-cli --help
npm install -g @aariccchen1991/n2-cli
n2 --help

发布步骤见 docs/publishing.md

Shell 补全(可选)

支持 Bash 与 Zsh 命令补全,安装后输入 n2 后按 Tab 可补全命令与子命令:

# Zsh
n2 completion --generate zsh >> ~/.zshrc && source ~/.zshrc

# Bash
n2 completion --generate bash >> ~/.bashrc && source ~/.bashrc

直接执行 n2 completion 可查看安装说明。

配置文件

默认 ~/.n2/cli/config.yaml,格式与包内 assets/deploy/domains.yaml 兼容。

示例:

aliyun_access_key_id: "your_key"
aliyun_access_key_secret: "your_secret"

api:
  backend_port: 3000

admin:
  domains:
    - n2-admin.example.com

tenant:
  domains:
    - n2-tenant.example.com

client:
  domains:
    - n2-client.example.com

配置管理(config)

| 子命令 | 说明 | | ------ | ---- | | config init | 初始化配置文件,-f 覆盖已存在 | | config list | 列出所有配置项 | | config get [key] | 查看配置项 | | config set <key> [values...] | 设置配置项 | | config delete <key> | 删除/清空配置项 |

命令速览

  • initn2 init [-c config] [--scripts-dir path] — 服务器初始化
  • nginxn2 nginx [-c config] [-o output] [-i install] — 生成/安装 Nginx 配置
  • ssln2 ssl [-c config] [--ali-key] [--ali-secret] [--log-file] [--scripts-dir] — SSL 申请/续期
  • ssl-logsn2 ssl-logs [--log-file] [-n lines] [-f follow] [--action] [--result] — 查看 SSL 日志

环境变量:N2_DEPLOY_SCRIPTS_DIRALIYUN_ACCESS_KEY_IDALIYUN_ACCESS_KEY_SECRET 等见根目录 READMEdocs/development-testing.md