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 🙏

© 2024 – Pkg Stats / Ryan Hefner

nstarter

v1.0.2

Published

Startup CLI tool for node projects with template.

Downloads

208

Readme

nstarter - Node.js 模板项目启动工具

nstarter 是一个用来基于工程模板初始化 Node.js 项目的命令行工具。允许将各种预定义的 包依赖, 代码块, 工具方法, 业务模块 等封装在项目模板中,来统一不同项目的开发规范。

⚠ 本工具当前仅适用于私有项目内部测试使用.

环境要求

  • node.js >= 20.16.0
  • npm >= 10.8.0
  • git

安装

通过 npm 可以直接安装 nstater CLI 的最新版本。

npm install -g nstarter

使用方式

nstarter deploy [target]

CLI tools to deploy TypeScript project.

Commands:
  nstarter deploy [target]           CLI tools to deploy TypeScript project.
                                                                       [default]
  nstarter config set <key> <value>  Config nstarter options.
  nstarter list                      List all templates configured.[aliases: ls]
  nstarter update [repo]             Update local repository cache.[aliases: up]
  nstarter upgrade [target]          Upgrade local project with template.
  nstarter clean [repo]              Clear local repository cache.
  nstarter remove <repo>             Remove selected repository.   [aliases: rm]

Positionals:
  target  Target project deploy path.                                   [string]

Options:
      --help      Show help                                            [boolean]
  -v, --verbose   Show debug info.                                     [boolean]
      --version   Show version number                                  [boolean]
  -n, --name      Project name.                                         [string]
  -r, --repo      Template repository to use.      [string] [default: "default"]
  -t, --template  Template to use.                                      [string]
  -y, --yes       Proceed deploy without confirm.     [boolean] [default: false]
  • 本地模板缓存 - nstarter 会将模板工程拉取到 ~/.nstarter/repos/ 目录下,进行统一管理。目前支持 git 类型的模板工程,同时支持对模板工程支持更新,清理等维护性操作。

部署工程

通过使用 nstarter deploy 即可进入默认部署模式,用于基于模板初始化新的工程。nstarter 默认情况下也会进入部署模式,基于模板执行目标工程部署。

nstarter 工具默认以交互式模式运行,同时也支持非交互模式命令行下使用,以支持自动化脚本编写。通过命令行参数制定部署所必要的参数,可以进入非交互模式,例如:

nstarter deploy -t default -n demo -y ~/projects/demo

配置设定

nstarter 支持通过命令操作修改工具的配置参数,用于配置使用的模板等相关行为。

nstarter config set <key> <value>

Config nstarter options.

Positionals:
  key    The key to set value at.                            [string] [required]
  value  The value to set.                                   [string] [required]

Options:
      --help     Show help                                             [boolean]
  -v, --verbose  Show debug info.                                      [boolean]
      --version  Show version number                                   [boolean]

目前 nstarter 支持设置以下配置项:

| 设置 | 类型 | 说明 | |:------------:|:---:|:---| | repo.<tag> | string | 设定制定标签模板工程的 git 版本库 url。 |

nstarter 默认配置文件存储在本地用户 HOME 路径下 ~/.nstarter/config.json

查看已配置模板

使用 nstarter list 可查看当前本地已配置的工程模板信息。

nstarter list

List all templates configured.

Options:
      --help     Show help                                             [boolean]
  -v, --verbose  Show debug info.                                      [boolean]
      --version  Show version number                                   [boolean]

更新本地模板

通过 nstarter update 可以将指定工程模板的本地缓存更新到上游的最新状态。

nstarter update [repo]

Update local repository cache.

Positionals:
  repo  Template repository to update.                                  [string]

Options:
      --help     Show help                                             [boolean]
  -v, --verbose  Show debug info.                                      [boolean]
      --version  Show version number                                   [boolean]

基于模板升级本地工程

可以使用 nstarter upgrade 操作,将本地现有工程,按照模板所提供的包依赖进行升级操作。

nstarter upgrade [target]

Upgrade local project with template.

Positionals:
  target  Target project directory.                                     [string]

Options:
      --help      Show help                                            [boolean]
  -v, --verbose   Show debug info.                                     [boolean]
      --version   Show version number                                  [boolean]
  -r, --repo      Template repository to use.      [string] [default: "default"]
  -t, --template  Template to use.                                      [string]
  -s, --strict    Use strict version rule to upgrade.                  [boolean]

其中,使用严格模式 (strict) 可以将本地目标工程中的依赖包版本限定为与模板严格相等的状态,默认情况下,不启用严格模式,按照原始范围限定规则替换版本号。

清除本地模板缓存

使用 nstarter clean 可对本地模板缓存进行清理操作,通过制定模板标签清理指定模板。默认情况下清理所有模板的本地缓存。

nstarter clean [repo]

Clear local repository cache.

Positionals:
  repo  Repository to clear. Use "all" to clear all repositories.
                                                       [string] [default: "all"]

Options:
      --help     Show help                                             [boolean]
  -v, --verbose  Show debug info.                                      [boolean]
      --version  Show version number                                   [boolean]

删除模板配置

通过 nstarter remove 操作可删除配置的模板。此操作会同时删除模板配置,并清楚缓存文件。

nstarter remove <repo>

Remove selected repository.

Positionals:
  repo  Repository to remove.               [string] [required] [default: "all"]

Options:
      --help     Show help                                             [boolean]
  -v, --verbose  Show debug info.                                      [boolean]
      --version  Show version number                                   [boolean]

模板开发

可以根据工程的实际需要,定制自己的 nstarter 模板工程,以满足不同场景下,统一项目开发规范的需求。

更多关于模板开发的详细信息,可以参考 templating.

许可

MIT


Made on 🌍 with 💓.