Compare commits

...

13 Commits

Author SHA1 Message Date
JJ Kasper
c1c8b454cc Publish Stable
- @vercel/build-utils@6.2.1
 - vercel@28.15.2
 - @vercel/client@12.3.7
 - @vercel/fs-detectors@3.7.10
 - @vercel/gatsby-plugin-vercel-builder@1.1.2
 - @vercel/go@2.3.3
 - @vercel/hydrogen@0.0.49
 - @vercel/next@3.4.1
 - @vercel/node@2.9.2
 - @vercel/python@3.1.45
 - @vercel/redwood@1.1.1
 - @vercel/remix@1.2.12
 - @vercel/ruby@1.3.61
 - @vercel/static-build@1.3.4
2023-02-07 11:51:17 -08:00
JJ Kasper
e2105e47b5 [build-utils] Add passQuery field to Prerender (#9388) 2023-02-06 16:57:17 -08:00
최지민(Jeemin Choi)
76d58673fc [cli] Add --no-color mode (#8826)
Co-authored-by: Sean Massa <EndangeredMassa@gmail.com>
Co-authored-by: Chris Barber <chris.barber@vercel.com>
2023-02-06 16:45:17 -06:00
Andy Bitz
a585969dd3 Publish Stable
- @vercel/build-utils@6.2.0
 - vercel@28.15.1
 - @vercel/client@12.3.6
 - @vercel/fs-detectors@3.7.9
 - @vercel/gatsby-plugin-vercel-builder@1.1.1
 - @vercel/go@2.3.2
 - @vercel/hydrogen@0.0.48
 - @vercel/next@3.4.0
 - @vercel/node@2.9.1
 - @vercel/python@3.1.44
 - @vercel/redwood@1.1.0
 - @vercel/remix@1.2.11
 - @vercel/ruby@1.3.60
 - @vercel/static-build@1.3.3
2023-02-06 17:24:54 +01:00
Andy
35eca33b44 [redwood] Consider all Lambda options (#9386) 2023-02-06 15:46:18 +01:00
Andy
d608153961 [next][build-utils] Add support for cron to vercel.json (#9374) 2023-02-06 12:28:41 +01:00
Bishal Shrestha
a4cfc5f943 [docs] Add troubleshooting step for no serverless pages error (#9333) 2023-02-03 15:23:20 -08:00
chloetedder
2eef3e3ddb [fs-detectors] Add fix for if monorepo and proj at root (#9353)
If there is a monorepo that has one project at the root level we want to
return commands without the relative to root prefixes

---------

Co-authored-by: Chris Barber <chris.barber@vercel.com>
2023-02-03 16:56:22 -06:00
Swarnava Sengupta
8120fd3d7a [examples] Update Astro example to v2 (#9371) 2023-02-03 14:12:29 -05:00
Andy McKay
ba498f3a8e [python] Cope with duplicate header values (#9205)
There are times when a request can arrive for a Python function with headers as a list. One of those examples is this header `x-vercel-proxied-for` which apparently is set twice. Example:

`[b'x-vercel-proxied-for', [b'207.81.134.243', b'172.71.147.74']]`

I took a quick scan through the other Python server implementations and I don't think any of them manipulate the value of the HTTP headers, the way the ASGI one does so I think we are good there.

To reproduce:

`curl https://..../ -H "foo: bar" -H "foo: bar"`

Will fail.

Fixes: https://github.com/vercel/vercel/issues/9132
2023-02-03 17:01:02 +00:00
Steven
b5a9408272 [node] Add log for unused config runtime (#9373)
Both `runtime: undefined` and `runtime: nodejs` have the same behavior
but we want to change that in the future.

The first step is to see if `runtime: nodejs` is currently used at all.
2023-02-03 10:46:18 -05:00
Nathan Rajlich
946f7f0bfc [remix] Remove render path (#9365)
Instead of outputting a single SSR function at `/render` path, scan the
build manifest file to determine the proper paths to output the SSR
function at.
2023-02-02 14:29:52 -08:00
Ethan Arrowood
804a3863e7 [cli] add charset to content-type headers for vc dev (#9364)
Adds `charset: utf8` to the `content-type` header
2023-02-02 01:07:08 +00:00
84 changed files with 1496 additions and 1372 deletions

View File

@@ -24,7 +24,7 @@ npm install next --save
}
```
3. Add `target: 'serverless'` to `next.config.js`
3. Add `target: 'serverless'` to `next.config.js` [deprecated]
```js
module.exports = {
@@ -43,3 +43,5 @@ module.exports = {
"builds": [{ "src": "package.json", "use": "@vercel/next" }]
}
```
6. Make sure you have the correct Node.js version selected for your build step in your project settings (`https://vercel.com/[username]/[project]/settings`)

View File

@@ -8,7 +8,7 @@
"astro": "astro"
},
"devDependencies": {
"astro": "^1.6.10",
"web-vitals": "^3.1.0"
"astro": "^2.0.6",
"web-vitals": "^3.1.1"
}
}

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -228,7 +228,7 @@ export async function getLambdaOptionsFromFunction({
sourceFile,
config,
}: GetLambdaOptionsFromFunctionOptions): Promise<
Pick<LambdaOptions, 'memory' | 'maxDuration'>
Pick<LambdaOptions, 'memory' | 'maxDuration' | 'cron'>
> {
if (config?.functions) {
for (const [pattern, fn] of Object.entries(config.functions)) {
@@ -236,6 +236,7 @@ export async function getLambdaOptionsFromFunction({
return {
memory: fn.memory,
maxDuration: fn.maxDuration,
cron: fn.cron,
};
}
}

View File

@@ -10,6 +10,7 @@ interface PrerenderOptions {
allowQuery?: string[];
initialHeaders?: Record<string, string>;
initialStatus?: number;
passQuery?: boolean;
}
export class Prerender {
@@ -22,6 +23,7 @@ export class Prerender {
public allowQuery?: string[];
public initialHeaders?: Record<string, string>;
public initialStatus?: number;
public passQuery?: boolean;
constructor({
expiration,
@@ -32,6 +34,7 @@ export class Prerender {
allowQuery,
initialHeaders,
initialStatus,
passQuery,
}: PrerenderOptions) {
this.type = 'Prerender';
this.expiration = expiration;
@@ -52,6 +55,17 @@ export class Prerender {
}
this.group = group;
if (passQuery === true) {
this.passQuery = true;
} else if (
typeof passQuery !== 'boolean' &&
typeof passQuery !== 'undefined'
) {
throw new Error(
`The \`passQuery\` argument for \`Prerender\` must be a boolean.`
);
}
if (bypassToken == null) {
this.bypassToken = null;
} else if (typeof bypassToken === 'string') {

View File

@@ -31,6 +31,11 @@ export const functionsSchema = {
type: 'string',
maxLength: 256,
},
cron: {
type: 'string',
minLength: 9,
maxLength: 256,
},
},
},
},

View File

@@ -319,6 +319,7 @@ export interface BuilderFunctions {
runtime?: string;
includeFiles?: string;
excludeFiles?: string;
cron?: Cron;
};
}

View File

@@ -318,6 +318,49 @@ it('should support initialHeaders and initialStatus correctly', async () => {
});
});
it('should support passQuery correctly', async () => {
new Prerender({
expiration: 1,
fallback: null,
group: 1,
bypassToken: 'some-long-bypass-token-to-make-it-work',
passQuery: true,
});
new Prerender({
expiration: 1,
fallback: null,
group: 1,
bypassToken: 'some-long-bypass-token-to-make-it-work',
passQuery: false,
});
new Prerender({
expiration: 1,
fallback: null,
group: 1,
bypassToken: 'some-long-bypass-token-to-make-it-work',
passQuery: undefined,
});
new Prerender({
expiration: 1,
fallback: null,
group: 1,
bypassToken: 'some-long-bypass-token-to-make-it-work',
});
expect(() => {
new Prerender({
expiration: 1,
fallback: null,
group: 1,
bypassToken: 'some-long-bypass-token-to-make-it-work',
// @ts-expect-error testing invalid field
passQuery: 'true',
});
}).toThrowError(
`The \`passQuery\` argument for \`Prerender\` must be a boolean.`
);
});
it('should support require by path for legacy builders', () => {
const index = require('../');

View File

@@ -1,6 +1,6 @@
{
"name": "vercel",
"version": "28.15.0",
"version": "28.15.2",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Vercel",
@@ -41,16 +41,16 @@
"node": ">= 14"
},
"dependencies": {
"@vercel/build-utils": "6.1.0",
"@vercel/go": "2.3.1",
"@vercel/hydrogen": "0.0.47",
"@vercel/next": "3.3.21",
"@vercel/node": "2.9.0",
"@vercel/python": "3.1.43",
"@vercel/redwood": "1.0.54",
"@vercel/remix": "1.2.10",
"@vercel/ruby": "1.3.59",
"@vercel/static-build": "1.3.2"
"@vercel/build-utils": "6.2.1",
"@vercel/go": "2.3.3",
"@vercel/hydrogen": "0.0.49",
"@vercel/next": "3.4.1",
"@vercel/node": "2.9.2",
"@vercel/python": "3.1.45",
"@vercel/redwood": "1.1.1",
"@vercel/remix": "1.2.12",
"@vercel/ruby": "1.3.61",
"@vercel/static-build": "1.3.4"
},
"devDependencies": {
"@alex_neo/jest-expect-message": "1.0.5",
@@ -93,10 +93,10 @@
"@types/which": "1.3.2",
"@types/write-json-file": "2.2.1",
"@types/yauzl-promise": "2.1.0",
"@vercel/client": "12.3.5",
"@vercel/client": "12.3.7",
"@vercel/error-utils": "1.0.8",
"@vercel/frameworks": "1.3.0",
"@vercel/fs-detectors": "3.7.8",
"@vercel/fs-detectors": "3.7.10",
"@vercel/fun": "1.0.4",
"@vercel/ncc": "0.24.0",
"@vercel/routing-utils": "2.1.8",

View File

@@ -32,6 +32,7 @@ const help = () => {
'DIR'
)} Path to the global ${'`.vercel`'} directory
-d, --debug Debug mode [off]
--no-color No color mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token

View File

@@ -33,6 +33,7 @@ const help = () => {
-h, --help Output usage information
-d, --debug Debug mode [off]
--no-color No color mode [off]
-b, --bad Known bad URL
-g, --good Known good URL
-o, --open Automatically open each URL in the browser

View File

@@ -118,6 +118,7 @@ const help = () => {
--output [path] Directory where built assets should be written to
--prod Build a production deployment
-d, --debug Debug mode [off]
--no-color No color mode [off]
-y, --yes Skip the confirmation prompt about pulling environment variables and project settings when not found locally
${chalk.dim('Examples:')}

View File

@@ -37,6 +37,7 @@ const help = () => {
'DIR'
)} Path to the global ${'`.vercel`'} directory
-d, --debug Debug mode [off]
--no-color No color mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token

View File

@@ -53,6 +53,7 @@ export const help = () => `
'DIR'
)} Path to the global ${'`.vercel`'} directory
-d, --debug Debug mode [off]
--no-color No color mode [off]
-f, --force Force a new deployment even if nothing has changed
--with-cache Retain build cache when using "--force"
-t ${chalk.underline('TOKEN')}, --token=${chalk.underline(

View File

@@ -31,6 +31,7 @@ const help = () => {
-h, --help Output usage information
-d, --debug Debug mode [off]
--no-color No color mode [off]
-l, --listen [uri] Specify a URI endpoint on which to listen [0.0.0.0:3000]
-t, --token [token] Specify an Authorization Token
-y, --yes Skip questions when setting up new project using default scope and settings

View File

@@ -33,6 +33,7 @@ const help = () => {
'DIR'
)} Path to the global ${'`.vercel`'} directory
-d, --debug Debug mode [off]
--no-color No color mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token

View File

@@ -33,6 +33,7 @@ const help = () => {
-h, --help Output usage information
-d, --debug Debug mode [off]
--no-color No color mode [off]
-f, --force Force a domain on a project and remove it from an existing one
-A ${chalk.bold.underline('FILE')}, --local-config=${chalk.bold.underline(
'FILE'

View File

@@ -40,6 +40,7 @@ const help = () => {
'DIR'
)} Path to the global ${'`.vercel`'} directory
-d, --debug Debug mode [off]
--no-color No color mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token

View File

@@ -21,6 +21,7 @@ const help = () => {
-h, --help Output usage information
-d, --debug Debug mode [off]
--no-color No color mode [off]
-f, --force Overwrite destination directory if exists [off]
${chalk.dim('Examples:')}

View File

@@ -32,6 +32,7 @@ const help = () => {
'TOKEN'
)} Login token
-d, --debug Debug mode [off]
--no-color No color mode [off]
-S, --scope Set a custom scope
${chalk.dim('Examples:')}

View File

@@ -19,6 +19,7 @@ const help = () => {
'DIR'
)} Path to the global ${'`.vercel`'} directory
-d, --debug Debug mode [off]
--no-color No color mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token

View File

@@ -36,6 +36,7 @@ const help = () => {
'DIR'
)} Path to the global ${'`.vercel`'} directory
-d, --debug Debug mode [off]
--no-color No color mode [off]
-y, --yes Skip questions when setting up new project using default scope and settings
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'

View File

@@ -23,6 +23,7 @@ const help = () => {
${chalk.dim('Options:')}
-h, --help Output usage information
--no-color No color mode [off]
-A ${chalk.bold.underline('FILE')}, --local-config=${chalk.bold.underline(
'FILE'
)} Path to the local ${'`vercel.json`'} file

View File

@@ -23,6 +23,7 @@ const help = () => {
'DIR'
)} Path to the global ${'`.vercel`'} directory
-d, --debug Debug mode [off]
--no-color No color mode [off]
-f, --follow Wait for additional data [off]
-n ${chalk.bold.underline(
'NUMBER'

View File

@@ -31,6 +31,7 @@ const help = () => {
'DIR'
)} Path to the global ${'`.vercel`'} directory
-d, --debug Debug mode [off]
--no-color No color mode [off]
--environment [environment] Deployment environment [development]
-y, --yes Skip questions when setting up new project using default scope and settings

View File

@@ -39,6 +39,7 @@ const help = () => {
'DIR'
)} Path to the global ${'`.vercel`'} directory
-d, --debug Debug mode [off]
--no-color No color mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token

View File

@@ -28,6 +28,7 @@ const help = () => {
'DIR'
)} Path to the global ${'`.vercel`'} directory
-d, --debug Debug mode [off]
--no-color No color mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token

View File

@@ -30,6 +30,7 @@ const help = () => {
'DIR'
)} Path to the global ${'`.vercel`'} directory
-d, --debug Debug mode [off]
--no-color No color mode [off]
-N, --next Show next page of results
${chalk.dim('Examples:')}

View File

@@ -19,6 +19,7 @@ const help = () => {
'DIR'
)} Path to the global ${'`.vercel`'} directory
-d, --debug Debug mode [off]
--no-color No color mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token

View File

@@ -103,7 +103,12 @@ const main = async () => {
}
const isDebugging = argv['--debug'];
const output = new Output(process.stderr, { debug: isDebugging });
const isNoColor = argv['--no-color'];
const output = new Output(process.stderr, {
debug: isDebugging,
noColor: isNoColor,
});
debug = output.debug;

View File

@@ -8,6 +8,8 @@ const ARG_COMMON = {
'--debug': Boolean,
'-d': '--debug',
'--no-color': Boolean,
'--token': String,
'-t': '--token',

View File

@@ -54,8 +54,12 @@ export async function setMonorepoDefaultSettings(
)} monorepo manager. Attempting to assign default settings.`
);
setCommand('buildCommand', commands.buildCommand);
setCommand('installCommand', commands.installCommand);
if (commands.buildCommand) {
setCommand('buildCommand', commands.buildCommand);
}
if (commands.installCommand) {
setCommand('installCommand', commands.installCommand);
}
if (commands.commandForIgnoringBuildStep) {
setCommand(
'commandForIgnoringBuildStep',

View File

@@ -13,6 +13,7 @@ import {
Builder,
BuildResultV2,
BuildResultV3,
Cron,
File,
FileFsRef,
BuilderV2,
@@ -40,6 +41,7 @@ export const OUTPUT_DIR = join(VERCEL_DIR, 'output');
* An entry in the "functions" object in `vercel.json`.
*/
interface FunctionConfiguration {
cron?: Cron;
memory?: number;
maxDuration?: number;
}
@@ -370,12 +372,14 @@ async function writeLambda(
throw new Error('Malformed `Lambda` - no "files" present');
}
const cron = functionConfiguration?.cron ?? lambda.cron;
const memory = functionConfiguration?.memory ?? lambda.memory;
const maxDuration = functionConfiguration?.maxDuration ?? lambda.maxDuration;
const config = {
...lambda,
handler: normalizePath(lambda.handler),
cron,
memory,
maxDuration,
type: undefined,

View File

@@ -1,5 +1,5 @@
import { lookup as lookupMimeType } from 'mime-types';
import { contentType } from 'mime-types';
export default function getMimeType(fileName: string) {
return lookupMimeType(fileName) || 'application/octet-stream';
return contentType(fileName) || 'application/octet-stream';
}

View File

@@ -1129,10 +1129,10 @@ export default class DevServer {
});
body = `${json}\n`;
} else if (accept.includes('html')) {
res.setHeader('content-type', 'text/html');
res.setHeader('content-type', 'text/html; charset=utf-8');
body = redirectTemplate({ location, statusCode });
} else {
res.setHeader('content-type', 'text/plain');
res.setHeader('content-type', 'text/plain; charset=utf-8');
body = `Redirecting to ${location} (${statusCode})\n`;
}
res.end(body);

View File

@@ -1,4 +1,4 @@
export const emojiLabels = {
const emojiLabels = {
notice: '📝',
tip: '💡',
warning: '❗️',
@@ -8,6 +8,8 @@ export const emojiLabels = {
locked: '🔒',
} as const;
const stripEmojiRegex = new RegExp(Object.values(emojiLabels).join('|'), 'gi');
export type EmojiLabel = keyof typeof emojiLabels;
export function emoji(label: EmojiLabel) {
@@ -21,3 +23,9 @@ export function prependEmoji(message: string, emoji?: string): string {
return message;
}
export function removeEmoji(message: string): string {
const result = message.replace(stripEmojiRegex, '').trimStart();
return result;
}

View File

@@ -5,12 +5,14 @@ import renderLink from './link';
import wait, { StopSpinner } from './wait';
import type { WritableTTY } from '../../types';
import { errorToString } from '@vercel/error-utils';
import { removeEmoji } from '../emoji';
const IS_TEST = process.env.NODE_ENV === 'test';
export interface OutputOptions {
debug?: boolean;
supportsHyperlink?: boolean;
noColor?: boolean;
}
export interface LogOptions {
@@ -25,6 +27,7 @@ export class Output {
stream: WritableTTY;
debugEnabled: boolean;
supportsHyperlink: boolean;
colorDisabled: boolean;
private spinnerMessage: string;
private _spinner: StopSpinner | null;
@@ -33,6 +36,7 @@ export class Output {
{
debug: debugEnabled = false,
supportsHyperlink = detectSupportsHyperlink(stream),
noColor = false,
}: OutputOptions = {}
) {
this.stream = stream;
@@ -40,6 +44,11 @@ export class Output {
this.supportsHyperlink = supportsHyperlink;
this.spinnerMessage = '';
this._spinner = null;
this.colorDisabled = getNoColor(noColor);
if (this.colorDisabled) {
chalk.level = 0;
}
}
isDebugEnabled = () => {
@@ -47,6 +56,9 @@ export class Output {
};
print = (str: string) => {
if (this.colorDisabled) {
str = removeEmoji(str);
}
this.stopSpinner();
this.stream.write(str);
};
@@ -203,3 +215,14 @@ export class Output {
return ansiEscapes.link(chalk.cyan(text), url);
};
}
function getNoColor(noColorArg: boolean | undefined): boolean {
// FORCE_COLOR: the standard supported by chalk https://github.com/chalk/chalk#supportscolor
// NO_COLOR: the standard we want to support https://no-color.org/
// noColorArg: the `--no-color` arg passed to the CLI command
const noColor =
process.env.FORCE_COLOR === '0' ||
process.env.NO_COLOR === '1' ||
noColorArg;
return !!noColor;
}

View File

@@ -686,6 +686,7 @@ test('[vercel dev] should support static files with zero config', async () => {
expect(body).toEqual('bye:user');
res = await fetch(`http://localhost:${port}/`);
expect(res.headers.get('content-type')).toBe('text/html; charset=utf-8');
body = await res.text();
expect(body.startsWith('<h1>goodbye world</h1>')).toBeTruthy();
} finally {

View File

@@ -0,0 +1,3 @@
export default function (req, res) {
res.json('hello from the edge');
}

View File

@@ -0,0 +1,3 @@
export default function (req, res) {
res.end('serverless says hello');
}

View File

@@ -0,0 +1,10 @@
{
"functions": {
"api/overwrite/serverless.js": {
"cron": "0 10-20 * * *"
},
"api/overwrite/edge.js": {
"cron": "10 * * * *"
}
}
}

View File

@@ -132,6 +132,14 @@ export class MockClient extends Client {
setArgv(...argv: string[]) {
this.argv = [process.execPath, 'cli.js', ...argv];
this.output = new Output(this.stderr, {
debug: argv.includes('--debug') || argv.includes('-d'),
noColor: argv.includes('--no-color'),
});
}
resetOutput() {
this.output = new Output(this.stderr);
}
useScenario(scenario: Scenario) {

View File

@@ -1120,6 +1120,16 @@ describe('build', () => {
join(output, 'serverless.func', '.vc-config.json')
);
expect(serverless).toHaveProperty('cron', '* * * * *');
const overwriteServerless = await fs.readJSON(
join(output, 'overwrite', 'serverless.func', '.vc-config.json')
);
expect(overwriteServerless).toHaveProperty('cron', '0 10-20 * * *');
const overwriteEdge = await fs.readJSON(
join(output, 'overwrite', 'edge.func', '.vc-config.json')
);
expect(overwriteEdge).toHaveProperty('cron', '10 * * * *');
} finally {
process.chdir(originalCwd);
delete process.env.__VERCEL_BUILD_RUNNING;

View File

@@ -1,4 +1,5 @@
import login from '../../../src/commands/login';
import { emoji } from '../../../src/util/emoji';
import { client } from '../../mocks/client';
import { useUser } from '../../mocks/user';
@@ -45,5 +46,115 @@ describe('login', () => {
await expect(exitCodePromise).resolves.toEqual(0);
});
it('should allow the `--no-color` flag', async () => {
const user = useUser();
client.setArgv('login', '--no-color');
const exitCodePromise = login(client);
await expect(client.stderr).toOutput(`> Log in to Vercel`);
// Move down to "Email" option
client.stdin.write('\x1B[B'); // Down arrow
client.stdin.write('\x1B[B'); // Down arrow
client.stdin.write('\x1B[B'); // Down arrow
client.stdin.write('\r'); // Return key
await expect(client.stderr).toOutput('> Enter your email address:');
client.stdin.write(`${user.email}\n`);
await expect(client.stderr).toOutput(
`Success! Email authentication complete for ${user.email}`
);
await expect(client.stderr).not.toOutput(emoji('tip'));
await expect(exitCodePromise).resolves.toEqual(0);
});
describe('with NO_COLOR="1" env var', () => {
let previousNoColor: string | undefined;
beforeEach(() => {
previousNoColor = process.env.NO_COLOR;
process.env.NO_COLOR = '1';
});
afterEach(() => {
delete process.env.NO_COLOR;
if (previousNoColor) {
process.env.NO_COLOR = previousNoColor;
}
});
it('should remove emoji the `NO_COLOR` env var with 1', async () => {
client.resetOutput();
const user = useUser();
client.setArgv('login');
const exitCodePromise = login(client);
await expect(client.stderr).toOutput(`> Log in to Vercel`);
// Move down to "Email" option
client.stdin.write('\x1B[B'); // Down arrow
client.stdin.write('\x1B[B'); // Down arrow
client.stdin.write('\x1B[B'); // Down arrow
client.stdin.write('\r'); // Return key
await expect(client.stderr).toOutput('> Enter your email address:');
client.stdin.write(`${user.email}\n`);
await expect(client.stderr).toOutput(
`Success! Email authentication complete for ${user.email}`
);
await expect(client.stderr).not.toOutput(emoji('tip'));
await expect(exitCodePromise).resolves.toEqual(0);
});
});
describe('with FORCE_COLOR="0" env var', () => {
let previousForceColor: string | undefined;
beforeEach(() => {
previousForceColor = process.env.FORCE_COLOR;
process.env.FORCE_COLOR = '0';
});
afterEach(() => {
delete process.env.FORCE_COLOR;
if (previousForceColor) {
process.env.FORCE_COLOR = previousForceColor;
}
});
it('should remove emoji the `FORCE_COLOR` env var with 0', async () => {
client.resetOutput();
const user = useUser();
client.setArgv('login');
const exitCodePromise = login(client);
await expect(client.stderr).toOutput(`> Log in to Vercel`);
// Move down to "Email" option
client.stdin.write('\x1B[B'); // Down arrow
client.stdin.write('\x1B[B'); // Down arrow
client.stdin.write('\x1B[B'); // Down arrow
client.stdin.write('\r'); // Return key
await expect(client.stderr).toOutput('> Enter your email address:');
client.stdin.write(`${user.email}\n`);
await expect(client.stderr).toOutput(
`Success! Email authentication complete for ${user.email}`
);
await expect(client.stderr).not.toOutput(emoji('tip'));
await expect(exitCodePromise).resolves.toEqual(0);
});
});
});
});

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/client",
"version": "12.3.5",
"version": "12.3.7",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"homepage": "https://vercel.com",
@@ -43,7 +43,7 @@
]
},
"dependencies": {
"@vercel/build-utils": "6.1.0",
"@vercel/build-utils": "6.2.1",
"@vercel/routing-utils": "2.1.8",
"@zeit/fetch": "5.2.0",
"async-retry": "1.2.3",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/fs-detectors",
"version": "3.7.8",
"version": "3.7.10",
"description": "Vercel filesystem detectors",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
@@ -35,7 +35,7 @@
"@types/minimatch": "3.0.5",
"@types/node": "14.18.33",
"@types/semver": "7.3.10",
"@vercel/build-utils": "6.1.0",
"@vercel/build-utils": "6.2.1",
"typescript": "4.3.4"
}
}

View File

@@ -21,12 +21,19 @@ export class MissingBuildTarget extends Error {
}
}
type MonorepoDefaultSettings = {
buildCommand?: string | null;
installCommand?: string | null;
commandForIgnoringBuildStep?: string;
monorepoManager: string;
} | null;
export async function getMonorepoDefaultSettings(
projectName: string,
projectPath: string,
relativeToRoot: string,
detectorFilesystem: DetectorFilesystem
) {
): Promise<MonorepoDefaultSettings> {
const [monorepoManager, packageManager] = await Promise.all([
detectFramework({
fs: detectorFilesystem,
@@ -64,14 +71,27 @@ export async function getMonorepoDefaultSettings(
throw new MissingBuildPipeline();
}
if (projectPath === '/') {
return {
monorepoManager: 'turbo',
buildCommand: 'npx turbo run build',
installCommand: packageManager ? `${packageManager} install` : null,
commandForIgnoringBuildStep: 'npx turbo-ignore',
};
}
return {
monorepoManager: 'turbo',
buildCommand: `cd ${relativeToRoot} && npx turbo run build --filter={${projectPath}}...`,
buildCommand: projectPath
? `cd ${relativeToRoot} && npx turbo run build --filter={${projectPath}}...`
: null,
installCommand:
packageManager === 'npm'
? `${packageManager} install --prefix=${relativeToRoot}`
: `${packageManager} install`,
commandForIgnoringBuildStep: `npx turbo-ignore`,
: packageManager
? `${packageManager} install`
: null,
commandForIgnoringBuildStep: 'npx turbo-ignore',
};
} else if (monorepoManager === 'nx') {
// No ENOENT handling required here since conditional wouldn't be `true` unless `nx.json` was found.
@@ -111,13 +131,24 @@ export async function getMonorepoDefaultSettings(
}
}
if (projectPath === '/') {
return {
monorepoManager: 'nx',
buildCommand: 'npx nx build',
installCommand: packageManager ? `${packageManager} install` : null,
};
}
return {
monorepoManager: 'nx',
buildCommand: `cd ${relativeToRoot} && npx nx build ${projectName}`,
buildCommand: projectName
? `cd ${relativeToRoot} && npx nx build ${projectName}`
: null,
installCommand:
packageManager === 'npm'
? `${packageManager} install --prefix=${relativeToRoot}`
: `${packageManager} install`,
: packageManager
? `${packageManager} install`
: null,
};
}
// TODO (@Ethan-Arrowood) - Revisit rush support when we can test it better

View File

@@ -0,0 +1,16 @@
{
"name": "app-root-proj",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "app-root-proj",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"next": "1.2.3"
}
}
}
}

View File

@@ -0,0 +1,5 @@
{
"dependencies": {
"next": "1.2.3"
}
}

View File

@@ -0,0 +1,19 @@
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
"dependsOn": ["^build"],
"outputs": [".next/**"]
},
"test": {
"dependsOn": ["^build"],
"outputs": []
},
"lint": {
"outputs": []
},
"dev": {
"cache": false
}
}
}

View File

@@ -26,41 +26,56 @@ describe('getMonorepoDefaultSettings', () => {
});
test.each([
['turbo', 'turbo', false, 'app-14'],
['turbo-package-config', 'turbo', false, 'app-13'],
['turbo-npm', 'turbo', true, 'app-15'],
['nx', 'nx', false, 'app-12'],
['nx-package-config', 'nx', false, 'app-11'],
['nx-project-and-package-config-1', 'nx', false, 'app-10'],
['nx-project-and-package-config-2', 'nx', false, 'app-9'],
['nx-project-config', 'nx', false, 'app-8'],
])('fixture %s', async (fixture, expectedResultKey, isNpm, packageName) => {
const expectedResultMap: Record<string, Record<string, string>> = {
turbo: {
monorepoManager: 'turbo',
buildCommand:
'cd ../.. && npx turbo run build --filter={packages/app-1}...',
installCommand: isNpm ? 'npm install --prefix=../..' : 'yarn install',
commandForIgnoringBuildStep: 'npx turbo-ignore',
},
nx: {
monorepoManager: 'nx',
buildCommand: `cd ../.. && npx nx build ${packageName}`,
installCommand: 'yarn install',
},
};
['turbo', 'turbo', false, 'app-14', false],
['turbo-package-config', 'turbo', false, 'app-13', false],
['turbo-npm', 'turbo', true, 'app-15', false],
['turbo-npm-root-proj', 'turbo', true, 'app-root-proj', true],
['nx', 'nx', false, 'app-12', false],
['nx-package-config', 'nx', false, 'app-11', false],
['nx-project-and-package-config-1', 'nx', false, 'app-10', false],
['nx-project-and-package-config-2', 'nx', false, 'app-9', false],
['nx-project-config', 'nx', false, 'app-8', false],
])(
'fixture %s',
async (fixture, expectedResultKey, isNpm, packageName, isRoot) => {
const expectedResultMap: Record<string, Record<string, string>> = {
turbo: {
monorepoManager: 'turbo',
buildCommand: isRoot
? 'npx turbo run build'
: 'cd ../.. && npx turbo run build --filter={packages/app-1}...',
installCommand:
isNpm && isRoot
? 'npm install'
: isNpm
? 'npm install --prefix=../..'
: 'yarn install',
commandForIgnoringBuildStep: 'npx turbo-ignore',
},
nx: {
monorepoManager: 'nx',
buildCommand: `cd ../.. && npx nx build ${packageName}`,
installCommand: 'yarn install',
},
};
const ffs = new FixtureFilesystem(
path.join(__dirname, 'fixtures', 'get-monorepo-default-settings', fixture)
);
const result = await getMonorepoDefaultSettings(
packageName,
'packages/app-1',
'../..',
ffs
);
expect(result).toStrictEqual(expectedResultMap[expectedResultKey]);
});
const ffs = new FixtureFilesystem(
path.join(
__dirname,
'fixtures',
'get-monorepo-default-settings',
fixture
)
);
const result = await getMonorepoDefaultSettings(
packageName,
isRoot ? '/' : 'packages/app-1',
isRoot ? '/' : '../..',
ffs
);
expect(result).toStrictEqual(expectedResultMap[expectedResultKey]);
}
);
test('returns null when neither nx nor turbo is detected', async () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'monorepo-test-'));

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/gatsby-plugin-vercel-builder",
"version": "1.1.0",
"version": "1.1.2",
"main": "dist/index.js",
"files": [
"dist",
@@ -14,8 +14,8 @@
"build:src": "tsc -p tsconfig.src.json"
},
"dependencies": {
"@vercel/build-utils": "6.1.0",
"@vercel/node": "2.9.0",
"@vercel/build-utils": "6.2.1",
"@vercel/node": "2.9.2",
"@vercel/routing-utils": "2.1.8",
"ajv": "8.12.0",
"esbuild": "0.14.47",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/go",
"version": "2.3.1",
"version": "2.3.3",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
@@ -36,7 +36,7 @@
"@types/node": "14.18.33",
"@types/node-fetch": "^2.3.0",
"@types/tar": "^4.0.0",
"@vercel/build-utils": "6.1.0",
"@vercel/build-utils": "6.2.1",
"@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.47",
"version": "0.0.49",
"license": "MIT",
"main": "./dist/index.js",
"homepage": "https://vercel.com/docs",
@@ -21,7 +21,7 @@
"devDependencies": {
"@types/jest": "27.5.1",
"@types/node": "14.18.33",
"@vercel/build-utils": "6.1.0",
"@vercel/build-utils": "6.2.1",
"@vercel/static-config": "2.0.12",
"execa": "3.2.0",
"fs-extra": "11.1.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/next",
"version": "3.3.21",
"version": "3.4.1",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -45,7 +45,7 @@
"@types/semver": "6.0.0",
"@types/text-table": "0.2.1",
"@types/webpack-sources": "3.2.0",
"@vercel/build-utils": "6.1.0",
"@vercel/build-utils": "6.2.1",
"@vercel/nft": "0.22.5",
"@vercel/routing-utils": "2.1.8",
"async-sema": "3.0.1",

View File

@@ -873,6 +873,7 @@ export async function serverBuild({
runtime: nodeVersion.runtime,
maxDuration: group.maxDuration,
isStreaming: group.isStreaming,
cron: group.cron,
});
for (const page of group.pages) {
@@ -967,6 +968,7 @@ export async function serverBuild({
});
const middleware = await getMiddlewareBundle({
config,
entryPath,
outputDirectory,
routesManifest,

View File

@@ -15,6 +15,7 @@ import {
NodejsLambda,
EdgeFunction,
Images,
Cron,
} from '@vercel/build-utils';
import { NodeFileTraceReasons } from '@vercel/nft';
import type {
@@ -1308,6 +1309,7 @@ export function addLocaleOrDefault(
export type LambdaGroup = {
pages: string[];
memory?: number;
cron?: Cron;
maxDuration?: number;
isStreaming?: boolean;
isPrerenders?: boolean;
@@ -1360,7 +1362,7 @@ export async function getPageLambdaGroups({
const routeName = normalizePage(page.replace(/\.js$/, ''));
const isPrerenderRoute = prerenderRoutes.has(routeName);
let opts: { memory?: number; maxDuration?: number } = {};
let opts: { memory?: number; maxDuration?: number; cron?: Cron } = {};
if (config && config.functions) {
const sourceFile = await getSourceFilePathFromPage({
@@ -1378,7 +1380,8 @@ export async function getPageLambdaGroups({
const matches =
group.maxDuration === opts.maxDuration &&
group.memory === opts.memory &&
group.isPrerenders === isPrerenderRoute;
group.isPrerenders === isPrerenderRoute &&
!opts.cron; // Functions with a cronjob must be on their own
if (matches) {
let newTracedFilesSize = group.pseudoLayerBytes;
@@ -2311,12 +2314,14 @@ interface EdgeFunctionMatcher {
}
export async function getMiddlewareBundle({
config = {},
entryPath,
outputDirectory,
routesManifest,
isCorrectMiddlewareOrder,
prerenderBypassToken,
}: {
config: Config;
entryPath: string;
outputDirectory: string;
prerenderBypassToken: string;
@@ -2372,6 +2377,21 @@ export async function getMiddlewareBundle({
edgeFunction.wasm
);
const edgeFunctionOptions: { cron?: Cron } = {};
if (config.functions) {
const sourceFile = await getSourceFilePathFromPage({
workPath: entryPath,
page: `${edgeFunction.page}.js`,
});
const opts = await getLambdaOptionsFromFunction({
sourceFile,
config,
});
edgeFunctionOptions.cron = opts.cron;
}
return {
type,
page: edgeFunction.page,
@@ -2416,6 +2436,7 @@ export async function getMiddlewareBundle({
);
return new EdgeFunction({
...edgeFunctionOptions,
deploymentTarget: 'v8-worker',
name: edgeFunction.name,
files: {

View File

@@ -0,0 +1,44 @@
const path = require('node:path');
const fs = require('fs-extra');
const { build } = require('../../dist');
function getFixture(name) {
return path.join(__dirname, 'fixtures', name);
}
const initialCorepackValue = process.env.COREPACK_ENABLE_STRICT;
beforeEach(() => {
process.env.COREPACK_ENABLE_STRICT = '0';
});
afterEach(() => {
process.env.COREPACK_ENABLE_STRICT = initialCorepackValue;
});
it('should include cron property from config', async () => {
const cwd = getFixture('03-with-api-routes');
await fs.remove(path.join(cwd, '.next'));
const result = await build({
workPath: cwd,
repoRootPath: cwd,
entrypoint: 'package.json',
config: {
functions: {
'pages/api/edge.js': {
cron: '* * * * *',
},
'pages/api/serverless.js': {
cron: '* * * * *',
},
},
},
meta: {
skipDownload: true,
},
});
expect(result.output['api/serverless']).toHaveProperty('cron', '* * * * *');
expect(result.output['api/edge']).toHaveProperty('cron', '* * * * *');
});

View File

@@ -0,0 +1,2 @@
.vercel
node_modules

View File

@@ -0,0 +1,5 @@
module.exports = {
generateBuildId() {
return 'testing-build-id';
},
};

View File

@@ -0,0 +1,13 @@
{
"name": "03-with-api-routes",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build"
},
"dependencies": {
"next": "latest",
"react": "latest",
"react-dom": "latest"
}
}

View File

@@ -0,0 +1,7 @@
export const config = {
runtime: 'edge',
};
export default async function Edge(req, res) {
res.json({ edge: 1 });
}

View File

@@ -0,0 +1,3 @@
export default async function Edge(req, res) {
res.json({ serverless: 1 });
}

View File

@@ -0,0 +1,185 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@next/env@13.1.6":
version "13.1.6"
resolved "https://registry.yarnpkg.com/@next/env/-/env-13.1.6.tgz#c4925609f16142ded1a5cb833359ab17359b7a93"
integrity sha512-s+W9Fdqh5MFk6ECrbnVmmAOwxKQuhGMT7xXHrkYIBMBcTiOqNWhv5KbJIboKR5STXxNXl32hllnvKaffzFaWQg==
"@next/swc-android-arm-eabi@13.1.6":
version "13.1.6"
resolved "https://registry.yarnpkg.com/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.1.6.tgz#d766dfc10e27814d947b20f052067c239913dbcc"
integrity sha512-F3/6Z8LH/pGlPzR1AcjPFxx35mPqjE5xZcf+IL+KgbW9tMkp7CYi1y7qKrEWU7W4AumxX/8OINnDQWLiwLasLQ==
"@next/swc-android-arm64@13.1.6":
version "13.1.6"
resolved "https://registry.yarnpkg.com/@next/swc-android-arm64/-/swc-android-arm64-13.1.6.tgz#f37a98d5f18927d8c9970d750d516ac779465176"
integrity sha512-cMwQjnB8vrYkWyK/H0Rf2c2pKIH4RGjpKUDvbjVAit6SbwPDpmaijLio0LWFV3/tOnY6kvzbL62lndVA0mkYpw==
"@next/swc-darwin-arm64@13.1.6":
version "13.1.6"
resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.1.6.tgz#ec1b90fd9bf809d8b81004c5182e254dced4ad96"
integrity sha512-KKRQH4DDE4kONXCvFMNBZGDb499Hs+xcFAwvj+rfSUssIDrZOlyfJNy55rH5t2Qxed1e4K80KEJgsxKQN1/fyw==
"@next/swc-darwin-x64@13.1.6":
version "13.1.6"
resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-13.1.6.tgz#e869ac75d16995eee733a7d1550322d9051c1eb4"
integrity sha512-/uOky5PaZDoaU99ohjtNcDTJ6ks/gZ5ykTQDvNZDjIoCxFe3+t06bxsTPY6tAO6uEAw5f6vVFX5H5KLwhrkZCA==
"@next/swc-freebsd-x64@13.1.6":
version "13.1.6"
resolved "https://registry.yarnpkg.com/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.1.6.tgz#84a7b2e423a2904afc2edca21c2f1ba6b53fa4c1"
integrity sha512-qaEALZeV7to6weSXk3Br80wtFQ7cFTpos/q+m9XVRFggu+8Ib895XhMWdJBzew6aaOcMvYR6KQ6JmHA2/eMzWw==
"@next/swc-linux-arm-gnueabihf@13.1.6":
version "13.1.6"
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.1.6.tgz#980eed1f655ff8a72187d8a6ef9e73ac39d20d23"
integrity sha512-OybkbC58A1wJ+JrJSOjGDvZzrVEQA4sprJejGqMwiZyLqhr9Eo8FXF0y6HL+m1CPCpPhXEHz/2xKoYsl16kNqw==
"@next/swc-linux-arm64-gnu@13.1.6":
version "13.1.6"
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.1.6.tgz#87a71db21cded3f7c63d1d19079845c59813c53d"
integrity sha512-yCH+yDr7/4FDuWv6+GiYrPI9kcTAO3y48UmaIbrKy8ZJpi7RehJe3vIBRUmLrLaNDH3rY1rwoHi471NvR5J5NQ==
"@next/swc-linux-arm64-musl@13.1.6":
version "13.1.6"
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.1.6.tgz#c5aac8619331b9fd030603bbe2b36052011e11de"
integrity sha512-ECagB8LGX25P9Mrmlc7Q/TQBb9rGScxHbv/kLqqIWs2fIXy6Y/EiBBiM72NTwuXUFCNrWR4sjUPSooVBJJ3ESQ==
"@next/swc-linux-x64-gnu@13.1.6":
version "13.1.6"
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.1.6.tgz#9513d36d540bbfea575576746736054c31aacdea"
integrity sha512-GT5w2mruk90V/I5g6ScuueE7fqj/d8Bui2qxdw6lFxmuTgMeol5rnzAv4uAoVQgClOUO/MULilzlODg9Ib3Y4Q==
"@next/swc-linux-x64-musl@13.1.6":
version "13.1.6"
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.1.6.tgz#d61fc6884899f5957251f4ce3f522e34a2c479b7"
integrity sha512-keFD6KvwOPzmat4TCnlnuxJCQepPN+8j3Nw876FtULxo8005Y9Ghcl7ACcR8GoiKoddAq8gxNBrpjoxjQRHeAQ==
"@next/swc-win32-arm64-msvc@13.1.6":
version "13.1.6"
resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.1.6.tgz#fac2077a8ae9768e31444c9ae90807e64117cda7"
integrity sha512-OwertslIiGQluFvHyRDzBCIB07qJjqabAmINlXUYt7/sY7Q7QPE8xVi5beBxX/rxTGPIbtyIe3faBE6Z2KywhQ==
"@next/swc-win32-ia32-msvc@13.1.6":
version "13.1.6"
resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.1.6.tgz#498bc11c91b4c482a625bf4b978f98ae91111e46"
integrity sha512-g8zowiuP8FxUR9zslPmlju7qYbs2XBtTLVSxVikPtUDQedhcls39uKYLvOOd1JZg0ehyhopobRoH1q+MHlIN/w==
"@next/swc-win32-x64-msvc@13.1.6":
version "13.1.6"
resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.1.6.tgz#17ed919c723426b7d0ce1cd73d40ce3dcd342089"
integrity sha512-Ls2OL9hi3YlJKGNdKv8k3X/lLgc3VmLG3a/DeTkAd+lAituJp8ZHmRmm9f9SL84fT3CotlzcgbdaCDfFwFA6bA==
"@swc/helpers@0.4.14":
version "0.4.14"
resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.4.14.tgz#1352ac6d95e3617ccb7c1498ff019654f1e12a74"
integrity sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==
dependencies:
tslib "^2.4.0"
caniuse-lite@^1.0.30001406:
version "1.0.30001450"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001450.tgz#022225b91200589196b814b51b1bbe45144cf74f"
integrity sha512-qMBmvmQmFXaSxexkjjfMvD5rnDL0+m+dUMZKoDYsGG8iZN29RuYh9eRoMvKsT6uMAWlyUUGDEQGJJYjzCIO9ew==
client-only@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/client-only/-/client-only-0.0.1.tgz#38bba5d403c41ab150bff64a95c85013cf73bca1"
integrity sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==
"js-tokens@^3.0.0 || ^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
loose-envify@^1.1.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
dependencies:
js-tokens "^3.0.0 || ^4.0.0"
nanoid@^3.3.4:
version "3.3.4"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab"
integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==
next@latest:
version "13.1.6"
resolved "https://registry.yarnpkg.com/next/-/next-13.1.6.tgz#054babe20b601f21f682f197063c9b0b32f1a27c"
integrity sha512-hHlbhKPj9pW+Cymvfzc15lvhaOZ54l+8sXDXJWm3OBNBzgrVj6hwGPmqqsXg40xO1Leq+kXpllzRPuncpC0Phw==
dependencies:
"@next/env" "13.1.6"
"@swc/helpers" "0.4.14"
caniuse-lite "^1.0.30001406"
postcss "8.4.14"
styled-jsx "5.1.1"
optionalDependencies:
"@next/swc-android-arm-eabi" "13.1.6"
"@next/swc-android-arm64" "13.1.6"
"@next/swc-darwin-arm64" "13.1.6"
"@next/swc-darwin-x64" "13.1.6"
"@next/swc-freebsd-x64" "13.1.6"
"@next/swc-linux-arm-gnueabihf" "13.1.6"
"@next/swc-linux-arm64-gnu" "13.1.6"
"@next/swc-linux-arm64-musl" "13.1.6"
"@next/swc-linux-x64-gnu" "13.1.6"
"@next/swc-linux-x64-musl" "13.1.6"
"@next/swc-win32-arm64-msvc" "13.1.6"
"@next/swc-win32-ia32-msvc" "13.1.6"
"@next/swc-win32-x64-msvc" "13.1.6"
picocolors@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c"
integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==
postcss@8.4.14:
version "8.4.14"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.14.tgz#ee9274d5622b4858c1007a74d76e42e56fd21caf"
integrity sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==
dependencies:
nanoid "^3.3.4"
picocolors "^1.0.0"
source-map-js "^1.0.2"
react-dom@latest:
version "18.2.0"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.2.0.tgz#22aaf38708db2674ed9ada224ca4aa708d821e3d"
integrity sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==
dependencies:
loose-envify "^1.1.0"
scheduler "^0.23.0"
react@latest:
version "18.2.0"
resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"
integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==
dependencies:
loose-envify "^1.1.0"
scheduler@^0.23.0:
version "0.23.0"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.23.0.tgz#ba8041afc3d30eb206a487b6b384002e4e61fdfe"
integrity sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==
dependencies:
loose-envify "^1.1.0"
source-map-js@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c"
integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==
styled-jsx@5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-5.1.1.tgz#839a1c3aaacc4e735fed0781b8619ea5d0009d1f"
integrity sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==
dependencies:
client-only "0.0.1"
tslib@^2.4.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/node",
"version": "2.9.0",
"version": "2.9.2",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
@@ -31,7 +31,7 @@
"dependencies": {
"@edge-runtime/vm": "2.0.0",
"@types/node": "14.18.33",
"@vercel/build-utils": "6.1.0",
"@vercel/build-utils": "6.2.1",
"@vercel/node-bridge": "3.1.10",
"@vercel/static-config": "2.0.12",
"edge-runtime": "2.0.0",

View File

@@ -413,6 +413,11 @@ export const build: BuildV3 = async ({
)} (must be one of: ${JSON.stringify(ALLOWED_RUNTIMES)})`
);
}
if (staticConfig.runtime === 'nodejs') {
console.log(
`Detected unused static config runtime "nodejs" in "${entrypointPath}"`
);
}
isEdgeFunction = isEdgeRuntime(staticConfig.runtime);
}

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/python",
"version": "3.1.43",
"version": "3.1.45",
"main": "./dist/index.js",
"license": "MIT",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -23,7 +23,7 @@
"@types/execa": "^0.9.0",
"@types/jest": "27.4.1",
"@types/node": "14.18.33",
"@vercel/build-utils": "6.1.0",
"@vercel/build-utils": "6.2.1",
"@vercel/ncc": "0.24.0",
"execa": "^1.0.0",
"typescript": "4.3.4"

View File

@@ -0,0 +1,14 @@
async def app(scope, receive, send):
assert scope["type"] == "http"
await send(
{
"type": "http.response.start",
"status": 200,
}
)
await send(
{
"type": "http.response.body",
"body": b"hello world"
}
)

View File

@@ -0,0 +1,18 @@
const execa = require('execa');
module.exports = async function ({ deploymentUrl, fetch }) {
const probeUrl = `https://${deploymentUrl}`;
const result = await execa('curl', [
probeUrl,
'-s',
'-H',
'foo: bar',
'-H',
'foo: bar',
]);
if (result.stdout.includes('FUNCTION_INVOCATION_FAILED')) {
throw new Error(
'Duplicate headers should not cause a function invocation failure'
);
}
};

View File

@@ -0,0 +1,9 @@
{
"version": 2,
"builds": [
{
"src": "*.py",
"use": "@vercel/python"
}
]
}

View File

@@ -276,6 +276,14 @@ elif 'app' in __vc_variables:
query = url.query.encode()
path = url.path
headers_encoded = []
for k, v in headers.items():
# Cope with repeated headers in the encoding.
if isinstance(v, list):
headers_encoded.append([k.lower().encode(), [i.encode() for i in v]])
else:
headers_encoded.append([k.lower().encode(), v.encode()])
scope = {
'server': (headers.get('host', 'lambda'), headers.get('x-forwarded-port', 80)),
'client': (headers.get(
@@ -285,7 +293,7 @@ elif 'app' in __vc_variables:
'scheme': headers.get('x-forwarded-proto', 'http'),
'root_path': '',
'query_string': query,
'headers': [[k.lower().encode(), v.encode()] for k, v in headers.items()],
'headers': headers_encoded,
'type': 'http',
'http_version': '1.1',
'method': payload['method'],

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/redwood",
"version": "1.0.54",
"version": "1.1.1",
"main": "./dist/index.js",
"license": "MIT",
"homepage": "https://vercel.com/docs",
@@ -27,7 +27,7 @@
"@types/aws-lambda": "8.10.19",
"@types/node": "14.18.33",
"@types/semver": "6.0.0",
"@vercel/build-utils": "6.1.0",
"@vercel/build-utils": "6.2.1",
"execa": "3.2.0",
"fs-extra": "11.1.0",
"typescript": "4.3.4"

View File

@@ -256,7 +256,7 @@ export const build: BuildV2 = async ({
lambdaFiles[relative(workPath, fileFsRef.fsPath)] = fileFsRef;
const { memory, maxDuration } = await getLambdaOptionsFromFunction({
const lambdaOptions = await getLambdaOptionsFromFunction({
sourceFile,
config,
});
@@ -265,11 +265,10 @@ export const build: BuildV2 = async ({
files: lambdaFiles,
handler: relativeEntrypoint,
runtime: nodeVersion.runtime,
memory,
maxDuration,
shouldAddHelpers: false,
shouldAddSourcemapSupport: false,
awsLambdaHandler,
...lambdaOptions,
});
lambdaOutputs[outputName] = lambda;
}

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/remix",
"version": "1.2.10",
"version": "1.2.12",
"license": "MIT",
"main": "./dist/index.js",
"homepage": "https://vercel.com/docs",
@@ -24,7 +24,7 @@
"devDependencies": {
"@types/jest": "27.5.1",
"@types/node": "14.18.33",
"@vercel/build-utils": "6.1.0",
"@vercel/build-utils": "6.2.1",
"typescript": "4.9.4"
}
}

View File

@@ -1,4 +1,5 @@
import { promises as fs } from 'fs';
import { runInContext, createContext } from 'vm';
import { dirname, join, relative } from 'path';
import {
debug,
@@ -23,8 +24,9 @@ import type {
PackageJson,
} from '@vercel/build-utils';
import { nodeFileTrace } from '@vercel/nft';
import type { AppConfig } from './types';
import { findConfig } from './utils';
import type { AppConfig, RemixBuildManifest } from './types';
import type { BuildResultV2Typical } from '@vercel/build-utils';
// Name of the Remix runtime adapter npm package for Vercel
const REMIX_RUNTIME_ADAPTER_NAME = '@remix-run/vercel';
@@ -205,7 +207,7 @@ export const build: BuildV2 = async ({
if (err.code !== 'MODULE_NOT_FOUND') throw err;
}
const [staticFiles, renderFunction] = await Promise.all([
const [staticFiles, renderFunction, ssrRoutes] = await Promise.all([
glob('**', join(entrypointFsDirname, 'public')),
createRenderFunction(
entrypointFsDirname,
@@ -214,8 +216,17 @@ export const build: BuildV2 = async ({
needsHandler,
nodeVersion
),
getSsrRoutes(entrypointFsDirname),
]);
const output: BuildResultV2Typical['output'] = staticFiles;
for (const path of ssrRoutes) {
output[path] = renderFunction;
}
// Add a 404 path for not found pages to be server-side rendered by Remix
output['404'] = renderFunction;
return {
routes: [
{
@@ -228,13 +239,10 @@ export const build: BuildV2 = async ({
},
{
src: '/(.*)',
dest: '/render',
dest: '/404',
},
],
output: {
render: renderFunction,
...staticFiles,
},
output,
};
};
@@ -287,3 +295,30 @@ async function createRenderFunction(
return lambda;
}
async function getSsrRoutes(entrypointDir: string): Promise<string[]> {
// Find the name of the manifest file
const buildDir = join(entrypointDir, 'public/build');
const manifestFileName = (await fs.readdir(buildDir)).find(n =>
n.startsWith('manifest-')
);
if (!manifestFileName) {
throw new Error(`Failed to find manifest file in "${buildDir}"`);
}
const context: { window: { __remixManifest?: RemixBuildManifest } } = {
window: {},
};
createContext(context);
const code = await fs.readFile(join(buildDir, manifestFileName), 'utf8');
runInContext(code, context);
const routes = context.window.__remixManifest?.routes || {};
return Object.keys(routes)
.filter(id => id !== 'root')
.map(id => {
return routes[id].path || 'index';
});
}

View File

@@ -5,3 +5,11 @@ export interface AppConfig {
serverBuildPath?: string;
serverBuildTarget?: string;
}
export interface RemixBuildManifest {
routes: {
[id: string]: {
path: string;
};
};
}

View File

@@ -0,0 +1,7 @@
export default function B() {
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>
<h1>B page</h1>
</div>
);
}

View File

@@ -0,0 +1,7 @@
export default function Another() {
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>
<h1>Nested another page</h1>
</div>
);
}

View File

@@ -0,0 +1,7 @@
export default function Nested() {
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>
<h1>Nested index page</h1>
</div>
);
}

View File

@@ -9,5 +9,12 @@
}
}
],
"probes": [{ "path": "/", "mustContain": "Welcome to Remix" }]
"probes": [
{ "path": "/", "mustContain": "Welcome to Remix" },
{ "path": "/b", "mustContain": "B page" },
{ "path": "/nested", "mustContain": "Nested index page" },
{ "path": "/nested/another", "mustContain": "Nested another page" },
{ "path": "/nested/index", "mustContain": "Not Found" },
{ "path": "/asdf", "mustContain": "Not Found" }
]
}

View File

@@ -1,7 +1,7 @@
{
"name": "@vercel/ruby",
"author": "Nathan Cahill <nathan@nathancahill.com>",
"version": "1.3.59",
"version": "1.3.61",
"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": "6.1.0",
"@vercel/build-utils": "6.2.1",
"@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.3.2",
"version": "1.3.4",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/build-step",
@@ -30,7 +30,7 @@
},
"dependencies": {
"@vercel/gatsby-plugin-vercel-analytics": "1.0.7",
"@vercel/gatsby-plugin-vercel-builder": "1.1.0"
"@vercel/gatsby-plugin-vercel-builder": "1.1.2"
},
"devDependencies": {
"@types/aws-lambda": "8.10.64",
@@ -42,9 +42,9 @@
"@types/node-fetch": "2.5.4",
"@types/promise-timeout": "1.3.0",
"@types/semver": "7.3.13",
"@vercel/build-utils": "6.1.0",
"@vercel/build-utils": "6.2.1",
"@vercel/frameworks": "1.3.0",
"@vercel/fs-detectors": "3.7.8",
"@vercel/fs-detectors": "3.7.10",
"@vercel/ncc": "0.24.0",
"@vercel/routing-utils": "2.1.8",
"@vercel/static-config": "2.0.12",

54
pnpm-lock.yaml generated
View File

@@ -196,23 +196,23 @@ importers:
'@types/which': 1.3.2
'@types/write-json-file': 2.2.1
'@types/yauzl-promise': 2.1.0
'@vercel/build-utils': 6.1.0
'@vercel/client': 12.3.5
'@vercel/build-utils': 6.2.1
'@vercel/client': 12.3.7
'@vercel/error-utils': 1.0.8
'@vercel/frameworks': 1.3.0
'@vercel/fs-detectors': 3.7.8
'@vercel/fs-detectors': 3.7.10
'@vercel/fun': 1.0.4
'@vercel/go': 2.3.1
'@vercel/hydrogen': 0.0.47
'@vercel/go': 2.3.3
'@vercel/hydrogen': 0.0.49
'@vercel/ncc': 0.24.0
'@vercel/next': 3.3.21
'@vercel/node': 2.9.0
'@vercel/python': 3.1.43
'@vercel/redwood': 1.0.54
'@vercel/remix': 1.2.10
'@vercel/next': 3.4.1
'@vercel/node': 2.9.2
'@vercel/python': 3.1.45
'@vercel/redwood': 1.1.1
'@vercel/remix': 1.2.12
'@vercel/routing-utils': 2.1.8
'@vercel/ruby': 1.3.59
'@vercel/static-build': 1.3.2
'@vercel/ruby': 1.3.61
'@vercel/static-build': 1.3.4
'@zeit/source-map-support': 0.6.2
ajv: 6.12.2
alpha-sort: 2.0.1
@@ -438,7 +438,7 @@ importers:
'@types/node-fetch': 2.5.4
'@types/recursive-readdir': 2.2.0
'@types/tar-fs': 1.16.1
'@vercel/build-utils': 6.1.0
'@vercel/build-utils': 6.2.1
'@vercel/routing-utils': 2.1.8
'@zeit/fetch': 5.2.0
async-retry: 1.2.3
@@ -543,7 +543,7 @@ importers:
'@types/minimatch': 3.0.5
'@types/node': 14.18.33
'@types/semver': 7.3.10
'@vercel/build-utils': 6.1.0
'@vercel/build-utils': 6.2.1
'@vercel/error-utils': 1.0.8
'@vercel/frameworks': 1.3.0
'@vercel/routing-utils': 2.1.8
@@ -591,8 +591,8 @@ importers:
'@types/fs-extra': 11.0.1
'@types/node': 14.18.33
'@types/react': 18.0.26
'@vercel/build-utils': 6.1.0
'@vercel/node': 2.9.0
'@vercel/build-utils': 6.2.1
'@vercel/node': 2.9.2
'@vercel/routing-utils': 2.1.8
ajv: 8.12.0
esbuild: 0.14.47
@@ -626,7 +626,7 @@ importers:
'@types/node': 14.18.33
'@types/node-fetch': ^2.3.0
'@types/tar': ^4.0.0
'@vercel/build-utils': 6.1.0
'@vercel/build-utils': 6.2.1
'@vercel/ncc': 0.24.0
async-retry: 1.3.1
execa: ^1.0.0
@@ -658,7 +658,7 @@ importers:
specifiers:
'@types/jest': 27.5.1
'@types/node': 14.18.33
'@vercel/build-utils': 6.1.0
'@vercel/build-utils': 6.2.1
'@vercel/static-config': 2.0.12
execa: 3.2.0
fs-extra: 11.1.0
@@ -689,7 +689,7 @@ importers:
'@types/semver': 6.0.0
'@types/text-table': 0.2.1
'@types/webpack-sources': 3.2.0
'@vercel/build-utils': 6.1.0
'@vercel/build-utils': 6.2.1
'@vercel/nft': 0.22.5
'@vercel/routing-utils': 2.1.8
async-sema: 3.0.1
@@ -768,7 +768,7 @@ importers:
'@types/node': 14.18.33
'@types/node-fetch': ^2.6.1
'@types/test-listen': 1.1.0
'@vercel/build-utils': 6.1.0
'@vercel/build-utils': 6.2.1
'@vercel/ncc': 0.24.0
'@vercel/nft': 0.22.5
'@vercel/node-bridge': 3.1.10
@@ -852,7 +852,7 @@ importers:
'@types/execa': ^0.9.0
'@types/jest': 27.4.1
'@types/node': 14.18.33
'@vercel/build-utils': 6.1.0
'@vercel/build-utils': 6.2.1
'@vercel/ncc': 0.24.0
execa: ^1.0.0
typescript: 4.3.4
@@ -870,7 +870,7 @@ importers:
'@types/aws-lambda': 8.10.19
'@types/node': 14.18.33
'@types/semver': 6.0.0
'@vercel/build-utils': 6.1.0
'@vercel/build-utils': 6.2.1
'@vercel/nft': 0.22.5
'@vercel/routing-utils': 2.1.8
execa: 3.2.0
@@ -894,7 +894,7 @@ importers:
specifiers:
'@types/jest': 27.5.1
'@types/node': 14.18.33
'@vercel/build-utils': 6.1.0
'@vercel/build-utils': 6.2.1
'@vercel/nft': 0.22.5
typescript: 4.9.4
dependencies:
@@ -925,7 +925,7 @@ importers:
specifiers:
'@types/fs-extra': 8.0.0
'@types/semver': 6.0.0
'@vercel/build-utils': 6.1.0
'@vercel/build-utils': 6.2.1
'@vercel/ncc': 0.24.0
execa: 2.0.4
fs-extra: ^7.0.1
@@ -952,11 +952,11 @@ importers:
'@types/node-fetch': 2.5.4
'@types/promise-timeout': 1.3.0
'@types/semver': 7.3.13
'@vercel/build-utils': 6.1.0
'@vercel/build-utils': 6.2.1
'@vercel/frameworks': 1.3.0
'@vercel/fs-detectors': 3.7.8
'@vercel/fs-detectors': 3.7.10
'@vercel/gatsby-plugin-vercel-analytics': 1.0.7
'@vercel/gatsby-plugin-vercel-builder': 1.1.0
'@vercel/gatsby-plugin-vercel-builder': 1.1.2
'@vercel/ncc': 0.24.0
'@vercel/routing-utils': 2.1.8
'@vercel/static-config': 2.0.12