@fivethree/billy-core
Advanced tools
Comparing version 0.6.4 to 0.7.0
@@ -19,4 +19,8 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const typescript_ioc_1 = require("typescript-ioc"); | ||
const cli_table_1 = __importDefault(require("cli-table")); | ||
require('dotenv').config(); | ||
@@ -77,16 +81,56 @@ const fs = require('fs'); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const answer = yield inquirer.prompt([ | ||
{ | ||
type: 'list', | ||
const table = new cli_table_1.default({ | ||
head: ["Number", "Lane", "Description"], | ||
chars: { | ||
'top': '═', 'top-mid': '╤', 'top-left': '╔', 'top-right': '╗', | ||
'bottom': '═', 'bottom-mid': '╧', 'bottom-left': '╚', 'bottom-right': '╝', | ||
'left': '║', 'left-mid': '╟', 'mid': '─', 'mid-mid': '┼', | ||
'right': '║', 'right-mid': '╢', 'middle': '│' | ||
} | ||
}); | ||
this.lanes.forEach((lane, index) => table.push([chalk.blueBright(`${index + 1}`), lane.name, lane.description])); | ||
console.log(table.toString()); | ||
// const answer = await inquirer.prompt([ | ||
// { | ||
// type: 'list', | ||
// name: 'lane', | ||
// pageSize: process.stdout.rows, | ||
// message: `${chalk.bold('Select Lane')}`, | ||
// choices: this.lanes.map((lane, index) => { | ||
// return { name: `${chalk.underline.blueBright(`${index + 1}. ${lane.name}`)} \n ${lane.description}`, value: lane }; | ||
// }) | ||
// } | ||
// ]); | ||
const lane = (yield inquirer.prompt([{ | ||
type: 'input', | ||
name: 'lane', | ||
paginated: true, | ||
pageSize: 20, | ||
message: `${chalk.bold('Select Lane')}`, | ||
choices: this.lanes.map((lane, index) => { | ||
return { name: `${chalk.underline.blueBright(`${index + 1}.${lane.name}:`)}\n${lane.description}`, value: lane }; | ||
}) | ||
} | ||
]); | ||
message: 'please enter number or lane name', | ||
validate: (input) => { | ||
if (!!input && isNaN(input)) { | ||
if (this.lanes.some(lane => lane.name === input)) { | ||
return true; | ||
} | ||
else { | ||
console.log(chalk.red(` | couldn't find lane with name ${input}`)); | ||
return false; | ||
} | ||
} | ||
else { | ||
if (+input > 0 && +input <= this.lanes.length) { | ||
return true; | ||
} | ||
else { | ||
console.log(chalk.red(' | specify a number between 1 and ' + this.lanes.length)); | ||
return false; | ||
} | ||
} | ||
} | ||
}])).lane; | ||
yield this.runHook(this.getHook('BEFORE_ALL')); | ||
yield this.takeLane(answer.lane); | ||
if (isNaN(lane)) { | ||
yield this.takeLane(this.lanes.find(l => l.name === lane)); | ||
} | ||
else { | ||
yield this.takeLane(this.lanes[lane - 1]); | ||
} | ||
yield this.runHook(this.getHook('AFTER_ALL')); | ||
@@ -93,0 +137,0 @@ }); |
{ | ||
"name": "@fivethree/billy-core", | ||
"version": "0.6.4", | ||
"version": "0.7.0", | ||
"description": "cli plugin system core.", | ||
@@ -35,2 +35,3 @@ "main": "dist/index.js", | ||
"clear": "^0.1.0", | ||
"cli-table": "^0.3.1", | ||
"commander": "^2.19.0", | ||
@@ -37,0 +38,0 @@ "dotenv": "^6.2.0", |
import { LaneType, LaneContext, JobType, HookType, HookName, WebHookType } from './types'; | ||
import { Provided, Provider, Singleton, Inject } from 'typescript-ioc'; | ||
import Table from 'cli-table'; | ||
require('dotenv').config(); | ||
@@ -71,18 +72,55 @@ | ||
async presentLanes() { | ||
const answer = await inquirer.prompt([ | ||
{ | ||
type: 'list', | ||
name: 'lane', | ||
paginated: true, | ||
pageSize: 20, | ||
message: `${chalk.bold('Select Lane')}`, | ||
choices: this.lanes.map((lane, index) => { | ||
return { name: `${chalk.underline.blueBright(`${index + 1}.${lane.name}:`)}\n${lane.description}`, value: lane }; | ||
}) | ||
const table = new Table({ | ||
head: ["Number", "Lane", "Description"], | ||
chars: { | ||
'top': '═', 'top-mid': '╤', 'top-left': '╔', 'top-right': '╗' | ||
, 'bottom': '═', 'bottom-mid': '╧', 'bottom-left': '╚', 'bottom-right': '╝' | ||
, 'left': '║', 'left-mid': '╟', 'mid': '─', 'mid-mid': '┼' | ||
, 'right': '║', 'right-mid': '╢', 'middle': '│' | ||
} | ||
]); | ||
}); | ||
this.lanes.forEach((lane, index) => table.push([chalk.blueBright(`${index + 1}`), lane.name, lane.description])); | ||
console.log(table.toString()); | ||
// const answer = await inquirer.prompt([ | ||
// { | ||
// type: 'list', | ||
// name: 'lane', | ||
// pageSize: process.stdout.rows, | ||
// message: `${chalk.bold('Select Lane')}`, | ||
// choices: this.lanes.map((lane, index) => { | ||
// return { name: `${chalk.underline.blueBright(`${index + 1}. ${lane.name}`)} \n ${lane.description}`, value: lane }; | ||
// }) | ||
// } | ||
// ]); | ||
const lane = (await inquirer.prompt([{ | ||
type: 'input', | ||
name: 'lane', | ||
message: 'please enter number or lane name', | ||
validate: (input) => { | ||
if (!!input && isNaN(input)) { | ||
if (this.lanes.some(lane => lane.name === input)) { | ||
return true; | ||
} else { | ||
console.log(chalk.red(` | couldn't find lane with name ${input}`)) | ||
return false; | ||
} | ||
} else { | ||
if (+input > 0 && +input <= this.lanes.length) { | ||
return true; | ||
} else { | ||
console.log(chalk.red(' | specify a number between 1 and ' + this.lanes.length)); | ||
return false; | ||
} | ||
} | ||
} | ||
}])).lane; | ||
await this.runHook(this.getHook('BEFORE_ALL')); | ||
await this.takeLane(answer.lane); | ||
if (isNaN(lane)) { | ||
await this.takeLane(this.lanes.find(l => l.name === lane)); | ||
} else { | ||
await this.takeLane(this.lanes[lane - 1]); | ||
} | ||
@@ -168,3 +206,3 @@ await this.runHook(this.getHook('AFTER_ALL')); | ||
res.sendStatus(200) | ||
await this.takeLane(hook.lane,req.body); | ||
await this.takeLane(hook.lane, req.body); | ||
}) | ||
@@ -171,0 +209,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28924
703
13
+ Addedcli-table@^0.3.1
+ Addedcli-table@0.3.11(transitive)
+ Addedcolors@1.0.3(transitive)