Ejemplo n.º 1
0
const parseCommandLine = function parseCommandLine() {
  let resourcePath = null;
  const version = app.getVersion();
  yargs
    .alias('d', 'dev')
      .boolean('d')
      .describe('d', 'Run in development mode.')
    .alias('h', 'help')
      .boolean('h')
      .describe('h', 'Print this usage message.')
    .alias('l', 'log-file')
      .string('l')
      .describe('l', 'Log all output to file.')
    .alias('r', 'resource-path')
      .string('r')
      .describe('r', 'Set the path to the App source directory and enable dev-mode.')
    .alias('t', 'test')
      .boolean('t')
      .describe('t', 'Run the specified specs and exit with error code on failures.')
    .alias('v', 'version')
      .boolean('v')
      .describe('v', 'Print the version.');

  const args = yargs.parse(process.argv.slice(1));
  process.stdout.write(`${JSON.stringify(args)}\n`);
  if (args.help) {
    let help = '';
    yargs.showHelp((s) => { help += s; });
    process.stdout.write(`${help}\n`);
    process.exit(0);
  }
  if (args.version) {
    process.stdout.write(`${version}\n`);
    process.exit(0);
  }
  let devMode = args.dev;
  const test = args.test;
  const exitWhenDone = test;
  const logFile = args['log-file'];
  if (args['resource-path']) {
    devMode = true;
    resourcePath = args['resource-path'];
    if (devMode) {
      if (resourcePath == null) {
        resourcePath = global.devResourcePath;
      }
    }
  }
  if (!fs.statSyncNoException(resourcePath)) {
    resourcePath = path.join(process.resourcesPath, 'app.asar');
  }
  resourcePath = path.resolve(resourcePath);
  return {
    resourcePath,
    devMode,
    test,
    exitWhenDone,
    logFile,
  };
};
Ejemplo n.º 2
0
/**
 * This package exports a function that binds tasks to a gulp instance
 * based on the provided config.
 */
function initTasks(gulp, _config) {
  const args = yargs
    .alias('p', 'production')
    .argv;
  let config = prepareConfig(_config);

  gutil.log('[react-component-tools] init...');

  gulp.task('env', () => {
    process.env.NODE_ENV = args.production ? 'production' : 'development'; // eslint-disable-line no-undef
  });

  require('./gulp/bump')(gulp, config);
  require('./gulp/dev')(gulp, config);
  require('./gulp/dist')(gulp, config);
  require('./gulp/release')(gulp, config);

  let buildTasks = ['build:dist'];
  let cleanTasks = ['clean:dist'];

  if (config.component.lib) {
    require('./gulp/lib')(gulp, config);
    buildTasks.push('build:lib');
    cleanTasks.push('clean:lib');
  }

  if (config.example) {
    require('./gulp/examples')(gulp, config);
    buildTasks.push('build:examples');
    cleanTasks.push('clean:examples');
  }

  gulp.task('build', buildTasks);
  gulp.task('clean', cleanTasks);
}
Ejemplo n.º 3
0
const config = () => {
  const config = yargs.alias('s', 'sources').
                       alias('o', 'out_file').
                       describe('o', 'file name for the output').
                       describe('s', 
                                'specify sources for ' +
                                'your reposting campaign. ').
                       demand(['sources', 'out_file']).
                       usage('Usage: $0 --sources [source1] [source2]...' +
                             ' --out_file [filename]').
                       array('sources').argv;
  
  return config;
}
Ejemplo n.º 4
0
import webpack from 'webpack';
import yargs from 'yargs';

export const options = yargs
  .alias('p', 'optimize-minimize')
  .alias('d', 'debug')
  .option('port', {
    default: '8080',
    type: 'string'
  })
  .argv;

export const jsLoader = 'babel';

const baseConfig = {
  entry: undefined,

  output: undefined,

  externals: undefined,

  module: {
    loaders: [
      { test: /\.js/, loader: jsLoader, exclude: /node_modules/ }
    ]
  },

  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify(options.optimizeMinimize ? 'production' : 'development')
Ejemplo n.º 5
0
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */

import yargs from 'yargs';
import semver from 'semver';

yargs
  .alias('r', 'release').describe('r', 'Create a release build, not a snapshot')
  .option('build-qualifier', {
    default: null
  });
const argv = yargs.argv;

export default function getVersion(pkg) {
  const { version } = pkg;
  if (!version) {
    throw new Error('No version found in package.json');
  }
  if (!semver.valid(version)) {
    throw new Error(`Version is not valid semver: ${version}`);
  }

  const snapshotText = (argv.release) ? '' : '-SNAPSHOT';
  const qualifierText = argv.buildQualifier ? '-' + argv.buildQualifier : '';
  return `${version}${qualifierText}${snapshotText}`;
}
Ejemplo n.º 6
0
/**
 * Webpack config
 */
import path from 'path';
import yargs from 'yargs';
import webpack from 'webpack';
import autoprefixer from 'autoprefixer';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import CleanWebpackPlugin from 'clean-webpack-plugin';
import CopyWebpackPlugin from 'copy-webpack-plugin';

/**
 * Environment type
 */
const {buildProduction, buildDevelopment} = yargs
  .alias('p', 'build-production')
  .alias('d', 'build-development')
  .argv;

let buildTest = !buildProduction && !buildDevelopment;

/**
 * Config
 * Reference: http://webpack.github.io/docs/configuration.html
 * This is the object where all configuration gets set
 */
let config = {};

/**
 * Entry
 * Reference: http://webpack.github.io/docs/configuration.html#entry
Ejemplo n.º 7
0
import path from 'path';
import gulp from 'gulp';
import gulpUtil from 'gulp-util';
import gulpBabel from 'gulp-babel';
import webpack from 'webpack';
import yargs from 'yargs';
import rimraf from 'rimraf';
import eslint from 'gulp-eslint';
import runSequence from 'run-sequence';
import fs from 'fs-extra';

import makeWebpackConfig from './makeWebpackConfig';
import {BUNDLE_DIR, ES6_COMPILE_DIR, SRC_DIR} from './constants';

const args = yargs
    .alias('d', 'debug')
    .argv;
const isDev = args.debug; // Debug mode, will produce uncompressed debug bundle, and watch src file changes

/////////////////////////////////////
// task for set up git hooks under "githooks" folder
gulp.task('githooks', function () {
    fs.readdirSync('githooks').forEach(function (filename) {
        fs.copySync(
            path.join('githooks', filename),
            path.join('.git', 'hooks', path.basename(filename, '.js'))
        );
    });
});

/////////////////////////////////////
import webpack from 'webpack';
import yargs from 'yargs';

const { optimizeMinimize } = yargs.alias('p', 'optimize-minimize').argv;
const nodeEnv = optimizeMinimize ? 'production' : 'development';

export default {
  entry: {
    'ReactRouterBootstrap': './src/index.js'
  },
  output: {
    path: './lib',
    filename: optimizeMinimize ? '[name].min.js' : '[name].js',
    library: 'ReactRouterBootstrap',
    libraryTarget: 'umd'
  },
  module: {
    loaders: [
      { test: /\.js$/, loader: 'babel', exclude: /node_modules/ }
    ]
  },
  externals: [
    {
      'react': {
        root: 'React',
        commonjs2: 'react',
        commonjs: 'react',
        amd: 'react'
      }
    },
    {
var path = require('path');
var yargs = require('yargs');

var options = yargs
      .alias('d', 'debug')
      .option('port', {
        default: '8080',
        type: 'string'
      })
      .argv;

var webpackDevServerAddr = 'http://localhost:' + options.port;

module.exports = {
  entry: [
    './client.js'
  ],
  output: {
    publicPath: options.debug ? webpackDevServerAddr + '/assets/' : '/assets/',
    filename: 'bundle.js',
    path: './assets'
  },
  module: {
    loaders: [
      { test: /\.js$/, exclude: /node_modules|Samples.js/, loader: 'babel?cacheDirectory', presets: ['es2015', 'react', 'stage-0'] },
      { test: /Samples.js/, loader: `transform/cacheable?brfs!babel` },
      { test: /\.json$/, loader: 'json' },
      { test: /\.css$|\.jpe?g$|\.gif$|\.png|\.ico$/, loader: 'file?name=[path][name].[ext]' },
    ]
  },
  node: {
var path = require("path");
var webpack = require("webpack");
var yargs = require("yargs");
var pjson = require("./package.json")

var args = yargs.alias("p", "production").argv;
var environment = args.production ? "production" : "development";
var dev = (environment === "development");
console.log("Environment: %s", environment);
console.log("Application: %s@%s", pjson.name, pjson.version);

process.env.BABEL_ENV = environment;
process.env.NODE_ENV = environment;

const define = {
    ENVIRONMENT: JSON.stringify(environment),
    APP_NAME: JSON.stringify(pjson.name),
    APP_VERSION: JSON.stringify(pjson.version),
    "process.env.NODE_ENV": JSON.stringify(environment),
    "process.env.BABEL_ENV": JSON.stringify(environment)
};

var entry = dev ? [
    "webpack-dev-server/client?http://localhost:3000",
    "webpack/hot/only-dev-server",
    "./src/index.js",
] : "./src/index.js";

var output =  {
    filename: "bundle.js",
    path: path.resolve(__dirname, "static"),
Ejemplo n.º 11
0
#!/usr/bin/env node

'use strict'

const yargs = require('yargs')

const pkgJSON = require('./package.json')
const server = require('./lib/server')
const generator = require('./lib/generator')

const GroupValues = ['package', 'version', 'path']
const Formats = ['svg', 'html', 'dot', 'data-url']
const Childrens = ['dep', 'parent']

const argv = yargs
  .alias('v', 'version')
  .alias('h', 'help')
  .alias('g', 'group')
  .alias('f', 'format')
  .alias('c', 'child')
  .alias('s', 'server').number('s')
  .argv

const appArg = argv._[0]

if (argv.version) {
  console.error(pkgJSON.version)
  process.exit(0)
}

if (argv.help || appArg === '?') {
Ejemplo n.º 12
0
// communicate with the other cli commands via a global variable.
global.wasCommand = false

const command = (fn) => {
  return function (...args) {
    global.wasCommand = true
    fn(...args)
  }
}

var libraryURI = process.env.BUGGY_LIBRARY_HOST || 'http://localhost:8088'

const spinner = ora()
global.buggyCliSpinner = spinner // TODO remove this global

var argv = yargs
  .alias('f', 'from')
  .describe('f', 'The source format.')
  .alias('t', 'to')
  .describe('t', 'The target format.')
  .alias('u', 'updateCache')
  .describe('u', 'Update the cache (do not use cached values).')
  .alias('r', 'require')
  .describe('r', 'Add toolchain requirements to activate certain tools like "typify" to enable resolving types.')
  .array('r')
  .alias('l', 'library')
  .describe('l', 'Library URI for the component library. Defaults to BUGGY_LIBRARY_HOST or "http://localhost:8088".')
  .default('l', libraryURI)
  .global(['updateCache', 'from', 'to', 'library', 'require'])
  .demandOption('t')
  .command('list-inputs', 'List all available input types', command(() => console.log(Format.tools(ToolAPI.inputs(Toolchain, NPM)))))
  .commandDir('cli')
Ejemplo n.º 13
0
var yargs = require("yargs");
var config = require("./config");

var argv = yargs
	.alias("rel", "release")
	.default("rel", false)

	.choices("bump", ["major", "minor", "patch", "prerelease"])
	.default("bump", "patch")

	.default("versionSuffix", "rc")
	.default("reporter", config.test.reporters)

	.default("browser", config.test.browsers)
	.array("browser")

	.default("continueOnError", false)

	.argv;

module.exports = {
	bump: argv.bump,
	versionSuffix: argv.versionSuffix.toLowerCase(),
	isRelease: argv.rel,
	reporter: argv.reporter,
	browser: argv.browser,
	continueOnError: argv.continueOnError
};
Ejemplo n.º 14
0
/* eslint no-var:0 */
var webpack = require('webpack');
var yargs = require('yargs');

var options = yargs
  .alias('p', 'optimize-minimize')
  .alias('d', 'debug')
  .argv;

var config = {
  entry: './src/vizceral.js',
  output: {
    path: './dist',
    filename: options.optimizeMinimize ? 'vizceral.min.js' : 'vizceral.js',
    library: 'Vizceral',
    libraryTarget: 'umd'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel',
        exclude: /node_modules/,
      },
      { test: /\.woff2?$/, loader: 'url?limit=10000&mimetype=application/font-woff' },
      { test: /\.otf$/, loader: 'file' },
      { test: /\.ttf$/, loader: 'file' },
      { test: /\.eot$/, loader: 'file' },
      { test: /\.svg$/, loader: 'url' },
      { test: /\.html$/, loader: 'html' },
      { test: /\.css$/, loader: 'style!css' }
Ejemplo n.º 15
0
    pool.connect((err, client, done) => {
        if (err) {
            //likely a connection error that will print to console.
            done();
            throw err;
        }
        client.query(query, argsArray, (err, results) => {
            done(); //call done to release the client to the connection pool.
            callback(err, results); //make it the callers responsiblity for checking for query errors.
        });
    });
}

const yargs = require('yargs');

const args = yargs
    .alias('i', 'orderId')
    .describe('i', 'order id to operate on')
    .alias('b', 'bookId')
    .describe('b', 'book id to operate on')
    .alias('q', 'quantity')
    .describe('q', 'the quantity of the book')
    .alias('a', 'action')
    .demand('a')
    .describe('a', 'action to take [create, addItem, removeItem, updateItem, list, delete]')
    .argv;

require('console.table');

function printer(words) {
    return function(err, results) {
        if (err) {
Ejemplo n.º 16
0
    pool.connect((err, client, done) => {
        if (err) {
            //likely a connection error that will print to console.
            done();
            throw err;
        }
        client.query(query, argsArray, (err, results) => {
            done(); //call done to release the client to the connection pool.
            callback(err, results); //make it the callers responsiblity for checking for query errors.
        });
    });
}

const yargs = require('yargs');

const args = yargs
    .alias('f', 'firstName')
    .describe('f', 'first name')
    .alias('l', 'lastName')
    .describe('l', 'last name')
    .alias('p', 'phone')
    .describe('p', 'phone number')
    .alias('e', 'email')
    .describe('e', 'email')
    .alias('a', 'action')
    .demand('a')
    .describe('a', 'action to take [update, create]')
    .alias('i', 'id')
    .describe('i', 'customer id for an update')
    .argv;

if (args.action === 'create') {
Ejemplo n.º 17
0
    pool.connect((err, client, done) => {
        if (err) {
            //likely a connection error that will print to console.
            done();
            throw err;
        }
        client.query(query, argsArray, (err, results) => {
            done(); //call done to release the client to the connection pool.
            callback(err, results); //make it the callers responsiblity for checking for query errors.
        });
    });
}

const yargs = require('yargs');

const args = yargs
    .alias('a', 'action')
    .demand('a')
    .describe('a', 'action to take [list]')
    .argv;


if (args.action === 'list') {
    runQuery('select id, title from books', [], (err, results) => {
        if (err) {
            throw err;
        }
        console.log('id', 'title');
        _.each(results.rows, (r) => {
            console.log(r.id, r.title);
        });
        process.exit();
import _ from "lodash";
import webpack from "webpack";
import strategies from "./strategies";
import yargs from "yargs";

const argv = yargs
  .alias("p", "optimize-minimize")
  .alias("d", "debug")
  .alias("s", "dev-server")
  .argv;

const defaultOptions = {
  development: argv.debug,
  docs: false,
  test: false,
  optimize: argv.optimizeMinimize,
  devServer: argv.devServer,
  separateStylesheet: argv.separateStylesheet,
  prerender: argv.prerender,
};

export default (options) => {
  options = _.merge({}, defaultOptions, options);

  options.publicPath = options.devServer ? "//localhost:2992/_assets/" : "";
  const environment = options.test || options.development ? "development" : "production";
  const babelLoader = "babel?optional[]=es7.objectRestSpread&optional[]=runtime";
  const reactLoader = options.development ? `react-hot!${babelLoader}` : babelLoader;
  const chunkFilename = (options.devServer ? "[id].js" : "[name].js") +
    (options.longTermCaching && !options.prerender ? "?[chunkhash]" : "");
Ejemplo n.º 19
0
import bg from 'gulp-bg';
import eslint from 'gulp-eslint';
import gulp from 'gulp';
import makeWebpackConfig from './webpack/makeconfig';
import path from 'path';
import runSequence from 'run-sequence';
import webpackBuild from './webpack/build';
import webpackDevServer from './webpack/devserver';
import yargs from 'yargs';
import {Server as KarmaServer} from 'karma';

const args = yargs
  .alias('p', 'production')
  .argv;

const runKarma = ({singleRun}, done) => {
  const server = new KarmaServer({
    configFile: path.join(__dirname, 'karma.conf.js'), // eslint-disable-line no-undef
    singleRun: singleRun
  }, done);
  server.start();
};

const runEslint = () => {
  return gulp.src([
    'gulpfile.babel.js',
    'src/**/*.js',
    'webpack/*.js',
    '!**/__tests__/*.*'
  ])
  .pipe(eslint())
Ejemplo n.º 20
0
#!/usr/bin/env node
'use strict'
var abbrev = require('abbrev')
var argv = require('yargs')
var icons = require('../')

// help
argv.help('help')
argv.alias('h', 'help')

// register abbreviated aliases
var abbrevs = abbrev(['help', 'size', 'format'])
var aliases = Object.keys(abbrevs)
aliases.forEach(function (alias) {
  if (alias !== abbrevs[alias]) {
    argv.alias(alias, abbrevs[alias])
  }
})

// document options
argv.option('size', {
  description: 'number of pixels (width) or string identifiying the icon image'
})
argv.option('format', {
  description: 'format of the output to stdout (csv or json)'
})

// will show up in help
argv.usage('Usage: android-icons [options]')

argv.example('$ android-icons --size 48', 'mdpi.png,48')
Ejemplo n.º 21
0
 topic: function(){
   var yargsInstance = yargs.alias('v', 'verbose').default('v', 'false');
   return [yargsInstance, new nconf.Argv(yargsInstance)];
 },
Ejemplo n.º 22
0
aliases.forEach(function (alias) {
  if (alias !== abbrevs[alias]) {
    argv.alias(alias, abbrevs[alias])
  }
})
Ejemplo n.º 23
0
/* eslint-env node */
'use strict';

var bg = require('gulp-bg');
var eslint = require('gulp-eslint');
var gulp = require('gulp');
var makeWebpackConfig = require('./webpack/makeconfig');
var webpackBuild = require('./webpack/build');
var webpackDevServer = require('./webpack/devserver');
var yargs = require('yargs');
var del = require('del');

var args = yargs
  .alias('p', 'production')
  .argv;

gulp.task('env', function() {
  process.env.NODE_ENV = args.production ? 'production' : 'development';
});

gulp.task('build-webpack-production', webpackBuild(makeWebpackConfig(false)));
gulp.task('build-webpack-dev', webpackDevServer(makeWebpackConfig(true)));

gulp.task('eslint', function() {
  return gulp.src([
    'gulpfile.js',
    'src/**/*.js',
    'webpack/*.js'
  ])
  .pipe(eslint())
  .pipe(eslint.format())
Ejemplo n.º 24
0
import _ from 'lodash';
import webpack from 'webpack';
import strategies from './strategies';
import yargs from 'yargs';

const argv = yargs
  .alias('p', 'optimize-minimize')
  .alias('d', 'debug')
  .argv;

const defaultOptions = {
  development: argv.debug,
  docs: false,
  test: false,
  optimize: argv.optimizeMinimize
};

export default (options) => {
  options = _.merge({}, defaultOptions, options);
  const environment = options.development ? 'development' : 'production';

  const config = {
    entry: {
      'react-bootstrap': './src/main.js'
    },

    output: {
      path: './dist',
      filename: '[name].js',
      library: 'ReactBootstrap',
      libraryTarget: 'umd'
Ejemplo n.º 25
0
const
  DEFAULT_CONFIG = {
    'http': {
      'host': process.env.KERUWAWA_HTTP_HOST || '127.0.0.1',
      'port': process.env.KERUWAWA_HTTP_PORT || 5000
    },
    'db': {
      'host': '127.0.0.1',
      'user': '******',
      'password': '',
      'database': 'timesheet'
    }
  },

  argv = yargs
    .alias('c', 'configfile')
    .argv

let
  fileConfig = {}

if(argv.configfile) {
  try {
    fileConfig = JSON.parse(readFileSync(argv.configfile, 'utf8'))
  }
  catch(e) { /* noop */ }
}

export default deepAssign({}, DEFAULT_CONFIG, fileConfig)
Ejemplo n.º 26
0
var cwd = process.cwd();
var fs = require('fs');
var path = require('path');
var glob = require('glob');
var complement = require('./complement');
var noop = function() {};
var logger = console.log;
var log;
var chalk = require('chalk');
var yargs = require('yargs');
var argv = yargs.alias('config', 'c')
    .describe('c', 'Load a config file by path - for relative paths see CWD and __dirname below')
    .alias('merge-default-config', 'm')
    .boolean('m')
    .describe('m', 'Just use this flag to merge supplied config with default config')
    .alias('ignore-default-config', 'i')
    .boolean('i')
    .describe('i', 'Just use this flag to ignore default config (no merging)')
    .alias('verbose', 'v')
    .boolean('v')
    .describe('v', 'Use this flag to log errors, infos, etc.')
    .epilog('Copyright 2016 Andreas Deuschlinger (MIT Licensed)')
    .help()
    .argv;

function load(options, done) {
    var configs;
    var globPattern;
    var verbose = options.verbose || argv.verbose;

    // set log function