Exemple #1
0
Server.prototype._printPin = function(pin) {
  console.log("Or enter this code with your HomeKit app on your iOS device to pair with Homebridge:");
  console.log(chalk.black.bgWhite("                       "));
  console.log(chalk.black.bgWhite("    ┌────────────┐     "));
  console.log(chalk.black.bgWhite("    │ " + pin + " │     "));
  console.log(chalk.black.bgWhite("    └────────────┘     "));
  console.log(chalk.black.bgWhite("                       "));
}
Exemple #2
0
export default async(request, keyword, artists) => {
    debug(chalk.black.bgGreen('💊  Loaded Xiami music.'));

    try {
        var response = await request({
            uri: 'http://api.xiami.com/web',
            qs: {
                v: '2.0',
                key: [keyword].concat(artists.split(',')).join('+'),
                limit: 100,
                page: 1,
                r: 'search/songs',
                app_key: 1,
            },
            json: true,
            headers,
        });

        var data = response.data;

        if (response.state !== 0
            || data.songs.length === 0) {
            error(chalk.black.bgRed('🚧  Nothing.'));
            return Promise.reject(Error(404));
        }

        for (let e of data.songs) {
            if (
                artists.split(',').findIndex(
                    artist => e.artist_name.indexOf(artist) !== -1
                ) === -1
            ) {
                continue;
            }

            let song = e;

            song.src = e.listen_file;

            if (!song.src) {
                return Promise.reject(Error(404));
            } else {
                debug(chalk.black.bgGreen('🚚  Result >>>'));
                debug(e);
                debug(chalk.black.bgGreen('🚚  <<<'));

                return song;
            }
        }
    } catch (ex) {
        error('Failed to get song: %O', ex);
        return Promise.reject(ex);
    }

    error(chalk.black.bgRed('🈚  Not Matched.'));
    return Promise.reject(Error(405));
};
Exemple #3
0
 return __generator(this, function (_a) {
     switch (_a.label) {
         case 0:
             connection = undefined;
             _a.label = 1;
         case 1:
             _a.trys.push([1, 7, , 10]);
             connectionOptionsReader = new ConnectionOptionsReader_1.ConnectionOptionsReader({ root: process.cwd(), configName: argv.config });
             return [4 /*yield*/, connectionOptionsReader.get(argv.connection)];
         case 2:
             connectionOptions = _a.sent();
             Object.assign(connectionOptions, {
                 subscribers: [],
                 synchronize: false,
                 migrationsRun: false,
                 dropSchema: false,
                 logging: ["schema"]
             });
             return [4 /*yield*/, index_1.createConnection(connectionOptions)];
         case 3:
             connection = _a.sent();
             if (!connection.queryResultCache)
                 return [2 /*return*/, console.log(chalk.black.bgRed("Cache is not enabled. To use cache enable it in connection configuration."))];
             return [4 /*yield*/, connection.queryResultCache.clear()];
         case 4:
             _a.sent();
             console.log(chalk.green("Cache was successfully cleared"));
             if (!connection) return [3 /*break*/, 6];
             return [4 /*yield*/, connection.close()];
         case 5:
             _a.sent();
             _a.label = 6;
         case 6: return [3 /*break*/, 10];
         case 7:
             err_1 = _a.sent();
             if (!connection) return [3 /*break*/, 9];
             return [4 /*yield*/, connection.close()];
         case 8:
             _a.sent();
             _a.label = 9;
         case 9:
             console.log(chalk.black.bgRed("Error during cache clear:"));
             console.error(err_1);
             process.exit(1);
             return [3 /*break*/, 10];
         case 10: return [2 /*return*/];
     }
 });
			it('should listen to device change', function(done) {
				console.log(chalk.black.bgCyan('Add/Insert or Remove a USB device'));
				once('change')
					.then(function(device) {
						testDeviceShape(device);
					})
					.then(done)
					.catch(done.fail);
			}, MANUAL_INTERACTION_TIMEOUT);
Exemple #5
0
const print = (level, ...args) => {
  let method = PRINT_LEVELS[level]

  if (!method) {
    args = [level].concat(args)
    method = PRINT_LEVELS.info
  }

  console.log(chalk.black.bgWhite('[botpress]'), '\t', method(...args))
}
const formatTypeaheadSelection = (
  item: string,
  index: number,
  activeIndex: number,
  prompt: Prompt,
) => {
  if (index === activeIndex) {
    prompt.setTypheadheadSelection(chalk.stripColor(item));
    return chalk.black.bgYellow(chalk.stripColor(item));
  }
  return item;
};
function logDevelopment() {
  const str = `
  ########  ######## ##     ##
  ##     ## ##       ##     ##
  ##     ## ##       ##     ##
  ##     ## ######   ##     ##
  ##     ## ##        ##   ##
  ##     ## ##         ## ##
  ########  ########    ###
  `;
  console.log(chalk.black.bgYellow(str));
}
Exemple #8
0
	}, function(err, environmentFiles) {
		if (!environmentFiles.length) {
			if (process.env.NODE_ENV) {
				console.error(chalk.red('No configuration file found for "' + process.env.NODE_ENV + '" environment using development instead'));
			} else {
				console.error(chalk.red('NODE_ENV is not defined! Using default development environment'));
			}

			process.env.NODE_ENV = 'development';
		} else {
			console.log(chalk.black.bgWhite('Application loaded using the "' + process.env.NODE_ENV + '" environment configuration'));
		}
	});
Exemple #9
0
export default async(request, keyword, artists, isFlac) => {
    debug(chalk.black.bgGreen('💊  Loaded QQ music.'));

    rp = request;

    try {
        var response = await rp({
            uri: 'http://c.y.qq.com/soso/fcgi-bin/search_cp',
            qs: {
                w: [keyword].concat(artists.split(',')).join('+'),
                p: 1,
                n: 100,
                aggr: 1,
                lossless: 1,
                cr: 1,
                format: 'json',
                inCharset: 'utf8',
                outCharset: 'utf-8'
            },
        });

        var data = response.data;

        if (response.code !== 0
            || data.song.list.length === 0) {
            error(chalk.black.bgRed('🚧  Nothing.'));
            return Promise.reject(Error(404));
        }

        for (let e of data.song.list) {
            let song = {};

            // Match the artists
            if (e.singer.find(e => artists.indexOf(e.name) === -1)) {
                continue;
            }

            song = await getSong(e.media_mid, isFlac);

            if (!song.src) {
                error(chalk.black.bgRed('🚧  Nothing.'));
                return Promise.reject(Error(404));
            }

            debug(chalk.black.bgGreen('🚚  Result >>>'));
            debug(e);
            debug(chalk.black.bgGreen('🚚  <<<'));

            return song;
        }
    } catch (ex) {
        error('Failed to get song: %O', ex);
        return Promise.reject(ex);
    }

    error(chalk.black.bgRed('🈚  Not Matched.'));
    return Promise.reject(Error(405));
};
Exemple #10
0
  this._detector.on('end', function(numFiles) {
    var summary, files;
    files = (numFiles > 1) ? 'files' : 'file';

    if (!self._found) {
      summary = chalk.black.bgGreen("\n No magic numbers found across " +
        numFiles + ' ' + files);
    } else {
      summary = chalk.bgRed("\n " + self._found +
        " magic numbers found across " + numFiles + ' ' + files);
    }

    process.stdout.write(summary + "\n");
  });
Exemple #11
0
  this._detector.on('end', function(numFiles) {
    var summary, files, numbers;
    files = (numFiles > 1) ? 'files' : 'file';
    numbers = (self._found > 1) ? 'numbers' : 'number';

    if (!self._found) {
      summary = chalk.black.bgGreen(util.format(
        "\n No magic numbers found across %d %s", numFiles, files));
    } else {
      summary = chalk.bgRed(util.format("\n %d magic %s found across %d %s",
        self._found, numbers, numFiles, files));
    }

    process.stdout.write(summary + "\n");
  });
Exemple #12
0
 return __generator(this, function (_a) {
     switch (_a.label) {
         case 0:
             connection = undefined;
             _a.label = 1;
         case 1:
             _a.trys.push([1, 6, , 9]);
             connectionOptionsReader = new ConnectionOptionsReader_1.ConnectionOptionsReader({ root: process.cwd(), configName: argv.config });
             return [4 /*yield*/, connectionOptionsReader.get(argv.connection)];
         case 2:
             connectionOptions = _a.sent();
             Object.assign(connectionOptions, {
                 subscribers: [],
                 synchronize: false,
                 migrationsRun: false,
                 dropSchema: false,
                 logging: ["query", "error", "schema"]
             });
             return [4 /*yield*/, index_1.createConnection(connectionOptions)];
         case 3:
             connection = _a.sent();
             options = {
                 transaction: argv["t"] === "false" ? false : true
             };
             return [4 /*yield*/, connection.runMigrations(options)];
         case 4:
             _a.sent();
             return [4 /*yield*/, connection.close()];
         case 5:
             _a.sent();
             // exit process if no errors
             process.exit(0);
             return [3 /*break*/, 9];
         case 6:
             err_1 = _a.sent();
             if (!connection) return [3 /*break*/, 8];
             return [4 /*yield*/, connection.close()];
         case 7:
             _a.sent();
             _a.label = 8;
         case 8:
             console.log(chalk.black.bgRed("Error during migration run:"));
             console.error(err_1);
             process.exit(1);
             return [3 /*break*/, 9];
         case 9: return [2 /*return*/];
     }
 });
  }], (err, result) => {
    if (err) return callback(err);

    if (result.value < valueToGuess) {
      console.log(chalk.red('Too small !'));
      return tryAgain(null, false);
    }
    else if (result.value > valueToGuess) {
      console.log(chalk.red('Too big !'));
      return tryAgain(null, false);
    }
    else {
      console.log(chalk.black.bgYellow('You won !'));
      return true;
    }
  });
function exec( cmd, args, fn, skip ) {
	if ( dryrun || skip ) {
		log( chalk.black.bgBlue( "# " + cmd + " " + args.join( " " ) ) );
		fn();
	} else {
		log( chalk.green( cmd + " " + args.join( " " ) ) );
		child.execFile( cmd, args, { env: process.env },
			function( err, stdout, stderr ) {
				if ( err ) {
					die( stderr || stdout || err );
				}
				fn();
			}
		);
	}
}
module.exports = function() {
	/**
	 * Before we begin, lets set the environment variable
	 * We'll Look for a valid NODE_ENV variable and if one cannot be found load the development NODE_ENV
	 */

	var environmentFiles = glob.sync('./config/env/' + process.env.NODE_ENV + '.js');
	if (!environmentFiles.length) {
		if (process.env.NODE_ENV) 
			console.error(chalk.red('No configuration file found for "' + process.env.NODE_ENV + '" environment using development instead'));
		else{
			console.error(chalk.red('NODE_ENV is not defined! Using default development environment'));
			process.env.NODE_ENV = 'development';
		}
	} 
	else console.log(chalk.black.bgWhite('Application loaded using the "' + process.env.NODE_ENV + '" environment configuration'));
};
Exemple #16
0
  this._inspector.on('end', function() {
    var summary, files, match, numFiles;

    numFiles = self._inspector.numFiles;
    files = (numFiles > 1) ? 'files' : 'file';
    matches = (self._found > 1) ? 'matches' : 'match';

    if (!self._found) {
      summary = chalk.black.bgGreen(util.format(
        '\n No matches found across %d %s', numFiles, files));
    } else {
      summary = chalk.bgRed(util.format('\n %d %s found across %d %s',
        self._found, matches, numFiles, files));
    }

    process.stdout.write(summary + '\n');
  });
  writing() {
    this.log(chalk.black.bgGreen('Update package.json to add plop commands.'));

    this.fs.extendJSON(
      'package.json',
      {
        scripts: {
          generate: 'plop --plopfile scripts/generators/index.js',
        }
      },
      null,
      2
    );

    this.fs.copyTpl(
      this.templatePath('scripts'),
      this.destinationPath('scripts'),
    );
  }
 return tslib_1.__generator(this, function (_a) {
     switch (_a.label) {
         case 0:
             if (args._[0] === "migrations:create") {
                 console.log("'migrations:create' is deprecated, please use 'migration:create' instead");
             }
             _a.label = 1;
         case 1:
             _a.trys.push([1, 7, , 8]);
             timestamp = new Date().getTime();
             fileContent = MigrationCreateCommand.getTemplate(args.name, timestamp);
             filename = timestamp + "-" + args.name + ".ts";
             directory = args.dir;
             if (!!directory) return [3 /*break*/, 5];
             _a.label = 2;
         case 2:
             _a.trys.push([2, 4, , 5]);
             connectionOptionsReader = new ConnectionOptionsReader_1.ConnectionOptionsReader({ root: process.cwd(), configName: args.config });
             return [4 /*yield*/, connectionOptionsReader.get(args.connection)];
         case 3:
             connectionOptions = _a.sent();
             directory = connectionOptions.cli ? connectionOptions.cli.migrationsDir : undefined;
             return [3 /*break*/, 5];
         case 4:
             err_1 = _a.sent();
             return [3 /*break*/, 5];
         case 5:
             path = process.cwd() + "/" + (directory ? (directory + "/") : "") + filename;
             return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(path, fileContent)];
         case 6:
             _a.sent();
             console.log("Migration " + chalk.blue(path) + " has been generated successfully.");
             return [3 /*break*/, 8];
         case 7:
             err_2 = _a.sent();
             console.log(chalk.black.bgRed("Error during migration creation:"));
             console.error(err_2);
             process.exit(1);
             return [3 /*break*/, 8];
         case 8: return [2 /*return*/];
     }
 });
Exemple #19
0
	app.post('/api/friends', function(req, res) {
		console.log(chalk.black.bgYellow('POST \n/api/friends'));
		var friend = req.body;
		var closes = 60;
		console.log(friends);
		console.log(friend);
		friends.map(function(item, index) {
			var difference = 0;
			item.scores.forEach(function(score, index) {
				difference += Math.abs(parseInt(score) - parseInt(friend.scores[index]));
			})
			if(closes > difference) {
				closes = difference 
				match = index;
			}
			console.log(difference, ' - ', match);
		})
		friends.push(friend);
		res.send(friends[match]);
	});
Generator.prototype.lemonSync = function lemonSync() {

    var done = this.async();
    var that = this;

    console.log('\n\n' +
        chalk.black.bgYellow('Installing your lemony theme!') +
        '\n');

    var lemonsync = spawn('lemonsync', ['--config=' + path.join(that.conf.get('themeFolder'), '../' + that.configFile), '--reset=local']);
    lemonsync.stdin.setEncoding = 'utf-8';
    lemonsync.stdout.on('data', function(data) {
        var str = data.toString();
        var lines = str.split(/(\r?\n)/g);
        console.log(str);

        for (var i = 0; i < lines.length; i++) {
            if (lines[i].match(/(LemonSync is listening to changes)/m)) {
                lemonsync.kill();
            }
        }
    });

    lemonsync.stdout.on('end', function() {
        console.log('\n' +
            chalk.black.bgYellow('Sync complete.') +
            '\n\n');
        done();
    });

    lemonsync.on('exit', function(code) {
        // console.log('lemonsync exit');
    });

    lemonsync.on('error', function(err) {
        console.log('error: ' + err);
    });

    // Say [Y]es!
    lemonsync.stdin.write("Y\n");
};
Exemple #21
0
setInterval(() => {
  if(LiveData.length > 0) {
    let deps = [];

    // console.log(LiveData.departures);

    LiveData.departures.map((dep) => {
      deps.push(` ${chalk.white.bgRed(dep.route.paddingLeft("   ")+" ")} in ${dep.arrivingIn.paddingLeft("  ")} minutes to ${dep.station}\n`);
    });


    tmpl = `
 ${chalk.black.bgWhite(`From ${LiveData.station}`)}  Last refresh: ${moment(LastRefresh).format('HH:mm:ss')}
- - - - - - - - - - - - - - - - - - - - - - - - - - -
${deps.join('')} - - - - - - - - - - - - - - - - - - - - - - - - - - -
`;
  } else {
    tmpl = `
    Loading...
    `;
  }
  logUpdate(tmpl);
},100);
 return tslib_1.__generator(this, function (_a) {
     switch (_a.label) {
         case 0:
             _a.trys.push([0, 6, , 7]);
             fileContent = SubscriberCreateCommand.getTemplate(args.name);
             filename = args.name + ".ts";
             directory = args.dir;
             if (!!directory) return [3 /*break*/, 4];
             _a.label = 1;
         case 1:
             _a.trys.push([1, 3, , 4]);
             connectionOptionsReader = new ConnectionOptionsReader_1.ConnectionOptionsReader({ root: process.cwd(), configName: args.config });
             return [4 /*yield*/, connectionOptionsReader.get(args.connection)];
         case 2:
             connectionOptions = _a.sent();
             directory = connectionOptions.cli ? connectionOptions.cli.subscribersDir : undefined;
             return [3 /*break*/, 4];
         case 3:
             err_1 = _a.sent();
             return [3 /*break*/, 4];
         case 4:
             path = process.cwd() + "/" + (directory ? (directory + "/") : "") + filename;
             return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(path, fileContent)];
         case 5:
             _a.sent();
             console.log(chalk.green("Subscriber " + chalk.blue(path) + " has been created successfully."));
             return [3 /*break*/, 7];
         case 6:
             err_2 = _a.sent();
             console.log(chalk.black.bgRed("Error during subscriber creation:"));
             console.error(err_2);
             process.exit(1);
             return [3 /*break*/, 7];
         case 7: return [2 /*return*/];
     }
 });
Exemple #23
0
 get timestamp() {
     return chalk.black.bgWhite(` ${moment().tz('Canada/Mountain').format('MM/DD HH:mm:ss')} `);
 }
Exemple #24
0
#!/usr/bin/env node --harmony
var chalk = require('chalk');

var output = [
    chalk.bold('bold'),
    chalk.dim('dim'),
    chalk.italic('italic'),
    chalk.inverse('inverse'),
    chalk.strikethrough('strikethrough'),
    chalk.black('black'),
    chalk.red('red'),
    chalk.green('green'),
    chalk.yellow('yellow'),
    chalk.blue('blue'),
    chalk.magenta('magenta'),
    chalk.cyan('cyan'),
    chalk.white('white'),
    chalk.gray('gray'),
    chalk.bgBlack('bgBlack'),
    chalk.black.bgRed('bgRed'),
    chalk.black.bgGreen('bgGreen'),
    chalk.black.bgYellow('bgYellow'),
    chalk.bgBlue('bgBlue'),
    chalk.black.bgMagenta('bgMagenta'),
    chalk.black.bgCyan('bgCyan'),
    chalk.black.bgWhite('bgWhite')
].join('\n');

console.log(output);
Exemple #25
0
var chalk = require('chalk');

module.exports =
chalk.red.bold('\n**********************************************************') +
chalk.red('\n        _    _   _   _      ____   _____   _    _  ' +
'\n       | |  | | | | | |    |  __| |  _  | | \\  | |  ' +
'\n       | |  | | | | | |    | |__  | | | | |  \\ | |  ' +
'\n       | |  | | | | | |    |__  | | | | | |   \\| |  ' +
'\n       |  /\\  | | | | |__   __| | | |_| | | |\\   |  ' +
'\n       |_/  \\_| |_| |____| |____| |_____| |_| \\__|  ' +
'\n                                                          ') +
'\n                                                          ' +
chalk.red.bold('\n        *****************************************') +
chalk.red.bold('\n        *') + chalk.black.bold('   S E R V I C E - G E N E R A T O R   ') + chalk.red.bold('*') +
chalk.red.bold('\n**********************************************************');
Exemple #26
0
import chalk from 'chalk';
import moment from 'moment';
import readlineSync from 'readline-sync';
import logUpdate from 'log-update';
import LoadData from './utils/loadData';

// Clear CLI
process.stdout.write("\u001b[2J\u001b[0;0H");
// Print a header
console.log(
  chalk.black.bgYellow('                    MVG                     ')
);

let startStation = undefined;

if(process.argv && process.argv[2]) {
  startStation = process.argv[2];
} else {
  startStation = readlineSync.question('From what station do you want to start? : ')
}

console.log(
  chalk.yellow(`Show all trips from ${chalk.yellow.underline(startStation)}`)
);

let LiveData = [];
let LastRefresh = +new Date()

const updateData = () => {
  LoadData({
    station: startStation
	.define(() => {
		drinkbar.log(chalk.black.bgGreen('Please run `gulp build` or `gulp serve`.'))
	})
function status( msg ) {
	console.log( chalk.black.bgGreen( msg ) );
}
 lemonsync.stdout.on('end', function() {
     console.log('\n' +
         chalk.black.bgYellow('Sync complete.') +
         '\n\n');
     done();
 });
Exemple #30
0
	app.get('/api/friends', function(req, res) {
		console.log(chalk.black.bgYellow('GET \n/api/friends'));
		res.send(friends);
	});