Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[include]

[ignore]
.*/node_modules/.*/\(lib\|test\|examples\).*\.json$
.*/node_modules/documentation/.*

[include]

[libs]
<PROJECT-ROOT>/flow-typed/.*
[lints]
all=warn

[options]
include_warnings=true
12 changes: 7 additions & 5 deletions config/.babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"presets": [
"env",
"react",
"stage-0",
"flow"
["env", {
"targets": {
"node": "8.9"
}
}]
],
"plugins": [
"transform-flow-strip-types",
[
"transform-runtime",
{ "polyfill": false, "regenerator": true }
Expand All @@ -17,6 +19,6 @@
]
],
"ignore": [
"specs"
"test/integration"
]
}
6 changes: 6 additions & 0 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ let plugins = [
{
loader: require.resolve('babel-loader'),
query: {
presets: [
"env",
"react",
"stage-0",
"flow"
],
plugins: [
require.resolve('react-hot-loader/babel'),
[
Expand Down
20 changes: 20 additions & 0 deletions init/.circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
jobs:
build:
docker:
- image: circleci/node:8.9
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: yarn test
- run: ./node_modules/.bin/hull-connector-tester
13 changes: 10 additions & 3 deletions init/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
"url": "https://github.com/<%= packageGitHubOrg %>"
},
"engines": {
"node": "8.x",
"npm": "3.x"
"node": "8.9.x",
"npm": "5.5.x",
"yarn": "1.3.x"
},
"lint-staged": {
"*.{js,jsx,css,scss,json}": ["prettier --write --single-quote", "git add"]
Expand All @@ -31,13 +32,15 @@
"update": "builder run update",
"test:client": "builder run test:client",
"test:coverage": "builder run test:coverage",
"test:flow": "builder run test:flow",
"test:lint": "builder run test:lint",
"test:modules": "builder run test:modules",
"test:specs": "builder run test:specs",
"test:units": "builder run test:units",
"start": "NODE_ENV=production node -r newrelic lib",
"dev": "builder run dev",
"test": "builder run npm:test"
"test": "builder run npm:test",
"repl": "builder run npm:repl"
},
"dependencies": {
"bluebird": "^3.5.1",
Expand All @@ -59,6 +62,10 @@
"redux-thunk": "^2.2.0"
},
"devDependencies": {
"chai": "^4.1.2",
"hull-connector-tester": "^0.1.1",
"flow-bin": "^0.59.0",
"flow-typed": "^2.2.3",
"react-hot-loader": "^3.1.1",
"reactotron-react-js": "^1.12.2",
"reactotron-redux": "^1.12.2"
Expand Down
6 changes: 4 additions & 2 deletions init/server/handlers/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export statusHandler from './status';
export notifyHandler from './notify';
module.exports = {
statusHandler: require("./status"),
notifyHandler: require("./notify")
};
6 changes: 3 additions & 3 deletions init/server/handlers/notify.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Promise from 'bluebird';
import { smartNotifierHandler } from 'hull/lib/utils';
const Promise = require("bluebird";
const { smartNotifierHandler, notifyHandler } = require("hull/lib/utils");

const notify = smartNotifierHandler({
handlers: {
Expand All @@ -21,4 +21,4 @@ const notify = smartNotifierHandler({
},
});

export default notify;
module.exports = notify;
4 changes: 3 additions & 1 deletion init/server/handlers/status.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export default function statusCheck(req, res) {
function statusCheck(req, res) {
const { ship, client } = req.hull;
const messages = [];
let status = 'ok';
res.json({ messages, status });
return client.put(`${req.hull.ship.id}/status`, { status, messages });
}

module.exports = statusCheck;
8 changes: 3 additions & 5 deletions init/server/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import Hull from 'hull';
import server from './server';
import pkg from '../package.json';
import { dotEnv } from 'hull-connector';
dotEnv();
const Hull = require("hull");
const server = require("./server");
const pkg = require("../package.json");

const {
SECRET = '1234',
Expand Down
12 changes: 12 additions & 0 deletions init/server/lib/service-client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Main 3rd party Service API client.
* Should implement functions like:
* `getContacts`
* `postContacts`
* which are named around the 3rd party API naming convention
*/
class ServiceClient {

}

module.exports = ServiceClient;
10 changes: 10 additions & 0 deletions init/server/lib/sync-agent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Main syncing utility.
* Should expose methods to work on hull data, transform it
* and use ServiceClient to push it further to 3rd party Service API
*/
class SyncAgent {

}

module.exports = SyncAgent;
14 changes: 9 additions & 5 deletions init/server/server.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import express from 'express';
import { errorHandler } from 'hull-connector';
import { statusHandler, notifyHandler } from './handlers';
const express = require("express");
const { errorHandler } = require("hull-connector");
const { statusHandler, notifyHandler } = require("./handlers");

export default function Server(options = {}) {
function server(options = {}) {
const app = express();
const { Hull } = options;

Expand All @@ -18,8 +18,12 @@ export default function Server(options = {}) {
app.post('/smart-notifier', notifyHandler);
app.all('/status', statusHandler);

connector.startApp(app);

// Error Handler
app.use(errorHandler);
connector.startApp(app);

return app;
}

module.exports = server;
7 changes: 7 additions & 0 deletions init/test/integration/integration-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { expect } = require("chai");

describe("integration test", () => {
it("should pass", () => {
expect(true).to.be.true;
});
});
7 changes: 7 additions & 0 deletions init/test/unit/unit-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { expect } = require("chai");

describe("unit test", () => {
it("should pass", () => {
expect(true).to.be.true;
});
});
4 changes: 3 additions & 1 deletion lib/dev-mode.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const _ = require("lodash");

export default function devMode(app, options) {
const _ = require('lodash');
const webpack = require('webpack');
Expand Down Expand Up @@ -28,7 +30,7 @@ export default function devMode(app, options) {
new webpack.NoEmitOnErrorsPlugin(),
];

const compiler = webpack({ ...config, entry, plugins });
const compiler = webpack(_.merge({}, config, { entry, plugins }));

app.use(
webpackDevMiddleware(compiler, {
Expand Down
3 changes: 0 additions & 3 deletions lib/dot-env.js

This file was deleted.

5 changes: 2 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export devMode from './dev-mode';
export errorHandler from './error';
export dotEnv from './dot-env';
export { devMode } from './dev-mode';
export { errorHandler } from './error';
27 changes: 19 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"main": "dist/index.js",
"license": "MIT",
"homepage": "https://hull.io/docs",
"keywords": ["hull", "ship", "hull-ship"],
"keywords": [
"hull",
"ship",
"hull-ship"
],
"author": {
"name": "Hull",
"email": "contact@hull.io",
Expand All @@ -16,14 +20,17 @@
"npm": "3.x"
},
"lint-staged": {
"*.{js,jsx,css,scss,json}": ["prettier --write --single-quote", "git add"]
"*.{js,jsx,css,scss,json}": [
"prettier --write --single-quote",
"git add"
]
},
"scripts": {
"gen-dev": "./node_modules/.bin/builder-support gen-dev",
"publish:both": "npm run gen-dev ; npm run prepare ; npm publish ; npm publish dev",
"lint": "eslint --color -c config/eslint/.eslintrc src server",
"flow": "flow",
"clean": "rimraf dist; rimraf lib",
"repl": "hull-repl",
"update": "npm-check",
"precommit": "lint-staged",
"npm:postinstall": "builder --env='{\"NODE_ENV\":\"production\"}' run build",
Expand All @@ -32,14 +39,15 @@
"build": "builder run clean && builder run build:server && builder run build:client",
"build:server": "NODE_ENV=production babel server --copy-files -d lib",
"build:client": "NODE_ENV=production webpack --config ./node_modules/hull-connector/config/webpack.config.js",
"dev": "NODE_ENV=development babel-watch -w server server/index.js",
"npm:test": "builder run test:lint && builder run test:units && builder run test:specs",
"dev": "NODE_ENV=development dotenv babel-watch -w server server/index.js",
"npm:test": "builder run test:lint && builder run test:unit && builder run test:integration",
"test:flow": "flow check",
"test:lint": "eslint server",
"test:modules": "npm outdated --depth=0",
"test:coverage": "NODE_ENV=test jest --env=jsdom --config=jest.config.json --coverage",
"test:client": "NODE_ENV=test jest --env=jsdom --config=jest.config.json",
"test:units": "NODE_ENV=test mocha --require babel-register -R spec ./tests/unit/*.js",
"test:specs": "NODE_ENV=test mocha --require babel-register -R spec ./tests/integration/*.js"
"test:unit": "NODE_ENV=test mocha --require babel-register -R spec ./test/unit/*.js",
"test:integration": "NODE_ENV=test mocha --require babel-register -R spec ./test/integration/*.js"
},
"dependencies": {
"autoprefixer": "^7.1.6",
Expand All @@ -63,7 +71,7 @@
"builder-support": "^0.5.0",
"chalk": "^2.3.0",
"css-loader": "^0.28.7",
"dotenv": "^4.0.0",
"dotenv-cli": "^1.4.0",
"exit-hook": "^1.1.1",
"glob": "^7.1.2",
"happypack": "^4.0.0",
Expand All @@ -80,6 +88,9 @@
"webpack-alternate-require-loader": "^0.0.3"
},
"devDependencies": {
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"hull-repl": "^0.1.1",
"mocha": "^4.0.1",
"npm-check": "^5.5.1",
"rimraf": "^2.6.2"
}
Expand Down
Loading