Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
archive.replicationStreams.forEach(stream => stream.destroy()) // stop all active replications
archive.replicationStreams.length = 0
archive.isSwarming = false
this.swarm.leave(archive.discoveryKey)
}
// done?
if (opts.download === false && opts.upload === false) {
if (wasSwarming) {
console.log(figures.info, 'Unswarming archive', datEncoding.toStr(archive.key))
}
return
}
// join the swarm
debounceConsole.log(`${figures.info} Swarming archive`, {timeout: 250, max: 1e3}, datEncoding.toStr(archive.key))
archive.isSwarming = true
archive.swarmOpts = opts
this.swarm.listen(archive.discoveryKey, 0, () => {})
}
return __awaiter(this, void 0, void 0, function* () {
const iconInfo = chalk_1.default.blueBright(figures_1.info);
const iconArrow = chalk_1.default.yellow(figures_1.arrowRight);
const iconError = chalk_1.default.redBright(figures_1.cross);
const iconWarning = chalk_1.default.yellow(figures_1.warning);
const textColor = chalk_1.default.cyanBright;
const textCommand = chalk_1.default.cyan;
const highlight = chalk_1.default.yellowBright;
if (!!options.sourceCodeDir) {
fse.mkdirs(options.sourceCodeDir);
}
if (!!options.executionResultDir) {
fse.mkdirs(options.executionResultDir);
}
const executionPath = process.cwd();
const cfgMaker = new ConfigMaker_1.ConfigMaker();
const writeF = util_1.promisify(fs_1.writeFile);
// About codeceptj.json ------------------------------------------------
it('多类型测试', function () {
const message = ['hello', 'world!']
const errorExcept = chalk.red(`\n ${figures.cross} ${message[0]}\n ${message[1]}\n`)
const successExcept = chalk.green(`\n ${figures.tick} ${message[0]}\n ${message[1]}\n`)
const infoExcept = chalk.blue(`\n ${figures.info} ${message[0]}\n ${message[1]}\n`)
const warnExcept = chalk.yellow(`\n ${figures.warning} ${message[0]}\n ${message[1]}\n`)
error(...message)
success(...message)
info(...message)
warn(...message)
console.log.getCall(0).args[0].should.be.equal(errorExcept)
console.log.getCall(1).args[0].should.be.equal(successExcept)
console.log.getCall(2).args[0].should.be.equal(infoExcept)
console.log.getCall(3).args[0].should.be.equal(warnExcept)
console.log.callCount.should.be.equal(4)
})
})
exports.migrateAsNeeded = async function (cloud, dataPath) {
var dbPath = path.join(dataPath, 'db')
if (fs.existsSync(dbPath)) {
console.log('')
console.log(figures.star, 'A database migration is required!')
console.log(figures.heart, 'Don\'t worry, this will be easy.')
var sqlFilePath = path.join(dataPath, 'legacy-leveldb-to-sqlite-dump.sql')
var archivedDbPath = path.join(dataPath, 'legacy-leveldb')
var newDbPath = path.join(dataPath, 'main.db')
await generateMigrationDump(dbPath, sqlFilePath)
await generateSqliteDb(cloud)
console.log(figures.info, 'SQL File:', sqlFilePath)
console.log(figures.info, 'The old database will be archived at', archivedDbPath)
console.log(figures.info, 'The new database is at', newDbPath)
if (!(await ask(figures.play + ' Are you ready to run the migration? (Y/n)', 'y'))) {
console.log('Okay.')
console.log('We need to run this migration to start, so Hashbase is now going to close.')
console.log(figures.pointerSmall, 'Shutting down.')
process.exit(0)
}
archiveOldDb(dbPath, archivedDbPath)
console.log(figures.star, 'A database migration complete!')
console.log('')
}
}
message(category = 'info', message) {
if (this.silent) return
const color = {
debug: 'magenta',
info: 'blue',
warning: 'yellow',
error: 'red',
success: 'green',
}[category]
const symbol = {
debug: figures.pointer,
info: figures.info,
warning: figures.warning,
error: figures.cross,
success: figures.tick,
}[category]
const icon = chalk[color](symbol)
console.log(` ${icon} ${message}`)
}
setInterval(() => console.log(figures.info, this.activeProgressStreams, 'active progress streams'), 60e3)
logLevel: 'error'
},
fatal: {
badge: figures.cross,
color: 'red',
label: 'fatal',
logLevel: 'error'
},
fav: {
badge: figures('❤'),
color: 'magenta',
label: 'favorite',
logLevel: 'info'
},
info: {
badge: figures.info,
color: 'blue',
label: 'info',
logLevel: 'info'
},
star: {
badge: figures.star,
color: 'yellow',
label: 'star',
logLevel: 'info'
},
success: {
badge: figures.tick,
color: 'green',
label: 'success',
logLevel: 'info'
},
import chalk from 'chalk'
import figures from 'figures'
export const DEBUG_ICON = chalk.magenta(figures.pointer)
export const INFO_ICON = chalk.blue(figures.info)
export const WARNING_ICON = chalk.yellow(figures.warning)
export const ERROR_ICON = chalk.red(figures.cross)
export const SUCCESS_ICON = chalk.green(figures.tick)
renderDepsTree(depsTree: DepsTree, output: string[] = []) {
let indent = Array(depsTree.depth * this.props.indent)
.fill(' ')
.join('')
let frames = Spinners.dots.frames as string[]
let symbol = {
[TaskState.waiting]: chalk.gray(logFigures.ellipsis),
[TaskState.pending]: chalk.blueBright(logFigures.arrowRight),
[TaskState.loading]: chalk.cyan(frames[this.count(depsTree.uid) % frames.length]),
[TaskState.succeeded]: chalk.green(logFigures.tick),
[TaskState.failed]: chalk.red(logFigures.cross),
[TaskState.skipped]: chalk.yellow(logFigures.info),
...this.props.symbolMap,
}[depsTree.state]
let color =
(this.props.grayState || [TaskState.waiting]).indexOf(depsTree.state) >= 0
? f => chalk.gray(f)
: f => f
let skipped = depsTree.state === TaskState.skipped
output.push(
`${indent}${symbol} ${color(depsTree.task.name)}${skipped ? chalk.gray(` [skipped]`) : ''}${depsTree.priority ? chalk.gray(` [priority: ${depsTree.priority}]`) : ''}`,
)
let childDeps = ([] as DepsTree[])
.concat(...depsTree.asyncDeps)
.concat(depsTree.syncDeps)
for (const child of childDeps) {
this.renderDepsTree(child, output)
}