Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bullhorn/bullhorn-cli

Package Overview
Dependencies
Maintainers
4
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bullhorn/bullhorn-cli - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

bully.png

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)

35

commands/create-typings.js

@@ -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>&nbsp; Built by Bullhorn, copyright (c) forever</span>
</p>
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc