1.2.1 • Published 4 years ago

sofa-scripts v1.2.1

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

sofa-scripts

sofa入口;

对外需求

对于外部的需求,需要明确方法名、导入方式、input、output、同步异步等;

  1. sofa-config: 检查是否存在有效的sofa.global.config.json文件;异步方法?同步方法?
  2. sofa-dev-utils: 与用户交互获取用户输入信息;
  3. sofa-database-helper: 测试数据库是否能够正常连接;
  4. sofa-git-helper: 检查是否安装Git;可以以伪代码示意;
  5. sofa-config: 初始化sofa.global.config.json文件,将文件持久化到用户系统;
  6. sofa-config: 将db配置写入到sofa.global.config.json文件;
  7. sofa-git-helper: 检查是否登录Git;可以以伪代码示意;
  8. sofa-git-helper: 获取当前git仓库关联的远程地址;
  9. sofa-dev-utils: 获取项目根路径;
  10. sofa-dev-utils: 获取模板根路径;
  11. sofa-dev-utils: 控制台打印,成功消息;
  12. sofa-dev-utils: 控制台打印,警示消息;
  13. sofa-dev-utils: 控制台打印,错误、失败消息;

全局安装

npm i sofa-scripts -g

全局安装成功后,可使用 sofa 命令;

A lot of packages have one or more executable files that they’d like to install into the PATH. npm makes this pretty easy (in fact, it uses this feature to install the “npm” executable.) To use this, supply a bin field in your package.json which is a map of command name to local file name. On install, npm will symlink that file into prefix/bin for global installs, or ./node_modules/.bin/ for local installs.

命令

安装后执行脚本

  1. 检查是否存在有效的sofa.global.config.json文件;
  2. 若不存在,执行init命令;

init

初始化用户配置,会直接重写sofa.global.config.json文件;需要确定sofa.global.config.json文件放在哪个位置比较合适;

  • 1 初始化db配置,与用户交互,要求用户输入数据库连接地址;
  • 2 获取用户输入后,测试是否能够正常连接到数据库;
  • 3.1 连接成功,将db配置写入到sofa.global.config.json;
  • 3.2 连接失败,提示用户重新输入;
  • 4 检查Git是否安装;
  • 5.1 未安装,提示安装Git,退出;
  • 5.2 已安装;
  • 6 检查Git是否登录;
  • 6.1 未登录,提示登录Git,退出;
  • 6.2 已登录,提示初始化成功,退出;

set

当前sofa.global.config.json中仅存在db一项配置;

help

给出完整的命令范围和命令示例;

命令分发

sofa-scripts是sofa命令的入口,需要将所有命令向下进行分发,此外还有基础命令校验;

  • init 不需要参数,直接本模块调用;
  • set 不需要参数,直接本模块调用;
  • publish \<type> 将用户输入参数、templateRootPath、config作为参数,调用template模块;
  • update \<type> [updateConfigPath] 将用户输入参数、templateRootPath、config作为参数,调用template模块;
  • remove \<type> [id] 将用户输入参数,调用template模块;
  • search \<type> [keyword] 将用户输入参数作为参数,调用template模块;
  • create \<type> 将用户输入参数、projectRootPath、config作为参数,调用factory模块;如果是project,将当前目录作为projectRootPath,config为空;若为module、component则向上查找到sofa.config.js,将此路径设置为projectRootPath,配置文件内容设置为config;
  • add \<type> 将用户输入参数、projectRootPath、config作为参数,调用factory模块;如果是project,将当前目录作为projectRootPath,config为空;若为module、component则向上查找到sofa.config.js,将此路径设置为projectRootPath,配置文件内容设置为config;
1.2.0

4 years ago

1.2.1

4 years ago

1.1.16

4 years ago

1.1.15

4 years ago

1.1.14

4 years ago

1.1.13

4 years ago

1.1.19

4 years ago

1.1.18

4 years ago

1.1.17

4 years ago

1.1.23

4 years ago

1.1.22

4 years ago

1.1.21

4 years ago

1.1.20

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago