nornj-cli-legacy

0.4.2 • Public • Published

NornJ-cli-legacy

The CLI for scaffolding NornJ template projects, and do more things.

NPM Version code style: prettier NPM Downloads

安装

npm install -g nornj-cli-legacy

使用方法

创建项目初始代码

  • 在当前目录下创建新项目目录:
njl init

# 请按上下键选择项目模板
Please select a project template:
> react-mst-universal
  react-mst-app
  react-mst
  react-mobx
  other

# 如果选择了other,则可输入任意模板名称
Template Name: anyTemplateName

# 输入新建的项目目录名称
Project Name: projectName

添加新页面

  • 进入已有项目目录后,输入如下命令创建新页面:
njl add-page [pageName]  # 或njl ap

# 请选择生成时要使用的页面模板
Which page template do you want to use?
> default  # 增删改查
  chart    # 图表
  form     # 表单
  empty    # 空页面

# 输入新创建的页面名称
Page Name: pageName

添加新组件

  • 进入已有项目目录后,输入如下命令创建新组件:
njl add-component [componentName]  # 或njl ac

# 请选择生成时要使用的组件模板
Which component template do you want to use?
> default       # 默认
  stateless     # 无状态组件
  higher-order  # 高阶组件

# 输入新创建的组件名称
Component Name: componentName

添加新Store

  • 进入已有项目目录后,输入如下命令创建新Store:
njl add-store [storeName]  # 或njl 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的单页面项目
  • 组件开发规范默认使用JSX
  • 样式开发默认集成了styled-jsxcss-modules
  • 请求数据使用axios
  • echarts组件使用echarts-for-react
  • 集成了可增强JSX开发的插件babel-plugin-nornj-in-jsx
  • 预置eslintstylelintprettier,可在格式化时对代码风格进行自动检查并修复
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

使用自定义模板

  1. 在github上创建一个新的模板项目即可,结构类似于react-mobx-htmlreact-mobx-ftl

  2. 然后使用以下命令即可下载并初始化:

njl 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当前版本

njl -v

cli版本更新

njl upgrade  # 更新cli版本到最新版

安装npm包

npm install相同,区别在于部署在私服上的包会自动从私服安装:

njl install  # 或njl i

更新npm包

npm update相同,区别在于部署在私服上的包会自动从私服更新:

njl update  # 或njl up

可选择使用npm国内镜像

当网络访问npm比较慢时,可选择使用npm国内镜像来安装。方法为在各命令后添加--cnpm参数:

njl init --cnpm
njl upgrade --cnpm
njl install --cnpm
njl update --cnpm

相关文档

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i nornj-cli-legacy

Weekly Downloads

0

Version

0.4.2

License

MIT

Unpacked Size

1.3 MB

Total Files

33

Last publish

Collaborators

  • joe_sky