Compare commits

..

5 Commits

Author SHA1 Message Date
Nathan Rajlich
41ce96a2db Publish Canary
- @vercel/build-utils@2.10.2-canary.4
 - vercel@21.3.4-canary.4
 - @vercel/client@9.0.9-canary.4
 - @vercel/frameworks@0.3.2-canary.4
 - @vercel/routing-utils@1.10.2-canary.2
2021-03-22 17:52:18 -07:00
Connor Davis
a4b4397151 [routing-utils] Add schema descriptions to routing schema (#6023)
Our automated documentation requires descriptions in the schema

#### Tests

- [x] All tests pass locally with `yarn test-unit`

#### Code Review

- [x] This PR has a concise title and thorough description useful to a reviewer
2021-03-23 00:51:30 +00:00
dav-is
473159f1da Publish Canary
- @vercel/build-utils@2.10.2-canary.3
 - vercel@21.3.4-canary.3
 - @vercel/client@9.0.9-canary.3
 - @vercel/frameworks@0.3.2-canary.3
 - @vercel/routing-utils@1.10.2-canary.1
2021-03-22 16:45:42 -04:00
Connor Davis
c6267b5acc [routing-utils] Add has type host to schema (#6022)
We need to support `{ "source": "/", "has": { "type", "host", "value": "vercel.com" }, "destination": "/prod" }`

#### Tests

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

#### Code Review

- [x] This PR has a concise title and thorough description useful to a reviewer
- [x] Issue from task tracker has a link to this PR

CH-19565
2021-03-22 20:37:27 +00:00
Steven
8a919043a2 [frameworks] Fix "svelte" detection and Dev Command (#6014)
- We were matching any project using [sirv](https://www.npmjs.com/package/sirv) which was too broad.
- Hot reloading didn't work because default dev command was incorrect.

This PR updates the framework detection and default dev command to match the example:

c2e7be80e8/examples/svelte/package.json (L6)
2021-03-19 22:21:46 +00:00
10 changed files with 133 additions and 40 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/build-utils",
"version": "2.10.2-canary.2",
"version": "2.10.2-canary.4",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.js",
@@ -29,7 +29,7 @@
"@types/node-fetch": "^2.1.6",
"@types/semver": "6.0.0",
"@types/yazl": "^2.4.1",
"@vercel/frameworks": "0.3.2-canary.2",
"@vercel/frameworks": "0.3.2-canary.4",
"@vercel/ncc": "0.24.0",
"aggregate-error": "3.0.1",
"async-retry": "1.2.3",

View File

@@ -1,6 +1,6 @@
{
"name": "vercel",
"version": "21.3.4-canary.2",
"version": "21.3.4-canary.4",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Vercel",
@@ -61,7 +61,7 @@
"node": ">= 10"
},
"dependencies": {
"@vercel/build-utils": "2.10.2-canary.2",
"@vercel/build-utils": "2.10.2-canary.4",
"@vercel/go": "1.2.2",
"@vercel/node": "1.9.1",
"@vercel/python": "2.0.1",
@@ -99,7 +99,7 @@
"@types/universal-analytics": "0.4.2",
"@types/which": "1.3.2",
"@types/write-json-file": "2.2.1",
"@vercel/frameworks": "0.3.2-canary.2",
"@vercel/frameworks": "0.3.2-canary.4",
"@vercel/ncc": "0.24.0",
"@zeit/fun": "0.11.2",
"@zeit/source-map-support": "0.6.2",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/client",
"version": "9.0.9-canary.2",
"version": "9.0.9-canary.4",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"homepage": "https://vercel.com",
@@ -37,7 +37,7 @@
]
},
"dependencies": {
"@vercel/build-utils": "2.10.2-canary.2",
"@vercel/build-utils": "2.10.2-canary.4",
"@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.3.2-canary.2",
"version": "0.3.2-canary.4",
"main": "./dist/frameworks.js",
"types": "./dist/frameworks.d.ts",
"files": [
@@ -20,7 +20,7 @@
"@types/js-yaml": "3.12.1",
"@types/node": "12.0.4",
"@types/node-fetch": "2.5.8",
"@vercel/routing-utils": "1.10.2-canary.0",
"@vercel/routing-utils": "1.10.2-canary.2",
"ajv": "6.12.2",
"jest": "24.9.0",
"ts-jest": "24.1.0",

View File

@@ -840,6 +840,11 @@ export const frameworks = [
website: 'https://svelte.dev',
detectors: {
every: [
{
path: 'package.json',
matchContent:
'"(dev)?(d|D)ependencies":\\s*{[^}]*"svelte":\\s*".+?"[^}]*}',
},
{
path: 'package.json',
matchContent:
@@ -855,14 +860,14 @@ export const frameworks = [
placeholder: '`npm run build` or `rollup -c`',
},
devCommand: {
value: 'sirv public --single --dev --port $PORT',
value: 'rollup -c -w',
},
outputDirectory: {
value: 'public',
},
},
dependency: 'sirv-cli',
devCommand: 'sirv public --single --dev --port $PORT',
devCommand: 'rollup -c -w',
buildCommand: 'rollup -c',
getOutputDirName: async () => 'public',
defaultRoutes: [

View File

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

View File

@@ -1,26 +1,54 @@
const hasSchema = {
export const hasSchema = {
description: 'An array of requirements that are needed to match',
type: 'array',
maxItems: 16,
items: {
type: 'object',
additionalProperties: false,
required: ['type', 'key'],
properties: {
type: {
type: 'string',
enum: ['header', 'cookie', 'query'],
anyOf: [
{
type: 'object',
additionalProperties: false,
required: ['type', 'value'],
properties: {
type: {
description: 'The type of request element to check',
type: 'string',
enum: ['host'],
},
value: {
description:
'A regular expression used to match the value. Named groups can be used in the destination',
type: 'string',
maxLength: 4096,
},
},
},
key: {
type: 'string',
maxLength: 4096,
{
type: 'object',
additionalProperties: false,
required: ['type', 'key'],
properties: {
type: {
description: 'The type of request element to check',
type: 'string',
enum: ['header', 'cookie', 'query'],
},
key: {
description:
'The name of the element contained in the particular type',
type: 'string',
maxLength: 4096,
},
value: {
description:
'A regular expression used to match the value. Named groups can be used in the destination',
type: 'string',
maxLength: 4096,
},
},
},
value: {
type: 'string',
maxLength: 4096,
},
},
],
},
};
} as const;
/**
* An ajv schema for the routes array
@@ -28,6 +56,10 @@ const hasSchema = {
export const routesSchema = {
type: 'array',
maxItems: 1024,
deprecated: true,
description:
'A list of routes objects used to rewrite paths to point towards other internal or external paths',
example: [{ dest: 'https://docs.example.com', src: '/docs' }],
items: {
anyOf: [
{
@@ -132,50 +164,63 @@ export const routesSchema = {
},
],
},
};
} as const;
export const rewritesSchema = {
type: 'array',
maxItems: 1024,
description: 'A list of rewrite definitions.',
items: {
type: 'object',
additionalProperties: false,
required: ['source', 'destination'],
properties: {
source: {
description:
'A pattern that matches each incoming pathname (excluding querystring).',
type: 'string',
maxLength: 4096,
},
destination: {
description:
'An absolute pathname to an existing resource or an external URL.',
type: 'string',
maxLength: 4096,
},
has: hasSchema,
},
},
};
} as const;
export const redirectsSchema = {
title: 'Redirects',
type: 'array',
maxItems: 1024,
description: 'A list of redirect definitions.',
items: {
type: 'object',
additionalProperties: false,
required: ['source', 'destination'],
properties: {
source: {
description:
'A pattern that matches each incoming pathname (excluding querystring).',
type: 'string',
maxLength: 4096,
},
destination: {
description:
'A location destination defined as an absolute pathname or external URL.',
type: 'string',
maxLength: 4096,
},
permanent: {
description:
'A boolean to toggle between permanent and temporary redirect. When `true`, the status code is `308`. When `false` the status code is `307`.',
type: 'boolean',
},
statusCode: {
private: true,
type: 'integer',
minimum: 100,
maximum: 999,
@@ -183,21 +228,26 @@ export const redirectsSchema = {
has: hasSchema,
},
},
};
} as const;
export const headersSchema = {
type: 'array',
maxItems: 1024,
description: 'A list of header definitions.',
items: {
type: 'object',
additionalProperties: false,
required: ['source', 'headers'],
properties: {
source: {
description:
'A pattern that matches each incoming pathname (excluding querystring)',
type: 'string',
maxLength: 4096,
},
headers: {
description:
'An array of key/value pairs representing each response header.',
type: 'array',
maxItems: 1024,
items: {
@@ -219,12 +269,16 @@ export const headersSchema = {
has: hasSchema,
},
},
};
} as const;
export const cleanUrlsSchema = {
description:
'When set to `true`, all HTML files and Serverless Functions will have their extension removed. When visiting a path that ends with the extension, a 308 response will redirect the client to the extensionless path.',
type: 'boolean',
};
} as const;
export const trailingSlashSchema = {
description:
'When `false`, visiting a path that ends with a forward slash will respond with a `308` status code and redirect to the path without the trailing slash.',
type: 'boolean',
};
} as const;

View File

@@ -9,11 +9,17 @@ export type RouteApiError = {
errors?: string[]; // array of all error messages
};
export type HasField = Array<{
type: 'header' | 'cookie' | 'query';
key: string;
value?: string;
}>;
export type HasField = Array<
| {
type: 'host';
value: string;
}
| {
type: 'header' | 'cookie' | 'query';
key: string;
value?: string;
}
>;
export type Source = {
src: string;

View File

@@ -89,6 +89,7 @@ describe('normalizeRoutes', () => {
{ type: 'header', key: 'x-rewrite' },
{ type: 'cookie', key: 'loggedIn', value: 'yup' },
{ type: 'query', key: 'authorized', value: 'yup' },
{ type: 'host', value: 'vercel.com' },
],
},
];
@@ -958,6 +959,7 @@ describe('getTransformedRoutes', () => {
{ type: 'header', key: 'x-rewrite' },
{ type: 'cookie', key: 'loggedIn', value: 'yup' },
{ type: 'query', key: 'authorized', value: 'yup' },
{ type: 'host', value: 'vercel.com' },
],
},
],
@@ -972,6 +974,7 @@ describe('getTransformedRoutes', () => {
{ type: 'header', key: 'x-redirect' },
{ type: 'cookie', key: 'loggedIn', value: 'yup' },
{ type: 'query', key: 'authorized', value: 'yup' },
{ type: 'host', value: 'vercel.com' },
],
permanent: false,
},
@@ -1005,6 +1008,7 @@ describe('getTransformedRoutes', () => {
{ type: 'header', key: 'x-header' },
{ type: 'cookie', key: 'loggedIn', value: 'yup' },
{ type: 'query', key: 'authorized', value: 'yup' },
{ type: 'host', value: 'vercel.com' },
],
headers: [
{

View File

@@ -211,6 +211,10 @@ test('convertRedirects', () => {
key: 'loggedIn',
value: '1',
},
{
type: 'host',
value: 'vercel.com',
},
],
permanent: false,
},
@@ -315,6 +319,10 @@ test('convertRedirects', () => {
type: 'cookie',
value: '1',
},
{
type: 'host',
value: 'vercel.com',
},
],
headers: {
Location: '/another',
@@ -433,6 +441,10 @@ test('convertRewrites', () => {
key: 'loggedIn',
value: '1',
},
{
type: 'host',
value: 'vercel.com',
},
],
},
]);
@@ -534,6 +546,10 @@ test('convertRewrites', () => {
type: 'cookie',
value: '1',
},
{
type: 'host',
value: 'vercel.com',
},
],
src: '^\\/hello$',
},
@@ -697,6 +713,10 @@ test('convertHeaders', () => {
type: 'cookie',
value: '1',
},
{
type: 'host',
value: 'vercel.com',
},
],
},
]);
@@ -748,6 +768,10 @@ test('convertHeaders', () => {
type: 'cookie',
value: '1',
},
{
type: 'host',
value: 'vercel.com',
},
],
headers: {
'x-header': 'something',