Restructure for monorepo

This commit is contained in:
Robert Schäfer 2019-03-20 21:17:53 +01:00
parent 4fe89e88ac
commit 44d1265681
55 changed files with 5095 additions and 1481 deletions

18
.gitignore vendored Normal file
View File

@ -0,0 +1,18 @@
.env
.idea
.vscode
.DS_Store
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.yarn-integrity
.eslintcache
/.github
node_modules/
cypress/videos
cypress/screenshots/
cypress.env.json
!.gitkeep

View File

@ -1,26 +1,21 @@
language: node_js
node_js:
- "10"
cache:
yarn: true
directories:
- node_modules
language: generic
services:
- docker
env:
- DOCKER_COMPOSE_VERSION=1.23.2
addons:
chrome: stable
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
before_install:
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
- yarn global add wait-on
- yarn install
- cp cypress.env.template.json cypress.env.json
install:
- docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT --target production -t humanconnection/nitro-backend:latest .
- docker-compose -f docker-compose.yml -f docker-compose.travis.yml up -d
- docker-compose -f docker-compose.yml -f docker-compose.travis.yml up --build -d
- wait-on http://localhost:7474 && docker-compose exec neo4j migrate
script:
@ -32,11 +27,20 @@ script:
- docker-compose exec backend yarn run test:coverage
- docker-compose exec backend yarn run db:reset
- docker-compose exec backend yarn run db:seed
- docker-compose exec webapp yarn run lint
- docker-compose exec webapp yarn run test --ci
- docker-compose exec -d backend yarn run test:cypress
- yarn run cypress:run --record --key $CYPRESS_TOKEN
after_success:
- wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
- chmod +x send.sh
- ./send.sh success $WEBHOOK_URL
- if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_EVENT_TYPE == "push" ]; then
wget https://raw.githubusercontent.com/Human-Connection/Discord-Bot/develop/tester.sh &&
chmod +x tester.sh &&
./tester.sh staging $WEBHOOK_URL;
fi
after_failure:
- wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
@ -48,17 +52,3 @@ deploy:
script: scripts/docker_push.sh
on:
branch: master
- provider: script
script: scripts/deploy.sh nitro.human-connection.org
on:
branch: master
tags: true
- provider: script
script: scripts/deploy.sh nitro-staging.human-connection.org
on:
branch: master
- provider: script
script: scripts/deploy.sh "nitro-$TRAVIS_COMMIT.human-connection.org"
on:
tags: true
all_branches: true

View File

@ -1,20 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Authenticate '...'
2. Post following data to endpoint '...'
3. See error
**Expected behavior**
A clear and concise description of what you expected to happen
**Additional context**
Add any other context about the problem here.

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
echo "See me deployed at $1 :)"

View File

@ -1,3 +0,0 @@
#!/usr/bin/env bash
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker push humanconnection/nitro-backend:latest

View File

@ -1 +0,0 @@
#!/usr/bin/env bash

View File

@ -1896,9 +1896,9 @@ bitcore-lib@^0.13.7:
inherits "=2.0.1"
lodash "=3.10.1"
"bitcore-message@github:comakery/bitcore-message#dist":
"bitcore-message@github:CoMakery/bitcore-message#dist":
version "1.0.2"
resolved "https://codeload.github.com/comakery/bitcore-message/tar.gz/8799cc327029c3d34fc725f05b2cf981363f6ebf"
resolved "https://codeload.github.com/CoMakery/bitcore-message/tar.gz/8799cc327029c3d34fc725f05b2cf981363f6ebf"
dependencies:
bitcore-lib "^0.13.7"

View File

@ -0,0 +1,17 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}

View File

@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

View File

@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')

View File

@ -1,6 +1,5 @@
// TODO: find a better way how to import the factories
import Factory from '../../../Nitro-Backend/src/seed/factories'
import { getDriver } from '../../../Nitro-Backend/src/bootstrap/neo4j'
import Factory from '../../backend/src/seed/factories'
import { getDriver } from '../../backend/src/bootstrap/neo4j'
const neo4jDriver = getDriver({
uri: Cypress.env('NEO4J_URI'),

View File

@ -1,7 +1,7 @@
import find from 'lodash/find'
const helpers = {
locales: require('../../locales'),
locales: require('../../webapp/locales'),
getLangByName: name => {
return find(helpers.locales, { name })
}

View File

@ -0,0 +1,34 @@
version: "3.4"
services:
webapp:
build:
context: webapp
target: build-and-test
volumes:
- ./webapp:/nitro-web
- webapp_node_modules:/nitro-web/node_modules
command: yarn run dev
user: root
backend:
image: humanconnection/nitro-backend:builder
build:
context: backend
target: builder
volumes:
- ./backend:/nitro-backend
- backend_node_modules:/nitro-backend/node_modules
command: yarn run dev
neo4j:
environment:
- NEO4J_AUTH=none
ports:
- 7687:7687
- 7474:7474
volumes:
- neo4j-data:/data
volumes:
webapp_node_modules:
backend_node_modules:
neo4j-data:

29
docker-compose.travis.yml Normal file
View File

@ -0,0 +1,29 @@
version: "3.4"
services:
neo4j:
environment:
- NEO4J_AUTH=none
ports:
- 7687:7687
- 7474:7474
webapp:
build:
context: webapp
target: build-and-test
environment:
- BACKEND_URL=http://backend:4123
backend:
image: humanconnection/nitro-backend:builder
build:
context: backend
target: builder
ports:
- 4001:4001
- 4123:4123
neo4j:
environment:
- NEO4J_AUTH=none
ports:
- 7687:7687
- 7474:7474

46
docker-compose.yml Normal file
View File

@ -0,0 +1,46 @@
version: "3.4"
services:
webapp:
image: humanconnection/nitro-web:latest
build:
context: webapp
target: production
ports:
- 3000:3000
- 8080:8080
networks:
- hc-network
environment:
- HOST=0.0.0.0
- BACKEND_URL=http://backend:4000
- MAPBOX_TOKEN="pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.bZ8KK9l70omjXbEkkbHGsQ"
backend:
image: humanconnection/nitro-backend:latest
build:
context: backend
target: production
networks:
- hc-network
depends_on:
- neo4j
ports:
- 4000:4000
environment:
- NEO4J_URI=bolt://neo4j:7687
- GRAPHQL_PORT=4000
- GRAPHQL_URI=http://localhost:4000
- CLIENT_URI=http://localhost:3000
- JWT_SECRET=b/&&7b78BF&fv/Vd
- MOCK=false
- MAPBOX_TOKEN=pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.KZ8KK9l70omjXbEkkbHGsQ
- PRIVATE_KEY_PASSPHRASE=a7dsf78sadg87ad87sfagsadg78
neo4j:
image: humanconnection/neo4j:latest
build:
context: backend/neo4j
networks:
- hc-network
networks:
hc-network:

22
package.json Normal file
View File

@ -0,0 +1,22 @@
{
"name": "nitro-cypress",
"version": "1.0.0",
"description": "Fullstack tests with cypress for Human Connection",
"author": "Human Connection gGmbh",
"license": "MIT",
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
},
"scripts": {
"cypress:run": "cypress run --browser chrome",
"cypress:open": "cypress open --browser chrome"
},
"devDependencies": {
"cypress": "^3.2.0",
"cypress-cucumber-preprocessor": "^1.11.0",
"dotenv": "^7.0.0",
"faker": "^4.1.0",
"graphql-request": "^1.8.2",
"neo4j-driver": "^1.7.3"
}
}

6
scripts/docker_push.sh Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT --target production -t humanconnection/nitro-backend:latest $TRAVIS_BUILD_DIR/backend
docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT --target production -t humanconnection/nitro-web:latest $TRAVIS_BUILD_DIR/webapp
docker push humanconnection/nitro-backend:latest
docker push humanconnection/nitro-web:latest

View File

@ -1,17 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@ -1,79 +0,0 @@
language: node_js
node_js:
- "10"
cache:
yarn: true
directories:
- node_modules
services:
- docker
addons:
chrome: stable
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
env:
- DOCKER_COMPOSE_VERSION=1.23.2 BACKEND_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH:-${TRAVIS_BRANCH:-master}}
before_install:
- echo $BACKEND_BRANCH
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
- cp cypress.env.template.json cypress.env.json
install:
- docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT --target production -t humanconnection/nitro-web .
- docker-compose -f docker-compose.yml -f docker-compose.travis.yml up -d
- git clone https://github.com/Human-Connection/Nitro-Backend.git ../Nitro-Backend
- git -C "../Nitro-Backend" checkout $BACKEND_BRANCH || git -C "../Nitro-Backend" checkout master
- cd ../Nitro-Backend && yarn install && cd -
- docker-compose -f ../Nitro-Backend/docker-compose.yml -f ../Nitro-Backend/docker-compose.cypress.yml up -d
- yarn global add cypress wait-on
- yarn add cypress-cucumber-preprocessor
script:
- docker-compose exec -e NODE_ENV=test webapp yarn run lint
- docker-compose exec -e NODE_ENV=test webapp yarn run test
- wait-on http://localhost:7474 && docker-compose -f ../Nitro-Backend/docker-compose.yml exec neo4j migrate
- wait-on http://localhost:3000 && cypress run --browser chrome --record --key $CYPRESS_TOKEN
after_success:
- wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
- chmod +x send.sh
- ./send.sh success $WEBHOOK_URL
- if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_EVENT_TYPE == "push" ]; then
wget https://raw.githubusercontent.com/Human-Connection/Discord-Bot/develop/tester.sh &&
chmod +x tester.sh &&
./tester.sh staging $WEBHOOK_URL;
fi
after_failure:
- wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
- chmod +x send.sh
- ./send.sh failure $WEBHOOK_URL
deploy:
- provider: script
script: scripts/docker_push.sh
on:
branch: master
- provider: script
script: scripts/deploy.sh nitro.human-connection.org
on:
branch: master
tags: true
- provider: script
script: scripts/deploy.sh nitro-staging.human-connection.org
on:
branch: master
- provider: script
script: scripts/deploy.sh "nitro-$(git rev-parse --short HEAD).human-connection.org"
on:
tags: true
all_branches: true

View File

@ -1,46 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at developer@human-connection.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2018 Human-Connection gGmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -82,6 +82,7 @@ export default {
routes.push({
name: this.$t(`comment.edit`),
callback: () => {
/* eslint-disable-next-line no-console */
console.log('EDIT COMMENT')
},
icon: 'edit'

View File

@ -7,3 +7,4 @@ services:
target: build-and-test
environment:
- BACKEND_URL=http://backend:4123
- NODE_ENV=test

View File

@ -142,6 +142,7 @@ module.exports = {
// includeNodeModules: true, // optional, default: false (this includes graphql-tag for node_modules folder)
// optional
errorHandler(error) {
/* eslint-disable-next-line no-console */
console.log(
'%cError',
'background: red; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;',

View File

@ -17,9 +17,6 @@
"e2e:ci": "npm-run-all --parallel --race start:ci 'cypress:ci --config baseUrl=http://localhost:3000'",
"test:unit:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --no-cache --runInBand"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
},
"jest": {
"verbose": true,
"moduleFileExtensions": [
@ -73,7 +70,6 @@
"babel-core": "~7.0.0-bridge.0",
"babel-eslint": "~10.0.1",
"babel-jest": "~24.5.0",
"cypress-cucumber-preprocessor": "~1.11.0",
"eslint": "~5.15.1",
"eslint-config-prettier": "~3.6.0",
"eslint-loader": "~2.1.2",

View File

@ -1,5 +1,6 @@
export default ({ $axios, app }) => {
$axios.onRequest(config => {
/* eslint-disable-next-line no-console */
console.log(Object.keys(app))
// add current ui language
config.headers['Accept-Language'] = app.$i18n.locale()

View File

@ -47,6 +47,7 @@ export default ({ app, req, cookie, store }) => {
Vue.use(vuexI18n.plugin, store, {
onTranslationNotFound: function(locale, key) {
if (debug) {
/* eslint-disable-next-line no-console */
console.warn(
`vuex-i18n :: Key '${key}' not found for locale '${locale}'`
)

View File

@ -1,4 +0,0 @@
#!/bin/bash
echo "See me deployed at $1 :)"

View File

@ -1,3 +0,0 @@
#!/usr/bin/env bash
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker push humanconnection/nitro-web:latest

File diff suppressed because it is too large Load Diff

4772
yarn.lock Normal file

File diff suppressed because it is too large Load Diff