@bullhorn/bullhorn-cli
Advanced tools
Comparing version 1.1.0 to 2.0.0
124
bullhorn.js
#!/usr/bin/env node | ||
const chalk = require('chalk'); | ||
const program = require('commander'); | ||
const { prompt } = require('inquirer'); | ||
const loadJsonFile = require('load-json-file'); | ||
const { login } = require('./commands/auth-login'); | ||
const { setconfig, getconfig } = require('./commands/config-set'); | ||
const { extract } = require('./commands/extract-extension'); | ||
const { upload } = require('./commands/upload-extension'); | ||
const { list } = require('./commands/list-extension'); | ||
const { generate } = require('./commands/create-typings'); | ||
const { isAuthorized } = require('./lib/auth'); | ||
const { version } = require('./package.json'); | ||
const AUTH_QUESTIONS = require('./questions/auth-login.json'); | ||
const UPLOAD_QUESTIONS = require('./questions/upload-extension.json'); | ||
program | ||
.version('0.0.1') | ||
.description('Bullhorn CLI') | ||
.version(version) | ||
.description('Bullhorn CLI'); | ||
program | ||
const auth = program.command('auth <action>').description('Authorize cli with Bullhorn'); | ||
auth | ||
.command('login') | ||
.description('Authorize cli with Bullhorn') | ||
.option('-u, --username <username>', 'specify the username to use to authenticate') | ||
.option('-p, --password <password>', 'specify the password to use to authenticate') | ||
.action((options) => { | ||
if(options.username && options.password) { | ||
const { username, password } = options; | ||
login({username, password}); | ||
} else { | ||
prompt(AUTH_QUESTIONS).then((answers) => login(answers)); | ||
} | ||
}); | ||
const config = program.command('config <action>').description('Authorize cli with Bullhorn'); | ||
config | ||
.command('set <property> <value>') | ||
.description('set a configuration property') | ||
.action((...args) => { | ||
setconfig(...args); | ||
}); | ||
config | ||
.command('get <property>') | ||
.description('set a configuration property') | ||
.action((...args) => { | ||
getconfig(...args); | ||
}); | ||
const extensions = program.command('extensions <action>').description('commands to manage extensions'); | ||
extensions | ||
.command('extract') | ||
@@ -20,3 +58,14 @@ .description('Extract an extension from the extension config JSON file') | ||
program | ||
extensions | ||
.command('list') | ||
.description('list installed extensions') | ||
.action(() => { | ||
isAuthorized() | ||
.then((credentials) => list(credentials)) | ||
.catch(() => { | ||
console.log(chalk.red('Please make sure you have run "bullhorn auth login" first.')); | ||
}); | ||
}); | ||
extensions | ||
.command('upload') | ||
@@ -28,3 +77,5 @@ .description('Upload an extension after extracting') | ||
program | ||
const typings = program.command('typings <action>').description('commands to generate typings file'); | ||
typings | ||
.command('generate [entity]') | ||
@@ -34,14 +85,55 @@ .description('generate data model from Bullhorn REST metadata') | ||
.option('-d, --directory <directory>', 'specify the directory to output files. (default: ./typings)') | ||
.option('-u, --username <username>', 'specify the username for authentication. (Required)') | ||
.option('-p, --password <password>', 'specify the password for authentication. (Required)') | ||
.action((...args) => { | ||
generate(...args); | ||
isAuthorized() | ||
.then((credentials) => generate(credentials, ...args)) | ||
.catch(() => { | ||
console.log(chalk.red('Please make sure you have run "bullhorn auth login" first.')); | ||
}); | ||
}); | ||
// Assert that a VALID command is provided | ||
if (!process.argv.slice(2).length || !/[arudl]/.test(process.argv.slice(2))) { | ||
program.outputHelp(); | ||
process.exit(); | ||
const env = process.argv.splice(2,1); | ||
switch (env[0]) { | ||
case 'auth': | ||
if (!process.argv.slice(2).length || !/[arudl]/.test(process.argv.slice(2))) { | ||
auth.outputHelp(); | ||
process.exit(); | ||
} | ||
auth.parse(process.argv); | ||
break; | ||
case 'config': | ||
case 'conf': | ||
if (!process.argv.slice(2).length || !/[arudl]/.test(process.argv.slice(2))) { | ||
config.outputHelp(); | ||
process.exit(); | ||
} | ||
config.parse(process.argv); | ||
break; | ||
case 'extensions': | ||
case 'ext': | ||
if (!process.argv.slice(2).length || !/[arudl]/.test(process.argv.slice(2))) { | ||
extensions.outputHelp(); | ||
process.exit(); | ||
} | ||
extensions.parse(process.argv); | ||
break; | ||
case 'typings': | ||
case 't': | ||
if (!process.argv.slice(2).length || !/[arudl]/.test(process.argv.slice(2))) { | ||
typings.outputHelp(); | ||
process.exit(); | ||
} | ||
typings.parse(process.argv); | ||
break; | ||
default: | ||
try { | ||
if (!process.argv.slice(2).length || !/[arudl]/.test(process.argv.slice(2))) { | ||
program.outputHelp(); | ||
process.exit(); | ||
} | ||
program.parse(process.argv); | ||
} catch (err) { | ||
program.outputHelp(); | ||
process.exit(); | ||
} | ||
break; | ||
} | ||
program.parse(process.argv) |
@@ -5,3 +5,2 @@ const series = require('p-series'); | ||
const fs = require('fs'); | ||
const mkdirp = require('mkdirp'); | ||
const Logger = require('loggy'); | ||
@@ -12,19 +11,8 @@ const rc = require('rc'); | ||
const generate = (entity = 'all', options = {}) => { | ||
const generate = (credentials, entity = 'all', options = {}) => { | ||
let rest = credentials.sessions.find(s => s.name === 'rest').value; | ||
let config = rc('bullhorn', options); | ||
let env = config.environment || 'https://universal.bullhornstaffing.com'; | ||
let dir = config.directory || './typings'; | ||
mkdirp(dir); | ||
Logger.log(`authenticating against... ${env}`); | ||
let access = null; | ||
//axios.defaults.withCredentials = true; | ||
return axios(`${env}/universal-login/session/login?username=${config.username}&password=${config.password}`) | ||
return axios(`${rest.endpoint}/meta?&BhRestToken=${rest.token}`) | ||
.then((res) => res.data) | ||
.then((json) => { | ||
access = json.sessions.find((s) => s.name === 'rest').value; | ||
Logger.log(`retrieving available entities...`); | ||
return axios(`${access.endpoint}/meta?&BhRestToken=${access.token}`); | ||
}) | ||
.then((res) => res.data) | ||
.then((list) => { | ||
@@ -41,3 +29,3 @@ let promises = []; | ||
() => new Lazy((resolve, reject) => { | ||
return getMetaData(item, access) | ||
return getMetaData(item, rest) | ||
.then(resolve) | ||
@@ -80,2 +68,3 @@ .catch(reject); | ||
}; | ||
let hasCustomObjects = false; | ||
if (meta.entity.indexOf('CustomObject') >= 0) { | ||
@@ -85,3 +74,5 @@ data.dynamic = true; | ||
for (let field of meta.fields) { | ||
if (['id'].indexOf(field.name) < 0) { | ||
if (field.name.indexOf('customObject') === 0) { | ||
hasCustomObjects = true; | ||
} else if (['id'].indexOf(field.name) < 0) { | ||
switch (field.dataType || '') { | ||
@@ -142,2 +133,12 @@ case 'Integer': | ||
} | ||
if(hasCustomObjects) { | ||
let entity = meta.entity.replace(/[0-9]/g, ''); | ||
entity = ['Candidate', 'ClientContact', 'Lead'].indexOf(entity) < 0 ? entity : 'Person'; | ||
for ( let i=1; i<=10; i++){ | ||
data.properties.push({ | ||
name: `customObject${i}s`, | ||
type: `${entity}CustomObjectInstance${i}[]` | ||
}); | ||
} | ||
} | ||
} | ||
@@ -144,0 +145,0 @@ return data; |
@@ -41,2 +41,5 @@ const fs = require('fs'); | ||
} | ||
if (configuration.bots) { | ||
output.bots = []; | ||
} | ||
@@ -80,2 +83,17 @@ console.log(chalk.blue('Extracting extension points...')); | ||
if (configuration.bots) { | ||
console.log(chalk.blue(' Extracting bot configurations...')); | ||
configuration.bots.forEach(bot => { | ||
let matches = glob.sync(bot); | ||
matches.forEach(file => { | ||
if (file.endsWith('.js')) { | ||
console.log(chalk.blue(` ${bot}`)); | ||
let botConfig = require(path.join(process.cwd(), bot)).default; | ||
// todo: modify bot if needed | ||
output.bots.push(botConfig); | ||
} | ||
}); | ||
}); | ||
} | ||
console.log(chalk.blue(`Extraction complete! File being written to config.json`)); | ||
@@ -82,0 +100,0 @@ |
{ | ||
"name": "@bullhorn/bullhorn-cli", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "", | ||
@@ -17,3 +17,3 @@ "preferGlobal": true, | ||
{ | ||
"name": "Brian Kimballf", | ||
"name": "Brian Kimball", | ||
"email": "bvkimball@gmail.com" | ||
@@ -35,3 +35,4 @@ } | ||
"chalk": "^2.3.0", | ||
"commander": "^2.12.0", | ||
"commander": "^2.15.1", | ||
"console.table": "^0.10.0", | ||
"glob": "^7.1.2", | ||
@@ -41,2 +42,3 @@ "handlebars": "^4.0.11", | ||
"jsonfile": "^4.0.0", | ||
"load-json-file": "^5.0.0", | ||
"loggy": "^1.0.2", | ||
@@ -47,3 +49,5 @@ "mkdirp": "^0.5.1", | ||
"p-series": "^1.0.0", | ||
"rc": "^1.2.2" | ||
"rc": "^1.2.2", | ||
"trash": "^4.3.0", | ||
"write-json-file": "^2.3.0" | ||
}, | ||
@@ -53,2 +57,2 @@ "publishConfig": { | ||
} | ||
} | ||
} |
@@ -1,12 +0,3 @@ | ||
[{ | ||
"type": "input", | ||
"name": "restUrl", | ||
"message": "Enter restUrl .." | ||
}, | ||
[ | ||
{ | ||
"type": "input", | ||
"name": "BhRestToken", | ||
"message": "Enter BhRestToken .." | ||
}, | ||
{ | ||
"type": "confirm", | ||
@@ -13,0 +4,0 @@ "name": "forceInstall", |
@@ -1,5 +0,7 @@ | ||
# Bullhorn CLI | ||
# [![BULLHORN CLI](header.gif)](https://bullhon.github.io) | ||
> Command line interface for Bullhorn and Bullhorn Extensions | ||
--- | ||
## Installation | ||
@@ -10,19 +12,31 @@ | ||
## Usage | ||
``` | ||
Usage: [options] [command] | ||
Usage: bullhorn [options] [command] | ||
Bullhorn CLI | ||
Bullhorn CLI | ||
Options: | ||
Options: | ||
-V, --version output the version number | ||
-h, --help output usage information | ||
-V, --version output the version number | ||
-h, --help output usage information | ||
Commands: | ||
auth <action> Authorize cli with Bullhorn | ||
login | ||
logout | ||
config <action> Authorize cli with Bullhorn | ||
set <property> <value> Generate data model from Bullhorn REST metadata | ||
get <property> Generate data model from Bullhorn REST metadata | ||
Commands: | ||
extensions <action> commands to manage extensions | ||
extract Extract an extension from the extension config JSON file | ||
list list installed extensions | ||
upload Upload an extension after extracting | ||
extract Extract an extension from the extension config JSON file | ||
upload Upload an extension after extracting | ||
generate [options] [entity] generate data model from Bullhorn REST metadata | ||
typings <action> commands to generate typings file | ||
generate [options] [entity] generate data model from Bullhorn REST metadata | ||
``` | ||
@@ -36,1 +50,8 @@ | ||
4. Change stuff | ||
--- | ||
<p> | ||
<img src="bully.png" align="left" width="24" /> | ||
<span> Built by Bullhorn, copyright (c) forever</span> | ||
</p> |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
100262
20
708
55
17
10
5
+ Addedconsole.table@^0.10.0
+ Addedload-json-file@^5.0.0
+ Addedtrash@^4.3.0
+ Addedwrite-json-file@^2.3.0
+ Added@sindresorhus/df@1.0.12.1.0(transitive)
+ Addedarray-union@1.0.2(transitive)
+ Addedarray-uniq@1.0.3(transitive)
+ Addedclone@1.0.4(transitive)
+ Addedconsole.table@0.10.0(transitive)
+ Addedcross-spawn@6.0.6(transitive)
+ Addedcross-spawn-async@2.2.5(transitive)
+ Addeddefaults@1.0.4(transitive)
+ Addeddetect-indent@5.0.0(transitive)
+ Addeddir-glob@2.2.2(transitive)
+ Addedeasy-table@1.1.0(transitive)
+ Addederror-ex@1.3.2(transitive)
+ Addedescape-string-applescript@2.0.0(transitive)
+ Addedexeca@0.10.00.2.2(transitive)
+ Addedfs-extra@0.30.0(transitive)
+ Addedget-stream@3.0.0(transitive)
+ Addedglobby@7.1.1(transitive)
+ Addedignore@3.3.10(transitive)
+ Addedimurmurhash@0.1.4(transitive)
+ Addedis-arrayish@0.2.1(transitive)
+ Addedis-plain-obj@1.1.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedjson-parse-better-errors@1.0.2(transitive)
+ Addedjsonfile@2.4.0(transitive)
+ Addedklaw@1.3.1(transitive)
+ Addedload-json-file@5.3.0(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addedmake-dir@1.3.0(transitive)
+ Addedmount-point@3.0.0(transitive)
+ Addednice-try@1.0.5(transitive)
+ Addednpm-run-path@1.0.02.0.2(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedos-homedir@1.0.2(transitive)
+ Addedp-finally@1.0.0(transitive)
+ Addedp-map@1.2.0(transitive)
+ Addedp-try@1.0.0(transitive)
+ Addedparse-json@4.0.0(transitive)
+ Addedpath-key@1.0.02.0.1(transitive)
+ Addedpath-type@3.0.0(transitive)
+ Addedpify@2.3.03.0.04.0.1(transitive)
+ Addedpinkie@2.0.4(transitive)
+ Addedpinkie-promise@2.0.1(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedrun-applescript@3.2.0(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedshebang-command@1.2.0(transitive)
+ Addedshebang-regex@1.0.0(transitive)
+ Addedslash@1.0.0(transitive)
+ Addedsort-keys@2.0.0(transitive)
+ Addedstrip-bom@3.0.0(transitive)
+ Addedstrip-eof@1.0.0(transitive)
+ Addedtrash@4.3.0(transitive)
+ Addedtype-fest@0.3.1(transitive)
+ Addeduser-home@2.0.0(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedwcwidth@1.0.1(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedwrite-file-atomic@2.4.3(transitive)
+ Addedwrite-json-file@2.3.0(transitive)
+ Addedxdg-basedir@2.0.0(transitive)
+ Addedxdg-trashdir@2.1.1(transitive)
+ Addedyallist@2.1.2(transitive)
Updatedcommander@^2.15.1