@bullhorn/bullhorn-cli
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -10,2 +10,4 @@ #!/usr/bin/env node | ||
const { upload } = require('./commands/upload-extension'); | ||
const { uninstall } = require('./commands/uninstall-extension'); | ||
const { lookup } = require('./commands/entity-cmds'); | ||
const { list } = require('./commands/list-extension'); | ||
@@ -72,7 +74,50 @@ const { generate } = require('./commands/create-typings'); | ||
.command('upload') | ||
.alias('install') | ||
.description('Upload an extension after extracting') | ||
.action(() => { | ||
prompt(UPLOAD_QUESTIONS).then((answers) => upload(answers)); | ||
.option('-f, --force', 'force upload') | ||
.option('-s, --skip', 'skip confirmation') | ||
.action((options) => { | ||
isAuthorized() | ||
.then((credentials) => { | ||
if(options && (options.force !== undefined || options.skip)) { | ||
const { force, skip } = options; | ||
upload(credentials, { force, skip }); | ||
} else { | ||
prompt(UPLOAD_QUESTIONS).then((answers) => upload(credentials, answers)); | ||
} | ||
}) | ||
.catch(() => { | ||
console.log(chalk.red('Please make sure you have run "bullhorn auth login" first.')); | ||
}); | ||
}); | ||
extensions | ||
.command('uninstall <id>') | ||
.option('-s, --skip', 'skip confirmation') | ||
.description('Uninstall an extension') | ||
.action((...args) => { | ||
isAuthorized() | ||
.then((credentials) => { | ||
uninstall(credentials, ...args); | ||
}) | ||
.catch(() => { | ||
console.log(chalk.red('Please make sure you have run "bullhorn auth login" first.')); | ||
}); | ||
}); | ||
const entity = program.command('entity <action>').description('commands to explore data'); | ||
entity | ||
.command('lookup <entity>') | ||
.description('Lookup entities in Bullhorn') | ||
.option('-f, --filter <filter>', 'specify a text filter') | ||
.action((...args) => { | ||
isAuthorized() | ||
.then((credentials) => lookup(credentials, ...args)) | ||
.catch(() => { | ||
console.log(chalk.red('Please make sure you have run "bullhorn auth login" first.')); | ||
}); | ||
}); | ||
const typings = program.command('typings <action>').description('commands to generate typings file'); | ||
@@ -118,2 +163,9 @@ | ||
break; | ||
case 'entity': | ||
if (!process.argv.slice(2).length || !/[arudl]/.test(process.argv.slice(2))) { | ||
entity.outputHelp(); | ||
process.exit(); | ||
} | ||
entity.parse(process.argv); | ||
break; | ||
case 'typings': | ||
@@ -120,0 +172,0 @@ case 't': |
@@ -8,55 +8,46 @@ const fs = require('fs'); | ||
const uninstall = (answers) => { | ||
// Check for "extension.json" file | ||
if (!fs.existsSync('./output/extension.json')) { | ||
console.log(chalk.red('No output file found for extension, please make sure to run "bullhorn extract" first!')); | ||
return; | ||
const doUninstall = (credentials, id, answers) => { | ||
let rest = credentials.sessions.find(s => s.name === 'rest').value; | ||
if (answers.confirm) { | ||
// Generate URL | ||
let URL = `${rest.endpoint}services/Extensions/uninstall/${id}?BhRestToken=${rest.token}`; | ||
console.log(chalk.blue(`Uploading to ${URL}...`)); | ||
// Push | ||
fetch(URL, { | ||
method: 'POST' | ||
}) | ||
.then(response => response.json()) | ||
.then(result => { | ||
console.log(chalk.blue('Success! Extension uninstalled, details:')); | ||
console.log(chalk.yellow(require('util').inspect(result, { | ||
colors: true, | ||
depth: null | ||
}))); | ||
}) | ||
.catch(error => { | ||
console.log(chalk.red(error)); | ||
}); | ||
} | ||
} | ||
// Find file and prompt | ||
console.log(chalk.blue('Output file found! The following will be uploaded:')); | ||
let extension = fs.readFileSync('./output/extension.json', 'utf-8'); | ||
console.log(chalk.yellow(extension)); | ||
prompt([{ | ||
type: 'confirm', | ||
name: 'confirm', | ||
message: 'Do you want to continue?', | ||
default: false | ||
}]).then((areYouSure) => { | ||
if (areYouSure.confirm) { | ||
// Generate URL | ||
let URL = `${answers.restUrl}/services/Extensions/uninstall/${id}?BhRestToken=${answers.BhRestToken}`; | ||
const uninstall = (credentials, id, answers) => { | ||
// Force install? | ||
if (answers.forceInstall) { | ||
URL += '&forceInstall=true'; | ||
} | ||
if( answers.skip) { | ||
doUninstall(credentials, id, Object.assign(answers, {confirm: true})); | ||
} else { | ||
prompt([{ | ||
type: 'confirm', | ||
name: 'confirm', | ||
message: 'Do you want to continue?', | ||
default: false | ||
}]).then((areYouSure) => { | ||
doUninstall(credentials, id, Object.assign(answers, areYouSure)); | ||
}); | ||
} | ||
console.log(chalk.blue(`Uploading to ${URL}...`)); | ||
// Push | ||
fetch(URL, { | ||
method: 'POST', | ||
body: extension | ||
}) | ||
.then(response => response.json()) | ||
.then(result => { | ||
if (result.errorMessage) { | ||
console.log(chalk.red(result.errorMessage.detailMessage)); | ||
console.log(chalk.red('Re-run with forceInstall as true to avoid this message...')); | ||
} else { | ||
console.log(chalk.blue('Success! Extension installed, details:')); | ||
console.log(chalk.yellow(require('util').inspect(result, { | ||
colors: true, | ||
depth: null | ||
}))); | ||
console.log(chalk.blue('Save this "extensionID" to uninstall at a later date...')); | ||
} | ||
}) | ||
.catch(error => { | ||
console.log(chalk.red(error)); | ||
}); | ||
} | ||
}); | ||
} | ||
@@ -63,0 +54,0 @@ |
@@ -8,3 +8,42 @@ const fs = require('fs'); | ||
const upload = (answers) => { | ||
const doUpload = (credentials, answers, extension) => { | ||
let rest = credentials.sessions.find(s => s.name === 'rest').value; | ||
if (answers.confirm) { | ||
// Generate URL | ||
let URL = `${rest.endpoint}services/Extensions/install?BhRestToken=${rest.token}`; | ||
// Force install? | ||
if (answers.force) { | ||
URL += '&forceInstall=true'; | ||
} | ||
console.log(chalk.blue(`Uploading to ${URL}...`)); | ||
// Push | ||
return fetch(URL, { | ||
method: 'POST', | ||
body: extension | ||
}) | ||
.then(response => response.json()) | ||
.then(result => { | ||
console.log('result', result); | ||
if (result.errorMessage) { | ||
console.log(chalk.red(result.errorMessage.detailMessage)); | ||
console.log(chalk.red('Re-run with forceInstall as true to avoid this message...')); | ||
} else { | ||
console.log(chalk.blue('Success! Extension installed, details:')); | ||
console.log(chalk.yellow(require('util').inspect(result, { | ||
colors: true, | ||
depth: null | ||
}))); | ||
console.log(chalk.blue('Save this "extensionID" to uninstall at a later date...')); | ||
} | ||
}) | ||
.catch(error => { | ||
console.log(chalk.red(error)); | ||
}); | ||
} | ||
} | ||
const upload = (credentials, answers) => { | ||
// Check for "extension.json" file | ||
@@ -21,43 +60,14 @@ if (!fs.existsSync('./output/extension.json')) { | ||
prompt([{ | ||
type: 'confirm', | ||
name: 'confirm', | ||
message: 'Do you want to continue?', | ||
default: false | ||
}]).then((areYouSure) => { | ||
if (areYouSure.confirm) { | ||
// Generate URL | ||
let URL = `${answers.restUrl}/services/Extensions/install?BhRestToken=${answers.BhRestToken}`; | ||
// Force install? | ||
if (answers.forceInstall) { | ||
URL += '&forceInstall=true'; | ||
} | ||
console.log(chalk.blue(`Uploading to ${URL}...`)); | ||
// Push | ||
fetch(URL, { | ||
method: 'POST', | ||
body: extension | ||
}) | ||
.then(response => response.json()) | ||
.then(result => { | ||
if (result.errorMessage) { | ||
console.log(chalk.red(result.errorMessage.detailMessage)); | ||
console.log(chalk.red('Re-run with forceInstall as true to avoid this message...')); | ||
} else { | ||
console.log(chalk.blue('Success! Extension installed, details:')); | ||
console.log(chalk.yellow(require('util').inspect(result, { | ||
colors: true, | ||
depth: null | ||
}))); | ||
console.log(chalk.blue('Save this "extensionID" to uninstall at a later date...')); | ||
} | ||
}) | ||
.catch(error => { | ||
console.log(chalk.red(error)); | ||
}); | ||
} | ||
}); | ||
if(answers.skip) { | ||
return doUpload(credentials, Object.assign(answers, { confirm: true }), extension); | ||
} else { | ||
return prompt([{ | ||
type: 'confirm', | ||
name: 'confirm', | ||
message: 'Do you want to continue?', | ||
default: false | ||
}]).then((areYouSure) => { | ||
return doUpload(credentials, Object.assign(answers, areYouSure), extension); | ||
}); | ||
} | ||
} | ||
@@ -64,0 +74,0 @@ |
{ | ||
"name": "@bullhorn/bullhorn-cli", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "preferGlobal": true, |
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
102443
21
777
11