1
0
mirror of https://github.com/yldio/copilot.git synced 2024-12-29 05:10:05 +02:00

compose demo

This commit is contained in:
Sérgio Ramos 2017-05-11 16:30:03 +01:00
parent 6365139253
commit fd19fff435
30 changed files with 13532 additions and 0 deletions

View File

@ -0,0 +1,34 @@
{
"parser": "babel-eslint",
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"xo-space/esnext",
"prettier",
"prettier/react"
],
"plugins": [
"react",
"prettier"
],
"rules": {
"react/react-in-jsx-scope": 0,
"react/display-name": 0,
"react/prop-types": 0,
"prettier/prettier": ["error", {
"useTabs": false,
"printWidth": 80,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"semi": true
}]
},
"env": {
"browser": true,
"es6": true,
"node": true
}
}

View File

@ -0,0 +1,13 @@
import styled from 'styled-components';
const Article = styled.article`
font-family: Helvetica;
padding: 10px;
color: dimgray;
`;
export default ({ children }) => (
<Article>
{children}
</Article>
);

View File

@ -0,0 +1,90 @@
import React, { Component } from 'react';
import ReactCodeMirror from 'react-codemirror';
import YamlMode from 'codemirror/mode/yaml/yaml';
// eslint-disable-next-line no-unused-vars
import KeyMap from 'codemirror/keymap/sublime';
// eslint-disable-next-line no-unused-vars
// import Lint from 'codemirror/addon/edit/lint';
// eslint-disable-next-line no-unused-vars
import CloseBrackets from 'codemirror/addon/edit/closebrackets';
// eslint-disable-next-line no-unused-vars
import MatchBrackets from 'codemirror/addon/edit/matchbrackets';
// eslint-disable-next-line no-unused-vars
import FoldCode from 'codemirror/addon/fold/foldcode';
// eslint-disable-next-line no-unused-vars
import FoldGutter from 'codemirror/addon/fold/foldgutter';
// eslint-disable-next-line no-unused-vars
import BraceFold from 'codemirror/addon/fold/brace-fold';
// eslint-disable-next-line no-unused-vars
import IndentFold from 'codemirror/addon/fold/indent-fold';
// eslint-disable-next-line no-unused-vars
import CommentFold from 'codemirror/addon/fold/comment-fold';
// eslint-disable-next-line no-unused-vars
import ActiveLine from 'codemirror/addon/selection/active-line';
// eslint-disable-next-line no-unused-vars
import CloseTag from 'codemirror/addon/edit/closetag';
const options = {
mode: {
name: 'javascript',
json: true
},
theme: 'eclipse',
indentUnit: 2,
smartIndent: true,
tabSize: 2,
indentWithTabs: false,
electricChars: true,
keyMap: 'sublime',
lineNumbers: true,
inputStyle: 'contenteditable',
readOnly: false,
autoCloseBrackets: true,
styleActiveLine: true,
matchBrackets: true,
lineWrapping: true,
foldGutter: true,
autoCloseTags: true,
viewportMargin: Infinity,
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter']
};
class Editor extends Component {
constructor() {
super();
this._refs = {};
this.state = {
code: manifest.trim()
};
this.handleOnChange = this.handleOnChange.bind(this);
}
handleOnChange(newCode) {
this.setState({
code: newCode
});
}
ref(name) {
return ref => {
this._refs[name] = ref;
};
}
render() {
return (
<ReactCodeMirror
ref={this.ref('cm')}
value={this.state.code}
onChange={this.handleOnChange}
onFocusChange={this.handleOnFocusChange}
options={options}
autoSave
preserveScrollPosition
/>
);
}
}
export default Editor;

View File

@ -0,0 +1,34 @@
import NProgress from 'nprogress';
import Head from 'next/head';
import Router from 'next/router';
import Article from './article';
Router.onRouteChangeStart = () => NProgress.start();
Router.onRouteChangeComplete = () => NProgress.done();
Router.onRouteChangeError = () => NProgress.done();
export default ({ children, title = '' }) => (
<main>
<Head>
<title>{title}</title>
<meta charSet="utf-8" />
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<link rel="stylesheet" type="text/css" href="/static/nprogress.css" />
<link rel="stylesheet" type="text/css" href="/static/codemirror.css" />
<link rel="stylesheet" type="text/css" href="/static/eclipse.css" />
<link rel="stylesheet" type="text/css" href="/static/foldgutter.css" />
<style jsx global>{`
html, body {
margin: 0;
padding: 0;
font-family: Helvetica;
}
`}</style>
</Head>
<Article>
{children}
</Article>
</main>
);

View File

@ -0,0 +1,43 @@
{
"name": "compose-demo",
"version": "1.0.0",
"private": true,
"description": "",
"license": "Apache-2.0",
"author": "Sérgio Ramos <mail@sergioramos.me>",
"keywords": [],
"main": "src/server.js",
"scripts": {
"fmt": "prettier --write --single-quote",
"format": "fmt {components,pages}/**/*.js",
"lint": "eslint {components,pages}/**/*.js --fix",
"build": "next build",
"start": "next start",
"dev": "next"
},
"dependencies": {
"body-parser": "^1.17.1",
"force-array": "^3.1.0",
"next": "^2.3.1",
"nprogress": "^0.2.0",
"react": "^15.5.4",
"react-codemirror": "^0.3.0",
"react-dom": "^15.5.4",
"router": "^1.3.0",
"simple-json-form-viewer": "^1.0.2",
"styled-components": "^1.4.6",
"triton-watch": "^1.0.0"
},
"devDependencies": {
"babel-eslint": "^7.2.3",
"eslint": "3.19.0",
"eslint-config-prettier": "2.0.0",
"eslint-config-xo-space": "^0.16.0",
"eslint-plugin-flowtype": "2.32.1",
"eslint-plugin-flowtype-errors": "3.2.0",
"eslint-plugin-prettier": "^2.0.1",
"eslint-plugin-react": "^7.0.0",
"prettier": "1.3.1",
"react-no-ssr": "^1.1.0"
}
}

View File

@ -0,0 +1,155 @@
import { Component } from 'react';
import Layout from '../components/layout';
// import Editor from '../components/editor';
import NoSSR from 'react-no-ssr';
import styled from 'styled-components';
import JSONViewer from 'simple-json-form-viewer';
import forceArray from 'force-array';
const tags = {
hash: 'docker:label:com.docker.compose.config-hash',
project: 'docker:label:com.docker.compose.project',
service: 'docker:label:com.docker.compose.service'
};
const Panel = styled.div`
width: 50%;
float: ${props => props['float']};
margin: 0 -10px 0 -10px;
`;
const Textarea = styled.textarea`
width: 100%;
height: 100px;
`;
// <code>{JSON.stringify(this.state.scale, null, 2)}</code>
// <code>{JSON.stringify(this.state.provision, null, 2)}</code>
// const ProvisionResult = (res) => {
// const services = Object.keys(res).map((name) => {
// return (
// <ul>
// <li>
// {name}
// <ul>
//
// </ul>
// </li>
// </ul>
// );
// });
// };
export default class App extends Component {
constructor() {
super();
this.state = {
manifest: `
hello:
image: hello-world:latest
world:
image: consul:latest
`.trim(),
name: 'compose-demo'
};
this.handleProvision = this.handleProvision.bind(this);
this.handleScale = this.handleScale.bind(this);
this.handleManifestChange = this.handleManifestChange.bind(this);
this.poll = this.poll.bind(this);
}
componentDidMount() {
this.poll();
}
async poll() {
const res = await fetch('/api/status', {
method: 'GET'
});
const containers = await res.json();
const status = Object.values(containers)
.filter(
container =>
container.tags[tags.hash] &&
container.tags[tags.project] === this.state.name
)
.reduce((sum, container) => {
const name = container.tags[tags.service];
const prevInstances = forceArray(sum[name]);
return Object.assign(sum, {
[name]: prevInstances.concat([
{
name: container.name,
state: container.state
}
])
});
}, {});
console.log(status);
this.setState({
status
});
setTimeout(() => this.poll(), 16);
}
async handleProvision() {
const body = JSON.stringify({
manifest: this.state.manifest,
name: this.state.name
});
const headers = new Headers({
'Content-Type': 'application/json',
'Content-Length': body.length.toString()
});
const res = await fetch('/api/provision', {
method: 'POST',
headers: headers,
body: body
});
this.setState({
provision: await res.json()
});
}
async handleScale() {}
handleManifestChange(ev) {
this.setState({
manifest: ev.target.value
});
}
render() {
return (
<Layout title="Docker Compose Demo">
<Panel float="left">
<Textarea
value={this.state.manifest}
onChange={this.handleManifestChange}
/>
<button onClick={this.handleProvision}>Provision</button>
<button onClick={this.handleScale}>Scale</button>
<NoSSR>
<JSONViewer data={this.state.provision} />
</NoSSR>
</Panel>
<Panel float="right">
<NoSSR>
<JSONViewer data={this.state.status} />
</NoSSR>
</Panel>
</Layout>
);
}
}

View File

@ -0,0 +1,7 @@
// eslint-disable-next-line no-unused-vars
import Style from 'codemirror/lib/codemirror.css';
// eslint-disable-next-line no-unused-vars
import Theme from 'codemirror/theme/eclipse.css';
// eslint-disable-next-line no-unused-vars
import FoldGutterStyle from 'codemirror/addon/fold/foldgutter.css';
// eslint-disable-next-line no-unused-vars

View File

@ -0,0 +1,58 @@
const DockerComposeClient = require('./vendor/docker-compose-client');
const Router = require('router');
const { createServer } = require('http');
const bodyParser = require('body-parser');
const next = require('next');
const TritonWatch = require('triton-watch');
const app = next({
dev: process.env.NODE_ENV !== 'production'
});
const tritonWatch = new TritonWatch({
frequency: 16,
triton: {
profileName: 'sw1',
configDir: '~/.triton/'
}
});
const containers = {};
const handle = app.getRequestHandler();
const client = new DockerComposeClient();
const router = Router();
router.use(bodyParser.json());
tritonWatch.on('change', container => (containers[container.id] = container));
router.get('/api/status', (req, res) => {
res.end(JSON.stringify(containers));
});
router.post('/api/provision', (req, res) => {
client
.provision({
projectName: req.body.name,
manifest: req.body.manifest
})
.then(status => res.end(JSON.stringify(status)));
});
router.post('/api/scale', (req, res) => {
client
.provision({
projectName: req.body.name,
manifest: req.body.manifest,
services: req.body.services
})
.then(status => res.end(JSON.stringify(status)));
});
tritonWatch.poll();
app.prepare().then(() =>
createServer((req, res) => {
router(req, res, () => handle(req, res));
}).listen(3000)
);

View File

@ -0,0 +1,340 @@
/* BASICS */
.CodeMirror {
/* Set height, width, borders, and global font properties here */
font-family: monospace;
height: 300px;
color: black;
}
/* PADDING */
.CodeMirror-lines {
padding: 4px 0; /* Vertical padding around content */
}
.CodeMirror pre {
padding: 0 4px; /* Horizontal padding of content */
}
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white; /* The little square between H and V scrollbars */
}
/* GUTTER */
.CodeMirror-gutters {
border-right: 1px solid #ddd;
background-color: #f7f7f7;
white-space: nowrap;
}
.CodeMirror-linenumbers {}
.CodeMirror-linenumber {
padding: 0 3px 0 5px;
min-width: 20px;
text-align: right;
color: #999;
white-space: nowrap;
}
.CodeMirror-guttermarker { color: black; }
.CodeMirror-guttermarker-subtle { color: #999; }
/* CURSOR */
.CodeMirror-cursor {
border-left: 1px solid black;
border-right: none;
width: 0;
}
/* Shown when moving in bi-directional text */
.CodeMirror div.CodeMirror-secondarycursor {
border-left: 1px solid silver;
}
.cm-fat-cursor .CodeMirror-cursor {
width: auto;
border: 0 !important;
background: #7e7;
}
.cm-fat-cursor div.CodeMirror-cursors {
z-index: 1;
}
.cm-animate-fat-cursor {
width: auto;
border: 0;
-webkit-animation: blink 1.06s steps(1) infinite;
-moz-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite;
background-color: #7e7;
}
@-moz-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@-webkit-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
/* Can style cursor different in overwrite (non-insert) mode */
.CodeMirror-overwrite .CodeMirror-cursor {}
.cm-tab { display: inline-block; text-decoration: inherit; }
.CodeMirror-rulers {
position: absolute;
left: 0; right: 0; top: -50px; bottom: -20px;
overflow: hidden;
}
.CodeMirror-ruler {
border-left: 1px solid #ccc;
top: 0; bottom: 0;
position: absolute;
}
/* DEFAULT THEME */
.cm-s-default .cm-header {color: blue;}
.cm-s-default .cm-quote {color: #090;}
.cm-negative {color: #d44;}
.cm-positive {color: #292;}
.cm-header, .cm-strong {font-weight: bold;}
.cm-em {font-style: italic;}
.cm-link {text-decoration: underline;}
.cm-strikethrough {text-decoration: line-through;}
.cm-s-default .cm-keyword {color: #708;}
.cm-s-default .cm-atom {color: #219;}
.cm-s-default .cm-number {color: #164;}
.cm-s-default .cm-def {color: #00f;}
.cm-s-default .cm-variable,
.cm-s-default .cm-punctuation,
.cm-s-default .cm-property,
.cm-s-default .cm-operator {}
.cm-s-default .cm-variable-2 {color: #05a;}
.cm-s-default .cm-variable-3 {color: #085;}
.cm-s-default .cm-comment {color: #a50;}
.cm-s-default .cm-string {color: #a11;}
.cm-s-default .cm-string-2 {color: #f50;}
.cm-s-default .cm-meta {color: #555;}
.cm-s-default .cm-qualifier {color: #555;}
.cm-s-default .cm-builtin {color: #30a;}
.cm-s-default .cm-bracket {color: #997;}
.cm-s-default .cm-tag {color: #170;}
.cm-s-default .cm-attribute {color: #00c;}
.cm-s-default .cm-hr {color: #999;}
.cm-s-default .cm-link {color: #00c;}
.cm-s-default .cm-error {color: #f00;}
.cm-invalidchar {color: #f00;}
.CodeMirror-composing { border-bottom: 2px solid; }
/* Default styles for common addons */
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
.CodeMirror-activeline-background {background: #e8f2ff;}
/* STOP */
/* The rest of this file contains styles related to the mechanics of
the editor. You probably shouldn't touch them. */
.CodeMirror {
position: relative;
overflow: hidden;
background: white;
}
.CodeMirror-scroll {
overflow: scroll !important; /* Things will break if this is overridden */
/* 30px is the magic margin used to hide the element's real scrollbars */
/* See overflow: hidden in .CodeMirror */
margin-bottom: -30px; margin-right: -30px;
padding-bottom: 30px;
height: 100%;
outline: none; /* Prevent dragging from highlighting the element */
position: relative;
}
.CodeMirror-sizer {
position: relative;
border-right: 30px solid transparent;
}
/* The fake, visible scrollbars. Used to force redraw during scrolling
before actual scrolling happens, thus preventing shaking and
flickering artifacts. */
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
position: absolute;
z-index: 6;
display: none;
}
.CodeMirror-vscrollbar {
right: 0; top: 0;
overflow-x: hidden;
overflow-y: scroll;
}
.CodeMirror-hscrollbar {
bottom: 0; left: 0;
overflow-y: hidden;
overflow-x: scroll;
}
.CodeMirror-scrollbar-filler {
right: 0; bottom: 0;
}
.CodeMirror-gutter-filler {
left: 0; bottom: 0;
}
.CodeMirror-gutters {
position: absolute; left: 0; top: 0;
min-height: 100%;
z-index: 3;
}
.CodeMirror-gutter {
white-space: normal;
height: 100%;
display: inline-block;
vertical-align: top;
margin-bottom: -30px;
}
.CodeMirror-gutter-wrapper {
position: absolute;
z-index: 4;
background: none !important;
border: none !important;
}
.CodeMirror-gutter-background {
position: absolute;
top: 0; bottom: 0;
z-index: 4;
}
.CodeMirror-gutter-elt {
position: absolute;
cursor: default;
z-index: 4;
}
.CodeMirror-gutter-wrapper ::selection { background-color: transparent }
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
.CodeMirror-lines {
cursor: text;
min-height: 1px; /* prevents collapsing before first draw */
}
.CodeMirror pre {
/* Reset some styles that the rest of the page might have set */
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
border-width: 0;
background: transparent;
font-family: inherit;
font-size: inherit;
margin: 0;
white-space: pre;
word-wrap: normal;
line-height: inherit;
color: inherit;
z-index: 2;
position: relative;
overflow: visible;
-webkit-tap-highlight-color: transparent;
-webkit-font-variant-ligatures: contextual;
font-variant-ligatures: contextual;
}
.CodeMirror-wrap pre {
word-wrap: break-word;
white-space: pre-wrap;
word-break: normal;
}
.CodeMirror-linebackground {
position: absolute;
left: 0; right: 0; top: 0; bottom: 0;
z-index: 0;
}
.CodeMirror-linewidget {
position: relative;
z-index: 2;
overflow: auto;
}
.CodeMirror-widget {}
.CodeMirror-rtl pre { direction: rtl; }
.CodeMirror-code {
outline: none;
}
/* Force content-box sizing for the elements where we expect it */
.CodeMirror-scroll,
.CodeMirror-sizer,
.CodeMirror-gutter,
.CodeMirror-gutters,
.CodeMirror-linenumber {
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.CodeMirror-measure {
position: absolute;
width: 100%;
height: 0;
overflow: hidden;
visibility: hidden;
}
.CodeMirror-cursor {
position: absolute;
pointer-events: none;
}
.CodeMirror-measure pre { position: static; }
div.CodeMirror-cursors {
visibility: hidden;
position: relative;
z-index: 3;
}
div.CodeMirror-dragcursors {
visibility: visible;
}
.CodeMirror-focused div.CodeMirror-cursors {
visibility: visible;
}
.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
.CodeMirror-crosshair { cursor: crosshair; }
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
.cm-searching {
background: #ffa;
background: rgba(255, 255, 0, .4);
}
/* Used to force a border model for a node */
.cm-force-border { padding-right: .1px; }
@media print {
/* Hide the cursor when printing */
.CodeMirror div.CodeMirror-cursors {
visibility: hidden;
}
}
/* See issue #2901 */
.cm-tab-wrap-hack:after { content: ''; }
/* Help users use markselection to safely style text background */
span.CodeMirror-selectedtext { background: none; }

View File

@ -0,0 +1,23 @@
.cm-s-eclipse span.cm-meta { color: #FF1717; }
.cm-s-eclipse span.cm-keyword { line-height: 1em; font-weight: bold; color: #7F0055; }
.cm-s-eclipse span.cm-atom { color: #219; }
.cm-s-eclipse span.cm-number { color: #164; }
.cm-s-eclipse span.cm-def { color: #00f; }
.cm-s-eclipse span.cm-variable { color: black; }
.cm-s-eclipse span.cm-variable-2 { color: #0000C0; }
.cm-s-eclipse span.cm-variable-3 { color: #0000C0; }
.cm-s-eclipse span.cm-property { color: black; }
.cm-s-eclipse span.cm-operator { color: black; }
.cm-s-eclipse span.cm-comment { color: #3F7F5F; }
.cm-s-eclipse span.cm-string { color: #2A00FF; }
.cm-s-eclipse span.cm-string-2 { color: #f50; }
.cm-s-eclipse span.cm-qualifier { color: #555; }
.cm-s-eclipse span.cm-builtin { color: #30a; }
.cm-s-eclipse span.cm-bracket { color: #cc7; }
.cm-s-eclipse span.cm-tag { color: #170; }
.cm-s-eclipse span.cm-attribute { color: #00c; }
.cm-s-eclipse span.cm-link { color: #219; }
.cm-s-eclipse span.cm-error { color: #f00; }
.cm-s-eclipse .CodeMirror-activeline-background { background: #e8f2ff; }
.cm-s-eclipse .CodeMirror-matchingbracket { outline:1px solid grey; color:black !important; }

View File

@ -0,0 +1,20 @@
.CodeMirror-foldmarker {
color: blue;
text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px;
font-family: arial;
line-height: .3;
cursor: pointer;
}
.CodeMirror-foldgutter {
width: .7em;
}
.CodeMirror-foldgutter-open,
.CodeMirror-foldgutter-folded {
cursor: pointer;
}
.CodeMirror-foldgutter-open:after {
content: "\25BE";
}
.CodeMirror-foldgutter-folded:after {
content: "\25B8";
}

View File

@ -0,0 +1,61 @@
#nprogress {
pointer-events: none;
}
#nprogress .bar {
background: #29d;
position: fixed;
z-index: 1031;
top: 0;
left: 0;
width: 100%;
height: 2px;
}
#nprogress .peg {
display: block;
position: absolute;
right: 0;
width: 100px;
height: 100%;
box-shadow: 0 0 10px #29d, 0 0 5px #29d;
opacity: 1.0;
-webkit-transform: rotate(3deg) translate(0px, -4px);
-ms-transform: rotate(3deg) translate(0px, -4px);
transform: rotate(3deg) translate(0px, -4px);
}
#nprogress .spinner {
display: block;
position: fixed;
z-index: 1031;
top: 15px;
right: 15px;
}
#nprogress .spinner-icon {
width: 18px;
height: 18px;
box-sizing: border-box;
border: solid 2px transparent;
border-top-color: #29d;
border-left-color: #29d;
border-radius: 50%;
-webkit-animation: nprogress-spinner 400ms linear infinite;
animation: nprogress-spinner 400ms linear infinite;
}
.nprogress-custom-parent {
overflow: hidden;
position: relative;
}
.nprogress-custom-parent #nprogress .spinner,
.nprogress-custom-parent #nprogress .bar {
position: absolute;
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}

View File

@ -0,0 +1,17 @@
{
"presets": [
["env", {
"spec": true,
"modules": false,
"targets": {
"browsers": ["last 2 versions", "safari >= 7"],
"node": 6
}
}]
],
"plugins": [
"babel-plugin-transform-flow-strip-types",
"external-helpers",
"istanbul"
]
}

View File

@ -0,0 +1,31 @@
{
"parser": "babel-eslint",
"extends": [
"eslint:recommended",
"plugin:flowtype/recommended",
"xo-space/esnext",
"prettier",
"prettier/flowtype"
],
"plugins": [
"flowtype",
"flowtype-errors",
"prettier"
],
"rules": {
"prettier/prettier": ["error", {
"useTabs": false,
"printWidth": 80,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"semi": true
}]
},
"env": {
"es6": true,
"node": true
}
}

View File

@ -0,0 +1,13 @@
[ignore]
.*/node_modules/.*
.*/dist/.*
.*/coverage/.*
.*/.nyc_output/.*
[include]
[libs]
flow-typed
./src/types.js
[options]

View File

@ -0,0 +1,580 @@
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_es50xc93t = function () {
var path = '/Users/ramitos/dev/yld/joyent-portal/spikes/compose-demo/vendor/docker-compose-client/src/index.js',
hash = 'f84fef795787745e6663470c5523a8005895771a',
global = new Function('return this')(),
gcv = '__coverage__',
coverageData = {
path: '/Users/ramitos/dev/yld/joyent-portal/spikes/compose-demo/vendor/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: 12,
column: 7
}
},
'5': {
start: {
line: 14,
column: 4
},
end: {
line: 14,
column: 34
}
},
'6': {
start: {
line: 15,
column: 4
},
end: {
line: 15,
column: 60
}
},
'7': {
start: {
line: 15,
column: 35
},
end: {
line: 15,
column: 58
}
},
'8': {
start: {
line: 17,
column: 4
},
end: {
line: 17,
column: 53
}
},
'9': {
start: {
line: 22,
column: 4
},
end: {
line: 22,
column: 45
}
},
'10': {
start: {
line: 26,
column: 4
},
end: {
line: 26,
column: 31
}
},
'11': {
start: {
line: 31,
column: 4
},
end: {
line: 31,
column: 71
}
},
'12': {
start: {
line: 35,
column: 4
},
end: {
line: 46,
column: 6
}
},
'13': {
start: {
line: 40,
column: 53
},
end: {
line: 43,
column: 9
}
},
'14': {
start: {
line: 50,
column: 0
},
end: {
line: 50,
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: 18,
column: 3
}
},
line: 6
},
'1': {
name: '(anonymous_1)',
decl: {
start: {
line: 15,
column: 28
},
end: {
line: 15,
column: 29
}
},
loc: {
start: {
line: 15,
column: 35
},
end: {
line: 15,
column: 58
}
},
line: 15
},
'2': {
name: '(anonymous_2)',
decl: {
start: {
line: 21,
column: 2
},
end: {
line: 21,
column: 3
}
},
loc: {
start: {
line: 21,
column: 25
},
end: {
line: 23,
column: 3
}
},
line: 21
},
'3': {
name: '(anonymous_3)',
decl: {
start: {
line: 25,
column: 2
},
end: {
line: 25,
column: 3
}
},
loc: {
start: {
line: 25,
column: 10
},
end: {
line: 27,
column: 3
}
},
line: 25
},
'4': {
name: '(anonymous_4)',
decl: {
start: {
line: 29,
column: 2
},
end: {
line: 29,
column: 3
}
},
loc: {
start: {
line: 29,
column: 39
},
end: {
line: 32,
column: 3
}
},
line: 29
},
'5': {
name: '(anonymous_5)',
decl: {
start: {
line: 34,
column: 2
},
end: {
line: 34,
column: 3
}
},
loc: {
start: {
line: 34,
column: 45
},
end: {
line: 47,
column: 3
}
},
line: 34
},
'6': {
name: '(anonymous_6)',
decl: {
start: {
line: 40,
column: 44
},
end: {
line: 40,
column: 45
}
},
loc: {
start: {
line: 40,
column: 53
},
end: {
line: 43,
column: 9
}
},
line: 40
}
},
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_es50xc93t.s[0], require('zerorpc'));
var Client = _ref.Client;
var _ref2 = (++cov_es50xc93t.s[1], require('events'));
var EventEmitter = _ref2.EventEmitter;
var awaitify = (++cov_es50xc93t.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_es50xc93t.b[0][0], 'tcp://0.0.0.0:4242');
classCallCheck(this, DockerComposeClient);
++cov_es50xc93t.f[0];
++cov_es50xc93t.s[3];
var _this = possibleConstructorReturn(this, (DockerComposeClient.__proto__ || Object.getPrototypeOf(DockerComposeClient)).call(this));
++cov_es50xc93t.s[4];
_this.client = new Client({
heartbeatInterval: 60 * 60 * 2,
timeout: 60 * 60 * 2
});
++cov_es50xc93t.s[5];
_this.client.connect(endpoint);
++cov_es50xc93t.s[6];
_this.client.on('error', function (err) {
newArrowCheck(this, _this2);
++cov_es50xc93t.f[1];
++cov_es50xc93t.s[7];
return _this.emit('error', err);
}.bind(this));
++cov_es50xc93t.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_es50xc93t.f[2];
++cov_es50xc93t.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_es50xc93t.f[3];
++cov_es50xc93t.s[10];
return this.client.close();
}
}, {
key: 'provision',
value: function provision(_ref3) {
var projectName = _ref3.projectName,
manifest = _ref3.manifest;
++cov_es50xc93t.f[4];
++cov_es50xc93t.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_es50xc93t.f[5];
++cov_es50xc93t.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_es50xc93t.f[6];
++cov_es50xc93t.s[13];
return {
name: name,
num: services[name]
};
}.bind(this))
}, manifest);
}
}]);
return DockerComposeClient;
}(EventEmitter);
++cov_es50xc93t.s[14];
module.exports = DockerComposeClient;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZXMuanMiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJjb25zdCB7IENsa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xPQUFmLEVBQXdCLGVBQU87Ozs7bUJBQUtDLElBQUwsQ0FBVSxPQUFWLEVBQW1CQyxHQUFuQjtLQUEvQjs7O1VBRUtDLE9BQUwsR0FBZVIsU0FBUyxNQUFLUSxPQUFMLENBQWFDLElBQWIsT0FBVCxDQUFmOzs7Ozs7Ozs7NEJBSU1DLE1BQWU7Ozs7Ozt3Q0FBTkMsSUFBTTtZQUFBOzs7YUFDZCxnQkFBS1IsTUFBTCxFQUFZUyxNQUFaLGlCQUFtQkYsSUFBbkIsU0FBNEJDLElBQTVCLEVBQVA7Ozs7NEJBR007Ozs7YUFDQyxLQUFLUixNQUFMLENBQVlVLEtBQVosRUFBUDs7OztxQ0FHbUM7VUFBekJDLFdBQXlCLFNBQXpCQSxXQUF5QjtVQUFaQyxRQUFZLFNBQVpBLFFBQVk7Ozs7O2FBRTVCLEtBQUtQLE9BQUwsQ0FBYSxJQUFiLEVBQW1CLEVBQUVRLGNBQWNGLFdBQWhCLEVBQW5CLEVBQWtEQyxRQUFsRCxDQUFQOzs7O2lDQUd5Qzs7O1VBQW5DRCxXQUFtQyxTQUFuQ0EsV0FBbUM7VUFBdEJHLFFBQXNCLFNBQXRCQSxRQUFzQjtVQUFaRixRQUFZLFNBQVpBLFFBQVk7Ozs7YUFDbEMsS0FBS1AsT0FBTCxDQUNMLE9BREssRUFFTDs7c0JBRWdCTSxXQUZoQjtrQkFHWUksT0FBT0MsSUFBUCxDQUFZRixRQUFaLEVBQXNCRyxHQUF0QixDQUEwQixnQkFBUzs7Ozs7c0JBQUE7aUJBRXRDSCxTQUFTUCxJQUFUOztTQUZHO09BTFAsRUFVTEssUUFWSyxDQUFQOzs7O0VBOUI4QmhCOzs7OztBQTZDbENzQixPQUFPQyxPQUFQLEdBQWlCckIsbUJBQWpCIn0=

View File

@ -0,0 +1,588 @@
(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_es50xc93t = function () {
var path = '/Users/ramitos/dev/yld/joyent-portal/spikes/compose-demo/vendor/docker-compose-client/src/index.js',
hash = 'f84fef795787745e6663470c5523a8005895771a',
global = new Function('return this')(),
gcv = '__coverage__',
coverageData = {
path: '/Users/ramitos/dev/yld/joyent-portal/spikes/compose-demo/vendor/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: 12,
column: 7
}
},
'5': {
start: {
line: 14,
column: 4
},
end: {
line: 14,
column: 34
}
},
'6': {
start: {
line: 15,
column: 4
},
end: {
line: 15,
column: 60
}
},
'7': {
start: {
line: 15,
column: 35
},
end: {
line: 15,
column: 58
}
},
'8': {
start: {
line: 17,
column: 4
},
end: {
line: 17,
column: 53
}
},
'9': {
start: {
line: 22,
column: 4
},
end: {
line: 22,
column: 45
}
},
'10': {
start: {
line: 26,
column: 4
},
end: {
line: 26,
column: 31
}
},
'11': {
start: {
line: 31,
column: 4
},
end: {
line: 31,
column: 71
}
},
'12': {
start: {
line: 35,
column: 4
},
end: {
line: 46,
column: 6
}
},
'13': {
start: {
line: 40,
column: 53
},
end: {
line: 43,
column: 9
}
},
'14': {
start: {
line: 50,
column: 0
},
end: {
line: 50,
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: 18,
column: 3
}
},
line: 6
},
'1': {
name: '(anonymous_1)',
decl: {
start: {
line: 15,
column: 28
},
end: {
line: 15,
column: 29
}
},
loc: {
start: {
line: 15,
column: 35
},
end: {
line: 15,
column: 58
}
},
line: 15
},
'2': {
name: '(anonymous_2)',
decl: {
start: {
line: 21,
column: 2
},
end: {
line: 21,
column: 3
}
},
loc: {
start: {
line: 21,
column: 25
},
end: {
line: 23,
column: 3
}
},
line: 21
},
'3': {
name: '(anonymous_3)',
decl: {
start: {
line: 25,
column: 2
},
end: {
line: 25,
column: 3
}
},
loc: {
start: {
line: 25,
column: 10
},
end: {
line: 27,
column: 3
}
},
line: 25
},
'4': {
name: '(anonymous_4)',
decl: {
start: {
line: 29,
column: 2
},
end: {
line: 29,
column: 3
}
},
loc: {
start: {
line: 29,
column: 39
},
end: {
line: 32,
column: 3
}
},
line: 29
},
'5': {
name: '(anonymous_5)',
decl: {
start: {
line: 34,
column: 2
},
end: {
line: 34,
column: 3
}
},
loc: {
start: {
line: 34,
column: 45
},
end: {
line: 47,
column: 3
}
},
line: 34
},
'6': {
name: '(anonymous_6)',
decl: {
start: {
line: 40,
column: 44
},
end: {
line: 40,
column: 45
}
},
loc: {
start: {
line: 40,
column: 53
},
end: {
line: 43,
column: 9
}
},
line: 40
}
},
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_es50xc93t.s[0], require('zerorpc'));
var Client = _ref.Client;
var _ref2 = (++cov_es50xc93t.s[1], require('events'));
var EventEmitter = _ref2.EventEmitter;
var awaitify = (++cov_es50xc93t.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_es50xc93t.b[0][0], 'tcp://0.0.0.0:4242');
classCallCheck(this, DockerComposeClient);
++cov_es50xc93t.f[0];
++cov_es50xc93t.s[3];
var _this = possibleConstructorReturn(this, (DockerComposeClient.__proto__ || Object.getPrototypeOf(DockerComposeClient)).call(this));
++cov_es50xc93t.s[4];
_this.client = new Client({
heartbeatInterval: 60 * 60 * 2,
timeout: 60 * 60 * 2
});
++cov_es50xc93t.s[5];
_this.client.connect(endpoint);
++cov_es50xc93t.s[6];
_this.client.on('error', function (err) {
newArrowCheck(this, _this2);
++cov_es50xc93t.f[1];
++cov_es50xc93t.s[7];
return _this.emit('error', err);
}.bind(this));
++cov_es50xc93t.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_es50xc93t.f[2];
++cov_es50xc93t.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_es50xc93t.f[3];
++cov_es50xc93t.s[10];
return this.client.close();
}
}, {
key: 'provision',
value: function provision(_ref3) {
var projectName = _ref3.projectName,
manifest = _ref3.manifest;
++cov_es50xc93t.f[4];
++cov_es50xc93t.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_es50xc93t.f[5];
++cov_es50xc93t.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_es50xc93t.f[6];
++cov_es50xc93t.s[13];
return {
name: name,
num: services[name]
};
}.bind(this))
}, manifest);
}
}]);
return DockerComposeClient;
}(EventEmitter);
++cov_es50xc93t.s[14];
module.exports = DockerComposeClient;
})));
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXgudW1kLmpzIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXguanMiXSwic291cmNlc0NvbnRlbnQiOlsiY29uc3QgeyBDbGllbnQgfSA9IHJlcXVpcmUoJ3plcm9ycGMnKTtcbmNv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stub for:
*
* 'apr-awaitify'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'apr-awaitify' {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
// Filename aliases
declare module 'apr-awaitify/index' {
declare module.exports: $Exports<'apr-awaitify'>;
}
declare module 'apr-awaitify/index.js' {
declare module.exports: $Exports<'apr-awaitify'>;
}

View File

@ -0,0 +1,283 @@
// flow-typed signature: f88809b2b328b42b18ac808a2185810a
// flow-typed version: <<STUB>>/ava_v0.19.1/flow_v0.45.0
/**
* This is an autogenerated libdef stub for:
*
* 'ava'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'ava' {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'ava/api' {
declare module.exports: any;
}
declare module 'ava/cli' {
declare module.exports: any;
}
declare module 'ava/lib/assert' {
declare module.exports: any;
}
declare module 'ava/lib/ava-error' {
declare module.exports: any;
}
declare module 'ava/lib/ava-files' {
declare module.exports: any;
}
declare module 'ava/lib/babel-config' {
declare module.exports: any;
}
declare module 'ava/lib/beautify-stack' {
declare module.exports: any;
}
declare module 'ava/lib/caching-precompiler' {
declare module.exports: any;
}
declare module 'ava/lib/cli' {
declare module.exports: any;
}
declare module 'ava/lib/code-excerpt' {
declare module.exports: any;
}
declare module 'ava/lib/colors' {
declare module.exports: any;
}
declare module 'ava/lib/concurrent' {
declare module.exports: any;
}
declare module 'ava/lib/enhance-assert' {
declare module.exports: any;
}
declare module 'ava/lib/extract-stack' {
declare module.exports: any;
}
declare module 'ava/lib/fork' {
declare module.exports: any;
}
declare module 'ava/lib/format-assert-error' {
declare module.exports: any;
}
declare module 'ava/lib/globals' {
declare module.exports: any;
}
declare module 'ava/lib/logger' {
declare module.exports: any;
}
declare module 'ava/lib/main' {
declare module.exports: any;
}
declare module 'ava/lib/prefix-title' {
declare module.exports: any;
}
declare module 'ava/lib/process-adapter' {
declare module.exports: any;
}
declare module 'ava/lib/reporters/improper-usage-messages' {
declare module.exports: any;
}
declare module 'ava/lib/reporters/mini' {
declare module.exports: any;
}
declare module 'ava/lib/reporters/tap' {
declare module.exports: any;
}
declare module 'ava/lib/reporters/verbose' {
declare module.exports: any;
}
declare module 'ava/lib/run-status' {
declare module.exports: any;
}
declare module 'ava/lib/runner' {
declare module.exports: any;
}
declare module 'ava/lib/sequence' {
declare module.exports: any;
}
declare module 'ava/lib/serialize-error' {
declare module.exports: any;
}
declare module 'ava/lib/test-collection' {
declare module.exports: any;
}
declare module 'ava/lib/test-worker' {
declare module.exports: any;
}
declare module 'ava/lib/test' {
declare module.exports: any;
}
declare module 'ava/lib/validate-test' {
declare module.exports: any;
}
declare module 'ava/lib/watcher' {
declare module.exports: any;
}
declare module 'ava/profile' {
declare module.exports: any;
}
declare module 'ava/types/make' {
declare module.exports: any;
}
// Filename aliases
declare module 'ava/api.js' {
declare module.exports: $Exports<'ava/api'>;
}
declare module 'ava/cli.js' {
declare module.exports: $Exports<'ava/cli'>;
}
declare module 'ava/index' {
declare module.exports: $Exports<'ava'>;
}
declare module 'ava/index.js' {
declare module.exports: $Exports<'ava'>;
}
declare module 'ava/lib/assert.js' {
declare module.exports: $Exports<'ava/lib/assert'>;
}
declare module 'ava/lib/ava-error.js' {
declare module.exports: $Exports<'ava/lib/ava-error'>;
}
declare module 'ava/lib/ava-files.js' {
declare module.exports: $Exports<'ava/lib/ava-files'>;
}
declare module 'ava/lib/babel-config.js' {
declare module.exports: $Exports<'ava/lib/babel-config'>;
}
declare module 'ava/lib/beautify-stack.js' {
declare module.exports: $Exports<'ava/lib/beautify-stack'>;
}
declare module 'ava/lib/caching-precompiler.js' {
declare module.exports: $Exports<'ava/lib/caching-precompiler'>;
}
declare module 'ava/lib/cli.js' {
declare module.exports: $Exports<'ava/lib/cli'>;
}
declare module 'ava/lib/code-excerpt.js' {
declare module.exports: $Exports<'ava/lib/code-excerpt'>;
}
declare module 'ava/lib/colors.js' {
declare module.exports: $Exports<'ava/lib/colors'>;
}
declare module 'ava/lib/concurrent.js' {
declare module.exports: $Exports<'ava/lib/concurrent'>;
}
declare module 'ava/lib/enhance-assert.js' {
declare module.exports: $Exports<'ava/lib/enhance-assert'>;
}
declare module 'ava/lib/extract-stack.js' {
declare module.exports: $Exports<'ava/lib/extract-stack'>;
}
declare module 'ava/lib/fork.js' {
declare module.exports: $Exports<'ava/lib/fork'>;
}
declare module 'ava/lib/format-assert-error.js' {
declare module.exports: $Exports<'ava/lib/format-assert-error'>;
}
declare module 'ava/lib/globals.js' {
declare module.exports: $Exports<'ava/lib/globals'>;
}
declare module 'ava/lib/logger.js' {
declare module.exports: $Exports<'ava/lib/logger'>;
}
declare module 'ava/lib/main.js' {
declare module.exports: $Exports<'ava/lib/main'>;
}
declare module 'ava/lib/prefix-title.js' {
declare module.exports: $Exports<'ava/lib/prefix-title'>;
}
declare module 'ava/lib/process-adapter.js' {
declare module.exports: $Exports<'ava/lib/process-adapter'>;
}
declare module 'ava/lib/reporters/improper-usage-messages.js' {
declare module.exports: $Exports<'ava/lib/reporters/improper-usage-messages'>;
}
declare module 'ava/lib/reporters/mini.js' {
declare module.exports: $Exports<'ava/lib/reporters/mini'>;
}
declare module 'ava/lib/reporters/tap.js' {
declare module.exports: $Exports<'ava/lib/reporters/tap'>;
}
declare module 'ava/lib/reporters/verbose.js' {
declare module.exports: $Exports<'ava/lib/reporters/verbose'>;
}
declare module 'ava/lib/run-status.js' {
declare module.exports: $Exports<'ava/lib/run-status'>;
}
declare module 'ava/lib/runner.js' {
declare module.exports: $Exports<'ava/lib/runner'>;
}
declare module 'ava/lib/sequence.js' {
declare module.exports: $Exports<'ava/lib/sequence'>;
}
declare module 'ava/lib/serialize-error.js' {
declare module.exports: $Exports<'ava/lib/serialize-error'>;
}
declare module 'ava/lib/test-collection.js' {
declare module.exports: $Exports<'ava/lib/test-collection'>;
}
declare module 'ava/lib/test-worker.js' {
declare module.exports: $Exports<'ava/lib/test-worker'>;
}
declare module 'ava/lib/test.js' {
declare module.exports: $Exports<'ava/lib/test'>;
}
declare module 'ava/lib/validate-test.js' {
declare module.exports: $Exports<'ava/lib/validate-test'>;
}
declare module 'ava/lib/watcher.js' {
declare module.exports: $Exports<'ava/lib/watcher'>;
}
declare module 'ava/profile.js' {
declare module.exports: $Exports<'ava/profile'>;
}
declare module 'ava/types/make.js' {
declare module.exports: $Exports<'ava/types/make'>;
}

View File

@ -0,0 +1,32 @@
// flow-typed signature: 20604af9a6e86cff1e7365a95b7f7b64
// flow-typed version: <<STUB>>/babelrc-rollup_v3.0.0/flow_v0.45.0
/**
* This is an autogenerated libdef stub for:
*
* 'babelrc-rollup'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'babelrc-rollup' {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'babelrc-rollup/dist/babelrc-rollup' {
declare module.exports: any;
}
// Filename aliases
declare module 'babelrc-rollup/dist/babelrc-rollup.js' {
declare module.exports: $Exports<'babelrc-rollup/dist/babelrc-rollup'>;
}

View File

@ -0,0 +1,67 @@
// flow-typed signature: 3cfdd2edb76d3399543bc86f7803f4ac
// flow-typed version: <<STUB>>/rollup-plugin-babel_v2.7.1/flow_v0.45.0
/**
* This is an autogenerated libdef stub for:
*
* 'rollup-plugin-babel'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'rollup-plugin-babel' {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'rollup-plugin-babel/dist/rollup-plugin-babel.cjs' {
declare module.exports: any;
}
declare module 'rollup-plugin-babel/dist/rollup-plugin-babel.es' {
declare module.exports: any;
}
declare module 'rollup-plugin-babel/src/constants' {
declare module.exports: any;
}
declare module 'rollup-plugin-babel/src/index' {
declare module.exports: any;
}
declare module 'rollup-plugin-babel/src/preflightCheck' {
declare module.exports: any;
}
declare module 'rollup-plugin-babel/src/utils' {
declare module.exports: any;
}
// Filename aliases
declare module 'rollup-plugin-babel/dist/rollup-plugin-babel.cjs.js' {
declare module.exports: $Exports<'rollup-plugin-babel/dist/rollup-plugin-babel.cjs'>;
}
declare module 'rollup-plugin-babel/dist/rollup-plugin-babel.es.js' {
declare module.exports: $Exports<'rollup-plugin-babel/dist/rollup-plugin-babel.es'>;
}
declare module 'rollup-plugin-babel/src/constants.js' {
declare module.exports: $Exports<'rollup-plugin-babel/src/constants'>;
}
declare module 'rollup-plugin-babel/src/index.js' {
declare module.exports: $Exports<'rollup-plugin-babel/src/index'>;
}
declare module 'rollup-plugin-babel/src/preflightCheck.js' {
declare module.exports: $Exports<'rollup-plugin-babel/src/preflightCheck'>;
}
declare module 'rollup-plugin-babel/src/utils.js' {
declare module.exports: $Exports<'rollup-plugin-babel/src/utils'>;
}

View File

@ -0,0 +1,143 @@
// flow-typed signature: d02c352f523e296631d9b724125d25d2
// flow-typed version: <<STUB>>/zerorpc_v^0.9.7/flow_v0.45.0
/**
* This is an autogenerated libdef stub for:
*
* 'zerorpc'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'zerorpc' {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'zerorpc/lib/buffer' {
declare module.exports: any;
}
declare module 'zerorpc/lib/channel' {
declare module.exports: any;
}
declare module 'zerorpc/lib/client' {
declare module.exports: any;
}
declare module 'zerorpc/lib/events' {
declare module.exports: any;
}
declare module 'zerorpc/lib/middleware' {
declare module.exports: any;
}
declare module 'zerorpc/lib/server' {
declare module.exports: any;
}
declare module 'zerorpc/lib/socket' {
declare module.exports: any;
}
declare module 'zerorpc/lib/util' {
declare module.exports: any;
}
declare module 'zerorpc/test/buffers' {
declare module.exports: any;
}
declare module 'zerorpc/test/errors' {
declare module.exports: any;
}
declare module 'zerorpc/test/heartbeats' {
declare module.exports: any;
}
declare module 'zerorpc/test/invocation' {
declare module.exports: any;
}
declare module 'zerorpc/test/lib/testutil' {
declare module.exports: any;
}
declare module 'zerorpc/test/repro-10' {
declare module.exports: any;
}
declare module 'zerorpc/test/streams' {
declare module.exports: any;
}
declare module 'zerorpc/test/timeouts' {
declare module.exports: any;
}
// Filename aliases
declare module 'zerorpc/index' {
declare module.exports: $Exports<'zerorpc'>;
}
declare module 'zerorpc/index.js' {
declare module.exports: $Exports<'zerorpc'>;
}
declare module 'zerorpc/lib/buffer.js' {
declare module.exports: $Exports<'zerorpc/lib/buffer'>;
}
declare module 'zerorpc/lib/channel.js' {
declare module.exports: $Exports<'zerorpc/lib/channel'>;
}
declare module 'zerorpc/lib/client.js' {
declare module.exports: $Exports<'zerorpc/lib/client'>;
}
declare module 'zerorpc/lib/events.js' {
declare module.exports: $Exports<'zerorpc/lib/events'>;
}
declare module 'zerorpc/lib/middleware.js' {
declare module.exports: $Exports<'zerorpc/lib/middleware'>;
}
declare module 'zerorpc/lib/server.js' {
declare module.exports: $Exports<'zerorpc/lib/server'>;
}
declare module 'zerorpc/lib/socket.js' {
declare module.exports: $Exports<'zerorpc/lib/socket'>;
}
declare module 'zerorpc/lib/util.js' {
declare module.exports: $Exports<'zerorpc/lib/util'>;
}
declare module 'zerorpc/test/buffers.js' {
declare module.exports: $Exports<'zerorpc/test/buffers'>;
}
declare module 'zerorpc/test/errors.js' {
declare module.exports: $Exports<'zerorpc/test/errors'>;
}
declare module 'zerorpc/test/heartbeats.js' {
declare module.exports: $Exports<'zerorpc/test/heartbeats'>;
}
declare module 'zerorpc/test/invocation.js' {
declare module.exports: $Exports<'zerorpc/test/invocation'>;
}
declare module 'zerorpc/test/lib/testutil.js' {
declare module.exports: $Exports<'zerorpc/test/lib/testutil'>;
}
declare module 'zerorpc/test/repro-10.js' {
declare module.exports: $Exports<'zerorpc/test/repro-10'>;
}
declare module 'zerorpc/test/streams.js' {
declare module.exports: $Exports<'zerorpc/test/streams'>;
}
declare module 'zerorpc/test/timeouts.js' {
declare module.exports: $Exports<'zerorpc/test/timeouts'>;
}

View File

@ -0,0 +1,82 @@
{
"name": "docker-compose-client",
"version": "1.0.0",
"private": true,
"description": "",
"license": "Apache-2.0",
"author": "Sérgio Ramos <mail@sergioramos.me>",
"repository": "github:yldio/docker-compose-client",
"keywords": [],
"files": [
"dist"
],
"main": "dist/index.umd.js",
"jsnext:main": "dist/index.es.js",
"module": "dist/index.es.js",
"entry": "src/index.js",
"scripts": {
"fmt": "prettier --write --single-quote --parser flow",
"format": "fmt {src,scripts,test}/**/*.js",
"lint": "eslint {src,scripts,test}/**/*.js --fix",
"test": "npm run build && cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text ava",
"flow": "flow check",
"lint-staged": "lint-staged",
"build": "rollup --config scripts/rollup.config.js",
"prepublish": "npm run build",
"dev-start": "npm run build && node ."
},
"dependencies": {
"apr-awaitify": "^1.0.2",
"zerorpc": "^0.9.7"
},
"devDependencies": {
"apr-intercept": "^1.0.2",
"ava": "0.19.1",
"babel-eslint": "^7.2.3",
"babel-plugin-external-helpers": "6.22.0",
"babel-plugin-istanbul": "^4.1.3",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-preset-env": "1.4.0",
"babel-preset-flow": "^6.23.0",
"babelrc-rollup": "3.0.0",
"cross-env": "^4.0.0",
"documentation": "4.0.0-rc.1",
"eslint": "3.19.0",
"eslint-config-prettier": "2.0.0",
"eslint-config-xo-space": "^0.16.0",
"eslint-plugin-flowtype": "2.32.1",
"eslint-plugin-flowtype-errors": "3.2.0",
"eslint-plugin-prettier": "^2.0.1",
"flow-bin": "0.45.0",
"flow-typed": "^2.1.2",
"js-yaml": "^3.8.4",
"lint-staged": "3.4.1",
"nyc": "10.3.2",
"pre-commit": "1.2.2",
"prettier": "1.3.1",
"quality-docs": "3.3.0",
"rollup": "0.41.6",
"rollup-plugin-babel": "2.7.1"
},
"pre-commit": "lint-staged",
"lint-staged": {
"*.js": [
"npm run fmt",
"eslint --fix",
"git add"
]
},
"nyc": {
"sourceMap": false,
"instrument": false
},
"ava": {
"files": [
"test/*.js"
],
"source": [
"src/**/*.{js,jsx}"
],
"tap": true
}
}

View File

@ -0,0 +1,27 @@
# docker-compose-client
## usage
```js
const client = new DockerComposeClient();
const res = await client.provision({
projectName: 'docker-compose-client',
manifest: `
hello:
image: hello-world:latest
world:
image: consul:latest
node:
image: node:latest
`
});
```
## todo
- proper flow support
## license
Apache-2.0

View File

@ -0,0 +1,30 @@
const babel = require('rollup-plugin-babel');
const { default: babelrc } = require('babelrc-rollup');
const path = require('path');
const pkg = require('../package.json');
module.exports = {
entry: path.join(__dirname, '..', pkg.entry),
external: Object.keys(pkg.dependencies),
plugins: [
babel(
babelrc({
path: path.join(__dirname, '../.babelrc')
})
)
],
targets: [
{
dest: path.join(__dirname, '..', pkg.main),
moduleName: pkg.name,
format: 'umd',
sourceMap: 'inline'
},
{
dest: path.join(__dirname, '..', pkg.module),
format: 'es',
sourceMap: 'inline'
}
]
};

View File

@ -0,0 +1,50 @@
const { Client } = require('zerorpc');
const { EventEmitter } = require('events');
const awaitify = require('apr-awaitify');
class DockerComposeClient extends EventEmitter {
constructor(endpoint = 'tcp://0.0.0.0:4242') {
super();
this.client = new Client({
heartbeatInterval: (60 * 60 * 2),
timeout: (60 * 60 * 2)
});
this.client.connect(endpoint);
this.client.on('error', err => this.emit('error', err));
this._invoke = awaitify(this._invoke.bind(this));
}
// Why isn't client.connect async with error??
_invoke(name, ...args) {
return this.client.invoke(name, ...args);
}
close() {
return this.client.close();
}
provision({ projectName, manifest }) {
// eslint-disable-next-line camelcase
return this._invoke('up', { project_name: projectName }, manifest);
}
scale({ projectName, services, manifest }) {
return this._invoke(
'scale',
{
// eslint-disable-next-line camelcase
project_name: projectName,
services: Object.keys(services).map(name => ({
name,
num: services[name]
}))
},
manifest
);
}
}
module.exports = DockerComposeClient;

View File

@ -0,0 +1,3 @@
export type Service = {
[string]: string
};

View File

@ -0,0 +1,122 @@
const { name } = require('../package.json');
const { safeLoad } = require('js-yaml');
const { Server } = require('zerorpc');
const intercept = require('apr-intercept');
const test = require('ava');
const DockerComposeClient = require('../');
const client = new DockerComposeClient();
const server = new Server({
up: function(options, manifest, fn) {
let m;
if (typeof options !== 'object') {
return fn(new Error('Expected options'));
}
if (typeof options.project_name !== 'string') {
return fn(new Error('Expected project name'));
}
if (typeof manifest !== 'string') {
return fn(new Error('Expected manifest'));
}
try {
m = safeLoad(manifest);
} catch (err) {
return fn(err);
}
fn(null, {
projectName: options.project_name
});
},
scale: function(options, manifest, fn) {
let m;
if (typeof options !== 'object') {
return fn(new Error('Expected options'));
}
if (typeof options.project_name !== 'string') {
return fn(new Error('Expected project name'));
}
if (!Array.isArray(options.services)) {
return fn(new Error('Expected services'));
}
if (typeof manifest !== 'string') {
return fn(new Error('Expected manifest'));
}
try {
m = safeLoad(manifest);
} catch (err) {
return fn(err);
}
fn(null, {
projectName: options.project_name,
services: options.services
});
}
});
server.bind('tcp://0.0.0.0:4242');
test('provision', async t => {
const [err, res] = await intercept(
client.provision({
projectName: name,
manifest: `
hello:
image: hello-world:latest
world:
image: consul:latest
node:
image: node:latest
`
})
);
t.ifError(err);
t.deepEqual(res, {
projectName: name
});
});
test('scale', async t => {
const [err, res] = await intercept(
client.scale({
projectName: name,
services: {
hello: 2,
world: 3
},
manifest: `
hello:
image: hello-world:latest
world:
image: consul:latest
node:
image: node:latest
`
})
);
t.ifError(err);
t.deepEqual(res, {
projectName: name,
services: [{ name: 'hello', num: 2 }, { name: 'world', num: 3 }]
});
});
test.after(() => {
client.close();
server.close();
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff