<commit_before>var main = require('./main.js');
var path = require('path');
var _ = require('underscore');
var fs = require('fs');
var util = require('util');
var files = require('./files.js');
var buildmessage = require('./buildmessage.js');
var project = require('./project.js').project;
var Future = require('fibers/future');
var utils = require('./utils.js');
var archinfo = require('./archinfo.js');
var tropohouse = require('./tropohouse.js');
var httpHelpers = require('./http-helpers.js');
var Console = require('./console.js').Console;
var processes = require('./processes.js');

// XXX hard-coded the use of default tropohouse
var tropo = tropohouse.default;
var webArchName = "web.cordova";

// android is available on all supported architectures
var availablePlatforms =
  project.getDefaultPlatforms().concat(["android", "firefoxos"]);

// ios is only available on OSX
if (process.platform === 'darwin') {
  availablePlatforms.push("ios");
}

// Borrowed from tropohouse
// The version in warehouse fails when run from a checkout.
// XXX: Rationalize
var cordovaWarehouseDir = function () {
  if (process.env.METEOR_WAREHOUSE_DIR)
    return process.env.METEOR_WAREHOUSE_DIR;

  var warehouseBase = files.inCheckout()
    ? files.getCurrentToolsDir() : process.env.HOME;
  return path.join(warehouseBase, ".meteor", "cordova");
};

var isValidPlatform = function (name) {
  if (name.match(/ios/i) && process.platform !== 'darwin') {
    throw new Error(name + ': not available on your system');
  }

  if (! _.contains(availablePlatforms, name)) {
    throw new Error(name + ': no such platform');
  }
};

var splitN = function (s, split, n) {
  if (n <= 1) {
    return s;
  }
  var tokens = s.split(split);
  if (tokens.length <= n) {
    return tokens;
  }
  var firstN = tokens.slice(0, n - 1);
  var tail = tokens.slice(n).join(split);
  firstN.push(tail);
  return firstN;
};

var cordova = exports;

// --- the public interface ---

// Builds a Cordova project that targets the list of 'platforms'
// options:
//   - appName: the target path of the build
//   - host
//   - port
cordova.buildPlatforms = function (localPath, platforms, options) {
  verboseLog('Running build for platforms:', platforms);
  checkRequestedPlatforms(platforms);

  _.each(platforms, function (platform) {
    requirePlatformReady(platform);
  });

  buildCordova(localPath, 'build', options);
};

cordova.buildPlatformRunners = function (localPath, platforms, options) {
  var runners = [];
  _.each(platforms, function (platformName) {
    runners.push(new CordovaRunner(localPath, platformName, options));
  });
  return runners;
};

// packages - list of strings
cordova.filterPackages = function (packages) {
// We hard-code the 'cordova' and 'platform' namespaces
  var ret = {
    rest: [],
    plugins: []
  };

  _.each(packages, function (p) {
    var namespace = p.split(':')[0];
    var name = p.split(':').slice(1).join(':');
    if (namespace === 'cordova') {
      ret.plugins.push(name);
    } else {
      ret.rest.push(p); // leave it the same
    }
  });
  return ret;
};

// --- helpers ---

var localCordova = path.join(files.getCurrentToolsDir(),
  "tools", "cordova-scripts", "cordova.sh");

var localAdb = path.join(files.getCurrentToolsDir(),
  "tools", "cordova-scripts", "adb.sh");

var localAndroid = path.join(files.getCurrentToolsDir(),
  "tools", "cordova-scripts", "android.sh");

var verboseness = false;
var setVerboseness = cordova.setVerboseness = function (v) {
  verboseness = !!v;
};
var verboseLog = cordova.verboseLog = function (/* args */) {
  if (verboseness)
    Console.stderr.write('%% ' + util.format.apply(null, arguments) + '\n');
};

<commit_msg>Put accidentally removed cordova.checkIsValidPlugin method back<commit_after>var main = require('./main.js');
var path = require('path');
var _ = require('underscore');
var fs = require('fs');
var util = require('util');
var files = require('./files.js');
var buildmessage = require('./buildmessage.js');
var project = require('./project.js').project;
var Future = require('fibers/future');
var utils = require('./utils.js');
var archinfo = require('./archinfo.js');
var tropohouse = require('./tropohouse.js');
var httpHelpers = require('./http-helpers.js');
var Console = require('./console.js').Console;
var processes = require('./processes.js');

// XXX hard-coded the use of default tropohouse
var tropo = tropohouse.default;
var webArchName = "web.cordova";

// android is available on all supported architectures
var availablePlatforms =
  project.getDefaultPlatforms().concat(["android", "firefoxos"]);

// ios is only available on OSX
if (process.platform === 'darwin') {
  availablePlatforms.push("ios");
}

// Borrowed from tropohouse
// The version in warehouse fails when run from a checkout.
// XXX: Rationalize
var cordovaWarehouseDir = function () {
  if (process.env.METEOR_WAREHOUSE_DIR)
    return process.env.METEOR_WAREHOUSE_DIR;

  var warehouseBase = files.inCheckout()
    ? files.getCurrentToolsDir() : process.env.HOME;
  return path.join(warehouseBase, ".meteor", "cordova");
};

var isValidPlatform = function (name) {
  if (name.match(/ios/i) && process.platform !== 'darwin') {
    throw new Error(name + ': not available on your system');
  }

  if (! _.contains(availablePlatforms, name)) {
    throw new Error(name + ': no such platform');
  }
};

var splitN = function (s, split, n) {
  if (n <= 1) {
    return s;
  }
  var tokens = s.split(split);
  if (tokens.length <= n) {
    return tokens;
  }
  var firstN = tokens.slice(0, n - 1);
  var tail = tokens.slice(n).join(split);
  firstN.push(tail);
  return firstN;
};

var cordova = exports;

// --- the public interface ---

// Builds a Cordova project that targets the list of 'platforms'
// options:
//   - appName: the target path of the build
//   - host
//   - port
cordova.buildPlatforms = function (localPath, platforms, options) {
  verboseLog('Running build for platforms:', platforms);
  checkRequestedPlatforms(platforms);

  _.each(platforms, function (platform) {
    requirePlatformReady(platform);
  });

  buildCordova(localPath, 'build', options);
};

cordova.buildPlatformRunners = function (localPath, platforms, options) {
  var runners = [];
  _.each(platforms, function (platformName) {
    runners.push(new CordovaRunner(localPath, platformName, options));
  });
  return runners;
};

// packages - list of strings
cordova.filterPackages = function (packages) {
// We hard-code the 'cordova' and 'platform' namespaces
  var ret = {
    rest: [],
    plugins: []
  };

  _.each(packages, function (p) {
    var namespace = p.split(':')[0];
    var name = p.split(':').slice(1).join(':');
    if (namespace === 'cordova') {
      ret.plugins.push(name);
    } else {
      ret.rest.push(p); // leave it the same
    }
  });
  return ret;
};

// used by packages commands
cordova.checkIsValidPlugin = function (name) {
  var pluginHash = {};
  pluginHash[name.split('@')[0]] = name.split('@')[1];

  // check that every plugin is specifying either an exact constraint or a
  // tarball url with sha
  utils.ensureOnlyExactVersions(pluginHash);
};

// --- helpers ---

var localCordova = path.join(files.getCurrentToolsDir(),
  "tools", "cordova-scripts", "cordova.sh");

var localAdb = path.join(files.getCurrentToolsDir(),
  "tools", "cordova-scripts", "adb.sh");

var localAndroid = path.join(files.getCurrentToolsDir(),
  "tools", "cordova-scripts", "android.sh");

var verboseness = false;
var setVerboseness = cordova.setVerboseness = function (v) {
  verboseness = !!v;
};
var verboseLog = cordova.verboseLog = function (/* args */) {
  if (verboseness)
    Console.stderr.write('%% ' + util.format.apply(null, arguments) + '\n');
};


{'fraction_non_alphanumeric': 0.16212727507422228, 'fraction_numerical': 0.0015489867045307862, 'mean_word_length': 3.897597977243995, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2235156', 'n_tokens_mistral': 2483, 'n_tokens_neox': 2457, 'n_words': 639}