first commit
This commit is contained in:
1
shell/.pydio
Normal file
1
shell/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
1f146e28-31b5-401e-b2ed-5953a56c83a9
|
||||
81
shell/config.js
Normal file
81
shell/config.js
Normal file
@@ -0,0 +1,81 @@
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = {
|
||||
home: {
|
||||
type: 'select',
|
||||
name: 'value',
|
||||
message: '请单选你需要的服务:',
|
||||
hint: '- 空格选择、回车提交',
|
||||
warn: '不可选',
|
||||
choices: [
|
||||
{
|
||||
title: '--------基础模块-----------',
|
||||
disabled: true
|
||||
},
|
||||
{
|
||||
title: '1:服务注册&发现',
|
||||
description: '启动服务注册中心,启动后各服务将自动连接',
|
||||
value: 'app'
|
||||
},
|
||||
{
|
||||
title: '2:Api 网关',
|
||||
description: '各微服务模块,将通过Api网关统一处理客户端请求',
|
||||
value: 'gateway'
|
||||
},
|
||||
{
|
||||
title: '--------业务模块-----------',
|
||||
disabled: true
|
||||
},
|
||||
...utils.getDirList("../services").map((v,i) => {
|
||||
return {
|
||||
title: `${i+1}:${v} 微服务模块`,
|
||||
description: `${v} 相关的业务模块`,
|
||||
value: v
|
||||
}
|
||||
}),
|
||||
{
|
||||
title: '--------批量操作-----------',
|
||||
disabled: true
|
||||
},
|
||||
{
|
||||
title: '1:全部 启/停',
|
||||
description: '启动 或 停止 所有项目',
|
||||
value: "operate_all"
|
||||
},
|
||||
{
|
||||
title: '2:单个 启/停',
|
||||
description: '启动 或 停止 单个项目',
|
||||
value: "operate_single"
|
||||
},
|
||||
{
|
||||
title: '3:终止端口',
|
||||
description: '结束指定的端口',
|
||||
value: "operate_kill"
|
||||
},
|
||||
]
|
||||
},
|
||||
actionList: {
|
||||
type: 'select',
|
||||
name: 'value',
|
||||
message: '请单选你需要的操作',
|
||||
hint: '- 空格选择、回车提交',
|
||||
warn: '不可选',
|
||||
choices: [
|
||||
{
|
||||
title: '1:安装依赖',
|
||||
description: '执行 npm i 初始化依赖',
|
||||
value: 'install'
|
||||
},
|
||||
{
|
||||
title: '2:删除依赖',
|
||||
description: '输入或粘贴需要 删除 的依赖包名称',
|
||||
value: 'uninstall'
|
||||
},
|
||||
{
|
||||
title: '3:更新依赖',
|
||||
description: '输入或粘贴需要 更新 的依赖包名称',
|
||||
value: 'update'
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
38
shell/index.js
Normal file
38
shell/index.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const prompts = require('prompts');
|
||||
const config = require('./config');
|
||||
const utils = require('./utils');
|
||||
|
||||
class run {
|
||||
constructor() {
|
||||
this.showHome()
|
||||
}
|
||||
|
||||
async showHome() {
|
||||
const homeRes = await prompts([ config.home ])
|
||||
if (!utils.checkActionType(homeRes.value)) {
|
||||
// console.log("非批量操作")
|
||||
const actionListRes = await prompts([ config.actionList ])
|
||||
console.log("response: ", homeRes)
|
||||
console.log("actionListRes: ", actionListRes)
|
||||
|
||||
} else {
|
||||
// console.log("批量操作")
|
||||
}
|
||||
// const response = await prompts([
|
||||
// {
|
||||
// type: 'select',
|
||||
// name: 'value',
|
||||
// message: 'Pick a color',
|
||||
// choices: [
|
||||
// { title: 'Red', description: 'This option has a description', value: '#ff0000' },
|
||||
// { title: 'Green', value: '#00ff00', disabled: true },
|
||||
// { title: 'Blue', value: '#0000ff' }
|
||||
// ],
|
||||
// initial: 1
|
||||
// }
|
||||
// ])
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
new run();
|
||||
16
shell/package.json
Normal file
16
shell/package.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "shell",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node index.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"prompts": "^2.4.2",
|
||||
"yargs": "^17.7.2"
|
||||
}
|
||||
}
|
||||
0
shell/prompts.js
Normal file
0
shell/prompts.js
Normal file
0
shell/text
Normal file
0
shell/text
Normal file
20
shell/utils.js
Normal file
20
shell/utils.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { readdirSync} = require("fs");
|
||||
const { join } = require("path");
|
||||
|
||||
class Utils {
|
||||
|
||||
/**
|
||||
* 读取指定路径下的第一级文件夹目录
|
||||
* @param dirName
|
||||
* @returns {string[]}
|
||||
*/
|
||||
static getDirList (dirName) {
|
||||
return readdirSync(`${join(__dirname, dirName)}`)
|
||||
}
|
||||
|
||||
static checkActionType(v) {
|
||||
return v.includes("operate_")
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Utils
|
||||
Reference in New Issue
Block a user