Skip to content

Commit

Permalink
Merge branch 'canary' into update/export-error-page
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk authored Dec 2, 2021
2 parents b3e5ed3 + cc9e1ea commit 8bdcc13
Show file tree
Hide file tree
Showing 20 changed files with 140 additions and 27 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/build_test_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ jobs:
docsChange: ${{ steps.docs-change.outputs.DOCS_CHANGE }}
isRelease: ${{ steps.check-release.outputs.IS_RELEASE }}
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

- uses: actions/checkout@v2
with:
fetch-depth: 25
Expand Down Expand Up @@ -62,6 +68,12 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

- uses: actions/cache@v2
id: restore-build
with:
Expand All @@ -77,6 +89,12 @@ jobs:
env:
NEXT_TELEMETRY_DISABLED: 1
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
Expand Down Expand Up @@ -115,6 +133,12 @@ jobs:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

- uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
Expand All @@ -139,6 +163,12 @@ jobs:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

- run: echo ${{needs.build.outputs.docsChange}}

# https://github.com/actions/virtual-environments/issues/1187
Expand Down Expand Up @@ -187,6 +217,12 @@ jobs:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

- run: echo ${{needs.build.outputs.docsChange}}

# https://github.com/actions/virtual-environments/issues/1187
Expand Down Expand Up @@ -230,6 +266,12 @@ jobs:
matrix:
group: [1, 2, 3, 4, 5, 6]
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

- run: echo ${{needs.build.outputs.docsChange}}

# https://github.com/actions/virtual-environments/issues/1187
Expand Down Expand Up @@ -274,6 +316,12 @@ jobs:
NEXT_TEST_JOB: 1
TEST_ELECTRON: 1
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

- uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
Expand All @@ -300,6 +348,12 @@ jobs:
NODE_OPTIONS: '--unhandled-rejections=strict'
YARN_COMPRESSION_LEVEL: '0'
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

- uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
Expand Down Expand Up @@ -342,6 +396,12 @@ jobs:
BROWSER_NAME: 'firefox'
NEXT_TELEMETRY_DISABLED: 1
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

- uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
Expand Down Expand Up @@ -370,6 +430,12 @@ jobs:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
Expand Down Expand Up @@ -408,6 +474,12 @@ jobs:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
Expand Down Expand Up @@ -479,6 +551,12 @@ jobs:
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
Expand Down Expand Up @@ -508,6 +586,12 @@ jobs:
runs-on: ubuntu-latest
needs: [publishRelease, build-native-dev]
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

- uses: actions/cache@v2
id: restore-build
with:
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/web/spec-extension/response.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { I18NConfig } from '../../config-shared'
import type { CookieSerializeOptions } from 'next/dist/compiled/cookie'
import { NextURL } from '../next-url'
import { toNodeHeaders } from '../utils'
import cookie from 'next/dist/compiled/cookie'
import { CookieSerializeOptions } from '../types'

const INTERNALS = Symbol('internal response')
const REDIRECTS = new Set([301, 302, 303, 307, 308])
Expand Down
11 changes: 11 additions & 0 deletions packages/next/server/web/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ export interface NodeHeaders {
[header: string]: string | string[] | undefined
}

export interface CookieSerializeOptions {
domain?: string
encode?(val: string): string
expires?: Date
httpOnly?: boolean
maxAge?: number
path?: string
sameSite?: boolean | 'lax' | 'strict' | 'none'
secure?: boolean
}

export interface RequestData {
geo?: {
city?: string
Expand Down
16 changes: 0 additions & 16 deletions test/integration/middleware-typescript/test/index.test.js

This file was deleted.

17 changes: 9 additions & 8 deletions test/lib/create-next-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ async function createNextInstall(dependencies) {
)) {
if (folder.startsWith('swc-')) {
const swcPkgPath = path.join(origRepoDir, 'node_modules/@next', folder)
await fs.copy(
swcPkgPath,
path.join(origRepoDir, 'packages/next-swc/native'),
{
filter: (item) =>
const outputPath = path.join(origRepoDir, 'packages/next-swc/native')
await fs.copy(swcPkgPath, outputPath, {
filter: (item) => {
return (
item === swcPkgPath ||
(item.endsWith('.node') && !fs.pathExistsSync(item)),
}
)
(item.endsWith('.node') &&
!fs.pathExistsSync(path.join(outputPath, path.basename(item))))
)
},
})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const middleware: NextMiddleware = function (request) {
console.log(request.ua?.isBot)
console.log(request.ua?.ua)

return new Response(null, {
return new Response('hello from middleware', {
headers: {
'req-url-basepath': request.nextUrl.basePath,
'req-url-pathname': request.nextUrl.pathname,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"skipLibCheck": false,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
Expand Down
33 changes: 33 additions & 0 deletions test/production/middleware-typescript/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* eslint-env jest */

import { join } from 'path'
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP } from 'next-test-utils'

const appDir = join(__dirname, '../app')

describe('should set-up next', () => {
let next: NextInstance

beforeAll(async () => {
next = await createNext({
files: {
pages: new FileRef(join(appDir, 'pages')),
'tsconfig.json': new FileRef(join(appDir, 'tsconfig.json')),
'next.config.js': new FileRef(join(appDir, 'next.config.js')),
},
dependencies: {
typescript: 'latest',
'@types/react': 'latest',
'@types/react-dom': 'latest',
},
})
})
afterAll(() => next.destroy())

it('should have built and started', async () => {
const html = await renderViaHTTP(next.url, '/interface/static')
expect(html).toContain('hello from middleware')
})
})

0 comments on commit 8bdcc13

Please sign in to comment.