1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 14:10:04 +02:00

integrate docker-compose-api into portal-data (#451)

this might break tests for now
This commit is contained in:
Sérgio Ramos 2017-05-16 16:54:39 +01:00 committed by Wyatt Preul
parent 813fe9f814
commit cf737aa2e7
22 changed files with 820 additions and 1449 deletions

View File

@ -11,7 +11,13 @@
],
"plugins": [
"babel-plugin-transform-flow-strip-types",
"external-helpers",
"istanbul"
]
"external-helpers"
],
"env": {
"test": {
"plugins": [
"istanbul"
]
}
}
}

158
docker-compose-client/dist/index.es.js vendored Normal file
View File

@ -0,0 +1,158 @@
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
var newArrowCheck = function (innerThis, boundThis) {
if (innerThis !== boundThis) {
throw new TypeError("Cannot instantiate an arrow function");
}
};
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
var _require = require('zerorpc');
var Client = _require.Client;
var _require2 = require('events');
var EventEmitter = _require2.EventEmitter;
var awaitify = require('apr-awaitify');
var DockerComposeClient = function (_EventEmitter) {
inherits(DockerComposeClient, _EventEmitter);
function DockerComposeClient() {
var _this2 = this;
var endpoint = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'tcp://0.0.0.0:4242';
classCallCheck(this, DockerComposeClient);
var _this = possibleConstructorReturn(this, (DockerComposeClient.__proto__ || Object.getPrototypeOf(DockerComposeClient)).call(this));
_this.client = new Client({
heartbeatInterval: 60 * 4 * 1000, // 4m
timeout: 60 * 30 });
_this.client.connect(endpoint);
_this.client.on('error', function (err) {
newArrowCheck(this, _this2);
return _this.emit('error', err);
}.bind(this));
_this._invoke = awaitify(_this._invoke.bind(_this));
return _this;
}
// Why isn't client.connect async with error??
createClass(DockerComposeClient, [{
key: '_invoke',
value: function _invoke(name) {
var _client;
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return (_client = this.client).invoke.apply(_client, [name].concat(args));
}
}, {
key: 'close',
value: function close() {
return this.client.close();
}
}, {
key: 'provision',
value: function provision(_ref) {
var projectName = _ref.projectName,
manifest = _ref.manifest;
// eslint-disable-next-line camelcase
return this._invoke('up', { project_name: projectName }, manifest);
}
}, {
key: 'scale',
value: function scale(_ref2) {
var _this3 = this;
var projectName = _ref2.projectName,
services = _ref2.services,
manifest = _ref2.manifest;
return this._invoke('scale', {
// eslint-disable-next-line camelcase
project_name: projectName,
services: Object.keys(services).map(function (name) {
newArrowCheck(this, _this3);
return {
name: name,
num: services[name]
};
}.bind(this))
}, manifest);
}
}]);
return DockerComposeClient;
}(EventEmitter);
module.exports = DockerComposeClient;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZXMuanMiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJjb25zdCB7IENsaWVudCB9ID0gcmVxdWlyZSgnemVyb3JwYycpO1xuY29uc3Qgey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DQUFZRixRQUFaLEVBQXNCRyxHQUF0QixDQUEwQjs7aUJBQVM7c0JBQUE7aUJBRXRDSCxTQUFTUCxJQUFUO1dBRjZCO1NBQTFCO09BTFAsRUFVTEssUUFWSyxDQUFQOzs7O0VBOUI4QmhCOztBQTZDbENzQixPQUFPQyxPQUFQLEdBQWlCckIsbUJBQWpCIn0=

166
docker-compose-client/dist/index.umd.js vendored Normal file
View File

@ -0,0 +1,166 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
var newArrowCheck = function (innerThis, boundThis) {
if (innerThis !== boundThis) {
throw new TypeError("Cannot instantiate an arrow function");
}
};
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
var _require = require('zerorpc');
var Client = _require.Client;
var _require2 = require('events');
var EventEmitter = _require2.EventEmitter;
var awaitify = require('apr-awaitify');
var DockerComposeClient = function (_EventEmitter) {
inherits(DockerComposeClient, _EventEmitter);
function DockerComposeClient() {
var _this2 = this;
var endpoint = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'tcp://0.0.0.0:4242';
classCallCheck(this, DockerComposeClient);
var _this = possibleConstructorReturn(this, (DockerComposeClient.__proto__ || Object.getPrototypeOf(DockerComposeClient)).call(this));
_this.client = new Client({
heartbeatInterval: 60 * 4 * 1000, // 4m
timeout: 60 * 30 });
_this.client.connect(endpoint);
_this.client.on('error', function (err) {
newArrowCheck(this, _this2);
return _this.emit('error', err);
}.bind(this));
_this._invoke = awaitify(_this._invoke.bind(_this));
return _this;
}
// Why isn't client.connect async with error??
createClass(DockerComposeClient, [{
key: '_invoke',
value: function _invoke(name) {
var _client;
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return (_client = this.client).invoke.apply(_client, [name].concat(args));
}
}, {
key: 'close',
value: function close() {
return this.client.close();
}
}, {
key: 'provision',
value: function provision(_ref) {
var projectName = _ref.projectName,
manifest = _ref.manifest;
// eslint-disable-next-line camelcase
return this._invoke('up', { project_name: projectName }, manifest);
}
}, {
key: 'scale',
value: function scale(_ref2) {
var _this3 = this;
var projectName = _ref2.projectName,
services = _ref2.services,
manifest = _ref2.manifest;
return this._invoke('scale', {
// eslint-disable-next-line camelcase
project_name: projectName,
services: Object.keys(services).map(function (name) {
newArrowCheck(this, _this3);
return {
name: name,
num: services[name]
};
}.bind(this))
}, manifest);
}
}]);
return DockerComposeClient;
}(EventEmitter);
module.exports = DockerComposeClient;
})));
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXgudW1kLmpzIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXguanMiXSwic291cmNlc0NvbnRlbnQiOlsiY29uc3QgeyBDbGllbnQgfSA9IHJlcXVpcmUoJ3plcm9ycGMnKTtcbmNvb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I7a0JBR1lJLE9BQU9DLElBQVAsQ0FBWUYsUUFBWixFQUFzQkcsR0FBdEIsQ0FBMEI7O2lCQUFTO3NCQUFBO2lCQUV0Q0gsU0FBU1AsSUFBVDtXQUY2QjtTQUExQjtPQUxQLEVBVUxLLFFBVkssQ0FBUDs7OztFQTlCOEJoQjs7QUE2Q2xDc0IsT0FBT0MsT0FBUCxHQUFpQnJCLG1CQUFqQjs7In0=

View File

@ -1,12 +1,8 @@
{
"name": "docker-compose-client",
"version": "1.0.0",
"private": true,
"description": "",
"license": "Apache-2.0",
"author": "Sérgio Ramos <mail@sergioramos.me>",
"version": "1.0.4",
"license": "MPL2.0",
"repository": "github:yldio/docker-compose-client",
"keywords": [],
"files": [
"dist"
],
@ -26,11 +22,11 @@
"dev-start": "npm run build && node ."
},
"dependencies": {
"apr-awaitify": "^1.0.2",
"apr-awaitify": "^1.0.4",
"zerorpc": "^0.9.7"
},
"devDependencies": {
"apr-intercept": "^1.0.2",
"apr-intercept": "^1.0.4",
"ava": "0.19.1",
"babel-eslint": "^7.2.3",
"babel-plugin-external-helpers": "6.22.0",
@ -39,15 +35,15 @@
"babel-preset-env": "1.4.0",
"babel-preset-flow": "^6.23.0",
"babelrc-rollup": "3.0.0",
"cross-env": "^4.0.0",
"cross-env": "^5.0.0",
"documentation": "4.0.0-rc.1",
"eslint": "3.19.0",
"eslint-config-prettier": "2.0.0",
"eslint-config-prettier": "2.1.0",
"eslint-config-xo-space": "^0.16.0",
"eslint-plugin-flowtype": "2.32.1",
"eslint-plugin-flowtype-errors": "3.2.0",
"eslint-plugin-flowtype": "2.33.0",
"eslint-plugin-flowtype-errors": "3.2.1",
"eslint-plugin-prettier": "^2.0.1",
"flow-bin": "0.45.0",
"flow-bin": "0.46.0",
"flow-typed": "^2.1.2",
"js-yaml": "^3.8.4",
"lint-staged": "3.4.1",

View File

@ -6,7 +6,11 @@ class DockerComposeClient extends EventEmitter {
constructor(endpoint = 'tcp://0.0.0.0:4242') {
super();
this.client = new Client();
this.client = new Client({
heartbeatInterval: 60 * 4 * 1000, // 4m
timeout: 60 * 30, // 30m
});
this.client.connect(endpoint);
this.client.on('error', err => this.emit('error', err));

View File

@ -129,9 +129,13 @@ append-transform@^0.4.0:
dependencies:
default-require-extensions "^1.0.0"
apr-awaitify@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/apr-awaitify/-/apr-awaitify-1.0.2.tgz#2c6889c783de5147fd61ac4421ba459e2dd9ca27"
apr-awaitify@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/apr-awaitify/-/apr-awaitify-1.0.4.tgz#a72074a0d333e090bb120be9f710fd106b48a90a"
apr-intercept@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/apr-intercept/-/apr-intercept-1.0.4.tgz#01c64345f4af647b6b04f5aba4755195429b061a"
aproba@^1.0.3:
version "1.1.1"
@ -962,6 +966,14 @@ babel-plugin-transform-strict-mode@^6.24.1:
babel-runtime "^6.22.0"
babel-types "^6.24.1"
babel-polyfill@^6.6.1:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.23.0.tgz#8364ca62df8eafb830499f699177466c3b03499d"
dependencies:
babel-runtime "^6.22.0"
core-js "^2.4.0"
regenerator-runtime "^0.10.0"
babel-preset-env@1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.4.0.tgz#c8e02a3bcc7792f23cded68e0355b9d4c28f0f7a"
@ -1143,8 +1155,8 @@ babelrc-rollup@3.0.0:
resolve "^1.1.7"
babylon@^6.1.0, babylon@^6.11.0, babylon@^6.11.4, babylon@^6.13.0, babylon@^6.15.0, babylon@^6.17.0:
version "6.17.0"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.0.tgz#37da948878488b9c4e3c4038893fa3314b3fc932"
version "6.17.1"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.1.tgz#17f14fddf361b695981fe679385e4f1c01ebd86f"
babylon@7.0.0-beta.8:
version "7.0.0-beta.8"
@ -1168,6 +1180,13 @@ binary-extensions@^1.0.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.8.0.tgz#48ec8d16df4377eae5fa5884682480af4d95c774"
"binary@>= 0.3.0 < 1":
version "0.3.0"
resolved "https://registry.yarnpkg.com/binary/-/binary-0.3.0.tgz#9f60553bc5ce8c3386f3b553cff47462adecaa79"
dependencies:
buffers "~0.1.1"
chainsaw "~0.1.0"
bindings@~1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.2.1.tgz#14ad6113812d2d37d72e67b4cacb4bb726505f11"
@ -1245,6 +1264,10 @@ buffer-shims@^1.0.0, buffer-shims@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51"
buffers@~0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/buffers/-/buffers-0.1.1.tgz#b24579c3bed4d6d396aeee6d9a8ae7f5482ab7bb"
builtin-modules@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
@ -1308,8 +1331,8 @@ camelcase@^4.0.0:
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd"
caniuse-db@^1.0.30000639:
version "1.0.30000666"
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000666.tgz#951ed9f3d3bfaa08a06dafbb5089ab07cce6ab90"
version "1.0.30000670"
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000670.tgz#90d33b79e3090e25829c311113c56d6b1788bf43"
capture-stack-trace@^1.0.0:
version "1.0.0"
@ -1330,6 +1353,12 @@ center-align@^0.1.1:
align-text "^0.1.3"
lazy-cache "^1.0.3"
chainsaw@~0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/chainsaw/-/chainsaw-0.1.0.tgz#5eab50b28afe58074d0d58291388828b5e5fbc98"
dependencies:
traverse ">=0.3.0 <0.4"
chalk@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.4.0.tgz#5199a3ddcd0c1efe23bc08c1b027b06176e0c64f"
@ -1364,6 +1393,10 @@ character-reference-invalid@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/character-reference-invalid/-/character-reference-invalid-1.1.0.tgz#dec9ad1dfb9f8d06b4fcdaa2adc3c4fd97af1e68"
charenc@~0.0.1:
version "0.0.2"
resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667"
chokidar@^1.2.0, chokidar@^1.4.2:
version "1.7.0"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468"
@ -1388,8 +1421,8 @@ circular-json@^0.3.1:
resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.1.tgz#be8b36aefccde8b3ca7aa2d6afc07a37242c0d2d"
clean-stack@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-1.1.1.tgz#a1b3711122df162df7c7cb9b3c0470f28cb58adb"
version "1.2.0"
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-1.2.0.tgz#a465128d62c31fb1a3606d00abfe59dcf652f568"
clean-yaml-object@^0.1.0:
version "0.1.0"
@ -1515,6 +1548,10 @@ color-name@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.2.tgz#5c8ab72b64bd2215d617ae9559ebb148475cf98d"
colors@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63"
combined-stream@^1.0.5, combined-stream@~1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009"
@ -1562,14 +1599,14 @@ concat-stream@~1.5.0:
typedarray "~0.0.5"
configstore@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/configstore/-/configstore-3.0.0.tgz#e1b8669c1803ccc50b545e92f8e6e79aa80e0196"
version "3.1.0"
resolved "https://registry.yarnpkg.com/configstore/-/configstore-3.1.0.tgz#45df907073e26dfa1cf4b2d52f5b60545eaa11d1"
dependencies:
dot-prop "^4.1.0"
graceful-fs "^4.1.2"
mkdirp "^0.5.0"
make-dir "^1.0.0"
unique-string "^1.0.0"
write-file-atomic "^1.1.2"
write-file-atomic "^2.0.0"
xdg-basedir "^3.0.0"
console-control-strings@^1.0.0, console-control-strings@~1.1.0:
@ -1622,6 +1659,13 @@ create-error-class@^3.0.0:
dependencies:
capture-stack-trace "^1.0.0"
cross-env@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.0.0.tgz#565ccae4d09676441a5087f406fe7661a29c931b"
dependencies:
cross-spawn "^5.1.0"
is-windows "^1.0.0"
cross-spawn-async@^2.1.1:
version "2.2.5"
resolved "https://registry.yarnpkg.com/cross-spawn-async/-/cross-spawn-async-2.2.5.tgz#845ff0c0834a3ded9d160daca6d390906bb288cc"
@ -1636,7 +1680,7 @@ cross-spawn@^4, cross-spawn@^4.0.0:
lru-cache "^4.0.1"
which "^1.2.9"
cross-spawn@^5.0.1:
cross-spawn@^5.0.1, cross-spawn@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
dependencies:
@ -1644,6 +1688,10 @@ cross-spawn@^5.0.1:
shebang-command "^1.2.0"
which "^1.2.9"
crypt@~0.0.1:
version "0.0.2"
resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b"
cryptiles@2.x.x:
version "2.0.5"
resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8"
@ -1713,8 +1761,8 @@ deep-equal@^1.0.0:
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
deep-extend@~0.4.0:
version "0.4.1"
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253"
version "0.4.2"
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f"
deep-is@~0.1.3:
version "0.1.3"
@ -1891,8 +1939,8 @@ ecc-jsbn@~0.1.1:
jsbn "~0.1.0"
electron-to-chromium@^1.2.7:
version "1.3.9"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.9.tgz#db1cba2a26aebcca2f7f5b8b034554468609157d"
version "1.3.10"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.10.tgz#63d62b785471f0d8dda85199d64579de8a449f08"
elegant-spinner@^1.0.1:
version "1.0.1"
@ -1933,8 +1981,8 @@ error@^7.0.0:
xtend "~4.0.0"
es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.14:
version "0.10.16"
resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.16.tgz#1ef1b04f3d09db6a5d630226d62202f2e425e45a"
version "0.10.18"
resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.18.tgz#dc239d3dce4c22b9c939aa180878837a3c0b5c92"
dependencies:
es6-iterator "2"
es6-symbol "~3.1"
@ -2001,9 +2049,9 @@ escope@^3.6.0:
esrecurse "^4.1.0"
estraverse "^4.1.1"
eslint-config-prettier@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-2.0.0.tgz#073cdb2760c0ba817c9b3fbf2300110a77a35626"
eslint-config-prettier@2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-2.1.0.tgz#cf78bc7864f98b0f87bcadf702459e933dfa659c"
dependencies:
get-stdin "^5.0.1"
@ -2017,17 +2065,16 @@ eslint-config-xo@^0.18.0:
version "0.18.1"
resolved "https://registry.yarnpkg.com/eslint-config-xo/-/eslint-config-xo-0.18.1.tgz#f3bc873b33b2c82513d881eacb2ee3428407ad33"
eslint-plugin-flowtype-errors@3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype-errors/-/eslint-plugin-flowtype-errors-3.2.0.tgz#28b3f6742e50e64562a21b6ab8bb054a4754199d"
eslint-plugin-flowtype-errors@3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype-errors/-/eslint-plugin-flowtype-errors-3.2.1.tgz#2c206ebbc1a41d1fb02fafcd87a69858f6999320"
dependencies:
babel-plugin-transform-runtime "^6.23.0"
shelljs "^0.7.7"
slash "^1.0.0"
eslint-plugin-flowtype@2.32.1:
version "2.32.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.32.1.tgz#bbee185dedf97e5f63ec975cdcddd199bd2a2501"
eslint-plugin-flowtype@2.33.0:
version "2.33.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.33.0.tgz#b2783814ed2ddcf729953b8f65ff73c90cabee4b"
dependencies:
lodash "^4.15.0"
@ -2304,14 +2351,34 @@ flesch@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/flesch/-/flesch-1.0.0.tgz#96bfaee5e208264ff63c4447c4f124b5d4361cd5"
flow-bin@0.45.0:
version "0.45.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.45.0.tgz#009dd0f577a3f665c74ca8be827ae8c2dd8fd6b5"
flow-bin@0.46.0:
version "0.46.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.46.0.tgz#06ad7fe19dddb1042264438064a2a32fee12b872"
flow-parser@0.45.0:
version "0.45.0"
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.45.0.tgz#aa29d4ae27f06aa02817772bba0fcbefef7e62f0"
flow-typed@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/flow-typed/-/flow-typed-2.1.2.tgz#468f7a8b6bc18689856a1d101713b23bb39f01e4"
dependencies:
babel-polyfill "^6.6.1"
colors "^1.1.2"
fs-extra "^2.0.0"
github "^0.2.4"
glob "^7.0.6"
md5 "^2.1.0"
mkdirp "^0.5.1"
request "^2.69.0"
rimraf "^2.6.0"
semver "^5.1.0"
table "^3.7.8"
through "^2.3.8"
unzip "^0.1.11"
which "^1.2.11"
yargs "^4.2.0"
fn-name@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/fn-name/-/fn-name-2.0.1.tgz#5214d7537a4d06a4a301c0cc262feb84188002e7"
@ -2345,6 +2412,13 @@ form-data@~2.1.1:
combined-stream "^1.0.5"
mime-types "^2.1.12"
fs-extra@^2.0.0:
version "2.1.2"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-2.1.2.tgz#046c70163cef9aad46b0e4a7fa467fb22d71de35"
dependencies:
graceful-fs "^4.1.2"
jsonfile "^2.1.0"
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
@ -2373,6 +2447,15 @@ fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2:
mkdirp ">=0.5 0"
rimraf "2"
"fstream@>= 0.1.30 < 1":
version "0.1.31"
resolved "https://registry.yarnpkg.com/fstream/-/fstream-0.1.31.tgz#7337f058fbbbbefa8c9f561a28cab0849202c988"
dependencies:
graceful-fs "~3.0.2"
inherits "~2.0.0"
mkdirp "0.5"
rimraf "2"
function-bind@^1.0.2:
version "1.1.0"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"
@ -2456,6 +2539,12 @@ github-slugger@^1.0.0, github-slugger@^1.1.1, github-slugger@1.1.1:
dependencies:
emoji-regex "^6.0.0"
github@^0.2.4:
version "0.2.4"
resolved "https://registry.yarnpkg.com/github/-/github-0.2.4.tgz#24fa7f0e13fa11b946af91134c51982a91ce538b"
dependencies:
mime "^1.2.11"
glob-base@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4"
@ -2559,6 +2648,12 @@ graceful-fs@^4.0.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
graceful-fs@~3.0.2:
version "3.0.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818"
dependencies:
natives "^1.1.0"
"graceful-readlink@>= 1.0.0":
version "1.0.1"
resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725"
@ -2833,7 +2928,7 @@ is-binary-path@^1.0.0:
dependencies:
binary-extensions "^1.0.0"
is-buffer@^1.1.4, is-buffer@^1.1.5:
is-buffer@^1.1.4, is-buffer@^1.1.5, is-buffer@~1.1.1:
version "1.1.5"
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc"
@ -3040,6 +3135,10 @@ is-windows@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-0.2.0.tgz#de1aa6d63ea29dd248737b69f1ff8b8002d2108c"
is-windows@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.1.tgz#310db70f742d259a16a369202b51af84233310d9"
is-word-character@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-word-character/-/is-word-character-1.0.0.tgz#a3a9e5ddad70c5c2ee36f4a9cfc9a53f44535247"
@ -3197,7 +3296,7 @@ js-tokens@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7"
js-yaml@^3.3.1, js-yaml@^3.4.3, js-yaml@^3.5.1, js-yaml@^3.8.2:
js-yaml@^3.3.1, js-yaml@^3.4.3, js-yaml@^3.5.1, js-yaml@^3.8.2, js-yaml@^3.8.4:
version "3.8.4"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.4.tgz#520b4564f86573ba96662af85a8cafa7b4b5a6f6"
dependencies:
@ -3234,13 +3333,19 @@ json5@^0.5.0, json5@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
jsonfile@^2.1.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
optionalDependencies:
graceful-fs "^4.1.6"
jsonify@~0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
jsonparse@^1.2.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.0.tgz#85fc245b1d9259acc6941960b905adf64e7de0e8"
version "1.3.1"
resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280"
jsonpointer@^4.0.0:
version "4.0.1"
@ -3408,6 +3513,10 @@ locate-path@^2.0.0:
p-locate "^2.0.0"
path-exists "^3.0.0"
lodash.assign@^4.0.3, lodash.assign@^4.0.6:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7"
lodash.clonedeep@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
@ -3493,6 +3602,12 @@ lru-cache@^4.0.0, lru-cache@^4.0.1:
pseudomap "^1.0.1"
yallist "^2.0.0"
make-dir@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.0.0.tgz#97a011751e91dd87cfadef58832ebb04936de978"
dependencies:
pify "^2.3.0"
make-iterator@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/make-iterator/-/make-iterator-0.1.1.tgz#873d27b8198a465a81483b6f5d16da4e863ecf5b"
@ -3521,6 +3636,13 @@ markdown-table@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-1.1.0.tgz#1f5ae61659ced8808d882554c32e8b3f38dd1143"
"match-stream@>= 0.0.2 < 1":
version "0.0.2"
resolved "https://registry.yarnpkg.com/match-stream/-/match-stream-0.0.2.tgz#99eb050093b34dffade421b9ac0b410a9cfa17cf"
dependencies:
buffers "~0.1.1"
readable-stream "~1.0.0"
matcher@^0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/matcher/-/matcher-0.1.2.tgz#ef20cbde64c24c50cc61af5b83ee0b1b8ff00101"
@ -3543,6 +3665,14 @@ md5-o-matic@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/md5-o-matic/-/md5-o-matic-0.1.1.tgz#822bccd65e117c514fab176b25945d54100a03c3"
md5@^2.1.0:
version "2.2.1"
resolved "https://registry.yarnpkg.com/md5/-/md5-2.2.1.tgz#53ab38d5fe3c8891ba465329ea23fac0540126f9"
dependencies:
charenc "~0.0.1"
crypt "~0.0.1"
is-buffer "~1.1.1"
mdast-comment-marker@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/mdast-comment-marker/-/mdast-comment-marker-1.0.1.tgz#f0f26c33fc5d81e41d9ec36ff4f066bb50d217fb"
@ -3660,9 +3790,9 @@ mime-types@^2.1.12, mime-types@~2.1.7:
dependencies:
mime-db "~1.27.0"
mime@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53"
mime@^1.2.11, mime@^1.3.4:
version "1.3.6"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.6.tgz#591d84d3653a6b0b4a3b9df8de5aa8108e72e5e0"
mimic-fn@^1.0.0:
version "1.1.0"
@ -3686,7 +3816,7 @@ minimist@0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
mkdirp@^0.5.0, mkdirp@^0.5.1, "mkdirp@>=0.5 0":
mkdirp@^0.5.0, mkdirp@^0.5.1, "mkdirp@>=0.5 0", mkdirp@0.5:
version "0.5.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
dependencies:
@ -3746,6 +3876,10 @@ nan@~2.3.0:
version "2.3.5"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.3.5.tgz#822a0dc266290ce4cd3a12282ca3e7e364668a08"
natives@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.0.tgz#e9ff841418a6b2ec7a495e939984f78f163e6e31"
natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
@ -4012,6 +4146,10 @@ osenv@^0.1.4:
os-homedir "^1.0.0"
os-tmpdir "^1.0.0"
"over@>= 0.0.5 < 1":
version "0.0.5"
resolved "https://registry.yarnpkg.com/over/-/over-0.0.5.tgz#f29852e70fd7e25f360e013a8ec44c82aedb5708"
p-finally@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae"
@ -4324,6 +4462,15 @@ pseudomap@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
"pullstream@>= 0.4.1 < 1":
version "0.4.1"
resolved "https://registry.yarnpkg.com/pullstream/-/pullstream-0.4.1.tgz#d6fb3bf5aed697e831150eb1002c25a3f8ae1314"
dependencies:
over ">= 0.0.5 < 1"
readable-stream "~1.0.31"
setimmediate ">= 1.0.2 < 2"
slice-stream ">= 1.0.0 < 2"
punycode@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e"
@ -4426,7 +4573,7 @@ readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable
string_decoder "~1.0.0"
util-deprecate "~1.0.1"
"readable-stream@>=1.0.33-1 <1.1.0-0":
"readable-stream@>=1.0.33-1 <1.1.0-0", readable-stream@~1.0.0, readable-stream@~1.0.31:
version "1.0.34"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c"
dependencies:
@ -4673,7 +4820,7 @@ replace-ext@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-0.0.1.tgz#29bbd92078a739f0bcce2b4ee41e837953522924"
request@^2.81.0:
request@^2.69.0, request@^2.81.0:
version "2.81.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0"
dependencies:
@ -4860,7 +5007,7 @@ right-align@^0.1.1:
dependencies:
align-text "^0.1.1"
rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@2:
rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.0, rimraf@^2.6.1, rimraf@2:
version "2.6.1"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d"
dependencies:
@ -4899,8 +5046,8 @@ rx-lite@^3.1.2:
resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102"
rxjs@^5.0.0-beta.11:
version "5.3.1"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.3.1.tgz#9ecc9e722247e4f4490d30a878577a3740fd0cb7"
version "5.4.0"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.4.0.tgz#a7db14ab157f9d7aac6a56e655e7a3860d39bf26"
dependencies:
symbol-observable "^1.0.1"
@ -4930,6 +5077,10 @@ set-immediate-shim@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61"
"setimmediate@>= 1.0.1 < 2", "setimmediate@>= 1.0.2 < 2":
version "1.0.5"
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
shebang-command@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
@ -4940,7 +5091,7 @@ shebang-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
shelljs@^0.7.5, shelljs@^0.7.7:
shelljs@^0.7.5:
version "0.7.7"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.7.tgz#b2f5c77ef97148f4b4f6e22682e10bba8667cff1"
dependencies:
@ -4964,6 +5115,12 @@ slice-ansi@0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35"
"slice-stream@>= 1.0.0 < 2":
version "1.0.0"
resolved "https://registry.yarnpkg.com/slice-stream/-/slice-stream-1.0.0.tgz#5b33bd66f013b1a7f86460b03d463dec39ad3ea0"
dependencies:
readable-stream "~1.0.31"
slide@^1.1.5:
version "1.1.6"
resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707"
@ -5273,7 +5430,7 @@ text-table@^0.2.0, text-table@~0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
through@^2.3.6, "through@>=2.2.7 <3":
through@^2.3.6, through@^2.3.8, "through@>=2.2.7 <3":
version "2.3.8"
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
@ -5346,6 +5503,10 @@ tough-cookie@~2.3.0:
dependencies:
punycode "^1.4.1"
"traverse@>=0.3.0 <0.4":
version "0.3.9"
resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9"
trim-lines@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/trim-lines/-/trim-lines-1.1.0.tgz#9926d03ede13ba18f7d42222631fb04c79ff26fe"
@ -5395,8 +5556,8 @@ typedarray@^0.0.6, typedarray@~0.0.5:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
uglify-js@^2.6:
version "2.8.23"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.23.tgz#8230dd9783371232d62a7821e2cf9a817270a8a0"
version "2.8.25"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.25.tgz#11b776e7c3925802853e4c3dd6d0ffad8eb72336"
dependencies:
source-map "~0.5.1"
yargs "~3.10.0"
@ -5512,6 +5673,17 @@ unzip-response@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97"
unzip@^0.1.11:
version "0.1.11"
resolved "https://registry.yarnpkg.com/unzip/-/unzip-0.1.11.tgz#89749c63b058d7d90d619f86b98aa1535d3b97f0"
dependencies:
binary ">= 0.3.0 < 1"
fstream ">= 0.1.30 < 1"
match-stream ">= 0.0.2 < 1"
pullstream ">= 0.4.1 < 1"
readable-stream "~1.0.31"
setimmediate ">= 1.0.1 < 2"
update-notifier@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-2.1.0.tgz#ec0c1e53536b76647a24b77cb83966d9315123d9"
@ -5653,17 +5825,17 @@ which-module@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f"
which@^1.2.10, which@^1.2.4, which@^1.2.8, which@^1.2.9, which@1.2.x:
which@^1.2.10, which@^1.2.11, which@^1.2.4, which@^1.2.8, which@^1.2.9, which@1.2.x:
version "1.2.14"
resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5"
dependencies:
isexe "^2.0.0"
wide-align@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.0.tgz#40edde802a71fea1f070da3e62dcda2e7add96ad"
version "1.1.2"
resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.2.tgz#571e0f1b0604636ebc0dfc21b0339bbe31341710"
dependencies:
string-width "^1.0.1"
string-width "^1.0.2"
widest-line@^1.0.0:
version "1.0.0"
@ -5671,6 +5843,10 @@ widest-line@^1.0.0:
dependencies:
string-width "^1.0.1"
window-size@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.2.0.tgz#b4315bb4214a3d7058ebeee892e13fa24d98b075"
window-size@0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d"
@ -5698,7 +5874,7 @@ wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
write-file-atomic@^1.1.2, write-file-atomic@^1.1.4:
write-file-atomic@^1.1.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-1.3.4.tgz#f807a4f0b1d9e913ae7a48112e6cc3af1991b45f"
dependencies:
@ -5706,15 +5882,23 @@ write-file-atomic@^1.1.2, write-file-atomic@^1.1.4:
imurmurhash "^0.1.4"
slide "^1.1.5"
write-file-atomic@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.1.0.tgz#1769f4b551eedce419f0505deae2e26763542d37"
dependencies:
graceful-fs "^4.1.11"
imurmurhash "^0.1.4"
slide "^1.1.5"
write-json-file@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/write-json-file/-/write-json-file-2.0.0.tgz#0eaec981fcf9288dbc2806cbd26e06ab9bdca4ed"
version "2.1.0"
resolved "https://registry.yarnpkg.com/write-json-file/-/write-json-file-2.1.0.tgz#ba1cf3ac7ee89db26c3d528986e48421389046b7"
dependencies:
graceful-fs "^4.1.2"
mkdirp "^0.5.1"
make-dir "^1.0.0"
pify "^2.0.0"
sort-keys "^1.1.1"
write-file-atomic "^1.1.2"
write-file-atomic "^2.0.0"
write-pkg@^2.0.0:
version "2.1.0"
@ -5753,6 +5937,13 @@ yallist@^2.0.0:
version "2.1.2"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"
yargs-parser@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-2.4.1.tgz#85568de3cf150ff49fa51825f03a8c880ddcc5c4"
dependencies:
camelcase "^3.0.0"
lodash.assign "^4.0.6"
yargs-parser@^4.2.0:
version "4.2.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-4.2.1.tgz#29cceac0dc4f03c6c87b4a9f217dd18c9f74871c"
@ -5765,6 +5956,25 @@ yargs-parser@^5.0.0:
dependencies:
camelcase "^3.0.0"
yargs@^4.2.0:
version "4.8.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-4.8.1.tgz#c0c42924ca4aaa6b0e6da1739dfb216439f9ddc0"
dependencies:
cliui "^3.2.0"
decamelize "^1.1.1"
get-caller-file "^1.0.1"
lodash.assign "^4.0.3"
os-locale "^1.4.0"
read-pkg-up "^1.0.1"
require-directory "^2.1.1"
require-main-filename "^1.0.1"
set-blocking "^2.0.0"
string-width "^1.0.1"
which-module "^1.0.0"
window-size "^0.2.0"
y18n "^3.2.1"
yargs-parser "^2.4.1"
yargs@^6.0.0:
version "6.6.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-6.6.0.tgz#782ec21ef403345f830a808ca3d513af56065208"

View File

@ -2,7 +2,8 @@
const Hoek = require('hoek');
const Penseur = require('penseur');
const DCClient = require('docker-compose-client');
const awaitify = require('apr-awaitify');
const internals = {
defaults: {
@ -10,189 +11,159 @@ const internals = {
}
};
module.exports = class Data {
constructor (options) {
constructor(options) {
const settings = Hoek.applyToDefaults(options || {}, internals.defaults);
const name = settings.name;
delete settings.name;
// Penseur will assert that the options are correct
this._db = new Penseur.Db(name, settings);
this._db = new Penseur.Db(settings.name, settings);
this._docker = new DCClient(settings.dockerHost);
this._db.establish = awaitify(this._db.establish);
this._db.deployments = awaitify(this._db.deployments);
// promisify Penseur
[
'activities',
'datacenters',
'deployments',
'manifests',
'metrics'
].forEach(tableName =>
['insert', 'get', 'update', 'remove', 'all'].forEach(methodName => {
this._db[tableName][methodName] = awaitify(
this._db[tableName][methodName]
);
})
);
}
connect (cb) {
return new Promise((resolve, reject) => {
this._db.establish(['activities', 'datacenters', 'deployments', 'manifests', 'metrics'], (err) => {
if (typeof cb === 'function') {
return cb(err);
}
if (err) {
return reject(err);
}
resolve();
});
});
connect(cb) {
return this._db.establish();
}
createDeployment (deployment) {
return new Promise((resolve, reject) => {
deployment.services = [];
deployment.state = { current: 'stopped' };
/*
* DeploymentGroupUuid
* Manifest
* id: UUID,
* created: Date.now(),
* type: 'docker-compose',
* format: 'yml',
* raw: 'original yml file content',
* obj: { }
*/
createDeployment({ deploymentGroupUuid, manifest, deployment }) {
// trigger deployment
// create deployment queue (we should think about what is a deployment queue)
// create the ConvergencePlans
// create a DeploymentPlan
// create a Version
// update the DeploymentGroup
this._db.deployments.insert(deployment, (err, key) => {
if (err) {
return reject(err);
}
// TODO
const updateDb = plan => {
// deployment.services = [];
// deployment.state = { current: 'stopped' };
deployment.id = key;
resolve(deployment);
});
});
}
getDeployment (id) {
return new Promise((resolve, reject) => {
this._db.deployments.get(id, (err, deployment) => {
return err ? reject(err) : resolve(deployment);
});
});
}
updateDeployment (deployment) {
return new Promise((resolve, reject) => {
this._db.deployments.update(deployment.id, deployment, (err) => {
return err ? reject(err) : resolve(deployment);
});
});
}
deleteDeployment (id) {
return new Promise((resolve, reject) => {
this._db.deployments.remove(id, (err) => {
return err ? reject(err) : resolve();
});
});
}
getDeployments () {
return new Promise((resolve, reject) => {
this._db.deployments.all((err, deployments) => {
return err ? reject(err) : resolve(deployments);
});
});
}
getDatacenters () {
return new Promise((resolve, reject) => {
this._db.datacenters.all((err, datacenters) => {
return err ? reject(err) : resolve(datacenters || []);
});
});
}
createManifest (deploymentId, manifest) {
return new Promise((resolve, reject) => {
manifest.deploymentId = deploymentId;
manifest.created = Date.now();
this._db.manifests.insert(manifest, (err, id) => {
if (err) {
return reject(err);
}
manifest.id = id;
resolve(manifest);
});
});
}
getManifest (id) {
return new Promise((resolve, reject) => {
this._db.manifests.get(id, (err, manifest) => {
return err ? reject(err) : resolve(manifest);
});
});
}
getActivities (deploymentId) {
return new Promise((resolve, reject) => {
this._db.activities.query({ deploymentId }, (err, activities) => {
return err ? reject(err) : resolve(activities || []);
});
});
}
getMetrics (containerId) {
return new Promise((resolve, reject) => {
this._db.metrics.get(containerId, (err, result) => {
return err ? reject(err) : resolve(result);
});
});
}
insertMetrics (containerId, metrics) {
return new Promise((resolve, reject) => {
this._db.metrics.get(containerId, (err, existing) => {
if (err) {
return reject(err);
}
if (existing) {
this._db.metrics.update(containerId, { metrics: this._db.append(metrics) }, (err) => {
return err ? reject(err) : resolve(existing);
});
return;
}
const entry = { id: containerId, metrics };
this._db.metrics.insert(entry, { merge: true }, (err) => {
return err ? reject(err) : resolve(entry);
this._db.deployments
.insert({
name:
})
.then(key => {
deployment.id = key;
return deployment;
});
});
});
};
const provision = ({ name }) =>
this._docker
.provision({
projectName: name,
manifest: manifest.raw
})
.then(updateDb);
this.getDeployment(deploymentGroupUuid).then(provision);
}
getServices (deploymentId) {
return new Promise((resolve, reject) => {
this._db.deployments.get(deploymentId, { filter: 'services' }, (err, deployment) => {
return err ? reject(err) : resolve(deployment.services);
});
});
getDeployment(id) {
return this._db.deployments.get(id);
}
updateService (deploymentId, service) {
return new Promise((resolve, reject) => {
this._db.deployments.get(deploymentId, { filter: 'services' }, (err, deployment) => {
if (err) {
return reject(err);
}
updateDeployment(deployment) {
return this._db.deployments.update(deployment.id, deployment);
}
const serviceToUpdate = deployment.services.find((currentService) => {
return (currentService.name === service.name);
deleteDeployment(id) {
return this._db.deployments.remove(id);
}
getDeployments() {
return this._db.deployments.all();
}
getDatacenters() {
return this._db.datacenters.all();
}
createManifest(deploymentId, manifest) {
manifest.deploymentId = deploymentId;
manifest.created = Date.now();
return this._db.manifests.insert().then(id => {
manifest.id = id;
return manifest;
});
}
getManifest(id) {
return this._db.manifests.get();
}
getActivities(deploymentId) {
return this._db.activities.query({ deploymentId });
}
getMetrics(containerId) {
return this._db.metrics.get(containerId);
}
insertMetrics(containerId, metrics) {
return this._db.metrics.get(containerId).then(existing => {
if (existing) {
return this._db.metrics.update(containerId, {
metrics: this._db.append(metrics)
});
}
if (!serviceToUpdate) {
deployment.services.push(service);
} else {
serviceToUpdate.count = service.count;
serviceToUpdate.containers = service.containers;
}
const entry = { id: containerId, metrics };
return this._db.metrics.insert(entry, { merge: true });
});
}
this._db.deployments.update(deploymentId, { services: deployment.services }, (err) => {
return err ? reject(err) : resolve(service);
});
getServices(deploymentId) {
this._db.deployments.get(deploymentId, { filter: 'services' });
}
updateService(deploymentId, service) {
this._db.deployments.get(deploymentId, { filter: 'services' }).then(() => {
const serviceToUpdate = deployment.services.find(currentService => {
return currentService.name === service.name;
});
if (!serviceToUpdate) {
deployment.services.push(service);
} else {
serviceToUpdate.count = service.count;
serviceToUpdate.containers = service.containers;
}
return this._db.deployments.update(deploymentId, {
services: deployment.services
});
});
}
deploymentChanges (handler) {
return new Promise((resolve, reject) => {
this._db.deployments.changes('*', { reconnect: true, handler }, (err) => {
return err ? reject(err) : resolve();
});
});
deploymentChanges(handler) {
return this._db.deployments.changes('*', { reconnect: true, handler });
}
};

View File

@ -6,6 +6,7 @@
"scripts": {
"bootstrap": "node ./bootstrap-data",
"lint": "belly-button",
"fmt": "prettier --write --single-quote {lib,test}/**/*.js",
"rethinkdb-up": "docker run -d -p 8080:8080 -p 28015:28015 -p 29015:29015 --name rethinkdb rethinkdb",
"rethinkdb-down": "docker rm -f rethinkdb",
"test": "npm run lint && lab -t 40"
@ -13,13 +14,17 @@
"keywords": [],
"author": "wyatt",
"license": "MPL-2.0",
"dependencies": {
"apr-awaitify": "^1.0.4",
"docker-compose-client": "^1.0.3",
"hoek": "^4.1.1",
"penseur": "^7.8.1"
},
"devDependencies": {
"belly-button": "^3.1.0",
"code": "^4.0.0",
"lab": "^13.0.4"
},
"dependencies": {
"hoek": "^4.1.1",
"penseur": "^7.8.1"
"lab": "^13.0.4",
"prettier": "^1.3.1",
"zerorpc": "^0.9.7"
}
}

View File

@ -1,33 +1,46 @@
'use strict';
const Code = require('code');
const Lab = require('lab');
const pkg = require('../package.json');
const { expect } = require('code');
const { before, describe, it, script } = require('lab');
const { Server } = require('zerorpc');
const PortalData = require('../');
exports.lab = script();
// Test shortcuts
const lab = exports.lab = Lab.script();
const describe = lab.describe;
const it = lab.it;
const expect = Code.expect;
const server = new Server({
up: function(options, manifest, fn) {
fn(null, {
projectName: options.project_name
});
}
});
const internals = {
options: { test: true, name: 'test' }
options: { test: true, name: 'test', dockerHost: 'tcp://0.0.0.0:4242'}
};
describe('createDeployment()', () => {
it('creates a deployment record in the deployment table', (done) => {
const data = new PortalData(internals.options);
data.connect().then(() => {
const deployment = {
name: 'User Services',
datacenter: 'us-sw-1'
};
before(() => {
server.bind(internals.options.dockerHost);
});
data.createDeployment(deployment).then((deployment) => {
after(() => {
server.close();
});
describe('createDeployment()', () => {
it('creates a deployment record in the deployment table', done => {
const data = new PortalData(internals.options);
const deployment = {
name: 'User Services',
datacenter: 'us-sw-1'
};
data.connect().then(() => {
data.createDeployment({
deployment
}).then(deployment => {
expect(deployment.id).to.exist();
done();
});
@ -35,9 +48,8 @@ describe('createDeployment()', () => {
});
});
describe('getDeployment()', () => {
it('will retrieve an existing deployment', (done) => {
it('will retrieve an existing deployment', done => {
const data = new PortalData(internals.options);
data.connect().then(() => {
const deployment = {
@ -45,9 +57,9 @@ describe('getDeployment()', () => {
datacenter: 'us-sw-1'
};
data.createDeployment(deployment).then((deployment) => {
data.createDeployment(deployment).then(deployment => {
expect(deployment.id).to.exist();
data.getDeployment(deployment.id).then((retrievedDeployment) => {
data.getDeployment(deployment.id).then(retrievedDeployment => {
expect(deployment).to.equal(retrievedDeployment);
done();
});
@ -57,7 +69,7 @@ describe('getDeployment()', () => {
});
describe('updateService()', () => {
it('will update the services for an existing deployment', (done) => {
it('will update the services for an existing deployment', done => {
const data = new PortalData(internals.options);
data.connect().then(() => {
const deployment = {
@ -78,9 +90,9 @@ describe('updateService()', () => {
count: 1
};
data.createDeployment(deployment).then((deployment) => {
data.createDeployment(deployment).then(deployment => {
expect(deployment.id).to.exist();
data.updateService(deployment.id, service).then((updatedService) => {
data.updateService(deployment.id, service).then(updatedService => {
expect(updatedService).to.equal(service);
done();
});
@ -90,7 +102,7 @@ describe('updateService()', () => {
});
describe('deploymentChanges()', () => {
it('will execute the handler when a deployment service changes', (done) => {
it('will execute the handler when a deployment service changes', done => {
const data = new PortalData(internals.options);
data.connect().then(() => {
const deployment = {
@ -139,35 +151,38 @@ describe('deploymentChanges()', () => {
count: 3
};
data.createDeployment(deployment).then((deployment) => {
data.createDeployment(deployment).then(deployment => {
expect(deployment.id).to.exist();
data.updateService(deployment.id, service1).then((updatedService1) => {
data.updateService(deployment.id, service1).then(updatedService1 => {
expect(updatedService1).to.equal(service1);
let executed = false;
data.deploymentChanges((err, changes) => {
if (executed) {
return;
}
data
.deploymentChanges((err, changes) => {
if (executed) {
return;
}
expect(changes.before).to.exist();
expect(changes.after).to.exist();
done();
executed = true;
}).then(() => {
data.updateService(deployment.id, service2).then((updatedService2) => {
expect(updatedService2).to.equal(service2);
expect(changes.before).to.exist();
expect(changes.after).to.exist();
done();
executed = true;
})
.then(() => {
data
.updateService(deployment.id, service2)
.then(updatedService2 => {
expect(updatedService2).to.equal(service2);
});
});
});
});
});
});
});
});
describe('insertMetrics()', () => {
it('will add new metrics to a service and won\'t overwrite existing ones', (done) => {
it("will add new metrics to a service and won't overwrite existing ones", done => {
const data = new PortalData(internals.options);
data.connect().then(() => {
const containerId = '81205d4a-92f4-c4d9-da8a-aafd689eeabb';
@ -189,12 +204,12 @@ describe('insertMetrics()', () => {
}
];
data.insertMetrics(containerId, metrics1).then((result1) => {
data.insertMetrics(containerId, metrics1).then(result1 => {
expect(result1.id).to.equal(containerId);
expect(result1.metrics).to.equal(metrics1);
data.insertMetrics(containerId, metrics2).then((result2) => {
data.insertMetrics(containerId, metrics2).then(result2 => {
expect(result2.id).to.equal(containerId);
data.getMetrics(containerId).then((results) => {
data.getMetrics(containerId).then(results => {
expect(results.metrics.length).to.equal(2);
done();
});

View File

@ -1,576 +0,0 @@
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
var newArrowCheck = function (innerThis, boundThis) {
if (innerThis !== boundThis) {
throw new TypeError("Cannot instantiate an arrow function");
}
};
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
var cov_1eyosjm197 = function () {
var path = '/Users/ramitos/dev/yld/joyent-portal/spikes/docker-compose-client/src/index.js',
hash = '384e02ed4692c70a8c8d9e69b30064cdb319bdf4',
global = new Function('return this')(),
gcv = '__coverage__',
coverageData = {
path: '/Users/ramitos/dev/yld/joyent-portal/spikes/docker-compose-client/src/index.js',
statementMap: {
'0': {
start: {
line: 1,
column: 19
},
end: {
line: 1,
column: 37
}
},
'1': {
start: {
line: 2,
column: 25
},
end: {
line: 2,
column: 42
}
},
'2': {
start: {
line: 3,
column: 17
},
end: {
line: 3,
column: 40
}
},
'3': {
start: {
line: 7,
column: 4
},
end: {
line: 7,
column: 12
}
},
'4': {
start: {
line: 9,
column: 4
},
end: {
line: 9,
column: 31
}
},
'5': {
start: {
line: 10,
column: 4
},
end: {
line: 10,
column: 34
}
},
'6': {
start: {
line: 11,
column: 4
},
end: {
line: 11,
column: 60
}
},
'7': {
start: {
line: 11,
column: 35
},
end: {
line: 11,
column: 58
}
},
'8': {
start: {
line: 13,
column: 4
},
end: {
line: 13,
column: 53
}
},
'9': {
start: {
line: 18,
column: 4
},
end: {
line: 18,
column: 45
}
},
'10': {
start: {
line: 22,
column: 4
},
end: {
line: 22,
column: 31
}
},
'11': {
start: {
line: 27,
column: 4
},
end: {
line: 27,
column: 71
}
},
'12': {
start: {
line: 31,
column: 4
},
end: {
line: 42,
column: 6
}
},
'13': {
start: {
line: 36,
column: 53
},
end: {
line: 39,
column: 9
}
},
'14': {
start: {
line: 46,
column: 0
},
end: {
line: 46,
column: 37
}
}
},
fnMap: {
'0': {
name: '(anonymous_0)',
decl: {
start: {
line: 6,
column: 2
},
end: {
line: 6,
column: 3
}
},
loc: {
start: {
line: 6,
column: 47
},
end: {
line: 14,
column: 3
}
},
line: 6
},
'1': {
name: '(anonymous_1)',
decl: {
start: {
line: 11,
column: 28
},
end: {
line: 11,
column: 29
}
},
loc: {
start: {
line: 11,
column: 35
},
end: {
line: 11,
column: 58
}
},
line: 11
},
'2': {
name: '(anonymous_2)',
decl: {
start: {
line: 17,
column: 2
},
end: {
line: 17,
column: 3
}
},
loc: {
start: {
line: 17,
column: 25
},
end: {
line: 19,
column: 3
}
},
line: 17
},
'3': {
name: '(anonymous_3)',
decl: {
start: {
line: 21,
column: 2
},
end: {
line: 21,
column: 3
}
},
loc: {
start: {
line: 21,
column: 10
},
end: {
line: 23,
column: 3
}
},
line: 21
},
'4': {
name: '(anonymous_4)',
decl: {
start: {
line: 25,
column: 2
},
end: {
line: 25,
column: 3
}
},
loc: {
start: {
line: 25,
column: 39
},
end: {
line: 28,
column: 3
}
},
line: 25
},
'5': {
name: '(anonymous_5)',
decl: {
start: {
line: 30,
column: 2
},
end: {
line: 30,
column: 3
}
},
loc: {
start: {
line: 30,
column: 45
},
end: {
line: 43,
column: 3
}
},
line: 30
},
'6': {
name: '(anonymous_6)',
decl: {
start: {
line: 36,
column: 44
},
end: {
line: 36,
column: 45
}
},
loc: {
start: {
line: 36,
column: 53
},
end: {
line: 39,
column: 9
}
},
line: 36
}
},
branchMap: {
'0': {
loc: {
start: {
line: 6,
column: 14
},
end: {
line: 6,
column: 45
}
},
type: 'default-arg',
locations: [{
start: {
line: 6,
column: 25
},
end: {
line: 6,
column: 45
}
}],
line: 6
}
},
s: {
'0': 0,
'1': 0,
'2': 0,
'3': 0,
'4': 0,
'5': 0,
'6': 0,
'7': 0,
'8': 0,
'9': 0,
'10': 0,
'11': 0,
'12': 0,
'13': 0,
'14': 0
},
f: {
'0': 0,
'1': 0,
'2': 0,
'3': 0,
'4': 0,
'5': 0,
'6': 0
},
b: {
'0': [0]
},
_coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c'
},
coverage = global[gcv] || (global[gcv] = {});
if (coverage[path] && coverage[path].hash === hash) {
return coverage[path];
}
coverageData.hash = hash;
return coverage[path] = coverageData;
}();
var _ref = (++cov_1eyosjm197.s[0], require('zerorpc'));
var Client = _ref.Client;
var _ref2 = (++cov_1eyosjm197.s[1], require('events'));
var EventEmitter = _ref2.EventEmitter;
var awaitify = (++cov_1eyosjm197.s[2], require('apr-awaitify'));
var DockerComposeClient = function (_EventEmitter) {
inherits(DockerComposeClient, _EventEmitter);
function DockerComposeClient() {
var _this2 = this;
var endpoint = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (++cov_1eyosjm197.b[0][0], 'tcp://0.0.0.0:4242');
classCallCheck(this, DockerComposeClient);
++cov_1eyosjm197.f[0];
++cov_1eyosjm197.s[3];
var _this = possibleConstructorReturn(this, (DockerComposeClient.__proto__ || Object.getPrototypeOf(DockerComposeClient)).call(this));
++cov_1eyosjm197.s[4];
_this.client = new Client();
++cov_1eyosjm197.s[5];
_this.client.connect(endpoint);
++cov_1eyosjm197.s[6];
_this.client.on('error', function (err) {
newArrowCheck(this, _this2);
++cov_1eyosjm197.f[1];
++cov_1eyosjm197.s[7];
return _this.emit('error', err);
}.bind(this));
++cov_1eyosjm197.s[8];
_this._invoke = awaitify(_this._invoke.bind(_this));
return _this;
}
// Why isn't client.connect async with error??
createClass(DockerComposeClient, [{
key: '_invoke',
value: function _invoke(name) {
var _client;
++cov_1eyosjm197.f[2];
++cov_1eyosjm197.s[9];
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return (_client = this.client).invoke.apply(_client, [name].concat(args));
}
}, {
key: 'close',
value: function close() {
++cov_1eyosjm197.f[3];
++cov_1eyosjm197.s[10];
return this.client.close();
}
}, {
key: 'provision',
value: function provision(_ref3) {
var projectName = _ref3.projectName,
manifest = _ref3.manifest;
++cov_1eyosjm197.f[4];
++cov_1eyosjm197.s[11];
// eslint-disable-next-line camelcase
return this._invoke('up', { project_name: projectName }, manifest);
}
}, {
key: 'scale',
value: function scale(_ref4) {
var _this3 = this;
var projectName = _ref4.projectName,
services = _ref4.services,
manifest = _ref4.manifest;
++cov_1eyosjm197.f[5];
++cov_1eyosjm197.s[12];
return this._invoke('scale', {
// eslint-disable-next-line camelcase
project_name: projectName,
services: Object.keys(services).map(function (name) {
newArrowCheck(this, _this3);
++cov_1eyosjm197.f[6];
++cov_1eyosjm197.s[13];
return {
name: name,
num: services[name]
};
}.bind(this))
}, manifest);
}
}]);
return DockerComposeClient;
}(EventEmitter);
++cov_1eyosjm197.s[14];
module.exports = DockerComposeClient;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZXMuanMiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJjb25zdCB7IENsaWVudCB9ID0gcmVxdWlyZSgnemVyb3JwYycpO1xuY29uc3QgeyBFdmVudEVtaXR0ZXIgfSA9IHJlcXVpcmUoJ2V2ZW50cycpO1xuY29uc3QgYXdhaXRpZnkgPSByZXF1aXJlKCdhcHItYXdhaXRpZnknKTtcblxuY2xhc3MgRG9ja2VyQ29tcG9zZUNsaWVudCBleHRlbmRzIEV2ZW50RW1pdHRlciB7XG4gIGNvbnN0cnVjdG9yKGVuZHBvaW50ID0gJ3RjcDovLzAuMC4wLjA6NDI0MicpIHtcbiAgICBzdXBlcigpO1xuXG4gICAgdGhpcy5jbGllbnQgPSBuZXcgQ2xpZW50KCk7XG4gICAgdGhpcy5jbGllbnQuY29ubmVjdChlbmRwb2ludCk7XG4gICAgdGhpcy5jbGllbnQub24oJ2Vycm9yJywgZXJyID0+IHRoaXMuZW1pdCgnZXJyb3InLCBlcnIpKTtcblxuICAgIHRoaXMuX2ludm9rZSA9IGF3YWl0aWZ5KHRoaXMuX2ludm9rZS5iaW5kKHRoaXMpKTtcbiAgfVxuXG4gIC8vIFdoeSBpc24ndCBjbGllbnQuY29ubmVjdCBhc3luYyB3aXRoIGVycm9yPz9cbiAgX2ludm9rZShuYW1lLCAuLi5hcmdzKSB7XG4gICAgcmV0dXJuIHRoaXMuY2xpZW50Lm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VTEssUUFWSyxDQUFQOzs7O0VBMUI4QmhCOzs7OztBQXlDbENzQixPQUFPQyxPQUFQLEdBQWlCckIsbUJBQWpCIn0=

View File

@ -1,584 +0,0 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
var newArrowCheck = function (innerThis, boundThis) {
if (innerThis !== boundThis) {
throw new TypeError("Cannot instantiate an arrow function");
}
};
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
var cov_1eyosjm197 = function () {
var path = '/Users/ramitos/dev/yld/joyent-portal/spikes/docker-compose-client/src/index.js',
hash = '384e02ed4692c70a8c8d9e69b30064cdb319bdf4',
global = new Function('return this')(),
gcv = '__coverage__',
coverageData = {
path: '/Users/ramitos/dev/yld/joyent-portal/spikes/docker-compose-client/src/index.js',
statementMap: {
'0': {
start: {
line: 1,
column: 19
},
end: {
line: 1,
column: 37
}
},
'1': {
start: {
line: 2,
column: 25
},
end: {
line: 2,
column: 42
}
},
'2': {
start: {
line: 3,
column: 17
},
end: {
line: 3,
column: 40
}
},
'3': {
start: {
line: 7,
column: 4
},
end: {
line: 7,
column: 12
}
},
'4': {
start: {
line: 9,
column: 4
},
end: {
line: 9,
column: 31
}
},
'5': {
start: {
line: 10,
column: 4
},
end: {
line: 10,
column: 34
}
},
'6': {
start: {
line: 11,
column: 4
},
end: {
line: 11,
column: 60
}
},
'7': {
start: {
line: 11,
column: 35
},
end: {
line: 11,
column: 58
}
},
'8': {
start: {
line: 13,
column: 4
},
end: {
line: 13,
column: 53
}
},
'9': {
start: {
line: 18,
column: 4
},
end: {
line: 18,
column: 45
}
},
'10': {
start: {
line: 22,
column: 4
},
end: {
line: 22,
column: 31
}
},
'11': {
start: {
line: 27,
column: 4
},
end: {
line: 27,
column: 71
}
},
'12': {
start: {
line: 31,
column: 4
},
end: {
line: 42,
column: 6
}
},
'13': {
start: {
line: 36,
column: 53
},
end: {
line: 39,
column: 9
}
},
'14': {
start: {
line: 46,
column: 0
},
end: {
line: 46,
column: 37
}
}
},
fnMap: {
'0': {
name: '(anonymous_0)',
decl: {
start: {
line: 6,
column: 2
},
end: {
line: 6,
column: 3
}
},
loc: {
start: {
line: 6,
column: 47
},
end: {
line: 14,
column: 3
}
},
line: 6
},
'1': {
name: '(anonymous_1)',
decl: {
start: {
line: 11,
column: 28
},
end: {
line: 11,
column: 29
}
},
loc: {
start: {
line: 11,
column: 35
},
end: {
line: 11,
column: 58
}
},
line: 11
},
'2': {
name: '(anonymous_2)',
decl: {
start: {
line: 17,
column: 2
},
end: {
line: 17,
column: 3
}
},
loc: {
start: {
line: 17,
column: 25
},
end: {
line: 19,
column: 3
}
},
line: 17
},
'3': {
name: '(anonymous_3)',
decl: {
start: {
line: 21,
column: 2
},
end: {
line: 21,
column: 3
}
},
loc: {
start: {
line: 21,
column: 10
},
end: {
line: 23,
column: 3
}
},
line: 21
},
'4': {
name: '(anonymous_4)',
decl: {
start: {
line: 25,
column: 2
},
end: {
line: 25,
column: 3
}
},
loc: {
start: {
line: 25,
column: 39
},
end: {
line: 28,
column: 3
}
},
line: 25
},
'5': {
name: '(anonymous_5)',
decl: {
start: {
line: 30,
column: 2
},
end: {
line: 30,
column: 3
}
},
loc: {
start: {
line: 30,
column: 45
},
end: {
line: 43,
column: 3
}
},
line: 30
},
'6': {
name: '(anonymous_6)',
decl: {
start: {
line: 36,
column: 44
},
end: {
line: 36,
column: 45
}
},
loc: {
start: {
line: 36,
column: 53
},
end: {
line: 39,
column: 9
}
},
line: 36
}
},
branchMap: {
'0': {
loc: {
start: {
line: 6,
column: 14
},
end: {
line: 6,
column: 45
}
},
type: 'default-arg',
locations: [{
start: {
line: 6,
column: 25
},
end: {
line: 6,
column: 45
}
}],
line: 6
}
},
s: {
'0': 0,
'1': 0,
'2': 0,
'3': 0,
'4': 0,
'5': 0,
'6': 0,
'7': 0,
'8': 0,
'9': 0,
'10': 0,
'11': 0,
'12': 0,
'13': 0,
'14': 0
},
f: {
'0': 0,
'1': 0,
'2': 0,
'3': 0,
'4': 0,
'5': 0,
'6': 0
},
b: {
'0': [0]
},
_coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c'
},
coverage = global[gcv] || (global[gcv] = {});
if (coverage[path] && coverage[path].hash === hash) {
return coverage[path];
}
coverageData.hash = hash;
return coverage[path] = coverageData;
}();
var _ref = (++cov_1eyosjm197.s[0], require('zerorpc'));
var Client = _ref.Client;
var _ref2 = (++cov_1eyosjm197.s[1], require('events'));
var EventEmitter = _ref2.EventEmitter;
var awaitify = (++cov_1eyosjm197.s[2], require('apr-awaitify'));
var DockerComposeClient = function (_EventEmitter) {
inherits(DockerComposeClient, _EventEmitter);
function DockerComposeClient() {
var _this2 = this;
var endpoint = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (++cov_1eyosjm197.b[0][0], 'tcp://0.0.0.0:4242');
classCallCheck(this, DockerComposeClient);
++cov_1eyosjm197.f[0];
++cov_1eyosjm197.s[3];
var _this = possibleConstructorReturn(this, (DockerComposeClient.__proto__ || Object.getPrototypeOf(DockerComposeClient)).call(this));
++cov_1eyosjm197.s[4];
_this.client = new Client();
++cov_1eyosjm197.s[5];
_this.client.connect(endpoint);
++cov_1eyosjm197.s[6];
_this.client.on('error', function (err) {
newArrowCheck(this, _this2);
++cov_1eyosjm197.f[1];
++cov_1eyosjm197.s[7];
return _this.emit('error', err);
}.bind(this));
++cov_1eyosjm197.s[8];
_this._invoke = awaitify(_this._invoke.bind(_this));
return _this;
}
// Why isn't client.connect async with error??
createClass(DockerComposeClient, [{
key: '_invoke',
value: function _invoke(name) {
var _client;
++cov_1eyosjm197.f[2];
++cov_1eyosjm197.s[9];
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return (_client = this.client).invoke.apply(_client, [name].concat(args));
}
}, {
key: 'close',
value: function close() {
++cov_1eyosjm197.f[3];
++cov_1eyosjm197.s[10];
return this.client.close();
}
}, {
key: 'provision',
value: function provision(_ref3) {
var projectName = _ref3.projectName,
manifest = _ref3.manifest;
++cov_1eyosjm197.f[4];
++cov_1eyosjm197.s[11];
// eslint-disable-next-line camelcase
return this._invoke('up', { project_name: projectName }, manifest);
}
}, {
key: 'scale',
value: function scale(_ref4) {
var _this3 = this;
var projectName = _ref4.projectName,
services = _ref4.services,
manifest = _ref4.manifest;
++cov_1eyosjm197.f[5];
++cov_1eyosjm197.s[12];
return this._invoke('scale', {
// eslint-disable-next-line camelcase
project_name: projectName,
services: Object.keys(services).map(function (name) {
newArrowCheck(this, _this3);
++cov_1eyosjm197.f[6];
++cov_1eyosjm197.s[13];
return {
name: name,
num: services[name]
};
}.bind(this))
}, manifest);
}
}]);
return DockerComposeClient;
}(EventEmitter);
++cov_1eyosjm197.s[14];
module.exports = DockerComposeClient;
})));
//# sourceMappingURL=data:application/json;charset=utf-8;base64,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