Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const path = require('path');
const figures = require('figures');
const chalk = require('../chalk').get();
const SEPERATOR = ' ' + chalk.gray.dim(figures.pointerSmall) + ' ';
module.exports = (base, file, title) => {
const prefix = file
// Only replace base if it is found at the start of the path
.replace(base, (match, offset) => offset === 0 ? '' : match)
.replace(/\.spec/, '')
.replace(/\.test/, '')
.replace(/test-/g, '')
.replace(/\.js$/, '')
.split(path.sep)
.filter(p => p !== '__tests__')
.join(SEPERATOR);
return prefix + SEPERATOR + title;
};
nuke('archives')
for (let archive of await dbs.archives.list()) {
archive.isFeatured = await dbs.featuredArchives.has(archive.key)
insert('archives', toArchiveRecord(archive))
}
console.log(figures.pointerSmall, 'Users->Archives...')
nuke('users_archives')
for (let userArchive of usersArchives) {
insert('users_archives', toUserArchiveRecord(userArchive))
}
console.log(figures.pointerSmall, 'Reports...')
nuke('reports')
for (let report of await dbs.reports.list()) {
insert('reports', toReportRecord(report))
}
console.log(figures.pointerSmall, 'Activity...')
nuke('activity')
for (let act of await dbs.activity.listGlobalEvents()) {
insert('activity', toActivityRecord(act))
}
// close output stream
await new Promise((resolve, reject) => {
ws.end((err) => {
if (err) reject(err)
else resolve()
})
})
// close the leveldb
await new Promise((resolve, reject) => {
levelInstance.close((err) => {
renderError(error, entity) {
// If no argument, skip
if (!error || error === '') {
return
}
// Clear any existing content
process.stdout.write(ansiEscapes.eraseDown)
console.log() // eslint-disable-line
// Write Error
if (entity) {
entity = `${red(entity)} ${red(figures.pointerSmall)} ${red(`error:`)}`
console.log(` ${entity}`) // eslint-disable-line
} else {
console.log(` ${red('error:')}`) // eslint-disable-line
}
console.log(` `, error) // eslint-disable-line
// Put cursor to starting position for next view
process.stdout.write(ansiEscapes.cursorLeft)
}
module.exports = async function (config) {
console.log(figures.heart, 'Hello friend')
console.log(figures.pointerSmall, 'Instantiating backend')
addConfigHelpers(config)
var cloud = new Hypercloud(config)
cloud.version = packageJson.version
await cloud.setup()
cloud.loadAllArchives()
console.log(figures.pointerSmall, 'Instantiating server')
var app = express()
if (config.proxy) {
app.set('trust proxy', 'loopback')
}
app.cloud = cloud
app.config = config
app.approveDomains = approveDomains(config, cloud)
app.locals = {
session: false, // default session value
sessionUser: false,
errors: false, // common default value
// Using the stripe publishable key to identify whether or not to show pricing related information
// on any page
stripePK: config.stripe ? config.stripe.publishableKey : null,
appInfo: {
constructor() {
this.colors = chalk_1.default;
this.figures = figures;
this.symbolPointer = figures.pointerSmall;
this.symbolItem = figures.line;
this.symbolSuccess = logSymbols.success;
this.symbolError = logSymbols.error;
this.symbolWarning = logSymbols.warning;
this.symbolInfo = logSymbols.info;
this.colorSuccess = this.colors.greenBright; // this.colors.rgb(0, 255, 0);
this.colorError = this.colors.redBright; // this.colors.rgb(255, 0, 0);
this.colorWarning = this.colors.yellow;
this.colorInfo = this.colors.gray;
this.colorHighlight = this.colors.yellowBright; // this.colors.rgb(255, 242, 0);
this.colorText = this.colors.white;
this.bgSuccess = this.colors.bgGreenBright;
this.bgError = this.colors.bgRedBright;
this.bgWarning = this.colors.bgYellow;
this.bgInfo = this.colors.bgBlackBright; // bgGray does not exist in chalk
this.bgHighlight = this.colors.bgYellowBright;
return this.bgWarning;
}
return this.bgSuccess;
}
properSymbol( hasErrors: boolean, hasWarnings: boolean ): any {
if ( hasErrors ) {
return this.symbolError;
}
if ( hasWarnings ) {
return this.symbolWarning;
}
return this.symbolSuccess;
}
readonly symbolPointer = figures.pointerSmall;
readonly symbolItem = figures.line;
readonly symbolSuccess = logSymbols.success;
readonly symbolError = logSymbols.error;
readonly symbolWarning = logSymbols.warning;
readonly symbolInfo = logSymbols.info;
readonly colorSuccess = this.colors.greenBright; // this.colors.rgb(0, 255, 0);
readonly colorError = this.colors.redBright; // this.colors.rgb(255, 0, 0);
readonly colorWarning = this.colors.yellow;
readonly colorInfo = this.colors.gray;
readonly colorHighlight = this.colors.yellowBright; // this.colors.rgb(255, 242, 0);
readonly colorText = this.colors.white;
readonly bgSuccess = this.colors.bgGreenBright;
readonly bgError = this.colors.bgRedBright;
readonly bgWarning = this.colors.bgYellow;
'use strict';
require('../../lib/chalk').set();
const path = require('path');
const figures = require('figures');
const {test} = require('tap');
const chalk = require('../../lib/chalk').get();
const prefixTitle = require('../../lib/reporters/prefix-title');
const sep = ' ' + chalk.gray.dim(figures.pointerSmall) + ' ';
test('removes base if found at start of path', t => {
t.is(prefixTitle(`test${path.sep}`, path.normalize('test/run-status.js'), 'title'), `run-status${sep}title`);
t.end();
});
test('does not remove base if found but not at start of path', t => {
t.is(prefixTitle(path.sep, path.normalize('test/run-status.js'), 'title'), `test${sep}run-status${sep}title`);
t.end();
});
test('removes .js extension', t => {
t.is(prefixTitle(path.sep, 'run-status.js', 'title'), `run-status${sep}title`);
t.end();
});
module.exports = async function (config) {
console.log(figures.heart, 'Hello friend')
console.log(figures.pointerSmall, 'Instantiating backend')
addConfigHelpers(config)
var cloud = new Hypercloud(config)
cloud.version = packageJson.version
await cloud.setup()
cloud.loadAllArchives()
console.log(figures.pointerSmall, 'Instantiating server')
var app = express()
if (config.proxy) {
app.set('trust proxy', 'loopback')
}
app.cloud = cloud
app.config = config
app.approveDomains = approveDomains(config, cloud)
app.locals = {
let extra = '';
if (test.differences) {
extra += test.differences.superfluous && test.differences.superfluous.length !== 0 ? chalk.yellow(` [+] ${test.differences.superfluous.join(' | ')}`) : '';
extra += test.differences.missing && test.differences.missing.length !== 0 ? chalk.red(` [-] ${test.differences.missing.join(' | ')}`) : '';
extra += test.differences.mismatched && test.differences.mismatched.length !== 0 ? chalk.red(` [*] ${test.differences.mismatched.join(' | ')}`) : '';
}
if (test.outdated) {
extra += ` ${chalk.dim(test.outdated.current)} → ${chalk.yellow(test.outdated.latest)}`;
}
if (test.linterOutput) {
extra += `\n${test.linterOutput}`;
}
terminal.echo(`${chalk.red(`${figures.pointerSmall} ${figures.cross}`)} ${test.message}${extra}`);
}
});
}
}
if (this._config.displayTimestamp) {
meta.push(this._formatTimestamp());
}
if (this._config.displayFilename) {
meta.push(this._formatFilename());
}
if (this._scopeName.length !== 0 && this._config.displayScope) {
meta.push(this._formatScopeName());
}
if (meta.length !== 0) {
meta.push(`${figures.pointerSmall}`);
return meta.map(item => grey(item));
}
return meta;
}