Skip to content

Commit

Permalink
Merge pull request #516 from opentripplanner/dev
Browse files Browse the repository at this point in the history
Release PR - December 2021
  • Loading branch information
miles-grant-ibigroup authored Dec 16, 2021
2 parents d1ecb80 + ed57e82 commit e24af86
Show file tree
Hide file tree
Showing 176 changed files with 27,574 additions and 18,825 deletions.
16 changes: 16 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"plugins": ["babel-plugin-add-module-exports", "babel-plugin-lodash"],
"presets": [
"@babel/preset-env",
"@babel/preset-typescript",
"@babel/preset-react"
],
"env": {
"development": {
"plugins": ["react-refresh/babel"]
},
"test": {
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }]]
}
}
}
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PORT=9966
125 changes: 125 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
module.exports = {
extends: [
'standard',
'standard-jsx',
'react-app',
'plugin:@typescript-eslint/recommended',
'plugin:typescript-sort-keys/recommended',
'plugin:react/recommended',
'plugin:jest/recommended',
'plugin:jsx-a11y/strict',
'plugin:prettier/recommended',
'prettier'
],
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
'sort-keys-fix',
'import',
'jest',
'jsx-a11y',
'react',
'sort-destructure-keys',
'sort-imports-es6-autofix',
'typescript-sort-keys'
],
rules: {
'@typescript-eslint/member-delimiter-style': [
'off',
{
multiline: {
delimiter: 'none',
requireLast: false
},
singleline: {
delimiter: 'comma',
requireLast: false
}
}
],
'@typescript-eslint/no-use-before-define': ['error'],
'@typescript-eslint/no-var-requires': 0,
complexity: ['warn', 12],
'import/order': [
'warn',
{
'newlines-between': 'always'
}
],
'jsx-a11y/label-has-for': [
2,
{
allowChildren: false,
components: ['Label'],
required: {
every: ['id']
}
}
],
// from docs: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md#how-to-use
// it must be disabled to work correctly
'no-use-before-define': 'off',
'object-curly-spacing': 0,
'prefer-const': [
'warn',
{
destructuring: 'all',
ignoreReadBeforeAssign: false
}
],
'prettier/prettier': [
'error',
{
semi: false,
singleQuote: true,
trailingComma: 'none'
}
],
quotes: [2, 'single', { avoidEscape: true }],
'react/jsx-handler-names': 'off',
'react/jsx-sort-props': [
'error',
{
ignoreCase: true
}
],
'sort-destructure-keys/sort-destructure-keys': [
'error',
{
caseSensitive: false
}
],
'sort-imports-es6-autofix/sort-imports-es6': [
2,
{
ignoreCase: true,
ignoreMemberSort: false
}
],
'sort-keys': [
'error',
'asc',
{
caseSensitive: false
}
],
'sort-keys-fix/sort-keys-fix': [
'warn',
'asc',
{
caseSensitive: false
}
],
'sort-vars': [
'error',
{
ignoreCase: true
}
]
},
settings: {
react: {
version: '999.999.999'
}
}
}
14 changes: 8 additions & 6 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
with:
# This allows us to work with the repository during the lint step
fetch-depth: 2
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 16.x
- name: Install npm packages using cache
uses: bahmutov/npm-install@v1
- name: Copy example config
run: cp example-config.yml config.yml
- name: Lint code
run: yarn lint
- name: Lint docs
run: yarn lint-docs
# Actual lint step temporarily removed to allow for package release
- name: Lint all code (ignoring errors)
run: yarn lint-all || true
- name: Run tests
run: yarn jest
- name: Build example project
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
yarn lint-staged
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,29 @@ An example of an OTP-RR application is included in the repository. The example p

To run, first clone the repo and install [yarn](https://yarnpkg.com/) if needed.

Copy `example-config.yml` to `config.yml`. Update `config.yml` with the needed API keys, and optionally, the OTP endpoint and initial map origin. (The default values are for a test server for Portland, OR.).
Update `example-config.yml` with the needed API keys, and optionally, the OTP endpoint and initial map origin. (The default values are for a test server for Portland, OR.).

Install the dependencies and start a local instance using the following script:

```bash
yarn start
```

Should you want to maintain multiple configuration files, OTP-RR can be made to use a custom config file by using environment variables. Other environment variables also exist. `CUSTOM_CSS` can be used to point to a css file to inject, and `JS_CONFIG` can be used to point to a `config.js` file to override the one shipped with OTP-RR.

```bash
yarn start --env.YAML_CONFIG=/absolute/path/to/config.yml
```

## Deploying the UI

1. Build the js/css bundle by running `yarn build`. The build will appear in the `dist/` directory).
2. Modify the `index.html` to point to `dist/index.js` (instead of `example.js`).
3. Upload the following files to wherever you're deploying the UI:
- `index.html` (modified to point to `dist/index.js`)
- `example.css`
- `dist/`
- `index.js`
- `index.js.map`
- `index.css`
- `index.css.map`

Note: only contents produced during build in the `dist/` directory are likely to change over time (the `index.html` and `example.css` files contain minimal code), so subsequent deployments will typically only need to replace the `dist/` contents.
Build the js/css bundle by running `yarn build`. The build will appear in the `dist/` directory).

The same environment variables which affect the behavior of `yarn start` also affect `yarn build`. Running the following command builds OTP-RR with customized js and css:

```bash
yarn build --env.JS_CONFIG=my-custom-js.js env.CUSTOM_CSS=my-custom-css.css
```

## Library Documentation

Expand Down
4 changes: 2 additions & 2 deletions __tests__/actions/__snapshots__/api.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Array [
Array [
Object {
"payload": Object {
"error": [TypeError: Cannot read property 'trackRecent' of undefined],
"error": [TypeError: Cannot read properties of undefined (reading 'trackRecent')],
"requestId": "abcd1239",
"searchId": "abcd1234",
"url": "http://mock-host.com:80/api/plan?fromPlace=Origin%20%2812%2C34%29%3A%3A12%2C34&toPlace=Destination%20%2834%2C12%29%3A%3A34%2C12&mode=WALK%2CTRANSIT&ignoreRealtimeUpdates=false&batchId=abcd1234",
Expand Down Expand Up @@ -110,7 +110,7 @@ Array [
Array [
Object {
"payload": Object {
"error": [TypeError: Cannot read property 'trackRecent' of undefined],
"error": [TypeError: Cannot read properties of undefined (reading 'trackRecent')],
"requestId": "abcd1236",
"searchId": "abcd1234",
"url": "http://mock-host.com:80/api/plan?fromPlace=Origin%20%2812%2C34%29%3A%3A12%2C34&toPlace=Destination%20%2834%2C12%29%3A%3A34%2C12&mode=WALK%2CTRANSIT&ignoreRealtimeUpdates=false&batchId=abcd1234",
Expand Down
Loading

0 comments on commit e24af86

Please sign in to comment.