示例#1
0
文件: cli.js 项目: msvbg/pom
export const helpText = (function () {
    let commands = [
        {
            name: 'pom',
            description: '',
            parameters: [
                {
                    name: '--no-sounds',
                    description: 'Disables all sound notifications.'
                },
                {
                    name: '--no-notifications',
                    description: 'Disables all OS notifications.'
                }
            ]
        },
        {
            name: 'pom start [<name>]',
            description:
                'Starts a pomodoro timer. If a name is given, creates ' +
                'a public pom group with the given name.',
            parameters: [
                {
                    name: '--schedule=<format>',
                    description:
                        'Sets the schedule of the pomodoro. Schedules are ' +
                        'provided in the format of work durations in minutes ' +
                        'followed by break durations in minutes, separated ' +
                        'by dashes. For example, the standard schedule is ' +
                        '25-5-25-5-25-5-25-35.'
                },
                {
                    name: '--start-time=<time>',
                    description:
                        'Specifies that the timer should be started relative ' +
                        'a specific time of the day, regardless of the ' +
                        'current time. The format is <hhmm> in the 24-hour ' +
                        'clock, so 1900 means 7 PM.'
                },
                {
                    name: '--timezone=<timezone>',
                    description:
                        'Specifies the timezone that --start-time is ' +
                        'given in.'
                }
            ]
        },
        {
            name: 'pom connect <name>',
            description: 'Connects to the public pom group of the given name.',
            parameters: []
        },
        {
            name: 'pom serve',
            description: 'Starts a pom server. Currently for internal use only.',
            parameters: []
        },
        {
            name: 'pom help',
            description: 'Displays this help text.',
            parameters: []
        }
    ];

    let introduction =
        `${chalk.bold('pom')} is a tool for synchronizing your work schedule ` +
        'with others. By starting your pomodoro cycles in phase with other ' +
        'people you work with, you can take breaks at the same time and ' +
        'never risk disrupting each other while in "the zone."\n\n' +

        `${chalk.bold('pom')} is also an excellent tool for solo usage, in ` +
        'case normal timers aren\'t geeky enough for you.\n\n';

    let formatCommandName = name => chalk.green(_.padRight(name, 32));
    let formatParamName = param => '    ' + chalk.blue(_.padRight(param, 28));
    let formatDescription = breakLines;

    let commandHelp = commands.map(command =>
        formatCommandName(command.name) +
        formatDescription(command.description) +
        '\n\n' +

        command.parameters.map(param =>
            formatParamName(param.name) +
            formatDescription(param.description) +
            '\n\n'
        ).join('')

    ).join('');

    return (
        breakLines(introduction, 74, 4, true) +
        chalk.bold.white('Help\n') +
        commandHelp
    );
})();
示例#2
0
            this.config.set('consoleOptions', this.consoleOptions);
            this.config.set('serviceDiscoveryType', this.serviceDiscoveryType);
            this.config.set('adminPassword', this.adminPassword);
            this.config.set('jwtSecretKey', this.jwtSecretKey);
        }
    },

    writing: writeFiles(),

    end() {
        if (this.warning) {
            this.log('\n');
            this.log(chalk.red('Docker Compose configuration generated with missing images!'));
            this.log(chalk.red(this.warningMessage));
        } else {
            this.log(`\n${chalk.bold.green('Docker Compose configuration successfully generated!')}`);
        }
        this.log(`You can launch all your infrastructure by running : ${chalk.cyan('docker-compose up -d')}`);
        if (this.gatewayNb + this.monolithicNb > 1) {
            this.log('\nYour applications will be accessible on these URLs:');
            let portIndex = 8080;
            this.appConfigs.forEach((appConfig) => {
                if (appConfig.applicationType === 'gateway' || appConfig.applicationType === 'monolith') {
                    this.log(`\t- ${appConfig.baseName}: http://localhost:${portIndex}`);
                    portIndex++;
                }
            });
            this.log('\n');
        }
    }
});
示例#3
0
 var injectJsFilesToIndex = function () {
     this.log('\n' + chalk.bold.green('Running gulp Inject to add javascript to index\n'));
     this.spawnCommand('gulp', ['inject:app']);
 };
示例#4
0
const warnText = (text) => { return console.warn(chalk.bold.yellow('[Warning] ') + text); }
示例#5
0
function protip() {
	const args = Array.prototype.slice.call(arguments);
	args.unshift(chalk.cyan('!'), chalk.bold.white('PROTIP:'));
	console.log.apply(null, args);
}
示例#6
0
exports.startDev = function startDev() {
	console.log(chalk.bold.magenta('\n\tPlease Wait ... This will take some time\n\n'));
	prepare(true);

	return spawn(`${cmd.webpackDevServer} --progress --inline --env dev`, {shell: true, stdio: 'inherit'});
};
示例#7
0
文件: gojo.js 项目: olafurr/gojo-cli
var args = process.argv.slice(2);

var fs = require('fs');
var chalk = require('chalk');
var readline = require('readline');
var pkg = require(__dirname + '/package.json');
var utils = require(__dirname + '/utils.json');
var _ = require('underscore');

// Let's change the name to something fancy
pkg.name = 'GoJo';

var cli = {
	pkg: pkg,
	utils: utils,
	prefix: chalk.bold.cyan('[' + pkg.name + ']'),
	info: function (message) {
		console.log(cli.prefix + chalk.cyan(' - ') + chalk.yellow(message));
	},
	log: function (task, message) {
		console.log(cli.prefix + chalk.cyan(' - ') + chalk.cyan(task) + '  ' + chalk.white(message));
	},
	success: function (message) {
		console.log(cli.prefix + chalk.cyan(' - ') + chalk.green(message));
	},
	error: function (message) {
		console.log(cli.prefix + chalk.cyan(' - ') + chalk.red(message));
	}

};
示例#8
0
var p      = require('path');
var util   = require('util');
var chalk  = require('chalk');

/**
 * Get PM2 path structure
 */
var path_structure = require('./paths.js')(process.env.OVER_HOME);

/**
 * Constants variables used by PM2
 */
var csts = {
  PREFIX_MSG              : chalk.green('[PM2] '),
  PREFIX_MSG_ERR          : chalk.red('[PM2][ERROR] '),
  PREFIX_MSG_MOD          : chalk.bold.green('[PM2][Module] '),
  PREFIX_MSG_MOD_ERR      : chalk.red('[PM2][Module][ERROR] '),
  PREFIX_MSG_WARNING      : chalk.yellow('[PM2][WARN] '),
  PREFIX_MSG_SUCCESS      : chalk.cyan('[PM2] '),

  PM2_IO_MSG : chalk.cyan('[PM2 I/O]'),
  PM2_IO_MSG_ERR : chalk.red('[PM2 I/O]'),

  TEMPLATE_FOLDER         : p.join(__dirname, 'lib/templates'),

  APP_CONF_DEFAULT_FILE   : 'ecosystem.config.js',
  APP_CONF_TPL            : 'ecosystem.tpl',
  APP_CONF_TPL_SIMPLE     : 'ecosystem-simple.tpl',
  SAMPLE_CONF_FILE        : 'sample-conf.js',
  LOGROTATE_SCRIPT        : 'logrotate.d/pm2',
示例#9
0
文件: ui.js 项目: Hypercubed/np
module.exports = options => {
	const pkg = util.readPkg();
	const oldVersion = pkg.version;
	const repositoryUrl = pkg.repository && githubUrlFromGit(pkg.repository.url);

	console.log(`\nPublish a new version of ${chalk.bold.magenta(pkg.name)} ${chalk.dim(`(current: ${oldVersion})`)}\n`);

	const prompts = [
		{
			type: 'list',
			name: 'version',
			message: 'Select semver increment or specify new version',
			pageSize: version.SEMVER_INCREMENTS.length + 2,
			choices: version.SEMVER_INCREMENTS
				.map(inc => ({
					name: `${inc} 	${prettyVersionDiff(oldVersion, inc)}`,
					value: inc
				}))
				.concat([
					new inquirer.Separator(),
					{
						name: 'Other (specify)',
						value: null
					}
				]),
			filter: input => version.isValidVersionInput(input) ? version.getNewVersion(oldVersion, input) : input
		},
		{
			type: 'input',
			name: 'version',
			message: 'Version',
			when: answers => !answers.version,
			filter: input => version.isValidVersionInput(input) ? version.getNewVersion(pkg.version, input) : input,
			validate: input => {
				if (!version.isValidVersionInput(input)) {
					return 'Please specify a valid semver, for example, `1.2.3`. See http://semver.org';
				}

				if (!version.isVersionGreater(oldVersion, input)) {
					return `Version must be greater than ${oldVersion}`;
				}

				return true;
			}
		},
		{
			type: 'list',
			name: 'tag',
			message: 'How should this pre-release version be tagged in npm?',
			when: answers => !pkg.private && version.isPrereleaseVersion(answers.version) && !options.tag,
			choices: () => execa.stdout('npm', ['view', '--json', pkg.name, 'dist-tags'])
				.then(stdout => {
					const existingPrereleaseTags = Object.keys(JSON.parse(stdout))
						.filter(tag => tag !== 'latest');

					if (existingPrereleaseTags.length === 0) {
						existingPrereleaseTags.push('next');
					}

					return existingPrereleaseTags
						.concat([
							new inquirer.Separator(),
							{
								name: 'Other (specify)',
								value: null
							}
						]);
				})
		},
		{
			type: 'input',
			name: 'tag',
			message: 'Tag',
			when: answers => !pkg.private && version.isPrereleaseVersion(answers.version) && !options.tag && !answers.tag,
			validate: input => {
				if (input.length === 0) {
					return 'Please specify a tag, for example, `next`.';
				}

				if (input.toLowerCase() === 'latest') {
					return 'It\'s not possible to publish pre-releases under the `latest` tag. Please specify something else, for example, `next`.';
				}

				return true;
			}
		},
		{
			type: 'confirm',
			name: 'confirm',
			message: answers => {
				const tag = answers.tag || options.tag;
				const tagPart = tag ? ` and tag this release in npm as ${tag}` : '';

				return `Will bump from ${chalk.cyan(oldVersion)} to ${chalk.cyan(answers.version + tagPart)}. Continue?`;
			}
		}
	];

	return printCommitLog(repositoryUrl)
		.then(hasCommits => {
			if (!hasCommits) {
				return inquirer.prompt([{
					type: 'confirm',
					name: 'confirm',
					message: 'No commits found since previous release, continue?',
					default: false
				}]);
			}
		})
		.then(answers => {
			if (answers && !answers.confirm) {
				return answers;
			}

			return inquirer.prompt(prompts);
		})
		.then(answers => Object.assign({}, options, answers));
};
  prompting: function() {
    var done = this.async();

    // Have Yeoman greet the user.
    this.log(yosay(
      'Welcome to the ' + chalk.bold.red('buildabanner') + ' generator!'
    ));

    var bannerSize = 'default';

    var prompts = [{
      type: 'input',
      name: 'bannerName',
      filter: function(answer) {
        return camelCase(answer)
      },
      message: 'Banner name (no spaces):',
      default: this.appname
    }, {
      type: 'input',
      name: 'bannerDesc',
      message: 'Description:',
      default: 'An HTML banner'
    }, {
      type: 'list',
      name: 'bannerType',
      message: 'What type of banner is this?',
      choices: ['Standard', 'AdWords', 'DoubleClick', 'TruEffect'],
      default: 'Standard'
    }, {
      type: 'list',
      name: 'bannerSize',
      message: 'Choose a size for this banner.',
      choices: ['300x250', '728x90', '970x90', '160x600', '300x600', '320x50'],
      default: '300x250'
    }, {
      type: 'confirm',
      name: 'includeGsap',
      message: 'Include GSAP for offline use?',
      default: false
    }, {
      when: function(answers) {
        return answers.bannerType === 'DoubleClick';
      },
      type: 'confirm',
      name: 'includeOfflineEnabler',
      message: "Include DoubleClick Enabler for offline use?",
      default: true
    }, {
      type: 'confirm',
      name: 'includeSublimeProject',
      message: 'Include SublimeText project file?',
      default: true
    }, {
      type: 'input',
      name: 'archiveName',
      message: 'Ad zip archive name? (Do not include .zip)',
      default: function(answers) {
        return answers.bannerName + "-" + answers.bannerSize
      }
    }];

    this.prompt(prompts, function(props) {
      /* Set the width and height properites based on bannerSize */
      switch (props.bannerSize) {
        case '320x50':
          props.bannerWidth = 318;
          props.bannerHeight = 48;
          props.actualBannerWidth = 320;
          props.actualBannerHeight = 50;
          break;
        case '300x600':
          props.bannerWidth = 298;
          props.bannerHeight = 598;
          props.actualBannerWidth = 300;
          props.actualBannerHeight = 600;
          break;
        case '728x90':
          props.bannerWidth = 726;
          props.bannerHeight = 88;
          props.actualBannerWidth = 728;
          props.actualBannerHeight = 90;
          break;
        case '970x90':
          props.bannerWidth = 968;
          props.bannerHeight = 88;
          props.actualBannerWidth = 970;
          props.actualBannerHeight = 90;
          break;
        case '160x600':
          props.bannerWidth = 158;
          props.bannerHeight = 598;
          props.actualBannerWidth = 160;
          props.actualBannerHeight = 600;
          break;
        case '300x250':
        default:
          props.bannerWidth = 298;
          props.bannerHeight = 248;
          props.actualBannerWidth = 300;
          props.actualBannerHeight = 250;
          break;
      }

      this.props = props;
      // To access props later use this.props.someOption;
      done();
    }.bind(this));
  },
示例#11
0
WirelessCommand.prototype.__networks = function networks(err, dat) {

	var self = this;
	var detectedDevices = [ ];

	this.stopSpin();

	if(err) {

		protip(
			"Some computers may require",
			chalk.cyan('Administrator'),
			"permissions for my",
			chalk.cyan("automagical"),
			"Wi-Fi scanning capabilities."
		);
		console.log();
		console.log(alert, chalk.bold.white('OOPS:'), "I was unable to scan for nearby Wi-Fi networks", chalk.magenta('(-___-)'));
		console.log();

		return prompt([{

			type: 'confirm',
			name: 'manual',
			message: "We can still proceed in 'manual' mode. Would you like to continue?",
			default: true

		}], manualChoice);
	}

	detectedDevices = dat;
	if (this.__macAddressFilter) {

		var macDevices = detectedDevices.filter(function (ap) {

			return ap.mac.toLowerCase() === self.__macAddressFilter;

		});
		if (macDevices && macDevices.length === 1) {

			detectedDevices = macDevices;

		}
	}

	detectedDevices = ssids(filter(detectedDevices, self.deviceFilterPattern));

	if(detectedDevices.length > 1) {

		// Multiple Photons detected
		prompt([{

			type: 'confirm',
			name: 'setup',
			message: 'Multiple Photons detected nearby. Would you like to select one to setup now?',
			default: true,

		}], multipleChoice);
	}
	else if(detectedDevices.length == 1) {

		// Perform wireless setup?
		prompt([{

			type: 'confirm',
			name: 'setupSingle',
			message: util.format(
				'Found "%s". Would you like to perform setup on this one now?',
				chalk.bold.cyan(detectedDevices[0])
			),
			default: true,

		}], singleChoice);
	}
	else {

		console.log(
			arrow,
			chalk.bold.white('No nearby Photons detected.'),
			chalk.bold.white('Try the', '`' + chalk.bold.cyan(cmd + ' help') + '` command for more information.')
		);

		// Monitor for new Photons?
		prompt([{

			type: 'confirm',
			name: 'monitor',
			message: strings.monitorPrompt,
			default: true

		}], monitorChoice);
	}

	function manualChoice(ans) {

		if(ans.manual) {

			// manual mode
			console.log();
			protip("Manual mode will", chalk.cyan('prompt'), "you to manage the", chalk.cyan('Wi-Fi'), "connection of your computer when it's necessary.");
			protip("To proceed, you will need to be able to manually change the Wi-Fi connectivity of your computer.");
			protip("Your Photon will appear in your computer's list of Wi-Fi networks with a name like,", chalk.cyan('Photon-XXXX'));
			protip("Where", chalk.cyan('XXXX'), "is a string of random letters and/or numbers", chalk.cyan("unique"), "to that specific Photon.");

			self.__manual = true;
			return self.setup(null, manualDone);
		}

		console.log();
		console.log(alert, "Try running", chalk.cyan(cmd + ' setup'), 'with Administrator privileges.');
		console.log(alert, "If the problem persists, please let us know:", chalk.cyan('https://community.particle.io/'));
		console.log();
	};

	function multipleChoice(ans) {

		if(ans.setup) {

			self.__batch = false;

			// Select any/all Photons to setup
			prompt([{

				type: 'list',
				name: 'selected',
				message: 'Please select which Photons you would like to setup at this time.',
				choices: detectedDevices

			}], multipleAnswers);
		}
		else {

			console.log('OK, bye!', chalk.magenta('<3'));
		}
	};

	function multipleAnswers(ans) {

		if(ans.selected.length > 1) {

			self.__batch = ans.selected;
			return self.setup(null);
		}
		self.__batch = undefined;
		self.setup(ans.selected[0]);
	};

	function singleChoice(ans) {

		if(ans.setupSingle) { self.setup(detectedDevices[0]); }
		else {

			// Monitor for new Photons?
			prompt([{

				type: 'confirm',
				name: 'monitor',
				message: strings.monitorPrompt,
				default: true

			}], monitorChoice);
		}
	};

	function monitorChoice(ans) {

		if(ans.monitor) {

			console.log(arrow, chalk.bold.white('Monitoring nearby Wi-Fi networks for Photons. This may take up to a minute.'));
			self.monitor();
		}
		else {

			self.exit();
		}
	};

	function manualDone(err, dat) {

		if(err) {

			return console.log(chalk.read('!'), "An error occurred:", err);
		}
		if(dat && dat.id) {

			return console.log(arrow, "We successfully configured your Photon! Great work. We make a good team!", chalk.magenta('<3'));
		};
	};
};
示例#12
0
 .listen(PORT, 'localhost', err => {
   err && console.error(err);
   console.log(`Listening at ${chalk.bold.cyan(`http://localhost:${PORT}/`)}`);
 });
示例#13
0
文件: db.js 项目: Coocla33/Freezy
const Datastore = require('nedb')
const config = require('./config.json')
const chalk = require('chalk')
var info = chalk.bold.green('Info: ')
var masterUser = config.perms.masterUsers
var serverDB = new Datastore({ filename: './datastorage/servers', autoload: true })

function removeUserLvl (server, user) {
  serverDB.update({serverId: server}, {$pull: {lvl1: user}}, {}, function () {})
  serverDB.update({serverId: server}, {$pull: {lvl2: user}}, {}, function () {})
  serverDB.update({serverId: server}, {$pull: {lvl3: user}}, {}, function () {})
}

exports.guildCreation = function (server, user) {
  console.log(info + 'Joined a guild, creating database entry!')
  return new Promise((resolve, reject) => {
    if (!server || !user) return reject('Abort! Missing one or two of the params')
    var serverData = {}
    serverData.serverId = server
    serverData.owner = user
    serverData.lvl1 = []
    serverData.lvl2 = []
    serverData.lvl3 = []
    serverDB.insert(serverData, function (err) {
      if (err) {
        console.log(err.stack) 
        return reject(err)
      } else {
        return resolve(true)
      }
    })
示例#14
0
 result.messages.filter(m => m.stylelintType === "invalidOption").forEach(m => {
   console.log(chalk.bold.yellow(`>> ${m.text}`))
 })
示例#15
0
exports.startTest = function startTest() {
	console.log(chalk.bold.magenta('\n\tPlease Wait ... This will take some time\n\n'));
	prepare(true);

	return spawn(server_test, {stdio: 'inherit', shell: true});
};
function _functionsOpLogReject(func, type, err) {
  utils.logWarning(chalk.bold.yellow('functions:') + ' failed to ' + type + ' function ' + func);
  utils.logWarning(chalk.bold.yellow('functions: ') + err.message);
  return RSVP.reject(err.message);
}
示例#17
0
exports.startProdE2E = function startProdE2E() {	
	console.log(chalk.bold.magenta('\n\tPlease Wait ... This will take some time\n\n'));
	prepare();

	return spawn(prod_e2e, {shell: true, stdio: 'inherit'});
}
示例#18
0
actions.createNode = (node: any, plugin?: Plugin, traceId?: string) => {
  if (!_.isObject(node)) {
    return console.log(
      chalk.bold.red(
        `The node passed to the "createNode" action creator must be an object`
      )
    )
  }

  // Ensure the new node has an internals object.
  if (!node.internal) {
    node.internal = {}
  }

  // Tell user not to set the owner name themself.
  if (node.internal.owner) {
    console.log(JSON.stringify(node, null, 4))
    console.log(
      chalk.bold.red(
        `The node internal.owner field is set automatically by Gatsby and not by plugin`
      )
    )
    process.exit(1)
  }

  // Add the plugin name to the internal object.
  if (plugin) {
    node.internal.owner = plugin.name
  }

  const result = Joi.validate(node, joiSchemas.nodeSchema)
  if (result.error) {
    console.log(chalk.bold.red(`The new node didn't pass validation`))
    console.log(chalk.bold.red(result.error))
    console.log(node)
    return { type: `VALIDATION_ERROR`, error: true }
  }

  // Ensure node isn't directly setting fields.
  if (node.fields) {
    throw new Error(
      stripIndent`
      Plugins creating nodes can not set data on the reserved field "fields"
      as this is reserved for plugins which wish to extend your nodes.

      If your plugin didn't add "fields" you're probably seeing this
      error because you're reusing an old node object.

      Node:

      ${JSON.stringify(node, null, 4)}

      Plugin that created the node:

      ${JSON.stringify(plugin, null, 4)}
    `
    )
  }

  trackSubObjectsToRootNodeId(node)

  const oldNode = getNode(node.id)

  // Ensure the plugin isn't creating a node type owned by another
  // plugin. Type "ownership" is first come first served.
  if (plugin) {
    let pluginName = plugin.name

    if (!typeOwners[node.internal.type])
      typeOwners[node.internal.type] = pluginName
    else if (typeOwners[node.internal.type] !== pluginName)
      throw new Error(stripIndent`
        The plugin "${pluginName}" created a node of a type owned by another plugin.

        The node type "${node.internal.type}" is owned by "${
        typeOwners[node.internal.type]
      }".

        If you copy and pasted code from elsewhere, you'll need to pick a new type name
        for your new node(s).

        The node object passed to "createNode":

        ${JSON.stringify(node, null, 4)}

        The plugin creating the node:

        ${JSON.stringify(plugin, null, 4)}
      `)

    // If the node has been created in the past, check that
    // the current plugin is the same as the previous.
    if (oldNode && oldNode.internal.owner !== pluginName) {
      throw new Error(
        stripIndent`
        Nodes can only be updated by their owner. Node "${node.id}" is
        owned by "${oldNode.internal.owner}" and another plugin "${pluginName}"
        tried to update it.

        `
      )
    }
  }

  // Check if the node has already been processed.
  if (oldNode && !hasNodeChanged(node.id, node.internal.contentDigest)) {
    return {
      type: `TOUCH_NODE`,
      plugin,
      traceId,
      payload: node.id,
    }
  } else {
    return {
      type: `CREATE_NODE`,
      plugin,
      traceId,
      payload: node,
    }
  }
}
示例#19
0
exports.startProd = function startProd() {
	console.log(chalk.bold.magenta('\n\tPlease Wait ... This will take some time\n\n'));
	prepare();

	return spawn(`${ngc} && ${cmd.webpack} --progress --hide-modules true --env prod && node -e "require('./config/helpers').cleanup('client')" && node dist`, {shell: true, stdio: 'inherit'});
};
  prompting: function() {
    var done = this.async();

    // yeoman greeting
    this.log(yosay(
      'Yo! I\'m here to help build your ' +
      chalk.bold.yellow('Angular2') +
      ' application.'
    ));

    var choices = licenses;

    var prompts = [
      {
        name: 'appname',
        message: 'Your application name',
        default: makeGeneratorName(path.basename(process.cwd())),
        filter: makeGeneratorName,
        validate: function (str) {
          return str.length > 0;
        }
      },
      {
        name: 'description',
        message: 'Description of the application:'
      },
      {
        name: 'keywords',
        message: 'Keywords:',
        default: ''
      },
      {
        name: 'name',
        message: 'What\'s your name:',
        default: this.options.name || this.gitc.user.name,
        when: !this.options.name
      },
      {
        name: 'email',
        message: 'Your email (optional):',
        default: this.options.email || this.gitc.user.email,
        when: !this.options.email
      },
      {
        name: 'website',
        message: 'Your website (optional):',
        default: this.options.website,
        when: !this.options.website
      },
      {
        type: 'list',
        name: 'license',
        message: 'Which license do you want to use?',
        choices: choices
      }
    ];

    this.prompt(prompts, function (props) {
      this.props = lodash.extend(this.props, props);
      this.props.author = this.props.name.trim();
      if (this.props.email) {
        this.props.author += ' <' + this.props.email.trim() + '>';
      }
      done();
    }.bind(this));
  },
示例#21
0
const errorText = (text) => { return console.error(Error(chalk.bold.red('[Error] ') + text)); }
示例#22
0
 .then((chunk) => {
   const message = chalk.bold.green('\'Clonning {0} gist\''.format(chunk.description));
   console.log(message);
   const pullUrl = chunk.git_pull_url;
   return Git.Clone(pullUrl, dest);
 })
示例#23
0
    client.api_request({ action: "browse", searchstr: query }, function(err, data) {
      if (err) {
        console.log(err);
        return onErr(err);
      }
      for (var i = 0; i < data.results.length; i++) {
        // Why not display Various artists?
        //if (data.results[i].artist && data.results[i].artist !== 'Various Artists') {
        if (data.results[i].artist) {
          console.log(chalk.bold(data.results[i].artist + ': ' + chalk.blue(data.results[i].groupName) + ' ' +
                      chalk.yellow(data.results[i].groupYear) + chalk.cyan(' ['+data.results[i].releaseType+']')));
          var torrents = data.results[i].torrents;
          if (torrents == undefined) {
            console.log('');
          } else {
            for (var t = 0; t < torrents.length; t++) {
	      // TODO: (torrents[t].scene ? chalk.bold.red(' SCENE') : ' ') Could be more subtle, maybe just color the hyphen?
              console.log('  - ' + torrents[t].format + ' ' + torrents[t].encoding  + (torrents[t].scene ? chalk.bold.red(' SCENE') : ' ') +
                          ' (' + chalk.green(torrents[t].seeders) + '/' + chalk.red(torrents[t].leechers) + ')' +
                          ' Torrent Id: ' + torrents[t].torrentId);
            }
          }
        }
      }
      console.log(' ');
      console.log('Type "det <enter> torrentid" to get details about a specific torrent.');
      mainMenu();
    });
示例#24
0
 .then(() => {
   const message = chalk.bold.blue('Gist cloned to {0}'.format(dest));
   console.log(message);
 })
示例#25
0
	/**
	 * Callback from scanning for wifi networks.
	 * @param err   Any error that happened during scanning
	 * @param dat   A list of APs that matched with these properties:
	 *  mac: MAC address for the AP
	 *  ssid: the SSID of the AP
	 * @private
	 */
	networks(err, dat) {

		const self = this;
		let detectedDevices = [];

		this.stopSpin();

		if (err) {

			protip(
				'Some computers may require',
				chalk.cyan('Administrator'),
				'permissions for my',
				chalk.cyan('automagical'),
				'Wi-Fi scanning capabilities.'
			);
			console.log();
			console.log(alert, chalk.bold.white('OOPS:'), 'I was unable to scan for nearby Wi-Fi networks', chalk.magenta('(-___-)'));
			console.log();

			return this.manualAsk(manualChoice);
		}

		detectedDevices = dat;
		if (this.macAddressFilter) {
			const macDevices = detectedDevices.filter((ap) => {
				return ap.mac && (ap.mac.toLowerCase() === self.macAddressFilter);
			});
			if (macDevices && macDevices.length === 1) {

				detectedDevices = macDevices;

			}
		}

		detectedDevices = ssids(filter(detectedDevices, self.deviceFilterPattern));

		if (detectedDevices.length > 1) {

			// Multiple Photons detected
			this.prompt([{

				type: 'confirm',
				name: 'setup',
				message: 'Multiple Photons detected nearby. Would you like to select one to setup now?',
				default: true,

			}]).then(multipleChoice);
		} else if (detectedDevices.length === 1) {

			// Perform wireless setup?
			this.prompt([{

				type: 'confirm',
				name: 'setupSingle',
				message: util.format(
					'Found "%s". Would you like to perform setup on this one now?',
					chalk.bold.cyan(detectedDevices[0])
				),
				default: true,

			}]).then(singleChoice);
		} else {

			console.log(
				arrow,
				chalk.bold.white('No nearby Photons detected.'),
				chalk.bold.white('Try the', '`' + chalk.bold.cyan(cmd + ' help') + '` command for more information.')
			);

			// Monitor for new Photons?
			this.prompt([{

				type: 'confirm',
				name: 'monitor',
				message: strings.monitorPrompt,
				default: true

			}]).then(monitorChoice);
		}

		function manualChoice(ans) {

			if (ans.manual) {

				// manual mode
				console.log();
				protip('Manual mode will', chalk.cyan('prompt'), 'you to manage the', chalk.cyan('Wi-Fi'), "connection of your computer when it's necessary.");
				protip('To proceed, you will need to be able to manually change the Wi-Fi connectivity of your computer.');
				protip("Your Photon will appear in your computer's list of Wi-Fi networks with a name like,", chalk.cyan('Photon-XXXX'));
				protip('Where', chalk.cyan('XXXX'), 'is a string of random letters and/or numbers', chalk.cyan('unique'), 'to that specific Photon.');

				self.manual = true;
				return self.setup(null, manualDone);
			}

			console.log();
			console.log(alert, 'Try running', chalk.cyan(cmd + ' setup'), 'with Administrator privileges.');
			console.log(alert, 'If the problem persists, please let us know:', chalk.cyan('https://community.particle.io/'));
			console.log();
		}

		function multipleChoice(ans) {

			if (ans.setup) {

				self.batch = false;

				// Select any/all Photons to setup
				return self.prompt([{

					type: 'list',
					name: 'selected',
					message: 'Please select which Photon you would like to setup at this time.',
					choices: detectedDevices

				}]).then(multipleAnswer);
			}
			self.exit();
		}

		function multipleAnswer(ans) {

			if (ans.selected) {

				return self.setup(ans.selected);
			}
			self.exit();
		}

		function singleChoice(ans) {

			if (ans.setupSingle) {
				self.setup(detectedDevices[0]);
			} else {
				// Monitor for new Photons?
				self.prompt([{

					type: 'confirm',
					name: 'monitor',
					message: strings.monitorPrompt,
					default: true

				}]).then(monitorChoice);
			}
		}

		function monitorChoice(ans) {

			if (ans.monitor) {

				console.log(arrow, chalk.bold.white('Monitoring nearby Wi-Fi networks for Photons. This may take up to a minute.'));
				self.monitor();
			} else {
				self.exit();
			}
		}
	}
示例#26
0
 .on('error', function (err) {
     console.error(String(err));
     console.error(chalk.bold.bgRed(' TESTS FAILED '));
     done(new Error(' TESTS FAILED '));
 })
示例#27
0
		getFrontSchema(name, false)
	} catch (e) {
		process.stderr.write(`\n\n${chalk.bold.red(`Fatal error in schema (front, restricted excluded) "${name}"`)}:\n${chalk.red(e.message)}\n\n`)
		invalids.push(name)
	}
	try {
		getFrontSchema(name, true)
	} catch (e) {
		process.stderr.write(`\n\n${chalk.bold.red(`Fatal error in schema (front, restricted included) "${name}"`)}:\n${chalk.red(e.message)}\n\n`)
		invalids.push(name)
	}
	try {
		getLayout(name, false)
	} catch (e) {
		process.stderr.write(`\n\n${chalk.bold.red(`Fatal error in layout (restricted excluded) "${name}"`)}:\n${chalk.red(e.message)}\n\n`)
		invalids.push(name)
	}
	try {
		getLayout(name, true)
	} catch (e) {
		process.stderr.write(`\n\n${chalk.bold.red(`Fatal error in layout (restricted included) "${name}"`)}:\n${chalk.red(e.message)}\n\n`)
		invalids.push(name)
	}
})
if (invalids.length > 0) {
	process.stderr.write(`\n\n${chalk.bold.red(`Fatal error in following schemas: ${uniq(invalids).join(', ')}`)}\n${chalk.red('Check errors above')}\n\n`)
	process.exit(1)
}

console.log('Successfully validated schemas and layouts!') // eslint-disable-line no-console
示例#28
0
 .on('error', function () {
     console.log(chalk.bold.bgRed(' TESTS FAILED '));
 });
示例#29
0
 modules.forEach(function (module) {
     if (module.hookFor === 'entity' && module.hookType === 'post') {
         // compose with the modules callback generator
         try {
             this.composeWith(module.generatorCallback, {
                 options: {
                     entityConfig: entityConfig,
                     force: this.options['force']
                 }
             });
         } catch (err) {
             this.log(chalk.red('Could not compose module ') + chalk.bold.yellow(module.npmPackageName) +
                 chalk.red('. \nMake sure you have installed the module with ') + chalk.bold.yellow('\'npm -g ' + module.npmPackageName + '\''));
         }
     }
 }, this);
示例#30
0
文件: cnsl.js 项目: Opencademy/buddy
exports.warn = function(msg, column) {
	if (column == null) column = 0;
	if ('string' instanceof Error) msg = msg.message;
	exports.print(chalk.bold.yellow('warning ') + msg, column);
};