Browse Source

fixed bug

master
npmrun 3 years ago
parent
commit
eb77dac973
  1. 40
      README.MD
  2. 2
      package.json
  3. 0
      templates/a.png
  4. 9
      templates/pp.ask.js

40
README.MD

@ -1,5 +1,3 @@
# @noderun/pp
### 安装
```bash
npm i @noderun/pp -g
@ -26,9 +24,42 @@ Commands:
ask <templateDir> 命令行交互测试
help [command] display help for command
```
### 命令行交互
在根目录新建一个`pp.ask.js`,内容如下:
```
module.exports = (inquirer) => {
return [
{
type: "checkbox",
message: "选择一个框架",
name: "framework",
choices: [
new inquirer.Separator(" = Vue = "),
{
name: "element"
},
{
name: "Ham",
}
],
validate(answer) {
if (answer.length < 1) {
return "You must choose at least one topping.";
}
return true;
},
},
];
};
```
通过之后变量会应用于模板中,模板采用的是`ejs`渲染,只需要在需要替换的地方使用`ejs`语法` <%= locals.toppings || '' %>`就行了,
如果需要测试`inquirer`,使用`pp ask 文件夹`(文件夹是指子目录有`pp.ask.js`的文件夹)
### 同步
* 在gitee创建私人令牌,权限包括gist的操作
* 复制token,执行`pp sync`同步到gist
> 注意操作gist的是description的pp的,请注意跟你的gist不要重复
> `pp sync`需要手动执行
@ -44,7 +75,6 @@ Commands:
* [x] 命令行交互
* [x] 本地模板命令行交互测试
TODO
### 注意
* [ ] 代码整理
* [ ] 远端同步可能造成的数据丢失
* 记得同步就行,冲突比对暂时没有好的想法

2
package.json

@ -1,6 +1,6 @@
{
"name": "@noderun/pp",
"version": "0.0.25",
"version": "0.0.27",
"description": "命令行管理模板项目",
"main": "dist/pp.umd.js",
"module": "dist/pp.esm.js",

0
templates/a.png

9
templates/pp.ask.js

@ -2,12 +2,13 @@ module.exports = (inquirer) => {
return [
{
type: "checkbox",
message: "Select toppings",
name: "toppings",
message: "选择一个框架",
name: "framework",
choices: [
new inquirer.Separator(" = The Meats = "),
new inquirer.Separator(" = Vue = "),
{
name: "Pepperoni",
name: "element",
message: "Element UI"
},
{
name: "Ham",

Loading…
Cancel
Save