market/README.md

154 lines
5.0 KiB
Markdown
Raw Normal View History

2020-05-07 08:03:30 +02:00
[![banner](https://raw.githubusercontent.com/oceanprotocol/art/master/github/repo-banner%402x.png)](https://oceanprotocol.com)
2020-05-19 11:31:20 +02:00
<h1 align="center">Ocean Marketplace</h1>
2020-05-07 08:03:30 +02:00
2020-07-29 18:27:04 +02:00
[![Build Status](https://travis-ci.com/oceanprotocol/market.svg?token=3psqw6c8KMDqfdGQ2x6d&branch=main)](https://travis-ci.com/oceanprotocol/market)
2020-11-12 16:41:40 +01:00
[![Netlify Status](https://api.netlify.com/api/v1/badges/c85f4d8b-95e1-4010-95a4-2bacd8b90981/deploy-status)](https://app.netlify.com/sites/market-oceanprotocol/deploys)
2020-05-07 08:03:30 +02:00
[![Maintainability](https://api.codeclimate.com/v1/badges/d114f94f75e6efd2ee71/maintainability)](https://codeclimate.com/repos/5e3933869a31771fd800011c/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/d114f94f75e6efd2ee71/test_coverage)](https://codeclimate.com/repos/5e3933869a31771fd800011c/test_coverage)
[![js oceanprotocol](https://img.shields.io/badge/js-oceanprotocol-7b1173.svg)](https://github.com/oceanprotocol/eslint-config-oceanprotocol)
**Table of Contents**
- [🏄 Get Started](#-get-started)
2020-07-20 22:36:53 +02:00
- [Local components with Barge](#local-components-with-barge)
2020-05-07 08:03:30 +02:00
- [🦑 Environment variables](#-environment-variables)
- [🎨 Storybook](#-storybook)
- [✨ Code Style](#-code-style)
- [👩‍🔬 Testing](#-testing)
- [🛳 Production](#-production)
- [⬆️ Deployment](#-deployment)
2020-10-27 09:13:11 +01:00
- [🏛 License](#-license)
2020-05-07 08:03:30 +02:00
## 🏄 Get Started
2020-07-20 22:36:53 +02:00
The app is a React app built with [Gatsby.js](https://www.gatsbyjs.org) + TypeScript + CSS modules and will connect to Ocean components in Rinkeby by default.
2020-05-07 08:03:30 +02:00
To start local development:
```bash
git clone git@github.com:oceanprotocol/market.git
cd market
2020-05-07 08:03:30 +02:00
npm install
npm start
```
This will start the development server under
`http://localhost:8000`.
2020-05-07 08:03:30 +02:00
To explore the generated GraphQL data structure fire up the accompanying GraphiQL IDE under
`http://localhost:8000/__graphql`.
2020-05-07 08:03:30 +02:00
2020-07-20 22:36:53 +02:00
### Local components with Barge
2020-05-07 08:03:30 +02:00
2020-07-20 22:36:53 +02:00
If you prefer to connect to locally running components instead of remote connections, you can spin up [`barge`](https://github.com/oceanprotocol/barge) and use a local Ganache network in another terminal before running `npm start`:
2020-05-07 08:03:30 +02:00
```bash
git clone git@github.com:oceanprotocol/barge.git
cd barge
2020-07-20 22:36:53 +02:00
# startup with local Ganache node
./start_ocean.sh
2020-05-07 08:03:30 +02:00
```
2020-07-20 22:36:53 +02:00
Finally, set environment variables to use this local connection in `.env` in the app:
2020-05-07 08:03:30 +02:00
```bash
2020-07-20 22:36:53 +02:00
# modify env variables, Rinkeby is enabled by default when using those files
cp .env.example .env
2020-05-07 08:03:30 +02:00
```
## 🦑 Environment variables
2020-07-08 15:15:02 +02:00
The `app.config.js` 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 app connects to, without directly modifying `app.config.js`.
2020-05-07 08:03:30 +02:00
For local development, you can use a `.env` file:
2020-05-07 08:03:30 +02:00
```bash
2020-07-20 22:36:53 +02:00
# modify env variables, Rinkeby is enabled by default when using those files
cp .env.example .env
2020-05-07 08:03:30 +02:00
```
## 🎨 Storybook
[Storybook](https://storybook.js.org) is set up for this project and is used for UI development of components. Stories are created inside `src/components/` alongside each component in the form of `ComponentName.stories.tsx`.
To run the Storybook server, execute in your Terminal:
```bash
npm run storybook
```
This will launch the Storybook UI with all stories loaded under [localhost:4000](http://localhost:4000).
## ✨ Code Style
For linting and auto-formatting you can use from the root of the project:
```bash
# lint all js with eslint
npm run lint
# auto format all js & css with prettier, taking all configs into account
npm run format
```
## 👩‍🔬 Testing
Test suite for unit tests is setup with [Jest](https://jestjs.io) as a test runner and:
- [react-testing-library](https://github.com/kentcdodds/react-testing-library) for all React components
To run all linting and unit tests:
```bash
npm test
```
For local development, you can start the test runner in a watch mode.
```bash
npm run test:watch
```
For analyzing the generated JavaScript bundle sizes you can use:
```bash
npm run analyze
```
## 🛳 Production
To create a production build, run from the root of the project:
```bash
npm run build
# serve production build
npm run serve
```
## ⬆️ Deployment
2020-11-12 16:41:40 +01:00
Every branch or Pull Request is automatically deployed by [Netlify](https://netlify.com) with their GitHub integration. A link to a deployment will appear under each Pull Request.
2020-05-07 08:03:30 +02:00
2020-11-12 16:41:40 +01:00
The latest deployment of the `main` branch is automatically aliased to `market.oceanprotocol.com`.
2020-05-07 08:03:30 +02:00
## 🏛 License
```text
2021-01-05 10:26:35 +01:00
Copyright 2021 Ocean Protocol Foundation Ltd.
2020-05-07 08:03:30 +02: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
http://www.apache.org/licenses/LICENSE-2.0
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.
```