mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-12 12:57:47 +00:00
Compare commits
20 Commits
@vercel/py
...
@vercel/py
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08b04d0bda | ||
|
|
92ae51c6a6 | ||
|
|
909c493d1e | ||
|
|
98b54ff61f | ||
|
|
3defd0b2fd | ||
|
|
5a7851a7f7 | ||
|
|
7f0caa7dec | ||
|
|
89b5aad367 | ||
|
|
c13775ba07 | ||
|
|
cc3c1d1eeb | ||
|
|
3aa2fbbb53 | ||
|
|
3a8b8aa03a | ||
|
|
d008617c0b | ||
|
|
8aecb99447 | ||
|
|
1793fa643f | ||
|
|
913683a8e6 | ||
|
|
0d1dc23d0d | ||
|
|
e829ce47c3 | ||
|
|
474770e9b0 | ||
|
|
e762d8d4e8 |
6
.github/workflows/test-unit.yml
vendored
6
.github/workflows/test-unit.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
node: [12]
|
||||
node: [14]
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
TURBO_REMOTE_ONLY: true
|
||||
@@ -39,9 +39,9 @@ jobs:
|
||||
- run: yarn install --network-timeout 1000000
|
||||
- run: yarn run build
|
||||
- run: yarn run lint
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.node == 12 # only run lint once
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.node == 14 # only run lint once
|
||||
- run: yarn run test-unit
|
||||
- run: yarn workspace vercel run coverage
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.node == 12 # only run coverage once
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.node == 14 # only run coverage once
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
1
examples/solidstart/.gitignore
vendored
1
examples/solidstart/.gitignore
vendored
@@ -2,6 +2,7 @@ dist
|
||||
worker
|
||||
.solid
|
||||
.vercel
|
||||
.output
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defineConfig } from "vite";
|
||||
import solid from "solid-start";
|
||||
import vercel from "solid-start-vercel"
|
||||
import vercel from "solid-start-vercel";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [solid({ adapter: vercel() })]
|
||||
plugins: [solid({ adapter: vercel() })],
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/build-utils",
|
||||
"version": "3.1.0",
|
||||
"version": "3.1.1-canary.1",
|
||||
"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",
|
||||
"@vercel/frameworks": "0.9.2-canary.0",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"aggregate-error": "3.0.1",
|
||||
"async-retry": "1.2.3",
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
import { Framework, FrameworkDetectionItem } from '@vercel/frameworks';
|
||||
import { DetectorFilesystem } from './detectors/filesystem';
|
||||
|
||||
export interface DetectFrameworkOptions {
|
||||
fs: DetectorFilesystem;
|
||||
frameworkList: readonly Framework[];
|
||||
interface BaseFramework {
|
||||
slug: Framework['slug'];
|
||||
detectors?: Framework['detectors'];
|
||||
}
|
||||
|
||||
async function matches(fs: DetectorFilesystem, framework: Framework) {
|
||||
export interface DetectFrameworkOptions {
|
||||
fs: DetectorFilesystem;
|
||||
frameworkList: readonly BaseFramework[];
|
||||
}
|
||||
|
||||
async function matches(fs: DetectorFilesystem, framework: BaseFramework) {
|
||||
const { detectors } = framework;
|
||||
|
||||
if (!detectors) {
|
||||
|
||||
@@ -117,3 +117,4 @@ export const isStaticRuntime = (name?: string): boolean => {
|
||||
};
|
||||
|
||||
export { workspaceManagers } from './workspaces/workspace-managers';
|
||||
export { monorepoManagers } from './monorepos/monorepo-managers';
|
||||
|
||||
36
packages/build-utils/src/monorepos/monorepo-managers.ts
Normal file
36
packages/build-utils/src/monorepos/monorepo-managers.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { Framework } from '@vercel/frameworks';
|
||||
|
||||
/**
|
||||
* The supported list of monorepo managers.
|
||||
*
|
||||
* This list is designed to work with the @see {@link detectFramework} function.
|
||||
*
|
||||
* @example
|
||||
* import { monorepoManagers as frameworkList } from '@vercel/build-utils'
|
||||
* import { detectFramework } from '@vercel/build-utils'
|
||||
*
|
||||
* const fs = new GitDetectorFilesystem(...)
|
||||
* detectFramwork({ fs, frameworkList }) // returns the 'slug' field if detected, otherwise null
|
||||
*
|
||||
*/
|
||||
export const monorepoManagers: Array<
|
||||
Omit<Framework, 'description' | 'logo' | 'settings' | 'getOutputDirName'>
|
||||
> = [
|
||||
{
|
||||
name: 'Turborepo',
|
||||
slug: 'turbo',
|
||||
detectors: {
|
||||
some: [
|
||||
{
|
||||
path: 'turbo.json',
|
||||
},
|
||||
{
|
||||
path: 'package.json',
|
||||
matchContent: '"turbo":\\s*{[^}]*.+[^}]*}',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export default monorepoManagers;
|
||||
@@ -327,6 +327,7 @@ export interface ProjectSettings {
|
||||
buildCommand?: string | null;
|
||||
outputDirectory?: string | null;
|
||||
rootDirectory?: string | null;
|
||||
nodeVersion?: string;
|
||||
createdAt?: number;
|
||||
autoExposeSystemEnvs?: boolean;
|
||||
sourceFilesOutsideRootDirectory?: boolean;
|
||||
@@ -351,11 +352,41 @@ export interface BuilderV3 {
|
||||
|
||||
type ImageFormat = 'image/avif' | 'image/webp';
|
||||
|
||||
export type RemotePattern = {
|
||||
/**
|
||||
* Must be `http` or `https`.
|
||||
*/
|
||||
protocol?: 'http' | 'https';
|
||||
|
||||
/**
|
||||
* Can be literal or wildcard.
|
||||
* Single `*` matches a single subdomain.
|
||||
* Double `**` matches any number of subdomains.
|
||||
*/
|
||||
hostname: string;
|
||||
|
||||
/**
|
||||
* Can be literal port such as `8080` or empty string
|
||||
* meaning no port.
|
||||
*/
|
||||
port?: string;
|
||||
|
||||
/**
|
||||
* Can be literal or wildcard.
|
||||
* Single `*` matches a single path segment.
|
||||
* Double `**` matches any number of path segments.
|
||||
*/
|
||||
pathname?: string;
|
||||
};
|
||||
|
||||
export interface Images {
|
||||
domains: string[];
|
||||
remotePatterns?: RemotePattern[];
|
||||
sizes: number[];
|
||||
minimumCacheTTL?: number;
|
||||
formats?: ImageFormat[];
|
||||
dangerouslyAllowSVG?: boolean;
|
||||
contentSecurityPolicy?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,15 +6,16 @@ import type { Framework } from '@vercel/frameworks';
|
||||
* This list is designed to work with the @see {@link detectFramework} function.
|
||||
*
|
||||
* @example
|
||||
* import { workspaceManagers as frameworkList } from '@vercel/build-utils/workspaces'
|
||||
* import { workspaceManagers as frameworkList } from '@vercel/build-utils'
|
||||
* import { detectFramework } from '@vercel/build-utils'
|
||||
*
|
||||
* const fs = new GitDetectorFilesystem(...)
|
||||
* detectFramwork({ fs, frameworkList }) // returns the 'slug' field if detected, otherwise null
|
||||
*
|
||||
* @todo Will be used by the detect-eligible-projects API endpoint for a given git url.
|
||||
*/
|
||||
export const workspaceManagers: Array<Framework> = [
|
||||
export const workspaceManagers: Array<
|
||||
Omit<Framework, 'description' | 'logo' | 'settings' | 'getOutputDirName'>
|
||||
> = [
|
||||
{
|
||||
name: 'Yarn',
|
||||
slug: 'yarn',
|
||||
@@ -30,28 +31,6 @@ export const workspaceManagers: Array<Framework> = [
|
||||
},
|
||||
],
|
||||
},
|
||||
// unused props - needed for typescript
|
||||
description: '',
|
||||
logo: '',
|
||||
settings: {
|
||||
buildCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
devCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
installCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
outputDirectory: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
},
|
||||
getOutputDirName: () => Promise.resolve(''),
|
||||
},
|
||||
{
|
||||
name: 'pnpm',
|
||||
@@ -63,28 +42,6 @@ export const workspaceManagers: Array<Framework> = [
|
||||
},
|
||||
],
|
||||
},
|
||||
// unused props - needed for typescript
|
||||
description: '',
|
||||
logo: '',
|
||||
settings: {
|
||||
buildCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
devCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
installCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
outputDirectory: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
},
|
||||
getOutputDirName: () => Promise.resolve(''),
|
||||
},
|
||||
{
|
||||
name: 'npm',
|
||||
@@ -101,28 +58,6 @@ export const workspaceManagers: Array<Framework> = [
|
||||
},
|
||||
],
|
||||
},
|
||||
// unused props - needed for typescript
|
||||
description: '',
|
||||
logo: '',
|
||||
settings: {
|
||||
buildCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
devCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
installCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
outputDirectory: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
},
|
||||
getOutputDirName: () => Promise.resolve(''),
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
15
packages/build-utils/test/fixtures/28-turborepo-with-yarn-workspaces/a/package.json
vendored
Normal file
15
packages/build-utils/test/fixtures/28-turborepo-with-yarn-workspaces/a/package.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "a",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"debug": "^4.3.2"
|
||||
}
|
||||
}
|
||||
15
packages/build-utils/test/fixtures/28-turborepo-with-yarn-workspaces/b/package.json
vendored
Normal file
15
packages/build-utils/test/fixtures/28-turborepo-with-yarn-workspaces/b/package.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "b",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"cowsay": "^1.5.0"
|
||||
}
|
||||
}
|
||||
9
packages/build-utils/test/fixtures/28-turborepo-with-yarn-workspaces/package.json
vendored
Normal file
9
packages/build-utils/test/fixtures/28-turborepo-with-yarn-workspaces/package.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "21-npm-workspaces",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"workspaces": [
|
||||
"a",
|
||||
"b"
|
||||
]
|
||||
}
|
||||
20
packages/build-utils/test/fixtures/28-turborepo-with-yarn-workspaces/turbo.json
vendored
Normal file
20
packages/build-utils/test/fixtures/28-turborepo-with-yarn-workspaces/turbo.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"$schema": "https://turborepo.org/schema.json",
|
||||
"baseBranch": "origin/main",
|
||||
"pipeline": {
|
||||
"build": {
|
||||
"dependsOn": ["^build"],
|
||||
"outputs": [".next/**"]
|
||||
},
|
||||
"test": {
|
||||
"dependsOn": ["^build"],
|
||||
"outputs": []
|
||||
},
|
||||
"lint": {
|
||||
"outputs": []
|
||||
},
|
||||
"dev": {
|
||||
"cache": false
|
||||
}
|
||||
}
|
||||
}
|
||||
232
packages/build-utils/test/fixtures/28-turborepo-with-yarn-workspaces/yarn.lock
vendored
Normal file
232
packages/build-utils/test/fixtures/28-turborepo-with-yarn-workspaces/yarn.lock
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
ansi-regex@^3.0.0:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.1.tgz#123d6479e92ad45ad897d4054e3c7ca7db4944e1"
|
||||
integrity sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==
|
||||
|
||||
ansi-regex@^5.0.1:
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304"
|
||||
integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==
|
||||
|
||||
ansi-styles@^4.0.0:
|
||||
version "4.3.0"
|
||||
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937"
|
||||
integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==
|
||||
dependencies:
|
||||
color-convert "^2.0.1"
|
||||
|
||||
camelcase@^5.0.0:
|
||||
version "5.3.1"
|
||||
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
|
||||
integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
|
||||
|
||||
cliui@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1"
|
||||
integrity sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==
|
||||
dependencies:
|
||||
string-width "^4.2.0"
|
||||
strip-ansi "^6.0.0"
|
||||
wrap-ansi "^6.2.0"
|
||||
|
||||
color-convert@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
|
||||
integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==
|
||||
dependencies:
|
||||
color-name "~1.1.4"
|
||||
|
||||
color-name@~1.1.4:
|
||||
version "1.1.4"
|
||||
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
|
||||
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
|
||||
|
||||
cowsay@^1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/cowsay/-/cowsay-1.5.0.tgz#4a2a453b8b59383c7d7a50e44d765c5de0bf615f"
|
||||
integrity sha512-8Ipzr54Z8zROr/62C8f0PdhQcDusS05gKTS87xxdji8VbWefWly0k8BwGK7+VqamOrkv3eGsCkPtvlHzrhWsCA==
|
||||
dependencies:
|
||||
get-stdin "8.0.0"
|
||||
string-width "~2.1.1"
|
||||
strip-final-newline "2.0.0"
|
||||
yargs "15.4.1"
|
||||
|
||||
debug@^4.3.2:
|
||||
version "4.3.4"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
|
||||
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
|
||||
dependencies:
|
||||
ms "2.1.2"
|
||||
|
||||
decamelize@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
|
||||
integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=
|
||||
|
||||
emoji-regex@^8.0.0:
|
||||
version "8.0.0"
|
||||
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
|
||||
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
|
||||
|
||||
find-up@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19"
|
||||
integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==
|
||||
dependencies:
|
||||
locate-path "^5.0.0"
|
||||
path-exists "^4.0.0"
|
||||
|
||||
get-caller-file@^2.0.1:
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
|
||||
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
|
||||
|
||||
get-stdin@8.0.0:
|
||||
version "8.0.0"
|
||||
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-8.0.0.tgz#cbad6a73feb75f6eeb22ba9e01f89aa28aa97a53"
|
||||
integrity sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==
|
||||
|
||||
is-fullwidth-code-point@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
|
||||
integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=
|
||||
|
||||
is-fullwidth-code-point@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
|
||||
integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==
|
||||
|
||||
locate-path@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0"
|
||||
integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==
|
||||
dependencies:
|
||||
p-locate "^4.1.0"
|
||||
|
||||
ms@2.1.2:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
|
||||
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
|
||||
|
||||
p-limit@^2.2.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
|
||||
integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==
|
||||
dependencies:
|
||||
p-try "^2.0.0"
|
||||
|
||||
p-locate@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07"
|
||||
integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==
|
||||
dependencies:
|
||||
p-limit "^2.2.0"
|
||||
|
||||
p-try@^2.0.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
|
||||
integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==
|
||||
|
||||
path-exists@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3"
|
||||
integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==
|
||||
|
||||
require-directory@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
|
||||
integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I=
|
||||
|
||||
require-main-filename@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
|
||||
integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==
|
||||
|
||||
set-blocking@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
|
||||
integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc=
|
||||
|
||||
string-width@^4.1.0, string-width@^4.2.0:
|
||||
version "4.2.3"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||
dependencies:
|
||||
emoji-regex "^8.0.0"
|
||||
is-fullwidth-code-point "^3.0.0"
|
||||
strip-ansi "^6.0.1"
|
||||
|
||||
string-width@~2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
|
||||
integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==
|
||||
dependencies:
|
||||
is-fullwidth-code-point "^2.0.0"
|
||||
strip-ansi "^4.0.0"
|
||||
|
||||
strip-ansi@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f"
|
||||
integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8=
|
||||
dependencies:
|
||||
ansi-regex "^3.0.0"
|
||||
|
||||
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||
dependencies:
|
||||
ansi-regex "^5.0.1"
|
||||
|
||||
strip-final-newline@2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad"
|
||||
integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==
|
||||
|
||||
which-module@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
|
||||
integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=
|
||||
|
||||
wrap-ansi@^6.2.0:
|
||||
version "6.2.0"
|
||||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53"
|
||||
integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==
|
||||
dependencies:
|
||||
ansi-styles "^4.0.0"
|
||||
string-width "^4.1.0"
|
||||
strip-ansi "^6.0.0"
|
||||
|
||||
y18n@^4.0.0:
|
||||
version "4.0.3"
|
||||
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf"
|
||||
integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==
|
||||
|
||||
yargs-parser@^18.1.2:
|
||||
version "18.1.3"
|
||||
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0"
|
||||
integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==
|
||||
dependencies:
|
||||
camelcase "^5.0.0"
|
||||
decamelize "^1.2.0"
|
||||
|
||||
yargs@15.4.1:
|
||||
version "15.4.1"
|
||||
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8"
|
||||
integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==
|
||||
dependencies:
|
||||
cliui "^6.0.0"
|
||||
decamelize "^1.2.0"
|
||||
find-up "^4.1.0"
|
||||
get-caller-file "^2.0.1"
|
||||
require-directory "^2.1.1"
|
||||
require-main-filename "^2.0.0"
|
||||
set-blocking "^2.0.0"
|
||||
string-width "^4.2.0"
|
||||
which-module "^2.0.0"
|
||||
y18n "^4.0.0"
|
||||
yargs-parser "^18.1.2"
|
||||
15
packages/build-utils/test/fixtures/29-turborepo-in-package-json/a/package.json
vendored
Normal file
15
packages/build-utils/test/fixtures/29-turborepo-in-package-json/a/package.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "a",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"debug": "^4.3.2"
|
||||
}
|
||||
}
|
||||
15
packages/build-utils/test/fixtures/29-turborepo-in-package-json/b/package.json
vendored
Normal file
15
packages/build-utils/test/fixtures/29-turborepo-in-package-json/b/package.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "b",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"cowsay": "^1.5.0"
|
||||
}
|
||||
}
|
||||
34
packages/build-utils/test/fixtures/29-turborepo-in-package-json/package.json
vendored
Normal file
34
packages/build-utils/test/fixtures/29-turborepo-in-package-json/package.json
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "21-npm-workspaces",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"workspaces": [
|
||||
"a",
|
||||
"b"
|
||||
],
|
||||
"turbo": {
|
||||
"baseBranch": "origin/main",
|
||||
"pipeline": {
|
||||
"build": {
|
||||
"dependsOn": [
|
||||
"^build"
|
||||
],
|
||||
"outputs": [
|
||||
".next/**"
|
||||
]
|
||||
},
|
||||
"test": {
|
||||
"dependsOn": [
|
||||
"^build"
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
"lint": {
|
||||
"outputs": []
|
||||
},
|
||||
"dev": {
|
||||
"cache": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
232
packages/build-utils/test/fixtures/29-turborepo-in-package-json/yarn.lock
vendored
Normal file
232
packages/build-utils/test/fixtures/29-turborepo-in-package-json/yarn.lock
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
ansi-regex@^3.0.0:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.1.tgz#123d6479e92ad45ad897d4054e3c7ca7db4944e1"
|
||||
integrity sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==
|
||||
|
||||
ansi-regex@^5.0.1:
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304"
|
||||
integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==
|
||||
|
||||
ansi-styles@^4.0.0:
|
||||
version "4.3.0"
|
||||
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937"
|
||||
integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==
|
||||
dependencies:
|
||||
color-convert "^2.0.1"
|
||||
|
||||
camelcase@^5.0.0:
|
||||
version "5.3.1"
|
||||
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
|
||||
integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
|
||||
|
||||
cliui@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1"
|
||||
integrity sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==
|
||||
dependencies:
|
||||
string-width "^4.2.0"
|
||||
strip-ansi "^6.0.0"
|
||||
wrap-ansi "^6.2.0"
|
||||
|
||||
color-convert@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
|
||||
integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==
|
||||
dependencies:
|
||||
color-name "~1.1.4"
|
||||
|
||||
color-name@~1.1.4:
|
||||
version "1.1.4"
|
||||
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
|
||||
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
|
||||
|
||||
cowsay@^1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/cowsay/-/cowsay-1.5.0.tgz#4a2a453b8b59383c7d7a50e44d765c5de0bf615f"
|
||||
integrity sha512-8Ipzr54Z8zROr/62C8f0PdhQcDusS05gKTS87xxdji8VbWefWly0k8BwGK7+VqamOrkv3eGsCkPtvlHzrhWsCA==
|
||||
dependencies:
|
||||
get-stdin "8.0.0"
|
||||
string-width "~2.1.1"
|
||||
strip-final-newline "2.0.0"
|
||||
yargs "15.4.1"
|
||||
|
||||
debug@^4.3.2:
|
||||
version "4.3.4"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
|
||||
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
|
||||
dependencies:
|
||||
ms "2.1.2"
|
||||
|
||||
decamelize@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
|
||||
integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=
|
||||
|
||||
emoji-regex@^8.0.0:
|
||||
version "8.0.0"
|
||||
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
|
||||
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
|
||||
|
||||
find-up@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19"
|
||||
integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==
|
||||
dependencies:
|
||||
locate-path "^5.0.0"
|
||||
path-exists "^4.0.0"
|
||||
|
||||
get-caller-file@^2.0.1:
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
|
||||
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
|
||||
|
||||
get-stdin@8.0.0:
|
||||
version "8.0.0"
|
||||
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-8.0.0.tgz#cbad6a73feb75f6eeb22ba9e01f89aa28aa97a53"
|
||||
integrity sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==
|
||||
|
||||
is-fullwidth-code-point@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
|
||||
integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=
|
||||
|
||||
is-fullwidth-code-point@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
|
||||
integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==
|
||||
|
||||
locate-path@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0"
|
||||
integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==
|
||||
dependencies:
|
||||
p-locate "^4.1.0"
|
||||
|
||||
ms@2.1.2:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
|
||||
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
|
||||
|
||||
p-limit@^2.2.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
|
||||
integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==
|
||||
dependencies:
|
||||
p-try "^2.0.0"
|
||||
|
||||
p-locate@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07"
|
||||
integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==
|
||||
dependencies:
|
||||
p-limit "^2.2.0"
|
||||
|
||||
p-try@^2.0.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
|
||||
integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==
|
||||
|
||||
path-exists@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3"
|
||||
integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==
|
||||
|
||||
require-directory@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
|
||||
integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I=
|
||||
|
||||
require-main-filename@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
|
||||
integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==
|
||||
|
||||
set-blocking@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
|
||||
integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc=
|
||||
|
||||
string-width@^4.1.0, string-width@^4.2.0:
|
||||
version "4.2.3"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||
dependencies:
|
||||
emoji-regex "^8.0.0"
|
||||
is-fullwidth-code-point "^3.0.0"
|
||||
strip-ansi "^6.0.1"
|
||||
|
||||
string-width@~2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
|
||||
integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==
|
||||
dependencies:
|
||||
is-fullwidth-code-point "^2.0.0"
|
||||
strip-ansi "^4.0.0"
|
||||
|
||||
strip-ansi@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f"
|
||||
integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8=
|
||||
dependencies:
|
||||
ansi-regex "^3.0.0"
|
||||
|
||||
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||
dependencies:
|
||||
ansi-regex "^5.0.1"
|
||||
|
||||
strip-final-newline@2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad"
|
||||
integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==
|
||||
|
||||
which-module@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
|
||||
integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=
|
||||
|
||||
wrap-ansi@^6.2.0:
|
||||
version "6.2.0"
|
||||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53"
|
||||
integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==
|
||||
dependencies:
|
||||
ansi-styles "^4.0.0"
|
||||
string-width "^4.1.0"
|
||||
strip-ansi "^6.0.0"
|
||||
|
||||
y18n@^4.0.0:
|
||||
version "4.0.3"
|
||||
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf"
|
||||
integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==
|
||||
|
||||
yargs-parser@^18.1.2:
|
||||
version "18.1.3"
|
||||
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0"
|
||||
integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==
|
||||
dependencies:
|
||||
camelcase "^5.0.0"
|
||||
decamelize "^1.2.0"
|
||||
|
||||
yargs@15.4.1:
|
||||
version "15.4.1"
|
||||
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8"
|
||||
integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==
|
||||
dependencies:
|
||||
cliui "^6.0.0"
|
||||
decamelize "^1.2.0"
|
||||
find-up "^4.1.0"
|
||||
get-caller-file "^2.0.1"
|
||||
require-directory "^2.1.1"
|
||||
require-main-filename "^2.0.0"
|
||||
set-blocking "^2.0.0"
|
||||
string-width "^4.2.0"
|
||||
which-module "^2.0.0"
|
||||
y18n "^4.0.0"
|
||||
yargs-parser "^18.1.2"
|
||||
@@ -33,6 +33,8 @@ const skipFixtures: string[] = [
|
||||
'21-npm-workspaces',
|
||||
'23-pnpm-workspaces',
|
||||
'27-yarn-workspaces',
|
||||
'28-turborepo-with-yarn-workspaces',
|
||||
'29-turborepo-in-package-json',
|
||||
];
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
|
||||
28
packages/build-utils/test/unit.detect-monorepo-managers.test.ts
vendored
Normal file
28
packages/build-utils/test/unit.detect-monorepo-managers.test.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import path from 'path';
|
||||
import { detectFramework } from '../src/detect-framework';
|
||||
import monorepoManagers from '../src/monorepos/monorepo-managers';
|
||||
import { FixtureFilesystem } from './utils/fixture-filesystem';
|
||||
|
||||
describe('monorepo-managers', () => {
|
||||
describe.each([
|
||||
['turbo', '28-turborepo-with-yarn-workspaces'],
|
||||
['turbo', '29-turborepo-in-package-json'],
|
||||
[null, '22-pnpm'],
|
||||
])('with detectFramework', (frameworkSlug, fixturePath) => {
|
||||
const testName = frameworkSlug
|
||||
? `should detect a ${frameworkSlug} workspace for ${fixturePath}`
|
||||
: `should not detect a monorepo manager for ${fixturePath}`;
|
||||
|
||||
it(testName, async () => {
|
||||
const fixture = path.join(__dirname, 'fixtures', fixturePath);
|
||||
const fs = new FixtureFilesystem(fixture);
|
||||
|
||||
const result = await detectFramework({
|
||||
fs,
|
||||
frameworkList: monorepoManagers,
|
||||
});
|
||||
|
||||
expect(result).toBe(frameworkSlug);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vercel",
|
||||
"version": "24.2.4",
|
||||
"version": "24.2.5-canary.1",
|
||||
"preferGlobal": true,
|
||||
"license": "Apache-2.0",
|
||||
"description": "The command-line interface for Vercel",
|
||||
@@ -43,11 +43,15 @@
|
||||
"node": ">= 12"
|
||||
},
|
||||
"dependencies": {
|
||||
"@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",
|
||||
"@vercel/build-utils": "3.1.1-canary.1",
|
||||
"@vercel/go": "1.4.4-canary.1",
|
||||
"@vercel/next": "2.8.67-canary.1",
|
||||
"@vercel/node": "1.15.4-canary.1",
|
||||
"@vercel/python": "2.3.4-canary.1",
|
||||
"@vercel/redwood": "0.8.4-canary.1",
|
||||
"@vercel/remix": "0.0.2-canary.1",
|
||||
"@vercel/ruby": "1.3.7-canary.1",
|
||||
"@vercel/static-build": "0.25.3-canary.1",
|
||||
"update-notifier": "4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -90,8 +94,9 @@
|
||||
"@types/update-notifier": "5.1.0",
|
||||
"@types/which": "1.3.2",
|
||||
"@types/write-json-file": "2.2.1",
|
||||
"@vercel/client": "11.0.3",
|
||||
"@vercel/frameworks": "0.9.1",
|
||||
"@types/yauzl-promise": "2.1.0",
|
||||
"@vercel/client": "11.0.4-canary.1",
|
||||
"@vercel/frameworks": "0.9.2-canary.0",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"@zeit/fun": "0.11.2",
|
||||
"@zeit/source-map-support": "0.6.2",
|
||||
@@ -167,7 +172,8 @@
|
||||
"utility-types": "2.1.0",
|
||||
"which": "2.0.2",
|
||||
"write-json-file": "2.2.0",
|
||||
"xdg-app-paths": "5.1.0"
|
||||
"xdg-app-paths": "5.1.0",
|
||||
"yauzl-promise": "2.1.3"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
|
||||
510
packages/cli/src/commands/build.ts
Normal file
510
packages/cli/src/commands/build.ts
Normal file
@@ -0,0 +1,510 @@
|
||||
import fs from 'fs-extra';
|
||||
import chalk from 'chalk';
|
||||
import dotenv from 'dotenv';
|
||||
import { join, relative } from 'path';
|
||||
import {
|
||||
detectBuilders,
|
||||
Files,
|
||||
FileFsRef,
|
||||
PackageJson,
|
||||
BuildOptions,
|
||||
Config,
|
||||
Meta,
|
||||
Builder,
|
||||
BuildResultV2,
|
||||
BuildResultV2Typical,
|
||||
BuildResultV3,
|
||||
} from '@vercel/build-utils';
|
||||
import minimatch from 'minimatch';
|
||||
import {
|
||||
appendRoutesToPhase,
|
||||
getTransformedRoutes,
|
||||
mergeRoutes,
|
||||
MergeRoutesProps,
|
||||
Route,
|
||||
} from '@vercel/routing-utils';
|
||||
import { VercelConfig } from '@vercel/client';
|
||||
|
||||
import pull from './pull';
|
||||
import { staticFiles as getFiles } from '../util/get-files';
|
||||
import Client from '../util/client';
|
||||
import getArgs from '../util/get-args';
|
||||
import cmd from '../util/output/cmd';
|
||||
import * as cli from '../util/pkg-name';
|
||||
import cliPkg from '../util/pkg';
|
||||
import readJSONFile from '../util/read-json-file';
|
||||
import { CantParseJSONFile } from '../util/errors-ts';
|
||||
import { readProjectSettings } from '../util/projects/project-settings';
|
||||
import { VERCEL_DIR } from '../util/projects/link';
|
||||
import confirm from '../util/input/confirm';
|
||||
import { emoji, prependEmoji } from '../util/emoji';
|
||||
import stamp from '../util/output/stamp';
|
||||
import {
|
||||
OUTPUT_DIR,
|
||||
PathOverride,
|
||||
writeBuildResult,
|
||||
} from '../util/build/write-build-result';
|
||||
import { importBuilders, BuilderWithPkg } from '../util/build/import-builders';
|
||||
|
||||
type BuildResult = BuildResultV2 | BuildResultV3;
|
||||
|
||||
const help = () => {
|
||||
return console.log(`
|
||||
${chalk.bold(`${cli.logo} ${cli.name} build`)}
|
||||
|
||||
${chalk.dim('Options:')}
|
||||
|
||||
-h, --help Output usage information
|
||||
-A ${chalk.bold.underline('FILE')}, --local-config=${chalk.bold.underline(
|
||||
'FILE'
|
||||
)} Path to the local ${'`vercel.json`'} file
|
||||
-Q ${chalk.bold.underline('DIR')}, --global-config=${chalk.bold.underline(
|
||||
'DIR'
|
||||
)} Path to the global ${'`.vercel`'} directory
|
||||
--cwd [path] The current working directory
|
||||
--prod Build a production deployment
|
||||
-d, --debug Debug mode [off]
|
||||
-y, --yes Skip the confirmation prompt
|
||||
|
||||
${chalk.dim('Examples:')}
|
||||
|
||||
${chalk.gray('–')} Build the project
|
||||
|
||||
${chalk.cyan(`$ ${cli.name} build`)}
|
||||
${chalk.cyan(`$ ${cli.name} build --cwd ./path-to-project`)}
|
||||
`);
|
||||
};
|
||||
|
||||
export default async function main(client: Client): Promise<number> {
|
||||
const { output } = client;
|
||||
|
||||
// Ensure that `vc build` is not being invoked recursively
|
||||
if (process.env.__VERCEL_BUILD_RUNNING) {
|
||||
output.error(
|
||||
`${cmd(
|
||||
`${cli.name} build`
|
||||
)} must not recursively invoke itself. Check the Build Command in the Project Settings or the ${cmd(
|
||||
'build'
|
||||
)} script in ${cmd('package.json')}`
|
||||
);
|
||||
output.error(
|
||||
`Learn More: https://vercel.link/recursive-invocation-of-commands`
|
||||
);
|
||||
return 1;
|
||||
} else {
|
||||
process.env.__VERCEL_BUILD_RUNNING = '1';
|
||||
}
|
||||
|
||||
// Parse CLI args
|
||||
const argv = getArgs(client.argv.slice(2), {
|
||||
'--cwd': String,
|
||||
'--prod': Boolean,
|
||||
});
|
||||
|
||||
if (argv['--help']) {
|
||||
help();
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Set the working directory if necessary
|
||||
if (argv['--cwd']) {
|
||||
process.chdir(argv['--cwd']);
|
||||
}
|
||||
const cwd = process.cwd();
|
||||
|
||||
// TODO: read project settings from the API, fall back to local `project.json` if that fails
|
||||
|
||||
// Read project settings, and pull them from Vercel if necessary
|
||||
let project = await readProjectSettings(join(cwd, VERCEL_DIR));
|
||||
const isTTY = process.stdin.isTTY;
|
||||
while (!project?.settings) {
|
||||
if (!isTTY) {
|
||||
client.output.print(
|
||||
`No Project Settings found locally. Run ${cli.getCommandName(
|
||||
'pull --yes'
|
||||
)} to retreive them.`
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const confirmed = await confirm(
|
||||
`No Project Settings found locally. Run ${cli.getCommandName(
|
||||
'pull'
|
||||
)} for retrieving them?`,
|
||||
true
|
||||
);
|
||||
if (!confirmed) {
|
||||
client.output.print(`Aborted. No Project Settings retrieved.\n`);
|
||||
return 0;
|
||||
}
|
||||
client.argv = [];
|
||||
const result = await pull(client);
|
||||
if (result !== 0) {
|
||||
return result;
|
||||
}
|
||||
project = await readProjectSettings(join(cwd, VERCEL_DIR));
|
||||
}
|
||||
|
||||
// Build `target` influences which environment variables will be used
|
||||
const target = argv['--prod'] ? 'production' : 'preview';
|
||||
|
||||
// TODO: load env vars from the API, fall back to local files if that fails
|
||||
|
||||
const envPath = await checkExists([
|
||||
join(cwd, VERCEL_DIR, `.env.${target}.local`),
|
||||
join(cwd, `.env`),
|
||||
]);
|
||||
if (envPath) {
|
||||
dotenv.config({ path: envPath, debug: client.output.isDebugEnabled() });
|
||||
output.log(`Loaded env from "${relative(cwd, envPath)}"`);
|
||||
}
|
||||
|
||||
// Some build processes use these env vars to platform detect Vercel
|
||||
process.env.VERCEL = '1';
|
||||
process.env.NOW_BUILDER = '1';
|
||||
|
||||
const workPath = join(cwd, project.settings.rootDirectory || '.');
|
||||
|
||||
// Load `package.json` and `vercel.json` files
|
||||
const [pkg, vercelConfig] = await Promise.all([
|
||||
readJSONFile<PackageJson>(join(workPath, 'package.json')),
|
||||
readJSONFile<VercelConfig>(join(workPath, 'vercel.json')).then(
|
||||
config => config || readJSONFile<VercelConfig>(join(workPath, 'now.json'))
|
||||
),
|
||||
]);
|
||||
if (pkg instanceof CantParseJSONFile) throw pkg;
|
||||
if (vercelConfig instanceof CantParseJSONFile) throw vercelConfig;
|
||||
|
||||
// Get a list of source files
|
||||
const files = (await getFiles(workPath, client)).map(f =>
|
||||
relative(workPath, f)
|
||||
);
|
||||
|
||||
const routesResult = getTransformedRoutes({ nowConfig: vercelConfig || {} });
|
||||
if (routesResult.error) {
|
||||
output.prettyError(routesResult.error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (vercelConfig?.builds && vercelConfig.functions) {
|
||||
output.prettyError({
|
||||
message:
|
||||
'The `functions` property cannot be used in conjunction with the `builds` property. Please remove one of them.',
|
||||
link: 'https://vercel.link/functions-and-builds',
|
||||
});
|
||||
return 1;
|
||||
}
|
||||
|
||||
let builds = vercelConfig?.builds || [];
|
||||
let zeroConfigRoutes: Route[] = [];
|
||||
|
||||
if (builds.length > 0) {
|
||||
output.warn(
|
||||
'Due to `builds` existing in your configuration file, the Build and Development Settings defined in your Project Settings will not apply. Learn More: https://vercel.link/unused-build-settings'
|
||||
);
|
||||
builds = builds.map(b => expandBuild(files, b)).flat();
|
||||
} else {
|
||||
// Zero config
|
||||
|
||||
// Detect the Vercel Builders that will need to be invoked
|
||||
const detectedBuilders = await detectBuilders(files, pkg, {
|
||||
...vercelConfig,
|
||||
projectSettings: project.settings,
|
||||
featHandleMiss: true,
|
||||
});
|
||||
|
||||
if (detectedBuilders.errors && detectedBuilders.errors.length > 0) {
|
||||
output.prettyError(detectedBuilders.errors[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (const w of detectedBuilders.warnings) {
|
||||
console.log(
|
||||
`Warning: ${w.message} ${w.action || 'Learn More'}: ${w.link}`
|
||||
);
|
||||
}
|
||||
|
||||
if (detectedBuilders.builders) {
|
||||
builds = detectedBuilders.builders;
|
||||
} else {
|
||||
builds = [{ src: '**', use: '@vercel/static' }];
|
||||
}
|
||||
|
||||
zeroConfigRoutes.push(...(detectedBuilders.redirectRoutes || []));
|
||||
zeroConfigRoutes.push(
|
||||
...appendRoutesToPhase({
|
||||
routes: [],
|
||||
newRoutes: detectedBuilders.rewriteRoutes,
|
||||
phase: 'filesystem',
|
||||
})
|
||||
);
|
||||
zeroConfigRoutes = appendRoutesToPhase({
|
||||
routes: zeroConfigRoutes,
|
||||
newRoutes: detectedBuilders.errorRoutes,
|
||||
phase: 'error',
|
||||
});
|
||||
zeroConfigRoutes.push(...(detectedBuilders.defaultRoutes || []));
|
||||
}
|
||||
|
||||
const builderSpecs = new Set(builds.map(b => b.use));
|
||||
|
||||
let buildersWithPkgs: Map<string, BuilderWithPkg>;
|
||||
try {
|
||||
buildersWithPkgs = await importBuilders(builderSpecs, cwd, output);
|
||||
} catch (err: any) {
|
||||
output.prettyError(err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Populate Files -> FileFsRef mapping
|
||||
const filesMap: Files = {};
|
||||
for (const path of files) {
|
||||
const fsPath = join(workPath, path);
|
||||
const { mode } = await fs.stat(fsPath);
|
||||
filesMap[path] = new FileFsRef({ mode, fsPath });
|
||||
}
|
||||
|
||||
// Delete output directory from potential previous build
|
||||
await fs.remove(OUTPUT_DIR);
|
||||
|
||||
const buildStamp = stamp();
|
||||
|
||||
// Create fresh new output directory
|
||||
await fs.mkdirp(OUTPUT_DIR);
|
||||
|
||||
const ops: Promise<Error | void>[] = [];
|
||||
|
||||
// Write the `detectedBuilders` result to output dir
|
||||
ops.push(
|
||||
fs.writeJSON(
|
||||
join(OUTPUT_DIR, 'builds.json'),
|
||||
{
|
||||
'//': 'This file was generated by the `vercel build` command. It is not part of the Build Output API.',
|
||||
target,
|
||||
builds: builds.map(build => {
|
||||
const builderWithPkg = buildersWithPkgs.get(build.use);
|
||||
if (!builderWithPkg) {
|
||||
throw new Error(`Failed to load Builder "${build.use}"`);
|
||||
}
|
||||
const { builder, pkg: builderPkg } = builderWithPkg;
|
||||
return {
|
||||
require: builderPkg.name,
|
||||
apiVersion: builder.version,
|
||||
...build,
|
||||
};
|
||||
}),
|
||||
},
|
||||
{
|
||||
spaces: 2,
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// The `meta` config property is re-used for each Builder
|
||||
// invocation so that Builders can share state between
|
||||
// subsequent entrypoint builds.
|
||||
const meta: Meta = {
|
||||
skipDownload: true,
|
||||
cliVersion: cliPkg.version,
|
||||
};
|
||||
|
||||
// Execute Builders for detected entrypoints
|
||||
// TODO: parallelize builds
|
||||
const buildResults: Map<Builder, BuildResult> = new Map();
|
||||
const overrides: PathOverride[] = [];
|
||||
for (const build of builds) {
|
||||
if (typeof build.src !== 'string') continue;
|
||||
|
||||
const builderWithPkg = buildersWithPkgs.get(build.use);
|
||||
if (!builderWithPkg) {
|
||||
throw new Error(`Failed to load Builder "${build.use}"`);
|
||||
}
|
||||
const { builder, pkg: builderPkg } = builderWithPkg;
|
||||
|
||||
const buildConfig: Config = {
|
||||
outputDirectory: project.settings.outputDirectory ?? undefined,
|
||||
...build.config,
|
||||
projectSettings: project.settings,
|
||||
installCommand: project.settings.installCommand ?? undefined,
|
||||
devCommand: project.settings.devCommand ?? undefined,
|
||||
buildCommand: project.settings.buildCommand ?? undefined,
|
||||
framework: project.settings.framework,
|
||||
nodeVersion: project.settings.nodeVersion,
|
||||
};
|
||||
const repoRootPath = cwd === workPath ? undefined : cwd;
|
||||
const buildOptions: BuildOptions = {
|
||||
files: filesMap,
|
||||
entrypoint: build.src,
|
||||
workPath,
|
||||
repoRootPath,
|
||||
config: buildConfig,
|
||||
meta,
|
||||
};
|
||||
output.debug(
|
||||
`Building entrypoint "${build.src}" with "${builderPkg.name}"`
|
||||
);
|
||||
const buildResult = await builder.build(buildOptions);
|
||||
|
||||
// Store the build result to generate the final `config.json` after
|
||||
// all builds have completed
|
||||
buildResults.set(build, buildResult);
|
||||
|
||||
// Start flushing the file outputs to the filesystem asynchronously
|
||||
ops.push(
|
||||
writeBuildResult(
|
||||
buildResult,
|
||||
build,
|
||||
builder,
|
||||
builderPkg,
|
||||
vercelConfig?.cleanUrls
|
||||
).then(
|
||||
override => {
|
||||
if (override) overrides.push(override);
|
||||
},
|
||||
err => err
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Wait for filesystem operations to complete
|
||||
// TODO render progress bar?
|
||||
let hadError = false;
|
||||
const errors = await Promise.all(ops);
|
||||
for (const error of errors) {
|
||||
if (error) {
|
||||
hadError = true;
|
||||
output.prettyError(error);
|
||||
}
|
||||
}
|
||||
if (hadError) return 1;
|
||||
|
||||
// Merge existing `config.json` file into the one that will be produced
|
||||
const configPath = join(OUTPUT_DIR, 'config.json');
|
||||
// TODO: properly type
|
||||
const existingConfig = await readJSONFile<any>(configPath);
|
||||
if (existingConfig instanceof CantParseJSONFile) {
|
||||
throw existingConfig;
|
||||
}
|
||||
if (existingConfig) {
|
||||
if (existingConfig.overrides) {
|
||||
overrides.push(existingConfig.overrides);
|
||||
}
|
||||
// Find the `Build` entry for this config file and update the build result
|
||||
for (const [build, buildResult] of buildResults.entries()) {
|
||||
if ('buildOutputPath' in buildResult) {
|
||||
output.debug(`Using "config.json" for "${build.use}`);
|
||||
buildResults.set(build, existingConfig);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const builderRoutes: MergeRoutesProps['builds'] = Array.from(
|
||||
buildResults.entries()
|
||||
)
|
||||
.filter(b => 'routes' in b[1] && Array.isArray(b[1].routes))
|
||||
.map(b => {
|
||||
return {
|
||||
use: b[0].use,
|
||||
entrypoint: b[0].src!,
|
||||
routes: (b[1] as BuildResultV2Typical).routes,
|
||||
};
|
||||
});
|
||||
if (zeroConfigRoutes.length) {
|
||||
builderRoutes.unshift({
|
||||
use: '@vercel/zero-config-routes',
|
||||
entrypoint: '/',
|
||||
routes: zeroConfigRoutes,
|
||||
});
|
||||
}
|
||||
const mergedRoutes = mergeRoutes({
|
||||
userRoutes: routesResult.routes,
|
||||
builds: builderRoutes,
|
||||
});
|
||||
|
||||
const mergedImages = mergeImages(buildResults.values());
|
||||
const mergedWildcard = mergeWildcard(buildResults.values());
|
||||
const mergedOverrides: Record<string, PathOverride> =
|
||||
overrides.length > 0 ? Object.assign({}, ...overrides) : undefined;
|
||||
|
||||
// Write out the final `config.json` file based on the
|
||||
// user configuration and Builder build results
|
||||
// TODO: properly type
|
||||
const config = {
|
||||
version: 3,
|
||||
routes: mergedRoutes,
|
||||
images: mergedImages,
|
||||
wildcard: mergedWildcard,
|
||||
overrides: mergedOverrides,
|
||||
};
|
||||
await fs.writeJSON(join(OUTPUT_DIR, 'config.json'), config, { spaces: 2 });
|
||||
|
||||
output.print(
|
||||
`${prependEmoji(
|
||||
`Build Completed in ${chalk.bold(OUTPUT_DIR)} ${chalk.gray(
|
||||
buildStamp()
|
||||
)}`,
|
||||
emoji('success')
|
||||
)}\n`
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function expandBuild(files: string[], build: Builder): Builder[] {
|
||||
if (!build.src) return [];
|
||||
|
||||
let pattern = build.src;
|
||||
if (pattern[0] === '/') {
|
||||
// Remove a leading slash so that the globbing is relative
|
||||
// to `cwd` instead of the root of the filesystem.
|
||||
pattern = pattern.substring(1);
|
||||
}
|
||||
|
||||
const matches = files.filter(
|
||||
name => name === pattern || minimatch(name, pattern, { dot: true })
|
||||
);
|
||||
|
||||
return matches.map(m => {
|
||||
return {
|
||||
...build,
|
||||
src: m,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function mergeImages(
|
||||
buildResults: Iterable<BuildResult>
|
||||
): BuildResultV2Typical['images'] {
|
||||
let images: BuildResultV2Typical['images'] = undefined;
|
||||
for (const result of buildResults) {
|
||||
if ('images' in result && result.images) {
|
||||
images = Object.assign({} || images, result.images);
|
||||
}
|
||||
}
|
||||
return images;
|
||||
}
|
||||
|
||||
function mergeWildcard(
|
||||
buildResults: Iterable<BuildResult>
|
||||
): BuildResultV2Typical['wildcard'] {
|
||||
let wildcard: BuildResultV2Typical['wildcard'] = undefined;
|
||||
for (const result of buildResults) {
|
||||
if ('wildcard' in result && result.wildcard) {
|
||||
if (!wildcard) wildcard = [];
|
||||
wildcard.push(...result.wildcard);
|
||||
}
|
||||
}
|
||||
return wildcard;
|
||||
}
|
||||
|
||||
async function checkExists(paths: Iterable<string>) {
|
||||
for (const path of paths) {
|
||||
try {
|
||||
await fs.stat(path);
|
||||
return path;
|
||||
} catch (err: any) {
|
||||
if (err.code !== 'ENOENT') throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ export default new Map([
|
||||
['aliases', 'alias'],
|
||||
['billing', 'billing'],
|
||||
['bisect', 'bisect'],
|
||||
['build', 'build'],
|
||||
['cc', 'billing'],
|
||||
['cert', 'certs'],
|
||||
['certs', 'certs'],
|
||||
|
||||
@@ -15,6 +15,12 @@ import { getPkgName, getCommandName } from '../util/pkg-name.ts';
|
||||
|
||||
const help = () => {
|
||||
console.log(`
|
||||
${chalk.yellow(
|
||||
`${chalk.bold('NOTE:')} The ${getCommandName(
|
||||
'env'
|
||||
)} command is recommended instead of ${getCommandName('secrets')}`
|
||||
)}
|
||||
|
||||
${chalk.bold(`${logo} ${getPkgName()} secrets`)} [options] <command>
|
||||
|
||||
${chalk.dim('Commands:')}
|
||||
@@ -64,7 +70,7 @@ const help = () => {
|
||||
|
||||
${chalk.gray('–')} Paginate results, where ${chalk.dim(
|
||||
'`1584722256178`'
|
||||
)} is the time in milliseconds since the UNIX epoch.
|
||||
)} is the time in milliseconds since the UNIX epoch
|
||||
|
||||
${chalk.cyan(`$ ${getPkgName()} secrets ls --next 1584722256178`)}
|
||||
`);
|
||||
@@ -130,8 +136,14 @@ async function run({ output, contextName, currentTeam, client }) {
|
||||
const args = argv._.slice(1);
|
||||
const start = Date.now();
|
||||
const { 'test-warning': testWarningFlag } = argv;
|
||||
const commandName = getCommandName('secret ' + subcommand);
|
||||
|
||||
if (subcommand === 'ls' || subcommand === 'list') {
|
||||
output.note(
|
||||
`The ${getCommandName(
|
||||
'env ls'
|
||||
)} command is recommended instead of ${commandName}\n`
|
||||
);
|
||||
if (args.length > 1) {
|
||||
console.error(
|
||||
error(
|
||||
@@ -194,6 +206,11 @@ async function run({ output, contextName, currentTeam, client }) {
|
||||
}
|
||||
|
||||
if (subcommand === 'rm' || subcommand === 'remove') {
|
||||
output.note(
|
||||
`The ${getCommandName(
|
||||
'env rm'
|
||||
)} command is recommended instead of ${commandName}\n`
|
||||
);
|
||||
if (args.length !== 1) {
|
||||
console.error(
|
||||
error(
|
||||
@@ -236,6 +253,11 @@ async function run({ output, contextName, currentTeam, client }) {
|
||||
}
|
||||
|
||||
if (subcommand === 'rename') {
|
||||
output.note(
|
||||
`The ${getCommandName('env rm')} and ${getCommandName(
|
||||
'env add'
|
||||
)} commands are recommended instead of ${commandName}\n`
|
||||
);
|
||||
if (args.length !== 2) {
|
||||
console.error(
|
||||
error(
|
||||
@@ -259,6 +281,11 @@ async function run({ output, contextName, currentTeam, client }) {
|
||||
}
|
||||
|
||||
if (subcommand === 'add' || subcommand === 'set') {
|
||||
output.note(
|
||||
`The ${getCommandName(
|
||||
'env add'
|
||||
)} command is recommended instead of ${commandName}\n`
|
||||
);
|
||||
if (args.length !== 2) {
|
||||
console.error(
|
||||
error(
|
||||
|
||||
@@ -171,7 +171,7 @@ const main = async () => {
|
||||
// * a subcommand (as in: `vercel ls`)
|
||||
const targetOrSubcommand = argv._[2];
|
||||
|
||||
const betaCommands: string[] = [];
|
||||
const betaCommands: string[] = ['build'];
|
||||
if (betaCommands.includes(targetOrSubcommand)) {
|
||||
console.log(
|
||||
`${chalk.grey(
|
||||
@@ -303,7 +303,14 @@ const main = async () => {
|
||||
|
||||
let authConfig = null;
|
||||
|
||||
const subcommandsWithoutToken = ['login', 'logout', 'help', 'init', 'update'];
|
||||
const subcommandsWithoutToken = [
|
||||
'login',
|
||||
'logout',
|
||||
'help',
|
||||
'init',
|
||||
'update',
|
||||
'build',
|
||||
];
|
||||
|
||||
if (authConfigExists) {
|
||||
try {
|
||||
@@ -524,6 +531,7 @@ const main = async () => {
|
||||
typeof scope === 'string' &&
|
||||
targetCommand !== 'login' &&
|
||||
targetCommand !== 'dev' &&
|
||||
targetCommand !== 'build' &&
|
||||
!(targetCommand === 'teams' && argv._[3] !== 'invite')
|
||||
) {
|
||||
let user = null;
|
||||
@@ -598,6 +606,9 @@ const main = async () => {
|
||||
case 'bisect':
|
||||
func = require('./commands/bisect').default;
|
||||
break;
|
||||
case 'build':
|
||||
func = require('./commands/build').default;
|
||||
break;
|
||||
case 'certs':
|
||||
func = require('./commands/certs').default;
|
||||
break;
|
||||
|
||||
@@ -251,9 +251,6 @@ export interface Project extends ProjectSettings {
|
||||
updatedAt: number;
|
||||
createdAt: number;
|
||||
alias?: ProjectAliasTarget[];
|
||||
devCommand?: string | null;
|
||||
framework?: string | null;
|
||||
rootDirectory?: string | null;
|
||||
latestDeployments?: Partial<Deployment>[];
|
||||
}
|
||||
|
||||
|
||||
225
packages/cli/src/util/build/import-builders.ts
Normal file
225
packages/cli/src/util/build/import-builders.ts
Normal file
@@ -0,0 +1,225 @@
|
||||
import npa from 'npm-package-arg';
|
||||
import { satisfies } from 'semver';
|
||||
import { dirname, join } from 'path';
|
||||
import { outputJSON, readJSON } from 'fs-extra';
|
||||
import {
|
||||
BuilderV2,
|
||||
BuilderV3,
|
||||
PackageJson,
|
||||
spawnAsync,
|
||||
} from '@vercel/build-utils';
|
||||
import * as staticBuilder from './static-builder';
|
||||
import { VERCEL_DIR } from '../projects/link';
|
||||
import { Output } from '../output';
|
||||
import readJSONFile from '../read-json-file';
|
||||
import { CantParseJSONFile } from '../errors-ts';
|
||||
|
||||
export interface BuilderWithPkg {
|
||||
path: string;
|
||||
pkgPath: string;
|
||||
builder: BuilderV2 | BuilderV3;
|
||||
pkg: PackageJson;
|
||||
}
|
||||
|
||||
type ResolveBuildersResult =
|
||||
| { buildersToAdd: Set<string> }
|
||||
| { builders: Map<string, BuilderWithPkg> };
|
||||
|
||||
/**
|
||||
* Imports the specified Vercel Builders, installing any missing ones
|
||||
* into `.vercel/builders` if necessary.
|
||||
*/
|
||||
export async function importBuilders(
|
||||
builderSpecs: Set<string>,
|
||||
cwd: string,
|
||||
output: Output
|
||||
): Promise<Map<string, BuilderWithPkg>> {
|
||||
const buildersDir = join(cwd, VERCEL_DIR, 'builders');
|
||||
|
||||
let importResult = await resolveBuilders(buildersDir, builderSpecs, output);
|
||||
|
||||
if ('buildersToAdd' in importResult) {
|
||||
const installResult = await installBuilders(
|
||||
buildersDir,
|
||||
importResult.buildersToAdd,
|
||||
output
|
||||
);
|
||||
|
||||
importResult = await resolveBuilders(
|
||||
buildersDir,
|
||||
builderSpecs,
|
||||
output,
|
||||
installResult.resolvedSpecs
|
||||
);
|
||||
|
||||
if ('buildersToAdd' in importResult) {
|
||||
throw new Error('Something went wrong!');
|
||||
}
|
||||
}
|
||||
|
||||
return importResult.builders;
|
||||
}
|
||||
|
||||
export async function resolveBuilders(
|
||||
buildersDir: string,
|
||||
builderSpecs: Set<string>,
|
||||
output: Output,
|
||||
resolvedSpecs?: Map<string, string>
|
||||
): Promise<ResolveBuildersResult> {
|
||||
const builders = new Map<string, BuilderWithPkg>();
|
||||
const buildersToAdd = new Set<string>();
|
||||
|
||||
for (const spec of builderSpecs) {
|
||||
const resolvedSpec = resolvedSpecs?.get(spec) || spec;
|
||||
const parsed = npa(resolvedSpec);
|
||||
|
||||
let { name } = parsed;
|
||||
if (!name) {
|
||||
// A URL was specified - will need to install it and resolve the
|
||||
// proper package name from the written `package.json` file
|
||||
buildersToAdd.add(spec);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name === '@vercel/static') {
|
||||
// `@vercel/static` is a special-case built-in builder
|
||||
builders.set(name, {
|
||||
builder: staticBuilder,
|
||||
pkg: { name },
|
||||
path: '',
|
||||
pkgPath: '',
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
let pkgPath: string | undefined;
|
||||
let builderPkg: PackageJson | undefined;
|
||||
|
||||
try {
|
||||
// First try `.vercel/builders`. The package name should always be available
|
||||
// at the top-level of `node_modules` since CLI is installing those directly.
|
||||
pkgPath = join(buildersDir, 'node_modules', name, 'package.json');
|
||||
builderPkg = await readJSON(pkgPath);
|
||||
} catch (err: any) {
|
||||
if (err?.code !== 'ENOENT') throw err;
|
||||
// If `pkgPath` wasn't found in `.vercel/builders` then try as a CLI local
|
||||
// dependency. `require.resolve()` will throw if the Builder is not a CLI
|
||||
// dep, in which case we'll install it into `.vercel/builders`.
|
||||
pkgPath = require.resolve(`${name}/package.json`, {
|
||||
paths: [__dirname],
|
||||
});
|
||||
builderPkg = await readJSON(pkgPath);
|
||||
}
|
||||
|
||||
if (!builderPkg || !pkgPath) {
|
||||
throw new Error(`Failed to load \`package.json\` for "${name}"`);
|
||||
}
|
||||
|
||||
if (typeof builderPkg.version !== 'string') {
|
||||
throw new Error(
|
||||
`\`package.json\` for "${name}" does not contain a "version" field`
|
||||
);
|
||||
}
|
||||
|
||||
if (parsed.type === 'version' && parsed.rawSpec !== builderPkg.version) {
|
||||
// An explicit Builder version was specified but it does
|
||||
// not match the version that is currently installed
|
||||
output.debug(
|
||||
`Installed version "${name}@${builderPkg.version}" does not match "${parsed.rawSpec}"`
|
||||
);
|
||||
buildersToAdd.add(spec);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
parsed.type === 'range' &&
|
||||
!satisfies(builderPkg.version, parsed.rawSpec)
|
||||
) {
|
||||
// An explicit Builder range was specified but it is not
|
||||
// compatible with the version that is currently installed
|
||||
output.debug(
|
||||
`Installed version "${name}@${builderPkg.version}" is not compatible with "${parsed.rawSpec}"`
|
||||
);
|
||||
buildersToAdd.add(spec);
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO: handle `parsed.type === 'tag'` ("latest" vs. anything else?)
|
||||
|
||||
const path = join(dirname(pkgPath), builderPkg.main || 'index.js');
|
||||
const builder = require(path);
|
||||
|
||||
builders.set(spec, {
|
||||
builder,
|
||||
pkg: builderPkg,
|
||||
path,
|
||||
pkgPath,
|
||||
});
|
||||
output.debug(`Imported Builder "${name}" from "${dirname(pkgPath)}"`);
|
||||
} catch (err: any) {
|
||||
// `resolvedSpecs` is only passed into this function on the 2nd run,
|
||||
// so if MODULE_NOT_FOUND happens in that case then we don't want to
|
||||
// try to install again. Instead just pass through the error to the user
|
||||
if (err.code === 'MODULE_NOT_FOUND' && !resolvedSpecs) {
|
||||
output.debug(`Failed to import "${name}": ${err}`);
|
||||
buildersToAdd.add(spec);
|
||||
} else {
|
||||
err.message = `Importing "${name}": ${err.message}`;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add any Builders that are not yet present into `.vercel/builders`
|
||||
if (buildersToAdd.size > 0) {
|
||||
return { buildersToAdd };
|
||||
}
|
||||
|
||||
return { builders };
|
||||
}
|
||||
|
||||
async function installBuilders(
|
||||
buildersDir: string,
|
||||
buildersToAdd: Set<string>,
|
||||
output: Output
|
||||
) {
|
||||
const resolvedSpecs = new Map<string, string>();
|
||||
const buildersPkgPath = join(buildersDir, 'package.json');
|
||||
try {
|
||||
const emptyPkgJson = {
|
||||
private: true,
|
||||
license: 'UNLICENSED',
|
||||
};
|
||||
await outputJSON(buildersPkgPath, emptyPkgJson, {
|
||||
flag: 'wx',
|
||||
});
|
||||
} catch (err: any) {
|
||||
if (err.code !== 'EEXIST') throw err;
|
||||
}
|
||||
|
||||
output.debug(`Installing Builders: ${Array.from(buildersToAdd).join(', ')}`);
|
||||
await spawnAsync('yarn', ['add', '@vercel/build-utils', ...buildersToAdd], {
|
||||
cwd: buildersDir,
|
||||
});
|
||||
|
||||
// Cross-reference any builderSpecs from the saved `package.json` file,
|
||||
// in case they were installed from a URL
|
||||
const buildersPkg = await readJSONFile<PackageJson>(buildersPkgPath);
|
||||
if (buildersPkg instanceof CantParseJSONFile) throw buildersPkg;
|
||||
if (!buildersPkg) {
|
||||
throw new Error(`Failed to load "${buildersPkgPath}"`);
|
||||
}
|
||||
for (const spec of buildersToAdd) {
|
||||
for (const [name, version] of Object.entries(
|
||||
buildersPkg.dependencies || {}
|
||||
)) {
|
||||
if (version === spec) {
|
||||
output.debug(`Resolved Builder spec "${spec}" to name "${name}"`);
|
||||
resolvedSpecs.set(spec, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { resolvedSpecs };
|
||||
}
|
||||
41
packages/cli/src/util/build/static-builder.ts
Normal file
41
packages/cli/src/util/build/static-builder.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import minimatch from 'minimatch';
|
||||
import { BuildV2, Files } from '@vercel/build-utils';
|
||||
|
||||
export const version = 2;
|
||||
|
||||
export const build: BuildV2 = async ({ entrypoint, files, config }) => {
|
||||
const output: Files = {};
|
||||
const outputDirectory = config.zeroConfig ? config.outputDirectory : '';
|
||||
|
||||
for (let [filename, fileFsRef] of Object.entries(files)) {
|
||||
if (
|
||||
filename.startsWith('.git/') ||
|
||||
filename === 'vercel.json' ||
|
||||
filename === 'now.json'
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
entrypoint &&
|
||||
!(
|
||||
entrypoint === filename ||
|
||||
minimatch(filename, entrypoint, { dot: true })
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (outputDirectory) {
|
||||
const outputMatch = outputDirectory + '/';
|
||||
if (filename.startsWith(outputMatch)) {
|
||||
// static output files are moved to the root directory
|
||||
filename = filename.slice(outputMatch.length);
|
||||
}
|
||||
}
|
||||
|
||||
output[filename] = fileFsRef;
|
||||
}
|
||||
|
||||
return { output };
|
||||
};
|
||||
108
packages/cli/src/util/build/unzip.ts
Normal file
108
packages/cli/src/util/build/unzip.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* Code modified from `extract-zip` to accept Buffer.
|
||||
* https://github.com/maxogden/extract-zip/blob/master/index.js
|
||||
* BSD-2 Copyright (c) 2014 Max Ogden and other contributors
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import pipe from 'promisepipe';
|
||||
import * as fs from 'fs-extra';
|
||||
import { streamToBuffer } from '@vercel/build-utils';
|
||||
import { Entry, ZipFile, fromBuffer as zipFromBuffer } from 'yauzl-promise';
|
||||
|
||||
async function* createZipIterator(zipFile: ZipFile) {
|
||||
let entry: Entry;
|
||||
while ((entry = await zipFile.readEntry()) !== null) {
|
||||
yield entry;
|
||||
}
|
||||
}
|
||||
|
||||
export async function unzip(buffer: Buffer, dir: string): Promise<void> {
|
||||
const zipFile = await zipFromBuffer(buffer);
|
||||
for await (const entry of createZipIterator(zipFile)) {
|
||||
if (entry.fileName.startsWith('__MACOSX/')) continue;
|
||||
|
||||
try {
|
||||
const destDir = path.dirname(path.join(dir, entry.fileName));
|
||||
await fs.mkdirp(destDir);
|
||||
|
||||
const canonicalDestDir = await fs.realpath(destDir);
|
||||
const relativeDestDir = path.relative(dir, canonicalDestDir);
|
||||
|
||||
if (relativeDestDir.split(path.sep).includes('..')) {
|
||||
throw new Error(
|
||||
`Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`
|
||||
);
|
||||
}
|
||||
|
||||
await extractEntry(zipFile, entry, dir);
|
||||
} catch (err) {
|
||||
await zipFile.close();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function extractEntry(
|
||||
zipFile: ZipFile,
|
||||
entry: Entry,
|
||||
dir: string
|
||||
): Promise<void> {
|
||||
const dest = path.join(dir, entry.fileName);
|
||||
|
||||
// convert external file attr int into a fs stat mode int
|
||||
const mode = (entry.externalFileAttributes >> 16) & 0xffff;
|
||||
// check if it's a symlink or dir (using stat mode constants)
|
||||
const IFMT = 61440;
|
||||
const IFDIR = 16384;
|
||||
const IFLNK = 40960;
|
||||
const symlink = (mode & IFMT) === IFLNK;
|
||||
let isDir = (mode & IFMT) === IFDIR;
|
||||
|
||||
// Failsafe, borrowed from jsZip
|
||||
if (!isDir && entry.fileName.endsWith('/')) {
|
||||
isDir = true;
|
||||
}
|
||||
|
||||
// check for windows weird way of specifying a directory
|
||||
// https://github.com/maxogden/extract-zip/issues/13#issuecomment-154494566
|
||||
const madeBy = entry.versionMadeBy >> 8;
|
||||
if (!isDir) isDir = madeBy === 0 && entry.externalFileAttributes === 16;
|
||||
|
||||
const procMode = getExtractedMode(mode, isDir) & 0o777;
|
||||
|
||||
// always ensure folders are created
|
||||
const destDir = isDir ? dest : path.dirname(dest);
|
||||
|
||||
const mkdirOptions = { recursive: true };
|
||||
if (isDir) {
|
||||
// @ts-ignore
|
||||
mkdirOptions.mode = procMode;
|
||||
}
|
||||
await fs.mkdir(destDir, mkdirOptions);
|
||||
if (isDir) return;
|
||||
|
||||
const readStream = await zipFile.openReadStream(entry);
|
||||
|
||||
if (symlink) {
|
||||
const link = await streamToBuffer(readStream);
|
||||
await fs.symlink(link.toString('utf8'), dest);
|
||||
} else {
|
||||
await pipe(readStream, fs.createWriteStream(dest, { mode: procMode }));
|
||||
}
|
||||
}
|
||||
|
||||
function getExtractedMode(entryMode: number, isDir: boolean): number {
|
||||
let mode = entryMode;
|
||||
|
||||
// Set defaults, if necessary
|
||||
if (mode === 0) {
|
||||
if (isDir) {
|
||||
mode = 0o755;
|
||||
} else {
|
||||
mode = 0o644;
|
||||
}
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
373
packages/cli/src/util/build/write-build-result.ts
Normal file
373
packages/cli/src/util/build/write-build-result.ts
Normal file
@@ -0,0 +1,373 @@
|
||||
import fs from 'fs-extra';
|
||||
import mimeTypes from 'mime-types';
|
||||
import { basename, dirname, extname, join, relative, resolve } from 'path';
|
||||
import {
|
||||
Builder,
|
||||
BuildResultV2,
|
||||
BuildResultV3,
|
||||
File,
|
||||
FileFsRef,
|
||||
BuilderV2,
|
||||
BuilderV3,
|
||||
Lambda,
|
||||
PackageJson,
|
||||
Prerender,
|
||||
download,
|
||||
EdgeFunction,
|
||||
BuildResultBuildOutput,
|
||||
} from '@vercel/build-utils';
|
||||
import pipe from 'promisepipe';
|
||||
import { unzip } from './unzip';
|
||||
import { VERCEL_DIR } from '../projects/link';
|
||||
|
||||
export const OUTPUT_DIR = join(VERCEL_DIR, 'output');
|
||||
|
||||
export async function writeBuildResult(
|
||||
buildResult: BuildResultV2 | BuildResultV3,
|
||||
build: Builder,
|
||||
builder: BuilderV2 | BuilderV3,
|
||||
builderPkg: PackageJson,
|
||||
cleanUrls?: boolean
|
||||
) {
|
||||
const { version } = builder;
|
||||
if (version === 2) {
|
||||
return writeBuildResultV2(buildResult as BuildResultV2, cleanUrls);
|
||||
} else if (version === 3) {
|
||||
return writeBuildResultV3(buildResult as BuildResultV3, build);
|
||||
}
|
||||
throw new Error(
|
||||
`Unsupported Builder version \`${version}\` from "${builderPkg.name}"`
|
||||
);
|
||||
}
|
||||
|
||||
function isEdgeFunction(v: any): v is EdgeFunction {
|
||||
return v?.type === 'EdgeFunction';
|
||||
}
|
||||
|
||||
function isLambda(v: any): v is Lambda {
|
||||
return v?.type === 'Lambda';
|
||||
}
|
||||
|
||||
function isPrerender(v: any): v is Prerender {
|
||||
return v?.type === 'Prerender';
|
||||
}
|
||||
|
||||
function isFile(v: any): v is File {
|
||||
const type = v?.type;
|
||||
return type === 'FileRef' || type === 'FileFsRef' || type === 'FileBlob';
|
||||
}
|
||||
|
||||
export interface PathOverride {
|
||||
contentType?: string;
|
||||
path?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the output from the `build()` return value of a v2 Builder to
|
||||
* the filesystem.
|
||||
*/
|
||||
async function writeBuildResultV2(
|
||||
buildResult: BuildResultV2,
|
||||
cleanUrls?: boolean
|
||||
) {
|
||||
if ('buildOutputPath' in buildResult) {
|
||||
await mergeBuilderOutput(buildResult);
|
||||
return;
|
||||
}
|
||||
|
||||
const lambdas = new Map<Lambda, string>();
|
||||
const overrides: Record<string, PathOverride> = {};
|
||||
for (const [path, output] of Object.entries(buildResult.output)) {
|
||||
if (isLambda(output)) {
|
||||
await writeLambda(output, path, lambdas);
|
||||
} else if (isPrerender(output)) {
|
||||
await writeLambda(output.lambda, path, lambdas);
|
||||
|
||||
// Write the fallback file alongside the Lambda directory
|
||||
let fallback = output.fallback;
|
||||
if (fallback) {
|
||||
const ext = getFileExtension(fallback);
|
||||
const fallbackName = `${path}.prerender-fallback${ext}`;
|
||||
const fallbackPath = join(OUTPUT_DIR, 'functions', fallbackName);
|
||||
const stream = fallback.toStream();
|
||||
await pipe(
|
||||
stream,
|
||||
fs.createWriteStream(fallbackPath, { mode: fallback.mode })
|
||||
);
|
||||
fallback = new FileFsRef({
|
||||
...output.fallback,
|
||||
fsPath: basename(fallbackName),
|
||||
});
|
||||
}
|
||||
|
||||
const prerenderConfigPath = join(
|
||||
OUTPUT_DIR,
|
||||
'functions',
|
||||
`${path}.prerender-config.json`
|
||||
);
|
||||
const prerenderConfig = {
|
||||
...output,
|
||||
lambda: undefined,
|
||||
fallback,
|
||||
};
|
||||
await fs.writeJSON(prerenderConfigPath, prerenderConfig, { spaces: 2 });
|
||||
} else if (isFile(output)) {
|
||||
await writeStaticFile(output, path, overrides, cleanUrls);
|
||||
} else if (isEdgeFunction(output)) {
|
||||
await writeEdgeFunction(output, path);
|
||||
} else {
|
||||
throw new Error(
|
||||
`Unsupported output type: "${(output as any).type}" for ${path}`
|
||||
);
|
||||
}
|
||||
}
|
||||
return Object.keys(overrides).length > 0 ? overrides : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the output from the `build()` return value of a v3 Builder to
|
||||
* the filesystem.
|
||||
*/
|
||||
async function writeBuildResultV3(buildResult: BuildResultV3, build: Builder) {
|
||||
const { output } = buildResult;
|
||||
if (isLambda(output)) {
|
||||
const src = build.src!;
|
||||
const ext = extname(src);
|
||||
const path = build.config?.zeroConfig
|
||||
? src.substring(0, src.length - ext.length)
|
||||
: src;
|
||||
await writeLambda(output, path);
|
||||
} else {
|
||||
throw new Error(
|
||||
`Unsupported output type: "${(output as any).type}" for ${build.src}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a static `File` instance to the file system in the "static" directory.
|
||||
* If the filename does not have a file extension then one attempts to be inferred
|
||||
* from the extension of the `fsPath`.
|
||||
*
|
||||
* @param file The `File` instance to write
|
||||
* @param path The URL path where the `File` can be accessed from
|
||||
* @param overrides Record of override configuration when a File is renamed or has other metadata
|
||||
*/
|
||||
async function writeStaticFile(
|
||||
file: File,
|
||||
path: string,
|
||||
overrides: Record<string, PathOverride>,
|
||||
cleanUrls = false
|
||||
) {
|
||||
let fsPath = path;
|
||||
let override: PathOverride | null = null;
|
||||
|
||||
// If the output path doesn't match the determined file extension of
|
||||
// the File then add the extension. This is to help avoid conflicts
|
||||
// where an output path matches a directory name of another output path
|
||||
// (i.e. `blog` -> `blog.html` and `blog/hello` -> `blog/hello.html`)
|
||||
const ext = getFileExtension(file);
|
||||
if (ext && extname(path) !== ext) {
|
||||
fsPath += ext;
|
||||
if (!override) override = {};
|
||||
override.path = path;
|
||||
}
|
||||
|
||||
// If `cleanUrls` is true then remove the `.html` file extension
|
||||
// for HTML files.
|
||||
if (cleanUrls && path.endsWith('.html')) {
|
||||
if (!override) override = {};
|
||||
override.path = path.slice(0, -5);
|
||||
}
|
||||
|
||||
// Ensure an explicit "content-type" on the `File` is returned in
|
||||
// the final output asset.
|
||||
if (file.contentType) {
|
||||
if (!override) override = {};
|
||||
override.contentType = file.contentType;
|
||||
}
|
||||
|
||||
if (override) {
|
||||
overrides[fsPath] = override;
|
||||
}
|
||||
|
||||
const dest = join(OUTPUT_DIR, 'static', fsPath);
|
||||
await fs.mkdirp(dirname(dest));
|
||||
|
||||
// TODO: handle (or skip) symlinks?
|
||||
const stream = file.toStream();
|
||||
await pipe(stream, fs.createWriteStream(dest, { mode: file.mode }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the `EdgeFunction` instance to the file system.
|
||||
*
|
||||
* @param edgeFunction The `EdgeFunction` instance
|
||||
* @param path The URL path where the `EdgeFunction` can be accessed from
|
||||
*/
|
||||
async function writeEdgeFunction(edgeFunction: EdgeFunction, path: string) {
|
||||
const dest = join(OUTPUT_DIR, 'functions', `${path}.func`);
|
||||
|
||||
await fs.mkdirp(dest);
|
||||
const ops: Promise<any>[] = [];
|
||||
ops.push(download(edgeFunction.files, dest));
|
||||
|
||||
const config = {
|
||||
runtime: 'edge',
|
||||
...edgeFunction,
|
||||
files: undefined,
|
||||
type: undefined,
|
||||
};
|
||||
const configPath = join(dest, '.vc-config.json');
|
||||
ops.push(
|
||||
fs.writeJSON(configPath, config, {
|
||||
spaces: 2,
|
||||
})
|
||||
);
|
||||
await Promise.all(ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the file references from the `Lambda` instance to the file system.
|
||||
*
|
||||
* @param lambda The `Lambda` instance
|
||||
* @param path The URL path where the `Lambda` can be accessed from
|
||||
* @param lambdas (optional) Map of `Lambda` instances that have previously been written
|
||||
*/
|
||||
async function writeLambda(
|
||||
lambda: Lambda,
|
||||
path: string,
|
||||
lambdas?: Map<Lambda, string>
|
||||
) {
|
||||
const dest = join(OUTPUT_DIR, 'functions', `${path}.func`);
|
||||
|
||||
// If the `lambda` has already been written to the filesystem at a different
|
||||
// location then create a symlink to the previous location instead of copying
|
||||
// the files again.
|
||||
const existingLambdaPath = lambdas?.get(lambda);
|
||||
if (existingLambdaPath) {
|
||||
const destDir = dirname(dest);
|
||||
const targetDest = join(
|
||||
OUTPUT_DIR,
|
||||
'functions',
|
||||
`${existingLambdaPath}.func`
|
||||
);
|
||||
const target = relative(destDir, targetDest);
|
||||
await fs.mkdirp(destDir);
|
||||
await fs.symlink(target, dest);
|
||||
return;
|
||||
}
|
||||
lambdas?.set(lambda, path);
|
||||
|
||||
await fs.mkdirp(dest);
|
||||
const ops: Promise<any>[] = [];
|
||||
if (lambda.files) {
|
||||
// `files` is defined
|
||||
ops.push(download(lambda.files, dest));
|
||||
} else if (lambda.zipBuffer) {
|
||||
// Builders that use the deprecated `createLambda()` might only have `zipBuffer`
|
||||
ops.push(unzip(lambda.zipBuffer, dest));
|
||||
} else {
|
||||
throw new Error('Malformed `Lambda` - no "files" present');
|
||||
}
|
||||
|
||||
const config = {
|
||||
...lambda,
|
||||
type: undefined,
|
||||
files: undefined,
|
||||
zipBuffer: undefined,
|
||||
};
|
||||
const configPath = join(dest, '.vc-config.json');
|
||||
ops.push(
|
||||
fs.writeJSON(configPath, config, {
|
||||
spaces: 2,
|
||||
})
|
||||
);
|
||||
await Promise.all(ops);
|
||||
|
||||
// XXX: remove any `.vercel/builders` directories that were
|
||||
// extracted into the `dest` dir. This is a temporary band-aid
|
||||
// to make `vercel-php` work since it is inadvertently including
|
||||
// `.vercel/builders` into the Lambda files due to glob syntax.
|
||||
// See: https://github.com/juicyfx/vercel-php/pull/232
|
||||
for await (const dir of findDirs('.vercel', dest)) {
|
||||
const absDir = join(dest, dir);
|
||||
const entries = await fs.readdir(absDir);
|
||||
if (entries.includes('cache')) {
|
||||
// Delete everything except for "cache"
|
||||
await Promise.all(
|
||||
entries
|
||||
.filter(e => e !== 'cache')
|
||||
.map(entry => fs.remove(join(absDir, entry)))
|
||||
);
|
||||
} else {
|
||||
// Delete the entire `.vercel` directory
|
||||
await fs.remove(absDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When the Root Directory setting is utilized, merge the contents of the
|
||||
* `.vercel/output` directory that was specified by the Builder into the
|
||||
* `vc build` output directory.
|
||||
*/
|
||||
async function mergeBuilderOutput(buildResult: BuildResultBuildOutput) {
|
||||
const absOutputDir = resolve(OUTPUT_DIR);
|
||||
if (absOutputDir === buildResult.buildOutputPath) {
|
||||
// `.vercel/output` dir is already in the correct location,
|
||||
// so no need to do anything
|
||||
return;
|
||||
}
|
||||
await fs.copy(buildResult.buildOutputPath, OUTPUT_DIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to return the file extension (i.e. `.html`) from the given
|
||||
* `File` instance, based on its actual filesystem path and/or the
|
||||
* "content-type" of the File.
|
||||
*/
|
||||
function getFileExtension(file: File): string {
|
||||
let ext = '';
|
||||
if (file.type === 'FileFsRef') {
|
||||
ext = extname(file.fsPath);
|
||||
}
|
||||
if (!ext && file.contentType) {
|
||||
const e = mimeTypes.extension(file.contentType);
|
||||
if (e) {
|
||||
ext = `.${e}`;
|
||||
}
|
||||
}
|
||||
return ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an async iterator that scans a directory
|
||||
* for sub-directories with the matching `name`.
|
||||
*/
|
||||
export async function* findDirs(
|
||||
name: string,
|
||||
dir: string,
|
||||
root = dir
|
||||
): AsyncIterable<string> {
|
||||
let paths: string[];
|
||||
try {
|
||||
paths = await fs.readdir(dir);
|
||||
} catch (err: any) {
|
||||
if (err.code !== 'ENOENT') {
|
||||
throw err;
|
||||
}
|
||||
paths = [];
|
||||
}
|
||||
for (const path of paths) {
|
||||
const abs = join(dir, path);
|
||||
const s = await fs.stat(abs);
|
||||
if (s.isDirectory()) {
|
||||
if (path === name) {
|
||||
yield relative(root, abs);
|
||||
} else {
|
||||
yield* findDirs(name, abs, root);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1040,7 +1040,12 @@ export default class DevServer {
|
||||
const { debug } = this.output;
|
||||
debug(`Killing builder dev server with PID ${pid}`);
|
||||
this.devServerPids.delete(pid);
|
||||
await treeKill(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}`);
|
||||
}
|
||||
}
|
||||
|
||||
async send404(
|
||||
|
||||
@@ -2,6 +2,16 @@ import title from 'title';
|
||||
import pkg from './pkg';
|
||||
import cmd from './output/cmd';
|
||||
|
||||
/**
|
||||
* The package name defined in the CLI's `package.json` file (`vercel`).
|
||||
*/
|
||||
export const name = pkg.name;
|
||||
|
||||
/**
|
||||
* Unicode symbol used to represent the CLI.
|
||||
*/
|
||||
export const logo = '▲';
|
||||
|
||||
/**
|
||||
* Returns the package name such as `vercel` or `now`.
|
||||
*/
|
||||
|
||||
@@ -5,12 +5,14 @@ import { join } from 'path';
|
||||
|
||||
export type ProjectLinkAndSettings = ProjectLink & {
|
||||
settings: {
|
||||
installCommand: Project['installCommand'];
|
||||
buildCommand: Project['buildCommand'];
|
||||
devCommand: Project['devCommand'];
|
||||
outputDirectory: Project['outputDirectory'];
|
||||
directoryListing: Project['directoryListing'];
|
||||
rootDirectory: Project['rootDirectory'];
|
||||
framework: Project['framework'];
|
||||
nodeVersion: Project['nodeVersion'];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -22,20 +24,22 @@ export async function writeProjectSettings(
|
||||
project: Project,
|
||||
org: Org
|
||||
) {
|
||||
const data = {
|
||||
const projectLinkAndSettings: ProjectLinkAndSettings = {
|
||||
projectId: project.id,
|
||||
orgId: org.id,
|
||||
settings: {
|
||||
buildCommand: project.buildCommand,
|
||||
devCommand: project.devCommand,
|
||||
outputDirectory: project.outputDirectory,
|
||||
directoryListing: project.directoryListing,
|
||||
rootDirectory: project.rootDirectory,
|
||||
framework: project.framework,
|
||||
devCommand: project.devCommand,
|
||||
installCommand: project.installCommand,
|
||||
buildCommand: project.buildCommand,
|
||||
outputDirectory: project.outputDirectory,
|
||||
rootDirectory: project.rootDirectory,
|
||||
directoryListing: project.directoryListing,
|
||||
nodeVersion: project.nodeVersion,
|
||||
},
|
||||
};
|
||||
const path = join(cwd, VERCEL_DIR, VERCEL_DIR_PROJECT);
|
||||
return await outputJSON(path, data, {
|
||||
return await outputJSON(path, projectLinkAndSettings, {
|
||||
spaces: 2,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
.next
|
||||
yarn.lock
|
||||
!.vercel
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
.next
|
||||
yarn.lock
|
||||
!.vercel
|
||||
|
||||
68
packages/cli/test/unit/util/build/import-builders.test.ts
Normal file
68
packages/cli/test/unit/util/build/import-builders.test.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { join } from 'path';
|
||||
import { remove } from 'fs-extra';
|
||||
import { getWriteableDirectory } from '@vercel/build-utils';
|
||||
import { client } from '../../../mocks/client';
|
||||
import {
|
||||
importBuilders,
|
||||
resolveBuilders,
|
||||
} from '../../../../src/util/build/import-builders';
|
||||
import vercelNextPkg from '@vercel/next/package.json';
|
||||
import vercelNodePkg from '@vercel/node/package.json';
|
||||
|
||||
describe('importBuilders()', () => {
|
||||
it('should import built-in Builders', async () => {
|
||||
const specs = new Set(['@vercel/node', '@vercel/next']);
|
||||
const builders = await importBuilders(specs, process.cwd(), client.output);
|
||||
expect(builders.size).toEqual(2);
|
||||
expect(builders.get('@vercel/node')?.pkg).toMatchObject(vercelNodePkg);
|
||||
expect(builders.get('@vercel/next')?.pkg).toMatchObject(vercelNextPkg);
|
||||
});
|
||||
|
||||
it('should install 3rd party Builders', async () => {
|
||||
const cwd = await getWriteableDirectory();
|
||||
try {
|
||||
const spec = 'vercel-deno@2.0.1';
|
||||
const specs = new Set([spec]);
|
||||
const builders = await importBuilders(specs, cwd, client.output);
|
||||
expect(builders.size).toEqual(1);
|
||||
expect(builders.get(spec)?.pkg.name).toEqual('vercel-deno');
|
||||
expect(builders.get(spec)?.pkg.version).toEqual('2.0.1');
|
||||
expect(builders.get(spec)?.pkgPath).toEqual(
|
||||
join(cwd, '.vercel/builders/node_modules/vercel-deno/package.json')
|
||||
);
|
||||
} finally {
|
||||
await remove(cwd);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveBuilders()', () => {
|
||||
it('should return builders to install when missing', async () => {
|
||||
const specs = new Set(['@vercel/does-not-exist']);
|
||||
const result = await resolveBuilders(process.cwd(), specs, client.output);
|
||||
if (!('buildersToAdd' in result)) {
|
||||
throw new Error('Expected `buildersToAdd` to be defined');
|
||||
}
|
||||
expect([...result.buildersToAdd]).toEqual(['@vercel/does-not-exist']);
|
||||
});
|
||||
|
||||
it('should throw error when `MODULE_NOT_FOUND` on 2nd pass', async () => {
|
||||
let err: Error | undefined;
|
||||
const specs = new Set(['@vercel/does-not-exist']);
|
||||
|
||||
// The empty Map represents `resolveBuilders()` being invoked after the install step
|
||||
try {
|
||||
await resolveBuilders(process.cwd(), specs, client.output, new Map());
|
||||
} catch (_err: any) {
|
||||
err = _err;
|
||||
}
|
||||
|
||||
if (!err) {
|
||||
throw new Error('Expected `err` to be defined');
|
||||
}
|
||||
|
||||
expect(
|
||||
err.message.startsWith('Importing "@vercel/does-not-exist": Cannot')
|
||||
).toEqual(true);
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/client",
|
||||
"version": "11.0.3",
|
||||
"version": "11.0.4-canary.1",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"homepage": "https://vercel.com",
|
||||
@@ -42,7 +42,7 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/build-utils": "3.1.0",
|
||||
"@vercel/build-utils": "3.1.1-canary.1",
|
||||
"@zeit/fetch": "5.2.0",
|
||||
"async-retry": "1.2.3",
|
||||
"async-sema": "3.0.0",
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
foo
|
||||
@@ -1 +0,0 @@
|
||||
baz
|
||||
@@ -1 +0,0 @@
|
||||
qux
|
||||
@@ -1 +0,0 @@
|
||||
bar
|
||||
@@ -1 +0,0 @@
|
||||
baz
|
||||
@@ -1 +0,0 @@
|
||||
qux
|
||||
@@ -1 +0,0 @@
|
||||
bar
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/frameworks",
|
||||
"version": "0.9.1",
|
||||
"version": "0.9.2-canary.0",
|
||||
"main": "./dist/frameworks.js",
|
||||
"types": "./dist/frameworks.d.ts",
|
||||
"files": [
|
||||
|
||||
@@ -52,7 +52,6 @@ export const frameworks = [
|
||||
placeholder: 'Next.js default',
|
||||
},
|
||||
},
|
||||
getFsOutputDir: async () => '.next',
|
||||
getOutputDirName: async () => 'public',
|
||||
},
|
||||
{
|
||||
@@ -102,7 +101,6 @@ export const frameworks = [
|
||||
dependencies: ['next-plugin-sentry', 'next-sentry-source-maps'],
|
||||
},
|
||||
],
|
||||
getFsOutputDir: async () => '.next',
|
||||
getOutputDirName: async () => 'public',
|
||||
cachePattern: '.next/cache/**',
|
||||
},
|
||||
@@ -202,6 +200,8 @@ export const frameworks = [
|
||||
description: 'A new Remix app — the result of running `npx create-remix`.',
|
||||
website: 'https://remix.run',
|
||||
sort: 6,
|
||||
useRuntime: { src: 'package.json', use: '@vercel/remix' },
|
||||
ignoreRuntimes: ['@vercel/node'],
|
||||
detectors: {
|
||||
every: [
|
||||
{
|
||||
@@ -227,39 +227,6 @@ export const frameworks = [
|
||||
},
|
||||
dependency: 'remix',
|
||||
getOutputDirName: async () => 'public',
|
||||
defaultRoutes: [
|
||||
{
|
||||
src: '^/build/(.*)$',
|
||||
headers: { 'cache-control': 'public, max-age=31536000, immutable' },
|
||||
continue: true,
|
||||
},
|
||||
{
|
||||
handle: 'filesystem',
|
||||
},
|
||||
{
|
||||
src: '/(.*)',
|
||||
dest: '/api',
|
||||
},
|
||||
],
|
||||
defaultRewrites: [
|
||||
{
|
||||
source: '/(.*)',
|
||||
regex: '/(.*)',
|
||||
destination: '/api',
|
||||
},
|
||||
],
|
||||
defaultHeaders: [
|
||||
{
|
||||
source: '/build/(.*)',
|
||||
regex: '/build/(.*)',
|
||||
headers: [
|
||||
{
|
||||
key: 'cache-control',
|
||||
value: 'public, max-age=31536000, immutable',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Astro',
|
||||
@@ -299,7 +266,6 @@ export const frameworks = [
|
||||
},
|
||||
},
|
||||
dependency: 'astro',
|
||||
getFsOutputDir: async () => 'dist',
|
||||
getOutputDirName: async () => 'dist',
|
||||
defaultRoutes: [
|
||||
{
|
||||
@@ -315,18 +281,6 @@ export const frameworks = [
|
||||
dest: '/index.html',
|
||||
},
|
||||
],
|
||||
defaultHeaders: [
|
||||
{
|
||||
source: '^/dist/(.*)$',
|
||||
regex: '^/dist/(.*)$',
|
||||
headers: [
|
||||
{
|
||||
key: 'cache-control',
|
||||
value: 'public, max-age=31536000, immutable',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Hexo',
|
||||
@@ -455,57 +409,6 @@ export const frameworks = [
|
||||
|
||||
return base;
|
||||
},
|
||||
defaultHeaders: [
|
||||
{
|
||||
source: '^/[^./]+\\.[0-9a-f]{8}\\.(css|js)$',
|
||||
regex: '^/[^./]+\\.[0-9a-f]{8}\\.(css|js)$',
|
||||
headers: [
|
||||
{ key: 'cache-control', value: 'max-age=31536000, immutable' },
|
||||
],
|
||||
},
|
||||
{
|
||||
source:
|
||||
'^/assets/images/[^/]+-[0-9a-f]{32}\\.(ico|svg|jpg|jpeg|png|gif|webp)$',
|
||||
regex:
|
||||
'^/assets/images/[^/]+-[0-9a-f]{32}\\.(ico|svg|jpg|jpeg|png|gif|webp)$',
|
||||
headers: [
|
||||
{ key: 'cache-control', value: 'max-age=31536000, immutable' },
|
||||
],
|
||||
},
|
||||
{
|
||||
source:
|
||||
'^/assets/medias/[^/]+-[0-9a-f]{32}\\.(ogv|wav|mp3|m4a|aac|oga|flac)$',
|
||||
regex:
|
||||
'^/assets/medias/[^/]+-[0-9a-f]{32}\\.(ogv|wav|mp3|m4a|aac|oga|flac)$',
|
||||
headers: [
|
||||
{ key: 'cache-control', value: 'max-age=31536000, immutable' },
|
||||
],
|
||||
},
|
||||
{
|
||||
source:
|
||||
'^/assets/files/[^/]+-[0-9a-f]{32}\\.(pdf|doc|docx|xls|xlsx|zip|rar)$',
|
||||
regex:
|
||||
'^/assets/files/[^/]+-[0-9a-f]{32}\\.(pdf|doc|docx|xls|xlsx|zip|rar)$',
|
||||
headers: [
|
||||
{ key: 'cache-control', value: 'max-age=31536000, immutable' },
|
||||
],
|
||||
},
|
||||
{
|
||||
source: '^/ideal-img/[^/]+\\.[0-9a-f]{7}\\.\\d+\\.(png|jpe?g|gif)$',
|
||||
regex: '^/ideal-img/[^/]+\\.[0-9a-f]{7}\\.\\d+\\.(png|jpe?g|gif)$',
|
||||
headers: [
|
||||
{ key: 'cache-control', value: 'max-age=31536000, immutable' },
|
||||
],
|
||||
},
|
||||
],
|
||||
defaultRedirects: [
|
||||
{
|
||||
source: '.*',
|
||||
regex: '.*',
|
||||
statusCode: 404,
|
||||
destination: '404.html',
|
||||
},
|
||||
],
|
||||
defaultRoutes: [
|
||||
{
|
||||
src: '^/[^./]+\\.[0-9a-f]{8}\\.(css|js)$',
|
||||
@@ -639,13 +542,6 @@ export const frameworks = [
|
||||
dest: '/index.html',
|
||||
},
|
||||
],
|
||||
defaultRewrites: [
|
||||
{
|
||||
source: '/(.*)',
|
||||
regex: '/(.*)',
|
||||
destination: '/index.html',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'SolidStart',
|
||||
@@ -748,13 +644,6 @@ export const frameworks = [
|
||||
continue: true,
|
||||
},
|
||||
],
|
||||
defaultRewrites: [
|
||||
{
|
||||
source: '/(.*)',
|
||||
regex: '/(.*)',
|
||||
destination: '/index.html',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Ember.js',
|
||||
@@ -801,13 +690,6 @@ export const frameworks = [
|
||||
dest: '/index.html',
|
||||
},
|
||||
],
|
||||
defaultRewrites: [
|
||||
{
|
||||
source: '/(.*)',
|
||||
regex: '/(.*)',
|
||||
destination: '/index.html',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Vue.js',
|
||||
@@ -865,27 +747,6 @@ export const frameworks = [
|
||||
dest: '/index.html',
|
||||
},
|
||||
],
|
||||
defaultHeaders: [
|
||||
{
|
||||
source: '^/[^/]*\\.(js|txt|ico|json)',
|
||||
regex: '^/[^/]*\\.(js|txt|ico|json)',
|
||||
headers: [{ key: 'cache-control', value: 'max-age=300' }],
|
||||
},
|
||||
{
|
||||
source: '^/(img|js|css|fonts|media)/[^/]+\\.[0-9a-f]{8}\\.*',
|
||||
regex: '^/(img|js|css|fonts|media)/[^/]+\\.[0-9a-f]{8}\\.*',
|
||||
headers: [
|
||||
{ key: 'cache-control', value: 'max-age=31536000, immutable' },
|
||||
],
|
||||
},
|
||||
],
|
||||
defaultRewrites: [
|
||||
{
|
||||
source: '^.*',
|
||||
regex: '^.*',
|
||||
destination: '/index.html',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Scully',
|
||||
@@ -967,13 +828,6 @@ export const frameworks = [
|
||||
dest: '/index.html',
|
||||
},
|
||||
],
|
||||
defaultRewrites: [
|
||||
{
|
||||
source: '/(.*)',
|
||||
regex: '/(.*)',
|
||||
destination: '/index.html',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Angular',
|
||||
@@ -1034,13 +888,6 @@ export const frameworks = [
|
||||
dest: '/index.html',
|
||||
},
|
||||
],
|
||||
defaultRewrites: [
|
||||
{
|
||||
source: '/(.*)',
|
||||
regex: '/(.*)',
|
||||
destination: '/index.html',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Polymer',
|
||||
@@ -1098,13 +945,6 @@ export const frameworks = [
|
||||
dest: '/index.html',
|
||||
},
|
||||
],
|
||||
defaultRewrites: [
|
||||
{
|
||||
source: '/(.*)',
|
||||
regex: '/(.*)',
|
||||
destination: '/index.html',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Svelte',
|
||||
@@ -1156,13 +996,6 @@ export const frameworks = [
|
||||
dest: '/index.html',
|
||||
},
|
||||
],
|
||||
defaultRewrites: [
|
||||
{
|
||||
source: '/(.*)',
|
||||
regex: '/(.*)',
|
||||
destination: '/index.html',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'SvelteKit',
|
||||
@@ -1263,45 +1096,6 @@ export const frameworks = [
|
||||
dest: '/index.html',
|
||||
},
|
||||
],
|
||||
defaultHeaders: [
|
||||
{
|
||||
source: '/static/(.*)',
|
||||
regex: '/static/(.*)',
|
||||
headers: [
|
||||
{ key: 'cache-control', value: 's-maxage=31536000, immutable' },
|
||||
],
|
||||
},
|
||||
{
|
||||
source: '/service-worker.js',
|
||||
regex: '/service-worker.js',
|
||||
headers: [{ key: 'cache-control', value: 's-maxage=0' }],
|
||||
},
|
||||
{
|
||||
source: '/(.*)',
|
||||
regex: '/(.*)',
|
||||
headers: [{ key: 'cache-control', value: 's-maxage=0' }],
|
||||
},
|
||||
],
|
||||
defaultRedirects: [
|
||||
{
|
||||
source: '/static/(.*)',
|
||||
destination: '/404.html',
|
||||
statusCode: 404,
|
||||
regex: '/static/(.*)',
|
||||
},
|
||||
],
|
||||
defaultRewrites: [
|
||||
{
|
||||
source: '/sockjs-node/(.*)',
|
||||
destination: '/sockjs-node/$1',
|
||||
regex: '/sockjs-node/(.*)',
|
||||
},
|
||||
{
|
||||
source: '/(.*)',
|
||||
destination: '/index.html',
|
||||
regex: '/(.*)',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Create React App',
|
||||
@@ -1369,45 +1163,6 @@ export const frameworks = [
|
||||
dest: '/index.html',
|
||||
},
|
||||
],
|
||||
defaultHeaders: [
|
||||
{
|
||||
source: '/static/(.*)',
|
||||
regex: '/static/(.*)',
|
||||
headers: [
|
||||
{ key: 'cache-control', value: 's-maxage=31536000, immutable' },
|
||||
],
|
||||
},
|
||||
{
|
||||
source: '/service-worker.js',
|
||||
regex: '/service-worker.js',
|
||||
headers: [{ key: 'cache-control', value: 's-maxage=0' }],
|
||||
},
|
||||
{
|
||||
source: '/(.*)',
|
||||
regex: '/(.*)',
|
||||
headers: [{ key: 'cache-control', value: 's-maxage=0' }],
|
||||
},
|
||||
],
|
||||
defaultRedirects: [
|
||||
{
|
||||
source: '/static/(.*)',
|
||||
destination: '/404.html',
|
||||
statusCode: 404,
|
||||
regex: '/static/(.*)',
|
||||
},
|
||||
],
|
||||
defaultRewrites: [
|
||||
{
|
||||
source: '/sockjs-node/(.*)',
|
||||
destination: '/sockjs-node/$1',
|
||||
regex: '/sockjs-node/(.*)',
|
||||
},
|
||||
{
|
||||
source: '/(.*)',
|
||||
destination: '/index.html',
|
||||
regex: '/(.*)',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Gridsome',
|
||||
@@ -1491,13 +1246,6 @@ export const frameworks = [
|
||||
dest: '/index.html',
|
||||
},
|
||||
],
|
||||
defaultRewrites: [
|
||||
{
|
||||
source: '/(.*)',
|
||||
destination: '/index.html',
|
||||
regex: '/(.*)',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Sapper',
|
||||
@@ -1586,23 +1334,6 @@ export const frameworks = [
|
||||
dest: '404.html',
|
||||
},
|
||||
],
|
||||
defaultHeaders: [
|
||||
{
|
||||
source: '/_saber/.*',
|
||||
regex: '/_saber/.*',
|
||||
headers: [
|
||||
{ key: 'cache-control', value: 'max-age=31536000, immutable' },
|
||||
],
|
||||
},
|
||||
],
|
||||
defaultRedirects: [
|
||||
{
|
||||
source: '.*',
|
||||
statusCode: 404,
|
||||
destination: '404.html',
|
||||
regex: '.*',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Stencil',
|
||||
@@ -1664,32 +1395,6 @@ export const frameworks = [
|
||||
dest: '/index.html',
|
||||
},
|
||||
],
|
||||
defaultHeaders: [
|
||||
{
|
||||
source: '/assets/(.*)',
|
||||
regex: '/assets/(.*)',
|
||||
headers: [{ key: 'cache-control', value: 'max-age=2592000' }],
|
||||
},
|
||||
{
|
||||
source: '/build/p-.*',
|
||||
regex: '/build/p-.*',
|
||||
headers: [
|
||||
{ key: 'cache-control', value: 'max-age=31536000, immutable' },
|
||||
],
|
||||
},
|
||||
{
|
||||
source: '/sw.js',
|
||||
regex: '/sw.js',
|
||||
headers: [{ key: 'cache-control', value: 'no-cache' }],
|
||||
},
|
||||
],
|
||||
defaultRewrites: [
|
||||
{
|
||||
source: '/(.*)',
|
||||
destination: '/index.html',
|
||||
regex: '/(.*)',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Nuxt.js',
|
||||
@@ -2069,15 +1774,6 @@ export const frameworks = [
|
||||
handle: 'filesystem',
|
||||
},
|
||||
],
|
||||
defaultHeaders: [
|
||||
{
|
||||
source: '^/[^./]+\\.[0-9a-f]{8}\\.(css|js|png|jpg|webp|avif|svg)$',
|
||||
regex: '^/[^./]+\\.[0-9a-f]{8}\\.(css|js|png|jpg|webp|avif|svg)$',
|
||||
headers: [
|
||||
{ key: 'cache-control', value: 's-maxage=31536000, immutable' },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Sanity',
|
||||
@@ -2143,22 +1839,6 @@ export const frameworks = [
|
||||
placeholder: '`public` if it exists, or `.`',
|
||||
},
|
||||
},
|
||||
getFsOutputDir: async (dirPrefix: string): Promise<string> => {
|
||||
// Public if it exists or `.`
|
||||
let base = 'public';
|
||||
try {
|
||||
const location = join(dirPrefix, base);
|
||||
const content = await readdir(location, { withFileTypes: true });
|
||||
|
||||
// If there is only one file in it that is a dir we'll use it as dist dir
|
||||
if (content.length === 1 && content[0].isDirectory()) {
|
||||
return join(base, content[0].name);
|
||||
}
|
||||
} catch (_error) {
|
||||
base = '.';
|
||||
}
|
||||
return base;
|
||||
},
|
||||
getOutputDirName: async () => 'public',
|
||||
},
|
||||
] as const;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Header, Rewrite, Route } from '@vercel/routing-utils';
|
||||
import { Rewrite, Route } from '@vercel/routing-utils';
|
||||
|
||||
export interface FrameworkDetectionItem {
|
||||
/**
|
||||
@@ -37,10 +37,6 @@ export type Redirect = Rewrite & {
|
||||
permanent?: boolean;
|
||||
};
|
||||
|
||||
type RoutesManifestRegex = {
|
||||
regex: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Framework detection information.
|
||||
*/
|
||||
@@ -170,11 +166,6 @@ export interface Framework {
|
||||
* @deprecated use `detectors` instead (new frameworks should not use this prop)
|
||||
*/
|
||||
dependency?: string;
|
||||
/**
|
||||
* Function that returns the name of the directory that the framework outputs
|
||||
* its File System API build results to, usually called `.output`.
|
||||
*/
|
||||
getFsOutputDir?: (dirPrefix: string) => Promise<string>;
|
||||
/**
|
||||
* Function that returns the name of the directory that the framework outputs
|
||||
* its STATIC build results to. In some cases this is read from a configuration file.
|
||||
@@ -186,27 +177,6 @@ export interface Framework {
|
||||
* @example [{ handle: 'filesystem' }, { src: '.*', status: 404, dest: '404.html' }]
|
||||
*/
|
||||
defaultRoutes?: Route[] | ((dirPrefix: string) => Promise<Route[]>);
|
||||
/**
|
||||
* An array (or a function that returns an array) of default `Header` rules that
|
||||
* the framework uses.
|
||||
*/
|
||||
defaultHeaders?:
|
||||
| (Header & RoutesManifestRegex)[]
|
||||
| ((dirPrefix: string) => Promise<(Header & RoutesManifestRegex)[]>);
|
||||
/**
|
||||
* An array (or a function that returns an array) of default `Redirect` rules that
|
||||
* the framework uses.
|
||||
*/
|
||||
defaultRedirects?:
|
||||
| (Redirect & RoutesManifestRegex)[]
|
||||
| ((dirPrefix: string) => Promise<(Redirect & RoutesManifestRegex)[]>);
|
||||
/**
|
||||
* An array (or a function that returns an array) of default `Rewrite` rules that
|
||||
* the framework uses.
|
||||
*/
|
||||
defaultRewrites?:
|
||||
| (Rewrite & RoutesManifestRegex)[]
|
||||
| ((dirPrefix: string) => Promise<(Rewrite & RoutesManifestRegex)[]>);
|
||||
/**
|
||||
* A glob string of files to cache for future deployments.
|
||||
* @example ".cache/**"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/go",
|
||||
"version": "1.4.3",
|
||||
"version": "1.4.4-canary.1",
|
||||
"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.1.0",
|
||||
"@vercel/build-utils": "3.1.1-canary.1",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"async-retry": "1.3.1",
|
||||
"execa": "^1.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/next",
|
||||
"version": "2.8.66",
|
||||
"version": "2.8.67-canary.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": "3.1.0",
|
||||
"@vercel/build-utils": "3.1.1-canary.1",
|
||||
"@vercel/nft": "0.19.0",
|
||||
"@vercel/routing-utils": "1.13.3",
|
||||
"async-sema": "3.0.1",
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
File,
|
||||
FileBlob,
|
||||
FileFsRef,
|
||||
Files,
|
||||
@@ -22,7 +21,7 @@ import {
|
||||
BuildV2,
|
||||
PrepareCache,
|
||||
NodejsLambda,
|
||||
EdgeFunction,
|
||||
BuildResultV2Typical as BuildResult,
|
||||
} from '@vercel/build-utils';
|
||||
import { Handler, Route, Source } from '@vercel/routing-utils';
|
||||
import {
|
||||
@@ -32,7 +31,6 @@ import {
|
||||
} from '@vercel/routing-utils/dist/superstatic';
|
||||
import { nodeFileTrace } from '@vercel/nft';
|
||||
import { Sema } from 'async-sema';
|
||||
import { ChildProcess } from 'child_process';
|
||||
// escape-string-regexp version must match Next.js version
|
||||
import escapeStringRegexp from 'escape-string-regexp';
|
||||
import findUp from 'find-up';
|
||||
@@ -180,66 +178,6 @@ function isLegacyNext(nextVersion: string) {
|
||||
return true;
|
||||
}
|
||||
|
||||
export interface BuildResult {
|
||||
routes: Route[];
|
||||
images?: {
|
||||
domains: string[];
|
||||
remotePatterns?: RemotePattern[];
|
||||
sizes: number[];
|
||||
minimumCacheTTL?: number;
|
||||
formats?: ImageFormat[];
|
||||
dangerouslyAllowSVG?: boolean;
|
||||
contentSecurityPolicy?: string;
|
||||
};
|
||||
middleware?: {
|
||||
buffer: Buffer;
|
||||
env: string[];
|
||||
format: 'module' | 'service-worker';
|
||||
name: string;
|
||||
sourcemap?: string;
|
||||
wasmBindings?: { name: string; filePath: string }[];
|
||||
type: 'v8-worker';
|
||||
}[];
|
||||
output: {
|
||||
[key: string]: File | Lambda | EdgeFunction | FileFsRef | Prerender;
|
||||
};
|
||||
wildcard?: Array<{
|
||||
domain: string;
|
||||
value: string;
|
||||
}>;
|
||||
watch?: string[];
|
||||
childProcesses: ChildProcess[];
|
||||
}
|
||||
|
||||
export type RemotePattern = {
|
||||
/**
|
||||
* Must be `http` or `https`.
|
||||
*/
|
||||
protocol?: 'http' | 'https';
|
||||
|
||||
/**
|
||||
* Can be literal or wildcard.
|
||||
* Single `*` matches a single subdomain.
|
||||
* Double `**` matches any number of subdomains.
|
||||
*/
|
||||
hostname: string;
|
||||
|
||||
/**
|
||||
* Can be literal port such as `8080` or empty string
|
||||
* meaning no port.
|
||||
*/
|
||||
port?: string;
|
||||
|
||||
/**
|
||||
* Can be literal or wildcard.
|
||||
* Single `*` matches a single path segment.
|
||||
* Double `**` matches any number of path segments.
|
||||
*/
|
||||
pathname?: string;
|
||||
};
|
||||
|
||||
type ImageFormat = 'image/avif' | 'image/webp';
|
||||
|
||||
export const build: BuildV2 = async ({
|
||||
files,
|
||||
workPath,
|
||||
@@ -978,8 +916,6 @@ export const build: BuildV2 = async ({
|
||||
]
|
||||
: []),
|
||||
],
|
||||
watch: [],
|
||||
childProcesses: [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2594,8 +2530,6 @@ export const build: BuildV2 = async ({
|
||||
]),
|
||||
]),
|
||||
],
|
||||
watch: [],
|
||||
childProcesses: [],
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -12,9 +12,10 @@ import {
|
||||
debug,
|
||||
glob,
|
||||
Files,
|
||||
BuildResultV2Typical as BuildResult,
|
||||
} from '@vercel/build-utils';
|
||||
import { Handler, Route, Source } from '@vercel/routing-utils';
|
||||
import { BuildResult, MAX_AGE_ONE_YEAR } from '.';
|
||||
import { MAX_AGE_ONE_YEAR } from '.';
|
||||
import {
|
||||
NextRequiredServerFilesManifest,
|
||||
NextImagesManifest,
|
||||
@@ -855,7 +856,7 @@ export async function serverBuild({
|
||||
currentRouteSrc = starterRouteSrc;
|
||||
}
|
||||
// add to existing route src if src length limit isn't reached
|
||||
currentRouteSrc = `${currentRouteSrc.substr(
|
||||
currentRouteSrc = `${currentRouteSrc.substring(
|
||||
0,
|
||||
currentRouteSrc.length - 1
|
||||
)}${
|
||||
@@ -870,7 +871,6 @@ export async function serverBuild({
|
||||
}
|
||||
|
||||
return {
|
||||
middleware: middleware.middleware,
|
||||
wildcard: wildcardConfig,
|
||||
images:
|
||||
imagesManifest?.images?.loader === 'default'
|
||||
@@ -1282,7 +1282,5 @@ export async function serverBuild({
|
||||
},
|
||||
]),
|
||||
],
|
||||
watch: [],
|
||||
childProcesses: [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ export function localizeDynamicRoutes(
|
||||
const isApiRoute =
|
||||
pathnameNoPrefix === '/api' || pathnameNoPrefix?.startsWith('/api/');
|
||||
const isAutoExport =
|
||||
staticPages[addLocaleOrDefault(pathname!, routesManifest).substr(1)];
|
||||
staticPages[addLocaleOrDefault(pathname!, routesManifest).substring(1)];
|
||||
|
||||
const isLocalePrefixed =
|
||||
isFallback || isBlocking || isAutoExport || isServerMode;
|
||||
@@ -2241,22 +2241,10 @@ export async function getMiddlewareBundle({
|
||||
staticRoutes: Route[];
|
||||
dynamicRouteMap: Map<string, Source>;
|
||||
edgeFunctions: Record<string, EdgeFunction>;
|
||||
middleware: {
|
||||
runtimeVersion: string;
|
||||
id: string;
|
||||
name: string;
|
||||
buffer: Buffer;
|
||||
env: string[];
|
||||
format: 'module' | 'service-worker';
|
||||
type: 'v8-worker';
|
||||
sourcemap?: string;
|
||||
wasmBindings: { name: string; filePath: string }[];
|
||||
}[];
|
||||
} = {
|
||||
staticRoutes: [],
|
||||
dynamicRouteMap: new Map(),
|
||||
edgeFunctions: {},
|
||||
middleware: [],
|
||||
};
|
||||
|
||||
for (const worker of workerConfigs.values()) {
|
||||
@@ -2265,6 +2253,7 @@ export async function getMiddlewareBundle({
|
||||
source.edgeFunctions[edgeFile] = worker.edgeFunction;
|
||||
const route = {
|
||||
continue: true,
|
||||
override: true,
|
||||
middlewarePath: edgeFile,
|
||||
src: worker.routeSrc,
|
||||
};
|
||||
@@ -2283,7 +2272,6 @@ export async function getMiddlewareBundle({
|
||||
staticRoutes: [],
|
||||
dynamicRouteMap: new Map(),
|
||||
edgeFunctions: {},
|
||||
middleware: [],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
8
packages/next/test/fixtures/00-middleware/index.test.js
vendored
Normal file
8
packages/next/test/fixtures/00-middleware/index.test.js
vendored
Normal 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);
|
||||
});
|
||||
});
|
||||
@@ -1,12 +1,20 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
const ALLOWED = ['allowed'];
|
||||
|
||||
export function middleware(request) {
|
||||
const url = request.nextUrl;
|
||||
const pathname = url.pathname;
|
||||
|
||||
if (process.env.FOO) {
|
||||
console.log(`Includes env variable ${process.env.FOO}`);
|
||||
}
|
||||
|
||||
if (url.pathname === '/redirect-me') {
|
||||
url.pathname = '/from-middleware';
|
||||
return NextResponse.redirect(url);
|
||||
}
|
||||
|
||||
if (url.pathname === '/next') {
|
||||
return NextResponse.next();
|
||||
}
|
||||
@@ -26,14 +34,12 @@ export function middleware(request) {
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
return new NextResponse(
|
||||
JSON.stringify({ globals: globalKeys, globalThis: globalThisKeys }),
|
||||
{
|
||||
headers: {
|
||||
'content-type': 'application/json; charset=utf-8',
|
||||
},
|
||||
}
|
||||
const res = NextResponse.next();
|
||||
res.headers.set(
|
||||
'data',
|
||||
JSON.stringify({ globals: globalKeys, globalThis: globalThisKeys })
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
if (url.pathname === '/log') {
|
||||
@@ -54,12 +60,10 @@ export function middleware(request) {
|
||||
|
||||
if (url.pathname === '/greetings') {
|
||||
const data = { message: 'hello world!' };
|
||||
return new NextResponse(JSON.stringify(data), {
|
||||
headers: {
|
||||
'x-example': 'edge',
|
||||
'content-type': 'application/json; charset=utf-8',
|
||||
},
|
||||
});
|
||||
const res = NextResponse.next();
|
||||
res.headers.set('x-example', 'edge');
|
||||
res.headers.set('data', JSON.stringify(data));
|
||||
return res;
|
||||
}
|
||||
|
||||
if (url.pathname === '/rewrite-me-to-about') {
|
||||
@@ -90,11 +94,13 @@ export function middleware(request) {
|
||||
|
||||
if (url.pathname === '/redirect-301') {
|
||||
url.pathname = '/greetings';
|
||||
return Response.redirect(url, 301);
|
||||
return NextResponse.redirect(url, 301);
|
||||
}
|
||||
|
||||
if (url.pathname === '/reflect') {
|
||||
return new Response(
|
||||
const res = NextResponse.next();
|
||||
res.headers.set(
|
||||
'data',
|
||||
JSON.stringify({
|
||||
geo: request.geo,
|
||||
headers: Object.fromEntries(request.headers),
|
||||
@@ -109,13 +115,9 @@ export function middleware(request) {
|
||||
search: request.nextUrl.search,
|
||||
},
|
||||
url: request.url,
|
||||
}),
|
||||
{
|
||||
headers: {
|
||||
'content-type': 'application/json; charset=utf-8',
|
||||
},
|
||||
}
|
||||
})
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
if (url.pathname === '/stream-response') {
|
||||
@@ -130,7 +132,7 @@ export function middleware(request) {
|
||||
|
||||
return {
|
||||
waitUntil,
|
||||
response: new NextResponse(readable),
|
||||
response: NextResponse.next(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -161,6 +163,64 @@ export function middleware(request) {
|
||||
|
||||
if (url.pathname === '/unhandledrejection') {
|
||||
Promise.reject(new TypeError('captured unhandledrejection error.'));
|
||||
return new NextResponse('OK');
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
if (pathname.startsWith('/query-params')) {
|
||||
if (pathname.endsWith('/clear')) {
|
||||
const strategy =
|
||||
url.searchParams.get('strategy') === 'rewrite' ? 'rewrite' : 'redirect';
|
||||
|
||||
for (const key of [...url.searchParams.keys()]) {
|
||||
if (!ALLOWED.includes(key)) {
|
||||
url.searchParams.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
const newPath = url.pathname.replace(/\/clear$/, '');
|
||||
url.pathname = newPath;
|
||||
|
||||
if (strategy === 'redirect') {
|
||||
return NextResponse.redirect(url);
|
||||
} else {
|
||||
return NextResponse.rewrite(url);
|
||||
}
|
||||
}
|
||||
|
||||
const obj = Object.fromEntries([...url.searchParams.entries()]);
|
||||
|
||||
const res = NextResponse.next();
|
||||
res.headers.set('data', JSON.stringify(obj));
|
||||
return res;
|
||||
}
|
||||
|
||||
if (pathname.startsWith('/home')) {
|
||||
if (!request.cookies.bucket) {
|
||||
const bucket = Math.random() >= 0.5 ? 'a' : 'b';
|
||||
url.pathname = `/home/${bucket}`;
|
||||
const response = NextResponse.rewrite(url);
|
||||
response.cookie('bucket', bucket);
|
||||
return response;
|
||||
}
|
||||
|
||||
url.pathname = `/home/${request.cookies.bucket}`;
|
||||
return NextResponse.rewrite(url);
|
||||
}
|
||||
|
||||
if (pathname.startsWith('/fetch-subrequest')) {
|
||||
const destinationUrl =
|
||||
url.searchParams.get('url') || 'https://example.vercel.sh';
|
||||
return fetch(destinationUrl, { headers: request.headers });
|
||||
}
|
||||
|
||||
if (url.pathname === '/dynamic/greet') {
|
||||
const res = NextResponse.next();
|
||||
res.headers.set(
|
||||
'data',
|
||||
JSON.stringify({
|
||||
message: url.searchParams.get('greeting') || 'Hi friend',
|
||||
})
|
||||
);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
21
packages/next/test/fixtures/00-middleware/next.config.js
vendored
Normal file
21
packages/next/test/fixtures/00-middleware/next.config.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
module.exports = {
|
||||
redirects() {
|
||||
return [
|
||||
{
|
||||
source: '/redirect-me',
|
||||
destination: '/from-next-config',
|
||||
permanent: false,
|
||||
},
|
||||
];
|
||||
},
|
||||
rewrites() {
|
||||
return {
|
||||
beforeFiles: [
|
||||
{
|
||||
source: '/rewrite-before-files',
|
||||
destination: '/somewhere',
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
};
|
||||
16
packages/next/test/fixtures/00-middleware/vercel.json
vendored
Normal file
16
packages/next/test/fixtures/00-middleware/vercel.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [{ "src": "package.json", "use": "@vercel/next" }],
|
||||
"probes": [
|
||||
{
|
||||
"path": "/redirect-me",
|
||||
"status": 307,
|
||||
"responseHeaders": {
|
||||
"Location": "/from-next-config/"
|
||||
},
|
||||
"fetchOptions": {
|
||||
"redirect": "manual"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -10,7 +10,12 @@ import runBuildLambda from '../../../../test/lib/run-build-lambda';
|
||||
import { EdgeFunction, Files, streamToBuffer } from '@vercel/build-utils';
|
||||
import { createHash } from 'crypto';
|
||||
|
||||
const SIMPLE_PROJECT = path.resolve(__dirname, 'middleware');
|
||||
const SIMPLE_PROJECT = path.resolve(
|
||||
__dirname,
|
||||
'..',
|
||||
'fixtures',
|
||||
'00-middleware'
|
||||
);
|
||||
|
||||
describe('Middleware simple project', () => {
|
||||
const ctx: Context = {};
|
||||
@@ -20,6 +25,28 @@ describe('Middleware simple project', () => {
|
||||
ctx.buildResult = result.buildResult;
|
||||
});
|
||||
|
||||
it('orders middleware route correctly', async () => {
|
||||
const middlewareIndex = ctx.buildResult.routes.findIndex(item => {
|
||||
return !!item.middlewarePath;
|
||||
});
|
||||
const redirectIndex = ctx.buildResult.routes.findIndex(item => {
|
||||
return item.src && item.src.includes('redirect-me');
|
||||
});
|
||||
const beforeFilesIndex = ctx.buildResult.routes.findIndex(item => {
|
||||
return item.src && item.src.includes('rewrite-before-files');
|
||||
});
|
||||
const handleFileSystemIndex = ctx.buildResult.routes.findIndex(item => {
|
||||
return item.handle === 'filesystem';
|
||||
});
|
||||
expect(typeof middlewareIndex).toBe('number');
|
||||
expect(typeof redirectIndex).toBe('number');
|
||||
expect(typeof beforeFilesIndex).toBe('number');
|
||||
expect(redirectIndex).toBeLessThan(middlewareIndex);
|
||||
expect(redirectIndex).toBeLessThan(beforeFilesIndex);
|
||||
expect(beforeFilesIndex).toBeLessThan(middlewareIndex);
|
||||
expect(middlewareIndex).toBeLessThan(handleFileSystemIndex);
|
||||
});
|
||||
|
||||
it('generates deterministic code', async () => {
|
||||
const result = await runBuildLambda(SIMPLE_PROJECT);
|
||||
const output = Object.entries(result.buildResult.output).filter(
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = {};
|
||||
@@ -1,16 +0,0 @@
|
||||
export function middleware(request) {
|
||||
const url = request.nextUrl;
|
||||
|
||||
if (url.pathname === '/dynamic/greet') {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
message: url.searchParams.get('greeting') || 'Hi friend',
|
||||
}),
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export function middleware(request) {
|
||||
const url = request.nextUrl;
|
||||
|
||||
const destinationUrl =
|
||||
url.searchParams.get('url') || 'https://example.vercel.sh';
|
||||
return fetch(destinationUrl, { headers: request.headers });
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export function middleware(request) {
|
||||
const url = request.nextUrl;
|
||||
if (!request.cookies.bucket) {
|
||||
const bucket = Math.random() >= 0.5 ? 'a' : 'b';
|
||||
url.pathname = `/home/${bucket}`;
|
||||
const response = NextResponse.rewrite(url);
|
||||
response.cookie('bucket', bucket);
|
||||
return response;
|
||||
}
|
||||
|
||||
url.pathname = `/home/${request.cookies.bucket}`;
|
||||
return NextResponse.rewrite(url);
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
const ALLOWED = ['allowed'];
|
||||
|
||||
/**
|
||||
* @param {import('next/server').NextRequest} req
|
||||
*/
|
||||
export default async function middleware(req) {
|
||||
const url = req.nextUrl;
|
||||
const pathname = url.pathname;
|
||||
|
||||
if (pathname.endsWith('/clear')) {
|
||||
const strategy =
|
||||
url.searchParams.get('strategy') === 'rewrite' ? 'rewrite' : 'redirect';
|
||||
|
||||
for (const key of [...url.searchParams.keys()]) {
|
||||
if (!ALLOWED.includes(key)) {
|
||||
url.searchParams.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
const newPath = url.pathname.replace(/\/clear$/, '');
|
||||
url.pathname = newPath;
|
||||
|
||||
if (strategy === 'redirect') {
|
||||
return NextResponse.redirect(url);
|
||||
} else {
|
||||
return NextResponse.rewrite(url);
|
||||
}
|
||||
}
|
||||
|
||||
const obj = Object.fromEntries([...url.searchParams.entries()]);
|
||||
|
||||
return new Response(JSON.stringify(obj), {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [{ "src": "package.json", "use": "@vercel/next" }]
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/node",
|
||||
"version": "1.15.3",
|
||||
"version": "1.15.4-canary.1",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
|
||||
@@ -45,7 +45,7 @@
|
||||
"@types/etag": "1.8.0",
|
||||
"@types/jest": "27.4.1",
|
||||
"@types/test-listen": "1.1.0",
|
||||
"@vercel/build-utils": "3.1.0",
|
||||
"@vercel/build-utils": "3.1.1-canary.1",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"@vercel/nft": "0.19.0",
|
||||
"content-type": "1.0.4",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/python",
|
||||
"version": "2.3.3",
|
||||
"version": "2.3.4-canary.1",
|
||||
"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.1.0",
|
||||
"@vercel/build-utils": "3.1.1-canary.1",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"execa": "^1.0.0",
|
||||
"typescript": "4.3.4"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/redwood",
|
||||
"version": "0.8.3",
|
||||
"version": "0.8.4-canary.1",
|
||||
"main": "./dist/index.js",
|
||||
"license": "MIT",
|
||||
"homepage": "https://vercel.com/docs",
|
||||
@@ -28,6 +28,6 @@
|
||||
"@types/aws-lambda": "8.10.19",
|
||||
"@types/node": "*",
|
||||
"@types/semver": "6.0.0",
|
||||
"@vercel/build-utils": "3.1.0"
|
||||
"@vercel/build-utils": "3.1.1-canary.1"
|
||||
}
|
||||
}
|
||||
|
||||
12
packages/remix/build.js
Normal file
12
packages/remix/build.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const execa = require('execa');
|
||||
const { remove } = require('fs-extra');
|
||||
|
||||
async function main() {
|
||||
await remove('dist');
|
||||
await execa('tsc', [], { stdio: 'inherit' });
|
||||
}
|
||||
|
||||
main().catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
3
packages/remix/default-server.js
Normal file
3
packages/remix/default-server.js
Normal file
@@ -0,0 +1,3 @@
|
||||
const { createRequestHandler } = require('@remix-run/vercel');
|
||||
const build = require('./');
|
||||
module.exports = createRequestHandler({ build });
|
||||
5
packages/remix/jest.config.js
Normal file
5
packages/remix/jest.config.js
Normal file
@@ -0,0 +1,5 @@
|
||||
/** @type {import('@ts-jest/dist/types').InitialOptionsTsJest} */
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
};
|
||||
33
packages/remix/package.json
Normal file
33
packages/remix/package.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@vercel/remix",
|
||||
"version": "0.0.2-canary.1",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"homepage": "https://vercel.com/docs",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/vercel/vercel.git",
|
||||
"directory": "packages/remix"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node build.js",
|
||||
"test-integration-once": "yarn test test/test.js",
|
||||
"test": "jest --env node --verbose --bail --runInBand",
|
||||
"test-unit": "yarn test test/build.test.ts",
|
||||
"prepublishOnly": "node build.js"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"default-server.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@remix-run/vercel": "1.4.3",
|
||||
"@vercel/nft": "0.19.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "27.5.1",
|
||||
"@types/node": "*",
|
||||
"@vercel/build-utils": "3.1.1-canary.1",
|
||||
"typescript": "4.6.4"
|
||||
}
|
||||
}
|
||||
266
packages/remix/src/build.ts
Normal file
266
packages/remix/src/build.ts
Normal file
@@ -0,0 +1,266 @@
|
||||
import { promises as fs } from 'fs';
|
||||
import { dirname, join } from 'path';
|
||||
import {
|
||||
debug,
|
||||
download,
|
||||
execCommand,
|
||||
FileFsRef,
|
||||
getNodeVersion,
|
||||
getSpawnOptions,
|
||||
glob,
|
||||
NodejsLambda,
|
||||
readConfigFile,
|
||||
runNpmInstall,
|
||||
runPackageJsonScript,
|
||||
scanParentDirs,
|
||||
} from '@vercel/build-utils';
|
||||
import type {
|
||||
BuildV2,
|
||||
Files,
|
||||
NodeVersion,
|
||||
PackageJson,
|
||||
} from '@vercel/build-utils';
|
||||
import { nodeFileTrace } from '@vercel/nft';
|
||||
import type { AppConfig } from './types';
|
||||
|
||||
export const build: BuildV2 = async ({
|
||||
entrypoint,
|
||||
files,
|
||||
workPath,
|
||||
config,
|
||||
meta = {},
|
||||
}) => {
|
||||
const { installCommand, buildCommand } = config;
|
||||
|
||||
await download(files, workPath, meta);
|
||||
|
||||
const mountpoint = dirname(entrypoint);
|
||||
const entrypointFsDirname = join(workPath, mountpoint);
|
||||
|
||||
// Run "Install Command"
|
||||
const nodeVersion = await getNodeVersion(
|
||||
entrypointFsDirname,
|
||||
undefined,
|
||||
config,
|
||||
meta
|
||||
);
|
||||
|
||||
const spawnOpts = getSpawnOptions(meta, nodeVersion);
|
||||
if (!spawnOpts.env) {
|
||||
spawnOpts.env = {};
|
||||
}
|
||||
const { cliType, lockfileVersion } = await scanParentDirs(
|
||||
entrypointFsDirname
|
||||
);
|
||||
if (cliType === 'npm') {
|
||||
if (
|
||||
typeof lockfileVersion === 'number' &&
|
||||
lockfileVersion >= 2 &&
|
||||
(nodeVersion?.major || 0) < 16
|
||||
) {
|
||||
// Ensure that npm 7 is at the beginning of the `$PATH`
|
||||
spawnOpts.env.PATH = `/node16/bin-npm7:${spawnOpts.env.PATH}`;
|
||||
console.log('Detected `package-lock.json` generated by npm 7...');
|
||||
}
|
||||
} else if (cliType === 'pnpm') {
|
||||
if (typeof lockfileVersion === 'number' && lockfileVersion === 5.4) {
|
||||
// Ensure that pnpm 7 is at the beginning of the `$PATH`
|
||||
spawnOpts.env.PATH = `/pnpm7/node_modules/.bin:${spawnOpts.env.PATH}`;
|
||||
console.log('Detected `pnpm-lock.yaml` generated by pnpm 7...');
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof installCommand === 'string') {
|
||||
if (installCommand.trim()) {
|
||||
console.log(`Running "install" command: \`${installCommand}\`...`);
|
||||
|
||||
const env: Record<string, string> = {
|
||||
YARN_NODE_LINKER: 'node-modules',
|
||||
...spawnOpts.env,
|
||||
};
|
||||
|
||||
await execCommand(installCommand, {
|
||||
...spawnOpts,
|
||||
env,
|
||||
cwd: entrypointFsDirname,
|
||||
});
|
||||
} else {
|
||||
console.log(`Skipping "install" command...`);
|
||||
}
|
||||
} else {
|
||||
await runNpmInstall(entrypointFsDirname, [], spawnOpts, meta, nodeVersion);
|
||||
}
|
||||
|
||||
// Make `remix build` output production mode
|
||||
spawnOpts.env.NODE_ENV = 'production';
|
||||
|
||||
// Run "Build Command"
|
||||
if (buildCommand) {
|
||||
debug(`Executing build command "${buildCommand}"`);
|
||||
await execCommand(buildCommand, {
|
||||
...spawnOpts,
|
||||
cwd: entrypointFsDirname,
|
||||
});
|
||||
} else {
|
||||
const pkg = await readConfigFile<PackageJson>(
|
||||
join(entrypointFsDirname, 'package.json')
|
||||
);
|
||||
if (hasScript('vercel-build', pkg)) {
|
||||
debug(`Executing "yarn vercel-build"`);
|
||||
await runPackageJsonScript(
|
||||
entrypointFsDirname,
|
||||
'vercel-build',
|
||||
spawnOpts
|
||||
);
|
||||
} else if (hasScript('build', pkg)) {
|
||||
debug(`Executing "yarn build"`);
|
||||
await runPackageJsonScript(entrypointFsDirname, 'build', spawnOpts);
|
||||
} else {
|
||||
await execCommand('remix build', {
|
||||
...spawnOpts,
|
||||
cwd: entrypointFsDirname,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let serverBuildPath = 'build/index.js';
|
||||
let needsHandler = true;
|
||||
try {
|
||||
const remixConfig: AppConfig = require(join(
|
||||
entrypointFsDirname,
|
||||
'remix.config'
|
||||
));
|
||||
|
||||
// If `serverBuildTarget === 'vercel'` then Remix will output a handler
|
||||
// that is already in Vercel (req, res) format, so don't inject the handler
|
||||
if (remixConfig.serverBuildTarget) {
|
||||
if (remixConfig.serverBuildTarget !== 'vercel') {
|
||||
throw new Error(
|
||||
`\`serverBuildTarget\` in Remix config must be "vercel" (got "${remixConfig.serverBuildTarget}")`
|
||||
);
|
||||
}
|
||||
serverBuildPath = 'api/index.js';
|
||||
needsHandler = false;
|
||||
}
|
||||
|
||||
if (remixConfig.serverBuildPath) {
|
||||
// Explicit file path where the server output file will be
|
||||
serverBuildPath = remixConfig.serverBuildPath;
|
||||
} else if (remixConfig.serverBuildDirectory) {
|
||||
// Explicit directory path the server output will be
|
||||
serverBuildPath = join(remixConfig.serverBuildDirectory, 'index.js');
|
||||
}
|
||||
} catch (err: any) {
|
||||
// Ignore error if `remix.config.js` does not exist
|
||||
if (err.code !== 'MODULE_NOT_FOUND') throw err;
|
||||
}
|
||||
|
||||
const [staticFiles, renderFunction] = await Promise.all([
|
||||
glob('**', join(entrypointFsDirname, 'public')),
|
||||
createRenderFunction(
|
||||
entrypointFsDirname,
|
||||
serverBuildPath,
|
||||
needsHandler,
|
||||
nodeVersion
|
||||
),
|
||||
]);
|
||||
|
||||
return {
|
||||
routes: [
|
||||
{
|
||||
src: '^/build/(.*)$',
|
||||
headers: { 'cache-control': 'public, max-age=31536000, immutable' },
|
||||
continue: true,
|
||||
},
|
||||
{
|
||||
handle: 'filesystem',
|
||||
},
|
||||
{
|
||||
src: '/(.*)',
|
||||
dest: '/render',
|
||||
},
|
||||
],
|
||||
output: {
|
||||
render: renderFunction,
|
||||
...staticFiles,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
function hasScript(scriptName: string, pkg: PackageJson | null) {
|
||||
const scripts = (pkg && pkg.scripts) || {};
|
||||
return typeof scripts[scriptName] === 'string';
|
||||
}
|
||||
|
||||
async function createRenderFunction(
|
||||
rootDir: string,
|
||||
serverBuildPath: string,
|
||||
needsHandler: boolean,
|
||||
nodeVersion: NodeVersion
|
||||
): Promise<NodejsLambda> {
|
||||
const files: Files = {};
|
||||
const handler = needsHandler
|
||||
? join(dirname(serverBuildPath), '__vc_handler.js')
|
||||
: serverBuildPath;
|
||||
const handlerPath = join(rootDir, handler);
|
||||
|
||||
if (needsHandler) {
|
||||
// Copy the `default-server.js` file into the "build" directory
|
||||
const sourceHandlerPath = join(__dirname, '../default-server.js');
|
||||
await fs.copyFile(sourceHandlerPath, handlerPath);
|
||||
}
|
||||
|
||||
// Trace the handler with `@vercel/nft`
|
||||
const trace = await nodeFileTrace([handlerPath], {
|
||||
base: rootDir,
|
||||
});
|
||||
|
||||
let needsVercelAdapter = false;
|
||||
for (const warning of trace.warnings) {
|
||||
if (warning.message.includes("'@remix-run/vercel'")) {
|
||||
needsVercelAdapter = true;
|
||||
} else if (warning.stack) {
|
||||
debug(warning.stack.replace('Error: ', 'Warning: '));
|
||||
}
|
||||
}
|
||||
for (const file of trace.fileList) {
|
||||
files[file] = await FileFsRef.fromFsPath({ fsPath: join(rootDir, file) });
|
||||
}
|
||||
|
||||
if (needsVercelAdapter) {
|
||||
// Package in the Builder's version of `@remix-run/vercel` Runtime adapter
|
||||
const remixVercelPackageJsonPath = require.resolve(
|
||||
'@remix-run/vercel/package.json',
|
||||
{
|
||||
paths: [__dirname],
|
||||
}
|
||||
);
|
||||
const remixVercelPackageJson: PackageJson = require(remixVercelPackageJsonPath);
|
||||
const remixVercelDir = dirname(remixVercelPackageJsonPath);
|
||||
const remixVercelEntrypoint = join(remixVercelDir, 'index.js');
|
||||
|
||||
console.log(
|
||||
`Warning: Implicitly adding \`${remixVercelPackageJson.name}\` v${remixVercelPackageJson.version} to your project. You should add this dependency to your \`package.json\` file.`
|
||||
);
|
||||
|
||||
const adapterBase = join(remixVercelDir, '../../..');
|
||||
const adapterTrace = await nodeFileTrace([remixVercelEntrypoint], {
|
||||
base: adapterBase,
|
||||
});
|
||||
for (const file of adapterTrace.fileList) {
|
||||
files[file] = await FileFsRef.fromFsPath({
|
||||
fsPath: join(adapterBase, file),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const lambda = new NodejsLambda({
|
||||
files,
|
||||
handler,
|
||||
runtime: nodeVersion.runtime,
|
||||
shouldAddHelpers: false,
|
||||
shouldAddSourcemapSupport: false,
|
||||
});
|
||||
|
||||
return lambda;
|
||||
}
|
||||
3
packages/remix/src/index.ts
Normal file
3
packages/remix/src/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export const version = 2;
|
||||
export * from './build';
|
||||
export * from './prepare-cache';
|
||||
38
packages/remix/src/prepare-cache.ts
Normal file
38
packages/remix/src/prepare-cache.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { dirname, join, relative } from 'path';
|
||||
import { glob } from '@vercel/build-utils';
|
||||
import type { PrepareCache } from '@vercel/build-utils';
|
||||
import type { AppConfig } from './types';
|
||||
|
||||
export const prepareCache: PrepareCache = async ({
|
||||
entrypoint,
|
||||
repoRootPath,
|
||||
workPath,
|
||||
}) => {
|
||||
let cacheDirectory = '.cache';
|
||||
const mountpoint = dirname(entrypoint);
|
||||
const entrypointFsDirname = join(workPath, mountpoint);
|
||||
try {
|
||||
const remixConfig: AppConfig = require(join(
|
||||
entrypointFsDirname,
|
||||
'remix.config'
|
||||
));
|
||||
if (remixConfig.cacheDirectory) {
|
||||
cacheDirectory = remixConfig.cacheDirectory;
|
||||
}
|
||||
} catch (err: any) {
|
||||
// Ignore error if `remix.config.js` does not exist
|
||||
if (err.code !== 'MODULE_NOT_FOUND') throw err;
|
||||
}
|
||||
|
||||
const root = repoRootPath || workPath;
|
||||
|
||||
const [nodeModulesFiles, cacheDirFiles] = await Promise.all([
|
||||
// Cache `node_modules`
|
||||
glob('**/node_modules/**', root),
|
||||
|
||||
// Cache the Remix "cacheDirectory" (typically `.cache`)
|
||||
glob(relative(root, join(entrypointFsDirname, cacheDirectory, '**')), root),
|
||||
]);
|
||||
|
||||
return { ...nodeModulesFiles, ...cacheDirFiles };
|
||||
};
|
||||
7
packages/remix/src/types.ts
Normal file
7
packages/remix/src/types.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
// Stripped down version of `@remix-run/dev` AppConfig
|
||||
export interface AppConfig {
|
||||
cacheDirectory?: string;
|
||||
serverBuildDirectory?: string;
|
||||
serverBuildPath?: string;
|
||||
serverBuildTarget?: string;
|
||||
}
|
||||
53
packages/remix/test/build.test.ts
vendored
Normal file
53
packages/remix/test/build.test.ts
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
import assert from 'assert';
|
||||
import { join } from 'path';
|
||||
import { NodejsLambda } from '@vercel/build-utils';
|
||||
import { build, prepareCache } from '../src';
|
||||
|
||||
jest.setTimeout(10 * 60 * 1000);
|
||||
|
||||
const fixture = (name: string) => join(__dirname, 'fixtures', name);
|
||||
|
||||
describe('build()', () => {
|
||||
it('should build fixture "01-remix-basics"', async () => {
|
||||
if (process.platform === 'win32') {
|
||||
// Fails on Windows (https://github.com/vercel/vercel/runs/6484955910):
|
||||
// > 'remix' is not recognized as an internal or external command,
|
||||
console.log('Skipping test on Windows.');
|
||||
return;
|
||||
}
|
||||
const workPath = fixture('01-remix-basics');
|
||||
const result = await build({
|
||||
files: {},
|
||||
entrypoint: 'package.json',
|
||||
workPath,
|
||||
config: {},
|
||||
});
|
||||
assert('output' in result);
|
||||
const names = Object.keys(result.output);
|
||||
|
||||
expect('favicon.ico' in result.output).toEqual(true);
|
||||
expect(names.filter(n => n.startsWith('build/')).length).toBeGreaterThan(5);
|
||||
|
||||
const render = result.output.render;
|
||||
expect(render.type).toEqual('Lambda');
|
||||
expect((render as NodejsLambda).launcherType).toEqual('Nodejs');
|
||||
|
||||
const cache = await prepareCache({
|
||||
files: {},
|
||||
entrypoint: 'package.json',
|
||||
workPath,
|
||||
config: {},
|
||||
});
|
||||
const cacheNames = Object.keys(cache);
|
||||
|
||||
// Assert `node_modules` was cached
|
||||
const nodeModulesFiles = cacheNames.filter(n =>
|
||||
n.startsWith('node_modules/')
|
||||
);
|
||||
expect(nodeModulesFiles.length).toBeGreaterThanOrEqual(10);
|
||||
|
||||
// Assert `.cache` was cached
|
||||
const dotCacheFiles = cacheNames.filter(n => n.startsWith('.cache/'));
|
||||
expect(dotCacheFiles.length).toBeGreaterThanOrEqual(4);
|
||||
});
|
||||
});
|
||||
6
packages/remix/test/fixtures/01-remix-basics/.gitignore
vendored
Normal file
6
packages/remix/test/fixtures/01-remix-basics/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
node_modules
|
||||
|
||||
/.cache
|
||||
/build
|
||||
/public/build
|
||||
.env
|
||||
53
packages/remix/test/fixtures/01-remix-basics/README.md
vendored
Normal file
53
packages/remix/test/fixtures/01-remix-basics/README.md
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
# Welcome to Remix!
|
||||
|
||||
- [Remix Docs](https://remix.run/docs)
|
||||
|
||||
## Development
|
||||
|
||||
From your terminal:
|
||||
|
||||
```sh
|
||||
npm run dev
|
||||
```
|
||||
|
||||
This starts your app in development mode, rebuilding assets on file changes.
|
||||
|
||||
## Deployment
|
||||
|
||||
First, build your app for production:
|
||||
|
||||
```sh
|
||||
npm run build
|
||||
```
|
||||
|
||||
Then run the app in production mode:
|
||||
|
||||
```sh
|
||||
npm start
|
||||
```
|
||||
|
||||
Now you'll need to pick a host to deploy it to.
|
||||
|
||||
### DIY
|
||||
|
||||
If you're familiar with deploying node applications, the built-in Remix app server is production-ready.
|
||||
|
||||
Make sure to deploy the output of `remix build`
|
||||
|
||||
- `build/`
|
||||
- `public/build/`
|
||||
|
||||
### Using a Template
|
||||
|
||||
When you ran `npx create-remix@latest` there were a few choices for hosting. You can run that again to create a new project, then copy over your `app/` folder to the new project that's pre-configured for your target server.
|
||||
|
||||
```sh
|
||||
cd ..
|
||||
# create a new project, and pick a pre-configured host
|
||||
npx create-remix@latest
|
||||
cd my-new-remix-app
|
||||
# remove the new project's app (not the old one!)
|
||||
rm -rf app
|
||||
# copy your app over
|
||||
cp -R ../my-old-remix-app/app app
|
||||
```
|
||||
4
packages/remix/test/fixtures/01-remix-basics/app/entry.client.tsx
vendored
Normal file
4
packages/remix/test/fixtures/01-remix-basics/app/entry.client.tsx
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { RemixBrowser } from "@remix-run/react";
|
||||
import { hydrate } from "react-dom";
|
||||
|
||||
hydrate(<RemixBrowser />, document);
|
||||
21
packages/remix/test/fixtures/01-remix-basics/app/entry.server.tsx
vendored
Normal file
21
packages/remix/test/fixtures/01-remix-basics/app/entry.server.tsx
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { EntryContext } from "@remix-run/node";
|
||||
import { RemixServer } from "@remix-run/react";
|
||||
import { renderToString } from "react-dom/server";
|
||||
|
||||
export default function handleRequest(
|
||||
request: Request,
|
||||
responseStatusCode: number,
|
||||
responseHeaders: Headers,
|
||||
remixContext: EntryContext
|
||||
) {
|
||||
let markup = renderToString(
|
||||
<RemixServer context={remixContext} url={request.url} />
|
||||
);
|
||||
|
||||
responseHeaders.set("Content-Type", "text/html");
|
||||
|
||||
return new Response("<!DOCTYPE html>" + markup, {
|
||||
status: responseStatusCode,
|
||||
headers: responseHeaders,
|
||||
});
|
||||
}
|
||||
32
packages/remix/test/fixtures/01-remix-basics/app/root.tsx
vendored
Normal file
32
packages/remix/test/fixtures/01-remix-basics/app/root.tsx
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import type { MetaFunction } from "@remix-run/node";
|
||||
import {
|
||||
Links,
|
||||
LiveReload,
|
||||
Meta,
|
||||
Outlet,
|
||||
Scripts,
|
||||
ScrollRestoration,
|
||||
} from "@remix-run/react";
|
||||
|
||||
export const meta: MetaFunction = () => ({
|
||||
charset: "utf-8",
|
||||
title: "New Remix App",
|
||||
viewport: "width=device-width,initial-scale=1",
|
||||
});
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<Meta />
|
||||
<Links />
|
||||
</head>
|
||||
<body>
|
||||
<Outlet />
|
||||
<ScrollRestoration />
|
||||
<Scripts />
|
||||
<LiveReload />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
32
packages/remix/test/fixtures/01-remix-basics/app/routes/index.tsx
vendored
Normal file
32
packages/remix/test/fixtures/01-remix-basics/app/routes/index.tsx
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
export default function Index() {
|
||||
return (
|
||||
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>
|
||||
<h1>Welcome to Remix</h1>
|
||||
<ul>
|
||||
<li>
|
||||
<a
|
||||
target="_blank"
|
||||
href="https://remix.run/tutorials/blog"
|
||||
rel="noreferrer"
|
||||
>
|
||||
15m Quickstart Blog Tutorial
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
target="_blank"
|
||||
href="https://remix.run/tutorials/jokes"
|
||||
rel="noreferrer"
|
||||
>
|
||||
Deep Dive Jokes App Tutorial
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a target="_blank" href="https://remix.run/docs" rel="noreferrer">
|
||||
Remix Docs
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
28
packages/remix/test/fixtures/01-remix-basics/package.json
vendored
Normal file
28
packages/remix/test/fixtures/01-remix-basics/package.json
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "remix-template-remix",
|
||||
"private": true,
|
||||
"description": "",
|
||||
"license": "",
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"build": "remix build",
|
||||
"dev": "remix dev",
|
||||
"start": "remix-serve build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@remix-run/node": "^1.4.3",
|
||||
"@remix-run/react": "^1.4.3",
|
||||
"@remix-run/serve": "^1.4.3",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@remix-run/dev": "^1.4.3",
|
||||
"@types/react": "^17.0.45",
|
||||
"@types/react-dom": "^17.0.17",
|
||||
"typescript": "^4.6.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
}
|
||||
BIN
packages/remix/test/fixtures/01-remix-basics/public/favicon.ico
vendored
Normal file
BIN
packages/remix/test/fixtures/01-remix-basics/public/favicon.ico
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
10
packages/remix/test/fixtures/01-remix-basics/remix.config.js
vendored
Normal file
10
packages/remix/test/fixtures/01-remix-basics/remix.config.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @type {import('@remix-run/dev').AppConfig}
|
||||
*/
|
||||
module.exports = {
|
||||
ignoredRouteFiles: ['**/.*'],
|
||||
// appDirectory: "app",
|
||||
// assetsBuildDirectory: "public/build",
|
||||
// serverBuildPath: "build/index.js",
|
||||
// publicPath: "/build/",
|
||||
};
|
||||
2
packages/remix/test/fixtures/01-remix-basics/remix.env.d.ts
vendored
Normal file
2
packages/remix/test/fixtures/01-remix-basics/remix.env.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/// <reference types="@remix-run/dev" />
|
||||
/// <reference types="@remix-run/node/globals" />
|
||||
22
packages/remix/test/fixtures/01-remix-basics/tsconfig.json
vendored
Normal file
22
packages/remix/test/fixtures/01-remix-basics/tsconfig.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
|
||||
"compilerOptions": {
|
||||
"lib": ["DOM", "DOM.Iterable", "ES2019"],
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"jsx": "react-jsx",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"target": "ES2019",
|
||||
"strict": true,
|
||||
"allowJs": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"~/*": ["./app/*"]
|
||||
},
|
||||
|
||||
// Remix takes care of building everything in `remix build`.
|
||||
"noEmit": true
|
||||
}
|
||||
}
|
||||
13
packages/remix/test/fixtures/01-remix-basics/vercel.json
vendored
Normal file
13
packages/remix/test/fixtures/01-remix-basics/vercel.json
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [
|
||||
{
|
||||
"src": "package.json",
|
||||
"use": "@vercel/remix",
|
||||
"config": {
|
||||
"zeroConfig": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"probes": [{ "path": "/", "mustContain": "Welcome to Remix" }]
|
||||
}
|
||||
5598
packages/remix/test/fixtures/01-remix-basics/yarn.lock
vendored
Normal file
5598
packages/remix/test/fixtures/01-remix-basics/yarn.lock
vendored
Normal file
File diff suppressed because it is too large
Load Diff
34
packages/remix/test/test.js
vendored
Normal file
34
packages/remix/test/test.js
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { version } = require('../package.json');
|
||||
|
||||
const {
|
||||
packAndDeploy,
|
||||
testDeployment,
|
||||
} = require('../../../test/lib/deployment/test-deployment.js');
|
||||
|
||||
jest.setTimeout(12 * 60 * 1000);
|
||||
|
||||
let builderUrl;
|
||||
const buildUtilsUrl = version.includes('canary') ? '@canary' : undefined;
|
||||
|
||||
beforeAll(async () => {
|
||||
const builderPath = path.resolve(__dirname, '..');
|
||||
builderUrl = await packAndDeploy(builderPath);
|
||||
console.log('builderUrl', builderUrl);
|
||||
});
|
||||
|
||||
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const fixture of fs.readdirSync(fixturesPath)) {
|
||||
// eslint-disable-next-line no-loop-func
|
||||
it(`should build ${fixture}`, async () => {
|
||||
await expect(
|
||||
testDeployment(
|
||||
{ builderUrl, buildUtilsUrl },
|
||||
path.join(fixturesPath, fixture)
|
||||
)
|
||||
).resolves.toBeDefined();
|
||||
});
|
||||
}
|
||||
4
packages/remix/test/tsconfig.json
vendored
Normal file
4
packages/remix/test/tsconfig.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"include": ["*.test.ts"]
|
||||
}
|
||||
21
packages/remix/tsconfig.json
Normal file
21
packages/remix/tsconfig.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": ["esnext"],
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"noEmitOnError": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"outDir": "./dist",
|
||||
"types": ["node", "jest"],
|
||||
"strict": true,
|
||||
"target": "es2019",
|
||||
"sourceMap": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@vercel/ruby",
|
||||
"author": "Nathan Cahill <nathan@nathancahill.com>",
|
||||
"version": "1.3.6",
|
||||
"version": "1.3.7-canary.1",
|
||||
"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.1.0",
|
||||
"@vercel/build-utils": "3.1.1-canary.1",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"execa": "2.0.4",
|
||||
"fs-extra": "^7.0.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/static-build",
|
||||
"version": "0.25.2",
|
||||
"version": "0.25.3-canary.1",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/build-step",
|
||||
@@ -32,12 +32,13 @@
|
||||
"devDependencies": {
|
||||
"@types/aws-lambda": "8.10.64",
|
||||
"@types/cross-spawn": "6.0.0",
|
||||
"@types/fs-extra": "9.0.13",
|
||||
"@types/jest": "27.4.1",
|
||||
"@types/ms": "0.7.31",
|
||||
"@types/node-fetch": "2.5.4",
|
||||
"@types/promise-timeout": "1.3.0",
|
||||
"@vercel/build-utils": "3.1.0",
|
||||
"@vercel/frameworks": "0.9.1",
|
||||
"@vercel/build-utils": "3.1.1-canary.1",
|
||||
"@vercel/frameworks": "0.9.2-canary.0",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"@vercel/routing-utils": "1.13.3",
|
||||
"fs-extra": "10.0.0",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user