NornJ-cli
The CLI for scaffolding NornJ template projects, and do more things.
安装
npm install -g nornj-cli
使用方法
创建项目初始代码
- 在当前目录下创建新项目目录:
nj init # 请按上下键选择项目模板 Please
添加新页面
- 进入已有项目目录后,输入如下命令创建新页面:
nj add-page [pageName] # 或nj ap # 请选择生成时要使用的页面模板 Which page template do you want to use?> default # 增删改查 chart # 图表 form # 表单 empty # 空页面 # 输入新创建的页面名称 Page Name: pageName
添加新组件
- 进入已有项目目录后,输入如下命令创建新组件:
nj add-component [componentName] # 或nj ac # 请选择生成时要使用的组件模板 Which component template do you want to use?> default # 默认 stateless # 无状态组件 higher-order # 高阶组件 # 输入新创建的组件名称 Component Name: componentName
添加新Store
- 进入已有项目目录后,输入如下命令创建新Store:
nj add-store [storeName] # 或nj as # 请选择生成时要使用的Store模板 Which store template do you want to use?> default # 默认使用axios default-fetch # 使用fetch # 输入新创建的Store名称 Store Name: storeName
选择项目模板
名称 | 描述 | 模板源码地址 |
---|---|---|
react-mst-universal | 基于React+Mobx-state-tree的单页面项目
|
https://github.com/joe-sky/nornj-cli/tree/master/templates/react-mst-universal |
react-mst-app | react-mst-universal 的h5版,配置同上 |
https://github.com/joe-sky/nornj-cli/tree/master/templates/react-mst-app |
react-mst | 基于React+Mobx-state-tree的单页面项目
|
https://github.com/joe-sky/nornj-cli/tree/master/templates/react-mst |
react-mobx | 基于React+Mobx的多页面项目 | https://github.com/joe-sky/nornj-cli/tree/master/templates/react-mobx |
joe-sky/react-mobx-html | 基于React+Mobx的多页面项目(html版) | https://github.com/joe-sky/react-mobx-html |
joe-sky/react-mobx-ftl | 基于React+Mobx的多页面项目(FreeMarker版) | https://github.com/joe-sky/react-mobx-ftl |
使用自定义模板
-
在github上创建一个新的模板项目即可,结构类似于react-mobx-html或react-mobx-ftl。
-
然后使用以下命令即可下载并初始化:
nj init # 请按上下键选择项目模板 Please
查看cli当前版本
nj -v
cli版本更新
nj upgrade # 更新cli版本到最新版
安装npm包
与npm install
相同,区别在于部署在私服上的包会自动从私服安装:
nj install # 或nj i
更新npm包
与npm update
相同,区别在于部署在私服上的包会自动从私服更新:
nj update # 或nj up
可选择使用npm国内镜像
当网络访问npm比较慢时,可选择使用npm国内镜像
来安装。方法为在各命令后添加--cnpm
参数:
nj init --cnpmnj upgrade --cnpmnj install --cnpmnj update --cnpm
相关文档
License
MIT