function finish() { console.log('\nwriting wikidata.json'); console.time(colors.green('wikidata.json updated')); Object.keys(_wikidata).forEach(qid => { let target = _wikidata[qid]; ['identities', 'logos'].forEach(prop => { if (target[prop] && Object.keys(target[prop]).length) { target[prop] = sort(target[prop]); } else { delete target[prop]; } }); _wikidata[qid] = sort(target); }); fs.writeFileSync('dist/wikidata.json', stringify({ wikidata: sort(_wikidata) })); console.timeEnd(colors.green('wikidata.json updated')); if (_errors.length) { console.log(colors.yellow.bold(`\nError Summary:`)); _errors.forEach(msg => console.error(colors.red(msg))); } }
exports.fatal = function(msg, code) { exports.helpHeader(); console.log(''); console.log(colors.red.bold('Fatal error: ') + colors.yellow.bold(msg)); console.log(''); exports.helpFooter(); process.exit(code); };
const plotVersionUpgrade = newVersion => { console.log(`${pkg.name} is on ${c.yellow.bgBlack(pkg.version)}`) if (newVersion) { console.log(`will upgrade to ${c.red.bgBlack(newVersion)}`) return } console.log('no relevant commits for a new release') }
.then(function(){ if(clean){ return handleCommand(ws,'clean'); } else { var colors = require('colors/safe'); sendWSData(ws,JSON.stringify({'message': colors.yellow.bold('[ Upload Complete ]'), 'data': pathToProject_ })); currentFile_ = null; } }).
/** * */ log(sql, params, time) { if (process.env.NODAL_TRACE_QUERY && process.env.NODAL_TRACE_QUERY === 'true') { this.logger.trace(` ${colors.yellow.bold(sql)} ${colors.blue.bold('Param(s): '+JSON.stringify(params))} ${colors.blue.bold('Time: '+time + 'ms')} `); } return true; // yet? }
return argList.slice(1).map(function(v) { v = v.split(':'); if (Object.keys(db.adapter.types).indexOf(v[1].toLowerCase()) == -1) { throw new Error(`Un-supported column type ${colors.yellow.bold(v[1])} for field ${colors.yellow.bold(v[0])}`); } let obj = {name: inflect.underscore(v[0]), type: v[1].toLowerCase()}; let rest = v.slice(2); let properties = {}; ['array', 'unique'].forEach(v => { if (rest.indexOf(v) !== -1) { properties[v] = true; } }); Object.keys(properties).length && (obj.properties = properties); return obj; });
function nextMatch() { _currIndex = clamp(_currIndex, 0, _toMatch.length - 1); _currKey = _toMatch[_currIndex]; clearConsole(); console.log(colors.yellow.bold(`[${_currIndex+1}/${_total}]: ${_currKey}`)); const name = _currKey.split('|', 2)[1]; const lang = 'en'; const searchURL = wdk.searchEntities({ search: name, lang: lang, limit: MAXCHOICE, format: 'json', uselang: 'en' }); let choices = []; fetch(searchURL) .then(response => response.json()) .then(result => { if (!result.search.length) { throw new Error(`"${name}" not found`); } let queue = []; result.search.forEach((entity, index) => { choices.push(entity); entity.lang = lang; queue.push( fetch(wdk.sparqlQuery(instancesSPARQL(entity))) .then(response => response.json()) .then(result => getInstances(result, entity)) .catch(e => console.error(colors.red(e))) ); queue.push( fetch(wdk.sparqlQuery(sitelinkSPARQL(entity))) .then(response => response.json()) .then(result => getSitelink(result, entity)) .catch(e => console.error(colors.red(e))) ); }); return Promise.all(queue); }) .then(() => showResults(choices)) .catch(e => { console.error(colors.red(e)); _currIndex = _currIndex + _direction; }) .then(nextMatch); }
module.exports = function (exit) { console.info(colors.yellow.bold('Generating wiki using jsdoc2md...')); // clean directory test('-d', OUT_DIR) && rm('-rf', OUT_DIR); mkdir('-p', OUT_DIR); // execute command jsdoc2md.render({files: INP_DIR}) .then(function (markdown) { fs.writeFile(OUT_PATH, markdown, function (err) { console.info(err ? err : SUCCESS_MESSAGE); exit(err ? 1 : 0); }); }) .catch(function (err) { console.error(err); exit(1); }); };
function doFetch(index) { index = index || 0; if (index >= _urls.length) { return Promise.resolve(); } let currURL = _urls[index]; console.log(colors.yellow.bold(`\nBatch ${index+1}/${_urls.length}`)); return fetch(currURL) .then(response => response.json()) .then(result => processEntities(result)) .catch(e => { _errors.push(e); console.error(colors.red(e)); }) .then(() => delay(500)) .then(() => doFetch(++index)); }
module.exports = function (exit) { console.info(colors.yellow.bold('Generating documentation...')); try { // clean directory test('-d', TARGET_DIR) && rm('-rf', TARGET_DIR); } catch (e) { console.error(e.stack || e); return exit(e ? 1 : 0); } exec(`${IS_WINDOWS ? '' : 'node'} ${path.join('node_modules', '.bin', 'jsdoc')}${IS_WINDOWS ? '.cmd' : ''}` + ` -c .jsdoc-config.json -u docs lib --query 'pkgVersion=${pkg.version}' -p`, function (code) { // output status console.info(code ? colors.red.bold('unable to genereate documentation') : ` - documentation created at "${TARGET_DIR}"`); exit(code); }); };
/** * Publish the documentation built in the previous step of the pipeline. * * @param {Function} next - The callback function invoked to mark the completion of the publish routine, either * way. * @returns {*} */ function (next) { console.info(colors.yellow.bold('Generating and publishing documentation for postman-runtime')); try { // go to the out directory and create a *new* Git repo cd('out/docs'); exec('git init'); // inside this git repo we'll pretend to be a new user // @todo - is this change perpetual? exec('git config user.name "Doc Publisher"'); exec('git config user.email "*****@*****.**"'); // The first and only commit to this new Git repo contains all the // files present with the commit message "Deploy to GitHub Pages". exec('git add .'); exec('git commit -m "Deploy to GitHub Pages"'); } catch (e) { console.error(e.stack || e); return next(e ? 1 : 0); } // Force push from the current repo's master branch to the remote // repo's gh-pages branch. (All previous history on the gh-pages branch // will be lost, since we are overwriting it.) We silence any output to // hide any sensitive credential data that might otherwise be exposed. // eslint-disable-next-line no-undef config.silent = true; // this is apparently reset after exec exec('git push --force "git@github.com:postmanlabs/postman-runtime.git" master:gh-pages', function (code) { console.info('pushed documents to gh-pages'); next(code); }); }
function showResults(choices) { clearConsole(); console.log(colors.yellow.bold(`[${_currIndex+1}/${_total}]: ${_currKey}`)); // only keep choices with wikidata and wikipedia tags choices = choices.filter(entity => entity.id && entity.sitelink); if (!choices.length) { throw new Error(`Wiki tags not found`); } let keymap = {}; choices.forEach((entity, index) => { let key = '' + (index + 1); keymap[key] = entity; console.log( colors.blue.bold(`\n\'${key}\': `), colors.green(`Matched: ${entity.label} (${entity.id})`) ); if (entity.description) { console.log(` "${entity.description}"`); } if (entity.instances) { console.log(` instance of: [${entity.instances}]`); } if (entity.article) { console.log(` article: ${entity.article}`); } console.log(colors.magenta(` brand:wikidata = ${entity.id}`)); console.log(colors.magenta(` brand:wikipedia = ${entity.sitelink}`)); if (_enTags) { console.log(colors.magenta(` brand:en = ${entity.label}`)); console.log(colors.magenta(` name:en = ${entity.label}`)); } }); const enStatus = _enTags ? 'ON' : 'OFF'; console.log(); console.log(colors.blue.bold(`']': Next name`)); console.log(colors.blue.bold(`'[': Previous name`)); console.log(colors.blue.bold(`'}': Skip to next tag`)); console.log(colors.blue.bold(`'{': Skip to previous tag`)); console.log(colors.blue.bold(`'/': Search for a key`)); console.log(colors.blue.bold(`'e': Toggle 'en:' tags (currently ${enStatus})`)); console.log(colors.blue.bold(`'q': Quit`)); console.log(colors.blue.bold(`\nChoose: `)); _keypress = function(key) { if (key === '\u0003') { // ctrl-c (end of text) console.log(''); process.exit(); } if (_captureKeypress) { if (key === '\r') { // return _captureKeypress = false; let origIndex = _currIndex; let k; let match; do { _currIndex = (_currIndex === _toMatch.length - 1) ? 0 : _currIndex + 1; k = _toMatch[_currIndex]; match = k.toLowerCase().includes(_searchString.toLowerCase()); } while (!match && _currIndex !== origIndex); if (match) { _direction = 1; _resolve(); } else { console.log(`\n"${_searchString}" not found.`); console.log(colors.blue.bold(`\nChoose: `)); } } else { // capture search string _searchString += key; process.stdout.write(key); // echo } return; } if (key === 'q') { // Quit console.log(''); process.exit(); } else if (key === ']' || key === ' ') { // Next _direction = 1; _currIndex++; _resolve(); } else if (key === '[') { // Previous _direction = -1; _currIndex--; _resolve(); } else if (key === '}') { // Skip to next tag let t1 = _currKey.split('|', 2)[0]; let t2 = t1; while (t2 === t1) { // increment past end of current tag _currIndex = (_currIndex === _toMatch.length - 1) ? 0 : _currIndex + 1; let k2 = _toMatch[_currIndex]; t2 = k2.split('|', 2)[0]; } _direction = 1; _resolve(); } else if (key === '{') { // Skip to previous tag let t1 = _currKey.split('|', 2)[0]; let t2 = t1; while (t2 === t1) { // decrement past beginning of current tag _currIndex = (_currIndex === 0) ? _toMatch.length - 1 : _currIndex - 1; let k2 = _toMatch[_currIndex]; t2 = k2.split('|', 2)[0]; } t1 = t2; while (t2 === t1) { // decrement past beginning of previous tag _currIndex = (_currIndex === 0) ? _toMatch.length - 1 : _currIndex - 1; let k2 = _toMatch[_currIndex] || ''; t2 = k2.split('|', 2)[0]; } // increment once _currIndex = (_currIndex === _toMatch.length - 1) ? 0 : _currIndex + 1; _direction = -1; _resolve(); } else if (key === '/') { // start watching for search string process.stdout.write('\nSearch? '); _captureKeypress = true; _searchString = ''; } else if (key === 'e') { // Toggle en: tags _enTags = !_enTags; _resolve(); } else if (key === '?') { // ? - just refresh the screen _resolve(); } else if (keymap[key]) { // Pressed a number for a choice // update tags let entity = keymap[key]; let obj = brands[_currKey]; obj.tags['brand:wikidata'] = entity.id; obj.tags['brand:wikipedia'] = entity.sitelink; if (_enTags) { obj.tags['brand:en'] = entity.label; obj.tags['name:en'] = entity.label; } fileTree.write('brands', brands); // save updates _direction = 1; _currIndex++; _resolve(); } }; return new Promise(resolve => { _resolve = resolve; }); }
function showResults(choices) { clearConsole(); console.log(colors.yellow.bold(`[${_currIndex+1}/${_total}]: ${_currKey}`)); // only keep choices with wikidata and wikipedia tags choices = choices.filter(entity => entity.id && entity.sitelink); if (!choices.length) { throw new Error(`Wiki tags not found`); } let keymap = {}; choices.forEach((entity, index) => { let key = '' + (index + 1); keymap[key] = entity; console.log( colors.blue.bold(`\n\'${key}\': `), colors.green(`Matched: ${entity.label} (${entity.id})`) ); if (entity.description) { console.log(` "${entity.description}"`); } if (entity.instances) { console.log(` instance of: [${entity.instances}]`); } if (entity.article) { console.log(` article: ${entity.article}`); } console.log(colors.magenta(` brand:wikidata = ${entity.id}`)); console.log(colors.magenta(` brand:wikipedia = ${entity.sitelink}`)); if (_enTags) { console.log(colors.magenta(` brand:en = ${entity.label}`)); console.log(colors.magenta(` name:en = ${entity.label}`)); } }); const enStatus = _enTags ? 'ON' : 'OFF'; console.log(); console.log(colors.blue.bold(`']': Next name`)); console.log(colors.blue.bold(`'[': Previous name`)); console.log(colors.blue.bold(`'}': Skip to next tag`)); console.log(colors.blue.bold(`'{': Skip to previous tag`)); console.log(colors.blue.bold(`'e': Toggle 'en:' tags (currently ${enStatus})`)); console.log(colors.blue.bold(`'q': Quit`)); console.log(colors.blue.bold(`\nChoose: `)); _keypress = function(key) { if (key === '\u0003' || key === 'q') { // Quit or ctrl-c (end of text) console.log(''); process.exit(); } else if (key === ']' || key === ' ') { // Next _direction = 1; _currIndex++; _resolve(); } else if (key === '[') { // Previous _direction = -1; _currIndex--; _resolve(); } else if (key === '}') { // Skip to next tag let t1 = _currKey.split('|', 2)[0]; let t2 = t1; while (t2 === t1) { // increment past end of current tag _currIndex = (_currIndex === _toMatch.length - 1) ? 0 : _currIndex + 1; let k2 = _toMatch[_currIndex]; t2 = k2.split('|', 2)[0]; } _direction = 1; _resolve(); } else if (key === '{') { // Skip to previous tag let t1 = _currKey.split('|', 2)[0]; let t2 = t1; while (t2 === t1) { // decrement past beginning of current tag _currIndex = (_currIndex === 0) ? _toMatch.length - 1 : _currIndex - 1; let k2 = _toMatch[_currIndex]; t2 = k2.split('|', 2)[0]; } t1 = t2; while (t2 === t1) { // decrement past beginning of previous tag _currIndex = (_currIndex === 0) ? _toMatch.length - 1 : _currIndex - 1; let k2 = _toMatch[_currIndex] || ''; t2 = k2.split('|', 2)[0]; } // increment once _currIndex = (_currIndex === _toMatch.length - 1) ? 0 : _currIndex + 1; _direction = -1; _resolve(); } else if (key === 'e') { // Toggle en: tags _enTags = !_enTags; _resolve(); } else if (keymap[key]) { // Pressed a number for a choice // update tags let entity = keymap[key]; let obj = canonical[_currKey]; obj.tags['brand:wikidata'] = entity.id; obj.tags['brand:wikipedia'] = entity.sitelink; if (_enTags) { obj.tags['brand:en'] = entity.label; obj.tags['name:en'] = entity.label; } obj.tags = sort(obj.tags); fs.writeFileSync('config/canonical.json', stringify(sort(canonical), { maxLength: 50 })); _direction = 1; _currIndex++; _resolve(); } } return new Promise(resolve => { _resolve = resolve; }); }
start() { var groups = this.testLoader.getGroupsList(); var groupsSockets = this.groupsSockets; var clientSockets = this.clientSockets; var self = this; console.info(colors.yellow.bgBlack("Web socket starting the controller")); var controller = this.io .of('/') .on('connection', function (socket) { self.clientSockets[socket.conn.id] = socket; //console.info(colors.yellow.bgBlack("On Connect this sends a ready to another controller.")); console.info(colors.black.bgGreen("New socket is getting in from client" +socket.conn.id )); socket.emit('ready', { sentByController: true , 'ready': 'this client is ready to execute tests' }); if (self.testLoader.getCurrentIndex() !== -1) { controller.emit('startTests', {}); } socket.on('start', function(){ }); socket.on('ready', function(data){ if (self.testLoader.getCurrentIndex() === -1) { //console.info(colors.yellow.bgBlack("The thing is now ready to start the pipeline.")); fsm.readyToRun({"id": socket.conn.id}).catch(function (err) { console.log(err); }); } }); socket.on('stop', function(){ }); socket.on('disconnect', function(){ console.log("Disconnecting."); console.info(colors.black.bgRed("Removed socket from client" + socket.conn.id)); delete self.clientSockets[socket.conn.id]; //resetServerStateMachine(); }); }); this.controller = controller; console.log(groups); for(var i = 0; i < groups.length ; i++){ var group = groups[i]; //console.info(colors.yellow.bgBlack("Do I really belong to the group? " + group)); //console.info(colors.yellow.bgBlack("Answer: " + this.EsgrimaInstance.getGroups()[group]())); console.info(colors.yellow.bgBlack("Web socket starting with " + group)); var groupSocket = this.io .of('/'+group) .on('connection', (function (g, socket) { if (g===undefined) { console.log("There are problems with group name"); } console.info(colors.black.bgGreen(g)); console.info(colors.black.bgGreen("New socket is getting in from " + g + ", " + socket.conn.id )); self.groupsSockets[g].push(socket); console.log("[Group]Number of sockets connected: " +self.groupsSockets[g].length); //console.log(self.groupsSockets[group]); //console.log(self.groupsSockets[group]); /* socket.on('reportTn', function(data){ // Test Complete let id = data.test.id; let reports = data.test.reports; let assertations = data.test.assertations; this.testLoader.completeTest(id, reports, assertations); });*/ socket.on('reportTn', function(data){ console.log("Arrived a new report from executing."); if (data.error) { fsm.resetStates(data); console.info(colors.white.bgBlue(data.error)); self.numberOfReceivedReports = 0 ; self.numberOfWaitingAnswers = 0 ; } else { self.numberOfReceivedReports++; if (self.numberOfReceivedReports===self.numberOfWaitingAnswers) { fsm.reportTn(); } } //console.log(data); }); socket.on('disconnect', function(){ console.log("Disconnecting." + g); console.log("[Group]Number of sockets connected: " +self.groupsSockets[g].length); //console.log(socket); for (var j = 0 ; j<self.groupsSockets[g].length; j++) { if (self.groupsSockets[g][j]!==undefined) if (self.groupsSockets[g][j].conn.id === socket.conn.id) { console.info(colors.black.bgRed("Removed socket from " + g+", " + socket.conn.id)); self.groupsSockets[g].splice(j,1); } } console.log("[Group]Number of sockets connected: " +self.groupsSockets[g].length); }) }).bind(this, group)); console.info(colors.yellow.bgBlack("Added Socket " + group)); } }
server.on('listening', function() { var addr = server.address(); var dev = args.dev ? ' (' + clrs.yellow.bold('dev') + ')' : ''; console.log('politics-2016/' + pakg.version + dev + ' started on port ' + addr.port); });
async function sanityCheck(sourceToSuiteMap) { console.log("Running sanity checks..."); let passed = 0; let failed = 0; let skipped = 0; for (const source in sourceToSuiteMap) { const suiteName = sourceToSuiteMap[source]; if (suiteName == null ) { console.log("%s: %s", colors.yellow.bold("[-] SKIP"), colors.blue(source)); skipped++; continue; } const expfile = join(source, suiteName.replace(/legacy\/(.*)/, "$1.exp")); const [exp, testFileContentsBuffer] = await Promise.all([ readFile(expfile), readFile(join(testsDir, suiteName, "test.js")), ]); const testFileContents = testFileContentsBuffer.toString(); let matches = exp.toString().match(/Found (.*) errors?/); if (!matches) { console.log( "%s: %s %s", colors.red.bold("[✗] FAIL"), colors.blue(suiteName), format("Couldn't find `Found _ errors` in %s", expfile), ); failed++; continue; } const numErrors = Number(matches[1]); if (testFileContents.match(/noNewErrors\(\)/) && numErrors != 0) { console.log( "%s: %s %s", colors.red.bold("[✗] FAIL"), colors.blue(suiteName), format("%s says %d errors, but %s uses noNewErrors()", expfile, numErrors, suiteName), ); failed++; continue; } else if (matches = testFileContents.match(/newErrors\(\n`((.|[\n])*)`,\n\)/)) { const numNewErrors = matches[1] .split("\n\n") .length; if (numNewErrors != numErrors) { console.log( "%s: %s %s", colors.red.bold("[✗] FAIL"), colors.blue(suiteName), format("%s says %d errors, but %s has %d errors", expfile, numErrors, suiteName, numNewErrors), ); failed++; continue } } console.log("%s: %s", colors.green.bold("[✓] PASS"), colors.blue(suiteName)); passed++; } console.log( colors.green("%d passed") + ", " + colors.red("%d failed") + ", " + colors.yellow("%d skipped"), passed, failed, skipped ); }
try { var usersFile = fs.readFileSync('users.json', 'utf8'); users = JSON.parse(usersFile); console.info(colors.green('Found users.json file')); console.info(colors.green('Contains '+ users.length + ' users')); } catch (e) { console.error(colors.red('users.json is not a valid json')); } } else { var fd = fs.openSync('users.json', 'w'); console.info(colors.green('users.json file created')); users = []; } console.log(colors.yellow.underline('Create a user:'******'Enter the username:'******'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = (d + Math.random()*16)%16 | 0; d = Math.floor(d/16); return (c=='x' ? r : (r&0x3|0x8)).toString(16); }); return uuid; } rl.on('line', function(line){
Reporter.prototype.computeToday = function() { var tt = this.timeTracker; var date = tt.date.toString(); tt.log(colors.bold.cyan("Project \"" + tt.system.configuration.activeProjectName + "\"") , colors.yellow.underline("(" + tt.configFile + ")")); var result = tt.sum(date); var restSecondsToWorkThisDay = tt.getAvailableSecondsPerDay(date.split(".")[1],date.split(".")[2]); var time = new tt.Moment("00:00:00", "HH:mm:ss").add(result, "seconds"); var color = colors.green; if (result >= restSecondsToWorkThisDay){ color = colors.cyan; if (restSecondsToWorkThisDay > 0 && result > 0){ tt.log(color("Time elapsed:"), color(date), color("-"), color(time.format("HH:mm:ss")), color("You are done for this day ;O)")); } else { tt.log(color("Time elapsed:"), color(date), color("-"), color(time.format("HH:mm:ss"))); } } else { var canWorkUntil = new tt.Moment(date + " " + tt.time.toString(), "DD.MM.YYYY HH:mm:ss").add(restSecondsToWorkThisDay - result, "seconds"); tt.log(colors.bold.yellow("Elapsed time on " + date + ": ") + colors.cyan(time.format("HH:mm:ss"))); tt.log(colors.bold.yellow("Expected end-time: ") + colors.cyan(canWorkUntil.format("dddd, MMMM Do YYYY, HH:mm:ss"))); } return result; };
(str) => { return colors.yellow.bold(str); },