Compare commits

..

3 Commits

Author SHA1 Message Date
Sean Massa
619ca93421 Publish Stable
- @vercel/build-utils@5.4.3
 - vercel@28.3.0
 - @vercel/client@12.2.5
 - @vercel/frameworks@1.1.6
 - @vercel/fs-detectors@3.3.0
 - @vercel/go@2.2.6
 - @vercel/hydrogen@0.0.19
 - @vercel/next@3.1.26
 - @vercel/node@2.5.15
 - @vercel/python@3.1.15
 - @vercel/redwood@1.0.24
 - @vercel/remix@1.0.25
 - @vercel/ruby@1.3.32
 - @vercel/static-build@1.0.24
2022-09-19 16:40:10 -05:00
Steven
cea2981512 [tests] Change some runNpmInstall() unit tests to mocks (#8581)
- Closes #8580
2022-09-19 21:30:32 +00:00
JJ Kasper
1f30e3a4b7 [next] Update app test fixture (#8584)
### Related Issues

Updates our test fixture for related changes in latest canary of
Next.js.

Fixes: https://vercel.slack.com/archives/CGU8HUTUH/p1663607276817069

### 📋 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-09-19 13:08:10 -07:00
57 changed files with 220 additions and 265 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/build-utils",
"version": "5.4.2",
"version": "5.4.3",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.js",

View File

@@ -20,6 +20,7 @@ afterEach(() => {
import path from 'path';
import { runNpmInstall, cloneEnv } from '../src';
import type { Meta } from '../src/types';
function getTestSpawnOpts(env: Record<string, string>) {
return { env: cloneEnv(process.env, env) };
@@ -31,7 +32,7 @@ function getNodeVersion(major: number) {
it('should not include peer dependencies when missing VERCEL_NPM_LEGACY_PEER_DEPS on node16', async () => {
const fixture = path.join(__dirname, 'fixtures', '20-npm-7');
const meta = {};
const meta: Meta = {};
const spawnOpts = getTestSpawnOpts({});
const nodeVersion = { major: 16 } as any;
await runNpmInstall(fixture, [], spawnOpts, meta, nodeVersion);
@@ -49,7 +50,7 @@ it('should not include peer dependencies when missing VERCEL_NPM_LEGACY_PEER_DEP
it('should include peer dependencies when VERCEL_NPM_LEGACY_PEER_DEPS=1 on node16', async () => {
const fixture = path.join(__dirname, 'fixtures', '20-npm-7');
const meta = {};
const meta: Meta = {};
const spawnOpts = getTestSpawnOpts({ VERCEL_NPM_LEGACY_PEER_DEPS: '1' });
const nodeVersion = getNodeVersion(16);
await runNpmInstall(fixture, [], spawnOpts, meta, nodeVersion);
@@ -72,7 +73,7 @@ it('should include peer dependencies when VERCEL_NPM_LEGACY_PEER_DEPS=1 on node1
it('should not include peer dependencies when VERCEL_NPM_LEGACY_PEER_DEPS=1 on node14', async () => {
const fixture = path.join(__dirname, 'fixtures', '20-npm-7');
const meta = {};
const meta: Meta = {};
const spawnOpts = getTestSpawnOpts({ VERCEL_NPM_LEGACY_PEER_DEPS: '1' });
const nodeVersion = getNodeVersion(14);
await runNpmInstall(fixture, [], spawnOpts, meta, nodeVersion);
@@ -90,7 +91,7 @@ it('should not include peer dependencies when VERCEL_NPM_LEGACY_PEER_DEPS=1 on n
it('should not include peer dependencies when VERCEL_NPM_LEGACY_PEER_DEPS=1 on node16 with corepack enabled', async () => {
const fixture = path.join(__dirname, 'fixtures', '20-npm-7');
const meta = {};
const meta: Meta = {};
const spawnOpts = getTestSpawnOpts({
VERCEL_NPM_LEGACY_PEER_DEPS: '1',
ENABLE_EXPERIMENTAL_COREPACK: '1',
@@ -108,3 +109,64 @@ it('should not include peer dependencies when VERCEL_NPM_LEGACY_PEER_DEPS=1 on n
env: expect.any(Object),
});
});
it('should only invoke `runNpmInstall()` once per `package.json` file (serial)', async () => {
const meta: Meta = {};
const fixture = path.join(__dirname, 'fixtures', '02-zero-config-api');
const apiDir = path.join(fixture, 'api');
const run1 = await runNpmInstall(apiDir, [], undefined, meta);
expect(run1).toEqual(true);
expect(
(meta.runNpmInstallSet as Set<string>).has(
path.join(fixture, 'package.json')
)
).toEqual(true);
const run2 = await runNpmInstall(apiDir, [], undefined, meta);
expect(run2).toEqual(false);
const run3 = await runNpmInstall(fixture, [], undefined, meta);
expect(run3).toEqual(false);
expect(spawnMock.mock.calls.length).toBe(1);
const args = spawnMock.mock.calls[0];
expect(args[0]).toEqual('yarn');
expect(args[1]).toEqual(['install']);
expect(args[2]).toEqual({
cwd: apiDir,
prettyCommand: 'yarn install',
stdio: 'inherit',
env: expect.any(Object),
});
});
it('should only invoke `runNpmInstall()` once per `package.json` file (parallel)', async () => {
const meta: Meta = {};
const fixture = path.join(__dirname, 'fixtures', '02-zero-config-api');
const apiDir = path.join(fixture, 'api');
const [run1, run2, run3] = await Promise.all([
runNpmInstall(apiDir, [], undefined, meta),
runNpmInstall(apiDir, [], undefined, meta),
runNpmInstall(fixture, [], undefined, meta),
]);
expect(run1).toEqual(true);
expect(run2).toEqual(false);
expect(run3).toEqual(false);
expect(
(meta.runNpmInstallSet as Set<string>).has(
path.join(fixture, 'package.json')
)
).toEqual(true);
expect(spawnMock.mock.calls.length).toBe(1);
const args = spawnMock.mock.calls[0];
expect(args[0]).toEqual('yarn');
expect(args[1]).toEqual(['install']);
expect(args[2]).toEqual({
cwd: apiDir,
prettyCommand: 'yarn install',
stdio: 'inherit',
env: expect.any(Object),
});
});

View File

@@ -1,7 +1,6 @@
import ms from 'ms';
import path from 'path';
import fs, { readlink } from 'fs-extra';
import retry from 'async-retry';
import { strict as assert, strictEqual } from 'assert';
import { createZip } from '../src/lambda';
import { getSupportedNodeVersion } from '../src/fs/node-version';
@@ -16,10 +15,9 @@ import {
runPackageJsonScript,
scanParentDirs,
FileBlob,
Meta,
} from '../src';
jest.setTimeout(20 * 1000);
jest.setTimeout(10 * 1000);
async function expectBuilderError(promise: Promise<any>, pattern: string) {
let result;
@@ -577,54 +575,3 @@ it('should detect package.json in nested frontend', async () => {
// There is no lockfile but this test will pick up vercel/vercel/yarn.lock
expect(result.packageJsonPath).toEqual(path.join(fixture, 'package.json'));
});
it('should only invoke `runNpmInstall()` once per `package.json` file (serial)', async () => {
const meta: Meta = {};
const fixture = path.join(__dirname, 'fixtures', '02-zero-config-api');
const apiDir = path.join(fixture, 'api');
const retryOpts = { maxRetryTime: 1000 };
let run1, run2, run3;
await retry(async () => {
run1 = await runNpmInstall(apiDir, [], undefined, meta);
expect(run1).toEqual(true);
expect(
(meta.runNpmInstallSet as Set<string>).has(
path.join(fixture, 'package.json')
)
).toEqual(true);
}, retryOpts);
await retry(async () => {
run2 = await runNpmInstall(apiDir, [], undefined, meta);
expect(run2).toEqual(false);
}, retryOpts);
await retry(async () => {
run3 = await runNpmInstall(fixture, [], undefined, meta);
expect(run3).toEqual(false);
}, retryOpts);
});
it('should only invoke `runNpmInstall()` once per `package.json` file (parallel)', async () => {
const meta: Meta = {};
const fixture = path.join(__dirname, 'fixtures', '02-zero-config-api');
const apiDir = path.join(fixture, 'api');
let results: [boolean, boolean, boolean] | undefined;
await retry(
async () => {
results = await Promise.all([
runNpmInstall(apiDir, [], undefined, meta),
runNpmInstall(apiDir, [], undefined, meta),
runNpmInstall(fixture, [], undefined, meta),
]);
},
{ maxRetryTime: 3000 }
);
const [run1, run2, run3] = results || [];
expect(run1).toEqual(true);
expect(run2).toEqual(false);
expect(run3).toEqual(false);
expect(
(meta.runNpmInstallSet as Set<string>).has(
path.join(fixture, 'package.json')
)
).toEqual(true);
});

View File

@@ -1,6 +1,6 @@
{
"name": "vercel",
"version": "28.2.5",
"version": "28.3.0",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Vercel",
@@ -41,16 +41,16 @@
"node": ">= 14"
},
"dependencies": {
"@vercel/build-utils": "5.4.2",
"@vercel/go": "2.2.5",
"@vercel/hydrogen": "0.0.18",
"@vercel/next": "3.1.25",
"@vercel/node": "2.5.14",
"@vercel/python": "3.1.14",
"@vercel/redwood": "1.0.23",
"@vercel/remix": "1.0.24",
"@vercel/ruby": "1.3.31",
"@vercel/static-build": "1.0.23",
"@vercel/build-utils": "5.4.3",
"@vercel/go": "2.2.6",
"@vercel/hydrogen": "0.0.19",
"@vercel/next": "3.1.26",
"@vercel/node": "2.5.15",
"@vercel/python": "3.1.15",
"@vercel/redwood": "1.0.24",
"@vercel/remix": "1.0.25",
"@vercel/ruby": "1.3.32",
"@vercel/static-build": "1.0.24",
"update-notifier": "5.1.0"
},
"devDependencies": {
@@ -95,9 +95,9 @@
"@types/which": "1.3.2",
"@types/write-json-file": "2.2.1",
"@types/yauzl-promise": "2.1.0",
"@vercel/client": "12.2.4",
"@vercel/frameworks": "1.1.5",
"@vercel/fs-detectors": "3.2.0",
"@vercel/client": "12.2.5",
"@vercel/frameworks": "1.1.6",
"@vercel/fs-detectors": "3.3.0",
"@vercel/fun": "1.0.4",
"@vercel/ncc": "0.24.0",
"@zeit/source-map-support": "0.6.2",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/client",
"version": "12.2.4",
"version": "12.2.5",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"homepage": "https://vercel.com",
@@ -43,7 +43,7 @@
]
},
"dependencies": {
"@vercel/build-utils": "5.4.2",
"@vercel/build-utils": "5.4.3",
"@vercel/routing-utils": "2.0.2",
"@zeit/fetch": "5.2.0",
"async-retry": "1.2.3",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/frameworks",
"version": "1.1.5",
"version": "1.1.6",
"main": "./dist/frameworks.js",
"types": "./dist/frameworks.d.ts",
"files": [

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/fs-detectors",
"version": "3.2.0",
"version": "3.3.0",
"description": "Vercel filesystem detectors",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
@@ -19,7 +19,7 @@
"test-unit": "yarn test"
},
"dependencies": {
"@vercel/frameworks": "1.1.5",
"@vercel/frameworks": "1.1.6",
"@vercel/routing-utils": "2.0.2",
"glob": "8.0.3",
"js-yaml": "4.1.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/go",
"version": "2.2.5",
"version": "2.2.6",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
@@ -35,7 +35,7 @@
"@types/jest": "28.1.6",
"@types/node-fetch": "^2.3.0",
"@types/tar": "^4.0.0",
"@vercel/build-utils": "5.4.2",
"@vercel/build-utils": "5.4.3",
"@vercel/ncc": "0.24.0",
"async-retry": "1.3.1",
"execa": "^1.0.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/hydrogen",
"version": "0.0.18",
"version": "0.0.19",
"license": "MIT",
"main": "./dist/index.js",
"homepage": "https://vercel.com/docs",
@@ -21,7 +21,7 @@
"devDependencies": {
"@types/jest": "27.5.1",
"@types/node": "*",
"@vercel/build-utils": "5.4.2",
"@vercel/build-utils": "5.4.3",
"typescript": "4.6.4"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/next",
"version": "3.1.25",
"version": "3.1.26",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -44,7 +44,7 @@
"@types/semver": "6.0.0",
"@types/text-table": "0.2.1",
"@types/webpack-sources": "3.2.0",
"@vercel/build-utils": "5.4.2",
"@vercel/build-utils": "5.4.3",
"@vercel/nft": "0.22.1",
"@vercel/routing-utils": "2.0.2",
"async-sema": "3.0.1",

View File

@@ -0,0 +1,10 @@
export default function Root({ children }) {
return (
<html className="this-is-another-document-html">
<head>
<title>{`hello world`}</title>
</head>
<body className="this-is-another-document-body">{children}</body>
</html>
);
}

View File

@@ -1,18 +0,0 @@
export async function getServerSideProps() {
return {
props: {
world: 'world',
},
};
}
export default function Root({ children, world }) {
return (
<html className="this-is-another-document-html">
<head>
<title>{`hello ${world}`}</title>
</head>
<body className="this-is-another-document-body">{children}</body>
</html>
);
}

View File

@@ -1,3 +1,5 @@
'client';
import { useState, useEffect } from 'react';
import style from './style.module.css';

View File

@@ -1,3 +1,5 @@
'client';
import { useState, useEffect } from 'react';
import styles from './style.module.css';

View File

@@ -1,15 +1,7 @@
export async function getServerSideProps({ params }) {
return {
props: {
id: params.id,
},
};
}
export default function DeploymentsPage(props) {
return (
<>
<p>hello from app/dashboard/deployments/[id]. ID is: {props.id}</p>
<p>hello from app/dashboard/deployments/[id]. ID is: {props.params.id}</p>
</>
);
}

View File

@@ -0,0 +1,8 @@
export default function DeploymentsLayout({ message, children }) {
return (
<>
<h2>Deployments hello</h2>
{children}
</>
);
}

View File

@@ -1,16 +0,0 @@
export function getServerSideProps() {
return {
props: {
message: 'hello',
},
};
}
export default function DeploymentsLayout({ message, children }) {
return (
<>
<h2>Deployments {message}</h2>
{children}
</>
);
}

View File

@@ -1,3 +1,5 @@
'client';
export default function LazyComponent() {
return (
<>

View File

@@ -1,4 +1,4 @@
import { ClientComponent } from './test.client.js';
import { ClientComponent } from './test.js';
export default function DashboardIndexPage() {
return (

View File

@@ -1,6 +1,8 @@
'client';
import { useState, lazy } from 'react';
const Lazy = lazy(() => import('./lazy.client.js'));
const Lazy = lazy(() => import('./lazy.js'));
export function ClientComponent() {
let [state] = useState('client');

View File

@@ -1,11 +1,3 @@
export async function getServerSideProps({ params }) {
return {
props: {
params,
},
};
}
export default function IdLayout({ children, params }) {
return (
<>

View File

@@ -1,11 +1,3 @@
export async function getServerSideProps({ params }) {
return {
props: {
params,
},
};
}
export default function IdPage({ children, params }) {
return (
<>

View File

@@ -1,11 +1,3 @@
export async function getServerSideProps({ params }) {
return {
props: {
params,
},
};
}
export default function CategoryLayout({ children, params }) {
return (
<>

View File

@@ -1,11 +1,3 @@
export async function getServerSideProps({ params }) {
return {
props: {
params,
},
};
}
export default function DynamicLayout({ children, params }) {
return (
<>

View File

@@ -0,0 +1,14 @@
export default function Root({ children }) {
return (
<html className="this-is-the-document-html">
<head>
<title>{`hello world`}</title>
</head>
<body className="this-is-the-document-body">{children}</body>
</html>
);
}
export const config = {
revalidate: 0,
};

View File

@@ -1,18 +0,0 @@
export async function getServerSideProps() {
return {
props: {
world: 'world',
},
};
}
export default function Root({ children, custom, world }) {
return (
<html className="this-is-the-document-html">
<head>
<title>{`hello ${world}`}</title>
</head>
<body className="this-is-the-document-body">{children}</body>
</html>
);
}

View File

@@ -0,0 +1,7 @@
export default function DeploymentsPage(props) {
return (
<>
<p>hello from app/partial-match-[id]. ID is: {props.params.id}</p>
</>
);
}

View File

@@ -1,15 +0,0 @@
export async function getServerSideProps({ params }) {
return {
props: {
id: params.id,
},
};
}
export default function DeploymentsPage(props) {
return (
<>
<p>hello from app/partial-match-[id]. ID is: {props.id}</p>
</>
);
}

View File

@@ -1,3 +1,5 @@
'client';
export default function ShouldNotServeClientDotJs(props) {
return (
<>

View File

@@ -0,0 +1,18 @@
import { experimental_use as use } from 'react';
async function getData() {
await new Promise(resolve => setTimeout(resolve, 1000));
return {
message: 'hello from slow layout',
};
}
export default function SlowLayout(props) {
const data = use(getData());
return (
<>
<p id="slow-layout-message">{data.message}</p>
{props.children}
</>
);
}

View File

@@ -1,17 +0,0 @@
export async function getServerSideProps() {
await new Promise(resolve => setTimeout(resolve, 1000));
return {
props: {
message: 'hello from slow layout',
},
};
}
export default function SlowLayout(props) {
return (
<>
<p id="slow-layout-message">{props.message}</p>
{props.children}
</>
);
}

View File

@@ -0,0 +1,13 @@
import { experimental_use as use } from 'react';
async function getData() {
await new Promise(resolve => setTimeout(resolve, 5000));
return {
message: 'hello from slow page',
};
}
export default function SlowPage(props) {
const data = use(getData());
return <h1 id="slow-page-message">{data.message}</h1>;
}

View File

@@ -1,12 +0,0 @@
export async function getServerSideProps() {
await new Promise(resolve => setTimeout(resolve, 5000));
return {
props: {
message: 'hello from slow page',
},
};
}
export default function SlowPage(props) {
return <h1 id="slow-page-message">{props.message}</h1>;
}

View File

@@ -0,0 +1,18 @@
import { experimental_use as use } from 'react';
async function getData() {
await new Promise(resolve => setTimeout(resolve, 5000));
return {
message: 'hello from slow layout',
};
}
export default function SlowLayout(props) {
const data = use(getData());
return (
<>
<p id="slow-layout-message">{data.message}</p>
{props.children}
</>
);
}

View File

@@ -1,17 +0,0 @@
export async function getServerSideProps() {
await new Promise(resolve => setTimeout(resolve, 5000));
return {
props: {
message: 'hello from slow layout',
},
};
}
export default function SlowLayout(props) {
return (
<>
<p id="slow-layout-message">{props.message}</p>
{props.children}
</>
);
}

View File

@@ -0,0 +1,13 @@
import { experimental_use as use } from 'react';
async function getData() {
await new Promise(resolve => setTimeout(resolve, 5000));
return {
message: 'hello from slow page',
};
}
export default function SlowPage(props) {
const data = use(getData());
return <h1 id="slow-page-message">{data.message}</h1>;
}

View File

@@ -1,12 +0,0 @@
export async function getServerSideProps() {
await new Promise(resolve => setTimeout(resolve, 5000));
return {
props: {
message: 'hello from slow page',
},
};
}
export default function SlowPage(props) {
return <h1 id="slow-page-message">{props.message}</h1>;
}

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/node",
"version": "2.5.14",
"version": "2.5.15",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
@@ -31,7 +31,7 @@
"dependencies": {
"@edge-runtime/vm": "1.1.0-beta.32",
"@types/node": "*",
"@vercel/build-utils": "5.4.2",
"@vercel/build-utils": "5.4.3",
"@vercel/node-bridge": "3.0.0",
"@vercel/static-config": "2.0.3",
"edge-runtime": "1.1.0-beta.32",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/python",
"version": "3.1.14",
"version": "3.1.15",
"main": "./dist/index.js",
"license": "MIT",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -22,7 +22,7 @@
"devDependencies": {
"@types/execa": "^0.9.0",
"@types/jest": "27.4.1",
"@vercel/build-utils": "5.4.2",
"@vercel/build-utils": "5.4.3",
"@vercel/ncc": "0.24.0",
"execa": "^1.0.0",
"typescript": "4.3.4"

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/redwood",
"version": "1.0.23",
"version": "1.0.24",
"main": "./dist/index.js",
"license": "MIT",
"homepage": "https://vercel.com/docs",
@@ -27,6 +27,6 @@
"@types/aws-lambda": "8.10.19",
"@types/node": "*",
"@types/semver": "6.0.0",
"@vercel/build-utils": "5.4.2"
"@vercel/build-utils": "5.4.3"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/remix",
"version": "1.0.24",
"version": "1.0.25",
"license": "MIT",
"main": "./dist/index.js",
"homepage": "https://vercel.com/docs",
@@ -25,7 +25,7 @@
"devDependencies": {
"@types/jest": "27.5.1",
"@types/node": "*",
"@vercel/build-utils": "5.4.2",
"@vercel/build-utils": "5.4.3",
"typescript": "4.6.4"
}
}

View File

@@ -1,7 +1,7 @@
{
"name": "@vercel/ruby",
"author": "Nathan Cahill <nathan@nathancahill.com>",
"version": "1.3.31",
"version": "1.3.32",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/ruby",
@@ -22,7 +22,7 @@
"devDependencies": {
"@types/fs-extra": "8.0.0",
"@types/semver": "6.0.0",
"@vercel/build-utils": "5.4.2",
"@vercel/build-utils": "5.4.3",
"@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": "1.0.23",
"version": "1.0.24",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/build-step",
@@ -36,8 +36,8 @@
"@types/ms": "0.7.31",
"@types/node-fetch": "2.5.4",
"@types/promise-timeout": "1.3.0",
"@vercel/build-utils": "5.4.2",
"@vercel/frameworks": "1.1.5",
"@vercel/build-utils": "5.4.3",
"@vercel/frameworks": "1.1.6",
"@vercel/ncc": "0.24.0",
"@vercel/routing-utils": "2.0.2",
"fs-extra": "10.0.0",