Exemple #1
0
function Perfome(options) {
  options = options || {};

  this.project = options.project || Project.closestSync(process.cwd());
  this.name    = options.name || this.project.name();

  this.bowerDirectory = 'bower_components';

  this.options = merge(options, {
    loader: this.bowerDirectory + '/loader/loader.js',
    trees: {},
    jshintrc: {},
    environment: this.project.getEnvironment(),
  }, defaults);

  this.options.trees = merge(this.options.trees, {
    implementations: 'implementations',
    dependencies:    'dependencies',
    tests:           'tests'
  }, defaults);

  this.options.jshintrc = merge(this.options.jshintrc, {
    implementations: path.join(this.project.root, 'implementations'),
    benchmarks:      path.join(this.project.root, 'tests'),
  }, defaults);

  this.trees = this.options.trees;
}
Exemple #2
0
function EmberApp(options) {
  options = options || {};

  this.project = options.project || Project.closestSync(process.cwd());

  this.env  = process.env.EMBER_ENV || 'development';
  this.name = options.name || this.project.name();

  this.registry = options.registry || p.setupRegistry(this);

  var isProduction = this.env === 'production';

  this.tests   = options.hasOwnProperty('tests')   ? options.tests   : !isProduction;
  this.hinting = options.hasOwnProperty('hinting') ? options.hinting : !isProduction;

  this.options = merge(options, {
    es3Safe: true,
    wrapInEval: !isProduction,
    minifyCSS: {
      enabled: true,
      options: {}
    },
    minifyJS: {
      enabled: true,
      options: {
        mangle: true,
        compress: true
      }
    },
    fingerprint: {
      enabled: isProduction,
      exclude: [],
      extensions: ['js', 'css', 'png', 'jpg', 'gif'],
      prepend: '',
      replaceExtensions: ['html', 'css', 'js']
    },
    loader: 'vendor/loader/loader.js',
    trees: {},
    getEnvJSON: this.project.require('./config/environment')
  }, defaults);

  this.options.trees = merge(this.options.trees, {
    app:    'app',
    styles: 'app/styles',
    tests:  'tests',
    vendor: unwatchedTree('vendor'),
  }, defaults);

  this.importWhitelist     = {};
  this.legacyFilesToAppend = [];
  this.vendorStaticStyles  = [];
  this.otherAssetTrees     = [];
  this._importTrees        = [];

  this.trees = this.options.trees;

  this.populateLegacyFiles();
  this._notifyAddonIncluded();
}
Exemple #3
0
  run: function(commandOptions, rawArgs) {
    var blueprintName = rawArgs[0];

    if (!blueprintName) {
      return Promise.reject(new SilentError('The `ember generate` command requires a ' +
                                            'blueprint name be specified in this format:' +
                                            'E.g.`ember generate <blueprint-name> <entity-name> <options...>`' +
                                            'For more details, use `ember help`.'));
    }

    var Task = this.tasks.GenerateFromBlueprint;
    var task = new Task({
      ui: this.ui,
      analytics: this.analytics,
      project: this.project,
      testing: this.testing
    });

    var taskArgs = {
      args: rawArgs
    };

    var taskOptions = merge(taskArgs, commandOptions || {});

    if (this.project.initializeAddons) {
      this.project.initializeAddons();
    }

    return task.run(taskOptions);
  },
Exemple #4
0
module.exports = function(data, config) {

  // don't merge destinations...
  var dests;
  if (config.movable) {
    dests = config.movable.dests;
    delete config.movable.dests;
  }

  merge(data, config);

  // ...but use the new ones instead
  if (dests !== undefined)
    data.movable.dests = dests;

  // if a fen was provided, replace the pieces
  if (data.fen) {
    data.pieces = fen.read(data.fen);
    delete data.fen;
  }

  // forget about the last dropped piece
  data.movable.dropped = [];

  // fix move/premove dests
  if (data.selected) board.setSelected(data, data.selected);

  // no need for such short animations
  if (data.animation.duration < 10) data.animation.enabled = false;
};
Exemple #5
0
  run: function(commandOptions, rawArgs) {
    var blueprintName = rawArgs[0];
    var entityName    = rawArgs[1];

    if (!blueprintName) {
      return Promise.reject(new SilentError('The `ember destroy` command requires a ' +
                                            'blueprint name to be specified. ' +
                                            'For more details, use `ember help`.'));
    }

    if (!entityName) {
      return Promise.reject(new SilentError('The `ember destroy` command requires an ' +
                                            'entity name to be specified. ' +
                                            'For more details, use `ember help`.'));
    }

    var Task = this.tasks.DestroyFromBlueprint;
    var task = new Task({
      ui: this.ui,
      analytics: this.analytics,
      project: this.project
    });

    var taskArgs = {
      args: rawArgs
    };

    var taskOptions = merge(taskArgs, commandOptions || {});

    if (this.project.initializeAddons) {
      this.project.initializeAddons();
    }

    return task.run(taskOptions);
  },
Exemple #6
0
MarkdownColor.prototype.generateTokens = function (renderer) {
  var defaultTokens = {
    // ember-cli styles
    option: {
      name: 'option',
      token: '--option',
      pattern: /((--\w*\b)|(<options>))/g,
      render: renderStylesFactory(renderer, 'cyan')
    },
    default: {
      name: 'default',
      token: '(Default: default)',
      pattern: /(\(Default:\s.*\))/g,
      render: renderStylesFactory(renderer, 'cyan')
    },
    required: {
      name: 'required',
      token: '(Required)',
      pattern: /(\(Required\))/g,
      render: renderStylesFactory(renderer, 'cyan')
    }
  };

  var colorTokens = unshiftValue(colors.concat(backgroundColors).map(getToken), {}).reduce(setToken);
  return merge(colorTokens, defaultTokens);
};
 render:function() {
   var choices = ["Yes", "No"];
   var props = merge({}, this.props, {
     choices: choices
   });
   return AnswerMultipleChoiceQuestion(props);
 }
Exemple #8
0
  return this.addons.reduce(function(config, addon) {
    if (addon.config) {
      merge(config, addon.config(env, config));
    }

    return config;
  }, initialConfig);
 renderSurveyItem: function() {
   var ItemComponentClass = this.getSurveyItemClass();
   var props = merge({}, this.props.item.meta, {
     onCompleted: this.handleItemCompleted
   });
   return ItemComponentClass(props);
 },
  run: function(options) {
    var self = this;
    var name = options.args[0];

    var mainBlueprint  = this.lookupBlueprint(name, options.ignoreMissingMain);
    var testBlueprint  = this.lookupBlueprint(name + '-test', true);
    var addonBlueprint = this.lookupBlueprint(name + '-addon', true);

    if (options.ignoreMissingMain && !mainBlueprint) {
      return Promise.resolve();
    }

    var entity = {
      name: options.args[1],
      options: parseOptions(options.args.slice(2))
    };

    var blueprintOptions = {
      target: this.project.root,
      entity: entity,
      ui: this.ui,
      analytics: this.analytics,
      project: this.project,
      settings: this.settings,
      testing: this.testing,
      taskOptions: options
    };

    blueprintOptions = merge(blueprintOptions, options || {});

    return mainBlueprint[this.blueprintFunction](blueprintOptions)
      .then(function() {
        if (!testBlueprint) { return; }

        if (testBlueprint.locals === Blueprint.prototype.locals) {
          testBlueprint.locals = function(options) {
            return mainBlueprint.locals(options);
          };
        }

        var testBlueprintOptions = merge({} , blueprintOptions, { installingTest: true });

        return testBlueprint[self.blueprintFunction](testBlueprintOptions);
      })
      .then(function() {
        if (!addonBlueprint) { return; }

        if (!this.project.isEmberCLIAddon()) { return; }

        if (addonBlueprint.locals === Blueprint.prototype.locals) {
          addonBlueprint.locals = function(options) {
            return mainBlueprint.locals(options);
          };
        }

        var addonBlueprintOptions = merge({}, blueprintOptions, { installingAddon: true });

        return addonBlueprint[self.blueprintFunction](addonBlueprintOptions);
      }.bind(this));
  },
Exemple #11
0
Cli.prototype.runCurrentCommand = function() {
  var cmd = this.cmd;
  cmd = commandAliases[cmd] ? commandAliases[cmd] : cmd;
  var action = this.commands[cmd];

  if (cmd && !action) {
    this.ui.write('The specified command ' + chalk.underline(cmd) + ' is invalid, for avaiable options see `ember help`\n\n');
    return;
  }

  if (!action) {
    action = this.commands.help;
  }

  var opts = nopt(action.types, action.shorthands, this.argv);

  var options = merge({}, opts, {
    appRoot: process.cwd(),
    cliRoot: path.resolve(path.join(__dirname, '..'))
  });

  var args = options.argv.remain.slice();

  args.shift();
  args.push(options);

  setupEnvironment(action, options);
  return action.run.apply(action, args);
};
function UglifyWriter (inputTree, options) {
  if (!(this instanceof UglifyWriter)) {
    return new UglifyWriter(inputTree, options);
  }
  Writer.call(this, inputTree, options);
  this.options = merge({
    mangle: true,
    compress: true,
    sourceMapIncludeSources: true
  }, options);

  this.sourceMapConfig = merge({
    enabled: true,
    extensions: ['js']
  }, this.options.sourceMapConfig);

  this.inputTree = inputTree;
}
 return this.props.items.map(function(item) {
   var props = merge({}, {
     key: item.id,
     item: item,
     onCompleted: this.handleItemCompleted
   });
   var itemView = TakeSurveyItem(props);
   return itemView;
 }.bind(this));
Exemple #14
0
function cli(options) {
  var UI = options.UI || require('../ui');
  var Leek = options.Leek || require('leek');
  var Yam = options.Yam || require('yam');
  var config = new Yam('ember-cli');
  var leekOptions;

  var disableAnalytics = options.cliArgs &&
    (options.cliArgs.indexOf('--disable-analytics') > -1 ) ||
    config.get('disableAnalytics');

  var defaultLeekOptions = {
    trackingCode: trackingCode,
    globalName:   name,
    name:         clientId(),
    version:      version,
    silent:       disableAnalytics
  };

  if (config.get('leekOptions')) {
    leekOptions = merge(defaultLeekOptions, config.get('leekOptions'));
  } else {
    leekOptions = defaultLeekOptions;
  }

  var ui = new UI({
    inputStream:  options.inputStream,
    outputStream: options.outputStream
  });

  debug('leek: %o', leekOptions);
  var leek = new Leek(leekOptions);

  var project = Project.closest(process.cwd())
    .catch(function(reason) {
      if (reason instanceof Project.NotFoundError) {
        return Project.NULL_PROJECT;
      } else {
        throw reason;
      }
    });

  var environment = {
    tasks:    tasks,
    cliArgs:  options.cliArgs,
    commands: commands,
    project:  project,
    settings: config.getAll()
  };

  return new CLI({
    ui:        ui,
    analytics: leek,
    testing:   options.testing
  }).run(environment);
}
Exemple #15
0
  installBlueprint: function(install, packageName, extraArgs, blueprintOptions) {
    var blueprintName = this.findDefaultBlueprintName(packageName);

    var taskOptions = merge({
      args: [blueprintName].concat(extraArgs),
      ignoreMissingMain: true
    }, blueprintOptions || {});

    return install.run(taskOptions);
  },
Exemple #16
0
  installBlueprint: function(install, rawArgs, commandOptions) {
    var args = this.addBlueprintNameToArgs(rawArgs);

    var taskOptions = merge({
      args: args,
      ignoreMissingMain: true
    }, commandOptions || {});

    return install.run(taskOptions);
  },
Exemple #17
0
Command.prototype.parseArgs = function(commandArgs) {
  var knownOpts       = {}; // Parse options
  var commandOptions  = {};
  var ui              = this.ui;
  var commandName     = this.name;
  var parsedOptions;

  var assembleAndValidateOption = function(option) {
    if (parsedOptions[option.name] === undefined) {
      if (option.default !== undefined) {
        commandOptions[option.key] = option.default;
      } else if (option.required) {
        ui.write('The specified command ' + chalk.green(commandName) +
                 ' requires the option ' + chalk.green(option.name) + '.\n');
        return false;
      }
    } else {
      commandOptions[option.key] = parsedOptions[option.name];
    }
    return true;
  };

  if (this.works === 'insideProject') {
    if (!this.isWithinProject) {
      this.ui.write('You have to be inside an ember-cli project in order to use ' +
               'the ' + chalk.green(this.name) + ' command.\n');
      return null;
    }
  }

  if (this.works === 'outsideProject') {
    if (this.isWithinProject) {
      this.ui.write('You cannot use the '+  chalk.green(this.name) +
               ' command inside an ember-cli project.\n');
      return null;
    }
  }
  this.availableOptions.forEach(function(option) {
    knownOpts[option.name] = option.type;
  });

  parsedOptions = nopt(knownOpts, {}, commandArgs, 0);

  if (!this.availableOptions.every(assembleAndValidateOption)) {
    return null;
  }

  var options = merge(this.settings || {}, commandOptions || {});

  return {
    options: options,
    args: parsedOptions.argv.remain
  };
};
Exemple #18
0
Project.prototype.config = function(env) {
  var configPath = this.configPath();

  if (fs.existsSync(path.join(this.root, configPath + '.js'))) {
    var appConfig = this.require('./' + configPath)(env);
    var addonsConfig = this.getAddonsConfig(env, appConfig);

    return merge(addonsConfig, appConfig);
  } else {
    return this.getAddonsConfig(env, {});
  }
};
Exemple #19
0
Project.prototype.getAddonsConfig = function(env, appConfig) {
  this.initializeAddons();

  var initialConfig = merge({}, appConfig);

  return this.addons.reduce(function(config, addon) {
    if (addon.config) {
      merge(config, addon.config(env, config));
    }

    return config;
  }, initialConfig);
};
      .then(function() {
        if (!testBlueprint) { return; }

        if (testBlueprint.locals === Blueprint.prototype.locals) {
          testBlueprint.locals = function(options) {
            return mainBlueprint.locals(options);
          };
        }

        var testBlueprintOptions = merge({} , blueprintOptions, { installingTest: true });

        return testBlueprint[self.blueprintFunction](testBlueprintOptions);
      });
Exemple #21
0
/*
  Parses markdown and applies coloring to output by matching defined tokens and 
  applying styling. Default outputs chalk.js coloring for terminal output.
  Options:
    tokens: pass additional tokens in the following format:
    {
      name:{
        token: '(Reserved)', // example of token
        pattern: /(Reserved)/g, // regexp pattern
        render: function(string) { return string + '!'} // function that takes and returns a string
      }
    }
    
    markdownRenderer: pass a renderer object that will render your markdown
      See https://github.com/mikaelbr/marked-terminal for an example
    
    renderStyles: pass an object to render color styles, default is chalk.js

  @class MarkdownColor
  @constructor
  @param {Object} [options]
*/
function MarkdownColor(options) {
  var optionTokens = options && options.tokens || {};
  var renderStyles = options && options.renderStyles || chalk;
  var tokens = this.generateTokens(renderStyles);
  
  this.options = options || {};
  this.marked = marked;
  this.tokens = merge(tokens, optionTokens);
  this.markdownRenderer = options && options.markdownRenderer || new TerminalRenderer(
    {
      code: chalk.green
    }
  );

  var defaultOptions;
  defaultOptions = {
    renderer: this.markdownRenderer,
  };

  var markedOptions = merge(defaultOptions, this.options);
  this.marked.setOptions(markedOptions);
  return this;
}
      .then(function() {
        if (!addonBlueprint) { return; }

        if (!this.project.isEmberCLIAddon()) { return; }

        if (addonBlueprint.locals === Blueprint.prototype.locals) {
          addonBlueprint.locals = function(options) {
            return mainBlueprint.locals(options);
          };
        }

        var addonBlueprintOptions = merge({}, blueprintOptions, { installingAddon: true });

        return addonBlueprint[self.blueprintFunction](addonBlueprintOptions);
      }.bind(this));
module.exports = function(inputTree, options) {
  if (!options || !options.outputFile) {
    throw new Error("outputFile is required");
  }

  var config = merge({ enabled: true}, options.sourceMapConfig);
  if (config.enabled) {
    var extensions = (config.extensions || ['js']);
    for (var i=0; i<extensions.length; i++) {
      var ext = '.' + extensions[i].replace(/^\./,'');
      if (options.outputFile.slice(-1 * ext.length) === ext) {
        return new SourceMapAwareConcat(inputTree, options);
      }
    }
  }
  return new SimpleConcat(inputTree, options);
};
Exemple #24
0
module.exports = function(cfg) {

  var data = {
    puzzle: {
      opponentColor: util.opposite(cfg.puzzle.color)
    },
    progress: [],
    chess: chess.make(cfg.puzzle.fen)
  };

  merge(data, cfg);

  data.puzzle.initialMove = puzzle.str2move(data.puzzle.initialMove);
  data.showContinueLinks = m.prop(false);

  return data;
};
Exemple #25
0
StylePlugin.prototype.toTree = function(tree, inputPath, outputPath, options) {
  options = merge({}, this.options, options);
  var _this = this,
      paths = options.outputPaths;

  var trees = Object.keys(paths).map(function (file) {
    var ext = _this.getExt(inputPath, file);
    if (!ext) {
      return tree;
    }
    var input = path.join(inputPath, file + '.' + ext);
    var output = paths[file];

    return requireLocal(_this.name).call(null, [tree], input, output, options);
  });

  return mergeTrees(trees);
};
function EmberAddon(options) {
  options = options || {};
  process.env.EMBER_ADDON_ENV = process.env.EMBER_ADDON_ENV || 'development';

  this.appConstructor(merge(options, {
    name: 'dummy',
    configPath: './tests/dummy/config/environment',
    trees: {
      app: 'tests/dummy/app',
      styles: 'tests/dummy/app/styles',
      templates: 'tests/dummy/app/templates',
      tests: remove('tests', {path: 'dummy'})
    },
    jshintrc: {
      tests: './tests',
      app: './tests/dummy'
    },
  }, defaults));
}
  included: function(app, parentAddon) {
    var target = (parentAddon || app);
    var config = this.project.config(target.env);

    var options = {
      options: {
        compress: {
          global_defs: config.featureFlags
        }
      }
    };

    target.options.minifyJS = merge(target.options.minifyJS, options);
    this.enableCompile = target.options.minifyJS.enabled;

    if (!this.enableCompile) {
      return
    }

    target.registry.remove('template', 'broccoli-ember-hbs-template-compiler');
    target.registry.add('template', {
      name: 'conditional-compile-template',
      toTree: function(tree) {
        Object.keys(config.featureFlags).map(function(flag) {
          var replaceRegex = new RegExp(
            '{{#if-flag-' + flag + '}}([\\s\\S]*?)(?:{{\/if-flag-' + flag + '}}|(?:{{else}}([\\s\\S]*?){{\/if-flag-' + flag + '}}))',
            'gmi'
          );
          var replacement = config.featureFlags[flag] ? "$1" : "$2";
          tree = replace(tree, {
            files: ['**/*'],
            patterns: [{
              match: replaceRegex,
              replacement: replacement
            }]
          });
        });
        return templateCompiler(tree, {module: true});
      }
    }, ['hbs', 'handlebars']);
  },
module.exports = function defeatureifyConfig(opts) {
  var options    = opts || {};
  var features   = merge({}, options.features || configJson.features);
  var stripDebug = false;

  if (configJson.hasOwnProperty('stripDebug')) { stripDebug = configJson.stripDebug; }
  if (options.hasOwnProperty('stripDebug')) { stripDebug = options.stripDebug; }

  for (var flag in features) {
    if (features[flag] === 'development-only') {
      features[flag] = options.environment !== 'production';
    }
  }

  return {
    enabled:           features,
    debugStatements:   options.debugStatements || configJson.debugStatements,
    namespace:         options.namespace || configJson.namespace,
    enableStripDebug:  stripDebug
  };
};
  run: function(options) {
    var self = this;
    var name = options.args[0];

    var mainBlueprint = this.lookupBlueprint(name);
    var testBlueprint = this.lookupBlueprint(name + '-test', true);

    var entity = {
      name: options.args[1],
      options: parseOptions(options.args.slice(2))
    };

    var blueprintOptions = {
      target: this.project.root,
      entity: entity,
      ui: this.ui,
      analytics: this.analytics,
      project: this.project,
      testing: this.testing,
      taskOptions: options
    };

    blueprintOptions = merge(blueprintOptions, options || {});

    return mainBlueprint[this.blueprintFunction](blueprintOptions)
      .then(function() {
        if (!testBlueprint) { return; }

        if (testBlueprint.locals === Blueprint.prototype.locals) {
          testBlueprint.locals = function(options) {
            return mainBlueprint.locals(options);
          };
        }

        var testBlueprintOptions = merge({} , blueprintOptions, { installingTest: true });

        return testBlueprint[self.blueprintFunction](testBlueprintOptions);
      });
  },
  run: function(options) {
    var blueprint = Blueprint.lookup(options.args[0], {
      paths: this.project.blueprintLookupPaths()
    });

    var entity = {
      name: options.args[1],
      options: parseOptions(options.args.slice(2))
    };

    var uninstallOptions = {
      target: this.project.root,
      entity: entity,
      ui: this.ui,
      analytics: this.analytics,
      project: this.project
    };

    uninstallOptions = merge(uninstallOptions, options || {});

    return blueprint.uninstall(uninstallOptions);
  }