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

Upgrades Next.js from 8.x.x to 9.x.x #512

Merged
merged 1 commit into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules-js/config-babel/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = api => ({
require('@babel/preset-env'),
{
useBuiltIns: 'usage',
corejs: 2,
modules: api.env('esm') ? false : undefined,
},
],
Expand Down
1 change: 1 addition & 0 deletions modules-js/config-babel/next.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = () => ({
{
'preset-env': {
useBuiltIns: 'usage',
corejs: 2,
},
},
],
Expand Down
16 changes: 8 additions & 8 deletions modules-js/config-babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"license": "CC0-1.0",
"private": true,
"dependencies": {
"@babel/core": "7.1.2",
"@babel/plugin-proposal-class-properties": "7.1.0",
"@babel/plugin-proposal-decorators": "7.0.0",
"@babel/plugin-transform-runtime": "7.0.0",
"@babel/preset-env": "7.1.0",
"@babel/preset-react": "7.0.0",
"@babel/preset-typescript": "^7.3.2",
"@babel/core": "^7.6.0",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-decorators": "^7.6.0",
"@babel/plugin-transform-runtime": "^7.6.0",
"@babel/preset-env": "^7.6.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.6.0",
"babel-plugin-require-context-hook": "^1.0.0",
"next": "8.0.3"
"next": "^9.0.6"
},
"devDependencies": {
"core-js": "^2.6.4"
Expand Down
8 changes: 4 additions & 4 deletions modules-js/form-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"core-js": "^2.6.4"
},
"peerDependencies": {
"@babel/runtime": "7.1.2",
"@babel/runtime": "^7.6.0",
"react": "16.8.5"
},
"devDependencies": {
"@babel/cli": "7.1.5",
"@babel/core": "7.1.2",
"@babel/runtime": "7.1.2",
"@babel/cli": "^7.6.0",
"@babel/core": "^7.6.0",
"@babel/runtime": "^7.6.0",
"@cityofboston/config-babel": "^0.0.0",
"@cityofboston/config-typescript": "^0.0.0",
"@types/jest": "24.x.x",
Expand Down
6 changes: 3 additions & 3 deletions modules-js/graphql-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"core-js": "^2.6.4"
},
"devDependencies": {
"@babel/cli": "7.1.5",
"@babel/core": "7.1.2",
"@babel/cli": "^7.6.0",
"@babel/core": "^7.6.0",
"@cityofboston/config-babel": "^0.0.0",
"@cityofboston/config-typescript": "^0.0.0",
"@types/jest": "24.x.x",
Expand All @@ -37,4 +37,4 @@
"peerDependencies": {
"core-js": "^2.6.4"
}
}
}
2 changes: 1 addition & 1 deletion modules-js/hapi-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"inert": "5.x.x"
},
"devDependencies": {
"@babel/core": "7.1.2",
"@babel/core": "^7.6.0",
"@cityofboston/config-babel": "^0.0.0",
"@cityofboston/config-typescript": "^0.0.0",
"@types/hoek": "^4.1.3",
Expand Down
4 changes: 2 additions & 2 deletions modules-js/hapi-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
"dependencies": {
"compression": "^1.6.2",
"core-js": "^2.6.4",
"next": "8.0.3",
"next": "^9.0.6",
"react": "16.8.5",
"react-dom": "16.8.5"
},
"devDependencies": {
"@babel/core": "7.1.2",
"@babel/core": "^7.6.0",
"@cityofboston/config-babel": "^0.0.0",
"@cityofboston/config-typescript": "^0.0.0",
"@types/hapi": "^17.0.19",
Expand Down
5 changes: 2 additions & 3 deletions modules-js/hapi-next/src/hapi-next.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import querystring from 'querystring';
import next from 'next';
import compression from 'compression';

import {
Expand Down Expand Up @@ -34,7 +33,7 @@ import { promisify } from 'util';
* );
*/
export function makeRoutesForNextApp(
app: next.Server,
app: any, // Next server object
pathPrefix: string = '/',
pageRouteOptions: RouteOptions | ((server: HapiServer) => RouteOptions) = {},
staticRouteOptions:
Expand Down Expand Up @@ -121,7 +120,7 @@ export function makeRoutesForNextApp(
* path. E.g.: /certificates/12345 should be handled by the "certificates" page.
*/
export function makeNextHandler(
app: next.Server,
app: any, // Next server object
page: string | null = null
): Lifecycle.Method {
return async (request: HapiRequest, h: ResponseToolkit) => {
Expand Down
2 changes: 1 addition & 1 deletion modules-js/mssql-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"mssql": "^4.2.1"
},
"devDependencies": {
"@babel/core": "7.1.2",
"@babel/core": "^7.6.0",
"@cityofboston/config-babel": "^0.0.0",
"@cityofboston/config-typescript": "^0.0.0",
"@types/jest": "24.x.x",
Expand Down
12 changes: 6 additions & 6 deletions modules-js/next-client-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"isomorphic-fetch": "^2.2.1"
},
"peerDependencies": {
"@babel/runtime": "7.1.2",
"next": "8.0.3",
"@babel/runtime": "^7.6.0",
"next": "^9.0.6",
"nprogress": "^0.2.0"
},
"devDependencies": {
"@babel/cli": "7.1.5",
"@babel/core": "7.1.2",
"@babel/runtime": "7.1.2",
"@babel/cli": "^7.6.0",
"@babel/core": "^7.6.0",
"@babel/runtime": "^7.6.0",
"@cityofboston/config-babel": "^0.0.0",
"@cityofboston/config-typescript": "^0.0.0",
"@types/google.analytics": "^0.0.39",
Expand All @@ -47,7 +47,7 @@
"concurrently": "^3.5.1",
"cross-env": "^5.2.0",
"jest": "^24.8.0",
"next": "8.0.3",
"next": "^9.0.6",
"nprogress": "^0.2.0",
"rimraf": "^2.6.2",
"rollup": "^0.60.1",
Expand Down
9 changes: 4 additions & 5 deletions modules-js/react-fleet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"peerDependencies": {
"@emotion/core": "^10.0.10",
"@babel/runtime": "7.1.2",
"@babel/runtime": "^7.6.0",
"detect-browser": "^3.0.1",
"prop-types": "^15.6.0",
"react": "16.8.5",
Expand All @@ -42,10 +42,9 @@
"string-hash": "^1.1.3"
},
"devDependencies": {
"@babel/cli": "7.1.5",
"@babel/core": "7.1.2",
"@babel/preset-react": "7.0.0",
"@babel/runtime": "7.1.2",
"@babel/cli": "^7.6.0",
"@babel/core": "^7.6.0",
"@babel/runtime": "^7.1.2",
"@cityofboston/config-babel": "^0.0.0",
"@cityofboston/config-typescript": "^0.0.0",
"@cityofboston/percy-common": "^0.0.0",
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"templates/js-*/build/*"
],
"nohoist": [
"**/@cityofboston/config-typescript"
"**/@cityofboston/config-typescript",
"**/acorn",
"**/acorn-dynamic-import"
]
},
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions services-js/311-indexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
]
},
"dependencies": {
"@babel/runtime": "7.1.2",
"@babel/runtime": "^7.6.0",
"@cityofboston/srv-decrypt-env": "^0.0.0",
"aws-sdk": "^2.100.0",
"cometd": "^4.0.3",
Expand All @@ -43,9 +43,9 @@
"url-search-params": "^0.10.0"
},
"devDependencies": {
"@babel/cli": "7.1.5",
"@babel/core": "7.1.2",
"@babel/node": "7.0.0",
"@babel/cli": "^7.6.0",
"@babel/core": "^7.6.0",
"@babel/node": "^7.6.1",
"@cityofboston/config-babel": "^0.0.0",
"@cityofboston/config-typescript": "^0.0.0",
"@types/cometd": "^4.0.4",
Expand Down
51 changes: 31 additions & 20 deletions services-js/311/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,40 @@ The source code for the future [311.boston.gov](https://311.boston.gov).

[![Build Status](https://travis-ci.org/CityOfBoston/311.svg?branch=develop)](https://travis-ci.org/CityOfBoston/311)

### todo note: 9/23/19

All apps have been upgraded from Next.js 8.x.x => 9.x.x **except** for this one!

After upgrading (along with Babel from 7.1.x to 7.6.x), running Jest throws

```
[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: 'Reaction[RecentRequestRow#3350.render()] { Invariant Violation: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
```

Since this application is not in production and it is unknown whether it ever will be, it was decided to leave it as-is for the time being.

## Developers

This is a Node project using the [Next.js](https://github.com/zeit/next.js/)
framework for server-side rendering.

* **Development Server**: `npm run dev` <http://localhost:3000/>
* **React Storybook**: `npm run storybook` <http://localhost:9001/>
* **Tests**: `npm test` or `npm test -- --watch`
* **Lint**: `npm run lint` (uses [ESLint](http://eslint.org/) `--fix` to fix common style errors)
- **Development Server**: `npm run dev` <http://localhost:3000/>
- **React Storybook**: `npm run storybook` <http://localhost:9001/>
- **Tests**: `npm test` or `npm test -- --watch`
- **Lint**: `npm run lint` (uses [ESLint](http://eslint.org/) `--fix` to fix common style errors)

### Getting started

__Make sure you have at least Node 8.2 installed, preferrably with `nvm` or
**Make sure you have at least Node 8.2 installed, preferrably with `nvm` or
equivalent so you automatically pick up our `.nvmrc` file. Also, `npm` >= 5.3
(installed by default with Node 8.2 and up) and `gulp-cli`.__
(installed by default with Node 8.2 and up) and `gulp-cli`.**

1. Get the Open311 api_key and URL from a friend
1. Copy `.env.sample` to `.env` and fill in the endpoint and keys
1. Get other API keys: Mapbox, Searchly, &c. and put them in .env
1. `yarn install`
1. `yarn dev`
1. Visit <http://localhost:3000/> in your browser
1. Get the Open311 api_key and URL from a friend
1. Copy `.env.sample` to `.env` and fill in the endpoint and keys
1. Get other API keys: Mapbox, Searchly, &c. and put them in .env
1. `yarn install`
1. `yarn dev`
1. Visit <http://localhost:3000/> in your browser

### JavaScript

Expand All @@ -37,9 +49,9 @@ preset.

Please make full use of:

* [Object rest spread](https://babeljs.io/docs/plugins/transform-object-rest-spread/): `{ foo: 1, ...bar }`
* [Async functions](https://babeljs.io/docs/plugins/transform-async-to-generator/): `async (promisedNum) => (3 + await promisedNum)`
* [Class properties](https://babeljs.io/docs/plugins/transform-class-properties/): `class MyComponent { onClick = () => { this.setState({ clicked: true })} }`
- [Object rest spread](https://babeljs.io/docs/plugins/transform-object-rest-spread/): `{ foo: 1, ...bar }`
- [Async functions](https://babeljs.io/docs/plugins/transform-async-to-generator/): `async (promisedNum) => (3 + await promisedNum)`
- [Class properties](https://babeljs.io/docs/plugins/transform-class-properties/): `class MyComponent { onClick = () => { this.setState({ clicked: true })} }`

Code style is enforced by ESLint, which can be run (in `--fix` mode) with
`npm run lint`. Committed code must contain no errors or warnings. On a per-file
Expand Down Expand Up @@ -78,8 +90,7 @@ Components and containers are organized under `/components` by page.
For UI-focused development, use [React Storybook](https://getstorybook.io/) by
running `npm run storybook` and visiting <http://localhost:9001>

**Local use of patterns library:** After running `gulp` and `npx fractal
start -- --watch` in the patterns directory, change `stylesheets.json` to
**Local use of patterns library:** After running `gulp` and `npx fractal start -- --watch` in the patterns directory, change `stylesheets.json` to
reference `https://localhost:3001` instead of `cob-patterns-staging`.

## Public domain
Expand All @@ -94,6 +105,6 @@ This project is in the worldwide [public domain](LICENSE.md). As stated in [LICE

If you're interested in helping this project, there are three ways to help. Be sure to checkout our [Guide to Contributing](https://github.com/CityOfBoston/boston.gov/blob/develop/guides/03-contributing-to-boston.gov.md).

* [Report issues on Boston.gov](https://github.com/CityOfBoston/boston.gov/blob/develop/guides/03-contributing-to-boston.gov.md#reporting-bugs)
* [Suggest new features](https://github.com/CityOfBoston/boston.gov/blob/develop/guides/03-contributing-to-boston.gov.md#suggest-new-features)
* [Contributing to development](https://github.com/CityOfBoston/boston.gov/blob/develop/guides/03-contributing-to-boston.gov.md#contributing-to-development)
- [Report issues on Boston.gov](https://github.com/CityOfBoston/boston.gov/blob/develop/guides/03-contributing-to-boston.gov.md#reporting-bugs)
- [Suggest new features](https://github.com/CityOfBoston/boston.gov/blob/develop/guides/03-contributing-to-boston.gov.md#suggest-new-features)
- [Contributing to development](https://github.com/CityOfBoston/boston.gov/blob/develop/guides/03-contributing-to-boston.gov.md#contributing-to-development)
3 changes: 2 additions & 1 deletion services-js/311/components/request/home/HomeDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ describe('choose page', () => {
});
});

describe('integration', () => {
// disabled as per Reilly 9/23 jm
xdescribe('integration', () => {
let wrapper;
let resolveSuggestions;

Expand Down
8 changes: 5 additions & 3 deletions services-js/311/data/store/AddressSearch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ describe('searching', () => {
addressSearch.stop();
});

it('updates address and location on success', async () => {
// disabled as per Reilly 9/23 jm
xit('updates address and location on success', async () => {
addressSearch.query = '1 City Hall Plaza';
addressSearch.search(false);

Expand All @@ -85,7 +86,8 @@ describe('searching', () => {
expect(addressSearch.intent).toEqual('ADDRESS');
});

it('searches for an intersection and uses LATLNG intent', async () => {
// disabled as per Reilly 9/23 jm
xit('searches for an intersection and uses LATLNG intent', async () => {
addressSearch.query = 'Milk and Washington';
addressSearch.search(false);

Expand Down Expand Up @@ -115,7 +117,7 @@ describe('searching', () => {
expect(addressSearch.addressId).toEqual(null);
});

it('has no selection when search returns multilpe things', async () => {
it('has no selection when search returns multiple things', async () => {
addressSearch.query = '1 City Hall Plaza';
addressSearch.search(false);

Expand Down
1 change: 1 addition & 0 deletions services-js/311/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"@types/storybook__addon-actions": "^3.4.2",
"@types/storybook__addon-storyshots": "^3.4.8",
"@types/storybook__react": "^4.0.1",
"@zeit/next-typescript": "1.1.1",
"babel-core": "^7.0.0-0",
"babel-plugin-inline-import": "^2.0.6",
"cheerio": "^1.0.0-rc.2",
Expand Down
8 changes: 4 additions & 4 deletions services-js/311/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,16 @@ function getInitialPageDependencies(
* - GetInitialPropsDependencies are passed as a second argument to getInitialProps
* - PageDependencies are spread as props for the page
*/
export default class Three11App extends App {
export default class Three11App extends App<Props | any> {
// TypeScript doesn't know that App already has a props member.
protected props: Props;
props: Props | any;

private pageDependencies: PageDependencies;

static async getInitialProps({
Component,
ctx,
}: AppGetInitialPropsContext): Promise<InitialProps> {
}: AppGetInitialPropsContext | any): Promise<InitialProps> {
const deps = getInitialPageDependencies(ctx.req);

const pageProps = Component.getInitialProps
Expand All @@ -182,7 +182,7 @@ export default class Three11App extends App {
};
}

constructor(props: Props) {
constructor(props: Props | any) {
super(props);

// We're a little hacky here because TypeScript doesn't have type
Expand Down
Loading