Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davesag committed Jun 2, 2020
1 parent d30e87e commit 381fc07
Show file tree
Hide file tree
Showing 552 changed files with 47,394 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: 2

jobs:
build:
docker:
# DOES NOT WORK UNDER 12.17.0 OR LATER.
- image: circleci/node:12.16.3
environment:
- NODE_ENV: test

steps:
- checkout

- restore_cache:
keys:
- dependencies-{{ checksum "package.json" }}

- run:
name: Install global packages
command: sudo npm i -g codecov greenkeeper-lockfile@1

- run:
name: Greenkeeper Lockfile
command: greenkeeper-lockfile-update

- run:
name: Install dependencies
command: npm ci

- save_cache:
key: dependencies-{{ checksum "package.json" }}
paths:
- node_modules

- run:
name: Javascript Linter
command: npm run lint

- run:
name: Unit Tests with Code Coverage
command: npm test -- --coverage --maxWorkers=2

- run:
name: Do a production build with connection to local back end.
command: npm run build -- --env.config=std --env.build=release --env.api=local

- run:
name: Push any lockfile changes
command: greenkeeper-lockfile-upload

- run:
name: Send reports to codecov.io
command: codecov
37 changes: 37 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = {
parser: "babel-eslint",
"ignorePatterns": ["node_modules/", 'build/', '_*.js'],
extends: [
'standard',
'prettier',
'prettier/standard',
'plugin:react/recommended',
'plugin:jest/recommended',
'plugin:jest/style'
],
plugins: ['prettier', 'standard', 'react', 'react-hooks', 'import', 'promise', 'jest'],
parserOptions: {
sourceType: 'module',
ecmaFeatures: {
jsx: true
}
},
env: {
es2020: true,
browser: true,
webextensions: true,
"jest/globals": true
},
rules: {
'prettier/prettier': ['error', { singleQuote: true, semi: true }],
'no-unused-vars': [
'error',
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' }
]
},
settings: {
react: {
version: 'detect'
}
}
}
1 change: 1 addition & 0 deletions .nodeversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12.16.3
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build
coverage
node_modules
.*
3 changes: 3 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "stylelint-config-standard"
}
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Change Log

## Version 0.6.0 — Initial release (2020-06-02)
81 changes: 81 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

## Our Standards

Examples of behaviour that contributes to a positive environment for our community include:

- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologising to those affected by our mistakes, and learning from the experience
- Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behaviour include:

- The use of sexualised language or imagery, and sexual attention or advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of acceptable behaviour and will take appropriate and fair corrective action in response to any behaviour that they deem inappropriate, threatening, offensive, or harmful.

Community leaders 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, and will communicate reasons for moderation decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behaviour may be reported to the community leaders responsible for enforcement at `[email protected]`.

All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behaviour deemed unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behaviour was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of actions.

**Consequence**: A warning with consequences for continued behaviour. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including sustained inappropriate behaviour.

**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behaviour, harassment of an individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][https://www.contributor-covenant.org/version/2/0/code_of_conduct.html], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
98 changes: 98 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# How to contribute to this project

## Development Environment

All development is assumed to be done on a Mac running a modern version of OS X but ought to be pretty much the same no matter what unixy environment you use.

## Development Process

All development is to follow the [standard git-flow](http://nvie.com/posts/a-successful-git-branching-model/) process, modified to allow for code-reviews.

See this handy, if ugly, [cheat sheet](http://danielkummer.github.io/git-flow-cheatsheet/).

### Setup

1. Fork this repo into your personal GitHub account
2. clone your fork to your local development machine
3. Set this repo as the `upstream` repo `git remote add upstream <insert the upstream url>`
4. Disallow direct pushing to upstream `git remote set-url --push upstream no_push`
5. create a local `master` branch `git checkout -b master` and test it via `git pull upstream master`
6. ensure you have installed the [`git-flow` command line helpers](https://github.com/nvie/gitflow) and [`git-flow-completion` utils](https://github.com/bobthecow/git-flow-completion) then run `git flow init -d`.

#### Optional Git Setup

Set up `git` to always `rebase` rather than merge.

```sh
git config --global branch.autosetuprebase always
```

Make sure `git` knows you are using your correct email.

```sh
git config user.email "[email protected]"
```

### Working on new features

1. Create a "feature branch" for the change you wish to make via `git flow feature start {feature_name}`. See below for how to name features.
2. Now work on your changes locally until you are happy the issue is resolved. See below for how to name commit messages.
3. `git flow feature publish {feature_name}` will push it back up to your fork on GitHub.
4. Use `git flow feature pull {remote_name} {feature_name}` to bring in any other changes, If other people have also merged changes in, and you can't merge your PR automatically you'll need to `rebase` their changes into your changes and then `--force` push the resulting changes using standard `git` commands.
5. Use GitHub to raise a Pull Request. Add labels as appropriate, and set one or more reviewers. Then paste the url of the PR into the `#development` Slack channel with a request for someone to please review the changes. See below for how to name pull requests.
6. Respond to any comments as appropriate, making changes and `git push` ing further changes as appropriate.
7. When all comments are dealt and the PR finally gets a :+1: from someone else then merge the PR. _Note we will not be using the `git flow feature finish`_ option as that merges into develop automatically without the option for review. [see this stackexchange for more on that](http://programmers.stackexchange.com/questions/187723/code-review-with-git-flow-and-github).
8. In your command-line `git checkout develop` then `git pull upstream develop` to get the latest code and `git branch -d feature/{branchname}` to delete the old feature branch.

#### Hotfixes and Support branches

It's basically the same process but use the word `hotfix` or `support` instead of `feature`. `git flow` knows what to do. Just keep in mind that any changes are going to happen to your fork, and not the upstream repo. If you need to merge a `hotfix` into upstream master you may only do it va a reviewed pull request.

### Releasing to production

1. `git flow release start {tag.number}` (using semantic versioning)
2. commit any changes to version info in `package.json` then `git flow release publish {tag.number}`
3. `git flow release finish {tag.number}` merges the release into `master` of your fork, tags it, merges that back into `develop` on your fork and removes the release branch.
4. Now go back to GitHub and raise a Pull Request to merge the upstream master from your fork's `master` branch. When that goes through you are done.
5. In your command-line go back and clean up any outstanding branches and `git pull upstream` your local `master` and `develop` branches to ensure everything on your local machine is up to date with everyone's changes.

Note you will **never** push changes directly to the upstream project, _only to your own fork_.

**Changes may only be introduced into the upstream project via a properly reviewed pull request.**

## Naming things

There are various systems, including GitHub itself, which will pick up the issue numbers from commit messages and pull requests and automatically associate them with the issues. It is therefore desirable to use a formal naming scheme for features, commit messages and pull requests.

### Features

Features must be named per the following pattern `#{issue number}/{some_descriptive-text}` — so for example, if you are working on issue `ABC-1` with the title "do the thing", call your feature `ABC-1/do_the-thing`. Obviously use your common sense to avoid making the feature names too long.

Note this will creating a feature via `git flow` will create a branch called `feature/{issue number}/{some_descriptive-text}`.

### Commit Messages

When commiting something use the `-m` flag to add a short commit message of the format `{issue number} summary of what you changed`. So for example if you are working on issue `ABC-1` and you added a method to the `aardvark_controller` you might use the following commit message `"ABC-1 added anteater method to aardvark controller"`

Commit messages ought to be in the past tense.

In general try to group file changes wherever appropriate, so if your controller change also involved updating something in a helper file, the one commit message can happily encompas the changes to both files. The message ought to reflect the main aim of the change.

### Pull Requests

Pull requests must be named as follows `[issue type, issue number] high level description of change`. The following Issue Types are recognised

- `Bug Fix` - the change fixes a bug
- `Feature` - the change adds a new feature (the usual issue type)
- `Documentation` — The change is a documentation only change
- `Optimisation` - The change is an optimisation of the code base without any functional changes

If your change does not fit any of these categories, use `Feature`. Likewise if your change is not tied to an issue number you may use `n/a` instead.

So to use the above example your Pull Request would be named `[Feature, ABC-1] added anteater to aardvark`

### You built it, you merge it

A developer must be responsible for their own work, from accepting a task through to merging to production. With that in mind if you review another developer's PR, please don't then merge it yourself. As a general rule you must let the developer merge her own PRs.

Likewise, don't expect someone else to merge your PR. Unless you do not have write permission on a project, you will always aim to take personal responsibility for the quality of the code that gets merged in.
3 changes: 3 additions & 0 deletions __mocks__/@reduxjs/toolkit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const configureStore = jest.fn();
export const combineReducers = jest.fn();
export const getDefaultMiddleware = jest.fn(() => []);
5 changes: 5 additions & 0 deletions __mocks__/debounce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const debounce = jest.fn(fn => {
fn()
.then(() => {})
.catch(console.log);
});
7 changes: 7 additions & 0 deletions __mocks__/dompurify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const DOMPurify = {
sanitize: jest.fn(html => html),
addHook: jest.fn(),
removeHook: jest.fn()
};

export default DOMPurify;
3 changes: 3 additions & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const stub = 'test-file-stub';

export default stub;
3 changes: 3 additions & 0 deletions __mocks__/react-redux.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const Provider = ({ children }) => children;
export const useSelector = jest.fn();
export const useDispatch = jest.fn();
7 changes: 7 additions & 0 deletions __mocks__/redux-saga.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const sagaMiddleware = {
run: jest.fn()
};

const createSagaMiddleware = jest.fn(() => sagaMiddleware);

export default createSagaMiddleware;
3 changes: 3 additions & 0 deletions __mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const empty = {};

export default empty;
6 changes: 6 additions & 0 deletions __mocks__/youtube-embed-video.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-disable react/prop-types */
import React from 'react';

const Player = ({ children, ...props }) => <div {...props}>{children}</div>;

export default Player;
26 changes: 26 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = function(api) {
api.cache(true);

const presets = [
[
'@babel/preset-env',
{
targets: '> 0.25%, not dead',
useBuiltIns: 'entry',
corejs: 3
}
],
'@babel/preset-react'
];
const plugins = [
'@babel/plugin-transform-arrow-functions',
'@babel/plugin-proposal-export-default-from',
['@babel/plugin-proposal-object-rest-spread', { useBuiltIns: true }]
];

return {
presets,
plugins,
sourceType: 'unambiguous'
};
};
Loading

0 comments on commit 381fc07

Please sign in to comment.