Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.help('help')
.argv
;
const logger = bole('wrapper');
const outputs = [];
if (/^dev/.test(process.env.NODE_ENV))
{
const prettystream = require('bistre')({ time: true });
prettystream.pipe(process.stdout);
outputs.push({ level: 'debug', stream: prettystream });
}
else
outputs.push({ level: 'info', stream: process.stdout });
bole.output(outputs);
// resolve ./ to the current working directory executing jthoober.
const rulesModule = argv.rules.match(/^.\//) ? path.resolve(process.cwd(), argv.rules) : argv.rules;
const ruleInput = require(rulesModule);
const rules = [];
ruleInput.forEach(data =>
{
const r = new jthoober.Rule(data);
rules.push(r);
logger.info(`loaded ${r.name}`);
});
const opts = {
name: 'jthoober',
port: process.env.PORT || argv.port,
host: process.env.HOST || argv.host,
outputs.push({ level: 'info', stream: fs.createWriteStream(fname) });
}
if (opts.logging.console)
{
if (process.env.NODE_ENV === 'dev')
{
var prettystream = require('bistre')({time: true}); // pretty
prettystream.pipe(process.stdout);
outputs.push({ level: 'debug', stream: prettystream });
}
else
outputs.push({level: 'info', stream: process.stdout });
}
bole.output(outputs);
};
}
var cf = path.resolve(process.cwd(), process.argv[2]);
var config = require(cf);
var outputs = [];
if (process.env.NODE_ENV === 'dev')
{
var prettystream = require('bistre')({ time: true }); // pretty
prettystream.pipe(process.stdout);
outputs.push({ level: 'debug', stream: prettystream });
}
else
outputs.push({level: 'info', stream: process.stdout });
bole.output(outputs);
var opsbot = new Opsbot(config);
opsbot.start();
}
config.saveDiffs = argv.saveDiffs
const options = {
version: config.version
}
if (argv.tokenFile) {
options.data = inquire.loadTokens(argv.tokenFile)
}
if (config.scale) {
options.scale = config.scale
}
bole.output({
level: argv.verbose ? 'debug' : 'info',
stream: debugOut
})
config.version = await version.getVersion(config)
await hikaru.deployCluster(argv.source, options)
.catch(async err => {
if (!err.tokens) {
console.error(`There was a problem in the specification at '${argv.source}'.\n ${err.stack}`)
process.exit(100)
}
console.log(`${err.tokens.length} tokens were found in the specification. When prompted, please provide a value for each.`)
const tokens = await inquire.acquireTokens(err.tokens)
if (options.data !== undefined) {
options.data = Object.assign(options.data, tokens)
} else {
if (argv.tokenFile) {
options.data = inquire.loadTokens(argv.tokenFile)
}
if (config.scale) {
options.scale = config.scale
}
if (!argv.job || !/[.]/.test(argv.job)) {
console.log(`the job name is required and must include the namespace and job name in 'namespace.job' format`)
process.exit(-1)
}
const [ namespace, jobName ] = argv.job.split('.')
options.namespace = namespace
options.job = jobName
bole.output({
level: argv.verbose ? 'debug' : 'info',
stream: debugOut
})
config.version = await version.getVersion(config)
await hikaru.runJob(argv.source, options)
.catch(async err => {
if (!err.tokens) {
console.error(`There was a problem in the specification at '${argv.source}'.\n ${err.stack}`)
process.exit(100)
}
console.log(`${err.tokens.length} tokens were found in the specification. When prompted, please provide a value for each.`)
const tokens = await inquire.acquireTokens(err.tokens)
if (options.data !== undefined) {
options.data = Object.assign(options.data, tokens)
} else {
const cached = aliasCache.getAlias(argv.alias)
Object.assign(config, cached)
}
const options = {
version: config.version
}
if (argv.tokenFile) {
options.data = inquire.loadTokens(argv.tokenFile)
}
if (config.scale) {
options.scale = config.scale
}
bole.output({
level: argv.verbose ? 'debug' : 'info',
stream: debugOut
})
config.version = await version.getVersion(config)
await hikaru.removeCluster(argv.source, options)
.catch(async err => {
if (!err.tokens) {
console.error(`There was a problem in the specification at '${argv.source}'.\n ${err.stack}`)
process.exit(100)
}
console.log(`${err.tokens.length} tokens were found in the specification. When prompted, please provide a value for each.`)
const tokens = await inquire.acquireTokens(err.tokens)
return hikaru.removeCluster(err.specPath, Object.assign(
{},
options,
config.username = argv.user
}
if (argv.password) {
config.password = argv.password
}
if (argv.token) {
config.token = argv.token
}
if (argv.url) {
config.url = argv.url
}
if (argv.apiVersion) {
config.version = argv.apiVersion
}
bole.output({
level: 'info',
stream: debugOut
})
config.version = await version.getVersion(config)
hikaru.aliasCluster(aliasCache, config)
.then(
() => console.log(`Alias '${config.alias}' for '${config.url}' was written to '${aliasCache.cacheFile}' successfully.`),
() => {
console.error(`There was a problem connecting to '${config.url}' with the information provided, alias was not created.`)
process.exit(100)
}
)
}
const bole = require('bole')('bench')
const fs = require('fs')
const plog = pino(pino.destination(('/dev/null')))
delete require.cache[require.resolve('../')]
const plogExtreme = require('../')(pino.extreme('/dev/null'))
const max = 10
const blog = bunyan.createLogger({
name: 'myapp',
streams: [{
level: 'trace',
stream: fs.createWriteStream('/dev/null')
}]
})
require('bole').output({
level: 'info',
stream: fs.createWriteStream('/dev/null')
}).setFastTime(true)
const run = bench([
function benchBunyanCreation (cb) {
var child = blog.child({ a: 'property' })
for (var i = 0; i < max; i++) {
child.info({ hello: 'world' })
}
setImmediate(cb)
},
function benchBoleCreation (cb) {
var child = bole('child')
for (var i = 0; i < max; i++) {
child.info({ hello: 'world' })
const plogUnsafeExtreme = require('../')({safe: false}, pino.extreme('/dev/null'))
const loglevel = require('./utils/wrap-log-level')(dest)
const deep = Object.assign({}, require('../package.json'), { level: 'info' })
const max = 10
const blog = bunyan.createLogger({
name: 'myapp',
streams: [{
level: 'trace',
stream: dest
}]
})
require('bole').output({
level: 'info',
stream: dest
}).setFastTime(true)
const chill = winston.createLogger({
transports: [
new winston.transports.Stream({
stream: fs.createWriteStream('/dev/null')
})
]
})
const run = bench([
function benchBunyanDeepObj (cb) {
for (var i = 0; i < max; i++) {
blog.info(deep)
const loglevel = require('./utils/wrap-log-level')(dest)
const plog = pino(dest)
delete require.cache[require.resolve('../')]
const plogExtreme = require('../')(pino.extreme('/dev/null'))
delete require.cache[require.resolve('../')]
const plogUnsafe = require('../')({safe: false}, dest)
delete require.cache[require.resolve('../')]
const plogUnsafeExtreme = require('../')({safe: false}, pino.extreme('/dev/null'))
const blog = bunyan.createLogger({
name: 'myapp',
streams: [{
level: 'trace',
stream: dest
}]
})
require('bole').output({
level: 'info',
stream: dest
}).setFastTime(true)
const chill = winston.createLogger({
transports: [
new winston.transports.Stream({
stream: fs.createWriteStream('/dev/null')
})
]
})
const max = 10
const run = bench([
function benchBunyanObj (cb) {
for (var i = 0; i < max; i++) {