Skip to content

Commit

Permalink
Merge branch 'migrate/gh-actions' of github.com:ijjk/next.js into mig…
Browse files Browse the repository at this point in the history
…rate/gh-actions
  • Loading branch information
ijjk committed Jan 27, 2020
2 parents 6cf3653 + b1a3685 commit 56f6ec5
Show file tree
Hide file tree
Showing 19 changed files with 119 additions and 23 deletions.
3 changes: 2 additions & 1 deletion docs/basic-features/built-in-css-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ For example, consider the following stylesheet named `styles.css`:

```css
body {
font-family: 'SF Pro Text', 'SF Pro Icons', system-ui;
font-family: 'SF Pro Text', 'SF Pro Icons', 'Helvetica Neue', 'Helvetica',
'Arial', sans-serif;
padding: 20px 20px 60px;
max-width: 680px;
margin: 0 auto;
Expand Down
4 changes: 2 additions & 2 deletions docs/basic-features/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ The following is an example of how to use the built-in types for API routes:
import { NextApiRequest, NextApiResponse } from 'next'

export default (req: NextApiRequest, res: NextApiResponse) => {
res.status(200).json({ name: 'Jhon Doe' })
res.status(200).json({ name: 'John Doe' })
}
```

Expand All @@ -115,6 +115,6 @@ type Data = {
}

export default (req: NextApiRequest, res: NextApiResponse<Data>) => {
res.status(200).json({ name: 'Jhon Doe' })
res.status(200).json({ name: 'John Doe' })
}
```
4 changes: 2 additions & 2 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The interactive course with quizzes will guide you through everything you need t
Install `next`, `react` and `react-dom` in your project:

```bash
npm install --save next react react-dom
npm install next react react-dom
```

Open `package.json` and add the following `scripts`:
Expand All @@ -39,7 +39,7 @@ These scripts refer to the different stages of developing an application:
- `build` - Runs `next build` which builds the application for production usage
- `start` - Runs `next start` which starts a Next.js production server

Next.js is built around the concept of pages. A page is a [React Component](https://reactjs.org/docs/components-and-props.html) exported from a `.js`, `.ts`, or `.tsx` file in the `pages` directory.
Next.js is built around the concept of pages. A page is a [React Component](https://reactjs.org/docs/components-and-props.html) exported from a `.js`, `.jsx`, `.ts`, or `.tsx` file in the `pages` directory.

Pages are associated with a route based on their file name. For example `pages/about.js` is mapped to `/about`. You can even add dynamic route parameters with the filename.

Expand Down
4 changes: 2 additions & 2 deletions examples/with-graphql-faunadb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ By importing a `.gql` or `.graphql` schema into FaunaDB ([see our sample schema

You can start with this template [using `create-next-app`](#using-create-next-app) or by [downloading the repository manually](#download-manually).

To use a live FaunaDB database, create a database at [dashboard.fauna.com](https://dashboard.fauna.com/) and generate a server token by going to the **Security** tab on the left and then click **New Key**. Give the new key a name and select the 'Server' Role. Copy the token since the setup script will ask for it. Do not use it in the frontend, it has superpowers which you don't want to give to your users.
To use a live FaunaDB database, create a database at [dashboard.fauna.com](https://dashboard.fauna.com/) and generate an admin token by going to the **Security** tab on the left and then click **New Key**. Give the new key a name and select the 'Admin' Role. Copy the token since the setup script will ask for it. Do not use it in the frontend, it has superpowers which you don't want to give to your users.

The database can then be set up with the delivered setup by running:

```
yarn setup
```

This script will ask for the server token. Once you provide it with a valid token, this is what the script automatically does for you:
This script will ask for the admin token. Once you provide it with a valid token, this is what the script automatically does for you:

- **Import the GraphQL schema**, by importing a GraphQL schema in FaunaDB, FaunaDB automatically sets up collections and indexes to support your queries. This is now done for you with this script but can also be done from the [dashboard.fauna.com](https://dashboard.fauna.com/) UI by going to the GraphQL tab
- **Create a role suitable for the Client**, FaunaDB has a security system that allows you to define which resources can be accessed for a specific token. That's how we limit our clients powers, feel free to look at the scripts/setup.js script to see how we make roles and tokens.
Expand Down
10 changes: 5 additions & 5 deletions examples/with-graphql-faunadb/scripts/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ const readline = require('readline').createInterface({
output: process.stdout,
})

// In order to set up a database, we need a server key, so let's ask the user for a key.
readline.question(`Please provide the FaunaDB server key\n`, serverKey => {
// In order to set up a database, we need an admin key, so let's ask the user for a key.
readline.question(`Please provide the FaunaDB admin key\n`, adminKey => {
// A graphql schema can be imported in override or merge mode: 'https://docs.fauna.com/fauna/current/api/graphql/endpoints#import'
const options = {
model: 'merge',
uri: 'https://graphql.fauna.com/import',
headers: { Authorization: `Bearer ${serverKey}` },
headers: { Authorization: `Bearer ${adminKey}` },
}
const stream = fs.createReadStream('./schema.gql').pipe(request.post(options))

Expand All @@ -44,7 +44,7 @@ readline.question(`Please provide the FaunaDB server key\n`, serverKey => {
.then(res => {
// The GraphQL schema is important, this means that we now have a GuestbookEntry Colleciton and an entries index.
// Then we create a token that can only read and write to that index and collection
var client = new faunadb.Client({ secret: serverKey })
var client = new faunadb.Client({ secret: adminKey })
return client
.query(
q.CreateRole({
Expand Down Expand Up @@ -81,7 +81,7 @@ readline.question(`Please provide the FaunaDB server key\n`, serverKey => {
.then(res => {
// The GraphQL schema is important, this means that we now have a GuestbookEntry Colleciton and an entries index.
// Then we create a token that can only read and write to that index and collection
var client = new faunadb.Client({ secret: serverKey })
var client = new faunadb.Client({ secret: adminKey })
return client
.query(
q.CreateKey({
Expand Down
4 changes: 2 additions & 2 deletions examples/with-stencil/packages/test-component/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ Instead, use a prefix that fits your company or any name for a group of related

### Node Modules

- Run `npm install my-component --save`
- Run `npm install my-component`
- Put a script tag similar to this `<script src='node_modules/my-component/dist/mycomponent.js'></script>` in the head of your index.html
- Then you can use the element anywhere in your template, JSX, html etc

### In a stencil-starter app

- Run `npm install my-component --save`
- Run `npm install my-component`
- Add an import to the npm packages `import my-component;`
- Then you can use the element anywhere in your template, JSX, html etc
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Use `webpack-bundle-analyzer` in your Next.js project
## Installation

```
npm install --save @next/bundle-analyzer
npm install @next/bundle-analyzer
```

or
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Use [MDX](https://github.com/mdx-js/mdx) with [Next.js](https://github.com/zeit/
## Installation

```
npm install --save @next/mdx @mdx-js/loader
npm install @next/mdx @mdx-js/loader
```

or
Expand Down
4 changes: 2 additions & 2 deletions packages/next/bin/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import arg from 'next/dist/compiled/arg/index.js'
} catch (err) {
// tslint:disable-next-line
console.warn(
`The module '${dependency}' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install --save ${dependency}'`
`The module '${dependency}' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install ${dependency}'`
)
}
})
Expand Down Expand Up @@ -94,7 +94,7 @@ const React = require('react')

if (typeof React.Suspense === 'undefined') {
throw new Error(
`The version of React you are using is lower than the minimum required version needed for Next.js. Please upgrade "react" and "react-dom": "npm install --save react react-dom" https://err.sh/zeit/next.js/invalid-react-version`
`The version of React you are using is lower than the minimum required version needed for Next.js. Please upgrade "react" and "react-dom": "npm install react react-dom" https://err.sh/zeit/next.js/invalid-react-version`
)
}

Expand Down
1 change: 1 addition & 0 deletions packages/next/build/babel/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ module.exports = (
],
require('@babel/plugin-proposal-optional-chaining'),
require('@babel/plugin-proposal-nullish-coalescing-operator'),
isServer && require('@babel/plugin-syntax-bigint'),
].filter(Boolean),
}
}
2 changes: 1 addition & 1 deletion packages/next/next-server/server/api-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function apiResolver(

if (process.env.NODE_ENV !== 'production' && !isResSent(res)) {
console.warn(
`API resolved without sending a response for ${req.url}, this may result in a stalled requests.`
`API resolved without sending a response for ${req.url}, this may result in stalled requests.`
)
}
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion packages/next/next-server/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function assignDefaults(userConfig: { [key: string]: any }) {
`The 'public' directory is reserved in Next.js and can not be set as the 'distDir'. https://err.sh/zeit/next.js/can-not-output-to-public`
)
}
// make sure distDir isn't an empty string which can result the provided
// make sure distDir isn't an empty string as it can result in the provided
// directory being deleted in development mode
if (userDistDir.length === 0) {
throw new Error(
Expand Down
1 change: 1 addition & 0 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"@babel/plugin-proposal-nullish-coalescing-operator": "7.7.4",
"@babel/plugin-proposal-object-rest-spread": "7.6.2",
"@babel/plugin-proposal-optional-chaining": "7.7.4",
"@babel/plugin-syntax-bigint": "7.8.3",
"@babel/plugin-syntax-dynamic-import": "7.2.0",
"@babel/plugin-transform-modules-commonjs": "7.7.0",
"@babel/plugin-transform-runtime": "7.6.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/next-dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import checkCustomRoutes from '../lib/check-custom-routes'

if (typeof React.Suspense === 'undefined') {
throw new Error(
`The version of React you are using is lower than the minimum required version needed for Next.js. Please upgrade "react" and "react-dom": "npm install --save react react-dom" https://err.sh/zeit/next.js/invalid-react-version`
`The version of React you are using is lower than the minimum required version needed for Next.js. Please upgrade "react" and "react-dom": "npm install react react-dom" https://err.sh/zeit/next.js/invalid-react-version`
)
}

Expand Down
2 changes: 1 addition & 1 deletion test/integration/api-support/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ function runTests(dev = false) {
signal: controller.signal,
}).catch(() => {})
expect(stderr).toContain(
`API resolved without sending a response for /api/test-no-end, this may result in a stalled requests`
`API resolved without sending a response for /api/test-no-end, this may result in stalled requests.`
)
})
} else {
Expand Down
4 changes: 4 additions & 0 deletions test/integration/bigint/pages/api/bigint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default (req, res) => {
res.statusCode = 200
res.send((1n + 2n).toString())
}
77 changes: 77 additions & 0 deletions test/integration/bigint/test/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/* eslint-env jest */
/* global jasmine */
import fs from 'fs-extra'
import { join } from 'path'
import {
fetchViaHTTP,
launchApp,
nextBuild,
nextStart,
killApp,
findPort,
} from 'next-test-utils'

jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2

const appDir = join(__dirname, '..')
const nextConfig = join(appDir, 'next.config.js')
let appPort
let app

const runTests = () => {
it('should return 200', async () => {
const res = await fetchViaHTTP(appPort, '/api/bigint', null, {
method: 'GET',
})
expect(res.status).toEqual(200)
})

it('should return the BigInt result text', async () => {
const resText = await fetchViaHTTP(appPort, '/api/bigint', null, {
method: 'GET',
}).then(res => res.ok && res.text())
expect(resText).toEqual('3')
})
}

describe('bigint API route support', () => {
describe('dev mode', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => killApp(app))

runTests()
})

describe('server mode', () => {
beforeAll(async () => {
await fs.remove(nextConfig)
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))

runTests()
})

describe('serverless mode', () => {
beforeAll(async () => {
await fs.writeFile(
nextConfig,
`module.exports = { target: 'serverless' }`
)
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
await fs.remove(nextConfig)
})

runTests()
})
})
2 changes: 1 addition & 1 deletion test/unit/handles-incorrect-react.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const nextBin = path.join(nextDir, 'dist/bin/next')
describe('Handles Incorrect React Version', () => {
it('should throw an error when building with next', async () => {
expect(() => require(nextBin)).toThrow(
/The version of React you are using is lower than the minimum required version needed for Next\.js\. Please upgrade "react" and "react-dom": "npm install --save react react-dom" https:\/\/err\.sh/
/The version of React you are using is lower than the minimum required version needed for Next\.js\. Please upgrade "react" and "react-dom": "npm install react react-dom" https:\/\/err\.sh/
)
})
})
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250"
integrity sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA==

"@babel/helper-plugin-utils@^7.8.0":
version "7.8.3"
resolved "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.8.3.tgz#9ea293be19babc0f52ff8ca88b34c3611b208670"
integrity sha512-j+fq49Xds2smCUNYmEHF9kGNkhbet6yVIBp4e6oeQpH1RUs/Ir06xUKzDjDkGcaaokPiTNs2JBWHjaE4csUkZQ==

"@babel/helper-regex@^7.0.0", "@babel/helper-regex@^7.4.4":
version "7.5.5"
resolved "https://registry.yarnpkg.com/@babel/helper-regex/-/helper-regex-7.5.5.tgz#0aa6824f7100a2e0e89c1527c23936c152cab351"
Expand Down Expand Up @@ -384,6 +389,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-syntax-bigint@7.8.3":
version "7.8.3"
resolved "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz#4c9a6f669f5d0cdf1b90a1671e9a146be5300cea"
integrity sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==
dependencies:
"@babel/helper-plugin-utils" "^7.8.0"

"@babel/plugin-syntax-dynamic-import@7.2.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.2.0.tgz#69c159ffaf4998122161ad8ebc5e6d1f55df8612"
Expand Down

0 comments on commit 56f6ec5

Please sign in to comment.