2019-01-23 11:26:13 +01:00
[![banner ](https://raw.githubusercontent.com/oceanprotocol/art/master/github/repo-banner%402x.png )](https://oceanprotocol.com)
2019-04-03 14:40:31 +02:00
< h1 align = "center" > Commons< / h1 >
2019-01-23 11:26:13 +01:00
2019-04-09 15:26:33 +02:00
> 🏄♀️ Marketplace front-end and backend server to explore, download, and publish open data sets.
2019-04-03 14:42:20 +02:00
> https://commons.oceanprotocol.com
2019-01-23 11:26:13 +01:00
2019-04-09 22:39:11 +02:00
[![Build Status ](https://travis-ci.com/oceanprotocol/commons.svg?branch=master )](https://travis-ci.com/oceanprotocol/commons)
2019-04-30 19:24:50 +02:00
[![Codacy Badge ](https://api.codacy.com/project/badge/Grade/6a19987e62344b1c9c1d5bc9f315c733 )](https://www.codacy.com/app/ocean-protocol/commons)
[![Codacy Badge ](https://api.codacy.com/project/badge/Coverage/6a19987e62344b1c9c1d5bc9f315c733 )](https://www.codacy.com/app/ocean-protocol/commons)
2019-01-23 11:26:13 +01:00
[![code style: prettier ](https://img.shields.io/badge/code_style-prettier-7b1173.svg?style=flat-square )](https://github.com/prettier/prettier)
[![js oceanprotocol ](https://img.shields.io/badge/js-oceanprotocol-7b1173.svg )](https://github.com/oceanprotocol/eslint-config-oceanprotocol)
[![css bigchaindb ](https://img.shields.io/badge/css-bigchaindb-39BA91.svg )](https://github.com/bigchaindb/stylelint-config-bigchaindb)
2019-04-10 13:12:29 +02:00
< img width = "1218" alt = "Commons UI" src = "https://user-images.githubusercontent.com/90316/55874266-296ef080-5b92-11e9-8ac6-2423cb2a80fb.png" >
2019-04-05 18:11:42 +02:00
2019-04-03 14:54:27 +02:00
---
2019-04-09 15:26:33 +02:00
< h3 align = "center" > 🦑🦑🦑< br / > This marketplace is deployed under < a href = "https://commons.oceanprotocol.com" > commons.oceanprotocol.com< / a > and can be used there. Feel free to < a href = "https://github.com/oceanprotocol/commons/issues" > report any issues< / a > you encounter.< br / > 🦑🦑🦑< / h3 >
2019-04-03 14:54:27 +02:00
---
2019-04-09 22:34:38 +02:00
If you're a developer and want to contribute to, or want to utilize this marketplace's code in your projects, then keep on reading.
2019-06-26 11:13:41 +02:00
- [🏄 Get Started ](#-Get-Started )
2019-06-25 13:57:18 +02:00
- [🏖 Remote Ocean: Pacific ](#-Remote-Ocean-Pacific )
2019-06-26 11:13:41 +02:00
- [🐳 Use with Barge ](#-Use-with-Barge )
- [⛵️ Environment Variables ](#️ -Environment-Variables )
2019-07-08 15:31:48 +02:00
- [Client ](#Client )
- [Server ](#Server )
2019-06-26 11:13:41 +02:00
- [👩🔬 Testing ](#-Testing )
- [Unit Tests ](#Unit-Tests )
- [End-to-End Integration Tests ](#End-to-End-Integration-Tests )
- [✨ Code Style ](#-Code-Style )
- [🛳 Production ](#-Production )
- [⬆️ Releases ](#️ -Releases )
- [📜 Changelog ](#-Changelog )
- [🎁 Contributing ](#-Contributing )
- [🏛 License ](#-License )
2019-04-03 16:11:27 +02:00
2019-04-15 23:27:19 +02:00
## 🏄 Get Started
2019-04-09 22:39:11 +02:00
This repo contains a client and a server, both written in TypeScript:
- **client**: React app setup with [squid-js ](https://github.com/oceanprotocol/squid-js ), bootstrapped with [Create React App ](https://github.com/facebook/create-react-app )
2019-07-08 15:31:48 +02:00
- **server**: Node.js app, utilizing [Express ](https://expressjs.com ). The server provides various microservices, like remote file checking. The endpoints are documented in [server Readme ](server/ ).
2019-04-09 22:39:11 +02:00
2019-03-24 02:10:00 +01:00
To spin up both, the client and the server in a watch mode for local development, execute:
2019-01-23 13:03:41 +01:00
2019-01-23 11:26:13 +01:00
```bash
2019-04-03 14:42:20 +02:00
npm install
2019-01-23 11:26:13 +01:00
npm start
```
2019-01-18 17:34:40 +01:00
2019-04-05 18:11:42 +02:00
Open [http://localhost:3000 ](http://localhost:3000 ) to view the client in the browser. The page will reload if you make edits to files in either `./client` or `./server` .
2019-01-18 17:34:40 +01:00
2019-06-25 13:57:18 +02:00
### 🏖 Remote Ocean: Pacific
2019-04-15 23:27:19 +02:00
2019-06-25 13:57:18 +02:00
To make use of all the functionality, you need to connect to an Ocean network.
2019-04-15 23:27:19 +02:00
2019-06-25 13:57:18 +02:00
By default, the client will connect to Ocean components running within [Ocean's Pacific network ](https://docs.oceanprotocol.com/concepts/pacific-network/ ) remotely.
With your MetaMask, connect to the Pacific network. To do this:
2019-04-15 23:27:19 +02:00
1. select Custom RPC in the network dropdown in MetaMask
2019-06-25 13:57:18 +02:00
2. under New Network, enter `https://pacific.oceanprotocol.com` as the custom RPC URL
3. Hit _Save_ , and you’ re now connected to Pacific
2019-03-24 02:10:00 +01:00
2019-04-05 18:11:42 +02:00
### 🐳 Use with Barge
2019-04-01 17:31:43 +02:00
If you prefer to connect to locally running components instead of remote connections to Ocean's Nile network, you can spin up [`barge` ](https://github.com/oceanprotocol/barge ) and use a local network:
```bash
git clone git@github.com:oceanprotocol/barge.git
cd barge
./start_ocean.sh --latest --no-pleuston --local-spree-node
```
2019-06-11 21:26:18 +02:00
Modify `./client/src/config.ts` or set environment variables to use those local connections.
### ⛵️ Environment Variables
2019-07-08 15:31:48 +02:00
#### Client
2019-06-11 21:26:18 +02:00
The `./client/src/config.ts` file is setup to prioritize environment variables for setting each Ocean component endpoint.
By setting environment variables, you can easily switch between Ocean networks the commons client connects to, without directly modifying `./client/src/config.ts` . This is helpful e.g. for local development so you don't accidentially commit changes to the config file.
For local development, you can use a `.env.local` file. There's an example file with the most common network configurations preconfigured:
```bash
cp client/.env.local.example client/.env.local
# uncomment the config you need
vi client/.env.local
```
2019-04-01 17:31:43 +02:00
2019-07-08 15:31:48 +02:00
#### Server
The server uses its own environment variables too:
```bash
cp server/.env.example server/.env
# edit variables
vi server/.env
```
2019-04-09 15:26:33 +02:00
## 👩🔬 Testing
2019-01-18 17:34:40 +01:00
2019-06-26 11:13:41 +02:00
Test suite is setup with [Jest ](https://jestjs.io ) and [react-testing-library ](https://github.com/kentcdodds/react-testing-library ) for unit testing, and [Cypress ](https://www.cypress.io ) for integration testing.
2019-04-15 23:27:19 +02:00
2019-06-26 12:53:50 +02:00
To run all linting, unit and integration tests in one go, run:
2019-04-15 23:27:19 +02:00
2019-01-23 11:26:13 +01:00
```bash
2019-04-09 15:26:33 +02:00
npm test
2019-01-23 11:26:13 +01:00
```
2019-01-18 17:34:40 +01:00
2019-06-26 19:54:53 +02:00
The endpoints the integration tests run against are defined by your [Environment Variables ](#️ -Environment-Variables ), and Cypress-specific variables in `cypress.json` .
2019-06-26 12:53:50 +02:00
### Unit Tests
2019-04-15 23:30:35 +02:00
For local development, you can start the test runners for client & server in a watch mode.
2019-04-15 23:27:19 +02:00
```bash
2019-04-15 23:30:35 +02:00
npm run test:watch
```
This will work for daily development but it misses the full interactivity of the test runner. If you need that, you will need to run them in individual terminal sessions:
```bash
cd client/
npm run test:watch
cd server/
npm run test:watch
2019-04-15 23:27:19 +02:00
```
2019-01-18 17:34:40 +01:00
2019-06-26 11:13:41 +02:00
### End-to-End Integration Tests
2019-06-26 12:29:41 +02:00
To run all integration tests in headless mode, run:
2019-06-26 11:13:41 +02:00
```bash
npm run test:e2e
```
This will automatically spin up all required resources to run the integrations tests, and then run them.
2019-06-26 12:29:41 +02:00
You can also use the UI of Cypress to run and inspect the integration tests locally:
```bash
npm run cypress:open
```
2019-04-09 15:26:33 +02:00
## ✨ Code Style
For linting and auto-formatting you can use from the root of the project:
2019-01-23 11:26:13 +01:00
```bash
2019-04-09 15:26:33 +02:00
# auto format all ts & css with eslint & stylelint
npm run lint
# auto format all ts & css with prettier, taking all configs into account
npm run format
2019-01-23 11:26:13 +01:00
```
2019-04-09 15:26:33 +02:00
## 🛳 Production
2019-01-18 17:34:40 +01:00
2019-04-09 15:26:33 +02:00
To create a production build of both, the client and the server, run from the root of the project:
2019-04-09 10:42:00 +02:00
2019-04-09 15:26:33 +02:00
```bash
npm run build
```
Builds the client for production to the `./client/build` folder, and the server into the `./server/dist` folder.
2019-04-09 10:42:00 +02:00
2019-04-09 14:32:33 +02:00
## ⬆️ Releases
2019-04-09 10:42:00 +02:00
2019-05-20 16:17:41 +02:00
From a clean `master` branch you can run any release task doing the following:
2019-04-09 10:42:00 +02:00
2019-05-28 11:44:35 +02:00
- bumps the project version in `package.json` , `client/package.json` , `server/package.json`
2019-05-28 01:54:27 +02:00
- auto-generates and updates the CHANGELOG.md file from commit messages
2019-04-09 14:32:33 +02:00
- creates a Git tag
- commits and pushes everything
- creates a GitHub release with commit messages as description
You can execute the script using {major|minor|patch} as first argument to bump the version accordingly:
- To bump a patch version: `npm run release`
2019-05-28 01:54:27 +02:00
- To bump a minor version: `npm run release minor`
- To bump a major version: `npm run release major`
2019-04-09 14:32:33 +02:00
2019-05-28 01:54:27 +02:00
By creating the Git tag with these tasks, Travis will trigger a new Kubernetes live deployment automatically, after a successful tag build.
2019-04-09 14:32:33 +02:00
For the GitHub releases steps a GitHub personal access token, exported as `GITHUB_TOKEN` is required. [Setup ](https://github.com/release-it/release-it#github-releases )
2019-04-09 10:42:00 +02:00
2019-05-28 01:54:27 +02:00
## 📜 Changelog
2019-05-20 16:17:41 +02:00
2019-05-28 01:54:27 +02:00
See the [CHANGELOG.md ](./CHANGELOG.md ) file. This file is auto-generated during the above mentioned release process.
2019-05-20 16:17:41 +02:00
2019-04-09 15:26:33 +02:00
## 🎁 Contributing
2019-01-18 17:34:40 +01:00
2019-04-09 15:26:33 +02:00
See the page titled "[Ways to Contribute](https://docs.oceanprotocol.com/concepts/contributing/)" in the Ocean Protocol documentation.
2019-01-18 17:34:40 +01:00
2019-04-05 18:11:42 +02:00
## 🏛 License
2019-01-18 17:34:40 +01:00
2019-01-23 11:26:13 +01:00
```text
Copyright 2018 Ocean Protocol Foundation Ltd.
2019-01-18 17:34:40 +01:00
2019-01-23 11:26:13 +01:00
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
2019-01-18 17:34:40 +01:00
2019-01-23 11:26:13 +01:00
http://www.apache.org/licenses/LICENSE-2.0
2019-01-18 17:34:40 +01:00
2019-01-23 11:26:13 +01:00
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```