Example #1
0
var showStatus = function() {
    console.log("");

    //FILES STATUS OK
    if (messageStatusOK.length > 0) {
        console.log(colors.bgGreen(colors.white("FILES OK: " + messageStatusOK.length)));
        for (var i = 0; i < messageStatusOK.length; i++) {
            console.log(colors.green(messageStatusOK[i]));
        }
    }

    //FILES EMPTY
    if (messageEmpty.length > 0) {
        console.log(colors.bgYellow(colors.white("FILES EMPTY: " + messageEmpty.length)));
        for (var i = 0; i < messageEmpty.length; i++) {
            console.log(colors.yellow(messageEmpty[i]));
        }
    }

    //FILES  NOT CREATED
    if (messageError.length > 0) {
        console.log(colors.bgRed(colors.white("FILES NOT CREATED: " + messageError.length)));
        for (var i = 0; i < messageError.length; i++) {
            console.log(colors.red(messageError[i]));
        }
    }
};
 function get_credentials(callback) {
     prmpt.get([{
         name: 'username',
         description: colors.white(options.method === 'github' ? 'Username' : 'Email'),
         required: true
     }, {
         name: 'password',
         description: colors.white('Password'),
         hidden: true
     }], callback);
 }
Example #3
0
File: serve.js Project: prui/betta
function gulpStartup(config) {
    if (shell.which('gulp')) {
        if (config.gulpStartupTasks && config.gulpStartupTasks.length > 0) {
            var result = showGulpTasks(config.gulpStartupTasks);
            shell.exec('gulp ' + result,{async:true});
        } else {
            shell.exec('gulp');
        }
    } else {
        console.log(colors.white(getTime() + ' gulp not found.'));
        console.log(colors.white(getTime() + ' Try running: npm install -g gulp.'));
    }
}
Example #4
0
  var printLocaleDiff = function(diff, name) {
    if (diff.length > 0) {
      console.error(
        colors.white(
          'The following translations seem to be missing from \'') +
        colors.red(name) +
        colors.white('\':')
      );

      _.each(diff, function(key) {
        console.error(colors.bold.red('  \u2717 ' + key));
      });
    }
  };
Example #5
0
Logger.prototype.success = function(message, extra) {
    if ( ! this.isSilent) {
        console.log(colors.green('success: ') + message);
        if (extra)
            console.log(colors.white(this._getExtra(extra)));
    }
};
Example #6
0
Logger.prototype.info = function(message, extra) {
    if (this.isVerbose && ! this.isSilent) {
        console.info('info:    ' + message);
        if (extra)
            console.info(colors.white(this._getExtra(extra)));
    }
};
Example #7
0
Logger.prototype.error = function(message, extra) {
    if ( ! this.isSilent) {
        console.error(colors.red('error:   ') + message);
        if (extra)
            console.error(colors.white(this._getExtra(extra)));
    }
};
Example #8
0
Logger.prototype.debug = function(message, extra) {
    if ( ! this.isSilent && this.isDebug) {
        console.log(colors.cyan('debug:   ') + message);
        if (extra)
            console.log(colors.white(this._getExtra(extra)));
    }
};
Example #9
0
Logger.prototype.warning = function(message, extra) {
    if ( ! this.isSilent) {
        console.warn(colors.yellow('warning: ') + message);
        if (extra)
            console.warn(colors.white(this._getExtra(extra)));
    }
};
Example #10
0
function log (env, type, mesg) {
    if (env == 'n') {
        env = 'NET';
    } else if (env == 'w') {
        env = 'WEB';
    } else {
        env = 'SERVER';
    }

    if (type == 's') {
        type = colors.green('success:');
    } else if (type == 'i') {
        type = colors.cyan('info:');
    } else if (type == 'w') {
        type = colors.yellow('warning:');
    } else if (type == 'e') {
        type = colors.red('error:');
    } else if (type == 'd') {
        type = colors.grey('debug:');
    }

    if (typeof mesg == 'object') {
        mesg = colors.italic(colors.grey(JSON.stringify(mesg)));
    }

    console.log('  '+'['+colors.bold(colors.white(env))+'] '+colors.bold(type)+' '+mesg);
} // log
Example #11
0
 self.writeFile(data.filename, data.contents, function(err) {
   if (err) {
     //console.log(colors.red('processRequest error: ' + err));
     return;
   }
   console.log(colors.white(`File ${data.filename} written.`));
 });
 function get_otp(callback) {
     prmpt.get([{
         name: 'otp',
         description: colors.white('Authentication Code'),
         required: true
     }], callback);
 }
Example #13
0
File: serve.js Project: prui/betta
function showWatchPatterns(taskArr) {
    var str = [];
    for (var i = 0; i < taskArr.length; i++) {
        str.push(i + ' = ' + taskArr[i]);
    }
    console.log(colors.green('Watching::') + colors.white(str.join(', ')));
}
Example #14
0
exports.debug = (title, obj, status) => {
  const moment = require('moment');
  const colors = require('colors');
  const fs = require('fs');
  // this will help format the json
  const utils = require('util');

  // Time formater
  const time = moment().format('ddd, MM/Do/YY, h:mm:ssa');

  const seperator = '\n--------------\n';

  // This is the payload for the append file function
  const pkg = colors.yellow('[' + time + ']') + ' ' + colors.white(title) +
  ' ' + colors.gray(utils.format('%j', obj)) + ' ' + colors.blue(status) + seperator;

  const pkglog = '[' + time + ']' +
  ' ' + title + ' ' + utils.format('%j', obj) + status + seperator;

  // if developer passes DEBUG=true it will show logging and will save to log file.
  if (process.env.DEBUG) {
    // using the file system to append to existing file with a flage of append.
    // passing in the package string.
    console.log(pkg);
    fs.appendFile('logs/logfile.log', pkglog, { flags: 'a' }, (err) => {
      if (err) throw err;
    });
  }
};
Example #15
0
function failed(expected, actual, index, equation, reason) {
  var output = colors.bold.red('\nTest %s: Failed --- %s\n');
  output += colors.white('\tFor equation: %s\n');
  output += colors.yellow('\tExpected: %s\n');
  output += colors.red('\tActual: %s\n');

  console.log(output, index, reason, equation, expected, actual);
}
Example #16
0
var cleanNodeModules = function(next) {
  var spinner = makeSpinner(' %s ' + colors.white('Cleaning old node packages'));

  rimraf('./node_modules', {}, function() {
    stopSpinner(spinner);
    next();
  });
};
Example #17
0
File: serve.js Project: prui/betta
function showGulpTasks(taskArr) {
    var str = [];
    var task = '';
    for (var i = 0; i < taskArr.length; i++) {
        str.push(i + ' = ' + taskArr[i]);
        task += taskArr[i] + ' ';
    }
    console.log(colors.green('Gulp startup tasks:') + colors.white(str.join(', ')));
    return task;
}
Example #18
0
DiffWatchUtils.info = function(m)
{
  if (arguments.length > 1)
  {
    m = Array.prototype.slice.call(arguments);
  }

  if (util.isArray(m))
    m = m.join(' ');

    util.log(colors.white(m));
  }
Example #19
0
var installPackages = function(title, packages, flag, next) {
  var command = 'npm install ' + flag + ' ' + packages.join(' ');
  var spinner = makeSpinner(' %s ' + colors.white(title));

  var installation = exec(command, function(err, stdout, stderr) {
    stopSpinner(spinner);
    if (err) throw err;
    // console.log(String(stdout));
    // console.log(colors.red(String(stderr)));
    next();
  });
};
Example #20
0
 this.trace = function (msg, level) {
     if (Utils.isError(msg)) {
         this.trace(msg.message, 'error');
         return false;
     }
     if (lodash.isPlainObject(msg)) {
         msg = Utils.inspect(msg, {
             depth: 0,
             colors: true,
             showHidden: true
         });
     }
     var m;
     switch (level) {
     case 'log':
         m = colors.white(msg);
         break;
     case 'debug':
         m = colors.grey('DEBUG: ' + msg);
         break;
     case 'info':
         m = colors.green('INFO: ' + msg);
         break;
     case 'warn':
         m = colors.yellow('WARN: ' + msg);
         break;
     case 'error':
         m = colors.red.bold('ERROR: ' + msg);
         break;
     case 'fatal':
         m = colors.magenta('FATAL: ' + msg);
         break;
     case 'head':
         m = colors.green.bold(msg);
         break;
     case 'subhead':
         m = colors.grey.bold(msg);
         break;
     case 'ok':
         m = colors.green.bold('>> ') + colors.green(msg);
         break;
     case 'nok':
         m = colors.red.bold('>> ') + colors.red(msg);
         break;
     }
     console.log(m);
     return true;
 };
Example #21
0
export default async()=>{
  try{
    const date = getNowDateString();

    console.log(colors.white('Time : ' + date ));
    console.log(colors.green('WORKER ROUTINE START'));

    await DeviceRoutine(await GetRooms());

    console.log(colors.green('WORKER ROUTINE END'));
    console.log();
  }catch(e){
    console.log(colors.red(e));
    console.log();
  }
};
Example #22
0
module.exports = function(command, data, title, screen) {

    var lines = [];

    var barTypes = [screen.cci.codes.block_whole, screen.cci.codes.block_faded_min, screen.cci.codes.block_faded_mid, screen.cci.codes.block_faded_max]

    var ccolours = ['cyan', 'green', 'red', 'yellow', 'blue', 'magenta'];

    var parts = [];

    /**
     * get keys
     */
    var keys = [];

    if (data.length > 0) {

        keys = Object.keys(data[0]);
    } else {
        lines.push("No Results");
        lines.push("");
        return lines;
    }

    /**
     * Get sections
     */

    var sections = [];

    for (var k = 0; k < data.length; k++) {

        if (sections.indexOf(data[k][keys[0]]) === -1) {
            sections.push(data[k][keys[0]]);
        }

    }

    sections.sort();

    for (var s = 0; s < sections.length; s++) {

        var sum = 0;

        for (var k = 0; k < data.length; k++) {

            if (data[k][keys[0]] !== sections[s]) continue;

            sum += data[k][keys[2]]

            if (parts.indexOf(data[k][keys[1]]) === -1) {
                parts.push(data[k][keys[1]])
            }

        }

        lines.push(colors.white(title + " - " + sections[s]))

        for (var q = 0; q < screen.settings.barHeight; q++) {
            var dataLine = "";

            for (var k = 0; k < data.length; k++) {

                if (data[k][keys[0]] !== sections[s]) continue;

                var width = Math.floor(global.censql.graphWidth * data[k][keys[2]] / sum);

                dataLine += colors[ccolours[parts.indexOf(data[k][keys[1]])]](new Array(width).join(barTypes[parts.indexOf(data[k][keys[1]]) % 4]));

            }

            lines.push(dataLine);
        }

        lines.push("");

    }

    for (var k = 0; k < parts.length; k++) {

        if(parts[k] == "hidden") continue;

        lines.push("- " + colors[ccolours[k]](parts[k]))
    }

    return lines;
}
Example #23
0
 info: function ( msg ) {
     return colors.white( msg );
 }
        callback: function(options) {
            prmpt.message = '';
            prmpt.delimiter = colors.white(':');
            prmpt.start();

            function get_credentials(callback) {
                prmpt.get([{
                    name: 'username',
                    description: colors.white(options.method === 'github' ? 'Username' : 'Email'),
                    required: true
                }, {
                    name: 'password',
                    description: colors.white('Password'),
                    hidden: true
                }], callback);
            }

            function get_otp(callback) {
                prmpt.get([{
                    name: 'otp',
                    description: colors.white('Authentication Code'),
                    required: true
                }], callback);
            }

            function authenticate(auth, method, callback) {
                const request_options = {
                    url: `${constants.environment.AUTH_API_BASE_URL}/v1/authenticate/${method}/authorization`,
                    method: 'POST'
                };

                if(method === 'github') {
                    request_options.json = {
                        authorization: auth.token
                    };
                } else if(method === 'bitbucket') {
                    request_options.json = auth;
                }

                request(request_options, (err, response) => {
                    if(err || response.statusCode != 201) {
                        return callback(new Error('Error generating ContainerShip auth token'));
                    } else{
                        config.load();

                        if(_.isUndefined(config.config.headers)) {
                            config.config.headers = {};
                        }

                        config.config.headers.authorization = `Bearer ${response.body.token}`;
                        if(response.body.organization) {
                            config.config.headers['x-containership-cloud-organization'] = response.body.organization.id;
                        }

                        config.set(config.config);
                        return callback();
                    }
                });
            }

            get_credentials((err, credentials) => {
                function github_authorize(otp, callback) {
                    if(_.isFunction(otp)) {
                        callback = otp;
                        otp = undefined;
                    }

                    github.authorize(otp, callback);
                }

                if(err) {
                    process.stderr.write(`${err.message}\n`);
                    process.exit(1);
                }

                if(options.method === 'github') {

                    github.authenticate(credentials);

                    github.get_user((err) => {
                        if(err && err.headers && err.headers['x-github-otp']) {
                            get_otp((err, credentials) => {
                                if(err) {
                                    process.stderr.write(`${err.message}\n`);
                                    process.exit(1);
                                }

                                github_authorize(credentials.otp, (err, auth) => {
                                    if(err) {
                                        process.stderr.write(`${err.message}\n`);
                                        process.exit(1);
                                    }

                                    authenticate(auth, options.method, (err) => {
                                        if(err) {
                                            process.stderr.write(`${err.message}\n`);
                                            process.exit(1);
                                        } else{
                                            process.stdout.write(colors.green('\nSuccessfully logged in!\n'));
                                        }
                                    });
                                });
                            });
                        } else if(err) {
                            process.stderr.write(`${err.message}\n`);
                            process.exit(1);
                        } else{
                            github_authorize((err, auth) => {
                                if(err) {
                                    process.stderr.write(`${err.message}\n`);
                                    process.exit(1);
                                }

                                authenticate(auth, options.method, (err) => {
                                    if(err) {
                                        process.stderr.write(`${err.message}\n`);
                                        process.exit(1);
                                    } else{
                                        process.stdout.write(colors.green('\nSuccessfully logged in!\n'));
                                    }
                                });
                            });
                        }
                    });
                } else if(options.method === 'bitbucket') {
                    authenticate(credentials, options.method, (err) => {
                        if(err) {
                            process.stderr.write(`${err.message}\n`);
                            process.exit(1);
                        } else{
                            process.stdout.write(colors.green('\nSuccessfully logged in!\n'));
                        }
                    });
                } else{
                    process.stderr.write(`Not a recognized login method.\n`);
                    process.exit(1);
                }
            });
        }
Example #25
0
 outStream.on('data', function (chunk) {
   process.stdout.write(colors.white(chunk.toString()))
 })
Example #26
0
    return function(file, options) {
        var reference, images,
            retina, filePath,
            url, image, meta, basename,
            makeRegexp, content;

        content = file.contents.toString();

        images = [];

        basename = path.basename(file.path);

        makeRegexp = (function() {
            var matchOperatorsRe = /[|\\/{}()[\]^$+*?.]/g;

            return function(str) {
                return str.replace(matchOperatorsRe,  '\\$&');
            }
        })();

        while ((reference = imageRegex.exec(content)) != null) {
            url   = reference[1];
            meta  = reference[2];

            image = {
                replacement: new RegExp('background-image:\\s+url\\(\\s?(["\']?)\\s?' + makeRegexp(url) + '\\s?\\1\\s?\\)[^;]*\\;', 'gi'),
                url:         url,
                group:       [],
                isRetina:    false,
                retinaRatio: 1,
                meta:        {}
            };

            if (httpRegex.test(url)) {
                options.verbose && log(colors.cyan(basename) + ' > ' + url + ' has been skipped as it\'s an external resource!');
                continue;
            }

            if (!pngRegex.test(url)) {
                options.verbose && log(colors.cyan(basename) + ' > ' + url + ' has been skipped as it\'s not a PNG!');
                continue;
            }

            if (meta) {
                try {
                    meta = JSON.parse(meta);
                    meta.sprite && (image.meta = meta.sprite);
                } catch (err) {
                    log(colors.cyan(basename) + ' > ' + colors.white('Can not parse meta json for ' + url) + ': "' + colors.red(err) + '"');
                }
            }

            if (options.retina && (retina = retinaRegex.exec(url))) {
                image.isRetina = true;
                image.retinaRatio = retina[1];
            }

            filePath = filePathRegex.exec(url)[0].replace(/['"]/g, '');

            // if url to image is relative
            if(filePath.charAt(0) === "/") {
                filePath = path.resolve(options.baseUrl + filePath);
            } else {
                filePath = path.resolve(file.path.substring(0, file.path.lastIndexOf(path.sep)), filePath);
            }

            image.path = filePath;

            // reset lastIndex
            [httpRegex, pngRegex, retinaRegex, filePathRegex].forEach(function(regex) {
                regex.lastIndex = 0;
            });

            images.push(image);
        }

        // reset lastIndex
        imageRegex.lastIndex = 0;

        // remove nulls and duplicates
        images = _.chain(images)
            .filter()
            .unique(function(image) {
                return image.path;
            })
            .value();

        return Q(images)
            // apply user filters
            .then(function(images) {
                return Q.Promise(function(resolve, reject) {
                    async.reduce(
                        options.filter,
                        images,
                        function(images, filter, next) {
                            async.filter(
                                images,
                                function(image, ok) {
                                    Q(filter(image)).then(ok);
                                },
                                function(images) {
                                    next(null, images);
                                }
                            );
                        },
                        function(err, images) {
                            if (err) {
                                return reject(err);
                            }

                            resolve(images);
                        }
                    );
                });
            })
            // apply user group processors
            .then(function(images) {
                return Q.Promise(function(resolve, reject) {
                    async.reduce(
                        options.groupBy,
                        images,
                        function(images, groupBy, next) {
                            async.map(images, function(image, done) {
                                Q(groupBy(image))
                                    .then(function(group) {
                                        if (group) {
                                            image.group.push(group);
                                        }

                                        done(null, image);
                                    })
                                    .catch(done);
                            }, next);
                        },
                        function(err, images) {
                            if (err) {
                                return reject(err);
                            }

                            resolve(images);
                        }
                    );
                });
            });
    }
Example #27
0
 log: function() {
     var args = Array.prototype.slice.call(arguments);
     args.unshift(colors.white(plotDate(), "[LOG]"));
     console.log.apply(console, args);
 },
Example #28
0
 /**
  * when a new test suite is started
  *
  * @param      {Object}  suite   The suite
  */
 onSuite (suite) {
   console.log(`\n${colors.white(suite.title)}`)
 }