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)));
    }
}
function buildAll() {
    console.log('building data');
    console.time(colors.green('data built'));

    // Start clean
    shell.rm('-f', ['dist/name-suggestions.*']);

    // convert discardedNames to lowerCase as we compare against
    // lowerCase later on and as changing case is locale specific
    // converting in code will at least use the same locale
    var len = filter.discardedNamesOverall.length;
    for (var i = 0; i < len; i++) {
        filter.discardedNamesOverall[i] = filter.discardedNamesOverall[i].toLowerCase();
    }

    for (var fullName in topNames) {
        filterValues(fullName);
    }

    // Save individual data files
    fs.writeFileSync('dist/name-suggestions.json', prettyStringify({ names: out }));
    fs.writeFileSync('dist/name-suggestions.min.json', JSON.stringify({ names: out }));

    console.timeEnd(colors.green('data built'));
}
function writeDocs(tree, obj) {
    console.log('\nwriting ' + tree);
    console.time(colors.green(tree + ' written'));
    let dict = {};

    // Start clean
    shell.rm('-rf', ['docs/brands']);

    // populate K-V dictionary
    Object.keys(obj).forEach(kvnd => {
        let kvndparts = kvnd.split('|', 2);
        let kvparts = kvndparts[0].split('/', 2);
        let k = kvparts[0];
        let v = kvparts[1];

        dict[k] = dict[k] || {};
        dict[k][v] = dict[k][v] || {};
        dict[k][v][kvnd] = sort(obj[kvnd]);

        if (dict[k][v][kvnd].tags) {
            dict[k][v][kvnd].tags = sort(obj[kvnd].tags);
        }
    });

    generateIndex(tree, dict);

    Object.keys(dict).forEach(k => {
        let entry = dict[k];
        Object.keys(entry).forEach(v => {
            generatePage(tree, dict, k, v);
        });
    });

    console.timeEnd(colors.green(tree + ' written'));
}
Example #4
0
.action( file => {
    file = path.resolve(process.cwd(), file);
    console.log(colors.green('File path:'), file);
    console.log(colors.green('Succeed to add.'));
    const err = new Error('some error info');
    console.log(colors.red(`Failed to add. err: ${err}`));
});
Example #5
0
  checkTest (test, cb) {
    if (process.platform === 'win32') {
      /* Delete \r on windows.
       * Note that process.platform is always win32 even on Windows 64 bits */
      if (typeof test.stdout !== 'undefined') { // && test.expect) {
        test.stdout = test.stdout.replace(/\r/g, '');
      }
      if (typeof test.stderr !== 'undefined') {
        test.stderr = test.stderr.replace(/\r/g, '');
      }
    }

    /* Check test output, if it's the same, the test passes */
    if (test.check === undefined) {
      if (test.expect !== undefined) {
        test.stdoutFail = (test.expect64 || test.expect64 === undefined)
          ? test.expect.trim() !== test.stdout.trim()
          : test.expect !== test.stdout;
      } else {
        test.stdoutFail = false;
      }
      test.stderrFail = test.expectErr !== undefined ? test.expectErr !== test.stderr : false;
      test.passes = !test.stdoutFail && !test.stderrFail;
    } else {
      test.check(test);
    }

    const status = (test.passes)
      ? (test.broken ? colors.yellow('[FX]') : colors.green('[OK]'))
      : (test.broken ? colors.blue('[BR]') : colors.red('[XX]'));
    this.report.total++;
    if (test.passes) {
      if (test.broken) {
        this.report.fixed++;
        this.fixed.push(test);
      } else {
        this.report.success++;
      }
    } else {
      if (test.broken) {
        this.report.broken++;
      } else {
        this.report.failed++;
      }
    }

    /* Hack to hide undefined */
    if (test.path === undefined) {
      test.path = '';
    }
    if (test.lifetime === undefined) {
      test.lifetime = '';
    }
    if ((process.env.NOOK && status !== colors.green('[OK]')) || !process.env.NOOK) {
      process.stdout.write('\x1b[0K\r' + status + ' ' + test.from + ' ' + colors.yellow(test.name) + ' ' + test.path + ' ' + test.lifetime + (this.verbose ? '\n' : '\r'));
    }
    return test.passes;
  }
Example #6
0
 fs.writeFile(path.join(config, 'config.json'), JSON.stringify(data, true, 4), function (error) {
     spinner.stop();
     if (!error) {
        console.log(colors.green(['Server: ', self.settings.server].join('')));
        console.log(colors.green(['Setup complete; You can now use ', self.name, '!'].join('')));
      } else {
        console.error('\n   Failed to write configuration file: %s\n', colors.red(error.message));
     }
 });
Example #7
0
 function bootstrapperStart () {
   log("loading", colors.green(shortname));
   delete require.cache[filename];
   session = require(filename);
   log("starting", colors.green(shortname));
   session.start().then(function () {
     log("started", colors.green(shortname));
   }).done();
 }
Example #8
0
    this.queue.awaitAll(function (err, streams) {

        console.log(colors.bgCyan("Starting pipeline"))

        if (err != null)
            return that.emit("error", "Error while opening streams: " + err);

        that.count = streams.length;
        that.emit("open", that.count, that.timeline.start.format());

        // pipe all streams
        for (var i = 0; i < streams.length; i++) {

            var count = i, stream = streams[i];

            // on any error in stream, destroy stream
            stream.on("error", function (err) {
                that.emit("error", "Error occurred in stream at idx : " + count + " : " + err);
            });

            // pipe end to stream
            if (that.end != null) {
                console.log(" | piping stream " + colors.green(that.end.name) + colors.grey(" >> ") + colors.green(stream.name));
                that.end.pipe(stream);
            }

            // assign the end to the newly piped stream
            that.end = stream;
            that._streams.push(stream);

            stream = null;
        }
        streams = null;

        // register for error event
        if (that.end == null)
            return that.emit("error", "Cannot stream, pipeline is empty");
        
        // register to end event
        that.end.on("close", function () {

            that.timeline.end = moment();
            that.meta.time = that.timeline.end.diff(that.timeline.start);

            console.log(colors.bgCyan("Pipeline finished, time taken: %s"), that.meta.time);

            that.emit("close", that.error, that.retVal, that.meta);

            // no error occurred
            if (that.error == null) {
                that.emit("end", that.retVal, that.meta);
            }
        });
    });
 function announceFinishedProcess() {
     console.log('\n');
     process.stdout.write('Finished compiling addon\n');
     console.log('');
     process.stdout.write(colors.green('Addon can be found at ' ));
     process.stdout.write(colors.cyan(path.resolve('./addons/' + npmId)));
     process.stdout.write(colors.green('.\nIn order to publish to NPM:  Navigate to the addon folder. Review the \'package.json\' file. Then run \'npm publish\'.\n'));
     process.stdout.write(colors.green('A basic descriptor for your addon was created in the file \'descriptor.json\'. Please review it and edit fields accordingly.\n'));
     process.stdout.write(colors.green('When you are ready to publish to Primo-Studio, create a pull request at '));
     process.stdout.write(colors.cyan('https://github.com/primousers/primostudio/tree/submit_here'));
     process.stdout.write(colors.green(' appending your descriptor to the \'features.json\' file.\n'));
 }
Example #10
0
  prompt.get(input, function (err, result) {

   	console.log('----------------------------------------------------------');

	console.log('Received Datas:');
    console.log('  The height is: ',colors.green(result.height));
    console.log('  The width is: ',colors.green(result.width));
    
	console.log('----------------------------------------------------------');
	console.log('Square Area: ',colors.green(result.height * result.width));
    	
   
  });
  request({url, json: true}, (err, res, body) => {
    if (err) {
      debugRequestError(colors.red('Project ') + colors.green('%s/%s') + colors.red(' is not loaded'), project.platform, project.name)
      return callback(null, {isLoaded: true})
    }
    if (res && res.statusCode !== 200) {
      debugRequestError(colors.red('Project ') + colors.green('%s/%s') + colors.red(' is not loaded') + ' Server error: %d %s', project.platform, project.name, res.statusCode, res.statusMessage)
      return callback(null, {isLoaded: true})
    }

    debugRequestSuccess('Project ' + colors.green('%s/%s') + ' loaded', project.platform, project.name)
    callback(null, body)
  })
Example #12
0
const verifyExtensiveTools = () => {
  // verify rnpm exists
  if (!Shell.which('rnpm')) {
    console.log(colors.red('This script requires rnpm to be installed.'))
    console.log(colors.green('Installing rnpm...'))
    Shell.exec('npm i -g rnpm')
  // Enforce latest rnpm -> line count of npm outdated should be zero
  } else if (!Shell.exec('npm outdated -g rnpm | wc -l | grep 0')) {
    console.log(colors.red('We depend on an updated rnpm.'))
    console.log(colors.yellow('Please update with ') + colors.green('npm i -g rnpm'))
    console.log(colors.red('Exiting!'))
    Shell.exit(1)
  }
}
Example #13
0
function printLibName() {
	console.log(colors.green("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"));
	console.log(colors.green("*                                                     *"));
	console.log(colors.green("*    ***    ****   ****   *   *  *****  ****  *   *   *"));
	console.log(colors.green("*   *       *      *      * *      *    *      * *    *"));
	console.log(colors.green("*   *  ***  ***    ***    **       *    ***     *     *"));
	console.log(colors.green("*   *   *   *      *      * *      *    *       *     *"));
	console.log(colors.green("*    ****   ****   ****   *   *  *****  *       *     *"));
	console.log(colors.green("*                                                     *"));
	console.log(colors.green("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"));
}
Example #14
0
  ].forEach(function (cache) {
    if (fs.existsSync(cache.path)) {
       var files = fs.readdirSync(cache.path);
       if (files.length >= 1) {
          console.log('   Cleared %s %s file(s).', colors.green(files.map(function (file) {
             var fpath = path.join(cache.path, file);
             return (!fs.unlinkSync(fpath) ? file : false);
          }).filter(function (file) { return file; }).length), cache.type);
        } else {
          console.log('   No %s files found.', colors.green(cache.type));
       }
     } else {
       console.log('   No %s files found.', colors.green(cache.type));
    }
 });
Example #15
0
function add(manager, name, password, enableLog) {
	var hash = Helper.password.hash(password);
	manager.addUser(name, hash, enableLog);

	log.info(`User ${colors.bold(name)} created.`);
	log.info(`User file located at ${colors.green(Helper.getUserConfigPath(name))}.`);
}
Example #16
0
  return _.map(mocks, function(source, pluginName){
    var p;
    try {
      p = require(path.resolve(source));
    } catch(er) {
      logger.log(colors.red(er.toString()));
      return;
    }

    if(!_.isFunction(p)){
      logger.log(colors.red(strings.errors.cli.MOCK_PLUGIN_IS_NOT_A_FUNCTION));
      return;
    }

    logger.log(colors.green('├── ' + pluginName + ' () => [Function]'));
    return {
      name: pluginName,
      register: {
        register: function(options, dependencies, next){
          return next();
        },
        execute: p
      }
    };
  }).filter(function(p){ return p; });
Example #17
0
  repository.getComponentVersions('oc-client', function(err, componentInfo){

    if(err){
      return logger.log(colors.red(err));
    }

    logger.log(format(colors.yellow('Ensuring oc-client@{0} is available on library...'), packageInfo.version));

    if(!_.contains(componentInfo, packageInfo.version)){

      logger.log(colors.yellow('Component not found. Publishing it...'));

      var pkgInfo = {
        outputFolder: path.resolve(__dirname, '../components/oc-client/_package'),
        packageJson: packageInfo
      };
      
      repository.publishComponent(pkgInfo, 'oc-client', packageInfo.version, function(err, res){
        if(!err){
          logger.log(colors.green('Component published.'));
        } else {
          logger.log(colors.red(format('Component not published: {0}', _.first(err).message)));
        }

        callback(err, res);
      });
    } else {
      logger.log(colors.green('Component is available on library.'));
      callback(null, 'ok');
    }
  });
Example #18
0
    solveProblem: async function () {

        var progressBar = new _progress.Bar({
            barsize: 65
        }, _progress.Presets.shades_grey);

        progressBar.start(oneMillion, 0);

        var maxChainLength = 1;
        var maxChainNumber = 2;

        for (var i = 2; i < oneMillion; i++) {
            var chain = processChain(i);

            if (chain.length > maxChainLength) {
                maxChainLength = chain.length;
                maxChainNumber = i;
            }

            progressBar.update(i);
        }

        progressBar.stop();

        console.log(colors.green(`${maxChainNumber} has the largest chain of ${maxChainLength}`));
    }
Example #19
0
    q.awaitAll(function (err, results) {
        if (err) {
            console.error(err);
            setTimeout(function () { process.exit(-1); }, 0);
            return;
        }

        results = results.slice(1, -1);

        if (process.env.UPDATE) {
            console.log('Updated ' + results.length + ' tests.');
            process.exit(0);
        }

        var passedCount = 0,
            ignoreCount = 0,
            ignorePassCount = 0,
            failedCount = 0;

        results.forEach(function (params) {
            if (params.ignored && !params.ok) {
                ignoreCount++;
            } else if (params.ignored) {
                ignorePassCount++;
            } else if (!params.ok) {
                failedCount++;
            } else {
                passedCount++;
            }
        });

        var totalCount = passedCount + ignorePassCount + ignoreCount + failedCount;

        if (passedCount > 0) {
            console.log(colors.green('%d passed (%s%)'),
                passedCount, (100 * passedCount / totalCount).toFixed(1));
        }

        if (ignorePassCount > 0) {
            console.log(colors.yellow('%d passed but were ignored (%s%)'),
                ignorePassCount, (100 * ignorePassCount / totalCount).toFixed(1));
        }

        if (ignoreCount > 0) {
            console.log(colors.white('%d ignored (%s%)'),
                ignoreCount, (100 * ignoreCount / totalCount).toFixed(1));
        }

        if (failedCount > 0) {
            console.log(colors.red('%d failed (%s%)'),
                failedCount, (100 * failedCount / totalCount).toFixed(1));
        }

        var template = handlebars.compile(fs.readFileSync(path.join(directory, 'results.html.tmpl'), 'utf8'));
        var p = path.join(directory, 'index.html');
        fs.writeFileSync(p, template({results: results}));
        console.log('Results at: ' + p);

        process.exit(failedCount === 0 ? 0 : 1);
    });
Example #20
0
gulp.task('sass', function () {
  var processors = [
        autoprefixer({browsers: [
          'last 1 version',
          'last 2 Chrome versions',
          'last 2 Firefox versions',
          'last 2 Opera versions',
          'last 2 Edge versions'
          ]})
    ];

  console.log('⬤  Run ' + colors.yellow('Sass') +
              ' + ' +
              colors.green('Autoprefixer') +
              ' + ' +
              colors.cyan('Cssnano') + ' ⬤'
              );

  return sass('src/scss/styles.scss')
    .pipe(postcss(processors))
    .pipe(gulp.dest('assets/css'))
    .pipe(reload({ stream:true }))
    .pipe(postcss([cssnano()]))
    .pipe(rename('styles.min.css'))
    .pipe(gulp.dest('assets/css'));
});
Example #21
0
exports.printCurrentBranch = function (status) {
    if (null !== status.currentBranchName) {
        return `On branch ${colors.green(status.currentBranchName)}.\n`;
    }
    return `\
On detached head ${colors.red(GitUtil.shortSha(status.headCommit))}.\n`;
};
Example #22
0
/**
 * Copies static files such as robots.txt, favicon.ico to the
 * output (build) folder.
 */
async function copy() {
  const ncp = Promise.promisify(require('ncp'));

  const watchedPaths = new Map([
    ['src/index.html', 'build/index.html'],
    ['src/images', 'build/images'],
    ['package.json', 'build/package.json'],
  ]);
  const promises = [];
  watchedPaths.forEach((dest, source) => {
    console.log('Copy %s to %s', source, dest);
    promises.push(ncp(source, dest));
  });
  await Promise.all(promises);

  replace({
    regex: '"start".*',
    replacement: '"start": "node server.js"',
    paths: ['build/package.json'],
    recursive: false,
    silent: false,
  });

  if (global.WATCH) {
    const watchPattern = Array.from(watchedPaths.keys());
    console.log('[COPY] : Watch',  colors.green(watchPattern));
    const watcher = await watch(watchPattern);
    watcher.on('changed', async (file) => {
      console.log('[COPY] : File %s changed', file);
      ncp(file, `build/${path.basename(file)}`);
    });
  }
}
Example #23
0
    q.awaitAll((err, results) => {
        if (err) {
            console.error(err);
            setTimeout(() => { process.exit(-1); }, 0);
            return;
        }

        results = results.slice(1, -1);

        if (process.env.UPDATE) {
            console.log(`Updated ${results.length} tests.`);
            process.exit(0);
        }

        let passedCount = 0,
            ignoreCount = 0,
            ignorePassCount = 0,
            failedCount = 0;

        results.forEach((params) => {
            if (params.ignored && !params.ok) {
                ignoreCount++;
            } else if (params.ignored) {
                ignorePassCount++;
            } else if (!params.ok) {
                failedCount++;
            } else {
                passedCount++;
            }
        });

        const totalCount = passedCount + ignorePassCount + ignoreCount + failedCount;

        if (passedCount > 0) {
            console.log(colors.green('%d passed (%s%)'),
                passedCount, (100 * passedCount / totalCount).toFixed(1));
        }

        if (ignorePassCount > 0) {
            console.log(colors.yellow('%d passed but were ignored (%s%)'),
                ignorePassCount, (100 * ignorePassCount / totalCount).toFixed(1));
        }

        if (ignoreCount > 0) {
            console.log(colors.white('%d ignored (%s%)'),
                ignoreCount, (100 * ignoreCount / totalCount).toFixed(1));
        }

        if (failedCount > 0) {
            console.log(colors.red('%d failed (%s%)'),
                failedCount, (100 * failedCount / totalCount).toFixed(1));
        }

        const resultsTemplate = template(fs.readFileSync(path.join(directory, 'results.html.tmpl'), 'utf8'));
        const p = path.join(directory, 'index.html');
        fs.writeFileSync(p, resultsTemplate({results: results}));
        console.log(`Results at: ${p}`);

        process.exit(failedCount === 0 ? 0 : 1);
    });
Example #24
0
				'invoke': function(session, args, callback)
			{
				//session.stdout().write(args[0] + '\n');
				console.log(colors.blue(" [*] ") + colors.red("opening mqtt shell on ") + colors.green(servername));
					shell();
				//		callback();
			}
    str   : function (err, type, split) {
        var date, ttxt, mtxt;

        date = new Date();
        date = (date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds()).toString();

        var text = date + (split ? '\r\n----------------------------------------------------------------\r\n' : ' => ');
        var strs = '', ttxt, mtxt;

        if ( 'string' === typeof err ) {
            strs = err;
        }
        else {
            strs = err.toString();
        }

        ttxt = text;
        mtxt = strs;

        if ( this.colorize ) ttxt = colr.green(ttxt);

        if ( this.colorize ) {
            if ( type === 'error' ) {
                mtxt = colr.red.bold(mtxt);
            }
            else {
                mtxt = colr.bold(mtxt);
            }
        }

        text += strs;
        ttxt += mtxt;

        return { text : text + '\r\n', color : ttxt };
    },
    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}`));
        }
    });
Example #27
0
 prompt.get(schema, function (err, result) {
   // Handle errors upon getting info
   if (err) { return onErr(err); }
   // Handle identical formats
   else if (result.formatA === result.formatB) {
     console.log(colors.yellow("unchanged value..."));
   }
   // Convert and output accordingly
   else {
     // Try Conversion, passing handling errors with onErr()
     try {
       var selection = result.formatA + result.formatB;
       var selectionLabel = options[selection].label;
       var inputValue = result.initValue;
       var outputValue = options[selection].convert(inputValue);
       var dashLine = '-'.repeat(12+selectionLabel.length);
     } catch (conversionError) {
       return onErr(conversionError);
     }
     // log result
     console.log(colors.cyan(`\n\t${dashLine}\n\tConversion: ${selectionLabel}\n\t${dashLine}\n`));
     console.log(colors.green(`\tOutput: ${outputValue}\n`));
     console.log(colors.grey(("\t\t\t('exit' to quit)")));
   }
   // Repeat prompt
   ask();
 });
Example #28
0
app.get('/login_zombie', function(req, res){
  res.setHeader('Access-Control-Allow-Origin', '*');
  console.log('|_['+colors.green('+')+'] New zombie');
  req.session.username = func.makeid();
  io.emit('listing',{zombie:req.session.username});
  res.end(req.session.username);
});
Example #29
0
app.get('/gate/:base', function(req, res){
  res.setHeader('Access-Control-Allow-Origin', '*');
  // console.log('gate');
  io.emit('new_gate', req.params.base);
  console.log('|__['+colors.green('+')+'] Received routine data');
  res.end('ok');
});
Example #30
0
 ncp(template_path, project, (err) => {
     if(err){
         console.log(err.toString());
     }else{
         console.log(colors.green('Done!'));
     }
 });