mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-11 04:22:13 +00:00
Compare commits
92 Commits
vercel@32.
...
@vercel/bu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0dd9a27859 | ||
|
|
b6ed28b9b1 | ||
|
|
0d034b6820 | ||
|
|
05c8be1a6d | ||
|
|
d21bb9f87e | ||
|
|
ab24444660 | ||
|
|
20080d4ae7 | ||
|
|
c32a909afc | ||
|
|
abaa700cea | ||
|
|
8ba0ce9324 | ||
|
|
4027a18337 | ||
|
|
3bad73401b | ||
|
|
50e135ea47 | ||
|
|
d05e41eeaf | ||
|
|
de63e35622 | ||
|
|
4d1ab422d3 | ||
|
|
a03cfa1040 | ||
|
|
eaae86d776 | ||
|
|
77bc00f92e | ||
|
|
19a373288f | ||
|
|
322c88536d | ||
|
|
1f259d5eb9 | ||
|
|
3759da57ab | ||
|
|
30ba68edf9 | ||
|
|
62ca2efa73 | ||
|
|
2b71ee6b42 | ||
|
|
acb2acf953 | ||
|
|
2601257846 | ||
|
|
30b0925218 | ||
|
|
eddd432e06 | ||
|
|
b185a7e207 | ||
|
|
5c910bf937 | ||
|
|
cdddb33ad4 | ||
|
|
0da7ea7b78 | ||
|
|
7de754398e | ||
|
|
d4cc520814 | ||
|
|
03d07dd163 | ||
|
|
b6b151f391 | ||
|
|
8c4b732d41 | ||
|
|
d4335f0b56 | ||
|
|
90d0455e1f | ||
|
|
0716130e58 | ||
|
|
8b7479fb6e | ||
|
|
72d8604c9d | ||
|
|
5fe7b57b8d | ||
|
|
ab826eb83d | ||
|
|
98040ec24e | ||
|
|
21c700aa93 | ||
|
|
50ed13b6ed | ||
|
|
597508ffa6 | ||
|
|
57ee3e1fd5 | ||
|
|
83952e45c2 | ||
|
|
8e8f44a21d | ||
|
|
91f8763edc | ||
|
|
b1e0523e71 | ||
|
|
7f8f5f8651 | ||
|
|
fbe08fe57e | ||
|
|
9903f11cc3 | ||
|
|
04f5f3f3d2 | ||
|
|
5e3c077b6b | ||
|
|
2cc2fac819 | ||
|
|
c536a74bc9 | ||
|
|
838d56c31c | ||
|
|
77585013de | ||
|
|
44569e6929 | ||
|
|
6194e8ca8d | ||
|
|
7b0adf371b | ||
|
|
471bdd5b45 | ||
|
|
67fa2f3dd6 | ||
|
|
b67b97023b | ||
|
|
9146885f80 | ||
|
|
98bc41d49a | ||
|
|
a38c102208 | ||
|
|
211c74a7d2 | ||
|
|
2a40ff564e | ||
|
|
d4cf2b9ae6 | ||
|
|
7695316cd4 | ||
|
|
7ecb146fdb | ||
|
|
ec3d6ad640 | ||
|
|
5d521af586 | ||
|
|
652a312753 | ||
|
|
bd516c505b | ||
|
|
4d63d9e954 | ||
|
|
6a9002f229 | ||
|
|
2829d541b8 | ||
|
|
6880dcb3c3 | ||
|
|
832ba4b69a | ||
|
|
9a250d528c | ||
|
|
382ff2f526 | ||
|
|
f80a59c73f | ||
|
|
d09dd1794b | ||
|
|
ab34a26205 |
16
.github/CODEOWNERS
vendored
16
.github/CODEOWNERS
vendored
@@ -2,17 +2,17 @@
|
||||
# https://help.github.com/en/articles/about-code-owners
|
||||
|
||||
# Restricted Paths
|
||||
* @TooTallNate @EndangeredMassa @cb1kenobi @Ethan-Arrowood @trek
|
||||
/.github/workflows @TooTallNate @EndangeredMassa @cb1kenobi @Ethan-Arrowood @trek @ijjk
|
||||
/packages/fs-detectors @TooTallNate @EndangeredMassa @cb1kenobi @Ethan-Arrowood @trek @agadzik @chloetedder
|
||||
/packages/next @TooTallNate @EndangeredMassa @cb1kenobi @Ethan-Arrowood @trek @ijjk @ztanner
|
||||
/packages/routing-utils @TooTallNate @EndangeredMassa @cb1kenobi @Ethan-Arrowood @trek @ijjk
|
||||
/packages/static-build @TooTallNate @EndangeredMassa @cb1kenobi @Ethan-Arrowood @trek
|
||||
/packages/edge @vercel/compute @TooTallNate @EndangeredMassa @cb1kenobi @Ethan-Arrowood @trek
|
||||
* @TooTallNate @EndangeredMassa @trek
|
||||
/.github/workflows @TooTallNate @EndangeredMassa @trek @ijjk
|
||||
/packages/fs-detectors @TooTallNate @EndangeredMassa @trek @agadzik @chloetedder
|
||||
/packages/next @TooTallNate @EndangeredMassa @Ethan-Arrowood @trek @ijjk @ztanner
|
||||
/packages/routing-utils @TooTallNate @EndangeredMassa @trek @ijjk
|
||||
/packages/static-build @TooTallNate @EndangeredMassa @trek
|
||||
/packages/edge @vercel/compute @TooTallNate @EndangeredMassa @trek
|
||||
/examples @leerob
|
||||
/examples/create-react-app @Timer
|
||||
/examples/nextjs @timneutkens @ijjk @ztanner @huozhi
|
||||
/packages/node @TooTallNate @EndangeredMassa @cb1kenobi @Ethan-Arrowood @trek @Kikobeats
|
||||
/packages/node @TooTallNate @EndangeredMassa @trek @Kikobeats
|
||||
|
||||
# Unrestricted Paths
|
||||
.changeset/
|
||||
|
||||
4
.github/ISSUE_TEMPLATE/config.yml
vendored
4
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,8 +1,8 @@
|
||||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: Bug Report
|
||||
url: https://vercel.com/support/request
|
||||
about: Report a bug using the Vercel support form
|
||||
url: https://vercel.com/help
|
||||
about: Reach out to our support team
|
||||
- name: Feature Request
|
||||
url: https://github.com/orgs/vercel/discussions/new?category=ideas
|
||||
about: Share ideas for new features
|
||||
|
||||
9
.github/workflows/release.yml
vendored
9
.github/workflows/release.yml
vendored
@@ -76,3 +76,12 @@ jobs:
|
||||
script: |
|
||||
const script = require('./utils/update-latest-release.js')
|
||||
await script({ github, context })
|
||||
summary:
|
||||
name: Summary
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
needs:
|
||||
- release
|
||||
steps:
|
||||
- name: Check All
|
||||
run: echo OK
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"react-router": "^5.1.2",
|
||||
"react-router-dom": "^5.1.2",
|
||||
"react-scripts": "3.3.0",
|
||||
"typescript": "3.8.3"
|
||||
"typescript": "4.9.5"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,3 +25,9 @@ body {
|
||||
)
|
||||
rgb(var(--background-start-rgb));
|
||||
}
|
||||
|
||||
@layer utilities {
|
||||
.text-balance {
|
||||
text-wrap: balance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { Inter } from 'next/font/google'
|
||||
import './globals.css'
|
||||
import type { Metadata } from "next";
|
||||
import { Inter } from "next/font/google";
|
||||
import "./globals.css";
|
||||
|
||||
const inter = Inter({ subsets: ['latin'] })
|
||||
const inter = Inter({ subsets: ["latin"] });
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Create Next App',
|
||||
description: 'Generated by create next app',
|
||||
}
|
||||
title: "Create Next App",
|
||||
description: "Generated by create next app",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body className={inter.className}>{children}</body>
|
||||
</html>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import Image from 'next/image'
|
||||
import Image from "next/image";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
@@ -15,7 +15,7 @@ export default function Home() {
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
By{' '}
|
||||
By{" "}
|
||||
<Image
|
||||
src="/vercel.svg"
|
||||
alt="Vercel Logo"
|
||||
@@ -28,7 +28,7 @@ export default function Home() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="relative flex place-items-center before:absolute before:h-[300px] before:w-[480px] before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-[240px] after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 before:lg:h-[360px] z-[-1]">
|
||||
<div className="relative flex place-items-center before:absolute before:h-[300px] before:w-full sm:before:w-[480px] before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-full sm:after:w-[240px] after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 before:lg:h-[360px] z-[-1]">
|
||||
<Image
|
||||
className="relative dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
|
||||
src="/next.svg"
|
||||
@@ -47,7 +47,7 @@ export default function Home() {
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2 className={`mb-3 text-2xl font-semibold`}>
|
||||
Docs{' '}
|
||||
Docs{" "}
|
||||
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
||||
->
|
||||
</span>
|
||||
@@ -64,7 +64,7 @@ export default function Home() {
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2 className={`mb-3 text-2xl font-semibold`}>
|
||||
Learn{' '}
|
||||
Learn{" "}
|
||||
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
||||
->
|
||||
</span>
|
||||
@@ -81,7 +81,7 @@ export default function Home() {
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2 className={`mb-3 text-2xl font-semibold`}>
|
||||
Templates{' '}
|
||||
Templates{" "}
|
||||
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
||||
->
|
||||
</span>
|
||||
@@ -98,16 +98,16 @@ export default function Home() {
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2 className={`mb-3 text-2xl font-semibold`}>
|
||||
Deploy{' '}
|
||||
Deploy{" "}
|
||||
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
||||
->
|
||||
</span>
|
||||
</h2>
|
||||
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
|
||||
<p className={`m-0 max-w-[30ch] text-sm opacity-50 text-balance`}>
|
||||
Instantly deploy your Next.js site to a shareable URL with Vercel.
|
||||
</p>
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {}
|
||||
|
||||
module.exports = nextConfig
|
||||
4
examples/nextjs/next.config.mjs
Normal file
4
examples/nextjs/next.config.mjs
Normal file
@@ -0,0 +1,4 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {};
|
||||
|
||||
export default nextConfig;
|
||||
812
examples/nextjs/package-lock.json
generated
812
examples/nextjs/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@
|
||||
"dependencies": {
|
||||
"react": "^18",
|
||||
"react-dom": "^18",
|
||||
"next": "14.0.4"
|
||||
"next": "14.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5",
|
||||
@@ -22,6 +22,6 @@
|
||||
"postcss": "^8",
|
||||
"tailwindcss": "^3.3.0",
|
||||
"eslint": "^8",
|
||||
"eslint-config-next": "14.0.4"
|
||||
"eslint-config-next": "14.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@ module.exports = {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import type { Config } from 'tailwindcss'
|
||||
import type { Config } from "tailwindcss";
|
||||
|
||||
const config: Config = {
|
||||
content: [
|
||||
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
|
||||
'./components/**/*.{js,ts,jsx,tsx,mdx}',
|
||||
'./app/**/*.{js,ts,jsx,tsx,mdx}',
|
||||
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
"./components/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
"./app/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
],
|
||||
theme: {
|
||||
extend: {
|
||||
backgroundImage: {
|
||||
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
|
||||
'gradient-conic':
|
||||
'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
|
||||
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
|
||||
"gradient-conic":
|
||||
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [],
|
||||
}
|
||||
export default config
|
||||
};
|
||||
export default config;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
|
||||
2
examples/package.json
vendored
2
examples/package.json
vendored
@@ -9,7 +9,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "27.4.1",
|
||||
"@vercel/frameworks": "2.0.5"
|
||||
"@vercel/frameworks": "2.0.6"
|
||||
},
|
||||
"version": null
|
||||
}
|
||||
|
||||
@@ -15,21 +15,21 @@
|
||||
"devDependencies": {
|
||||
"@fontsource/fira-mono": "^4.5.10",
|
||||
"@neoconfetti/svelte": "^1.0.0",
|
||||
"@playwright/test": "^1.28.1",
|
||||
"@sveltejs/adapter-vercel": "^3.0.0",
|
||||
"@sveltejs/kit": "^1.5.0",
|
||||
"@types/cookie": "^0.5.1",
|
||||
"eslint": "^8.28.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-svelte": "^2.26.0",
|
||||
"prettier": "^2.8.0",
|
||||
"prettier-plugin-svelte": "^2.8.1",
|
||||
"svelte": "^3.54.0",
|
||||
"svelte-check": "^3.0.1",
|
||||
"typescript": "^5.0.0",
|
||||
"vite": "^4.3.0",
|
||||
"vitest": "^0.25.3",
|
||||
"web-vitals": "^3.3.1"
|
||||
"@playwright/test": "^1.40.1",
|
||||
"@sveltejs/adapter-vercel": "^3.1.0",
|
||||
"@sveltejs/kit": "^1.30.3",
|
||||
"@types/cookie": "^0.5.4",
|
||||
"eslint": "^8.55.0",
|
||||
"eslint-config-prettier": "^8.10.0",
|
||||
"eslint-plugin-svelte": "^2.35.1",
|
||||
"prettier": "^2.8.8",
|
||||
"prettier-plugin-svelte": "^2.10.1",
|
||||
"svelte": "^3.59.2",
|
||||
"svelte-check": "^3.6.2",
|
||||
"typescript": "^5.3.3",
|
||||
"vite": "^4.5.1",
|
||||
"vitest": "^0.25.8",
|
||||
"web-vitals": "^3.5.0"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
1148
examples/sveltekit-1/pnpm-lock.yaml
generated
1148
examples/sveltekit-1/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,40 @@
|
||||
# @vercel-internals/types
|
||||
|
||||
## 1.0.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`b6ed28b9b`](https://github.com/vercel/vercel/commit/b6ed28b9b1712f882c93fe053b70d3eb1df21819), [`8ba0ce932`](https://github.com/vercel/vercel/commit/8ba0ce932434c6295fedb5307bee59a804b7e6a8), [`0d034b682`](https://github.com/vercel/vercel/commit/0d034b6820c0f3252949c0ffc483048c5aac7f04), [`abaa700ce`](https://github.com/vercel/vercel/commit/abaa700cea44c723cfc851baa2dfe9e1ae2e8a5c)]:
|
||||
- @vercel/build-utils@7.6.0
|
||||
|
||||
## 1.0.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`cdddb33ad`](https://github.com/vercel/vercel/commit/cdddb33ad49f6080c49f4fff3767e6111acd0bbe)]:
|
||||
- @vercel/build-utils@7.5.1
|
||||
|
||||
## 1.0.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`98040ec24`](https://github.com/vercel/vercel/commit/98040ec24e1ee585865d11eb216b6525d39d209e)]:
|
||||
- @vercel/build-utils@7.5.0
|
||||
|
||||
## 1.0.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`67fa2f3dd`](https://github.com/vercel/vercel/commit/67fa2f3dd6a6d5a3504b7f9081e56deff7b36eab)]:
|
||||
- @vercel/build-utils@7.4.1
|
||||
|
||||
## 1.0.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`4d63d9e95`](https://github.com/vercel/vercel/commit/4d63d9e954549d811063d259250d1865b7de2ba1)]:
|
||||
- @vercel/build-utils@7.4.0
|
||||
|
||||
## 1.0.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
7
internals/types/index.d.ts
vendored
7
internals/types/index.d.ts
vendored
@@ -5,7 +5,12 @@ import type { Route } from '@vercel/routing-utils';
|
||||
import { PROJECT_ENV_TARGET } from '@vercel-internals/constants';
|
||||
|
||||
export type ProjectEnvTarget = typeof PROJECT_ENV_TARGET[number];
|
||||
export type ProjectEnvType = 'plain' | 'secret' | 'encrypted' | 'system';
|
||||
export type ProjectEnvType =
|
||||
| 'plain'
|
||||
| 'secret'
|
||||
| 'encrypted'
|
||||
| 'system'
|
||||
| 'sensitive';
|
||||
|
||||
export type ProjectSettings = import('@vercel/build-utils').ProjectSettings;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "@vercel-internals/types",
|
||||
"version": "1.0.17",
|
||||
"version": "1.0.22",
|
||||
"types": "index.d.ts",
|
||||
"main": "index.d.ts",
|
||||
"files": [
|
||||
@@ -10,7 +10,7 @@
|
||||
"dependencies": {
|
||||
"@types/node": "14.14.31",
|
||||
"@vercel-internals/constants": "1.0.4",
|
||||
"@vercel/build-utils": "7.3.0",
|
||||
"@vercel/build-utils": "7.6.0",
|
||||
"@vercel/routing-utils": "3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"create-svelte": "2.0.1",
|
||||
"dot": "1.1.3",
|
||||
"esbuild": "0.19.2",
|
||||
"eslint": "8.14.0",
|
||||
"eslint": "8.24.0",
|
||||
"eslint-config-prettier": "8.5.0",
|
||||
"eslint-plugin-jest": "26.1.5",
|
||||
"execa": "3.2.0",
|
||||
@@ -29,11 +29,11 @@
|
||||
"lint-staged": "9.2.5",
|
||||
"node-fetch": "2.6.7",
|
||||
"npm-package-arg": "6.1.0",
|
||||
"prettier": "2.6.2",
|
||||
"prettier": "2.7.0",
|
||||
"source-map-support": "0.5.12",
|
||||
"ts-eager": "2.0.2",
|
||||
"ts-jest": "29.1.0",
|
||||
"turbo": "1.10.16",
|
||||
"turbo": "1.12.2",
|
||||
"typescript": "4.9.5"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,43 @@
|
||||
# @vercel/build-utils
|
||||
|
||||
## 7.6.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Revert "Default ruby to only currently supported version (3.2.0)" ([#11135](https://github.com/vercel/vercel/pull/11135))
|
||||
|
||||
- Mark `flags` as deprecated and replace them with `variants` ([#11098](https://github.com/vercel/vercel/pull/11098))
|
||||
|
||||
- [build-utils] change default package manager when no lockfile detected from `yarn` to `npm` (gated behind feature flag) ([#11131](https://github.com/vercel/vercel/pull/11131))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Update internal type for variants ([#11111](https://github.com/vercel/vercel/pull/11111))
|
||||
|
||||
## 7.5.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Add experimental field to Lambda and size to FileFsRef output ([#11059](https://github.com/vercel/vercel/pull/11059))
|
||||
|
||||
## 7.5.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Deprecate `EdgeFunction#name` property ([#11010](https://github.com/vercel/vercel/pull/11010))
|
||||
|
||||
## 7.4.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Extend Node v16 discontinue date to 2024-06-15 ([#10967](https://github.com/vercel/vercel/pull/10967))
|
||||
|
||||
## 7.4.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Adds new helper `getPathForPackageManager()` ([#10918](https://github.com/vercel/vercel/pull/10918))
|
||||
|
||||
## 7.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/build-utils",
|
||||
"version": "7.3.0",
|
||||
"version": "7.6.0",
|
||||
"license": "Apache-2.0",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.js",
|
||||
|
||||
@@ -8,12 +8,13 @@ export class EdgeFunction {
|
||||
|
||||
/**
|
||||
* A display name for the edge function.
|
||||
* @deprecated This property should no longer be used. The name is inferred from the URL path of the function.
|
||||
*/
|
||||
name: string;
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* The deployment target.
|
||||
* Only v8-worker is currently supported.
|
||||
* Only `v8-worker` is currently supported.
|
||||
*/
|
||||
deploymentTarget: 'v8-worker';
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ interface FileFsRefOptions {
|
||||
mode?: number;
|
||||
contentType?: string;
|
||||
fsPath: string;
|
||||
size?: number;
|
||||
}
|
||||
|
||||
interface FromStreamOptions {
|
||||
@@ -24,28 +25,38 @@ class FileFsRef implements FileBase {
|
||||
public type: 'FileFsRef';
|
||||
public mode: number;
|
||||
public fsPath: string;
|
||||
public size?: number;
|
||||
public contentType: string | undefined;
|
||||
|
||||
constructor({ mode = 0o100644, contentType, fsPath }: FileFsRefOptions) {
|
||||
constructor({
|
||||
mode = 0o100644,
|
||||
contentType,
|
||||
fsPath,
|
||||
size,
|
||||
}: FileFsRefOptions) {
|
||||
assert(typeof mode === 'number');
|
||||
assert(typeof fsPath === 'string');
|
||||
this.type = 'FileFsRef';
|
||||
this.mode = mode;
|
||||
this.contentType = contentType;
|
||||
this.fsPath = fsPath;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
static async fromFsPath({
|
||||
mode,
|
||||
contentType,
|
||||
fsPath,
|
||||
size,
|
||||
}: FileFsRefOptions): Promise<FileFsRef> {
|
||||
let m = mode;
|
||||
if (!m) {
|
||||
let s = size;
|
||||
if (!m || typeof s === 'undefined') {
|
||||
const stat = await fs.lstat(fsPath);
|
||||
m = stat.mode;
|
||||
s = stat.size;
|
||||
}
|
||||
return new FileFsRef({ mode: m, contentType, fsPath });
|
||||
return new FileFsRef({ mode: m, contentType, fsPath, size: s });
|
||||
}
|
||||
|
||||
static async fromStream({
|
||||
@@ -69,7 +80,7 @@ class FileFsRef implements FileBase {
|
||||
dest.on('error', reject);
|
||||
});
|
||||
|
||||
return new FileFsRef({ mode, contentType, fsPath });
|
||||
return FileFsRef.fromFsPath({ mode, contentType, fsPath });
|
||||
}
|
||||
|
||||
async toStreamAsync(): Promise<NodeJS.ReadableStream> {
|
||||
|
||||
@@ -13,7 +13,7 @@ export const NODE_VERSIONS: NodeVersion[] = [
|
||||
major: 16,
|
||||
range: '16.x',
|
||||
runtime: 'nodejs16.x',
|
||||
discontinueDate: new Date('2024-02-06'),
|
||||
discontinueDate: new Date('2024-06-15'),
|
||||
},
|
||||
{
|
||||
major: 14,
|
||||
|
||||
@@ -302,7 +302,7 @@ export async function scanParentDirs(
|
||||
});
|
||||
let lockfilePath: string | undefined;
|
||||
let lockfileVersion: number | undefined;
|
||||
let cliType: CliType = 'yarn';
|
||||
let cliType: CliType;
|
||||
|
||||
const [hasYarnLock, packageLockJson, pnpmLockYaml, bunLockBin] =
|
||||
await Promise.all([
|
||||
@@ -338,6 +338,12 @@ export async function scanParentDirs(
|
||||
lockfilePath = bunLockPath;
|
||||
// TODO: read "bun-lockfile-format-v0"
|
||||
lockfileVersion = 0;
|
||||
} else {
|
||||
if (process.env.VERCEL_ENABLE_NPM_DEFAULT === '1') {
|
||||
cliType = 'npm';
|
||||
} else {
|
||||
cliType = 'yarn';
|
||||
}
|
||||
}
|
||||
|
||||
const packageJsonPath = pkgJsonPath || undefined;
|
||||
@@ -414,6 +420,14 @@ export async function runNpmInstall(
|
||||
destPath
|
||||
);
|
||||
|
||||
if (!packageJsonPath) {
|
||||
debug(
|
||||
`Skipping dependency installation because no package.json was found for ${destPath}`
|
||||
);
|
||||
runNpmInstallSema.release();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only allow `runNpmInstall()` to run once per `package.json`
|
||||
// when doing a default install (no additional args)
|
||||
if (meta && packageJsonPath && args.length === 0) {
|
||||
@@ -516,6 +530,10 @@ export async function runNpmInstall(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the input environment based on the used package manager and lockfile
|
||||
* versions.
|
||||
*/
|
||||
export function getEnvForPackageManager({
|
||||
cliType,
|
||||
lockfileVersion,
|
||||
@@ -527,7 +545,90 @@ export function getEnvForPackageManager({
|
||||
nodeVersion: NodeVersion | undefined;
|
||||
env: { [x: string]: string | undefined };
|
||||
}) {
|
||||
const newEnv: { [x: string]: string | undefined } = { ...env };
|
||||
const {
|
||||
detectedLockfile,
|
||||
detectedPackageManager,
|
||||
path: newPath,
|
||||
yarnNodeLinker,
|
||||
} = getPathForPackageManager({
|
||||
cliType,
|
||||
lockfileVersion,
|
||||
nodeVersion,
|
||||
env,
|
||||
});
|
||||
|
||||
const newEnv: { [x: string]: string | undefined } = {
|
||||
...env,
|
||||
};
|
||||
|
||||
if (newPath) {
|
||||
// Ensure that the binaries of the detected package manager are at the
|
||||
// beginning of the `$PATH`.
|
||||
const oldPath = env.PATH + '';
|
||||
newEnv.PATH = `${newPath}${path.delimiter}${oldPath}`;
|
||||
}
|
||||
|
||||
if (yarnNodeLinker) {
|
||||
newEnv.YARN_NODE_LINKER = yarnNodeLinker;
|
||||
}
|
||||
|
||||
if (detectedLockfile && detectedPackageManager) {
|
||||
// For pnpm we also show the version of the lockfile we found
|
||||
const versionString =
|
||||
cliType === 'pnpm' ? `version ${lockfileVersion} ` : '';
|
||||
|
||||
console.log(
|
||||
`Detected \`${detectedLockfile}\` ${versionString}generated by ${detectedPackageManager}`
|
||||
);
|
||||
|
||||
if (cliType === 'bun') {
|
||||
console.warn(
|
||||
'Warning: Bun is used as a package manager at build time only, not at runtime with Functions'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return newEnv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to get the binary paths that link to the used package manager.
|
||||
* Note: Make sure it doesn't contain any `console.log` calls.
|
||||
*/
|
||||
export function getPathForPackageManager({
|
||||
cliType,
|
||||
lockfileVersion,
|
||||
nodeVersion,
|
||||
env,
|
||||
}: {
|
||||
cliType: CliType;
|
||||
lockfileVersion: number | undefined;
|
||||
nodeVersion: NodeVersion | undefined;
|
||||
env: { [x: string]: string | undefined };
|
||||
}): {
|
||||
/**
|
||||
* Which lockfile was detected.
|
||||
*/
|
||||
detectedLockfile: string | undefined;
|
||||
/**
|
||||
* Detected package manager that generated the found lockfile.
|
||||
*/
|
||||
detectedPackageManager: string | undefined;
|
||||
/**
|
||||
* Value of $PATH that includes the binaries for the detected package manager.
|
||||
* Undefined if no $PATH are necessary.
|
||||
*/
|
||||
path: string | undefined;
|
||||
/**
|
||||
* Set if yarn was identified as package manager and `YARN_NODE_LINKER`
|
||||
* environment variable was not found on the input environment.
|
||||
*/
|
||||
yarnNodeLinker: string | undefined;
|
||||
} {
|
||||
let detectedLockfile: string | undefined;
|
||||
let detectedPackageManager: string | undefined;
|
||||
let pathValue: string | undefined;
|
||||
let yarnNodeLinker: string | undefined;
|
||||
const oldPath = env.PATH + '';
|
||||
const npm7 = '/node16/bin-npm7';
|
||||
const pnpm7 = '/pnpm7/node_modules/.bin';
|
||||
@@ -542,9 +643,10 @@ export function getEnvForPackageManager({
|
||||
!oldPath.includes(npm7) &&
|
||||
!corepackEnabled
|
||||
) {
|
||||
// Ensure that npm 7 is at the beginning of the `$PATH`
|
||||
newEnv.PATH = `${npm7}${path.delimiter}${oldPath}`;
|
||||
console.log('Detected `package-lock.json` generated by npm 7+');
|
||||
// npm 7
|
||||
pathValue = npm7;
|
||||
detectedLockfile = 'package-lock.json';
|
||||
detectedPackageManager = 'npm 7+';
|
||||
}
|
||||
} else if (cliType === 'pnpm') {
|
||||
if (
|
||||
@@ -553,39 +655,40 @@ export function getEnvForPackageManager({
|
||||
!oldPath.includes(pnpm7) &&
|
||||
!corepackEnabled
|
||||
) {
|
||||
// Ensure that pnpm 7 is at the beginning of the `$PATH`
|
||||
newEnv.PATH = `${pnpm7}${path.delimiter}${oldPath}`;
|
||||
console.log(
|
||||
`Detected \`pnpm-lock.yaml\` version ${lockfileVersion} generated by pnpm 7`
|
||||
);
|
||||
// pnpm 7
|
||||
pathValue = pnpm7;
|
||||
detectedLockfile = 'pnpm-lock.yaml';
|
||||
detectedPackageManager = 'pnpm 7';
|
||||
} else if (
|
||||
typeof lockfileVersion === 'number' &&
|
||||
lockfileVersion >= 6 &&
|
||||
!oldPath.includes(pnpm8) &&
|
||||
!corepackEnabled
|
||||
) {
|
||||
// Ensure that pnpm 8 is at the beginning of the `$PATH`
|
||||
newEnv.PATH = `${pnpm8}${path.delimiter}${oldPath}`;
|
||||
console.log(
|
||||
`Detected \`pnpm-lock.yaml\` version ${lockfileVersion} generated by pnpm 8`
|
||||
);
|
||||
// pnpm 8
|
||||
pathValue = pnpm8;
|
||||
detectedLockfile = 'pnpm-lock.yaml';
|
||||
detectedPackageManager = 'pnpm 8';
|
||||
}
|
||||
} else if (cliType === 'bun') {
|
||||
if (!oldPath.includes(bun1) && !corepackEnabled) {
|
||||
// Ensure that Bun 1 is at the beginning of the `$PATH`
|
||||
newEnv.PATH = `${bun1}${path.delimiter}${oldPath}`;
|
||||
console.log('Detected `bun.lockb` generated by Bun');
|
||||
console.warn(
|
||||
'Warning: Bun is used as a package manager at build time only, not at runtime with Functions'
|
||||
);
|
||||
// Bun 1
|
||||
pathValue = bun1;
|
||||
detectedLockfile = 'bun.lockb';
|
||||
detectedPackageManager = 'Bun';
|
||||
}
|
||||
} else {
|
||||
// Yarn v2 PnP mode may be activated, so force "node-modules" linker style
|
||||
if (!env.YARN_NODE_LINKER) {
|
||||
newEnv.YARN_NODE_LINKER = 'node-modules';
|
||||
yarnNodeLinker = 'node-modules';
|
||||
}
|
||||
}
|
||||
return newEnv;
|
||||
return {
|
||||
detectedLockfile,
|
||||
detectedPackageManager,
|
||||
path: pathValue,
|
||||
yarnNodeLinker,
|
||||
};
|
||||
}
|
||||
|
||||
export async function runCustomInstallCommand({
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
runCustomInstallCommand,
|
||||
getEnvForPackageManager,
|
||||
getNodeVersion,
|
||||
getPathForPackageManager,
|
||||
getSpawnOptions,
|
||||
getNodeBinPath,
|
||||
getNodeBinPaths,
|
||||
@@ -78,6 +79,7 @@ export {
|
||||
runCustomInstallCommand,
|
||||
getEnvForPackageManager,
|
||||
getNodeVersion,
|
||||
getPathForPackageManager,
|
||||
getLatestNodeVersion,
|
||||
getDiscontinuedNodeVersions,
|
||||
getSpawnOptions,
|
||||
|
||||
@@ -37,6 +37,7 @@ export interface LambdaOptionsBase {
|
||||
|
||||
export interface LambdaOptionsWithFiles extends LambdaOptionsBase {
|
||||
files: Files;
|
||||
experimentalAllowBundling?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,6 +80,7 @@ export class Lambda {
|
||||
supportsWrapper?: boolean;
|
||||
supportsResponseStreaming?: boolean;
|
||||
framework?: FunctionFramework;
|
||||
experimentalAllowBundling?: boolean;
|
||||
|
||||
constructor(opts: LambdaOptions) {
|
||||
const {
|
||||
@@ -114,6 +116,16 @@ export class Lambda {
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
'experimentalAllowBundling' in opts &&
|
||||
opts.experimentalAllowBundling !== undefined
|
||||
) {
|
||||
assert(
|
||||
typeof opts.experimentalAllowBundling === 'boolean',
|
||||
'"experimentalAllowBundling" is not a boolean'
|
||||
);
|
||||
}
|
||||
|
||||
if (memory !== undefined) {
|
||||
assert(typeof memory === 'number', '"memory" is not a number');
|
||||
}
|
||||
@@ -183,6 +195,10 @@ export class Lambda {
|
||||
this.supportsResponseStreaming =
|
||||
supportsResponseStreaming ?? experimentalResponseStreaming;
|
||||
this.framework = framework;
|
||||
this.experimentalAllowBundling =
|
||||
'experimentalAllowBundling' in opts
|
||||
? opts.experimentalAllowBundling
|
||||
: undefined;
|
||||
}
|
||||
|
||||
async createZip(): Promise<Buffer> {
|
||||
|
||||
@@ -196,6 +196,12 @@ export interface StartDevServerSuccess {
|
||||
* shut down the dev server once an HTTP request has been fulfilled.
|
||||
*/
|
||||
pid: number;
|
||||
|
||||
/**
|
||||
* An optional function to shut down the dev server. If not provided, the
|
||||
* dev server will forcefully be killed.
|
||||
*/
|
||||
shutdown?: () => Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -434,7 +440,9 @@ export interface Cron {
|
||||
schedule: string;
|
||||
}
|
||||
|
||||
// TODO: Proper description once complete
|
||||
/**
|
||||
* @deprecated Replaced by Variants. Remove once fully replaced.
|
||||
*/
|
||||
export interface Flag {
|
||||
key: string;
|
||||
defaultValue?: unknown;
|
||||
@@ -465,7 +473,9 @@ export interface BuildResultV2Typical {
|
||||
framework?: {
|
||||
version: string;
|
||||
};
|
||||
/** @deprecated Replaced by Variants. Remove once fully replaced. */
|
||||
flags?: Flag[];
|
||||
variants?: Record<string, VariantDefinition>;
|
||||
}
|
||||
|
||||
export type BuildResultV2 = BuildResultV2Typical | BuildResultBuildOutput;
|
||||
@@ -485,3 +495,28 @@ export type ShouldServe = (
|
||||
export type StartDevServer = (
|
||||
options: StartDevServerOptions
|
||||
) => Promise<StartDevServerResult>;
|
||||
|
||||
/**
|
||||
* TODO: The following types will eventually be exported by a more
|
||||
* relevant package.
|
||||
*/
|
||||
type VariantJSONArray = ReadonlyArray<VariantJSONValue>;
|
||||
|
||||
type VariantJSONValue =
|
||||
| string
|
||||
| boolean
|
||||
| number
|
||||
| null
|
||||
| VariantJSONArray
|
||||
| { [key: string]: VariantJSONValue };
|
||||
|
||||
type VariantOption = {
|
||||
value: VariantJSONValue;
|
||||
label?: string;
|
||||
};
|
||||
|
||||
export interface VariantDefinition {
|
||||
options?: VariantOption[];
|
||||
origin?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
4
packages/build-utils/test/fixtures/07-cross-install/api/yarn.lock
vendored
Normal file
4
packages/build-utils/test/fixtures/07-cross-install/api/yarn.lock
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
4
packages/build-utils/test/fixtures/07-cross-install/lib/yarn.lock
vendored
Normal file
4
packages/build-utils/test/fixtures/07-cross-install/lib/yarn.lock
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
4
packages/build-utils/test/fixtures/08-yarn-npm/with-yarn/yarn.lock
vendored
Normal file
4
packages/build-utils/test/fixtures/08-yarn-npm/with-yarn/yarn.lock
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
9
packages/build-utils/test/fixtures/40-no-lockfile/package.json
vendored
Normal file
9
packages/build-utils/test/fixtures/40-no-lockfile/package.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "mkdir -p public && (printf \"npm version: \" && npm -v) > public/index.txt"
|
||||
},
|
||||
"dependencies": {
|
||||
"sharp": "0.33.2"
|
||||
}
|
||||
}
|
||||
3
packages/build-utils/test/fixtures/40-no-lockfile/probes.json
vendored
Normal file
3
packages/build-utils/test/fixtures/40-no-lockfile/probes.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"probes": [{ "path": "/", "mustContain": "npm version: 8" }]
|
||||
}
|
||||
7
packages/build-utils/test/fixtures/40-no-lockfile/vercel.json
vendored
Normal file
7
packages/build-utils/test/fixtures/40-no-lockfile/vercel.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"build": {
|
||||
"env": {
|
||||
"VERCEL_ENABLE_NPM_DEFAULT": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,34 @@
|
||||
import assert from 'assert';
|
||||
import { delimiter } from 'path';
|
||||
import { getEnvForPackageManager } from '../src';
|
||||
import { getEnvForPackageManager, getPathForPackageManager } from '../src';
|
||||
|
||||
describe('Test `getEnvForPackageManager()`', () => {
|
||||
const cases: Array<{
|
||||
let consoleLogSpy: jest.SpyInstance;
|
||||
let consoleWarnSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
consoleLogSpy = jest.spyOn(console, 'log');
|
||||
consoleWarnSpy = jest.spyOn(console, 'warn');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
test.each<{
|
||||
name: string;
|
||||
args: Parameters<typeof getEnvForPackageManager>[0];
|
||||
want: unknown;
|
||||
}> = [
|
||||
/**
|
||||
* Expected output on `console.log`. Set to `null` when no output is
|
||||
* expected.
|
||||
*/
|
||||
consoleLogOutput?: string | null;
|
||||
/**
|
||||
* Expected output on `console.warn`. Set to `null` when no output is
|
||||
* expected.
|
||||
*/
|
||||
consoleWarnOutput?: string | null;
|
||||
}>([
|
||||
{
|
||||
name: 'should do nothing to env for npm < 6 and node < 16',
|
||||
args: {
|
||||
@@ -21,6 +42,8 @@ describe('Test `getEnvForPackageManager()`', () => {
|
||||
want: {
|
||||
FOO: 'bar',
|
||||
},
|
||||
consoleLogOutput: null,
|
||||
consoleWarnOutput: null,
|
||||
},
|
||||
{
|
||||
name: 'should set path if npm 7+ is detected and node < 16',
|
||||
@@ -37,6 +60,8 @@ describe('Test `getEnvForPackageManager()`', () => {
|
||||
FOO: 'bar',
|
||||
PATH: `/node16/bin-npm7${delimiter}foo`,
|
||||
},
|
||||
consoleLogOutput: 'Detected `package-lock.json` generated by npm 7+',
|
||||
consoleWarnOutput: null,
|
||||
},
|
||||
{
|
||||
name: 'should not set npm path if corepack enabled',
|
||||
@@ -53,6 +78,8 @@ describe('Test `getEnvForPackageManager()`', () => {
|
||||
FOO: 'bar',
|
||||
ENABLE_EXPERIMENTAL_COREPACK: '1',
|
||||
},
|
||||
consoleLogOutput: null,
|
||||
consoleWarnOutput: null,
|
||||
},
|
||||
{
|
||||
name: 'should not prepend npm path again if already detected',
|
||||
@@ -69,6 +96,8 @@ describe('Test `getEnvForPackageManager()`', () => {
|
||||
FOO: 'bar',
|
||||
PATH: `/node16/bin-npm7${delimiter}foo`,
|
||||
},
|
||||
consoleLogOutput: null,
|
||||
consoleWarnOutput: null,
|
||||
},
|
||||
{
|
||||
name: 'should not set path if node is 16 and npm 7+ is detected',
|
||||
@@ -85,6 +114,8 @@ describe('Test `getEnvForPackageManager()`', () => {
|
||||
FOO: 'bar',
|
||||
PATH: 'foo',
|
||||
},
|
||||
consoleLogOutput: null,
|
||||
consoleWarnOutput: null,
|
||||
},
|
||||
{
|
||||
name: 'should set YARN_NODE_LINKER w/yarn if it is not already defined',
|
||||
@@ -100,6 +131,8 @@ describe('Test `getEnvForPackageManager()`', () => {
|
||||
FOO: 'bar',
|
||||
YARN_NODE_LINKER: 'node-modules',
|
||||
},
|
||||
consoleLogOutput: null,
|
||||
consoleWarnOutput: null,
|
||||
},
|
||||
{
|
||||
name: 'should not set YARN_NODE_LINKER if it already exists',
|
||||
@@ -116,6 +149,8 @@ describe('Test `getEnvForPackageManager()`', () => {
|
||||
FOO: 'bar',
|
||||
YARN_NODE_LINKER: 'exists',
|
||||
},
|
||||
consoleLogOutput: null,
|
||||
consoleWarnOutput: null,
|
||||
},
|
||||
{
|
||||
name: 'should set path if pnpm 7+ is detected',
|
||||
@@ -132,6 +167,9 @@ describe('Test `getEnvForPackageManager()`', () => {
|
||||
FOO: 'bar',
|
||||
PATH: `/pnpm7/node_modules/.bin${delimiter}foo`,
|
||||
},
|
||||
consoleLogOutput:
|
||||
'Detected `pnpm-lock.yaml` version 5.4 generated by pnpm 7',
|
||||
consoleWarnOutput: null,
|
||||
},
|
||||
{
|
||||
name: 'should set path if bun v1 is detected',
|
||||
@@ -148,6 +186,9 @@ describe('Test `getEnvForPackageManager()`', () => {
|
||||
FOO: 'bar',
|
||||
PATH: `/bun1${delimiter}/usr/local/bin`,
|
||||
},
|
||||
consoleLogOutput: 'Detected `bun.lockb` generated by Bun',
|
||||
consoleWarnOutput:
|
||||
'Warning: Bun is used as a package manager at build time only, not at runtime with Functions',
|
||||
},
|
||||
{
|
||||
name: 'should not set pnpm path if corepack is enabled',
|
||||
@@ -164,6 +205,8 @@ describe('Test `getEnvForPackageManager()`', () => {
|
||||
FOO: 'bar',
|
||||
ENABLE_EXPERIMENTAL_COREPACK: '1',
|
||||
},
|
||||
consoleLogOutput: null,
|
||||
consoleWarnOutput: null,
|
||||
},
|
||||
{
|
||||
name: 'should not prepend pnpm path again if already detected',
|
||||
@@ -180,6 +223,8 @@ describe('Test `getEnvForPackageManager()`', () => {
|
||||
FOO: 'bar',
|
||||
PATH: `/pnpm7/node_modules/.bin${delimiter}foo`,
|
||||
},
|
||||
consoleLogOutput: null,
|
||||
consoleWarnOutput: null,
|
||||
},
|
||||
{
|
||||
name: 'should not set path if pnpm 6 is detected',
|
||||
@@ -194,20 +239,262 @@ describe('Test `getEnvForPackageManager()`', () => {
|
||||
want: {
|
||||
FOO: 'bar',
|
||||
},
|
||||
consoleLogOutput: null,
|
||||
consoleWarnOutput: null,
|
||||
},
|
||||
];
|
||||
])('$name', ({ args, want, consoleLogOutput, consoleWarnOutput }) => {
|
||||
expect(
|
||||
getEnvForPackageManager({
|
||||
cliType: args.cliType,
|
||||
lockfileVersion: args.lockfileVersion,
|
||||
nodeVersion: args.nodeVersion,
|
||||
env: args.env,
|
||||
})
|
||||
).toStrictEqual(want);
|
||||
|
||||
for (const { name, want, args } of cases) {
|
||||
it(name, () => {
|
||||
assert.deepStrictEqual(
|
||||
getEnvForPackageManager({
|
||||
cliType: args.cliType,
|
||||
lockfileVersion: args.lockfileVersion,
|
||||
nodeVersion: args.nodeVersion,
|
||||
env: args.env,
|
||||
}),
|
||||
want
|
||||
);
|
||||
});
|
||||
}
|
||||
// Check console.log output
|
||||
if (typeof consoleLogOutput === 'string') {
|
||||
expect(consoleLogSpy).toHaveBeenCalledWith(consoleLogOutput);
|
||||
} else if (consoleLogOutput === null) {
|
||||
expect(consoleLogSpy).not.toHaveBeenCalled();
|
||||
}
|
||||
|
||||
// Check console.warn output
|
||||
if (typeof consoleWarnOutput === 'string') {
|
||||
expect(consoleWarnSpy).toHaveBeenCalledWith(consoleWarnOutput);
|
||||
} else if (consoleLogOutput === null) {
|
||||
expect(consoleWarnSpy).not.toHaveBeenCalled();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Test `getPathForPackageManager()`', () => {
|
||||
test.each<{
|
||||
name: string;
|
||||
args: Parameters<typeof getEnvForPackageManager>[0];
|
||||
want: unknown;
|
||||
}>([
|
||||
{
|
||||
name: 'should do nothing to env for npm < 6 and node < 16',
|
||||
args: {
|
||||
cliType: 'npm',
|
||||
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
|
||||
lockfileVersion: 1,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
},
|
||||
},
|
||||
want: {
|
||||
detectedLockfile: undefined,
|
||||
detectedPackageManager: undefined,
|
||||
path: undefined,
|
||||
yarnNodeLinker: undefined,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'should set path if npm 7+ is detected and node < 16',
|
||||
args: {
|
||||
cliType: 'npm',
|
||||
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
|
||||
lockfileVersion: 2,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
PATH: 'foo',
|
||||
},
|
||||
},
|
||||
want: {
|
||||
detectedLockfile: 'package-lock.json',
|
||||
detectedPackageManager: 'npm 7+',
|
||||
path: '/node16/bin-npm7',
|
||||
yarnNodeLinker: undefined,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'should not set npm path if corepack enabled',
|
||||
args: {
|
||||
cliType: 'npm',
|
||||
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
|
||||
lockfileVersion: 2,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
ENABLE_EXPERIMENTAL_COREPACK: '1',
|
||||
},
|
||||
},
|
||||
want: {
|
||||
detectedLockfile: undefined,
|
||||
detectedPackageManager: undefined,
|
||||
path: undefined,
|
||||
yarnNodeLinker: undefined,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'should not prepend npm path again if already detected',
|
||||
args: {
|
||||
cliType: 'npm',
|
||||
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
|
||||
lockfileVersion: 2,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
PATH: `/node16/bin-npm7${delimiter}foo`,
|
||||
},
|
||||
},
|
||||
want: {
|
||||
detectedLockfile: undefined,
|
||||
detectedPackageManager: undefined,
|
||||
path: undefined,
|
||||
yarnNodeLinker: undefined,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'should not set path if node is 16 and npm 7+ is detected',
|
||||
args: {
|
||||
cliType: 'npm',
|
||||
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
|
||||
lockfileVersion: 2,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
PATH: 'foo',
|
||||
},
|
||||
},
|
||||
want: {
|
||||
detectedLockfile: undefined,
|
||||
detectedPackageManager: undefined,
|
||||
path: undefined,
|
||||
yarnNodeLinker: undefined,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'should set YARN_NODE_LINKER w/yarn if it is not already defined',
|
||||
args: {
|
||||
cliType: 'yarn',
|
||||
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
|
||||
lockfileVersion: 2,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
},
|
||||
},
|
||||
want: {
|
||||
detectedLockfile: undefined,
|
||||
detectedPackageManager: undefined,
|
||||
path: undefined,
|
||||
yarnNodeLinker: 'node-modules',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'should not set YARN_NODE_LINKER if it already exists',
|
||||
args: {
|
||||
cliType: 'yarn',
|
||||
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
|
||||
lockfileVersion: 2,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
YARN_NODE_LINKER: 'exists',
|
||||
},
|
||||
},
|
||||
want: {
|
||||
detectedLockfile: undefined,
|
||||
detectedPackageManager: undefined,
|
||||
path: undefined,
|
||||
yarnNodeLinker: undefined,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'should set path if pnpm 7+ is detected',
|
||||
args: {
|
||||
cliType: 'pnpm',
|
||||
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
|
||||
lockfileVersion: 5.4,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
PATH: 'foo',
|
||||
},
|
||||
},
|
||||
want: {
|
||||
detectedLockfile: 'pnpm-lock.yaml',
|
||||
detectedPackageManager: 'pnpm 7',
|
||||
path: '/pnpm7/node_modules/.bin',
|
||||
yarnNodeLinker: undefined,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'should set path if bun v1 is detected',
|
||||
args: {
|
||||
cliType: 'bun',
|
||||
nodeVersion: { major: 18, range: '18.x', runtime: 'nodejs18.x' },
|
||||
lockfileVersion: 0,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
PATH: '/usr/local/bin',
|
||||
},
|
||||
},
|
||||
want: {
|
||||
detectedLockfile: 'bun.lockb',
|
||||
detectedPackageManager: 'Bun',
|
||||
path: '/bun1',
|
||||
yarnNodeLinker: undefined,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'should not set pnpm path if corepack is enabled',
|
||||
args: {
|
||||
cliType: 'pnpm',
|
||||
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
|
||||
lockfileVersion: 5.4,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
ENABLE_EXPERIMENTAL_COREPACK: '1',
|
||||
},
|
||||
},
|
||||
want: {
|
||||
detectedLockfile: undefined,
|
||||
detectedPackageManager: undefined,
|
||||
path: undefined,
|
||||
yarnNodeLinker: undefined,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'should not prepend pnpm path again if already detected',
|
||||
args: {
|
||||
cliType: 'pnpm',
|
||||
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
|
||||
lockfileVersion: 5.4,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
PATH: `/pnpm7/node_modules/.bin${delimiter}foo`,
|
||||
},
|
||||
},
|
||||
want: {
|
||||
detectedLockfile: undefined,
|
||||
detectedPackageManager: undefined,
|
||||
path: undefined,
|
||||
yarnNodeLinker: undefined,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'should not set path if pnpm 6 is detected',
|
||||
args: {
|
||||
cliType: 'pnpm',
|
||||
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
|
||||
lockfileVersion: 5.3,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
},
|
||||
},
|
||||
want: {
|
||||
detectedLockfile: undefined,
|
||||
detectedPackageManager: undefined,
|
||||
path: undefined,
|
||||
yarnNodeLinker: undefined,
|
||||
},
|
||||
},
|
||||
])('$name', ({ args, want }) => {
|
||||
expect(
|
||||
getPathForPackageManager({
|
||||
cliType: args.cliType,
|
||||
lockfileVersion: args.lockfileVersion,
|
||||
nodeVersion: args.nodeVersion,
|
||||
env: args.env,
|
||||
})
|
||||
).toStrictEqual(want);
|
||||
});
|
||||
});
|
||||
|
||||
188
packages/build-utils/test/unit.test.ts
vendored
188
packages/build-utils/test/unit.test.ts
vendored
@@ -268,81 +268,85 @@ it('should get latest node version with Node 20.x in build-container', async ()
|
||||
});
|
||||
|
||||
it('should throw for discontinued versions', async () => {
|
||||
// Mock a future date so that Node 8 and 10 become discontinued
|
||||
const realDateNow = Date.now.bind(global.Date);
|
||||
global.Date.now = () => new Date('2024-02-13').getTime();
|
||||
// Mock a future date so that Node 16 becomes discontinued
|
||||
const realDateNow = Date.now;
|
||||
try {
|
||||
global.Date.now = () => new Date('2024-07-16').getTime();
|
||||
|
||||
expect(getSupportedNodeVersion('8.10.x', false)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('8.10.x', true)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('10.x', false)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('10.x', true)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('12.x', false)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('12.x', true)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('14.x', false)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('14.x', true)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('16.x', false)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('16.x', true)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('8.10.x', false)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('8.10.x', true)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('10.x', false)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('10.x', true)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('12.x', false)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('12.x', true)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('14.x', false)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('14.x', true)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('16.x', false)).rejects.toThrow();
|
||||
expect(getSupportedNodeVersion('16.x', true)).rejects.toThrow();
|
||||
|
||||
const discontinued = getDiscontinuedNodeVersions();
|
||||
expect(discontinued.length).toBe(5);
|
||||
expect(discontinued[0]).toHaveProperty('range', '16.x');
|
||||
expect(discontinued[1]).toHaveProperty('range', '14.x');
|
||||
expect(discontinued[2]).toHaveProperty('range', '12.x');
|
||||
expect(discontinued[3]).toHaveProperty('range', '10.x');
|
||||
expect(discontinued[4]).toHaveProperty('range', '8.10.x');
|
||||
|
||||
global.Date.now = realDateNow;
|
||||
const discontinued = getDiscontinuedNodeVersions();
|
||||
expect(discontinued.length).toBe(5);
|
||||
expect(discontinued[0]).toHaveProperty('range', '16.x');
|
||||
expect(discontinued[1]).toHaveProperty('range', '14.x');
|
||||
expect(discontinued[2]).toHaveProperty('range', '12.x');
|
||||
expect(discontinued[3]).toHaveProperty('range', '10.x');
|
||||
expect(discontinued[4]).toHaveProperty('range', '8.10.x');
|
||||
} finally {
|
||||
global.Date.now = realDateNow;
|
||||
}
|
||||
});
|
||||
|
||||
it('should warn for deprecated versions, soon to be discontinued', async () => {
|
||||
// Mock a future date so that Node 10 warns
|
||||
const realDateNow = Date.now.bind(global.Date);
|
||||
global.Date.now = () => new Date('2021-02-23').getTime();
|
||||
// Mock a future date so that Node 16 warns
|
||||
const realDateNow = Date.now;
|
||||
try {
|
||||
global.Date.now = () => new Date('2021-02-23').getTime();
|
||||
|
||||
expect(await getSupportedNodeVersion('10.x', false)).toHaveProperty(
|
||||
'major',
|
||||
10
|
||||
);
|
||||
expect(await getSupportedNodeVersion('10.x', true)).toHaveProperty(
|
||||
'major',
|
||||
10
|
||||
);
|
||||
expect(await getSupportedNodeVersion('12.x', false)).toHaveProperty(
|
||||
'major',
|
||||
12
|
||||
);
|
||||
expect(await getSupportedNodeVersion('12.x', true)).toHaveProperty(
|
||||
'major',
|
||||
12
|
||||
);
|
||||
expect(await getSupportedNodeVersion('14.x', false)).toHaveProperty(
|
||||
'major',
|
||||
14
|
||||
);
|
||||
expect(await getSupportedNodeVersion('14.x', true)).toHaveProperty(
|
||||
'major',
|
||||
14
|
||||
);
|
||||
expect(await getSupportedNodeVersion('16.x', false)).toHaveProperty(
|
||||
'major',
|
||||
16
|
||||
);
|
||||
expect(await getSupportedNodeVersion('16.x', true)).toHaveProperty(
|
||||
'major',
|
||||
16
|
||||
);
|
||||
expect(warningMessages).toStrictEqual([
|
||||
'Error: Node.js version 10.x has reached End-of-Life. Deployments created on or after 2021-04-20 will fail to build. Please set "engines": { "node": "20.x" } in your `package.json` file to use Node.js 20.',
|
||||
'Error: Node.js version 10.x has reached End-of-Life. Deployments created on or after 2021-04-20 will fail to build. Please set Node.js Version to 20.x in your Project Settings to use Node.js 20.',
|
||||
'Error: Node.js version 12.x has reached End-of-Life. Deployments created on or after 2022-10-03 will fail to build. Please set "engines": { "node": "20.x" } in your `package.json` file to use Node.js 20.',
|
||||
'Error: Node.js version 12.x has reached End-of-Life. Deployments created on or after 2022-10-03 will fail to build. Please set Node.js Version to 20.x in your Project Settings to use Node.js 20.',
|
||||
'Error: Node.js version 14.x has reached End-of-Life. Deployments created on or after 2023-08-15 will fail to build. Please set "engines": { "node": "20.x" } in your `package.json` file to use Node.js 20.',
|
||||
'Error: Node.js version 14.x has reached End-of-Life. Deployments created on or after 2023-08-15 will fail to build. Please set Node.js Version to 20.x in your Project Settings to use Node.js 20.',
|
||||
'Error: Node.js version 16.x has reached End-of-Life. Deployments created on or after 2024-02-06 will fail to build. Please set "engines": { "node": "20.x" } in your `package.json` file to use Node.js 20.',
|
||||
'Error: Node.js version 16.x has reached End-of-Life. Deployments created on or after 2024-02-06 will fail to build. Please set Node.js Version to 20.x in your Project Settings to use Node.js 20.',
|
||||
]);
|
||||
|
||||
global.Date.now = realDateNow;
|
||||
expect(await getSupportedNodeVersion('10.x', false)).toHaveProperty(
|
||||
'major',
|
||||
10
|
||||
);
|
||||
expect(await getSupportedNodeVersion('10.x', true)).toHaveProperty(
|
||||
'major',
|
||||
10
|
||||
);
|
||||
expect(await getSupportedNodeVersion('12.x', false)).toHaveProperty(
|
||||
'major',
|
||||
12
|
||||
);
|
||||
expect(await getSupportedNodeVersion('12.x', true)).toHaveProperty(
|
||||
'major',
|
||||
12
|
||||
);
|
||||
expect(await getSupportedNodeVersion('14.x', false)).toHaveProperty(
|
||||
'major',
|
||||
14
|
||||
);
|
||||
expect(await getSupportedNodeVersion('14.x', true)).toHaveProperty(
|
||||
'major',
|
||||
14
|
||||
);
|
||||
expect(await getSupportedNodeVersion('16.x', false)).toHaveProperty(
|
||||
'major',
|
||||
16
|
||||
);
|
||||
expect(await getSupportedNodeVersion('16.x', true)).toHaveProperty(
|
||||
'major',
|
||||
16
|
||||
);
|
||||
expect(warningMessages).toStrictEqual([
|
||||
'Error: Node.js version 10.x has reached End-of-Life. Deployments created on or after 2021-04-20 will fail to build. Please set "engines": { "node": "20.x" } in your `package.json` file to use Node.js 20.',
|
||||
'Error: Node.js version 10.x has reached End-of-Life. Deployments created on or after 2021-04-20 will fail to build. Please set Node.js Version to 20.x in your Project Settings to use Node.js 20.',
|
||||
'Error: Node.js version 12.x has reached End-of-Life. Deployments created on or after 2022-10-03 will fail to build. Please set "engines": { "node": "20.x" } in your `package.json` file to use Node.js 20.',
|
||||
'Error: Node.js version 12.x has reached End-of-Life. Deployments created on or after 2022-10-03 will fail to build. Please set Node.js Version to 20.x in your Project Settings to use Node.js 20.',
|
||||
'Error: Node.js version 14.x has reached End-of-Life. Deployments created on or after 2023-08-15 will fail to build. Please set "engines": { "node": "20.x" } in your `package.json` file to use Node.js 20.',
|
||||
'Error: Node.js version 14.x has reached End-of-Life. Deployments created on or after 2023-08-15 will fail to build. Please set Node.js Version to 20.x in your Project Settings to use Node.js 20.',
|
||||
'Error: Node.js version 16.x has reached End-of-Life. Deployments created on or after 2024-06-15 will fail to build. Please set "engines": { "node": "20.x" } in your `package.json` file to use Node.js 20.',
|
||||
'Error: Node.js version 16.x has reached End-of-Life. Deployments created on or after 2024-06-15 will fail to build. Please set Node.js Version to 20.x in your Project Settings to use Node.js 20.',
|
||||
]);
|
||||
} finally {
|
||||
global.Date.now = realDateNow;
|
||||
}
|
||||
});
|
||||
|
||||
it('should support initialHeaders and initialStatus correctly', async () => {
|
||||
@@ -572,6 +576,52 @@ it(
|
||||
ms('1m')
|
||||
);
|
||||
|
||||
it('should return cliType npm when no lockfile is present and VERCEL_ENABLE_NPM_DEFAULT is set', async () => {
|
||||
const originalRepoLockfilePath = path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'pnpm-lock.yaml'
|
||||
);
|
||||
const originalRepoLockfileData = await fs.readFile(originalRepoLockfilePath);
|
||||
await fs.remove(originalRepoLockfilePath);
|
||||
try {
|
||||
process.env.VERCEL_ENABLE_NPM_DEFAULT = '1';
|
||||
const fixture = path.join(__dirname, 'fixtures', '40-no-lockfile');
|
||||
const result = await scanParentDirs(fixture);
|
||||
expect(result.cliType).toEqual('npm');
|
||||
expect(result.lockfileVersion).toEqual(undefined);
|
||||
expect(result.lockfilePath).toEqual(undefined);
|
||||
expect(result.packageJsonPath).toEqual(path.join(fixture, 'package.json'));
|
||||
} finally {
|
||||
delete process.env.VERCEL_ENABLE_NPM_DEFAULT;
|
||||
await fs.writeFile(originalRepoLockfilePath, originalRepoLockfileData);
|
||||
}
|
||||
});
|
||||
|
||||
it('should return cliType yarn when no lockfile is present and VERCEL_ENABLE_NPM_DEFAULT is not set', async () => {
|
||||
const originalRepoLockfilePath = path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'pnpm-lock.yaml'
|
||||
);
|
||||
const originalRepoLockfileData = await fs.readFile(originalRepoLockfilePath);
|
||||
await fs.remove(originalRepoLockfilePath);
|
||||
try {
|
||||
const fixture = path.join(__dirname, 'fixtures', '40-no-lockfile');
|
||||
const result = await scanParentDirs(fixture);
|
||||
expect(result.cliType).toEqual('yarn');
|
||||
expect(result.lockfileVersion).toEqual(undefined);
|
||||
expect(result.lockfilePath).toEqual(undefined);
|
||||
expect(result.packageJsonPath).toEqual(path.join(fixture, 'package.json'));
|
||||
} finally {
|
||||
await fs.writeFile(originalRepoLockfilePath, originalRepoLockfileData);
|
||||
}
|
||||
});
|
||||
|
||||
it('should return cliType bun and correct lock file for bun v1', async () => {
|
||||
const fixture = path.join(__dirname, 'fixtures', '31-bun-v1-with-yarn-lock');
|
||||
const result = await scanParentDirs(fixture);
|
||||
|
||||
@@ -1,5 +1,140 @@
|
||||
# vercel
|
||||
|
||||
## 33.5.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Mark `flags` as deprecated and replace them with `variants` ([#11098](https://github.com/vercel/vercel/pull/11098))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`c32a909af`](https://github.com/vercel/vercel/commit/c32a909afcedf0ee55777d5dcaecc0c8383dd8c8), [`b6ed28b9b`](https://github.com/vercel/vercel/commit/b6ed28b9b1712f882c93fe053b70d3eb1df21819), [`d21bb9f87`](https://github.com/vercel/vercel/commit/d21bb9f87e1d837666fe8104d4e199b2590725d6), [`4027a1833`](https://github.com/vercel/vercel/commit/4027a1833718a92be74b2b3c5a4df23745d19a36), [`8ba0ce932`](https://github.com/vercel/vercel/commit/8ba0ce932434c6295fedb5307bee59a804b7e6a8), [`0d034b682`](https://github.com/vercel/vercel/commit/0d034b6820c0f3252949c0ffc483048c5aac7f04), [`abaa700ce`](https://github.com/vercel/vercel/commit/abaa700cea44c723cfc851baa2dfe9e1ae2e8a5c), [`3bad73401`](https://github.com/vercel/vercel/commit/3bad73401b4ec1f61e515965732cde8dcc052b17)]:
|
||||
- @vercel/next@4.1.1
|
||||
- @vercel/node@3.0.18
|
||||
- @vercel/redwood@2.0.7
|
||||
- @vercel/remix-builder@2.0.19
|
||||
- @vercel/build-utils@7.6.0
|
||||
- @vercel/static-build@2.3.0
|
||||
|
||||
## 33.4.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`d05e41eea`](https://github.com/vercel/vercel/commit/d05e41eeaf97a024157d2bd843782c95c39389be), [`de63e3562`](https://github.com/vercel/vercel/commit/de63e356223467447cda539ddc435a892303afc7)]:
|
||||
- @vercel/static-build@2.2.0
|
||||
|
||||
## 33.4.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Added a new option to add a sensitive environment variable ([#11033](https://github.com/vercel/vercel/pull/11033))
|
||||
|
||||
## 33.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Emit "filePathMap" in `vc-config.json` for `FileFsRef` instances ([#11060](https://github.com/vercel/vercel/pull/11060))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Update `vc dev` to support `Lambda` instances without `zipBuffer` ([#11080](https://github.com/vercel/vercel/pull/11080))
|
||||
|
||||
- Updated dependencies [[`322c88536`](https://github.com/vercel/vercel/commit/322c88536dfa0ba3892eb580858ee54f6b04ed3f), [`62ca2efa7`](https://github.com/vercel/vercel/commit/62ca2efa731c4df46d586b94078b2dcb1c0bb934)]:
|
||||
- @vercel/ruby@2.0.5
|
||||
- @vercel/python@4.1.1
|
||||
|
||||
## 33.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- chore: deprecate next/nuxt/gastby Speed Insights injection in favor of @vercel/speed-insights ([#11048](https://github.com/vercel/vercel/pull/11048))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fix error when @vercel/analytics is a transitive dependency of the deployed application ([#10892](https://github.com/vercel/vercel/pull/10892))
|
||||
|
||||
- [cli] Add documentation string for `skip-domain` option ([#11051](https://github.com/vercel/vercel/pull/11051))
|
||||
|
||||
- Updated dependencies [[`260125784`](https://github.com/vercel/vercel/commit/2601257846fa201fc9efde021a906c706f6191aa), [`cdddb33ad`](https://github.com/vercel/vercel/commit/cdddb33ad49f6080c49f4fff3767e6111acd0bbe), [`72d8604c9`](https://github.com/vercel/vercel/commit/72d8604c9dba108ccca41d6288b765a7ba727295), [`90d0455e1`](https://github.com/vercel/vercel/commit/90d0455e1ff7b5892ff4960226535f57f704ef6f), [`0716130e5`](https://github.com/vercel/vercel/commit/0716130e580a920d92d249d029ed37f92f2ca847), [`b6b151f39`](https://github.com/vercel/vercel/commit/b6b151f3917c5cb47226951446b9dbb96c7d872b), [`b185a7e20`](https://github.com/vercel/vercel/commit/b185a7e207b153c378bd3db2618eece3a3b6a93e)]:
|
||||
- @vercel/static-build@2.1.0
|
||||
- @vercel/build-utils@7.5.1
|
||||
- @vercel/next@4.1.0
|
||||
- @vercel/remix-builder@2.0.18
|
||||
- @vercel/node@3.0.17
|
||||
|
||||
## 33.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Serialize duplicate `EdgeFunction` references as symlinks in `vc build` ([#11027](https://github.com/vercel/vercel/pull/11027))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Handle rate limit response when fetching /teams ([#11013](https://github.com/vercel/vercel/pull/11013))
|
||||
|
||||
- Display actual deployment's 'target' ([#11025](https://github.com/vercel/vercel/pull/11025))
|
||||
|
||||
- Updated dependencies [[`98040ec24`](https://github.com/vercel/vercel/commit/98040ec24e1ee585865d11eb216b6525d39d209e)]:
|
||||
- @vercel/build-utils@7.5.0
|
||||
- @vercel/static-build@2.0.17
|
||||
- @vercel/hydrogen@1.0.2
|
||||
- @vercel/remix-builder@2.0.17
|
||||
- @vercel/node@3.0.16
|
||||
|
||||
## 33.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Log extension execution failures ([#10937](https://github.com/vercel/vercel/pull/10937))
|
||||
|
||||
- Updated dependencies [[`fbe08fe57`](https://github.com/vercel/vercel/commit/fbe08fe57eededc0bcd2409692b23d185c70069d), [`77585013d`](https://github.com/vercel/vercel/commit/77585013dec5fc406b8b7ea00918e49fdb8f10ec), [`c536a74bc`](https://github.com/vercel/vercel/commit/c536a74bc9e7188a87b292615fa88d6fc506b105), [`91f8763ed`](https://github.com/vercel/vercel/commit/91f8763edce672a3c05b6096db6084f1e6741384), [`7f8f5f865`](https://github.com/vercel/vercel/commit/7f8f5f86516934acb0c4b936ea601433c8d30c5c)]:
|
||||
- @vercel/next@4.0.17
|
||||
- @vercel/go@3.0.5
|
||||
- @vercel/node@3.0.15
|
||||
- @vercel/redwood@2.0.6
|
||||
- @vercel/remix-builder@2.0.16
|
||||
|
||||
## 33.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`67fa2f3dd`](https://github.com/vercel/vercel/commit/67fa2f3dd6a6d5a3504b7f9081e56deff7b36eab), [`7b0adf371`](https://github.com/vercel/vercel/commit/7b0adf371bae64d33ed0a1b966fc50b1f7c9639b)]:
|
||||
- @vercel/build-utils@7.4.1
|
||||
- @vercel/next@4.0.16
|
||||
- @vercel/static-build@2.0.16
|
||||
- @vercel/node@3.0.14
|
||||
|
||||
## 33.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- [cli] replace `--deprecated` with `--update-required` in `vc project ls` ([#10965](https://github.com/vercel/vercel/pull/10965))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix `vercel bisect` selecting too many deployments ([#10956](https://github.com/vercel/vercel/pull/10956))
|
||||
|
||||
- Updated dependencies [[`6a9002f22`](https://github.com/vercel/vercel/commit/6a9002f2296c5ccce4522c0fa9a8938c3d7a4849), [`4d63d9e95`](https://github.com/vercel/vercel/commit/4d63d9e954549d811063d259250d1865b7de2ba1)]:
|
||||
- @vercel/remix-builder@2.0.15
|
||||
- @vercel/build-utils@7.4.0
|
||||
- @vercel/static-build@2.0.15
|
||||
- @vercel/node@3.0.13
|
||||
|
||||
## 32.7.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [cli] Use new `deprecated` query param in projects api for `vc project ls --deprecated` ([#10938](https://github.com/vercel/vercel/pull/10938))
|
||||
|
||||
## 32.7.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [cli] double page limit for vc project ls --deprecated ([#10932](https://github.com/vercel/vercel/pull/10932))
|
||||
|
||||
- Updated dependencies [[`d09dd1794`](https://github.com/vercel/vercel/commit/d09dd1794b5ffa28c15d3ad2880b90db2f4c06f0)]:
|
||||
- @vercel/remix-builder@2.0.14
|
||||
|
||||
## 32.7.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vercel",
|
||||
"version": "32.7.0",
|
||||
"version": "33.5.0",
|
||||
"preferGlobal": true,
|
||||
"license": "Apache-2.0",
|
||||
"description": "The command-line interface for Vercel",
|
||||
@@ -31,17 +31,17 @@
|
||||
"node": ">= 16"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/build-utils": "7.3.0",
|
||||
"@vercel/build-utils": "7.6.0",
|
||||
"@vercel/fun": "1.1.0",
|
||||
"@vercel/go": "3.0.4",
|
||||
"@vercel/hydrogen": "1.0.1",
|
||||
"@vercel/next": "4.0.15",
|
||||
"@vercel/node": "3.0.12",
|
||||
"@vercel/python": "4.1.0",
|
||||
"@vercel/redwood": "2.0.5",
|
||||
"@vercel/remix-builder": "2.0.13",
|
||||
"@vercel/ruby": "2.0.4",
|
||||
"@vercel/static-build": "2.0.14",
|
||||
"@vercel/go": "3.0.5",
|
||||
"@vercel/hydrogen": "1.0.2",
|
||||
"@vercel/next": "4.1.1",
|
||||
"@vercel/node": "3.0.18",
|
||||
"@vercel/python": "4.1.1",
|
||||
"@vercel/redwood": "2.0.7",
|
||||
"@vercel/remix-builder": "2.0.19",
|
||||
"@vercel/ruby": "2.0.5",
|
||||
"@vercel/static-build": "2.3.0",
|
||||
"chokidar": "3.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -88,11 +88,11 @@
|
||||
"@types/yauzl-promise": "2.1.0",
|
||||
"@vercel-internals/constants": "1.0.4",
|
||||
"@vercel-internals/get-package-json": "1.0.0",
|
||||
"@vercel-internals/types": "1.0.17",
|
||||
"@vercel/client": "13.0.10",
|
||||
"@vercel-internals/types": "1.0.22",
|
||||
"@vercel/client": "13.1.2",
|
||||
"@vercel/error-utils": "2.0.2",
|
||||
"@vercel/frameworks": "2.0.5",
|
||||
"@vercel/fs-detectors": "5.1.5",
|
||||
"@vercel/frameworks": "2.0.6",
|
||||
"@vercel/fs-detectors": "5.1.6",
|
||||
"@vercel/routing-utils": "3.1.0",
|
||||
"ajv": "6.12.2",
|
||||
"alpha-sort": "2.0.1",
|
||||
|
||||
@@ -188,15 +188,18 @@ export default async function bisect(client: Client): Promise<number> {
|
||||
let newDeployments = chunk.deployments;
|
||||
|
||||
// If we have the "good" deployment in this chunk, then we're done
|
||||
let hasGood = false;
|
||||
for (let i = 0; i < newDeployments.length; i++) {
|
||||
if (newDeployments[i].url === good) {
|
||||
// grab all deployments up until the good one
|
||||
newDeployments = newDeployments.slice(0, i);
|
||||
hasGood = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
deployments = deployments.concat(newDeployments);
|
||||
if (hasGood) break;
|
||||
}
|
||||
|
||||
if (!deployments.length) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import fs from 'fs-extra';
|
||||
import fs, { readJSON } from 'fs-extra';
|
||||
import chalk from 'chalk';
|
||||
import dotenv from 'dotenv';
|
||||
import semver from 'semver';
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
Cron,
|
||||
validateNpmrc,
|
||||
Flag,
|
||||
VariantDefinition,
|
||||
} from '@vercel/build-utils';
|
||||
import {
|
||||
detectBuilders,
|
||||
@@ -71,6 +72,7 @@ import { setMonorepoDefaultSettings } from '../../util/build/monorepo';
|
||||
import { help } from '../help';
|
||||
import { buildCommand } from './command';
|
||||
import { scrubArgv } from '../../util/build/scrub-argv';
|
||||
import { cwd } from 'process';
|
||||
|
||||
type BuildResult = BuildResultV2 | BuildResultV3;
|
||||
|
||||
@@ -94,7 +96,9 @@ interface BuildOutputConfig {
|
||||
version: string;
|
||||
};
|
||||
crons?: Cron[];
|
||||
/** @deprecated Replaced by Variants. Remove once fully replaced. */
|
||||
flags?: Flag[];
|
||||
variants?: Record<string, VariantDefinition>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,6 +261,9 @@ export default async function main(client: Client): Promise<number> {
|
||||
if (project.settings.analyticsId) {
|
||||
envToUnset.add('VERCEL_ANALYTICS_ID');
|
||||
process.env.VERCEL_ANALYTICS_ID = project.settings.analyticsId;
|
||||
output.warn(
|
||||
'Vercel Speed Insights auto-injection is deprecated in favor of @vercel/speed-insights package. Learn more: https://vercel.link/upgrate-to-speed-insights-package'
|
||||
);
|
||||
}
|
||||
|
||||
// Some build processes use these env vars to platform detect Vercel
|
||||
@@ -432,29 +439,6 @@ async function doBuild(
|
||||
|
||||
const ops: Promise<Error | void>[] = [];
|
||||
|
||||
const dependencyMap = makeDepencyMap(pkg);
|
||||
const speedInsighsVersion = dependencyMap.get('@vercel/speed-insights');
|
||||
if (speedInsighsVersion) {
|
||||
if (process.env.VERCEL_ANALYTICS_ID) {
|
||||
output.warn(
|
||||
`The \`VERCEL_ANALYTICS_ID\` environment variable is deprecated and will be removed in a future release. Please remove it from your environment variables`
|
||||
);
|
||||
|
||||
delete process.env.VERCEL_ANALYTICS_ID;
|
||||
}
|
||||
buildsJson.features = {
|
||||
...(buildsJson.features ?? {}),
|
||||
speedInsightsVersion: speedInsighsVersion,
|
||||
};
|
||||
}
|
||||
const webAnalyticsVersion = dependencyMap.get('@vercel/analytics');
|
||||
if (webAnalyticsVersion) {
|
||||
buildsJson.features = {
|
||||
...(buildsJson.features ?? {}),
|
||||
webAnalyticsVersion: webAnalyticsVersion,
|
||||
};
|
||||
}
|
||||
|
||||
// Write the `detectedBuilders` result to output dir
|
||||
const buildsJsonBuilds = new Map<Builder, SerializedBuilder>(
|
||||
builds.map(build => {
|
||||
@@ -474,10 +458,9 @@ async function doBuild(
|
||||
];
|
||||
})
|
||||
);
|
||||
|
||||
buildsJson.builds = Array.from(buildsJsonBuilds.values());
|
||||
await fs.writeJSON(join(outputDir, 'builds.json'), buildsJson, {
|
||||
spaces: 2,
|
||||
});
|
||||
await writeBuildJson(buildsJson, outputDir);
|
||||
|
||||
// The `meta` config property is re-used for each Builder
|
||||
// invocation so that Builders can share state between
|
||||
@@ -573,6 +556,7 @@ async function doBuild(
|
||||
// Start flushing the file outputs to the filesystem asynchronously
|
||||
ops.push(
|
||||
writeBuildResult(
|
||||
repoRootPath,
|
||||
outputDir,
|
||||
buildResult,
|
||||
build,
|
||||
@@ -608,6 +592,33 @@ async function doBuild(
|
||||
}
|
||||
}
|
||||
|
||||
let needBuildsJsonOverride = false;
|
||||
const speedInsightsVersion = await readInstalledVersion(
|
||||
client,
|
||||
'@vercel/speed-insights'
|
||||
);
|
||||
if (speedInsightsVersion) {
|
||||
buildsJson.features = {
|
||||
...(buildsJson.features ?? {}),
|
||||
speedInsightsVersion,
|
||||
};
|
||||
needBuildsJsonOverride = true;
|
||||
}
|
||||
const webAnalyticsVersion = await readInstalledVersion(
|
||||
client,
|
||||
'@vercel/analytics'
|
||||
);
|
||||
if (webAnalyticsVersion) {
|
||||
buildsJson.features = {
|
||||
...(buildsJson.features ?? {}),
|
||||
webAnalyticsVersion,
|
||||
};
|
||||
needBuildsJsonOverride = true;
|
||||
}
|
||||
if (needBuildsJsonOverride) {
|
||||
await writeBuildJson(buildsJson, outputDir);
|
||||
}
|
||||
|
||||
// Merge existing `config.json` file into the one that will be produced
|
||||
const configPath = join(outputDir, 'config.json');
|
||||
const existingConfig = await readJSONFile<BuildOutputConfig>(configPath);
|
||||
@@ -670,10 +681,13 @@ async function doBuild(
|
||||
overrides: mergedOverrides,
|
||||
framework,
|
||||
crons: mergedCrons,
|
||||
/** @deprecated Replaced by Variants. Remove once fully replaced. */
|
||||
flags: mergedFlags,
|
||||
};
|
||||
await fs.writeJSON(join(outputDir, 'config.json'), config, { spaces: 2 });
|
||||
|
||||
await writeVariantsJson(client, buildResults.values(), outputDir);
|
||||
|
||||
const relOutputDir = relative(cwd, outputDir);
|
||||
output.print(
|
||||
`${prependEmoji(
|
||||
@@ -818,9 +832,69 @@ function mergeFlags(
|
||||
});
|
||||
}
|
||||
|
||||
function makeDepencyMap(pkg: PackageJson | null): Map<string, string> {
|
||||
return new Map([
|
||||
...Object.entries(pkg?.devDependencies ?? {}),
|
||||
...Object.entries(pkg?.dependencies ?? {}),
|
||||
]);
|
||||
/**
|
||||
* Takes the build output and writes all the variants into the `variants.json`
|
||||
* file. It'll skip variants that already exist.
|
||||
*/
|
||||
async function writeVariantsJson(
|
||||
{ output }: Client,
|
||||
buildResults: Iterable<BuildResult | BuildOutputConfig>,
|
||||
outputDir: string
|
||||
): Promise<void> {
|
||||
const variantsFilePath = join(outputDir, 'variants.json');
|
||||
|
||||
let hasVariants = true;
|
||||
|
||||
const variants = (await fs.readJSON(variantsFilePath).catch(error => {
|
||||
if (error.code === 'ENOENT') {
|
||||
hasVariants = false;
|
||||
return { definitions: {} };
|
||||
}
|
||||
|
||||
throw error;
|
||||
})) as { definitions: Record<string, VariantDefinition> };
|
||||
|
||||
for (const result of buildResults) {
|
||||
if (!('variants' in result) || !result.variants) continue;
|
||||
|
||||
for (const [key, defintion] of Object.entries(result.variants)) {
|
||||
if (result.variants[key]) {
|
||||
output.warn(
|
||||
`The variant "${key}" was found multiple times. Only its first occurrence will be considered.`
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
hasVariants = true;
|
||||
variants.definitions[key] = defintion;
|
||||
}
|
||||
}
|
||||
|
||||
// Only create the file when there are variants to write,
|
||||
// or when the file already exists.
|
||||
if (hasVariants) {
|
||||
await fs.writeJSON(variantsFilePath, variants, { spaces: 2 });
|
||||
}
|
||||
}
|
||||
|
||||
async function writeBuildJson(buildsJson: BuildsManifest, outputDir: string) {
|
||||
await fs.writeJSON(join(outputDir, 'builds.json'), buildsJson, { spaces: 2 });
|
||||
}
|
||||
|
||||
export async function readInstalledVersion(
|
||||
{ output }: Client,
|
||||
pkgName: string
|
||||
): Promise<string | undefined> {
|
||||
try {
|
||||
const descriptorPath = require.resolve(`${pkgName}/package.json`, {
|
||||
paths: [cwd()],
|
||||
});
|
||||
const descriptor = await readJSON(descriptorPath);
|
||||
return descriptor?.version;
|
||||
} catch (err) {
|
||||
output.debug(
|
||||
`Package ${pkgName} is not installed (failed to read its package.json: ${err})`
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -112,7 +112,8 @@ export const deployCommand: Command = {
|
||||
shorthand: null,
|
||||
type: 'boolean',
|
||||
deprecated: false,
|
||||
description: undefined,
|
||||
description:
|
||||
'Disable the automatic promotion (aliasing) of the relevant domains to a new production deployment. You can use `vc promote` to complete the domain-assignment process later',
|
||||
multi: false,
|
||||
},
|
||||
{
|
||||
|
||||
5
packages/cli/src/commands/env/add.ts
vendored
5
packages/cli/src/commands/env/add.ts
vendored
@@ -19,6 +19,7 @@ import { isAPIError } from '../../util/errors-ts';
|
||||
|
||||
type Options = {
|
||||
'--debug': boolean;
|
||||
'--sensitive': boolean;
|
||||
};
|
||||
|
||||
export default async function add(
|
||||
@@ -144,6 +145,8 @@ export default async function add(
|
||||
envGitBranch = inputValue || '';
|
||||
}
|
||||
|
||||
const type = opts['--sensitive'] ? 'sensitive' : 'encrypted';
|
||||
|
||||
const addStamp = stamp();
|
||||
try {
|
||||
output.spinner('Saving');
|
||||
@@ -151,7 +154,7 @@ export default async function add(
|
||||
output,
|
||||
client,
|
||||
project.id,
|
||||
'encrypted',
|
||||
type,
|
||||
envName,
|
||||
envValue,
|
||||
envTargets,
|
||||
|
||||
15
packages/cli/src/commands/env/command.ts
vendored
15
packages/cli/src/commands/env/command.ts
vendored
@@ -34,7 +34,16 @@ export const envCommand: Command = {
|
||||
required: false,
|
||||
},
|
||||
],
|
||||
options: [],
|
||||
options: [
|
||||
{
|
||||
name: 'sensitive',
|
||||
description: 'Add a sensitive Environment Variable',
|
||||
shorthand: null,
|
||||
type: 'string',
|
||||
deprecated: false,
|
||||
multi: false,
|
||||
},
|
||||
],
|
||||
examples: [],
|
||||
},
|
||||
{
|
||||
@@ -117,6 +126,10 @@ export const envCommand: Command = {
|
||||
`${packageName} env add DB_PASS production`,
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Add a sensitive Environment Variable',
|
||||
value: `${packageName} env add API_TOKEN --sensitive`,
|
||||
},
|
||||
{
|
||||
name: 'Add a new variable for a specific Environment and Git Branch',
|
||||
value: [
|
||||
|
||||
1
packages/cli/src/commands/env/index.ts
vendored
1
packages/cli/src/commands/env/index.ts
vendored
@@ -34,6 +34,7 @@ export default async function main(client: Client) {
|
||||
'-y': '--yes',
|
||||
'--environment': String,
|
||||
'--git-branch': String,
|
||||
'--sensitive': Boolean,
|
||||
});
|
||||
} catch (error) {
|
||||
handleError(error);
|
||||
|
||||
@@ -17,9 +17,9 @@ export const projectCommand: Command = {
|
||||
arguments: [],
|
||||
options: [
|
||||
{
|
||||
name: 'deprecated',
|
||||
description: 'A list of projects affected by a deprecation',
|
||||
argument: 'deprecated',
|
||||
name: 'update-required',
|
||||
description: 'A list of projects affected by an upcoming deprecation',
|
||||
argument: 'update-required',
|
||||
shorthand: null,
|
||||
type: 'boolean',
|
||||
deprecated: false,
|
||||
|
||||
@@ -23,7 +23,7 @@ export default async function main(client: Client) {
|
||||
argv = getArgs(client.argv.slice(2), {
|
||||
'--next': Number,
|
||||
'-N': '--next',
|
||||
'--deprecated': Boolean,
|
||||
'--update-required': Boolean,
|
||||
});
|
||||
} catch (error) {
|
||||
handleError(error);
|
||||
|
||||
@@ -28,15 +28,18 @@ export default async function list(
|
||||
|
||||
output.spinner(`Fetching projects in ${chalk.bold(contextName)}`);
|
||||
|
||||
let projectsUrl = '/v4/projects/?limit=20';
|
||||
let projectsUrl = `/v4/projects/?limit=20`;
|
||||
|
||||
const deprecated = argv['--update-required'] || false;
|
||||
if (deprecated) {
|
||||
projectsUrl += `&deprecated=${deprecated}`;
|
||||
}
|
||||
|
||||
const next = argv['--next'] || false;
|
||||
if (next) {
|
||||
projectsUrl += `&until=${next}`;
|
||||
}
|
||||
|
||||
const deprecated = argv['--deprecated'] || false;
|
||||
|
||||
let {
|
||||
projects: projectList,
|
||||
pagination,
|
||||
@@ -52,24 +55,21 @@ export default async function list(
|
||||
const elapsed = ms(Date.now() - start);
|
||||
|
||||
if (deprecated) {
|
||||
const upcomingDeprecationVersions = NODE_VERSIONS.filter(
|
||||
nodeVersion =>
|
||||
const upcomingDeprecationVersionsList = [];
|
||||
|
||||
for (const nodeVersion of NODE_VERSIONS) {
|
||||
if (
|
||||
nodeVersion.discontinueDate &&
|
||||
nodeVersion.discontinueDate.valueOf() > Date.now()
|
||||
);
|
||||
const upcomingDeprecationVersionsList = upcomingDeprecationVersions.map(
|
||||
nodeVersion => nodeVersion.range
|
||||
);
|
||||
projectList = projectList.filter(
|
||||
project =>
|
||||
project.nodeVersion &&
|
||||
upcomingDeprecationVersionsList.includes(project.nodeVersion)
|
||||
);
|
||||
) {
|
||||
upcomingDeprecationVersionsList.push(nodeVersion.range);
|
||||
}
|
||||
}
|
||||
|
||||
output.warn(
|
||||
`The following Node.js versions will be deprecated soon: ${upcomingDeprecationVersionsList.join(
|
||||
', '
|
||||
)}. Upgrade your projects immediately.`
|
||||
)}. Please upgrade your projects immediately.`
|
||||
);
|
||||
output.log(
|
||||
`For more information visit: https://vercel.com/docs/functions/serverless-functions/runtimes/node-js#node.js-version`
|
||||
|
||||
@@ -465,6 +465,15 @@ const main = async () => {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (isErrnoException(err) && err.code === 'rate_limited') {
|
||||
output.prettyError({
|
||||
message:
|
||||
'Rate limited. Too many requests to the same endpoint: /teams',
|
||||
});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
console.error(error('Not able to load teams'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
BuildResultV2,
|
||||
BuildResultV3,
|
||||
File,
|
||||
Files,
|
||||
FileFsRef,
|
||||
BuilderV2,
|
||||
BuilderV3,
|
||||
@@ -45,6 +46,7 @@ interface FunctionConfiguration {
|
||||
}
|
||||
|
||||
export async function writeBuildResult(
|
||||
repoRootPath: string,
|
||||
outputDir: string,
|
||||
buildResult: BuildResultV2 | BuildResultV3,
|
||||
build: Builder,
|
||||
@@ -55,6 +57,7 @@ export async function writeBuildResult(
|
||||
const { version } = builder;
|
||||
if (typeof version !== 'number' || version === 2) {
|
||||
return writeBuildResultV2(
|
||||
repoRootPath,
|
||||
outputDir,
|
||||
buildResult as BuildResultV2,
|
||||
build,
|
||||
@@ -62,6 +65,7 @@ export async function writeBuildResult(
|
||||
);
|
||||
} else if (version === 3) {
|
||||
return writeBuildResultV3(
|
||||
repoRootPath,
|
||||
outputDir,
|
||||
buildResult as BuildResultV3,
|
||||
build,
|
||||
@@ -107,6 +111,7 @@ function stripDuplicateSlashes(path: string): string {
|
||||
* the filesystem.
|
||||
*/
|
||||
async function writeBuildResultV2(
|
||||
repoRootPath: string,
|
||||
outputDir: string,
|
||||
buildResult: BuildResultV2,
|
||||
build: Builder,
|
||||
@@ -129,13 +134,20 @@ async function writeBuildResultV2(
|
||||
);
|
||||
}
|
||||
|
||||
const lambdas = new Map<Lambda, string>();
|
||||
const existingFunctions = new Map<Lambda | EdgeFunction, string>();
|
||||
const overrides: Record<string, PathOverride> = {};
|
||||
|
||||
for (const [path, output] of Object.entries(buildResult.output)) {
|
||||
const normalizedPath = stripDuplicateSlashes(path);
|
||||
if (isLambda(output)) {
|
||||
await writeLambda(outputDir, output, normalizedPath, undefined, lambdas);
|
||||
await writeLambda(
|
||||
repoRootPath,
|
||||
outputDir,
|
||||
output,
|
||||
normalizedPath,
|
||||
undefined,
|
||||
existingFunctions
|
||||
);
|
||||
} else if (isPrerender(output)) {
|
||||
if (!output.lambda) {
|
||||
throw new Error(
|
||||
@@ -144,11 +156,12 @@ async function writeBuildResultV2(
|
||||
}
|
||||
|
||||
await writeLambda(
|
||||
repoRootPath,
|
||||
outputDir,
|
||||
output.lambda,
|
||||
normalizedPath,
|
||||
undefined,
|
||||
lambdas
|
||||
existingFunctions
|
||||
);
|
||||
|
||||
// Write the fallback file alongside the Lambda directory
|
||||
@@ -203,7 +216,13 @@ async function writeBuildResultV2(
|
||||
vercelConfig?.cleanUrls
|
||||
);
|
||||
} else if (isEdgeFunction(output)) {
|
||||
await writeEdgeFunction(outputDir, output, normalizedPath);
|
||||
await writeEdgeFunction(
|
||||
repoRootPath,
|
||||
outputDir,
|
||||
output,
|
||||
normalizedPath,
|
||||
existingFunctions
|
||||
);
|
||||
} else {
|
||||
throw new Error(
|
||||
`Unsupported output type: "${
|
||||
@@ -220,6 +239,7 @@ async function writeBuildResultV2(
|
||||
* the filesystem.
|
||||
*/
|
||||
async function writeBuildResultV3(
|
||||
repoRootPath: string,
|
||||
outputDir: string,
|
||||
buildResult: BuildResultV3,
|
||||
build: Builder,
|
||||
@@ -243,9 +263,15 @@ async function writeBuildResultV3(
|
||||
build.config?.zeroConfig ? src.substring(0, src.length - ext.length) : src
|
||||
);
|
||||
if (isLambda(output)) {
|
||||
await writeLambda(outputDir, output, path, functionConfiguration);
|
||||
await writeLambda(
|
||||
repoRootPath,
|
||||
outputDir,
|
||||
output,
|
||||
path,
|
||||
functionConfiguration
|
||||
);
|
||||
} else if (isEdgeFunction(output)) {
|
||||
await writeEdgeFunction(outputDir, output, path);
|
||||
await writeEdgeFunction(repoRootPath, outputDir, output, path);
|
||||
} else {
|
||||
throw new Error(
|
||||
`Unsupported output type: "${(output as any).type}" for ${build.src}`
|
||||
@@ -315,27 +341,79 @@ async function writeStaticFile(
|
||||
await downloadFile(file, dest);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the `fn` Lambda or Edge function 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.
|
||||
*
|
||||
* @param outputPath The path of the `.vercel/output` directory
|
||||
* @param dest The path of destination function's `.func` directory
|
||||
* @param fn The Lambda or EdgeFunction instance to create the symlink for
|
||||
* @param existingFunctions Map of `Lambda`/`EdgeFunction` instances that have previously been written
|
||||
*/
|
||||
async function writeFunctionSymlink(
|
||||
outputDir: string,
|
||||
dest: string,
|
||||
fn: Lambda | EdgeFunction,
|
||||
existingFunctions: Map<Lambda | EdgeFunction, string>
|
||||
) {
|
||||
const existingPath = existingFunctions.get(fn);
|
||||
|
||||
// Function has not been written to the filesystem, so bail
|
||||
if (!existingPath) return false;
|
||||
|
||||
const destDir = dirname(dest);
|
||||
const targetDest = join(outputDir, 'functions', `${existingPath}.func`);
|
||||
const target = relative(destDir, targetDest);
|
||||
await fs.mkdirp(destDir);
|
||||
await fs.symlink(target, dest);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the `EdgeFunction` instance to the file system.
|
||||
*
|
||||
* @param outputPath The path of the `.vercel/output` directory
|
||||
* @param edgeFunction The `EdgeFunction` instance
|
||||
* @param path The URL path where the `EdgeFunction` can be accessed from
|
||||
* @param existingFunctions (optional) Map of `Lambda`/`EdgeFunction` instances that have previously been written
|
||||
*/
|
||||
async function writeEdgeFunction(
|
||||
repoRootPath: string,
|
||||
outputDir: string,
|
||||
edgeFunction: EdgeFunction,
|
||||
path: string
|
||||
path: string,
|
||||
existingFunctions?: Map<Lambda | EdgeFunction, string>
|
||||
) {
|
||||
const dest = join(outputDir, 'functions', `${path}.func`);
|
||||
|
||||
if (existingFunctions) {
|
||||
if (
|
||||
await writeFunctionSymlink(
|
||||
outputDir,
|
||||
dest,
|
||||
edgeFunction,
|
||||
existingFunctions
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
existingFunctions.set(edgeFunction, path);
|
||||
}
|
||||
|
||||
await fs.mkdirp(dest);
|
||||
const ops: Promise<any>[] = [];
|
||||
ops.push(download(edgeFunction.files, dest));
|
||||
const { files, filePathMap } = filesWithoutFsRefs(
|
||||
edgeFunction.files,
|
||||
repoRootPath
|
||||
);
|
||||
ops.push(download(files, dest));
|
||||
|
||||
const config = {
|
||||
runtime: 'edge',
|
||||
...edgeFunction,
|
||||
entrypoint: normalizePath(edgeFunction.entrypoint),
|
||||
filePathMap,
|
||||
files: undefined,
|
||||
type: undefined,
|
||||
};
|
||||
@@ -351,42 +429,39 @@ async function writeEdgeFunction(
|
||||
/**
|
||||
* Writes the file references from the `Lambda` instance to the file system.
|
||||
*
|
||||
* @param outputPath The path of the `.vercel/output` directory
|
||||
* @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
|
||||
* @param functionConfiguration (optional) Extra configuration to apply to the function's `.vc-config.json` file
|
||||
* @param existingFunctions (optional) Map of `Lambda`/`EdgeFunction` instances that have previously been written
|
||||
*/
|
||||
async function writeLambda(
|
||||
repoRootPath: string,
|
||||
outputDir: string,
|
||||
lambda: Lambda,
|
||||
path: string,
|
||||
functionConfiguration?: FunctionConfiguration,
|
||||
lambdas?: Map<Lambda, string>
|
||||
existingFunctions?: Map<Lambda | EdgeFunction, string>
|
||||
) {
|
||||
const dest = join(outputDir, '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(
|
||||
outputDir,
|
||||
'functions',
|
||||
`${existingLambdaPath}.func`
|
||||
);
|
||||
const target = relative(destDir, targetDest);
|
||||
await fs.mkdirp(destDir);
|
||||
await fs.symlink(target, dest);
|
||||
return;
|
||||
if (existingFunctions) {
|
||||
if (
|
||||
await writeFunctionSymlink(outputDir, dest, lambda, existingFunctions)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
existingFunctions.set(lambda, path);
|
||||
}
|
||||
lambdas?.set(lambda, path);
|
||||
|
||||
await fs.mkdirp(dest);
|
||||
const ops: Promise<any>[] = [];
|
||||
let filePathMap: Record<string, string> | undefined;
|
||||
if (lambda.files) {
|
||||
// `files` is defined
|
||||
ops.push(download(lambda.files, dest));
|
||||
const f = filesWithoutFsRefs(lambda.files, repoRootPath);
|
||||
filePathMap = f.filePathMap;
|
||||
ops.push(download(f.files, dest));
|
||||
} else if (lambda.zipBuffer) {
|
||||
// Builders that use the deprecated `createLambda()` might only have `zipBuffer`
|
||||
ops.push(unzip(lambda.zipBuffer, dest));
|
||||
@@ -402,6 +477,7 @@ async function writeLambda(
|
||||
handler: normalizePath(lambda.handler),
|
||||
memory,
|
||||
maxDuration,
|
||||
filePathMap,
|
||||
type: undefined,
|
||||
files: undefined,
|
||||
zipBuffer: undefined,
|
||||
@@ -509,3 +585,25 @@ export async function* findDirs(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the `FileFsRef` instances from the `Files` object
|
||||
* and returns them in a JSON serializable map of repo root
|
||||
* relative paths to Lambda destination paths.
|
||||
*/
|
||||
function filesWithoutFsRefs(
|
||||
files: Files,
|
||||
repoRootPath: string
|
||||
): { files: Files; filePathMap?: Record<string, string> } {
|
||||
let filePathMap: Record<string, string> | undefined;
|
||||
const out: Files = {};
|
||||
for (const [path, file] of Object.entries(files)) {
|
||||
if (file.type === 'FileFsRef') {
|
||||
if (!filePathMap) filePathMap = {};
|
||||
filePathMap[path] = relative(repoRootPath, file.fsPath);
|
||||
} else {
|
||||
out[path] = file;
|
||||
}
|
||||
}
|
||||
return { files: out, filePathMap };
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ export const defaultGlobalConfig: GlobalConfig = {
|
||||
'// Note':
|
||||
'This is your Vercel config file. For more information see the global configuration documentation.',
|
||||
'// Docs':
|
||||
'https://vercel.com/docs/project-configuration#global-configuration/config-json',
|
||||
'https://vercel.com/docs/projects/project-configuration/global-configuration#config.json',
|
||||
collectMetrics: true,
|
||||
};
|
||||
|
||||
export const defaultAuthConfig: AuthConfig = {
|
||||
'// Note': 'This is your Vercel credentials file. DO NOT SHARE!',
|
||||
'// Docs':
|
||||
'https://vercel.com/docs/project-configuration#global-configuration/auth-json',
|
||||
'https://vercel.com/docs/projects/project-configuration/global-configuration#auth.json',
|
||||
};
|
||||
|
||||
@@ -185,7 +185,7 @@ export default async function processDeployment({
|
||||
|
||||
printInspectUrl(output, deployment.inspectorUrl, deployStamp);
|
||||
|
||||
const isProdDeployment = requestBody.target === 'production';
|
||||
const isProdDeployment = deployment.target === 'production';
|
||||
const previewUrl = `https://${deployment.url}`;
|
||||
|
||||
output.print(
|
||||
|
||||
@@ -42,6 +42,18 @@ async function processMessage(message) {
|
||||
// structure to JSON" errors, so delete the property...
|
||||
delete result.childProcesses;
|
||||
|
||||
if (builder.version === 3) {
|
||||
if (result.output.type === 'Lambda') {
|
||||
result.output.zipBuffer = await result.output.createZip();
|
||||
}
|
||||
} else {
|
||||
for (const output of Object.values(result.output)) {
|
||||
if (output.type === 'Lambda') {
|
||||
output.zipBuffer = await output.createZip();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
process.send({ type: 'buildResult', result });
|
||||
}
|
||||
|
||||
|
||||
@@ -361,8 +361,10 @@ export async function executeBuild(
|
||||
await oldAsset.fn.destroy();
|
||||
}
|
||||
|
||||
const ZipFile = asset.zipBuffer || (await asset.createZip());
|
||||
|
||||
asset.fn = await createFunction({
|
||||
Code: { ZipFile: asset.zipBuffer },
|
||||
Code: { ZipFile },
|
||||
Handler: asset.handler,
|
||||
Runtime: asset.runtime,
|
||||
MemorySize: asset.memory || 3008,
|
||||
|
||||
@@ -158,7 +158,10 @@ export default class DevServer {
|
||||
private podId: string;
|
||||
private devProcess?: ChildProcess;
|
||||
private devProcessOrigin?: string;
|
||||
private devServerPids: Set<number>;
|
||||
private shutdownCallbacks: Map<
|
||||
number /* PID */,
|
||||
undefined | (() => Promise<void>)
|
||||
>;
|
||||
private originalProjectSettings?: ProjectSettings;
|
||||
private projectSettings?: ProjectSettings;
|
||||
|
||||
@@ -211,7 +214,7 @@ export default class DevServer {
|
||||
this.filter = path => Boolean(path);
|
||||
this.podId = Math.random().toString(32).slice(-5);
|
||||
|
||||
this.devServerPids = new Set();
|
||||
this.shutdownCallbacks = new Map();
|
||||
}
|
||||
|
||||
async exit(code = 1) {
|
||||
@@ -1006,7 +1009,7 @@ export default class DevServer {
|
||||
ops.push(this.watcher.close());
|
||||
}
|
||||
|
||||
for (const pid of this.devServerPids) {
|
||||
for (const pid of this.shutdownCallbacks.keys()) {
|
||||
ops.push(this.killBuilderDevServer(pid));
|
||||
}
|
||||
|
||||
@@ -1024,7 +1027,15 @@ export default class DevServer {
|
||||
async killBuilderDevServer(pid: number) {
|
||||
const { debug } = this.output;
|
||||
debug(`Killing builder dev server with PID ${pid}`);
|
||||
this.devServerPids.delete(pid);
|
||||
const shutdownCb = this.shutdownCallbacks.get(pid);
|
||||
this.shutdownCallbacks.delete(pid);
|
||||
|
||||
if (shutdownCb) {
|
||||
debug(`Running shutdown callback for PID ${pid}`);
|
||||
await shutdownCb();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await treeKill(pid);
|
||||
debug(`Killed builder dev server with PID ${pid}`);
|
||||
@@ -1432,9 +1443,9 @@ export default class DevServer {
|
||||
}
|
||||
|
||||
if (startMiddlewareResult) {
|
||||
const { port, pid } = startMiddlewareResult;
|
||||
const { port, pid, shutdown } = startMiddlewareResult;
|
||||
middlewarePid = pid;
|
||||
this.devServerPids.add(pid);
|
||||
this.shutdownCallbacks.set(pid, shutdown);
|
||||
|
||||
const middlewareReqHeaders = nodeHeadersToFetchHeaders(req.headers);
|
||||
|
||||
@@ -1899,8 +1910,8 @@ export default class DevServer {
|
||||
// is also included in the request ID. So use the same `dev1` fake region.
|
||||
requestId = generateRequestId(this.podId, true);
|
||||
|
||||
const { port, pid } = devServerResult;
|
||||
this.devServerPids.add(pid);
|
||||
const { port, pid, shutdown } = devServerResult;
|
||||
this.shutdownCallbacks.set(pid, shutdown);
|
||||
|
||||
res.once('close', () => {
|
||||
this.killBuilderDevServer(pid);
|
||||
|
||||
@@ -21,7 +21,7 @@ export async function execExtension(
|
||||
args: string[],
|
||||
cwd: string
|
||||
): Promise<number> {
|
||||
const { debug } = client.output;
|
||||
const { debug, log } = client.output;
|
||||
const extensionCommand = `vercel-${name}`;
|
||||
|
||||
const { packageJsonPath, lockfilePath } = await scanParentDirs(cwd);
|
||||
@@ -76,7 +76,7 @@ export async function execExtension(
|
||||
proxy.close();
|
||||
|
||||
if (result instanceof Error) {
|
||||
debug(`error running extension: ${result.message}`);
|
||||
log(`Error running extension ${extensionCommand}: ${result.message}`);
|
||||
}
|
||||
|
||||
return result.exitCode;
|
||||
|
||||
1
packages/cli/test/fixtures/unit/commands/build/functions-symlink/.vercel/builders/.gitignore
vendored
Normal file
1
packages/cli/test/fixtures/unit/commands/build/functions-symlink/.vercel/builders/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!node_modules
|
||||
21
packages/cli/test/fixtures/unit/commands/build/functions-symlink/.vercel/builders/node_modules/functions-symlink/main.js
generated
vendored
Normal file
21
packages/cli/test/fixtures/unit/commands/build/functions-symlink/.vercel/builders/node_modules/functions-symlink/main.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
const { Lambda, EdgeFunction } = require('@vercel/build-utils');
|
||||
|
||||
exports.build = async () => {
|
||||
const lambda = new Lambda({
|
||||
files: {},
|
||||
runtime: 'provided',
|
||||
handler: 'example.js'
|
||||
});
|
||||
const edge = new EdgeFunction({
|
||||
files: {},
|
||||
deploymentTarget: 'v8-worker',
|
||||
entrypoint: 'example.js'
|
||||
});
|
||||
const output = {
|
||||
lambda,
|
||||
lambda2: lambda,
|
||||
edge,
|
||||
edge2: edge
|
||||
};
|
||||
return { output };
|
||||
};
|
||||
6
packages/cli/test/fixtures/unit/commands/build/functions-symlink/.vercel/builders/node_modules/functions-symlink/package.json
generated
vendored
Normal file
6
packages/cli/test/fixtures/unit/commands/build/functions-symlink/.vercel/builders/node_modules/functions-symlink/package.json
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "functions-symlink",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"main": "main.js"
|
||||
}
|
||||
7
packages/cli/test/fixtures/unit/commands/build/functions-symlink/.vercel/project.json
vendored
Normal file
7
packages/cli/test/fixtures/unit/commands/build/functions-symlink/.vercel/project.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"orgId": ".",
|
||||
"projectId": ".",
|
||||
"settings": {
|
||||
"framework": null
|
||||
}
|
||||
}
|
||||
4
packages/cli/test/fixtures/unit/commands/build/functions-symlink/package.json
vendored
Normal file
4
packages/cli/test/fixtures/unit/commands/build/functions-symlink/package.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "functions-symlink-test",
|
||||
"private": true
|
||||
}
|
||||
3
packages/cli/test/fixtures/unit/commands/build/functions-symlink/vercel.json
vendored
Normal file
3
packages/cli/test/fixtures/unit/commands/build/functions-symlink/vercel.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"builds": [{ "src": "package.json", "use": "functions-symlink@0.0.0" }]
|
||||
}
|
||||
@@ -382,6 +382,9 @@ module.exports = async function prepare(session, binaryPath, tmpFixturesDir) {
|
||||
'index.html': 'Hello',
|
||||
'vercel.json': '{"builds":[{"src":"*.html","use":"@vercel/static"}]}',
|
||||
},
|
||||
'project-sensitive-env-vars': {
|
||||
'package.json': '{}',
|
||||
},
|
||||
'dev-proxy-headers-and-env': {
|
||||
'package.json': JSON.stringify({}),
|
||||
'server.js': `require('http').createServer((req, res) => {
|
||||
@@ -421,7 +424,6 @@ module.exports = async function prepare(session, binaryPath, tmpFixturesDir) {
|
||||
projectId: '.',
|
||||
settings: {
|
||||
framework: null,
|
||||
installCommand: 'echo "skipping install"',
|
||||
},
|
||||
}),
|
||||
'package.json': JSON.stringify({
|
||||
@@ -429,7 +431,22 @@ module.exports = async function prepare(session, binaryPath, tmpFixturesDir) {
|
||||
build: 'mkdir -p public && echo hi > public/index.txt',
|
||||
},
|
||||
dependencies: {
|
||||
'@vercel/speed-insights': '0.0.1',
|
||||
'@vercel/speed-insights': '0.0.4',
|
||||
},
|
||||
}),
|
||||
},
|
||||
'vc-build-indirect-web-analytics': {
|
||||
'.vercel/project.json': JSON.stringify({
|
||||
orgId: '.',
|
||||
projectId: '.',
|
||||
settings: {
|
||||
framework: null,
|
||||
installCommand: 'yarn add @vercel/analytics@1.1.1',
|
||||
},
|
||||
}),
|
||||
'package.json': JSON.stringify({
|
||||
scripts: {
|
||||
build: 'mkdir -p public && echo hi > public/index.txt',
|
||||
},
|
||||
}),
|
||||
},
|
||||
@@ -439,7 +456,6 @@ module.exports = async function prepare(session, binaryPath, tmpFixturesDir) {
|
||||
projectId: '.',
|
||||
settings: {
|
||||
framework: null,
|
||||
installCommand: 'echo "skipping install"',
|
||||
},
|
||||
}),
|
||||
'package.json': JSON.stringify({
|
||||
|
||||
85
packages/cli/test/integration-2.test.ts
vendored
85
packages/cli/test/integration-2.test.ts
vendored
@@ -681,6 +681,53 @@ test('vercel env with unknown `VERCEL_ORG_ID` or `VERCEL_PROJECT_ID` should erro
|
||||
expect(output.stderr).toContain('Project not found');
|
||||
});
|
||||
|
||||
test('add a sensitive env var', async () => {
|
||||
const dir = await setupE2EFixture('project-sensitive-env-vars');
|
||||
const projectName = `project-sensitive-env-vars-${
|
||||
Math.random().toString(36).split('.')[1]
|
||||
}`;
|
||||
|
||||
// remove previously linked project if it exists
|
||||
await remove(path.join(dir, '.vercel'));
|
||||
|
||||
const vc = execCli(binaryPath, ['link'], {
|
||||
cwd: dir,
|
||||
env: {
|
||||
FORCE_TTY: '1',
|
||||
},
|
||||
});
|
||||
|
||||
await setupProject(vc, projectName, {
|
||||
buildCommand: `mkdir -p o && echo '<h1>custom hello</h1>' > o/index.html`,
|
||||
outputDirectory: 'o',
|
||||
});
|
||||
|
||||
await vc;
|
||||
|
||||
const link = require(path.join(dir, '.vercel/project.json'));
|
||||
|
||||
const addEnvCommand = execCli(
|
||||
binaryPath,
|
||||
['env', 'add', 'envVarName', 'production', '--sensitive'],
|
||||
{
|
||||
env: {
|
||||
VERCEL_ORG_ID: link.orgId,
|
||||
VERCEL_PROJECT_ID: link.projectId,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
await waitForPrompt(addEnvCommand, /What’s the value of [^?]+\?/);
|
||||
addEnvCommand.stdin?.write('test\n');
|
||||
|
||||
const output = await addEnvCommand;
|
||||
|
||||
expect(output.exitCode, formatOutput(output)).toBe(0);
|
||||
expect(output.stderr).toContain(
|
||||
'Added Environment Variable envVarName to Project'
|
||||
);
|
||||
});
|
||||
|
||||
test('whoami with `VERCEL_ORG_ID` should favor `--scope` and should error', async () => {
|
||||
if (!token) {
|
||||
throw new Error('Shared state "token" not set.');
|
||||
@@ -750,7 +797,7 @@ test('deploys with only vercel.json and README.md', async () => {
|
||||
|
||||
// assert timing order of showing URLs vs status updates
|
||||
expect(stderr).toMatch(
|
||||
/Inspect.*\nPreview.*\nQueued.*\nBuilding.*\nCompleting/
|
||||
/Inspect.*\nProduction.*\nQueued.*\nBuilding.*\nCompleting/
|
||||
);
|
||||
|
||||
const { host } = new URL(stdout);
|
||||
@@ -857,7 +904,7 @@ test('deploy pnpm twice using pnp and symlink=false', async () => {
|
||||
page = await fetch(stdout);
|
||||
text = await page.text();
|
||||
|
||||
expect(text).toBe('cache exists\n');
|
||||
expect(text).toContain('cache exists\n');
|
||||
});
|
||||
|
||||
test('reject deploying with wrong team .vercel config', async () => {
|
||||
@@ -1168,23 +1215,25 @@ test('[vc build] should build project with `@vercel/static-build`', async () =>
|
||||
});
|
||||
|
||||
test('[vc build] should build project with `@vercel/speed-insights`', async () => {
|
||||
try {
|
||||
process.env.VERCEL_ANALYTICS_ID = '123';
|
||||
const directory = await setupE2EFixture('vc-build-speed-insights');
|
||||
const output = await execCli(binaryPath, ['build'], { cwd: directory });
|
||||
expect(output.exitCode, formatOutput(output)).toBe(0);
|
||||
expect(output.stderr).toContain('Build Completed in .vercel/output');
|
||||
const builds = await fs.readJSON(
|
||||
path.join(directory, '.vercel/output/builds.json')
|
||||
);
|
||||
expect(builds?.features?.speedInsightsVersion).toEqual('0.0.4');
|
||||
});
|
||||
|
||||
const directory = await setupE2EFixture('vc-build-speed-insights');
|
||||
const output = await execCli(binaryPath, ['build'], { cwd: directory });
|
||||
expect(output.exitCode, formatOutput(output)).toBe(0);
|
||||
expect(output.stderr).toContain('Build Completed in .vercel/output');
|
||||
expect(output.stderr).toContain(
|
||||
'The `VERCEL_ANALYTICS_ID` environment variable is deprecated and will be removed in a future release. Please remove it from your environment variables'
|
||||
);
|
||||
const builds = await fs.readJSON(
|
||||
path.join(directory, '.vercel/output/builds.json')
|
||||
);
|
||||
expect(builds?.features?.speedInsightsVersion).toEqual('0.0.1');
|
||||
} finally {
|
||||
delete process.env.VERCEL_ANALYTICS_ID;
|
||||
}
|
||||
test('[vc build] should build project with an indirect dependency to `@vercel/analytics`', async () => {
|
||||
const directory = await setupE2EFixture('vc-build-indirect-web-analytics');
|
||||
const output = await execCli(binaryPath, ['build'], { cwd: directory });
|
||||
expect(output.exitCode, formatOutput(output)).toBe(0);
|
||||
expect(output.stderr).toContain('Build Completed in .vercel/output');
|
||||
const builds = await fs.readJSON(
|
||||
path.join(directory, '.vercel/output/builds.json')
|
||||
);
|
||||
expect(builds?.features?.webAnalyticsVersion).toEqual('1.1.1');
|
||||
});
|
||||
|
||||
test('[vc build] should build project with `@vercel/analytics`', async () => {
|
||||
|
||||
@@ -88,6 +88,26 @@ exports[`help command help output snapshots column width 40 1`] = `
|
||||
the
|
||||
deploym…
|
||||
on
|
||||
--skip-domain Disable
|
||||
the
|
||||
automat…
|
||||
promoti…
|
||||
(aliasi…
|
||||
of the
|
||||
relevant
|
||||
domains
|
||||
to a new
|
||||
product…
|
||||
deploym…
|
||||
You can
|
||||
use \`vc
|
||||
promote\`
|
||||
to
|
||||
complete
|
||||
the
|
||||
domain-…
|
||||
process
|
||||
later
|
||||
--with-cache Retain
|
||||
build
|
||||
cache
|
||||
@@ -192,6 +212,10 @@ exports[`help command help output snapshots column width 80 1`] = `
|
||||
--prod Create a production deployment
|
||||
-p, --public Deployment is public (\`/_src\`) is exposed)
|
||||
--regions Set default regions to enable the deployment on
|
||||
--skip-domain Disable the automatic promotion (aliasing) of
|
||||
the relevant domains to a new production
|
||||
deployment. You can use \`vc promote\` to complete
|
||||
the domain-assignment process later
|
||||
--with-cache Retain build cache when using "--force"
|
||||
-y, --yes Use default options to skip all prompts
|
||||
|
||||
@@ -255,6 +279,8 @@ exports[`help command help output snapshots column width 120 1`] = `
|
||||
--prod Create a production deployment
|
||||
-p, --public Deployment is public (\`/_src\`) is exposed)
|
||||
--regions Set default regions to enable the deployment on
|
||||
--skip-domain Disable the automatic promotion (aliasing) of the relevant domains to a new production
|
||||
deployment. You can use \`vc promote\` to complete the domain-assignment process later
|
||||
--with-cache Retain build cache when using "--force"
|
||||
-y, --yes Use default options to skip all prompts
|
||||
|
||||
|
||||
@@ -785,7 +785,7 @@ describe('build', () => {
|
||||
expect(files.sort()).toEqual(['index.html', 'package.json']);
|
||||
});
|
||||
|
||||
it('should set `VERCEL_ANALYTICS_ID` environment variable', async () => {
|
||||
it('should set `VERCEL_ANALYTICS_ID` environment variable and warn users', async () => {
|
||||
const cwd = fixture('vercel-analytics');
|
||||
const output = join(cwd, '.vercel/output');
|
||||
client.cwd = cwd;
|
||||
@@ -794,6 +794,9 @@ describe('build', () => {
|
||||
|
||||
const env = await fs.readJSON(join(output, 'static', 'env.json'));
|
||||
expect(Object.keys(env).includes('VERCEL_ANALYTICS_ID')).toEqual(true);
|
||||
await expect(client.stderr).toOutput(
|
||||
'Vercel Speed Insights auto-injection is deprecated in favor of @vercel/speed-insights package. Learn more: https://vercel.link/upgrate-to-speed-insights-package'
|
||||
);
|
||||
});
|
||||
|
||||
it('should load environment variables from `.vercel/.env.preview.local`', async () => {
|
||||
@@ -1248,3 +1251,42 @@ describe('build', () => {
|
||||
).toEqual('marketing');
|
||||
});
|
||||
});
|
||||
|
||||
it('should create symlinks for duplicate references to Lambda / EdgeFunction instances', async () => {
|
||||
if (process.platform === 'win32') {
|
||||
console.log('Skipping test on Windows');
|
||||
return;
|
||||
}
|
||||
const cwd = fixture('functions-symlink');
|
||||
const output = join(cwd, '.vercel/output');
|
||||
client.cwd = cwd;
|
||||
const exitCode = await build(client);
|
||||
expect(exitCode).toEqual(0);
|
||||
|
||||
// "functions" directory has output Functions
|
||||
const functions = await fs.readdir(join(output, 'functions'));
|
||||
expect(functions.sort()).toEqual([
|
||||
'edge.func',
|
||||
'edge2.func',
|
||||
'lambda.func',
|
||||
'lambda2.func',
|
||||
]);
|
||||
expect(
|
||||
fs.lstatSync(join(output, 'functions/lambda.func')).isDirectory()
|
||||
).toEqual(true);
|
||||
expect(
|
||||
fs.lstatSync(join(output, 'functions/edge.func')).isDirectory()
|
||||
).toEqual(true);
|
||||
expect(
|
||||
fs.lstatSync(join(output, 'functions/lambda2.func')).isSymbolicLink()
|
||||
).toEqual(true);
|
||||
expect(
|
||||
fs.lstatSync(join(output, 'functions/edge2.func')).isSymbolicLink()
|
||||
).toEqual(true);
|
||||
expect(fs.readlinkSync(join(output, 'functions/lambda2.func'))).toEqual(
|
||||
'lambda.func'
|
||||
);
|
||||
expect(fs.readlinkSync(join(output, 'functions/edge2.func'))).toEqual(
|
||||
'edge.func'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ describe('project', () => {
|
||||
nodeVersion: '16.x',
|
||||
});
|
||||
|
||||
client.setArgv('project', 'ls', '--deprecated');
|
||||
client.setArgv('project', 'ls', '--update-required');
|
||||
await projects(client);
|
||||
|
||||
const lines = createLineIterator(client.stderr);
|
||||
@@ -65,7 +65,7 @@ describe('project', () => {
|
||||
|
||||
line = await lines.next();
|
||||
expect(line.value).toEqual(
|
||||
'WARN! The following Node.js versions will be deprecated soon: 16.x. Upgrade your projects immediately.'
|
||||
'WARN! The following Node.js versions will be deprecated soon: 16.x. Please upgrade your projects immediately.'
|
||||
);
|
||||
line = await lines.next();
|
||||
expect(line.value).toEqual(
|
||||
|
||||
@@ -1,5 +1,52 @@
|
||||
# @vercel/client
|
||||
|
||||
## 13.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`b6ed28b9b`](https://github.com/vercel/vercel/commit/b6ed28b9b1712f882c93fe053b70d3eb1df21819), [`8ba0ce932`](https://github.com/vercel/vercel/commit/8ba0ce932434c6295fedb5307bee59a804b7e6a8), [`0d034b682`](https://github.com/vercel/vercel/commit/0d034b6820c0f3252949c0ffc483048c5aac7f04), [`abaa700ce`](https://github.com/vercel/vercel/commit/abaa700cea44c723cfc851baa2dfe9e1ae2e8a5c)]:
|
||||
- @vercel/build-utils@7.6.0
|
||||
|
||||
## 13.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- More helpful error message when `vc deploy --prebuilt` has missing files ([#11105](https://github.com/vercel/vercel/pull/11105))
|
||||
|
||||
## 13.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Upload files referenced by "filePathMap" during `vc deploy --prebuilt` ([#11077](https://github.com/vercel/vercel/pull/11077))
|
||||
|
||||
## 13.0.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`cdddb33ad`](https://github.com/vercel/vercel/commit/cdddb33ad49f6080c49f4fff3767e6111acd0bbe)]:
|
||||
- @vercel/build-utils@7.5.1
|
||||
|
||||
## 13.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`98040ec24`](https://github.com/vercel/vercel/commit/98040ec24e1ee585865d11eb216b6525d39d209e)]:
|
||||
- @vercel/build-utils@7.5.0
|
||||
|
||||
## 13.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`67fa2f3dd`](https://github.com/vercel/vercel/commit/67fa2f3dd6a6d5a3504b7f9081e56deff7b36eab)]:
|
||||
- @vercel/build-utils@7.4.1
|
||||
|
||||
## 13.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`4d63d9e95`](https://github.com/vercel/vercel/commit/4d63d9e954549d811063d259250d1865b7de2ba1)]:
|
||||
- @vercel/build-utils@7.4.0
|
||||
|
||||
## 13.0.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/client",
|
||||
"version": "13.0.10",
|
||||
"version": "13.1.2",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"homepage": "https://vercel.com",
|
||||
@@ -37,7 +37,8 @@
|
||||
"typescript": "4.9.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/build-utils": "7.3.0",
|
||||
"@vercel/build-utils": "7.6.0",
|
||||
"@vercel/error-utils": "2.0.2",
|
||||
"@vercel/routing-utils": "3.1.0",
|
||||
"@zeit/fetch": "5.2.0",
|
||||
"async-retry": "1.2.3",
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { lstatSync } from 'fs-extra';
|
||||
import { isAbsolute, join, relative } from 'path';
|
||||
import { isAbsolute, join, relative, sep } from 'path';
|
||||
import { hash, hashes, mapToObject } from './utils/hashes';
|
||||
import { upload } from './upload';
|
||||
import { buildFileTree, createDebug } from './utils';
|
||||
import { DeploymentError } from './errors';
|
||||
import { isErrnoException } from '@vercel/error-utils';
|
||||
import {
|
||||
VercelClientOptions,
|
||||
DeploymentOptions,
|
||||
@@ -90,27 +91,43 @@ export default function buildCreateDeployment() {
|
||||
|
||||
let files;
|
||||
|
||||
if (clientOptions.archive === 'tgz') {
|
||||
debug('Packing tarball');
|
||||
const tarStream = tar
|
||||
.pack(workPath, {
|
||||
entries: fileList.map(file => relative(workPath, file)),
|
||||
})
|
||||
.pipe(createGzip());
|
||||
const tarBuffer = await streamToBuffer(tarStream);
|
||||
debug('Packed tarball');
|
||||
files = new Map([
|
||||
[
|
||||
hash(tarBuffer),
|
||||
{
|
||||
names: [join(workPath, '.vercel/source.tgz')],
|
||||
data: tarBuffer,
|
||||
mode: 0o666,
|
||||
},
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
files = await hashes(fileList);
|
||||
try {
|
||||
if (clientOptions.archive === 'tgz') {
|
||||
debug('Packing tarball');
|
||||
const tarStream = tar
|
||||
.pack(workPath, {
|
||||
entries: fileList.map(file => relative(workPath, file)),
|
||||
})
|
||||
.pipe(createGzip());
|
||||
const tarBuffer = await streamToBuffer(tarStream);
|
||||
debug('Packed tarball');
|
||||
files = new Map([
|
||||
[
|
||||
hash(tarBuffer),
|
||||
{
|
||||
names: [join(workPath, '.vercel/source.tgz')],
|
||||
data: tarBuffer,
|
||||
mode: 0o666,
|
||||
},
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
files = await hashes(fileList);
|
||||
}
|
||||
} catch (err: unknown) {
|
||||
if (
|
||||
clientOptions.prebuilt &&
|
||||
isErrnoException(err) &&
|
||||
err.code === 'ENOENT' &&
|
||||
err.path
|
||||
) {
|
||||
const errPath = relative(workPath, err.path);
|
||||
err.message = `File does not exist: "${relative(workPath, errPath)}"`;
|
||||
if (errPath.split(sep).includes('node_modules')) {
|
||||
err.message = `Please ensure project dependencies have been installed:\n${err.message}`;
|
||||
}
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
|
||||
debug(`Yielding a 'hashes-calculated' event with ${files.size} hashes`);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { FilesMap } from './hashes';
|
||||
import { FetchOptions } from '@zeit/fetch';
|
||||
import { nodeFetch, zeitFetch } from './fetch';
|
||||
import { join, sep, relative } from 'path';
|
||||
import { join, sep, relative, basename } from 'path';
|
||||
import { URL } from 'url';
|
||||
import ignore from 'ignore';
|
||||
import { pkgVersion } from '../pkg';
|
||||
@@ -109,6 +109,29 @@ export async function buildFileTree(
|
||||
return ignored;
|
||||
};
|
||||
fileList = await readdir(path, [ignores]);
|
||||
|
||||
if (prebuilt) {
|
||||
// Traverse over the `.vc-config.json` files and include
|
||||
// the files referenced by the "filePathMap" properties
|
||||
const refs = new Set<string>();
|
||||
const vcConfigFilePaths = fileList.filter(
|
||||
file => basename(file) === '.vc-config.json'
|
||||
);
|
||||
await Promise.all(
|
||||
vcConfigFilePaths.map(async p => {
|
||||
const configJson = await readFile(p, 'utf8');
|
||||
const config = JSON.parse(configJson);
|
||||
if (!config.filePathMap) return;
|
||||
for (const v of Object.values(config.filePathMap) as string[]) {
|
||||
refs.add(join(path, v));
|
||||
}
|
||||
})
|
||||
);
|
||||
if (refs.size > 0) {
|
||||
fileList = fileList.concat(Array.from(refs));
|
||||
}
|
||||
}
|
||||
|
||||
debug(`Found ${fileList.length} files in the specified directory`);
|
||||
} else if (Array.isArray(path)) {
|
||||
// Array of file paths
|
||||
|
||||
1
packages/client/tests/fixtures/file-system-api/.gitignore
vendored
Normal file
1
packages/client/tests/fixtures/file-system-api/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!/.vercel
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"filePathMap": {
|
||||
"node_modules/another/index.js": "node_modules/another/index.js"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"filePathMap": {
|
||||
"node_modules/example/index.js": "node_modules/example/index.js"
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ describe('buildFileTree()', () => {
|
||||
normalizeWindowsPaths(fileList).sort()
|
||||
);
|
||||
|
||||
const expectedIgnoreList = ['.vercel'];
|
||||
const expectedIgnoreList = ['.gitignore', '.vercel'];
|
||||
expect(normalizeWindowsPaths(expectedIgnoreList).sort()).toEqual(
|
||||
normalizeWindowsPaths(ignoreList).sort()
|
||||
);
|
||||
@@ -124,14 +124,18 @@ describe('buildFileTree()', () => {
|
||||
);
|
||||
|
||||
const expectedFileList = toAbsolutePaths(cwd, [
|
||||
'.vercel/output/functions/api/another.func/.vc-config.json',
|
||||
'.vercel/output/functions/api/example.func/.vc-config.json',
|
||||
'.vercel/output/static/baz.txt',
|
||||
'.vercel/output/static/sub/qux.txt',
|
||||
'node_modules/another/index.js',
|
||||
'node_modules/example/index.js',
|
||||
]);
|
||||
expect(normalizeWindowsPaths(expectedFileList).sort()).toEqual(
|
||||
normalizeWindowsPaths(fileList).sort()
|
||||
);
|
||||
|
||||
const expectedIgnoreList = ['foo.txt', 'sub'];
|
||||
const expectedIgnoreList = ['.gitignore', 'foo.txt', 'sub'];
|
||||
expect(normalizeWindowsPaths(expectedIgnoreList).sort()).toEqual(
|
||||
normalizeWindowsPaths(ignoreList).sort()
|
||||
);
|
||||
|
||||
@@ -70,7 +70,7 @@ Unicode characters for emoji flags start at this number, and run up to 127469.
|
||||
|
||||
• `Const` **IP_HEADER_NAME**: `"x-real-ip"`
|
||||
|
||||
Client IP as calcualted by Vercel Proxy.
|
||||
Client IP as calculated by Vercel Proxy.
|
||||
|
||||
#### Defined in
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ export const CITY_HEADER_NAME = 'x-vercel-ip-city';
|
||||
*/
|
||||
export const COUNTRY_HEADER_NAME = 'x-vercel-ip-country';
|
||||
/**
|
||||
* Client IP as calcualted by Vercel Proxy.
|
||||
* Client IP as calculated by Vercel Proxy.
|
||||
*/
|
||||
export const IP_HEADER_NAME = 'x-real-ip';
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @vercel/frameworks
|
||||
|
||||
## 2.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Update nuxt logo ([#10977](https://github.com/vercel/vercel/pull/10977))
|
||||
|
||||
## 2.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
<svg width="48" height="38" viewBox="0 0 48 38" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.7599 35.9199L14.6399 35.7999C14.3999 35.3199 14.3999 34.8399 14.3999 34.3599H2.99992L20.0399 4.11988L27.1199 16.9599L29.3999 15.2799L22.3199 2.43988C22.1999 2.19988 21.3599 0.879883 19.9199 0.879883C19.3199 0.879883 18.3599 1.11988 17.6399 2.43988L0.479919 33.0399C0.359919 33.2799 -0.360081 34.7199 0.359919 35.9199C0.599919 36.5199 1.31992 37.1199 2.87992 37.1199H17.2799C15.7199 37.1199 14.9999 36.5199 14.7599 35.9199Z" fill="#00C58E"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M47.3999 33.1598L33.5999 8.31977C33.3599 8.07977 32.6399 6.75977 31.1999 6.75977C30.5999 6.75977 29.7599 6.99977 28.9199 8.31977L27.1199 11.1998V16.9598L31.1999 9.87977L44.8799 34.3598H39.7199C39.7913 34.853 39.7075 35.3563 39.4799 35.7998V35.9198C38.7599 37.1198 37.1999 37.1198 36.9599 37.1198H45.1199C45.3599 37.1198 46.9199 37.1198 47.6399 35.9198C47.8799 35.3198 48.1199 34.3598 47.3999 33.1598Z" fill="#108775"/>
|
||||
<path d="M39.84 35.9199V35.7999L39.96 35.5599C40.08 35.1999 40.2 34.7199 40.08 34.3599L39.6 33.0399L28.8 14.08L27.24 11.2H27.12L25.56 14.08L14.64 33.0399L14.28 34.3599C14.1908 34.8922 14.275 35.4391 14.52 35.9199C14.88 36.5199 15.6 37.1199 17.04 37.1199H37.2C37.56 37.1199 39.12 37.1199 39.84 35.9199ZM27.12 16.96L37.08 34.3599H17.28L27.12 16.96Z" fill="#2F495E"/>
|
||||
<svg width="61" height="40" viewBox="0 0 61 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M33.997 39.539h22.528c.715 0 1.418-.183 2.038-.53a4.014 4.014 0 0 0 1.492-1.447 3.861 3.861 0 0 0 .545-1.977 3.86 3.86 0 0 0-.547-1.977L44.923 8.19a4.016 4.016 0 0 0-1.49-1.447 4.172 4.172 0 0 0-2.038-.53c-.716 0-1.418.183-2.038.53a4.016 4.016 0 0 0-1.492 1.447l-3.868 6.504-7.563-12.718A4.018 4.018 0 0 0 24.942.53 4.175 4.175 0 0 0 22.904 0c-.716 0-1.419.183-2.039.53a4.018 4.018 0 0 0-1.492 1.446L.547 33.608A3.861 3.861 0 0 0 0 35.585c0 .694.188 1.376.545 1.977.358.601.873 1.1 1.492 1.447.62.347 1.323.53 2.038.53h14.141c5.603 0 9.735-2.387 12.578-7.044l6.902-11.596 3.698-6.205 11.096 18.64H37.695l-3.699 6.205Zm-16.011-6.212-9.869-.002L22.91 8.474l7.381 12.425-4.942 8.305c-1.888 3.022-4.033 4.123-7.363 4.123Z" fill="#00DC82"/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 850 B |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/frameworks",
|
||||
"version": "2.0.5",
|
||||
"version": "2.0.6",
|
||||
"main": "./dist/frameworks.js",
|
||||
"types": "./dist/frameworks.d.ts",
|
||||
"files": [
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @vercel/fs-detectors
|
||||
|
||||
## 5.1.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`471bdd5b4`](https://github.com/vercel/vercel/commit/471bdd5b4506f1410afd7bca6efae3bc696cd939)]:
|
||||
- @vercel/frameworks@2.0.6
|
||||
|
||||
## 5.1.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/fs-detectors",
|
||||
"version": "5.1.5",
|
||||
"version": "5.1.6",
|
||||
"description": "Vercel filesystem detectors",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -22,7 +22,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/error-utils": "2.0.2",
|
||||
"@vercel/frameworks": "2.0.5",
|
||||
"@vercel/frameworks": "2.0.6",
|
||||
"@vercel/routing-utils": "3.1.0",
|
||||
"glob": "8.0.3",
|
||||
"js-yaml": "4.1.0",
|
||||
@@ -37,7 +37,7 @@
|
||||
"@types/minimatch": "3.0.5",
|
||||
"@types/node": "14.18.33",
|
||||
"@types/semver": "7.3.10",
|
||||
"@vercel/build-utils": "7.3.0",
|
||||
"@vercel/build-utils": "7.6.0",
|
||||
"jest-junit": "16.0.0",
|
||||
"typescript": "4.9.5"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,44 @@
|
||||
# @vercel/gatsby-plugin-vercel-builder
|
||||
|
||||
## 2.0.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [gatsby-plugin-vercel-builder] use --keep-names esbuild flag ([#11117](https://github.com/vercel/vercel/pull/11117))
|
||||
|
||||
- Updated dependencies [[`b6ed28b9b`](https://github.com/vercel/vercel/commit/b6ed28b9b1712f882c93fe053b70d3eb1df21819), [`8ba0ce932`](https://github.com/vercel/vercel/commit/8ba0ce932434c6295fedb5307bee59a804b7e6a8), [`0d034b682`](https://github.com/vercel/vercel/commit/0d034b6820c0f3252949c0ffc483048c5aac7f04), [`abaa700ce`](https://github.com/vercel/vercel/commit/abaa700cea44c723cfc851baa2dfe9e1ae2e8a5c)]:
|
||||
- @vercel/build-utils@7.6.0
|
||||
|
||||
## 2.0.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`cdddb33ad`](https://github.com/vercel/vercel/commit/cdddb33ad49f6080c49f4fff3767e6111acd0bbe)]:
|
||||
- @vercel/build-utils@7.5.1
|
||||
|
||||
## 2.0.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`98040ec24`](https://github.com/vercel/vercel/commit/98040ec24e1ee585865d11eb216b6525d39d209e)]:
|
||||
- @vercel/build-utils@7.5.0
|
||||
|
||||
## 2.0.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`67fa2f3dd`](https://github.com/vercel/vercel/commit/67fa2f3dd6a6d5a3504b7f9081e56deff7b36eab)]:
|
||||
- @vercel/build-utils@7.4.1
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Add support for "rewrites" ([#10954](https://github.com/vercel/vercel/pull/10954))
|
||||
|
||||
- Updated dependencies [[`4d63d9e95`](https://github.com/vercel/vercel/commit/4d63d9e954549d811063d259250d1865b7de2ba1)]:
|
||||
- @vercel/build-utils@7.4.0
|
||||
|
||||
## 2.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/gatsby-plugin-vercel-builder",
|
||||
"version": "2.0.12",
|
||||
"version": "2.0.17",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
"dist",
|
||||
@@ -20,7 +20,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@sinclair/typebox": "0.25.24",
|
||||
"@vercel/build-utils": "7.3.0",
|
||||
"@vercel/build-utils": "7.6.0",
|
||||
"@vercel/routing-utils": "3.1.0",
|
||||
"esbuild": "0.14.47",
|
||||
"etag": "1.8.1",
|
||||
|
||||
@@ -35,6 +35,9 @@ export const writeHandler = async ({
|
||||
platform: 'node',
|
||||
bundle: true,
|
||||
minify: true,
|
||||
// prevents renaming edge cases from causing failures like:
|
||||
// https://github.com/node-fetch/node-fetch/issues/784
|
||||
keepNames: true,
|
||||
define: {
|
||||
'process.env.NODE_ENV': "'production'",
|
||||
vercel_pathPrefix: JSON.stringify(prefix),
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { getTransformedRoutes } from '@vercel/routing-utils';
|
||||
import {
|
||||
getTransformedRoutes,
|
||||
type Redirect,
|
||||
type Rewrite,
|
||||
} from '@vercel/routing-utils';
|
||||
import { writeJson } from 'fs-extra';
|
||||
import { validateGatsbyState } from './schemas';
|
||||
import {
|
||||
@@ -31,7 +35,7 @@ export async function generateVercelBuildOutputAPI3Output({
|
||||
if (validateGatsbyState.Check(state)) {
|
||||
console.log('▲ Creating Vercel build output');
|
||||
|
||||
const { pages, redirects, functions, config: gatsbyConfig } = state;
|
||||
const { pages, functions, config: gatsbyConfig } = state;
|
||||
const { pathPrefix = '' } = gatsbyConfig;
|
||||
|
||||
const ssrRoutes = pages
|
||||
@@ -60,14 +64,36 @@ export async function generateVercelBuildOutputAPI3Output({
|
||||
trailingSlash = false;
|
||||
}
|
||||
|
||||
const routes =
|
||||
getTransformedRoutes({
|
||||
trailingSlash,
|
||||
redirects: redirects.map(({ fromPath, toPath, isPermanent }) => ({
|
||||
const redirects: Redirect[] = [];
|
||||
const rewrites: Rewrite[] = [];
|
||||
|
||||
for (const {
|
||||
fromPath,
|
||||
toPath,
|
||||
isPermanent,
|
||||
statusCode,
|
||||
} of state.redirects) {
|
||||
if (statusCode === 200) {
|
||||
// A `statusCode` of 200 on `createRedirect()` creates a rewrite (i.e. a reverse proxy)
|
||||
// https://www.gatsbyjs.com/docs/how-to/cloud/working-with-redirects-and-rewrites/#rewrites-and-reverse-proxies
|
||||
rewrites.push({
|
||||
source: fromPath,
|
||||
destination: toPath,
|
||||
});
|
||||
} else {
|
||||
redirects.push({
|
||||
source: fromPath,
|
||||
destination: toPath,
|
||||
permanent: isPermanent,
|
||||
})),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const routes =
|
||||
getTransformedRoutes({
|
||||
trailingSlash,
|
||||
redirects,
|
||||
rewrites,
|
||||
}).routes || [];
|
||||
|
||||
routes.push({
|
||||
|
||||
@@ -31,6 +31,7 @@ const GatsbyRedirectSchema = Type.Object({
|
||||
fromPath: Type.String(),
|
||||
toPath: Type.String(),
|
||||
isPermanent: Type.Optional(Type.Boolean()),
|
||||
statusCode: Type.Optional(Type.Number()),
|
||||
});
|
||||
export type GatsbyRedirect = Static<typeof GatsbyRedirectSchema>;
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @vercel/go
|
||||
|
||||
## 3.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Remove `VERCEL_USE_GO_PROVIDED_RUNTIME` env var check ([#10968](https://github.com/vercel/vercel/pull/10968))
|
||||
|
||||
## 3.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/go",
|
||||
"version": "3.0.4",
|
||||
"version": "3.0.5",
|
||||
"license": "Apache-2.0",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
|
||||
@@ -29,7 +29,7 @@
|
||||
"@types/node-fetch": "^2.3.0",
|
||||
"@types/tar": "6.1.5",
|
||||
"@types/yauzl-promise": "2.1.0",
|
||||
"@vercel/build-utils": "7.3.0",
|
||||
"@vercel/build-utils": "7.6.0",
|
||||
"async-retry": "1.3.3",
|
||||
"execa": "^1.0.0",
|
||||
"fs-extra": "^7.0.0",
|
||||
|
||||
@@ -249,10 +249,7 @@ export async function build({
|
||||
await buildHandlerWithGoMod(buildOptions);
|
||||
}
|
||||
|
||||
const runtime =
|
||||
process.env.VERCEL_USE_GO_PROVIDED_RUNTIME === '1'
|
||||
? 'provided.al2'
|
||||
: 'go1.x';
|
||||
const runtime = 'provided.al2';
|
||||
const lambda = new Lambda({
|
||||
files: { ...(await glob('**', outDir)), ...includedFiles },
|
||||
handler: HANDLER_FILENAME,
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @vercel/hydrogen
|
||||
|
||||
## 1.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Deprecate `EdgeFunction#name` property ([#11010](https://github.com/vercel/vercel/pull/11010))
|
||||
|
||||
## 1.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/hydrogen",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"license": "Apache-2.0",
|
||||
"main": "./dist/index.js",
|
||||
"homepage": "https://vercel.com/docs",
|
||||
@@ -26,7 +26,7 @@
|
||||
"devDependencies": {
|
||||
"@types/jest": "27.5.1",
|
||||
"@types/node": "14.18.33",
|
||||
"@vercel/build-utils": "7.3.0",
|
||||
"@vercel/build-utils": "7.6.0",
|
||||
"execa": "3.2.0",
|
||||
"fs-extra": "11.1.0",
|
||||
"jest-junit": "16.0.0"
|
||||
|
||||
@@ -126,7 +126,6 @@ export const build: BuildV2 = async ({
|
||||
]);
|
||||
|
||||
const edgeFunction = new EdgeFunction({
|
||||
name: 'hydrogen',
|
||||
deploymentTarget: 'v8-worker',
|
||||
entrypoint: 'index.js',
|
||||
files: edgeFunctionFiles,
|
||||
|
||||
@@ -1,5 +1,44 @@
|
||||
# @vercel/next
|
||||
|
||||
## 4.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [node][next][redwood][remix] bump `@vercel/nft@0.26.3` ([#11115](https://github.com/vercel/vercel/pull/11115))
|
||||
|
||||
- Load common chunks on module initialization ([#11126](https://github.com/vercel/vercel/pull/11126))
|
||||
|
||||
- Fix index normalizing for app outputs ([#11099](https://github.com/vercel/vercel/pull/11099))
|
||||
|
||||
- Mark `flags` as deprecated and replace them with `variants` ([#11098](https://github.com/vercel/vercel/pull/11098))
|
||||
|
||||
- Fix rewrite RSC handling with trailingSlash ([#11107](https://github.com/vercel/vercel/pull/11107))
|
||||
|
||||
## 4.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- fix error when @vercel/analytics is a transitive dependency of the deployed application ([#10892](https://github.com/vercel/vercel/pull/10892))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Use `worker.name` instead of edge function name to fix type error in `@vercel/next` ([#11050](https://github.com/vercel/vercel/pull/11050))
|
||||
|
||||
## 4.0.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Ensure rewrites handle RSC requests ([#11005](https://github.com/vercel/vercel/pull/11005))
|
||||
|
||||
- [next][node][redwood][remix] Bump `@vercel/nft@0.26.1` ([#11009](https://github.com/vercel/vercel/pull/11009))
|
||||
|
||||
## 4.0.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Entries in the `prerender-manifest.json` without a `dataRoute` but with a `prefetchDataRoute` will be treated as an App Page. App Route's that do not have ([#10978](https://github.com/vercel/vercel/pull/10978))
|
||||
a body will not cause a build error.
|
||||
|
||||
## 4.0.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/next",
|
||||
"version": "4.0.15",
|
||||
"version": "4.1.1",
|
||||
"license": "Apache-2.0",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
|
||||
@@ -23,7 +23,7 @@
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"@vercel/nft": "0.24.2"
|
||||
"@vercel/nft": "0.26.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/aws-lambda": "8.10.19",
|
||||
@@ -40,7 +40,7 @@
|
||||
"@types/semver": "6.0.0",
|
||||
"@types/text-table": "0.2.1",
|
||||
"@types/webpack-sources": "3.2.0",
|
||||
"@vercel/build-utils": "7.3.0",
|
||||
"@vercel/build-utils": "7.6.0",
|
||||
"@vercel/routing-utils": "3.1.0",
|
||||
"async-sema": "3.0.1",
|
||||
"buffer-crc32": "0.2.13",
|
||||
|
||||
@@ -47,7 +47,7 @@ import {
|
||||
UnwrapPromise,
|
||||
getOperationType,
|
||||
FunctionsConfigManifestV1,
|
||||
VariantsManifest,
|
||||
VariantsManifestLegacy,
|
||||
RSC_CONTENT_TYPE,
|
||||
RSC_PREFETCH_SUFFIX,
|
||||
normalizePrefetches,
|
||||
@@ -70,6 +70,30 @@ const NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION = 'v12.1.7-canary.33';
|
||||
const EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION = 'v12.2.0';
|
||||
const CORRECTED_MANIFESTS_VERSION = 'v12.2.0';
|
||||
|
||||
// Ideally this should be in a Next.js manifest so we can change it in
|
||||
// the future but this also allows us to improve existing versions
|
||||
const PRELOAD_CHUNKS = {
|
||||
APP_ROUTER_PAGES: [
|
||||
'.next/server/webpack-runtime.js',
|
||||
'next/dist/client/components/action-async-storage.external.js',
|
||||
'next/dist/client/components/request-async-storage.external.js',
|
||||
'next/dist/client/components/static-generation-async-storage.external.js',
|
||||
'next/dist/compiled/next-server/app-page.runtime.prod.js',
|
||||
],
|
||||
APP_ROUTER_HANDLER: [
|
||||
'.next/server/webpack-runtime.js',
|
||||
'next/dist/compiled/next-server/app-route.runtime.prod.js',
|
||||
],
|
||||
PAGES_ROUTER_PAGES: [
|
||||
'.next/server/webpack-runtime.js',
|
||||
'next/dist/compiled/next-server/pages.runtime.prod.js',
|
||||
],
|
||||
PAGES_ROUTER_API: [
|
||||
'.next/server/webpack-api-runtime.js',
|
||||
'next/dist/compiled/next-server/pages-api.runtime.prod.js',
|
||||
],
|
||||
};
|
||||
|
||||
// related PR: https://github.com/vercel/next.js/pull/52997
|
||||
// and https://github.com/vercel/next.js/pull/56318
|
||||
const BUNDLED_SERVER_NEXT_VERSION = 'v13.5.4';
|
||||
@@ -158,7 +182,7 @@ export async function serverBuild({
|
||||
imagesManifest?: NextImagesManifest;
|
||||
prerenderManifest: NextPrerenderedRoutes;
|
||||
requiredServerFilesManifest: NextRequiredServerFilesManifest;
|
||||
variantsManifest: VariantsManifest | null;
|
||||
variantsManifest: VariantsManifestLegacy | null;
|
||||
}): Promise<BuildResult> {
|
||||
lambdaPages = Object.assign({}, lambdaPages, lambdaAppPaths);
|
||||
|
||||
@@ -213,6 +237,25 @@ export async function serverBuild({
|
||||
value.contentType = rscContentTypeHeader;
|
||||
}
|
||||
}
|
||||
|
||||
for (const rewrite of afterFilesRewrites) {
|
||||
if (rewrite.src && rewrite.dest) {
|
||||
rewrite.src = rewrite.src.replace(
|
||||
/\/?\(\?:\/\)\?/,
|
||||
'(?<rscsuff>(\\.prefetch)?\\.rsc)?(?:/)?'
|
||||
);
|
||||
let destQueryIndex = rewrite.dest.indexOf('?');
|
||||
|
||||
if (destQueryIndex === -1) {
|
||||
destQueryIndex = rewrite.dest.length;
|
||||
}
|
||||
|
||||
rewrite.dest =
|
||||
rewrite.dest.substring(0, destQueryIndex) +
|
||||
'$rscsuff' +
|
||||
rewrite.dest.substring(destQueryIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const isCorrectNotFoundRoutes = semver.gte(
|
||||
@@ -1049,9 +1092,58 @@ export async function serverBuild({
|
||||
}
|
||||
}
|
||||
|
||||
let launcherData = group.isAppRouter ? appLauncher : launcher;
|
||||
let preloadChunks: string[] = [];
|
||||
|
||||
if (process.env.VERCEL_NEXT_PRELOAD_COMMON === '1') {
|
||||
const nextPackageDir = path.dirname(
|
||||
resolveFrom(projectDir, 'next/package.json')
|
||||
);
|
||||
|
||||
if (group.isPages) {
|
||||
preloadChunks = PRELOAD_CHUNKS.PAGES_ROUTER_PAGES;
|
||||
} else if (group.isApiLambda) {
|
||||
preloadChunks = PRELOAD_CHUNKS.PAGES_ROUTER_API;
|
||||
} else if (group.isAppRouter && !group.isAppRouteHandler) {
|
||||
preloadChunks = PRELOAD_CHUNKS.APP_ROUTER_PAGES;
|
||||
} else if (group.isAppRouteHandler) {
|
||||
preloadChunks = PRELOAD_CHUNKS.APP_ROUTER_HANDLER;
|
||||
}
|
||||
const normalizedPreloadChunks: string[] = [];
|
||||
|
||||
for (const preloadChunk of preloadChunks) {
|
||||
const absoluteChunk = preloadChunk.startsWith('.next')
|
||||
? path.join(projectDir, preloadChunk)
|
||||
: path.join(nextPackageDir, '..', preloadChunk);
|
||||
|
||||
// ensure the chunks are actually in this layer
|
||||
if (
|
||||
group.pseudoLayer[
|
||||
path.join('.', path.relative(baseDir, absoluteChunk))
|
||||
]
|
||||
) {
|
||||
normalizedPreloadChunks.push(
|
||||
// relative files need to be prefixed with ./ for require
|
||||
preloadChunk.startsWith('.next')
|
||||
? `./${preloadChunk}`
|
||||
: preloadChunk
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (normalizedPreloadChunks.length > 0) {
|
||||
launcherData = launcherData.replace(
|
||||
'// @preserve next-server-preload-target',
|
||||
normalizedPreloadChunks
|
||||
.map(name => `require('${name}');`)
|
||||
.join('\n')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const launcherFiles: { [name: string]: FileFsRef | FileBlob } = {
|
||||
[path.join(path.relative(baseDir, projectDir), '___next_launcher.cjs')]:
|
||||
new FileBlob({ data: group.isAppRouter ? appLauncher : launcher }),
|
||||
new FileBlob({ data: launcherData }),
|
||||
};
|
||||
const operationType = getOperationType({ group, prerenderManifest });
|
||||
|
||||
@@ -1109,11 +1201,11 @@ export async function serverBuild({
|
||||
);
|
||||
});
|
||||
}
|
||||
let outputName = path.posix.join(entryDirectory, pageNoExt);
|
||||
|
||||
let outputName = normalizeIndexOutput(
|
||||
path.posix.join(entryDirectory, pageNoExt),
|
||||
true
|
||||
);
|
||||
if (!group.isAppRouter && !group.isAppRouteHandler) {
|
||||
outputName = normalizeIndexOutput(outputName, true);
|
||||
}
|
||||
|
||||
// If this is a PPR page, then we should prefix the output name.
|
||||
if (isPPR) {
|
||||
@@ -1424,9 +1516,10 @@ export async function serverBuild({
|
||||
continue;
|
||||
}
|
||||
|
||||
const pathname = normalizeIndexOutput(
|
||||
path.posix.join('./', entryDirectory, route === '/' ? '/index' : route),
|
||||
true
|
||||
const pathname = path.posix.join(
|
||||
'./',
|
||||
entryDirectory,
|
||||
route === '/' ? '/index' : route
|
||||
);
|
||||
|
||||
if (lambdas[pathname]) {
|
||||
@@ -1857,6 +1950,26 @@ export async function serverBuild({
|
||||
// with that routing section
|
||||
...afterFilesRewrites,
|
||||
|
||||
// ensure non-normalized /.rsc from rewrites is handled
|
||||
...(appPathRoutesManifest
|
||||
? [
|
||||
{
|
||||
src: path.posix.join('/', entryDirectory, '/\\.prefetch\\.rsc$'),
|
||||
dest: path.posix.join(
|
||||
'/',
|
||||
entryDirectory,
|
||||
`/__index${RSC_PREFETCH_SUFFIX}`
|
||||
),
|
||||
check: true,
|
||||
},
|
||||
{
|
||||
src: path.posix.join('/', entryDirectory, '/\\.rsc$'),
|
||||
dest: path.posix.join('/', entryDirectory, `/index.rsc`),
|
||||
check: true,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
|
||||
{ handle: 'resource' },
|
||||
|
||||
...fallbackRewrites,
|
||||
|
||||
@@ -23,6 +23,8 @@ if (process.env.NODE_ENV !== 'production' && region !== 'dev1') {
|
||||
// eslint-disable-next-line
|
||||
const NextServer = require('__NEXT_SERVER_PATH__').default;
|
||||
|
||||
// @preserve next-server-preload-target
|
||||
|
||||
// __NEXT_CONFIG__ value is injected
|
||||
declare const __NEXT_CONFIG__: any;
|
||||
const conf = __NEXT_CONFIG__;
|
||||
|
||||
@@ -2053,13 +2053,18 @@ export const onPrerenderRoute =
|
||||
|
||||
let isAppPathRoute = false;
|
||||
|
||||
// experimentalPPR signals app path route
|
||||
if (appDir && experimentalPPR) {
|
||||
isAppPathRoute = true;
|
||||
}
|
||||
|
||||
// TODO: leverage manifest to determine app paths more accurately
|
||||
if (appDir && srcRoute && (!dataRoute || dataRoute?.endsWith('.rsc'))) {
|
||||
isAppPathRoute = true;
|
||||
}
|
||||
|
||||
const isOmittedOrNotFound = isOmitted || isNotFound;
|
||||
let htmlFsRef: File | null;
|
||||
let htmlFsRef: File | null = null;
|
||||
|
||||
// If enabled, try to get the postponed route information from the file
|
||||
// system and use it to assemble the prerender.
|
||||
@@ -2108,14 +2113,22 @@ export const onPrerenderRoute =
|
||||
} else if (
|
||||
appDir &&
|
||||
!dataRoute &&
|
||||
!prefetchDataRoute &&
|
||||
isAppPathRoute &&
|
||||
!(isBlocking || isFallback)
|
||||
) {
|
||||
const contentType = initialHeaders?.['content-type'];
|
||||
htmlFsRef = new FileFsRef({
|
||||
fsPath: path.join(appDir, `${routeFileNoExt}.body`),
|
||||
contentType: contentType || 'text/html;charset=utf-8',
|
||||
});
|
||||
|
||||
// If the route has a body file, use it as the fallback, otherwise it may
|
||||
// not have an associated fallback. This could be the case for routes that
|
||||
// have dynamic segments.
|
||||
const fsPath = path.join(appDir, `${routeFileNoExt}.body`);
|
||||
if (fs.existsSync(fsPath)) {
|
||||
htmlFsRef = new FileFsRef({
|
||||
fsPath,
|
||||
contentType: contentType || 'text/html;charset=utf-8',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
htmlFsRef =
|
||||
isBlocking || (isNotFound && !static404Page)
|
||||
@@ -2176,7 +2189,6 @@ export const onPrerenderRoute =
|
||||
if (routeKey !== '/index' && routeKey.endsWith('/index')) {
|
||||
routeKey = `${routeKey}/index`;
|
||||
routeFileNoExt = routeKey;
|
||||
origRouteFileNoExt = routeKey;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2247,15 +2259,20 @@ export const onPrerenderRoute =
|
||||
const lambdaId = pageLambdaMap[outputSrcPathPage];
|
||||
lambda = lambdas[lambdaId];
|
||||
} else {
|
||||
const outputSrcPathPage = normalizeIndexOutput(
|
||||
let outputSrcPathPage =
|
||||
srcRoute == null
|
||||
? outputPathPageOrig
|
||||
: path.posix.join(
|
||||
entryDirectory,
|
||||
srcRoute === '/' ? '/index' : srcRoute
|
||||
),
|
||||
isServerMode
|
||||
);
|
||||
);
|
||||
|
||||
if (!isAppPathRoute) {
|
||||
outputSrcPathPage = normalizeIndexOutput(
|
||||
outputSrcPathPage,
|
||||
isServerMode
|
||||
);
|
||||
}
|
||||
|
||||
lambda = lambdas[outputSrcPathPage];
|
||||
}
|
||||
@@ -2456,11 +2473,18 @@ export const onPrerenderRoute =
|
||||
routesManifest,
|
||||
locale
|
||||
);
|
||||
const localeOutputPathPage = normalizeIndexOutput(
|
||||
path.posix.join(entryDirectory, localeRouteFileNoExt),
|
||||
isServerMode
|
||||
let localeOutputPathPage = path.posix.join(
|
||||
entryDirectory,
|
||||
localeRouteFileNoExt
|
||||
);
|
||||
|
||||
if (!isAppPathRoute) {
|
||||
localeOutputPathPage = normalizeIndexOutput(
|
||||
localeOutputPathPage,
|
||||
isServerMode
|
||||
);
|
||||
}
|
||||
|
||||
const origPrerenderPage = prerenders[outputPathPage];
|
||||
prerenders[localeOutputPathPage] = {
|
||||
...origPrerenderPage,
|
||||
@@ -2848,6 +2872,7 @@ export async function getMiddlewareBundle({
|
||||
return {
|
||||
type,
|
||||
page: edgeFunction.page,
|
||||
name: edgeFunction.name,
|
||||
edgeFunction: (() => {
|
||||
const { source, map } = wrappedModuleSource.sourceAndMap();
|
||||
const transformedMap = stringifySourceMap(
|
||||
@@ -2943,8 +2968,7 @@ export async function getMiddlewareBundle({
|
||||
};
|
||||
|
||||
for (const worker of workerConfigs.values()) {
|
||||
const edgeFile = worker.edgeFunction.name;
|
||||
let shortPath = edgeFile;
|
||||
let shortPath = worker.name;
|
||||
|
||||
// Replacing the folder prefix for the page
|
||||
//
|
||||
@@ -2961,14 +2985,17 @@ export async function getMiddlewareBundle({
|
||||
}
|
||||
|
||||
if (routesManifest?.basePath) {
|
||||
shortPath = normalizeIndexOutput(
|
||||
path.posix.join(
|
||||
'./',
|
||||
routesManifest?.basePath,
|
||||
shortPath.replace(/^\//, '')
|
||||
),
|
||||
true
|
||||
const isAppPathRoute = !!appPathRoutesManifest[shortPath];
|
||||
|
||||
shortPath = path.posix.join(
|
||||
'./',
|
||||
routesManifest?.basePath,
|
||||
shortPath.replace(/^\//, '')
|
||||
);
|
||||
|
||||
if (!isAppPathRoute) {
|
||||
shortPath = normalizeIndexOutput(shortPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
worker.edgeFunction.name = shortPath;
|
||||
@@ -3230,7 +3257,8 @@ export function isApiPage(page: string | undefined) {
|
||||
.match(/(serverless|server)\/pages\/api(\/|\.js$)/);
|
||||
}
|
||||
|
||||
export type VariantsManifest = Record<
|
||||
/** @deprecated */
|
||||
export type VariantsManifestLegacy = Record<
|
||||
string,
|
||||
{
|
||||
defaultValue?: unknown;
|
||||
@@ -3241,7 +3269,7 @@ export type VariantsManifest = Record<
|
||||
export async function getVariantsManifest(
|
||||
entryPath: string,
|
||||
outputDirectory: string
|
||||
): Promise<null | VariantsManifest> {
|
||||
): Promise<null | VariantsManifestLegacy> {
|
||||
const pathVariantsManifest = path.join(
|
||||
entryPath,
|
||||
outputDirectory,
|
||||
@@ -3255,7 +3283,7 @@ export async function getVariantsManifest(
|
||||
|
||||
if (!hasVariantsManifest) return null;
|
||||
|
||||
const variantsManifest: VariantsManifest = await fs.readJSON(
|
||||
const variantsManifest: VariantsManifestLegacy = await fs.readJSON(
|
||||
pathVariantsManifest
|
||||
);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user