Compare commits

...

45 Commits

Author SHA1 Message Date
Vercel Release Bot
bcebab7517 Version Packages (#10478)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/build-utils@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))

## vercel@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`](6784e77516),
[`a8ad17626`](a8ad176262),
[`0ee089a50`](0ee089a501),
[`f15cba614`](f15cba6148),
[`b265e13d4`](b265e13d40),
[`50e04dd85`](50e04dd858),
[`45b73c7e8`](45b73c7e86),
[`a732d30c8`](a732d30c84),
[`9d64312aa`](9d64312aaa),
[`6baefc825`](6baefc825a),
[`989f0d813`](989f0d8139),
[`d8bc570f6`](d8bc570f60)]:
    -   @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

## @vercel/client@13.0.3

### Patch Changes

- Updated dependencies
\[[`50e04dd85`](50e04dd858),
[`45b73c7e8`](45b73c7e86),
[`d8bc570f6`](d8bc570f60)]:
    -   @vercel/build-utils@7.2.0

## @vercel/edge@1.0.2

### Patch Changes

- [node] upgrade edge-runtime
([#10451](https://github.com/vercel/vercel/pull/10451))

## @vercel/gatsby-plugin-vercel-builder@2.0.5

### Patch Changes

- Updated dependencies
\[[`50e04dd85`](50e04dd858),
[`45b73c7e8`](45b73c7e86),
[`9d64312aa`](9d64312aaa),
[`d8bc570f6`](d8bc570f60)]:
    -   @vercel/build-utils@7.2.0
    -   @vercel/node@3.0.5

## @vercel/go@3.0.1

### Patch Changes

- Update to esbuild script
([#10468](https://github.com/vercel/vercel/pull/10468))

## @vercel/hydrogen@1.0.1

### Patch Changes

- Use `build-builder.mjs` script to bundle, and remove types and source
maps ([#10480](https://github.com/vercel/vercel/pull/10480))

## @vercel/next@4.0.3

### Patch Changes

- fix content-type for RSC prefetches
([#10487](https://github.com/vercel/vercel/pull/10487))

## @vercel/node@3.0.5

### Patch Changes

- [node] upgrade edge-runtime
([#10451](https://github.com/vercel/vercel/pull/10451))

- Updated dependencies
\[[`50e04dd85`](50e04dd858),
[`45b73c7e8`](45b73c7e86),
[`d8bc570f6`](d8bc570f60)]:
    -   @vercel/build-utils@7.2.0

## @vercel/python@4.0.1

### Patch Changes

- Update to esbuild script
([#10470](https://github.com/vercel/vercel/pull/10470))

## @vercel/redwood@2.0.2

### Patch Changes

- Update to esbuild script
([#10471](https://github.com/vercel/vercel/pull/10471))

## @vercel/remix-builder@2.0.4

### Patch Changes

- Use `build-builder.mjs` script to bundle, and remove types and source
maps ([#10479](https://github.com/vercel/vercel/pull/10479))

## @vercel/ruby@2.0.2

### Patch Changes

- Update to esbuild script
([#10472](https://github.com/vercel/vercel/pull/10472))

## @vercel/static-build@2.0.5

### Patch Changes

- Build package using "esbuild"
([#10462](https://github.com/vercel/vercel/pull/10462))

-   Updated dependencies \[]:
    -   @vercel/gatsby-plugin-vercel-builder@2.0.5

## @vercel-internals/types@1.0.10

### Patch Changes

- Updated dependencies
\[[`50e04dd85`](50e04dd858),
[`45b73c7e8`](45b73c7e86),
[`d8bc570f6`](d8bc570f60)]:
    -   @vercel/build-utils@7.2.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-11 17:30:02 -04:00
Steven
45b73c7e86 [build-utils] Add zero config detection for bun package manager (#10486)
> [!IMPORTANT]  
> This PR will only support Bun as a package manager at build time. 
> Bun will **not** work at runtime with Serverless Functions or Edge
Functions at this time.

- Depends on https://github.com/vercel/api/pull/21869
- Fixes https://github.com/orgs/vercel/discussions/2021
- Closes https://github.com/vercel/vercel/pull/10244
- Related https://github.com/nodejs/corepack/issues/295
- Docs https://bun.sh/docs/install
2023-09-11 17:26:34 -04:00
Zack Tanner
a732d30c84 [next] fix content-type for RSC prefetches (#10487)
This ensures that the `.prefetch.rsc` requests respond with the correct `content-type` since this is used by Next.js to determine if a request is valid or not (and in the case it's invalid, an mpa navigation will occur)

Fixes: https://github.com/vercel/next.js/issues/54934
2023-09-11 19:04:16 +00:00
Lee Robinson
8504735808 [examples] Update Astro starter (#10397)
Deployed https://astro.vercel.app/image.
2023-09-11 16:29:54 +00:00
Kiko Beats
9d64312aaa [node] upgrade edge-runtime (#10451) 2023-09-10 13:14:43 +00:00
Chris Barber
a8ad176262 [redwood] Use new esbuild script (#10471) 2023-09-09 01:48:54 +00:00
Nathan Rajlich
0ee089a501 [remix] Bundle, remove types and source maps (#10479)
For consistency with other Builders.
2023-09-09 00:35:56 +00:00
Zack Tanner
d8bc570f60 [build-utils] add experimentalBypassFor field to Prerender (#10481)
This adds an experimental flag to `Prerender` outputs as a way to programmatically bypass the cache and hit the lambda directly, using a similar interface to `has`. 

(Note: I copied over `HasField` from `@vercel/router-utils` since it wasn't available for import in `build-utils`, but can add it as a dep if that's preferred)

The specific use-case being targeted here relates to https://github.com/vercel/next.js/pull/51534 -- a Next.js page marked static should still be able to initiate server actions.
2023-09-08 23:33:59 +00:00
Nathan Rajlich
f15cba6148 [hydrogen] Bundle, remove types and source maps (#10480)
Similar to #10479, but for `@vercel/hydrogen`.
2023-09-08 22:55:03 +00:00
Chris Barber
989f0d8139 [ruby] Use new esbuild script (#10472) 2023-09-08 17:27:17 -05:00
Chris Barber
6784e77516 [go] Update to esbuild script (#10468)
Co-authored-by: Nathan Rajlich <n@n8.io>
2023-09-08 17:00:40 -05:00
Chris Barber
6baefc825a [python] Update to esbuild script (#10470)
Co-authored-by: Steven <steven@ceriously.com>
2023-09-08 16:23:23 -05:00
Chris Barber
0a08e4b23e [cli] Update @vercel/fun@1.1.0 (#10477) 2023-09-08 15:39:13 -05:00
Nathan Rajlich
b265e13d40 [static-build] Use esbuild (#10462)
Switch to using esbuild to compile + bundle `@vercel/static-build`.
2023-09-08 19:39:12 +00:00
Nabeel Sulieman
50e04dd858 Add optional experimentalStreamingLambda field for prerender (#10476)
This adds a new `experimentalStreamingLambda` field to Prerender
outputs, allowing references to an optional streaming lambda path.
2023-09-08 11:42:06 -07:00
Vercel Release Bot
82231058da Version Packages (#10400)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-08 11:41:32 -05:00
Steven
61227bf7e3 fix .changeset/nice-lies-sip.md (#10474)
I think we need to remove `api` since its private so its not published to npm and therefore isn't versioned.
2023-09-08 02:09:11 +00:00
Zack Tanner
6aa0aa4e65 [next] fix ENOENT on /404.html when fallback: false w/ basePath (#10473)
The following error occurs during build when `basePath` is present in conjunction with `fallback: false` in `getStaticPaths`:

> Error: ENOENT: no such file or directory, open '/vercel/path0/.next/server/pages/404.html'

`localePrefixed404` was incorrectly being set to `false` because it was looking for `/<basePath>/<locale>/404.html` (when it's actually `/<locale>/404.html`)

This meant that inside `onPrerenderRoute`, `htmlFsRef` was pointing to `/404.html` rather than `/en/404.html`.
2023-09-08 00:17:08 +00:00
JJ Kasper
caaba0d685 [next] fix app dir edge functions with basePath (#10465)
x-ref: https://github.com/vercel/vercel/pull/10394
2023-09-07 22:03:12 +00:00
Steven
335fd70a68 [ci] Update codeowners (#10467)
Update codeowners for Next.js
2023-09-07 14:20:20 +00:00
Zack Tanner
c3c54d6e69 [next]: Fix RSC rewrite behavior (#10415)
- Removes some of the hacks from #10388 that were attempting to resolve an issue with RSC prefetches to `pages` routes in favor of adding rsc rewrites for all dynamic paths, and letting it fall through to a 404 if there's no match
- Fixes an issue where RSC requests were matching the wrong path (filesystem rather than RSC variant) introduced in above mentioned change
  - Closes https://github.com/vercel/next.js/issues/54698
2023-09-07 14:03:14 +00:00
Shu Uesugi
43048a0dd8 [CLI] Fix team URL on vercel help switch (#10466)
In `vercel help switch`, it suggests that team URL is of the format `vercel.com/teams/name`, but this will be 404. It should be `vercel.com/name`.
2023-09-07 13:12:54 +00:00
Sean Massa
60c75fd76c [CLI] show instant preview url on vc deploy and vc redeploy (#10458)
Show Instant Preview URLs immediately during `vc deploy`.

This does mean that we'll no longer show the nicer aliased URLs, but that's probably fine.

https://github.com/vercel/vercel/assets/41545/5d6d5695-60c3-49ca-a54d-a16828583070

---

- [Card](https://linear.app/vercel/issue/VCCLI-897/show-instant-preview-url-on-vc-deploy)
2023-09-06 23:46:44 +00:00
Trek Glowacki
bd1319d7a3 [cli] Update secrets.js to more current styles (#10461)
Updates the `secrets` command to be a bit more modern. Initially I was going to covert this to typescript but that change was quite large, so going stepwise for easier review.

1. Moves the command implementation into a directory like other commands
2. Shifts the command data structure into its own file
3. Adds a test.

Other relevant comments inline.
2023-09-06 20:58:57 +00:00
Nathan Rajlich
1138f7e3d1 Use esbuild for non-ncc'd packages (#10430)
The intention is for this to be a drop-in replacement for compiling TypeScript to JavaScript, but using `esbuild` instead of `tsc`. `tsc` is still needed, but only for the cases where we want to generate type definitions.
2023-09-06 19:49:50 +00:00
Ethan Arrowood
bb95cb9225 [cli] migrate teams command (#10434)
Before:
<img width="661" alt="Screenshot 2023-08-31 at 13 59 35" src="https://github.com/vercel/vercel/assets/16144158/7d16367a-662e-4ef1-8561-c197f4badf48">

After:
<img width="1036" alt="Screenshot 2023-08-31 at 14 00 23" src="https://github.com/vercel/vercel/assets/16144158/64431bdb-48ce-4bc1-8ed0-c719bdfbb350">
2023-09-06 16:15:35 +00:00
Trek Glowacki
0048eb999e [cli] N, not n. (#10460)
Followup to https://github.com/vercel/vercel/pull/10432#discussion_r1315482954
2023-09-06 15:42:37 +00:00
Espen Hovlandsdal
1b4de4a986 chore(deps): upgrade semver dependency (#10411)
Addresses ReDoS vulnerability: https://security.snyk.io/vuln/SNYK-JS-SEMVER-3247795
Uses the latest unaffected versions in the respective major versions, to prevent having to deal with any other breaking changes.
2023-09-06 13:37:37 +00:00
JJ Kasper
c9ad4084ee [next] Update page config test (#10456)
Updates failing test in https://github.com/vercel/vercel/actions/runs/6090040294/job/16525842631?pr=10430 per changes in https://github.com/vercel/next.js/pull/54786
2023-09-06 00:46:37 +00:00
Trek Glowacki
98ee6e4728 [cli] Migrate domains to new command structure (#10427)
After:
<img width="790" alt="CleanShot 2023-08-31 at 11 39 25@2x" src="https://github.com/vercel/vercel/assets/9736/b2e0e090-8c7c-4659-b1aa-1c59744d2eb1">

Before:
<img width="813" alt="CleanShot 2023-08-31 at 11 40 06@2x" src="https://github.com/vercel/vercel/assets/9736/731626a0-86f0-446d-8f77-436205acac87">
2023-09-05 21:11:03 +00:00
Vercel Release Bot
d7db0c5794 [tests] Upgrade Turbo to version 1.10.13 (#10404)
This auto-generated PR updates Turbo to version 1.10.13
2023-09-05 20:28:17 +00:00
Sean Massa
e90e922ee8 migrate dev command structure for help output (#10433)
Migrates the `vc git` command to the command data structure for use in the help output.

---

<img width="1891" alt="Screenshot 2023-08-31 at 1 35 07 PM" src="https://github.com/vercel/vercel/assets/41545/d3d63faa-9427-49e8-8137-a76d4c208cb3">
2023-09-05 19:51:44 +00:00
Trek Glowacki
adb9ac87ce [cli] Remove mri workaround (#10452)
As of https://github.com/vercel/vercel/pull/10389 the `mri` package is no longer used and this workaround can be removed.
2023-09-05 16:17:18 +00:00
Steven
e43191b186 [next] fix 404 enoent for i18n (#10416)
This PR fixes the following error:

```
Error: ENOENT: no such file or directory, open '/vercel/path0/.next/server/pages/en/404.html'
```


https://github.com/vercel/vercel/actions/runs/6030773334/job/16364078054?pr=10415#step:9:1352
2023-09-01 10:39:52 -04:00
Dan Stowell
a962e84409 migrate env to command structure (#10429)
Migrates the `vc env` command to the command data structure for use in the help output.
2023-08-31 23:10:28 +00:00
Trek Glowacki
7593e219fd [cli] Update project command to new structure (#10432)
Before:
<img width="687" alt="CleanShot 2023-08-31 at 13 29 29@2x" src="https://github.com/vercel/vercel/assets/9736/87e0f445-701a-4851-b73f-c787db01abe3">

After:
<img width="868" alt="CleanShot 2023-08-31 at 13 31 50@2x" src="https://github.com/vercel/vercel/assets/9736/b6820654-3254-4a65-820a-30ff7b577a44">
2023-08-31 22:45:44 +00:00
Dan Stowell
ec95066689 migrate vc secrets to help command structure (#10435) 2023-08-31 15:17:51 -07:00
Sean Massa
42a71416b9 migrate init command structure for help output (#10428)
Migrates the `vc init` command to the command data structure for use in the help output.

---

<img width="1891" alt="Screenshot 2023-08-31 at 11 36 37 AM" src="https://github.com/vercel/vercel/assets/41545/1caeb203-470f-49a5-86b2-273b04bc0489">
2023-08-31 21:48:09 +00:00
Sean Massa
80af30ce60 migrate git command structure for help output (#10431) 2023-08-31 16:02:49 -05:00
Sean Massa
74a15b5f32 migrate rollback command structure for help output (#10426)
Migrates the `vc rollback` command to the command data structure for use in the help output.

---

<img width="1891" alt="Screenshot 2023-08-31 at 11 25 49 AM" src="https://github.com/vercel/vercel/assets/41545/a6d802ac-3851-4641-b950-764fc65fa9d2">
2023-08-31 19:09:59 +00:00
Sean Massa
c0416f7e95 migrate promote command structure for help output (#10425)
Migrates the `vc promote` command to the command data structure for use in the help output.

---

<img width="1878" alt="Screenshot 2023-08-31 at 11 04 32 AM" src="https://github.com/vercel/vercel/assets/41545/b79c6aec-af03-4685-8ee4-9c0d89b2f236">
2023-08-31 18:41:55 +00:00
Kiko Beats
fc1e13c099 fix: remove console.log (#10417) 2023-08-31 16:34:27 +02:00
Nathan Rajlich
0e9ec194a3 Keep vercel@canary up to date with vercel@latest (#10410) 2023-08-28 22:50:30 -07:00
Sean Massa
5609a1187b [build-utils] add descriptions to NodeVersion properties (#10403) 2023-08-26 19:49:47 -05:00
Sean Massa
cff72e3129 [examples] fix redwood template and update examples to use at least node@16 (#10395)
The redwood template was broken because it would use node@18, which is not supported for the version of redwood used in the template. This PR updates that version to be node@16, which does work.

While we're at it, I also updated other examples to be at least node@16. I tested deployments of each of these and the all work.
2023-08-25 15:01:55 +00:00
163 changed files with 2724 additions and 1519 deletions

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
/packages/next @TooTallNate @EndangeredMassa @styfle @cb1kenobi @Ethan-Arrowood @trek @ijjk @ztanner
/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
/examples/nextjs @timneutkens @ijjk @styfle @ztanner
/examples/hugo @styfle
/examples/jekyll @styfle
/examples/zola @styfle

7
examples/CHANGELOG.md vendored Normal file
View File

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

View File

@@ -3,9 +3,10 @@
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)
- `/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
- `/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)
Learn more about [Astro on Vercel](https://vercel.com/docs/frameworks/astro).

View File

@@ -1,7 +1,17 @@
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',
adapter: vercel(),
experimental: {
assets: true
},
adapter: vercel({
imageService: true,
}),
});

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

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

View File

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

View File

@@ -10,5 +10,6 @@
"devDependencies": {
"@types/jest": "27.4.1",
"@vercel/frameworks": "2.0.1"
}
},
"version": null
}

View File

@@ -30,6 +30,6 @@
"wct-browser-legacy": "^1.0.0"
},
"engines": {
"node": ">=8.0"
"node": ">=16.0"
}
}

View File

@@ -14,7 +14,7 @@
"extends": "@redwoodjs/eslint-config"
},
"engines": {
"node": ">=12",
"node": "16.x",
"yarn": ">=1.15"
}
}

View File

@@ -27,6 +27,6 @@
"typescript": "^5.1.3"
},
"engines": {
"node": ">=14"
"node": ">=16"
}
}

View File

@@ -46,6 +46,6 @@
]
},
"engines": {
"node": ">=8.0.0 <17"
"node": "16.x"
}
}

View File

@@ -5,7 +5,7 @@
"build": "vuepress build src"
},
"engines": {
"node": ">=14.0.0 <18.0.0"
"node": ">=16.0.0 <18.0.0"
},
"devDependencies": {
"vuepress": "1.9.7"

View File

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

View File

@@ -1,7 +1,9 @@
{
"extends": "@vercel-internals/tsconfig",
"compilerOptions": {
"outDir": "dist"
"outDir": "dist",
"declaration": true,
"emitDeclarationOnly": true
},
"include": ["src/**/*"]
}

View File

@@ -1,5 +1,19 @@
# @vercel-internals/types
## 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

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

View File

@@ -16,6 +16,7 @@
"buffer-replace": "1.0.0",
"create-svelte": "2.0.1",
"dot": "1.1.3",
"esbuild": "0.19.2",
"eslint": "8.14.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-jest": "26.1.5",
@@ -32,7 +33,7 @@
"source-map-support": "0.5.12",
"ts-eager": "2.0.2",
"ts-jest": "29.1.0",
"turbo": "1.10.12",
"turbo": "1.10.13",
"typescript": "4.9.5"
},
"scripts": {
@@ -49,7 +50,7 @@
"prepare": "husky install",
"pack": "cd utils && node -r ts-eager/register ./pack.ts",
"ci:version": "changeset version && pnpm install --no-frozen-lockfile",
"ci:publish": "pnpm publish -r && changeset tag"
"ci:publish": "pnpm publish -r && node utils/update-canary-tags.mjs && changeset tag"
},
"lint-staged": {
"./{*,{api,packages,test,utils}/**/*}.{js,ts}": [

View File

@@ -1,5 +1,25 @@
# @vercel/build-utils
## 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,30 +0,0 @@
#!/usr/bin/env node
const fs = require('fs-extra');
const execa = require('execa');
const { join } = require('path');
async function main() {
const outDir = join(__dirname, 'dist');
// Start fresh
await fs.remove(outDir);
// Compile TypeScript
await execa('tsc', [], { stdio: 'inherit' });
// Run `ncc`
const mainDir = join(outDir, 'main');
await execa('ncc', ['build', 'src/index.ts', '-o', mainDir], {
stdio: 'inherit',
});
// Move compiled ncc file to out dir
await fs.rename(join(mainDir, 'index.js'), join(outDir, 'index.js'));
// Delete leftover "main" dir
await fs.remove(mainDir);
}
main().catch(err => {
console.error(err);
process.exit(1);
});

View File

@@ -0,0 +1,3 @@
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.1.0",
"version": "7.2.0",
"license": "Apache-2.0",
"main": "./dist/index.js",
"types": "./dist/index.d.js",
@@ -11,7 +11,7 @@
"directory": "packages/now-build-utils"
},
"scripts": {
"build": "node build",
"build": "node build.mjs",
"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 +49,7 @@
"minimatch": "3.1.2",
"multistream": "2.1.1",
"node-fetch": "2.6.7",
"semver": "6.1.1",
"semver": "6.3.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';
export type CliType = 'yarn' | 'npm' | 'pnpm' | 'bun';
export interface ScanParentDirsResult {
/**
@@ -284,26 +284,34 @@ export async function scanParentDirs(
readPackageJson && pkgJsonPath
? JSON.parse(await fs.readFile(pkgJsonPath, 'utf8'))
: undefined;
const [yarnLockPath, npmLockPath, pnpmLockPath] = await walkParentDirsMulti({
base: '/',
start: destPath,
filenames: ['yarn.lock', 'package-lock.json', 'pnpm-lock.yaml'],
});
const [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath] =
await walkParentDirsMulti({
base: '/',
start: destPath,
filenames: [
'yarn.lock',
'package-lock.json',
'pnpm-lock.yaml',
'bun.lockb',
],
});
let lockfilePath: string | undefined;
let lockfileVersion: number | undefined;
let cliType: CliType = 'yarn';
const [hasYarnLock, packageLockJson, pnpmLockYaml] = await Promise.all([
Boolean(yarnLockPath),
npmLockPath
? readConfigFile<{ lockfileVersion: number }>(npmLockPath)
: null,
pnpmLockPath
? readConfigFile<{ lockfileVersion: number }>(pnpmLockPath)
: null,
]);
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,
]);
// Priority order is Yarn > pnpm > npm
// Priority order is Yarn > pnpm > npm > bun
if (hasYarnLock) {
cliType = 'yarn';
lockfilePath = yarnLockPath;
@@ -315,6 +323,11 @@ 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;
@@ -451,6 +464,10 @@ 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];
@@ -505,6 +522,7 @@ 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 (
@@ -516,7 +534,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 (
@@ -528,7 +546,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' &&
@@ -539,7 +557,16 @@ 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...`
`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'
);
}
} else {
@@ -548,7 +575,6 @@ export function getEnvForPackageManager({
newEnv.YARN_NODE_LINKER = 'node-modules';
}
}
return newEnv;
}
@@ -614,6 +640,8 @@ 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 { File } from './types';
import type { File, HasField } from './types';
import { Lambda } from './lambda';
interface PrerenderOptions {
@@ -12,6 +12,8 @@ interface PrerenderOptions {
initialStatus?: number;
passQuery?: boolean;
sourcePath?: string;
experimentalBypassFor?: HasField;
experimentalStreamingLambdaPath?: string;
}
export class Prerender {
@@ -26,6 +28,8 @@ export class Prerender {
public initialStatus?: number;
public passQuery?: boolean;
public sourcePath?: string;
public experimentalBypassFor?: HasField;
public experimentalStreamingLambdaPath?: string;
constructor({
expiration,
@@ -38,6 +42,8 @@ export class Prerender {
initialStatus,
passQuery,
sourcePath,
experimentalBypassFor,
experimentalStreamingLambdaPath,
}: PrerenderOptions) {
this.type = 'Prerender';
this.expiration = expiration;
@@ -86,6 +92,26 @@ 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.'
@@ -130,5 +156,14 @@ 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,6 +45,18 @@ 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;
@@ -300,9 +312,13 @@ export interface PackageJson {
}
export interface NodeVersion {
/** major version number: 18 */
major: number;
/** major version range: "18.x" */
range: string;
/** runtime descriptor: "nodejs18.x" */
runtime: string;
/** date beyond which this version is discontinued: 2023-08-17T19:05:45.951Z */
discontinueDate?: Date;
}

View File

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

View File

@@ -0,0 +1,8 @@
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)

Binary file not shown.

View File

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

View File

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

View File

@@ -133,6 +133,22 @@ 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,6 +344,70 @@ 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,
@@ -387,6 +451,42 @@ 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('../');
@@ -440,6 +540,15 @@ 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,6 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",

View File

@@ -1,5 +1,72 @@
# vercel
## 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.1.0",
"version": "32.2.1",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Vercel",
@@ -31,20 +31,20 @@
"node": ">= 16"
},
"dependencies": {
"@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"
"@vercel/build-utils": "7.2.0",
"@vercel/go": "3.0.1",
"@vercel/hydrogen": "1.0.1",
"@vercel/next": "4.0.3",
"@vercel/node": "3.0.5",
"@vercel/python": "4.0.1",
"@vercel/redwood": "2.0.2",
"@vercel/remix-builder": "2.0.4",
"@vercel/ruby": "2.0.2",
"@vercel/static-build": "2.0.5"
},
"devDependencies": {
"@alex_neo/jest-expect-message": "1.0.5",
"@edge-runtime/node-utils": "2.2.0",
"@edge-runtime/node-utils": "2.2.1",
"@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.8",
"@vercel/client": "13.0.1",
"@vercel-internals/types": "1.0.10",
"@vercel/client": "13.0.3",
"@vercel/error-utils": "2.0.1",
"@vercel/frameworks": "2.0.1",
"@vercel/fs-detectors": "5.0.1",
"@vercel/fun": "1.0.4",
"@vercel/fs-detectors": "5.0.2",
"@vercel/fun": "1.1.0",
"@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.5.0",
"semver": "5.7.2",
"serve-handler": "6.1.1",
"strip-ansi": "6.0.1",
"supports-hyperlinks": "3.0.0",

View File

@@ -0,0 +1,34 @@
import { Command } from '../help';
import { packageName } from '../../util/pkg-name';
export const devCommand: Command = {
name: 'dev',
description: `Starts the \`${packageName} dev\` server.`,
arguments: [
{
name: 'dir',
required: false,
},
],
options: [
{
name: 'listen',
description: 'Specify a URI endpoint on which to listen [0.0.0.0:3000]',
argument: 'uri',
shorthand: null,
type: 'string',
deprecated: false,
multi: false,
},
],
examples: [
{
name: `Start the \`${packageName} dev\` server on port 8080`,
value: `${packageName} dev --listen 8080`,
},
{
name: 'Make the `vercel dev` server bind to localhost on port 5000',
value: `${packageName} dev --listen 127.0.0.1:5000 `,
},
],
};

View File

@@ -12,43 +12,16 @@ import highlight from '../../util/output/highlight';
import dev from './dev';
import readConfig from '../../util/config/read-config';
import readJSONFile from '../../util/read-json-file';
import { packageName, getCommandName, logo } from '../../util/pkg-name';
import { packageName, getCommandName } from '../../util/pkg-name';
import { CantParseJSONFile } from '../../util/errors-ts';
import { isErrnoException } from '@vercel/error-utils';
import { help } from '../help';
import { devCommand } from './command';
const COMMAND_CONFIG = {
dev: ['dev'],
};
const help = () => {
console.log(`
${chalk.bold(`${logo} ${packageName} dev`)} [options] <dir>
Starts the \`${packageName} dev\` server.
${chalk.dim('Options:')}
-h, --help Output usage information
-d, --debug Debug mode [off]
--no-color No color mode [off]
-l, --listen [uri] Specify a URI endpoint on which to listen [0.0.0.0:3000]
-t, --token [token] Specify an Authorization Token
-y, --yes Skip questions when setting up new project using default scope and settings
${chalk.dim('Examples:')}
${chalk.gray('')} Start the \`${packageName} dev\` server on port 8080
${chalk.cyan(`$ ${packageName} dev --listen 8080`)}
${chalk.gray(
''
)} Make the \`vercel dev\` server bind to localhost on port 5000
${chalk.cyan(`$ ${packageName} dev --listen 127.0.0.1:5000`)}
`);
};
export default async function main(client: Client) {
if (process.env.__VERCEL_DEV_RUNNING) {
client.output.error(
@@ -100,7 +73,7 @@ export default async function main(client: Client) {
}
if (argv['--help']) {
help();
client.output.print(help(devCommand, { columns: client.stderr.columns }));
return 2;
}

View File

@@ -0,0 +1,153 @@
import { Command } from '../help';
import { packageName } from '../../util/pkg-name';
export const domainsCommand: Command = {
name: 'domains',
description: 'Manage domains',
arguments: [
{
name: 'command',
required: true,
},
],
subcommands: [
{
name: 'ls',
description: 'Show all domains in a list',
arguments: [],
options: [],
examples: [],
},
{
name: 'inspect',
description: 'Displays information related to a domain',
arguments: [
{
name: 'name',
required: true,
},
],
options: [],
examples: [],
},
{
name: 'add',
description: 'Add a new domain that you already own',
arguments: [
{
name: 'name',
required: true,
},
{
name: 'project',
required: true,
},
],
options: [],
examples: [],
},
{
name: 'rm',
description: 'Remove a domain',
arguments: [
{
name: 'name',
required: true,
},
],
options: [],
examples: [],
},
{
name: 'buy',
description: "Buy a domain that you don't yet own",
arguments: [
{
name: 'name',
required: true,
},
],
options: [],
examples: [],
},
{
name: 'move',
description: 'Move a domain to another user or team',
arguments: [
{
name: 'name',
required: true,
},
{
name: 'destination',
required: true,
},
],
options: [],
examples: [],
},
{
name: 'transfer-in',
description: 'Transfer in a domain to Vercel',
arguments: [
{
name: 'name',
required: true,
},
],
options: [],
examples: [],
},
],
options: [
{
name: 'next',
description: 'Show next page of results',
shorthand: 'N',
type: 'string',
deprecated: false,
multi: false,
},
{
name: 'yes',
description: 'Skip the confirmation prompt when removing a domain',
shorthand: 'y',
type: 'boolean',
deprecated: false,
multi: false,
},
{
name: 'limit',
shorthand: 'n',
description:
'Number of results to return per page (default: 20, max: 100)',
argument: 'NUMBER',
type: 'string',
deprecated: false,
multi: false,
},
{
name: 'force',
shorthand: 'f',
type: 'boolean',
deprecated: false,
description:
'Force a domain on a project and remove it from an existing one',
multi: false,
},
],
examples: [
{
name: 'Add a domain that you already own',
value: [
`${packageName} domains add domain-name.com`,
"Make sure the domain's DNS nameservers are at least 2 of the ones listed on https://vercel.com/edge-network",
`NOTE: Running ${packageName} alias will automatically register your domain if it's configured with these nameservers (no need to 'domains add')`,
],
},
{
name: 'Paginate results, where `1584722256178` is the time in milliseconds since the UNIX epoch',
value: `${packageName} domains ls--next 1584722256178`,
},
],
};

View File

@@ -1,5 +1,3 @@
import chalk from 'chalk';
import Client from '../../util/client';
import getArgs from '../../util/get-args';
import getSubcommand from '../../util/get-subcommand';
@@ -11,69 +9,8 @@ import inspect from './inspect';
import ls from './ls';
import rm from './rm';
import move from './move';
import { packageName, logo } from '../../util/pkg-name';
const help = () => {
console.log(`
${chalk.bold(`${logo} ${packageName} domains`)} [options] <command>
${chalk.dim('Commands:')}
ls Show all domains in a list
inspect [name] Displays information related to a domain
add [name] [project] Add a new domain that you already own
rm [name] Remove a domain
buy [name] Buy a domain that you don't yet own
move [name] [destination] Move a domain to another user or team.
transfer-in [name] Transfer in a domain to Vercel
${chalk.dim('Options:')}
-h, --help Output usage information
-d, --debug Debug mode [off]
--no-color No color mode [off]
-f, --force Force a domain on a project and remove it from an existing one
-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
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-S, --scope Set a custom scope
-N, --next Show next page of results
--limit=${chalk.bold.underline(
'VALUE'
)} Number of results to return per page (default: 20, max: 100)
-y, --yes Skip the confirmation prompt when removing a domain
${chalk.dim('Examples:')}
${chalk.gray('')} Add a domain that you already own
${chalk.cyan(
`$ ${packageName} domains add ${chalk.underline('domain-name.com')}`
)}
Make sure the domain's DNS nameservers are at least 2 of the
ones listed on ${chalk.underline('https://vercel.com/edge-network')}.
${chalk.yellow('NOTE:')} Running ${chalk.dim(
`${packageName} alias`
)} will automatically register your domain
if it's configured with these nameservers (no need to ${chalk.dim(
'`domain add`'
)}).
${chalk.gray('')} Paginate results, where ${chalk.dim(
'`1584722256178`'
)} is the time in milliseconds since the UNIX epoch.
${chalk.cyan(`$ ${packageName} domains ls --next 1584722256178`)}
`);
};
import { domainsCommand } from './command';
import { help } from '../help';
const COMMAND_CONFIG = {
add: ['add'],
@@ -104,7 +41,9 @@ export default async function main(client: Client) {
}
if (argv['--help']) {
help();
client.output.print(
help(domainsCommand, { columns: client.stderr.columns })
);
return 2;
}

157
packages/cli/src/commands/env/command.ts vendored Normal file
View File

@@ -0,0 +1,157 @@
import { Command } from '../help';
import { packageName } from '../../util/pkg-name';
import { getEnvTargetPlaceholder } from '../../util/env/env-target';
const targetPlaceholder = getEnvTargetPlaceholder();
export const envCommand: Command = {
name: 'env',
description: 'Interact with environment variables.',
arguments: [
{
name: 'command',
required: false,
},
],
subcommands: [
{
name: 'ls',
description: 'List all variables for the specified Environment',
arguments: [],
options: [],
examples: [],
},
{
name: 'add',
description: 'Add an Environment Variable (see examples below)',
arguments: [
{
name: 'name',
required: true,
},
{
name: 'environment',
required: false,
},
],
options: [],
examples: [],
},
{
name: 'rm',
description: 'Remove an Environment Variable (see examples below)',
arguments: [
{
name: 'name',
required: true,
},
{
name: 'environment',
required: false,
},
],
options: [],
examples: [],
},
{
name: 'pull',
description:
'Pull all Development Environment Variables from the cloud and write to a file [.env.local]',
arguments: [
{
name: 'filename',
required: false,
},
],
options: [],
examples: [],
},
],
options: [
{
name: 'environment',
description:
'Set the Environment (development, preview, production) when pulling Environment Variables',
shorthand: null,
type: 'boolean',
deprecated: false,
multi: false,
},
{
name: 'git-branch',
description:
'Specify the Git branch to pull specific Environment Variables for',
shorthand: null,
type: 'string',
deprecated: false,
multi: false,
},
{
name: 'yes',
description: 'Skip the confirmation prompt when removing an alias',
shorthand: 'y',
type: 'boolean',
deprecated: false,
multi: false,
},
],
examples: [
{
name: 'Pull all Development Environment Variables down from the cloud',
value: [
`${packageName} env pull <file>`,
`${packageName} env pull .env.development.local`,
],
},
{
name: 'Add a new variable to multiple Environments',
value: [
`${packageName} env add <name>`,
`${packageName} env add API_TOKEN`,
],
},
{
name: 'Add a new variable for a specific Environment',
value: [
`${packageName} env add <name> ${targetPlaceholder}`,
`${packageName} env add DB_PASS production`,
],
},
{
name: 'Add a new variable for a specific Environment and Git Branch',
value: [
`${packageName} env add <name> ${targetPlaceholder} <gitbranch>`,
`${packageName} env add DB_PASS preview feat1`,
],
},
{
name: 'Add a new Environment Variable from stdin',
value: [
`cat <file> | ${packageName} env add <name> ${targetPlaceholder}`,
`cat ~/.npmrc | ${packageName} env add NPM_RC preview`,
`${packageName} env add API_URL production < url.txt`,
],
},
{
name: 'Remove a variable from multiple Environments',
value: [
`${packageName} env rm <name>`,
`${packageName} env rm API_TOKEN`,
],
},
{
name: 'Remove a variable from a specific Environment',
value: [
`${packageName} env rm <name> ${targetPlaceholder}`,
`${packageName} env rm NPM_RC preview`,
],
},
{
name: 'Remove a variable from a specific Environment and Git Branch',
value: [
`${packageName} env rm <name> ${targetPlaceholder} <gitbranch>`,
`${packageName} env rm NPM_RC preview feat1`,
],
},
],
};

View File

@@ -8,99 +8,15 @@ import getArgs from '../../util/get-args';
import getInvalidSubcommand from '../../util/get-invalid-subcommand';
import getSubcommand from '../../util/get-subcommand';
import handleError from '../../util/handle-error';
import { getCommandName, packageName, logo } from '../../util/pkg-name';
import { help } from '../help';
import { getCommandName } from '../../util/pkg-name';
import { getLinkedProject } from '../../util/projects/link';
import add from './add';
import ls from './ls';
import pull from './pull';
import rm from './rm';
const help = () => {
const targetPlaceholder = getEnvTargetPlaceholder();
console.log(`
${chalk.bold(`${logo} ${packageName} env`)} [options] <command>
${chalk.dim('Commands:')}
ls [environment] [gitbranch] List all variables for the specified Environment
add [name] [environment] [gitbranch] Add an Environment Variable (see examples below)
rm [name] [environment] [gitbranch] Remove an Environment Variable (see examples below)
pull [filename] Pull all Development Environment Variables from the cloud and write to a file [.env.local]
${chalk.dim('Options:')}
-h, --help Output usage information
--environment Set the Environment (development, preview, production) when pulling Environment Variables
--git-branch Specify the Git branch to pull specific Environment Variables for
-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]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-y, --yes Skip the confirmation prompt when overwriting env file on pull or removing an env variable
${chalk.dim('Examples:')}
${chalk.gray(
''
)} Pull all Development Environment Variables down from the cloud
${chalk.cyan(`$ ${packageName} env pull <file>`)}
${chalk.cyan(`$ ${packageName} env pull .env.development.local`)}
${chalk.gray('')} Add a new variable to multiple Environments
${chalk.cyan(`$ ${packageName} env add <name>`)}
${chalk.cyan(`$ ${packageName} env add API_TOKEN`)}
${chalk.gray('')} Add a new variable for a specific Environment
${chalk.cyan(`$ ${packageName} env add <name> ${targetPlaceholder}`)}
${chalk.cyan(`$ ${packageName} env add DB_PASS production`)}
${chalk.gray(
''
)} Add a new variable for a specific Environment and Git Branch
${chalk.cyan(
`$ ${packageName} env add <name> ${targetPlaceholder} <gitbranch>`
)}
${chalk.cyan(`$ ${packageName} env add DB_PASS preview feat1`)}
${chalk.gray('')} Add a new Environment Variable from stdin
${chalk.cyan(
`$ cat <file> | ${packageName} env add <name> ${targetPlaceholder}`
)}
${chalk.cyan(`$ cat ~/.npmrc | ${packageName} env add NPM_RC preview`)}
${chalk.cyan(`$ ${packageName} env add API_URL production < url.txt`)}
${chalk.gray('')} Remove a variable from multiple Environments
${chalk.cyan(`$ ${packageName} env rm <name>`)}
${chalk.cyan(`$ ${packageName} env rm API_TOKEN`)}
${chalk.gray('')} Remove a variable from a specific Environment
${chalk.cyan(`$ ${packageName} env rm <name> ${targetPlaceholder}`)}
${chalk.cyan(`$ ${packageName} env rm NPM_RC preview`)}
${chalk.gray(
''
)} Remove a variable from a specific Environment and Git Branch
${chalk.cyan(
`$ ${packageName} env rm <name> ${targetPlaceholder} <gitbranch>`
)}
${chalk.cyan(`$ ${packageName} env rm NPM_RC preview feat1`)}
`);
};
import { envCommand } from './command';
const COMMAND_CONFIG = {
ls: ['ls', 'list'],
@@ -125,7 +41,7 @@ export default async function main(client: Client) {
}
if (argv['--help']) {
help();
client.output.print(help(envCommand, { columns: client.stderr.columns }));
return 2;
}
@@ -177,7 +93,9 @@ export default async function main(client: Client) {
);
default:
output.error(getInvalidSubcommand(COMMAND_CONFIG));
help();
client.output.print(
help(envCommand, { columns: client.stderr.columns })
);
return 2;
}
}

View File

@@ -0,0 +1,50 @@
import { Command } from '../help';
import { packageName } from '../../util/pkg-name';
export const gitCommand: Command = {
name: 'git',
description: 'Manage your Git provider connections.',
arguments: [
{
name: 'command',
required: true,
},
],
subcommands: [
{
name: 'connect',
description:
'Connect your Vercel Project to your Git repository or provide the remote URL to your Git repository',
arguments: [
{
name: 'git url',
required: false,
},
],
options: [],
examples: [],
},
{
name: 'disconnect',
description: 'Disconnect the Git provider repository from your project',
arguments: [],
options: [],
examples: [],
},
],
options: [],
examples: [
{
name: 'Connect your Vercel Project to your Git repository defined in your local .git config',
value: `${packageName} git connect`,
},
{
name: 'Connect your Vercel Project to a Git repository using the remote URL',
value: `${packageName} git connect https://github.com/user/repo.git`,
},
{
name: 'Disconnect the Git provider repository',
value: `${packageName} git disconnect`,
},
],
};

View File

@@ -1,51 +1,12 @@
import chalk from 'chalk';
import Client from '../../util/client';
import { ensureLink } from '../../util/link/ensure-link';
import getArgs from '../../util/get-args';
import getInvalidSubcommand from '../../util/get-invalid-subcommand';
import handleError from '../../util/handle-error';
import { packageName, logo } from '../../util/pkg-name';
import connect from './connect';
import disconnect from './disconnect';
const help = () => {
console.log(`
${chalk.bold(`${logo} ${packageName} git`)} <command>
${chalk.dim('Commands:')}
connect [url] Connect your Vercel Project to your Git repository or provide the remote URL to your Git repository
disconnect Disconnect the Git provider repository from your project
${chalk.dim('Options:')}
-h, --help Output usage information
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-y, --yes Skip confirmation when connecting a Git provider
${chalk.dim('Examples:')}
${chalk.gray(
''
)} Connect your Vercel Project to your Git repository defined in your local .git config
${chalk.cyan(`$ ${packageName} git connect`)}
${chalk.gray(
''
)} Connect your Vercel Project to a Git repository using the remote URL
${chalk.cyan(
`$ ${packageName} git connect https://github.com/user/repo.git`
)}
${chalk.gray('')} Disconnect the Git provider repository
${chalk.cyan(`$ ${packageName} git disconnect`)}
`);
};
import { help } from '../help';
import { gitCommand } from './command';
const COMMAND_CONFIG = {
connect: ['connect'],
@@ -71,7 +32,7 @@ export default async function main(client: Client) {
}
if (argv['--help']) {
help();
client.output.print(help(gitCommand, { columns: client.stderr.columns }));
return 2;
}
@@ -96,7 +57,7 @@ export default async function main(client: Client) {
return await disconnect(client, args, project, org);
default:
output.error(getInvalidSubcommand(COMMAND_CONFIG));
help();
client.output.print(help(gitCommand, { columns: client.stderr.columns }));
return 2;
}
}

View File

@@ -12,6 +12,7 @@ export interface CommandOption {
argument?: string;
deprecated: boolean;
description?: string;
/** supports multiple entries */
multi: boolean;
}
export interface CommandArgument {
@@ -322,7 +323,10 @@ export function buildSubcommandLines(
]);
}
const finalColumnWidth = options.columns - maxWidthOfUnwrappedColumns;
// Really long descriptions go RIGHT up to the edge, which looks unpleasant.
const rightMargin = INDENT.repeat(4).length;
const finalColumnWidth =
options.columns - maxWidthOfUnwrappedColumns - rightMargin;
const table = new Table(
Object.assign({}, tableOptions, {

View File

@@ -0,0 +1,47 @@
import { Command } from '../help';
import { packageName } from '../../util/pkg-name';
export const initCommand: Command = {
name: 'init',
description: 'Initialize example Vercel Projects',
arguments: [
{
name: 'example',
required: false,
},
{
name: 'dir',
required: false,
},
],
subcommands: undefined,
options: [
{
name: 'force',
description: 'Overwrite destination directory if exists [off]',
argument: undefined,
shorthand: 'f',
type: 'boolean',
deprecated: false,
multi: false,
},
],
examples: [
{
name: 'Choose from all available examples',
value: `${packageName} init`,
},
{
name: 'Initialize example project into a new directory',
value: `${packageName} init <example>`,
},
{
name: 'Initialize example project into specified directory',
value: `${packageName} <example> <dir>`,
},
{
name: 'Initialize example project without checking',
value: `${packageName} init <example> --force`,
},
],
};

View File

@@ -1,48 +1,16 @@
import chalk from 'chalk';
import getArgs from '../../util/get-args';
import getSubcommand from '../../util/get-subcommand';
import Client from '../../util/client';
import handleError from '../../util/handle-error';
import init from './init';
import { packageName, logo } from '../../util/pkg-name';
import { isError } from '@vercel/error-utils';
import { help } from '../help';
import { initCommand } from './command';
const COMMAND_CONFIG = {
init: ['init'],
};
const help = () => {
console.log(`
${chalk.bold(`${logo} ${packageName} init`)} [example] [dir] [-f | --force]
${chalk.dim('Options:')}
-h, --help Output usage information
-d, --debug Debug mode [off]
--no-color No color mode [off]
-f, --force Overwrite destination directory if exists [off]
${chalk.dim('Examples:')}
${chalk.gray('')} Choose from all available examples
${chalk.cyan(`$ ${packageName} init`)}
${chalk.gray('')} Initialize example project into a new directory
${chalk.cyan(`$ ${packageName} init <example>`)}
${chalk.gray('')} Initialize example project into specified directory
${chalk.cyan(`$ ${packageName} init <example> <dir>`)}
${chalk.gray('')} Initialize example project without checking
${chalk.cyan(`$ ${packageName} init <example> --force`)}
`);
};
export default async function main(client: Client) {
const { output } = client;
let argv;
@@ -60,7 +28,7 @@ export default async function main(client: Client) {
}
if (argv['--help']) {
help();
client.output.print(help(initCommand, { columns: client.stderr.columns }));
return 2;
}

View File

@@ -0,0 +1,67 @@
import { Command } from '../help';
import { packageName } from '../../util/pkg-name';
export const projectCommand: Command = {
name: 'project',
description: 'Manage your Vercel Projects.',
arguments: [
{
name: 'command',
required: true,
},
],
subcommands: [
{
name: 'ls',
description: 'Show all projects in the selected team/user',
arguments: [],
options: [],
examples: [],
},
{
name: 'add',
description: 'Add a new project',
arguments: [
{
name: 'name',
required: true,
},
],
options: [],
examples: [],
},
{
name: 'rm',
description: 'Remove a project',
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 project',
value: `${packageName} project add my-project`,
},
{
name: 'Paginate projects, where `1584722256178` is the time in milliseconds since the UNIX epoch',
value: `${packageName} project ls --next 1584722256178`,
},
],
};

View File

@@ -1,46 +1,13 @@
import chalk from 'chalk';
import Client from '../../util/client';
import getArgs from '../../util/get-args';
import getInvalidSubcommand from '../../util/get-invalid-subcommand';
import getScope from '../../util/get-scope';
import handleError from '../../util/handle-error';
import { packageName, logo } from '../../util/pkg-name';
import { help } from '../help';
import add from './add';
import list from './list';
import rm from './rm';
const help = () => {
console.log(`
${chalk.bold(`${logo} ${packageName} project`)} [options] <command>
${chalk.dim('Commands:')}
ls Show all projects in the selected team/user
add [name] Add a new project
rm [name] Remove a project
${chalk.dim('Options:')}
-h, --help Output usage information
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-S, --scope Set a custom scope
-N, --next Show next page of results
${chalk.dim('Examples:')}
${chalk.gray('')} Add a new project
${chalk.cyan(`$ ${packageName} project add my-project`)}
${chalk.gray('')} Paginate projects, where ${chalk.dim(
'`1584722256178`'
)} is the time in milliseconds since the UNIX epoch.
${chalk.cyan(`$ ${packageName} project ls --next 1584722256178`)}
`);
};
import { projectCommand } from './command';
const COMMAND_CONFIG = {
ls: ['ls', 'list'],
@@ -63,7 +30,9 @@ export default async function main(client: Client) {
}
if (argv['--help']) {
help();
client.output.print(
help(projectCommand, { columns: client.stderr.columns })
);
return 2;
}
@@ -84,7 +53,9 @@ export default async function main(client: Client) {
return await rm(client, args);
default:
output.error(getInvalidSubcommand(COMMAND_CONFIG));
help();
client.output.print(
help(projectCommand, { columns: client.stderr.columns })
);
return 2;
}
}

View File

@@ -0,0 +1,53 @@
import { Command } from '../help';
import { packageName } from '../../util/pkg-name';
export const promoteCommand: Command = {
name: 'promote',
description: 'Promote an existing deployment to current.',
arguments: [
{
name: 'deployment id/url',
required: true,
},
],
subcommands: [
{
name: 'status',
description: 'Show the status of any current pending promotions',
arguments: [
{
name: 'project',
required: false,
},
],
options: [],
examples: [],
},
],
options: [
{
name: 'timeout',
description: 'Time to wait for promotion completion [3m]',
argument: 'timeout',
shorthand: null,
type: 'string',
deprecated: false,
multi: false,
},
],
examples: [
{
name: 'Show the status of any current pending promotions',
value: [
`${packageName} promote`,
`${packageName} promote status`,
`${packageName} promote status <project>`,
`${packageName} promote status --timeout 30s`,
],
},
{
name: 'Promote a deployment using id or url',
value: `${packageName} promote <deployment id/url>`,
},
],
};

View File

@@ -1,53 +1,13 @@
import chalk from 'chalk';
import type Client from '../../util/client';
import getArgs from '../../util/get-args';
import getProjectByCwdOrLink from '../../util/projects/get-project-by-cwd-or-link';
import { packageName, logo } from '../../util/pkg-name';
import handleError from '../../util/handle-error';
import { isErrnoException } from '@vercel/error-utils';
import ms from 'ms';
import requestPromote from './request-promote';
import promoteStatus from './status';
const help = () => {
console.log(`
${chalk.bold(`${logo} ${packageName} promote`)} [deployment id/url]
Promote an existing deployment to current.
${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]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
--timeout=${chalk.bold.underline(
'TIME'
)} Time to wait for promotion completion [3m]
-y, --yes Skip questions when setting up new project using default scope and settings
${chalk.dim('Examples:')}
${chalk.gray('')} Show the status of any current pending promotions
${chalk.cyan(`$ ${packageName} promote`)}
${chalk.cyan(`$ ${packageName} promote status`)}
${chalk.cyan(`$ ${packageName} promote status <project>`)}
${chalk.cyan(`$ ${packageName} promote status --timeout 30s`)}
${chalk.gray('')} Promote a deployment using id or url
${chalk.cyan(`$ ${packageName} promote <deployment id/url>`)}
`);
};
import { promoteCommand } from './command';
import { help } from '../help';
/**
* `vc promote` command
@@ -68,7 +28,9 @@ export default async (client: Client): Promise<number> => {
}
if (argv['--help'] || argv._[0] === 'help') {
help();
client.output.print(
help(promoteCommand, { columns: client.stderr.columns })
);
return 2;
}

View File

@@ -76,12 +76,23 @@ 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

@@ -0,0 +1,53 @@
import { Command } from '../help';
import { packageName } from '../../util/pkg-name';
export const rollbackCommand: Command = {
name: 'rollback',
description: 'Quickly revert back to a previous deployment.',
arguments: [
{
name: 'deployment id/url',
required: true,
},
],
subcommands: [
{
name: 'status',
description: 'Show the status of any current pending rollbacks',
arguments: [
{
name: 'project',
required: false,
},
],
options: [],
examples: [],
},
],
options: [
{
name: 'timeout',
description: 'Time to wait for rollback completion [3m]',
argument: 'timeout',
shorthand: null,
type: 'string',
deprecated: false,
multi: false,
},
],
examples: [
{
name: 'Show the status of any current pending rollbacks',
value: [
`${packageName} rollback`,
`${packageName} rollback status`,
`${packageName} rollback status <project>`,
`${packageName} rollback status --timeout 30s`,
],
},
{
name: 'Rollback a deployment using id or url',
value: `${packageName} rollback <deployment id/url>`,
},
],
};

View File

@@ -1,53 +1,13 @@
import chalk from 'chalk';
import type Client from '../../util/client';
import getArgs from '../../util/get-args';
import getProjectByCwdOrLink from '../../util/projects/get-project-by-cwd-or-link';
import { packageName, logo } from '../../util/pkg-name';
import handleError from '../../util/handle-error';
import { isErrnoException } from '@vercel/error-utils';
import ms from 'ms';
import requestRollback from './request-rollback';
import rollbackStatus from './status';
const help = () => {
console.log(`
${chalk.bold(`${logo} ${packageName} rollback`)} [deployment id/url]
Quickly revert back to a previous deployment.
${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]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
--timeout=${chalk.bold.underline(
'TIME'
)} Time to wait for rollback completion [3m]
-y, --yes Skip questions when setting up new project using default scope and settings
${chalk.dim('Examples:')}
${chalk.gray('')} Show the status of any current pending rollbacks
${chalk.cyan(`$ ${packageName} rollback`)}
${chalk.cyan(`$ ${packageName} rollback status`)}
${chalk.cyan(`$ ${packageName} rollback status <project>`)}
${chalk.cyan(`$ ${packageName} rollback status --timeout 30s`)}
${chalk.gray('')} Rollback a deployment using id or url
${chalk.cyan(`$ ${packageName} rollback <deployment id/url>`)}
`);
};
import { help } from '../help';
import { rollbackCommand } from './command';
/**
* `vc rollback` command
@@ -68,7 +28,9 @@ export default async (client: Client): Promise<number> => {
}
if (argv['--help'] || argv._[0] === 'help') {
help();
client.output.print(
help(rollbackCommand, { columns: client.stderr.columns })
);
return 2;
}

View File

@@ -0,0 +1,96 @@
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,78 +1,17 @@
import isErrnoException from '@vercel/error-utils';
import chalk from 'chalk';
import table from 'text-table';
import ms from 'ms';
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, logo } from '../util/pkg-name.ts';
import getArgs from '../util/get-args';
const help = () => {
console.log(`
${chalk.yellow(
`${chalk.bold('NOTE:')} The ${getCommandName(
'env'
)} command is recommended instead of ${getCommandName('secrets')}`
)}
${chalk.bold(`${logo} ${packageName} secrets`)} [options] <command>
${chalk.dim('Commands:')}
ls Show all secrets in a list
add [name] [value] Add a new secret
rename [old-name] [new-name] Change the name of a secret
rm [name] Remove a secret
${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]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-S, --scope Set a custom scope
-N, --next Show next page of results
${chalk.dim('Examples:')}
${chalk.gray('')} Add a new secret
${chalk.cyan(`$ ${packageName} secrets add my-secret "my value"`)}
${chalk.gray(
''
)} Once added, a secret's value can't be retrieved in plain text anymore
${chalk.gray(
''
)} If the secret's value is more than one word, wrap it in quotes
${chalk.gray('')} When in doubt, always wrap your value in quotes
${chalk.gray(
''
)} Expose a secret as an environment variable (notice the ${chalk.cyan.bold(
'`@`'
)} symbol)
${chalk.cyan(`$ ${packageName} -e MY_SECRET=${chalk.bold('@my-secret')}`)}
${chalk.gray('')} Paginate results, where ${chalk.dim(
'`1584722256178`'
)} is the time in milliseconds since the UNIX epoch
${chalk.cyan(`$ ${packageName} secrets ls --next 1584722256178`)}
`);
};
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';
// Options
let argv;
@@ -94,8 +33,10 @@ const main = async client => {
nextTimestamp = argv.next;
if (argv.help || !subcommand) {
help();
await exit(2);
client.output.print(
help(secretsCommand, { columns: client.stderr.columns })
);
return 2;
}
const {
@@ -107,9 +48,11 @@ const main = async client => {
try {
({ contextName } = await getScope(client));
} catch (err) {
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
output.error(err.message);
return 1;
if (isErrnoException(err)) {
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
output.error(err.message);
return 1;
}
}
throw err;
@@ -120,7 +63,7 @@ const main = async client => {
export default async client => {
try {
await main(client);
return await main(client);
} catch (err) {
handleError(err);
process.exit(1);
@@ -183,7 +126,7 @@ async function run({ output, contextName, currentTeam, client }) {
);
if (out) {
console.log(`\n${out}\n`);
client.output.print(`\n${out}\n`);
}
}
@@ -298,19 +241,7 @@ async function run({ output, contextName, currentTeam, client }) {
return 1;
}
const [name, parsedValue] = args;
const [originalName, originalValue] = client.argv.slice(-2);
let value = parsedValue;
if (
name === originalName &&
typeof parsedValue === 'boolean' &&
parsedValue !== originalValue
) {
// Corner case where `mri` transforms the secret value into a boolean because
// it starts with a `-` so it thinks its a flag, so we use the original value instead.
value = originalValue;
}
const [name, value] = args;
if (typeof value === 'boolean') {
const example = chalk.cyan(
@@ -340,7 +271,7 @@ async function run({ output, contextName, currentTeam, client }) {
console.error(
error('Please specify a valid subcommand: ls | add | rename | rm')
);
help();
client.output.print(help(secretsCommand, { columns: client.stderr.columns }));
return 2;
}

View File

@@ -0,0 +1,77 @@
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,63 +1,12 @@
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';
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`)}
`);
};
import { teamsCommand } from './command';
import { help } from '../help';
export default async (client: Client) => {
let subcommand;
@@ -74,7 +23,7 @@ export default async (client: Client) => {
}
if (argv['--help'] || !subcommand) {
help();
client.output.print(help(teamsCommand, { columns: client.stderr.columns }));
return 2;
}
@@ -107,7 +56,9 @@ export default async (client: Client) => {
);
}
exitCode = 2;
help();
client.output.print(
help(teamsCommand, { columns: client.stderr.columns })
);
}
}
return exitCode;

View File

@@ -1,48 +0,0 @@
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,7 +36,6 @@ export async function printDeploymentStatus(
const { output } = client;
indications = indications || [];
const isProdDeployment = target === 'production';
let isStillBuilding = false;
if (noWait) {
@@ -64,30 +63,6 @@ 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 { Org } from '@vercel-internals/types';
import type { Deployment, Org } from '@vercel-internals/types';
import ua from '../ua';
import { linkFolderToProject } from '../projects/link';
import { prependEmoji, emoji } from '../emoji';
@@ -17,9 +17,13 @@ import type { Agent } from 'http';
function printInspectUrl(
output: Output,
inspectorUrl: string,
inspectorUrl: string | null | undefined,
deployStamp: () => string
) {
if (!inspectorUrl) {
return;
}
output.print(
prependEmoji(
`Inspect: ${chalk.bold(inspectorUrl)} ${deployStamp()}`,
@@ -162,33 +166,47 @@ export default async function processDeployment({
}
if (event.type === 'created') {
const deployment: Deployment = event.payload;
await linkFolderToProject(
client,
cwd,
{
orgId: org.id,
projectId: event.payload.projectId,
projectId: deployment.projectId!,
},
projectName,
org.slug
);
now.url = event.payload.url;
now.url = deployment.url;
output.stopSpinner();
printInspectUrl(output, event.payload.inspectorUrl, deployStamp);
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`
);
if (quiet) {
process.stdout.write(`https://${event.payload.url}`);
}
if (noWait) {
return event.payload;
return deployment;
}
output.spinner(
event.payload.readyState === 'QUEUED' ? 'Queued' : 'Building',
deployment.readyState === 'QUEUED' ? 'Queued' : 'Building',
0
);
}
@@ -243,6 +261,7 @@ 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

@@ -1,8 +0,0 @@
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

@@ -292,7 +292,7 @@ test('[vc dev] should print help from `vc develop --help`', async () => {
);
expect(exitCode, formatOutput({ stdout, stderr })).toBe(2);
expect(stdout).toMatch(/▲ vercel dev/gm);
expect(stderr).toMatch(/▲ vercel dev/gm);
});
test('default command should deploy directory', async () => {

View File

@@ -735,6 +735,12 @@ 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();

View File

@@ -0,0 +1,29 @@
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

@@ -0,0 +1,37 @@
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,5 +1,19 @@
# @vercel/client
## 13.0.3
### 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
## 13.0.2
### 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
## 13.0.1
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/client",
"version": "13.0.1",
"version": "13.0.3",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"homepage": "https://vercel.com",
@@ -14,7 +14,7 @@
"directory": "packages/client"
},
"scripts": {
"build": "tsc",
"build": "node ../../utils/build.mjs",
"test-e2e": "pnpm test tests/create-deployment.test.ts tests/create-legacy-deployment.test.ts tests/paths.test.ts",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
"test-unit": "pnpm test tests/unit.*test.*"
@@ -36,7 +36,7 @@
"typescript": "4.9.5"
},
"dependencies": {
"@vercel/build-utils": "7.1.0",
"@vercel/build-utils": "7.2.0",
"@vercel/routing-utils": "3.0.0",
"@zeit/fetch": "5.2.0",
"async-retry": "1.2.3",

View File

@@ -1,6 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",

View File

@@ -1,5 +1,11 @@
# @vercel/edge
## 1.0.2
### Patch Changes
- [node] upgrade edge-runtime ([#10451](https://github.com/vercel/vercel/pull/10451))
## 1.0.1
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/edge",
"version": "1.0.1",
"version": "1.0.2",
"license": "Apache-2.0",
"main": "dist/index.js",
"module": "dist/index.mjs",
@@ -21,7 +21,7 @@
"build:docs": "typedoc && node scripts/fix-links.js && prettier --write docs/**/*.md docs/*.md"
},
"devDependencies": {
"@edge-runtime/jest-environment": "2.3.0",
"@edge-runtime/jest-environment": "2.3.1",
"@types/jest": "27.4.1",
"jest-junit": "16.0.0",
"ts-node": "8.9.1",

View File

@@ -13,7 +13,7 @@
"directory": "packages/error-utils"
},
"scripts": {
"build": "tsc",
"build": "node ../../utils/build.mjs",
"test": "jest --reporters=default --reporters=jest-junit --coverage --env node --verbose",
"test-unit": "pnpm test"
},

View File

@@ -1,7 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",

View File

@@ -13,7 +13,7 @@
},
"license": "Apache-2.0",
"scripts": {
"build": "tsc",
"build": "node ../../utils/build.mjs",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
"test-unit": "pnpm test"
},

View File

@@ -1,6 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",

View File

@@ -1,5 +1,11 @@
# @vercel/fs-detectors
## 5.0.2
### Patch Changes
- Updated semver dependency ([#10411](https://github.com/vercel/vercel/pull/10411))
## 5.0.1
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/fs-detectors",
"version": "5.0.1",
"version": "5.0.2",
"description": "Vercel filesystem detectors",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
@@ -14,7 +14,7 @@
},
"license": "Apache-2.0",
"scripts": {
"build": "tsc",
"build": "node ../../utils/build.mjs",
"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"
@@ -27,7 +27,7 @@
"js-yaml": "4.1.0",
"json5": "2.2.2",
"minimatch": "3.1.2",
"semver": "6.1.1"
"semver": "6.3.1"
},
"devDependencies": {
"@types/glob": "7.2.0",
@@ -36,7 +36,7 @@
"@types/minimatch": "3.0.5",
"@types/node": "14.18.33",
"@types/semver": "7.3.10",
"@vercel/build-utils": "7.1.0",
"@vercel/build-utils": "7.2.0",
"jest-junit": "16.0.0",
"typescript": "4.9.5"
}

View File

@@ -1,6 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",

View File

@@ -1,5 +1,21 @@
# @vercel/gatsby-plugin-vercel-builder
## 2.0.5
### Patch Changes
- Updated dependencies [[`50e04dd85`](https://github.com/vercel/vercel/commit/50e04dd8584664c842a86c15d92d654f4ea8dcbb), [`45b73c7e8`](https://github.com/vercel/vercel/commit/45b73c7e86458564dc0bab007f6f6365c4c4ab5d), [`9d64312aa`](https://github.com/vercel/vercel/commit/9d64312aaaa875a4e193b7602c50e5dc68979aad), [`d8bc570f6`](https://github.com/vercel/vercel/commit/d8bc570f604950d97156d4f33c8accecf3b3b28f)]:
- @vercel/build-utils@7.2.0
- @vercel/node@3.0.5
## 2.0.4
### Patch Changes
- Updated dependencies [[`5609a1187`](https://github.com/vercel/vercel/commit/5609a1187be9d6cf8d5f16825690c5ea72f17dc5), [`1b4de4a98`](https://github.com/vercel/vercel/commit/1b4de4a986f7a612aac834ebae3ec7bb9e9b8cf8), [`fc1e13c09`](https://github.com/vercel/vercel/commit/fc1e13c09928c654410b373fc1775c2b63c6ef4a)]:
- @vercel/build-utils@7.1.1
- @vercel/node@3.0.4
## 2.0.3
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/gatsby-plugin-vercel-builder",
"version": "2.0.3",
"version": "2.0.5",
"main": "dist/index.js",
"files": [
"dist",
@@ -20,8 +20,8 @@
},
"dependencies": {
"@sinclair/typebox": "0.25.24",
"@vercel/build-utils": "7.1.0",
"@vercel/node": "3.0.3",
"@vercel/build-utils": "7.2.0",
"@vercel/node": "3.0.5",
"@vercel/routing-utils": "3.0.0",
"esbuild": "0.14.47",
"etag": "1.8.1",

View File

@@ -1,5 +1,11 @@
# @vercel/go
## 3.0.1
### Patch Changes
- Update to esbuild script ([#10468](https://github.com/vercel/vercel/pull/10468))
## 3.0.0
### Major Changes

View File

@@ -1,25 +0,0 @@
#!/usr/bin/env node
const fs = require('fs-extra');
const execa = require('execa');
const { join } = require('path');
async function main() {
const outDir = join(__dirname, 'dist');
// Start fresh
await fs.remove(outDir);
// Build with `ncc`
await execa(
'ncc',
['build', 'index.ts', '-e', '@vercel/build-utils', '-o', outDir],
{
stdio: 'inherit',
}
);
}
main().catch(err => {
console.error(err);
process.exit(1);
});

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/go",
"version": "3.0.0",
"version": "3.0.1",
"license": "Apache-2.0",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
@@ -10,32 +10,33 @@
"directory": "packages/go"
},
"scripts": {
"build": "node build",
"build": "node ../../utils/build-builder.mjs",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
"test-e2e": "pnpm test"
},
"files": [
"dist"
"dist",
"*.go"
],
"devDependencies": {
"@tootallnate/once": "1.1.2",
"@types/async-retry": "1.4.2",
"@types/async-retry": "1.4.5",
"@types/execa": "^0.9.0",
"@types/fs-extra": "^5.0.5",
"@types/jest": "28.1.6",
"@types/node": "14.18.33",
"@types/node-fetch": "^2.3.0",
"@types/tar": "^4.0.0",
"@types/tar": "6.1.5",
"@types/yauzl-promise": "2.1.0",
"@vercel/build-utils": "7.1.0",
"@vercel/build-utils": "7.2.0",
"@vercel/ncc": "0.24.0",
"async-retry": "1.3.1",
"async-retry": "1.3.3",
"execa": "^1.0.0",
"fs-extra": "^7.0.0",
"jest-junit": "16.0.0",
"node-fetch": "^2.2.1",
"string-argv": "0.3.1",
"tar": "4.4.6",
"tar": "6.2.0",
"typescript": "4.3.4",
"xdg-app-paths": "5.1.0",
"yauzl-promise": "2.1.3"

View File

@@ -108,7 +108,7 @@ export async function getAnalyzedEntrypoint({
const isAnalyzeExist = await pathExists(bin);
if (!isAnalyzeExist) {
debug(`Building analyze bin: ${bin}`);
const src = join(__dirname, 'util', 'analyze.go');
const src = join(__dirname, '../analyze.go');
let go;
const createOpts = {
modulePath,

View File

@@ -621,7 +621,7 @@ async function copyDevServer(
functionName: string,
dest: string
): Promise<void> {
const data = await readFile(join(__dirname, 'dev-server.go'), 'utf8');
const data = await readFile(join(__dirname, '../dev-server.go'), 'utf8');
// Populate the handler function name
const patched = data.replace('__HANDLER_FUNC_NAME', functionName);
@@ -634,7 +634,10 @@ async function writeEntrypoint(
goPackageName: string,
goFuncName: string
) {
const modMainGoContents = await readFile(join(__dirname, 'main.go'), 'utf8');
const modMainGoContents = await readFile(
join(__dirname, '../main.go'),
'utf8'
);
const mainModGoContents = modMainGoContents
.replace('__VC_HANDLER_PACKAGE_NAME', goPackageName)
.replace('__VC_HANDLER_FUNC_NAME', goFuncName);

View File

@@ -1,4 +1,4 @@
import { getNewHandlerFunctionName } from '../index';
import { getNewHandlerFunctionName } from '../src/index';
describe('getNewHandlerFunctionName', function () {
it('does nothing with empty original function name', async () => {

View File

@@ -11,8 +11,10 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitThis": false,
"outDir": "./dist",
"types": ["node", "jest"],
"strict": true,
"target": "ES2021"
}
},
"include": ["src/**/*"]
}

View File

@@ -1,5 +1,11 @@
# @vercel/hydrogen
## 1.0.1
### Patch Changes
- Use `build-builder.mjs` script to bundle, and remove types and source maps ([#10480](https://github.com/vercel/vercel/pull/10480))
## 1.0.0
### Major Changes

View File

@@ -1,12 +0,0 @@
const execa = require('execa');
const { remove } = require('fs-extra');
async function main() {
await remove('dist');
await execa('tsc', [], { stdio: 'inherit' });
}
main().catch(err => {
console.error(err);
process.exit(1);
});

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/hydrogen",
"version": "1.0.0",
"version": "1.0.1",
"license": "Apache-2.0",
"main": "./dist/index.js",
"homepage": "https://vercel.com/docs",
@@ -10,7 +10,7 @@
"directory": "packages/hydrogen"
},
"scripts": {
"build": "node build.js",
"build": "node ../../utils/build-builder.mjs",
"test-e2e": "pnpm test test/test.js",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --bail --runInBand"
},
@@ -18,14 +18,16 @@
"dist",
"edge-entry.js"
],
"dependencies": {
"@vercel/static-config": "3.0.0",
"ts-morph": "12.0.0"
},
"devDependencies": {
"@types/jest": "27.5.1",
"@types/node": "14.18.33",
"@vercel/build-utils": "7.1.0",
"@vercel/static-config": "3.0.0",
"@vercel/build-utils": "7.2.0",
"execa": "3.2.0",
"fs-extra": "11.1.0",
"jest-junit": "16.0.0",
"ts-morph": "12.0.0"
"jest-junit": "16.0.0"
}
}

View File

@@ -1,6 +1,6 @@
{
"compilerOptions": {
"declaration": true,
"declaration": false,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",
@@ -13,8 +13,7 @@
"outDir": "./dist",
"types": ["node", "jest"],
"strict": true,
"target": "ES2021",
"sourceMap": true
"target": "ES2021"
},
"include": ["src/**/*"],
"exclude": ["node_modules"]

View File

@@ -1,5 +1,25 @@
# @vercel/next
## 4.0.3
### Patch Changes
- fix content-type for RSC prefetches ([#10487](https://github.com/vercel/vercel/pull/10487))
## 4.0.2
### Patch Changes
- Fix Next.js with `basePath` + Edge runtime + App Router on a top level `page.jsx` ([#10465](https://github.com/vercel/vercel/pull/10465))
- Updated semver dependency ([#10411](https://github.com/vercel/vercel/pull/10411))
- Fix RSC rewrite behavior ([#10415](https://github.com/vercel/vercel/pull/10415))
- fix ENOENT on /404.html when `fallback: false` w/ `basePath` ([#10473](https://github.com/vercel/vercel/pull/10473))
- fix 404 enoent for i18n ([#10416](https://github.com/vercel/vercel/pull/10416))
## 4.0.1
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/next",
"version": "4.0.1",
"version": "4.0.3",
"license": "Apache-2.0",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -35,7 +35,7 @@
"@types/semver": "6.0.0",
"@types/text-table": "0.2.1",
"@types/webpack-sources": "3.2.0",
"@vercel/build-utils": "7.1.0",
"@vercel/build-utils": "7.2.0",
"@vercel/nft": "0.22.5",
"@vercel/routing-utils": "3.0.0",
"async-sema": "3.0.1",
@@ -54,7 +54,7 @@
"ndjson": "2.0.0",
"pretty-bytes": "5.3.0",
"resolve-from": "5.0.0",
"semver": "6.1.1",
"semver": "6.3.1",
"set-cookie-parser": "2.4.6",
"source-map": "0.7.3",
"test-listen": "1.1.0",

View File

@@ -91,6 +91,7 @@ import {
getOperationType,
isApiPage,
getFunctionsConfigManifest,
normalizeEdgeFunctionPath,
} from './utils';
export const version = 2;
@@ -1320,11 +1321,7 @@ export const build: BuildV2 = async ({
const localePrefixed404 = !!(
routesManifest.i18n &&
originalStaticPages[
path.posix.join(
entryDirectory,
routesManifest.i18n.defaultLocale,
'404.html'
)
path.posix.join('.', routesManifest.i18n.defaultLocale, '404.html')
]
);
@@ -2720,7 +2717,15 @@ async function getServerlessPages(params: {
for (const edgeFunctionFile of Object.keys(
middlewareManifest?.functions ?? {}
)) {
const edgePath = (edgeFunctionFile.slice(1) || 'index') + '.js';
let edgePath =
middlewareManifest?.functions?.[edgeFunctionFile].name ||
edgeFunctionFile;
edgePath = normalizeEdgeFunctionPath(
edgePath,
params.appPathRoutesManifest || {}
);
edgePath = (edgePath || 'index') + '.js';
delete normalizedAppPaths[edgePath];
delete pages[edgePath];
}

View File

@@ -45,6 +45,8 @@ import {
UnwrapPromise,
getOperationType,
FunctionsConfigManifestV1,
RSC_CONTENT_TYPE,
RSC_PREFETCH_SUFFIX,
} from './utils';
import {
nodeFileTrace,
@@ -168,7 +170,6 @@ export async function serverBuild({
}
}
const APP_PREFETCH_SUFFIX = '.prefetch.rsc';
let appRscPrefetches: UnwrapPromise<ReturnType<typeof glob>> = {};
let appBuildTraces: UnwrapPromise<ReturnType<typeof glob>> = {};
let appDir: string | null = null;
@@ -176,7 +177,18 @@ export async function serverBuild({
if (appPathRoutesManifest) {
appDir = path.join(pagesDir, '../app');
appBuildTraces = await glob('**/*.js.nft.json', appDir);
appRscPrefetches = await glob(`**/*${APP_PREFETCH_SUFFIX}`, appDir);
appRscPrefetches = await glob(`**/*${RSC_PREFETCH_SUFFIX}`, appDir);
const rscContentTypeHeader =
routesManifest?.rsc?.contentTypeHeader || RSC_CONTENT_TYPE;
// ensure all appRscPrefetches have a contentType since this is used by Next.js
// to determine if it's a valid response
for (const value of Object.values(appRscPrefetches)) {
if (!value.contentType) {
value.contentType = rscContentTypeHeader;
}
}
}
const isCorrectNotFoundRoutes = semver.gte(
@@ -437,11 +449,19 @@ export async function serverBuild({
if (i18n) {
for (const locale of i18n.locales) {
const static404File =
staticPages[path.posix.join(entryDirectory, locale, '/404')] ||
new FileFsRef({
let static404File =
staticPages[path.posix.join(entryDirectory, locale, '/404')];
if (!static404File) {
static404File = new FileFsRef({
fsPath: path.join(pagesDir, locale, '/404.html'),
});
if (!fs.existsSync(static404File.fsPath)) {
static404File = new FileFsRef({
fsPath: path.join(pagesDir, '/404.html'),
});
}
}
requiredFiles[path.relative(baseDir, static404File.fsPath)] =
static404File;
}
@@ -1066,8 +1086,7 @@ export async function serverBuild({
canUsePreviewMode,
prerenderManifest.bypassToken || '',
true,
middleware.dynamicRouteMap,
inversedAppPathManifest
middleware.dynamicRouteMap
).then(arr =>
localizeDynamicRoutes(
arr,
@@ -1082,6 +1101,32 @@ export async function serverBuild({
)
);
const pagesPlaceholderRscEntries: Record<string, FileBlob> = {};
if (appDir) {
// since we attempt to rewrite all paths to an .rsc variant,
// we need to create dummy rsc outputs for all pages entries
// this is so that an RSC request to a `pages` entry will match
// rather than falling back to a catchall `app` entry
// on the nextjs side, invalid RSC response payloads will correctly trigger an mpa navigation
const pagesManifest = path.join(
entryPath,
outputDirectory,
`server/pages-manifest.json`
);
const pagesData = await fs.readJSON(pagesManifest);
const pagesEntries = Object.keys(pagesData);
for (const page of pagesEntries) {
const pathName = page.startsWith('/') ? page.slice(1) : page;
pagesPlaceholderRscEntries[`${pathName}.rsc`] = new FileBlob({
data: '{}',
contentType: 'application/json',
});
}
}
const { staticFiles, publicDirectoryFiles, staticDirectoryFiles } =
await getStaticFiles(entryPath, entryDirectory, outputDirectory);
@@ -1212,10 +1257,9 @@ export async function serverBuild({
if (ogRoute.endsWith('/route')) {
continue;
}
route = path.posix.join(
'./',
entryDirectory,
route === '/' ? '/index' : route
route = normalizeIndexOutput(
path.posix.join('./', entryDirectory, route === '/' ? '/index' : route),
true
);
if (lambdas[route]) {
@@ -1241,6 +1285,7 @@ export async function serverBuild({
...publicDirectoryFiles,
...lambdas,
...appRscPrefetches,
...pagesPlaceholderRscEntries,
// Prerenders may override Lambdas -- this is an intentional behavior.
...prerenders,
...staticPages,
@@ -1493,7 +1538,7 @@ export async function serverBuild({
dest: path.posix.join(
'/',
entryDirectory,
'/index.prefetch.rsc'
`/index${RSC_PREFETCH_SUFFIX}`
),
headers: { vary: rscVaryHeader },
continue: true,
@@ -1514,7 +1559,7 @@ export async function serverBuild({
dest: path.posix.join(
'/',
entryDirectory,
`/$1${APP_PREFETCH_SUFFIX}`
`/$1${RSC_PREFETCH_SUFFIX}`
),
headers: { vary: rscVaryHeader },
continue: true,
@@ -1593,7 +1638,7 @@ export async function serverBuild({
src: path.posix.join(
'/',
entryDirectory,
`/index${APP_PREFETCH_SUFFIX}`
`/index${RSC_PREFETCH_SUFFIX}`
),
dest: path.posix.join('/', entryDirectory, '/index.rsc'),
has: [
@@ -1609,7 +1654,7 @@ export async function serverBuild({
src: `^${path.posix.join(
'/',
entryDirectory,
`/(.+?)${APP_PREFETCH_SUFFIX}(?:/)?$`
`/(.+?)${RSC_PREFETCH_SUFFIX}(?:/)?$`
)}`,
dest: path.posix.join('/', entryDirectory, '/$1.rsc'),
has: [
@@ -1624,72 +1669,22 @@ export async function serverBuild({
]
: []),
...(appDir
? [
// check routes that end in `.rsc` to see if a page with the resulting name (sans-.rsc) exists in the filesystem
// if so, we want to match that page instead. (This matters when prefetching a pages route while on an appdir route)
{
src: `^${path.posix.join('/', entryDirectory, '/(.*)\\.rsc$')}`,
dest: path.posix.join('/', entryDirectory, '/$1'),
has: [
{
type: 'header',
key: rscHeader,
},
],
...(rscPrefetchHeader
? {
missing: [
{
type: 'header',
key: rscPrefetchHeader,
},
],
}
: {}),
check: true,
} as Route,
]
: []),
// These need to come before handle: miss or else they are grouped
// with that routing section
...afterFilesRewrites,
...(appDir
? [
// rewrite route back to `.rsc`, but skip checking fs
{
src: `^${path.posix.join(
'/',
entryDirectory,
'/((?!.+\\.rsc).+?)(?:/)?$'
)}`,
has: [
{
type: 'header',
key: rscHeader,
},
],
dest: path.posix.join('/', entryDirectory, '/$1.rsc'),
headers: { vary: rscVaryHeader },
continue: true,
override: true,
},
]
: []),
// make sure 404 page is used when a directory is matched without
// an index page
{ handle: 'resource' },
...fallbackRewrites,
// make sure 404 page is used when a directory is matched without
// an index page
{ src: path.posix.join('/', entryDirectory, '.*'), status: 404 },
{ handle: 'miss' },
// We need to make sure to 404 for /_next after handle: miss since
// handle: miss is called before rewrites and to prevent rewriting /_next
{ handle: 'miss' },
{
src: path.posix.join(
'/',

View File

@@ -48,6 +48,9 @@ export const MIB = 1024 * KIB;
export const prettyBytes = (n: number) => bytes(n, { unitSeparator: ' ' });
export const RSC_CONTENT_TYPE = 'x-component';
export const RSC_PREFETCH_SUFFIX = '.prefetch.rsc';
// Identify /[param]/ in route string
// eslint-disable-next-line no-useless-escape
const TEST_DYNAMIC_ROUTE = /\/\[[^\/]+?\](?=\/|$)/;
@@ -305,8 +308,7 @@ export async function getDynamicRoutes(
canUsePreviewMode?: boolean,
bypassToken?: string,
isServerMode?: boolean,
dynamicMiddlewareRouteMap?: Map<string, RouteWithSrc>,
appPathRoutesManifest?: Record<string, string>
dynamicMiddlewareRouteMap?: Map<string, RouteWithSrc>
): Promise<RouteWithSrc[]> {
if (routesManifest) {
switch (routesManifest.version) {
@@ -379,17 +381,15 @@ export async function getDynamicRoutes(
},
];
}
routes.push({
...route,
src: route.src.replace(
new RegExp(escapeStringRegexp('(?:/)?$')),
'(?:\\.rsc)(?:/)?$'
),
dest: route.dest?.replace(/($|\?)/, '.rsc$1'),
});
if (appPathRoutesManifest?.[page]) {
routes.push({
...route,
src: route.src.replace(
new RegExp(escapeStringRegexp('(?:/)?$')),
'(?:\\.rsc)(?:/)?$'
),
dest: route.dest?.replace(/($|\?)/, '.rsc$1'),
});
}
routes.push(route);
continue;
}
@@ -2161,7 +2161,7 @@ export const onPrerenderRoute =
routesManifest?.rsc?.varyHeader ||
'RSC, Next-Router-State-Tree, Next-Router-Prefetch';
const rscContentTypeHeader =
routesManifest?.rsc?.contentTypeHeader || 'text/x-component';
routesManifest?.rsc?.contentTypeHeader || RSC_CONTENT_TYPE;
let sourcePath: string | undefined;
if (`/${outputPathPage}` !== srcRoute && srcRoute) {
@@ -2347,7 +2347,7 @@ export function normalizeIndexOutput(
outputName: string,
isServerMode: boolean
) {
if (outputName !== '/index' && isServerMode) {
if (outputName !== 'index' && outputName !== '/index' && isServerMode) {
return outputName.replace(/\/index$/, '');
}
return outputName;
@@ -2524,6 +2524,29 @@ function normalizeRegions(regions: Regions): undefined | string | string[] {
return newRegions;
}
export function normalizeEdgeFunctionPath(
shortPath: string,
appPathRoutesManifest: Record<string, string>
) {
if (
shortPath.startsWith('app/') &&
(shortPath.endsWith('/page') ||
shortPath.endsWith('/route') ||
shortPath === 'app/_not-found')
) {
const ogRoute = shortPath.replace(/^app\//, '/');
shortPath = (
appPathRoutesManifest[ogRoute] ||
shortPath.replace(/(^|\/)(page|route)$/, '')
).replace(/^\//, '');
if (!shortPath || shortPath === '/') {
shortPath = 'index';
}
}
return shortPath;
}
export async function getMiddlewareBundle({
entryPath,
outputDirectory,
@@ -2702,27 +2725,19 @@ export async function getMiddlewareBundle({
// app/index/page -> index/index
if (shortPath.startsWith('pages/')) {
shortPath = shortPath.replace(/^pages\//, '');
} else if (
shortPath.startsWith('app/') &&
(shortPath.endsWith('/page') ||
shortPath.endsWith('/route') ||
shortPath === 'app/_not-found')
) {
const ogRoute = shortPath.replace(/^app\//, '/');
shortPath = (
appPathRoutesManifest[ogRoute] ||
shortPath.replace(/(^|\/)(page|route)$/, '')
).replace(/^\//, '');
if (!shortPath || shortPath === '/') {
shortPath = 'index';
}
} else {
shortPath = normalizeEdgeFunctionPath(shortPath, appPathRoutesManifest);
}
if (routesManifest?.basePath) {
shortPath = path.posix
.join(routesManifest.basePath, shortPath)
.replace(/^\//, '');
shortPath = normalizeIndexOutput(
path.posix.join(
'./',
routesManifest?.basePath,
shortPath.replace(/^\//, '')
),
true
);
}
worker.edgeFunction.name = shortPath;

View File

@@ -1,7 +1,10 @@
import Link from 'next/link';
export default function Home() {
return (
<div>
<h1>Home</h1>
<Link href="/en/about">About</Link>
</div>
);
}

View File

@@ -16,7 +16,7 @@
"headers": {
"RSC": "1"
},
"mustContain": "<html"
"bodyMustBe": "{}"
},
{
"path": "/en/foobar",

View File

@@ -2,4 +2,6 @@ export default function handler(req, res) {
return res.json({ hello: 'world' });
}
export const maxDuration = 7;
export const config = {
maxDuration: 7
};

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