Example #1
0
function getPackageInfo(type, data) {
  if (!data) return;
  var author = data.author ? chalk.green('  Author: ') + data.author.name : '';
  if (type === pkgType.custom && data.author.name === 'Linnovate') type = pkgType.core;
  return chalk.green('   ' + type + ': ') + data.name + '@' + data.version + author;
}
Example #2
0
 this.each(function(board) {
   board.info("Board ID: ", chalk.green(board.id));
 });
 .then(function () {
   ui.writeLine(chalk.green('Successfully formatted files.'));
 })
Example #4
0
File: cli.js Project: AiNoKame/knex
 pending = initKnex(env).migrate.currentVersion().then(function(version) {
   success(chalk.green('Current Version: ') + chalk.blue(version));
 }).catch(exit);
Example #5
0
File: cli.js Project: AiNoKame/knex
 pending = initKnex(env).seed.run().spread(function(log) {
   if (log.length === 0) {
     success(chalk.cyan('No seed files exist'));
   }
   success(chalk.green('Ran ' + log.length + ' seed files \n' + chalk.cyan(log.join('\n'))));
 }).catch(exit);
Example #6
0
File: cli.js Project: AiNoKame/knex
 }).then(function() {
   success(chalk.green('Created ' + stubPath));
 }).catch(exit);
Example #7
0
File: cli.js Project: AiNoKame/knex
 pending = initKnex(env).migrate.latest().spread(function(batchNo, log) {
   if (log.length === 0) {
     success(chalk.cyan('Already up to date'));
   }
   success(chalk.green('Batch ' + batchNo + ' run: ' + log.length + ' migrations \n' + chalk.cyan(log.join('\n'))));
 }).catch(exit);
Example #8
0
 packageData[componentKey].forEach(function(item, index) {
   msg += '\n' + chalk.green(index + 1) + ' ' + item;
 });
Example #9
0
 possibleFiles.forEach(function(file, index) {
   msg += '\n' + chalk.green(index + 1) + ' ' + file;
 });
Example #10
0
    return new Promise(function(resolve, reject) {
      var componentType;
      var componentIndex;
      var fileIndex;
      var componentKey;
      var msg;

      var packageData = this.parseFile(packageName);

      msg = 'What would you like to inject from ' + chalk.yellow(path.basename(packageName)) + '?';
      Object.keys(packageData).forEach(function(item, index) {
        msg += '\n' + chalk.green(index + 1) + ' ' + item;
      });
      msg += '\n' + chalk.green('-----------');
      msg += '\n' + chalk.green('q') + ' Quit';
      msg += '\nEnter value:';

      return this.ui.prompt({
        type: 'input',
        name: 'component',
        message: msg,
        validate: function(value) {
          return (value > 0 && value <= Object.keys(packageData).length) ||
                  value === 'q' ? true : 'Enter a valid value';
        }
      })
      .then(function(choice) {
        componentType = choice.component;

        if (componentType.toLowerCase() === 'q') {
          return resolve();
        }

        Object.keys(packageData).forEach(function(item, index) {
          if ((index + 1) === parseInt(componentType, 10)) {
            componentKey = item;
          }
        });

        msg = '\nWhich ' + componentKey + ' would you like to inject?';
        packageData[componentKey].forEach(function(item, index) {
          msg += '\n' + chalk.green(index + 1) + ' ' + item;
        });
        msg += '\nEnter value:';

        return this.ui.prompt({
          type: 'input',
          name: 'sel',
          message: msg,
          filter: function (val) { return val.trim(); },
          validate: function(value) {
            return value > 0 && value <= packageData[componentKey].length ? true : 'Enter a valid value';
          }
        })
        .then(function(choice) {
          componentIndex = choice.sel - 1;

          msg = '\nWhere would you like to inject it?';
          var possibleFiles = glob.sync(appRoot + '/**/*.ts').sort();
          possibleFiles.forEach(function(file, index) {
            msg += '\n' + chalk.green(index + 1) + ' ' + file;
          });
          msg += '\nEnter value:';

          return this.ui.prompt({
            type: 'input',
            name: 'file',
            message: msg,
            validate: function(value) {
              return value > 0 && value <= possibleFiles.length ? true : 'Enter a valid value';
            }
          })
          .then(function(choice) {
            fileIndex = choice.file - 1;

            this.ui.writeLine(chalk.yellow('Injecting', componentKey +
            ' (' + packageData[componentKey][componentIndex] + ') to', possibleFiles[fileIndex]));


            this.injectImport(possibleFiles[fileIndex],
                              packageName,
                              packageData[componentKey][componentIndex]);

            this.injectItem(componentKey.toLowerCase(),
                            packageData[componentKey][componentIndex],
                            possibleFiles[fileIndex]);

            this.ui.writeLine(chalk.green('Successfully injected.'));

            return this.customImport(packageName)
              .then(function() {
                resolve();
              });

          }.bind(this));
        }.bind(this));
      }.bind(this));
    }.bind(this));
Example #11
0
 Object.keys(packageData).forEach(function(item, index) {
   msg += '\n' + chalk.green(index + 1) + ' ' + item;
 });
Example #12
0
 return Fsxx.emptydir(dirpath).then((dirpath) => {
   console.log(Chalk.green(`${dirpath} All clear.`));
 });
Example #13
0
	gulp.task('say', function (e) {
		var time = '[' + chalk.grey(dateformat(new Date(), 'HH:MM:ss')) + ']';
		console.error(time +
		chalk.dim.bold.blue(' [' + chalk.cyan.underline('Petrie') + '] ') +
		chalk.green(message) + chalk.white(''));
	});
Example #14
0
 }, function(err) {
   if (err) console.error(err);
   else console.log(chalk.green('successfully updated'));
   db.close();
 });
Example #15
0
            files.forEach((file) => {
              const from = path.resolve(cwd, 'src', file);
              const to = path.resolve(cwd, 'lib', file);
              result.push(to);

              mkdirp.sync(path.dirname(to));
              switch (path.extname(file)) {
                case '.jsx':
                case '.js':
                  // 检测依赖 start
                  const depsInContents = matchRequire.findAll(
                    fs.readFileSync(from, 'utf-8'),
                  );
                  (depsInContents || []).forEach((dep) => {
                    // 本地依赖 忽略
                    if (/^\./.test(dep)) {
                      return;
                    }
                    // external 忽略
                    if (['react', 'react-dom'].indexOf(dep) > -1) {
                      return;
                    }
                    // normal module
                    const splitDep = dep.split('/');
                    let depModule = '';
                    if (dep[0] === '@') {
                      depModule = splitDep.slice(0, 2).join('/');
                    } else {
                      depModule = splitDep[0];
                    }
                    const modulePath = path.join(
                      cwd,
                      'node_modules',
                      depModule,
                      'package.json',
                    );
                    if (!fs.existsSync(modulePath)) {
                      throw new Error('依赖检测错误: ' + dep);
                    }
                    if (!dep in dependencies) {
                      throw new Error('依赖检测错误, dep 未添加: ' + dep);
                    }
                  });
                  const transformed = babel.transformFileSync(
                    from,
                    babelConfig,
                  );
                  fs.writeFileSync(
                    to.replace(/\.jsx/, '.js'),
                    transformed.code,
                    'utf-8',
                  );
                  console.log(
                    `${path.relative(cwd, from)} ${colors.green(
                      '-babel->',
                    )} ${path.relative(cwd, to)}`,
                  );
                  // todo .map file
                  break;
                default:
                  console.log(
                    `${path.relative(cwd, from)} ${colors.green(
                      '-copy->',
                    )} ${path.relative(cwd, to)}`,
                  );
                  copy(from, to);
              }
            });
Example #16
0
  importInBootstrap: function(entryPoint, packageName, packageData) {
    var providers = packageData.Provider;
    var contents = fs.readFileSync(entryPoint, 'utf8');
    var contentsArr = contents.split('\n');
    var lastIndex;
    var alreadyImported = false;
    var regExp = new RegExp(packageName, 'i');

    contentsArr.forEach(function(line, index) {
      if (regExp.test(line)) {
        alreadyImported = true;
      }
    });

    if (alreadyImported) {
      return false;
    }

    var imports = 'import {' + providers.join(',') + '} from \'' + packageName + '\';';

    if (imports.length > 100) {
      imports = 'import {\n' + providers.join('  ,\n') + '}\n from \'' + packageName + '\';';
    }

    contentsArr.forEach(function(line, index) {
      if (/import/.test(line)) {
        lastIndex = index;
      }
      else if (/bootstrap\(/.test(line) && providers && providers.length) {
        var replace;
        var replacement;

        if (/\)/.test(line)) {
          replace = line.match(/\((.*?)\)/)[0];
        }
        else {
          replace = contentsArr.splice(index, contentsArr.length - 1).join('\n').replace(/\n/g, '');
          replace = replace.match(/\((.*?)\)/)[0];
        }

        var current = replace.replace(/\(/, '').replace(/\)/, '').replace(/ /g, '');
        var replacementProviders;

        if (/\[/.test(current)) {
          var currentProviders = current.match(/\[(.*?)\]/)[0];
          currentProviders = currentProviders.replace(/\[/, '').replace(/\]/, '').replace(/ /, '');
          currentProviders = currentProviders.split(',');
          replacementProviders = currentProviders.concat(providers);
          current = current.replace(/\,/, '').replace(/\[(.*?)\]/, '');

          replacement = 'bootstrap(' + current + ', [\n  ' + replacementProviders.join(', \n  ') + '\n]);';
          contentsArr[index] = replacement;
        }
        else {
          replacementProviders = providers;

          replacement = '(' + current + ', [\n  ' + replacementProviders.join(', \n  ') + '\n])';
          contentsArr[index] = contentsArr[index].replace(replace, replacement);
        }
      }
    });

    contentsArr.splice(lastIndex + 1, 0, imports);

    fs.writeFileSync(entryPoint, contentsArr.join('\n'), 'utf8');
    this.ui.writeLine(chalk.green('Providers imported in', entryPoint));
  },
Example #17
0
		return generate(options.type || type, options, settings).then(() => {
			console.log();
			console.log(chalk.green('Done!'));
		});
Example #18
0
 announceOKCompletion: function() {
   this.completionOKMessage = 'Done.';
   this.ui.writeLine(chalk.green(this.completionOKMessage));
   this.done();
 },
Example #19
0
File: cli.js Project: AiNoKame/knex
 pending = instance.migrate.make(name, {extension: ext}).then(function(name) {
   success(chalk.green('Created Migration: ' + name));
 }).catch(exit);
Example #20
0
#!/usr/bin/env node

var program = require('commander');
var chalk = require('chalk');
var init = require('./init');
var setTheme = require('./theme').setTheme;
var updateNotifier = require('update-notifier');
var pkg = require('../package.json');

updateNotifier({ pkg }).notify();

program
  .command('init')
  .option(
    '-t, --theme <theme>',
    `Doca theme. Must be the full package name if @scoped. ${chalk.grey('Default')}: ${chalk.green('bootstrap')}`
  )
  .option(
    '-i, --input <input>',
    `Folder with JSON HyperSchemas. ${chalk.grey('Default')}: It goes through the current dir.`
  )
  .option(
    '-o, --output <output>',
    `Doca project name. ${chalk.grey('Default')}: ${chalk.green('documentation')}`
  )
  .description('initialize a new doca project')
  .action(function (args) { init(args.theme, args.input, args.output); });

program
  .command('theme <newTheme> <project>')
  .description('set project <project> theme to <newTheme>; note that @namespaced theme packages must be given with their full package name')
Example #21
0
File: cli.js Project: AiNoKame/knex
 pending = initKnex(env).migrate.rollback().spread(function(batchNo, log) {
   if (log.length === 0) {
     success(chalk.cyan('Already at the base migration'));
   }
   success(chalk.green('Batch ' + batchNo + ' rolled back: ' + log.length + ' migrations \n') + chalk.cyan(log.join('\n')));
 }).catch(exit);
Example #22
0
 .then(function () {
   this.log(chalk.green('Added plugins: ' + this.answers.plugins.join(', ')));
   this.log(chalk.green('Cordova project was set up successfully! Project Name: '), chalk.bgGreen(this.answers.appName));
   done();
 }.bind(this))
Example #23
0
File: cli.js Project: AiNoKame/knex
 pending = instance.seed.make(name, {extension: ext}).then(function(name) {
   success(chalk.green('Created seed file: ' + name));
 }).catch(exit);
Example #24
0
app.listen(port, () => {
  console.log(`Listing on port ${chalk.green(port)}`);
});
Example #25
0
File: cli.js Project: AiNoKame/knex
function invoke(env) {

  var pending, filetypes = ['js', 'coffee', 'eg', 'ls'];

  commander
    .version(
      chalk.blue('Knex CLI version: ', chalk.green(cliPkg.version)) + '\n' +
      chalk.blue('Local Knex version: ', chalk.green(env.modulePackage.version)) + '\n'
    )
    .option('--debug', 'Run with debugging.')
    .option('--knexfile [path]', 'Specify the knexfile path.')
    .option('--cwd [path]', 'Specify the working directory.')
    .option('--env [name]', 'environment, default: process.env.NODE_ENV || development');


  commander
    .command('init')
    .description('        Create a fresh knexfile.')
    .option('-x [' + filetypes.join('|') + ']', 'Specify the knexfile extension (default js)')
    .action(function() {
      var type = (argv.x || 'js').toLowerCase();
      if (filetypes.indexOf(type) === -1) {
        exit('Invalid filetype specified: ' + type);
      }
      if (env.configPath) {
        exit('Error: ' + env.configPath + ' already exists');
      }
      checkLocalModule(env);
      var stubPath = './knexfile.' + type;
      pending = fs.readFileAsync(path.dirname(env.modulePath) + '/lib/migrate/stub/knexfile-' + type + '.stub')
        .then(function(code) {
          return fs.writeFileAsync(stubPath, code);
        }).then(function() {
          success(chalk.green('Created ' + stubPath));
        }).catch(exit);
    });

  commander
    .command('migrate:make <name>')
    .description('       Create a named migration file.')
    .option('-x [' + filetypes.join('|') + ']', 'Specify the stub extension (default js)')
    .action(function(name) {
      var instance = initKnex(env);
      var ext = (argv.x || env.configPath.split('.').pop()).toLowerCase();
      pending = instance.migrate.make(name, {extension: ext}).then(function(name) {
        success(chalk.green('Created Migration: ' + name));
      }).catch(exit);
    });

  commander
    .command('migrate:latest')
    .description('        Run all migrations that have not yet been run.')
    .action(function() {
      pending = initKnex(env).migrate.latest().spread(function(batchNo, log) {
        if (log.length === 0) {
          success(chalk.cyan('Already up to date'));
        }
        success(chalk.green('Batch ' + batchNo + ' run: ' + log.length + ' migrations \n' + chalk.cyan(log.join('\n'))));
      }).catch(exit);
    });

  commander
    .command('migrate:rollback')
    .description('        Rollback the last set of migrations performed.')
    .action(function() {
      pending = initKnex(env).migrate.rollback().spread(function(batchNo, log) {
        if (log.length === 0) {
          success(chalk.cyan('Already at the base migration'));
        }
        success(chalk.green('Batch ' + batchNo + ' rolled back: ' + log.length + ' migrations \n') + chalk.cyan(log.join('\n')));
      }).catch(exit);
    });

  commander
    .command('migrate:currentVersion')
    .description('       View the current version for the migration.')
    .action(function () {
      pending = initKnex(env).migrate.currentVersion().then(function(version) {
        success(chalk.green('Current Version: ') + chalk.blue(version));
      }).catch(exit);
    });

  commander
    .command('seed:make <name>')
    .description('       Create a named seed file.')
    .option('-x [' + filetypes.join('|') + ']', 'Specify the stub extension (default js)')
    .action(function(name) {
      var instance = initKnex(env);
      var ext = (argv.x || env.configPath.split('.').pop()).toLowerCase();
      pending = instance.seed.make(name, {extension: ext}).then(function(name) {
        success(chalk.green('Created seed file: ' + name));
      }).catch(exit);
    });

  commander
    .command('seed:run')
    .description('       Run seed files.')
    .action(function() {
      pending = initKnex(env).seed.run().spread(function(log) {
        if (log.length === 0) {
          success(chalk.cyan('No seed files exist'));
        }
        success(chalk.green('Ran ' + log.length + ' seed files \n' + chalk.cyan(log.join('\n'))));
      }).catch(exit);
    });

  commander.parse(process.argv);

  Promise.resolve(pending).then(function() {
    commander.help();
  });
}
Example #26
0
server.listen(8080, () => {
    console.log(chalk.green('Server started.'));
});
Example #27
0
GhostServer.prototype.hammertime = function () {
    console.log(chalk.green(i18n.t('notices.httpServer.cantTouchThis')));

    return Promise.resolve(this);
};
Example #28
0
    port = 7357;
}

var logStream = fs.createWriteStream(__dirname + '/server.log', { flags: 'a' });

var app = express();

app.use(express.static(path.join(__dirname + '/../src')));
app.use(bodyParser.json());

if (process.env.NODE_ENV === 'production') {
    process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

    app.use(morgan('PROD :remote-addr - ' +
        chalk.cyan('[:date] ') +
        chalk.green('":method :url ') +
        chalk.gray('HTTP/:http-version" ') +
        chalk.yellow(':status ') +
        ':res[content-length] ' +
        chalk.gray('":referrer" ":user-agent" ') +
        'time=:response-time ms',
        {
            stream: logStream,
            skip: function(req) {
                "use strict";
                return !/api\/v1\/|sse\//.test(req.originalUrl);
            }
        }
    ));

    app.use(passport.initialize());
Example #29
0
    FF3B30 (copied)
    $ opaline ios red -f
    #FF3B30 (copied)
    $ opaline md red 500 -f -r
    rgb(244, 67, 54) (copied)
`]);

const palette = cli.input[0];
const color = cli.input[1];
const hue = cli.input[2] === undefined ? cli.input[2] : cli.input[2].toString();
const isRGB = (cli.flags.rgb || cli.flags.r) !== undefined;
const isFormat = (cli.flags.format || cli.flags.f) !== undefined;

let result;

try {
    if (isFormat) {
        result = isRGB ? opaline.rgb(palette, color, hue) : opaline.hex(palette, color, hue);
    } else {
        result = opaline.raw(palette, color, hue);
        result = isRGB ? `${result.r}, ${result.g}, ${result.b}` : result.hex;
    }

    clipboard.copy(result);
    console.log(result + chalk.green(' (copied)'));
    process.exit(0);
} catch (err) {
    console.error('No matching color. See --help.');
    process.exit(1);
}
Example #30
0
exports.init = function(name, options) {
  if (!shell.which('git')) return console.log(chalk.red('    Prerequisite not installed: git'));

  var source = (options.git ? 'git@github.com:linnovate/mean.git' : 'https://github.com/linnovate/mean.git');

  // Allow specifying specific repo
  if (options.repo) {
    source = options.repo;
  }

  console.log(chalk.green('Cloning branch: %s into destination folder:'), options.branch, name);

  progress.start();
  source = options.branch + ' ' + source + ' ' + name;
  shell.exec('git clone -b ' + source, function(code, output) {
    progress.stop();
    if (code) return console.log(chalk.red('Error: git clone failed:', output));

    loadPackageJson('./' + name + '/package.json', function(err, data) {
      if (err) {
        console.log(chalk.yellow('Something went wrong. Try again or use --git flag'));
        console.log(chalk.yellow('If the problem persists see past issues here: https://github.com/linnovate/mean/issues'));
        console.log(chalk.yellow('Or open a new issue here https://github.com/linnovate/mean/issues/new'));
        //fallback code here
        process.exit();
      }

      console.log(chalk.green('Version: %s cloned'), data.meanVersion);
      console.log();

      fs.readFile(__dirname + '/../img/logo.txt', function(err, data) {
        console.log(data.toString());
        console.log();

        shell.cd(name);
        shell.exec('git remote rename origin upstream', function(code) {
          if (!code) {
            console.log('   git remote upstream set');
            console.log();
          }
        });

        var grunted = shell.which('grunt');

        if (options.quick) {
          npm.load(function(err, npm) {
            console.log(chalk.green('   installing dependencies...'));
            console.log();
            npm.commands.install(function(err) {
              if (err) {
                console.log(chalk.red('Error: npm install failed'));
                return console.error(err);
              }
              console.log(chalk.green('   running the mean app...'));
              console.log();
              if (grunted) {
                shell.exec('grunt', ['-f']);
              } else {
                shell.exec('node server');
              }
            });
          });
        } else {
          console.log('   install dependencies:');
          console.log('     $ cd %s && npm install', name);
          console.log();
          console.log('   run the app:');
          console.log('     $', grunted ? 'grunt' : 'node server');
          console.log();
        }
        console.log('   Extra Docs at http://mean.io');
        console.log();
      });
    });
  });
};