Ejemplo n.º 1
0
export const deploy = co.wrap(function *(files, options, AWSOptions, s3Options, clientOptions = {}) {
  AWSOptions = clone(AWSOptions, true);
  s3Options = clone(s3Options, true);
  const cwd = options.cwd;
  const filePrefix = options.filePrefix || '';

  AWS.config.update(Object.assign({
    sslEnabled: true
  }, AWSOptions));

  var client = new AWS.S3(clientOptions);

  yield Promise.all(files.map(function(filePath) {
    return handleFile(filePath, cwd, filePrefix, client, s3Options);
  }));
});
Ejemplo n.º 2
0
  function builder() {
    if (arguments.length > keys.length) {
      throw new Error(
        `t.${type}: Too many arguments passed. Received ${arguments.length} but can receive ` +
        `no more than ${keys.length}`
      );
    }

    let node = {};
    node.type = type;

    let i = 0;

    for (let key of (keys: Array<string>)) {
      let field = t.NODE_FIELDS[type][key];

      let arg = arguments[i++];
      if (arg === undefined) arg = loClone(field.default);

      node[key] = arg;
    }

    for (let key in node) {
      validate(node, key, node[key]);
    }

    return node;
  }
Ejemplo n.º 3
0
/**
 * Invoked when a user submits the <QueryForm>.
 * @param {Event|Object} e The native or React event.
 */
function handleSubmit(e) {
  e.preventDefault();

  let paramsClone = clone(params.get());

  // Construct a "Query Parameter" dimension string based off this report
  let paramsToTrack = pick(paramsClone,
      ['start-date', 'end-date', 'metrics', 'dimensions']);
  // Don't run `encodeURIComponent` on these params because the they will
  // never contain characters that make parsing fail (or be ambiguous).
  // NOTE: Manual serializing is requred until the encodeURIComponent override
  // is supported here: https://github.com/Gozala/querystring/issues/6
  let serializedParamsToTrack = map(paramsToTrack,
      (value, key) => `${key}=${value}`).join('&');

  // Set it on the tracker so it gets sent with all Query Explorer hits.
  ga('set', 'dimension2', serializedParamsToTrack);

  state.set({
    isQuerying: true,
    report: {
      params: paramsClone
    }
  });
}
Ejemplo n.º 4
0
Dispatcher.prototype._dispatch = function(action) {
  if(!action || !action.type) {
    throw new Error('Can only dispatch actions with a \'type\' property');
  }

  if(this.currentDispatch) {
    var complaint = 'Cannot dispatch an action (\'' + action.type + '\') while another action (\'' +
                    this.currentActionType + '\') is being dispatched';
    throw new Error(complaint);
  }

  this.waitingToDispatch = _clone(this.stores);

  this.currentActionType = action.type;
  this.currentDispatch   = _mapValues(this.stores, function() {
    return { resolved: false, waitingOn: [], waitCallback: null };
  });

  try {
    this.doDispatchLoop(action);
  }
  finally {
    this.currentActionType = null;
    this.currentDispatch   = null;
  }
};
Ejemplo n.º 5
0
function destroySuccess(state, action) {
  const books = clone(state.books)
  books.splice(indexOfBook(state, action.id), 1)
  return {
    ...state,
    books
  }
}
Ejemplo n.º 6
0
function CharmeleonWatcher(opts){
  delete require.cache[__filename];
  this._childCwd = path.dirname(module.parent.filename);

  this.closed = false; // from chokidar
  this._child = null;
  this._paths = [];
  this._opts = clone(opts);
}
Ejemplo n.º 7
0
/**
 * Invoked when a user submits the <QueryForm>.
 * @param {Event|Object} e The native or React event.
 */
function handleSubmit(e) {
  e.preventDefault();
  state.set({
    isQuerying: true,
    report: {
      params: clone(params.get())
    }
  });
}
Ejemplo n.º 8
0
    it('should work with arrays inside JSON', function() {
      var cameledPostCloned =  iwUtils.toCamel(clone(postJson, true));

      cameledPostCloned.categories[0].name = 'Linux';

      var syncedObject = iwUtils.syncObjects(postJson, cameledPostCloned);

      assert.equal(syncedObject.categories[0].name, 'Linux');
    });
Ejemplo n.º 9
0
/**
 * Invoked when the DataChart component's "error" event emits.
 * @param {Object} data The error emitted by the DataChart's "error" event.
 */
function handleDataChartError(err) {
  state.set({
    isQuerying: false,
    report: {
      accountData: clone(state.get('selectedAccountData')),
      params: state.get('report').params,
      error: err.error
    }
  });
}
Ejemplo n.º 10
0
    this.__adapter.onDone((attr) => {
      /**
       * GET Resource case
       */
      this.attr = toCamel(clone(attr, true));
      storage.store(this);
      original[this.type + this.__unique] = attr;

      defer.resolve(this);
    }).ajax('get', this.address, false);
Ejemplo n.º 11
0
/**
 * Invoked when the DataChart component's "success" event emits.
 * @param {Object} data The object emitted by the DataChart's "success" event.
 */
function handleDataChartSuccess(data) {
  state.set({
    isQuerying: false,
    report: {
      accountData: clone(state.get('selectedAccountData')),
      params: state.get('report').params,
      response: data.response
    }
  });
}
Ejemplo n.º 12
0
  static createBareOptions() {
    let opts = {};

    for (let key in config) {
      let opt = config[key];
      opts[key] = clone(opt.default);
    }

    return opts;
  }
Ejemplo n.º 13
0
function updateSuccess(state, action) {
  const books = clone(state.books)
  books[indexOfBook(state, action.book.id)] = action.book
  return {
    ...state,
    updateBook: action.book,
    updateBooksErrors: [],
    books,
    updateIsSuccess: true
  }
}
Ejemplo n.º 14
0
  constructor(plugin: Object) {
    super();

    this.initialized = false;
    this.raw         = assign({}, plugin);

    this.manipulateOptions = this.take("manipulateOptions");
    this.post              = this.take("post");
    this.pre               = this.take("pre");
    this.visitor           = this.normalize(clone(this.take("visitor")) || {});
  }
Ejemplo n.º 15
0
exports.Property = function (node, parent, scope, context, file) {
  if (node.method) {
    node.method = false;
    nameMethod.property(node, file, scope);
  }

  if (node.shorthand) {
    node.shorthand = false;
    node.key = t.removeComments(clone(node.key));
  }
};
Ejemplo n.º 16
0
  function createElement(w, h, type, deParent, onload) {
    var de = document.createElement(type)
    de.style.width = w + 'px'
    de.style.height = h + 'px'
    de.style.backgroundColor = takeOne(colors)
    de.style.boxShadow = '1px 1px 4px 0px rgba(50, 50, 50, 0.75)'
    de._handlerTransform = clone(INIT_TRANSFORM)

    de.onload = onload

    place(de, deParent)

    return de
  }
Ejemplo n.º 17
0
    it('should work with large JSON objects', function() {
      var cameledPostCloned =  iwUtils.toCamel(clone(postJson, true)),
          syncedObject;

      cameledPostCloned.processedCover = 'test.jpg';
      cameledPostCloned.blog.userBlog.blog.domainChangeCount = 100;
      cameledPostCloned.blog.userBlog.onepager.processedCover = 'img.jpg';

      syncedObject = iwUtils.syncObjects(postJson, cameledPostCloned);

      assert.equal(syncedObject.processed_cover, 'test.jpg');
      assert.equal(syncedObject.blog.user_blog.blog.domain_change_count, 100);
      assert.equal(syncedObject.blog.user_blog.onepager.processed_cover, 'img.jpg');
    });
Ejemplo n.º 18
0
AlgoliaSearchParse.prototype._request = function(rawUrl, opts) {
  /* global Parse */
  var clone = require('lodash/lang/clone');
  var promise = new Parse.Promise();

  debug('url: %s, opts: %j', rawUrl, opts);

  var parseReqOpts = {
    url: rawUrl,
    headers: clone(opts.headers),
    method: opts.method,
    success: success,
    error: error
  };

  if (opts.body) {
    // parse is proxing our requests and requires us to set a charset. while json is always utf-8
    parseReqOpts.headers['content-type'] = 'application/json;charset=utf-8';
    parseReqOpts.body = opts.body;
  }

  Parse.Cloud.httpRequest(parseReqOpts);

  function error(res) {
    debug('error: %j  - %s %j', res, rawUrl, opts);

    // we still resolve, bc Parse does not distinguish network errors
    // from 400/500 statuses
    promise.resolve({
      statusCode: res.status,
      body: res.data,
      headers: res.headers
    });
  }

  function success(res) {
    debug('success: %j  - %s %j', res, rawUrl, opts);

    promise.resolve({
      statusCode: res.status,
      body: res.data,
      headers: res.headers
    });
  }

  return promise;
};
Ejemplo n.º 19
0
const compact = (o) => {
  let cloned = clone(o);

  if (isArray(cloned) || isPlainObject(cloned)) {
    each(cloned, (v, k) => {
      let newV = compact(v);

      if (isEmpty(newV) && !isNumber(newV) && !isBoolean(newV)) {
        delete cloned[k];
      } else {
        cloned[k] = newV;
      }
    });
  }

  return cloned;
};
Ejemplo n.º 20
0
    var end = function () {
      var opts2 = clone(opts);
      delete opts2.sourceMapRelative;
      delete opts2.extensions;
      delete opts2.global;
      opts2.filename = filename;

      try {
        var out = babel.transform(data, opts2).code;
      } catch(err) {
        stream.emit("error", err);
        stream.queue(null);
        return;
      }

      stream.queue(out);
      stream.queue(null);
    };
Ejemplo n.º 21
0
/**
 * Invoked when the DataChart component's "error" event emits.
 * @param {Object} data The error emitted by the DataChart's "error" event.
 */
function handleDataChartError(err) {
  state.set({
    isQuerying: false,
    report: {
      accountData: clone(state.get('selectedAccountData')),
      params: state.get('report').params,
      error: err.error
    }
  });

  ga('send', {
    hitType: 'event',
    eventCategory: 'query',
    eventAction: 'submit',
    eventLabel: `(${err.error.code}) ${err.error.message}`,
    metric2: 1
  });
}
Ejemplo n.º 22
0
/**
 * Invoked when the DataChart component's "success" event emits.
 * @param {Object} data The object emitted by the DataChart's "success" event.
 */
function handleDataChartSuccess(data) {
  state.set({
    isQuerying: false,
    report: {
      accountData: clone(state.get('selectedAccountData')),
      params: state.get('report').params,
      response: data.response
    }
  });

  ga('send', {
    hitType: 'event',
    eventCategory: 'query',
    eventAction: 'submit',
    eventLabel: '(200) OK',
    metric1: 1
  });
}
Ejemplo n.º 23
0
/**
 * Invoked when a user changes the ViewSelector2 instance.
 * @param {Object} data The object emited by the ViewSelector2's "changeView"
 * event.
 */
function handleViewSelectorChange(data) {
  let {account, property, view} = data;

  params.set('ids', data.ids);
  state.set('selectedAccountData', clone(data));

  tagData.getMetricsAndDimensions(
      account, property, view).then(function(data) {
    metrics = data.metrics;
    dimensions = data.dimensions;

    // TODO(philipwalton) This does need to happen after metrics and dimensions
    // potentially change, but it sould probably happen in an event handler
    // rather than here. Refactor once dimensions and metrics are moved to
    // be properties of `state`.
    setSortOptions();

    render();
  });
}
Ejemplo n.º 24
0
  bindLeafletEvents(next = {}, prev = {}) {
    const el = this.leafletElement;
    if (!el) return;

    const diff = clone(prev);
    forEach(prev, (cb, ev) => {
      if (!next[ ev ] || cb !== next[ ev ]) {
        delete diff[ ev ];
        el.off(ev, cb);
      }
    });

    forEach(next, (cb, ev) => {
      if (!prev[ ev ] || cb !== prev[ ev ]) {
        diff[ ev ] = cb;
        el.on(ev, cb);
      }
    });

    return diff;
  }
Ejemplo n.º 25
0
      this.__adapter.onDone((model) => {
        if (model.length) {
          /**
           * GET Collection case
           */
          model.forEach((item) => {
            models.push( new Model(type, item.id, item, this.__adapter) );
          });
          p.resolve(models);
        }
        else {
          /**
           * GET Resource case
           */
          this.attr = toCamel(clone(model, true));
          storage.store(this);
          original[this.type + this.__unique] = model;

          p.resolve(this);
        }
      }).onFail(() => {
Ejemplo n.º 26
0
	var chartSettings = map(bySeries.series, function(dataSeries, i) {
		var settings;
		// add data points to relevant scale
		scaleData = scaleData.concat(map(dataSeries.values, function(d) {
			return +d.value;
		}));

		if (chartProps.chartSettings[i]) {
			settings = chartProps.chartSettings[i];
		} else {
			settings = clone(chartgrid_defaults.chartSettings[0]);
			settings.colorIndex = i;
		}

		if (parseOpts.columnsChanged) {
			settings.label = dataSeries.name;
		} else {
			settings.label = settings.label || dataSeries.name;
		}

		return settings;
	});
Ejemplo n.º 27
0
  normalizeOptions(opts: Object) {
    opts = assign({}, opts);

    if (opts.filename) {
      var rcFilename = opts.filename;
      if (!isAbsolute(rcFilename)) rcFilename = path.join(process.cwd(), rcFilename);
      opts = resolveRc(rcFilename, opts);
    }

    //

    for (let key in opts) {
      if (key[0] === "_") continue;

      let option = File.options[key];
      if (!option) this.log.error(`Unknown option: ${key}`, ReferenceError);
    }

    for (let key in File.options) {
      let option = File.options[key];

      var val = opts[key];
      if (!val && option.optional) continue;

      if (val && option.deprecated) {
        throw new Error("Deprecated option " + key + ": " + option.deprecated);
      }

      if (val == null) {
        val = clone(option.default);
      }

      var optionParser = optionParsers[option.type];
      if (optionParser) val = optionParser(key, val, this.pipeline);

      if (option.alias) {
        opts[option.alias] = opts[option.alias] || val;
      } else {
        opts[key] = val;
      }
    }

    if (opts.inputSourceMap) {
      opts.sourceMaps = true;
    }

    // normalize windows path separators to unix
    opts.filename = slash(opts.filename);
    if (opts.sourceRoot) {
      opts.sourceRoot = slash(opts.sourceRoot);
    }

    if (opts.moduleId) {
      opts.moduleIds = true;
    }

    opts.basename = path.basename(opts.filename, path.extname(opts.filename));

    opts.ignore = util.arrayify(opts.ignore, util.regexify);
    opts.only   = util.arrayify(opts.only, util.regexify);

    defaults(opts, {
      moduleRoot: opts.sourceRoot
    });

    defaults(opts, {
      sourceRoot: opts.moduleRoot
    });

    defaults(opts, {
      filenameRelative: opts.filename
    });

    defaults(opts, {
      sourceFileName: opts.filenameRelative,
      sourceMapName:  opts.filenameRelative
    });

    //

    if (opts.externalHelpers) {
      this.set("helpersNamespace", t.identifier("babelHelpers"));
    }

    return opts;
  };
Ejemplo n.º 28
0
  normaliseOptions(opts: Object) {
    opts = this.opts = normaliseOptions(assign({}, opts));

    // resolve babelrc
    if (opts.filename) {
      var rcFilename = opts.filename;
      if (!isAbsolute(rcFilename)) rcFilename = path.join(process.cwd(), rcFilename);
      opts = resolveRc(rcFilename, opts);
    }

    // check for unknown options
    for (let key in opts) {
      if (key[0] === "_") continue;

      let option = File.options[key];
      if (!option) this.log.error(`Unknown option: ${key}`, ReferenceError);
    }

    // merge in environment options
    var envKey = process.env.BABEL_ENV || process.env.NODE_ENV || "development";
    if (opts.env) merge(opts, normaliseOptions(opts.env[envKey]));

    // normalise options
    for (let key in File.options) {
      let option = File.options[key];
      var val    = opts[key];

      // optional
      if (!val && option.optional) continue;

      // deprecated
      if (val && option.deprecated) {
        this.log.deprecate("Deprecated option " + key + ": " + option.deprecated);
      }

      // default
      if (val == null) val = clone(option.default);

      // validate
      if (val) val = validateOption(key, val, this.pipeline);

      // aaliases
      if (option.alias) {
        opts[option.alias] = opts[option.alias] || val;
      } else {
        opts[key] = val;
      }
    }

    if (opts.inputSourceMap) {
      opts.sourceMaps = true;
    }

    // normalize windows path separators to unix
    opts.filename = slash(opts.filename);
    if (opts.sourceRoot) {
      opts.sourceRoot = slash(opts.sourceRoot);
    }

    if (opts.moduleId) {
      opts.moduleIds = true;
    }

    opts.basename = path.basename(opts.filename, path.extname(opts.filename));

    opts.ignore = util.arrayify(opts.ignore, util.regexify);

    if (opts.only) {
      opts.only = util.arrayify(opts.only, util.regexify);
    }

    defaults(opts, {
      moduleRoot: opts.sourceRoot
    });

    defaults(opts, {
      sourceRoot: opts.moduleRoot
    });

    defaults(opts, {
      filenameRelative: opts.filename
    });

    defaults(opts, {
      sourceFileName: opts.filenameRelative,
      sourceMapTarget:  opts.filenameRelative
    });

    //

    if (opts.externalHelpers) {
      this.set("helpersNamespace", t.identifier("babelHelpers"));
    }

    return opts;
  };
var clone = require('lodash/lang/clone');

var partialObject = {
  objectID: 'dawg IE!',
  yaw: 'partial'
};

module.exports = [{
  object: 'index',
  methodName: 'partialUpdateObject',
  testName: 'index.partialUpdateObject(partialObject, cb)',
  callArguments: [partialObject],
  action: 'write',
  expectedRequest: {
    method: 'POST',
    body: clone(partialObject),
    URL: {
      pathname: '/1/indexes/%s/' + encodeURIComponent(partialObject.objectID) + '/partial'
    }
  }
}, {
  object: 'index',
  methodName: 'partialUpdateObject',
  testName: 'index.partialUpdateObject(partialObject, createIfNotExists=false, cb)',
  callArguments: [partialObject, false],
  action: 'write',
  expectedRequest: {
    method: 'POST',
    body: clone(partialObject),
    URL: {
      pathname: '/1/indexes/%s/' + encodeURIComponent(partialObject.objectID) + '/partial',
Ejemplo n.º 30
0
 return function (node) {
   if (node[bindingKey] === node[refKey]) {
     node[refKey] = t.removeComments(clone(node[refKey]));
   }
 };