Compare commits

..

85 Commits

Author SHA1 Message Date
Vercel Release Bot
4cd77608e8 Version Packages (#10020)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-01 10:09:24 -05:00
Steven
e6b2980eba [tests] Fix summary workflow to always run (#10048)
### Description
This ensures the Summary job always runs to check if any test failed and
cause itself to fail as well.

This allows us to dynamically add as many concurrent jobs as we want but
only have one (Summary) marked as required.

### Testing
I verified this worked by making a change to `@vercel/static-config`
which is not required and the Summary check failed:

https://github.com/vercel/vercel/actions/runs/5136560652/jobs/9243924596

Then I reverted it so that the test was passing and the Summary check
passed:

https://github.com/vercel/vercel/actions/runs/5137401343/jobs/9245554297
2023-05-31 18:24:54 -04:00
Nathan Rajlich
67e20a6ede [cli] Add repo linking support for deploy command (#10013)
Adds support for `vercel deploy` command when the repository has been linked via `vercel link --repo`.
2023-05-31 18:07:30 +00:00
JJ Kasper
c63679ea0a Revert "[next] Update rsc content-type test fixtures" (#10040)
Relies on https://github.com/vercel/next.js/pull/50472 this should only be merged after the Next.js PR is released to canary

Reverts vercel/vercel#10023
2023-05-31 15:38:22 +00:00
Damien Simonin Feugas
4280166df4 docs(sveltekit): re-introduce speed insights (#9988) 2023-05-31 09:41:46 +02:00
Nathan Rajlich
18ae78137c Fetch git tags during Release workflow (#10045)
Follow-up to #10044. The git tags need to be present for `changeset tag` to work properly.
2023-05-30 21:10:03 +00:00
Nathan Rajlich
ebe4058073 Use pnpm publish -r and changeset tag to publish packages (#10044)
This is a re-application of #10022 (which was reverted in #10032), but with the addition of `changeset tag` after the `pnpm publish -r` command. This ensures the proper git tags are also created, allowing for the GitHub releases to be published.
2023-05-30 19:25:24 +00:00
Vercel Release Bot
942e76840e [tests] Upgrade Turbo to version 1.9.9 (#10036)
This auto-generated PR updates Turbo to version 1.9.9
2023-05-29 20:31:12 +00:00
Nathan Rajlich
57515d2d07 [cli] Fix link subcommand unit tests on Windows (#10033)
Follow-up to #10031 which broke the `link` unit tests on Windows.

For some reason Kodiak was a bad bot and merged the PR with failing tests <picture data-single-emoji=":rarityannoyed:" title=":rarityannoyed:"><img class="emoji" src="https://emoji.slack-edge.com/T0CAQ00TU/rarityannoyed/b62f8c87a5fb7239.png" alt=":rarityannoyed:" width="20" height="auto" align="absmiddle"></picture> 

_Note:_ Probably easier to review with [whitespace hidden](https://github.com/vercel/vercel/pull/10033/files?w=1).
2023-05-26 21:27:19 +00:00
Nathan Rajlich
ef30a46c03 [cli] Add client.cwd to unify all working directory related logic (#10031)
A few commands were still checking on `--cwd` explicitly, which is incorrect since the entrypoint file already handles the directory change.

The new `client.cwd` property is a helper to make writing tests easier. Tests no longer need to `chdir()` explicitly and then revert afterwards.
2023-05-26 20:42:03 +00:00
Nathan Rajlich
113b8ac87b Revert "Use pnpm publish -r to publish packages (#10022)" (#10032)
This reverts commit 1e47bbf32f.

`changeset publish` also creates git tags, whereas `pnpm publish -r` does not. This causes the GitHub Releases to not be created.
2023-05-26 20:18:49 +00:00
Shohei Maeda
b56ac2717d [next] Pass pageExtensions data to apiLambdaGroups (#10015)
Right now, we can't detect API routes correctly if `pageExtensions` is set:

> WARNING: Unable to find source file for page xxxx with extensions: js, jsx, ts, tsx, this can cause functions config from `vercel.json` to not be applied
2023-05-26 18:01:05 +00:00
Vercel Release Bot
aa8957ab10 [examples][tests] Upgrade Next.js to version 13.4.4 (#10025)
This auto-generated PR updates 3 packages to Next.js version 13.4.4
2023-05-26 10:54:42 -04:00
Shohei Maeda
c6c19354e8 [next] Fix functions config with App Router (#9889)
We added appDir support in https://github.com/vercel/vercel/pull/9811 so that users can customize `memory`/`maxDuration` for routes in appDir.

But since RSC is enabled by default in Next.js 13, `vercel build` still reports some warning messages, such as:

```json
"functions": {
  "app/**/*": {
    "maxDuration": 5,
    "memory": 512
  }
}
```
```
WARNING: Unable to find source file for page hello.js with extensions: ts, tsx, js, jsx, md, mdx, this can cause functions config from `vercel.json` to not be applied
WARNING: Unable to find source file for page index.js with extensions: ts, tsx, js, jsx, md, mdx, this can cause functions config from `vercel.json` to not be applied
```

To suppress these errors and properly apply `functions` setting to those routes, updating the current detection logic to also search `page.${ext}` files.
2023-05-25 21:01:29 +00:00
JJ Kasper
96b2502133 [next] Update rsc content-type test fixtures (#10023)
This updates the tests to the latest expected content-type header for RSC responses. 

x-ref: https://github.com/vercel/next.js/pull/50314
2023-05-25 08:32:53 +00:00
Swarnava Sengupta
2df0262675 [examples] Update preact template to use Node 18 (#10012) 2023-05-24 15:06:01 -07:00
Nathan Rajlich
1e47bbf32f Use pnpm publish -r to publish packages (#10022)
Following the instructions here: https://pnpm.io/using-changesets

This should ensure that packages are published in the correct order (see related issue: https://github.com/changesets/changesets/issues/238).
2023-05-24 21:56:45 +00:00
Nathan Rajlich
00813a3945 [cli] Add expect dev dependency to fix type error in toOutput (#10021)
Also make the timeout print what was buffered to help with debugging failed tests.
2023-05-24 21:35:33 +00:00
Chris Barber
a73ec6343f [cli] Clean up 'vc rollback' (#10019)
This PR removes dependency on the deprecated `lastRollbackTarget` project property and adopts many of the code conventions used in `vc promote`.

Important! Please merge #9984 first!
2023-05-24 19:10:28 +00:00
Chris Barber
4bd70d4b6e [cli] New vc promote command (#9984)
~This PR is blocked by https://github.com/vercel/api/pull/19508.~

Linear: https://linear.app/vercel/issue/VCCLI-262/cli-new-command-to-promote-deployment
2023-05-24 17:22:11 +00:00
Javi Velasco
c7bcea4081 Remove usage of env from Edge Functions and Middleware (#10018)
Co-authored-by: Steven <steven@ceriously.com>
2023-05-24 18:22:43 +02:00
Vercel Release Bot
aab95532d6 Version Packages (#10006)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-05-24 10:13:01 -05:00
Sean Massa
1b18c853c2 [cli] implement vc deploy --prod --skip-domain (#9836)
Adds the `--skip-domain` option to be used like `vc deploy --prod --skip-domain`. This passes along the `autoAliasCustomDomains: false` flag to the API so that the deployment will not auto alias domains for this deployment.

This PR also moves the `commands/deploy/archive` fixture to `commands/deploy/static` to better describe what the fixture is, not how it is sometimes used in a test.

---

Depends on: https://github.com/vercel/api/pull/18730
Card: https://linear.app/vercel/issue/VCCLI-276/cli-allow-creation-of-production-deployment-without-auto-alias
2023-05-23 19:26:47 +00:00
Swarnava Sengupta
1663db7ca3 [examples] Update solid-js template to use Node 18 (#10009) 2023-05-23 11:29:14 -07:00
Nathan Rajlich
e80247fb99 Update to latest version of patrickedqvist/wait-for-vercel-preview (#10008)
The older version we were using is using Node 12, and GH Actions prints this warning:

> Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: patrickedqvist/wait-for-vercel-preview@ae34b392ef. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.

The current version of this action uses Node 16.
2023-05-23 15:01:18 +00:00
Samuel Bodin
a19edc985b [cli] Fix vercel git connect command when passing a URL parameter (#9967)
Hey team,

I had an error this morning when trying to link my repo using the CLI 
![Screenshot 2023-05-17 at 11 38 01](https://github.com/vercel/vercel/assets/1637651/798d6e4f-8c9e-41b7-b712-0322001fca02)


Seems like a combination of `: any` and a recent refacto introduced an issue here.

~- Removed all `any` that were hiding the error~
- Correctly pass the URL already parsed

~- Removed the second useless parsing~
~- Added missing `--help` flag~
  ~I noticed you never specify them and Typescript screams because of that, not sure if on purpose and how you make the compilation pass with this error. Don't hesitate to tell me.~

The fix could be improved by using `arg.Result<THE_ACTUAL_TYPE>` but that would require to store the dictionnary of flags somewhere else and also create an external type. This is already better so...

--- 

NB: 
I had multiple issues while cloning this repo
- pnpm bootstrap does not work
- missing `constants.ts` file that is not explained in the Contributing guidelines
- maybe due to bootstrap not working, almost nothing else worked and the tests too.
2023-05-23 02:50:42 +00:00
Nathan Rajlich
4fd593ac09 Sync repo package versions (#10002)
Some of these packages got out of sync at some point, causing duplicate
/ older copies to be installed. Additionally, the `@vercel-internal`
packages should have "version" fields.

Attempting to fix these
[warnings](https://github.com/vercel/vercel/actions/runs/5048844603/jobs/9057538600)
during release:

```
Package "examples" must depend on the current version of "@vercel/frameworks": "1.4.2" vs "1.3.0"
Package "@vercel-internals/constants" must depend on the current version of "@vercel/build-utils": "6.7.3" vs "6.3.2"
Package "@vercel-internals/constants" must depend on the current version of "@vercel/routing-utils": "2.2.1" vs "2.1.10"
Package "@vercel-internals/constants" must depend on the current version of "@vercel-internals/tsconfig": "undefined" vs "*"
Package "@vercel-internals/get-package-json" must depend on the current version of "@vercel-internals/tsconfig": "undefined" vs "*"
Package "@vercel-internals/types" must depend on the current version of "@vercel-internals/constants": "undefined" vs "*"
Package "@vercel-internals/types" must depend on the current version of "@vercel/build-utils": "6.7.3" vs "6.3.2"
Package "@vercel-internals/types" must depend on the current version of "@vercel/routing-utils": "2.2.1" vs "2.1.10"
Package "@vercel-internals/types" must depend on the current version of "@vercel-internals/tsconfig": "undefined" vs "*"
Package "vercel" must depend on the current version of "@vercel-internals/constants": "undefined" vs "*"
Package "vercel" must depend on the current version of "@vercel-internals/get-package-json": "undefined" vs "*"
Package "vercel" must depend on the current version of "@vercel-internals/types": "undefined" vs "*"
Package "@vercel/node" must depend on the current version of "@vercel/error-utils": "1.0.10" vs "1.0.8"
```
2023-05-22 15:26:36 -07:00
Dan Stowell
1b0d72aba5 [cli] Change vc env pull default output file to .env.local (#9892)
`vc deploy` ignores `.env.local`. To make sure we don't inadvertently
push people's secrets to source control, have all environment pulls
default to writing to `.env.local`.
2023-05-22 15:24:38 -07:00
Nathan Rajlich
c52a59809e Remove pnpm bootstrap from contributing instructions (#10005)
This script no longer exists.
2023-05-22 22:16:47 +00:00
Chris Barber
cdf55b3b1a [cli] New vc redeploy command (#9956)
This adds a new `vc redeploy <url-or-id>` command. It fetches the requested deployment, then performs a redeploy with similar output to `vc deploy` including the ability to pipe the deployment URL into a file or program.

### Redeploy Example:

<img width="650" alt="image" src="https://github.com/vercel/vercel/assets/97262/b17fc424-558b-415c-8b74-63e450f4b753">

### Bad deployment URL:

<img width="579" alt="image" src="https://github.com/vercel/vercel/assets/97262/0cb53209-396e-4490-b5d0-744d5d870aaf">

### No args:

<img width="622" alt="image" src="https://github.com/vercel/vercel/assets/97262/cb36d625-991b-41fa-bb49-d7d36c1a201b">

Linear: https://linear.app/vercel/issue/VCCLI-558/cli-new-command-to-redeploy
2023-05-22 22:08:49 +00:00
Nathan Rajlich
8de42e0a70 [cli] Remove --platform-version global common arg (#9807)
Removes the unused `--platform-version` flag from the common args.

Technically this is a breaking change, so we should probably hold off on merging until we plan to do a major version bump.
2023-05-22 21:44:52 +00:00
Swarnava Sengupta
7ff321310f [examples] Update "vue" template to use Node 18 (#10001) 2023-05-22 11:56:21 -07:00
Nathan Rajlich
2da72bc5e4 Fix promoting CLI release to "latest" GH Release (#10003)
The logic to retrieve the latest release was not working correctly, so use the `getLatestRelease()` function instead of assuming that `release[0]` is tagged as the latest.
2023-05-22 18:49:51 +00:00
Vercel Release Bot
46950633f4 Version Packages (#9994) 2023-05-22 10:47:47 -07:00
Vercel Release Bot
44b1dfe7c5 [tests] Upgrade Turbo to version 1.9.8 (#9996)
This auto-generated PR updates Turbo to version 1.9.8
2023-05-22 08:50:23 +00:00
Vercel Release Bot
0278c7b7b9 [examples] Upgrade Next.js to version 13.4.3 (#9980)
This auto-generated PR updates Next.js to version 13.4.3
2023-05-19 21:08:38 +00:00
Sean Massa
761db597be clarify next.js dupe api directory warning (#9979)
In a Next.js app, if you have Node.js Functions in both `api` and `pages/api`, you'll get a warning about moving those `api` functions into `pages/api`. This does specify Node.js Functions already, but a user was confused and tried to move their non-Node.js functions into `pages/api` as well.

This PR tries to make it clearer that you can do both. Note that this still requires a non-ideal local dev setup where you:

- update next config to fall back to the `vc dev` port for `api` handlers
- run `next dev` for the Next.js app on one port
- run `vc dev` for the top-level `api` Functions on another port

---

Example repo: https://github.com/rexfordessilfie/vercel-api-languages
2023-05-19 19:31:32 +00:00
Nathan Rajlich
671e63e7b8 [cli] Add vc link --repo flag (alpha) (#8931)
Adding a new `--repo` flag to `vc link` which is a new linking style to
link to a Git URL rather then directly to a single Vercel Project. This
allows for multiple Projects to be linked simultaneously, which is
useful for monorepo setups.

Utilization of this new linking style in other commands will be done in
a follow-up PR.
2023-05-19 11:53:49 -07:00
Vercel Release Bot
f7bdc6cc26 Version Packages (#9991)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-05-19 12:08:50 -05:00
Sean Massa
e94a153b2f add repo details for packages that are missing it (#9990) 2023-05-19 12:02:12 -05:00
Vercel Release Bot
74e639a772 Version Packages (#9978)
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@6.7.3

### Patch Changes

- Deprecate Node.js 14.x and 16.x with warning
([#9976](https://github.com/vercel/vercel/pull/9976))

## vercel@29.3.5

### Patch Changes

- Updated dependencies
\[[`2c950d47a`](2c950d47ae),
[`71b9f3a94`](71b9f3a94b),
[`f00b08a82`](f00b08a820)]:
    -   @vercel/static-build@1.3.31
    -   @vercel/build-utils@6.7.3
    -   @vercel/next@3.8.5
    -   @vercel/node@2.14.3
    -   @vercel/remix-builder@1.8.10

## @vercel/client@12.5.1

### Patch Changes

- Updated dependencies
\[[`71b9f3a94`](71b9f3a94b)]:
    -   @vercel/build-utils@6.7.3

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

### Patch Changes

- Updated dependencies
\[[`71b9f3a94`](71b9f3a94b)]:
    -   @vercel/build-utils@6.7.3
    -   @vercel/node@2.14.3

## @vercel/next@3.8.5

### Patch Changes

- [next] Ensure app functions are detected/separated properly
([#9989](https://github.com/vercel/vercel/pull/9989))

## @vercel/node@2.14.3

### Patch Changes

- Updated dependencies
\[[`71b9f3a94`](71b9f3a94b)]:
    -   @vercel/build-utils@6.7.3

## @vercel/remix-builder@1.8.10

### Patch Changes

- Updated dependencies
\[[`71b9f3a94`](71b9f3a94b)]:
    -   @vercel/build-utils@6.7.3

## @vercel/static-build@1.3.31

### Patch Changes

- ensure cleanup after gatsby plugin runs
([#9975](https://github.com/vercel/vercel/pull/9975))

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

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-05-19 09:34:26 -07:00
JJ Kasper
f00b08a820 [next] Ensure app functions are detected/separated properly (#9989)
Follow-up to https://github.com/vercel/vercel/pull/9974 this uses the `lambdaAppPaths` as the source of truth instead of the manifest which is more accurate for separating/detecting. Also adds additional test cases for new root and index app functions. 

x-ref: https://github.com/vercel/next.js/issues/49169
2023-05-19 16:22:44 +00:00
Chris Barber
6cdd38d130 [tests] Pin Next.js version in test fixtures (#9910)
Co-authored-by: Sean Massa <EndangeredMassa@gmail.com>
2023-05-19 09:06:08 -05:00
Sean Massa
2c950d47ae ensure cleanup after the gatsby plugin runs (#9975)
There is an issue where you can interrupt a gatsby project build and the temporary files are not cleaned up. If you try to build again, it will get stuck in an infinite loop.

This PR adds an exit hook to make sure the cleanup happens.
2023-05-18 19:42:08 +00:00
Sean Massa
71b9f3a94b Deprecate Node.js 14.x and 16.x with warning (#9976)
Node.js 14 and 16 are being deprecated. This PR will cause a warning when they are used today and an error after August 15.
2023-05-18 19:03:01 +00:00
Vercel Release Bot
91b7f6dcd9 Version Packages (#9973)
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@29.3.4

### Patch Changes

- Updated dependencies
\[[`67e556bc8`](67e556bc80),
[`ba10fb4dd`](ba10fb4dd4)]:
    -   @vercel/remix-builder@1.8.9
    -   @vercel/next@3.8.4

## @vercel/next@3.8.4

### Patch Changes

- Update handling for react prebundled flag
([#9974](https://github.com/vercel/vercel/pull/9974))

## @vercel/remix-builder@1.8.9

### Patch Changes

- Upgrade `@remix-run/dev` fork to v1.16.1
([#9971](https://github.com/vercel/vercel/pull/9971))

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-05-18 10:38:24 -07:00
JJ Kasper
ba10fb4dd4 [next] Update handling for react prebundled flag (#9974)
This ensures we properly set the prebundled react flag conditionally for
app and pages ensuring they are kept separate when bundling.

x-ref: https://github.com/vercel/next.js/issues/49169
2023-05-18 06:37:50 -07:00
Nathan Rajlich
18c1c45ce3 Add changeset for @remix-run/dev updater GH Action (#9972)
Adds a changeset file when the GH Action to update `@remix-run/dev`
creates a pull request.
2023-05-17 16:39:09 -07:00
Vercel Release Bot
67e556bc80 [remix] Upgrade @remix-run/dev to version 1.16.1 (#9971)
This auto-generated PR updates @remix-run/dev to version 1.16.1
2023-05-17 19:34:12 +00:00
Sean Massa
7235000181 fix release script (#9959)
The [previous PR](https://github.com/vercel/vercel/pull/9942) used `github.repos`, but I think this needs to be `github.rest.repos`.

- [Docs](https://octokit.github.io/rest.js/v19#repos)
- [Failed GH Action](https://github.com/vercel/vercel/actions/runs/4994578940/jobs/8945329301)
2023-05-17 18:26:30 +00:00
Sean Massa
5124d431ea fix deploy from local (#9969)
Local deployments of this repo would fail because this repo assumes that it's only ever deployed via git connection.
2023-05-17 17:45:28 +00:00
Vercel Release Bot
c879401bbc Version Packages (#9966)
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@29.3.3

### Patch Changes

- Updated dependencies
\[[`6c6f3ce9d`](6c6f3ce9d2)]:
    -   @vercel/next@3.8.3

## @vercel/next@3.8.3

### Patch Changes

- Ensure un-necessary rsc routes are not added
([#9963](https://github.com/vercel/vercel/pull/9963))

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-05-17 10:45:41 +02:00
JJ Kasper
6c6f3ce9d2 [next] Ensure un-necessary rsc routes are not added (#9963)
These routes aren't needed for RSC as `_next/data` isn't used for
routing app paths.

x-ref: [slack
thread](https://vercel.slack.com/archives/C058FQFKAGH/p1684272340654679?thread_ts=1684271538.503259&cid=C058FQFKAGH)
2023-05-16 16:33:09 -07:00
Vercel Release Bot
aa83680832 [examples] Upgrade Next.js to version 13.4.2 (#9943)
This auto-generated PR updates Next.js to version 13.4.2
2023-05-16 22:54:10 +00:00
Vercel Release Bot
06113d3e39 Version Packages (#9962)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-05-16 15:53:57 -05:00
Luc Leray
5150f21404 [vc dev] Fix serverless function size limit condition (#9961)
Co-authored-by: Sean Massa <EndangeredMassa@gmail.com>
2023-05-16 14:17:00 -05:00
Sean Massa
eb6bb98406 empty push test 2023-05-16 11:49:25 -05:00
Vercel Release Bot
d8e3b6e738 Version Packages (#9950)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Sean Massa <EndangeredMassa@gmail.com>
2023-05-16 11:48:06 -05:00
Luc Leray
25da051d62 [vc dev] Skip 50MB zip size limit for Python (#9944)
Do not apply the 50MB zip size limit for Python serverless function during `vc dev`.

Related to internal PR: https://github.com/vercel/api/pull/19279
2023-05-16 15:58:04 +00:00
Vercel Release Bot
f57af66dc2 [tests] Upgrade Turbo to version 1.9.4 (#9952)
This auto-generated PR updates Turbo to version 1.9.4
2023-05-16 03:21:01 +00:00
Nathan Rajlich
b2f71d5352 Remove "Required PR Label" workflow (#9958)
Changesets enforces this, so no need for this extra workflow anymore.
2023-05-15 14:38:30 -07:00
Lee Robinson
6115f0d74a Update README (#9951)
To be more clear about what Vercel is actually providing you, as a developer.
2023-05-13 20:32:46 +00:00
Nathan Rajlich
14c877e468 [cli] Sort keys in vc env pull (#9949)
Makes sense to have the output be deterministic. Alphabetical sort seems like a logical choice.
2023-05-12 22:08:59 +00:00
Nathan Rajlich
d80732d74f [release] Promote vercel CLI release to "latest" (#9942)
It's possible that changesets will promote a release to latest that is
not the Vercel CLI release. This script ensures that a `vercel@` release
is always the latest after a publish happens.
2023-05-11 13:40:34 -07:00
Vercel Release Bot
b739c1845c Version Packages (#9939)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-05-11 10:46:10 -05:00
Sean Massa
e9f0fcf397 [cli] remove vc rollback beta label (#9928)
Remove the "beta" label from `vc rollback`.
2023-05-11 15:16:48 +00:00
Sean Massa
924a20a0fc [tests] make prettier ignore .changeset (#9938) 2023-05-11 09:50:14 -05:00
Nathan Rajlich
fc3b74d06f Add id-token: write permissions to enable npm publish provenance (#9936)
Was previously added in https://github.com/vercel/vercel/pull/9583, was
missed in the changesets switchover.
2023-05-10 16:24:28 -07:00
Vercel Release Bot
380ed38c71 Version Packages (#9935)
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@29.2.1

### Patch Changes

-   Updated dependencies \[[`6d5983eaa`](6d5983eaae)]:
    -   @vercel/remix-builder@1.8.8

## @vercel/remix-builder@1.8.8

### Patch Changes

-   Upgrade `@remix-run/dev` to v1.16.0-patch.1 to fix erroneous "not found in your node_modules" warning ([#9930](https://github.com/vercel/vercel/pull/9930))
2023-05-10 22:55:42 +00:00
Nathan Rajlich
e228cdd373 Add @svitejs/changesets-changelog-github-compact to package.json (#9934)
Forgot to add the package in #9933 :doh:
2023-05-10 14:47:42 -07:00
Nathan Rajlich
9bd92535d6 Use Svelte's changelog generator and don't delete CHANGELOG.md (#9933)
Partial revert of #9932, since apparently [that didn't
work](https://github.com/vercel/vercel/actions/runs/4941266637/jobs/8833725828).

We can investigate that more later, but this gets it working again
properly at least.

Also use Svelte's changelog generator, since it includes the PR numbers
which Sean wanted.
2023-05-10 14:41:19 -07:00
Nathan Rajlich
5825e30700 Create release PR as "Vercel Bot" and remove CHANGELOG.md files (#9932)
* Have changesets create the release PR as "Vercel Bot", so that the
tests run.
* Remove the `CHANGELOG.md` files. They are redundant with the GH
Releases which contain the same information.
2023-05-10 13:58:29 -07:00
Vercel Release Bot
6d5983eaae [remix] Upgrade @remix-run/dev to version 1.16.0-patch.1 (#9930)
This auto-generated PR updates @remix-run/dev to version 1.16.0-patch.1
2023-05-10 20:20:15 +00:00
Nathan Rajlich
2fd59a3b5a Use changesets instead of lerna (#9914)
`changesets` will improve our release workflow, since we will no longer need to manually curate and publish the changelog and GitHub Release. Instead, you simply merge the publish PR that the changesets GH action maintains as we push commits to `main`.
2023-05-10 19:35:17 +00:00
Nathan Rajlich
d1d3e9384d Publish Stable
- vercel@29.2.0
 - @vercel/client@12.5.0
 - @vercel/frameworks@1.4.2
 - @vercel/fs-detectors@3.9.2
 - @vercel/gatsby-plugin-vercel-builder@1.3.3
 - @vercel/node@2.14.2
 - @vercel/static-build@1.3.30
2023-05-10 10:39:11 -07:00
Nathan Rajlich
8428632eb1 [cli] Add support for Vercel CLI Extensions (#9800)
# Vercel CLI Extensions

Adds a new mechanism to add additional sub-commands to Vercel CLI, inspired by how Git handles sub-commands:

* Extensions are standalone executables that Vercel CLI will spawn as a child process.
* The name of the executable must begin with `vercel-`. For example, to add a sub-command called `vercel example`, there should exist an executable called `vercel-example`.
* The executable can either be a npm package with a `"bin"` entry installed into the local project's workspace, or be globally available in the `$PATH`.
* Extensions can access the [Vercel REST API](https://vercel.com/docs/rest-api), pre-authenticated, by utilizing the `VERCEL_API` env var. Vercel CLI spawns a local HTTP server that adds the `Authorization` header and then proxies to the Vercel REST API.

## Environment Variables

A few environment variables which provide features and context to the extension:

| Name      | Description |
| ----------- | ----------- |
| `VERCEL_API`      | HTTP URL to access the pre-authenticated Vercel API.       |
| `VERCEL_TEAM_ID`  | Provided when the currently selected scope is a Team. |
| `VERCEL_DEBUG` | Provided when the `--debug` flag is used. The command _may_ output additional debug logging. |
| `VERCEL_HELP` | Provided when the `--help` flag is used. The command _should_ print the help output and then end with exit code **2**. |

## Example

```bash
#!/usr/bin/env bash
set -euo pipefail

echo Hi, from a Vercel CLI Extension!
user="$(curl -s "$VERCEL_API/v2/user" | jq -r .user.username)"
echo "Logged in as: $user"
```

Usage:

```
$ vc example
Vercel CLI 28.18.5
Hi, from a Vercel CLI Extension!
Logged in as: tootallnate
```
2023-05-10 16:36:58 +00:00
Chris Barber
fa443035f6 [tests] Add test for set-cookie with multiple cookies (#9916)
This adds the missing test for https://github.com/vercel/vercel/pull/9899.
2023-05-06 10:18:52 +00:00
Sean Massa
de2c7e1633 [cli] rename global options in help output (#9917)
Make the distinction between global and deploy options more clear.

The dim note about how to get `deploy`-specific help:

<img width="670" alt="Screenshot 2023-05-05 at 3 55 49 PM" src="https://user-images.githubusercontent.com/41545/236568356-10b9ce4f-2865-4267-a3eb-3488df88a133.png">
2023-05-05 22:00:27 +00:00
Sean Massa
75d2435138 [cli] refactor help output around default and deploy commands (#9912)
When getting help output for the default command `vc --help`, you get a list of commands. When you specify the `deploy` command with `vc deploy --help`, you get the same list of commands.

This PR makes a distinction between an explicit `deploy` command and a default one for the purposes of help output.

Should show CLI help:

- `vc -h`
- `vc --help`
- `vc help`

Should show `deploy` command help:

- `vc deploy -h`
- `vc deploy --help`
- `vc help deploy`
2023-05-05 18:54:50 +00:00
Vercel Release Bot
5328bb69e2 [examples] Upgrade Next.js to version 13.4.1 (#9911)
This auto-generated PR updates Next.js to version 13.4.1
2023-05-05 16:25:11 +00:00
Kiko Beats
e3fe368baa [cli][node] upgrade async-listen to 3.0.0 (#9907)
The `async-listen@3.0.0` is ESM ready and always returns a `URL`
instance; That helps us to unify code.
2023-05-05 16:09:10 +02:00
Nathan Rajlich
99832587c5 [cli] Add support for HTTPS_PROXY env var (#9880)
By leveraging the [`proxy-agent`](https://www.npmjs.com/package/proxy-agent) npm module, enable CLI to support making HTTP requests over a proxy, by leveraging the `HTTPS_PROXY` or `ALL_PROXY` env var (same convention as `curl` uses).

Finally closes this ancient issue: https://github.com/vercel/vercel/issues/255
2023-05-05 00:52:18 +00:00
Vercel Release Bot
47d0d4f84a [examples] Upgrade Next.js to version 13.4.0 (#9902)
This auto-generated PR updates Next.js to version 13.4.0
2023-05-04 20:25:08 +00:00
Sean Massa
aba54ee6cf [frameworks] validate getOutputDirName and other missing values on framework entries (#9900)
Covers the validation whole in Framework entries over function properties and other missing holes.
2023-05-03 23:36:26 +00:00
Chris Barber
cd7d3ef1c5 [node] Explicitly set 'set-cookie' header (#9899)
When looping over the response headers returned by `node-fetch`, it will join `set-cookie` header value into a single string. The whatwg calls for a `headers.getSetCookie()` function to handle the `set-cookie` special case, but `node-fetch@2.x` doesn't support it.

As a workaround, we need to grab the raw `set-cookie` header value.
2023-05-03 22:12:45 +00:00
361 changed files with 17470 additions and 17848 deletions

8
.changeset/README.md Normal file
View File

@@ -0,0 +1,8 @@
# Changesets
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

14
.changeset/config.json Normal file
View File

@@ -0,0 +1,14 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
"changelog": [
"@svitejs/changesets-changelog-github-compact",
{ "repo": "vercel/vercel" }
],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}

View File

@@ -15,7 +15,6 @@ git clone https://github.com/vercel/vercel
cd vercel
corepack enable
pnpm install
pnpm bootstrap
pnpm build
pnpm lint
pnpm test-unit

View File

@@ -1,75 +1,78 @@
name: Publish
name: Release
on:
push:
branches:
- main
tags:
- '!*'
env:
TURBO_REMOTE_ONLY: 'true'
TURBO_TEAM: 'vercel'
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
publish:
name: Publish
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check Release
id: check-release
run: |
tag="$(git describe --tags --exact-match 2> /dev/null || :)"
if [[ -z "$tag" ]];
then
echo "IS_RELEASE=false" >> $GITHUB_OUTPUT
else
echo "IS_RELEASE=true" >> $GITHUB_OUTPUT
fi
- name: Setup Go
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
uses: actions/setup-go@v3
with:
go-version: '1.13.15'
- name: Fetch git tags
run: git fetch origin 'refs/tags/*:refs/tags/*'
- name: Setup Node
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
uses: actions/setup-node@v3
with:
node-version: 16
- name: install npm@9
run: npm i -g npm@9
- name: install pnpm@8.3.1
run: npm i -g pnpm@8.3.1
- name: Install
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
run: pnpm install
- name: Build
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Build Packages
run: pnpm build
env:
GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
- name: Publish
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
run: pnpm publish-from-github
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
version: pnpm ci:version
publish: pnpm ci:publish
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PULL_REQUESTS }}
NPM_CONFIG_PROVENANCE: 'true'
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}
GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
- name: Trigger Update
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
- name: Trigger Update (if a Publish Happened)
if: steps.changesets.outputs.published == 'true'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_TOKEN_PULL_REQUESTS }}
script: |
const script = require('./utils/trigger-update-workflow.js')
await script({ github, context })
- name: Set latest Release to `vercel` (if a Publish Happened)
if: steps.changesets.outputs.published == 'true'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_TOKEN_PULL_REQUESTS }}
script: |
const script = require('./utils/update-latest-release.js')
await script({ github, context })

View File

@@ -1,26 +0,0 @@
name: Required PR Label
on:
pull_request:
types: [opened, labeled, unlabeled, synchronize]
jobs:
label:
runs-on: ubuntu-latest
steps:
- name: Check PR Labels
uses: actions/github-script@v6
with:
script: |
let missing = false;
const labels = context.payload.pull_request.labels.map(l => l.name);
if (labels.filter(l => l.startsWith('area:')).length === 0) {
console.error('::error::Missing label: Please add at least one "area" label.');
missing = true;
}
if (labels.filter(l => l.startsWith('semver:')).length !== 1) {
console.error('::error::Missing label: Please add exactly one "semver" label.');
missing = true;
}
if (missing) {
process.exit(1);
}
console.log('::notice::Success: This pull request has correct labels, thanks!');

View File

@@ -41,7 +41,7 @@ jobs:
echo "Files to test:"
echo "$TESTS_ARRAY"
echo "tests=$TESTS_ARRAY" >> $GITHUB_OUTPUT
- uses: patrickedqvist/wait-for-vercel-preview@ae34b392ef30297f2b672f9afb3c329bde9bd487
- uses: patrickedqvist/wait-for-vercel-preview@bfdff514ff78a669f2536e9f4dd4ef5813a704a2
id: waitForTarball
with:
token: ${{ secrets.GITHUB_TOKEN }}
@@ -97,11 +97,21 @@ jobs:
if: matrix.runner != 'windows-latest'
run: echo | openssl s_client -showcerts -servername 'api.vercel.com' -connect 76.76.21.21:443
conclusion:
summary:
name: Summary
runs-on: ubuntu-latest
timeout-minutes: 5
if: always()
needs:
- test
runs-on: ubuntu-latest
name: E2E
steps:
- name: Done
run: echo "Done."
- name: Check All
run: |-
for status in ${{ join(needs.*.result, ' ') }}
do
if [ "$status" != "success" ] && [ "$status" != "skipped" ]
then
echo "Some checks failed"
exit 1
fi
done

View File

@@ -12,6 +12,7 @@ packages/gatsby-plugin-vercel-analytics
node_modules
dist
pnpm-lock.yaml
.changeset
.vscode
.DS_Store
.next
@@ -31,4 +32,4 @@ packages/**/test/fixtures
packages/**/test/dev/fixtures
packages/**/test/build-fixtures
packages/**/test/cache-fixtures
packages/cli/src/util/dev/templates/*.ts

View File

@@ -19,9 +19,7 @@
## Vercel
Vercel is the platform for frontend developers, providing the speed and reliability innovators need to create at the moment of inspiration.
We enable teams to iterate quickly and develop, preview, and ship delightful user experiences. Vercel has zero-configuration support for 35+ frontend frameworks and integrates with your headless content, commerce, or database of choice.
Vercel's frontend cloud gives developers frameworks, workflows, and infrastructure to build a faster, more personalized web.
## Deploy

View File

@@ -4,7 +4,7 @@
You ran `vercel dev` inside a project that contains a `vercel.json` file with `env` or `build.env` properties that use [Vercel Secrets](https://vercel.com/docs/concepts/projects/environment-variables).
In order to use environment variables in your project locally that have values defined using the Vercel Secrets format (e.g. `@my-secret-value`), you will need to provide the value as an environment variable using a `.env`.
In order to use environment variables in your project locally that have values defined using the Vercel Secrets format (e.g. `@my-secret-value`), you will need to provide the value as an environment variable using a `.env.local`.
We require this to ensure your app works as you intend it to, in the development environment, and to provide you with a way to mirror or separate private environment variables within your applications, for example when connecting to a database.
@@ -12,11 +12,11 @@ Read below for how to address this error.
#### Possible Ways to Fix It
The error message will list environment variables that are required and which file they are required to be included in `.env`.
The error message will list environment variables that are required and which file they are required to be included in `.env.local`.
If the file does not exist yet, please create the file that the error message mentions and insert the missing environment variable into it.
For example, if the error message shows that the environment variable `TEST` is missing from `.env`, then the `.env` file should look like this:
For example, if the error message shows that the environment variable `TEST` is missing from `.env.local`, then the `.env.local` file should look like this:
```
TEST=value

View File

@@ -14,11 +14,7 @@ pnpm dev
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file.
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -0,0 +1,17 @@
import './globals.css'
import { Inter } from 'next/font/google'
const inter = Inter({ subsets: ['latin'] })
export const metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
}
export default function RootLayout({ children }) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
</html>
)
}

View File

@@ -0,0 +1,95 @@
import Image from 'next/image'
import styles from './page.module.css'
export default function Home() {
return (
<main className={styles.main}>
<div className={styles.description}>
<p>
Get started by editing&nbsp;
<code className={styles.code}>app/page.js</code>
</p>
<div>
<a
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
By{' '}
<Image
src="/vercel.svg"
alt="Vercel Logo"
className={styles.vercelLogo}
width={100}
height={24}
priority
/>
</a>
</div>
</div>
<div className={styles.center}>
<Image
className={styles.logo}
src="/next.svg"
alt="Next.js Logo"
width={180}
height={37}
priority
/>
</div>
<div className={styles.grid}>
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Docs <span>-&gt;</span>
</h2>
<p>Find in-depth information about Next.js features and API.</p>
</a>
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Learn <span>-&gt;</span>
</h2>
<p>Learn about Next.js in an interactive course with&nbsp;quizzes!</p>
</a>
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Templates <span>-&gt;</span>
</h2>
<p>Explore the Next.js 13 playground.</p>
</a>
<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Deploy <span>-&gt;</span>
</h2>
<p>
Instantly deploy your Next.js site to a shareable URL with Vercel.
</p>
</a>
</div>
</main>
)
}

View File

@@ -1,6 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}
const nextConfig = {}
module.exports = nextConfig

File diff suppressed because it is too large Load Diff

View File

@@ -9,9 +9,9 @@
"lint": "next lint"
},
"dependencies": {
"eslint": "8.39.0",
"eslint-config-next": "13.3.4",
"next": "13.3.4",
"eslint": "8.41.0",
"eslint-config-next": "13.4.4",
"next": "13.4.4",
"react": "18.2.0",
"react-dom": "18.2.0"
}

View File

@@ -1,5 +0,0 @@
import '@/styles/globals.css'
export default function App({ Component, pageProps }) {
return <Component {...pageProps} />
}

View File

@@ -1,13 +0,0 @@
import { Html, Head, Main, NextScript } from 'next/document'
export default function Document() {
return (
<Html lang="en">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}

View File

@@ -1,5 +0,0 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
export default function handler(req, res) {
res.status(200).json({ name: 'John Doe' })
}

View File

@@ -1,114 +0,0 @@
import Head from 'next/head'
import Image from 'next/image'
import { Inter } from 'next/font/google'
import styles from '@/styles/Home.module.css'
const inter = Inter({ subsets: ['latin'] })
export default function Home() {
return (
<>
<Head>
<title>Create Next App</title>
<meta name="description" content="Generated by create next app" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={`${styles.main} ${inter.className}`}>
<div className={styles.description}>
<p>
Get started by editing&nbsp;
<code className={styles.code}>pages/index.js</code>
</p>
<div>
<a
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
By{' '}
<Image
src="/vercel.svg"
alt="Vercel Logo"
className={styles.vercelLogo}
width={100}
height={24}
priority
/>
</a>
</div>
</div>
<div className={styles.center}>
<Image
className={styles.logo}
src="/next.svg"
alt="Next.js Logo"
width={180}
height={37}
priority
/>
</div>
<div className={styles.grid}>
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Docs <span>-&gt;</span>
</h2>
<p>
Find in-depth information about Next.js features and&nbsp;API.
</p>
</a>
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Learn <span>-&gt;</span>
</h2>
<p>
Learn about Next.js in an interactive course with&nbsp;quizzes!
</p>
</a>
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Templates <span>-&gt;</span>
</h2>
<p>
Discover and deploy boilerplate example Next.js&nbsp;projects.
</p>
</a>
<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Deploy <span>-&gt;</span>
</h2>
<p>
Instantly deploy your Next.js site to a shareable URL
with&nbsp;Vercel.
</p>
</a>
</div>
</main>
</>
)
}

View File

@@ -9,6 +9,6 @@
},
"devDependencies": {
"@types/jest": "27.4.1",
"@vercel/frameworks": "1.3.0"
"@vercel/frameworks": "1.4.2"
}
}

View File

@@ -1,14 +1,14 @@
{
"private": true,
"scripts": {
"build": "preact build",
"build": "NODE_OPTIONS=--openssl-legacy-provider preact build",
"serve": "sirv build --port 8080 --cors --single",
"dev": "preact watch",
"lint": "eslint src",
"test": "jest"
},
"engines": {
"node": "16.x"
"node": "18.x"
},
"eslintConfig": {
"extends": "preact",
@@ -17,19 +17,19 @@
]
},
"devDependencies": {
"enzyme": "^3.10.0",
"enzyme-adapter-preact-pure": "^2.0.0",
"eslint": "^6.0.1",
"eslint-config-preact": "^1.1.0",
"jest": "^24.9.0",
"jest-preset-preact": "^1.0.0",
"preact-cli": "^3.0.0",
"sirv-cli": "1.0.3"
"enzyme": "^3.11.0",
"enzyme-adapter-preact-pure": "^4.1.0",
"eslint": "^8.41.0",
"eslint-config-preact": "^1.3.0",
"jest": "^29.5.0",
"jest-preset-preact": "^4.0.4",
"preact-cli": "^3.4.5",
"sirv-cli": "2.0.2"
},
"dependencies": {
"preact": "^10.3.2",
"preact-render-to-string": "^5.1.4",
"preact-router": "^3.2.1"
"preact": "^10.15.0",
"preact-render-to-string": "6.0.3",
"preact-router": "^4.1.1"
},
"jest": {
"preset": "jest-preset-preact",

File diff suppressed because it is too large Load Diff

View File

@@ -7,18 +7,18 @@
"type": "module",
"private": true,
"devDependencies": {
"solid-start-vercel": "^0.2.0",
"typescript": "^4.8.3",
"vite": "^3.1.0"
"solid-start-vercel": "^0.2.26",
"typescript": "^5.0.4",
"vite": "^4.3.8"
},
"dependencies": {
"@solidjs/meta": "^0.28.2",
"@solidjs/router": "^0.5.0",
"solid-js": "^1.6.0",
"solid-start": "^0.2.0",
"undici": "^5.11.0"
"@solidjs/meta": "^0.28.5",
"@solidjs/router": "^0.8.2",
"solid-js": "^1.7.5",
"solid-start": "^0.2.26",
"undici": "^5.22.1"
},
"engines": {
"node": "16.x"
"node": "18.x"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,10 @@
module.exports = {
root: true,
extends: ['eslint:recommended', 'prettier'],
plugins: ['svelte3'],
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
extends: ['eslint:recommended', 'plugin:svelte/recommended', 'prettier'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
},
env: {
browser: true,

View File

@@ -1 +1,2 @@
engine-strict=true
resolution-mode=highest

View File

@@ -1,18 +1,12 @@
# create-svelte
# SvelteKit Demo app
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
The official demo app for SvelteKit, hosted on Vercel.
## Creating a project
## Deploy Your Own
If you're seeing this, you've probably already done this step. Congrats!
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fvercel%2Ftree%2Fmain%2Fexamples%2Fsveltekit-1&project-name=sveltekit-vercel&repository-name=sveltekit-vercel&demo-title=SvelteKit%20%2B%20Vercel&demo-url=https%3A%2F%2Fsveltekit-template.vercel.app%2F)
```bash
# create a new project in the current directory
npm create svelte@latest
# create a new project in my-app
npm create svelte@latest my-app
```
_Live Example: https://sveltekit-template.vercel.app_
## Developing
@@ -35,4 +29,8 @@ npm run build
You can preview the production build with `npm run preview`.
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
## Speed Insights
Once deployed on Vercel, you can benefit from [Speed Insights](https://vercel.com/docs/concepts/speed-insights) simply by navigating to Vercel's dashboard, clicking on the 'Speed Insights' tab, and enabling the product.
You will get data once your application will be re-deployed and will receive visitors.

View File

@@ -16,19 +16,20 @@
"@fontsource/fira-mono": "^4.5.10",
"@neoconfetti/svelte": "^1.0.0",
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-vercel": "^1.0.0",
"@sveltejs/kit": "^1.0.0",
"@sveltejs/adapter-vercel": "^3.0.0",
"@sveltejs/kit": "^1.5.0",
"@types/cookie": "^0.5.1",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-svelte3": "^4.0.0",
"eslint-plugin-svelte": "^2.26.0",
"prettier": "^2.8.0",
"prettier-plugin-svelte": "^2.8.1",
"svelte": "^3.54.0",
"svelte-check": "^2.9.2",
"typescript": "^4.9.3",
"vite": "^4.0.0",
"vitest": "^0.25.3"
"svelte-check": "^3.0.1",
"typescript": "^5.0.0",
"vite": "^4.3.0",
"vitest": "^0.25.3",
"web-vitals": "^3.3.1"
},
"type": "module"
}

View File

@@ -4,7 +4,8 @@ const config = {
command: 'npm run build && npm run preview',
port: 4173
},
testDir: 'tests'
testDir: 'tests',
testMatch: /(.+\.)?(test|spec)\.[jt]s/
};
export default config;

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,12 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
// and what to do when importing types
declare namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface Platform {}
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface Platform {}
}
}
export {};

View File

@@ -0,0 +1,63 @@
import { onCLS, onFCP, onFID, onLCP, onTTFB } from 'web-vitals';
const vitalsUrl = 'https://vitals.vercel-analytics.com/v1/vitals';
function getConnectionSpeed() {
// @ts-ignore
return navigator?.connection?.effectiveType ?? '';
}
/**
* @param {import("web-vitals").Metric} metric
* @param {{ params: { [s: string]: any; } | ArrayLike<any>; path: string; analyticsId: string; debug: boolean; }} options
*/
function sendToAnalytics(metric, options) {
const page = Object.entries(options.params).reduce(
(acc, [key, value]) => acc.replace(value, `[${key}]`),
options.path
);
const body = {
dsn: options.analyticsId,
id: metric.id,
page,
href: location.href,
event_name: metric.name,
value: metric.value.toString(),
speed: getConnectionSpeed()
};
if (options.debug) {
console.log('[Web Vitals]', metric.name, JSON.stringify(body, null, 2));
}
const blob = new Blob([new URLSearchParams(body).toString()], {
// This content type is necessary for `sendBeacon`
type: 'application/x-www-form-urlencoded'
});
if (navigator.sendBeacon) {
navigator.sendBeacon(vitalsUrl, blob);
} else
fetch(vitalsUrl, {
body: blob,
method: 'POST',
credentials: 'omit',
keepalive: true
});
}
/**
* @param {any} options
*/
export function webVitals(options) {
try {
console.log(`[Web Vitals] for page ${options.path}`);
onFID((metric) => sendToAnalytics(metric, options));
onTTFB((metric) => sendToAnalytics(metric, options));
onLCP((metric) => sendToAnalytics(metric, options));
onCLS((metric) => sendToAnalytics(metric, options));
onFCP((metric) => sendToAnalytics(metric, options));
} catch (err) {
console.error(`[Web Vitals] for page ${options.path}`, err);
}
}

View File

@@ -0,0 +1,6 @@
import { env } from '$env/dynamic/private';
/** @type {import('./$types').LayoutServerLoad} */
export function load() {
return { analyticsId: env.VERCEL_ANALYTICS_ID };
}

View File

@@ -1,6 +1,20 @@
<script>
import { browser } from '$app/environment';
import { page } from '$app/stores';
import { webVitals } from '$lib/vitals';
import Header from './Header.svelte';
import './styles.css';
/** @type {import('./$types').LayoutServerData} */
export let data;
$: if (browser && data?.analyticsId) {
webVitals({
path: $page.url.pathname,
params: $page.params,
analyticsId: data.analyticsId
});
}
</script>
<div class="app">

View File

@@ -107,11 +107,11 @@
<a class="how-to-play" href="/sverdle/how-to-play">How to play</a>
<div class="grid" class:playing={!won} class:bad-guess={form?.badGuess}>
{#each Array(6) as _, row}
{#each Array.from(Array(6).keys()) as row (row)}
{@const current = row === i}
<h2 class="visually-hidden">Row {row + 1}</h2>
<div class="row" class:current>
{#each Array(5) as _, column}
{#each Array.from(Array(5).keys()) as column (column)}
{@const answer = data.answers[row]?.[column]}
{@const value = data.guesses[row]?.[column] ?? ''}
{@const selected = current && column === data.guesses[row].length}

View File

@@ -2,5 +2,5 @@ import { expect, test } from '@playwright/test';
test('about page has expected h1', async ({ page }) => {
await page.goto('/about');
expect(await page.textContent('h1')).toBe('About this app');
await expect(page.getByRole('heading', { name: 'About this app' })).toBeVisible();
});

View File

@@ -1,11 +1,9 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';
/** @type {import('vite').UserConfig} */
const config = {
export default defineConfig({
plugins: [sveltekit()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
}
};
export default config;
});

View File

@@ -6,20 +6,20 @@
"lint": "vue-cli-service lint"
},
"engines": {
"node": "16.x"
"node": "18.x"
},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^3.0.0"
"core-js": "^3.30.2",
"vue": "^3.3.4"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^7.0.0"
"@vue/cli-plugin-babel": "~5.0.8",
"@vue/cli-plugin-eslint": "~5.0.8",
"@vue/cli-service": "~5.0.8",
"@vue/compiler-sfc": "^3.3.4",
"@babel/eslint-parser": "^7.21.8",
"eslint": "^8.4.1",
"eslint-plugin-vue": "^9.14.0"
},
"eslintConfig": {
"root": true,
@@ -31,7 +31,7 @@
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
"parser": "@babel/eslint-parser"
},
"rules": {}
},

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
# @vercel-internals/constants
## 1.0.1
### Patch Changes
- Updated dependencies [[`c7bcea408`](https://github.com/vercel/vercel/commit/c7bcea408131df2d65338e50ce319a6d8e4a8a82)]:
- @vercel/build-utils@6.7.4

View File

@@ -1,17 +1,18 @@
{
"private": true,
"name": "@vercel-internals/constants",
"version": "1.0.1",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"scripts": {
"build": "tsc -p tsconfig.json"
},
"dependencies": {
"@vercel/build-utils": "6.3.2",
"@vercel/routing-utils": "2.1.10"
"@vercel/build-utils": "6.7.4",
"@vercel/routing-utils": "2.2.1"
},
"devDependencies": {
"@vercel-internals/tsconfig": "*",
"@vercel-internals/tsconfig": "1.0.0",
"@vercel/style-guide": "4.0.2",
"typescript": "4.9.4"
}

View File

@@ -1,6 +1,7 @@
{
"private": true,
"name": "@vercel-internals/get-package-json",
"version": "1.0.0",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"files": [
@@ -14,7 +15,7 @@
"devDependencies": {
"@types/jest": "29.5.0",
"@types/node": "14.14.31",
"@vercel-internals/tsconfig": "*",
"@vercel-internals/tsconfig": "1.0.0",
"@vercel/style-guide": "4.0.2",
"jest": "29.5.0",
"ts-jest": "29.1.0",

View File

@@ -1,6 +1,7 @@
{
"private": true,
"name": "@vercel-internals/tsconfig",
"version": "1.0.0",
"description": "Node.js tsconfig file based on `@vercel/style-guide`",
"files": [
"tsconfig.json"

View File

@@ -0,0 +1,9 @@
# @vercel-internals/types
## 1.0.1
### Patch Changes
- Updated dependencies [[`c7bcea408`](https://github.com/vercel/vercel/commit/c7bcea408131df2d65338e50ce319a6d8e4a8a82)]:
- @vercel/build-utils@6.7.4
- @vercel-internals/constants@1.0.1

View File

@@ -157,6 +157,7 @@ export type Deployment = {
errorLink?: string;
errorMessage?: string | null;
errorStep?: string;
forced?: boolean;
functions?: BuilderFunctions | null;
gitSource?: {
org?: string;
@@ -183,6 +184,7 @@ export type Deployment = {
ownerId?: string;
plan?: 'enterprise' | 'hobby' | 'oss' | 'pro';
previewCommentsEnabled?: boolean;
private?: boolean;
projectId?: string;
projectSettings?: {
buildCommand?: string | null;
@@ -353,7 +355,7 @@ export interface Project extends ProjectSettings {
link?: ProjectLinkData;
alias?: ProjectAliasTarget[];
latestDeployments?: Partial<Deployment>[];
lastRollbackTarget: RollbackTarget | null;
lastAliasRequest?: LastAliasRequest | null;
}
export interface Org {
@@ -363,8 +365,19 @@ export interface Org {
}
export interface ProjectLink {
/**
* ID of the Vercel Project.
*/
projectId: string;
/**
* User or Team ID of the owner of the Vercel Project.
*/
orgId: string;
/**
* When linked as a repository, contains the absolute path
* to the root directory of the repository.
*/
repoRoot?: string;
}
export interface PaginationOptions {
@@ -374,7 +387,7 @@ export interface PaginationOptions {
}
export type ProjectLinkResult =
| { status: 'linked'; org: Org; project: Project }
| { status: 'linked'; org: Org; project: Project; repoRoot?: string }
| { status: 'not_linked'; org: null; project: null }
| {
status: 'error';
@@ -388,6 +401,9 @@ export type ProjectLinkResult =
| 'MISSING_PROJECT_SETTINGS';
};
/**
* @deprecated - `RollbackJobStatus` has been replace by `LastAliasRequest['jobStatus']`.
*/
export type RollbackJobStatus =
| 'pending'
| 'in-progress'
@@ -395,6 +411,10 @@ export type RollbackJobStatus =
| 'failed'
| 'skipped';
/**
* @deprecated - `RollbackTarget` has been renamed to `LastAliasRequest` so it can
* be shared with "promote".
*/
export interface RollbackTarget {
fromDeploymentId: string;
jobStatus: RollbackJobStatus;
@@ -402,6 +422,14 @@ export interface RollbackTarget {
toDeploymentId: string;
}
export interface LastAliasRequest {
fromDeploymentId: string;
jobStatus: 'pending' | 'in-progress' | 'succeeded' | 'failed' | 'skipped';
requestedAt: number;
toDeploymentId: string;
type: 'rollback' | 'promote';
}
export interface Token {
id: string;
name: string;

View File

@@ -1,16 +1,17 @@
{
"private": true,
"name": "@vercel-internals/types",
"version": "1.0.1",
"types": "index.d.ts",
"main": "index.d.ts",
"dependencies": {
"@types/node": "14.14.31",
"@vercel-internals/constants": "*",
"@vercel/build-utils": "6.3.2",
"@vercel/routing-utils": "2.1.10"
"@vercel-internals/constants": "1.0.1",
"@vercel/build-utils": "6.7.4",
"@vercel/routing-utils": "2.2.1"
},
"devDependencies": {
"@vercel-internals/tsconfig": "*",
"@vercel-internals/tsconfig": "1.0.0",
"@vercel/style-guide": "4.0.2",
"typescript": "4.9.4"
}

View File

@@ -4,10 +4,9 @@
"private": true,
"license": "Apache-2.0",
"packageManager": "pnpm@8.3.1",
"dependencies": {
"lerna": "5.6.2"
},
"devDependencies": {
"@changesets/cli": "2.26.1",
"@svitejs/changesets-changelog-github-compact": "1.1.0",
"@types/node": "14.18.33",
"@typescript-eslint/eslint-plugin": "5.21.0",
"@typescript-eslint/parser": "5.21.0",
@@ -22,6 +21,7 @@
"eslint-plugin-jest": "26.1.5",
"execa": "3.2.0",
"fs-extra": "11.1.0",
"glob": "10.2.3",
"husky": "7.0.4",
"jest": "29.5.0",
"json5": "2.1.1",
@@ -32,16 +32,10 @@
"source-map-support": "0.5.12",
"ts-eager": "2.0.2",
"ts-jest": "29.1.0",
"typescript": "4.9.5",
"turbo": "1.9.3"
"turbo": "1.9.9",
"typescript": "4.9.5"
},
"scripts": {
"lerna": "lerna",
"version": "pnpm install && git add pnpm-lock.yaml",
"bootstrap": "lerna bootstrap",
"publish-stable": "echo 'Run `pnpm changelog` for instructions'",
"publish-from-github": "./utils/publish.sh",
"changelog": "node utils/changelog.js",
"build": "node utils/gen.js && turbo --no-update-notifier run build",
"vercel-build": "pnpm build && pnpm run pack && cd api && node -r ts-eager/register ./_lib/script/build.ts",
"pre-commit": "lint-staged",
@@ -53,7 +47,9 @@
"lint": "eslint . --cache --ext .ts,.js",
"prettier-check": "prettier --check .",
"prepare": "husky install",
"pack": "cd utils && node -r ts-eager/register ./pack.ts"
"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"
},
"lint-staged": {
"./{*,{api,packages,test,utils}/**/*}.{js,ts}": [

View File

@@ -0,0 +1,13 @@
# @vercel/build-utils
## 6.7.4
### Patch Changes
- Remove usage of `env` from Edge Functions and Middleware ([#10018](https://github.com/vercel/vercel/pull/10018))
## 6.7.3
### Patch Changes
- Deprecate Node.js 14.x and 16.x with warning ([#9976](https://github.com/vercel/vercel/pull/9976))

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/build-utils",
"version": "6.7.2",
"version": "6.7.4",
"license": "Apache-2.0",
"main": "./dist/index.js",
"types": "./dist/index.d.js",

View File

@@ -27,12 +27,6 @@ export class EdgeFunction {
*/
files: Files;
/**
* Extra environment variables in use for the user code, to be
* assigned to the edge function.
*/
envVarsInUse?: string[];
/**
* Extra binary files to be included in the edge function
*/
@@ -50,7 +44,6 @@ export class EdgeFunction {
this.deploymentTarget = params.deploymentTarget;
this.entrypoint = params.entrypoint;
this.files = params.files;
this.envVarsInUse = params.envVarsInUse;
this.assets = params.assets;
this.regions = params.regions;
this.framework = params.framework;

View File

@@ -6,8 +6,18 @@ import debug from '../debug';
function getOptions() {
const options = [
{ major: 18, range: '18.x', runtime: 'nodejs18.x' },
{ major: 16, range: '16.x', runtime: 'nodejs16.x' },
{ major: 14, range: '14.x', runtime: 'nodejs14.x' },
{
major: 16,
range: '16.x',
runtime: 'nodejs16.x',
discontinueDate: new Date('2023-08-15'),
},
{
major: 14,
range: '14.x',
runtime: 'nodejs14.x',
discontinueDate: new Date('2023-08-15'),
},
{
major: 12,
range: '12.x',

View File

@@ -1,6 +1,6 @@
{
"private": true,
"engines": {
"node": "16.14.0"
"node": "18.2.0"
}
}

View File

@@ -1,6 +1,6 @@
{
"private": true,
"engines": {
"node": "14.x"
"node": "18.x"
}
}

View File

@@ -140,20 +140,20 @@ it('should ignore node version in vercel dev getNodeVersion()', async () => {
it('should select project setting from config when no package.json is found and fallback undefined', async () => {
expect(
await getNodeVersion('/tmp', undefined, { nodeVersion: '16.x' }, {})
).toHaveProperty('range', '16.x');
await getNodeVersion('/tmp', undefined, { nodeVersion: '18.x' }, {})
).toHaveProperty('range', '18.x');
expect(warningMessages).toStrictEqual([]);
});
it('should select project setting from config when no package.json is found and fallback is null', async () => {
expect(
await getNodeVersion('/tmp', null as any, { nodeVersion: '16.x' }, {})
).toHaveProperty('range', '16.x');
await getNodeVersion('/tmp', null as any, { nodeVersion: '18.x' }, {})
).toHaveProperty('range', '18.x');
expect(warningMessages).toStrictEqual([]);
});
it('should select project setting from fallback when no package.json is found', async () => {
expect(await getNodeVersion('/tmp', '16.x')).toHaveProperty('range', '16.x');
expect(await getNodeVersion('/tmp', '18.x')).toHaveProperty('range', '18.x');
expect(warningMessages).toStrictEqual([]);
});
@@ -165,9 +165,9 @@ it('should prefer package.json engines over project setting from config and warn
{ nodeVersion: '12.x' },
{}
)
).toHaveProperty('range', '14.x');
).toHaveProperty('range', '18.x');
expect(warningMessages).toStrictEqual([
'Warning: Due to "engines": { "node": "14.x" } in your `package.json` file, the Node.js Version defined in your Project Settings ("12.x") will not apply. Learn More: http://vercel.link/node-version',
'Warning: Due to "engines": { "node": "18.x" } in your `package.json` file, the Node.js Version defined in your Project Settings ("12.x") will not apply. Learn More: http://vercel.link/node-version',
]);
});
@@ -179,9 +179,9 @@ it('should warn when package.json engines is exact version', async () => {
{},
{}
)
).toHaveProperty('range', '16.x');
).toHaveProperty('range', '18.x');
expect(warningMessages).toStrictEqual([
'Warning: Detected "engines": { "node": "16.14.0" } in your `package.json` with major.minor.patch, but only major Node.js Version can be selected. Learn More: http://vercel.link/node-version',
'Warning: Detected "engines": { "node": "18.2.0" } in your `package.json` with major.minor.patch, but only major Node.js Version can be selected. Learn More: http://vercel.link/node-version',
]);
});
@@ -204,30 +204,30 @@ it('should not warn when package.json engines matches project setting from confi
await getNodeVersion(
path.join(__dirname, 'pkg-engine-node'),
undefined,
{ nodeVersion: '14' },
{ nodeVersion: '18' },
{}
)
).toHaveProperty('range', '14.x');
).toHaveProperty('range', '18.x');
expect(warningMessages).toStrictEqual([]);
expect(
await getNodeVersion(
path.join(__dirname, 'pkg-engine-node'),
undefined,
{ nodeVersion: '14.x' },
{ nodeVersion: '18.x' },
{}
)
).toHaveProperty('range', '14.x');
).toHaveProperty('range', '18.x');
expect(warningMessages).toStrictEqual([]);
expect(
await getNodeVersion(
path.join(__dirname, 'pkg-engine-node'),
undefined,
{ nodeVersion: '<15' },
{ nodeVersion: '<19' },
{}
)
).toHaveProperty('range', '14.x');
).toHaveProperty('range', '18.x');
expect(warningMessages).toStrictEqual([]);
});
@@ -238,7 +238,7 @@ it('should get latest node version', async () => {
it('should throw for discontinued versions', async () => {
// Mock a future date so that Node 8 and 10 become discontinued
const realDateNow = Date.now.bind(global.Date);
global.Date.now = () => new Date('2022-10-15').getTime();
global.Date.now = () => new Date('2023-10-01').getTime();
expect(getSupportedNodeVersion('8.10.x', false)).rejects.toThrow();
expect(getSupportedNodeVersion('8.10.x', true)).rejects.toThrow();
@@ -246,12 +246,18 @@ it('should throw for discontinued versions', async () => {
expect(getSupportedNodeVersion('10.x', true)).rejects.toThrow();
expect(getSupportedNodeVersion('12.x', false)).rejects.toThrow();
expect(getSupportedNodeVersion('12.x', true)).rejects.toThrow();
expect(getSupportedNodeVersion('14.x', false)).rejects.toThrow();
expect(getSupportedNodeVersion('14.x', true)).rejects.toThrow();
expect(getSupportedNodeVersion('16.x', false)).rejects.toThrow();
expect(getSupportedNodeVersion('16.x', true)).rejects.toThrow();
const discontinued = getDiscontinuedNodeVersions();
expect(discontinued.length).toBe(3);
expect(discontinued[0]).toHaveProperty('range', '12.x');
expect(discontinued[1]).toHaveProperty('range', '10.x');
expect(discontinued[2]).toHaveProperty('range', '8.10.x');
expect(discontinued.length).toBe(5);
expect(discontinued[0]).toHaveProperty('range', '16.x');
expect(discontinued[1]).toHaveProperty('range', '14.x');
expect(discontinued[2]).toHaveProperty('range', '12.x');
expect(discontinued[3]).toHaveProperty('range', '10.x');
expect(discontinued[4]).toHaveProperty('range', '8.10.x');
global.Date.now = realDateNow;
});
@@ -277,11 +283,31 @@ it('should warn for deprecated versions, soon to be discontinued', async () => {
'major',
12
);
expect(await getSupportedNodeVersion('14.x', false)).toHaveProperty(
'major',
14
);
expect(await getSupportedNodeVersion('14.x', true)).toHaveProperty(
'major',
14
);
expect(await getSupportedNodeVersion('16.x', false)).toHaveProperty(
'major',
16
);
expect(await getSupportedNodeVersion('16.x', true)).toHaveProperty(
'major',
16
);
expect(warningMessages).toStrictEqual([
'Error: Node.js version 10.x has reached End-of-Life. Deployments created on or after 2021-04-20 will fail to build. Please set "engines": { "node": "18.x" } in your `package.json` file to use Node.js 18.',
'Error: Node.js version 10.x has reached End-of-Life. Deployments created on or after 2021-04-20 will fail to build. Please set Node.js Version to 18.x in your Project Settings to use Node.js 18.',
'Error: Node.js version 12.x has reached End-of-Life. Deployments created on or after 2022-10-03 will fail to build. Please set "engines": { "node": "18.x" } in your `package.json` file to use Node.js 18.',
'Error: Node.js version 12.x has reached End-of-Life. Deployments created on or after 2022-10-03 will fail to build. Please set Node.js Version to 18.x in your Project Settings to use Node.js 18.',
'Error: Node.js version 14.x has reached End-of-Life. Deployments created on or after 2023-08-15 will fail to build. Please set "engines": { "node": "18.x" } in your `package.json` file to use Node.js 18.',
'Error: Node.js version 14.x has reached End-of-Life. Deployments created on or after 2023-08-15 will fail to build. Please set Node.js Version to 18.x in your Project Settings to use Node.js 18.',
'Error: Node.js version 16.x has reached End-of-Life. Deployments created on or after 2023-08-15 will fail to build. Please set "engines": { "node": "18.x" } in your `package.json` file to use Node.js 18.',
'Error: Node.js version 16.x has reached End-of-Life. Deployments created on or after 2023-08-15 will fail to build. Please set Node.js Version to 18.x in your Project Settings to use Node.js 18.',
]);
global.Date.now = realDateNow;

105
packages/cli/CHANGELOG.md Normal file
View File

@@ -0,0 +1,105 @@
# vercel
## 30.1.0
### Minor Changes
- New `vc promote` command ([#9984](https://github.com/vercel/vercel/pull/9984))
### Patch Changes
- Support `deploy` subcommand in "repo linked" mode ([#10013](https://github.com/vercel/vercel/pull/10013))
- [cli] Update `vc rollback` to use `lastRequestAlias` instead of `lastRollbackTarget` ([#10019](https://github.com/vercel/vercel/pull/10019))
- Fix `--cwd` flag with a relative path for `env`, `link`, `promote`, and `rollback` subcommands ([#10031](https://github.com/vercel/vercel/pull/10031))
- Updated dependencies [[`c6c19354e`](https://github.com/vercel/vercel/commit/c6c19354e852cfc1338b223058c4b07fdc71c723), [`b56ac2717`](https://github.com/vercel/vercel/commit/b56ac2717d6769eb400f9746f0a05431929b4501), [`c63679ea0`](https://github.com/vercel/vercel/commit/c63679ea0a6bc48c0759ccf3c0c0a8106bd324f0), [`c7bcea408`](https://github.com/vercel/vercel/commit/c7bcea408131df2d65338e50ce319a6d8e4a8a82)]:
- @vercel/next@3.8.6
- @vercel/build-utils@6.7.4
- @vercel/node@2.14.4
- @vercel/remix-builder@1.8.11
- @vercel/static-build@1.3.33
## 30.0.0
### Major Changes
- Change `vc env pull` default output file to `.env.local` ([#9892](https://github.com/vercel/vercel/pull/9892))
- Remove `--platform-version` global common arg ([#9807](https://github.com/vercel/vercel/pull/9807))
### Minor Changes
- [cli] implement `vc deploy --prod --skip-build` ([#9836](https://github.com/vercel/vercel/pull/9836))
- New `vc redeploy` command ([#9956](https://github.com/vercel/vercel/pull/9956))
### Patch Changes
- Fix `vercel git connect` command when passing a URL parameter ([#9967](https://github.com/vercel/vercel/pull/9967))
## 29.4.0
### Minor Changes
- Add `vercel link --repo` flag to link to repository (multiple projects), rather than an individual project (alpha) ([#8931](https://github.com/vercel/vercel/pull/8931))
## 29.3.6
### Patch Changes
- Updated dependencies []:
- @vercel/static-build@1.3.32
## 29.3.5
### Patch Changes
- Updated dependencies [[`2c950d47a`](https://github.com/vercel/vercel/commit/2c950d47aeb22a3de16f983259ea6f37a4555189), [`71b9f3a94`](https://github.com/vercel/vercel/commit/71b9f3a94b7922607f8f24bf7b2bd1742e62cc05), [`f00b08a82`](https://github.com/vercel/vercel/commit/f00b08a82085c3a63059f34f67f10ced92f2979c)]:
- @vercel/static-build@1.3.31
- @vercel/build-utils@6.7.3
- @vercel/next@3.8.5
- @vercel/node@2.14.3
- @vercel/remix-builder@1.8.10
## 29.3.4
### Patch Changes
- Updated dependencies [[`67e556bc8`](https://github.com/vercel/vercel/commit/67e556bc80c821c233120a2ec1611adb8e195baa), [`ba10fb4dd`](https://github.com/vercel/vercel/commit/ba10fb4dd4155a75df79b98a0c43a6c42eac7b62)]:
- @vercel/remix-builder@1.8.9
- @vercel/next@3.8.4
## 29.3.3
### Patch Changes
- Updated dependencies [[`6c6f3ce9d`](https://github.com/vercel/vercel/commit/6c6f3ce9d228b1e038641e4bafb38c3487e7dff7)]:
- @vercel/next@3.8.3
## 29.3.2
### Patch Changes
- [vc dev] Fix serverless function size limit condition ([#9961](https://github.com/vercel/vercel/pull/9961))
## 29.3.1
### Patch Changes
- Sort environment variables alphabetically in `vercel env pull` ([#9949](https://github.com/vercel/vercel/pull/9949))
- Skip 50MB zip size limit for Python ([#9944](https://github.com/vercel/vercel/pull/9944))
## 29.3.0
### Minor Changes
- [cli] remove `vc rollback` beta label ([#9928](https://github.com/vercel/vercel/pull/9928))
## 29.2.1
### Patch Changes
- Updated dependencies [[`6d5983eaa`](https://github.com/vercel/vercel/commit/6d5983eaaefe3fd2204f49c3228718ac64a452e3)]:
- @vercel/remix-builder@1.8.8

View File

@@ -10,9 +10,7 @@
## Usage
Vercel is the platform for frontend developers, providing the speed and reliability innovators need to create at the moment of inspiration.
We enable teams to iterate quickly and develop, preview, and ship delightful user experiences. Vercel has zero-configuration support for 35+ frontend frameworks and integrates with your headless content, commerce, or database of choice.
Vercel's frontend cloud gives developers frameworks, workflows, and infrastructure to build a faster, more personalized web.
To install the latest version of Vercel CLI, run this command:

View File

@@ -1,6 +1,6 @@
{
"name": "vercel",
"version": "29.1.1",
"version": "30.1.0",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Vercel",
@@ -32,19 +32,20 @@
"node": ">= 14"
},
"dependencies": {
"@vercel/build-utils": "6.7.2",
"@vercel/build-utils": "6.7.4",
"@vercel/go": "2.5.1",
"@vercel/hydrogen": "0.0.64",
"@vercel/next": "3.8.2",
"@vercel/node": "2.14.1",
"@vercel/next": "3.8.6",
"@vercel/node": "2.14.4",
"@vercel/python": "3.1.60",
"@vercel/redwood": "1.1.15",
"@vercel/remix-builder": "1.8.7",
"@vercel/remix-builder": "1.8.11",
"@vercel/ruby": "1.3.76",
"@vercel/static-build": "1.3.29"
"@vercel/static-build": "1.3.33"
},
"devDependencies": {
"@alex_neo/jest-expect-message": "1.0.5",
"@edge-runtime/node-utils": "2.0.3",
"@next/env": "11.1.2",
"@sentry/node": "5.5.0",
"@sindresorhus/slugify": "0.11.0",
@@ -81,16 +82,16 @@
"@types/title": "3.4.1",
"@types/universal-analytics": "0.4.2",
"@types/update-notifier": "5.1.0",
"@types/which": "1.3.2",
"@types/which": "3.0.0",
"@types/write-json-file": "2.2.1",
"@types/yauzl-promise": "2.1.0",
"@vercel-internals/constants": "*",
"@vercel-internals/get-package-json": "*",
"@vercel-internals/types": "*",
"@vercel/client": "12.4.12",
"@vercel-internals/constants": "1.0.1",
"@vercel-internals/get-package-json": "1.0.0",
"@vercel-internals/types": "1.0.1",
"@vercel/client": "12.6.1",
"@vercel/error-utils": "1.0.10",
"@vercel/frameworks": "1.4.1",
"@vercel/fs-detectors": "3.9.1",
"@vercel/frameworks": "1.4.2",
"@vercel/fs-detectors": "3.9.3",
"@vercel/fun": "1.0.4",
"@vercel/ncc": "0.24.0",
"@vercel/routing-utils": "2.2.1",
@@ -100,7 +101,7 @@
"ansi-escapes": "4.3.2",
"ansi-regex": "5.0.1",
"arg": "5.0.0",
"async-listen": "1.2.0",
"async-listen": "3.0.0",
"async-retry": "1.1.3",
"async-sema": "2.1.4",
"bytes": "3.0.0",
@@ -118,6 +119,7 @@
"escape-html": "1.0.3",
"esm": "3.1.4",
"execa": "3.2.0",
"expect": "29.5.0",
"express": "4.17.1",
"fast-deep-equal": "3.1.3",
"find-up": "4.1.0",
@@ -147,6 +149,8 @@
"pcre-to-regexp": "1.0.0",
"pluralize": "7.0.0",
"promisepipe": "3.0.0",
"proxy": "2.0.0",
"proxy-agent": "6.1.1",
"psl": "1.1.31",
"qr-image": "3.2.0",
"raw-body": "2.4.1",
@@ -165,6 +169,7 @@
"ts-node": "10.9.1",
"universal-analytics": "0.4.20",
"utility-types": "2.1.0",
"which": "3.0.0",
"write-json-file": "2.2.0",
"xdg-app-paths": "5.1.0",
"yauzl-promise": "2.1.3"

84
packages/cli/src/args.ts Normal file
View File

@@ -0,0 +1,84 @@
import chalk from 'chalk';
import logo from './util/output/logo';
import { getPkgName } from './util/pkg-name';
export const help = () => `
${chalk.bold(`${logo} ${getPkgName()}`)} [options] <command | path>
${chalk.dim('For deploy command help, run `vercel deploy --help`')}
${chalk.dim('Commands:')}
${chalk.dim('Basic')}
deploy [path] Performs a deployment ${chalk.bold(
'(default)'
)}
dev Start a local development server
env Manages the Environment Variables for your current Project
git Manage Git provider repository for your current Project
help [cmd] Displays complete help for [cmd]
init [example] Initialize an example project
inspect [id] Displays information related to a deployment
link [path] Link local directory to a Vercel Project
ls | list [app] Lists deployments
login [email] Logs into your account or creates a new one
logout Logs out of your account
promote [url|id] Promote an existing deployment to current
pull [path] Pull your Project Settings from the cloud
redeploy [url|id] Rebuild and deploy a previous deployment.
rollback [url|id] Quickly revert back to a previous deployment
switch [scope] Switches between teams and your personal account
${chalk.dim('Advanced')}
alias [cmd] Manages your domain aliases
bisect Use binary search to find the deployment that introduced a bug
certs [cmd] Manages your SSL certificates
dns [name] Manages your DNS records
domains [name] Manages your domain names
logs [url] Displays the logs for a deployment
projects Manages your Projects
rm | remove [id] Removes a deployment
secrets [name] Manages your global Secrets, for use in Environment Variables
teams Manages your teams
whoami Shows the username of the currently logged in user
${chalk.dim('Global Options:')}
-h, --help Output usage information
-v, --version Output the version number
--cwd Current working directory
-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]
-S, --scope Set a custom scope
-t ${chalk.underline('TOKEN')}, --token=${chalk.underline(
'TOKEN'
)} Login token
${chalk.dim('Examples:')}
${chalk.gray('')} Deploy the current directory
${chalk.cyan(`$ ${getPkgName()}`)}
${chalk.gray('')} Deploy a custom path
${chalk.cyan(`$ ${getPkgName()} /usr/src/project`)}
${chalk.gray('')} Deploy with Environment Variables
${chalk.cyan(`$ ${getPkgName()} -e NODE_ENV=production`)}
${chalk.gray('')} Show the usage information for the sub command ${chalk.dim(
'`list`'
)}
${chalk.cyan(`$ ${getPkgName()} help list`)}
`;

View File

@@ -133,7 +133,7 @@ const help = () => {
};
export default async function main(client: Client): Promise<number> {
const { output } = client;
const { cwd, output } = client;
// Ensure that `vc build` is not being invoked recursively
if (process.env.__VERCEL_BUILD_RUNNING) {
@@ -165,8 +165,6 @@ export default async function main(client: Client): Promise<number> {
return 2;
}
const cwd = process.cwd();
// Build `target` influences which environment variables will be used
const target = argv['--prod'] ? 'production' : 'preview';
const yes = Boolean(argv['--yes']);

View File

@@ -2,80 +2,27 @@ import chalk from 'chalk';
import logo from '../../util/output/logo';
import { getPkgName } from '../../util/pkg-name';
export const help = () => `
${chalk.bold(`${logo} ${getPkgName()}`)} [options] <command | path>
export const help = () => {
return `
${chalk.bold(`${logo} ${getPkgName()} [deploy]`)} [path-to-project] [options]
${chalk.dim('Commands:')}
${chalk.dim('Basic')}
deploy [path] Performs a deployment ${chalk.bold(
'(default)'
)}
dev Start a local development server
env Manages the Environment Variables for your current Project
git Manage Git provider repository for your current Project
help [cmd] Displays complete help for [cmd]
init [example] Initialize an example project
inspect [id] Displays information related to a deployment
link [path] Link local directory to a Vercel Project
ls | list [app] Lists deployments
login [email] Logs into your account or creates a new one
logout Logs out of your account
pull [path] Pull your Project Settings from the cloud
rollback [url|id] Quickly revert back to a previous deployment [beta]
switch [scope] Switches between teams and your personal account
${chalk.dim('Advanced')}
alias [cmd] Manages your domain aliases
bisect Use binary search to find the deployment that introduced a bug
certs [cmd] Manages your SSL certificates
dns [name] Manages your DNS records
domains [name] Manages your domain names
logs [url] Displays the logs for a deployment
projects Manages your Projects
rm | remove [id] Removes a deployment
secrets [name] Manages your global Secrets, for use in Environment Variables
teams Manages your teams
whoami Shows the username of the currently logged in user
${chalk.dim('Options:')}
-h, --help Output usage information
-v, --version Output the version number
--cwd Current working directory
-V, --platform-version Set the platform version to deploy to
-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]
-f, --force Force a new deployment even if nothing has changed
--with-cache Retain build cache when using "--force"
-t ${chalk.underline('TOKEN')}, --token=${chalk.underline(
'TOKEN'
)} Login token
-p, --public Deployment is public (${chalk.dim(
'`/_src`'
)} is exposed)
-e, --env Include an env var during run time (e.g.: ${chalk.dim(
'`-e KEY=value`'
)}). Can appear many times.
-b, --build-env Similar to ${chalk.dim(
'`--env`'
)} but for build time only.
-m, --meta Add metadata for the deployment (e.g.: ${chalk.dim(
'`-m KEY=value`'
)}). Can appear many times.
--no-wait Don't wait for the deployment to finish
-S, --scope Set a custom scope
--regions Set default regions to enable the deployment on
--prod Create a production deployment
-y, --yes Skip questions when setting up new project using default scope and settings
--prod Create a production deployment
-p, --public Deployment is public (${chalk.dim(
'`/_src`'
)} is exposed)
-e, --env Include an env var during run time (e.g.: ${chalk.dim(
'`-e KEY=value`'
)}). Can appear many times.
-b, --build-env Similar to ${chalk.dim(
'`--env`'
)} but for build time only.
-m, --meta Add metadata for the deployment (e.g.: ${chalk.dim(
'`-m KEY=value`'
)}). Can appear many times.
--no-wait Don't wait for the deployment to finish
-f, --force Force a new deployment even if nothing has changed
--with-cache Retain build cache when using "--force"
--regions Set default regions to enable the deployment on
${chalk.dim('Examples:')}
@@ -89,14 +36,15 @@ export const help = () => `
${chalk.gray('')} Deploy with Environment Variables
${chalk.cyan(
`$ ${getPkgName()} -e NODE_ENV=production -e SECRET=@mysql-secret`
)}
${chalk.cyan(`$ ${getPkgName()} -e NODE_ENV=production`)}
${chalk.gray('')} Show the usage information for the sub command ${chalk.dim(
'`list`'
)}
${chalk.gray('')} Deploy with prebuilt outputs
${chalk.cyan(`$ ${getPkgName()} help list`)}
${chalk.cyan(`$ ${getPkgName()} build`)}
${chalk.cyan(`$ ${getPkgName()} deploy --prebuilt`)}
${chalk.gray('')} Write Deployment URL to a file
${chalk.cyan(`$ ${getPkgName()} > deployment-url.txt`)}
`;
};

View File

@@ -2,7 +2,7 @@ import ms from 'ms';
import fs from 'fs-extra';
import bytes from 'bytes';
import chalk from 'chalk';
import { join, resolve, basename } from 'path';
import { join, resolve } from 'path';
import {
fileNameSymbol,
VALID_ARCHIVE_FORMATS,
@@ -21,7 +21,6 @@ import stamp from '../../util/output/stamp';
import createDeploy from '../../util/deploy/create-deploy';
import getDeployment from '../../util/get-deployment';
import parseMeta from '../../util/parse-meta';
import linkStyle from '../../util/output/link';
import param from '../../util/output/param';
import {
BuildsRateLimited,
@@ -59,7 +58,6 @@ import validatePaths, {
validateRootDirectory,
} from '../../util/validate-paths';
import { getCommandName } from '../../util/pkg-name';
import { getPreferredPreviewURL } from '../../util/deploy/get-preferred-preview-url';
import { Output } from '../../util/output';
import { help } from './args';
import { getDeploymentChecks } from '../../util/deploy/get-deployment-checks';
@@ -70,8 +68,7 @@ import { isValidArchive } from '../../util/deploy/validate-archive-format';
import { parseEnv } from '../../util/parse-env';
import { errorToString, isErrnoException, isError } from '@vercel/error-utils';
import { pickOverrides } from '../../util/projects/project-settings';
import { isDeploying } from '../../util/deploy/is-deploying';
import type { Deployment } from '@vercel-internals/types';
import { printDeploymentStatus } from '../../util/deploy/print-deployment-status';
export default async (client: Client): Promise<number> => {
const { output } = client;
@@ -93,6 +90,7 @@ export default async (client: Client): Promise<number> => {
'--prod': Boolean,
'--archive': String,
'--no-wait': Boolean,
'--skip-domain': Boolean,
'--yes': Boolean,
'-f': '--force',
'-p': '--public',
@@ -132,24 +130,19 @@ export default async (client: Client): Promise<number> => {
if (argv._.length > 0) {
// If path is relative: resolve
// if path is absolute: clear up strange `/` etc
paths = argv._.map(item => resolve(process.cwd(), item));
paths = argv._.map(item => resolve(client.cwd, item));
} else {
paths = [process.cwd()];
paths = [client.cwd];
}
// check paths
const pathValidation = await validatePaths(client, paths);
if (!pathValidation.valid) {
return pathValidation.exitCode;
}
let localConfig = client.localConfig || readLocalConfig(paths[0]);
for (const path of paths) {
try {
await fs.stat(path);
} catch (err) {
output.error(
`The specified file or directory "${basename(path)}" does not exist.`
);
return 1;
}
}
if (localConfig) {
const { version } = localConfig;
const file = highlight(localConfig[fileNameSymbol]!);
@@ -178,14 +171,7 @@ export default async (client: Client): Promise<number> => {
const quiet = !client.stdout.isTTY;
// check paths
const pathValidation = await validatePaths(client, paths);
if (!pathValidation.valid) {
return pathValidation.exitCode;
}
const { path } = pathValidation;
let { path: cwd } = pathValidation;
const autoConfirm = argv['--yes'];
// deprecate --name
@@ -219,7 +205,7 @@ export default async (client: Client): Promise<number> => {
// build `--prebuilt`
if (argv['--prebuilt']) {
const prebuiltExists = await fs.pathExists(join(path, '.vercel/output'));
const prebuiltExists = await fs.pathExists(join(cwd, '.vercel/output'));
if (!prebuiltExists) {
error(
`The ${param(
@@ -231,7 +217,7 @@ export default async (client: Client): Promise<number> => {
return 1;
}
const prebuiltBuild = await getPrebuiltJson(path);
const prebuiltBuild = await getPrebuiltJson(cwd);
// Ensure that there was not a build error
const prebuiltError =
@@ -274,7 +260,7 @@ export default async (client: Client): Promise<number> => {
}
// retrieve `project` and `org` from .vercel
const link = await getLinkedProject(client, path);
const link = await getLinkedProject(client, cwd);
if (link.status === 'error') {
return link.exitCode;
@@ -291,7 +277,7 @@ export default async (client: Client): Promise<number> => {
autoConfirm ||
(await confirm(
client,
`Set up and deploy ${chalk.cyan(`${toHumanPath(path)}`)}?`,
`Set up and deploy ${chalk.cyan(`${toHumanPath(cwd)}`)}?`,
true
));
@@ -338,7 +324,7 @@ export default async (client: Client): Promise<number> => {
if (typeof projectOrNewProjectName === 'string') {
newProjectName = projectOrNewProjectName;
rootDirectory = await inputRootDirectory(client, path, autoConfirm);
rootDirectory = await inputRootDirectory(client, cwd, autoConfirm);
} else {
project = projectOrNewProjectName;
rootDirectory = project.rootDirectory;
@@ -346,8 +332,8 @@ export default async (client: Client): Promise<number> => {
// we can already link the project
await linkFolderToProject(
output,
path,
client,
cwd,
{
projectId: project.id,
orgId: org.id,
@@ -359,6 +345,11 @@ export default async (client: Client): Promise<number> => {
}
}
// For repo-style linking, reset the path to the root of the repository
if (link.status === 'linked' && link.repoRoot) {
cwd = link.repoRoot;
}
// At this point `org` should be populated
if (!org) {
throw new Error(`"org" is not defined`);
@@ -373,14 +364,14 @@ export default async (client: Client): Promise<number> => {
// and upload the entire directory.
const sourcePath =
rootDirectory && !sourceFilesOutsideRootDirectory
? join(path, rootDirectory)
: path;
? join(cwd, rootDirectory)
: cwd;
if (
rootDirectory &&
(await validateRootDirectory(
output,
path,
cwd,
sourcePath,
project
? `To change your Project Settings, go to https://vercel.com/${org?.slug}/${project.name}/settings`
@@ -393,7 +384,7 @@ export default async (client: Client): Promise<number> => {
// If Root Directory is used we'll try to read the config
// from there instead and use it if it exists.
if (rootDirectory) {
const rootDirectoryConfig = readLocalConfig(join(path, rootDirectory));
const rootDirectoryConfig = readLocalConfig(join(cwd, rootDirectory));
if (rootDirectoryConfig) {
debug(`Read local config from root directory (${rootDirectory})`);
@@ -469,7 +460,7 @@ export default async (client: Client): Promise<number> => {
parseMeta(argv['--meta'])
);
const gitMetadata = await createGitMeta(path, output, project);
const gitMetadata = await createGitMeta(cwd, output, project);
// Merge dotenv config, `env` from vercel.json, and `--env` / `-e` arguments
const deploymentEnv = Object.assign(
@@ -520,6 +511,8 @@ export default async (client: Client): Promise<number> => {
}
try {
const autoAssignCustomDomains = !argv['--skip-domain'];
const createArgs: CreateOptions = {
name,
env: deploymentEnv,
@@ -543,6 +536,7 @@ export default async (client: Client): Promise<number> => {
target,
skipAutoDetectionConfirmation: autoConfirm,
noWait,
autoAssignCustomDomains,
};
if (!localConfig.builds || localConfig.builds.length === 0) {
@@ -559,11 +553,11 @@ export default async (client: Client): Promise<number> => {
client,
now,
contextName,
[sourcePath],
sourcePath,
createArgs,
org,
!project,
path,
cwd,
archive
);
@@ -595,11 +589,11 @@ export default async (client: Client): Promise<number> => {
client,
now,
contextName,
[sourcePath],
sourcePath,
createArgs,
org,
false,
path
cwd
);
}
@@ -728,7 +722,7 @@ export default async (client: Client): Promise<number> => {
return 1;
}
return printDeploymentStatus(output, client, deployment, deployStamp, noWait);
return printDeploymentStatus(client, deployment, deployStamp, noWait);
};
function handleCreateDeployError(
@@ -835,112 +829,3 @@ const addProcessEnv = async (
}
}
};
const printDeploymentStatus = async (
output: Output,
client: Client,
{
readyState,
alias: aliasList,
aliasError,
target,
indications,
url: deploymentUrl,
aliasWarning,
}: {
readyState: Deployment['readyState'];
alias: string[];
aliasError: Error;
target: string;
indications: any;
url: string;
aliasWarning?: {
code: string;
message: string;
link?: string;
action?: string;
};
},
deployStamp: () => string,
noWait: boolean
) => {
indications = indications || [];
const isProdDeployment = target === 'production';
let isStillBuilding = false;
if (noWait) {
if (isDeploying(readyState)) {
isStillBuilding = true;
output.print(
prependEmoji(
'Note: Deployment is still processing...',
emoji('notice')
) + '\n'
);
}
}
if (!isStillBuilding && readyState !== 'READY') {
output.error(
`Your deployment failed. Please retry later. More: https://err.sh/vercel/deployment-error`
);
return 1;
}
if (aliasError) {
output.warn(
`Failed to assign aliases${
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) {
indications.push({
type: 'warning',
payload: aliasWarning.message,
link: aliasWarning.link,
action: aliasWarning.action,
});
}
const newline = '\n';
for (let indication of indications) {
const message =
prependEmoji(chalk.dim(indication.payload), emoji(indication.type)) +
newline;
let link = '';
if (indication.link)
link =
chalk.dim(
`${indication.action || 'Learn More'}: ${linkStyle(indication.link)}`
) + newline;
output.print(message + link);
}
return 0;
};

View File

@@ -26,7 +26,7 @@ const help = () => {
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]
pull [filename] Pull all Development Environment Variables from the cloud and write to a file [.env.local]
${chalk.dim('Options:')}
@@ -130,10 +130,9 @@ export default async function main(client: Client) {
return 2;
}
const cwd = argv['--cwd'] || process.cwd();
const subArgs = argv._.slice(1);
const { subcommand, args } = getSubcommand(subArgs, COMMAND_CONFIG);
const { output, config } = client;
const { cwd, output, config } = client;
const target = argv['--environment']?.toLowerCase() || 'development';
if (!isValidEnvTarget(target)) {

View File

@@ -67,7 +67,7 @@ export default async function pull(
}
// handle relative or absolute filename
const [filename = '.env'] = args;
const [filename = '.env.local'] = args;
const fullPath = resolve(cwd, filename);
const skipConfirmation = opts['--yes'];
const gitBranch = opts['--git-branch'];
@@ -122,8 +122,9 @@ export default async function pull(
const contents =
CONTENTS_PREFIX +
Object.entries(records)
.map(([key, value]) => `${key}="${escapeValue(value)}"`)
Object.keys(records)
.sort()
.map(key => `${key}="${escapeValue(records[key])}"`)
.join('\n') +
'\n';

View File

@@ -16,7 +16,6 @@ import {
parseRepoUrl,
printRemoteUrls,
} from '../../util/git/connect-git-provider';
import validatePaths from '../../util/validate-paths';
interface GitRepoCheckParams {
client: Client;
@@ -56,7 +55,7 @@ export default async function connect(
project: Project | undefined,
org: Org | undefined
) {
const { output } = client;
const { cwd, output } = client;
const confirm = Boolean(argv['--yes']);
const repoArg = argv._[1];
@@ -77,19 +76,11 @@ export default async function connect(
return 1;
}
let paths = [process.cwd()];
const validate = await validatePaths(client, paths);
if (!validate.valid) {
return validate.exitCode;
}
const { path } = validate;
const gitProviderLink = project.link;
client.config.currentTeam = org.type === 'team' ? org.id : undefined;
// get project from .git
const gitConfigPath = join(path, '.git/config');
const gitConfigPath = join(cwd, '.git/config');
const gitConfig = await parseGitConfig(gitConfigPath, output);
if (repoArg) {
@@ -116,7 +107,7 @@ export default async function connect(
confirm,
org,
project,
repoInfo: repoArg,
repoInfo: parsedUrlArg,
});
}

View File

@@ -6,7 +6,6 @@ import getInvalidSubcommand from '../../util/get-invalid-subcommand';
import handleError from '../../util/handle-error';
import logo from '../../util/output/logo';
import { getPkgName } from '../../util/pkg-name';
import validatePaths from '../../util/validate-paths';
import connect from './connect';
import disconnect from './disconnect';
@@ -81,16 +80,9 @@ export default async function main(client: Client) {
subcommand = argv._[0];
const args = argv._.slice(1);
const autoConfirm = Boolean(argv['--yes']);
const { output } = client;
const { cwd, output } = client;
let paths = [process.cwd()];
const pathValidation = await validatePaths(client, paths);
if (!pathValidation.valid) {
return pathValidation.exitCode;
}
const { path } = pathValidation;
const linkedProject = await ensureLink('git', client, path, { autoConfirm });
const linkedProject = await ensureLink('git', client, cwd, { autoConfirm });
if (typeof linkedProject === 'number') {
return linkedProject;
}

View File

@@ -26,7 +26,9 @@ export default new Map([
['ls', 'list'],
['project', 'project'],
['projects', 'project'],
['promote', 'promote'],
['pull', 'pull'],
['redeploy', 'redeploy'],
['remove', 'remove'],
['rm', 'remove'],
['rollback', 'rollback'],

View File

@@ -52,7 +52,7 @@ export default async function main(client: Client) {
try {
argv = getArgs(client.argv.slice(2), {
'--force': Boolean,
'-f': Boolean,
'-f': '--force',
});
args = getSubcommand(argv._.slice(1), COMMAND_CONFIG).args;
} catch (err) {

View File

@@ -35,7 +35,7 @@ export default async function init(
) {
const { output } = client;
const [name, dir] = args;
const force = opts['-f'] || opts['--force'];
const force = opts['--force'];
const examples = await fetchExampleList(client);

View File

@@ -2,8 +2,10 @@ import chalk from 'chalk';
import Client from '../../util/client';
import getArgs from '../../util/get-args';
import logo from '../../util/output/logo';
import cmd from '../../util/output/cmd';
import { getPkgName } from '../../util/pkg-name';
import { ensureLink } from '../../util/link/ensure-link';
import { ensureRepoLink } from '../../util/link/repo';
const help = () => {
console.log(`
@@ -12,6 +14,7 @@ const help = () => {
${chalk.dim('Options:')}
-h, --help Output usage information
-r, --repo Link multiple projects based on Git repository (alpha)
-A ${chalk.bold.underline('FILE')}, --local-config=${chalk.bold.underline(
'FILE'
)} Path to the local ${'`vercel.json`'} file
@@ -42,7 +45,14 @@ const help = () => {
${chalk.gray('')} Link a specific directory to a Vercel Project
${chalk.cyan(`$ ${getPkgName()} link /usr/src/project`)}
${chalk.cyan(`$ ${getPkgName()} link --cwd /path/to/project`)}
${chalk.gray('')} ${chalk.yellow(
'(alpha)'
)} Link to the current Git repository, allowing for multiple
Vercel Projects to be linked simultaneously (useful for monorepos)
${chalk.cyan(`$ ${getPkgName()} link --repo`)}
`);
};
@@ -52,6 +62,8 @@ export default async function main(client: Client) {
'-y': '--yes',
'--project': String,
'-p': '--project',
'--repo': Boolean,
'-r': '--repo',
// deprecated
'--confirm': Boolean,
@@ -68,17 +80,36 @@ export default async function main(client: Client) {
argv['--yes'] = argv['--confirm'];
}
const cwd = argv._[1] || process.cwd();
const yes = !!argv['--yes'];
const link = await ensureLink('link', client, cwd, {
autoConfirm: !!argv['--yes'],
forceDelete: true,
projectName: argv['--project'],
successEmoji: 'success',
});
if (typeof link === 'number') {
return link;
let cwd = argv._[1];
if (cwd) {
client.output.warn(
`The ${cmd('vc link <directory>')} syntax is deprecated, please use ${cmd(
`vc link --cwd ${cwd}`
)} instead`
);
} else {
cwd = client.cwd;
}
if (argv['--repo']) {
client.output.warn(
`The ${cmd('--repo')} flag is in alpha, please report issues`
);
await ensureRepoLink(client, cwd, yes);
} else {
const link = await ensureLink('link', client, cwd, {
autoConfirm: yes,
forceDelete: true,
projectName: argv['--project'],
successEmoji: 'success',
});
if (typeof link === 'number') {
return link;
}
}
return 0;
}

View File

@@ -15,7 +15,6 @@ import getCommandFlags from '../util/get-command-flags';
import { getPkgName, getCommandName } from '../util/pkg-name';
import Client from '../util/client';
import { Deployment } from '@vercel/client';
import validatePaths from '../util/validate-paths';
import { getLinkedProject } from '../util/projects/link';
import { ensureLink } from '../util/link/ensure-link';
import getScope from '../util/get-scope';
@@ -94,7 +93,7 @@ export default async function main(client: Client) {
return 1;
}
const { output, config } = client;
const { cwd, output, config } = client;
if ('--confirm' in argv) {
output.warn('`--confirm` is deprecated, please use `--yes` instead');
@@ -115,19 +114,10 @@ export default async function main(client: Client) {
const autoConfirm = !!argv['--yes'];
const prod = argv['--prod'] || false;
const meta = parseMeta(argv['--meta']);
let paths = [process.cwd()];
const pathValidation = await validatePaths(client, paths);
if (!pathValidation.valid) {
return pathValidation.exitCode;
}
const { path } = pathValidation;
// retrieve `project` and `org` from .vercel
let link = await getLinkedProject(client, path);
let link = await getLinkedProject(client, cwd);
if (link.status === 'error') {
return link.exitCode;
@@ -146,7 +136,7 @@ export default async function main(client: Client) {
// If there's no linked project and user doesn't pass `app` arg,
// prompt to link their current directory.
if (status === 'not_linked' && !app) {
const linkedProject = await ensureLink('list', client, path, {
const linkedProject = await ensureLink('list', client, cwd, {
autoConfirm,
link,
});

View File

@@ -0,0 +1,121 @@
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 { getPkgName } from '../../util/pkg-name';
import handleError from '../../util/handle-error';
import { isErrnoException } from '@vercel/error-utils';
import logo from '../../util/output/logo';
import ms from 'ms';
import requestPromote from './request-promote';
import promoteStatus from './status';
const help = () => {
console.log(`
${chalk.bold(`${logo} ${getPkgName()} 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(`$ ${getPkgName()} promote`)}
${chalk.cyan(`$ ${getPkgName()} promote status`)}
${chalk.cyan(`$ ${getPkgName()} promote status <project>`)}
${chalk.cyan(`$ ${getPkgName()} promote status --timeout 30s`)}
${chalk.gray('')} Promote a deployment using id or url
${chalk.cyan(`$ ${getPkgName()} promote <deployment id/url>`)}
`);
};
/**
* `vc promote` command
* @param {Client} client
* @returns {Promise<number>} Resolves an exit code; 0 on success
*/
export default async (client: Client): Promise<number> => {
let argv;
try {
argv = getArgs(client.argv.slice(2), {
'--timeout': String,
'--yes': Boolean,
'-y': '--yes',
});
} catch (err) {
handleError(err);
return 1;
}
if (argv['--help'] || argv._[0] === 'help') {
help();
return 2;
}
// validate the timeout
let timeout = argv['--timeout'];
if (timeout && ms(timeout) === undefined) {
client.output.error(`Invalid timeout "${timeout}"`);
return 1;
}
const actionOrDeployId = argv._[1] || 'status';
try {
if (actionOrDeployId === 'status') {
const project = await getProjectByCwdOrLink({
autoConfirm: Boolean(argv['--yes']),
client,
commandName: 'promote',
cwd: client.cwd,
projectNameOrId: argv._[2],
});
return await promoteStatus({
client,
project,
timeout,
});
}
return await requestPromote({
client,
deployId: actionOrDeployId,
timeout,
});
} catch (err) {
if (isErrnoException(err)) {
if (err.code === 'ERR_CANCELED') {
return 0;
}
if (err.code === 'ERR_INVALID_CWD' || err.code === 'ERR_LINK_PROJECT') {
// do not show the message
return 1;
}
}
client.output.prettyError(err);
return 1;
}
};

View File

@@ -0,0 +1,57 @@
import chalk from 'chalk';
import type Client from '../../util/client';
import { getCommandName } from '../../util/pkg-name';
import getProjectByDeployment from '../../util/projects/get-project-by-deployment';
import ms from 'ms';
import promoteStatus from './status';
/**
* Requests a promotion and waits for it complete.
* @param {Client} client - The Vercel client instance
* @param {string} deployId - The deployment name or id to promote
* @param {string} [timeout] - Time to poll for succeeded/failed state
* @returns {Promise<number>} Resolves an exit code; 0 on success
*/
export default async function requestPromote({
client,
deployId,
timeout,
}: {
client: Client;
deployId: string;
timeout?: string;
}): Promise<number> {
const { output } = client;
const { contextName, deployment, project } = await getProjectByDeployment({
client,
deployId,
output: client.output,
});
// request the promotion
await client.fetch(`/v9/projects/${project.id}/promote/${deployment.id}`, {
body: {}, // required
json: false,
method: 'POST',
});
if (timeout !== undefined && ms(timeout) === 0) {
output.log(
`Successfully requested promote of ${chalk.bold(project.name)} to ${
deployment.url
} (${deployment.id})`
);
output.log(`To check promote status, run ${getCommandName('promote')}.`);
return 0;
}
// check the status
return await promoteStatus({
client,
contextName,
deployment,
project,
timeout,
});
}

View File

@@ -0,0 +1,265 @@
import chalk from 'chalk';
import type Client from '../../util/client';
import type {
Deployment,
LastAliasRequest,
PaginationOptions,
Project,
} from '@vercel-internals/types';
import elapsed from '../../util/output/elapsed';
import formatDate from '../../util/format-date';
import getDeployment from '../../util/get-deployment';
import { getPkgName } from '../../util/pkg-name';
import getProjectByNameOrId from '../../util/projects/get-project-by-id-or-name';
import getScope from '../../util/get-scope';
import ms from 'ms';
import { ProjectNotFound } from '../../util/errors-ts';
import renderAliasStatus from '../../util/alias/render-alias-status';
import sleep from '../../util/sleep';
interface DeploymentAlias {
alias: {
alias: string;
deploymentId: string;
};
id: string;
status: 'completed' | 'in-progress' | 'pending' | 'failed';
}
interface AliasesResponse {
aliases: DeploymentAlias[];
pagination: PaginationOptions;
}
/**
* Continuously checks a deployment status until it has succeeded, failed, or
* taken longer than the timeout (default 3 minutes).
*
* @param {Client} client - The Vercel client instance
* @param {string} [contextName] - The scope name; if not specified, it will be
* extracted from the `client`
* @param {Deployment} [deployment] - Info about the deployment which is used
* to display different output following a promotion request
* @param {Project} project - Project info instance
* @param {string} [timeout] - Milliseconds to poll for succeeded/failed state
* @returns {Promise<number>} Resolves an exit code; 0 on success
*/
export default async function promoteStatus({
client,
contextName,
deployment,
project,
timeout = '3m',
}: {
client: Client;
contextName?: string;
deployment?: Deployment;
project: Project;
timeout?: string;
}): Promise<number> {
const { output } = client;
const recentThreshold = Date.now() - ms('3m');
const promoteTimeout = Date.now() + ms(timeout);
let counter = 0;
let spinnerMessage = deployment
? 'Promote in progress'
: `Checking promotion status of ${project.name}`;
if (!contextName) {
({ contextName } = await getScope(client));
}
try {
output.spinner(`${spinnerMessage}`);
// continuously loop until the promotion has explicitly succeeded, failed,
// or timed out
for (;;) {
const projectCheck = await getProjectByNameOrId(
client,
project.id,
project.accountId,
true
);
if (projectCheck instanceof ProjectNotFound) {
throw projectCheck;
}
const {
jobStatus,
requestedAt,
toDeploymentId,
type,
}: Partial<LastAliasRequest> = projectCheck.lastAliasRequest ?? {};
if (
!jobStatus ||
(jobStatus !== 'in-progress' && jobStatus !== 'pending')
) {
output.stopSpinner();
output.log(`${spinnerMessage}`);
}
if (
!jobStatus ||
!requestedAt ||
!toDeploymentId ||
requestedAt < recentThreshold
) {
output.log('No deployment promotion in progress');
return 0;
}
if (jobStatus === 'skipped' && type === 'promote') {
output.log('Promote deployment was skipped');
return 0;
}
if (jobStatus === 'succeeded') {
return await renderJobSucceeded({
client,
contextName,
performingPromote: !!deployment,
requestedAt,
project,
toDeploymentId,
});
}
if (jobStatus === 'failed') {
return await renderJobFailed({
client,
contextName,
deployment,
project,
toDeploymentId,
});
}
// lastly, if we're not pending/in-progress, then we don't know what
// the status is, so bail
if (jobStatus !== 'pending' && jobStatus !== 'in-progress') {
output.log(`Unknown promote deployment status "${jobStatus}"`);
return 1;
}
// check if we have been running for too long
if (requestedAt < recentThreshold || Date.now() >= promoteTimeout) {
output.log(
`The promotion exceeded its deadline - rerun ${chalk.bold(
`${getPkgName()} promote ${toDeploymentId}`
)} to try again`
);
return 1;
}
// if we've done our first poll and not rolling back, then print the
// requested at date/time
if (counter++ === 0 && !deployment) {
spinnerMessage += ` requested at ${formatDate(requestedAt)}`;
}
output.spinner(`${spinnerMessage}`);
await sleep(250);
}
} finally {
output.stopSpinner();
}
}
async function renderJobFailed({
client,
contextName,
deployment,
project,
toDeploymentId,
}: {
client: Client;
contextName: string;
deployment?: Deployment;
project: Project;
toDeploymentId: string;
}) {
const { output } = client;
try {
const name = (
deployment || (await getDeployment(client, contextName, toDeploymentId))
)?.url;
output.error(
`Failed to remap all aliases to the requested deployment ${name} (${toDeploymentId})`
);
} catch (e) {
output.error(
`Failed to remap all aliases to the requested deployment ${toDeploymentId}`
);
}
// aliases are paginated, so continuously loop until all of them have been
// fetched
let nextTimestamp;
for (;;) {
let url = `/v9/projects/${project.id}/promote/aliases?failedOnly=true&limit=20`;
if (nextTimestamp) {
url += `&until=${nextTimestamp}`;
}
const { aliases, pagination } = await client.fetch<AliasesResponse>(url);
for (const { alias, status } of aliases) {
output.log(
` ${renderAliasStatus(status).padEnd(11)} ${alias.alias} (${
alias.deploymentId
})`
);
}
if (pagination?.next) {
nextTimestamp = pagination.next;
} else {
break;
}
}
return 1;
}
async function renderJobSucceeded({
client,
contextName,
performingPromote,
project,
requestedAt,
toDeploymentId,
}: {
client: Client;
contextName: string;
performingPromote: boolean;
project: Project;
requestedAt: number;
toDeploymentId: string;
}) {
const { output } = client;
// attempt to get the new deployment url
let deploymentInfo = '';
try {
const deployment = await getDeployment(client, contextName, toDeploymentId);
deploymentInfo = `${chalk.bold(deployment.url)} (${toDeploymentId})`;
} catch (err: any) {
output.debug(
`Failed to get deployment url for ${toDeploymentId}: ${
err?.toString() || err
}`
);
deploymentInfo = chalk.bold(toDeploymentId);
}
const duration = performingPromote ? elapsed(Date.now() - requestedAt) : '';
output.log(
`Success! ${chalk.bold(
project.name
)} was promoted to ${deploymentInfo} ${duration}`
);
return 0;
}

View File

@@ -0,0 +1,204 @@
import chalk from 'chalk';
import { checkDeploymentStatus } from '@vercel/client';
import type Client from '../util/client';
import { emoji, prependEmoji } from '../util/emoji';
import getArgs from '../util/get-args';
import { getCommandName, getPkgName } from '../util/pkg-name';
import { getDeploymentByIdOrURL } from '../util/deploy/get-deployment-by-id-or-url';
import getScope from '../util/get-scope';
import handleError from '../util/handle-error';
import { isErrnoException } from '@vercel/error-utils';
import logo from '../util/output/logo';
import Now from '../util';
import { printDeploymentStatus } from '../util/deploy/print-deployment-status';
import stamp from '../util/output/stamp';
import ua from '../util/ua';
import type { VercelClientOptions } from '@vercel/client';
const help = () => {
console.log(`
${chalk.bold(
`${logo} ${getPkgName()} redeploy`
)} [deploymentId|deploymentName]
Rebuild and deploy 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]
--no-wait Don't wait for the redeploy to finish
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-y, --yes Skip questions when setting up new project using default scope and settings
${chalk.dim('Examples:')}
${chalk.gray('')} Rebuild and deploy an existing deployment using id or url
${chalk.cyan(`$ ${getPkgName()} redeploy my-deployment.vercel.app`)}
${chalk.gray('')} Write Deployment URL to a file
${chalk.cyan(
`$ ${getPkgName()} redeploy my-deployment.vercel.app > deployment-url.txt`
)}
`);
};
/**
* `vc redeploy` command
* @param {Client} client
* @returns {Promise<number>} Resolves an exit code; 0 on success
*/
export default async (client: Client): Promise<number> => {
let argv;
try {
argv = getArgs(client.argv.slice(2), {
'--no-wait': Boolean,
'--yes': Boolean,
'-y': '--yes',
});
} catch (err) {
handleError(err);
return 1;
}
if (argv['--help'] || argv._[0] === 'help') {
help();
return 2;
}
const { output } = client;
const deployIdOrUrl = argv._[1];
if (!deployIdOrUrl) {
output.error(
`Missing required deployment id or url: ${getCommandName(
`redeploy <deployment-id-or-url>`
)}`
);
return 1;
}
const { contextName } = await getScope(client);
const noWait = !!argv['--no-wait'];
try {
const fromDeployment = await getDeploymentByIdOrURL({
client,
contextName,
deployIdOrUrl,
});
const deployStamp = stamp();
output.spinner(`Redeploying project ${fromDeployment.id}`, 0);
let deployment = await client.fetch<any>(`/v13/deployments?forceNew=1`, {
body: {
deploymentId: fromDeployment.id,
meta: {
action: 'redeploy',
},
name: fromDeployment.name,
target: fromDeployment.target || 'production',
},
method: 'POST',
});
output.stopSpinner();
output.print(
`${prependEmoji(
`Inspect: ${chalk.bold(deployment.inspectorUrl)} ${deployStamp()}`,
emoji('inspect')
)}\n`
);
if (!client.stdout.isTTY) {
client.stdout.write(`https://${deployment.url}`);
}
if (!noWait) {
output.spinner(
deployment.readyState === 'QUEUED' ? 'Queued' : 'Building',
0
);
if (deployment.readyState === 'READY' && deployment.aliasAssigned) {
output.spinner('Completing', 0);
} else {
try {
const clientOptions: VercelClientOptions = {
agent: client.agent,
apiUrl: client.apiUrl,
debug: client.output.debugEnabled,
path: '', // unused by checkDeploymentStatus()
teamId: fromDeployment.team?.id,
token: client.authConfig.token!,
userAgent: ua,
};
for await (const event of checkDeploymentStatus(
deployment,
clientOptions
)) {
if (event.type === 'building') {
output.spinner('Building', 0);
} else if (
event.type === 'ready' &&
((event.payload as any).checksState
? (event.payload as any).checksState === 'completed'
: true)
) {
output.spinner('Completing', 0);
} else if (event.type === 'checks-running') {
output.spinner('Running Checks', 0);
} else if (
event.type === 'alias-assigned' ||
event.type === 'checks-conclusion-failed'
) {
output.stopSpinner();
deployment = event.payload;
break;
} else if (event.type === 'canceled') {
output.stopSpinner();
output.print('The deployment has been canceled.\n');
return 1;
} else if (event.type === 'error') {
output.stopSpinner();
const now = new Now({
client,
currentTeam: fromDeployment.team?.id,
});
const error = await now.handleDeploymentError(event.payload, {
env: {},
});
throw error;
}
}
} catch (err: unknown) {
output.prettyError(err);
process.exit(1);
}
}
}
return printDeploymentStatus(client, deployment, deployStamp, noWait);
} catch (err: unknown) {
output.prettyError(err);
if (isErrnoException(err) && err.code === 'ERR_INVALID_TEAM') {
output.error(
`Use ${chalk.bold('vc switch')} to change your current team`
);
}
return 1;
}
};

View File

@@ -1,20 +1,18 @@
import chalk from 'chalk';
import type Client from '../util/client';
import { ensureLink } from '../util/link/ensure-link';
import getArgs from '../util/get-args';
import { getPkgName } from '../util/pkg-name';
import handleError from '../util/handle-error';
import logo from '../util/output/logo';
import type Client from '../../util/client';
import getArgs from '../../util/get-args';
import getProjectByCwdOrLink from '../../util/projects/get-project-by-cwd-or-link';
import { getPkgName } from '../../util/pkg-name';
import handleError from '../../util/handle-error';
import { isErrnoException } from '@vercel/error-utils';
import logo from '../../util/output/logo';
import ms from 'ms';
import requestRollback from '../util/rollback/request-rollback';
import rollbackStatus from '../util/rollback/status';
import validatePaths from '../util/validate-paths';
import requestRollback from './request-rollback';
import rollbackStatus from './status';
const help = () => {
console.log(`
${chalk.bold(
`${logo} ${getPkgName()} rollback`
)} [deploymentId|deploymentName]
${chalk.bold(`${logo} ${getPkgName()} rollback`)} [deployment id/url]
Quickly revert back to a previous deployment.
@@ -43,6 +41,7 @@ const help = () => {
${chalk.cyan(`$ ${getPkgName()} rollback`)}
${chalk.cyan(`$ ${getPkgName()} rollback status`)}
${chalk.cyan(`$ ${getPkgName()} rollback status <project>`)}
${chalk.cyan(`$ ${getPkgName()} rollback status --timeout 30s`)}
${chalk.gray('')} Rollback a deployment using id or url
@@ -60,8 +59,6 @@ export default async (client: Client): Promise<number> => {
let argv;
try {
argv = getArgs(client.argv.slice(2), {
'--debug': Boolean,
'-d': '--debug',
'--timeout': String,
'--yes': Boolean,
'-y': '--yes',
@@ -76,26 +73,6 @@ export default async (client: Client): Promise<number> => {
return 2;
}
// ensure the current directory is good
const cwd = argv['--cwd'] || process.cwd();
const pathValidation = await validatePaths(client, [cwd]);
if (!pathValidation.valid) {
return pathValidation.exitCode;
}
// ensure the current directory is a linked project
const linkedProject = await ensureLink(
'rollback',
client,
pathValidation.path,
{
autoConfirm: Boolean(argv['--yes']),
}
);
if (typeof linkedProject === 'number') {
return linkedProject;
}
// validate the timeout
let timeout = argv['--timeout'];
if (timeout && ms(timeout) === undefined) {
@@ -103,21 +80,42 @@ export default async (client: Client): Promise<number> => {
return 1;
}
const { project } = linkedProject;
const actionOrDeployId = argv._[1] || 'status';
if (actionOrDeployId === 'status') {
return await rollbackStatus({
try {
if (actionOrDeployId === 'status') {
const project = await getProjectByCwdOrLink({
autoConfirm: Boolean(argv['--yes']),
client,
commandName: 'promote',
cwd: client.cwd,
projectNameOrId: argv._[2],
});
return await rollbackStatus({
client,
project,
timeout,
});
}
return await requestRollback({
client,
project,
deployId: actionOrDeployId,
timeout,
});
}
} catch (err) {
if (isErrnoException(err)) {
if (err.code === 'ERR_CANCELED') {
return 0;
}
if (err.code === 'ERR_INVALID_CWD' || err.code === 'ERR_LINK_PROJECT') {
// do not show the message
return 1;
}
}
return await requestRollback({
client,
deployId: actionOrDeployId,
project,
timeout,
});
client.output.prettyError(err);
return 1;
}
};

View File

@@ -0,0 +1,56 @@
import chalk from 'chalk';
import type Client from '../../util/client';
import { getCommandName } from '../../util/pkg-name';
import getProjectByDeployment from '../../util/projects/get-project-by-deployment';
import ms from 'ms';
import rollbackStatus from './status';
/**
* Requests a rollback and waits for it complete.
* @param {Client} client - The Vercel client instance
* @param {string} deployIdOrUrl - The deployment name or id to rollback
* @param {string} [timeout] - Time to poll for succeeded/failed state
* @returns {Promise<number>} Resolves an exit code; 0 on success
*/
export default async function requestRollback({
client,
deployId,
timeout,
}: {
client: Client;
deployId: string;
timeout?: string;
}): Promise<number> {
const { output } = client;
const { contextName, deployment, project } = await getProjectByDeployment({
client,
deployId,
output: client.output,
});
// create the rollback
await client.fetch(`/v9/projects/${project.id}/rollback/${deployment.id}`, {
body: {}, // required
method: 'POST',
});
if (timeout !== undefined && ms(timeout) === 0) {
output.log(
`Successfully requested rollback of ${chalk.bold(project.name)} to ${
deployment.url
} (${deployment.id})`
);
output.log(`To check rollback status, run ${getCommandName('rollback')}.`);
return 0;
}
// check the status
return await rollbackStatus({
client,
contextName,
deployment,
project,
timeout,
});
}

View File

@@ -1,18 +1,21 @@
import chalk from 'chalk';
import type Client from '../client';
import type Client from '../../util/client';
import type {
Deployment,
LastAliasRequest,
PaginationOptions,
Project,
RollbackTarget,
} from '@vercel-internals/types';
import elapsed from '../output/elapsed';
import formatDate from '../format-date';
import getDeployment from '../get-deployment';
import getScope from '../get-scope';
import elapsed from '../../util/output/elapsed';
import formatDate from '../../util/format-date';
import getDeployment from '../../util/get-deployment';
import { getPkgName } from '../../util/pkg-name';
import getProjectByNameOrId from '../../util/projects/get-project-by-id-or-name';
import getScope from '../../util/get-scope';
import ms from 'ms';
import renderAliasStatus from './render-alias-status';
import sleep from '../sleep';
import { ProjectNotFound } from '../../util/errors-ts';
import renderAliasStatus from '../../util/alias/render-alias-status';
import sleep from '../../util/sleep';
interface RollbackAlias {
alias: {
@@ -61,13 +64,6 @@ export default async function rollbackStatus({
? 'Rollback in progress'
: `Checking rollback status of ${project.name}`;
const check = async () => {
const { lastRollbackTarget } = await client.fetch<any>(
`/v9/projects/${project.id}?rollbackInfo=true`
);
return lastRollbackTarget;
};
if (!contextName) {
({ contextName } = await getScope(client));
}
@@ -78,8 +74,22 @@ export default async function rollbackStatus({
// continuously loop until the rollback has explicitly succeeded, failed,
// or timed out
for (;;) {
const { jobStatus, requestedAt, toDeploymentId }: RollbackTarget =
(await check()) ?? {};
const projectCheck = await getProjectByNameOrId(
client,
project.id,
project.accountId,
true
);
if (projectCheck instanceof ProjectNotFound) {
throw projectCheck;
}
const {
jobStatus,
requestedAt,
toDeploymentId,
type,
}: Partial<LastAliasRequest> = projectCheck.lastAliasRequest ?? {};
if (
!jobStatus ||
@@ -89,12 +99,17 @@ export default async function rollbackStatus({
output.log(`${spinnerMessage}`);
}
if (!jobStatus || requestedAt < recentThreshold) {
if (
!jobStatus ||
!requestedAt ||
!toDeploymentId ||
requestedAt < recentThreshold
) {
output.log('No deployment rollback in progress');
return 0;
}
if (jobStatus === 'skipped') {
if (jobStatus === 'skipped' && type === 'rollback') {
output.log('Rollback was skipped');
return 0;
}
@@ -131,7 +146,7 @@ export default async function rollbackStatus({
if (requestedAt < recentThreshold || Date.now() >= rollbackTimeout) {
output.log(
`The rollback exceeded its deadline - rerun ${chalk.bold(
`vercel rollback ${toDeploymentId}`
`${getPkgName()} rollback ${toDeploymentId}`
)} to try again`
);
return 1;

View File

@@ -52,7 +52,10 @@ import { getCommandName, getTitleName } from './util/pkg-name';
import doLoginPrompt from './util/login/prompt';
import type { AuthConfig, GlobalConfig } from '@vercel-internals/types';
import { VercelConfig } from '@vercel/client';
import { ProxyAgent } from 'proxy-agent';
import box from './util/output/box';
import { execExtension } from './util/extension/exec';
import { help } from './args';
const VERCEL_DIR = getGlobalPathConfig();
const VERCEL_CONFIG_PATH = configFiles.getConfigFilePath();
@@ -141,19 +144,15 @@ const main = async () => {
return 1;
}
const cwd = argv['--cwd'];
if (cwd) {
process.chdir(cwd);
}
// The second argument to the command can be:
//
// * a path to deploy (as in: `vercel path/`)
// * a subcommand (as in: `vercel ls`)
const targetOrSubcommand = argv._[2];
const subSubCommand = argv._[3];
// Currently no beta commands - add here as needed
const betaCommands: string[] = ['rollback'];
// If empty, leave this code here for easy adding of beta commands later
const betaCommands: string[] = [];
if (betaCommands.includes(targetOrSubcommand)) {
console.log(
`${chalk.grey(
@@ -172,6 +171,14 @@ const main = async () => {
return 0;
}
// Handle bare `-h` directly
const bareHelpOption = !targetOrSubcommand && argv['--help'];
const bareHelpSubcommand = targetOrSubcommand === 'help' && !subSubCommand;
if (bareHelpOption || bareHelpSubcommand) {
output.print(help());
return 2;
}
// Ensure that the Vercel global configuration directory exists
try {
await mkdirp(VERCEL_DIR);
@@ -251,6 +258,7 @@ const main = async () => {
// Shared API `Client` instance for all sub-commands to utilize
client = new Client({
agent: new ProxyAgent({ keepAlive: true }),
apiUrl,
stdin: process.stdin,
stdout: process.stdout,
@@ -263,11 +271,19 @@ const main = async () => {
argv: process.argv,
});
let subcommand;
// The `--cwd` flag is respected for all sub-commands
if (argv['--cwd']) {
client.cwd = argv['--cwd'];
}
const { cwd } = client;
// Gets populated to the subcommand name when a built-in is
// provided, otherwise it remains undefined for an extension
let subcommand: string | undefined = undefined;
// Check if we are deploying something
if (targetOrSubcommand) {
const targetPath = join(process.cwd(), targetOrSubcommand);
const targetPath = join(cwd, targetOrSubcommand);
const targetPathExists = existsSync(targetPath);
const subcommandExists =
GLOBAL_COMMANDS.has(targetOrSubcommand) ||
@@ -289,8 +305,7 @@ const main = async () => {
debug(`user supplied known subcommand: "${targetOrSubcommand}"`);
subcommand = targetOrSubcommand;
} else {
debug('user supplied a possible target for deployment');
subcommand = 'deploy';
debug('user supplied a possible target for deployment or an extension');
}
} else {
debug('user supplied no target, defaulting to deploy');
@@ -298,7 +313,7 @@ const main = async () => {
}
if (subcommand === 'help') {
subcommand = argv._[3] || 'deploy';
subcommand = subSubCommand || 'deploy';
client.argv.push('-h');
}
@@ -310,6 +325,7 @@ const main = async () => {
!client.argv.includes('-h') &&
!client.argv.includes('--help') &&
!argv['--token'] &&
subcommand &&
!subcommandsWithoutToken.includes(subcommand)
) {
if (isTTY) {
@@ -401,7 +417,8 @@ const main = async () => {
);
}
const targetCommand = commands.get(subcommand);
let targetCommand =
typeof subcommand === 'string' ? commands.get(subcommand) : undefined;
const scope = argv['--scope'] || argv['--team'] || localConfig?.scope;
if (
@@ -409,7 +426,7 @@ const main = async () => {
targetCommand !== 'login' &&
targetCommand !== 'dev' &&
targetCommand !== 'build' &&
!(targetCommand === 'teams' && argv._[3] !== 'invite')
!(targetCommand === 'teams' && subSubCommand !== 'invite')
) {
let user = null;
@@ -472,96 +489,129 @@ const main = async () => {
try {
const start = Date.now();
let func: any;
switch (targetCommand) {
case 'alias':
func = require('./commands/alias').default;
break;
case 'bisect':
func = require('./commands/bisect').default;
break;
case 'build':
func = require('./commands/build').default;
break;
case 'certs':
func = require('./commands/certs').default;
break;
case 'deploy':
func = require('./commands/deploy').default;
break;
case 'dev':
func = require('./commands/dev').default;
break;
case 'dns':
func = require('./commands/dns').default;
break;
case 'domains':
func = require('./commands/domains').default;
break;
case 'env':
func = require('./commands/env').default;
break;
case 'git':
func = require('./commands/git').default;
break;
case 'init':
func = require('./commands/init').default;
break;
case 'inspect':
func = require('./commands/inspect').default;
break;
case 'link':
func = require('./commands/link').default;
break;
case 'list':
func = require('./commands/list').default;
break;
case 'logs':
func = require('./commands/logs').default;
break;
case 'login':
func = require('./commands/login').default;
break;
case 'logout':
func = require('./commands/logout').default;
break;
case 'project':
func = require('./commands/project').default;
break;
case 'pull':
func = require('./commands/pull').default;
break;
case 'remove':
func = require('./commands/remove').default;
break;
case 'rollback':
func = require('./commands/rollback').default;
break;
case 'secrets':
func = require('./commands/secrets').default;
break;
case 'teams':
func = require('./commands/teams').default;
break;
case 'whoami':
func = require('./commands/whoami').default;
break;
default:
func = null;
break;
if (!targetCommand) {
// Set this for the metrics to record it at the end
targetCommand = argv._[2];
// Try to execute as an extension
try {
exitCode = await execExtension(
client,
targetCommand,
argv._.slice(3),
cwd
);
} catch (err: unknown) {
if (isErrnoException(err) && err.code === 'ENOENT') {
// Fall back to `vc deploy <dir>`
targetCommand = subcommand = 'deploy';
} else {
throw err;
}
}
}
if (!func || !targetCommand) {
const sub = param(subcommand);
output.error(`The ${sub} subcommand does not exist`);
return 1;
}
// Not using an `else` here because if the CLI extension
// was not found then we have to fall back to `vc deploy`
if (subcommand) {
let func: any;
switch (targetCommand) {
case 'alias':
func = require('./commands/alias').default;
break;
case 'bisect':
func = require('./commands/bisect').default;
break;
case 'build':
func = require('./commands/build').default;
break;
case 'certs':
func = require('./commands/certs').default;
break;
case 'deploy':
func = require('./commands/deploy').default;
break;
case 'dev':
func = require('./commands/dev').default;
break;
case 'dns':
func = require('./commands/dns').default;
break;
case 'domains':
func = require('./commands/domains').default;
break;
case 'env':
func = require('./commands/env').default;
break;
case 'git':
func = require('./commands/git').default;
break;
case 'init':
func = require('./commands/init').default;
break;
case 'inspect':
func = require('./commands/inspect').default;
break;
case 'link':
func = require('./commands/link').default;
break;
case 'list':
func = require('./commands/list').default;
break;
case 'logs':
func = require('./commands/logs').default;
break;
case 'login':
func = require('./commands/login').default;
break;
case 'logout':
func = require('./commands/logout').default;
break;
case 'project':
func = require('./commands/project').default;
break;
case 'promote':
func = require('./commands/promote').default;
break;
case 'pull':
func = require('./commands/pull').default;
break;
case 'redeploy':
func = require('./commands/redeploy').default;
break;
case 'remove':
func = require('./commands/remove').default;
break;
case 'rollback':
func = require('./commands/rollback').default;
break;
case 'secrets':
func = require('./commands/secrets').default;
break;
case 'teams':
func = require('./commands/teams').default;
break;
case 'whoami':
func = require('./commands/whoami').default;
break;
default:
func = null;
break;
}
if (func.default) {
func = func.default;
}
if (!func || !targetCommand) {
const sub = param(subcommand);
output.error(`The ${sub} subcommand does not exist`);
return 1;
}
exitCode = await func(client);
if (func.default) {
func = func.default;
}
exitCode = await func(client);
}
const end = Date.now() - start;
if (shouldCollectMetrics) {

View File

@@ -2,9 +2,6 @@ const ARG_COMMON = {
'--help': Boolean,
'-h': '--help',
'--platform-version': Number,
'-V': '--platform-version',
'--debug': Boolean,
'-d': '--debug',

View File

@@ -23,6 +23,7 @@ import type {
import { sharedPromise } from './promise';
import { APIError } from './errors-ts';
import { normalizeError } from '@vercel/error-utils';
import type { Agent } from 'http';
const isSAMLError = (v: any): v is SAMLError => {
return v && v.saml;
@@ -44,6 +45,7 @@ export interface ClientOptions extends Stdio {
config: GlobalConfig;
localConfig?: VercelConfig;
localConfigPath?: string;
agent?: Agent;
}
export const isJSONObject = (v: any): v is JSONObject => {
@@ -59,13 +61,15 @@ export default class Client extends EventEmitter implements Stdio {
stderr: WritableTTY;
output: Output;
config: GlobalConfig;
agent?: Agent;
localConfig?: VercelConfig;
localConfigPath?: string;
prompt!: inquirer.PromptModule;
private requestIdCounter: number;
requestIdCounter: number;
constructor(opts: ClientOptions) {
super();
this.agent = opts.agent;
this.argv = opts.argv;
this.apiUrl = opts.apiUrl;
this.authConfig = opts.authConfig;
@@ -126,10 +130,10 @@ export default class Client extends EventEmitter implements Stdio {
} else {
return `#${requestId}${opts.method || 'GET'} ${url.href}`;
}
}, fetch(url, { ...opts, headers, body }));
}, fetch(url, { agent: this.agent, ...opts, headers, body }));
}
fetch(url: string, opts: { json: false }): Promise<Response>;
fetch(url: string, opts: FetchOptions & { json: false }): Promise<Response>;
fetch<T>(url: string, opts?: FetchOptions): Promise<T>;
fetch(url: string, opts: FetchOptions = {}) {
return this.retry(async bail => {
@@ -203,4 +207,12 @@ export default class Client extends EventEmitter implements Stdio {
output: this.stderr as NodeJS.WriteStream,
});
}
get cwd(): string {
return process.cwd();
}
set cwd(v: string) {
process.chdir(v);
}
}

View File

@@ -12,21 +12,21 @@ export default async function createDeploy(
client: Client,
now: Now,
contextName: string,
paths: string[],
path: string,
createArgs: CreateOptions,
org: Org,
isSettingUpProject: boolean,
cwd?: string,
cwd: string,
archive?: ArchiveFormat
): Promise<any | DeploymentError> {
try {
return await now.create(
paths,
path,
createArgs,
org,
isSettingUpProject,
archive,
cwd
cwd,
archive
);
} catch (err: unknown) {
if (ERRORS_TS.isAPIError(err)) {
@@ -109,10 +109,11 @@ export default async function createDeploy(
client,
now,
contextName,
paths,
path,
createArgs,
org,
isSettingUpProject
isSettingUpProject,
cwd
);
}

View File

@@ -0,0 +1,89 @@
import chalk from 'chalk';
import getDeployment from '../get-deployment';
import getTeamById from '../teams/get-team-by-id';
import { isValidName } from '../is-valid-name';
import type Client from '../client';
import type { Deployment, Team } from '@vercel-internals/types';
/**
* Renders feedback while retrieving a deployment, then validates the
* deployment belongs to the current team.
*
* @param client - The CLI client instance.
* @param contextName - The context/team name.
* @param deployIdOrUrl - The deployment id or URL.
* @returns The deployment info.
*/
export async function getDeploymentByIdOrURL({
client,
contextName,
deployIdOrUrl,
}: {
client: Client;
contextName: string;
deployIdOrUrl: string;
}): Promise<Deployment> {
const { config, output } = client;
if (!isValidName(deployIdOrUrl)) {
throw new Error(
`The provided argument "${deployIdOrUrl}" is not a valid deployment ID or URL`
);
}
let deployment: Deployment;
let team: Team | undefined;
try {
output.spinner(
`Fetching deployment "${deployIdOrUrl}" in ${chalk.bold(contextName)}`
);
const [teamResult, deploymentResult] = await Promise.allSettled([
config.currentTeam ? getTeamById(client, config.currentTeam) : undefined,
getDeployment(client, contextName, deployIdOrUrl),
]);
if (teamResult.status === 'rejected') {
throw new Error(
`Failed to retrieve team information: ${teamResult.reason}`
);
}
if (deploymentResult.status === 'rejected') {
throw new Error(deploymentResult.reason.message);
}
team = teamResult.value;
deployment = deploymentResult.value;
// re-render the spinner text because it goes so fast
output.log(
`Fetching deployment "${deployIdOrUrl}" in ${chalk.bold(contextName)}`
);
} finally {
output.stopSpinner();
}
if (deployment.team?.id) {
if (!team || deployment.team.id !== team.id) {
const err: NodeJS.ErrnoException = new Error(
team
? `Deployment doesn't belong to current team ${chalk.bold(
contextName
)}`
: `Deployment belongs to a different team`
);
err.code = 'ERR_INVALID_TEAM';
throw err;
}
} else if (team) {
const err: NodeJS.ErrnoException = new Error(
`Deployment doesn't belong to current team ${chalk.bold(contextName)}`
);
err.code = 'ERR_INVALID_TEAM';
throw err;
}
return deployment;
}

View File

@@ -0,0 +1,117 @@
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';
export async function printDeploymentStatus(
client: Client,
{
readyState,
alias: aliasList,
aliasError,
target,
indications,
url: deploymentUrl,
aliasWarning,
}: {
readyState: Deployment['readyState'];
alias: string[];
aliasError: Error;
target: string;
indications: any;
url: string;
aliasWarning?: {
code: string;
message: string;
link?: string;
action?: string;
};
},
deployStamp: () => string,
noWait: boolean
): Promise<number> {
const { output } = client;
indications = indications || [];
const isProdDeployment = target === 'production';
let isStillBuilding = false;
if (noWait) {
if (isDeploying(readyState)) {
isStillBuilding = true;
output.print(
prependEmoji(
'Note: Deployment is still processing...',
emoji('notice')
) + '\n'
);
}
}
if (!isStillBuilding && readyState !== 'READY') {
output.error(
`Your deployment failed. Please retry later. More: https://err.sh/vercel/deployment-error`
);
return 1;
}
if (aliasError) {
output.warn(
`Failed to assign aliases${
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) {
indications.push({
type: 'warning',
payload: aliasWarning.message,
link: aliasWarning.link,
action: aliasWarning.action,
});
}
const newline = '\n';
for (let indication of indications) {
const message =
prependEmoji(chalk.dim(indication.payload), emoji(indication.type)) +
newline;
let link = '';
if (indication.link)
link =
chalk.dim(
`${indication.action || 'Learn More'}: ${linkStyle(indication.link)}`
) + newline;
output.print(message + link);
}
return 0;
}

View File

@@ -13,6 +13,7 @@ import type { Org } from '@vercel-internals/types';
import ua from '../ua';
import { linkFolderToProject } from '../projects/link';
import { prependEmoji, emoji } from '../emoji';
import type { Agent } from 'http';
function printInspectUrl(
output: Output,
@@ -35,11 +36,11 @@ export default async function processDeployment({
archive,
skipAutoDetectionConfirmation,
noWait,
agent,
...args
}: {
now: Now;
output: Output;
paths: string[];
path: string;
requestBody: DeploymentOptions;
uploadStamp: () => string;
deployStamp: () => string;
@@ -52,14 +53,14 @@ export default async function processDeployment({
isSettingUpProject: boolean;
archive?: ArchiveFormat;
skipAutoDetectionConfirmation?: boolean;
cwd?: string;
cwd: string;
rootDirectory?: string | null;
noWait?: boolean;
agent?: Agent;
}) {
let {
now,
output,
paths,
path,
requestBody,
deployStamp,
force,
@@ -69,10 +70,9 @@ export default async function processDeployment({
rootDirectory,
} = args;
const { debug } = output;
const client = now._client;
const { output } = client;
const { env = {} } = requestBody;
const token = now._token;
if (!token) {
throw new Error('Missing authentication token');
@@ -84,13 +84,14 @@ export default async function processDeployment({
token,
debug: now._debug,
userAgent: ua,
path: paths[0],
path,
force,
withCache,
prebuilt,
rootDirectory,
skipAutoDetectionConfirmation,
archive,
agent,
};
const deployingSpinnerVal = isSettingUpProject
@@ -110,7 +111,7 @@ export default async function processDeployment({
if (event.type === 'file-count') {
const { total, missing, uploads } = event.payload;
debug(`Total files ${total.size}, ${missing.length} changed`);
output.debug(`Total files ${total.size}, ${missing.length} changed`);
const missingSize = missing
.map((sha: string) => total.get(sha).data.length)
@@ -153,7 +154,7 @@ export default async function processDeployment({
}
if (event.type === 'file-uploaded') {
debug(
output.debug(
`Uploaded: ${event.payload.file.names.join(' ')} (${bytes(
event.payload.file.data.length
)})`
@@ -162,8 +163,8 @@ export default async function processDeployment({
if (event.type === 'created') {
await linkFolderToProject(
output,
cwd || paths[0],
client,
cwd,
{
orgId: org.id,
projectId: event.payload.projectId,

View File

@@ -337,7 +337,10 @@ export async function executeBuild(
// Enforce the lambda zip size soft watermark
const maxLambdaBytes = bytes('50mb');
for (const asset of Object.values(result.output)) {
if (asset.type === 'Lambda') {
if (
asset.type === 'Lambda' &&
!(typeof asset.runtime === 'string' && asset.runtime.startsWith('python'))
) {
const size = asset.zipBuffer.length;
if (size > maxLambdaBytes) {
throw new LambdaSizeExceededError(size, maxLambdaBytes);

View File

@@ -5,7 +5,7 @@ import chalk from 'chalk';
import fetch from 'node-fetch';
import plural from 'pluralize';
import rawBody from 'raw-body';
import listen from 'async-listen';
import { listen } from 'async-listen';
import minimatch from 'minimatch';
import httpProxy from 'http-proxy';
import { randomBytes } from 'crypto';
@@ -860,7 +860,7 @@ export default class DevServer {
let address: string | null = null;
while (typeof address !== 'string') {
try {
address = await listen(this.server, ...listenSpec);
address = (await listen(this.server, ...listenSpec)).toString();
} catch (err: unknown) {
if (isErrnoException(err)) {
this.output.debug(`Got listen error: ${err.code}`);

View File

@@ -0,0 +1,90 @@
import which from 'which';
import execa from 'execa';
import { dirname } from 'path';
import { listen } from 'async-listen';
import { scanParentDirs, walkParentDirs } from '@vercel/build-utils';
import { createProxy } from './proxy';
import type Client from '../client';
/**
* Attempts to execute a Vercel CLI Extension.
*
* If the extension was found and executed, then the
* exit code is returned.
*
* If the program could not be found, then an `ENOENT`
* error is thrown.
*/
export async function execExtension(
client: Client,
name: string,
args: string[],
cwd: string
): Promise<number> {
const { debug } = client.output;
const extensionCommand = `vercel-${name}`;
const { packageJsonPath, lockfilePath } = await scanParentDirs(cwd);
const baseFile = lockfilePath || packageJsonPath;
let extensionPath: string | null = null;
if (baseFile) {
// Scan `node_modules/.bin` works for npm / pnpm / yarn v1
// TOOD: add support for Yarn PnP
extensionPath = await walkParentDirs({
base: dirname(baseFile),
start: cwd,
filename: `node_modules/.bin/${extensionCommand}`,
});
}
if (!extensionPath) {
// Attempt global `$PATH` lookup
extensionPath = which.sync(extensionCommand, { nothrow: true });
}
if (!extensionPath) {
debug(`failed to find extension command with name "${extensionCommand}"`);
throw new ENOENT(extensionCommand);
}
debug(`invoking extension: ${extensionPath}`);
const proxy = createProxy(client);
proxy.once('close', () => {
debug(`extension proxy server shut down`);
});
const proxyUrl = await listen(proxy, { port: 0, host: '127.0.0.1' });
const VERCEL_API = proxyUrl.href.replace(/\/$/, '');
debug(`extension proxy server listening at ${VERCEL_API}`);
const result = await execa(extensionPath, args, {
cwd,
reject: false,
stdio: 'inherit',
env: {
...process.env,
VERCEL_API,
// TODO:
// VERCEL_SCOPE
// VERCEL_DEBUG
// VERCEL_HELP
},
});
proxy.close();
if (result instanceof Error) {
debug(`error running extension: ${result.message}`);
}
return result.exitCode;
}
class ENOENT extends Error {
code = 'ENOENT';
constructor(command: string) {
super(`Command "${command}" not found`);
}
}

View File

@@ -0,0 +1,44 @@
import { createServer } from 'http';
import { Headers } from 'node-fetch';
import {
toOutgoingHeaders,
mergeIntoServerResponse,
buildToHeaders,
} from '@edge-runtime/node-utils';
import type { Server } from 'http';
import type Client from '../client';
const toHeaders = buildToHeaders({
// @ts-expect-error - `node-fetch` Headers is missing `getAll()`
Headers,
});
export function createProxy(client: Client): Server {
return createServer(async (req, res) => {
try {
// Proxy to the upstream Vercel REST API
const headers = toHeaders(req.headers);
headers.delete('host');
const fetchRes = await client.fetch(req.url || '/', {
headers,
method: req.method,
body: req.method === 'GET' || req.method === 'HEAD' ? undefined : req,
useCurrentTeam: false,
json: false,
});
res.statusCode = fetchRes.status;
mergeIntoServerResponse(
// @ts-expect-error - `node-fetch` Headers is missing `getAll()`
toOutgoingHeaders(fetchRes.headers),
res
);
fetchRes.body.pipe(res);
} catch (err: unknown) {
client.output.prettyError(err);
if (!res.headersSent) {
res.statusCode = 500;
res.end('Unexpected error during API call');
}
}
});
}

View File

@@ -10,7 +10,7 @@ import mapCertError from './certs/map-cert-error';
import toHost from './to-host';
/**
* Retrieves a v13 deployment.
* Retrieves a deployment by id or URL.
*
* @param client - The Vercel CLI client instance.
* @param contextName - The scope context/team name.

View File

@@ -50,6 +50,7 @@ export interface CreateOptions {
projectSettings?: any;
skipAutoDetectionConfirmation?: boolean;
noWait?: boolean;
autoAssignCustomDomains: boolean;
}
export interface RemoveOptions {
@@ -106,7 +107,7 @@ export default class Now extends EventEmitter {
}
async create(
paths: string[],
path: string,
{
// Legacy
nowConfig: nowConfig = {},
@@ -130,11 +131,12 @@ export default class Now extends EventEmitter {
projectSettings,
skipAutoDetectionConfirmation,
noWait,
autoAssignCustomDomains,
}: CreateOptions,
org: Org,
isSettingUpProject: boolean,
archive?: ArchiveFormat,
cwd?: string
cwd: string,
archive?: ArchiveFormat
) {
let hashes: any = {};
const uploadStamp = stamp();
@@ -152,6 +154,7 @@ export default class Now extends EventEmitter {
target: target || undefined,
projectSettings,
source: 'cli',
autoAssignCustomDomains,
};
// Ignore specific items from vercel.json
@@ -160,8 +163,8 @@ export default class Now extends EventEmitter {
const deployment = await processDeployment({
now: this,
output: this._output,
paths,
agent: this._client.agent,
path,
requestBody,
uploadStamp,
deployStamp,
@@ -294,7 +297,7 @@ export default class Now extends EventEmitter {
if (
error.errorCode === 'BUILD_FAILED' ||
error.errorCode === 'UNEXPECTED_ERROR' ||
error.errorCode.includes('BUILD_UTILS_SPAWN_')
error.errorCode?.includes('BUILD_UTILS_SPAWN_')
) {
return new BuildError({
message: error.errorMessage,

View File

@@ -0,0 +1,31 @@
import os from 'os';
import { join } from 'path';
import { readFile, writeFile } from 'fs-extra';
import { VERCEL_DIR } from '../projects/link';
export async function addToGitIgnore(path: string, ignore = VERCEL_DIR) {
let isGitIgnoreUpdated = false;
try {
const gitIgnorePath = join(path, '.gitignore');
let gitIgnore =
(await readFile(gitIgnorePath, 'utf8').catch(() => null)) ?? '';
const EOL = gitIgnore.includes('\r\n') ? '\r\n' : os.EOL;
let contentModified = false;
if (!gitIgnore.split(EOL).includes(ignore)) {
gitIgnore += `${
gitIgnore.endsWith(EOL) || gitIgnore.length === 0 ? '' : EOL
}${ignore}${EOL}`;
contentModified = true;
}
if (contentModified) {
await writeFile(gitIgnorePath, gitIgnore);
isGitIgnoreUpdated = true;
}
} catch (error) {
// ignore errors since this is non-critical
}
return isGitIgnoreUpdated;
}

View File

@@ -0,0 +1,294 @@
import chalk from 'chalk';
import pluralize from 'pluralize';
import { homedir } from 'os';
import { join, normalize } from 'path';
import { normalizePath } from '@vercel/build-utils';
import { lstat, readJSON, outputJSON, writeFile, readFile } from 'fs-extra';
import confirm from '../input/confirm';
import toHumanPath from '../humanize-path';
import {
VERCEL_DIR,
VERCEL_DIR_README,
VERCEL_DIR_REPO,
} from '../projects/link';
import { getRemoteUrls } from '../create-git-meta';
import link from '../output/link';
import { emoji, prependEmoji } from '../emoji';
import selectOrg from '../input/select-org';
import { addToGitIgnore } from './add-to-gitignore';
import type Client from '../client';
import type { Project } from '@vercel-internals/types';
const home = homedir();
export interface RepoProjectConfig {
id: string;
name: string;
directory: string;
}
export interface RepoProjectsConfig {
orgId: string;
remoteName: string;
projects: RepoProjectConfig[];
}
export interface RepoLink {
rootPath: string;
repoConfigPath: string;
repoConfig?: RepoProjectsConfig;
}
/**
* Given a directory path `cwd`, finds the root of the Git repository
* and returns the parsed `.vercel/repo.json` file if the repository
* has already been linked.
*/
export async function getRepoLink(cwd: string): Promise<RepoLink | undefined> {
// Determine where the root of the repo is
const rootPath = await findRepoRoot(cwd);
if (!rootPath) return undefined;
// Read the `repo.json`, if this repo has already been linked
const repoConfigPath = join(rootPath, VERCEL_DIR, VERCEL_DIR_REPO);
const repoConfig: RepoProjectsConfig = await readJSON(repoConfigPath).catch(
err => {
if (err.code !== 'ENOENT') throw err;
}
);
return { rootPath, repoConfig, repoConfigPath };
}
export async function ensureRepoLink(
client: Client,
cwd: string,
yes = false
): Promise<RepoLink | undefined> {
const { output } = client;
const repoLink = await getRepoLink(cwd);
if (repoLink) {
output.debug(`Found Git repository root directory: ${repoLink.rootPath}`);
} else {
throw new Error('Could not determine Git repository root directory');
}
let { rootPath, repoConfig, repoConfigPath } = repoLink;
if (!repoConfig) {
// Not yet linked, so prompt user to begin linking
let shouldLink =
yes ||
(await confirm(
client,
`Link Git repository at ${chalk.cyan(
`${toHumanPath(rootPath)}`
)} to your Project(s)?`,
true
));
if (!shouldLink) {
output.print(`Canceled. Repository not linked.\n`);
return;
}
const org = await selectOrg(
client,
'Which scope should contain your Project(s)?',
yes
);
client.config.currentTeam = org.type === 'team' ? org.id : undefined;
const remoteUrls = await getRemoteUrls(
join(rootPath, '.git/config'),
output
);
if (!remoteUrls) {
throw new Error('Could not determine Git remote URLs');
}
const remoteNames = Object.keys(remoteUrls);
let remoteName: string;
if (remoteNames.length === 1) {
remoteName = remoteNames[0];
} else {
// Prompt user to select which remote to use
const originIndex = remoteNames.indexOf('origin');
const answer = await client.prompt({
type: 'list',
name: 'value',
message: 'Which Git remote should be used?',
choices: remoteNames.map(name => {
return { name: name, value: name };
}),
default: originIndex === -1 ? 0 : originIndex,
});
remoteName = answer.value;
}
const repoUrl = remoteUrls[remoteName];
output.spinner(
`Fetching Projects for ${link(repoUrl)} under ${chalk.bold(org.slug)}`
);
// TODO: Add pagination to fetch all Projects
const query = new URLSearchParams({ repoUrl, limit: '100' });
const projects: Project[] = await client.fetch(`/v2/projects?${query}`);
if (projects.length === 0) {
output.log(
`No Projects are linked to ${link(repoUrl)} under ${chalk.bold(
org.slug
)}.`
);
// TODO: run detection logic to find potential projects.
// then prompt user to select valid projects.
// then create new Projects
} else {
output.log(
`Found ${chalk.bold(projects.length)} ${pluralize(
'Project',
projects.length
)} linked to ${link(repoUrl)} under ${chalk.bold(org.slug)}:`
);
}
for (const project of projects) {
output.print(` * ${chalk.cyan(`${org.slug}/${project.name}\n`)}`);
}
shouldLink =
yes ||
(await confirm(
client,
`Link to ${projects.length === 1 ? 'it' : 'them'}?`,
true
));
if (!shouldLink) {
output.print(`Canceled. Repository not linked.\n`);
return;
}
repoConfig = {
orgId: org.id,
remoteName,
projects: projects.map(project => {
return {
id: project.id,
name: project.name,
directory: normalize(project.rootDirectory || ''),
};
}),
};
await outputJSON(repoConfigPath, repoConfig, { spaces: 2 });
await writeFile(
join(rootPath, VERCEL_DIR, VERCEL_DIR_README),
await readFile(join(__dirname, 'VERCEL_DIR_README.txt'), 'utf8')
);
// update .gitignore
const isGitIgnoreUpdated = await addToGitIgnore(rootPath);
output.print(
prependEmoji(
`Linked to ${link(repoUrl)} under ${chalk.bold(
org.slug
)} (created ${VERCEL_DIR}${
isGitIgnoreUpdated ? ' and added it to .gitignore' : ''
})`,
emoji('link')
) + '\n'
);
}
return {
repoConfig,
repoConfigPath,
rootPath,
};
}
/**
* Given a `start` directory, traverses up the directory hierarchy until
* the nearest `.git/config` file is found. Returns the directory where
* the Git config was found, or `undefined` when no Git repo was found.
*/
export async function findRepoRoot(start: string): Promise<string | undefined> {
for (const current of traverseUpDirectories(start)) {
if (current === home) {
// Sometimes the $HOME directory is set up as a Git repo
// (for dotfiles, etc.). In this case it's safe to say that
// this isn't the repo we're looking for. Bail.
break;
}
// if `.vercel/repo.json` exists (already linked),
// then consider this the repo root
const repoConfigPath = join(current, VERCEL_DIR, VERCEL_DIR_REPO);
let stat = await lstat(repoConfigPath).catch(err => {
if (err.code !== 'ENOENT') throw err;
});
if (stat) {
return current;
}
// if `.git/config` exists (unlinked),
// then consider this the repo root
const gitConfigPath = join(current, '.git/config');
stat = await lstat(gitConfigPath).catch(err => {
if (err.code !== 'ENOENT') throw err;
});
if (stat) {
return current;
}
}
}
export function* traverseUpDirectories(start: string) {
let current: string | undefined = normalize(start);
while (current) {
yield current;
// Go up one directory
const next = join(current, '..');
current = next === current ? undefined : next;
}
}
function sortByDirectory(a: RepoProjectConfig, b: RepoProjectConfig): number {
const aParts = a.directory.split('/');
const bParts = b.directory.split('/');
return bParts.length - aParts.length;
}
/**
* Finds the matching Projects from an array of Project links
* where the provided relative path is within the Project's
* root directory.
*/
export function findProjectsFromPath(
projects: RepoProjectConfig[],
path: string
): RepoProjectConfig[] {
const normalizedPath = normalizePath(path);
return projects
.slice()
.sort(sortByDirectory)
.filter(project => {
if (project.directory === '.') {
// Project has no "Root Directory" setting, so any path is valid
return true;
}
return (
normalizedPath === project.directory ||
normalizedPath.startsWith(`${project.directory}/`)
);
});
}
/**
* TODO: remove
*/
export function findProjectFromPath(
projects: RepoProjectConfig[],
path: string
): RepoProjectConfig | undefined {
return findProjectsFromPath(projects, path)[0];
}

View File

@@ -133,7 +133,7 @@ export default async function setupAndLink(
const project = projectOrNewProjectName;
await linkFolderToProject(
output,
client,
path,
{
projectId: project.id,
@@ -200,13 +200,14 @@ export default async function setupAndLink(
...localConfigurationOverrides,
sourceFilesOutsideRootDirectory,
},
autoAssignCustomDomains: true,
};
const deployment = await createDeploy(
client,
now,
config.currentTeam || 'current user',
[sourcePath],
sourcePath,
createArgs,
org,
true,
@@ -250,7 +251,7 @@ export default async function setupAndLink(
Object.assign(project, settings);
await linkFolderToProject(
output,
client,
path,
{
projectId: project.id,

View File

@@ -1,7 +1,7 @@
import http from 'http';
import open from 'open';
import { URL } from 'url';
import listen from 'async-listen';
import { listen } from 'async-listen';
import isDocker from 'is-docker';
import Client from '../client';
import prompt, { readInput } from './prompt';
@@ -64,8 +64,7 @@ async function getVerificationTokenInBand(
) {
const { output } = client;
const server = http.createServer();
const address = await listen(server, 0, '127.0.0.1');
const { port } = new URL(address);
const { port } = await listen(server, 0, '127.0.0.1');
url.searchParams.set('next', `http://localhost:${port}`);
output.log(`Please visit the following URL in your web browser:`);

View File

@@ -0,0 +1,40 @@
import type Client from '../client';
import { ProjectNotFound } from '../errors-ts';
import { ensureLink } from '../link/ensure-link';
import getProjectByNameOrId from './get-project-by-id-or-name';
import type { Project } from '@vercel-internals/types';
export default async function getProjectByCwdOrLink({
autoConfirm,
client,
commandName,
cwd,
projectNameOrId,
}: {
autoConfirm?: boolean;
client: Client;
commandName: string;
cwd: string;
projectNameOrId?: string;
}): Promise<Project> {
if (projectNameOrId) {
const project = await getProjectByNameOrId(client, projectNameOrId);
if (project instanceof ProjectNotFound) {
throw project;
}
return project;
}
// ensure the current directory is a linked project
const linkedProject = await ensureLink(commandName, client, cwd, {
autoConfirm,
});
if (typeof linkedProject === 'number') {
const err: NodeJS.ErrnoException = new Error('Link project error');
err.code = 'ERR_LINK_PROJECT';
throw err;
}
return linkedProject.project;
}

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