Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable SSR #2017

Merged
merged 63 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
8ac4831
Setup TSC for including openneuro-app in openneuro-server
nellh Mar 2, 2021
5b322b4
Update apollo-client dependencies for newer type defintions.
nellh Mar 5, 2021
732134a
Client: Refactor to allow for TypeScript builds.
nellh Mar 5, 2021
0d7c9df
CLI: Refactor to allow for TypeScript builds.
nellh Mar 5, 2021
9c41baa
Server: Refactor for TypeScript improvements
nellh Mar 5, 2021
5a894be
App: Refactor to allow for TypeScript builds.
nellh Mar 5, 2021
89e2160
Additional TypeScript build fixes.
nellh Mar 6, 2021
b096041
Fix regression with OpenNeuro custom GraphQL extension.
nellh Mar 7, 2021
2d0bd9c
Ignore TypeScript issues with metadata form.
nellh Mar 7, 2021
bb239a4
Fix linting for TypeScript changes.
nellh Mar 8, 2021
61f26e1
Update tests to support TypeScript client builds.
nellh Mar 8, 2021
e06298e
Drop unused debounce utility function from openneuro-client
nellh Mar 8, 2021
900403c
Fix Snapshot typescript model call typing.
nellh Mar 8, 2021
631656e
Fix missing import for recently removed utils module.
nellh Mar 8, 2021
a0a3a5c
Revert change to Mongoose TypeScript imports
nellh Mar 8, 2021
4e42c47
Merge branch 'master' into ssr-refactor
nellh Mar 8, 2021
13790de
Drop openneuro-content repo and webpack.
nellh Mar 9, 2021
c4e1a09
Upgrade react-markdown to fix markdown component crash.
nellh Mar 17, 2021
159ef37
Fix createClient prettier formatting
nellh Mar 17, 2021
d43425d
Don't enforce propTypes for tsx components (redundant).
nellh Mar 17, 2021
09e2b0c
Update Jest for improved @testing-library/react support.
nellh Mar 17, 2021
bfde743
Fix broken navbar dropdown by replacing with custom component.
nellh Mar 17, 2021
6a4f348
Fix validate web worker build for esbuild.
nellh Mar 17, 2021
bb50e87
Fix esbuild sourcemap compatibility.
nellh Mar 18, 2021
7439252
Work around new build issues with bids-validator.
nellh Mar 19, 2021
f25d9c0
Add the mostly working esbuild setup.
nellh Mar 22, 2021
c6c217e
Update bids-validator package locking.
nellh Mar 25, 2021
d784ae8
Fix extraneous noEmit on openneuro-app
nellh Mar 25, 2021
dbac18e
Switch to Vite for dev server.
nellh Mar 25, 2021
ad2e19a
Cleanup various issues with Vite support.
nellh Mar 25, 2021
f6c6281
Fix default import structure for Vite
nellh Mar 25, 2021
23d4722
Enable working SSR 🎉
nellh Mar 25, 2021
1d63afc
Replace custom useMedia hook with @artsy/fresnel
nellh Mar 26, 2021
708cc48
Remove runtime configuration requirement.
nellh Mar 26, 2021
c85917d
Enable cookies in SSR mode.
nellh Mar 26, 2021
b91f64d
Disable code-splitting because of SSR conflicts.
nellh Mar 27, 2021
e4b485e
Fix hydration bugs with Apollo and Helmet.
nellh Mar 27, 2021
a995865
Fix missing react-virtualized DOM in SSR mode.
nellh Mar 27, 2021
d326ee9
Fix Metric PropTypes.
nellh Mar 27, 2021
a9a8165
Provide HMR port for middleware mode Vite.
nellh Mar 27, 2021
6bf82f9
Add comment for why createClient is called on every SSR request.
nellh Mar 27, 2021
44a828f
Refactor all cookie references to access via CookieProvider
nellh Mar 27, 2021
ef7e7e6
Forward Vite HMR port in docker-compose
nellh Mar 27, 2021
5a9e334
Fix download page rendering in SSR.
nellh Mar 27, 2021
e717f65
Consolidate config module to one file (fixing linting and tests)
nellh Mar 27, 2021
8dc7e85
Upgrade linters and fix up various TypeScript linting bugs.
nellh Mar 27, 2021
826517d
Additional TypeScript cleanup and build fixes.
nellh Mar 27, 2021
f06713a
Fix linting warning for incorrect useEffect deps in useMeasure
nellh Mar 27, 2021
7b94151
Use jsdoc import for SnapshotDocument in js file.
nellh Mar 27, 2021
f54a88b
Fix outdate OpenNeuroConfig mock.
nellh Mar 27, 2021
8e6063d
Fix checkDestination() passing despite directory argument.
nellh Mar 27, 2021
ea2cd5a
Fix remaining test issues from SSR/TypeScript refactors.
nellh Mar 27, 2021
5e9e97a
Fix startup for openneuro-indexer with typescript references.
nellh Mar 27, 2021
7929d3a
Revert debug package for bids-validator in openneuro-app
nellh Mar 27, 2021
18d685d
Fix missing TypeScript build for tests.
nellh Mar 31, 2021
125e6bf
Serve self-destroying service worker via SSR.
nellh Apr 2, 2021
280f862
Update to bids-validator@1.6.3
nellh Apr 5, 2021
ae55da7
Fix dashboard missing sort buttons issue.
nellh Apr 5, 2021
93ad63a
Disable bids-validator workers temporarily.
nellh Apr 7, 2021
088b801
Merge branch 'master' into ssr-enable
nellh Apr 7, 2021
d9c28f5
Fix missing metadata.
nellh Apr 7, 2021
ab7dafb
Merge remote-tracking branch 'origin/master' into ssr-enable
nellh Apr 7, 2021
c57b488
Fix out of date snapshot.
nellh Apr 7, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
**/dist
**/.eslintcache
**/__pycache__
.build-cache
.github
.vscode
coverage
Expand All @@ -16,4 +17,5 @@ services/datalad/node_modules
.env.example
config.env.example
LICENSE
README.md
README.md
yarn-error.log
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
/packages/*/node_modules
/packages/*/coverage
/packages/*/dist
__mocks__
*.spec.js
*.spec.jsx
*.spec.ts
*.spec.tsx
jestsetup.js
papaya.js
42 changes: 34 additions & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,42 @@
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:react/recommended",
"prettier",
"prettier/@typescript-eslint",
"prettier/react"
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"allowImportExportEverywhere": false,
"codeFrame": false,
"project": "./tsconfig.json"
"project": [
"./packages/openneuro-app/tsconfig.json",
"./packages/openneuro-cli/tsconfig.json",
"./packages/openneuro-client/tsconfig.json",
"./packages/openneuro-indexer/tsconfig.json",
"./packages/openneuro-server/tsconfig.json"
]
},
"rules": {
"linebreak-style": ["error", "unix"],
"quotes": ["error", "single", { "avoidEscape": true }],
"semi": ["error", "never"],
"no-prototype-builtins": 0,
"@typescript-eslint/explicit-function-return-type": "off",
"prettier/prettier": "error"
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"prettier/prettier": "error",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
},
"plugins": ["import", "prettier", "react"],
"plugins": [
"import",
"prettier",
"react",
"react-hooks",
"@typescript-eslint"
],
"settings": {
"import/core-modules": ["openneuro-content"],
"react": {
"version": "detect"
}
Expand All @@ -44,7 +58,19 @@
// enable the rule specifically for TypeScript files
"files": ["*.ts", "*.tsx"],
"rules": {
"@typescript-eslint/explicit-function-return-type": ["error"]
"@typescript-eslint/explicit-function-return-type": ["error"],
"react/prop-types": "off"
}
},
{
"files": ["*.js", "*.jsx"],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/ban-ts-comment": "off"
}
}
]
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ coverage
datalad-key
content
packages/openneuro-server/yarn.lock
.docz
.docz
dist
.build-cache
.ultra.cache.json
14 changes: 3 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
FROM node:12.18.1 as dependencies
FROM node:14.16.0 as dependencies

WORKDIR /srv

COPY package.json yarn.lock ./
# Sadly we have to manually copy each of these to get a full node_modules tree
COPY packages/openneuro-app/package.json packages/openneuro-app/package.json
COPY packages/openneuro-cli/package.json packages/openneuro-cli/package.json
COPY packages/openneuro-client/package.json packages/openneuro-client/package.json
COPY packages/openneuro-indexer/package.json packages/openneuro-indexer/package.json
COPY packages/openneuro-server/package.json packages/openneuro-server/package.json

RUN yarn install --frozen-lockfile

COPY . /srv

RUN yarn install --frozen-lockfile && yarn tsc -b

FROM dependencies as tests

RUN yarn test
2 changes: 1 addition & 1 deletion config.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ ELASTIC_APM_ACTIVE=false

# GraphQL path
# For docker-compose, use a network relative URI
GRAPHQL_URI=http://web/crn/graphql
GRAPHQL_URI=http://server:8111/crn/graphql
# For other deployments, use the public FQDN URI
# GRAPHQL_URI=https://openneuro.org/crn/graphql
11 changes: 6 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ version: "2.3"

# shared volumes
volumes:
project:
yarn_cache:
webpack_cache:

Expand All @@ -18,27 +17,28 @@ services:
working_dir: /srv
volumes:
- yarn_cache:/usr/local/share/.cache
- project:/srv/packages/openneuro-app/dist

# web app bundle build
app:
extends:
service: node
working_dir: /srv/packages/openneuro-app
command: yarn start
command: ./vite-env.sh
volumes:
- webpack_cache:/webpack-cache
- ./packages/openneuro-app/src:/srv/packages/openneuro-app/src
ports:
- "8145:8145"
- "9992:9992"

# crn node server
server:
extends:
service: node
working_dir: /srv/packages/openneuro-server
command: yarn ts-node-dev --respawn --transpile-only src/server.js
command: yarn start
volumes:
- ./packages/openneuro-app/src:/srv/packages/openneuro-app/src
- ./packages/openneuro-server/src:/srv/packages/openneuro-server/src
depends_on:
- redis
Expand All @@ -50,7 +50,8 @@ services:
indexer:
extends:
service: node
command: yarn ts-node /srv/packages/openneuro-indexer/src/index.ts
working_dir: /srv/packages/openneuro-indexer
command: yarn start
depends_on:
- server
- elasticsearch
Expand Down
30 changes: 17 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,35 @@
"private": true,
"scripts": {
"start": "docker-compose up --build -V",
"build": "yarn tsc -b",
"bootstrap": "lerna bootstrap",
"test": "jest",
"coverage": "jest --coverage",
"codecov": "codecov",
"lint": "eslint --cache --ext .jsx --ext .js --ext .ts --ext .tsx packages/",
"lint": "eslint --ext .jsx --ext .js --ext .ts --ext .tsx packages/*/src",
"openneuro": "node packages/openneuro-cli/src"
},
"devDependencies": {
"@sentry/cli": "1.37.4",
"@typescript-eslint/eslint-plugin": "^2.20.0",
"@typescript-eslint/parser": "^2.20.0",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0.4.1",
"babel-eslint": "10.0.3",
"codecov": "^3.0.0",
"core-js": "^3.3.2",
"eslint": "6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.7.0",
"eslint": "7.23.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.23.1",
"eslint-plugin-react-hooks": "^4.2.0",
"husky": "^0.15.0-rc.13",
"jest": "^24.9.0",
"jest": "^26.6.3",
"lerna": "3.20.2",
"lint-staged": "^6.0.1",
"prettier": "^1.7.0",
"typescript": "^4.0.3"
"prettier": "^2.2.1",
"tsc-watch": "^4.2.9",
"typescript": "4.0.6"
},
"workspaces": [
"packages/*"
Expand Down Expand Up @@ -60,7 +64,7 @@
"dependencies": {
"docz": "^2.3.1",
"gatsby-plugin-s3": "^0.3.3",
"react": "^16.13.1",
"react-dom": "^16.13.1"
"react": "^17.0.1",
"react-dom": "^17.0.1"
}
}
17 changes: 0 additions & 17 deletions packages/openneuro-app/__mocks__/contentMock.js

This file was deleted.

6 changes: 0 additions & 6 deletions packages/openneuro-app/config.js

This file was deleted.

4 changes: 2 additions & 2 deletions packages/openneuro-app/jestsetup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Make Enzyme functions available in all test files without importing
import React from 'react'
import Enzyme, { shallow, render, mount } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import Adapter from '@wojtekmaj/enzyme-adapter-react-17'
import moment from 'moment-timezone'
import fetch from 'jest-fetch-mock'
import fromEntries from 'object.fromentries'
Expand All @@ -18,7 +18,7 @@ if (!Object.fromEntries) {
fromEntries.shim()
}

jest.mock('./config.js')
jest.mock('./src/scripts/config')

Object.defineProperty(window, 'matchMedia', {
writable: true,
Expand Down
Loading