Compare commits

..

9 Commits

Author SHA1 Message Date
Steven
6e8935883b Publish Stable
- @vercel/build-utils@3.1.0
 - vercel@24.2.4
 - @vercel/client@11.0.3
 - @vercel/frameworks@0.9.1
 - @vercel/go@1.4.3
 - @vercel/next@2.8.66
 - @vercel/node-bridge@2.2.2
 - @vercel/node@1.15.3
 - @vercel/python@2.3.3
 - @vercel/redwood@0.8.3
 - @vercel/routing-utils@1.13.3
 - @vercel/ruby@1.3.6
 - @vercel/static-build@0.25.2
 - @vercel/static-config@1.0.1
2022-05-19 16:30:30 -04:00
Steven
1c3497dc74 Publish Canary
- vercel@24.2.4-canary.1
 - @vercel/next@2.8.66-canary.1
 - @vercel/node@1.15.3-canary.1
 - @vercel/redwood@0.8.3-canary.1
2022-05-19 16:18:29 -04:00
JJ Kasper
9836fdb5ca [next][node][redwood] Update to latest version of @vercel/nft (#7827)
### Related Issues

x-ref: https://github.com/vercel/nft/releases/tag/0.19.0

### 📋 Checklist

<!--
  Please keep your PR as a Draft until the checklist is complete
-->

#### Tests

- [ ] The code changed/added as part of this PR has been covered with tests
- [ ] All tests pass locally with `yarn test-unit`

#### Code Review

- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
2022-05-19 19:49:48 +00:00
JJ Kasper
d6f88f019f [next] Fix loading next launcher with type: module in package.json (#7828)
### Related Issues

Currently if you have a `package.json` with `type: 'module'` the launcher will fail to load as it is not using ESM and isn't using the `.cjs` extension. This corrects the extension per the below error message. 

```sh
ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/var/task/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
```

x-ref: https://github.com/vercel/next.js/issues/36903

### 📋 Checklist

<!--
  Please keep your PR as a Draft until the checklist is complete
-->

#### Tests

- [ ] The code changed/added as part of this PR has been covered with tests
- [ ] All tests pass locally with `yarn test-unit`

#### Code Review

- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
2022-05-19 19:23:29 +00:00
JJ Kasper
0f720472c4 [cli] Migrate Dev tests from ava to jest (#7822)
* Migrate ava cli dev tests to jest

* remove outdated test

* update tests

* Update utils

* update stdio to fix stalling

* test stdio tests

* add debug logs

* more logs

* use strip ansi

* update

* add exit flag and fix next dev test

* update timeout for mac ci

* update cancel

* update cancel tests.yml -> test.yml

* update other ids -> names

* remove outdated test

* de-dupe scripts

* remove redwood dev test due to size
2022-05-19 14:01:13 -05:00
JJ Kasper
8d0c5114e4 Update to latest version of turbo (#7829) 2022-05-19 13:35:26 -05:00
Nathan Rajlich
e3c4435606 [cli] Fix "now-dev-next" and "now-dev-static-build-routing" unit tests (#7824)
These two tests have been problematic on MacOS for a long time,
but now that we've re-introduced `@vercel/next` into this repo,
they've started to fail on Linux/Windows as well.

So the idea is to use the `devCommand` property so that
`@vercel/next` Builder doesn't get invoked at all.

Since the `devCommand` property was not yet being unit tested,
some logic in `vc build` needed to be adjusted in order to properly
shut down the dev command (via `tree-kill` module) when the
process was being stopped in order to cleanly shut down.
2022-05-19 09:27:51 -07:00
Steven
234c4dfa84 [tests] Update codeowners (#7825) 2022-05-19 11:43:27 -04:00
Nathan Rajlich
acd756436c [node] Fix 11-symlinks integration test fixture (#7823)
The `symlink` symlink wasn't being persisted through Turbo's cache,
so this test was failing. So move the symlink directly into the git repo
since there's no need to create it at build-time (git can store symlinks
just fine).

Additionally, the test itself was not testing that the symlink was indeed
re-created as a symlink from within the lambda environment (it actually
wasn't, due to the upload code not considering symlinks), so the test
has been updated to test for that as well.
2022-05-18 22:04:58 -07:00
90 changed files with 2289 additions and 14061 deletions

39
.github/CODEOWNERS vendored
View File

@@ -1,29 +1,26 @@
# Documentation
# https://help.github.com/en/articles/about-code-owners
* @TooTallNate
/.github/workflows @AndyBitz @styfle
/packages/frameworks @AndyBitz
/packages/cli/src/commands/build @TooTallNate @styfle @AndyBitz @gdborton @jaredpalmer
/packages/cli/src/commands/dev @TooTallNate @styfle @AndyBitz
/packages/cli/src/util/dev @TooTallNate @styfle @AndyBitz
* @TooTallNate @EndangeredMassa @styfle
/.github/workflows @TooTallNate @EndangeredMassa @styfle @ijjk
/packages/frameworks @TooTallNate @EndangeredMassa @styfle @AndyBitz
/packages/cli/src/commands/domains @javivelasco @mglagola @anatrajkovska
/packages/cli/src/commands/certs @javivelasco @mglagola @anatrajkovska
/packages/cli/src/commands/env @styfle @lucleray
/packages/client @styfle @TooTallNate
/packages/build-utils @styfle @AndyBitz @TooTallNate
/packages/client @TooTallNate @EndangeredMassa @styfle
/packages/build-utils @TooTallNate @EndangeredMassa @styfle @AndyBitz
/packages/middleware @gdborton @javivelasco
/packages/node @styfle @TooTallNate @lucleray
/packages/node-bridge @styfle @TooTallNate @lucleray
/packages/next @Timer @ijjk
/packages/go @styfle @TooTallNate
/packages/python @styfle @TooTallNate
/packages/ruby @styfle @TooTallNate
/packages/static-build @styfle @AndyBitz
/packages/routing-utils @styfle @dav-is @ijjk
/examples @mcsdevv
/packages/node @TooTallNate @EndangeredMassa @styfle
/packages/node-bridge @TooTallNate @EndangeredMassa @styfle @ijjk
/packages/next @TooTallNate @ijjk
/packages/go @TooTallNate @EndangeredMassa @styfle
/packages/python @TooTallNate @EndangeredMassa @styfle
/packages/ruby @TooTallNate @EndangeredMassa @styfle
/packages/static-build @TooTallNate @EndangeredMassa @styfle @AndyBitz
/packages/routing-utils @TooTallNate @EndangeredMassa @styfle @ijjk
/examples @leerob
/examples/create-react-app @Timer
/examples/nextjs @timneutkens @Timer
/examples/hugo @mcsdevv @styfle
/examples/jekyll @mcsdevv @styfle
/examples/zola @mcsdevv @styfle
/examples/nextjs @timneutkens @ijjk @styfle
/examples/hugo @styfle
/examples/jekyll @styfle
/examples/zola @styfle

View File

@@ -13,6 +13,5 @@ jobs:
steps:
- uses: styfle/cancel-workflow-action@0.9.1
with:
workflow_id: 849295, 849296, 849297, 849298
workflow_id: test.yml, test-integration-cli.yml, test-unit.yml
access_token: ${{ github.token }}

View File

@@ -1,47 +0,0 @@
name: Dev
on:
push:
branches:
- main
tags:
- '!*'
pull_request:
jobs:
test:
name: Dev
timeout-minutes: 75
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
node: [12]
runs-on: ${{ matrix.os }}
env:
TURBO_REMOTE_ONLY: true
TURBO_TEAM: vercel
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
steps:
- uses: actions/setup-go@v2
with:
go-version: '1.13.15'
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- uses: actions/checkout@v2
with:
fetch-depth: 100
- run: git --version
- run: git fetch origin main --depth=100
- run: git fetch origin ${{ github.ref }} --depth=100
- run: git diff origin/main...HEAD --name-only
- name: Install Hugo
if: matrix.os == 'macos-latest'
run: curl -L -O https://github.com/gohugoio/hugo/releases/download/v0.56.0/hugo_0.56.0_macOS-64bit.tar.gz && tar -xzf hugo_0.56.0_macOS-64bit.tar.gz && mv ./hugo packages/cli/test/dev/fixtures/08-hugo/
- run: yarn install --network-timeout 1000000
- run: yarn run build
- run: yarn test-integration-dev
env:
VERCEL_TEAM_TOKEN: ${{ secrets.VERCEL_TEAM_TOKEN }}
VERCEL_REGISTRATION_URL: ${{ secrets.VERCEL_REGISTRATION_URL }}

View File

@@ -26,7 +26,6 @@ jobs:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- run: yarn install --network-timeout 1000000
- id: set-tests
run: |
TESTS_ARRAY=$(node utils/chunk-tests.js $SCRIPT_NAME)
@@ -60,6 +59,11 @@ jobs:
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Install Hugo
if: matrix.runner == 'macos-latest'
run: curl -L -O https://github.com/gohugoio/hugo/releases/download/v0.56.0/hugo_0.56.0_macOS-64bit.tar.gz && tar -xzf hugo_0.56.0_macOS-64bit.tar.gz && mv ./hugo packages/cli/test/dev/fixtures/08-hugo/
- run: yarn install --network-timeout 1000000
- name: Build ${{matrix.packageName}} and all its dependencies

View File

@@ -31,7 +31,7 @@
"prettier": "2.6.2",
"ts-eager": "2.0.2",
"ts-jest": "28.0.0-next.1",
"turbo": "1.2.5"
"turbo": "1.2.9"
},
"scripts": {
"lerna": "lerna",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/build-utils",
"version": "3.0.2-canary.0",
"version": "3.1.0",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.js",
@@ -31,7 +31,7 @@
"@types/node-fetch": "^2.1.6",
"@types/semver": "6.0.0",
"@types/yazl": "2.4.2",
"@vercel/frameworks": "0.9.1-canary.0",
"@vercel/frameworks": "0.9.1",
"@vercel/ncc": "0.24.0",
"aggregate-error": "3.0.1",
"async-retry": "1.2.3",

View File

@@ -1,6 +1,6 @@
{
"name": "vercel",
"version": "24.2.4-canary.0",
"version": "24.2.4",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Vercel",
@@ -12,10 +12,10 @@
},
"scripts": {
"preinstall": "node ./scripts/preinstall.js",
"test": "jest --env node --verbose --runInBand --bail",
"test-unit": "yarn test",
"test": "jest --env node --verbose --runInBand --bail --forceExit",
"test-unit": "yarn test test/unit/",
"test-integration-cli": "rimraf test/fixtures/integration && ava test/integration.js --serial --fail-fast --verbose",
"test-integration-dev": "ava test/dev/integration.js --serial --fail-fast --verbose",
"test-integration-dev": "yarn test test/dev/",
"prepublishOnly": "yarn build",
"coverage": "codecov",
"build": "node -r ts-eager/register ./scripts/build.ts",
@@ -43,11 +43,11 @@
"node": ">= 12"
},
"dependencies": {
"@vercel/build-utils": "3.0.2-canary.0",
"@vercel/go": "1.4.3-canary.0",
"@vercel/node": "1.15.3-canary.0",
"@vercel/python": "2.3.3-canary.0",
"@vercel/ruby": "1.3.6-canary.0",
"@vercel/build-utils": "3.1.0",
"@vercel/go": "1.4.3",
"@vercel/node": "1.15.3",
"@vercel/python": "2.3.3",
"@vercel/ruby": "1.3.6",
"update-notifier": "4.1.0"
},
"devDependencies": {
@@ -90,8 +90,8 @@
"@types/update-notifier": "5.1.0",
"@types/which": "1.3.2",
"@types/write-json-file": "2.2.1",
"@vercel/client": "11.0.3-canary.0",
"@vercel/frameworks": "0.9.1-canary.0",
"@vercel/client": "11.0.3",
"@vercel/frameworks": "0.9.1",
"@vercel/ncc": "0.24.0",
"@zeit/fun": "0.11.2",
"@zeit/source-map-support": "0.6.2",

View File

@@ -89,6 +89,7 @@ import {
} from './types';
import { ProjectEnvVariable, ProjectSettings } from '../../types';
import exposeSystemEnvs from './expose-system-envs';
import { treeKill } from '../tree-kill';
const frontendRuntimeSet = new Set(
frameworkList.map(f => f.useRuntime?.use || '@vercel/static-build')
@@ -998,20 +999,7 @@ export default class DevServer {
}
if (devProcess) {
ops.push(
new Promise<void>((resolve, reject) => {
devProcess.once('exit', () => resolve());
try {
process.kill(devProcess.pid);
} catch (err) {
if (err.code === 'ESRCH') {
// Process already exited
return resolve();
}
reject(err);
}
})
);
ops.push(treeKill(devProcess.pid));
}
ops.push(close(this.server));
@@ -1052,12 +1040,7 @@ export default class DevServer {
const { debug } = this.output;
debug(`Killing builder dev server with PID ${pid}`);
this.devServerPids.delete(pid);
try {
process.kill(pid, 'SIGTERM');
debug(`Killed builder dev server with PID ${pid}`);
} catch (err) {
debug(`Failed to kill builder dev server with PID ${pid}: ${err}`);
}
await treeKill(pid);
}
async send404(
@@ -2120,7 +2103,7 @@ export default class DevServer {
.replace(/%PORT%/g, `${port}`);
this.output.debug(
`Starting dev command with parameters : ${JSON.stringify({
`Starting dev command with parameters: ${JSON.stringify({
cwd,
command,
port,
@@ -2152,6 +2135,7 @@ export default class DevServer {
cwd,
env,
});
this.devProcess = p;
if (!p.stdout || !p.stderr) {
throw new Error('Expected child process to have stdout and stderr');
@@ -2164,17 +2148,14 @@ export default class DevServer {
process.stdout.write(data.replace(proxyPort, devPort));
});
p.on('exit', (code: number) => {
if (code > 0) {
process.exit(code);
}
p.on('exit', (code, signal) => {
this.output.debug(`Dev command exited with "${signal || code}"`);
this.devProcessPort = undefined;
});
await checkForPort(port, 1000 * 60 * 5);
this.devProcessPort = port;
this.devProcess = p;
}
}

View File

@@ -1 +0,0 @@
ANOTHER_SECRET=runtime

View File

@@ -1 +0,0 @@
SECRET=buildtime

View File

@@ -1,7 +0,0 @@
.now
.vercel
.next
.idea
node_modules
!.env
!.env.build

View File

@@ -1,10 +0,0 @@
console.log({
SECRET: process.env.SECRET,
ANOTHER_SECRET: process.env.ANOTHER_SECRET,
});
module.exports = {
env: {
SECRET: process.env.SECRET,
},
};

View File

@@ -1,3 +0,0 @@
export default async (_req, res) => {
return res.end(process.env.ANOTHER_SECRET);
};

View File

@@ -1 +0,0 @@
export default () => <p>{process.env.SECRET}</p>;

View File

@@ -1,10 +0,0 @@
{
"build": {
"env": {
"SECRET": "@buildtime"
}
},
"env": {
"ANOTHER_SECRET": "@runtime"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +0,0 @@
module.exports = {
assetPrefix: '/blog',
env: {
ASSET_PREFIX: '/blog',
},
};

View File

@@ -1,10 +0,0 @@
{
"name": "with-zones-blog",
"version": "1.0.0",
"dependencies": {
"next": "latest",
"react": "latest",
"react-dom": "latest"
},
"license": "ISC"
}

View File

@@ -1,22 +0,0 @@
import Link from 'next/link';
export default function Blog() {
return (
<div>
<h3>This is our blog</h3>
<ul>
<li>
<Link href="/blog/post/[id]" as="/blog/post/1">
<a>Post 1</a>
</Link>
</li>
<li>
<Link href="/blog/post/[id]" as="/blog/post/2">
<a>Post 2</a>
</Link>
</li>
</ul>
<a href="/">Home</a>
</div>
);
}

View File

@@ -1,15 +0,0 @@
import Link from 'next/link'
import { useRouter } from 'next/router'
export default function Post() {
const router = useRouter()
return (
<div>
<h3>Post #{router.query.id}</h3>
<p>Lorem ipsum</p>
<Link href="/blog">
<a>Back to blog</a>
</Link>
</div>
)
}

View File

@@ -1,7 +0,0 @@
const Header = () => (
<div>
<h2>The Company</h2>
</div>
);
export default Header;

View File

@@ -1,10 +0,0 @@
{
"name": "with-zones-home",
"version": "1.0.0",
"dependencies": {
"next": "latest",
"react": "latest",
"react-dom": "latest"
},
"license": "ISC"
}

View File

@@ -1,21 +0,0 @@
import Link from 'next/link';
const About = ({ id }) => {
return (
<div>
<p>This is the {id} page with static props.</p>
<div>
<Link href="/">
<a>Go Back</a>
</Link>
</div>
</div>
);
};
export const getStaticProps = ({ params }) => {
return { props: { id: params.id } };
};
export const getStaticPaths = () => ({ paths: ['/1/dynamic'], fallback: true });
export default About;

View File

@@ -1,19 +0,0 @@
import Link from 'next/link';
import { useRouter } from 'next/router';
const About = () => {
const router = useRouter();
const { id } = router.query;
return (
<div>
<p>This is the {id} page without static props.</p>
<div>
<Link href="/">
<a>Go Back</a>
</Link>
</div>
</div>
);
};
export default About;

View File

@@ -1,19 +0,0 @@
import Link from 'next/link';
import { useRouter } from 'next/router';
const About = () => {
const router = useRouter();
const { id } = router.query;
return (
<div>
<p>This is the about static page.</p>
<div>
<Link href="/">
<a>Go Back</a>
</Link>
</div>
</div>
);
};
export default About;

View File

@@ -1,36 +0,0 @@
import Link from 'next/link';
import dynamic from 'next/dynamic';
const Header = dynamic(import('../components/Header'));
export default function Home() {
return (
<div>
<Header />
<p>This is our homepage</p>
<div>
<a href="/blog">Blog</a>
</div>
<div>
<Link href="/about">
<a>About us</a>
</Link>
</div>
<div>
<Link href="/foo">
<a>foo</a>
</Link>
</div>
<div>
<Link href="/1/dynamic">
<a>1/dynamic</a>
</Link>
</div>
<div>
<Link href="/1/foo">
<a>1/foo</a>
</Link>
</div>
</div>
);
}

View File

@@ -1,11 +0,0 @@
{
"name": "with-zones-example",
"private": true,
"workspaces": [
"home",
"blog"
],
"devDependencies": {
"vercel": "canary"
}
}

View File

@@ -1,12 +0,0 @@
{
"version": 2,
"builds": [
{ "src": "blog/package.json", "use": "@vercel/next@canary" },
{ "src": "home/package.json", "use": "@vercel/next@canary" }
],
"routes": [
{ "src": "/blog/_next(.*)", "dest": "blog/_next$1" },
{ "src": "/blog(.*)", "dest": "blog/blog$1" },
{ "src": "(.*)", "dest": "home$1" }
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,356 @@
import os from 'os';
import fs from 'fs-extra';
import { join } from 'path';
const {
exec,
fetch,
fixture,
testFixture,
testFixtureStdio,
} = require('./utils.js');
test('[vercel dev] prints `npm install` errors', async () => {
const dir = fixture('runtime-not-installed');
const result = await exec(dir);
expect(result.stderr.includes('npm ERR! 404')).toBeTruthy();
expect(
result.stderr.includes('Failed to install `vercel dev` dependencies')
).toBeTruthy();
expect(
result.stderr.includes('https://vercel.link/npm-install-failed-dev')
).toBeTruthy();
});
test('[vercel dev] `vercel.json` should be invalidated if deleted', async () => {
const dir = fixture('invalidate-vercel-config');
const configPath = join(dir, 'vercel.json');
const originalConfig = await fs.readJSON(configPath);
const { dev, port, readyResolver } = await testFixture(dir);
try {
await readyResolver;
{
// Env var should be set from `vercel.json`
const res = await fetch(`http://localhost:${port}/api`);
const body = await res.json();
expect(body.FOO).toBe('bar');
}
{
// Env var should not be set after `vercel.json` is deleted
await fs.remove(configPath);
const res = await fetch(`http://localhost:${port}/api`);
const body = await res.json();
expect(body.FOO).toBe(undefined);
}
} finally {
dev.kill('SIGTERM');
await fs.writeJSON(configPath, originalConfig);
}
});
test('[vercel dev] reflects changes to config and env without restart', async () => {
const dir = fixture('node-helpers');
const configPath = join(dir, 'vercel.json');
const originalConfig = await fs.readJSON(configPath);
const { dev, port, readyResolver } = await testFixture(dir);
try {
await readyResolver;
{
// Node.js helpers should be available by default
const res = await fetch(`http://localhost:${port}/?foo=bar`);
const body = await res.json();
expect(body.hasHelpers).toBe(true);
expect(body.query.foo).toBe('bar');
}
{
// Disable the helpers via `config.helpers = false`
const config = {
...originalConfig,
builds: [
{
...originalConfig.builds[0],
config: {
helpers: false,
},
},
],
};
await fs.writeJSON(configPath, config);
const res = await fetch(`http://localhost:${port}/?foo=bar`);
const body = await res.json();
expect(body.hasHelpers).toBe(false);
expect(body.query).toBe(undefined);
}
{
// Enable the helpers via `config.helpers = true`
const config = {
...originalConfig,
builds: [
{
...originalConfig.builds[0],
config: {
helpers: true,
},
},
],
};
await fs.writeJSON(configPath, config);
const res = await fetch(`http://localhost:${port}/?foo=baz`);
const body = await res.json();
expect(body.hasHelpers).toBe(true);
expect(body.query.foo).toBe('baz');
}
{
// Disable the helpers via `NODEJS_HELPERS = '0'`
const config = {
...originalConfig,
build: {
env: {
NODEJS_HELPERS: '0',
},
},
};
await fs.writeJSON(configPath, config);
const res = await fetch(`http://localhost:${port}/?foo=baz`);
const body = await res.json();
expect(body.hasHelpers).toBe(false);
expect(body.query).toBe(undefined);
}
{
// Enable the helpers via `NODEJS_HELPERS = '1'`
const config = {
...originalConfig,
build: {
env: {
NODEJS_HELPERS: '1',
},
},
};
await fs.writeJSON(configPath, config);
const res = await fetch(`http://localhost:${port}/?foo=boo`);
const body = await res.json();
expect(body.hasHelpers).toBe(true);
expect(body.query.foo).toBe('boo');
}
} finally {
dev.kill('SIGTERM');
await fs.writeJSON(configPath, originalConfig);
}
});
test('[vercel dev] `@vercel/node` TypeScript should be resolved by default', async () => {
// The purpose of this test is to test that `@vercel/node` can properly
// resolve the default "typescript" module when the project doesn't include
// its own version. To properly test for this, a fixture needs to be created
// *outside* of the `vercel` repo, since otherwise the root-level
// "node_modules/typescript" is resolved as relative to the project, and
// not relative to `@vercel/node` which is what we are testing for here.
const dir = join(os.tmpdir(), 'vercel-node-typescript-resolve-test');
const apiDir = join(dir, 'api');
await fs.mkdirp(apiDir);
await fs.writeFile(
join(apiDir, 'hello.js'),
'export default (req, res) => { res.end("world"); }'
);
const { dev, port, readyResolver } = await testFixture(dir);
try {
await readyResolver;
const res = await fetch(`http://localhost:${port}/api/hello`);
const body = await res.text();
expect(body).toBe('world');
} finally {
dev.kill('SIGTERM');
await fs.remove(dir);
}
});
test(
'[vercel dev] validate routes that use `check: true`',
testFixtureStdio('routes-check-true', async (testPath: any) => {
await testPath(200, '/blog/post', 'Blog Home');
})
);
test(
'[vercel dev] validate routes that use `check: true` and `status` code',
testFixtureStdio('routes-check-true-status', async (testPath: any) => {
await testPath(403, '/secret');
await testPath(200, '/post', 'This is a post.');
await testPath(200, '/post.html', 'This is a post.');
})
);
test(
'[vercel dev] validate routes that use custom 404 page',
testFixtureStdio('routes-custom-404', async (testPath: any) => {
await testPath(200, '/', 'Home Page');
await testPath(404, '/nothing', 'Custom User 404');
await testPath(404, '/exact', 'Exact Custom 404');
await testPath(200, '/api/hello', 'Hello');
await testPath(404, '/api/nothing', 'Custom User 404');
})
);
test(
'[vercel dev] handles miss after route',
testFixtureStdio('handle-miss-after-route', async (testPath: any) => {
await testPath(200, '/post', 'Blog Post Page', {
test: '1',
override: 'one',
});
})
);
test(
'[vercel dev] handles miss after rewrite',
testFixtureStdio('handle-miss-after-rewrite', async (testPath: any) => {
await testPath(200, '/post', 'Blog Post Page', {
test: '1',
override: 'one',
});
await testPath(200, '/blog/post', 'Blog Post Page', {
test: '1',
override: 'two',
});
await testPath(404, '/blog/about.html', undefined, {
test: '1',
override: 'two',
});
})
);
test(
'[vercel dev] does not display directory listing after 404',
testFixtureStdio('handle-miss-hide-dir-list', async (testPath: any) => {
await testPath(404, '/post');
await testPath(200, '/post/one.html', 'First Post');
})
);
test(
'[vercel dev] should preserve query string even after miss phase',
testFixtureStdio('handle-miss-querystring', async (testPath: any) => {
await testPath(200, '/', 'Index Page');
if (process.env.CI && process.platform === 'darwin') {
console.log('Skipping since GH Actions hangs for some reason');
} else {
await testPath(200, '/echo/first/second', 'a=first,b=second');
await testPath(200, '/functions/echo.js?a=one&b=two', 'a=one,b=two');
}
})
);
test(
'[vercel dev] handles hit after handle: filesystem',
testFixtureStdio('handle-hit-after-fs', async (testPath: any) => {
await testPath(200, '/blog.html', 'Blog Page', { test: '1' });
})
);
test(
'[vercel dev] handles hit after dest',
testFixtureStdio('handle-hit-after-dest', async (testPath: any) => {
await testPath(200, '/post', 'Blog Post', { test: '1', override: 'one' });
})
);
test(
'[vercel dev] handles hit after rewrite',
testFixtureStdio('handle-hit-after-rewrite', async (testPath: any) => {
await testPath(200, '/post', 'Blog Post', { test: '1', override: 'one' });
})
);
test(
'[vercel dev] should serve the public directory and api functions',
testFixtureStdio('public-and-api', async (testPath: any) => {
await testPath(200, '/', 'This is the home page');
await testPath(200, '/about.html', 'This is the about page');
await testPath(200, '/.well-known/humans.txt', 'We come in peace');
await testPath(200, '/api/date', /current date/);
await testPath(200, '/api/rand', /random number/);
await testPath(200, '/api/rand.js', /random number/);
await testPath(404, '/api/api', /NOT_FOUND/m);
await testPath(404, '/nothing', /Custom 404 Page/);
})
);
test(
'[vercel dev] should allow user rewrites for path segment files',
testFixtureStdio('test-zero-config-rewrite', async (testPath: any) => {
await testPath(404, '/');
await testPath(200, '/echo/1', '{"id":"1"}', {
'Access-Control-Allow-Origin': '*',
});
await testPath(200, '/echo/2', '{"id":"2"}', {
'Access-Control-Allow-Headers': '*',
});
})
);
test('[vercel dev] validate builds', async () => {
const directory = fixture('invalid-builds');
const output = await exec(directory);
expect(output.exitCode).toBe(1);
expect(output.stderr).toMatch(
/Invalid vercel\.json - `builds\[0\].src` should be string/m
);
});
test('[vercel dev] validate routes', async () => {
const directory = fixture('invalid-routes');
const output = await exec(directory);
expect(output.exitCode).toBe(1);
expect(output.stderr).toMatch(
/Invalid vercel\.json - `routes\[0\].src` should be string/m
);
});
test('[vercel dev] validate cleanUrls', async () => {
const directory = fixture('invalid-clean-urls');
const output = await exec(directory);
expect(output.exitCode).toBe(1);
expect(output.stderr).toMatch(
/Invalid vercel\.json - `cleanUrls` should be boolean/m
);
});
test('[vercel dev] validate trailingSlash', async () => {
const directory = fixture('invalid-trailing-slash');
const output = await exec(directory);
expect(output.exitCode).toBe(1);
expect(output.stderr).toMatch(
/Invalid vercel\.json - `trailingSlash` should be boolean/m
);
});
test('[vercel dev] validate rewrites', async () => {
const directory = fixture('invalid-rewrites');
const output = await exec(directory);
expect(output.exitCode).toBe(1);
expect(output.stderr).toMatch(
/Invalid vercel\.json - `rewrites\[0\].destination` should be string/m
);
});

View File

@@ -0,0 +1,336 @@
// eslint-disable-next-line
import path from 'path';
const { exec, fixture, testFixture, testFixtureStdio } = require('./utils.js');
test('[vercel dev] validate redirects', async () => {
const directory = fixture('invalid-redirects');
const output = await exec(directory);
expect(output.exitCode).toBe(1);
expect(output.stderr).toMatch(
/Invalid vercel\.json - `redirects\[0\].statusCode` should be integer/m
);
});
test('[vercel dev] validate headers', async () => {
const directory = fixture('invalid-headers');
const output = await exec(directory);
expect(output.exitCode).toBe(1);
expect(output.stderr).toMatch(
/Invalid vercel\.json - `headers\[0\].headers\[0\].value` should be string/m
);
});
test('[vercel dev] validate mixed routes and rewrites', async () => {
const directory = fixture('invalid-mixed-routes-rewrites');
const output = await exec(directory);
expect(output.exitCode).toBe(1);
expect(output.stderr).toMatch(
/If `rewrites`, `redirects`, `headers`, `cleanUrls` or `trailingSlash` are used, then `routes` cannot be present./m
);
expect(output.stderr).toMatch(/vercel\.link\/mix-routing-props/m);
});
// Test seems unstable: It won't return sometimes.
test('[vercel dev] validate env var names', async () => {
const directory = fixture('invalid-env-var-name');
const { dev } = await testFixture(directory, { stdio: 'pipe' });
try {
let stderr = '';
dev.stderr.setEncoding('utf8');
await new Promise<void>((resolve, reject) => {
dev.stderr.on('data', (b: any) => {
stderr += b.toString();
if (
stderr.includes('Ignoring env var "1" because name is invalid') &&
stderr.includes(
'Ignoring build env var "_a" because name is invalid'
) &&
stderr.includes(
'Env var names must start with letters, and can only contain alphanumeric characters and underscores'
)
) {
resolve();
}
});
dev.on('error', reject);
dev.on('exit', resolve);
});
} finally {
dev.kill('SIGTERM');
}
});
test(
'[vercel dev] test rewrites with segments serve correct content',
testFixtureStdio('test-rewrites-with-segments', async (testPath: any) => {
await testPath(200, '/api/users/first', 'first');
await testPath(200, '/api/fourty-two', '42');
await testPath(200, '/rand', '42');
await testPath(200, '/api/dynamic', 'dynamic');
await testPath(404, '/api');
})
);
test(
'[vercel dev] test rewrites serve correct content',
testFixtureStdio('test-rewrites', async (testPath: any) => {
await testPath(200, '/hello', 'Hello World');
})
);
test(
'[vercel dev] test rewrites and redirects serve correct external content',
testFixtureStdio(
'test-external-rewrites-and-redirects',
async (testPath: any) => {
const vcRobots = `https://vercel.com/robots.txt`;
await testPath(200, '/rewrite', /User-Agent: \*/m);
await testPath(308, '/redirect', `Redirecting to ${vcRobots} (308)`, {
Location: vcRobots,
});
await testPath(307, '/tempRedirect', `Redirecting to ${vcRobots} (307)`, {
Location: vcRobots,
});
}
)
);
test(
'[vercel dev] test rewrites and redirects is case sensitive',
testFixtureStdio('test-routing-case-sensitive', async (testPath: any) => {
await testPath(200, '/Path', 'UPPERCASE');
await testPath(200, '/path', 'lowercase');
await testPath(308, '/GoTo', 'Redirecting to /upper.html (308)', {
Location: '/upper.html',
});
await testPath(308, '/goto', 'Redirecting to /lower.html (308)', {
Location: '/lower.html',
});
})
);
test(
'[vercel dev] test cleanUrls serve correct content',
testFixtureStdio('test-clean-urls', async (testPath: any) => {
await testPath(200, '/', 'Index Page');
await testPath(200, '/about', 'About Page');
await testPath(200, '/sub', 'Sub Index Page');
await testPath(200, '/sub/another', 'Sub Another Page');
await testPath(200, '/style.css', 'body { color: green }');
await testPath(308, '/index.html', 'Redirecting to / (308)', {
Location: '/',
});
await testPath(308, '/about.html', 'Redirecting to /about (308)', {
Location: '/about',
});
await testPath(308, '/sub/index.html', 'Redirecting to /sub (308)', {
Location: '/sub',
});
await testPath(
308,
'/sub/another.html',
'Redirecting to /sub/another (308)',
{ Location: '/sub/another' }
);
})
);
test(
'[vercel dev] test cleanUrls serve correct content when using `outputDirectory`',
testFixtureStdio(
'test-clean-urls-with-output-directory',
async (testPath: any) => {
await testPath(200, '/', 'Index Page');
await testPath(200, '/about', 'About Page');
await testPath(200, '/sub', 'Sub Index Page');
await testPath(200, '/sub/another', 'Sub Another Page');
await testPath(200, '/style.css', 'body { color: green }');
await testPath(308, '/index.html', 'Redirecting to / (308)', {
Location: '/',
});
await testPath(308, '/about.html', 'Redirecting to /about (308)', {
Location: '/about',
});
await testPath(308, '/sub/index.html', 'Redirecting to /sub (308)', {
Location: '/sub',
});
await testPath(
308,
'/sub/another.html',
'Redirecting to /sub/another (308)',
{ Location: '/sub/another' }
);
}
)
);
test(
'[vercel dev] should serve custom 404 when `cleanUrls: true`',
testFixtureStdio('test-clean-urls-custom-404', async (testPath: any) => {
await testPath(200, '/', 'This is the home page');
await testPath(200, '/about', 'The about page');
await testPath(200, '/contact/me', 'Contact Me Subdirectory');
await testPath(404, '/nothing', 'Custom 404 Page');
await testPath(404, '/nothing/', 'Custom 404 Page');
})
);
test(
'[vercel dev] test cleanUrls and trailingSlash serve correct content',
testFixtureStdio('test-clean-urls-trailing-slash', async (testPath: any) => {
await testPath(200, '/', 'Index Page');
await testPath(200, '/about/', 'About Page');
await testPath(200, '/sub/', 'Sub Index Page');
await testPath(200, '/sub/another/', 'Sub Another Page');
await testPath(200, '/style.css', 'body { color: green }');
//TODO: fix this test so that location is `/` instead of `//`
//await testPath(308, '/index.html', 'Redirecting to / (308)', { Location: '/' });
await testPath(308, '/about.html', 'Redirecting to /about/ (308)', {
Location: '/about/',
});
await testPath(308, '/sub/index.html', 'Redirecting to /sub/ (308)', {
Location: '/sub/',
});
await testPath(
308,
'/sub/another.html',
'Redirecting to /sub/another/ (308)',
{
Location: '/sub/another/',
}
);
})
);
test(
'[vercel dev] test cors headers work with OPTIONS',
testFixtureStdio('test-cors-routes', async (testPath: any) => {
const headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers':
'Content-Type, Authorization, Accept, Content-Length, Origin, User-Agent',
'Access-Control-Allow-Methods':
'GET, POST, OPTIONS, HEAD, PATCH, PUT, DELETE',
};
await testPath(200, '/', 'status api', headers, { method: 'GET' });
await testPath(200, '/', 'status api', headers, { method: 'POST' });
await testPath(200, '/api/status.js', 'status api', headers, {
method: 'GET',
});
await testPath(200, '/api/status.js', 'status api', headers, {
method: 'POST',
});
await testPath(204, '/', '', headers, { method: 'OPTIONS' });
await testPath(204, '/api/status.js', '', headers, { method: 'OPTIONS' });
})
);
test(
'[vercel dev] test trailingSlash true serve correct content',
testFixtureStdio('test-trailing-slash', async (testPath: any) => {
await testPath(200, '/', 'Index Page');
await testPath(200, '/index.html', 'Index Page');
await testPath(200, '/about.html', 'About Page');
await testPath(200, '/sub/', 'Sub Index Page');
await testPath(200, '/sub/index.html', 'Sub Index Page');
await testPath(200, '/sub/another.html', 'Sub Another Page');
await testPath(200, '/style.css', 'body { color: green }');
await testPath(308, '/about.html/', 'Redirecting to /about.html (308)', {
Location: '/about.html',
});
await testPath(308, '/style.css/', 'Redirecting to /style.css (308)', {
Location: '/style.css',
});
await testPath(308, '/sub', 'Redirecting to /sub/ (308)', {
Location: '/sub/',
});
})
);
test(
'[vercel dev] should serve custom 404 when `trailingSlash: true`',
testFixtureStdio('test-trailing-slash-custom-404', async (testPath: any) => {
await testPath(200, '/', 'This is the home page');
await testPath(200, '/about.html', 'The about page');
await testPath(200, '/contact/', 'Contact Subdirectory');
await testPath(404, '/nothing/', 'Custom 404 Page');
})
);
test(
'[vercel dev] test trailingSlash false serve correct content',
testFixtureStdio('test-trailing-slash-false', async (testPath: any) => {
await testPath(200, '/', 'Index Page');
await testPath(200, '/index.html', 'Index Page');
await testPath(200, '/about.html', 'About Page');
await testPath(200, '/sub', 'Sub Index Page');
await testPath(200, '/sub/index.html', 'Sub Index Page');
await testPath(200, '/sub/another.html', 'Sub Another Page');
await testPath(200, '/style.css', 'body { color: green }');
await testPath(308, '/about.html/', 'Redirecting to /about.html (308)', {
Location: '/about.html',
});
await testPath(308, '/sub/', 'Redirecting to /sub (308)', {
Location: '/sub',
});
await testPath(
308,
'/sub/another.html/',
'Redirecting to /sub/another.html (308)',
{
Location: '/sub/another.html',
}
);
})
);
test(
'[vercel dev] throw when invalid builder routes detected',
testFixtureStdio(
'invalid-builder-routes',
async (testPath: any) => {
await testPath(
500,
'/',
/Route at index 0 has invalid `src` regular expression/m
);
},
{ skipDeploy: true }
)
);
test(
'[vercel dev] support legacy `@now` scope runtimes',
testFixtureStdio('legacy-now-runtime', async (testPath: any) => {
await testPath(200, '/', /A simple deployment with the Vercel API!/m);
})
);
test(
'[vercel dev] 00-list-directory',
testFixtureStdio(
'00-list-directory',
async (testPath: any) => {
await testPath(200, '/', /Files within/m);
await testPath(200, '/', /test[0-3]\.txt/m);
await testPath(200, '/', /\.well-known/m);
await testPath(200, '/.well-known/keybase.txt', 'proof goes here');
},
{ projectSettings: { directoryListing: true } }
)
);
test(
'[vercel dev] 01-node',
testFixtureStdio('01-node', async (testPath: any) => {
await testPath(200, '/', /A simple deployment with the Vercel API!/m);
})
);

View File

@@ -0,0 +1,348 @@
import { resolve, delimiter } from 'path';
const {
fetch,
sleep,
fixture,
isCanary,
shouldSkip,
testFixture,
fetchWithRetry,
testFixtureStdio,
validateResponseHeaders,
} = require('./utils.js');
// Angular has `engines: { node: "10.x" }` in its `package.json`
test('[vercel dev] 02-angular-node', async () => {
if (shouldSkip('02-angular-node', '10.x')) return;
const directory = fixture('02-angular-node');
const { dev, port } = await testFixture(directory, { stdio: 'pipe' }, [
'--debug',
]);
let stderr = '';
try {
dev.stderr.on('data', async (data: any) => {
stderr += data.toString();
});
// start `vercel dev` detached in child_process
dev.unref();
const response = await fetchWithRetry(`http://localhost:${port}`, {
retries: 180,
status: 200,
});
validateResponseHeaders(response);
const body = await response.text();
expect(body).toMatch(/Angular \+ Node.js API/m);
} finally {
dev.kill('SIGTERM');
}
await sleep(5000);
if (isCanary()) {
stderr.includes('@now/build-utils@canary');
} else {
stderr.includes('@now/build-utils@latest');
}
});
test(
'[vercel dev] 03-aurelia',
testFixtureStdio(
'03-aurelia',
async (testPath: any) => {
await testPath(200, '/', /Aurelia Navigation Skeleton/m);
},
{ skipDeploy: true }
)
);
test(
'[vercel dev] 04-create-react-app',
testFixtureStdio('04-create-react-app', async (testPath: any) => {
await testPath(200, '/', /React App/m);
})
);
/*
test(
'[vercel dev] 05-gatsby',
testFixtureStdio('05-gatsby', async (testPath: any) => {
await testPath(200, '/', /Gatsby Default Starter/m);
})
);
*/
test(
'[vercel dev] 06-gridsome',
testFixtureStdio('06-gridsome', async (testPath: any) => {
await testPath(200, '/');
await testPath(200, '/about');
await testPath(308, '/support', 'Redirecting to /about?ref=support (308)', {
Location: '/about?ref=support',
});
// Bug with gridsome's dev server: https://github.com/gridsome/gridsome/issues/831
// Works in prod only so leave out for now
// await testPath(404, '/nothing');
})
);
test(
'[vercel dev] 07-hexo-node',
testFixtureStdio('07-hexo-node', async (testPath: any) => {
await testPath(200, '/', /Hexo \+ Node.js API/m);
await testPath(200, '/api/date', new RegExp(new Date().getFullYear() + ''));
await testPath(200, '/contact.html', /Contact Us/m);
await testPath(200, '/support', /Contact Us/m);
})
);
test('[vercel dev] 08-hugo', async () => {
if (process.platform === 'darwin') {
// Update PATH to find the Hugo executable installed via GH Actions
process.env.PATH = `${resolve(fixture('08-hugo'))}${delimiter}${
process.env.PATH
}`;
const tester = testFixtureStdio('08-hugo', async (testPath: any) => {
await testPath(200, '/', /Hugo/m);
});
await tester();
} else {
console.log(`Skipping 08-hugo on platform ${process.platform}`);
}
});
test(
'[vercel dev] 10-nextjs-node',
testFixtureStdio('10-nextjs-node', async (testPath: any) => {
await testPath(200, '/', /Next.js \+ Node.js API/m);
await testPath(200, '/api/date', new RegExp(new Date().getFullYear() + ''));
await testPath(200, '/contact', /Contact Page/);
await testPath(200, '/support', /Contact Page/);
// TODO: Fix this test assertion that fails intermittently
// await testPath(404, '/nothing', /Custom Next 404/);
})
);
test(
'[vercel dev] 10a-nextjs-routes',
testFixtureStdio('10a-nextjs-routes', async (testPath: any) => {
await testPath(200, '/', /Next.js with routes/m);
await testPath(200, '/hello', /Hello Routes/m);
})
);
test(
'[vercel dev] 12-polymer-node',
testFixtureStdio(
'12-polymer-node',
async (testPath: any) => {
await testPath(200, '/', /Polymer \+ Node.js API/m);
await testPath(
200,
'/api/date',
new RegExp(new Date().getFullYear() + '')
);
},
{ skipDeploy: true }
)
);
test(
'[vercel dev] 13-preact-node',
testFixtureStdio(
'13-preact-node',
async (testPath: any) => {
await testPath(200, '/', /Preact/m);
await testPath(
200,
'/api/date',
new RegExp(new Date().getFullYear() + '')
);
},
{ skipDeploy: true }
)
);
test(
'[vercel dev] 14-svelte-node',
testFixtureStdio(
'14-svelte-node',
async (testPath: any) => {
await testPath(200, '/', /Svelte/m);
await testPath(
200,
'/api/date',
new RegExp(new Date().getFullYear() + '')
);
},
{ skipDeploy: true }
)
);
test(
'[vercel dev] 16-vue-node',
testFixtureStdio(
'16-vue-node',
async (testPath: any) => {
await testPath(200, '/', /Vue.js \+ Node.js API/m);
await testPath(
200,
'/api/date',
new RegExp(new Date().getFullYear() + '')
);
},
{ skipDeploy: true }
)
);
test(
'[vercel dev] 17-vuepress-node',
testFixtureStdio(
'17-vuepress-node',
async (testPath: any) => {
await testPath(200, '/', /VuePress \+ Node.js API/m);
await testPath(
200,
'/api/date',
new RegExp(new Date().getFullYear() + '')
);
},
{ skipDeploy: true }
)
);
test(
'[vercel dev] double slashes redirect',
testFixtureStdio(
'01-node',
async (_testPath: any, port: any) => {
{
const res = await fetch(`http://localhost:${port}////?foo=bar`, {
redirect: 'manual',
});
validateResponseHeaders(res);
const body = await res.text();
expect(res.status).toBe(301);
expect(res.headers.get('location')).toBe(
`http://localhost:${port}/?foo=bar`
);
expect(body).toBe('Redirecting to /?foo=bar (301)\n');
}
{
const res = await fetch(`http://localhost:${port}///api////date.js`, {
method: 'POST',
redirect: 'manual',
});
validateResponseHeaders(res);
const body = await res.text();
expect(res.status).toBe(200);
expect(
body.startsWith('January') ||
body.startsWith('February') ||
body.startsWith('March') ||
body.startsWith('April') ||
body.startsWith('May') ||
body.startsWith('June') ||
body.startsWith('July') ||
body.startsWith('August') ||
body.startsWith('September') ||
body.startsWith('October') ||
body.startsWith('November') ||
body.startsWith('December')
).toBeTruthy();
}
},
{ skipDeploy: true }
)
);
test(
'[vercel dev] 18-marko',
testFixtureStdio(
'18-marko',
async (testPath: any) => {
await testPath(200, '/', /Marko Starter/m);
},
{ skipDeploy: true }
)
);
test(
'[vercel dev] 19-mithril',
testFixtureStdio(
'19-mithril',
async (testPath: any) => {
await testPath(200, '/', /Mithril on Vercel/m);
},
{ skipDeploy: true }
)
);
test(
'[vercel dev] 20-riot',
testFixtureStdio(
'20-riot',
async (testPath: any) => {
await testPath(200, '/', /Riot on Vercel/m);
},
{ skipDeploy: true }
)
);
test(
'[vercel dev] 21-charge',
testFixtureStdio(
'21-charge',
async (testPath: any) => {
await testPath(200, '/', /Welcome to my new Charge site/m);
},
{ skipDeploy: true }
)
);
test(
'[vercel dev] 22-brunch',
testFixtureStdio(
'22-brunch',
async (testPath: any) => {
await testPath(200, '/', /Bon Appétit./m);
},
{ skipDeploy: true }
)
);
test(
'[vercel dev] 23-docusaurus',
testFixtureStdio(
'23-docusaurus',
async (testPath: any) => {
await testPath(200, '/', /My Site/m);
},
{ skipDeploy: true }
)
);
test('[vercel dev] 24-ember', async () => {
if (shouldSkip('24-ember', '>^6.14.0 || ^8.10.0 || >=9.10.0')) return;
const tester = testFixtureStdio(
'24-ember',
async (testPath: any) => {
await testPath(200, '/', /HelloWorld/m);
},
{ skipDeploy: true }
);
await tester();
});

View File

@@ -0,0 +1,427 @@
import ms from 'ms';
import fs from 'fs-extra';
import { isIP } from 'net';
import { join } from 'path';
const {
fetch,
sleep,
fixture,
testFixture,
testFixtureStdio,
validateResponseHeaders,
} = require('./utils.js');
test(
'[vercel dev] temporary directory listing',
testFixtureStdio(
'temporary-directory-listing',
async (_testPath: any, port: any) => {
const directory = fixture('temporary-directory-listing');
await fs.unlink(join(directory, 'index.txt')).catch(() => null);
await sleep(ms('20s'));
const firstResponse = await fetch(`http://localhost:${port}`);
validateResponseHeaders(firstResponse);
const body = await firstResponse.text();
console.log(body);
expect(firstResponse.status).toBe(404);
await fs.writeFile(join(directory, 'index.txt'), 'hello');
for (let i = 0; i < 20; i++) {
const response = await fetch(`http://localhost:${port}`);
validateResponseHeaders(response);
if (response.status === 200) {
const body = await response.text();
expect(body).toBe('hello');
}
await sleep(ms('1s'));
}
},
{ skipDeploy: true }
)
);
test('[vercel dev] add a `package.json` to trigger `@vercel/static-build`', async () => {
const directory = fixture('trigger-static-build');
await fs.unlink(join(directory, 'package.json')).catch(() => null);
await fs.unlink(join(directory, 'public', 'index.txt')).catch(() => null);
await fs.rmdir(join(directory, 'public')).catch(() => null);
const tester = testFixtureStdio(
'trigger-static-build',
async (_testPath: any, port: any) => {
{
const response = await fetch(`http://localhost:${port}`);
validateResponseHeaders(response);
const body = await response.text();
expect(body.trim()).toBe('hello:index.txt');
}
const rnd = Math.random().toString();
const pkg = {
private: true,
scripts: { build: `mkdir -p public && echo ${rnd} > public/index.txt` },
};
await fs.writeFile(join(directory, 'package.json'), JSON.stringify(pkg));
// Wait until file events have been processed
await sleep(ms('2s'));
{
const response = await fetch(`http://localhost:${port}`);
validateResponseHeaders(response);
const body = await response.text();
expect(body.trim()).toBe(rnd);
}
},
{ skipDeploy: true }
);
await tester();
});
test('[vercel dev] no build matches warning', async () => {
const directory = fixture('no-build-matches');
const { dev } = await testFixture(directory, {
stdio: ['ignore', 'pipe', 'pipe'],
});
try {
// start `vercel dev` detached in child_process
dev.unref();
dev.stderr.setEncoding('utf8');
await new Promise<void>(resolve => {
dev.stderr.on('data', (str: string) => {
if (str.includes('did not match any source files')) {
resolve();
}
});
});
} finally {
dev.kill('SIGTERM');
}
});
test(
'[vercel dev] do not recursivly check the path',
testFixtureStdio('handle-filesystem-missing', async (testPath: any) => {
await testPath(200, '/', /hello/m);
await testPath(404, '/favicon.txt');
})
);
test('[vercel dev] render warning for empty cwd dir', async () => {
const directory = fixture('empty');
const { dev, port } = await testFixture(directory, {
stdio: ['ignore', 'pipe', 'pipe'],
});
try {
dev.unref();
// Monitor `stderr` for the warning
dev.stderr.setEncoding('utf8');
const msg = 'There are no files inside your deployment.';
await new Promise<void>(resolve => {
dev.stderr.on('data', (str: string) => {
if (str.includes(msg)) {
resolve();
}
});
});
// Issue a request to ensure a 404 response
await sleep(ms('3s'));
const response = await fetch(`http://localhost:${port}`);
validateResponseHeaders(response);
expect(response.status).toBe(404);
} finally {
dev.kill('SIGTERM');
}
});
test('[vercel dev] do not rebuild for changes in the output directory', async () => {
const directory = fixture('output-is-source');
const { dev, port } = await testFixture(directory, {
stdio: ['ignore', 'pipe', 'pipe'],
});
try {
dev.unref();
let stderr: any = [];
const start = Date.now();
dev.stderr.on('data', (str: any) => stderr.push(str));
while (stderr.join('').includes('Ready') === false) {
await sleep(ms('3s'));
if (Date.now() - start > ms('30s')) {
console.log('stderr:', stderr.join(''));
break;
}
}
const resp1 = await fetch(`http://localhost:${port}`);
const text1 = await resp1.text();
expect(text1.trim()).toBe('hello first');
await fs.writeFile(join(directory, 'public', 'index.html'), 'hello second');
await sleep(ms('3s'));
const resp2 = await fetch(`http://localhost:${port}`);
const text2 = await resp2.text();
expect(text2.trim()).toBe('hello second');
} finally {
dev.kill('SIGTERM');
}
});
test(
'[vercel dev] 25-nextjs-src-dir',
testFixtureStdio('25-nextjs-src-dir', async (testPath: any) => {
await testPath(200, '/', /Next.js \+ Node.js API/m);
})
);
test(
'[vercel dev] 27-zero-config-env',
testFixtureStdio(
'27-zero-config-env',
async (testPath: any) => {
await testPath(200, '/api/print', /build-and-runtime/m);
await testPath(200, '/', /build-and-runtime/m);
},
{ skipDeploy: true }
)
);
test(
'[vercel dev] 28-vercel-json-and-ignore',
testFixtureStdio('28-vercel-json-and-ignore', async (testPath: any) => {
await testPath(200, '/api/one', 'One');
await testPath(404, '/api/two');
await testPath(200, '/api/three', 'One');
})
);
test(
'[vercel dev] 30-next-image-optimization',
testFixtureStdio('30-next-image-optimization', async (testPath: any) => {
const toUrl = (url: any, w: any, q: any) => {
// @ts-ignore
const query = new URLSearchParams();
query.append('url', url);
query.append('w', w);
query.append('q', q);
return `/_next/image?${query}`;
};
const expectHeader = (accept: any) => ({
'content-type': accept,
'cache-control': 'public, max-age=0, must-revalidate',
});
const fetchOpts = (accept: any) => ({ method: 'GET', headers: { accept } });
await testPath(200, '/', /Home Page/m);
await testPath(
200,
toUrl('/test.jpg', 64, 100),
null,
expectHeader('image/webp'),
fetchOpts('image/webp')
);
await testPath(
200,
toUrl('/test.png', 64, 90),
null,
expectHeader('image/webp'),
fetchOpts('image/webp')
);
/*
* Disabled gif in https://github.com/vercel/next.js/pull/22253
* Eventually we should enable again when `next dev` supports it
await testPath(
200,
toUrl('/test.gif', 64, 80),
null,
expectHeader('image/webp'),
fetchOpts('image/webp')
);
*/
/*
* Disabled svg in https://github.com/vercel/next.js/pull/34431
* We can test for 400 status since config option is not enabled.
*/
await testPath(400, toUrl('/test.svg', 64, 70));
/* Disabled bmp because `next dev` bypasses
* and production will convert. Eventually
* we can enable once `next dev` supports it.
await testPath(
200,
toUrl('/test.bmp', 64, 50),
null,
expectHeader('image/bmp'),
fetchOpts('image/webp')
);
*/
// animated gif should bypass: serve as-is
await testPath(
200,
toUrl('/animated.gif', 64, 60),
null,
expectHeader('image/gif'),
fetchOpts('image/webp')
);
})
);
test(
'[vercel dev] 40-mixed-modules',
testFixtureStdio('40-mixed-modules', async (testPath: any) => {
await testPath(200, '/entrypoint.js', 'mixed-modules:js');
await testPath(200, '/entrypoint.mjs', 'mixed-modules:mjs');
await testPath(200, '/entrypoint.ts', 'mixed-modules:ts');
await testPath(
200,
'/type-module-package-json/auto.js',
'mixed-modules:auto'
);
await testPath(
200,
'/type-module-package-json/nested/also.js',
'mixed-modules:also'
);
})
);
test(
'[vercel dev] 41-tsconfig-jsx',
testFixtureStdio('41-tsconfig-jsx', async (testPath: any) => {
await testPath(200, '/', /Solid App/m);
await testPath(200, '/api/test', 'working');
})
);
test(
'[vercel dev] Use `@vercel/python` with Flask requirements.txt',
testFixtureStdio('python-flask', async (testPath: any) => {
const name = 'Alice';
const year = new Date().getFullYear();
await testPath(200, `/api/user?name=${name}`, new RegExp(`Hello ${name}`));
await testPath(200, `/api/date`, new RegExp(`Current date is ${year}`));
await testPath(200, `/api/date.py`, new RegExp(`Current date is ${year}`));
await testPath(200, `/api/headers`, (body: any, res: any) => {
// @ts-ignore
const { host } = new URL(res.url);
expect(body).toBe(host);
});
})
);
test(
'[vercel dev] Use custom runtime from the "functions" property',
testFixtureStdio('custom-runtime', async (testPath: any) => {
await testPath(200, `/api/user`, /Hello, from Bash!/m);
await testPath(200, `/api/user.sh`, /Hello, from Bash!/m);
})
);
test(
'[vercel dev] Should work with nested `tsconfig.json` files',
testFixtureStdio('nested-tsconfig', async (testPath: any) => {
await testPath(200, `/`, /Nested tsconfig.json test page/);
await testPath(200, `/api`, 'Nested `tsconfig.json` API endpoint');
})
);
test(
'[vercel dev] Should force `tsc` option "module: commonjs" for `startDevServer()`',
testFixtureStdio('force-module-commonjs', async (testPath: any) => {
await testPath(200, `/`, /Force &quot;module: commonjs&quot; test page/);
await testPath(
200,
`/api`,
'Force "module: commonjs" JavaScript with ES Modules API endpoint'
);
await testPath(
200,
`/api/ts`,
'Force "module: commonjs" TypeScript API endpoint'
);
})
);
test(
'[vercel dev] should prioritize index.html over other file named index.*',
testFixtureStdio('index-html-priority', async (testPath: any) => {
await testPath(200, '/', 'This is index.html');
await testPath(200, '/index.css', 'This is index.css');
})
);
test(
'[vercel dev] Should support `*.go` API serverless functions',
testFixtureStdio('go', async (testPath: any) => {
await testPath(200, `/api`, 'This is the index page');
await testPath(200, `/api/index`, 'This is the index page');
await testPath(200, `/api/index.go`, 'This is the index page');
await testPath(200, `/api/another`, 'This is another page');
await testPath(200, '/api/another.go', 'This is another page');
await testPath(200, `/api/foo`, 'Req Path: /api/foo');
await testPath(200, `/api/bar`, 'Req Path: /api/bar');
})
);
test(
'[vercel dev] Should set the `ts-node` "target" to match Node.js version',
testFixtureStdio('node-ts-node-target', async (testPath: any) => {
await testPath(200, `/api/subclass`, '{"ok":true}');
await testPath(
200,
`/api/array`,
'{"months":[1,2,3,4,5,6,7,8,9,10,11,12]}'
);
await testPath(200, `/api/dump`, (body: any, res: any, isDev: any) => {
// @ts-ignore
const { host } = new URL(res.url);
const { env, headers } = JSON.parse(body);
// Test that the API endpoint receives the Vercel proxy request headers
expect(headers['x-forwarded-host']).toBe(host);
expect(headers['x-vercel-deployment-url']).toBe(host);
expect(isIP(headers['x-real-ip'])).toBeTruthy();
expect(isIP(headers['x-forwarded-for'])).toBeTruthy();
expect(isIP(headers['x-vercel-forwarded-for'])).toBeTruthy();
// Test that the API endpoint has the Vercel platform env vars defined.
expect(env.NOW_REGION).toMatch(/^[a-z]{3}\d$/);
if (isDev) {
// Only dev is tested because in production these are opt-in.
expect(env.VERCEL_URL).toBe(host);
expect(env.VERCEL_REGION).toBe('dev1');
}
});
})
);
test(
'[vercel dev] Do not fail if `src` is missing',
testFixtureStdio('missing-src-property', async (testPath: any) => {
await testPath(200, '/', /hello:index.txt/m);
await testPath(404, '/i-do-not-exist');
})
);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,495 @@
const fs = require('fs-extra');
const { join, resolve } = require('path');
const _execa = require('execa');
const fetch = require('node-fetch');
const retry = require('async-retry');
const { satisfies } = require('semver');
const stripAnsi = require('strip-ansi');
const { getDistTag } = require('../../src/util/get-dist-tag');
const { version: cliVersion } = require('../../package.json');
const {
fetchCachedToken,
} = require('../../../../test/lib/deployment/now-deploy');
jest.setTimeout(6 * 60 * 1000);
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
const isCanary = () => getDistTag(cliVersion) === 'canary';
let port = 3000;
const binaryPath = resolve(__dirname, `../../scripts/start.js`);
const fixture = name => join('test', 'dev', 'fixtures', name);
const fixtureAbsolute = name => join(__dirname, 'fixtures', name);
const exampleAbsolute = name =>
join(__dirname, '..', '..', '..', '..', 'examples', name);
let processCounter = 0;
const processList = new Map();
function execa(...args) {
const procId = ++processCounter;
const child = _execa(...args);
processList.set(procId, child);
child.on('exit', () => processList.delete(procId));
return child;
}
function fetchWithRetry(url, opts = {}) {
return retry(
async () => {
const res = await fetch(url, opts);
if (res.status !== opts.status) {
const text = await res.text();
throw new Error(
`Failed to fetch ${url} with status ${res.status} (expected ${opts.status}):\n\n${text}\n\n`
);
}
return res;
},
{
retries: opts.retries || 3,
factor: 1,
}
);
}
function createResolver() {
let resolver;
const p = new Promise(res => (resolver = res));
p.resolve = resolver;
return p;
}
function formatOutput({ stderr, stdout }) {
return `Received:\n"${stderr}"\n"${stdout}"`;
}
function printOutput(fixture, stdout, stderr) {
const lines = (
`\nOutput for "${fixture}"\n` +
`\n----- stdout -----\n` +
stdout +
`\n----- stderr -----\n` +
stderr
).split('\n');
const getPrefix = nr => {
return nr === 0 ? '╭' : nr === lines.length - 1 ? '╰' : '│';
};
console.log(
lines.map((line, index) => ` ${getPrefix(index)} ${line}`).join('\n')
);
}
function shouldSkip(name, versions) {
if (!satisfies(process.version, versions)) {
console.log(`Skipping "${name}" because it requires "${versions}".`);
return true;
}
return false;
}
function validateResponseHeaders(res) {
if (res.status < 500) {
expect(res.headers.get('x-vercel-id')).toBeTruthy();
expect(res.headers.get('cache-control').length > 0).toBeTruthy;
}
}
async function exec(directory, args = []) {
const token = await fetchCachedToken();
return execa(
binaryPath,
[
'dev',
directory,
'-t',
token,
...(process.env.VERCEL_TEAM_ID
? ['--scope', process.env.VERCEL_TEAM_ID]
: []),
...args,
],
{
reject: false,
shell: true,
env: { __VERCEL_SKIP_DEV_CMD: 1 },
}
);
}
async function runNpmInstall(fixturePath) {
if (await fs.pathExists(join(fixturePath, 'package.json'))) {
await execa('yarn', ['install'], {
cwd: fixturePath,
shell: true,
});
}
}
async function testPath(
isDev,
origin,
status,
path,
expectedText,
expectedHeaders = {},
fetchOpts = {}
) {
const opts = {
...fetchOpts,
redirect: 'manual-dont-change',
retries: 5,
status,
};
const url = `${origin}${path}`;
const res = await fetchWithRetry(url, opts);
const msg = `Testing response from ${fetchOpts.method || 'GET'} ${url}`;
console.log(msg);
expect(res.status).toBe(status);
validateResponseHeaders(res);
if (typeof expectedText === 'string') {
const actualText = await res.text();
expect(actualText.trim()).toBe(expectedText.trim());
} else if (typeof expectedText === 'function') {
const actualText = await res.text();
await expectedText(actualText, res, isDev);
} else if (expectedText instanceof RegExp) {
const actualText = await res.text();
expectedText.lastIndex = 0; // reset since we test twice
expect(actualText).toMatch(expectedText);
}
if (expectedHeaders) {
Object.entries(expectedHeaders).forEach(([key, expectedValue]) => {
let actualValue = res.headers.get(key);
if (key.toLowerCase() === 'location' && actualValue === '//') {
// HACK: `node-fetch` has strange behavior for location header so fix it
// with `manual-dont-change` opt and convert double slash to single.
// See https://github.com/node-fetch/node-fetch/issues/417#issuecomment-587233352
actualValue = '/';
}
expect(actualValue).toBe(expectedValue);
});
}
}
async function testFixture(directory, opts = {}, args = []) {
await runNpmInstall(directory);
const token = await fetchCachedToken();
const dev = execa(
binaryPath,
[
'dev',
directory,
'-t',
token,
...(process.env.VERCEL_TEAM_ID
? ['--scope', process.env.VERCEL_TEAM_ID]
: []),
'-l',
String(port),
...args,
],
{
reject: false,
detached: true,
shell: true,
stdio: 'pipe',
...opts,
env: { ...opts.env, __VERCEL_SKIP_DEV_CMD: 1 },
}
);
let stdout = '';
let stderr = '';
const readyResolver = createResolver();
const exitResolver = createResolver();
dev.stdout.setEncoding('utf8');
dev.stderr.setEncoding('utf8');
dev.stdout.on('data', data => {
stdout += data;
});
dev.stderr.on('data', data => {
stderr += data;
if (stripAnsi(stderr).includes('Ready! Available at')) {
readyResolver.resolve();
}
});
let printedOutput = false;
dev.on('exit', () => {
if (!printedOutput) {
printOutput(directory, stdout, stderr);
printedOutput = true;
}
exitResolver.resolve();
readyResolver.resolve();
});
dev.on('error', () => {
if (!printedOutput) {
printOutput(directory, stdout, stderr);
printedOutput = true;
}
exitResolver.resolve();
readyResolver.resolve();
});
dev._kill = dev.kill;
dev.kill = async (...args) => {
dev._kill(...args);
await exitResolver;
};
return {
dev,
port,
readyResolver,
};
}
function testFixtureStdio(
directory,
fn,
{ expectedCode = 0, skipDeploy, isExample, projectSettings } = {}
) {
return async () => {
const nodeMajor = Number(process.versions.node.split('.')[0]);
if (isExample && nodeMajor < 12) {
console.log(`Skipping ${directory} on Node ${process.version}`);
return;
}
const cwd = isExample
? exampleAbsolute(directory)
: fixtureAbsolute(directory);
const token = await fetchCachedToken();
let deploymentUrl;
// Deploy fixture and link project
if (!skipDeploy) {
const projectJsonPath = join(cwd, '.vercel', 'project.json');
await fs.remove(projectJsonPath);
const gitignore = join(cwd, '.gitignore');
const hasGitignore = await fs.pathExists(gitignore);
try {
// Run `vc link`
const linkResult = await execa(
binaryPath,
[
'-t',
token,
...(process.env.VERCEL_TEAM_ID
? ['--scope', process.env.VERCEL_TEAM_ID]
: []),
'link',
'--confirm',
],
{ cwd, stdio: 'pipe', reject: false }
);
console.log({
stderr: linkResult.stderr,
stdout: linkResult.stdout,
});
expect(linkResult.exitCode).toBe(0);
// Patch the project with any non-default properties
if (projectSettings) {
const { projectId } = await fs.readJson(projectJsonPath);
const res = await fetchWithRetry(
`https://api.vercel.com/v2/projects/${projectId}${
process.env.VERCEL_TEAM_ID
? `?teamId=${process.env.VERCEL_TEAM_ID}`
: ''
}`,
{
method: 'PATCH',
headers: {
Authorization: `Bearer ${token}`,
},
body: JSON.stringify(projectSettings),
retries: 3,
status: 200,
}
);
expect(res.status).toBe(200);
}
// Run `vc deploy`
let deployResult = await execa(
binaryPath,
[
'-t',
token,
...(process.env.VERCEL_TEAM_ID
? ['--scope', process.env.VERCEL_TEAM_ID]
: []),
'deploy',
'--public',
'--no-clipboard',
'--debug',
],
{ cwd, stdio: 'pipe', reject: false }
);
console.log({
exitCode: deployResult.exitCode,
stdout: deployResult.stdout,
stderr: deployResult.stderr,
});
expect(deployResult.exitCode).toBe(expectedCode);
if (expectedCode === 0) {
deploymentUrl = new URL(deployResult.stdout).host;
}
} finally {
if (!hasGitignore) {
await fs.remove(gitignore);
}
}
}
// Start dev
let dev;
await runNpmInstall(cwd);
let stdout = '';
let stderr = '';
const readyResolver = createResolver();
const exitResolver = createResolver();
try {
let printedOutput = false;
const env = skipDeploy
? { ...process.env, __VERCEL_SKIP_DEV_CMD: 1 }
: process.env;
dev = execa(
binaryPath,
[
'dev',
'-l',
port,
'-t',
token,
...(process.env.VERCEL_TEAM_ID
? ['--scope', process.env.VERCEL_TEAM_ID]
: []),
'--debug',
],
{
cwd,
env,
}
);
dev.stdout.setEncoding('utf8');
dev.stderr.setEncoding('utf8');
dev.stdout.pipe(process.stdout);
dev.stderr.pipe(process.stderr);
dev.stdout.on('data', data => {
stdout += data;
});
dev.stderr.on('data', data => {
stderr += data;
if (stripAnsi(data).includes('Ready! Available at')) {
readyResolver.resolve();
}
if (stderr.includes(`Requested port ${port} is already in use`)) {
dev.kill('SIGTERM');
throw new Error(
`Failed for "${directory}" with port ${port} with stderr "${stderr}".`
);
}
if (stderr.includes('Command failed') || stderr.includes('Error!')) {
dev.kill('SIGTERM');
throw new Error(`Failed for "${directory}" with stderr "${stderr}".`);
}
});
dev.on('exit', () => {
if (!printedOutput) {
printOutput(directory, stdout, stderr);
printedOutput = true;
}
exitResolver.resolve();
});
dev.on('error', () => {
if (!printedOutput) {
printOutput(directory, stdout, stderr);
printedOutput = true;
}
exitResolver.resolve();
});
await readyResolver;
const helperTestPath = async (...args) => {
if (!skipDeploy) {
await testPath(false, `https://${deploymentUrl}`, ...args);
}
await testPath(true, `http://localhost:${port}`, ...args);
};
await fn(helperTestPath, port);
} finally {
dev.kill('SIGTERM');
await exitResolver;
}
};
}
beforeEach(() => {
port = ++port;
});
afterEach(async () => {
await Promise.all(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Array.from(processList).map(([_procId, proc]) => {
if (proc.killed === false) {
console.log(
`killing process ${proc.pid} "${proc.spawnargs.join(' ')}"`
);
try {
process.kill(proc.pid, 'SIGTERM');
} catch (err) {
// Was already killed
console.error(`Failed to kill process`, proc.pid, err);
}
}
})
);
});
module.exports = {
sleep,
isCanary,
testPath,
testFixture,
testFixtureStdio,
exec,
formatOutput,
shouldSkip,
fixture,
fetch,
validateResponseHeaders,
};

View File

@@ -1,2 +1,3 @@
.next
yarn.lock
.vercel

View File

@@ -1,3 +0,0 @@
module.exports = {
target: 'serverless'
}

View File

@@ -5,8 +5,8 @@
"now-build": "next build"
},
"dependencies": {
"next": "^8.0.0",
"react": "^16.7.0",
"react-dom": "^16.7.0"
"next": "12.1.6",
"react": "18.1.0",
"react-dom": "18.1.0"
}
}

View File

@@ -1,11 +1,11 @@
import { withRouter } from 'next/router';
function Index({ router }) {
const data = {
pathname: router.pathname,
query: router.query
export async function getServerSideProps({ req }) {
return {
props: {
url: req.url,
},
};
return <div>{ JSON.stringify(data) }</div>;
}
export default withRouter(Index);
export default function Index(props) {
return <pre>{JSON.stringify(props)}</pre>;
}

View File

@@ -1,11 +1,9 @@
{
"version": 2,
"name": "now-dev-next",
"builds": [{ "src": "package.json", "use": "@vercel/next@canary" }],
"routes": [
{
"src": "/(.*)",
"dest": "/index?route-param=b"
"src": "/test",
"dest": "/?route-param=b"
}
]
}

View File

@@ -1,11 +1,11 @@
import { join } from 'path';
import { fileNameSymbol } from '@vercel/client';
import { client } from '../mocks/client';
import deploy from '../../src/commands/deploy';
import { setupFixture } from '../helpers/setup-fixture';
import { defaultProject, useProject } from '../mocks/project';
import { useTeams } from '../mocks/team';
import { useUser } from '../mocks/user';
import { client } from '../../mocks/client';
import deploy from '../../../src/commands/deploy';
import { setupFixture } from '../../helpers/setup-fixture';
import { defaultProject, useProject } from '../../mocks/project';
import { useTeams } from '../../mocks/team';
import { useUser } from '../../mocks/user';
describe('deploy', () => {
it('should reject deploying a single file', async () => {

View File

@@ -1,11 +1,11 @@
import fs from 'fs-extra';
import path from 'path';
import env from '../../src/commands/env';
import { setupFixture } from '../helpers/setup-fixture';
import { client } from '../mocks/client';
import { defaultProject, useProject } from '../mocks/project';
import { useTeams } from '../mocks/team';
import { useUser } from '../mocks/user';
import env from '../../../src/commands/env';
import { setupFixture } from '../../helpers/setup-fixture';
import { client } from '../../mocks/client';
import { defaultProject, useProject } from '../../mocks/project';
import { useTeams } from '../../mocks/team';
import { useUser } from '../../mocks/user';
describe('env', () => {
describe('pull', () => {

View File

@@ -1,7 +1,7 @@
import { client } from '../mocks/client';
import { useUser } from '../mocks/user';
import { useDeployment } from '../mocks/deployment';
import inspect from '../../src/commands/inspect';
import { client } from '../../mocks/client';
import { useUser } from '../../mocks/user';
import { useDeployment } from '../../mocks/deployment';
import inspect from '../../../src/commands/inspect';
describe('inspect', () => {
it('should print out deployment information', async () => {

View File

@@ -1,6 +1,6 @@
import login from '../../src/commands/login';
import { client } from '../mocks/client';
import { useUser } from '../mocks/user';
import login from '../../../src/commands/login';
import { client } from '../../mocks/client';
import { useUser } from '../../mocks/user';
describe('login', () => {
it('should not allow the `--token` flag', async () => {

View File

@@ -1,11 +1,11 @@
import fs from 'fs-extra';
import path from 'path';
import pull from '../../src/commands/pull';
import { setupFixture } from '../helpers/setup-fixture';
import { client } from '../mocks/client';
import { defaultProject, useProject } from '../mocks/project';
import { useTeams } from '../mocks/team';
import { useUser } from '../mocks/user';
import pull from '../../../src/commands/pull';
import { setupFixture } from '../../helpers/setup-fixture';
import { client } from '../../mocks/client';
import { defaultProject, useProject } from '../../mocks/project';
import { useTeams } from '../../mocks/team';
import { useUser } from '../../mocks/user';
describe('pull', () => {
it('should handle pulling', async () => {

View File

@@ -1,6 +1,6 @@
import { client } from '../mocks/client';
import { useUser } from '../mocks/user';
import whoami from '../../src/commands/whoami';
import { client } from '../../mocks/client';
import { useUser } from '../../mocks/user';
import whoami from '../../../src/commands/whoami';
describe('whoami', () => {
it('should reject invalid arguments', async () => {

View File

@@ -1,5 +1,5 @@
import parseTarget from '../../../src/util/deploy/parse-target';
import { Output } from '../../../src/util/output';
import parseTarget from '../../../../src/util/deploy/parse-target';
import { Output } from '../../../../src/util/output';
describe('parseTarget', () => {
let output: Output;

View File

@@ -3,7 +3,7 @@ import {
filterPackage,
getBuildUtils,
isBundledBuilder,
} from '../../../src/util/dev/builder-cache';
} from '../../../../src/util/dev/builder-cache';
describe('filterPackage', () => {
it('should filter install "latest", cached canary', () => {

View File

@@ -1,4 +1,4 @@
import parseListen from '../../../src/util/dev/parse-listen';
import parseListen from '../../../../src/util/dev/parse-listen';
const IS_WINDOWS = process.platform === 'win32';

View File

@@ -1,4 +1,4 @@
import { devRouter } from '../../../src/util/dev/router';
import { devRouter } from '../../../../src/util/dev/router';
describe('devRouter', () => {
it('should handle 301 redirection', async () => {

View File

@@ -6,10 +6,10 @@ import fs from 'fs-extra';
import fetch, { Response } from 'node-fetch';
import listen from 'async-listen';
import { createServer } from 'http';
import { client } from '../../mocks/client';
import DevServer from '../../../src/util/dev/server';
import { client } from '../../../mocks/client';
import DevServer from '../../../../src/util/dev/server';
import { DevServerOptions } from '../../../../src/util/dev/types';
const IS_MAC_OS = process.platform === 'darwin';
const IS_WINDOWS = process.platform === 'win32';
async function runNpmInstall(fixturePath: string) {
@@ -21,29 +21,34 @@ async function runNpmInstall(fixturePath: string) {
}
}
interface TestFixtureOptions extends Omit<DevServerOptions, 'output'> {
skip?: boolean;
}
const testFixture =
(
name: string,
fn: (server: DevServer) => Promise<void>,
options: { skip: boolean } = { skip: false }
options?: TestFixtureOptions
) =>
async () => {
if (options.skip) {
if (options?.skip) {
console.log('Skipping this test for this platform.');
return;
}
let server: DevServer | null = null;
let server: DevServer | undefined;
const fixturePath = path.join(__dirname, '../../fixtures/unit', name);
await runNpmInstall(fixturePath);
try {
server = new DevServer(fixturePath, { output: client.output });
server = new DevServer(fixturePath, {
...options,
output: client.output,
});
await server.start(0);
await fn(server);
} finally {
if (server) {
await server.stop();
}
await server?.stop();
}
};
@@ -141,7 +146,7 @@ describe('DevServer', () => {
testFixture(
'now-dev-next',
async server => {
const res = await fetch(`${server.address}/something?url-param=a`);
const res = await fetch(`${server.address}/test?url-param=a`);
validateResponseHeaders(res);
const text = await res.text();
@@ -149,16 +154,19 @@ describe('DevServer', () => {
// Hacky way of getting the page payload from the response
// HTML since we don't have a HTML parser handy.
const json = text
.match(/<div>(.*)<\/div>/)![1]
.replace('</div>', '')
.match(/<pre>(.*)<\/pre>/)![1]
.replace('</pre>', '')
.replace('<!-- -->', '')
.replace(/&amp;/g, '&')
.replace(/&quot;/g, '"');
const parsed = JSON.parse(json);
const query = url.parse(parsed.url, true).query;
expect(parsed.query['url-param']).toEqual('a');
expect(parsed.query['route-param']).toEqual('b');
expect(query['url-param']).toEqual('a');
expect(query['route-param']).toEqual('b');
},
{
skip: IS_MAC_OS,
devCommand: 'next dev --port $PORT',
}
)
);
@@ -215,8 +223,7 @@ describe('DevServer', () => {
expect(body).toEqual('hello and welcome');
},
{
// this test very often times out in the testFixture startup logic on Mac
skip: IS_MAC_OS,
devCommand: 'next dev --port $PORT',
}
)
);

View File

@@ -1,4 +1,4 @@
import { validateConfig } from '../../../src/util/dev/validate';
import { validateConfig } from '../../../../src/util/dev/validate';
describe('validateConfig', () => {
it('should not error with empty config', async () => {

View File

@@ -1,8 +1,8 @@
import fetch from 'node-fetch';
import listen from 'async-listen';
import { createServer, IncomingMessage, Server, ServerResponse } from 'http';
import { JSONValue } from '../../src/types';
import { responseError, responseErrorMessage } from '../../src/util/error';
import { JSONValue } from '../../../src/types';
import { responseError, responseErrorMessage } from '../../../src/util/error';
const send = (res: ServerResponse, statusCode: number, body: JSONValue) => {
res.statusCode = statusCode;

View File

@@ -1,11 +1,11 @@
import { join, sep } from 'path';
// @ts-ignore - Missing types for "alpha-sort"
import { asc as alpha } from 'alpha-sort';
import createOutput from '../../src/util/output';
import { staticFiles as getStaticFiles_ } from '../../src/util/get-files';
import createOutput from '../../../src/util/output';
import { staticFiles as getStaticFiles_ } from '../../../src/util/get-files';
const output = createOutput({ debug: false });
const prefix = `${join(__dirname, '../fixtures/unit')}${sep}`;
const prefix = `${join(__dirname, '../../fixtures/unit')}${sep}`;
const base = (path: string) => path.replace(prefix, '');
const fixture = (name: string) => join(prefix, name);

View File

@@ -1,4 +1,4 @@
import getProjectName from '../../src/util/get-project-name';
import getProjectName from '../../../src/util/get-project-name';
describe('getProjectName', () => {
it('should work with argv', () => {

View File

@@ -1,5 +1,5 @@
import { isCanary } from '../../src/util/is-canary';
import getUpdateCommand from '../../src/util/get-update-command';
import { isCanary } from '../../../src/util/is-canary';
import getUpdateCommand from '../../../src/util/get-update-command';
describe('getUpdateCommand', () => {
it('should detect update command', async () => {

View File

@@ -1,4 +1,4 @@
import didYouMean from '../../../src/util/init/did-you-mean';
import didYouMean from '../../../../src/util/init/did-you-mean';
describe('didYouMean', () => {
const examples = [

View File

@@ -1,4 +1,4 @@
import { isValidName } from '../../src/util/is-valid-name';
import { isValidName } from '../../../src/util/is-valid-name';
const tests = {
'hello world': true,

View File

@@ -1,5 +1,5 @@
import { basename, join } from 'path';
import { getVercelDirectory } from '../../../src/util/projects/link';
import { getVercelDirectory } from '../../../../src/util/projects/link';
const fixture = (name: string) => join(__dirname, '../../fixtures/unit', name);

View File

@@ -1,10 +1,10 @@
import { join } from 'path';
import { getLinkedProject } from '../../../src/util/projects/link';
import { client } from '../../mocks/client';
import { getLinkedProject } from '../../../../src/util/projects/link';
import { client } from '../../../mocks/client';
import { defaultProject, useProject } from '../../mocks/project';
import { useTeams } from '../../mocks/team';
import { useUser } from '../../mocks/user';
import { defaultProject, useProject } from '../../../mocks/project';
import { useTeams } from '../../../mocks/team';
import { useUser } from '../../../mocks/user';
type UnPromisify<T> = T extends Promise<infer U> ? U : T;

View File

@@ -1,4 +1,4 @@
import toHost from '../../src/util/to-host';
import toHost from '../../../src/util/to-host';
describe('toHost', () => {
it('should parse simple to host', () => {

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/client",
"version": "11.0.3-canary.0",
"version": "11.0.3",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"homepage": "https://vercel.com",
@@ -42,7 +42,7 @@
]
},
"dependencies": {
"@vercel/build-utils": "3.0.2-canary.0",
"@vercel/build-utils": "3.1.0",
"@zeit/fetch": "5.2.0",
"async-retry": "1.2.3",
"async-sema": "3.0.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/frameworks",
"version": "0.9.1-canary.0",
"version": "0.9.1",
"main": "./dist/frameworks.js",
"types": "./dist/frameworks.d.ts",
"files": [
@@ -21,7 +21,7 @@
"@types/js-yaml": "3.12.1",
"@types/node": "12.0.4",
"@types/node-fetch": "2.5.8",
"@vercel/routing-utils": "1.13.3-canary.0",
"@vercel/routing-utils": "1.13.3",
"ajv": "6.12.2",
"typescript": "4.3.4"
}

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/go",
"version": "1.4.3-canary.0",
"version": "1.4.3",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
@@ -25,7 +25,7 @@
"@types/fs-extra": "^5.0.5",
"@types/node-fetch": "^2.3.0",
"@types/tar": "^4.0.0",
"@vercel/build-utils": "3.0.2-canary.0",
"@vercel/build-utils": "3.1.0",
"@vercel/ncc": "0.24.0",
"async-retry": "1.3.1",
"execa": "^1.0.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/next",
"version": "2.8.66-canary.0",
"version": "2.8.66",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -45,9 +45,9 @@
"@types/semver": "6.0.0",
"@types/text-table": "0.2.1",
"@types/webpack-sources": "3.2.0",
"@vercel/build-utils": "3.0.2-canary.0",
"@vercel/nft": "0.18.1",
"@vercel/routing-utils": "1.13.3-canary.0",
"@vercel/build-utils": "3.1.0",
"@vercel/nft": "0.19.0",
"@vercel/routing-utils": "1.13.3",
"async-sema": "3.0.1",
"buffer-crc32": "0.2.13",
"cheerio": "1.0.0-rc.10",

View File

@@ -1116,9 +1116,9 @@ export const build: BuildV2 = async ({
files: {
...nextFiles,
...pageFiles,
'___next_launcher.js': new FileBlob({ data: launcher }),
'___next_launcher.cjs': new FileBlob({ data: launcher }),
},
handler: '___next_launcher.js',
handler: '___next_launcher.cjs',
runtime: nodeVersion.runtime,
...lambdaOptions,
shouldAddHelpers: false,
@@ -1786,7 +1786,7 @@ export const build: BuildV2 = async ({
const launcherFiles: { [name: string]: FileFsRef | FileBlob } = {
[path.join(
path.relative(baseDir, entryPath),
'___next_launcher.js'
'___next_launcher.cjs'
)]: new FileBlob({ data: launcher }),
};
let lambdaOptions: { memory?: number; maxDuration?: number } = {};
@@ -1822,7 +1822,7 @@ export const build: BuildV2 = async ({
],
handler: path.join(
path.relative(baseDir, entryPath),
'___next_launcher.js'
'___next_launcher.cjs'
),
runtime: nodeVersion.runtime,
...lambdaOptions,
@@ -1841,7 +1841,7 @@ export const build: BuildV2 = async ({
],
handler: path.join(
path.relative(baseDir, entryPath),
'___next_launcher.js'
'___next_launcher.cjs'
),
runtime: nodeVersion.runtime,
...lambdaOptions,
@@ -2023,7 +2023,7 @@ export const build: BuildV2 = async ({
const launcherFiles: { [name: string]: FileFsRef | FileBlob } = {
[path.join(
path.relative(baseDir, entryPath),
'___next_launcher.js'
'___next_launcher.cjs'
)]: new FileBlob({ data: launcher }),
};
@@ -2040,7 +2040,7 @@ export const build: BuildV2 = async ({
layers: [group.pseudoLayer],
handler: path.join(
path.relative(baseDir, entryPath),
'___next_launcher.js'
'___next_launcher.cjs'
),
runtime: nodeVersion.runtime,
});

View File

@@ -500,7 +500,7 @@ export async function serverBuild({
const launcherFiles: { [name: string]: FileFsRef | FileBlob } = {
[path.join(
path.relative(baseDir, requiredServerFilesManifest.appDir || entryPath),
'___next_launcher.js'
'___next_launcher.cjs'
)]: new FileBlob({ data: launcher }),
};
const pageTraces: {
@@ -688,7 +688,7 @@ export async function serverBuild({
baseDir,
requiredServerFilesManifest.appDir || entryPath
),
'___next_launcher.js'
'___next_launcher.cjs'
),
memory: group.memory,
runtime: nodeVersion.runtime,

View File

@@ -0,0 +1,8 @@
const path = require('path');
const { deployAndTest } = require('../../utils');
describe(`${__dirname.split(path.sep).pop()}`, () => {
it('should deploy and pass probe checks', async () => {
await deployAndTest(__dirname);
});
});

View File

@@ -1,4 +1,7 @@
{
"name": "esm-package",
"version": "0.1.0",
"type": "module",
"private": true,
"scripts": {
"dev": "next dev",
@@ -6,8 +9,8 @@
"start": "next start"
},
"dependencies": {
"next": "9.2.2",
"react": "16.13.0",
"react-dom": "16.13.0"
"next": "canary",
"react": "17.0.2",
"react-dom": "17.0.2"
}
}

View File

@@ -0,0 +1,5 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
export default (req, res) => {
res.status(200).json({ name: 'John Doe' });
};

View File

@@ -0,0 +1,3 @@
export default function Home() {
return 'index page';
}

View File

@@ -0,0 +1,21 @@
{
"version": 2,
"builds": [
{
"src": "package.json",
"use": "@vercel/next"
}
],
"probes": [
{
"path": "/",
"status": 200,
"mustContain": "index page"
},
{
"path": "/api/hello",
"status": 200,
"mustContain": "John Doe"
}
]
}

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/node-bridge",
"version": "2.2.2-canary.0",
"version": "2.2.2",
"license": "MIT",
"main": "./index.js",
"repository": {

View File

@@ -1,4 +1,3 @@
/dist
/test/fixtures/**/types.d.ts
/test/fixtures/11-symlinks/symlink
!test/cache-fixtures/**
!test/cache-fixtures/**

View File

@@ -21,11 +21,6 @@ async function main() {
join(__dirname, 'test/fixtures/15-helpers/ts/types.d.ts')
);
// Setup symlink for symlink test
const symlinkTarget = join(__dirname, 'test/fixtures/11-symlinks/symlink');
await fs.remove(symlinkTarget);
await fs.symlink('symlinked-asset', symlinkTarget);
const mainDir = join(outDir, 'main');
await execa(
'ncc',

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/node",
"version": "1.15.3-canary.0",
"version": "1.15.3",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
@@ -31,7 +31,7 @@
},
"dependencies": {
"@types/node": "*",
"@vercel/node-bridge": "2.2.2-canary.0",
"@vercel/node-bridge": "2.2.2",
"ts-node": "8.9.1",
"typescript": "4.3.4"
},
@@ -45,9 +45,9 @@
"@types/etag": "1.8.0",
"@types/jest": "27.4.1",
"@types/test-listen": "1.1.0",
"@vercel/build-utils": "3.0.2-canary.0",
"@vercel/build-utils": "3.1.0",
"@vercel/ncc": "0.24.0",
"@vercel/nft": "0.18.1",
"@vercel/nft": "0.19.0",
"content-type": "1.0.4",
"cookie": "0.4.0",
"etag": "1.8.1",

View File

@@ -1,5 +1,9 @@
import fs from 'fs';
export default function handler(req, res) {
res.end(fs.readFileSync(`${__dirname}/symlink`));
export default function (req, res) {
const path = `${__dirname}/symlink`;
const data = fs.readFileSync(path, 'utf8');
const isSymlink = fs.lstatSync(path).isSymbolicLink();
const target = fs.readlinkSync(path);
res.json({ path, target, isSymlink, data });
}

View File

@@ -0,0 +1 @@
symlinked-asset

View File

@@ -9,7 +9,7 @@
"probes": [
{
"path": "/",
"mustContain": "asdf"
"mustContain": "{\"path\":\"/var/task/symlink\",\"target\":\"symlinked-asset\",\"isSymlink\":true,\"data\":\"asdf\\n\"}"
}
]
}

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/python",
"version": "2.3.3-canary.0",
"version": "2.3.3",
"main": "./dist/index.js",
"license": "MIT",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -23,7 +23,7 @@
"devDependencies": {
"@types/execa": "^0.9.0",
"@types/jest": "27.4.1",
"@vercel/build-utils": "3.0.2-canary.0",
"@vercel/build-utils": "3.1.0",
"@vercel/ncc": "0.24.0",
"execa": "^1.0.0",
"typescript": "4.3.4"

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/redwood",
"version": "0.8.3-canary.0",
"version": "0.8.3",
"main": "./dist/index.js",
"license": "MIT",
"homepage": "https://vercel.com/docs",
@@ -20,14 +20,14 @@
"prepublishOnly": "node build.js"
},
"dependencies": {
"@vercel/nft": "0.18.1",
"@vercel/routing-utils": "1.13.3-canary.0",
"@vercel/nft": "0.19.0",
"@vercel/routing-utils": "1.13.3",
"semver": "6.1.1"
},
"devDependencies": {
"@types/aws-lambda": "8.10.19",
"@types/node": "*",
"@types/semver": "6.0.0",
"@vercel/build-utils": "3.0.2-canary.0"
"@vercel/build-utils": "3.1.0"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/routing-utils",
"version": "1.13.3-canary.0",
"version": "1.13.3",
"description": "Vercel routing utilities",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",

View File

@@ -1,7 +1,7 @@
{
"name": "@vercel/ruby",
"author": "Nathan Cahill <nathan@nathancahill.com>",
"version": "1.3.6-canary.0",
"version": "1.3.6",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/ruby",
@@ -23,7 +23,7 @@
"devDependencies": {
"@types/fs-extra": "8.0.0",
"@types/semver": "6.0.0",
"@vercel/build-utils": "3.0.2-canary.0",
"@vercel/build-utils": "3.1.0",
"@vercel/ncc": "0.24.0",
"execa": "2.0.4",
"fs-extra": "^7.0.1",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/static-build",
"version": "0.25.2-canary.0",
"version": "0.25.2",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/build-step",
@@ -36,10 +36,10 @@
"@types/ms": "0.7.31",
"@types/node-fetch": "2.5.4",
"@types/promise-timeout": "1.3.0",
"@vercel/build-utils": "3.0.2-canary.0",
"@vercel/frameworks": "0.9.1-canary.0",
"@vercel/build-utils": "3.1.0",
"@vercel/frameworks": "0.9.1",
"@vercel/ncc": "0.24.0",
"@vercel/routing-utils": "1.13.3-canary.0",
"@vercel/routing-utils": "1.13.3",
"fs-extra": "10.0.0",
"get-port": "5.0.0",
"is-port-reachable": "2.0.1",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/static-config",
"version": "1.0.1-canary.0",
"version": "1.0.1",
"license": "MIT",
"main": "./dist/index",
"repository": {

View File

@@ -12,14 +12,19 @@ const dateFormat = new Intl.DateTimeFormat('en-us', {
});
function logWithinTest(...inputs) {
const { testPath, currentTestName } = expect.getState();
const { testPath, currentTestName } =
typeof expect === 'undefined' ? expect.getState() : {};
const messages = [dateFormat.format(new Date()), currentTestName, ...inputs];
const messages = [
dateFormat.format(new Date()),
currentTestName,
...inputs,
].filter(Boolean);
const message = messages
.map(x => (typeof x === 'string' ? x : util.inspect(x)))
.join('\t');
if (shouldWriteToFile) {
if (shouldWriteToFile && testPath) {
const filePath = `${testPath}.artifact.log`;
fs.appendFileSync(filePath, `${message.trim()}\n`);
}

View File

@@ -76,7 +76,7 @@ async function nowDeploy(bodies, randomness, uploadNowJson) {
}
logWithinTest('id', deploymentId);
const st = expect.getState();
const st = typeof expect !== 'undefined' ? expect.getState() : {};
const expectstate = {
currentTestName: st.currentTestName,
testPath: st.testPath,
@@ -170,8 +170,9 @@ async function deploymentGet(deploymentId) {
}
let token;
let currentCount = 0;
const MAX_COUNT = 10;
let tokenCreated = 0;
// temporary tokens last for 25 minutes
const MAX_TOKEN_AGE = 25 * 60 * 1000;
async function fetchWithAuth(url, opts = {}) {
if (!opts.headers) opts.headers = {};
@@ -189,9 +190,8 @@ async function fetchWithAuth(url, opts = {}) {
}
async function fetchCachedToken() {
currentCount += 1;
if (!token || currentCount === MAX_COUNT) {
currentCount = 0;
if (!token || tokenCreated < Date.now() - MAX_TOKEN_AGE) {
tokenCreated = Date.now();
token = await fetchTokenWithRetry();
}
return token;

View File

@@ -257,9 +257,16 @@ async function testDeployment(
dot: true,
});
const bodies = globResult.reduce((b, f) => {
let data;
const r = path.relative(fixturePath, f);
b[r] = fs.readFileSync(f);
b[r][fileModeSymbol] = fs.statSync(f).mode;
const stat = fs.lstatSync(f);
if (stat.isSymbolicLink()) {
data = Buffer.from(fs.readlinkSync(f), 'utf8');
} else {
data = fs.readFileSync(f);
}
data[fileModeSymbol] = stat.mode;
b[r] = data;
return b;
}, {});

View File

@@ -3,10 +3,13 @@ const path = require('path');
const NUMBER_OF_CHUNKS = 5;
const MINIMUM_PER_CHUNK = 1;
const runnersMap = new Map([['test-integration-once', ['ubuntu-latest']]]);
const runnersMap = new Map([
['test-integration-once', ['ubuntu-latest']],
['test-integration-dev', ['ubuntu-latest', 'macos-latest']],
]);
async function getChunkedTests() {
const scripts = ['test-integration-once'];
const scripts = [...runnersMap.keys()];
const rootPath = path.resolve(__dirname, '..');
const dryRunText = (

142
yarn.lock
View File

@@ -2838,10 +2838,10 @@
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.24.0.tgz#a2e8783a185caa99b5d8961a57dfc9665de16296"
integrity sha512-crqItMcIwCkvdXY/V3/TzrHJQx6nbIaRqE1cOopJhgGX6izvNov40SmD//nS5flfEvdK54YGjwVVq+zG6crjOg==
"@vercel/nft@0.18.1":
version "0.18.1"
resolved "https://registry.yarnpkg.com/@vercel/nft/-/nft-0.18.1.tgz#d1681f7fd538168553d8df19fc3761ca643ebb73"
integrity sha512-i2zmXs8ueqCe/dmQ0fzQk9MmXoqdqxR1ZsxPN8poHZfc3NQES1WTEsXkEoaL+RV5BKZi04lNpkoGwtqcxERAOQ==
"@vercel/nft@0.19.0":
version "0.19.0"
resolved "https://registry.yarnpkg.com/@vercel/nft/-/nft-0.19.0.tgz#56f2a17e0685b5c052158aafec3a9f31552de5b4"
integrity sha512-diHIP3/OHq/4wSkS4JJ7LqY6NAQOpCr83vpNZuKqx2PV7zrhwUH8CZ9QCu0SHkZh3LYaV0zcbGusVxTNw3DMvA==
dependencies:
"@mapbox/node-pre-gyp" "^1.0.5"
acorn "^8.6.0"
@@ -11681,83 +11681,89 @@ tunnel-agent@^0.6.0:
dependencies:
safe-buffer "^5.0.1"
turbo-darwin-64@1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/turbo-darwin-64/-/turbo-darwin-64-1.2.5.tgz#9a52d68388c79b00e765a7063c881012c8d89c06"
integrity sha512-AjMEF8hlA9vy1gXLHBruqgO42s0M0rKKZLQPM239wli5lKEprmxd8WMSjd9YmxRflS+/fwrXfjVl0QRhHjDIww==
turbo-darwin-64@1.2.9:
version "1.2.9"
resolved "https://registry.yarnpkg.com/turbo-darwin-64/-/turbo-darwin-64-1.2.9.tgz#001159794757f77c4b016fc56d045c5e7bfc9510"
integrity sha512-rVwDQpi6p0GwTiqSsvtA1b3RvKl8l2y+ElZ3EKGiIIJYZt1D6wBMJoADaZ9uZ/LWkT+WKfAWNtKdwRmuBAOS6g==
turbo-darwin-arm64@1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/turbo-darwin-arm64/-/turbo-darwin-arm64-1.2.5.tgz#c3a90dc682df94ffa8f8f6716f8ff1b7cde7724d"
integrity sha512-2kj4+X9XMGF9o398qVo4HDsaoPy2kcl77X+EYlq2bROoQlGXRrR7R+i/qMvLh4tLsSQAm5eOqEbFyvtMkxT/xg==
turbo-darwin-arm64@1.2.9:
version "1.2.9"
resolved "https://registry.yarnpkg.com/turbo-darwin-arm64/-/turbo-darwin-arm64-1.2.9.tgz#fb19615984d1780fdcdd9e54a607efb46a700e72"
integrity sha512-j7NgQHkQWWODw1I/saiqmjjD54uGAEq0qTTtLI3RoLaA+yI+awXmHwsiHRqsvGSyGJlBoKBcbxXkekLf21q3GA==
turbo-freebsd-64@1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/turbo-freebsd-64/-/turbo-freebsd-64-1.2.5.tgz#9a079417cfe43be3f4e6855530a9e7bf7c1d8ef4"
integrity sha512-29eQUiS/Fky7O8E0YzGh3EETPvMKmMDkFjJn4XtRGO+iZfkIxlqKnAUpT+8kx3nQ/5dAAoTGHflyf4FNEZaCKA==
turbo-freebsd-64@1.2.9:
version "1.2.9"
resolved "https://registry.yarnpkg.com/turbo-freebsd-64/-/turbo-freebsd-64-1.2.9.tgz#edb2ee840ba80c257068e339d10ac460c1f9fb10"
integrity sha512-+tLb3iCOrIeGrcOJZYey5mD9qgNgKYuwRRg6FeX/6TDITvZXcCS50A2uRbaD/PQzQKs1lHcshiCe/DRtbvJ63g==
turbo-freebsd-arm64@1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/turbo-freebsd-arm64/-/turbo-freebsd-arm64-1.2.5.tgz#3b0f1569c4d9ce40177a7259ba5bdc68021ff25d"
integrity sha512-WRFmzgXqXurdRntPrEb7hcOM1Zfjse8OC/sH3V8R9QspYE+upZ42m9ePLt2n5N2shc4XLced/9VFdczx9549Tw==
turbo-freebsd-arm64@1.2.9:
version "1.2.9"
resolved "https://registry.yarnpkg.com/turbo-freebsd-arm64/-/turbo-freebsd-arm64-1.2.9.tgz#aebfb5b07a2dd6e9211fb6d9827c2f2288e2ca73"
integrity sha512-gwI8jocTf036kc9GI1BebzftxrkT5pewHPA2iqvAXAJpX01G1x1iGcl8/uIbkbL5hp038nu+l2Kb+lRI96sJuA==
turbo-linux-32@1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/turbo-linux-32/-/turbo-linux-32-1.2.5.tgz#f4789961739b6280f97f0f258951851f842c9bfc"
integrity sha512-YBzKqXJEoORpPq7vwpNf9ovbVru9aQi7HD88fxYW1wvvuPdNx2ZAmjn8sEMZZPkndfOlf9fXgO3aXr0fjqUWMw==
turbo-linux-32@1.2.9:
version "1.2.9"
resolved "https://registry.yarnpkg.com/turbo-linux-32/-/turbo-linux-32-1.2.9.tgz#1462e45776d3ce93c57f2014745e7edb60910a44"
integrity sha512-Rm47bIsCHIae/DkXJ58YrWvdh8o4Ug9U4VnTDb9byXrz2B7624ol9XdfpXv429z7LXkQR1+WnwCMwFB4K6DyuQ==
turbo-linux-64@1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/turbo-linux-64/-/turbo-linux-64-1.2.5.tgz#5845e332707ac82a9668800d1585701cfd817889"
integrity sha512-a85WEfOj4Cw0zd/wo1xoRmqW4kZHAz63nf+vWINyxZOK2H899TCUs+KJpgsacafU0fO36l1rsx2fdUDce/3Dww==
turbo-linux-64@1.2.9:
version "1.2.9"
resolved "https://registry.yarnpkg.com/turbo-linux-64/-/turbo-linux-64-1.2.9.tgz#0eef4a6f6f267b773ea58c4bda86922092eda3eb"
integrity sha512-8Gqi+TzEdmOmxxAukU0NO0JlIqdm98C97u9qEsxWrXTFL/xL21gKCixqsBTEO7JOISC4M8VjArxjSsITRbkD5g==
turbo-linux-arm64@1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/turbo-linux-arm64/-/turbo-linux-arm64-1.2.5.tgz#73a3535755ff7354be09ff374a7c76bdf7cffda0"
integrity sha512-ZtPQx9yw+iMT+sYPYcrtbCye7a/aj93gA2krir4MI+CDp69LuHLuZOOfc8u4JCxSJTbRLoYcwJrdfB9uBSddIQ==
turbo-linux-arm64@1.2.9:
version "1.2.9"
resolved "https://registry.yarnpkg.com/turbo-linux-arm64/-/turbo-linux-arm64-1.2.9.tgz#57777d356bf74ef2cc284998ef86fe19c77b92c2"
integrity sha512-FVIeM7koUtyu1cNAJhPYjb90kL/ICdWoJr4PoZZYnqty5sxLsBg75bVErEDQeDzKQvwXLlcax2lEzHvaSyn/wg==
turbo-linux-arm@1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/turbo-linux-arm/-/turbo-linux-arm-1.2.5.tgz#337dc045e7377a1140fbf3162bdd1919d349fbd0"
integrity sha512-JlLk5cGmj5yRwBQuPMH36w5ZJg0sBfi+dxBZTkJUV9XM9MRgNUs0MkNnjh9ogGvB4R08HY4ud6XcyRdoKLs9pA==
turbo-linux-arm@1.2.9:
version "1.2.9"
resolved "https://registry.yarnpkg.com/turbo-linux-arm/-/turbo-linux-arm-1.2.9.tgz#2424016fb926143682f9029bd86a8d455979e075"
integrity sha512-OS+XCWiGFbuM7UNBVQdVbIJqxhVu9Sr2WxQgDcGZpCYn32yLLPlWDDGL0Cl/EG006J9k+VS1e4OzyM6kfMxS9Q==
turbo-linux-mips64le@1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/turbo-linux-mips64le/-/turbo-linux-mips64le-1.2.5.tgz#80f3c71f4a2f44d93e3ae9509c2c776d2f2842f6"
integrity sha512-3LLnEwKc5pf7MlUhwvq/ND2cx0f7v3LHK5587CVTQI9nnwgie42n5U168J7BPPPkIE0k0j4S1jeXU18DV3vWbA==
turbo-linux-mips64le@1.2.9:
version "1.2.9"
resolved "https://registry.yarnpkg.com/turbo-linux-mips64le/-/turbo-linux-mips64le-1.2.9.tgz#e3bb35f53cb84ff836cf42fc576b6197c92a5e8a"
integrity sha512-2zVBnOVivWGpl51qO/lycfw7euM4b04AXYUmhsWkUN3FygIwyNgjuiMU8rxQOlu9VGX8X+WXkX2gfbgTovTeFw==
turbo-linux-ppc64le@1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/turbo-linux-ppc64le/-/turbo-linux-ppc64le-1.2.5.tgz#5e1cfbab5be75209ca1b4b7a3266cb5053d769e0"
integrity sha512-1k4lBCu2jdQNF3KXjPAbOER5/j37AdBqHnuHB6JuiOocm+v3WgEfkctkqLrgow3q1HLeb4me3wGXstV//6dzSg==
turbo-linux-ppc64le@1.2.9:
version "1.2.9"
resolved "https://registry.yarnpkg.com/turbo-linux-ppc64le/-/turbo-linux-ppc64le-1.2.9.tgz#130041711579a1b6b3fe774d85c394425d45c0ac"
integrity sha512-EGgKyzf8IhodOF32BvE3Zlgbr/dSGuUbemC9RGSuhF1F1PMnP1nYS/t3JWN5QKZU4O2uWiIyLdC/0ZjtcGAcZQ==
turbo-windows-32@1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/turbo-windows-32/-/turbo-windows-32-1.2.5.tgz#2b7a7a768bc452769a219039c0c3371eb0cf7cdc"
integrity sha512-XT2g/kZopqARjs39MNVP5XysrK2R0P9QVnrRdVY72zgswLvvcvDI6SM5SPX/SWF4iLU5OEUlpCaUz5dJLGMGUw==
turbo-windows-32@1.2.9:
version "1.2.9"
resolved "https://registry.yarnpkg.com/turbo-windows-32/-/turbo-windows-32-1.2.9.tgz#89a0d8463dffba01627d69998bfe6ea5fa975511"
integrity sha512-XrMJMUtewlfksBUB0R7Tyw16IoqshVl6f/3R2ccMccddEMcvak0oW03FK9n+Y4F+wyIoJ22AVhu8jMv+HgEehA==
turbo-windows-64@1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/turbo-windows-64/-/turbo-windows-64-1.2.5.tgz#d9ba4265384dc3c66189b4cdfbc5f7bc39abfc57"
integrity sha512-Ut097JJv9qy/8cpHANB7/BH0uh2IZbUeSSRudTl8tfMX8ZEdla/NpJd+omMV4CwPRrZAO6SyKiTfeHFOt/6NgQ==
turbo-windows-64@1.2.9:
version "1.2.9"
resolved "https://registry.yarnpkg.com/turbo-windows-64/-/turbo-windows-64-1.2.9.tgz#a55e3f32996ce4a8a538f9667748e7a1129ed10e"
integrity sha512-ewhj4MrqcMpW/keag4xG7YRLTJ7PzcqBc6Kc96OGD2qfK/uJV/r7H3Xt09WuYHRWwPgGEeNn8utpqdqbYfCVDw==
turbo@1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/turbo/-/turbo-1.2.5.tgz#e7260e8250a128616b39bf65e655e53280cee861"
integrity sha512-KXk5BGCaiSSXhtorrLUILB3OTqZ/uruIi0ggb0jSp55ZDSS+G/4OANw7y5QuRjizCpjwunb47AAOox/2Zn2nbA==
turbo-windows-arm64@1.2.9:
version "1.2.9"
resolved "https://registry.yarnpkg.com/turbo-windows-arm64/-/turbo-windows-arm64-1.2.9.tgz#3dc635c0031a0998be0322f9a258553f7cb4eb6e"
integrity sha512-B8BoNb/yZWAyKwQUbs2+UFzLmOu/WGv/+ADT6SQfI8jOaTenS7Od4bbMsGJT0iXcqv+v8TcWKX83KmQ6gxBQpg==
turbo@1.2.9:
version "1.2.9"
resolved "https://registry.yarnpkg.com/turbo/-/turbo-1.2.9.tgz#61257149a2a29966c9941a16e0b5ad88b07b4e79"
integrity sha512-aPGzZqmUHE9yx9TS7wcAJnDmXiuQSNXDwU5b1KrgNlFuID18TL443wna79p7k4awmf4Yuhu1cSZIvO+se72iVQ==
optionalDependencies:
turbo-darwin-64 "1.2.5"
turbo-darwin-arm64 "1.2.5"
turbo-freebsd-64 "1.2.5"
turbo-freebsd-arm64 "1.2.5"
turbo-linux-32 "1.2.5"
turbo-linux-64 "1.2.5"
turbo-linux-arm "1.2.5"
turbo-linux-arm64 "1.2.5"
turbo-linux-mips64le "1.2.5"
turbo-linux-ppc64le "1.2.5"
turbo-windows-32 "1.2.5"
turbo-windows-64 "1.2.5"
turbo-darwin-64 "1.2.9"
turbo-darwin-arm64 "1.2.9"
turbo-freebsd-64 "1.2.9"
turbo-freebsd-arm64 "1.2.9"
turbo-linux-32 "1.2.9"
turbo-linux-64 "1.2.9"
turbo-linux-arm "1.2.9"
turbo-linux-arm64 "1.2.9"
turbo-linux-mips64le "1.2.9"
turbo-linux-ppc64le "1.2.9"
turbo-windows-32 "1.2.9"
turbo-windows-64 "1.2.9"
turbo-windows-arm64 "1.2.9"
tweetnacl@^0.14.3, tweetnacl@~0.14.0:
version "0.14.5"