https://github.com/steamerjs/steamer-pluginutils
utils for steamer plugin
https://github.com/steamerjs/steamer-pluginutils
Last synced: about 1 month ago
JSON representation
utils for steamer plugin
- Host: GitHub
- URL: https://github.com/steamerjs/steamer-pluginutils
- Owner: steamerjs
- Created: 2016-12-10T15:29:16.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-05-02T17:17:24.000Z (about 8 years ago)
- Last Synced: 2025-01-13T23:32:53.261Z (over 1 year ago)
- Language: JavaScript
- Size: 57.6 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
## steamer-pluginutils
### 即将过时
本项目即将过时,插件开发后续主要使用 [steamer-plugin](https://github.com/steamerjs/steamer-plugin) 作为基类开发。
[](https://www.npmjs.com/package/steamer-pluginutils)
[](https://travis-ci.org/steamerjs/steamer-pluginutils)
[](https://david-dm.org/steamerjs/steamer-pluginutils)
[](https://coveralls.io/github/steamerjs/steamer-pluginutils)
[steamerjs](https://github.com/steamerjs/steamer-pluginutils) 便于开发 `plugin` 的 `util` 函数
### 接口
#### 属性
- `pluginName`
- `String`
- 默认值: ""
- 注册 `plugin` 名
- `config`
- `Object`
- 默认值: null,
- 配置值
- `isWindows`
- `Boolean`
- 是否window系统
- `globalHome`
- `String`
- 通常用作全局配置存放的位置,是 `os.homedir()` 的一层包装
- `globalNodeModules`
- `String`
- 全局 `npm` 模块包位置, 是 `process.env.NODE_PATH` 的一层包装
#### 配置函数
- `addRequirePath`
- `Function`
- 添加模块搜索路径
- 参数
- `requirePath`, `String`, 新的模块搜索路径
- `targetPath`, `String`, 添加新模块搜索路径的目标, 默认值: `require.main.paths`
- `createConfig`
- Function
- 创建配置
- 参数
- `config`, config object, 默认值为: `{}`
- `option`, 其它配置项目
- `isGlobal`,`Boolean`, 是否放于全局
- `folder`, `String`, `.steamer` 的父目录,
- `filename`, `String`, 具体的文件名
- `extension`, `String`, 文件名后缀,默认值:`js`
- `overwrite`, `Boolean`, 是否覆盖已经存在的配置文件
- `readConfig`
- Function
- 读取配置, 采用配置继承的方式,本地配置继承全局配置
- 参数
- `option`, 其它配置项目
- `folder`, `String`, `.steamer` 的父目录,
- `filename`, `String`, 具体的文件名
- `extension`, `String`, 文件名后缀,默认值:`js`
- readSteamerConfig
- Function
- read steamerjs global or local config
- Parameters
- `isGlobal`, is the config global or local, default: `false`
- Return
- `config`, config object
- readSteamerLocalConfig
- Function
- read steamerjs local config
- Return
- `config`, local config object
- readSteamerGlobalConfig
- Function
- read steamerjs global config
- Return
- `config`, global config object
- createSteamerConfig
- Function
- read steamerjs global or local config
- Parameters
- `isGlobal`, is the config global or local, default: `false`
- `overwrite`, `Boolean`, 是否覆盖已经存在的配置文件
- Return
- `config`, config object
#### 命令输出
- error
- Function
- 将文本以红色输出
- info
- Function
- 将文本以蓝色输出
- warn
- Function
- 将文本以黄色输出
- success
- Function
- 将文本以绿色输出
- printTitle
- Function
- 输出命令标题
- Parameters
- `str`, 标题
- `color`, 颜色
```javascript
// 例子
================================ Command Usage ================================
```
- printEnd
- Function
- 输出命令结尾
- Parameters
- `color`, 颜色
```javascript
// 例子
================================================================================
```
- printUsage
- Function
- 输出命令使用
- Parameters
- `description`, 命令描述
- `cmd`, 命令名称
```javascript
// 例子
usage:
steamer doctor help you check steamer running environment!!!
```
- printOption
- Function
- 输出命令参数
- Parameters
- `options`, 参数数组
- `option.option`, 参数名
- `option.alias`, 参数别名
- `option.value`, 参数值
```javascript
// 例子
options:
--help, -h 123
--ak, -a 456
--plugin, -p 789
--help 123
```
#### 外部库
- fs ([fs-extra](https://github.com/jprichardson/node-fs-extra))
- chalk ([chalk](https://github.com/chalk/chalk))
### 开发及测试
```javascript
// 用于全局进行代码清理
npm i -g eslint
npm run lint
// 用于测试
npm test
```