nornj-cli v0.4.2
NornJ-cli
The CLI for scaffolding NornJ template projects, and do more things.
安装
npm install -g nornj-cli
使用方法
创建项目初始代码
- 在当前目录下创建新项目目录:
nj init
# 请按上下键选择项目模板
Please select a project template:
> react-mst-universal
react-mst-app
react-mst
react-mobx
other
# 如果选择了other,则可输入任意模板名称
Template Name: anyTemplateName
# 输入新建的项目目录名称
Project Name: projectName
添加新页面
- 进入已有项目目录后,输入如下命令创建新页面:
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 # 默认
function # 函数组件
# 输入新创建的组件名称
Component Name: componentName
添加新Store
- 进入已有项目目录后,输入如下命令创建新Store:
nj add-store [storeName] # 或nj as
# 请选择生成时要使用的Store模板
Which store template do you want to use?
> default # 默认使用mst
mobx # 使用mobx
# 输入新创建的Store名称
Store Name: storeName
选择项目模板
名称 | 描述 | 模板源码地址 |
---|---|---|
react-mst-universal | 基于React+Mobx-state-tree的单页面项目组件开发规范默认使用JSX 样式开发默认集成了styled-jsx 和css-modules 请求数据使用axios echarts组件使用echarts-for-react 集成了可增强JSX开发的插件babel-plugin-nornj-in-jsx预置eslint 、stylelint 、prettier ,可在格式化时对代码风格进行自动检查并修复 | 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的单页面项目组件开发规范默认使用NornJ | 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 select a project template:
react-mst-universal
react-mst-app
react-mst
react-mobx
> other
# 选择other,然后按照github地址输入"用户(或组织)名/项目名",例如"https://github.com/joe-sky/react-mobx-html"中的"joe-sky/react-mobx-htm"
Template Name: UserName/ProjectName
查看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 --cnpm
nj upgrade --cnpm
nj install --cnpm
nj update --cnpm
相关文档
License
MIT
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago