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

nei

v3.8.0

Published

builder for nei platform

Downloads

576

Readme

工具简介

本工具是NEI 接口管理平台自动化构建工具,主要功能有:

  • 根据 NEI 平台定义的工程规范,生成工程的初始化目录结构
  • 自动集成在 NEI 上定义的资源: 页面、异步接口、数据模型、页面模板、业务分组等
  • 本地模拟容器

视频教程

NEI 工程规范介绍

教程

FAQ

插件

工具使用

环境配置

构建工具基于 Node.js 平台,因此需要先安装 Node.js 环境,Node.js 在各平台上的安装配置请参阅官方说明。

安装的 Node.js 版本须为 v4.2 及以上

安装

npm install nei –g

提示1: 如果安装不成功, 可以尝试命令 npm install -g nei

提示2: 如果已经安装过 nei, 请使用更新命令 npm update nei -g

提示3: 也可以安装某个分支,比如安装 dev 分支的命令如下:

sudo npm install "NEYouFan/nei-toolkit#dev" -g

提示4:如果安装失败,可能是网络超时引起的,可以试着使用下面的命令安装:

sudo npm install nei -g --registry=https://registry.npm.taobao.org

指令说明

本工具使用时在终端或者命令行输入以下格式指令运行

nei [指令] [参数]

其中可用的指令包括:

| 指令 | 描述 | | :--- | :--- | | build | 根据在 NEI 平台上定义的工程规范,生成工程的初始化目录结构 | | update | 更新通过 nei build 构建的项目 | | server | 启动本地模拟容器 | | template | 使用本地数据解析模板 |

build

根据在 NEI 平台上定义的工程规范,生成工程的初始化目录结构,指令的运行格式为:

nei build -k [key] [参数]

其中 [key] 是 NEI 平台上的项目的唯一标识,可以在项目的"工具(设置)"中查看

针对 nei build 指令可用的参数包括:

| 简写 | 全称 | 默认值 | 描述 | | :--- | :--- | :--- | :--- | | -h | --help | | 显示 build 命令的帮助信息 | | -o | --output | ./ | 指定项目的输出目录 | | -k | --key | | 项目的唯一标识,可以在项目的"工具(设置)"中查看 | | -sk| --specKey | | 规范的唯一标识,可以在规范的"规范设置"中查看 | | -w | --overwrite | false | 是否覆盖已存在的文件,需要下载的文件不在此列,如果需要重新下载,请先将本地的文件删除 | | 无 | --specType | web | 要构建的规范类型,目前支持 web、aos、ios、test 四种类型 | | -s | --server | https://nei.netease.com | 数据源服务器 |

使用范例:

在当前目录下构建 key 为 xyz 的项目:

nei build -k xyz

规范也可以独立于项目生成脚手架文件, 在当前目录下构建 key 为 xyz 的规范:

nei build -sk xyz

注意: 如果 k 和 sk 参数同时存在, 系统会优先考虑 sk 参数

update

更新通过 nei build 构建的项目,指令的运行格式为:

nei update [参数]

nei update 指令可用的参数包括:

| 简写 | 全称 | 默认值 | 描述 | | :--- | :--- | :--- | :--- | | -h | --help | | 显示 update 命令的帮助信息 | | -o | --output | ./ | 指定的项目目录 | | -k | --key | | 需要更新的项目的唯一标识 | | -a | --all | false | 是否更新指定目录下面的所有项目,前提是没有指定的 key | | -w | --overwrite | false | 是否覆盖已存在的文件,需要下载的文件不在此列,如果需要重新下载,请先将本地的文件删除 | | 无 | --spec | false | 是否更新规范中的普通文件和文件夹,以数据填充的文件不在此列 | | -s | --server | https://nei.netease.com | 数据源服务器 |

使用范例:

更新当前目录下通过 nei build 生成的项目

nei update

提示: 可以先在本地创建项目目录,然后在该目录下使用 nei buildnei update 命令,使用默认值即可.

server

启动内置的本地模拟容器

nei server [参数]

nei server 指令可用的参数包括:

| 简写 | 全称 | 默认值 | 描述 | | :--- | :--- | :--- | :--- | | -h | --help | | 显示 server 命令帮助信息 | | -o | --output | ./ | 已构建项目的输出路径 | | -k | --key | | 需要启动的项目的唯一标识 |

使用范例

启动目录为 ./mypro 下的项目:

nei server -o ./mypro

OS X 下如果有异常请使用 sudo nei server 命令启动

template

使用本地数据解析模板。通过指定本地模板文件以及数据文件,能够将模板解析得到输出文件。目前支持的模板语言为handlebars

nei template [参数]

nei template 指令可用的参数包括:

| 简写 | 全称 | 默认值 | 描述 | | :--- | :--- | :--- | :--- | | -h | --help | | 显示 template 命令帮助信息 | | -o | --output | ./ | 输出路径 | | -p | --path | | 本地模板路径,必须指定 | | -d | --data | | 数据json文件路径,可选 | | -b | --handlebars | | 自定义handlebars辅助函数文件路径,可选 | | -w | --overwrite | false | 是否覆盖已存在的文件 |

用户可以指定数据文件,如data.json的文件内容如下:

{
  "project":{
    "name" : "test",
    "version" : "0.0.1"
  },
  "author":{
    "Netease"
  }
}

然后用户就可以在模板文件中访问到数据中的数据,如{{project.name}}就能够解析为test。用户同样可以指定本地handlebars辅助文件,如果用户有多个辅助函数,需要将这些都写到一个文件中,自定义辅助函数的写法与上文一致,参照此链接相同。 另外用户也可以不通过指定数据json文件来传入数据,可以通过命令行直接传入数据参数,如:

nei template -ProductName Test -Prefix HT [其他参数]

ProductName和Prefix这两个参数就会作为数据传入到模板中,其等同于

{
  "args":{
    "ProductName" : "Test",
    "Prefix":  "HT"
  }
}

如果同时指定了数据文件,将会执行merge操作,其中命令行参数指定的方式优先于数据json文件方式。

设置输出信息级别

共设有"all"、"debug"、"info"、"warn"、"error"、"off"等日志级别,级别顺序由大到小,通过--logLevel指定一个级别之后,比该级别小的日志级别信息都将会显示出来,比如:

nei build -k xxxxxxxx --logLevel info

那么所有info以下级别(即warn、error)级别的信息都将会显示出来。当指定为off的时候,所有日志信息都将关闭。

版本更新说明

更新说明

Licence

MIT

感谢

感谢网易云提供的云服务, 目前 NEI 已经托管在网易云上。

讨论组:

NEI 用户交流 QQ 群(453281988):

QQ 群