mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-11 21:07:47 +00:00
Compare commits
143 Commits
@vercel/er
...
@vercel-in
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e50fe2b37c | ||
|
|
678ebbe525 | ||
|
|
10e200e0bf | ||
|
|
24c3dd282d | ||
|
|
142a397d8e | ||
|
|
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 | ||
|
|
7582571d94 | ||
|
|
e6aaf79d04 | ||
|
|
a1df25a197 | ||
|
|
dfe47f6e6c | ||
|
|
3a58431695 | ||
|
|
204c3592c7 | ||
|
|
3cede43ca7 | ||
|
|
1dbb22bb6d | ||
|
|
f124779b35 | ||
|
|
371c7a08f2 | ||
|
|
447c20fb99 | ||
|
|
0fe8c07194 | ||
|
|
78d1d548d9 | ||
|
|
c41ff450c0 | ||
|
|
ca2cbf06fb | ||
|
|
2d86a2d4ba | ||
|
|
4edfcd74b6 | ||
|
|
c52bdf7758 | ||
|
|
bc5ac1ec50 | ||
|
|
aa0f3d712b | ||
|
|
e02212ae80 | ||
|
|
a8934da623 | ||
|
|
0e9bb30fd2 | ||
|
|
6afdd7fb0b | ||
|
|
fdef0339f2 | ||
|
|
4636ae54c6 | ||
|
|
61a23f1382 | ||
|
|
4b8b4992c4 | ||
|
|
611fbdd5ac | ||
|
|
ffd2f34c6c | ||
|
|
8feaa9c3b3 | ||
|
|
31daff66af | ||
|
|
48c6b2dcc3 | ||
|
|
6f3ae1a0ed | ||
|
|
88da7463ce | ||
|
|
142aa55a5d | ||
|
|
7bc8b65d13 | ||
|
|
65dec5b7e7 | ||
|
|
f3b62d8ea2 | ||
|
|
9472c22bf7 | ||
|
|
493185709a | ||
|
|
89c1e03233 | ||
|
|
ebd7e3ac39 | ||
|
|
fd29b966d3 | ||
|
|
2bd9216403 | ||
|
|
c94a082f6b |
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
|
||||
|
||||
3
.github/workflows/test-lint.yml
vendored
3
.github/workflows/test-lint.yml
vendored
@@ -28,7 +28,8 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: main
|
||||
- run: git checkout ${{ github.event.pull_request.head.ref }}
|
||||
- run: git fetch origin ${{ github.event.pull_request.head.sha }}:pr-${{ github.event.pull_request.number }}
|
||||
- run: git checkout pr-${{ github.event.pull_request.number }}
|
||||
- name: install pnpm@8.3.1
|
||||
run: npm i -g pnpm@8.3.1
|
||||
- run: pnpm install
|
||||
|
||||
5
.github/workflows/test.yml
vendored
5
.github/workflows/test.yml
vendored
@@ -70,6 +70,11 @@ jobs:
|
||||
if: matrix.runner == 'macos-latest'
|
||||
run: curl -L -O https://github.com/gohugoio/hugo/releases/download/v0.56.0/hugo_0.56.0_macOS-64bit.tar.gz && tar -xzf hugo_0.56.0_macOS-64bit.tar.gz && mv ./hugo packages/cli/test/dev/fixtures/08-hugo/
|
||||
|
||||
# yarn 1.22.21 introduced a Corepack bug when running tests.
|
||||
# this can be removed once https://github.com/yarnpkg/yarn/issues/9015 is resolved
|
||||
- name: install yarn@1.22.19
|
||||
run: npm i -g yarn@1.22.19
|
||||
|
||||
- name: install pnpm@8.3.1
|
||||
run: npm i -g pnpm@8.3.1
|
||||
|
||||
|
||||
1
.node_version
Normal file
1
.node_version
Normal file
@@ -0,0 +1 @@
|
||||
v16.20.2
|
||||
@@ -385,15 +385,16 @@ This is a [class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refere
|
||||
|
||||
This is an abstract enumeration type that is implemented by one of the following possible `String` values:
|
||||
|
||||
- `nodejs20.x`
|
||||
- `nodejs18.x`
|
||||
- `nodejs16.x`
|
||||
- `go1.x`
|
||||
- `java11`
|
||||
- `python3.9`
|
||||
- `dotnet6`
|
||||
- `dotnetcore3.1`
|
||||
- `ruby2.7`
|
||||
- `provided.al2`
|
||||
- `provided.al2023`
|
||||
|
||||
## `@vercel/build-utils` Helper Functions
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
## Vercel
|
||||
|
||||
Vercel's frontend cloud gives developers frameworks, workflows, and infrastructure to build a faster, more personalized web.
|
||||
Vercel’s Frontend Cloud provides the developer experience and infrastructure to build, scale, and secure a faster, more personalized Web.
|
||||
|
||||
## Deploy
|
||||
|
||||
|
||||
6
examples/CHANGELOG.md
vendored
6
examples/CHANGELOG.md
vendored
@@ -4,4 +4,10 @@
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- chore: update Nuxt example ([#10869](https://github.com/vercel/vercel/pull/10869))
|
||||
|
||||
## null
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- update examples to use at least node@16 ([#10395](https://github.com/vercel/vercel/pull/10395))
|
||||
|
||||
@@ -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,13 +81,13 @@ 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>
|
||||
</h2>
|
||||
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
|
||||
Explore the Next.js 13 playground.
|
||||
Explore starter templates for Next.js.
|
||||
</p>
|
||||
</a>
|
||||
|
||||
@@ -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;
|
||||
1057
examples/nextjs/package-lock.json
generated
1057
examples/nextjs/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,17 +11,17 @@
|
||||
"dependencies": {
|
||||
"react": "^18",
|
||||
"react-dom": "^18",
|
||||
"next": "14.0.0"
|
||||
"next": "14.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^18",
|
||||
"@types/react-dom": "^18",
|
||||
"autoprefixer": "^10",
|
||||
"autoprefixer": "^10.0.1",
|
||||
"postcss": "^8",
|
||||
"tailwindcss": "^3",
|
||||
"tailwindcss": "^3.3.0",
|
||||
"eslint": "^8",
|
||||
"eslint-config-next": "14.0.0"
|
||||
"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,4 +2,4 @@
|
||||
<div>
|
||||
<NuxtWelcome />
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
export default {
|
||||
nitro: {
|
||||
preset: 'vercel-edge',
|
||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||
export default defineNuxtConfig({
|
||||
devtools: { enabled: true },
|
||||
routeRules: {
|
||||
// prerender index route by default
|
||||
'/': { prerender: true },
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "nuxt build",
|
||||
"dev": "nuxt dev",
|
||||
@@ -8,6 +9,9 @@
|
||||
"postinstall": "nuxt prepare"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nuxt": "^3.0.0"
|
||||
"@nuxt/devtools": "^1.0.3",
|
||||
"nuxt": "^3.8.2",
|
||||
"vue": "^3.3.8",
|
||||
"vue-router": "^4.2.5"
|
||||
}
|
||||
}
|
||||
|
||||
6100
examples/nuxtjs/pnpm-lock.yaml
generated
Normal file
6100
examples/nuxtjs/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
BIN
examples/nuxtjs/public/favicon.ico
Normal file
BIN
examples/nuxtjs/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
3
examples/nuxtjs/server/tsconfig.json
Normal file
3
examples/nuxtjs/server/tsconfig.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../.nuxt/tsconfig.server.json"
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
// https://v3.nuxtjs.org/concepts/typescript
|
||||
// https://nuxt.com/docs/guide/concepts/typescript
|
||||
"extends": "./.nuxt/tsconfig.json"
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
2
examples/package.json
vendored
2
examples/package.json
vendored
@@ -9,7 +9,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "27.4.1",
|
||||
"@vercel/frameworks": "2.0.3"
|
||||
"@vercel/frameworks": "2.0.6"
|
||||
},
|
||||
"version": null
|
||||
}
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
This directory is a brief example of a [Remix](https://remix.run/docs) site that can be deployed to Vercel with zero configuration.
|
||||
|
||||
To get started, run the Remix cli with this template
|
||||
|
||||
```sh
|
||||
npx create-remix@latest --template vercel/vercel/examples/remix
|
||||
```
|
||||
|
||||
## Deploy Your Own
|
||||
|
||||
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/remix&template=remix)
|
||||
|
||||
@@ -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,68 @@
|
||||
# @vercel-internals/types
|
||||
|
||||
## 1.0.23
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`24c3dd282`](https://github.com/vercel/vercel/commit/24c3dd282d7714cd63d2b94fb94745c45fdc79ab)]:
|
||||
- @vercel/build-utils@7.7.0
|
||||
|
||||
## 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
|
||||
|
||||
- Updated dependencies [[`dfe47f6e6`](https://github.com/vercel/vercel/commit/dfe47f6e6c1d395ae24d802f4b7c98e39b9f90f4)]:
|
||||
- @vercel/build-utils@7.3.0
|
||||
|
||||
## 1.0.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`88da7463c`](https://github.com/vercel/vercel/commit/88da7463ce12df91d49fbde85cb617030d55f558)]:
|
||||
- @vercel/build-utils@7.2.5
|
||||
|
||||
## 1.0.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`65dec5b7e`](https://github.com/vercel/vercel/commit/65dec5b7e752f4da8fe0ffdb25215170453f6f8b)]:
|
||||
- @vercel/build-utils@7.2.4
|
||||
|
||||
## 1.0.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
10
internals/types/index.d.ts
vendored
10
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;
|
||||
|
||||
@@ -428,7 +433,8 @@ export type ProjectLinkedError = {
|
||||
| 'TEAM_DELETED'
|
||||
| 'PATH_IS_FILE'
|
||||
| 'INVALID_ROOT_DIRECTORY'
|
||||
| 'MISSING_PROJECT_SETTINGS';
|
||||
| 'MISSING_PROJECT_SETTINGS'
|
||||
| 'TOO_MANY_PROJECTS';
|
||||
};
|
||||
|
||||
export type ProjectLinkResult =
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "@vercel-internals/types",
|
||||
"version": "1.0.14",
|
||||
"version": "1.0.23",
|
||||
"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.2.3",
|
||||
"@vercel/build-utils": "7.7.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,67 @@
|
||||
# @vercel/build-utils
|
||||
|
||||
## 7.7.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Revert "Revert "Default ruby to only currently supported version (3.2.0)"" ([#11137](https://github.com/vercel/vercel/pull/11137))
|
||||
|
||||
## 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
|
||||
|
||||
- [cli] add `--deprecated` option to `vc project ls` command ([#10919](https://github.com/vercel/vercel/pull/10919))
|
||||
|
||||
## 7.2.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Remove Node.js v20 env var check ([#10834](https://github.com/vercel/vercel/pull/10834))
|
||||
|
||||
## 7.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Select Node.js version based on what's available in build-container ([#10822](https://github.com/vercel/vercel/pull/10822))
|
||||
|
||||
## 7.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/build-utils",
|
||||
"version": "7.2.3",
|
||||
"version": "7.7.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> {
|
||||
|
||||
@@ -1,60 +1,88 @@
|
||||
import { statSync } from 'fs';
|
||||
import { intersects, validRange } from 'semver';
|
||||
import { NodeVersion } from '../types';
|
||||
import { NowBuildError } from '../errors';
|
||||
import debug from '../debug';
|
||||
|
||||
export type NodeVersionMajor = ReturnType<typeof getOptions>[number]['major'];
|
||||
|
||||
export const NODE_VERSIONS: NodeVersion[] = [
|
||||
{ major: 20, range: '20.x', runtime: 'nodejs20.x' },
|
||||
{ major: 18, range: '18.x', runtime: 'nodejs18.x' },
|
||||
{
|
||||
major: 16,
|
||||
range: '16.x',
|
||||
runtime: 'nodejs16.x',
|
||||
discontinueDate: new Date('2024-06-15'),
|
||||
},
|
||||
{
|
||||
major: 14,
|
||||
range: '14.x',
|
||||
runtime: 'nodejs14.x',
|
||||
discontinueDate: new Date('2023-08-15'),
|
||||
},
|
||||
{
|
||||
major: 12,
|
||||
range: '12.x',
|
||||
runtime: 'nodejs12.x',
|
||||
discontinueDate: new Date('2022-10-03'),
|
||||
},
|
||||
{
|
||||
major: 10,
|
||||
range: '10.x',
|
||||
runtime: 'nodejs10.x',
|
||||
discontinueDate: new Date('2021-04-20'),
|
||||
},
|
||||
{
|
||||
major: 8,
|
||||
range: '8.10.x',
|
||||
runtime: 'nodejs8.10',
|
||||
discontinueDate: new Date('2020-01-06'),
|
||||
},
|
||||
];
|
||||
|
||||
function getOptions() {
|
||||
const options = [
|
||||
{ major: 18, range: '18.x', runtime: 'nodejs18.x' },
|
||||
{
|
||||
major: 16,
|
||||
range: '16.x',
|
||||
runtime: 'nodejs16.x',
|
||||
discontinueDate: new Date('2024-02-06'),
|
||||
},
|
||||
{
|
||||
major: 14,
|
||||
range: '14.x',
|
||||
runtime: 'nodejs14.x',
|
||||
discontinueDate: new Date('2023-08-15'),
|
||||
},
|
||||
{
|
||||
major: 12,
|
||||
range: '12.x',
|
||||
runtime: 'nodejs12.x',
|
||||
discontinueDate: new Date('2022-10-03'),
|
||||
},
|
||||
{
|
||||
major: 10,
|
||||
range: '10.x',
|
||||
runtime: 'nodejs10.x',
|
||||
discontinueDate: new Date('2021-04-20'),
|
||||
},
|
||||
{
|
||||
major: 8,
|
||||
range: '8.10.x',
|
||||
runtime: 'nodejs8.10',
|
||||
discontinueDate: new Date('2020-01-06'),
|
||||
},
|
||||
] as const;
|
||||
if (process.env.VERCEL_ALLOW_NODEJS20 === '1') {
|
||||
return [
|
||||
{ major: 20, range: '20.x', runtime: 'nodejs20.x' },
|
||||
...options,
|
||||
] as const;
|
||||
}
|
||||
return options;
|
||||
return NODE_VERSIONS;
|
||||
}
|
||||
|
||||
function getHint(isAuto = false) {
|
||||
const { major, range } = getLatestNodeVersion();
|
||||
function isNodeVersionAvailable(version: NodeVersion): boolean {
|
||||
try {
|
||||
return statSync(`/node${version.major}`).isDirectory();
|
||||
} catch {
|
||||
// ENOENT, or any other error, we don't care about
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getAvailableNodeVersions(): NodeVersionMajor[] {
|
||||
return getOptions()
|
||||
.filter(isNodeVersionAvailable)
|
||||
.map(n => n.major);
|
||||
}
|
||||
|
||||
function getHint(isAuto = false, availableVersions?: NodeVersionMajor[]) {
|
||||
const { major, range } = getLatestNodeVersion(availableVersions);
|
||||
return isAuto
|
||||
? `Please set Node.js Version to ${range} in your Project Settings to use Node.js ${major}.`
|
||||
: `Please set "engines": { "node": "${range}" } in your \`package.json\` file to use Node.js ${major}.`;
|
||||
}
|
||||
|
||||
export function getLatestNodeVersion() {
|
||||
return getOptions()[0];
|
||||
export function getLatestNodeVersion(availableVersions?: NodeVersionMajor[]) {
|
||||
const all = getOptions();
|
||||
if (availableVersions) {
|
||||
// Return the first node version that is definitely
|
||||
// available in the build-container.
|
||||
for (const version of all) {
|
||||
for (const major of availableVersions) {
|
||||
if (version.major === major) {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// As a fallback for local `vc build` and the tests,
|
||||
// return the first node version if none is found.
|
||||
return all[0];
|
||||
}
|
||||
|
||||
export function getDiscontinuedNodeVersions(): NodeVersion[] {
|
||||
@@ -63,9 +91,10 @@ export function getDiscontinuedNodeVersions(): NodeVersion[] {
|
||||
|
||||
export async function getSupportedNodeVersion(
|
||||
engineRange: string | undefined,
|
||||
isAuto = false
|
||||
isAuto = false,
|
||||
availableVersions?: NodeVersionMajor[]
|
||||
): Promise<NodeVersion> {
|
||||
let selection: NodeVersion = getLatestNodeVersion();
|
||||
let selection: NodeVersion | undefined;
|
||||
|
||||
if (engineRange) {
|
||||
const found =
|
||||
@@ -74,19 +103,29 @@ export async function getSupportedNodeVersion(
|
||||
// the array is already in order so return the first
|
||||
// match which will be the newest version of node
|
||||
selection = o;
|
||||
return intersects(o.range, engineRange);
|
||||
return (
|
||||
intersects(o.range, engineRange) &&
|
||||
(availableVersions?.length
|
||||
? availableVersions.includes(o.major)
|
||||
: true)
|
||||
);
|
||||
});
|
||||
if (!found) {
|
||||
throw new NowBuildError({
|
||||
code: 'BUILD_UTILS_NODE_VERSION_INVALID',
|
||||
link: 'http://vercel.link/node-version',
|
||||
message: `Found invalid Node.js Version: "${engineRange}". ${getHint(
|
||||
isAuto
|
||||
isAuto,
|
||||
availableVersions
|
||||
)}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!selection) {
|
||||
selection = getLatestNodeVersion(availableVersions);
|
||||
}
|
||||
|
||||
if (isDiscontinued(selection)) {
|
||||
const intro = `Node.js Version "${selection.range}" is discontinued and must be upgraded.`;
|
||||
throw new NowBuildError({
|
||||
|
||||
@@ -9,7 +9,11 @@ import { deprecate } from 'util';
|
||||
import debug from '../debug';
|
||||
import { NowBuildError } from '../errors';
|
||||
import { Meta, PackageJson, NodeVersion, Config } from '../types';
|
||||
import { getSupportedNodeVersion, getLatestNodeVersion } from './node-version';
|
||||
import {
|
||||
getSupportedNodeVersion,
|
||||
getLatestNodeVersion,
|
||||
getAvailableNodeVersions,
|
||||
} from './node-version';
|
||||
import { readConfigFile } from './read-config-file';
|
||||
import { cloneEnv } from '../clone-env';
|
||||
|
||||
@@ -238,9 +242,10 @@ export async function getNodeVersion(
|
||||
destPath: string,
|
||||
nodeVersionFallback = process.env.VERCEL_PROJECT_SETTINGS_NODE_VERSION,
|
||||
config: Config = {},
|
||||
meta: Meta = {}
|
||||
meta: Meta = {},
|
||||
availableVersions = getAvailableNodeVersions()
|
||||
): Promise<NodeVersion> {
|
||||
const latest = getLatestNodeVersion();
|
||||
const latest = getLatestNodeVersion(availableVersions);
|
||||
if (meta.isDev) {
|
||||
// Use the system-installed version of `node` in PATH for `vercel dev`
|
||||
return { ...latest, runtime: 'nodejs' };
|
||||
@@ -266,7 +271,7 @@ export async function getNodeVersion(
|
||||
nodeVersion = node;
|
||||
isAuto = false;
|
||||
}
|
||||
return getSupportedNodeVersion(nodeVersion, isAuto);
|
||||
return getSupportedNodeVersion(nodeVersion, isAuto, availableVersions);
|
||||
}
|
||||
|
||||
export async function scanParentDirs(
|
||||
@@ -297,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([
|
||||
@@ -333,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;
|
||||
@@ -409,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) {
|
||||
@@ -511,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,
|
||||
@@ -522,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';
|
||||
@@ -537,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 (
|
||||
@@ -548,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,
|
||||
@@ -104,3 +106,5 @@ export * from './should-serve';
|
||||
export * from './schemas';
|
||||
export * from './types';
|
||||
export * from './errors';
|
||||
|
||||
export { NODE_VERSIONS } from './fs/node-version';
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@ const skipFixtures: string[] = [
|
||||
'23-pnpm-workspaces',
|
||||
'41-nx-monorepo',
|
||||
'42-npm-workspace-with-nx',
|
||||
'jekyll-v4',
|
||||
'middleman-v4',
|
||||
];
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
247
packages/build-utils/test/unit.test.ts
vendored
247
packages/build-utils/test/unit.test.ts
vendored
@@ -60,7 +60,7 @@ it('should only match supported node versions, otherwise throw an error', async
|
||||
);
|
||||
|
||||
const autoMessage =
|
||||
'Please set Node.js Version to 18.x in your Project Settings to use Node.js 18.';
|
||||
'Please set Node.js Version to 20.x in your Project Settings to use Node.js 20.';
|
||||
await expectBuilderError(
|
||||
getSupportedNodeVersion('8.11.x', true),
|
||||
autoMessage
|
||||
@@ -80,7 +80,7 @@ it('should only match supported node versions, otherwise throw an error', async
|
||||
);
|
||||
|
||||
const foundMessage =
|
||||
'Please set "engines": { "node": "18.x" } in your `package.json` file to use Node.js 18.';
|
||||
'Please set "engines": { "node": "20.x" } in your `package.json` file to use Node.js 20.';
|
||||
await expectBuilderError(
|
||||
getSupportedNodeVersion('8.11.x', false),
|
||||
foundMessage
|
||||
@@ -101,8 +101,8 @@ it('should match all semver ranges', async () => {
|
||||
// See https://docs.npmjs.com/files/package.json#engines
|
||||
expect(await getSupportedNodeVersion('16.0.0')).toHaveProperty('major', 16);
|
||||
expect(await getSupportedNodeVersion('16.x')).toHaveProperty('major', 16);
|
||||
expect(await getSupportedNodeVersion('>=10')).toHaveProperty('major', 18);
|
||||
expect(await getSupportedNodeVersion('>=10.3.0')).toHaveProperty('major', 18);
|
||||
expect(await getSupportedNodeVersion('>=10')).toHaveProperty('major', 20);
|
||||
expect(await getSupportedNodeVersion('>=10.3.0')).toHaveProperty('major', 20);
|
||||
expect(await getSupportedNodeVersion('16.5.0 - 16.9.0')).toHaveProperty(
|
||||
'major',
|
||||
16
|
||||
@@ -120,11 +120,33 @@ it('should match all semver ranges', async () => {
|
||||
});
|
||||
|
||||
it('should allow nodejs18.x', async () => {
|
||||
expect(getLatestNodeVersion()).toHaveProperty('major', 18);
|
||||
expect(await getSupportedNodeVersion('18.x')).toHaveProperty('major', 18);
|
||||
expect(await getSupportedNodeVersion('18')).toHaveProperty('major', 18);
|
||||
expect(await getSupportedNodeVersion('18.1.0')).toHaveProperty('major', 18);
|
||||
expect(await getSupportedNodeVersion('>=16')).toHaveProperty('major', 18);
|
||||
});
|
||||
|
||||
it('should allow nodejs20.x', async () => {
|
||||
expect(getLatestNodeVersion()).toHaveProperty('major', 20);
|
||||
expect(await getSupportedNodeVersion('20.x')).toHaveProperty('major', 20);
|
||||
expect(await getSupportedNodeVersion('20')).toHaveProperty('major', 20);
|
||||
expect(await getSupportedNodeVersion('20.1.0')).toHaveProperty('major', 20);
|
||||
expect(await getSupportedNodeVersion('>=18')).toHaveProperty('major', 20);
|
||||
});
|
||||
|
||||
it('should not allow nodejs20.x when not available', async () => {
|
||||
// Simulates AL2 build-container
|
||||
await expect(
|
||||
getSupportedNodeVersion('20.x', true, [14, 16, 18])
|
||||
).rejects.toThrow(
|
||||
'Found invalid Node.js Version: "20.x". Please set Node.js Version to 18.x in your Project Settings to use Node.js 18.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should not allow nodejs18.x when not available', async () => {
|
||||
// Simulates AL2023 build-container
|
||||
await expect(getSupportedNodeVersion('18.x', true, [20])).rejects.toThrow(
|
||||
'Found invalid Node.js Version: "18.x". Please set Node.js Version to 20.x in your Project Settings to use Node.js 20.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should ignore node version in vercel dev getNodeVersion()', async () => {
|
||||
@@ -193,7 +215,7 @@ it('should warn when package.json engines is greater than', async () => {
|
||||
{},
|
||||
{}
|
||||
)
|
||||
).toHaveProperty('range', '18.x');
|
||||
).toHaveProperty('range', '20.x');
|
||||
expect(warningMessages).toStrictEqual([
|
||||
'Warning: Detected "engines": { "node": ">=16" } in your `package.json` that will automatically upgrade when a new major Node.js Version is released. Learn More: http://vercel.link/node-version',
|
||||
]);
|
||||
@@ -232,101 +254,98 @@ it('should not warn when package.json engines matches project setting from confi
|
||||
});
|
||||
|
||||
it('should get latest node version', async () => {
|
||||
expect(getLatestNodeVersion()).toHaveProperty('major', 18);
|
||||
expect(getLatestNodeVersion()).toHaveProperty('major', 20);
|
||||
});
|
||||
|
||||
it('should get latest node version with Node 18.x in build-container', async () => {
|
||||
// Simulates AL2 build-container
|
||||
expect(getLatestNodeVersion([14, 16, 18])).toHaveProperty('major', 18);
|
||||
});
|
||||
|
||||
it('should get latest node version with Node 20.x in build-container', async () => {
|
||||
// Simulates AL2023 build-container
|
||||
expect(getLatestNodeVersion([20])).toHaveProperty('major', 20);
|
||||
});
|
||||
|
||||
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();
|
||||
|
||||
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": "18.x" } in your `package.json` file to use Node.js 18.',
|
||||
'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 18.x in your Project Settings to use Node.js 18.',
|
||||
'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": "18.x" } in your `package.json` file to use Node.js 18.',
|
||||
'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 18.x in your Project Settings to use Node.js 18.',
|
||||
'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": "18.x" } in your `package.json` file to use Node.js 18.',
|
||||
'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 18.x in your Project Settings to use Node.js 18.',
|
||||
'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": "18.x" } in your `package.json` file to use Node.js 18.',
|
||||
'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 18.x in your Project Settings to use Node.js 18.',
|
||||
]);
|
||||
|
||||
global.Date.now = realDateNow;
|
||||
});
|
||||
|
||||
it('should only allow nodejs20.x when env var is set', async () => {
|
||||
// Mock a future date so that Node 16 warns
|
||||
const realDateNow = Date.now;
|
||||
try {
|
||||
expect(getLatestNodeVersion()).toHaveProperty('major', 18);
|
||||
await expect(getSupportedNodeVersion('20.x')).rejects.toThrow();
|
||||
global.Date.now = () => new Date('2021-02-23').getTime();
|
||||
|
||||
process.env.VERCEL_ALLOW_NODEJS20 = '1';
|
||||
|
||||
expect(getLatestNodeVersion()).toHaveProperty('major', 20);
|
||||
expect(await getSupportedNodeVersion('20.x')).toHaveProperty('major', 20);
|
||||
expect(await getSupportedNodeVersion('20')).toHaveProperty('major', 20);
|
||||
expect(await getSupportedNodeVersion('20.1.0')).toHaveProperty('major', 20);
|
||||
expect(await getSupportedNodeVersion('>=16')).toHaveProperty('major', 20);
|
||||
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 {
|
||||
delete process.env.VERCEL_ALLOW_NODEJS20;
|
||||
global.Date.now = realDateNow;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -557,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,232 @@
|
||||
# vercel
|
||||
|
||||
## 33.5.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- build: upgrade edge-runtime ([#11148](https://github.com/vercel/vercel/pull/11148))
|
||||
|
||||
- Updated dependencies [[`24c3dd282`](https://github.com/vercel/vercel/commit/24c3dd282d7714cd63d2b94fb94745c45fdc79ab), [`10e200e0b`](https://github.com/vercel/vercel/commit/10e200e0bf8f692b6740e098e0572b4e7de83850), [`678ebbe52`](https://github.com/vercel/vercel/commit/678ebbe5255766656bf2dddc574e86b2999f11c8)]:
|
||||
- @vercel/build-utils@7.7.0
|
||||
- @vercel/static-build@2.4.0
|
||||
- @vercel/node@3.0.19
|
||||
|
||||
## 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
|
||||
|
||||
- [cli] add `--deprecated` option to `vc project ls` command ([#10919](https://github.com/vercel/vercel/pull/10919))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Remove some debug statements and make log into warning ([#10926](https://github.com/vercel/vercel/pull/10926))
|
||||
|
||||
- Updated dependencies [[`3cede43ca`](https://github.com/vercel/vercel/commit/3cede43ca7ea3aec3ff33864b7d33da57891ddb2), [`dfe47f6e6`](https://github.com/vercel/vercel/commit/dfe47f6e6c1d395ae24d802f4b7c98e39b9f90f4), [`1dbb22bb6`](https://github.com/vercel/vercel/commit/1dbb22bb6d33657faa78376f527fe350188c5257), [`204c3592c`](https://github.com/vercel/vercel/commit/204c3592c78fc544e62f0210b0e7e1e4cd382a0c)]:
|
||||
- @vercel/ruby@2.0.4
|
||||
- @vercel/build-utils@7.3.0
|
||||
- @vercel/remix-builder@2.0.13
|
||||
- @vercel/node@3.0.12
|
||||
- @vercel/static-build@2.0.14
|
||||
|
||||
## 32.6.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Revert "forbids globally installed @vercel/speed-insights and @vercel/analytics (#10848)" ([#10895](https://github.com/vercel/vercel/pull/10895))
|
||||
|
||||
## 32.6.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- forbids globally installed @vercel/speed-insights and @vercel/analytics ([#10848](https://github.com/vercel/vercel/pull/10848))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [cli] Fix behavior for combination of northstar user + team scope provided to cli as an argument. ([#10884](https://github.com/vercel/vercel/pull/10884))
|
||||
|
||||
- Updated dependencies [[`4edfcd74b`](https://github.com/vercel/vercel/commit/4edfcd74b6dfd8e9cbc05a71d47578051a2a7d63), [`0e9bb30fd`](https://github.com/vercel/vercel/commit/0e9bb30fd285492beadc365bece2ab1df67b387b), [`ca2cbf06f`](https://github.com/vercel/vercel/commit/ca2cbf06fbf252e23aff6e007d0df5ffc243b56e), [`c52bdf775`](https://github.com/vercel/vercel/commit/c52bdf77585dfa41b25cabe2f9403827d0964169)]:
|
||||
- @vercel/remix-builder@2.0.12
|
||||
- @vercel/static-build@2.0.13
|
||||
- @vercel/go@3.0.4
|
||||
|
||||
## 32.5.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`ffd2f34c6`](https://github.com/vercel/vercel/commit/ffd2f34c6c3d53bbb673aa3241845abc50e67c5e), [`4636ae54c`](https://github.com/vercel/vercel/commit/4636ae54c6c17709c1a058169cdca19c3df73ddb)]:
|
||||
- @vercel/next@4.0.15
|
||||
- @vercel/ruby@2.0.3
|
||||
|
||||
## 32.5.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`88da7463c`](https://github.com/vercel/vercel/commit/88da7463ce12df91d49fbde85cb617030d55f558)]:
|
||||
- @vercel/build-utils@7.2.5
|
||||
- @vercel/node@3.0.11
|
||||
- @vercel/static-build@2.0.12
|
||||
|
||||
## 32.5.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`65dec5b7e`](https://github.com/vercel/vercel/commit/65dec5b7e752f4da8fe0ffdb25215170453f6f8b)]:
|
||||
- @vercel/build-utils@7.2.4
|
||||
- @vercel/node@3.0.10
|
||||
- @vercel/static-build@2.0.11
|
||||
|
||||
## 32.5.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Handle `TooManyProjects` error in places where projects are created ([#10807](https://github.com/vercel/vercel/pull/10807))
|
||||
|
||||
- Updated dependencies [[`89c1e0323`](https://github.com/vercel/vercel/commit/89c1e032335d9ec0fcfc84fe499cf004fe73fafc), [`fd29b966d`](https://github.com/vercel/vercel/commit/fd29b966d39776318b0e11a53909edb43d1fc5f2)]:
|
||||
- @vercel/node@3.0.9
|
||||
- @vercel/next@4.0.14
|
||||
|
||||
## 32.5.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`c94a082f6`](https://github.com/vercel/vercel/commit/c94a082f6bb1b84eaf420ac47ea83640dc83668e)]:
|
||||
- @vercel/next@4.0.13
|
||||
|
||||
## 32.5.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vercel",
|
||||
"version": "32.5.1",
|
||||
"version": "33.5.1",
|
||||
"preferGlobal": true,
|
||||
"license": "Apache-2.0",
|
||||
"description": "The command-line interface for Vercel",
|
||||
@@ -31,22 +31,22 @@
|
||||
"node": ">= 16"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/build-utils": "7.2.3",
|
||||
"@vercel/build-utils": "7.7.0",
|
||||
"@vercel/fun": "1.1.0",
|
||||
"@vercel/go": "3.0.3",
|
||||
"@vercel/hydrogen": "1.0.1",
|
||||
"@vercel/next": "4.0.12",
|
||||
"@vercel/node": "3.0.8",
|
||||
"@vercel/python": "4.1.0",
|
||||
"@vercel/redwood": "2.0.5",
|
||||
"@vercel/remix-builder": "2.0.11",
|
||||
"@vercel/ruby": "2.0.2",
|
||||
"@vercel/static-build": "2.0.10",
|
||||
"@vercel/go": "3.0.5",
|
||||
"@vercel/hydrogen": "1.0.2",
|
||||
"@vercel/next": "4.1.1",
|
||||
"@vercel/node": "3.0.19",
|
||||
"@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.4.0",
|
||||
"chokidar": "3.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@alex_neo/jest-expect-message": "1.0.5",
|
||||
"@edge-runtime/node-utils": "2.2.2",
|
||||
"@edge-runtime/node-utils": "2.3.0",
|
||||
"@next/env": "11.1.2",
|
||||
"@sentry/node": "5.5.0",
|
||||
"@sindresorhus/slugify": "0.11.0",
|
||||
@@ -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.14",
|
||||
"@vercel/client": "13.0.7",
|
||||
"@vercel-internals/types": "1.0.23",
|
||||
"@vercel/client": "13.1.3",
|
||||
"@vercel/error-utils": "2.0.2",
|
||||
"@vercel/frameworks": "2.0.3",
|
||||
"@vercel/fs-detectors": "5.1.3",
|
||||
"@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);
|
||||
|
||||
@@ -3,6 +3,7 @@ import ms from 'ms';
|
||||
import Client from '../../util/client';
|
||||
import { isAPIError } from '../../util/errors-ts';
|
||||
import { getCommandName } from '../../util/pkg-name';
|
||||
import createProject from '../../util/projects/create-project';
|
||||
|
||||
export default async function add(
|
||||
client: Client,
|
||||
@@ -32,12 +33,14 @@ export default async function add(
|
||||
const start = Date.now();
|
||||
|
||||
const [name] = args;
|
||||
|
||||
try {
|
||||
await client.fetch('/projects', {
|
||||
method: 'POST',
|
||||
body: { name },
|
||||
});
|
||||
await createProject(client, { name });
|
||||
} catch (err: unknown) {
|
||||
if (isAPIError(err) && err.code === 'too_many_projects') {
|
||||
output.prettyError(err);
|
||||
return 1;
|
||||
}
|
||||
if (isAPIError(err) && err.status === 409) {
|
||||
// project already exists, so we can
|
||||
// show a success message
|
||||
|
||||
@@ -15,7 +15,17 @@ export const projectCommand: Command = {
|
||||
name: 'ls',
|
||||
description: 'Show all projects in the selected scope',
|
||||
arguments: [],
|
||||
options: [],
|
||||
options: [
|
||||
{
|
||||
name: 'update-required',
|
||||
description: 'A list of projects affected by an upcoming deprecation',
|
||||
argument: 'update-required',
|
||||
shorthand: null,
|
||||
type: 'boolean',
|
||||
deprecated: false,
|
||||
multi: false,
|
||||
},
|
||||
],
|
||||
examples: [],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ export default async function main(client: Client) {
|
||||
argv = getArgs(client.argv.slice(2), {
|
||||
'--next': Number,
|
||||
'-N': '--next',
|
||||
'--update-required': Boolean,
|
||||
});
|
||||
} catch (error) {
|
||||
handleError(error);
|
||||
|
||||
@@ -6,6 +6,7 @@ import Client from '../../util/client';
|
||||
import getCommandFlags from '../../util/get-command-flags';
|
||||
import { getCommandName } from '../../util/pkg-name';
|
||||
import strlen from '../../util/strlen';
|
||||
import { NODE_VERSIONS } from '@vercel/build-utils';
|
||||
|
||||
export default async function list(
|
||||
client: Client,
|
||||
@@ -27,14 +28,19 @@ 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 {
|
||||
let {
|
||||
projects: projectList,
|
||||
pagination,
|
||||
}: {
|
||||
@@ -48,10 +54,34 @@ export default async function list(
|
||||
|
||||
const elapsed = ms(Date.now() - start);
|
||||
|
||||
if (deprecated) {
|
||||
const upcomingDeprecationVersionsList = [];
|
||||
|
||||
for (const nodeVersion of NODE_VERSIONS) {
|
||||
if (
|
||||
nodeVersion.discontinueDate &&
|
||||
nodeVersion.discontinueDate.valueOf() > Date.now()
|
||||
) {
|
||||
upcomingDeprecationVersionsList.push(nodeVersion.range);
|
||||
}
|
||||
}
|
||||
|
||||
output.warn(
|
||||
`The following Node.js versions will be deprecated soon: ${upcomingDeprecationVersionsList.join(
|
||||
', '
|
||||
)}. Please upgrade your projects immediately.`
|
||||
);
|
||||
output.log(
|
||||
`For more information visit: https://vercel.com/docs/functions/serverless-functions/runtimes/node-js#node.js-version`
|
||||
);
|
||||
}
|
||||
|
||||
output.log(
|
||||
`${
|
||||
projectList.length > 0 ? 'Projects' : 'No projects'
|
||||
} found under ${chalk.bold(contextName)} ${chalk.gray(`[${elapsed}]`)}`
|
||||
} found under ${chalk.bold(contextName)} ${
|
||||
deprecated ? 'that are using a deprecated Node.js version' : '\b'
|
||||
} ${chalk.gray(`[${elapsed}]`)}`
|
||||
);
|
||||
|
||||
if (projectList.length > 0) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -43,10 +43,13 @@ export default async function selectOrg(
|
||||
})),
|
||||
];
|
||||
|
||||
const defaultOrgIndex = teams.findIndex(team => team.id === currentTeam) + 1;
|
||||
const defaultChoiceIndex = Math.max(
|
||||
choices.findIndex(choice => choice.value.id === currentTeam),
|
||||
0
|
||||
);
|
||||
|
||||
if (autoConfirm) {
|
||||
return choices[defaultOrgIndex].value;
|
||||
return choices[defaultChoiceIndex].value;
|
||||
}
|
||||
|
||||
const answers = await client.prompt({
|
||||
@@ -54,7 +57,7 @@ export default async function selectOrg(
|
||||
name: 'org',
|
||||
message: question,
|
||||
choices,
|
||||
default: defaultOrgIndex,
|
||||
default: defaultChoiceIndex,
|
||||
});
|
||||
|
||||
const org = answers.org;
|
||||
|
||||
@@ -21,6 +21,7 @@ import createProject from '../projects/create-project';
|
||||
import { detectProjects } from '../projects/detect-projects';
|
||||
import { repoInfoToUrl } from '../git/repo-info-to-url';
|
||||
import { connectGitProvider, parseRepoUrl } from '../git/connect-git-provider';
|
||||
import { isAPIError } from '../errors-ts';
|
||||
|
||||
const home = homedir();
|
||||
|
||||
@@ -283,24 +284,31 @@ export async function ensureRepoLink(
|
||||
output.spinner(`Creating new Project: ${orgAndName}`);
|
||||
delete selection.newProject;
|
||||
if (!selection.rootDirectory) delete selection.rootDirectory;
|
||||
const project = (selected[i] = await createProject(client, {
|
||||
...selection,
|
||||
framework: selection.framework.slug,
|
||||
}));
|
||||
await connectGitProvider(
|
||||
client,
|
||||
org,
|
||||
project.id,
|
||||
parsedRepoUrl.provider,
|
||||
`${parsedRepoUrl.org}/${parsedRepoUrl.repo}`
|
||||
);
|
||||
output.log(
|
||||
`Created new Project: ${output.link(
|
||||
orgAndName,
|
||||
`https://vercel.com/${orgAndName}`,
|
||||
{ fallback: false }
|
||||
)}`
|
||||
);
|
||||
try {
|
||||
const project = (selected[i] = await createProject(client, {
|
||||
...selection,
|
||||
framework: selection.framework.slug,
|
||||
}));
|
||||
await connectGitProvider(
|
||||
client,
|
||||
org,
|
||||
project.id,
|
||||
parsedRepoUrl.provider,
|
||||
`${parsedRepoUrl.org}/${parsedRepoUrl.repo}`
|
||||
);
|
||||
output.log(
|
||||
`Created new Project: ${output.link(
|
||||
orgAndName,
|
||||
`https://vercel.com/${orgAndName}`,
|
||||
{ fallback: false }
|
||||
)}`
|
||||
);
|
||||
} catch (err) {
|
||||
if (isAPIError(err) && err.code === 'too_many_projects') {
|
||||
output.prettyError(err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repoConfig = {
|
||||
|
||||
@@ -263,6 +263,10 @@ export default async function setupAndLink(
|
||||
|
||||
return { status: 'linked', org, project };
|
||||
} catch (err) {
|
||||
if (isAPIError(err) && err.code === 'too_many_projects') {
|
||||
output.prettyError(err);
|
||||
return { status: 'error', exitCode: 1, reason: 'TOO_MANY_PROJECTS' };
|
||||
}
|
||||
handleError(err);
|
||||
|
||||
return { status: 'error', exitCode: 1 };
|
||||
|
||||
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({
|
||||
|
||||
92
packages/cli/test/integration-1.test.ts
vendored
92
packages/cli/test/integration-1.test.ts
vendored
@@ -238,51 +238,59 @@ test('[vc build] should build project with corepack and select npm@8.1.0', async
|
||||
});
|
||||
|
||||
test('[vc build] should build project with corepack and select pnpm@7.1.0', async () => {
|
||||
process.env.ENABLE_EXPERIMENTAL_COREPACK = '1';
|
||||
const directory = await setupE2EFixture('vc-build-corepack-pnpm');
|
||||
const before = await exec(directory, 'pnpm', ['--version']);
|
||||
const output = await execCli(binaryPath, ['build'], { cwd: directory });
|
||||
expect(output.exitCode, formatOutput(output)).toBe(0);
|
||||
expect(output.stderr).toMatch(/Build Completed/gm);
|
||||
const after = await exec(directory, 'pnpm', ['--version']);
|
||||
// Ensure global pnpm didn't change
|
||||
expect(before.stdout).toBe(after.stdout);
|
||||
// Ensure version is correct
|
||||
expect(
|
||||
await fs.readFile(
|
||||
path.join(directory, '.vercel/output/static/index.txt'),
|
||||
'utf8'
|
||||
)
|
||||
).toBe('7.1.0\n');
|
||||
// Ensure corepack will be cached
|
||||
const contents = fs.readdirSync(
|
||||
path.join(directory, '.vercel/cache/corepack')
|
||||
);
|
||||
expect(contents).toEqual(['home', 'shim']);
|
||||
try {
|
||||
process.env.ENABLE_EXPERIMENTAL_COREPACK = '1';
|
||||
const directory = await setupE2EFixture('vc-build-corepack-pnpm');
|
||||
const before = await exec(directory, 'pnpm', ['--version']);
|
||||
const output = await execCli(binaryPath, ['build'], { cwd: directory });
|
||||
expect(output.exitCode, formatOutput(output)).toBe(0);
|
||||
expect(output.stderr).toMatch(/Build Completed/gm);
|
||||
const after = await exec(directory, 'pnpm', ['--version']);
|
||||
// Ensure global pnpm didn't change
|
||||
expect(before.stdout).toBe(after.stdout);
|
||||
// Ensure version is correct
|
||||
expect(
|
||||
await fs.readFile(
|
||||
path.join(directory, '.vercel/output/static/index.txt'),
|
||||
'utf8'
|
||||
)
|
||||
).toBe('7.1.0\n');
|
||||
// Ensure corepack will be cached
|
||||
const contents = fs.readdirSync(
|
||||
path.join(directory, '.vercel/cache/corepack')
|
||||
);
|
||||
expect(contents).toEqual(['home', 'shim']);
|
||||
} finally {
|
||||
delete process.env.ENABLE_EXPERIMENTAL_COREPACK;
|
||||
}
|
||||
});
|
||||
|
||||
test('[vc build] should build project with corepack and select yarn@2.4.3', async () => {
|
||||
process.env.ENABLE_EXPERIMENTAL_COREPACK = '1';
|
||||
const directory = await setupE2EFixture('vc-build-corepack-yarn');
|
||||
const before = await exec(directory, 'yarn', ['--version']);
|
||||
const output = await execCli(binaryPath, ['build'], { cwd: directory });
|
||||
expect(output.exitCode, formatOutput(output)).toBe(0);
|
||||
expect(output.stderr).toMatch(/Build Completed/gm);
|
||||
const after = await exec(directory, 'yarn', ['--version']);
|
||||
// Ensure global yarn didn't change
|
||||
expect(before.stdout).toBe(after.stdout);
|
||||
// Ensure version is correct
|
||||
expect(
|
||||
await fs.readFile(
|
||||
path.join(directory, '.vercel/output/static/index.txt'),
|
||||
'utf8'
|
||||
)
|
||||
).toBe('2.4.3\n');
|
||||
// Ensure corepack will be cached
|
||||
const contents = fs.readdirSync(
|
||||
path.join(directory, '.vercel/cache/corepack')
|
||||
);
|
||||
expect(contents).toEqual(['home', 'shim']);
|
||||
try {
|
||||
process.env.ENABLE_EXPERIMENTAL_COREPACK = '1';
|
||||
const directory = await setupE2EFixture('vc-build-corepack-yarn');
|
||||
const before = await exec(directory, 'yarn', ['--version']);
|
||||
const output = await execCli(binaryPath, ['build'], { cwd: directory });
|
||||
expect(output.exitCode, formatOutput(output)).toBe(0);
|
||||
expect(output.stderr).toMatch(/Build Completed/gm);
|
||||
const after = await exec(directory, 'yarn', ['--version']);
|
||||
// Ensure global yarn didn't change
|
||||
expect(before.stdout).toBe(after.stdout);
|
||||
// Ensure version is correct
|
||||
expect(
|
||||
await fs.readFile(
|
||||
path.join(directory, '.vercel/output/static/index.txt'),
|
||||
'utf8'
|
||||
)
|
||||
).toBe('2.4.3\n');
|
||||
// Ensure corepack will be cached
|
||||
const contents = fs.readdirSync(
|
||||
path.join(directory, '.vercel/cache/corepack')
|
||||
);
|
||||
expect(contents).toEqual(['home', 'shim']);
|
||||
} finally {
|
||||
delete process.env.ENABLE_EXPERIMENTAL_COREPACK;
|
||||
}
|
||||
});
|
||||
|
||||
test('[vc dev] should print help from `vc develop --help`', async () => {
|
||||
|
||||
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 () => {
|
||||
|
||||
@@ -353,11 +353,11 @@ export function useProject(
|
||||
});
|
||||
client.scenario.get(`/v4/projects`, (req, res) => {
|
||||
res.json({
|
||||
projects: [defaultProject],
|
||||
projects: [project],
|
||||
pagination: null,
|
||||
});
|
||||
});
|
||||
client.scenario.post(`/projects`, (req, res) => {
|
||||
client.scenario.post(`/v1/projects`, (req, res) => {
|
||||
const { name } = req.body;
|
||||
if (name === project.name) {
|
||||
res.json(project);
|
||||
|
||||
@@ -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'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -5,10 +5,7 @@ import { useTeams } from '../../mocks/team';
|
||||
import { defaultProject, useProject } from '../../mocks/project';
|
||||
import { client } from '../../mocks/client';
|
||||
import type { Project } from '@vercel-internals/types';
|
||||
import {
|
||||
pluckIdentifiersFromDeploymentList,
|
||||
parseSpacedTableRow,
|
||||
} from '../../helpers/parse-table';
|
||||
import { parseSpacedTableRow } from '../../helpers/parse-table';
|
||||
|
||||
describe('project', () => {
|
||||
describe('list', () => {
|
||||
@@ -28,8 +25,7 @@ describe('project', () => {
|
||||
expect(line.value).toEqual(`Fetching projects in ${user.username}`);
|
||||
|
||||
line = await lines.next();
|
||||
const { org } = pluckIdentifiersFromDeploymentList(line.value!);
|
||||
expect(org).toEqual(user.username);
|
||||
expect(line.value).toContain(user.username);
|
||||
|
||||
// empty line
|
||||
line = await lines.next();
|
||||
@@ -49,6 +45,55 @@ describe('project', () => {
|
||||
expect(data).toEqual([project.project.name, 'https://foobar.com']);
|
||||
});
|
||||
|
||||
it('should list projects running on an soon-to-be-deprecated Node.js version', async () => {
|
||||
jest.useFakeTimers().setSystemTime(new Date('2023-12-08'));
|
||||
|
||||
const user = useUser();
|
||||
useTeams('team_dummy');
|
||||
const project = useProject({
|
||||
...defaultProject,
|
||||
nodeVersion: '16.x',
|
||||
});
|
||||
|
||||
client.setArgv('project', 'ls', '--update-required');
|
||||
await projects(client);
|
||||
|
||||
const lines = createLineIterator(client.stderr);
|
||||
|
||||
let line = await lines.next();
|
||||
expect(line.value).toEqual(`Fetching projects in ${user.username}`);
|
||||
|
||||
line = await lines.next();
|
||||
expect(line.value).toEqual(
|
||||
'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(
|
||||
'> For more information visit: https://vercel.com/docs/functions/serverless-functions/runtimes/node-js#node.js-version'
|
||||
);
|
||||
line = await lines.next();
|
||||
expect(line.value).toContain(user.username);
|
||||
|
||||
// empty line
|
||||
line = await lines.next();
|
||||
expect(line.value).toEqual('');
|
||||
|
||||
line = await lines.next();
|
||||
const header = parseSpacedTableRow(line.value!);
|
||||
expect(header).toEqual([
|
||||
'Project Name',
|
||||
'Latest Production URL',
|
||||
'Updated',
|
||||
]);
|
||||
|
||||
line = await lines.next();
|
||||
const data = parseSpacedTableRow(line.value!);
|
||||
data.pop();
|
||||
expect(data).toEqual([project.project.name, 'https://foobar.com']);
|
||||
|
||||
jest.clearAllTimers();
|
||||
});
|
||||
|
||||
it('should list projects when there is no production deployment', async () => {
|
||||
const user = useUser();
|
||||
useTeams('team_dummy');
|
||||
@@ -66,8 +111,7 @@ describe('project', () => {
|
||||
expect(line.value).toEqual(`Fetching projects in ${user.username}`);
|
||||
|
||||
line = await lines.next();
|
||||
const { org } = pluckIdentifiersFromDeploymentList(line.value!);
|
||||
expect(org).toEqual(user.username);
|
||||
expect(line.value).toContain(user.username);
|
||||
|
||||
// empty line
|
||||
line = await lines.next();
|
||||
|
||||
@@ -4,10 +4,19 @@ import { useTeams } from '../../../mocks/team';
|
||||
import { useUser } from '../../../mocks/user';
|
||||
|
||||
describe('selectOrg', () => {
|
||||
let user;
|
||||
let team;
|
||||
|
||||
beforeEach(() => {
|
||||
team = useTeams()[0];
|
||||
});
|
||||
|
||||
describe('non-northstar', () => {
|
||||
beforeEach(() => {
|
||||
user = useUser();
|
||||
});
|
||||
|
||||
it('should allow selecting user', async () => {
|
||||
const user = useUser();
|
||||
useTeams();
|
||||
const selectOrgPromise = selectOrg(client, 'Select the scope');
|
||||
await expect(client.stderr).toOutput(user.name);
|
||||
client.stdin.write('\r'); // Return key
|
||||
@@ -15,26 +24,71 @@ describe('selectOrg', () => {
|
||||
});
|
||||
|
||||
it('should allow selecting team', async () => {
|
||||
useUser();
|
||||
const team = useTeams()[0];
|
||||
const selectOrgPromise = selectOrg(client, 'Select the scope');
|
||||
await expect(client.stderr).toOutput('Select the scope');
|
||||
client.stdin.write('\x1B[B'); // Down arrow
|
||||
client.stdin.write('\r'); // Return key
|
||||
await expect(selectOrgPromise).resolves.toHaveProperty('id', team.id);
|
||||
});
|
||||
|
||||
it('automatically selects the correct scope when autoconfirm flag is passed', async () => {
|
||||
const selectOrgPromise = selectOrg(client, 'Select the scope', true);
|
||||
await expect(selectOrgPromise).resolves.toHaveProperty('id', user.id);
|
||||
});
|
||||
|
||||
describe('with a selected team scope', () => {
|
||||
beforeEach(() => {
|
||||
client.config.currentTeam = team.id;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete client.config.currentTeam;
|
||||
});
|
||||
|
||||
it('should allow selecting user', async () => {
|
||||
const selectOrgPromise = selectOrg(client, 'Select the scope');
|
||||
await expect(client.stderr).toOutput(user.name);
|
||||
client.stdin.write('\r'); // Return key
|
||||
await expect(selectOrgPromise).resolves.toHaveProperty('id', team.id);
|
||||
});
|
||||
|
||||
it('should allow selecting team', async () => {
|
||||
const selectOrgPromise = selectOrg(client, 'Select the scope');
|
||||
await expect(client.stderr).toOutput('Select the scope');
|
||||
client.stdin.write('\x1B[B'); // Down arrow
|
||||
client.stdin.write('\r'); // Return key
|
||||
await expect(selectOrgPromise).resolves.toHaveProperty('id', user.id);
|
||||
});
|
||||
|
||||
it('automatically selects the correct scope when autoconfirm flag is passed', async () => {
|
||||
const selectOrgPromise = selectOrg(client, 'Select the scope', true);
|
||||
await expect(selectOrgPromise).resolves.toHaveProperty('id', team.id);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('northstar', () => {
|
||||
it('should not allow selecting user', async () => {
|
||||
const user = useUser({
|
||||
beforeEach(() => {
|
||||
user = useUser({
|
||||
version: 'northstar',
|
||||
});
|
||||
const team = useTeams()[0];
|
||||
client.config.currentTeam = team.id;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete client.config.currentTeam;
|
||||
});
|
||||
|
||||
it('should not allow selecting user', async () => {
|
||||
const selectOrgPromise = selectOrg(client, 'Select the scope');
|
||||
await expect(client.stderr).not.toOutput(user.name);
|
||||
client.stdin.write('\r'); // Return key
|
||||
await expect(selectOrgPromise).resolves.toHaveProperty('id', team.id);
|
||||
});
|
||||
|
||||
it('automatically selects the correct scope when autoconfirm flag is passed', async () => {
|
||||
const selectOrgPromise = selectOrg(client, 'Select the scope', true);
|
||||
await expect(selectOrgPromise).resolves.toHaveProperty('id', team.id);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,80 @@
|
||||
# @vercel/client
|
||||
|
||||
## 13.1.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`24c3dd282`](https://github.com/vercel/vercel/commit/24c3dd282d7714cd63d2b94fb94745c45fdc79ab)]:
|
||||
- @vercel/build-utils@7.7.0
|
||||
|
||||
## 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
|
||||
|
||||
- Updated dependencies [[`dfe47f6e6`](https://github.com/vercel/vercel/commit/dfe47f6e6c1d395ae24d802f4b7c98e39b9f90f4)]:
|
||||
- @vercel/build-utils@7.3.0
|
||||
|
||||
## 13.0.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`88da7463c`](https://github.com/vercel/vercel/commit/88da7463ce12df91d49fbde85cb617030d55f558)]:
|
||||
- @vercel/build-utils@7.2.5
|
||||
|
||||
## 13.0.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`65dec5b7e`](https://github.com/vercel/vercel/commit/65dec5b7e752f4da8fe0ffdb25215170453f6f8b)]:
|
||||
- @vercel/build-utils@7.2.4
|
||||
|
||||
## 13.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/client",
|
||||
"version": "13.0.7",
|
||||
"version": "13.1.3",
|
||||
"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.2.3",
|
||||
"@vercel/build-utils": "7.7.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"
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user