Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.format = function (str) {
if (str instanceof Error) {
return '\n' + exports.errorToString(str);
}
if (typeof str == 'object') {
return str;
}
return ('' + str)
// add colour to our build logs so that it's easier to see if and where things went wrong.
.replace(/\d*(^|\s|[^a-zA-Z0-9-])error(s|\(s\))?/gi, function (res) { return color.redBright(res); })
.replace(/\d*(^|\s|[^a-zA-Z0-9-])warn(ing)?(s|\(s\))?/gi, function (res) { return color.yellowBright(res); })
.replace('BUILD SUCCESSFUL', color.greenBright('BUILD SUCCESSFUL'))
.replace('BUILD FAILED', color.redBright('BUILD FAILED'))
// fix new lines
.replace(/\r?\n(?!$)/g, '\n' + this._prefix);
}
function exec(args, config, next) {
var Optimist = require('optimist');
var optimistParser = new Optimist(args)
.usage('Usage: ' + clc.greenBright('basil testapp') + clc.yellowBright(' [target], ')
+ 'where ' + clc.yellowBright('[target]') + ' may be: ' + clc.yellowBright(targetNames.join(', ')));
var argv = optimistParser.argv;
var target = argv._[0] && argv._[0].toLowerCase();
if (!target || targetNames.indexOf(target) < 0) {
optimistParser.showHelp();
next && next();
return;
}
common.startTime('testapp');
testapp(target, {}, next);
}
_.forEach(passedTests, (test) => {
logger.warn("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
logger.warn(` Passed Test: ${test.toString()}`);
logger.warn(` # attempts: ${test.attempts}`);
logger.warn("From last attempt: \n");
logger.loghelp(test.stdout);
logger.loghelp(test.stderr);
});
}
analytics.mark("magellan-run", "passed");
}
let status = failedTests.length > 0 ?
clc.redBright("FAILED") :
clc.greenBright("PASSED");
if (this.strategies.bail.hasBailed) {
status += clc.redBright(` due to bail strategy: ${this.strategies.bail.getBailReason()}`);
}
this.queue.tests.forEach((test) => {
if (test.status === Test.TEST_STATUS_SUCCESSFUL
&& test.getRetries() > 0) {
if (retryMetrics[test.getRetries()]) {
retryMetrics[test.getRetries()]++;
} else {
retryMetrics[test.getRetries()] = 1;
}
}
});
function getMySQLColumns() {
console.log('\n' + clc.greenBright('Loading columns for tables...') + '\n');
u.each(tables, function(table) {
if (!tableDependencies[table]) tableDependencies[table] = [];
mysqlConnection.query('describe ' + table, function (err, rows) {
if (err) return exitError(err);
if (!columns[table]) columns[table] = [];
u.each(rows, function(row) {
columns[table].push(row['Field']);
});
});
});
console.log('\n' + clc.greenBright('Finished loading columns.') + '\n');
enterRelationsLoop();
}
u.each(columns[table], function(col, idx) {
console.log(clc.greenBright(idx) + ': ' + clc.greenBright(col));
});
}
const saveCompiled = compiledFiles => compiledFiles.forEach((content, key) => {
mkdirp.sync(path.dirname(destinations[key]));
const from = path.relative(path.join(__dirname, '..'), sources[key]);
const to = path.relative(process.cwd(), destinations[key]);
const exists = glob.sync(destinations[key]).length > 0;
console.log(grey('Writing'), from, green('->'), to, exists ? red('[overwrite]') : green('[create]'));
fs.writeFileSync(destinations[key], content, 'utf-8');
});
u.each(tableRelations, function(relation) {
console.log('Relation exists from ' + clc.greenBright(relation.source) + '.' + clc.greenBright(relation.sourceField) + ' to ' + clc.greenBright(relation.target) + '.' + clc.greenBright(relation.targetField));
});
console.log('\n');
sayThanks() {
console.log(clc.greenBright("\nSuccess...\n"));
console.log(`Thanks for use ${clc.whiteBright("Rocket Translator")}.\n\nOpen ${clc.whiteBright(this.output)} to view your files.`);
console.log(`\nSend a feedback to ${clc.whiteBright("@David_Devel")} on Twitter.\n\nTo report a Error, open a new issue on:\n${clc.whiteBright("https://github.com/Davids-Devel/rocket-translator")}`);
unlinkSync(global.defineGlobals);
unlinkSync(global.tempDataFile);
}
}
exports.success = function(result) {
console.log(color.greenBright(util.inspect(result, false, 1, true)));
}
function colorProbability (probability, options) {
if (probability === null) {
return ''
}
options = options || {}
var useColors = !!options.color && colorAvailable
if (probability < 0 || probability > 1) {
throw new Error('Expected probability between 0 and 1, not ' + probability)
}
var probabilityStr = (probability * 100).toFixed(0) + '%'
if (useColors) {
if (probability > 0.8) {
probabilityStr = colors.greenBright(probabilityStr)
} else if (probability > 0.5) {
probabilityStr = colors.yellowBright(probabilityStr)
} else {
probabilityStr = colors.redBright(probabilityStr)
}
}
return probabilityStr
}