mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-11 12:57:46 +00:00
Compare commits
36 Commits
@vercel/py
...
@vercel/py
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40f38948a0 | ||
|
|
87eba56063 | ||
|
|
d0a5676c26 | ||
|
|
da9fa997ed | ||
|
|
3d79a9d4d4 | ||
|
|
ae13c5ee92 | ||
|
|
ad654139df | ||
|
|
74f8414e12 | ||
|
|
65c2860e14 | ||
|
|
3b5b397b35 | ||
|
|
051e061176 | ||
|
|
30d46321cc | ||
|
|
c2563535ea | ||
|
|
5f2bed4f24 | ||
|
|
cfb7946f4b | ||
|
|
05c5b3a80d | ||
|
|
45bd855250 | ||
|
|
49de8ad9a0 | ||
|
|
a1ea56fd67 | ||
|
|
e88addc9ed | ||
|
|
5d50013f93 | ||
|
|
44e1eb3983 | ||
|
|
f8af013349 | ||
|
|
972cc495ec | ||
|
|
1c580da3d8 | ||
|
|
244554ab1b | ||
|
|
053c185481 | ||
|
|
8805b586ea | ||
|
|
681070ffa0 | ||
|
|
362b17d60a | ||
|
|
c7c9b1a791 | ||
|
|
c42f309463 | ||
|
|
a0ead28369 | ||
|
|
8814fc1515 | ||
|
|
0d044b4eac | ||
|
|
f6bd1aa8c0 |
1
.github/CONTRIBUTING.md
vendored
1
.github/CONTRIBUTING.md
vendored
@@ -13,6 +13,7 @@ To get started, execute the following:
|
||||
```
|
||||
git clone https://github.com/vercel/vercel
|
||||
cd vercel
|
||||
corepack enable
|
||||
yarn install
|
||||
yarn bootstrap
|
||||
yarn build
|
||||
|
||||
17
.github/workflows/cancel.yml
vendored
17
.github/workflows/cancel.yml
vendored
@@ -1,17 +0,0 @@
|
||||
name: Cancel
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
- '!main'
|
||||
|
||||
jobs:
|
||||
cancel:
|
||||
name: 'Cancel Previous Runs'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 2
|
||||
steps:
|
||||
- uses: styfle/cancel-workflow-action@0.9.1
|
||||
with:
|
||||
workflow_id: test.yml, test-integration-cli.yml, test-unit.yml
|
||||
access_token: ${{ github.token }}
|
||||
4
.github/workflows/publish.yml
vendored
4
.github/workflows/publish.yml
vendored
@@ -18,7 +18,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Check Release
|
||||
id: check-release
|
||||
run: |
|
||||
|
||||
4
.github/workflows/test-integration-cli.yml
vendored
4
.github/workflows/test-integration-cli.yml
vendored
@@ -13,6 +13,10 @@ env:
|
||||
TURBO_TEAM: 'vercel'
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: CLI
|
||||
|
||||
4
.github/workflows/test-unit.yml
vendored
4
.github/workflows/test-unit.yml
vendored
@@ -13,6 +13,10 @@ env:
|
||||
TURBO_TEAM: 'vercel'
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Unit
|
||||
|
||||
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -14,6 +14,10 @@ env:
|
||||
TURBO_TEAM: 'vercel'
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
name: Find Changes
|
||||
|
||||
@@ -380,8 +380,8 @@ This is a [class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refere
|
||||
|
||||
This is an abstract enumeration type that is implemented by one of the following possible `String` values:
|
||||
|
||||
- `nodejs16.x`
|
||||
- `nodejs14.x`
|
||||
- `nodejs12.x`
|
||||
- `go1.x`
|
||||
- `java11`
|
||||
- `python3.9`
|
||||
|
||||
@@ -19,11 +19,9 @@
|
||||
|
||||
## Vercel
|
||||
|
||||
Vercel is a platform for **static sites and frontend frameworks**, built to integrate with your headless content, commerce, or database.
|
||||
Vercel is the platform for frontend developers, providing the speed and reliability innovators need to create at the moment of inspiration.
|
||||
|
||||
We provide a **frictionless developer experience** to take care of the hard things: deploy instantly, scale automatically, and serve personalized content around the globe.
|
||||
|
||||
We make it easy for frontend teams to **develop, preview, and ship** delightful user experiences, where performance is the default.
|
||||
We enable teams to iterate quickly and develop, preview, and ship delightful user experiences. Vercel has zero-configuration support for 35+ frontend frameworks and integrates with your headless content, commerce, or database of choice.
|
||||
|
||||
## Deploy
|
||||
|
||||
|
||||
@@ -18,6 +18,12 @@ async function main() {
|
||||
{ recursive: true, force: true }
|
||||
);
|
||||
|
||||
await fs.cp(
|
||||
join(repoRoot, 'packages', 'fs-detectors', 'logos'),
|
||||
join(pubDir, 'monorepo-logos'),
|
||||
{ recursive: true, force: true }
|
||||
);
|
||||
|
||||
const examples = await getExampleList();
|
||||
const pathListAll = join(pubDir, 'list-all.json');
|
||||
await fs.writeFile(pathListAll, JSON.stringify(examples));
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"license": "Apache-2.0",
|
||||
"packageManager": "yarn@1.22.19",
|
||||
"workspaces": {
|
||||
"packages": [
|
||||
"packages/*"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/build-utils",
|
||||
"version": "5.5.2",
|
||||
"version": "5.5.5",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.js",
|
||||
|
||||
@@ -5,7 +5,13 @@ import path from 'path';
|
||||
import Sema from 'async-sema';
|
||||
import { FileBase } from './types';
|
||||
|
||||
const semaToPreventEMFILE = new Sema(20);
|
||||
const DEFAULT_SEMA = 20;
|
||||
const semaToPreventEMFILE = new Sema(
|
||||
parseInt(
|
||||
process.env.VERCEL_INTERNAL_FILE_FS_REF_SEMA || String(DEFAULT_SEMA),
|
||||
10
|
||||
) || DEFAULT_SEMA
|
||||
);
|
||||
|
||||
interface FileFsRefOptions {
|
||||
mode?: number;
|
||||
|
||||
@@ -12,7 +12,13 @@ interface FileRefOptions {
|
||||
mutable?: boolean;
|
||||
}
|
||||
|
||||
const semaToDownloadFromS3 = new Sema(5);
|
||||
const DEFAULT_SEMA = 5;
|
||||
const semaToDownloadFromS3 = new Sema(
|
||||
parseInt(
|
||||
process.env.VERCEL_INTERNAL_FILE_REF_SEMA || String(DEFAULT_SEMA),
|
||||
10
|
||||
) || DEFAULT_SEMA
|
||||
);
|
||||
|
||||
class BailableError extends Error {
|
||||
public bail: boolean;
|
||||
|
||||
@@ -251,33 +251,24 @@ export async function getNodeVersion(
|
||||
meta: Meta = {}
|
||||
): Promise<NodeVersion> {
|
||||
const latest = getLatestNodeVersion();
|
||||
if (meta && meta.isDev) {
|
||||
if (meta.isDev) {
|
||||
// Use the system-installed version of `node` in PATH for `vercel dev`
|
||||
return { ...latest, runtime: 'nodejs' };
|
||||
}
|
||||
const { packageJson } = await scanParentDirs(destPath, true);
|
||||
let { nodeVersion } = config;
|
||||
let isAuto = true;
|
||||
if (packageJson && packageJson.engines && packageJson.engines.node) {
|
||||
if (packageJson?.engines?.node) {
|
||||
const { node } = packageJson.engines;
|
||||
if (
|
||||
nodeVersion &&
|
||||
validRange(node) &&
|
||||
!intersects(nodeVersion, node) &&
|
||||
!meta.isDev
|
||||
) {
|
||||
if (nodeVersion && validRange(node) && !intersects(nodeVersion, node)) {
|
||||
console.warn(
|
||||
`Warning: Due to "engines": { "node": "${node}" } in your \`package.json\` file, the Node.js Version defined in your Project Settings ("${nodeVersion}") will not apply. Learn More: http://vercel.link/node-version`
|
||||
);
|
||||
} else if (coerce(node)?.raw === node && !meta.isDev) {
|
||||
} else if (coerce(node)?.raw === node) {
|
||||
console.warn(
|
||||
`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` with major.minor.patch, but only major Node.js Version can be selected. Learn More: http://vercel.link/node-version`
|
||||
);
|
||||
} else if (
|
||||
validRange(node) &&
|
||||
intersects(`${latest.major + 1}.x`, node) &&
|
||||
!meta.isDev
|
||||
) {
|
||||
} else if (validRange(node) && intersects(`${latest.major + 1}.x`, node)) {
|
||||
console.warn(
|
||||
`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` that will automatically upgrade when a new major Node.js Version is released. Learn More: http://vercel.link/node-version`
|
||||
);
|
||||
|
||||
@@ -77,7 +77,6 @@ it('should include peer dependencies when VERCEL_NPM_LEGACY_PEER_DEPS=1 on node1
|
||||
const spawnOpts = getTestSpawnOpts({ VERCEL_NPM_LEGACY_PEER_DEPS: '1' });
|
||||
|
||||
const nodeVersion = getNodeVersion(14);
|
||||
console.log({ nodeVersion, path: spawnOpts.env.PATH });
|
||||
await runNpmInstall(fixture, [], spawnOpts, meta, nodeVersion);
|
||||
expect(spawnMock.mock.calls.length).toBe(1);
|
||||
const args = spawnMock.mock.calls[0];
|
||||
@@ -102,7 +101,6 @@ it('should not include peer dependencies when VERCEL_NPM_LEGACY_PEER_DEPS=1 on n
|
||||
const spawnOpts = getTestSpawnOpts({ VERCEL_NPM_LEGACY_PEER_DEPS: '1' });
|
||||
|
||||
const nodeVersion = getNodeVersion(14);
|
||||
console.log({ nodeVersion, path: spawnOpts.env.PATH });
|
||||
await runNpmInstall(fixture, [], spawnOpts, meta, nodeVersion);
|
||||
expect(spawnMock.mock.calls.length).toBe(1);
|
||||
const args = spawnMock.mock.calls[0];
|
||||
|
||||
26
packages/build-utils/test/unit.test.ts
vendored
26
packages/build-utils/test/unit.test.ts
vendored
@@ -216,10 +216,6 @@ it('should download symlinks even with incorrect file', async () => {
|
||||
});
|
||||
|
||||
it('should only match supported node versions, otherwise throw an error', async () => {
|
||||
expect(await getSupportedNodeVersion('12.x', false)).toHaveProperty(
|
||||
'major',
|
||||
12
|
||||
);
|
||||
expect(await getSupportedNodeVersion('14.x', false)).toHaveProperty(
|
||||
'major',
|
||||
14
|
||||
@@ -240,10 +236,6 @@ it('should only match supported node versions, otherwise throw an error', async
|
||||
await expectBuilderError(getSupportedNodeVersion('foo', true), autoMessage);
|
||||
await expectBuilderError(getSupportedNodeVersion('=> 10', true), autoMessage);
|
||||
|
||||
expect(await getSupportedNodeVersion('12.x', true)).toHaveProperty(
|
||||
'major',
|
||||
12
|
||||
);
|
||||
expect(await getSupportedNodeVersion('14.x', true)).toHaveProperty(
|
||||
'major',
|
||||
14
|
||||
@@ -273,21 +265,21 @@ it('should only match supported node versions, otherwise throw an error', async
|
||||
|
||||
it('should match all semver ranges', async () => {
|
||||
// See https://docs.npmjs.com/files/package.json#engines
|
||||
expect(await getSupportedNodeVersion('12.0.0')).toHaveProperty('major', 12);
|
||||
expect(await getSupportedNodeVersion('12.x')).toHaveProperty('major', 12);
|
||||
expect(await getSupportedNodeVersion('14.0.0')).toHaveProperty('major', 14);
|
||||
expect(await getSupportedNodeVersion('14.x')).toHaveProperty('major', 14);
|
||||
expect(await getSupportedNodeVersion('>=10')).toHaveProperty('major', 16);
|
||||
expect(await getSupportedNodeVersion('>=10.3.0')).toHaveProperty('major', 16);
|
||||
expect(await getSupportedNodeVersion('11.5.0 - 12.5.0')).toHaveProperty(
|
||||
expect(await getSupportedNodeVersion('16.5.0 - 16.9.0')).toHaveProperty(
|
||||
'major',
|
||||
12
|
||||
16
|
||||
);
|
||||
expect(await getSupportedNodeVersion('>=9.5.0 <=12.5.0')).toHaveProperty(
|
||||
expect(await getSupportedNodeVersion('>=9.5.0 <=14.5.0')).toHaveProperty(
|
||||
'major',
|
||||
12
|
||||
14
|
||||
);
|
||||
expect(await getSupportedNodeVersion('~12.5.0')).toHaveProperty('major', 12);
|
||||
expect(await getSupportedNodeVersion('^12.5.0')).toHaveProperty('major', 12);
|
||||
expect(await getSupportedNodeVersion('12.5.0 - 14.5.0')).toHaveProperty(
|
||||
expect(await getSupportedNodeVersion('~14.5.0')).toHaveProperty('major', 14);
|
||||
expect(await getSupportedNodeVersion('^14.5.0')).toHaveProperty('major', 14);
|
||||
expect(await getSupportedNodeVersion('14.5.0 - 14.20.0')).toHaveProperty(
|
||||
'major',
|
||||
14
|
||||
);
|
||||
|
||||
@@ -10,11 +10,9 @@
|
||||
|
||||
## Usage
|
||||
|
||||
Vercel is a platform for **static sites and frontend frameworks**, built to integrate with your headless content, commerce, or database.
|
||||
Vercel is the platform for frontend developers, providing the speed and reliability innovators need to create at the moment of inspiration.
|
||||
|
||||
We provide a **frictionless developer experience** to take care of the hard things: deploy instantly, scale automatically, and serve personalized content around the globe.
|
||||
|
||||
We make it easy for frontend teams to **develop, preview, and ship** delightful user experiences, where performance is the default.
|
||||
We enable teams to iterate quickly and develop, preview, and ship delightful user experiences. Vercel has zero-configuration support for 35+ frontend frameworks and integrates with your headless content, commerce, or database of choice.
|
||||
|
||||
To install the latest version of Vercel CLI, run this command:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vercel",
|
||||
"version": "28.4.4",
|
||||
"version": "28.4.11",
|
||||
"preferGlobal": true,
|
||||
"license": "Apache-2.0",
|
||||
"description": "The command-line interface for Vercel",
|
||||
@@ -41,16 +41,16 @@
|
||||
"node": ">= 14"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/build-utils": "5.5.2",
|
||||
"@vercel/go": "2.2.10",
|
||||
"@vercel/hydrogen": "0.0.23",
|
||||
"@vercel/next": "3.2.0",
|
||||
"@vercel/node": "2.5.20",
|
||||
"@vercel/python": "3.1.19",
|
||||
"@vercel/redwood": "1.0.28",
|
||||
"@vercel/remix": "1.0.29",
|
||||
"@vercel/ruby": "1.3.36",
|
||||
"@vercel/static-build": "1.0.28",
|
||||
"@vercel/build-utils": "5.5.5",
|
||||
"@vercel/go": "2.2.13",
|
||||
"@vercel/hydrogen": "0.0.26",
|
||||
"@vercel/next": "3.2.5",
|
||||
"@vercel/node": "2.5.25",
|
||||
"@vercel/python": "3.1.22",
|
||||
"@vercel/redwood": "1.0.31",
|
||||
"@vercel/remix": "1.0.32",
|
||||
"@vercel/ruby": "1.3.39",
|
||||
"@vercel/static-build": "1.0.32",
|
||||
"update-notifier": "5.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -95,9 +95,9 @@
|
||||
"@types/which": "1.3.2",
|
||||
"@types/write-json-file": "2.2.1",
|
||||
"@types/yauzl-promise": "2.1.0",
|
||||
"@vercel/client": "12.2.9",
|
||||
"@vercel/frameworks": "1.1.6",
|
||||
"@vercel/fs-detectors": "3.4.0",
|
||||
"@vercel/client": "12.2.13",
|
||||
"@vercel/frameworks": "1.1.8",
|
||||
"@vercel/fs-detectors": "3.4.5",
|
||||
"@vercel/fun": "1.0.4",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"@zeit/source-map-support": "0.6.2",
|
||||
|
||||
@@ -3,6 +3,7 @@ import chalk from 'chalk';
|
||||
import dotenv from 'dotenv';
|
||||
import { join, normalize, relative, resolve } from 'path';
|
||||
import {
|
||||
getDiscontinuedNodeVersions,
|
||||
normalizePath,
|
||||
Files,
|
||||
FileFsRef,
|
||||
@@ -467,6 +468,25 @@ async function doBuild(
|
||||
);
|
||||
const buildResult = await builder.build(buildOptions);
|
||||
|
||||
if (
|
||||
buildResult &&
|
||||
'output' in buildResult &&
|
||||
'runtime' in buildResult.output &&
|
||||
'type' in buildResult.output &&
|
||||
buildResult.output.type === 'Lambda'
|
||||
) {
|
||||
const lambdaRuntime = buildResult.output.runtime;
|
||||
if (
|
||||
getDiscontinuedNodeVersions().some(o => o.runtime === lambdaRuntime)
|
||||
) {
|
||||
throw new NowBuildError({
|
||||
code: 'NODEJS_DISCONTINUED_VERSION',
|
||||
message: `The Runtime "${build.use}" is using "${lambdaRuntime}", which is discontinued. Please upgrade your Runtime to a more recent version or consult the author for more details.`,
|
||||
link: 'https://github.com/vercel/vercel/blob/main/DEVELOPING_A_RUNTIME.md#lambdaruntime',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Store the build result to generate the final `config.json` after
|
||||
// all builds have completed
|
||||
buildResults.set(build, buildResult);
|
||||
|
||||
@@ -115,29 +115,39 @@ export default async function processDeployment({
|
||||
.reduce((a: number, b: number) => a + b, 0);
|
||||
const totalSizeHuman = bytes.format(missingSize, { decimalPlaces: 1 });
|
||||
|
||||
uploads.forEach((e: any) =>
|
||||
e.on('progress', () => {
|
||||
const uploadedBytes = uploads.reduce((acc: number, e: any) => {
|
||||
return acc + e.bytesUploaded;
|
||||
}, 0);
|
||||
// When stderr is not a TTY then we only want to
|
||||
// print upload progress in 25% increments
|
||||
let nextStep = 0;
|
||||
const stepSize = now._client.stderr.isTTY ? 0 : 0.25;
|
||||
|
||||
const bar = progress(uploadedBytes, missingSize);
|
||||
if (!bar || uploadedBytes === missingSize) {
|
||||
output.spinner(deployingSpinnerVal, 0);
|
||||
} else {
|
||||
const uploadedHuman = bytes.format(uploadedBytes, {
|
||||
decimalPlaces: 1,
|
||||
fixedDecimals: true,
|
||||
});
|
||||
const updateProgress = () => {
|
||||
const uploadedBytes = uploads.reduce((acc: number, e: any) => {
|
||||
return acc + e.bytesUploaded;
|
||||
}, 0);
|
||||
|
||||
const bar = progress(uploadedBytes, missingSize);
|
||||
if (!bar) {
|
||||
output.spinner(deployingSpinnerVal, 0);
|
||||
} else {
|
||||
const uploadedHuman = bytes.format(uploadedBytes, {
|
||||
decimalPlaces: 1,
|
||||
fixedDecimals: true,
|
||||
});
|
||||
const percent = uploadedBytes / missingSize;
|
||||
if (percent >= nextStep) {
|
||||
output.spinner(
|
||||
`Uploading ${chalk.reset(
|
||||
`[${bar}] (${uploadedHuman}/${totalSizeHuman})`
|
||||
)}`,
|
||||
0
|
||||
);
|
||||
nextStep += stepSize;
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
uploads.forEach((e: any) => e.on('progress', updateProgress));
|
||||
updateProgress();
|
||||
}
|
||||
|
||||
if (event.type === 'file-uploaded') {
|
||||
|
||||
@@ -4,6 +4,8 @@ import wait, { StopSpinner } from './wait';
|
||||
import type { WritableTTY } from '../../types';
|
||||
import { errorToString } from '../is-error';
|
||||
|
||||
const IS_TEST = process.env.NODE_ENV === 'test';
|
||||
|
||||
export interface OutputOptions {
|
||||
debug?: boolean;
|
||||
}
|
||||
@@ -108,12 +110,15 @@ export class Output {
|
||||
};
|
||||
|
||||
spinner = (message: string, delay: number = 300): void => {
|
||||
this.spinnerMessage = message;
|
||||
if (this.debugEnabled) {
|
||||
this.debug(`Spinner invoked (${message}) with a ${delay}ms delay`);
|
||||
return;
|
||||
}
|
||||
if (this.stream.isTTY) {
|
||||
if (IS_TEST || !this.stream.isTTY) {
|
||||
this.print(`${message}\n`);
|
||||
} else {
|
||||
this.spinnerMessage = message;
|
||||
|
||||
if (this._spinner) {
|
||||
this._spinner.text = message;
|
||||
} else {
|
||||
@@ -125,8 +130,6 @@ export class Output {
|
||||
delay
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.print(`${message}\n`);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
2
packages/cli/test/fixtures/unit/commands/build/discontinued-nodejs12.x/.gitignore
vendored
Normal file
2
packages/cli/test/fixtures/unit/commands/build/discontinued-nodejs12.x/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.vercel/builders
|
||||
.vercel/output
|
||||
7
packages/cli/test/fixtures/unit/commands/build/discontinued-nodejs12.x/.vercel/project.json
vendored
Normal file
7
packages/cli/test/fixtures/unit/commands/build/discontinued-nodejs12.x/.vercel/project.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"orgId": ".",
|
||||
"projectId": ".",
|
||||
"settings": {
|
||||
"framework": null
|
||||
}
|
||||
}
|
||||
1
packages/cli/test/fixtures/unit/commands/build/discontinued-nodejs12.x/api/index.php
vendored
Normal file
1
packages/cli/test/fixtures/unit/commands/build/discontinued-nodejs12.x/api/index.php
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<?php echo 'This version of vercel-php uses the nodejs12.x Lambda Runtime'; ?>
|
||||
8
packages/cli/test/fixtures/unit/commands/build/discontinued-nodejs12.x/vercel.json
vendored
Normal file
8
packages/cli/test/fixtures/unit/commands/build/discontinued-nodejs12.x/vercel.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "https://openapi.vercel.sh/vercel.json",
|
||||
"functions": {
|
||||
"api/index.php": {
|
||||
"runtime": "vercel-php@0.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -326,7 +326,7 @@ module.exports = async function prepare(session, binaryPath, tmpFixturesDir) {
|
||||
'vercel.json': JSON.stringify({
|
||||
functions: {
|
||||
'api/**/*.php': {
|
||||
runtime: 'vercel-php@0.1.0',
|
||||
runtime: 'vercel-php@0.5.2',
|
||||
},
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -776,6 +776,55 @@ describe('build', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('should error when "functions" has runtime that emits discontinued "nodejs12.x"', async () => {
|
||||
if (process.platform === 'win32') {
|
||||
console.log('Skipping test on Windows');
|
||||
return;
|
||||
}
|
||||
const cwd = fixture('discontinued-nodejs12.x');
|
||||
const output = join(cwd, '.vercel/output');
|
||||
try {
|
||||
process.chdir(cwd);
|
||||
const exitCode = await build(client);
|
||||
expect(exitCode).toEqual(1);
|
||||
|
||||
// Error gets printed to the terminal
|
||||
await expect(client.stderr).toOutput(
|
||||
'The Runtime "vercel-php@0.1.0" is using "nodejs12.x", which is discontinued. Please upgrade your Runtime to a more recent version or consult the author for more details.'
|
||||
);
|
||||
|
||||
// `builds.json` contains "error" build
|
||||
const builds = await fs.readJSON(join(output, 'builds.json'));
|
||||
const errorBuilds = builds.builds.filter((b: any) => 'error' in b);
|
||||
expect(errorBuilds).toHaveLength(1);
|
||||
expect(errorBuilds[0].error).toEqual({
|
||||
name: 'Error',
|
||||
message: expect.stringContaining('Please upgrade your Runtime'),
|
||||
stack: expect.stringContaining('Please upgrade your Runtime'),
|
||||
hideStackTrace: true,
|
||||
code: 'NODEJS_DISCONTINUED_VERSION',
|
||||
link: 'https://github.com/vercel/vercel/blob/main/DEVELOPING_A_RUNTIME.md#lambdaruntime',
|
||||
});
|
||||
|
||||
// top level "error" also contains the same error
|
||||
expect(builds.error).toEqual({
|
||||
name: 'Error',
|
||||
message: expect.stringContaining('Please upgrade your Runtime'),
|
||||
stack: expect.stringContaining('Please upgrade your Runtime'),
|
||||
hideStackTrace: true,
|
||||
code: 'NODEJS_DISCONTINUED_VERSION',
|
||||
link: 'https://github.com/vercel/vercel/blob/main/DEVELOPING_A_RUNTIME.md#lambdaruntime',
|
||||
});
|
||||
|
||||
// `config.json` contains `version`
|
||||
const configJson = await fs.readJSON(join(output, 'config.json'));
|
||||
expect(configJson.version).toBe(3);
|
||||
} finally {
|
||||
process.chdir(originalCwd);
|
||||
delete process.env.__VERCEL_BUILD_RUNNING;
|
||||
}
|
||||
});
|
||||
|
||||
it('should allow for missing "build" script', async () => {
|
||||
const cwd = fixture('static-with-pkg');
|
||||
const output = join(cwd, '.vercel/output');
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import bytes from 'bytes';
|
||||
import fs from 'fs-extra';
|
||||
import { join } from 'path';
|
||||
import { randomBytes } from 'crypto';
|
||||
import { fileNameSymbol } from '@vercel/client';
|
||||
import { client } from '../../mocks/client';
|
||||
import deploy from '../../../src/commands/deploy';
|
||||
@@ -199,4 +202,119 @@ describe('deploy', () => {
|
||||
process.chdir(originalCwd);
|
||||
}
|
||||
});
|
||||
|
||||
it('should upload missing files', async () => {
|
||||
const cwd = setupFixture('commands/deploy/archive');
|
||||
const originalCwd = process.cwd();
|
||||
|
||||
// Add random 1mb file
|
||||
await fs.writeFile(join(cwd, 'data'), randomBytes(bytes('1mb')));
|
||||
|
||||
try {
|
||||
process.chdir(cwd);
|
||||
|
||||
const user = useUser();
|
||||
useTeams('team_dummy');
|
||||
useProject({
|
||||
...defaultProject,
|
||||
name: 'archive',
|
||||
id: 'archive',
|
||||
});
|
||||
|
||||
let body: any;
|
||||
let fileUploaded = false;
|
||||
client.scenario.post(`/v13/deployments`, (req, res) => {
|
||||
if (fileUploaded) {
|
||||
body = req.body;
|
||||
res.json({
|
||||
creator: {
|
||||
uid: user.id,
|
||||
username: user.username,
|
||||
},
|
||||
id: 'dpl_archive_test',
|
||||
});
|
||||
} else {
|
||||
const sha = req.body.files[0].sha;
|
||||
res.status(400).json({
|
||||
error: {
|
||||
code: 'missing_files',
|
||||
message: 'Missing files',
|
||||
missing: [sha],
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
client.scenario.post('/v2/files', (req, res) => {
|
||||
// Wait for file to be finished uploading
|
||||
req.on('data', () => {
|
||||
// Noop
|
||||
});
|
||||
req.on('end', () => {
|
||||
fileUploaded = true;
|
||||
res.end();
|
||||
});
|
||||
});
|
||||
client.scenario.get(`/v13/deployments/dpl_archive_test`, (req, res) => {
|
||||
res.json({
|
||||
creator: {
|
||||
uid: user.id,
|
||||
username: user.username,
|
||||
},
|
||||
id: 'dpl_archive_test',
|
||||
readyState: 'READY',
|
||||
aliasAssigned: true,
|
||||
alias: [],
|
||||
});
|
||||
});
|
||||
client.scenario.get(
|
||||
`/v10/now/deployments/dpl_archive_test`,
|
||||
(req, res) => {
|
||||
res.json({
|
||||
creator: {
|
||||
uid: user.id,
|
||||
username: user.username,
|
||||
},
|
||||
id: 'dpl_archive_test',
|
||||
readyState: 'READY',
|
||||
aliasAssigned: true,
|
||||
alias: [],
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// When stderr is not a TTY we expect 5 progress lines to be printed
|
||||
client.stderr.isTTY = false;
|
||||
|
||||
client.setArgv('deploy', '--archive=tgz');
|
||||
const uploadingLines: string[] = [];
|
||||
client.stderr.on('data', data => {
|
||||
if (data.startsWith('Uploading [')) {
|
||||
uploadingLines.push(data);
|
||||
}
|
||||
});
|
||||
client.stderr.resume();
|
||||
const exitCode = await deploy(client);
|
||||
expect(exitCode).toEqual(0);
|
||||
expect(body?.files?.length).toEqual(1);
|
||||
expect(body?.files?.[0].file).toEqual('.vercel/source.tgz');
|
||||
expect(uploadingLines.length).toEqual(5);
|
||||
expect(
|
||||
uploadingLines[0].startsWith('Uploading [--------------------]')
|
||||
).toEqual(true);
|
||||
expect(
|
||||
uploadingLines[1].startsWith('Uploading [=====---------------]')
|
||||
).toEqual(true);
|
||||
expect(
|
||||
uploadingLines[2].startsWith('Uploading [==========----------]')
|
||||
).toEqual(true);
|
||||
expect(
|
||||
uploadingLines[3].startsWith('Uploading [===============-----]')
|
||||
).toEqual(true);
|
||||
expect(
|
||||
uploadingLines[4].startsWith('Uploading [====================]')
|
||||
).toEqual(true);
|
||||
} finally {
|
||||
process.chdir(originalCwd);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -38,11 +38,11 @@ describe('list', () => {
|
||||
|
||||
await list(client);
|
||||
|
||||
const output = await readOutputStream(client, 4);
|
||||
const output = await readOutputStream(client, 6);
|
||||
|
||||
const { org } = pluckIdentifiersFromDeploymentList(output.split('\n')[0]);
|
||||
const header: string[] = parseSpacedTableRow(output.split('\n')[3]);
|
||||
const data: string[] = parseSpacedTableRow(output.split('\n')[4]);
|
||||
const { org } = pluckIdentifiersFromDeploymentList(output.split('\n')[2]);
|
||||
const header: string[] = parseSpacedTableRow(output.split('\n')[5]);
|
||||
const data: string[] = parseSpacedTableRow(output.split('\n')[6]);
|
||||
data.shift();
|
||||
|
||||
expect(org).toEqual(team[0].slug);
|
||||
@@ -81,11 +81,11 @@ describe('list', () => {
|
||||
client.setArgv('-S', user.username);
|
||||
await list(client);
|
||||
|
||||
const output = await readOutputStream(client, 4);
|
||||
const output = await readOutputStream(client, 6);
|
||||
|
||||
const { org } = pluckIdentifiersFromDeploymentList(output.split('\n')[0]);
|
||||
const header: string[] = parseSpacedTableRow(output.split('\n')[3]);
|
||||
const data: string[] = parseSpacedTableRow(output.split('\n')[4]);
|
||||
const { org } = pluckIdentifiersFromDeploymentList(output.split('\n')[2]);
|
||||
const header: string[] = parseSpacedTableRow(output.split('\n')[5]);
|
||||
const data: string[] = parseSpacedTableRow(output.split('\n')[6]);
|
||||
data.shift();
|
||||
|
||||
expect(org).toEqual(user.username);
|
||||
@@ -116,11 +116,11 @@ describe('list', () => {
|
||||
client.setArgv(deployment.name);
|
||||
await list(client);
|
||||
|
||||
const output = await readOutputStream(client, 4);
|
||||
const output = await readOutputStream(client, 6);
|
||||
|
||||
const { org } = pluckIdentifiersFromDeploymentList(output.split('\n')[0]);
|
||||
const header: string[] = parseSpacedTableRow(output.split('\n')[3]);
|
||||
const data: string[] = parseSpacedTableRow(output.split('\n')[4]);
|
||||
const { org } = pluckIdentifiersFromDeploymentList(output.split('\n')[2]);
|
||||
const header: string[] = parseSpacedTableRow(output.split('\n')[5]);
|
||||
const data: string[] = parseSpacedTableRow(output.split('\n')[6]);
|
||||
data.shift();
|
||||
|
||||
expect(org).toEqual(teamSlug || team[0].slug);
|
||||
|
||||
@@ -22,10 +22,10 @@ describe('project', () => {
|
||||
client.setArgv('project', 'ls');
|
||||
await projects(client);
|
||||
|
||||
const output = await readOutputStream(client, 2);
|
||||
const { org } = pluckIdentifiersFromDeploymentList(output.split('\n')[0]);
|
||||
const header: string[] = parseSpacedTableRow(output.split('\n')[2]);
|
||||
const data: string[] = parseSpacedTableRow(output.split('\n')[3]);
|
||||
const output = await readOutputStream(client, 3);
|
||||
const { org } = pluckIdentifiersFromDeploymentList(output.split('\n')[1]);
|
||||
const header: string[] = parseSpacedTableRow(output.split('\n')[3]);
|
||||
const data: string[] = parseSpacedTableRow(output.split('\n')[4]);
|
||||
data.pop();
|
||||
|
||||
expect(org).toEqual(user.username);
|
||||
@@ -47,10 +47,10 @@ describe('project', () => {
|
||||
client.setArgv('project', 'ls');
|
||||
await projects(client);
|
||||
|
||||
const output = await readOutputStream(client, 2);
|
||||
const { org } = pluckIdentifiersFromDeploymentList(output.split('\n')[0]);
|
||||
const header: string[] = parseSpacedTableRow(output.split('\n')[2]);
|
||||
const data: string[] = parseSpacedTableRow(output.split('\n')[3]);
|
||||
const output = await readOutputStream(client, 3);
|
||||
const { org } = pluckIdentifiersFromDeploymentList(output.split('\n')[1]);
|
||||
const header: string[] = parseSpacedTableRow(output.split('\n')[3]);
|
||||
const data: string[] = parseSpacedTableRow(output.split('\n')[4]);
|
||||
data.pop();
|
||||
|
||||
expect(org).toEqual(user.username);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/client",
|
||||
"version": "12.2.9",
|
||||
"version": "12.2.13",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"homepage": "https://vercel.com",
|
||||
@@ -43,7 +43,7 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/build-utils": "5.5.2",
|
||||
"@vercel/build-utils": "5.5.5",
|
||||
"@vercel/routing-utils": "2.0.2",
|
||||
"@zeit/fetch": "5.2.0",
|
||||
"async-retry": "1.2.3",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Agent } from 'https';
|
||||
import http from 'http';
|
||||
import https from 'https';
|
||||
import { Readable } from 'stream';
|
||||
import { EventEmitter } from 'events';
|
||||
import retry from 'async-retry';
|
||||
@@ -78,7 +79,9 @@ export async function* upload(
|
||||
debug('Building an upload list...');
|
||||
|
||||
const semaphore = new Sema(50, { capacity: 50 });
|
||||
const agent = new Agent({ keepAlive: true });
|
||||
const agent = apiUrl?.startsWith('https://')
|
||||
? new https.Agent({ keepAlive: true })
|
||||
: new http.Agent({ keepAlive: true });
|
||||
|
||||
shas.forEach((sha, index) => {
|
||||
const uploadProgress = uploads[index];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/frameworks",
|
||||
"version": "1.1.6",
|
||||
"version": "1.1.8",
|
||||
"main": "./dist/frameworks.js",
|
||||
"types": "./dist/frameworks.d.ts",
|
||||
"files": [
|
||||
|
||||
@@ -1792,9 +1792,15 @@ export const frameworks = [
|
||||
{
|
||||
path: 'sanity.config.js',
|
||||
},
|
||||
{
|
||||
path: 'sanity.config.jsx',
|
||||
},
|
||||
{
|
||||
path: 'sanity.config.ts',
|
||||
},
|
||||
{
|
||||
path: 'sanity.config.tsx',
|
||||
},
|
||||
],
|
||||
},
|
||||
settings: {
|
||||
@@ -1834,10 +1840,13 @@ export const frameworks = [
|
||||
website: 'https://hydrogen.shopify.dev',
|
||||
useRuntime: { src: 'package.json', use: '@vercel/hydrogen' },
|
||||
detectors: {
|
||||
every: [
|
||||
some: [
|
||||
{
|
||||
path: 'hydrogen.config.js',
|
||||
},
|
||||
{
|
||||
path: 'hydrogen.config.ts',
|
||||
},
|
||||
],
|
||||
},
|
||||
settings: {
|
||||
|
||||
8
packages/fs-detectors/logos/nx.svg
Normal file
8
packages/fs-detectors/logos/nx.svg
Normal file
@@ -0,0 +1,8 @@
|
||||
<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M49.8779 58.813L37.2099 39.0114L37.1908 55.6489L15.3588 18.8931H0V80.9427H15.187L15.2366 44.2328L36.8435 79.2977L49.8779 58.813Z" fill="white"/>
|
||||
<path d="M37.2137 34.8435H52.3817L52.416 34.6679V18.8931H37.229L37.2099 34.6679L37.2137 34.8435Z" fill="white"/>
|
||||
<path d="M75.8244 52.0458C72.1908 51.9769 68.9079 54.2048 67.6298 57.6069C69.7576 54.4249 73.809 53.1463 77.3779 54.5305C79.0267 55.2023 81.1947 56.2863 82.9122 55.7061C81.2787 53.4137 78.6393 52.0506 75.8244 52.0458Z" fill="#96D8E9"/>
|
||||
<path d="M93.0343 59.5114C93.0343 57.6527 92.0229 57.2214 89.9237 56.458C88.3664 55.916 86.5992 55.3053 85.313 53.6259C85.0611 53.2939 84.8282 52.9198 84.5802 52.5229C84.0244 51.4948 83.2707 50.5868 82.3626 49.8511C81.1374 48.9504 79.5305 48.5114 77.4466 48.5114C73.265 48.5144 69.4978 51.0384 67.9046 54.9046C69.9187 52.1099 73.2659 50.5956 76.6947 50.928C80.1235 51.2605 83.1175 53.3895 84.5572 56.5191C85.2766 57.706 86.6952 58.2728 88.0343 57.9084C90.084 57.4695 89.9427 59.4084 93.0382 60.0649L93.0343 59.5114Z" fill="#48C4E5"/>
|
||||
<path d="M99.7939 59.1145V59.0725C99.7481 46.7672 89.7595 36.2405 77.4466 36.2405C69.9264 36.2352 62.9091 40.0172 58.7786 46.3015L58.6985 46.1641L52.3779 36.2405L37.2137 36.2404L51.6221 58.8053L37.5611 80.9427H52.2901L58.6985 71.0992L65.2214 80.9427H79.9542L66.5954 59.9198C66.3737 59.5102 66.2533 59.0535 66.2443 58.5878C66.2433 55.6185 67.4224 52.7705 69.522 50.6708C71.6216 48.5712 74.4696 47.3921 77.4389 47.3931C83.6298 47.3931 84.6641 51.0954 86 52.8359C88.6374 56.271 93.9046 54.7672 93.9046 59.2481C93.9203 60.2981 94.4949 61.2599 95.4121 61.7713C96.3292 62.2827 97.4495 62.266 98.351 61.7274C99.2525 61.1889 99.7981 60.2103 99.7824 59.1603V59.1145H99.7939Z" fill="white"/>
|
||||
<path d="M99.8092 62.2824C99.9589 63.3289 99.8107 64.3964 99.3817 65.3626C98.542 67.3053 97.1412 66.6565 97.1412 66.6565C97.1412 66.6565 95.9351 66.0687 96.6679 64.9427C97.4809 63.687 99.0878 63.8321 99.8092 62.2824Z" fill="#022F56"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
3
packages/fs-detectors/logos/rush.svg
Normal file
3
packages/fs-detectors/logos/rush.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 7.2 KiB |
35
packages/fs-detectors/logos/turborepo-dark.svg
Normal file
35
packages/fs-detectors/logos/turborepo-dark.svg
Normal file
@@ -0,0 +1,35 @@
|
||||
<svg width="100" height="125" viewBox="0 0 100 125" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M40 0.0374222C25.8531 -0.46154 11.7078 4.02912 0 13.5094L7.80471 18C17.0735 11.0146 28.7797 8.02081 40 8.51977V0.0374222Z" fill="url(#paint0_linear_8_11)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M82 19.1224C72.2699 8.83673 59.6211 2.46939 46 1V9.32653C57.6764 11.2857 67.8927 16.6735 76.1626 25L82 19.1224Z" fill="url(#paint1_linear_8_11)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M100 60C99.5253 47 94.7753 34 86.701 23L81 29C87.6503 38.5001 91.451 49 91.9256 60H100Z" fill="url(#paint2_linear_8_11)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M86.701 102C94.7753 91.2973 99.5253 78.6487 100 66H91.9256C91.451 76.7027 87.6503 86.9189 81 96.1621L86.701 102Z" fill="url(#paint3_linear_8_11)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M46 124C59.135 122.531 72.2699 116.163 82 105.878L76.1626 100C67.8927 108.816 57.1886 114.204 46 115.673V124Z" fill="url(#paint4_linear_8_11)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 111.491C11.7078 120.971 25.8531 125.461 40 124.963V116.48C28.7797 116.979 17.561 113.985 7.80471 107L0 111.491Z" fill="url(#paint5_linear_8_11)"/>
|
||||
<path d="M19.9222 63C19.9222 65.6382 20.4182 68.0713 21.4084 70.299C22.3987 72.5267 23.7403 74.4614 25.4299 76.103C27.1196 77.7446 29.0732 79.0343 31.2875 79.9724C33.5605 80.8518 35.9495 81.2915 38.4563 81.2915C40.963 81.2915 43.3235 80.8518 45.5377 79.9724C47.8108 79.0343 49.793 77.7446 51.4826 76.103C53.2311 74.4614 54.6014 72.5267 55.5916 70.299C56.5819 68.0713 57.0778 65.6382 57.0778 63C57.0778 60.3618 56.5819 57.9288 55.5916 55.701C54.6014 53.4733 53.2311 51.5386 51.4826 49.897C49.793 48.2554 47.8108 46.995 45.5377 46.1156C43.3235 45.1775 40.963 44.7085 38.4563 44.7085C35.9495 44.7085 33.5605 45.1775 31.2875 46.1156C29.0732 46.995 27.1196 48.2554 25.4299 49.897C23.7403 51.5386 22.3987 53.4733 21.4084 55.701C20.4182 57.9288 19.9222 60.3618 19.9222 63ZM2 63C2 58.0754 2.90283 53.5025 4.71018 49.2814C6.51753 45.0016 9.02263 41.2789 12.2288 38.1131C15.4349 34.9472 19.2513 32.4849 23.6814 30.7261C28.1687 28.9087 33.0947 28 38.4563 28C43.7606 28 48.6565 28.9087 53.1437 30.7261C57.631 32.4849 61.4777 34.9472 64.6838 38.1131C67.9471 41.2789 70.4825 45.0016 72.2899 49.2814C74.0972 53.5025 75 58.0754 75 63C75 67.9246 74.0972 72.5267 72.2899 76.8065C70.4825 81.0276 67.9471 84.7211 64.6838 87.8869C61.4777 91.0528 57.631 93.5443 53.1437 95.3618C48.6565 97.1206 43.7606 98 38.4563 98C33.0947 98 28.1687 97.1206 23.6814 95.3618C19.2513 93.5443 15.4349 91.0528 12.2288 87.8869C9.02263 84.7211 6.51753 81.0276 4.71018 76.8065C2.90283 72.5267 2 67.9246 2 63Z" fill="white"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_8_11" x1="49.5117" y1="-6.94291e-08" x2="49.5117" y2="125.813" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1E90FF"/>
|
||||
<stop offset="1" stop-color="#FF1E56"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_8_11" x1="50.135" y1="0.473494" x2="50.135" y2="123.975" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1E90FF"/>
|
||||
<stop offset="1" stop-color="#FF1E56"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_8_11" x1="51.7888" y1="-0.0373877" x2="51.7888" y2="126.037" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1E90FF"/>
|
||||
<stop offset="1" stop-color="#FF1E56"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_8_11" x1="51.7888" y1="1.74712" x2="51.7888" y2="124.415" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1E90FF"/>
|
||||
<stop offset="1" stop-color="#FF1E56"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint4_linear_8_11" x1="50.135" y1="1.02464" x2="50.135" y2="124.526" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1E90FF"/>
|
||||
<stop offset="1" stop-color="#FF1E56"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint5_linear_8_11" x1="49.5117" y1="-0.812955" x2="49.5117" y2="125" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1E90FF"/>
|
||||
<stop offset="1" stop-color="#FF1E56"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.9 KiB |
35
packages/fs-detectors/logos/turborepo.svg
Normal file
35
packages/fs-detectors/logos/turborepo.svg
Normal file
@@ -0,0 +1,35 @@
|
||||
<svg width="100" height="125" viewBox="0 0 100 125" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M40 0.0374222C25.8531 -0.46154 11.7078 4.02912 0 13.5094L7.80471 18C17.0735 11.0146 28.7797 8.02081 40 8.51977V0.0374222Z" fill="url(#paint0_linear_8_11)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M82 19.1224C72.2699 8.83673 59.6211 2.46939 46 1V9.32653C57.6764 11.2857 67.8927 16.6735 76.1626 25L82 19.1224Z" fill="url(#paint1_linear_8_11)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M100 60C99.5253 47 94.7753 34 86.701 23L81 29C87.6503 38.5001 91.451 49 91.9256 60H100Z" fill="url(#paint2_linear_8_11)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M86.701 102C94.7753 91.2973 99.5253 78.6487 100 66H91.9256C91.451 76.7027 87.6503 86.9189 81 96.1621L86.701 102Z" fill="url(#paint3_linear_8_11)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M46 124C59.135 122.531 72.2699 116.163 82 105.878L76.1626 100C67.8927 108.816 57.1886 114.204 46 115.673V124Z" fill="url(#paint4_linear_8_11)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 111.491C11.7078 120.971 25.8531 125.461 40 124.963V116.48C28.7797 116.979 17.561 113.985 7.80471 107L0 111.491Z" fill="url(#paint5_linear_8_11)"/>
|
||||
<path d="M19.9222 63C19.9222 65.6382 20.4182 68.0713 21.4084 70.299C22.3987 72.5267 23.7403 74.4614 25.4299 76.103C27.1196 77.7446 29.0732 79.0343 31.2875 79.9724C33.5605 80.8518 35.9495 81.2915 38.4563 81.2915C40.963 81.2915 43.3235 80.8518 45.5377 79.9724C47.8108 79.0343 49.793 77.7446 51.4826 76.103C53.2311 74.4614 54.6014 72.5267 55.5916 70.299C56.5819 68.0713 57.0778 65.6382 57.0778 63C57.0778 60.3618 56.5819 57.9288 55.5916 55.701C54.6014 53.4733 53.2311 51.5386 51.4826 49.897C49.793 48.2554 47.8108 46.995 45.5377 46.1156C43.3235 45.1775 40.963 44.7085 38.4563 44.7085C35.9495 44.7085 33.5605 45.1775 31.2875 46.1156C29.0732 46.995 27.1196 48.2554 25.4299 49.897C23.7403 51.5386 22.3987 53.4733 21.4084 55.701C20.4182 57.9288 19.9222 60.3618 19.9222 63ZM2 63C2 58.0754 2.90283 53.5025 4.71018 49.2814C6.51753 45.0016 9.02263 41.2789 12.2288 38.1131C15.4349 34.9472 19.2513 32.4849 23.6814 30.7261C28.1687 28.9087 33.0947 28 38.4563 28C43.7606 28 48.6565 28.9087 53.1437 30.7261C57.631 32.4849 61.4777 34.9472 64.6838 38.1131C67.9471 41.2789 70.4825 45.0016 72.2899 49.2814C74.0972 53.5025 75 58.0754 75 63C75 67.9246 74.0972 72.5267 72.2899 76.8065C70.4825 81.0276 67.9471 84.7211 64.6838 87.8869C61.4777 91.0528 57.631 93.5443 53.1437 95.3618C48.6565 97.1206 43.7606 98 38.4563 98C33.0947 98 28.1687 97.1206 23.6814 95.3618C19.2513 93.5443 15.4349 91.0528 12.2288 87.8869C9.02263 84.7211 6.51753 81.0276 4.71018 76.8065C2.90283 72.5267 2 67.9246 2 63Z" fill="black"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_8_11" x1="49.5117" y1="-6.94291e-08" x2="49.5117" y2="125.813" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1E90FF"/>
|
||||
<stop offset="1" stop-color="#FF1E56"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_8_11" x1="50.135" y1="0.473494" x2="50.135" y2="123.975" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1E90FF"/>
|
||||
<stop offset="1" stop-color="#FF1E56"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_8_11" x1="51.7888" y1="-0.0373877" x2="51.7888" y2="126.037" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1E90FF"/>
|
||||
<stop offset="1" stop-color="#FF1E56"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_8_11" x1="51.7888" y1="1.74712" x2="51.7888" y2="124.415" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1E90FF"/>
|
||||
<stop offset="1" stop-color="#FF1E56"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint4_linear_8_11" x1="50.135" y1="1.02464" x2="50.135" y2="124.526" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1E90FF"/>
|
||||
<stop offset="1" stop-color="#FF1E56"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint5_linear_8_11" x1="49.5117" y1="-0.812955" x2="49.5117" y2="125" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1E90FF"/>
|
||||
<stop offset="1" stop-color="#FF1E56"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.9 KiB |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/fs-detectors",
|
||||
"version": "3.4.0",
|
||||
"version": "3.4.5",
|
||||
"description": "Vercel filesystem detectors",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -19,10 +19,11 @@
|
||||
"test-unit": "yarn test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/frameworks": "1.1.6",
|
||||
"@vercel/frameworks": "1.1.8",
|
||||
"@vercel/routing-utils": "2.0.2",
|
||||
"glob": "8.0.3",
|
||||
"js-yaml": "4.1.0",
|
||||
"json5": "2.2.1",
|
||||
"minimatch": "3.0.4",
|
||||
"semver": "6.1.1"
|
||||
},
|
||||
|
||||
@@ -14,11 +14,14 @@ import type { Framework } from '@vercel/frameworks';
|
||||
*
|
||||
*/
|
||||
export const monorepoManagers: Array<
|
||||
Omit<Framework, 'description' | 'logo' | 'settings' | 'getOutputDirName'>
|
||||
Omit<Framework, 'description' | 'getOutputDirName'>
|
||||
> = [
|
||||
{
|
||||
name: 'Turborepo',
|
||||
slug: 'turbo',
|
||||
logo: 'https://api-frameworks.vercel.sh/monorepo-logos/turborepo.svg',
|
||||
darkModeLogo:
|
||||
'https://api-frameworks.vercel.sh/monorepo-logos/turborepo-dark.svg',
|
||||
detectors: {
|
||||
some: [
|
||||
{
|
||||
@@ -30,10 +33,26 @@ export const monorepoManagers: Array<
|
||||
},
|
||||
],
|
||||
},
|
||||
settings: {
|
||||
buildCommand: {
|
||||
placeholder: 'Turborepo default',
|
||||
value: null,
|
||||
},
|
||||
outputDirectory: {
|
||||
value: null,
|
||||
},
|
||||
installCommand: {
|
||||
value: null,
|
||||
},
|
||||
devCommand: {
|
||||
value: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Nx',
|
||||
slug: 'nx',
|
||||
logo: 'https://api-frameworks.vercel.sh/monorepo-logos/nx.svg',
|
||||
detectors: {
|
||||
every: [
|
||||
{
|
||||
@@ -41,10 +60,26 @@ export const monorepoManagers: Array<
|
||||
},
|
||||
],
|
||||
},
|
||||
settings: {
|
||||
buildCommand: {
|
||||
placeholder: 'Nx default',
|
||||
value: null,
|
||||
},
|
||||
outputDirectory: {
|
||||
placeholder: 'Nx default',
|
||||
},
|
||||
installCommand: {
|
||||
value: null,
|
||||
},
|
||||
devCommand: {
|
||||
value: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Rush',
|
||||
slug: 'rush',
|
||||
logo: 'https://api-frameworks.vercel.sh/monorepo-logos/rush.svg',
|
||||
detectors: {
|
||||
every: [
|
||||
{
|
||||
@@ -52,6 +87,21 @@ export const monorepoManagers: Array<
|
||||
},
|
||||
],
|
||||
},
|
||||
settings: {
|
||||
buildCommand: {
|
||||
placeholder: 'Rush default',
|
||||
value: null,
|
||||
},
|
||||
outputDirectory: {
|
||||
placeholder: 'Rush default',
|
||||
},
|
||||
installCommand: {
|
||||
placeholder: 'Rush default',
|
||||
},
|
||||
devCommand: {
|
||||
value: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import _path from 'path';
|
||||
import yaml from 'js-yaml';
|
||||
import glob from 'glob';
|
||||
import json5 from 'json5';
|
||||
import { DetectorFilesystem } from '../detectors/filesystem';
|
||||
import { Workspace } from './get-workspaces';
|
||||
import { getGlobFs } from './get-glob-fs';
|
||||
@@ -144,7 +145,7 @@ async function getRushWorkspacePackagePaths({
|
||||
}: GetPackagePathOptions): Promise<string[]> {
|
||||
const rushWorkspaceAsBuffer = await fs.readFile('rush.json');
|
||||
|
||||
const { projects = [] } = JSON.parse(
|
||||
const { projects = [] } = json5.parse(
|
||||
rushWorkspaceAsBuffer.toString()
|
||||
) as RushWorkspaces;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json",
|
||||
|
||||
"rushVersion": "5.76.1",
|
||||
|
||||
"pnpmVersion": "6.7.1",
|
||||
|
||||
"pnpmOptions": {
|
||||
@@ -22,6 +21,7 @@
|
||||
|
||||
"postRushBuild": []
|
||||
},
|
||||
// comment
|
||||
"variants": [],
|
||||
"projects": [
|
||||
{
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
"nodeSupportedVersionRange": ">=12.13.0 <13.0.0 || >=14.15.0 <15.0.0 || >=16.13.0 <17.0.0",
|
||||
|
||||
"gitPolicy": {},
|
||||
|
||||
/*
|
||||
this is a comment
|
||||
*/
|
||||
"repository": {},
|
||||
"eventHooks": {
|
||||
"preRushInstall": [],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/go",
|
||||
"version": "2.2.10",
|
||||
"version": "2.2.13",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
|
||||
@@ -35,7 +35,7 @@
|
||||
"@types/jest": "28.1.6",
|
||||
"@types/node-fetch": "^2.3.0",
|
||||
"@types/tar": "^4.0.0",
|
||||
"@vercel/build-utils": "5.5.2",
|
||||
"@vercel/build-utils": "5.5.5",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"async-retry": "1.3.1",
|
||||
"execa": "^1.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/hydrogen",
|
||||
"version": "0.0.23",
|
||||
"version": "0.0.26",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"homepage": "https://vercel.com/docs",
|
||||
@@ -21,7 +21,7 @@
|
||||
"devDependencies": {
|
||||
"@types/jest": "27.5.1",
|
||||
"@types/node": "*",
|
||||
"@vercel/build-utils": "5.5.2",
|
||||
"@vercel/build-utils": "5.5.5",
|
||||
"typescript": "4.6.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/next",
|
||||
"version": "3.2.0",
|
||||
"version": "3.2.5",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
|
||||
@@ -44,7 +44,7 @@
|
||||
"@types/semver": "6.0.0",
|
||||
"@types/text-table": "0.2.1",
|
||||
"@types/webpack-sources": "3.2.0",
|
||||
"@vercel/build-utils": "5.5.2",
|
||||
"@vercel/build-utils": "5.5.5",
|
||||
"@vercel/nft": "0.22.1",
|
||||
"@vercel/routing-utils": "2.0.2",
|
||||
"async-sema": "3.0.1",
|
||||
|
||||
@@ -633,7 +633,7 @@ export async function serverBuild({
|
||||
const curPagesDir = isAppPath && appDir ? appDir : pagesDir;
|
||||
const pageDir = path.dirname(path.join(curPagesDir, originalPagePath));
|
||||
const normalizedBaseDir = `${baseDir}${
|
||||
baseDir.endsWith('/') ? '' : '/'
|
||||
baseDir.endsWith(path.sep) ? '' : path.sep
|
||||
}`;
|
||||
files.forEach((file: string) => {
|
||||
const absolutePath = path.join(pageDir, file);
|
||||
@@ -970,7 +970,9 @@ export async function serverBuild({
|
||||
// routes since only the status is being modified and we don't want
|
||||
// to exceed the routes limit
|
||||
const starterRouteSrc = `^${
|
||||
entryDirectory !== '.' ? path.posix.join('/', entryDirectory, '()') : '()'
|
||||
entryDirectory !== '.'
|
||||
? `${path.posix.join('/', entryDirectory)}()`
|
||||
: '()'
|
||||
}`;
|
||||
let currentRouteSrc = starterRouteSrc;
|
||||
|
||||
@@ -997,7 +999,7 @@ export async function serverBuild({
|
||||
const isLastRoute = i === prerenderManifest.notFoundRoutes.length - 1;
|
||||
|
||||
if (prerenderManifest.staticRoutes[route]?.initialRevalidate === false) {
|
||||
if (currentRouteSrc.length + route.length + 1 >= 4096) {
|
||||
if (currentRouteSrc.length + route.length + 1 >= 4000) {
|
||||
pushRoute(currentRouteSrc);
|
||||
currentRouteSrc = starterRouteSrc;
|
||||
}
|
||||
@@ -1134,7 +1136,7 @@ export async function serverBuild({
|
||||
if (appPathRoutesManifest) {
|
||||
// create .rsc variant for app lambdas and edge functions
|
||||
// to match prerenders so we can route the same when the
|
||||
// __flight__ header is present
|
||||
// __rsc__ header is present
|
||||
const edgeFunctions = middleware.edgeFunctions;
|
||||
|
||||
for (let route of Object.values(appPathRoutesManifest)) {
|
||||
@@ -1142,7 +1144,8 @@ export async function serverBuild({
|
||||
|
||||
if (lambdas[route]) {
|
||||
lambdas[`${route}.rsc`] = lambdas[route];
|
||||
} else if (edgeFunctions[route]) {
|
||||
}
|
||||
if (edgeFunctions[route]) {
|
||||
edgeFunctions[`${route}.rsc`] = edgeFunctions[route];
|
||||
}
|
||||
}
|
||||
@@ -1343,6 +1346,12 @@ export async function serverBuild({
|
||||
.join('|')})?[/]?404/?`,
|
||||
status: 404,
|
||||
continue: true,
|
||||
missing: [
|
||||
{
|
||||
type: 'header',
|
||||
key: 'x-prerender-revalidate',
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
: [
|
||||
@@ -1350,6 +1359,12 @@ export async function serverBuild({
|
||||
src: path.posix.join('/', entryDirectory, '404/?'),
|
||||
status: 404,
|
||||
continue: true,
|
||||
missing: [
|
||||
{
|
||||
type: 'header',
|
||||
key: 'x-prerender-revalidate',
|
||||
},
|
||||
],
|
||||
},
|
||||
]),
|
||||
|
||||
@@ -1388,12 +1403,23 @@ export async function serverBuild({
|
||||
|
||||
...(appDir
|
||||
? [
|
||||
{
|
||||
src: `^${path.posix.join('/', entryDirectory, '/')}`,
|
||||
has: [
|
||||
{
|
||||
type: 'header',
|
||||
key: '__rsc__',
|
||||
},
|
||||
],
|
||||
dest: path.posix.join('/', entryDirectory, '/index.rsc'),
|
||||
check: true,
|
||||
},
|
||||
{
|
||||
src: `^${path.posix.join('/', entryDirectory, '/(.*)$')}`,
|
||||
has: [
|
||||
{
|
||||
type: 'header',
|
||||
key: '__flight__',
|
||||
key: '__rsc__',
|
||||
},
|
||||
],
|
||||
dest: path.posix.join('/', entryDirectory, '/$1.rsc'),
|
||||
@@ -1497,18 +1523,31 @@ export async function serverBuild({
|
||||
dynamicRoutes
|
||||
.map(route => {
|
||||
route = Object.assign({}, route);
|
||||
let normalizedSrc = route.src;
|
||||
|
||||
if (routesManifest.basePath) {
|
||||
normalizedSrc = normalizedSrc.replace(
|
||||
new RegExp(
|
||||
`\\^${escapeStringRegexp(routesManifest.basePath)}`
|
||||
),
|
||||
'^'
|
||||
);
|
||||
}
|
||||
|
||||
route.src = path.posix.join(
|
||||
'^/',
|
||||
entryDirectory,
|
||||
'_next/data/',
|
||||
escapedBuildId,
|
||||
route.src.replace(/(^\^|\$$)/g, '') + '.json$'
|
||||
normalizedSrc
|
||||
.replace(/\^\(\?:\/\(\?</, '(?:(?<')
|
||||
.replace(/(^\^|\$$)/g, '') + '.json$'
|
||||
);
|
||||
|
||||
const { pathname, search } = new URL(
|
||||
route.dest || '/',
|
||||
'http://n'
|
||||
);
|
||||
const parsedDestination = new URL(route.dest || '/', 'http://n');
|
||||
let pathname = parsedDestination.pathname;
|
||||
const search = parsedDestination.search;
|
||||
|
||||
let isPrerender = !!prerenders[path.join('./', pathname)];
|
||||
|
||||
if (routesManifest.i18n) {
|
||||
@@ -1525,9 +1564,17 @@ export async function serverBuild({
|
||||
}
|
||||
|
||||
if (isPrerender) {
|
||||
route.dest = `/_next/data/${buildId}${pathname}.json${
|
||||
search || ''
|
||||
}`;
|
||||
if (routesManifest.basePath) {
|
||||
pathname = pathname.replace(
|
||||
new RegExp(
|
||||
`^${escapeStringRegexp(routesManifest.basePath)}`
|
||||
),
|
||||
''
|
||||
);
|
||||
}
|
||||
route.dest = `${
|
||||
routesManifest.basePath || ''
|
||||
}/_next/data/${buildId}${pathname}.json${search || ''}`;
|
||||
}
|
||||
return route;
|
||||
})
|
||||
@@ -1600,6 +1647,18 @@ export async function serverBuild({
|
||||
continue: true,
|
||||
important: true,
|
||||
},
|
||||
...(appDir
|
||||
? [
|
||||
{
|
||||
src: path.posix.join('/', entryDirectory, '/(.*).rsc$'),
|
||||
headers: {
|
||||
'content-type': 'application/octet-stream',
|
||||
},
|
||||
continue: true,
|
||||
important: true,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
|
||||
// TODO: remove below workaround when `/` is allowed to be output
|
||||
// different than `/index`
|
||||
|
||||
@@ -1698,7 +1698,6 @@ export const onPrerenderRoute =
|
||||
const {
|
||||
appDir,
|
||||
pagesDir,
|
||||
hasPages404,
|
||||
static404Page,
|
||||
entryDirectory,
|
||||
prerenderManifest,
|
||||
@@ -1896,11 +1895,12 @@ export const onPrerenderRoute =
|
||||
});
|
||||
}
|
||||
|
||||
// If revalidate isn't enabled we force the /404 route to be static
|
||||
// to match next start behavior otherwise getStaticProps would be
|
||||
// recalled for each 404 URL path since Prerender is cached based
|
||||
// on the URL path
|
||||
if (!canUsePreviewMode || (hasPages404 && routeKey === '/404')) {
|
||||
// if preview mode/On-Demand ISR can't be leveraged
|
||||
// we can output pure static outputs instead of prerenders
|
||||
if (
|
||||
!canUsePreviewMode ||
|
||||
(routeKey === '/404' && !lambdas[outputPathPage])
|
||||
) {
|
||||
htmlFsRef.contentType = htmlContentType;
|
||||
prerenders[outputPathPage] = htmlFsRef;
|
||||
prerenders[outputPathData] = jsonFsRef;
|
||||
|
||||
10
packages/next/test/fixtures/00-app-dir-edge/app/layout.js
vendored
Normal file
10
packages/next/test/fixtures/00-app-dir-edge/app/layout.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export default function Root({ children }) {
|
||||
return (
|
||||
<html>
|
||||
<head>
|
||||
<title>test app</title>
|
||||
</head>
|
||||
<body>{children}</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
/* eslint-env jest */
|
||||
const path = require('path');
|
||||
const { deployAndTest } = require('../../utils');
|
||||
|
||||
const ctx = {};
|
||||
|
||||
describe(`${__dirname.split(path.sep).pop()}`, () => {
|
||||
it('should deploy and pass probe checks', async () => {
|
||||
await deployAndTest(__dirname);
|
||||
const info = await deployAndTest(__dirname);
|
||||
Object.assign(ctx, info);
|
||||
});
|
||||
});
|
||||
@@ -10,6 +10,49 @@
|
||||
"path": "/edge",
|
||||
"status": 200,
|
||||
"mustContain": "edge"
|
||||
},
|
||||
{
|
||||
"path": "/edge",
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"__rsc__": "1"
|
||||
},
|
||||
"mustContain": "M1:{",
|
||||
"mustNotContain": "<html"
|
||||
},
|
||||
{
|
||||
"path": "/edge",
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"__rsc__": "1"
|
||||
},
|
||||
"responseHeaders": {
|
||||
"content-type": "application/octet-stream"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/",
|
||||
"status": 200,
|
||||
"mustContain": "page"
|
||||
},
|
||||
{
|
||||
"path": "/",
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"__rsc__": "1"
|
||||
},
|
||||
"mustContain": "M1:{",
|
||||
"mustNotContain": "<html"
|
||||
},
|
||||
{
|
||||
"path": "/",
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"__rsc__": "1"
|
||||
},
|
||||
"responseHeaders": {
|
||||
"content-type": "application/octet-stream"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'client';
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'client';
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'client';
|
||||
'use client';
|
||||
|
||||
export default function LazyComponent() {
|
||||
return (
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
'client';
|
||||
'use client';
|
||||
|
||||
import { useState, lazy } from 'react';
|
||||
|
||||
const Lazy = lazy(() => import('./lazy.js'));
|
||||
|
||||
export function ClientComponent() {
|
||||
let [state] = useState('client');
|
||||
let [state] = useState('use client');
|
||||
return (
|
||||
<>
|
||||
<Lazy />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'client';
|
||||
'use client';
|
||||
|
||||
export default function ShouldNotServeClientDotJs(props) {
|
||||
return (
|
||||
|
||||
@@ -15,23 +15,31 @@
|
||||
"path": "/dashboard",
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"__flight__": "1"
|
||||
"__rsc__": "1"
|
||||
},
|
||||
"mustContain": "M1:{",
|
||||
"mustNotContain": "<html"
|
||||
},
|
||||
{
|
||||
"path": "/dashboard",
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"__rsc__": "1"
|
||||
},
|
||||
"responseHeaders": {
|
||||
"content-type": "application/octet-stream"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/dashboard/another",
|
||||
"status": 200,
|
||||
"mustContain": "hello from newroot/dashboard/another"
|
||||
},
|
||||
// TODO: uncomment after this is fixed upstream
|
||||
// x-ref: https://vercel.slack.com/archives/C035J346QQL/p1663820032810519?thread_ts=1663775935.504379&cid=C035J346QQL
|
||||
// {
|
||||
// "path": "/dashboard/deployments/123",
|
||||
// "status": 200,
|
||||
// "mustContain": "hello from app/dashboard/deployments/[id]. ID is: <!-- -->123"
|
||||
// },
|
||||
{
|
||||
"path": "/dashboard/deployments/123",
|
||||
"status": 200,
|
||||
"mustContain": "hello from app/dashboard/deployments/[id]. ID is: <!-- -->123"
|
||||
},
|
||||
{
|
||||
"path": "/",
|
||||
"status": 200,
|
||||
@@ -42,16 +50,24 @@
|
||||
"status": 200,
|
||||
"mustContain": "hello from pages/blog/[slug]"
|
||||
},
|
||||
// TODO: uncomment after this is fixed upstream
|
||||
// {
|
||||
// "path": "/dynamic/category-1/id-1",
|
||||
// "status": 200,
|
||||
// "mustContain": "{"category":"category-1","id":"id-1"}"
|
||||
// },
|
||||
{
|
||||
"path": "/dynamic/category-1/id-1",
|
||||
"status": 200,
|
||||
"mustContain": "{"category":"category-1","id":"id-1"}"
|
||||
},
|
||||
{
|
||||
"path": "/dashboard/changelog",
|
||||
"status": 200,
|
||||
"mustContain": "hello from app/dashboard/changelog"
|
||||
},
|
||||
{
|
||||
"path": "/",
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"__rsc__": "1"
|
||||
},
|
||||
"mustContain": "M1:{",
|
||||
"mustNotContain": "<html"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
12
packages/next/test/fixtures/00-legacy-404/index.test.js
vendored
Normal file
12
packages/next/test/fixtures/00-legacy-404/index.test.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/* eslint-env jest */
|
||||
const path = require('path');
|
||||
const { deployAndTest } = require('../../utils');
|
||||
|
||||
const ctx = {};
|
||||
|
||||
describe(`${__dirname.split(path.sep).pop()}`, () => {
|
||||
it('should deploy and pass probe checks', async () => {
|
||||
const info = await deployAndTest(__dirname);
|
||||
Object.assign(ctx, info);
|
||||
});
|
||||
});
|
||||
7
packages/next/test/fixtures/00-legacy-404/package.json
vendored
Normal file
7
packages/next/test/fixtures/00-legacy-404/package.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"next": "9.5.5",
|
||||
"react": "17.0.2",
|
||||
"react-dom": "17.0.2"
|
||||
}
|
||||
}
|
||||
11
packages/next/test/fixtures/00-legacy-404/pages/404.js
vendored
Normal file
11
packages/next/test/fixtures/00-legacy-404/pages/404.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
export default function Page() {
|
||||
return <p>custom 404</p>;
|
||||
}
|
||||
|
||||
export function getStaticProps() {
|
||||
return {
|
||||
props: {
|
||||
is404: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
3
packages/next/test/fixtures/00-legacy-404/pages/api/hello.js
vendored
Normal file
3
packages/next/test/fixtures/00-legacy-404/pages/api/hello.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function handler(req, res) {
|
||||
return res.json({ hello: 'world' });
|
||||
}
|
||||
3
packages/next/test/fixtures/00-legacy-404/pages/index.js
vendored
Normal file
3
packages/next/test/fixtures/00-legacy-404/pages/index.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function Page() {
|
||||
return <p>index page</p>;
|
||||
}
|
||||
14
packages/next/test/fixtures/00-legacy-404/probes.json
vendored
Normal file
14
packages/next/test/fixtures/00-legacy-404/probes.json
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"probes": [
|
||||
{
|
||||
"path": "/",
|
||||
"status": 200,
|
||||
"mustContain": "index page"
|
||||
},
|
||||
{
|
||||
"path": "/non-existent",
|
||||
"status": 404,
|
||||
"mustContain": "custom 404"
|
||||
}
|
||||
]
|
||||
}
|
||||
127
packages/next/test/fixtures/00-middleware-base-path/index.test.js
vendored
Normal file
127
packages/next/test/fixtures/00-middleware-base-path/index.test.js
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
const path = require('path');
|
||||
const cheerio = require('cheerio');
|
||||
const { deployAndTest, check } = require('../../utils');
|
||||
const fetch = require('../../../../../test/lib/deployment/fetch-retry');
|
||||
|
||||
describe(`${__dirname.split(path.sep).pop()}`, () => {
|
||||
let ctx = {};
|
||||
|
||||
it('should deploy and pass probe checks', async () => {
|
||||
const info = await deployAndTest(__dirname);
|
||||
Object.assign(ctx, info);
|
||||
});
|
||||
|
||||
it('should revalidate content correctly for middleware rewrite', async () => {
|
||||
const propsFromHtml = async () => {
|
||||
let res = await fetch(
|
||||
`${ctx.deploymentUrl}/docs/rewrite-to-another-site`
|
||||
);
|
||||
let $ = cheerio.load(await res.text());
|
||||
let props = JSON.parse($('#props').text());
|
||||
return props;
|
||||
};
|
||||
let props = await propsFromHtml();
|
||||
expect(isNaN(props.now)).toBe(false);
|
||||
|
||||
const { pageProps: data } = await fetch(
|
||||
`${ctx.deploymentUrl}/docs/_next/data/testing-build-id/rewrite-to-another-site.json`
|
||||
).then(res => res.json());
|
||||
|
||||
expect(isNaN(data.now)).toBe(false);
|
||||
|
||||
const revalidateRes = await fetch(
|
||||
`${ctx.deploymentUrl}/docs/api/revalidate?urlPath=/docs/_sites/test-revalidate`
|
||||
);
|
||||
expect(revalidateRes.status).toBe(200);
|
||||
expect(await revalidateRes.json()).toEqual({ revalidated: true });
|
||||
|
||||
await check(async () => {
|
||||
const newProps = await propsFromHtml();
|
||||
console.log({ props, newProps });
|
||||
|
||||
if (isNaN(newProps.now)) {
|
||||
throw new Error();
|
||||
}
|
||||
return newProps.now !== props.now
|
||||
? 'success'
|
||||
: JSON.stringify({
|
||||
newProps,
|
||||
props,
|
||||
});
|
||||
}, 'success');
|
||||
|
||||
await check(async () => {
|
||||
const { pageProps: newData } = await fetch(
|
||||
`${ctx.deploymentUrl}/docs/_next/data/testing-build-id/rewrite-to-another-site.json`
|
||||
).then(res => res.json());
|
||||
|
||||
console.log({ newData, data });
|
||||
|
||||
if (isNaN(newData.now)) {
|
||||
throw new Error();
|
||||
}
|
||||
return newData.now !== data.now
|
||||
? 'success'
|
||||
: JSON.stringify({
|
||||
newData,
|
||||
data,
|
||||
});
|
||||
}, 'success');
|
||||
});
|
||||
|
||||
it('should revalidate content correctly for optional catch-all route', async () => {
|
||||
const propsFromHtml = async () => {
|
||||
let res = await fetch(`${ctx.deploymentUrl}/docs/financial`);
|
||||
let $ = cheerio.load(await res.text());
|
||||
let props = JSON.parse($('#props').text());
|
||||
return props;
|
||||
};
|
||||
let props = await propsFromHtml();
|
||||
expect(isNaN(props.now)).toBe(false);
|
||||
|
||||
const { pageProps: data } = await fetch(
|
||||
`${ctx.deploymentUrl}/docs/_next/data/testing-build-id/financial.json?slug=financial`
|
||||
).then(res => res.json());
|
||||
|
||||
expect(isNaN(data.now)).toBe(false);
|
||||
|
||||
const revalidateRes = await fetch(
|
||||
`${ctx.deploymentUrl}/docs/api/revalidate?urlPath=/docs/financial`
|
||||
);
|
||||
expect(revalidateRes.status).toBe(200);
|
||||
expect(await revalidateRes.json()).toEqual({ revalidated: true });
|
||||
|
||||
await check(async () => {
|
||||
const newProps = await propsFromHtml();
|
||||
console.log({ props, newProps });
|
||||
|
||||
if (isNaN(newProps.now)) {
|
||||
throw new Error();
|
||||
}
|
||||
return newProps.now !== props.now
|
||||
? 'success'
|
||||
: JSON.stringify({
|
||||
newProps,
|
||||
props,
|
||||
});
|
||||
}, 'success');
|
||||
|
||||
await check(async () => {
|
||||
const { pageProps: newData } = await fetch(
|
||||
`${ctx.deploymentUrl}/docs/_next/data/testing-build-id/financial.json?slug=financial`
|
||||
).then(res => res.json());
|
||||
|
||||
console.log({ newData, data });
|
||||
|
||||
if (isNaN(newData.now)) {
|
||||
throw new Error();
|
||||
}
|
||||
return newData.now !== data.now
|
||||
? 'success'
|
||||
: JSON.stringify({
|
||||
newData,
|
||||
data,
|
||||
});
|
||||
}, 'success');
|
||||
});
|
||||
});
|
||||
253
packages/next/test/fixtures/00-middleware-base-path/middleware.js
vendored
Normal file
253
packages/next/test/fixtures/00-middleware-base-path/middleware.js
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
const ALLOWED = ['allowed'];
|
||||
|
||||
export const config = {
|
||||
matcher: [
|
||||
'/dynamic/:path*',
|
||||
'/_sites/:path*',
|
||||
'/:teamId/:slug',
|
||||
'/:path*',
|
||||
'/',
|
||||
],
|
||||
};
|
||||
|
||||
export function middleware(request) {
|
||||
const url = request.nextUrl;
|
||||
const pathname = url.pathname;
|
||||
|
||||
if (process.env.FOO) {
|
||||
console.log(`Includes env variable ${process.env.FOO}`);
|
||||
}
|
||||
|
||||
if (url.pathname === '/redirect-me') {
|
||||
url.pathname = '/from-middleware';
|
||||
return NextResponse.redirect(url, 307);
|
||||
}
|
||||
|
||||
if (url.pathname === '/next') {
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
if (url.pathname === '/version') {
|
||||
return NextResponse.json({
|
||||
enumerable: Object.keys(self).includes('VercelRuntime'),
|
||||
version: self.VercelRuntime.version,
|
||||
});
|
||||
}
|
||||
|
||||
if (url.pathname === '/globals') {
|
||||
const globalThisKeys = Object.keys(globalThis);
|
||||
const globalKeys = globalThisKeys.reduce((acc, globalName) => {
|
||||
const key = globalName.toString();
|
||||
if (global[key]) acc.push(key);
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
const res = NextResponse.next();
|
||||
res.headers.set(
|
||||
'data',
|
||||
JSON.stringify({ globals: globalKeys, globalThis: globalThisKeys })
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
if (url.pathname === '/log') {
|
||||
console.log('hi there');
|
||||
return;
|
||||
}
|
||||
|
||||
if (url.pathname === '/somewhere') {
|
||||
url.pathname = '/from-middleware';
|
||||
return NextResponse.redirect(url);
|
||||
}
|
||||
|
||||
if (url.pathname === '/logs') {
|
||||
console.clear();
|
||||
for (let i = 0; i < 3; i++) console.count();
|
||||
console.count('test');
|
||||
console.count('test');
|
||||
console.dir({ hello: 'world' });
|
||||
console.log('hello');
|
||||
console.log('world');
|
||||
return;
|
||||
}
|
||||
|
||||
if (url.pathname === '/greetings') {
|
||||
const data = { message: 'hello world!' };
|
||||
const res = NextResponse.next();
|
||||
res.headers.set('x-example', 'edge');
|
||||
res.headers.set('data', JSON.stringify(data));
|
||||
return res;
|
||||
}
|
||||
|
||||
if (url.pathname === '/rewrite-me-to-about') {
|
||||
url.pathname = '/about';
|
||||
url.searchParams.set('middleware', 'foo');
|
||||
return NextResponse.rewrite(url);
|
||||
}
|
||||
|
||||
if (url.pathname === '/rewrite-to-site') {
|
||||
url.pathname = '/_sites/subdomain-1';
|
||||
console.log('rewriting to', url.pathname, url.href);
|
||||
return NextResponse.rewrite(url);
|
||||
}
|
||||
|
||||
if (url.pathname === '/rewrite-to-another-site') {
|
||||
url.pathname = '/_sites/test-revalidate';
|
||||
console.log('rewriting to', url.pathname, url.href);
|
||||
return NextResponse.rewrite(url);
|
||||
}
|
||||
|
||||
if (url.pathname === '/redirect-me-to-about') {
|
||||
url.pathname = '/about';
|
||||
url.searchParams.set('middleware', 'foo');
|
||||
return Response.redirect(url);
|
||||
}
|
||||
|
||||
if (url.pathname === '/rewrite-absolute') {
|
||||
return NextResponse.rewrite('https://example.vercel.sh/foo?foo=bar');
|
||||
}
|
||||
|
||||
if (url.pathname === '/rewrite-relative') {
|
||||
url.pathname = '/foo';
|
||||
url.searchParams.set('foo', 'bar');
|
||||
return NextResponse.rewrite(url);
|
||||
}
|
||||
|
||||
if (url.pathname === '/redirect-absolute') {
|
||||
return Response.redirect('https://vercel.com');
|
||||
}
|
||||
|
||||
if (url.pathname === '/redirect-301') {
|
||||
url.pathname = '/greetings';
|
||||
return NextResponse.redirect(url, 301);
|
||||
}
|
||||
|
||||
if (url.pathname === '/reflect') {
|
||||
const res = NextResponse.next();
|
||||
res.headers.set(
|
||||
'data',
|
||||
JSON.stringify({
|
||||
geo: request.geo,
|
||||
headers: Object.fromEntries(request.headers),
|
||||
ip: request.ip,
|
||||
method: request.method,
|
||||
nextUrl: {
|
||||
hash: request.nextUrl.hash,
|
||||
hostname: request.nextUrl.hostname,
|
||||
pathname: request.nextUrl.pathname,
|
||||
port: request.nextUrl.port,
|
||||
protocol: request.nextUrl.protocol,
|
||||
search: request.nextUrl.search,
|
||||
},
|
||||
url: request.url,
|
||||
})
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
if (url.pathname === '/stream-response') {
|
||||
const { readable, writable } = new TransformStream();
|
||||
const waitUntil = (async () => {
|
||||
const enc = new TextEncoder();
|
||||
const writer = writable.getWriter();
|
||||
writer.write(enc.encode('this is a streamed '));
|
||||
writer.write(enc.encode('response '));
|
||||
return writer.close();
|
||||
})();
|
||||
|
||||
return {
|
||||
waitUntil,
|
||||
response: NextResponse.next(),
|
||||
};
|
||||
}
|
||||
|
||||
if (url.pathname === '/throw-error') {
|
||||
const error = new Error('oh no!');
|
||||
console.log('This is not worker.js');
|
||||
console.error(error);
|
||||
return new Promise((_, reject) => reject(error));
|
||||
}
|
||||
|
||||
if (url.pathname === '/throw-error-internal') {
|
||||
function myFunctionName() {
|
||||
throw new Error('Oh no!');
|
||||
}
|
||||
|
||||
function anotherFunction() {
|
||||
return myFunctionName();
|
||||
}
|
||||
|
||||
try {
|
||||
anotherFunction();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
return new Promise((_, reject) => reject(new Error('oh no!')));
|
||||
}
|
||||
|
||||
if (url.pathname === '/unhandledrejection') {
|
||||
Promise.reject(new TypeError('captured unhandledrejection error.'));
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
if (pathname.startsWith('/query-params')) {
|
||||
if (pathname.endsWith('/clear')) {
|
||||
const strategy =
|
||||
url.searchParams.get('strategy') === 'rewrite' ? 'rewrite' : 'redirect';
|
||||
|
||||
for (const key of [...url.searchParams.keys()]) {
|
||||
if (!ALLOWED.includes(key)) {
|
||||
url.searchParams.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
const newPath = url.pathname.replace(/\/clear$/, '');
|
||||
url.pathname = newPath;
|
||||
|
||||
if (strategy === 'redirect') {
|
||||
return NextResponse.redirect(url);
|
||||
} else {
|
||||
return NextResponse.rewrite(url);
|
||||
}
|
||||
}
|
||||
|
||||
const obj = Object.fromEntries([...url.searchParams.entries()]);
|
||||
|
||||
const res = NextResponse.next();
|
||||
res.headers.set('data', JSON.stringify(obj));
|
||||
return res;
|
||||
}
|
||||
|
||||
if (pathname.startsWith('/home')) {
|
||||
if (!request.cookies.get('bucket')) {
|
||||
const bucket = Math.random() >= 0.5 ? 'a' : 'b';
|
||||
url.pathname = `/home/${bucket}`;
|
||||
const response = NextResponse.rewrite(url);
|
||||
response.cookies.set('bucket', bucket);
|
||||
return response;
|
||||
}
|
||||
|
||||
url.pathname = `/home/${request.cookies.get('bucket')}`;
|
||||
return NextResponse.rewrite(url);
|
||||
}
|
||||
|
||||
if (pathname.startsWith('/fetch-subrequest')) {
|
||||
const destinationUrl =
|
||||
url.searchParams.get('url') || 'https://example.vercel.sh';
|
||||
return fetch(destinationUrl, { headers: request.headers });
|
||||
}
|
||||
|
||||
if (url.pathname === '/dynamic/greet') {
|
||||
const res = NextResponse.next();
|
||||
res.headers.set(
|
||||
'data',
|
||||
JSON.stringify({
|
||||
message: url.searchParams.get('greeting') || 'Hi friend',
|
||||
})
|
||||
);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
39
packages/next/test/fixtures/00-middleware-base-path/next.config.js
vendored
Normal file
39
packages/next/test/fixtures/00-middleware-base-path/next.config.js
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
module.exports = {
|
||||
generateBuildId() {
|
||||
return 'testing-build-id';
|
||||
},
|
||||
basePath: '/docs',
|
||||
redirects() {
|
||||
return [
|
||||
{
|
||||
source: '/redirect-me',
|
||||
destination: '/from-next-config',
|
||||
permanent: false,
|
||||
},
|
||||
];
|
||||
},
|
||||
rewrites() {
|
||||
return {
|
||||
beforeFiles: [
|
||||
{
|
||||
source: '/rewrite-before-files',
|
||||
destination: '/somewhere',
|
||||
},
|
||||
],
|
||||
afterFiles: [
|
||||
{
|
||||
source: '/after-file-rewrite',
|
||||
destination: '/about',
|
||||
},
|
||||
{
|
||||
source: '/after-file-rewrite-auto-static',
|
||||
destination: '/home/a',
|
||||
},
|
||||
{
|
||||
source: '/after-file-rewrite-auto-static-dynamic',
|
||||
destination: '/dynamic/first',
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
};
|
||||
11
packages/next/test/fixtures/00-middleware-base-path/package.json
vendored
Normal file
11
packages/next/test/fixtures/00-middleware-base-path/package.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build"
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "canary",
|
||||
"react": "latest",
|
||||
"react-dom": "latest"
|
||||
}
|
||||
}
|
||||
111
packages/next/test/fixtures/00-middleware-base-path/pages/[[...slug]].js
vendored
Normal file
111
packages/next/test/fixtures/00-middleware-base-path/pages/[[...slug]].js
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
import Link from 'next/link';
|
||||
|
||||
export default function Page(props) {
|
||||
if (!props.params.slug) {
|
||||
return (
|
||||
<div>
|
||||
<h1>Demo</h1>
|
||||
<ul>
|
||||
<li>
|
||||
<Link href="/home">
|
||||
<a>A/B Testing</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/rewrite-me-to-about">
|
||||
<a>Rewrite to existing page</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/redirect-me-to-about">
|
||||
<a>Redirect to existing page</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/rewrite">
|
||||
<a>Rewrite to external site</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/redirect">
|
||||
<a>Redirect to external site</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/greetings">
|
||||
<a>Respond with JSON</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/stream-response">
|
||||
<a>Respond with Stream</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/dynamic/greet?greeting=hola">
|
||||
<a>Dynamic Nested Middleware</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/eval">
|
||||
<a>do a eval</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/logs">
|
||||
<a>print some logs</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/fetch">
|
||||
<a>perform a fetch</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/throw-error">
|
||||
<a>throw an error</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/throw-error-internal">
|
||||
<a>throw a controller error</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/timeout">
|
||||
<a>simulate timeout</a>
|
||||
</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<p id="page">[[..slug]]</p>
|
||||
<p id="props">{JSON.stringify(props)}</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function getStaticPaths() {
|
||||
return {
|
||||
paths: ['/somewhere'],
|
||||
fallback: 'blocking',
|
||||
};
|
||||
}
|
||||
|
||||
export function getStaticProps({ params }) {
|
||||
if (params.slug?.[0] === 'somewhere' && params.slug.length === 1) {
|
||||
return {
|
||||
notFound: true,
|
||||
};
|
||||
}
|
||||
return {
|
||||
props: {
|
||||
params,
|
||||
now: Date.now(),
|
||||
},
|
||||
};
|
||||
}
|
||||
3
packages/next/test/fixtures/00-middleware-base-path/pages/[teamId]/[slug].js
vendored
Normal file
3
packages/next/test/fixtures/00-middleware-base-path/pages/[teamId]/[slug].js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function Page() {
|
||||
return <p>/[teamId]/[slug]</p>;
|
||||
}
|
||||
31
packages/next/test/fixtures/00-middleware-base-path/pages/_sites/[site].js
vendored
Normal file
31
packages/next/test/fixtures/00-middleware-base-path/pages/_sites/[site].js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
export default function Page(props) {
|
||||
return (
|
||||
<>
|
||||
<p>/_sites/[site]</p>
|
||||
<p id="props">{JSON.stringify(props)}</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function getStaticProps({ params }) {
|
||||
return {
|
||||
props: {
|
||||
params,
|
||||
now: Date.now(),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function getStaticPaths() {
|
||||
return {
|
||||
paths: [
|
||||
{
|
||||
params: { site: 'subdomain-1' },
|
||||
},
|
||||
{
|
||||
params: { site: 'subdomain-2' },
|
||||
},
|
||||
],
|
||||
fallback: 'blocking',
|
||||
};
|
||||
}
|
||||
17
packages/next/test/fixtures/00-middleware-base-path/pages/about.js
vendored
Normal file
17
packages/next/test/fixtures/00-middleware-base-path/pages/about.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
export default function Main({ message, middleware }) {
|
||||
return (
|
||||
<div>
|
||||
<h1 className="title">About Page</h1>
|
||||
<p className={message}>{message}</p>
|
||||
<p className="middleware">{middleware}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export const getServerSideProps = ({ query }) => ({
|
||||
props: {
|
||||
middleware: query.middleware || '',
|
||||
message: query.message || '',
|
||||
page: 'about',
|
||||
},
|
||||
});
|
||||
4
packages/next/test/fixtures/00-middleware-base-path/pages/api/revalidate.js
vendored
Normal file
4
packages/next/test/fixtures/00-middleware-base-path/pages/api/revalidate.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export default async function handler(req, res) {
|
||||
await res.revalidate(req.query.urlPath);
|
||||
res.json({ revalidated: true });
|
||||
}
|
||||
3
packages/next/test/fixtures/00-middleware-base-path/pages/dynamic/[id]/index.js
vendored
Normal file
3
packages/next/test/fixtures/00-middleware-base-path/pages/dynamic/[id]/index.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function Index() {
|
||||
return <p className="title">Dynamic route</p>;
|
||||
}
|
||||
3
packages/next/test/fixtures/00-middleware-base-path/pages/dynamic/static.js
vendored
Normal file
3
packages/next/test/fixtures/00-middleware-base-path/pages/dynamic/static.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function Index() {
|
||||
return <p className="title">static route</p>;
|
||||
}
|
||||
16
packages/next/test/fixtures/00-middleware-base-path/pages/fetch-subrequest/index.js
vendored
Normal file
16
packages/next/test/fixtures/00-middleware-base-path/pages/fetch-subrequest/index.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
export default function Main({ message, middleware }) {
|
||||
return (
|
||||
<div>
|
||||
<h1 className="title">About Page</h1>
|
||||
<p className={message}>{message}</p>
|
||||
<p className="middleware">{middleware}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export const getServerSideProps = ({ query }) => ({
|
||||
props: {
|
||||
middleware: query.middleware || '',
|
||||
message: query.message || '',
|
||||
},
|
||||
});
|
||||
3
packages/next/test/fixtures/00-middleware-base-path/pages/home/a.js
vendored
Normal file
3
packages/next/test/fixtures/00-middleware-base-path/pages/home/a.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function Home() {
|
||||
return <h1>Home A</h1>;
|
||||
}
|
||||
3
packages/next/test/fixtures/00-middleware-base-path/pages/home/b.js
vendored
Normal file
3
packages/next/test/fixtures/00-middleware-base-path/pages/home/b.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function Home() {
|
||||
return <h1>Home B</h1>;
|
||||
}
|
||||
120
packages/next/test/fixtures/00-middleware-base-path/vercel.json
vendored
Normal file
120
packages/next/test/fixtures/00-middleware-base-path/vercel.json
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [
|
||||
{
|
||||
"src": "package.json",
|
||||
"use": "@vercel/next"
|
||||
}
|
||||
],
|
||||
"probes": [
|
||||
{
|
||||
"path": "/docs/_next/data/testing-build-id/dynamic/static.json",
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"x-nextjs-data": 1
|
||||
},
|
||||
"responseHeaders": {
|
||||
"x-matched-path": "/dynamic/static"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/docs/_next/data/testing-build-id/team-1/slug-1.json",
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"x-nextjs-data": 1
|
||||
},
|
||||
"responseHeaders": {
|
||||
"x-matched-path": "/[teamId]/[slug]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/docs/_next/data/testing-build-id/dynamic/id-1.json",
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"x-nextjs-data": 1
|
||||
},
|
||||
"responseHeaders": {
|
||||
"x-matched-path": "/dynamic/[id]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/docs/_next/data/testing-build-id/rewrite-to-site.json",
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"x-nextjs-data": 1
|
||||
},
|
||||
"mustContain": "site\":\"subdomain-1\"",
|
||||
"mustNotContain": "<html>"
|
||||
},
|
||||
{
|
||||
"path": "/docs/redirect-me",
|
||||
"status": 307,
|
||||
"responseHeaders": {
|
||||
"Location": "/from-next-config/"
|
||||
},
|
||||
"fetchOptions": {
|
||||
"redirect": "manual"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/docs/rewrite-before-files",
|
||||
"status": 404,
|
||||
"fetchOptions": {
|
||||
"redirect": "manual"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/docs/somewhere",
|
||||
"status": 307,
|
||||
"responseHeaders": {
|
||||
"Location": "/from-middleware/"
|
||||
},
|
||||
"fetchOptions": {
|
||||
"redirect": "manual"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/docs/after-file-rewrite",
|
||||
"status": 200,
|
||||
"mustContain": "About Page"
|
||||
},
|
||||
{
|
||||
"path": "/docs/_next/data/testing-build-id/after-file-rewrite.json",
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"x-nextjs-data": "1"
|
||||
},
|
||||
"mustContain": "page\":\"about\""
|
||||
},
|
||||
{
|
||||
"path": "/docs/_next/data/testing-build-id/after-file-rewrite-auto-static-dynamic.json",
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"x-nextjs-data": "1"
|
||||
},
|
||||
"responseHeaders": {
|
||||
"x-matched-path": "/dynamic/[id]"
|
||||
},
|
||||
"mustContain": "{}"
|
||||
},
|
||||
{
|
||||
"path": "/docs/_next/data/testing-build-id/redirect-me.json",
|
||||
"status": 307,
|
||||
"fetchOptions": {
|
||||
"redirect": "manual"
|
||||
},
|
||||
"responseHeaders": {
|
||||
"Location": "/from-middleware/"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/docs/_next/data/testing-build-id/_sites/subdomain-1.json",
|
||||
"status": 200,
|
||||
"fetchOptions": {
|
||||
"redirect": "manual"
|
||||
},
|
||||
"mustNotContain": "<html>",
|
||||
"mustContain": "\"site\":\"subdomain-1\""
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -66,4 +66,60 @@ describe(`${__dirname.split(path.sep).pop()}`, () => {
|
||||
});
|
||||
}, 'success');
|
||||
});
|
||||
|
||||
it('should revalidate content correctly for optional catch-all route', async () => {
|
||||
const propsFromHtml = async () => {
|
||||
let res = await fetch(`${ctx.deploymentUrl}/financial`);
|
||||
let $ = cheerio.load(await res.text());
|
||||
let props = JSON.parse($('#props').text());
|
||||
return props;
|
||||
};
|
||||
let props = await propsFromHtml();
|
||||
expect(isNaN(props.now)).toBe(false);
|
||||
|
||||
const { pageProps: data } = await fetch(
|
||||
`${ctx.deploymentUrl}/_next/data/testing-build-id/financial.json?slug=financial`
|
||||
).then(res => res.json());
|
||||
|
||||
expect(isNaN(data.now)).toBe(false);
|
||||
|
||||
const revalidateRes = await fetch(
|
||||
`${ctx.deploymentUrl}/api/revalidate?urlPath=/financial`
|
||||
);
|
||||
expect(revalidateRes.status).toBe(200);
|
||||
expect(await revalidateRes.json()).toEqual({ revalidated: true });
|
||||
|
||||
await check(async () => {
|
||||
const newProps = await propsFromHtml();
|
||||
console.log({ props, newProps });
|
||||
|
||||
if (isNaN(newProps.now)) {
|
||||
throw new Error();
|
||||
}
|
||||
return newProps.now !== props.now
|
||||
? 'success'
|
||||
: JSON.stringify({
|
||||
newProps,
|
||||
props,
|
||||
});
|
||||
}, 'success');
|
||||
|
||||
await check(async () => {
|
||||
const { pageProps: newData } = await fetch(
|
||||
`${ctx.deploymentUrl}/_next/data/testing-build-id/financial.json?slug=financial`
|
||||
).then(res => res.json());
|
||||
|
||||
console.log({ newData, data });
|
||||
|
||||
if (isNaN(newData.now)) {
|
||||
throw new Error();
|
||||
}
|
||||
return newData.now !== data.now
|
||||
? 'success'
|
||||
: JSON.stringify({
|
||||
newData,
|
||||
data,
|
||||
});
|
||||
}, 'success');
|
||||
});
|
||||
});
|
||||
|
||||
111
packages/next/test/fixtures/00-middleware/pages/[[...slug]].js
vendored
Normal file
111
packages/next/test/fixtures/00-middleware/pages/[[...slug]].js
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
import Link from 'next/link';
|
||||
|
||||
export default function Page(props) {
|
||||
if (!props.params.slug) {
|
||||
return (
|
||||
<div>
|
||||
<h1>Demo</h1>
|
||||
<ul>
|
||||
<li>
|
||||
<Link href="/home">
|
||||
<a>A/B Testing</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/rewrite-me-to-about">
|
||||
<a>Rewrite to existing page</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/redirect-me-to-about">
|
||||
<a>Redirect to existing page</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/rewrite">
|
||||
<a>Rewrite to external site</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/redirect">
|
||||
<a>Redirect to external site</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/greetings">
|
||||
<a>Respond with JSON</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/stream-response">
|
||||
<a>Respond with Stream</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/dynamic/greet?greeting=hola">
|
||||
<a>Dynamic Nested Middleware</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/eval">
|
||||
<a>do a eval</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/logs">
|
||||
<a>print some logs</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/fetch">
|
||||
<a>perform a fetch</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/throw-error">
|
||||
<a>throw an error</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/throw-error-internal">
|
||||
<a>throw a controller error</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/timeout">
|
||||
<a>simulate timeout</a>
|
||||
</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<p id="page">[[..slug]]</p>
|
||||
<p id="props">{JSON.stringify(props)}</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function getStaticPaths() {
|
||||
return {
|
||||
paths: ['/somewhere'],
|
||||
fallback: 'blocking',
|
||||
};
|
||||
}
|
||||
|
||||
export function getStaticProps({ params }) {
|
||||
if (params.slug?.[0] === 'somewhere' && params.slug.length === 1) {
|
||||
return {
|
||||
notFound: true,
|
||||
};
|
||||
}
|
||||
return {
|
||||
props: {
|
||||
params,
|
||||
now: Date.now(),
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
import Link from 'next/link';
|
||||
|
||||
export default function Index() {
|
||||
return (
|
||||
<div>
|
||||
<h1>Demo</h1>
|
||||
<ul>
|
||||
<li>
|
||||
<Link href="/home">
|
||||
<a>A/B Testing</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/rewrite-me-to-about">
|
||||
<a>Rewrite to existing page</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/redirect-me-to-about">
|
||||
<a>Redirect to existing page</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/rewrite">
|
||||
<a>Rewrite to external site</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/redirect">
|
||||
<a>Redirect to external site</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/greetings">
|
||||
<a>Respond with JSON</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/stream-response">
|
||||
<a>Respond with Stream</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/dynamic/greet?greeting=hola">
|
||||
<a>Dynamic Nested Middleware</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/eval">
|
||||
<a>do a eval</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/logs">
|
||||
<a>print some logs</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/fetch">
|
||||
<a>perform a fetch</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/throw-error">
|
||||
<a>throw an error</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/throw-error-internal">
|
||||
<a>throw a controller error</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/timeout">
|
||||
<a>simulate timeout</a>
|
||||
</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-env jest */
|
||||
const path = require('path');
|
||||
const cheerio = require('cheerio');
|
||||
const { deployAndTest, check, waitFor } = require('../../utils');
|
||||
const { deployAndTest, check } = require('../../utils');
|
||||
const fetch = require('../../../../../test/lib/deployment/fetch-retry');
|
||||
|
||||
async function checkForChange(url, initialValue, getNewValue) {
|
||||
@@ -141,4 +141,30 @@ describe(`${__dirname.split(path.sep).pop()}`, () => {
|
||||
expect(preRevalidateRandom).toBeDefined();
|
||||
expect(preRevalidateRandomData).toBeDefined();
|
||||
});
|
||||
|
||||
it('should revalidate 404 page itself correctly', async () => {
|
||||
const initial404 = await fetch(`${ctx.deploymentUrl}/404`);
|
||||
const initial404Html = await initial404.text();
|
||||
const initial404Props = JSON.parse(
|
||||
cheerio.load(initial404Html)('#props').text()
|
||||
);
|
||||
expect(initial404.status).toBe(404);
|
||||
expect(initial404Props.is404).toBe(true);
|
||||
|
||||
const revalidateRes = await fetch(
|
||||
`${ctx.deploymentUrl}/api/revalidate?urlPath=/404`
|
||||
);
|
||||
expect(revalidateRes.status).toBe(200);
|
||||
expect(await revalidateRes.json()).toEqual({ revalidated: true });
|
||||
|
||||
await check(async () => {
|
||||
const res = await fetch(`${ctx.deploymentUrl}/404`);
|
||||
const resHtml = await res.text();
|
||||
const resProps = JSON.parse(cheerio.load(resHtml)('#props').text());
|
||||
expect(res.status).toBe(404);
|
||||
expect(resProps.is404).toBe(true);
|
||||
expect(resProps.time).not.toEqual(initial404Props.time);
|
||||
return 'success';
|
||||
}, 'success');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
export default function Page() {
|
||||
return <p>custom 404</p>;
|
||||
export default function Page(props) {
|
||||
return (
|
||||
<>
|
||||
<p>custom 404</p>
|
||||
<p id="props">{JSON.stringify(props)}</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function getStaticProps() {
|
||||
console.log('pages/404 getStaticProps');
|
||||
return {
|
||||
props: {
|
||||
is404: true,
|
||||
time: Date.now(),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
module.exports = {
|
||||
generateBuildId() {
|
||||
return 'testing-build-id';
|
||||
},
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"engines": {
|
||||
"node": "12.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "canary",
|
||||
"react": "^16.8.6",
|
||||
"react-dom": "^16.8.6",
|
||||
"firebase": "6.3.4"
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import firebase from 'firebase/app';
|
||||
import 'firebase/firestore';
|
||||
|
||||
if (!firebase.apps.length) {
|
||||
firebase.initializeApp({ projectId: 'noop' });
|
||||
}
|
||||
|
||||
const store = firebase.firestore();
|
||||
|
||||
const Comp = ({ results }) => {
|
||||
return <div>Hello Firebase: {results}</div>;
|
||||
};
|
||||
|
||||
Comp.getInitialProps = async () => {
|
||||
const query = await store.collection('users').get();
|
||||
return { results: query.size };
|
||||
};
|
||||
|
||||
export default Comp;
|
||||
@@ -1,19 +0,0 @@
|
||||
import firebase from 'firebase/app';
|
||||
import 'firebase/firestore';
|
||||
|
||||
if (!firebase.apps.length) {
|
||||
firebase.initializeApp({ projectId: 'noop' });
|
||||
}
|
||||
|
||||
const store = firebase.firestore();
|
||||
|
||||
const Comp = ({ results }) => {
|
||||
return <div>Hello Firebase: {results}</div>;
|
||||
};
|
||||
|
||||
Comp.getInitialProps = async () => {
|
||||
const query = await store.collection('users').get();
|
||||
return { results: query.size };
|
||||
};
|
||||
|
||||
export default Comp;
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [{ "src": "package.json", "use": "@vercel/next" }],
|
||||
"probes": [
|
||||
{ "path": "/nested/fb", "mustContain": "Hello Firebase: <!-- -->0" },
|
||||
{ "path": "/nested/moar/fb", "mustContain": "Hello Firebase: <!-- -->0" }
|
||||
]
|
||||
}
|
||||
@@ -36,7 +36,10 @@ it('should build with app-dir correctly', async () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should build with app-dir in edg runtime correctly', async () => {
|
||||
// TODO: re-enable after edge build failure is fixed in Next.js
|
||||
// Disabled Oct, 1st 2022
|
||||
// eslint-disable-next-line jest/no-disabled-tests
|
||||
it.skip('should build with app-dir in edge runtime correctly', async () => {
|
||||
const { buildResult } = await runBuildLambda(
|
||||
path.join(__dirname, '../fixtures/00-app-dir-edge')
|
||||
);
|
||||
@@ -315,9 +318,9 @@ it('Should build the gip-gsp-404 example', async () => {
|
||||
expect(routes[handleErrorIdx + 1].dest).toBe('/404');
|
||||
expect(routes[handleErrorIdx + 1].headers).toBe(undefined);
|
||||
expect(output['404']).toBeDefined();
|
||||
expect(output['404'].type).toBe('FileFsRef');
|
||||
expect(output['404'].type).toBe('Prerender');
|
||||
expect(output['_next/data/testing-build-id/404.json']).toBeDefined();
|
||||
expect(output['_next/data/testing-build-id/404.json'].type).toBe('FileFsRef');
|
||||
expect(output['_next/data/testing-build-id/404.json'].type).toBe('Prerender');
|
||||
const filePaths = Object.keys(output);
|
||||
const serverlessError = filePaths.some(filePath => filePath.match(/_error/));
|
||||
const hasUnderScoreAppStaticFile = filePaths.some(filePath =>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"foo": "bar"
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
const fs = require('fs-extra');
|
||||
const ms = require('ms');
|
||||
const path = require('path');
|
||||
const { build } = require('../../../../src');
|
||||
const { build } = require('../../../../dist');
|
||||
const { FileFsRef } = require('@vercel/build-utils');
|
||||
|
||||
jest.setTimeout(ms('6m'));
|
||||
@@ -12,6 +12,7 @@ describe(`${__dirname.split(path.sep).pop()}`, () => {
|
||||
'index.test.js',
|
||||
'next.config.js',
|
||||
'package.json',
|
||||
'data/strings.json',
|
||||
'pages/foo/bar/index.js',
|
||||
'pages/foo/index.js',
|
||||
'pages/index.js',
|
||||
@@ -38,9 +39,15 @@ describe(`${__dirname.split(path.sep).pop()}`, () => {
|
||||
|
||||
for (const page of pages) {
|
||||
expect(output).toHaveProperty(page);
|
||||
expect(path.resolve(output[page].fsPath)).toEqual(
|
||||
path.join(pagesDir, `${page}.html`)
|
||||
);
|
||||
if (page === 'index') {
|
||||
const { files, type } = output[page];
|
||||
expect(type).toEqual('Lambda');
|
||||
expect(files).toHaveProperty([path.join('data', 'strings.json')]);
|
||||
} else {
|
||||
expect(path.resolve(output[page].fsPath)).toEqual(
|
||||
path.join(pagesDir, `${page}.html`)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (const route of routes) {
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
export default function Page() {
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
export default function Page({ foo }) {
|
||||
return (
|
||||
<>
|
||||
<p>hello from pages</p>
|
||||
<p>hello from pages {foo}</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps() {
|
||||
const dataFile = path.join(process.cwd(), 'data', 'strings.json');
|
||||
const strings = JSON.parse(fs.readFileSync(dataFile));
|
||||
return {
|
||||
props: strings,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/node",
|
||||
"version": "2.5.20",
|
||||
"version": "2.5.25",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
|
||||
@@ -29,12 +29,12 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@edge-runtime/vm": "1.1.0-beta.32",
|
||||
"@edge-runtime/vm": "1.1.0-beta.36",
|
||||
"@types/node": "*",
|
||||
"@vercel/build-utils": "5.5.2",
|
||||
"@vercel/build-utils": "5.5.5",
|
||||
"@vercel/node-bridge": "3.0.0",
|
||||
"@vercel/static-config": "2.0.3",
|
||||
"edge-runtime": "1.1.0-beta.32",
|
||||
"edge-runtime": "1.1.0-beta.38",
|
||||
"esbuild": "0.14.47",
|
||||
"exit-hook": "2.2.1",
|
||||
"node-fetch": "2.6.7",
|
||||
|
||||
@@ -20,7 +20,7 @@ export type VercelResponse = ServerResponse & {
|
||||
export type VercelApiHandler = (
|
||||
req: VercelRequest,
|
||||
res: VercelResponse
|
||||
) => void;
|
||||
) => void | Promise<void>;
|
||||
|
||||
/** @deprecated Use VercelRequestCookies instead. */
|
||||
export type NowRequestCookies = VercelRequestCookies;
|
||||
|
||||
@@ -141,9 +141,11 @@ export function register(opts: Options = {}): Register {
|
||||
//eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const ts: typeof _ts = require_(compiler);
|
||||
if (compiler.startsWith(nowNodeBase)) {
|
||||
console.log('Using TypeScript ' + ts.version + ' (no local tsconfig.json)');
|
||||
console.log(
|
||||
`Using built-in TypeScript ${ts.version} since "typescript" missing from "devDependencies"`
|
||||
);
|
||||
} else {
|
||||
console.log('Using TypeScript ' + ts.version + ' (local user-provided)');
|
||||
console.log(`Using TypeScript ${ts.version} (local user-provided)`);
|
||||
}
|
||||
const transformers = options.transformers || undefined;
|
||||
const readFile = options.readFile || ts.sys.readFile;
|
||||
|
||||
8
packages/node/test/fixtures/15-helpers/ts/async-handler.ts
vendored
Normal file
8
packages/node/test/fixtures/15-helpers/ts/async-handler.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { VercelApiHandler } from './types';
|
||||
|
||||
const listener: VercelApiHandler = async (req, res) => {
|
||||
res.status(200);
|
||||
res.send('hello:RANDOMNESS_PLACEHOLDER');
|
||||
};
|
||||
|
||||
export default listener;
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/python",
|
||||
"version": "3.1.19",
|
||||
"version": "3.1.22",
|
||||
"main": "./dist/index.js",
|
||||
"license": "MIT",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
|
||||
@@ -22,7 +22,7 @@
|
||||
"devDependencies": {
|
||||
"@types/execa": "^0.9.0",
|
||||
"@types/jest": "27.4.1",
|
||||
"@vercel/build-utils": "5.5.2",
|
||||
"@vercel/build-utils": "5.5.5",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"execa": "^1.0.0",
|
||||
"typescript": "4.3.4"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/redwood",
|
||||
"version": "1.0.28",
|
||||
"version": "1.0.31",
|
||||
"main": "./dist/index.js",
|
||||
"license": "MIT",
|
||||
"homepage": "https://vercel.com/docs",
|
||||
@@ -27,6 +27,6 @@
|
||||
"@types/aws-lambda": "8.10.19",
|
||||
"@types/node": "*",
|
||||
"@types/semver": "6.0.0",
|
||||
"@vercel/build-utils": "5.5.2"
|
||||
"@vercel/build-utils": "5.5.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/remix",
|
||||
"version": "1.0.29",
|
||||
"version": "1.0.32",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"homepage": "https://vercel.com/docs",
|
||||
@@ -25,7 +25,7 @@
|
||||
"devDependencies": {
|
||||
"@types/jest": "27.5.1",
|
||||
"@types/node": "*",
|
||||
"@vercel/build-utils": "5.5.2",
|
||||
"@vercel/build-utils": "5.5.5",
|
||||
"typescript": "4.6.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@vercel/ruby",
|
||||
"author": "Nathan Cahill <nathan@nathancahill.com>",
|
||||
"version": "1.3.36",
|
||||
"version": "1.3.39",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/ruby",
|
||||
@@ -22,7 +22,7 @@
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "8.0.0",
|
||||
"@types/semver": "6.0.0",
|
||||
"@vercel/build-utils": "5.5.2",
|
||||
"@vercel/build-utils": "5.5.5",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"execa": "2.0.4",
|
||||
"fs-extra": "^7.0.1",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user