Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* @flow */
import chalk from 'chalk'
import readline from 'readline'
import {dots} from 'cli-spinners'
import {getNavy} from '../'
import table from '../util/table'
import hasUpdate from '../util/has-update'
const debug = require('debug')('navy:updates')
let spinnerIndex = 0
let spinnerFrame = dots.frames[0]
function renderStatus(status) {
if (status == null) {
return chalk.yellow(spinnerFrame) + ' ' + chalk.dim('Checking...')
} else if (status === true) {
return chalk.yellow('• Update available')
} else if (status === 'UNKNOWN_REMOTE') {
return chalk.red('• Not found')
} else if (status === 'UNKNOWN_ERROR') {
return chalk.red('• Internal error')
} else if (status === 'NO_IMAGE') {
return chalk.red('• No image for service')
} else {
return chalk.green('✔ Up to date')
}
}
return api.getName(x);
});
spinnerNames.sort();
const maxPadding = Math.max.apply(
null,
spinnerNames.map(x => {
return x.length;
})
);
const multiSpinners = new Multispinner(spinnerNames, {
clear: false,
autoStart: true,
frames: dotsSpinner.frames,
interval: dotsSpinner.interval
});
let allModuleInfos = uniqueModuleInfos.map(x => {
return makeTask(token, x, multiSpinners, maxPadding);
});
// Place checking for musically-ut/appreciate at the top of the
// list for recovery afterwards.
allModuleInfos.unshift(checkIsAppreciateAppreciated(token, multiSpinners));
return Promise.all(allModuleInfos);
})
.then(allModuleInfosResolved => {
function _redraw(opts = {}) {
let symbol = chalk.cyan(dots.frames[_spinnerIndex])
if (opts.success === true) {
symbol = chalk.green('✔')
} else if (opts.success === false) {
symbol = chalk.red('•')
}
if (!process.stdout.isTTY) {
if (opts.success) {
console.log()
console.log(symbol, 'SUCCESS')
} else if (opts.success === false) {
console.log()
console.log(symbol, 'FAILURE')
}
return
this.timerId = window.setInterval(() => {
this.index += 1
this.index %= dots.frames.length
this.stdio.reset()
this.stdio.print(`${dots.frames[this.index]} ${message}`)
}, dots.interval)
}
getPrefix() {
const { status, loadingIncrement } = this.getState();
let prefix = chalk.green('?');
if (status === 'loading') {
const frame = loadingIncrement % spinner.frames.length;
prefix = chalk.yellow(spinner.frames[frame]);
}
return prefix;
}
_spinnerInterval = setInterval(() => {
_spinnerIndex++
if (_spinnerIndex >= dots.frames.length) {
_spinnerIndex = 0
}
_redraw()
}, dots.interval)
}
this.timerId = window.setInterval(() => {
this.index += 1
this.index %= dots.frames.length
this.stdio.reset()
this.stdio.print(`${dots.frames[this.index]} ${message}`)
}, dots.interval)
}
getPrefix() {
const { status, loadingIncrement } = this.getState();
let prefix = chalk.green('?');
if (status === 'loading') {
const frame = loadingIncrement % spinner.frames.length;
prefix = chalk.yellow(spinner.frames[frame]);
}
return prefix;
}
const spinner = setInterval(() => {
spinnerIndex++
if (spinnerIndex >= dots.frames.length) {
spinnerIndex = 0
}
spinnerFrame = dots.frames[spinnerIndex]
redraw()
}, dots.interval)