Compare commits

..

24 Commits

Author SHA1 Message Date
Chris Barber
9019810288 Move tsc options to tsconfig 2023-09-05 17:26:45 -05:00
Chris Barber
5e4a8aff34 Merge branch 'esbuild' into esbuild-python 2023-09-05 17:26:38 -05:00
Nathan Rajlich
55d574cd26 Merge branch 'main' of github.com:vercel/vercel into esbuild 2023-09-05 14:39:13 -07:00
Nathan Rajlich
18cdcf35d3 Move "emitDeclarationOnly" to tsconfig.json 2023-09-05 14:38:55 -07:00
Nathan Rajlich
d2ce05ba27 Lint 2023-09-05 14:19:54 -07:00
Nathan Rajlich
3f5f368b19 Parse tsconfig and pass relevant valuse to esbuild 2023-09-05 14:16:32 -07:00
Chris Barber
48520ff329 Merge branch 'esbuild' into esbuild-python 2023-09-01 11:42:18 -07:00
Nathan Rajlich
10c3251b95 Merge branch 'main' into esbuild 2023-09-01 10:07:07 -07:00
Nathan Rajlich
bdd8958895 Merge branch 'main' into esbuild 2023-09-01 00:00:27 -07:00
Chris Barber
2d4d87e7dc Remove build script 2023-08-31 15:56:50 -07:00
Chris Barber
a94450d78e [python] Use new build 2023-08-31 15:35:35 -07:00
Nathan Rajlich
52e0c01cf5 . 2023-08-31 15:12:21 -07:00
Nathan Rajlich
65ecb16b04 Fix Windows? 2023-08-31 15:01:33 -07:00
Nathan Rajlich
6ce38c4cc8 . 2023-08-31 14:41:01 -07:00
Nathan Rajlich
a27cfd661b Debug Windows 2023-08-31 14:40:18 -07:00
Nathan Rajlich
6523ab43b2 . 2023-08-31 14:14:22 -07:00
Nathan Rajlich
102a83f1b5 Merge branch 'main' of github.com:vercel/vercel into esbuild 2023-08-31 13:58:25 -07:00
Nathan Rajlich
93c5a2b182 . 2023-08-31 13:58:07 -07:00
Nathan Rajlich
323a8d7122 . 2023-08-31 13:49:08 -07:00
Nathan Rajlich
4ab1720df2 Convert a few more 2023-08-31 13:43:22 -07:00
Chris Barber
6495dd150e [frameworks] Use new build 2023-08-31 13:37:54 -07:00
Nathan Rajlich
1d69870141 Add changeset 2023-08-31 13:28:52 -07:00
Nathan Rajlich
2eee17de24 Use npm-run-all 2023-08-31 13:28:37 -07:00
Nathan Rajlich
e62b3da5a7 Add common esbuild script and enable for @vercel/error-utils 2023-08-31 13:19:41 -07:00
271 changed files with 3244 additions and 9157 deletions

View File

@@ -0,0 +1,5 @@
---
"@vercel/build-utils": patch
---
add descriptions to NodeVersion properties

View File

@@ -0,0 +1,2 @@
---
---

View File

@@ -0,0 +1,5 @@
---
'vercel': patch
---
Migrates the vc env command to the command data structure for use in the help output.

View File

@@ -0,0 +1,5 @@
---
'vercel': patch
---
Update domains command to new structure

View File

@@ -0,0 +1,5 @@
---
"vercel": patch
---
migrate `rollback` command structure for help output

View File

@@ -0,0 +1,5 @@
---
"vercel": patch
---
migrate `inti` command structure for help output

View File

@@ -0,0 +1,5 @@
---
'vercel': patch
---
Remove mri workaround

View File

@@ -0,0 +1,5 @@
---
"vercel": patch
---
migrate dev command structure for help output

View File

@@ -0,0 +1,2 @@
---
---

View File

@@ -0,0 +1,5 @@
---
"@vercel/next": patch
---
fix 404 enoent for i18n

View File

@@ -0,0 +1,5 @@
---
'vercel': patch
---
Migrate `vc secrets` to new help command structure

View File

@@ -0,0 +1,5 @@
---
"vercel": patch
---
migrate `promote` command structure for help output

View File

@@ -0,0 +1,5 @@
---
"@vercel/node": patch
---
remove console.log

View File

@@ -0,0 +1,5 @@
---
"examples": patch
---
update examples to use at least node@16

View File

@@ -0,0 +1,5 @@
---
"vercel": patch
---
migrate `git` command structure for help output

View File

@@ -0,0 +1,5 @@
---
'vercel': patch
---
Update project command to new data structure

4
.github/CODEOWNERS vendored
View File

@@ -5,12 +5,12 @@
* @TooTallNate @EndangeredMassa @styfle @cb1kenobi @Ethan-Arrowood @trek
/.github/workflows @TooTallNate @EndangeredMassa @styfle @cb1kenobi @Ethan-Arrowood @trek @ijjk
/packages/fs-detectors @TooTallNate @EndangeredMassa @styfle @cb1kenobi @Ethan-Arrowood @trek @agadzik @chloetedder
/packages/next @TooTallNate @EndangeredMassa @styfle @cb1kenobi @Ethan-Arrowood @trek @ijjk @ztanner
/packages/next @TooTallNate @EndangeredMassa @styfle @cb1kenobi @Ethan-Arrowood @trek @ijjk
/packages/routing-utils @TooTallNate @EndangeredMassa @styfle @cb1kenobi @Ethan-Arrowood @trek @ijjk
/packages/edge @vercel/compute
/examples @leerob
/examples/create-react-app @Timer
/examples/nextjs @timneutkens @ijjk @styfle @ztanner @huozhi
/examples/nextjs @timneutkens @ijjk @styfle
/examples/hugo @styfle
/examples/jekyll @styfle
/examples/zola @styfle

View File

@@ -83,7 +83,7 @@ jobs:
env:
FORCE_COLOR: '1'
- name: Test ${{matrix.packageName}}
run: node utils/gen.js && node_modules/.bin/turbo run test --summarize --cache-dir=".turbo" --log-order=stream --scope=${{matrix.packageName}} --no-deps -- ${{ join(matrix.testPaths, ' ') }}
run: node utils/gen.js && node_modules/.bin/turbo run test --cache-dir=".turbo" --log-order=stream --scope=${{matrix.packageName}} --no-deps -- ${{ join(matrix.testPaths, ' ') }}
shell: bash
env:
JEST_JUNIT_OUTPUT_FILE: ${{github.workspace}}/.junit-reports/${{matrix.scriptName}}-${{matrix.packageName}}-${{matrix.chunkNumber}}-${{ matrix.runner }}.xml
@@ -91,18 +91,13 @@ jobs:
VERCEL_TEST_TOKEN: ${{ secrets.VERCEL_TEST_TOKEN }}
VERCEL_TEST_REGISTRATION_URL: ${{ secrets.VERCEL_TEST_REGISTRATION_URL }}
FORCE_COLOR: '1'
- name: 'Determing Turbo HIT or MISS'
id: turbo-summary
shell: bash
run: |
TURBO_MISS_COUNT=`node utils/determine-turbo-hit-or-miss.js`
echo "MISS COUNT: $TURBO_MISS_COUNT"
echo "misses=$TURBO_MISS_COUNT" >> $GITHUB_OUTPUT
- name: fetch ssl certificate after tests (linux, os x)
if: matrix.runner != 'windows-latest'
run: echo | openssl s_client -showcerts -servername 'api.vercel.com' -connect 76.76.21.21:443
- name: 'Upload Test Report to Datadog'
if: ${{ steps['turbo-summary'].outputs.misses != '0' }}
if: always()
run: 'npx @datadog/datadog-ci@2.18.1 junit upload --service vercel-cli .junit-reports'
env:
DATADOG_API_KEY: ${{secrets.DATADOG_API_KEY_CLI}}

View File

@@ -1,7 +0,0 @@
# examples
## null
### Patch Changes
- update examples to use at least node@16 ([#10395](https://github.com/vercel/vercel/pull/10395))

View File

@@ -3,10 +3,9 @@
This directory is a brief example of an [Astro](https://astro.build/) site that can be deployed to Vercel with zero configuration. This demo showcases:
- `/` - A static page (pre-rendered)
- `/ssr` - A page that uses server-side rendering (through [Vercel Edge Functions](https://vercel.com/docs/functions/edge-functions))
- `/ssr-with-swr-caching` - Similar to the previous page, but also caches the response on the [Vercel Edge Network](https://vercel.com/docs/edge-network/overview) using `cache-control` headers
- `/image` - Astro [Asset](https://docs.astro.build/en/guides/assets/) using Vercel [Image Optimization](https://vercel.com/docs/image-optimization)
- `/edge.json` - An Astro API Endpoint that returns JSON data using [Vercel Edge Functions](https://vercel.com/docs/functions/edge-functions)
- `/ssr` - A page that uses server-side rendering (through Vercel Edge Functions)
- `/ssr-with-swr-caching` - Similar to the previous page, but also caches the response on the Vercel Edge Network using `cache-control` headers
- `/edge.json` - An Astro API Endpoint that returns JSON data using Vercel Edge Functions
Learn more about [Astro on Vercel](https://vercel.com/docs/frameworks/astro).

View File

@@ -1,17 +1,7 @@
import { defineConfig } from 'astro/config';
// Use Vercel Edge Functions (Recommended)
import vercel from '@astrojs/vercel/edge';
// Can also use Serverless Functions
// import vercel from '@astrojs/vercel/serverless';
// Or a completely static build
// import vercel from '@astrojs/vercel/static';
export default defineConfig({
output: 'server',
experimental: {
assets: true
},
adapter: vercel({
imageService: true,
}),
adapter: vercel(),
});

View File

@@ -8,8 +8,8 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/vercel": "3.8.2",
"astro": "^2.10.14",
"@astrojs/vercel": "3.2.2",
"astro": "^2.2.1",
"react": "18.2.0",
"web-vitals": "^3.3.1"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -1,4 +1,4 @@
/// <reference types="astro/client-image" />
/// <reference types="astro/client" />
interface ImportMetaEnv {
readonly PUBLIC_VERCEL_ANALYTICS_ID: string;

View File

@@ -1,6 +0,0 @@
---
import { Image } from 'astro:assets';
import astroLogo from '../assets/logo.png';
---
<Image src={astroLogo} alt="Astro Logo" width={50} quality={75} />

View File

@@ -29,7 +29,7 @@
<!-- Replace the API key with your own, see:
https://developers.google.com/maps/documentation/javascript/get-api-key -->
<!-- <script async="" defer="" src="https://maps.googleapis.com/maps/api/js?key=<YOUR_GOOGLE_MAPS_API_KEY>"></script> -->
<!-- <script async="" defer="" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB8pf6ZdFQj5qw7rc_HSGrhUwQKfIe9ICw"></script> -->
<noscript>Please enable JavaScript to continue using this application.</noscript>
</body>

View File

@@ -10,8 +10,6 @@ npm run dev
yarn dev
# or
pnpm dev
# or
bun dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

File diff suppressed because it is too large Load Diff

View File

@@ -9,17 +9,17 @@
"lint": "next lint"
},
"dependencies": {
"@types/node": "20.6.3",
"@types/react": "18.2.22",
"@types/node": "20.5.1",
"@types/react": "18.2.20",
"@types/react-dom": "18.2.7",
"autoprefixer": "10.4.15",
"eslint": "8.49.0",
"eslint-config-next": "13.5.2",
"next": "13.5.2",
"postcss": "8.4.30",
"eslint": "8.47.0",
"eslint-config-next": "13.4.19",
"next": "13.4.19",
"postcss": "8.4.28",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwindcss": "3.3.3",
"typescript": "5.2.2"
"typescript": "5.1.6"
}
}

View File

@@ -9,7 +9,6 @@
},
"devDependencies": {
"@types/jest": "27.4.1",
"@vercel/frameworks": "2.0.2"
},
"version": null
"@vercel/frameworks": "2.0.1"
}
}

View File

@@ -4,4 +4,9 @@ node_modules
/build
/public/build
.env
.vercel
.output
/api/index.js
/api/index.js.map

View File

@@ -19,7 +19,7 @@ export default function App() {
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<Meta />
<Links />
</head>

View File

@@ -1,15 +1,10 @@
import type { MetaFunction } from "@vercel/remix";
import type { V2_MetaFunction } from "@vercel/remix";
export const meta: MetaFunction = () => {
return [
{ title: "New Remix App" },
{ name: "description", content: "Welcome to Remix!" },
];
};
export const meta: V2_MetaFunction = () => [{ title: "New Remix App" }];
export default function Index() {
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.8" }}>
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>
<h1>Welcome to Remix</h1>
<ul>
<li>

View File

@@ -1,8 +1,8 @@
import type { MetaFunction } from "@vercel/remix";
import type { V2_MetaFunction } from "@vercel/remix";
export const config = { runtime: "edge" };
export const meta: MetaFunction = () => [{ title: "Remix@Edge | New Remix App" }];
export const meta: V2_MetaFunction = () => [{ title: "Remix@Edge | New Remix App" }];
export default function Edge() {
return (

View File

@@ -1,34 +1,32 @@
{
"name": "my-remix-app",
"private": true,
"sideEffects": false,
"type": "module",
"scripts": {
"build": "remix build",
"dev": "remix dev --manual",
"start": "remix-serve ./build/index.js",
"dev": "remix dev",
"start": "remix-serve build",
"typecheck": "tsc"
},
"dependencies": {
"@remix-run/css-bundle": "^2.0.0",
"@remix-run/node": "^2.0.0",
"@remix-run/react": "^2.0.0",
"@remix-run/serve": "^2.0.0",
"@vercel/analytics": "^1.0.2",
"@vercel/remix": "^2.0.0",
"@remix-run/css-bundle": "^1.18.0",
"@remix-run/node": "^1.18.0",
"@remix-run/react": "^1.18.0",
"@remix-run/serve": "^1.18.0",
"@vercel/analytics": "^0.1.11",
"@vercel/remix": "^1.18.0",
"isbot": "^3.6.8",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@remix-run/dev": "^2.0.0",
"@remix-run/eslint-config": "^2.0.0",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"eslint": "^8.38.0",
"typescript": "^5.1.6"
"@remix-run/dev": "^1.18.0",
"@remix-run/eslint-config": "^1.18.0",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.11",
"eslint": "^8.28.0",
"typescript": "^5.1.3"
},
"engines": {
"node": ">=18.0.0"
"node": ">=16"
}
}

View File

@@ -1,8 +1,17 @@
/** @type {import('@remix-run/dev').AppConfig} */
export default {
module.exports = {
future: {
v2_dev: true,
v2_errorBoundary: true,
v2_headers: true,
v2_meta: true,
v2_normalizeFormMethod: true,
v2_routeConvention: true,
},
ignoredRouteFiles: ["**/.*"],
serverModuleFormat: "cjs",
// appDirectory: "app",
// assetsBuildDirectory: "public/build",
// publicPath: "/build/",
// serverBuildPath: "build/index.js",
// publicPath: "/build/",
};

View File

@@ -1,13 +1,13 @@
{
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"lib": ["DOM", "DOM.Iterable", "ES2019"],
"isolatedModules": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"moduleResolution": "Bundler",
"moduleResolution": "node",
"resolveJsonModule": true,
"target": "ES2022",
"target": "ES2019",
"strict": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,

View File

@@ -8,7 +8,9 @@
"dist"
],
"scripts": {
"build": "node ../../utils/build.mjs",
"build": "run-p build:*",
"build:js": "node ../../scripts/esbuild.mjs",
"build:types": "tsc",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
"test-unit": "pnpm test tests/unit"
},

View File

@@ -1,26 +1,5 @@
# @vercel-internals/types
## 1.0.11
### Patch Changes
- Updated dependencies [[`decdf27fb`](https://github.com/vercel/vercel/commit/decdf27fb5ca914fe50a9320c4fd50ef79d2fbb3)]:
- @vercel/build-utils@7.2.1
## 1.0.10
### Patch Changes
- Updated dependencies [[`50e04dd85`](https://github.com/vercel/vercel/commit/50e04dd8584664c842a86c15d92d654f4ea8dcbb), [`45b73c7e8`](https://github.com/vercel/vercel/commit/45b73c7e86458564dc0bab007f6f6365c4c4ab5d), [`d8bc570f6`](https://github.com/vercel/vercel/commit/d8bc570f604950d97156d4f33c8accecf3b3b28f)]:
- @vercel/build-utils@7.2.0
## 1.0.9
### Patch Changes
- Updated dependencies [[`5609a1187`](https://github.com/vercel/vercel/commit/5609a1187be9d6cf8d5f16825690c5ea72f17dc5), [`1b4de4a98`](https://github.com/vercel/vercel/commit/1b4de4a986f7a612aac834ebae3ec7bb9e9b8cf8)]:
- @vercel/build-utils@7.1.1
## 1.0.8
### Patch Changes

View File

@@ -65,8 +65,6 @@ export type User = {
billing: Billing;
name?: string;
limited?: boolean;
version?: 'northstar';
defaultTeamId?: string;
};
export interface Team {

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "@vercel-internals/types",
"version": "1.0.11",
"version": "1.0.8",
"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.1",
"@vercel/build-utils": "7.1.0",
"@vercel/routing-utils": "3.0.0"
},
"devDependencies": {

View File

@@ -29,11 +29,12 @@
"lint-staged": "9.2.5",
"node-fetch": "2.6.7",
"npm-package-arg": "6.1.0",
"npm-run-all": "4.1.5",
"prettier": "2.6.2",
"source-map-support": "0.5.12",
"ts-eager": "2.0.2",
"ts-jest": "29.1.0",
"turbo": "1.10.14",
"turbo": "1.10.13",
"typescript": "4.9.5"
},
"scripts": {

View File

@@ -1,31 +1,5 @@
# @vercel/build-utils
## 7.2.1
### Patch Changes
- Internal variants ([#10549](https://github.com/vercel/vercel/pull/10549))
## 7.2.0
### Minor Changes
- Add new optional prerender field: experimentalStreamingLambdaPath ([#10476](https://github.com/vercel/vercel/pull/10476))
- [build-utils] Add zero config detection for bun package manager ([#10486](https://github.com/vercel/vercel/pull/10486))
### Patch Changes
- add `experimentalBypassFor` field to Prerender ([#10481](https://github.com/vercel/vercel/pull/10481))
## 7.1.1
### Patch Changes
- add descriptions to NodeVersion properties ([#10403](https://github.com/vercel/vercel/pull/10403))
- Updated semver dependency ([#10411](https://github.com/vercel/vercel/pull/10411))
## 7.1.0
### Minor Changes

View File

@@ -1,3 +0,0 @@
import { tsc, esbuild } from '../../utils/build.mjs';
await Promise.all([tsc(), esbuild().then(() => esbuild({ bundle: true }))]);

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/build-utils",
"version": "7.2.1",
"version": "7.1.0",
"license": "Apache-2.0",
"main": "./dist/index.js",
"types": "./dist/index.d.js",
@@ -11,7 +11,11 @@
"directory": "packages/now-build-utils"
},
"scripts": {
"build": "node build.mjs",
"build": "run-p build:js build:types",
"build:js": "run-s build:single build:bundle",
"build:single": "node ../../scripts/esbuild.mjs",
"build:bundle": "node ../../scripts/esbuild.mjs --bundle",
"build:types": "tsc",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
"test-unit": "pnpm test test/unit.*test.*",
"test-e2e": "pnpm test test/integration.test.ts"
@@ -49,7 +53,7 @@
"minimatch": "3.1.2",
"multistream": "2.1.1",
"node-fetch": "2.6.7",
"semver": "6.3.1",
"semver": "6.1.1",
"typescript": "4.9.5",
"yazl": "2.5.1"
}

View File

@@ -16,7 +16,7 @@ import { cloneEnv } from '../clone-env';
// Only allow one `runNpmInstall()` invocation to run concurrently
const runNpmInstallSema = new Sema(1);
export type CliType = 'yarn' | 'npm' | 'pnpm' | 'bun';
export type CliType = 'yarn' | 'npm' | 'pnpm';
export interface ScanParentDirsResult {
/**
@@ -284,34 +284,26 @@ export async function scanParentDirs(
readPackageJson && pkgJsonPath
? JSON.parse(await fs.readFile(pkgJsonPath, 'utf8'))
: undefined;
const [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath] =
await walkParentDirsMulti({
base: '/',
start: destPath,
filenames: [
'yarn.lock',
'package-lock.json',
'pnpm-lock.yaml',
'bun.lockb',
],
});
const [yarnLockPath, npmLockPath, pnpmLockPath] = await walkParentDirsMulti({
base: '/',
start: destPath,
filenames: ['yarn.lock', 'package-lock.json', 'pnpm-lock.yaml'],
});
let lockfilePath: string | undefined;
let lockfileVersion: number | undefined;
let cliType: CliType = 'yarn';
const [hasYarnLock, packageLockJson, pnpmLockYaml, bunLockBin] =
await Promise.all([
Boolean(yarnLockPath),
npmLockPath
? readConfigFile<{ lockfileVersion: number }>(npmLockPath)
: null,
pnpmLockPath
? readConfigFile<{ lockfileVersion: number }>(pnpmLockPath)
: null,
bunLockPath ? fs.readFile(bunLockPath, 'utf8') : null,
]);
const [hasYarnLock, packageLockJson, pnpmLockYaml] = await Promise.all([
Boolean(yarnLockPath),
npmLockPath
? readConfigFile<{ lockfileVersion: number }>(npmLockPath)
: null,
pnpmLockPath
? readConfigFile<{ lockfileVersion: number }>(pnpmLockPath)
: null,
]);
// Priority order is Yarn > pnpm > npm > bun
// Priority order is Yarn > pnpm > npm
if (hasYarnLock) {
cliType = 'yarn';
lockfilePath = yarnLockPath;
@@ -323,11 +315,6 @@ export async function scanParentDirs(
cliType = 'npm';
lockfilePath = npmLockPath;
lockfileVersion = packageLockJson.lockfileVersion;
} else if (bunLockBin) {
cliType = 'bun';
lockfilePath = bunLockPath;
// TODO: read "bun-lockfile-format-v0"
lockfileVersion = 0;
}
const packageJsonPath = pkgJsonPath || undefined;
@@ -464,10 +451,6 @@ export async function runNpmInstall(
commandArgs = args
.filter(a => a !== '--prefer-offline')
.concat(['install', '--unsafe-perm']);
} else if (cliType === 'bun') {
// @see options https://bun.sh/docs/cli/install
opts.prettyCommand = 'bun install';
commandArgs = ['install', ...args];
} else {
opts.prettyCommand = 'yarn install';
commandArgs = ['install', ...args];
@@ -522,7 +505,6 @@ export function getEnvForPackageManager({
const npm7 = '/node16/bin-npm7';
const pnpm7 = '/pnpm7/node_modules/.bin';
const pnpm8 = '/pnpm8/node_modules/.bin';
const bun1 = '/bun1';
const corepackEnabled = env.ENABLE_EXPERIMENTAL_COREPACK === '1';
if (cliType === 'npm') {
if (
@@ -534,7 +516,7 @@ export function getEnvForPackageManager({
) {
// 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+');
console.log('Detected `package-lock.json` generated by npm 7+...');
}
} else if (cliType === 'pnpm') {
if (
@@ -546,7 +528,7 @@ export function getEnvForPackageManager({
// 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`
`Detected \`pnpm-lock.yaml\` version ${lockfileVersion} generated by pnpm 7...`
);
} else if (
typeof lockfileVersion === 'number' &&
@@ -557,16 +539,7 @@ export function getEnvForPackageManager({
// 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`
);
}
} 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'
`Detected \`pnpm-lock.yaml\` version ${lockfileVersion} generated by pnpm 8...`
);
}
} else {
@@ -575,6 +548,7 @@ export function getEnvForPackageManager({
newEnv.YARN_NODE_LINKER = 'node-modules';
}
}
return newEnv;
}
@@ -640,8 +614,6 @@ export async function runPackageJsonScript(
opts.prettyCommand = `npm run ${scriptName}`;
} else if (cliType === 'pnpm') {
opts.prettyCommand = `pnpm run ${scriptName}`;
} else if (cliType === 'bun') {
opts.prettyCommand = `bun run ${scriptName}`;
} else {
opts.prettyCommand = `yarn run ${scriptName}`;
}

View File

@@ -1,4 +1,4 @@
import type { File, HasField } from './types';
import { File } from './types';
import { Lambda } from './lambda';
interface PrerenderOptions {
@@ -12,8 +12,6 @@ interface PrerenderOptions {
initialStatus?: number;
passQuery?: boolean;
sourcePath?: string;
experimentalBypassFor?: HasField;
experimentalStreamingLambdaPath?: string;
}
export class Prerender {
@@ -28,8 +26,6 @@ export class Prerender {
public initialStatus?: number;
public passQuery?: boolean;
public sourcePath?: string;
public experimentalBypassFor?: HasField;
public experimentalStreamingLambdaPath?: string;
constructor({
expiration,
@@ -42,8 +38,6 @@ export class Prerender {
initialStatus,
passQuery,
sourcePath,
experimentalBypassFor,
experimentalStreamingLambdaPath,
}: PrerenderOptions) {
this.type = 'Prerender';
this.expiration = expiration;
@@ -92,26 +86,6 @@ export class Prerender {
);
}
if (experimentalBypassFor !== undefined) {
if (
!Array.isArray(experimentalBypassFor) ||
experimentalBypassFor.some(
field =>
typeof field !== 'object' ||
// host doesn't need a key
(field.type !== 'host' && typeof field.key !== 'string') ||
typeof field.type !== 'string' ||
(field.value !== undefined && typeof field.value !== 'string')
)
) {
throw new Error(
'The `experimentalBypassFor` argument for `Prerender` must be Array of objects with fields `type`, `key` and optionally `value`.'
);
}
this.experimentalBypassFor = experimentalBypassFor;
}
if (typeof fallback === 'undefined') {
throw new Error(
'The `fallback` argument for `Prerender` needs to be a `FileBlob`, `FileFsRef`, `FileRef`, or null.'
@@ -156,14 +130,5 @@ export class Prerender {
}
this.allowQuery = allowQuery;
}
if (experimentalStreamingLambdaPath !== undefined) {
if (typeof experimentalStreamingLambdaPath !== 'string') {
throw new Error(
'The `experimentalStreamingLambdaPath` argument for `Prerender` must be a string.'
);
}
this.experimentalStreamingLambdaPath = experimentalStreamingLambdaPath;
}
}
}

View File

@@ -45,18 +45,6 @@ export interface Config {
[key: string]: unknown;
}
export type HasField = Array<
| {
type: 'host';
value: string;
}
| {
type: 'header' | 'cookie' | 'query';
key: string;
value?: string;
}
>;
export interface Meta {
isDev?: boolean;
devCacheDir?: string;
@@ -434,13 +422,6 @@ export interface Cron {
schedule: string;
}
// TODO: Proper description once complete
export interface Flag {
key: string;
defaultValue?: unknown;
metadata: Record<string, unknown>;
}
/** The framework which created the function */
export interface FunctionFramework {
slug: string;
@@ -465,7 +446,6 @@ export interface BuildResultV2Typical {
framework?: {
version: string;
};
flags?: Flag[];
}
export type BuildResultV2 = BuildResultV2Typical | BuildResultBuildOutput;

View File

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

View File

@@ -1,8 +0,0 @@
import { mkdir, rm, writeFile } from 'node:fs/promises'
import { say } from 'cowsay'
const text = say({ text: `bun version: ${process.versions.bun}` })
const content = say({ text })
await rm('./public', { recursive: true, force: true })
await mkdir('./public', { recursive: true })
await writeFile('./public/index.txt', content)

View File

@@ -1,9 +0,0 @@
{
"private": true,
"scripts": {
"build": "bun build.js"
},
"dependencies": {
"cowsay": "1.5.0"
}
}

View File

@@ -1,8 +0,0 @@
{
"probes": [
{
"path": "/",
"mustContain": "bun version: 1"
}
]
}

View File

@@ -133,22 +133,6 @@ describe('Test `getEnvForPackageManager()`', () => {
PATH: `/pnpm7/node_modules/.bin${delimiter}foo`,
},
},
{
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: {
FOO: 'bar',
PATH: `/bun1${delimiter}/usr/local/bin`,
},
},
{
name: 'should not set pnpm path if corepack is enabled',
args: {

View File

@@ -344,70 +344,6 @@ it('should support initialHeaders and initialStatus correctly', async () => {
});
});
it('should support experimentalBypassFor correctly', async () => {
new Prerender({
expiration: 1,
fallback: null,
group: 1,
bypassToken: 'some-long-bypass-token-to-make-it-work',
experimentalBypassFor: [{ type: 'header', key: 'Next-Action' }],
});
new Prerender({
expiration: 1,
fallback: null,
group: 1,
bypassToken: 'some-long-bypass-token-to-make-it-work',
experimentalBypassFor: [
{ type: 'header', key: 'Next-Action' },
{
type: 'cookie',
key: '__prerender_bypass',
value: 'some-long-bypass-token-to-make-it-work',
},
],
});
new Prerender({
expiration: 1,
fallback: null,
group: 1,
bypassToken: 'some-long-bypass-token-to-make-it-work',
experimentalBypassFor: [{ type: 'query', key: 'bypass', value: '1' }],
});
new Prerender({
expiration: 1,
fallback: null,
group: 1,
bypassToken: 'some-long-bypass-token-to-make-it-work',
experimentalBypassFor: [{ type: 'host', value: 'vercel.com' }],
});
expect(() => {
new Prerender({
expiration: 1,
fallback: null,
group: 1,
bypassToken: 'some-long-bypass-token-to-make-it-work',
// @ts-expect-error: testing invalid args
experimentalBypassFor: 'foo',
});
}).toThrowError(
'The `experimentalBypassFor` argument for `Prerender` must be Array of objects with fields `type`, `key` and optionally `value`.'
);
expect(() => {
new Prerender({
expiration: 1,
fallback: null,
group: 1,
bypassToken: 'some-long-bypass-token-to-make-it-work',
// @ts-expect-error: testing invalid args
experimentalBypassFor: [{ type: 'header', value: { foo: 'bar' } }],
});
}).toThrowError(
'The `experimentalBypassFor` argument for `Prerender` must be Array of objects with fields `type`, `key` and optionally `value`.'
);
});
it('should support passQuery correctly', async () => {
new Prerender({
expiration: 1,
@@ -451,42 +387,6 @@ it('should support passQuery correctly', async () => {
);
});
it('should support experimentalStreamingLambdaPath correctly', async () => {
new Prerender({
expiration: 1,
fallback: null,
group: 1,
bypassToken: 'some-long-bypass-token-to-make-it-work',
experimentalStreamingLambdaPath: undefined,
});
new Prerender({
expiration: 1,
fallback: null,
group: 1,
bypassToken: 'some-long-bypass-token-to-make-it-work',
experimentalStreamingLambdaPath: '/some/path/to/lambda',
});
new Prerender({
expiration: 1,
fallback: null,
group: 1,
bypassToken: 'some-long-bypass-token-to-make-it-work',
});
expect(() => {
new Prerender({
expiration: 1,
fallback: null,
group: 1,
bypassToken: 'some-long-bypass-token-to-make-it-work',
// @ts-expect-error testing invalid field
experimentalStreamingLambdaPath: 1,
});
}).toThrowError(
`The \`experimentalStreamingLambdaPath\` argument for \`Prerender\` must be a string.`
);
});
it('should support require by path for legacy builders', () => {
const index = require('../');
@@ -540,15 +440,6 @@ it(
ms('1m')
);
it('should return cliType bun and correct lock file for bun v1', async () => {
const fixture = path.join(__dirname, 'fixtures', '30-bun-v1');
const result = await scanParentDirs(fixture);
expect(result.cliType).toEqual('bun');
expect(result.lockfileVersion).toEqual(0);
expect(result.lockfilePath).toEqual(path.join(fixture, 'bun.lockb'));
expect(result.packageJsonPath).toEqual(path.join(fixture, 'package.json'));
});
it('should return lockfileVersion 2 with npm7', async () => {
const fixture = path.join(__dirname, 'fixtures', '20-npm-7');
const result = await scanParentDirs(fixture);

View File

@@ -1,126 +1,5 @@
# vercel
## 32.3.0
### Minor Changes
- [cli] Support northstar users ([#10535](https://github.com/vercel/vercel/pull/10535))
### Patch Changes
- Internal variants ([#10549](https://github.com/vercel/vercel/pull/10549))
- [speed insights] Prepare for migration to new speed insights package ([#10500](https://github.com/vercel/vercel/pull/10500))
- Updated dependencies [[`b0898a665`](https://github.com/vercel/vercel/commit/b0898a66591d5296dc38ffcf0e8345c9338b72f3), [`10d4e51ac`](https://github.com/vercel/vercel/commit/10d4e51ac57b76f05ddc0bf3adf220e2490244fc), [`decdf27fb`](https://github.com/vercel/vercel/commit/decdf27fb5ca914fe50a9320c4fd50ef79d2fbb3), [`f5ca497b7`](https://github.com/vercel/vercel/commit/f5ca497b7522a2dad637cef238da9716ac133057), [`ab329f0fe`](https://github.com/vercel/vercel/commit/ab329f0fe88e9cb72607d0cba41f5e168d77e077), [`d0d052011`](https://github.com/vercel/vercel/commit/d0d0520111264434d57d5920de0f622f6a2588dc), [`9bb3067de`](https://github.com/vercel/vercel/commit/9bb3067de28be77f3ce268a31a7aa6184836dfb1)]:
- @vercel/static-build@2.0.7
- @vercel/node@3.0.6
- @vercel/build-utils@7.2.1
- @vercel/next@4.0.7
- @vercel/python@4.0.2
- @vercel/redwood@2.0.3
- @vercel/remix-builder@2.0.7
- @vercel/go@3.0.2
## 32.2.5
### Patch Changes
- Updated dependencies [[`849eedf0f`](https://github.com/vercel/vercel/commit/849eedf0f2841211e4175d374f1cf01330bf9611), [`f6f16b034`](https://github.com/vercel/vercel/commit/f6f16b0347bac9f5c33c79ccb1fb9fd9d254cae5), [`3035e18fb`](https://github.com/vercel/vercel/commit/3035e18fb67dfe7031e235a74136a41948f86d5a), [`cb784aeb9`](https://github.com/vercel/vercel/commit/cb784aeb9c9e4eddf1c65b61849a87edb1117af1)]:
- @vercel/next@4.0.6
- @vercel/remix-builder@2.0.6
## 32.2.4
### Patch Changes
- Add support for bun detection in monorepo ([#10511](https://github.com/vercel/vercel/pull/10511))
- Updated dependencies [[`1b6f3a0f6`](https://github.com/vercel/vercel/commit/1b6f3a0f6534f71c7486a4e33ac199f1da330626)]:
- @vercel/static-build@2.0.6
## 32.2.3
### Patch Changes
- Updated dependencies [[`083aad448`](https://github.com/vercel/vercel/commit/083aad448e45edae296da3201eec9f890a01d22d)]:
- @vercel/next@4.0.5
## 32.2.2
### Patch Changes
- Updated dependencies [[`7a0fed970`](https://github.com/vercel/vercel/commit/7a0fed970c39cb8f4df70544ded3284d3538b06a), [`2f461a8b0`](https://github.com/vercel/vercel/commit/2f461a8b0bcbdd05da0516395c2905c2d0242682), [`1bab21026`](https://github.com/vercel/vercel/commit/1bab21026ec0bb8a4a8fbeac3d6e4a197f1030fd)]:
- @vercel/next@4.0.4
- @vercel/remix-builder@2.0.5
## 32.2.1
### Patch Changes
- Update @vercel/fun@1.1.0 ([#10477](https://github.com/vercel/vercel/pull/10477))
- [node] upgrade edge-runtime ([#10451](https://github.com/vercel/vercel/pull/10451))
- Updated dependencies [[`6784e7751`](https://github.com/vercel/vercel/commit/6784e77516ba180a691e3c48323b32bb4506d7b6), [`a8ad17626`](https://github.com/vercel/vercel/commit/a8ad176262ef822860ce338927e6f959961d2d32), [`0ee089a50`](https://github.com/vercel/vercel/commit/0ee089a501ebb78901c4afe1658e794917998f8f), [`f15cba614`](https://github.com/vercel/vercel/commit/f15cba6148a0cdb6975db7724775c35ab7d929b2), [`b265e13d4`](https://github.com/vercel/vercel/commit/b265e13d40d541b77148fa79ac60b4c4dd10974c), [`50e04dd85`](https://github.com/vercel/vercel/commit/50e04dd8584664c842a86c15d92d654f4ea8dcbb), [`45b73c7e8`](https://github.com/vercel/vercel/commit/45b73c7e86458564dc0bab007f6f6365c4c4ab5d), [`a732d30c8`](https://github.com/vercel/vercel/commit/a732d30c8409f96f59ea5406e974a6c4186cc130), [`9d64312aa`](https://github.com/vercel/vercel/commit/9d64312aaaa875a4e193b7602c50e5dc68979aad), [`6baefc825`](https://github.com/vercel/vercel/commit/6baefc825ad7cfc3a5edce31cb4244721452f753), [`989f0d813`](https://github.com/vercel/vercel/commit/989f0d813910d8d67ed355de93018f1dcd91b6ba), [`d8bc570f6`](https://github.com/vercel/vercel/commit/d8bc570f604950d97156d4f33c8accecf3b3b28f)]:
- @vercel/go@3.0.1
- @vercel/redwood@2.0.2
- @vercel/remix-builder@2.0.4
- @vercel/hydrogen@1.0.1
- @vercel/static-build@2.0.5
- @vercel/build-utils@7.2.0
- @vercel/next@4.0.3
- @vercel/node@3.0.5
- @vercel/python@4.0.1
- @vercel/ruby@2.0.2
## 32.2.0
### Minor Changes
- show instant preview url on deploy ([#10458](https://github.com/vercel/vercel/pull/10458))
### Patch Changes
- N, not n. ([#10460](https://github.com/vercel/vercel/pull/10460))
- Fix team URL on `vercel help switch` ([#10466](https://github.com/vercel/vercel/pull/10466))
- Migrates the vc env command to the command data structure for use in the help output. ([#10429](https://github.com/vercel/vercel/pull/10429))
- Update domains command to new structure ([#10427](https://github.com/vercel/vercel/pull/10427))
- Updated semver dependency ([#10411](https://github.com/vercel/vercel/pull/10411))
- migrate `rollback` command structure for help output ([#10426](https://github.com/vercel/vercel/pull/10426))
- migrate `inti` command structure for help output ([#10428](https://github.com/vercel/vercel/pull/10428))
- Remove mri workaround ([#10452](https://github.com/vercel/vercel/pull/10452))
- migrate dev command structure for help output ([#10433](https://github.com/vercel/vercel/pull/10433))
- Update secrets to more recent structure ([#10461](https://github.com/vercel/vercel/pull/10461))
- Migrate `vc secrets` to new help command structure ([#10435](https://github.com/vercel/vercel/pull/10435))
- migrate `promote` command structure for help output ([#10425](https://github.com/vercel/vercel/pull/10425))
- migrate `git` command structure for help output ([#10431](https://github.com/vercel/vercel/pull/10431))
- Update project command to new data structure ([#10432](https://github.com/vercel/vercel/pull/10432))
- migrate teams command ([#10434](https://github.com/vercel/vercel/pull/10434))
- Updated dependencies [[`5609a1187`](https://github.com/vercel/vercel/commit/5609a1187be9d6cf8d5f16825690c5ea72f17dc5), [`caaba0d68`](https://github.com/vercel/vercel/commit/caaba0d6855eff4350b6a04acc3ea502025bff8f), [`1b4de4a98`](https://github.com/vercel/vercel/commit/1b4de4a986f7a612aac834ebae3ec7bb9e9b8cf8), [`c3c54d6e6`](https://github.com/vercel/vercel/commit/c3c54d6e695ec078777c4b1f4f23acbeee3c3b09), [`6aa0aa4e6`](https://github.com/vercel/vercel/commit/6aa0aa4e65b81903f4fce677a198dcfaebee744b), [`e43191b18`](https://github.com/vercel/vercel/commit/e43191b1866da70a3dab3815a3f2176942240ef3), [`fc1e13c09`](https://github.com/vercel/vercel/commit/fc1e13c09928c654410b373fc1775c2b63c6ef4a)]:
- @vercel/build-utils@7.1.1
- @vercel/next@4.0.2
- @vercel/static-build@2.0.4
- @vercel/redwood@2.0.1
- @vercel/remix-builder@2.0.3
- @vercel/ruby@2.0.1
- @vercel/node@3.0.4
## 32.1.0
### Minor Changes

View File

@@ -1,6 +1,6 @@
{
"name": "vercel",
"version": "32.3.0",
"version": "32.1.0",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Vercel",
@@ -31,20 +31,20 @@
"node": ">= 16"
},
"dependencies": {
"@vercel/build-utils": "7.2.1",
"@vercel/go": "3.0.2",
"@vercel/hydrogen": "1.0.1",
"@vercel/next": "4.0.7",
"@vercel/node": "3.0.6",
"@vercel/python": "4.0.2",
"@vercel/redwood": "2.0.3",
"@vercel/remix-builder": "2.0.7",
"@vercel/ruby": "2.0.2",
"@vercel/static-build": "2.0.7"
"@vercel/build-utils": "7.1.0",
"@vercel/go": "3.0.0",
"@vercel/hydrogen": "1.0.0",
"@vercel/next": "4.0.1",
"@vercel/node": "3.0.3",
"@vercel/python": "4.0.0",
"@vercel/redwood": "2.0.0",
"@vercel/remix-builder": "2.0.2",
"@vercel/ruby": "2.0.0",
"@vercel/static-build": "2.0.3"
},
"devDependencies": {
"@alex_neo/jest-expect-message": "1.0.5",
"@edge-runtime/node-utils": "2.2.1",
"@edge-runtime/node-utils": "2.2.0",
"@next/env": "11.1.2",
"@sentry/node": "5.5.0",
"@sindresorhus/slugify": "0.11.0",
@@ -86,12 +86,12 @@
"@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.11",
"@vercel/client": "13.0.4",
"@vercel-internals/types": "1.0.8",
"@vercel/client": "13.0.1",
"@vercel/error-utils": "2.0.1",
"@vercel/frameworks": "2.0.2",
"@vercel/fs-detectors": "5.1.0",
"@vercel/fun": "1.1.0",
"@vercel/frameworks": "2.0.1",
"@vercel/fs-detectors": "5.0.1",
"@vercel/fun": "1.0.4",
"@vercel/ncc": "0.24.0",
"@vercel/routing-utils": "3.0.0",
"@zeit/source-map-support": "0.6.2",
@@ -156,7 +156,7 @@
"qr-image": "3.2.0",
"raw-body": "2.4.1",
"rimraf": "3.0.2",
"semver": "5.7.2",
"semver": "5.5.0",
"serve-handler": "6.1.1",
"strip-ansi": "6.0.1",
"supports-hyperlinks": "3.0.0",

View File

@@ -27,7 +27,7 @@ export const help = () => `
pull [path] Pull your Project Settings from the cloud
redeploy [url|id] Rebuild and deploy a previous deployment.
rollback [url|id] Quickly revert back to a previous deployment
switch [scope] Switches between different scopes
switch [scope] Switches between teams and your personal account
${chalk.dim('Advanced')}

View File

@@ -21,7 +21,6 @@ import {
NowBuildError,
Cron,
validateNpmrc,
Flag,
} from '@vercel/build-utils';
import {
detectBuilders,
@@ -94,7 +93,6 @@ interface BuildOutputConfig {
version: string;
};
crons?: Cron[];
flags?: Flag[];
}
/**
@@ -428,23 +426,6 @@ async function doBuild(
const ops: Promise<Error | void>[] = [];
const dependencies = [
...Object.keys(pkg?.dependencies ?? {}),
...Object.keys(pkg?.devDependencies ?? {}),
];
const isUsingSpeedInsights = dependencies.some(
d => d === '@vercel/speed-insights'
);
if (isUsingSpeedInsights && 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;
}
// Write the `detectedBuilders` result to output dir
const buildsJsonBuilds = new Map<Builder, SerializedBuilder>(
builds.map(build => {
@@ -646,7 +627,6 @@ async function doBuild(
const mergedWildcard = mergeWildcard(buildResults.values());
const mergedOverrides: Record<string, PathOverride> =
overrides.length > 0 ? Object.assign({}, ...overrides) : undefined;
const mergedFlags = mergeFlags(buildResults.values());
const framework = await getFramework(cwd, buildResults);
@@ -660,7 +640,6 @@ async function doBuild(
overrides: mergedOverrides,
framework,
crons: mergedCrons,
flags: mergedFlags,
};
await fs.writeJSON(join(outputDir, 'config.json'), config, { spaces: 2 });
@@ -795,15 +774,3 @@ function mergeWildcard(
}
return wildcard;
}
function mergeFlags(
buildResults: Iterable<BuildResult | BuildOutputConfig>
): BuildResultV2Typical['flags'] {
return Array.from(buildResults).flatMap(result => {
if ('flags' in result) {
return result.flags ?? [];
}
return [];
});
}

View File

@@ -72,7 +72,7 @@ export const domainsCommand: Command = {
},
{
name: 'move',
description: 'Move a domain to another scope',
description: 'Move a domain to another user or team',
arguments: [
{
name: 'name',

View File

@@ -53,12 +53,6 @@ export default async function move(
const teams = await getTeams(client);
const matchId = await findDestinationMatch(destination, user, teams);
if (matchId && matchId === user.id && user.version === 'northstar') {
output.error(`You may not move your domain to your user account.`);
return 1;
}
if (!matchId && !opts['--yes']) {
output.warn(
`You're not a member of ${param(destination)}. ` +

View File

@@ -55,12 +55,6 @@ function tryReadHeadSync(path: string, length: number) {
}
}
const VARIABLES_TO_IGNORE = [
'VERCEL_ANALYTICS_ID',
'VERCEL_SPEED_INSIGHTS_ID',
'VERCEL_WEB_ANALYTICS_ID',
];
export default async function pull(
client: Client,
link: ProjectLinked,
@@ -137,7 +131,6 @@ export default async function pull(
CONTENTS_PREFIX +
Object.keys(records)
.sort()
.filter(key => !VARIABLES_TO_IGNORE.includes(key))
.map(key => `${key}="${escapeValue(records[key])}"`)
.join('\n') +
'\n';

View File

@@ -19,7 +19,6 @@ import Client from '../../util/client';
import { LoginResult } from '../../util/login/types';
import { help } from '../help';
import { loginCommand } from './command';
import { updateCurrentTeamAfterLogin } from '../../util/login/update-current-team-after-login';
export default async function login(client: Client): Promise<number> {
const { output } = client;
@@ -68,16 +67,20 @@ export default async function login(client: Client): Promise<number> {
return result;
}
const isNewLogin = !client.authConfig.token;
// If the token was upgraded (not a new login), then don't modify
// the current scope.
if (!client.authConfig.token) {
if (result.teamId) {
// SSO login, so set the current scope to the appropriate Team
client.config.currentTeam = result.teamId;
} else {
delete client.config.currentTeam;
}
}
// Save the user's authentication token to the configuration file.
client.authConfig.token = result.token;
// If we have a new login, update `currentTeam`
if (isNewLogin) {
await updateCurrentTeamAfterLogin(client, output, result.teamId);
}
writeToAuthConfigFile(client.authConfig);
writeToConfigFile(client.config);

View File

@@ -3,7 +3,7 @@ import { packageName } from '../../util/pkg-name';
export const logoutCommand: Command = {
name: 'logout',
description: 'Logout the current authenticated user.',
description: 'Logout the current authenticated user or team.',
arguments: [],
options: [],
examples: [

View File

@@ -13,7 +13,7 @@ export const projectCommand: Command = {
subcommands: [
{
name: 'ls',
description: 'Show all projects in the selected scope',
description: 'Show all projects in the selected team/user',
arguments: [],
options: [],
examples: [],
@@ -48,7 +48,7 @@ export const projectCommand: Command = {
name: 'next',
description: 'Show next page of results',
argument: 'MS',
shorthand: 'N',
shorthand: 'n',
type: 'string',
deprecated: false,
multi: false,

View File

@@ -76,23 +76,12 @@ export default async function redeploy(client: Client): Promise<number> {
});
output.stopSpinner();
const isProdDeployment = deployment.target === 'production';
const previewUrl = `https://${deployment.url}`;
output.print(
`${prependEmoji(
`Inspect: ${chalk.bold(deployment.inspectorUrl)} ${deployStamp()}`,
emoji('inspect')
)}\n`
);
output.print(
prependEmoji(
`${isProdDeployment ? 'Production' : 'Preview'}: ${chalk.bold(
previewUrl
)} ${deployStamp()}`,
emoji('success')
) + `\n`
);
if (!client.stdout.isTTY) {
client.stdout.write(`https://${deployment.url}`);

View File

@@ -1,17 +1,111 @@
import isErrnoException from '@vercel/error-utils';
import chalk from 'chalk';
import table from 'text-table';
import ms from 'ms';
import strlen from '../../util/strlen';
import { handleError, error } from '../../util/error';
import NowSecrets from '../../util/secrets';
import getScope from '../../util/get-scope';
import confirm from '../../util/input/confirm';
import getCommandFlags from '../../util/get-command-flags';
import { getCommandName } from '../../util/pkg-name';
import getArgs from '../../util/get-args';
import { help } from '../help';
import { secretsCommand } from './command';
import strlen from '../util/strlen.ts';
import { handleError, error } from '../util/error';
import NowSecrets from '../util/secrets';
import exit from '../util/exit';
import getScope from '../util/get-scope.ts';
import confirm from '../util/input/confirm';
import getCommandFlags from '../util/get-command-flags';
import { packageName, getCommandName } from '../util/pkg-name.ts';
import getArgs from '../util/get-args';
import { help } from './help';
export const secretsCommand = {
name: 'secrets',
description: `NOTE: The ${getCommandName(
'env'
)} command is recommended instead of ${getCommandName('secrets')}`,
arguments: [
{
name: 'command',
required: false,
},
],
subcommands: [
{
name: 'ls',
description: 'Show all secrets in a list',
arguments: [],
options: [],
examples: [],
},
{
name: 'add',
description: 'Add a new secret',
arguments: [
{
name: 'name',
required: true,
},
{
name: 'value',
required: true,
},
],
options: [],
examples: [],
},
{
name: 'rename',
description: 'Change the name of a secret',
arguments: [
{
name: 'old-name',
required: true,
},
{
name: 'new-name',
required: true,
},
],
options: [],
examples: [],
},
{
name: 'rm',
description: 'Remove a secret',
arguments: [
{
name: 'name',
required: true,
},
],
options: [],
examples: [],
},
],
options: [
{
name: 'next',
description: 'Show next page of results',
argument: 'MS',
shorthand: 'n',
type: 'string',
deprecated: false,
multi: false,
},
],
examples: [
{
name: 'Add a new secret',
value: `${packageName} secrets add my-secret "my value"
- Once added, a secret's value can't be retrieved in plain text anymore
- If the secret's value is more than one word, wrap it in quotes
- When in doubt, always wrap your value in quotes`,
},
{
name: 'Expose a secret as an environment variable (notice the `@` symbol)',
value: `${packageName} -e MY_SECRET=@my-secret`,
},
{
name: 'Paginate results, where 1584722256178 is the time in milliseconds since the UNIX epoch',
value: `$ ${packageName} secrets ls --next 1584722256178`,
},
],
};
// Options
let argv;
@@ -36,7 +130,7 @@ const main = async client => {
client.output.print(
help(secretsCommand, { columns: client.stderr.columns })
);
return 2;
await exit(2);
}
const {
@@ -48,11 +142,9 @@ const main = async client => {
try {
({ contextName } = await getScope(client));
} catch (err) {
if (isErrnoException(err)) {
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
output.error(err.message);
return 1;
}
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
output.error(err.message);
return 1;
}
throw err;
@@ -63,7 +155,7 @@ const main = async client => {
export default async client => {
try {
return await main(client);
await main(client);
} catch (err) {
handleError(err);
process.exit(1);
@@ -126,7 +218,7 @@ async function run({ output, contextName, currentTeam, client }) {
);
if (out) {
client.output.print(`\n${out}\n`);
console.log(`\n${out}\n`);
}
}

View File

@@ -1,96 +0,0 @@
import { packageName, getCommandName } from '../../util/pkg-name';
export const secretsCommand = {
name: 'secrets',
description: `NOTE: The ${getCommandName(
'env'
)} command is recommended instead of ${getCommandName('secrets')}`,
arguments: [
{
name: 'command',
required: false,
},
],
subcommands: [
{
name: 'ls',
description: 'Show all secrets in a list',
arguments: [],
options: [],
examples: [],
},
{
name: 'add',
description: 'Add a new secret',
arguments: [
{
name: 'name',
required: true,
},
{
name: 'value',
required: true,
},
],
options: [],
examples: [],
},
{
name: 'rename',
description: 'Change the name of a secret',
arguments: [
{
name: 'old-name',
required: true,
},
{
name: 'new-name',
required: true,
},
],
options: [],
examples: [],
},
{
name: 'rm',
description: 'Remove a secret',
arguments: [
{
name: 'name',
required: true,
},
],
options: [],
examples: [],
},
],
options: [
{
name: 'next',
description: 'Show next page of results',
argument: 'MS',
shorthand: 'n',
type: 'string',
deprecated: false,
multi: false,
},
],
examples: [
{
name: 'Add a new secret',
value: `${packageName} secrets add my-secret "my value"
- Once added, a secret's value can't be retrieved in plain text anymore
- If the secret's value is more than one word, wrap it in quotes
- When in doubt, always wrap your value in quotes`,
},
{
name: 'Expose a secret as an environment variable (notice the `@` symbol)',
value: `${packageName} -e MY_SECRET=@my-secret`,
},
{
name: 'Paginate results, where 1584722256178 is the time in milliseconds since the UNIX epoch',
value: `$ ${packageName} secrets ls --next 1584722256178`,
},
],
};

View File

@@ -1,77 +0,0 @@
import { Command } from '../help';
import { packageName } from '../../util/pkg-name';
export const teamsCommand: Command = {
name: 'teams',
description: 'Manage teams under your Vercel account',
arguments: [],
subcommands: [
{
name: 'add',
description: 'Create a new team',
arguments: [],
options: [],
examples: [],
},
{
name: 'ls',
description: "Show all teams you're a part of",
arguments: [],
options: [],
examples: [],
},
{
name: 'switch',
description: 'Switch to a different team',
arguments: [
{
name: 'name',
required: false,
},
],
options: [],
examples: [],
},
{
name: 'invite',
description: 'Invite a new member to a team',
arguments: [
{
name: 'emails',
required: true,
},
],
options: [],
examples: [],
},
],
options: [
{
name: 'next',
shorthand: 'N',
type: 'string',
argument: 'MS',
deprecated: false,
multi: false,
description: 'Show next page of results',
},
],
examples: [
{
name: "Switch to a team. If your team's url is 'vercel.com/name', then 'name' is the slug. If the slug is omitted, you can choose interactively.",
value: `${packageName} teams switch <slug>`,
},
{
name: 'Invite new members (interactively)',
value: `${packageName} teams invite`,
},
{
name: 'Invite multiple members simultaneously',
value: `${packageName} teams invite abc@vercel.com xyz@vercel.com`,
},
{
name: 'Paginate results, where `1584722256178` is the time in milliseconds since the UNIX epoch.',
value: `${packageName} teams ls --next 1584722256178`,
},
],
};

View File

@@ -1,12 +1,63 @@
import chalk from 'chalk';
import error from '../../util/output/error';
import list from './list';
import add from './add';
import change from './switch';
import invite from './invite';
import { packageName, logo } from '../../util/pkg-name';
import getArgs from '../../util/get-args';
import Client from '../../util/client';
import { teamsCommand } from './command';
import { help } from '../help';
const help = () => {
console.log(`
${chalk.bold(`${logo} ${packageName} teams`)} [options] <command>
${chalk.dim('Commands:')}
add Create a new team
ls Show all teams you're a part of
switch [name] Switch to a different team
invite [email] Invite a new member to a team
${chalk.dim('Options:')}
-h, --help Output usage information
-A ${chalk.bold.underline('FILE')}, --local-config=${chalk.bold.underline(
'FILE'
)} Path to the local ${'`vercel.json`'} file
-Q ${chalk.bold.underline('DIR')}, --global-config=${chalk.bold.underline(
'DIR'
)} Path to the global ${'`.vercel`'} directory
-d, --debug Debug mode [off]
--no-color No color mode [off]
-N, --next Show next page of results
${chalk.dim('Examples:')}
${chalk.gray('')} Switch to a team
${chalk.cyan(`$ ${packageName} switch <slug>`)}
${chalk.gray(
''
)} If your team's url is 'vercel.com/teams/name', 'name' is the slug
${chalk.gray('')} If the slug is omitted, you can choose interactively
${chalk.yellow(
'NOTE:'
)} When you switch, everything you add, list or remove will be scoped that team!
${chalk.gray('')} Invite new members (interactively)
${chalk.cyan(`$ ${packageName} teams invite`)}
${chalk.gray('')} Paginate results, where ${chalk.dim(
'`1584722256178`'
)} is the time in milliseconds since the UNIX epoch.
${chalk.cyan(`$ ${packageName} teams ls --next 1584722256178`)}
`);
};
export default async (client: Client) => {
let subcommand;
@@ -23,7 +74,7 @@ export default async (client: Client) => {
}
if (argv['--help'] || !subcommand) {
client.output.print(help(teamsCommand, { columns: client.stderr.columns }));
help();
return 2;
}
@@ -56,9 +107,7 @@ export default async (client: Client) => {
);
}
exitCode = 2;
client.output.print(
help(teamsCommand, { columns: client.stderr.columns })
);
help();
}
}
return exitCode;

View File

@@ -39,12 +39,11 @@ export default async function list(client: Client): Promise<number> {
apiVersion: 2,
});
let { currentTeam } = config;
const accountIsCurrent = !currentTeam;
output.spinner('Fetching user information');
const user = await getUser(client);
const accountIsCurrent = !currentTeam && user.version !== 'northstar';
if (accountIsCurrent) {
currentTeam = user.id;
}
@@ -56,14 +55,12 @@ export default async function list(client: Client): Promise<number> {
current: id === currentTeam ? chars.tick : '',
}));
if (user.version !== 'northstar') {
teamList.unshift({
id: user.id,
name: user.email,
value: user.username || user.email,
current: accountIsCurrent ? chars.tick : '',
});
}
teamList.unshift({
id: user.id,
name: user.email,
value: user.username || user.email,
current: accountIsCurrent ? chars.tick : '',
});
// Bring the current Team to the beginning of the list
if (!accountIsCurrent) {
@@ -74,21 +71,18 @@ export default async function list(client: Client): Promise<number> {
// Printing
output.stopSpinner();
client.stdout.write('\n'); // empty line
console.log(); // empty line
table(
['', 'id', 'email / name'],
teamList.map(team => [team.current, team.value, team.name]),
[1, 5],
(str: string) => {
client.stdout.write(str);
}
[1, 5]
);
if (pagination?.count === 20) {
const flags = getCommandFlags(argv, ['_', '--next', '-N', '-d']);
const nextCmd = `${packageName} teams ls${flags} --next ${pagination.next}`;
client.stdout.write('\n'); // empty line
console.log(); // empty line
output.log(`To display the next page run ${cmd(nextCmd)}`);
}

View File

@@ -70,21 +70,14 @@ export default async function main(client: Client, desiredSlug?: string) {
suffix += ` ${emoji('locked')}`;
}
const personalAccountChoice =
user.version === 'northstar'
? []
: [
{ separator: 'Personal Account' },
{
name: `${user.name || user.email} (${user.username})${suffix}`,
value: user.username,
short: user.username,
selected: personalScopeSelected,
},
];
const choices = [
...personalAccountChoice,
{ separator: 'Personal Account' },
{
name: `${user.name || user.email} (${user.username})${suffix}`,
value: user.username,
short: user.username,
selected: personalScopeSelected,
},
{ separator: 'Teams' },
...teamChoices,
];
@@ -104,11 +97,6 @@ export default async function main(client: Client, desiredSlug?: string) {
}
if (desiredSlug === user.username || desiredSlug === user.email) {
if (user.version === 'northstar') {
output.error('You cannot set your Personal Account as the scope.');
return 1;
}
// Switch to user's personal account
if (personalScopeSelected) {
output.log('No changes made');

View File

@@ -56,7 +56,6 @@ import { ProxyAgent } from 'proxy-agent';
import box from './util/output/box';
import { execExtension } from './util/extension/exec';
import { help } from './args';
import { updateCurrentTeamAfterLogin } from './util/login/update-current-team-after-login';
const VERCEL_DIR = getGlobalPathConfig();
const VERCEL_CONFIG_PATH = configFiles.getConfigFilePath();
@@ -338,12 +337,17 @@ const main = async () => {
return result;
}
if (result.teamId) {
// SSO login, so set the current scope to the appropriate Team
client.config.currentTeam = result.teamId;
} else {
delete client.config.currentTeam;
}
// When `result` is a string it's the user's authentication token.
// It needs to be saved to the configuration file.
client.authConfig.token = result.token;
await updateCurrentTeamAfterLogin(client, output, result.teamId);
configFiles.writeToAuthConfigFile(client.authConfig);
configFiles.writeToConfigFile(client.config);
@@ -443,11 +447,6 @@ const main = async () => {
}
if (user.id === scope || user.email === scope || user.username === scope) {
if (user.version === 'northstar') {
output.error('You cannot set your Personal Account as the scope.');
return 1;
}
delete client.config.currentTeam;
} else {
let teams = [];

View File

@@ -41,7 +41,7 @@ export async function initCorepack({
const pkgManagerName = pkg.packageManager.split('@')[0];
// We must explicitly call `corepack enable npm` since `corepack enable`
// doesn't work with npm. See https://github.com/nodejs/corepack/pull/24
// Also, `corepack enable` is too broad and will change the version of
// Also, `corepack enable` is too broad and will change the verison of
// yarn & pnpm even though those versions are not specified by the user.
// See https://github.com/nodejs/corepack#known-good-releases
// Finally, we use `--install-directory` so we can cache the result to

View File

@@ -0,0 +1,48 @@
import isWildcardAlias from '../alias/is-wildcard-alias';
import { getCertsForCn } from '../certs/get-certs-for-cn';
import Client from '../client';
/**
* Tries to find the "best" alias url.
* @param aliasList
*/
export async function getPreferredPreviewURL(
client: Client,
aliasList: string[]
) {
if (aliasList.length === 0) {
return null;
}
/**
* First checks for non public aliases and non wildcard domains.
*/
const preferredAliases = aliasList.filter(
alias =>
!alias.endsWith('.now.sh') &&
!alias.endsWith('.vercel.app') &&
!isWildcardAlias(alias)
);
for (const alias of preferredAliases) {
const certs = await getCertsForCn(client, alias, { limit: 1 }).catch(() => {
return null;
});
if (certs && certs.length > 0) {
return { previewUrl: `https://${alias}`, isWildcard: false };
}
}
/**
* Fallback to first alias
*/
const [firstAlias] = aliasList;
if (isWildcardAlias(firstAlias)) {
return { previewUrl: firstAlias, isWildcard: true };
}
if (firstAlias.endsWith('.vercel.app') || firstAlias.endsWith('.now.sh')) {
return { previewUrl: `https://${firstAlias}`, isWildcard: false };
}
return { previewUrl: `http://${firstAlias}`, isWildcard: false };
}

View File

@@ -1,20 +1,20 @@
import chalk from 'chalk';
import type Client from '../client';
import type { Deployment } from '@vercel-internals/types';
import { getPreferredPreviewURL } from '../../util/deploy/get-preferred-preview-url';
import { isDeploying } from '../../util/deploy/is-deploying';
import linkStyle from '../output/link';
import { prependEmoji, emoji } from '../../util/emoji';
/**
* Prints (to `client.output`) warnings and errors, if any.
*/
export async function printDeploymentStatus(
client: Client,
{
readyState,
alias: aliasList,
aliasError,
target,
indications,
url: deploymentUrl,
aliasWarning,
}: {
readyState: Deployment['readyState'];
@@ -36,6 +36,7 @@ export async function printDeploymentStatus(
const { output } = client;
indications = indications || [];
const isProdDeployment = target === 'production';
let isStillBuilding = false;
if (noWait) {
@@ -63,6 +64,30 @@ export async function printDeploymentStatus(
aliasError.message ? `: ${aliasError.message}` : ''
}`
);
} else {
// print preview/production url
let previewUrl: string;
// if `noWait` is true, then use the deployment url, not an alias
if (!noWait && Array.isArray(aliasList) && aliasList.length > 0) {
const previewUrlInfo = await getPreferredPreviewURL(client, aliasList);
if (previewUrlInfo) {
previewUrl = previewUrlInfo.previewUrl;
} else {
previewUrl = `https://${deploymentUrl}`;
}
} else {
// fallback to deployment url
previewUrl = `https://${deploymentUrl}`;
}
output.print(
prependEmoji(
`${isProdDeployment ? 'Production' : 'Preview'}: ${chalk.bold(
previewUrl
)} ${deployStamp()}`,
emoji('success')
) + `\n`
);
}
if (aliasWarning?.message) {

View File

@@ -9,7 +9,7 @@ import {
import { Output } from '../output';
import { progress } from '../output/progress';
import Now from '../../util';
import type { Deployment, Org } from '@vercel-internals/types';
import type { Org } from '@vercel-internals/types';
import ua from '../ua';
import { linkFolderToProject } from '../projects/link';
import { prependEmoji, emoji } from '../emoji';
@@ -17,13 +17,9 @@ import type { Agent } from 'http';
function printInspectUrl(
output: Output,
inspectorUrl: string | null | undefined,
inspectorUrl: string,
deployStamp: () => string
) {
if (!inspectorUrl) {
return;
}
output.print(
prependEmoji(
`Inspect: ${chalk.bold(inspectorUrl)} ${deployStamp()}`,
@@ -166,47 +162,33 @@ export default async function processDeployment({
}
if (event.type === 'created') {
const deployment: Deployment = event.payload;
await linkFolderToProject(
client,
cwd,
{
orgId: org.id,
projectId: deployment.projectId!,
projectId: event.payload.projectId,
},
projectName,
org.slug
);
now.url = deployment.url;
now.url = event.payload.url;
output.stopSpinner();
printInspectUrl(output, deployment.inspectorUrl, deployStamp);
const isProdDeployment = requestBody.target === 'production';
const previewUrl = `https://${deployment.url}`;
output.print(
prependEmoji(
`${isProdDeployment ? 'Production' : 'Preview'}: ${chalk.bold(
previewUrl
)} ${deployStamp()}`,
emoji('success')
) + `\n`
);
printInspectUrl(output, event.payload.inspectorUrl, deployStamp);
if (quiet) {
process.stdout.write(`https://${event.payload.url}`);
}
if (noWait) {
return deployment;
return event.payload;
}
output.spinner(
deployment.readyState === 'QUEUED' ? 'Queued' : 'Building',
event.payload.readyState === 'QUEUED' ? 'Queued' : 'Building',
0
);
}
@@ -261,7 +243,6 @@ export default async function processDeployment({
// Handle alias-assigned event
if (event.type === 'alias-assigned') {
output.stopSpinner();
event.payload.indications = indications;
return event.payload;
}

View File

@@ -59,7 +59,7 @@ export class TeamDeleted extends NowError<'TEAM_DELETED', {}> {
constructor() {
super({
code: 'TEAM_DELETED',
message: `Your team was deleted or you were removed from the team. You can switch to a different one using ${getCommandName(
message: `Your team was deleted. You can switch to a different one using ${getCommandName(
`switch`
)}.`,
meta: {},

View File

@@ -0,0 +1,8 @@
export default (code?: number) =>
new Promise(() => {
// We give stdout some time to flush out
// because there's a node bug where
// stdout writes are asynchronous
// https://github.com/nodejs/node/issues/6456
setTimeout(() => process.exit(code || 0), 100);
});

View File

@@ -15,12 +15,9 @@ export default async function getScope(
const user = await getUser(client);
let contextName = user.username || user.email;
let team: Team | null = null;
const defaultTeamId =
user.version === 'northstar' ? user.defaultTeamId : undefined;
const currentTeamOrDefaultTeamId = client.config.currentTeam || defaultTeamId;
if (currentTeamOrDefaultTeamId && opts.getTeam !== false) {
team = await getTeamById(client, currentTeamOrDefaultTeamId);
if (client.config.currentTeam && opts.getTeam !== false) {
team = await getTeamById(client, client.config.currentTeam);
if (!team) {
throw new TeamDeleted();

View File

@@ -25,18 +25,11 @@ export default async function selectOrg(
output.stopSpinner();
}
const personalAccountChoice =
user.version === 'northstar'
? []
: [
{
name: user.name || user.username,
value: { type: 'user', id: user.id, slug: user.username },
} as const,
];
const choices: Choice[] = [
...personalAccountChoice,
{
name: user.name || user.username,
value: { type: 'user', id: user.id, slug: user.username },
},
...teams.map<Choice>(team => ({
name: team.name || team.slug,
value: { type: 'team', id: team.id, slug: team.slug },

View File

@@ -1,29 +0,0 @@
import type Client from '../client';
import type { Output } from '../output';
import getUser from '../get-user';
// NOTE: `client.authConfig.token` must be set before calling this
export async function updateCurrentTeamAfterLogin(
client: Client,
output: Output,
ssoTeamId?: string
) {
if (ssoTeamId) {
client.config.currentTeam = ssoTeamId;
} else {
let user = null;
try {
user = await getUser(client);
} catch (err: unknown) {
// Shouldn't happen since we just logged in
output.error('Failed to fetch the logged in user. Please try again.');
return 1;
}
if (user.version === 'northstar' && user.defaultTeamId) {
client.config.currentTeam = user.defaultTeamId;
} else {
delete client.config.currentTeam;
}
}
}

View File

@@ -9,8 +9,7 @@ const printLine = (data: string[], sizes: number[]) =>
export default function table(
fieldNames: string[] = [],
data: string[][] = [],
margins: number[] = [],
print: (str: string) => void
margins: number[] = []
) {
// Compute size of each column
const sizes = data
@@ -27,12 +26,10 @@ export default function table(
.map((size, i) => (i < margins.length && size + margins[i]) || size);
// Print header
print(chalk.grey(printLine(fieldNames, sizes)));
print('\n');
console.log(chalk.grey(printLine(fieldNames, sizes)));
// Print content
for (const row of data) {
print(printLine(row, sizes));
print('\n');
console.log(printLine(row, sizes));
}
}

View File

@@ -415,24 +415,6 @@ module.exports = async function prepare(session, binaryPath, tmpFixturesDir) {
projectId: 'QmRoBYhejkkmssotLZr8tWgewPdPcjYucYUNERFbhJrRNi',
}),
},
'vc-build-speed-insights': {
'.vercel/project.json': JSON.stringify({
orgId: '.',
projectId: '.',
settings: {
framework: null,
installCommand: 'echo "skipping install"',
},
}),
'package.json': JSON.stringify({
scripts: {
build: 'mkdir -p public && echo hi > public/index.txt',
},
dependencies: {
'@vercel/speed-insights': '0.0.1',
},
}),
},
'vc-build-static-build': {
'.vercel/project.json': JSON.stringify({
orgId: '.',

View File

@@ -16,6 +16,7 @@ import {
import formatOutput from './helpers/format-output';
import type http from 'http';
import type { CLIProcess } from './helpers/types';
import type {} from './helpers/types';
const TEST_TIMEOUT = 3 * 60 * 1000;
jest.setTimeout(TEST_TIMEOUT);
@@ -104,8 +105,6 @@ function mockLoginApi(req: http.IncomingMessage, res: http.ServerResponse) {
query.email === email
) {
res.end(JSON.stringify({ token }));
} else if (method === 'GET' && pathname === '/v2/user') {
res.end(JSON.stringify({ user: { email } }));
} else {
res.statusCode = 405;
res.end(JSON.stringify({ code: 'method_not_allowed' }));

View File

@@ -79,8 +79,6 @@ function mockLoginApi(req: http.IncomingMessage, res: http.ServerResponse) {
query.email === email
) {
res.end(JSON.stringify({ token }));
} else if (method === 'GET' && pathname === '/v2/user') {
res.end(JSON.stringify({ user: { email } }));
} else {
res.statusCode = 405;
res.end(JSON.stringify({ code: 'method_not_allowed' }));
@@ -737,12 +735,6 @@ test('deploys with only vercel.json and README.md', async () => {
});
expect(exitCode, formatOutput({ stdout, stderr })).toBe(0);
// assert timing order of showing URLs vs status updates
expect(stderr).toMatch(
/Inspect.*\nPreview.*\nQueued.*\nBuilding.*\nCompleting/
);
const { host } = new URL(stdout);
const res = await fetch(`https://${host}/README.md`);
const text = await res.text();
@@ -1154,22 +1146,6 @@ test('[vc build] should build project with `@vercel/static-build`', async () =>
expect(builds.builds[0].use).toBe('@vercel/static-build');
});
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');
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'
);
} finally {
delete process.env.VERCEL_ANALYTICS_ID;
}
});
test('[vc build] should not include .vercel when distDir is "."', async () => {
const directory = await setupE2EFixture('static-build-dist-dir');
const output = await execCli(binaryPath, ['build'], { cwd: directory });

View File

@@ -89,8 +89,6 @@ function mockLoginApi(req: http.IncomingMessage, res: http.ServerResponse) {
query.email === email
) {
res.end(JSON.stringify({ token }));
} else if (method === 'GET' && pathname === '/v2/user') {
res.end(JSON.stringify({ user: { email } }));
} else {
res.statusCode = 405;
res.end(JSON.stringify({ code: 'method_not_allowed' }));

View File

@@ -40,15 +40,3 @@ export function useDomains() {
});
});
}
export function useDomain(postfix: string) {
client.scenario.get(
`/v4/domains/${encodeURIComponent(`example-${postfix}.com`)}`,
(req, res) => {
const domain = createDomain(postfix);
res.json({
domain,
});
}
);
}

View File

@@ -1,29 +0,0 @@
import chance from 'chance';
import { client } from './client';
export function useSecrets({
name,
created,
}: {
name: string;
created: number;
}) {
const secret = {
uid: chance().guid(),
name: name || chance().name(),
created: created || chance().timestamp(),
};
client.scenario.get('/v3/now/secrets', (_req, res) => {
res.json({
secrets: [secret],
pagination: {
count: 1,
next: 0,
prev: 0,
},
});
});
return secret;
}

View File

@@ -7,12 +7,10 @@ export function useTeams(
failMissingToken?: boolean;
failInvalidToken?: boolean;
failNoAccess?: boolean;
apiVersion?: number;
} = {
failMissingToken: false,
failInvalidToken: false,
failNoAccess: false,
apiVersion: 1,
}
) {
const id = teamId || chance().guid();
@@ -61,11 +59,11 @@ export function useTeams(
});
}
client.scenario.get(`/v${options.apiVersion}/teams`, (_req, res) => {
client.scenario.get('/v1/teams', (_req, res) => {
res.json({
teams,
});
});
return options.apiVersion === 2 ? { teams } : teams;
return teams;
}

View File

@@ -1,14 +1,12 @@
import chance from 'chance';
import { client } from './client';
import type { User } from '@vercel-internals/types';
export function useUser(additionalAttrs: Partial<User> = {}) {
export function useUser() {
const user = {
id: chance().guid(),
email: chance().email(),
name: chance().name(),
username: chance().first().toLowerCase(),
...additionalAttrs,
};
client.scenario.get('/v2/user', (_req, res) => {
res.json({

View File

@@ -1,173 +0,0 @@
import type http from 'http';
import fs from 'fs-extra';
import path from 'path';
import { parse as parseUrl } from 'url';
import { execCli } from './helpers/exec';
import waitForPrompt from './helpers/wait-for-prompt';
import getGlobalDir from './helpers/get-global-dir';
import { listTmpDirs } from './helpers/get-tmp-dir';
import formatOutput from './helpers/format-output';
import { User } from '@vercel-internals/types';
const binaryPath = path.resolve(__dirname, `../scripts/start.js`);
function getGlobalConfigPath() {
return path.join(getGlobalDir(), 'config.json');
}
function getConfigAuthPath() {
return path.join(getGlobalDir(), 'auth.json');
}
beforeEach(async () => {
try {
await fs.remove(getGlobalConfigPath());
await fs.remove(getConfigAuthPath());
} catch (err) {
process.exit(1);
}
});
afterEach(() => {
if (localApiServer) {
localApiServer.close();
}
const allTmpDirs = listTmpDirs();
for (const tmpDir of allTmpDirs) {
tmpDir.removeCallback();
}
});
function mockApi(user: Partial<User>) {
return function (req: http.IncomingMessage, res: http.ServerResponse) {
const { url = '/', method } = req;
let { pathname = '/', query = {} } = parseUrl(url, true);
const securityCode = 'Bears Beets Battlestar Galactica';
res.setHeader('content-type', 'application/json');
if (
method === 'POST' &&
pathname === '/registration' &&
query.mode === 'login'
) {
res.end(JSON.stringify({ token: 'test', securityCode }));
} else if (
method === 'GET' &&
pathname === '/registration/verify' &&
query.email === user.email
) {
res.end(JSON.stringify({ token: 'test' }));
} else if (method === 'GET' && pathname === '/v2/user') {
res.end(JSON.stringify({ user }));
} else {
res.statusCode = 405;
res.end(JSON.stringify({ code: 'method_not_allowed' }));
}
};
}
let localApiServer: any;
function setupLocalApiServer(user: Partial<User>) {
return new Promise<string>(resolve => {
localApiServer = require('http')
.createServer(mockApi(user))
.listen(0, () => {
const { port } = localApiServer.address();
const loginApiUrl = `http://localhost:${port}`;
resolve(loginApiUrl);
});
});
}
async function loginSteps(
vercel: ReturnType<typeof execCli>,
user: Partial<User>
) {
await waitForPrompt(vercel, 'Continue with Email');
vercel.stdin?.write('\x1B[B'); // Down arrow
vercel.stdin?.write('\x1B[B'); // Down arrow
vercel.stdin?.write('\x1B[B'); // Down arrow
vercel.stdin?.write('\r'); // Return key
await waitForPrompt(vercel, 'Enter your email address');
vercel.stdin?.write(user.email);
vercel.stdin?.write('\r');
await waitForPrompt(
vercel,
`Email authentication complete for ${user.email}`
);
return vercel;
}
describe('CLI initialization', () => {
describe('login required before running a command', () => {
describe('non-northstar', () => {
const user = {
id: 'test-id',
username: 'test-username',
email: 'test@example.com',
};
it('should not set currentTeam to defaultTeamId', async () => {
const loginApiUrl = await setupLocalApiServer(user);
const vercel = execCli(
binaryPath,
['domains', 'invalidSubCommand', '--api', loginApiUrl],
{ env: { FORCE_TTY: '1' } }
);
const steps = loginSteps(vercel, user);
await waitForPrompt(vercel, 'Please specify a valid subcommand');
const output = await steps;
expect(output.exitCode, formatOutput(output)).toBe(2);
const config = await fs.readJSON(getGlobalConfigPath());
expect(config.currentTeam).toBeUndefined();
});
});
describe('northstar', () => {
const user = {
id: 'test-id',
username: 'test-username',
email: 'test@example.com',
version: 'northstar',
defaultTeamId: 'test-default-team-id',
};
it('should set currentTeam to defaultTeamId', async () => {
const loginApiUrl = await setupLocalApiServer(user);
const vercel = execCli(
binaryPath,
['domains', 'invalidSubCommand', '--api', loginApiUrl],
{ env: { FORCE_TTY: '1' } }
);
const steps = loginSteps(vercel, user);
await waitForPrompt(vercel, 'Please specify a valid subcommand');
const output = await steps;
expect(output.exitCode, formatOutput(output)).toBe(2);
const config = await fs.readJSON(getGlobalConfigPath());
expect(config.currentTeam).toEqual(user.defaultTeamId);
});
it('should not allow setting user as scope', async () => {
const loginApiUrl = await setupLocalApiServer(user);
const vercel = execCli(
binaryPath,
[
'domains',
'invalidSubCommand',
'--api',
loginApiUrl,
'--scope',
user.username,
],
{ env: { FORCE_TTY: '1' } }
);
const steps = loginSteps(vercel, user);
await waitForPrompt(
vercel,
'You cannot set your Personal Account as the scope.'
);
const output = await steps;
expect(output.exitCode, formatOutput(output)).toBe(1);
});
});
});
});

View File

@@ -1,8 +1,7 @@
import { client } from '../../mocks/client';
import domains from '../../../src/commands/domains';
import { useUser } from '../../mocks/user';
import { useTeams } from '../../mocks/team';
import { useDomain, useDomains } from '../../mocks/domains';
import { useDomains } from '../../mocks/domains';
describe('domains', () => {
it('should list up to 20 domains by default', async () => {
@@ -22,19 +21,4 @@ describe('domains', () => {
await expect(client.stderr).toOutput('example-1.com');
await expect(exitCodePromise).resolves.toEqual(0);
});
describe('northstar', () => {
it('should prevent moving a domain to a user account', async () => {
const { username } = useUser({ version: 'northstar' });
useTeams();
useDomain('northstar');
client.setArgv('domains', 'move', 'example-northstar.com', username);
const exitCodePromise = domains(client);
await expect(client.stderr).toOutput(
`Fetching domain example-northstar.com under ${username}
Error: You may not move your domain to your user account.`
);
await expect(exitCodePromise).resolves.toEqual(1);
});
});
});

View File

@@ -426,46 +426,5 @@ describe('env', () => {
);
expect(gitignoreAfter).toBe(gitignoreBefore);
});
it('should not pull VERCEL_ANALYTICS_ID', async () => {
useUser();
useTeams('team_dummy');
useProject(
{
...defaultProject,
id: 'vercel-env-pull',
name: 'vercel-env-pull',
analytics: {
id: 'VC-ANALYTICS-ID',
enabledAt: Date.now(),
},
},
[
{
type: 'encrypted',
id: '781dt89g8r2h789g',
key: 'VERCEL_ANALYTICS_ID',
value: 'VC-ANALYTICS-ID',
target: ['development'],
configurationId: null,
updatedAt: 1557241361455,
createdAt: 1557241361455,
},
]
);
const cwd = setupUnitFixture('vercel-env-pull');
client.cwd = cwd;
client.setArgv('env', 'pull', '--yes');
const exitCodePromise = env(client);
await expect(client.stderr).toOutput(
'Downloading `development` Environment Variables for Project '
);
await expect(client.stderr).toOutput('Created .env.local file');
await expect(exitCodePromise).resolves.toEqual(0);
const rawDevEnv = await fs.readFile(path.join(cwd, '.env.local'));
expect(rawDevEnv.toString().includes('VERCEL_ANALYTICS_ID')).toBeFalsy();
});
});
});

View File

@@ -13,8 +13,8 @@ import { setupTmpDir } from '../../helpers/setup-unit-fixture';
describe('link', () => {
it('should prompt for link', async () => {
const user = useUser();
const cwd = setupTmpDir();
const user = useUser();
useTeams('team_dummy');
const { project } = useProject({
...defaultProject,

View File

@@ -25,22 +25,6 @@ describe('login', () => {
await expect(exitCodePromise).resolves.toEqual(0);
});
describe('northstar', () => {
it('should set currentTeam to defaultTeamId', async () => {
const user = useUser({
version: 'northstar',
defaultTeamId: 'northstar-defaultTeamId',
});
client.authConfig.token = undefined;
client.setArgv('login', user.email);
const exitCodePromise = login(client);
await expect(exitCodePromise).resolves.toEqual(0);
await expect(client.config.currentTeam).toEqual(
'northstar-defaultTeamId'
);
});
});
describe('interactive', () => {
it('should allow login via email', async () => {
const user = useUser();

View File

@@ -1,37 +0,0 @@
import { client } from '../../mocks/client';
import secrets from '../../../src/commands/secrets';
import { useSecrets } from '../../mocks/secrets';
import { useUser } from '../../mocks/user';
import { useTeams } from '../../mocks/team';
import ms from 'ms';
describe('secrets', () => {
it('errors when no subcommand is provided', async () => {
client.setArgv('secrets');
const exitCode = await secrets(client);
expect(exitCode).toEqual(2);
});
it('lists secrets with ls subcommand', async () => {
useUser();
useTeams('team_dummy');
const name = 'secret-api-password';
const created = 1519555701;
useSecrets({ name, created });
client.setArgv('secrets', 'ls');
await secrets(client);
const timeAgo = `${ms(
new Date().getTime() - new Date(created).getTime()
)} ago`;
await expect(client.stderr).toOutput(
'> NOTE: The `vercel env ls` command is recommended instead of `vercel secret ls`'
);
const output = client.stderr.read();
await expect(output).toMatch(name);
await expect(output).toMatch(timeAgo);
});
});

View File

@@ -1,81 +0,0 @@
import { client } from '../../mocks/client';
import teamsSwitch from '../../../src/commands/teams/switch';
import { useUser } from '../../mocks/user';
import { useTeams } from '../../mocks/team';
describe('switch', () => {
describe('non-northstar', () => {
it('should let you switch to team and back', async () => {
const user = useUser();
const team = useTeams()[0];
// ? Switch to:
// ── Personal Account ──────────────
// ● Name (username) (current)
// ── Teams ─────────────────────────
// ○ Team (slug)
// ──────────────────────────────────
// ○ Cancel
let exitCodePromise = teamsSwitch(client);
await expect(client.stderr).toOutput('Switch to:');
client.stdin.write('\x1B[B'); // Down arrow
client.stdin.write('\r'); // Return key
await expect(exitCodePromise).resolves.toEqual(0);
await expect(client.stderr).toOutput(
`Success! The team ${team.name} (${team.slug}) is now active!`
);
// ? Switch to:
// ── Personal Account ──────────────
// ○ Name (username)
// ── Teams ─────────────────────────
// ● Team (slug) (current)
// ──────────────────────────────────
// ○ Cancel
exitCodePromise = teamsSwitch(client);
await expect(client.stderr).toOutput('Switch to:');
client.stdin.write('\x1B[A'); // Up arrow
client.stdin.write('\r'); // Return key
await expect(exitCodePromise).resolves.toEqual(0);
await expect(client.stderr).toOutput(
`Your account (${user.username}) is now active!`
);
});
});
describe('northstar', () => {
it('should not let you switch to personal account', async () => {
const user = useUser({
version: 'northstar',
});
const team = useTeams()[0];
client.config.currentTeam = team.id;
// ? Switch to:
// ── Teams ─────────────────────────
// ● Team (slug) (current)
// ──────────────────────────────────
// ○ Cancel
const exitCodePromise = teamsSwitch(client);
// Test that personal account is not displayed in scope switcher
await expect(client.stderr).not.toOutput(user.username);
client.stdin.write('\r'); // Return key
await expect(exitCodePromise).resolves.toEqual(0);
await expect(client.stderr).toOutput('No changes made');
});
it('should not let you switch to personal account if desiredSlug is set as personal account', async () => {
const user = useUser({
version: 'northstar',
});
useTeams();
const exitCodePromise = teamsSwitch(client, user.username);
// Personal account should be hidden
await expect(client.stderr).toOutput(
'You cannot set your Personal Account as the scope.'
);
await expect(exitCodePromise).resolves.toEqual(1);
});
});
});

View File

@@ -1,30 +0,0 @@
import { client } from '../../mocks/client';
import teamsList from '../../../src/commands/teams/list';
import { useUser } from '../../mocks/user';
import { useTeams } from '../../mocks/team';
describe('teams', () => {
describe('ls', () => {
describe('non-northstar', () => {
it('should display your personal account', async () => {
const user = useUser();
useTeams(undefined, { apiVersion: 2 });
const exitCodePromise = teamsList(client);
await expect(client.stdout).toOutput(user.username);
await expect(exitCodePromise).resolves.toEqual(0);
});
});
describe('northstar', () => {
it('should not display your personal account', async () => {
const user = useUser({
version: 'northstar',
});
useTeams(undefined, { apiVersion: 2 });
const exitCodePromise = teamsList(client);
await expect(client.stdout).not.toOutput(user.username);
await expect(exitCodePromise).resolves.toEqual(0);
});
});
});
});

Some files were not shown because too many files have changed in this diff Show More