Compare commits

...

80 Commits

Author SHA1 Message Date
Vercel Release Bot
acc10e47c7 Version Packages (#10123)
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@31.0.0

### Major Changes

- Update `vc dev` redirect response to match production behavior
([#10143](https://github.com/vercel/vercel/pull/10143))

### Patch Changes

- require `--yes` to promote preview deployment
([#10135](https://github.com/vercel/vercel/pull/10135))

- [cli] Optimize write build result for vc build
([#10154](https://github.com/vercel/vercel/pull/10154))

- Only show relevant Project matches in Project selector
([#10114](https://github.com/vercel/vercel/pull/10114))

- [cli] Fix error message when token is invalid
([#10131](https://github.com/vercel/vercel/pull/10131))

- Updated dependencies
\[[`e4895d979`](e4895d979b),
[`346892210`](3468922108),
[`346892210`](3468922108),
[`a6de052ed`](a6de052ed2)]:
    -   @vercel/next@3.8.7
    -   @vercel/static-build@1.3.38
    -   @vercel/build-utils@6.8.0
    -   @vercel/remix-builder@1.8.15
    -   @vercel/node@2.15.3

## @vercel/build-utils@6.8.0

### Minor Changes

- Add `getNodeBinPaths()` and `traverseUpDirectories()` functions
([#10150](https://github.com/vercel/vercel/pull/10150))

## @vercel/client@12.6.3

### Patch Changes

- Updated dependencies
\[[`346892210`](3468922108)]:
    -   @vercel/build-utils@6.8.0

## @vercel/frameworks@1.4.3

### Patch Changes

- [frameworks] Update `saber.land` to `saber.egoist.dev`
([#10148](https://github.com/vercel/vercel/pull/10148))

## @vercel/fs-detectors@4.0.1

### Patch Changes

- Resolve symlinks in `LocalFileSystemDetector#readdir()`
([#10126](https://github.com/vercel/vercel/pull/10126))

- Updated dependencies
\[[`0867f11a6`](0867f11a6a)]:
    -   @vercel/frameworks@1.4.3

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

### Patch Changes

- Updated dependencies
\[[`346892210`](3468922108)]:
    -   @vercel/build-utils@6.8.0
    -   @vercel/node@2.15.3

## @vercel/next@3.8.7

### Patch Changes

- [next] Update payload flag
([#10147](https://github.com/vercel/vercel/pull/10147))

- Use `getNodeBinPaths()` function to improve monorepo support
([#10150](https://github.com/vercel/vercel/pull/10150))

## @vercel/node@2.15.3

### Patch Changes

- Updated dependencies
\[[`346892210`](3468922108)]:
    -   @vercel/build-utils@6.8.0

## @vercel/remix-builder@1.8.15

### Patch Changes

- Update `@remix-run/dev` fork to v1.18.0
([#10146](https://github.com/vercel/vercel/pull/10146))

- Updated dependencies
\[[`346892210`](3468922108)]:
    -   @vercel/build-utils@6.8.0

## @vercel/static-build@1.3.38

### Patch Changes

- Use `getNodeBinPaths()` function to improve monorepo support
([#10150](https://github.com/vercel/vercel/pull/10150))

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

## @vercel-internals/constants@1.0.3

### Patch Changes

- Updated dependencies
\[[`346892210`](3468922108)]:
    -   @vercel/build-utils@6.8.0

## @vercel-internals/types@1.0.3

### Patch Changes

- Updated dependencies
\[[`346892210`](3468922108)]:
    -   @vercel/build-utils@6.8.0
    -   @vercel-internals/constants@1.0.3
2023-06-28 12:29:31 -07:00
JJ Kasper
6a0e1e0b66 [cli] Optimize write build result for vc build (#10154)
As noticed this is copying all fallback files from output even if they are already on the disk in the build container which should be able to be considered a "pure" environment. This copying can cause disk space/perf issues when there are massive amounts of fallback files generated e.g. 8000 outputs at 200KB/output is already 1.6GB of copying needing to be done that could just be a move operation. 


x-ref: [slack thread](https://vercel.slack.com/archives/C03F2CMNGKG/p1687969734598509?thread_ts=1687963253.178369&cid=C03F2CMNGKG)
x-ref: [slack thread](https://vercel.slack.com/archives/C02SM2K2UM9/p1687970267370669)
x-ref: [slack thread](https://vercel.slack.com/archives/C03DQ3QFV7C/p1687338157228459)
2023-06-28 19:07:52 +00:00
Nathan Rajlich
3468922108 [build-utils] Add getNodeBinPaths() function (#10150)
The `getNodeBinPath()` function is problematic because it assumes that commands are installed in the `node_modules` directory alongside the detected lockfile. This works fine the majority of the time, but ends up not being the case when using a monorepo that uses a package manager in "linked" mode (i.e. pnpm by default).

Consider the following:

```
.
├── pnpm-lock.yaml
├── node_modules
├── blog
│   ├── node_modules
│   │   ├── hexo -> .pnpm/hexo@3.9.0/node_modules/hexo
```

In this setup, adding the root-level `node_modules/.bin` would not make the `hexo` command be visible in the `$PATH`.

To solve this issue, the new `getNodeBinPaths()` function returns an array of all directories up to the specified `root`, which can then be placed into the `$PATH`. It's also more efficient (synchronous) since it does not need to scan for a lockfile anymore (the `root` needs to be specified explicitly).

The new function is being used in `@vercel/next` and `@vercel/static-build`.

The `traverseUpDirectories()` function from CLI was moved to `build-utils` to implement this function. Consequently, that makes the implementations of `walkParentDirs()` and `walkParentDirsMulti()` simpler, since it's using this generator now.
2023-06-28 01:53:34 +00:00
JJ Kasper
e4895d979b [next] Update payload flag (#10147)
x-ref: [slack thread](https://vercel.slack.com/archives/C05E6RJTPJS/p1687898295532579)
2023-06-27 23:34:21 +00:00
Steven
733ff5ed85 [tests] Add x-vercel-id to test error message (#10149)
Including the `x-vercel-id` header when a e2e test fails will help us
debug issues
2023-06-27 19:05:55 -04:00
Steven
0867f11a6a [frameworks] Update saber.land to saber.egoist.dev (#10148)
The website url for Saber changed

x-ref:
[slack](https://vercel.slack.com/archives/C01RUTYJYHW/p1687900208904799)
2023-06-27 15:23:27 -07:00
Vercel Release Bot
a6de052ed2 [remix] Update @remix-run/dev to v1.18.0 (#10146)
This auto-generated PR updates `@remix-run/dev` to version 1.18.0.
2023-06-27 17:32:46 +00:00
Michaël De Boey
f5d48ec3bc [examples] Update remix template (#9846)
Bring in line with latest template
2023-06-26 16:52:24 -07:00
Sean Massa
6ec1180798 require --yes flag to promote preview deployment (#10135)
In order to promote a preview deployment, we want to make sure the user knows that this is not typical. Now the `--yes` flag is required to make this work.
2023-06-26 21:43:48 +00:00
Nathan Rajlich
36db62a491 Delete .changeset/beige-carrots-begin.md (#10144)
We don't want changesets to try and create a release / changelog for the
`examples` dir.
2023-06-26 13:12:21 -07:00
Vercel Release Bot
f9266e069f [tests] Upgrade Turbo to version 1.10.6 (#10140)
This auto-generated PR updates Turbo to version 1.10.6
2023-06-26 20:10:26 +00:00
Nathan Rajlich
8163a153df [cli] Respond with "Redirecting..." to match production behavior (#10143)
Production was recently changed to make redirect responses return the text "Redirecting..." without the destination nor status code in the text.

This caused some tests to start failing, so update `vc dev` to match this new behavior and update the relevant tests.
2023-06-26 19:41:35 +00:00
Steven
c5e6bd1a7a Delete lerna.json (#10133)
We no longer use lerna since switching to changesets so we can delete `lerna.json`

- See https://github.com/vercel/vercel/pull/9914
2023-06-23 16:14:23 +00:00
Steven
c2f1bebd1f [cli] Fix error message when token is invalid (#10131)
This changes the error when a token is invalid or expired from

```
Error: Could not retrieve Project Settings. To link your Project, remove the `.vercel` directory and deploy again.
Learn More: https://vercel.link/cannot-load-project-settings
```

to a better error

```
Error: The specified token is not valid. Use `vercel login` to generate a new token.
```

- This could be considered a follow up to
https://github.com/vercel/vercel/pull/7794
2023-06-23 11:18:58 -04:00
Nathan Rajlich
3138415533 [fs-detectors] Resolve symlinks in LocalFileSystemDetector#readdir() (#10126)
`LocalFileSystemDetector#readdir()` was throwing an error when a symlink was encountered, due to `fs.readdir()` `withFileTypes: true` option performing an lstat instead of a stat operation.

So re-implement the `readdir()` logic to use `fs.stat()` so that the symlink is resolved (only "dir" and "file" types are expected in the result).
2023-06-22 18:19:28 +00:00
Vercel Release Bot
8f6813bb63 [examples][tests] Upgrade Next.js to version 13.4.7 (#10125)
This auto-generated PR updates 3 packages to Next.js version 13.4.7
2023-06-22 00:36:23 +00:00
Nathan Rajlich
734499fc03 [cli] Only show relevant Project matches in Project selector (#10114)
When showing the Project selector and there's more than one Project matched given the current cwd, only show the matched Projects instead of all Projects listed in the `repo.json` file.
2023-06-21 17:22:21 +00:00
Nathan Rajlich
f06988d914 [cli] Add debug logging for repo link root lookup (#10112)
Adds some logging during the root directory resolving logic to help debug any cases where that lookup isn't behaving correctly.
2023-06-20 18:09:40 +00:00
Vercel Release Bot
71ac16220b Version Packages (#10107)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-20 11:42:04 -05:00
Kiko Beats
8b3a4146af [node][edge][cli] upgrade Edge Runtime (#10051)
We avoided to use `undici.WebSocket` because @jawj found a bug in the
implementation.

The [fix was merged](https://github.com/nodejs/undici/pull/2106) in
[undici@5.22.1](https://github.com/nodejs/undici/releases/tag/v5.22.1),
so we can be back to use it.

The latest version of Edge Runtime exposes `undici.WebSocket` compatible
with node.js 14, 16 & 18

---------

Co-authored-by: Sean Massa <endangeredmassa@gmail.com>
2023-06-20 11:06:43 +02:00
Nathan Rajlich
cfea31e6cf Remove .changeset/curvy-stingrays-cheat.md (#10115) 2023-06-16 15:45:52 -07:00
Vercel Release Bot
7090fec110 [examples][tests] Upgrade Next.js to version 13.4.6 (#10111)
This auto-generated PR updates 3 packages to Next.js version 13.4.6
2023-06-16 22:21:41 +00:00
Sean Massa
bc7c80fb9b [cli] do not force auto-assign value on deployments (#10110)
When `vc deploy` happens, it was forcing a `true`/`false` value for `autoAssignCustomDomains`. This overwrites the project setting in some cases, which is not what we want.

If a CLI command or API call explicitly wants to force `autoAssignCustomDomains` on or off, it can. Otherwise, the project setting value should be used.

This PR only sets `autoAssignCustomDomains` to `false` when the `--skip-domain` flag is passed. Otherwise, the value is `undefined` so that the project setting can take effect.
2023-06-15 22:19:34 +00:00
Sean Massa
91406abdb0 [node] add tests to getBodyParser helper (#10109) 2023-06-15 12:31:47 -05:00
Nathan Rajlich
a5af8381ce [fs-detectors] Add test-e2e script (#10103)
Seems we have not been running the `fs-detectors` integration tests.
2023-06-14 19:20:20 +00:00
Nathan Rajlich
2230ea6cc1 [remix] Link to https://vercel.com/help (#10106) 2023-06-14 18:53:14 +00:00
Vercel Release Bot
f057f0421b Version Packages (#10081) 2023-06-14 10:47:10 -07:00
Nathan Rajlich
42c0b32a8d [fs-detectors] Use LocalFileSystemDetector instead of FixtureFilesystem (#10100)
The code for these two are almost identical, so consolidate into one codebase.

Also adjusts the `pnpm test` script to allow for specifying a file name to be executed, instead of running all tests.
2023-06-13 23:30:00 +00:00
Chris Barber
d61a1a7988 [cli] Fix team validation bug where you are apart of a team (#10092)
When consolidating the deployment team validation, a bug was introduced where the command would error if the user was currently using a team. The logic was meant to copy the logic in `getDeploymentByIdOrURL()`: https://github.com/vercel/vercel/blob/main/packages/cli/src/util/deploy/get-deployment-by-id-or-url.ts#L80.
2023-06-12 16:32:01 +00:00
Vercel Release Bot
c438bbb362 [examples][tests] Upgrade Next.js to version 13.4.5 (#10097)
This auto-generated PR updates 3 packages to Next.js version 13.4.5
2023-06-12 15:02:47 +00:00
Vercel Release Bot
cb5eef0eb5 [tests] Upgrade Turbo to version 1.10.3 (#10096)
This auto-generated PR updates Turbo to version 1.10.3
2023-06-11 07:44:11 +00:00
Nathan Rajlich
79dee367cf [cli] Remove findProjectFromPath() (#10093)
Superceded by the `findProjectsFromPath()` function which may return multiple matches, and it was only being used in tests.

The relevant tests have been updated to use the multiple matches version instead, and updated to include the case where multiple matches are returned.

__Note:__ No changeset for this one since it's an internal function being removed, and doesn't need to be referenced in the public changelog.
2023-06-09 22:59:17 +00:00
Nathan Rajlich
dea58dea7e [cli] Add support for vc deploy --prebuilt command with repo link (#10083)
When repo linked, `vc deploy --prebuilt` will change working directory to the Project root directory, instead of the repo root, so that the project's local `.vercel/output` directory is what gets uploaded + deployed.
2023-06-09 09:54:17 +00:00
Steven
fecebfa7fa [cli] vc env pull should add .env*.local to .gitignore (#10085)
This is a follow up to PR #9892 which changed the default to `.env.local`.

Now that we know local files should never be committed to git, we can automatically add `.env*.local` to `.gitignore`. Note that this is the same ignore pattern that ships with create-next-app [as seen here](06abd63489/packages/create-next-app/templates/app/js/gitignore (L28)), so most Next.js users won't see anything change.

See the related [Linear ticket](https://linear.app/vercel/issue/VCCLI-461/)
2023-06-08 00:09:22 +00:00
Nathan Rajlich
94d5612dce [cli] Move readme copy logic to a helper function for vc link (#10084)
ncc has an issue with detecting + rewriting this file path for some reason. Moving to a helper function should work around that issue.

Fixing:

```
Error: ENOENT: no such file or directory, open '/node_modules/vercel/projects/VERCEL_DIR_README.txt'
```
2023-06-07 21:33:47 +00:00
Nathan Rajlich
3eaf58bb74 [cli] Add support for vc dev command with repo link (#10082)
When repo linked, `vc dev` already works fine when run from the root of the repo. This change makes it so that `vc dev` also works as expected when executed within a project subdirectory.
2023-06-07 18:48:28 +00:00
Nathan Rajlich
e63cf40153 [cli] Add support for vc build command with repo link (#10075)
When the repo is linked to Vercel with `vc link --repo`, the `vc build` command should be invoked from the project subdirectory (otherwise the project selector is displayed). The output directory is at `<projectRoot>/.vercel/output` instead of at the repo root.
2023-06-07 08:26:13 +00:00
Sean Massa
709c9509f4 Revert "Revert "[cli] Add support for vc pull command with repo link"" (#10078)
Reverts vercel/vercel#10076

Restores the original PR: https://github.com/vercel/vercel/pull/10071

With the fix from: https://github.com/vercel/vercel/pull/10073
2023-06-07 07:49:45 +00:00
Nathan Rajlich
6107c1ed22 Disable "Enforce Changeset" job for release PRs (#10080)
This job leads to a false-positive for the release PR, so disable it.
2023-06-06 23:27:39 -07:00
Vercel Release Bot
7a0f377afe Version Packages (#10074)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-07 01:23:29 -05:00
Sean Massa
a04bf557fc handle undefined content type in vc dev (#10077)
When no content type header is sent to an API request during `vc dev`, the request fails:

```
/Users/smassa/source/vercel/vercel-2/node_modules/.pnpm/content-type@1.0.4/node_modules/content-type/index.js:108
    throw new TypeError('argument string is required')
          ^
TypeError: argument string is required
...
```

This comes from some runtime type validation happening in the `content-type` package, for which we do not have types, which is why typescript didn't catch this.
2023-06-07 06:20:19 +00:00
Sean Massa
b6736e82cf Clear revert out of changelog (#10079) 2023-06-07 00:46:21 -05:00
Sean Massa
7923056bc0 Revert "[cli] Add support for vc pull command with repo link" (#10076) 2023-06-07 00:35:12 -05:00
Nathan Rajlich
71ff193ea3 [cli] Add support for vc pull command with repo link (#10071)
When the repo is linked to Vercel with `vc link --repo`, the `.vercel` directory will be created at the _project root_ instead of the _repo root_, and will still contain the `project.json`.

The difference is that the `orgId` and `projectId` props will not be present in the `project.json` file when repo linked, since that information is available at the root level `repo.json` file.
2023-06-06 22:01:37 +00:00
Vercel Release Bot
c21d93de44 Version Packages (#10062)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-06 16:34:04 -05:00
Kiko Beats
0039c8b5ce [node] Add isomorphic functions (#9947)
This PR allow using Web APIs in Serverless functions

```js
// api/serverless.js
export const GET = () => {
  return new Response(`new Response('👋 Hello from Serverless Web!)`)
}
```

More about that
https://nextjs.org/docs/app/building-your-application/routing/router-handlers

---------

Co-authored-by: Sean Massa <EndangeredMassa@gmail.com>
2023-06-06 23:15:10 +02:00
Vercel Release Bot
49c7178567 [remix] Update @remix-run/dev to v1.17.0 (#10072)
This auto-generated PR updates `@remix-run/dev` to version 1.17.0.
2023-06-06 20:31:48 +00:00
Ethan Arrowood
b038b29614 Add vercel.json setting overrides to storybook example for zero-config experience (#10067)
This PR adds necessary configuration overrides to the storybook example so that it can have a zero-config experience.
2023-06-06 00:52:38 +00:00
Nathan Rajlich
7a249a2284 Enforce a changeset file to be present (#10065)
Based off of these setup instructions:

https://github.com/changesets/changesets/blob/main/docs/automating-changesets.md#blocking

If a commit should really not publish a release, you can run `changeset
--empty`.
2023-06-05 15:44:40 -07:00
Nathan Rajlich
a5e32ec31d [cli] Add client.fetchPaginated() async iterator (#10054)
Adds async iterator helper function for interacting with endpoints that have pagination.

Implemented for use with `vc bisect` (fetching deployments) and `vc link --repo` (fetching projects).
2023-06-05 17:06:57 +00:00
Florentin / 珞辰
bc5afe24c4 [node] add maxDuration config support for vc node deployments (#10028)
This PR enables specifying `maxDuration` in `config` for node vc
deployments.

---------

Co-authored-by: Nathan Rajlich <n@n8.io>
2023-06-05 10:05:53 +02:00
Vercel Release Bot
5070e3bbbd [tests] Upgrade Turbo to version 1.10.1 (#10059)
This auto-generated PR updates Turbo to version 1.10.1
2023-06-05 03:57:56 +00:00
Vercel Release Bot
4ad1cbbd7d Version Packages (#10058)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-02 19:29:17 -05:00
Chris Barber
4f4e09477d Attempting to publish build-utils and vercel (#10057) 2023-06-02 19:24:32 -05:00
Chris Barber
cd35071f60 Attempting to publish build-utils and vercel (#10057) 2023-06-02 19:22:22 -05:00
Vercel Release Bot
f373c94508 Version Packages (#10055)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-02 16:28:57 -05:00
Chris Barber
553c001eb0 [cli] vc build ignore .env* & ignore files for @vercel/static (#10056)
For projects with static files only (e.g. `@vercel/static` builder), do not copy`.env*`, `.vercelignore`, or `.nowignore` into the BOA output dir.
2023-06-02 21:04:03 +00:00
Chris Barber
f6c3a95783 [cli] Ensure .npmrc does not contain use-node-version (#10049)
When a project has a `.npmrc` containing `use-node-version`, package managers (notably `pnpm`) will download the specified Node.js version. This is not the correct way as it can lead to `pnpm` downloading Node.js 18 or newer which depends on a version of GLIBC that is not present in the current AWS image. The proper way is to set the `"engines"` in the `package.json`.

<img width="468" alt="image" src="https://github.com/vercel/vercel/assets/97262/0974cf05-6a11-4d95-88e8-13affc4aad2a">

Discussion: https://github.com/orgs/vercel/discussions/2436
2023-06-02 15:27:28 +00:00
Sean Massa
c0bcef0ca4 Update CODEOWNERS for .changeset/ (#10053) 2023-06-01 12:07:18 -05:00
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
211 changed files with 10123 additions and 14974 deletions

4
.github/CODEOWNERS vendored
View File

@@ -1,6 +1,7 @@
# Documentation
# https://help.github.com/en/articles/about-code-owners
# Restricted Paths
* @TooTallNate @EndangeredMassa @styfle @cb1kenobi @Ethan-Arrowood
/.github/workflows @TooTallNate @EndangeredMassa @styfle @cb1kenobi @Ethan-Arrowood @ijjk
/packages/fs-detectors @TooTallNate @EndangeredMassa @styfle @cb1kenobi @Ethan-Arrowood @agadzik @chloetedder
@@ -14,3 +15,6 @@
/examples/jekyll @styfle
/examples/zola @styfle
/packages/node @TooTallNate @EndangeredMassa @styfle @cb1kenobi @Ethan-Arrowood @Kikobeats
# Unrestricted Paths
.changeset/

View File

@@ -23,6 +23,9 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Fetch git tags
run: git fetch origin 'refs/tags/*:refs/tags/*'
- name: Setup Node
uses: actions/setup-node@v3
with:
@@ -47,8 +50,8 @@ jobs:
id: changesets
uses: changesets/action@v1
with:
version: pnpm version:prepare
publish: pnpm release
version: pnpm ci:version
publish: pnpm ci:publish
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PULL_REQUESTS }}
NPM_CONFIG_PROVENANCE: 'true'

View File

@@ -19,6 +19,22 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
enforce-changeset:
name: Enforce Changeset
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.title != 'Version Packages'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- run: git checkout ${{ github.event.pull_request.head.ref }}
- name: install pnpm@8.3.1
run: npm i -g pnpm@8.3.1
- run: pnpm install
# Enforce a changeset file to be present
- run: pnpm exec changeset status --since=main
test:
name: Lint
timeout-minutes: 10

View File

@@ -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

@@ -8,17 +8,17 @@
"name": "nextjs",
"version": "0.1.0",
"dependencies": {
"eslint": "8.40.0",
"eslint-config-next": "13.4.3",
"next": "13.4.3",
"eslint": "8.43.0",
"eslint-config-next": "13.4.7",
"next": "13.4.7",
"react": "18.2.0",
"react-dom": "18.2.0"
}
},
"node_modules/@babel/runtime": {
"version": "7.21.5",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.5.tgz",
"integrity": "sha512-8jI69toZqqcsnqGGqwGS4Qb1VwLOEp4hz+CXPywcvjs60u3B4Pom/U/7rm4W8tMOYEB+E9wgD0mW1l3r8qlI9Q==",
"version": "7.22.5",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.5.tgz",
"integrity": "sha512-ecjvYlnAaZ/KVneE/OdKYBYfgXV3Ptu6zQWmgEF7vwKhQnvVS6bjMD2XYgj+SNvQ1GfK/pjgokfPkC/2CO8CuA==",
"dependencies": {
"regenerator-runtime": "^0.13.11"
},
@@ -71,17 +71,17 @@
}
},
"node_modules/@eslint/js": {
"version": "8.40.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.40.0.tgz",
"integrity": "sha512-ElyB54bJIhXQYVKjDSvCkPO1iU1tSAeVQJbllWJq1XQSmmA4dgFk8CbiBGpiOPxleE48vDogxCtmMYku4HSVLA==",
"version": "8.43.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.43.0.tgz",
"integrity": "sha512-s2UHCoiXfxMvmfzqoN+vrQ84ahUSYde9qNO1MdxmoEhyHWsfmwOpFlwYV+ePJEVc7gFnATGUi376WowX1N7tFg==",
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
}
},
"node_modules/@humanwhocodes/config-array": {
"version": "0.11.8",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz",
"integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==",
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz",
"integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==",
"dependencies": {
"@humanwhocodes/object-schema": "^1.2.1",
"debug": "^4.1.1",
@@ -109,22 +109,22 @@
"integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA=="
},
"node_modules/@next/env": {
"version": "13.4.3",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.3.tgz",
"integrity": "sha512-pa1ErjyFensznttAk3EIv77vFbfSYT6cLzVRK5jx4uiRuCQo+m2wCFAREaHKIy63dlgvOyMlzh6R8Inu8H3KrQ=="
"version": "13.4.7",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.7.tgz",
"integrity": "sha512-ZlbiFulnwiFsW9UV1ku1OvX/oyIPLtMk9p/nnvDSwI0s7vSoZdRtxXNsaO+ZXrLv/pMbXVGq4lL8TbY9iuGmVw=="
},
"node_modules/@next/eslint-plugin-next": {
"version": "13.4.3",
"resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-13.4.3.tgz",
"integrity": "sha512-5B0uOnh7wyUY9vNNdIA6NUvWozhrZaTMZOzdirYAefqD0ZBK5C/h3+KMYdCKrR7JrXGvVpWnHtv54b3dCzwICA==",
"version": "13.4.7",
"resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-13.4.7.tgz",
"integrity": "sha512-ANEPltxzXbyyG7CvqxdY4PmeM5+RyWdAJGufTHnU+LA/i3J6IDV2r8Z4onKwskwKEhwqzz5lMaSYGGXLyHX+mg==",
"dependencies": {
"glob": "7.1.7"
}
},
"node_modules/@next/swc-darwin-arm64": {
"version": "13.4.3",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.3.tgz",
"integrity": "sha512-yx18udH/ZmR4Bw4M6lIIPE3JxsAZwo04iaucEfA2GMt1unXr2iodHUX/LAKNyi6xoLP2ghi0E+Xi1f4Qb8f1LQ==",
"version": "13.4.7",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.7.tgz",
"integrity": "sha512-VZTxPv1b59KGiv/pZHTO5Gbsdeoxcj2rU2cqJu03btMhHpn3vwzEK0gUSVC/XW96aeGO67X+cMahhwHzef24/w==",
"cpu": [
"arm64"
],
@@ -137,9 +137,9 @@
}
},
"node_modules/@next/swc-darwin-x64": {
"version": "13.4.3",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.3.tgz",
"integrity": "sha512-Mi8xJWh2IOjryAM1mx18vwmal9eokJ2njY4nDh04scy37F0LEGJ/diL6JL6kTXi0UfUCGbMsOItf7vpReNiD2A==",
"version": "13.4.7",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.7.tgz",
"integrity": "sha512-gO2bw+2Ymmga+QYujjvDz9955xvYGrWofmxTq7m70b9pDPvl7aDFABJOZ2a8SRCuSNB5mXU8eTOmVVwyp/nAew==",
"cpu": [
"x64"
],
@@ -152,9 +152,9 @@
}
},
"node_modules/@next/swc-linux-arm64-gnu": {
"version": "13.4.3",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.3.tgz",
"integrity": "sha512-aBvtry4bxJ1xwKZ/LVPeBGBwWVwxa4bTnNkRRw6YffJnn/f4Tv4EGDPaVeYHZGQVA56wsGbtA6nZMuWs/EIk4Q==",
"version": "13.4.7",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.7.tgz",
"integrity": "sha512-6cqp3vf1eHxjIDhEOc7Mh/s8z1cwc/l5B6ZNkOofmZVyu1zsbEM5Hmx64s12Rd9AYgGoiCz4OJ4M/oRnkE16/Q==",
"cpu": [
"arm64"
],
@@ -167,9 +167,9 @@
}
},
"node_modules/@next/swc-linux-arm64-musl": {
"version": "13.4.3",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.3.tgz",
"integrity": "sha512-krT+2G3kEsEUvZoYte3/2IscscDraYPc2B+fDJFipPktJmrv088Pei/RjrhWm5TMIy5URYjZUoDZdh5k940Dyw==",
"version": "13.4.7",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.7.tgz",
"integrity": "sha512-T1kD2FWOEy5WPidOn1si0rYmWORNch4a/NR52Ghyp4q7KyxOCuiOfZzyhVC5tsLIBDH3+cNdB5DkD9afpNDaOw==",
"cpu": [
"arm64"
],
@@ -182,9 +182,9 @@
}
},
"node_modules/@next/swc-linux-x64-gnu": {
"version": "13.4.3",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.3.tgz",
"integrity": "sha512-AMdFX6EKJjC0G/CM6hJvkY8wUjCcbdj3Qg7uAQJ7PVejRWaVt0sDTMavbRfgMchx8h8KsAudUCtdFkG9hlEClw==",
"version": "13.4.7",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.7.tgz",
"integrity": "sha512-zaEC+iEiAHNdhl6fuwl0H0shnTzQoAoJiDYBUze8QTntE/GNPfTYpYboxF5LRYIjBwETUatvE0T64W6SKDipvg==",
"cpu": [
"x64"
],
@@ -197,9 +197,9 @@
}
},
"node_modules/@next/swc-linux-x64-musl": {
"version": "13.4.3",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.3.tgz",
"integrity": "sha512-jySgSXE48shaLtcQbiFO9ajE9mqz7pcAVLnVLvRIlUHyQYR/WyZdK8ehLs65Mz6j9cLrJM+YdmdJPyV4WDaz2g==",
"version": "13.4.7",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.7.tgz",
"integrity": "sha512-X6r12F8d8SKAtYJqLZBBMIwEqcTRvUdVm+xIq+l6pJqlgT2tNsLLf2i5Cl88xSsIytBICGsCNNHd+siD2fbWBA==",
"cpu": [
"x64"
],
@@ -212,9 +212,9 @@
}
},
"node_modules/@next/swc-win32-arm64-msvc": {
"version": "13.4.3",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.3.tgz",
"integrity": "sha512-5DxHo8uYcaADiE9pHrg8o28VMt/1kR8voDehmfs9AqS0qSClxAAl+CchjdboUvbCjdNWL1MISCvEfKY2InJ3JA==",
"version": "13.4.7",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.7.tgz",
"integrity": "sha512-NPnmnV+vEIxnu6SUvjnuaWRglZzw4ox5n/MQTxeUhb5iwVWFedolPFebMNwgrWu4AELwvTdGtWjqof53AiWHcw==",
"cpu": [
"arm64"
],
@@ -227,9 +227,9 @@
}
},
"node_modules/@next/swc-win32-ia32-msvc": {
"version": "13.4.3",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.3.tgz",
"integrity": "sha512-LaqkF3d+GXRA5X6zrUjQUrXm2MN/3E2arXBtn5C7avBCNYfm9G3Xc646AmmmpN3DJZVaMYliMyCIQCMDEzk80w==",
"version": "13.4.7",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.7.tgz",
"integrity": "sha512-6Hxijm6/a8XqLQpOOf/XuwWRhcuc/g4rBB2oxjgCMuV9Xlr2bLs5+lXyh8w9YbAUMYR3iC9mgOlXbHa79elmXw==",
"cpu": [
"ia32"
],
@@ -242,9 +242,9 @@
}
},
"node_modules/@next/swc-win32-x64-msvc": {
"version": "13.4.3",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.3.tgz",
"integrity": "sha512-jglUk/x7ZWeOJWlVoKyIAkHLTI+qEkOriOOV+3hr1GyiywzcqfI7TpFSiwC7kk1scOiH7NTFKp8mA3XPNO9bDw==",
"version": "13.4.7",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.7.tgz",
"integrity": "sha512-sW9Yt36Db1nXJL+mTr2Wo0y+VkPWeYhygvcHj1FF0srVtV+VoDjxleKtny21QHaG05zdeZnw2fCtf2+dEqgwqA==",
"cpu": [
"x64"
],
@@ -289,9 +289,9 @@
}
},
"node_modules/@pkgr/utils": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.4.0.tgz",
"integrity": "sha512-2OCURAmRtdlL8iUDTypMrrxfwe8frXTeXaxGsVOaYtc/wrUyk8Z/0OBetM7cdlsy7ZFWlMX72VogKeh+A4Xcjw==",
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.4.1.tgz",
"integrity": "sha512-JOqwkgFEyi+OROIyq7l4Jy28h/WwhDnG/cPkXG2Z1iFbubB6jsHW1NDvmyOzTBxHr3yg68YGirmh1JUgMqa+9w==",
"dependencies": {
"cross-spawn": "^7.0.3",
"fast-glob": "^3.2.12",
@@ -308,9 +308,9 @@
}
},
"node_modules/@rushstack/eslint-patch": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.2.0.tgz",
"integrity": "sha512-sXo/qW2/pAcmT43VoRKOJbDOfV3cYpq3szSVfIThQXNt+E4DfKj361vaAt3c88U5tPUxzEswam7GW48PJqtKAg=="
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.3.2.tgz",
"integrity": "sha512-V+MvGwaHH03hYhY+k6Ef/xKd6RYlc4q8WBx+2ANmipHJcKuktNcI/NgEsJgdSUF6Lw32njT6OnrRsKYCdgHjYw=="
},
"node_modules/@swc/helpers": {
"version": "0.5.1",
@@ -326,13 +326,13 @@
"integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ=="
},
"node_modules/@typescript-eslint/parser": {
"version": "5.59.6",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.6.tgz",
"integrity": "sha512-7pCa6al03Pv1yf/dUg/s1pXz/yGMUBAw5EeWqNTFiSueKvRNonze3hma3lhdsOrQcaOXhbk5gKu2Fludiho9VA==",
"version": "5.60.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.60.0.tgz",
"integrity": "sha512-jBONcBsDJ9UoTWrARkRRCgDz6wUggmH5RpQVlt7BimSwaTkTjwypGzKORXbR4/2Hqjk9hgwlon2rVQAjWNpkyQ==",
"dependencies": {
"@typescript-eslint/scope-manager": "5.59.6",
"@typescript-eslint/types": "5.59.6",
"@typescript-eslint/typescript-estree": "5.59.6",
"@typescript-eslint/scope-manager": "5.60.0",
"@typescript-eslint/types": "5.60.0",
"@typescript-eslint/typescript-estree": "5.60.0",
"debug": "^4.3.4"
},
"engines": {
@@ -352,12 +352,12 @@
}
},
"node_modules/@typescript-eslint/scope-manager": {
"version": "5.59.6",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.6.tgz",
"integrity": "sha512-gLbY3Le9Dxcb8KdpF0+SJr6EQ+hFGYFl6tVY8VxLPFDfUZC7BHFw+Vq7bM5lE9DwWPfx4vMWWTLGXgpc0mAYyQ==",
"version": "5.60.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.60.0.tgz",
"integrity": "sha512-hakuzcxPwXi2ihf9WQu1BbRj1e/Pd8ZZwVTG9kfbxAMZstKz8/9OoexIwnmLzShtsdap5U/CoQGRCWlSuPbYxQ==",
"dependencies": {
"@typescript-eslint/types": "5.59.6",
"@typescript-eslint/visitor-keys": "5.59.6"
"@typescript-eslint/types": "5.60.0",
"@typescript-eslint/visitor-keys": "5.60.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@@ -368,9 +368,9 @@
}
},
"node_modules/@typescript-eslint/types": {
"version": "5.59.6",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.6.tgz",
"integrity": "sha512-tH5lBXZI7T2MOUgOWFdVNUILsI02shyQvfzG9EJkoONWugCG77NDDa1EeDGw7oJ5IvsTAAGVV8I3Tk2PNu9QfA==",
"version": "5.60.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.60.0.tgz",
"integrity": "sha512-ascOuoCpNZBccFVNJRSC6rPq4EmJ2NkuoKnd6LDNyAQmdDnziAtxbCGWCbefG1CNzmDvd05zO36AmB7H8RzKPA==",
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
@@ -380,12 +380,12 @@
}
},
"node_modules/@typescript-eslint/typescript-estree": {
"version": "5.59.6",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.6.tgz",
"integrity": "sha512-vW6JP3lMAs/Tq4KjdI/RiHaaJSO7IUsbkz17it/Rl9Q+WkQ77EOuOnlbaU8kKfVIOJxMhnRiBG+olE7f3M16DA==",
"version": "5.60.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.60.0.tgz",
"integrity": "sha512-R43thAuwarC99SnvrBmh26tc7F6sPa2B3evkXp/8q954kYL6Ro56AwASYWtEEi+4j09GbiNAHqYwNNZuNlARGQ==",
"dependencies": {
"@typescript-eslint/types": "5.59.6",
"@typescript-eslint/visitor-keys": "5.59.6",
"@typescript-eslint/types": "5.60.0",
"@typescript-eslint/visitor-keys": "5.60.0",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
@@ -406,11 +406,11 @@
}
},
"node_modules/@typescript-eslint/visitor-keys": {
"version": "5.59.6",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.6.tgz",
"integrity": "sha512-zEfbFLzB9ETcEJ4HZEEsCR9HHeNku5/Qw1jSS5McYJv5BR+ftYXwFFAH5Al+xkGaZEqowMwl7uoJjQb1YSPF8Q==",
"version": "5.60.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.60.0.tgz",
"integrity": "sha512-wm9Uz71SbCyhUKgcaPRauBdTegUyY/ZWl8gLwD/i/ybJqscrrdVSFImpvUz16BLPChIeKBK5Fa9s6KDQjsjyWw==",
"dependencies": {
"@typescript-eslint/types": "5.59.6",
"@typescript-eslint/types": "5.60.0",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
@@ -422,9 +422,9 @@
}
},
"node_modules/acorn": {
"version": "8.8.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz",
"integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==",
"version": "8.9.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.9.0.tgz",
"integrity": "sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==",
"bin": {
"acorn": "bin/acorn"
},
@@ -483,11 +483,11 @@
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
},
"node_modules/aria-query": {
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz",
"integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==",
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.2.1.tgz",
"integrity": "sha512-7uFg4b+lETFgdaJyETnILsXgnnzVnkHcgRbwbPwevm5x/LmUlt3MjczMRe1zg824iBgXZNRPTBftNYyRSKLp2g==",
"dependencies": {
"deep-equal": "^2.0.5"
"dequal": "^2.0.3"
}
},
"node_modules/array-buffer-byte-length": {
@@ -591,19 +591,19 @@
}
},
"node_modules/axe-core": {
"version": "4.7.1",
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.7.1.tgz",
"integrity": "sha512-sCXXUhA+cljomZ3ZAwb8i1p3oOlkABzPy08ZDAoGcYuvtBPlQ1Ytde129ArXyHWDhfeewq7rlx9F+cUx2SSlkg==",
"version": "4.7.2",
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.7.2.tgz",
"integrity": "sha512-zIURGIS1E1Q4pcrMjp+nnEh+16G56eG/MUllJH8yEvw7asDo7Ac9uhC9KIH5jzpITueEZolfYglnCGIuSBz39g==",
"engines": {
"node": ">=4"
}
},
"node_modules/axobject-query": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.1.1.tgz",
"integrity": "sha512-goKlv8DZrK9hUh975fnHzhNIO4jUnFCfv/dszV5VwUGDFjI6vQ2VwoyjYjYNEbBE8AH87TduWP5uyDR1D+Iteg==",
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz",
"integrity": "sha512-jsyHu61e6N4Vbz/v18DHwWYKK0bSWLqn47eeDSKPB7m8tqMHF9YJ+mhIk2lVteyZrY8tnSj/jHOv4YiTCuCJgg==",
"dependencies": {
"deep-equal": "^2.0.5"
"dequal": "^2.0.3"
}
},
"node_modules/balanced-match": {
@@ -696,9 +696,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001488",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001488.tgz",
"integrity": "sha512-NORIQuuL4xGpIy6iCCQGN4iFjlBXtfKWIenlUuyZJumLRIindLb7wXM+GO8erEhb7vXfcnf4BAg2PrSDN5TNLQ==",
"version": "1.0.30001506",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001506.tgz",
"integrity": "sha512-6XNEcpygZMCKaufIcgpQNZNf00GEqc7VQON+9Rd0K1bMYo8xhMZRAo5zpbnbMNizi4YNgIDAFrdykWsvY3H4Hw==",
"funding": [
{
"type": "opencollective",
@@ -789,34 +789,6 @@
}
}
},
"node_modules/deep-equal": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.1.tgz",
"integrity": "sha512-lKdkdV6EOGoVn65XaOsPdH4rMxTZOnmFyuIkMjM1i5HHCbfjC97dawgTAy0deYNfuqUqW+Q5VrVaQYtUpSd6yQ==",
"dependencies": {
"array-buffer-byte-length": "^1.0.0",
"call-bind": "^1.0.2",
"es-get-iterator": "^1.1.3",
"get-intrinsic": "^1.2.0",
"is-arguments": "^1.1.1",
"is-array-buffer": "^3.0.2",
"is-date-object": "^1.0.5",
"is-regex": "^1.1.4",
"is-shared-array-buffer": "^1.0.2",
"isarray": "^2.0.5",
"object-is": "^1.1.5",
"object-keys": "^1.1.1",
"object.assign": "^4.1.4",
"regexp.prototype.flags": "^1.5.0",
"side-channel": "^1.0.4",
"which-boxed-primitive": "^1.0.2",
"which-collection": "^1.0.1",
"which-typed-array": "^1.1.9"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/deep-is": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
@@ -880,6 +852,14 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/dequal": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
"integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",
"engines": {
"node": ">=6"
}
},
"node_modules/dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
@@ -908,9 +888,9 @@
"integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="
},
"node_modules/enhanced-resolve": {
"version": "5.14.0",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.14.0.tgz",
"integrity": "sha512-+DCows0XNwLDcUhbFJPdlQEVnT2zXlCv7hPxemTz86/O+B/hCQ+mb7ydkPKiflpVraqLPCAfu7lDy+hBXueojw==",
"version": "5.15.0",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz",
"integrity": "sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==",
"dependencies": {
"graceful-fs": "^4.2.4",
"tapable": "^2.2.0"
@@ -966,25 +946,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/es-get-iterator": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz",
"integrity": "sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw==",
"dependencies": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.1.3",
"has-symbols": "^1.0.3",
"is-arguments": "^1.1.1",
"is-map": "^2.0.2",
"is-set": "^2.0.2",
"is-string": "^1.0.7",
"isarray": "^2.0.5",
"stop-iteration-iterator": "^1.0.0"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/es-set-tostringtag": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz",
@@ -1034,15 +995,15 @@
}
},
"node_modules/eslint": {
"version": "8.40.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.40.0.tgz",
"integrity": "sha512-bvR+TsP9EHL3TqNtj9sCNJVAFK3fBN8Q7g5waghxyRsPLIMwL73XSKnZFK0hk/O2ANC+iAoq6PWMQ+IfBAJIiQ==",
"version": "8.43.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.43.0.tgz",
"integrity": "sha512-aaCpf2JqqKesMFGgmRPessmVKjcGXqdlAYLLC3THM8t5nBRZRQ+st5WM/hoJXkdioEXLLbXgclUpM0TXo5HX5Q==",
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.4.0",
"@eslint/eslintrc": "^2.0.3",
"@eslint/js": "8.40.0",
"@humanwhocodes/config-array": "^0.11.8",
"@eslint/js": "8.43.0",
"@humanwhocodes/config-array": "^0.11.10",
"@humanwhocodes/module-importer": "^1.0.1",
"@nodelib/fs.walk": "^1.2.8",
"ajv": "^6.10.0",
@@ -1061,13 +1022,12 @@
"find-up": "^5.0.0",
"glob-parent": "^6.0.2",
"globals": "^13.19.0",
"grapheme-splitter": "^1.0.4",
"graphemer": "^1.4.0",
"ignore": "^5.2.0",
"import-fresh": "^3.0.0",
"imurmurhash": "^0.1.4",
"is-glob": "^4.0.0",
"is-path-inside": "^3.0.3",
"js-sdsl": "^4.1.4",
"js-yaml": "^4.1.0",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.4.1",
@@ -1090,11 +1050,11 @@
}
},
"node_modules/eslint-config-next": {
"version": "13.4.3",
"resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-13.4.3.tgz",
"integrity": "sha512-1lXwdFi29fKxzeugof/TUE7lpHyJQt5+U4LaUHyvQfHjvsWO77vFNicJv5sX6k0VDVSbnfz0lw+avxI+CinbMg==",
"version": "13.4.7",
"resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-13.4.7.tgz",
"integrity": "sha512-+IRAyD0+J1MZaTi9RQMPUfr6Q+GCZ1wOkK6XM52Vokh7VI4R6YFGOFzdkEFHl4ZyIX4FKa5vcwUP2WscSFNjNQ==",
"dependencies": {
"@next/eslint-plugin-next": "13.4.3",
"@next/eslint-plugin-next": "13.4.7",
"@rushstack/eslint-patch": "^1.1.3",
"@typescript-eslint/parser": "^5.42.0",
"eslint-import-resolver-node": "^0.3.6",
@@ -1158,9 +1118,9 @@
}
},
"node_modules/eslint-import-resolver-typescript/node_modules/globby": {
"version": "13.1.4",
"resolved": "https://registry.npmjs.org/globby/-/globby-13.1.4.tgz",
"integrity": "sha512-iui/IiiW+QrJ1X1hKH5qwlMQyv34wJAYwH1vrf8b9kBA4sNiif3gKsMHa+BrdnOpEudWjpotfa7LrTzB1ERS/g==",
"version": "13.2.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-13.2.0.tgz",
"integrity": "sha512-jWsQfayf13NvqKUIL3Ta+CIqMnvlaIDFveWE/dpOZ9+3AMEJozsxDvKA02zync9UuvOM8rOXzsD5GqKP4OnWPQ==",
"dependencies": {
"dir-glob": "^3.0.1",
"fast-glob": "^3.2.11",
@@ -1665,9 +1625,12 @@
}
},
"node_modules/get-tsconfig": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.5.0.tgz",
"integrity": "sha512-MjhiaIWCJ1sAU4pIQ5i5OfOuHHxVo1oYeNsWTON7jxYkod8pHocXeh+SSbmu5OZZZK73B6cbJ2XADzXehLyovQ==",
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.6.0.tgz",
"integrity": "sha512-lgbo68hHTQnFddybKbbs/RDRJnJT5YyGy2kQzVwbq+g67X73i+5MVTval34QxGkOe9X5Ujf1UYpCaphLyltjEg==",
"dependencies": {
"resolve-pkg-maps": "^1.0.0"
},
"funding": {
"url": "https://github.com/privatenumber/get-tsconfig?sponsor=1"
}
@@ -1702,6 +1665,11 @@
"node": ">=10.13.0"
}
},
"node_modules/glob-to-regexp": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz",
"integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw=="
},
"node_modules/globals": {
"version": "13.20.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz",
@@ -1765,10 +1733,10 @@
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="
},
"node_modules/grapheme-splitter": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz",
"integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ=="
"node_modules/graphemer": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz",
"integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag=="
},
"node_modules/has": {
"version": "1.0.3",
@@ -1910,21 +1878,6 @@
"node": ">= 0.4"
}
},
"node_modules/is-arguments": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz",
"integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==",
"dependencies": {
"call-bind": "^1.0.2",
"has-tostringtag": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-array-buffer": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.2.tgz",
@@ -2050,14 +2003,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-map": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.2.tgz",
"integrity": "sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-negative-zero": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz",
@@ -2114,14 +2059,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-set": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.2.tgz",
"integrity": "sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-shared-array-buffer": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz",
@@ -2190,14 +2127,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-weakmap": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.1.tgz",
"integrity": "sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-weakref": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz",
@@ -2209,18 +2138,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-weakset": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.2.tgz",
"integrity": "sha512-t2yVvttHkQktwnNNmBQ98AhENLdPUTDTE21uPqAQ0ARwQfGeQKRVS0NNurH7bTf7RrvcVn1OOge45CnBeHCSmg==",
"dependencies": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.1.1"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-wsl": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
@@ -2246,25 +2163,11 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/isarray": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz",
"integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw=="
},
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="
},
"node_modules/js-sdsl": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz",
"integrity": "sha512-FfVSdx6pJ41Oa+CF7RDaFmTnCaFhua+SNYQX74riGOpl96x+2jQCqEfQ2bnXu/5DPCqlRuiqyvTJM0Qjz26IVg==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/js-sdsl"
}
},
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@@ -2463,16 +2366,17 @@
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw=="
},
"node_modules/next": {
"version": "13.4.3",
"resolved": "https://registry.npmjs.org/next/-/next-13.4.3.tgz",
"integrity": "sha512-FV3pBrAAnAIfOclTvncw9dDohyeuEEXPe5KNcva91anT/rdycWbgtu3IjUj4n5yHnWK8YEPo0vrUecHmnmUNbA==",
"version": "13.4.7",
"resolved": "https://registry.npmjs.org/next/-/next-13.4.7.tgz",
"integrity": "sha512-M8z3k9VmG51SRT6v5uDKdJXcAqLzP3C+vaKfLIAM0Mhx1um1G7MDnO63+m52qPdZfrTFzMZNzfsgvm3ghuVHIQ==",
"dependencies": {
"@next/env": "13.4.3",
"@next/env": "13.4.7",
"@swc/helpers": "0.5.1",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001406",
"postcss": "8.4.14",
"styled-jsx": "5.1.1",
"watchpack": "2.4.0",
"zod": "3.21.4"
},
"bin": {
@@ -2482,20 +2386,19 @@
"node": ">=16.8.0"
},
"optionalDependencies": {
"@next/swc-darwin-arm64": "13.4.3",
"@next/swc-darwin-x64": "13.4.3",
"@next/swc-linux-arm64-gnu": "13.4.3",
"@next/swc-linux-arm64-musl": "13.4.3",
"@next/swc-linux-x64-gnu": "13.4.3",
"@next/swc-linux-x64-musl": "13.4.3",
"@next/swc-win32-arm64-msvc": "13.4.3",
"@next/swc-win32-ia32-msvc": "13.4.3",
"@next/swc-win32-x64-msvc": "13.4.3"
"@next/swc-darwin-arm64": "13.4.7",
"@next/swc-darwin-x64": "13.4.7",
"@next/swc-linux-arm64-gnu": "13.4.7",
"@next/swc-linux-arm64-musl": "13.4.7",
"@next/swc-linux-x64-gnu": "13.4.7",
"@next/swc-linux-x64-musl": "13.4.7",
"@next/swc-win32-arm64-msvc": "13.4.7",
"@next/swc-win32-ia32-msvc": "13.4.7",
"@next/swc-win32-x64-msvc": "13.4.7"
},
"peerDependencies": {
"@opentelemetry/api": "^1.1.0",
"fibers": ">= 3.1.0",
"node-sass": "^6.0.0 || ^7.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sass": "^1.3.0"
@@ -2507,9 +2410,6 @@
"fibers": {
"optional": true
},
"node-sass": {
"optional": true
},
"sass": {
"optional": true
}
@@ -2556,21 +2456,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/object-is": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz",
"integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==",
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/object-keys": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
@@ -2941,6 +2826,14 @@
"node": ">=4"
}
},
"node_modules/resolve-pkg-maps": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz",
"integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==",
"funding": {
"url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1"
}
},
"node_modules/reusify": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz",
@@ -3104,9 +2997,9 @@
}
},
"node_modules/semver": {
"version": "7.5.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz",
"integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==",
"version": "7.5.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.2.tgz",
"integrity": "sha512-SoftuTROv/cRjCze/scjGyiDtcUyxw1rgYQSZY7XTmtR5hX+dm76iDbTH8TkLPHCQmlbQVSSbNZCPM2hb0knnQ==",
"dependencies": {
"lru-cache": "^6.0.0"
},
@@ -3170,17 +3063,6 @@
"node": ">=0.10.0"
}
},
"node_modules/stop-iteration-iterator": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz",
"integrity": "sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ==",
"dependencies": {
"internal-slot": "^1.0.4"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/streamsearch": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
@@ -3396,9 +3278,9 @@
}
},
"node_modules/tslib": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.2.tgz",
"integrity": "sha512-5svOrSA2w3iGFDs1HibEVBGbDrAY82bFQ3HZ3ixB+88nsbsWQoKqDRb5UBYAUPEzbBn6dAp5gRNXglySbx1MlA=="
"version": "2.5.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.3.tgz",
"integrity": "sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w=="
},
"node_modules/tsutils": {
"version": "3.21.0",
@@ -3455,16 +3337,16 @@
}
},
"node_modules/typescript": {
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz",
"integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==",
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.3.tgz",
"integrity": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==",
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=12.20"
"node": ">=14.17"
}
},
"node_modules/unbox-primitive": {
@@ -3497,6 +3379,18 @@
"punycode": "^2.1.0"
}
},
"node_modules/watchpack": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz",
"integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==",
"dependencies": {
"glob-to-regexp": "^0.4.1",
"graceful-fs": "^4.1.2"
},
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@@ -3526,20 +3420,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/which-collection": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.1.tgz",
"integrity": "sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A==",
"dependencies": {
"is-map": "^2.0.1",
"is-set": "^2.0.1",
"is-weakmap": "^2.0.1",
"is-weakset": "^2.0.1"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/which-typed-array": {
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz",

View File

@@ -9,9 +9,9 @@
"lint": "next lint"
},
"dependencies": {
"eslint": "8.40.0",
"eslint-config-next": "13.4.3",
"next": "13.4.3",
"eslint": "8.43.0",
"eslint-config-next": "13.4.7",
"next": "13.4.7",
"react": "18.2.0",
"react-dom": "18.2.0"
}

View File

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

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

@@ -1,3 +1,4 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ["@remix-run/eslint-config", "@remix-run/eslint-config/node"],
};

View File

@@ -1,11 +1,12 @@
node_modules
.cache
/.cache
/build
/public/build
.env
.vercel
.output
/build/
/public/build
/api/index.js
/api/index.js.map

View File

@@ -1,4 +1,4 @@
import type { MetaFunction } from "@vercel/remix";
import { cssBundleHref } from "@remix-run/css-bundle";
import {
Links,
LiveReload,
@@ -8,17 +8,18 @@ import {
ScrollRestoration,
} from "@remix-run/react";
import { Analytics } from "@vercel/analytics/react";
import type { LinksFunction } from "@vercel/remix";
export const meta: MetaFunction = () => ({
charset: "utf-8",
title: "New Remix App",
viewport: "width=device-width,initial-scale=1",
});
export const links: LinksFunction = () => [
...(cssBundleHref ? [{ rel: "stylesheet", href: cssBundleHref }] : []),
];
export default function App() {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<Meta />
<Links />
</head>

View File

@@ -1,3 +1,7 @@
import type { V2_MetaFunction } from "@vercel/remix";
export const meta: V2_MetaFunction = () => [{ title: "New Remix App" }];
export default function Index() {
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>

View File

@@ -1,5 +1,9 @@
import type { V2_MetaFunction } from "@vercel/remix";
export const config = { runtime: "edge" };
export const meta: V2_MetaFunction = () => [{ title: "Remix@Edge | New Remix App" }];
export default function Edge() {
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>

View File

@@ -3,24 +3,28 @@
"sideEffects": false,
"scripts": {
"build": "remix build",
"dev": "remix dev"
"dev": "remix dev",
"start": "remix-serve build",
"typecheck": "tsc"
},
"dependencies": {
"@remix-run/node": "^1.15.0",
"@remix-run/react": "^1.15.0",
"@remix-run/serve": "^1.15.0",
"@remix-run/css-bundle": "^1.18.0",
"@remix-run/node": "^1.18.0",
"@remix-run/react": "^1.18.0",
"@remix-run/serve": "^1.18.0",
"@vercel/analytics": "^0.1.11",
"@vercel/remix": "^1.15.0",
"@vercel/remix": "^1.18.0",
"isbot": "^3.6.8",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@remix-run/dev": "^1.15.0",
"@remix-run/eslint-config": "^1.15.0",
"@remix-run/dev": "^1.18.0",
"@remix-run/eslint-config": "^1.18.0",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.11",
"eslint": "^8.28.0",
"typescript": "^4.9.3"
"typescript": "^5.1.3"
},
"engines": {
"node": ">=14"

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -2,7 +2,7 @@
# Saber Example
This directory is a brief example of a [Saber](https://saber.land) site that can be deployed to Vercel with zero configuration.
This directory is a brief example of a [Saber](https://saber.egoist.dev) site that can be deployed to Vercel with zero configuration.
## Deploy Your Own

View File

@@ -5,4 +5,4 @@ layout: page
This is the Saber port of the base Jekyll theme. Check out the [GitHub project](https://github.com/egoist/saber-theme-minima) for detailed usages.
You can find out more info about customizing your theme, as well as basic Saber usage documentation at https://saber.land
You can find out more info about customizing your theme, as well as basic Saber usage documentation at https://saber.egoist.dev

View File

@@ -0,0 +1,4 @@
{
"framework": "storybook",
"buildCommand": "storybook build"
}

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

@@ -0,0 +1,22 @@
# @vercel-internals/constants
## 1.0.3
### Patch Changes
- Updated dependencies [[`346892210`](https://github.com/vercel/vercel/commit/3468922108f411482a72acd0331f0f2ee52a6d4c)]:
- @vercel/build-utils@6.8.0
## 1.0.2
### Patch Changes
- Updated dependencies [[`cd35071f6`](https://github.com/vercel/vercel/commit/cd35071f609d615d47bc04634c123b33768436cb)]:
- @vercel/build-utils@6.7.5
## 1.0.1
### Patch Changes
- Updated dependencies [[`c7bcea408`](https://github.com/vercel/vercel/commit/c7bcea408131df2d65338e50ce319a6d8e4a8a82)]:
- @vercel/build-utils@6.7.4

View File

@@ -1,14 +1,14 @@
{
"private": true,
"name": "@vercel-internals/constants",
"version": "1.0.0",
"version": "1.0.3",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"scripts": {
"build": "tsc -p tsconfig.json"
},
"dependencies": {
"@vercel/build-utils": "6.7.3",
"@vercel/build-utils": "6.8.0",
"@vercel/routing-utils": "2.2.1"
},
"devDependencies": {

View File

@@ -0,0 +1,25 @@
# @vercel-internals/types
## 1.0.3
### Patch Changes
- Updated dependencies [[`346892210`](https://github.com/vercel/vercel/commit/3468922108f411482a72acd0331f0f2ee52a6d4c)]:
- @vercel/build-utils@6.8.0
- @vercel-internals/constants@1.0.3
## 1.0.2
### Patch Changes
- Updated dependencies [[`cd35071f6`](https://github.com/vercel/vercel/commit/cd35071f609d615d47bc04634c123b33768436cb)]:
- @vercel/build-utils@6.7.5
- @vercel-internals/constants@1.0.2
## 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

@@ -355,7 +355,7 @@ export interface Project extends ProjectSettings {
link?: ProjectLinkData;
alias?: ProjectAliasTarget[];
latestDeployments?: Partial<Deployment>[];
lastRollbackTarget: RollbackTarget | null;
lastAliasRequest?: LastAliasRequest | null;
}
export interface Org {
@@ -365,31 +365,77 @@ 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;
/**
* When linked as a repository, contains the relative path
* to the selected project root directory.
*/
projectRootDirectory?: string;
}
export interface PaginationOptions {
prev: number;
/**
* Amount of items in the current page.
* @example 20
*/
count: number;
next?: number;
/**
* Timestamp that must be used to request the next page.
* @example 1540095775951
*/
next: number | null;
/**
* Timestamp that must be used to request the previous page.
* @example 1540095775951
*/
prev: number | null;
}
export type ProjectLinkResult =
| { status: 'linked'; org: Org; project: Project }
| { status: 'not_linked'; org: null; project: null }
| {
status: 'error';
exitCode: number;
reason?:
| 'HEADLESS'
| 'NOT_AUTHORIZED'
| 'TEAM_DELETED'
| 'PATH_IS_FILE'
| 'INVALID_ROOT_DIRECTORY'
| 'MISSING_PROJECT_SETTINGS';
};
export type ProjectLinked = {
status: 'linked';
org: Org;
project: Project;
repoRoot?: string;
};
export type ProjectNotLinked = {
status: 'not_linked';
org: null;
project: null;
};
export type ProjectLinkedError = {
status: 'error';
exitCode: number;
reason?:
| 'HEADLESS'
| 'NOT_AUTHORIZED'
| 'TEAM_DELETED'
| 'PATH_IS_FILE'
| 'INVALID_ROOT_DIRECTORY'
| 'MISSING_PROJECT_SETTINGS';
};
export type ProjectLinkResult =
| ProjectLinked
| ProjectNotLinked
| ProjectLinkedError;
/**
* @deprecated - `RollbackJobStatus` has been replace by `LastAliasRequest['jobStatus']`.
*/
export type RollbackJobStatus =
| 'pending'
| 'in-progress'
@@ -397,6 +443,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;
@@ -404,6 +454,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,13 +1,13 @@
{
"private": true,
"name": "@vercel-internals/types",
"version": "1.0.0",
"version": "1.0.3",
"types": "index.d.ts",
"main": "index.d.ts",
"dependencies": {
"@types/node": "14.14.31",
"@vercel-internals/constants": "1.0.0",
"@vercel/build-utils": "6.7.3",
"@vercel-internals/constants": "1.0.3",
"@vercel/build-utils": "6.8.0",
"@vercel/routing-utils": "2.2.1"
},
"devDependencies": {

View File

@@ -1,13 +0,0 @@
{
"npmClient": "pnpm",
"useWorkspaces": true,
"packages": ["packages/*"],
"command": {
"publish": {
"npmClient": "npm",
"allowBranch": ["main"],
"registry": "https://registry.npmjs.org/"
}
},
"version": "independent"
}

View File

@@ -32,7 +32,7 @@
"source-map-support": "0.5.12",
"ts-eager": "2.0.2",
"ts-jest": "29.1.0",
"turbo": "1.9.8",
"turbo": "1.10.6",
"typescript": "4.9.5"
},
"scripts": {
@@ -48,8 +48,8 @@
"prettier-check": "prettier --check .",
"prepare": "husky install",
"pack": "cd utils && node -r ts-eager/register ./pack.ts",
"version:prepare": "changeset version && pnpm install --no-frozen-lockfile",
"release": "changeset publish"
"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

@@ -1,5 +1,23 @@
# @vercel/build-utils
## 6.8.0
### Minor Changes
- Add `getNodeBinPaths()` and `traverseUpDirectories()` functions ([#10150](https://github.com/vercel/vercel/pull/10150))
## 6.7.5
### Patch Changes
- Publish missing build-utils ([`cd35071f6`](https://github.com/vercel/vercel/commit/cd35071f609d615d47bc04634c123b33768436cb))
## 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

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/build-utils",
"version": "6.7.3",
"version": "6.8.0",
"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

@@ -44,23 +44,33 @@ export interface ScanParentDirsResult {
lockfileVersion?: number;
}
export interface WalkParentDirsProps {
export interface TraverseUpDirectoriesProps {
/**
* The highest directory, typically the workPath root of the project.
* If this directory is reached and it doesn't contain the file, null is returned.
*/
base: string;
/**
* The directory to start searching, typically the same directory of the entrypoint.
* If this directory doesn't contain the file, the parent is checked, etc.
* The directory to start iterating from, typically the same directory of the entrypoint.
*/
start: string;
/**
* The highest directory, typically the workPath root of the project.
*/
base?: string;
}
export interface WalkParentDirsProps
extends Required<TraverseUpDirectoriesProps> {
/**
* The name of the file to search for, typically `package.json` or `Gemfile`.
*/
filename: string;
}
export interface WalkParentDirsMultiProps
extends Required<TraverseUpDirectoriesProps> {
/**
* The name of the file to search for, typically `package.json` or `Gemfile`.
*/
filenames: string[];
}
export interface SpawnOptionsExtended extends SpawnOptions {
/**
* Pretty formatted command that is being spawned for logging purposes.
@@ -131,6 +141,24 @@ export async function execCommand(command: string, options: SpawnOptions = {}) {
return true;
}
export function* traverseUpDirectories({
start,
base,
}: TraverseUpDirectoriesProps) {
let current: string | undefined = path.normalize(start);
const normalizedRoot = base ? path.normalize(base) : undefined;
while (current) {
yield current;
if (current === normalizedRoot) break;
// Go up one directory
const next = path.join(current, '..');
current = next === current ? undefined : next;
}
}
/**
* @deprecated Use `getNodeBinPaths()` instead.
*/
export async function getNodeBinPath({
cwd,
}: {
@@ -141,6 +169,15 @@ export async function getNodeBinPath({
return path.join(dir, 'node_modules', '.bin');
}
export function getNodeBinPaths({
start,
base,
}: TraverseUpDirectoriesProps): string[] {
return Array.from(traverseUpDirectories({ start, base })).map(dir =>
path.join(dir, 'node_modules/.bin')
);
}
async function chmodPlusX(fsPath: string) {
const s = await fs.stat(fsPath);
const newMode = s.mode | 64 | 8 | 1; // eslint-disable-line no-bitwise
@@ -297,22 +334,14 @@ export async function walkParentDirs({
}: WalkParentDirsProps): Promise<string | null> {
assert(path.isAbsolute(base), 'Expected "base" to be absolute path');
assert(path.isAbsolute(start), 'Expected "start" to be absolute path');
let parent = '';
for (let current = start; base.length <= current.length; current = parent) {
const fullPath = path.join(current, filename);
for (const dir of traverseUpDirectories({ start, base })) {
const fullPath = path.join(dir, filename);
// eslint-disable-next-line no-await-in-loop
if (await fs.pathExists(fullPath)) {
return fullPath;
}
parent = path.dirname(current);
if (parent === current) {
// Reached root directory of the filesystem
break;
}
}
return null;
@@ -322,14 +351,9 @@ async function walkParentDirsMulti({
base,
start,
filenames,
}: {
base: string;
start: string;
filenames: string[];
}): Promise<(string | undefined)[]> {
let parent = '';
for (let current = start; base.length <= current.length; current = parent) {
const fullPaths = filenames.map(f => path.join(current, f));
}: WalkParentDirsMultiProps): Promise<(string | undefined)[]> {
for (const dir of traverseUpDirectories({ start, base })) {
const fullPaths = filenames.map(f => path.join(dir, f));
const existResults = await Promise.all(
fullPaths.map(f => fs.pathExists(f))
);
@@ -338,13 +362,6 @@ async function walkParentDirsMulti({
if (foundOneOrMore) {
return fullPaths.map((f, i) => (existResults[i] ? f : undefined));
}
parent = path.dirname(current);
if (parent === current) {
// Reached root directory of the filesystem
break;
}
}
return [];

View File

@@ -30,7 +30,9 @@ import {
getNodeVersion,
getSpawnOptions,
getNodeBinPath,
getNodeBinPaths,
scanParentDirs,
traverseUpDirectories,
} from './fs/run-user-scripts';
import {
getLatestNodeVersion,
@@ -43,6 +45,7 @@ import { getPlatformEnv } from './get-platform-env';
import { getPrefixedEnvVars } from './get-prefixed-env-vars';
import { cloneEnv } from './clone-env';
import { hardLinkDir } from './hard-link-dir';
import { validateNpmrc } from './validate-npmrc';
export {
FileBlob,
@@ -67,6 +70,7 @@ export {
spawnCommand,
walkParentDirs,
getNodeBinPath,
getNodeBinPaths,
runNpmInstall,
runBundleInstall,
runPipInstall,
@@ -88,6 +92,8 @@ export {
getIgnoreFilter,
cloneEnv,
hardLinkDir,
traverseUpDirectories,
validateNpmrc,
};
export { EdgeFunction } from './edge-function';

View File

@@ -0,0 +1,26 @@
import { join } from 'path';
import { readFile } from 'fs/promises';
/**
* Checks if there is a `.npmrc` in the cwd (project root) and makes sure it
* doesn't contain a `use-node-version`. This config setting is not supported
* since it causes the package manager to install the Node.js version which in
* the case of newer Node.js versions is not compatible with AWS due to
* outdated GLIBC binaries.
*
* @see https://pnpm.io/npmrc#use-node-version
*
* @param cwd The current working directory (e.g. project root);
*/
export async function validateNpmrc(cwd: string): Promise<void> {
const npmrc = await readFile(join(cwd, '.npmrc'), 'utf-8').catch(err => {
if (err.code !== 'ENOENT') throw err;
});
const nodeRegExp = /(?<!#.*)use-node-version/;
if (npmrc?.match(nodeRegExp)) {
throw new Error(
'Detected unsupported "use-node-version" in your ".npmrc". Please use "engines" in your "package.json" instead.'
);
}
}

View File

@@ -0,0 +1,2 @@
foo=bar
# use-node-version=16.16.0

View File

@@ -0,0 +1 @@
foo=bar

View File

@@ -0,0 +1,3 @@
foo=bar
# the next line is not supported
use-node-version=16.16.0

View File

@@ -0,0 +1,17 @@
import { join } from 'path';
import { getNodeBinPaths } from '../src/fs/run-user-scripts';
describe('getNodeBinPaths()', () => {
const cwd = process.cwd();
it('should return array of `node_modules/.bin` paths', () => {
const start = join(cwd, 'foo/bar/baz');
const paths = getNodeBinPaths({ start, base: cwd });
expect(paths).toEqual([
join(cwd, 'foo/bar/baz/node_modules/.bin'),
join(cwd, 'foo/bar/node_modules/.bin'),
join(cwd, 'foo/node_modules/.bin'),
join(cwd, 'node_modules/.bin'),
]);
});
});

View File

@@ -0,0 +1,50 @@
import { traverseUpDirectories } from '../src/fs/run-user-scripts';
const isWindows = process.platform === 'win32';
describe('traverseUpDirectories()', () => {
test.each(
isWindows
? [
{
start: 'C:\\foo\\bar\\baz',
expected: ['C:\\foo\\bar\\baz', 'C:\\foo\\bar', 'C:\\foo', 'C:\\'],
},
{
start: 'C:\\foo\\..\\bar\\.\\baz',
expected: ['C:\\bar\\baz', 'C:\\bar', 'C:\\'],
},
{
start: 'C:\\foo\\bar\\baz\\another',
base: 'C:\\foo\\bar',
expected: [
'C:\\foo\\bar\\baz\\another',
'C:\\foo\\bar\\baz',
'C:\\foo\\bar',
],
},
]
: [
{
start: '/foo/bar/baz',
expected: ['/foo/bar/baz', '/foo/bar', '/foo', '/'],
},
{
start: '/foo/../bar/./baz',
expected: ['/bar/baz', '/bar', '/'],
},
{
start: '/foo/bar/baz/another',
base: '/foo/bar',
expected: ['/foo/bar/baz/another', '/foo/bar/baz', '/foo/bar'],
},
]
)(
'should traverse start="$start", base="$base"',
({ start, base, expected }) => {
expect(Array.from(traverseUpDirectories({ start, base }))).toEqual(
expected
);
}
);
});

View File

@@ -0,0 +1,22 @@
import { join } from 'path';
import { validateNpmrc } from '../src/validate-npmrc';
const fixture = (name: string) => join(__dirname, 'fixtures', '29-npmrc', name);
describe('validateNpmrc', () => {
it('should not error with no use-node-version', async () => {
await expect(validateNpmrc(fixture('good'))).resolves.toBe(undefined);
});
it('should throw when use-node-version is found', async () => {
await expect(
validateNpmrc(fixture('has-use-node-version'))
).rejects.toThrow('Detected unsupported');
});
it('should not error when use-node-version is commented out', async () => {
await expect(
validateNpmrc(fixture('comment-use-node-version'))
).resolves.toBe(undefined);
});
});

View File

@@ -1,5 +1,121 @@
# vercel
## 31.0.0
### Major Changes
- Update `vc dev` redirect response to match production behavior ([#10143](https://github.com/vercel/vercel/pull/10143))
### Patch Changes
- require `--yes` to promote preview deployment ([#10135](https://github.com/vercel/vercel/pull/10135))
- [cli] Optimize write build result for vc build ([#10154](https://github.com/vercel/vercel/pull/10154))
- Only show relevant Project matches in Project selector ([#10114](https://github.com/vercel/vercel/pull/10114))
- [cli] Fix error message when token is invalid ([#10131](https://github.com/vercel/vercel/pull/10131))
- Updated dependencies [[`e4895d979`](https://github.com/vercel/vercel/commit/e4895d979b57e369e0618481c5974243887d72cc), [`346892210`](https://github.com/vercel/vercel/commit/3468922108f411482a72acd0331f0f2ee52a6d4c), [`346892210`](https://github.com/vercel/vercel/commit/3468922108f411482a72acd0331f0f2ee52a6d4c), [`a6de052ed`](https://github.com/vercel/vercel/commit/a6de052ed2f09cc80bf4c2d0f06bedd267a63cdc)]:
- @vercel/next@3.8.7
- @vercel/static-build@1.3.38
- @vercel/build-utils@6.8.0
- @vercel/remix-builder@1.8.15
- @vercel/node@2.15.3
## 30.2.3
### Patch Changes
- [cli] do not force auto-assign value on deployments ([#10110](https://github.com/vercel/vercel/pull/10110))
- Updated dependencies [[`91406abdb`](https://github.com/vercel/vercel/commit/91406abdb0c332152fc6c7c1e4bd3a872b084434), [`2230ea6cc`](https://github.com/vercel/vercel/commit/2230ea6cc1b84c1f03227a4e197b7684635b5955), [`8b3a4146a`](https://github.com/vercel/vercel/commit/8b3a4146af68d2b7288c80a5b919d832dba929b5)]:
- @vercel/node@2.15.2
- @vercel/remix-builder@1.8.14
- @vercel/static-build@1.3.37
## 30.2.2
### Patch Changes
- [cli] vc env pull should add `.env*.local` to `.gitignore` ([#10085](https://github.com/vercel/vercel/pull/10085))
- [cli] Fix team validation bug where you are apart of a team ([#10092](https://github.com/vercel/vercel/pull/10092))
- Add support for `vc dev` command with repo link ([#10082](https://github.com/vercel/vercel/pull/10082))
- Add support for `vc deploy --prebuilt` command with repo link ([#10083](https://github.com/vercel/vercel/pull/10083))
- Move readme copy logic to a helper function for `vc link` ([#10084](https://github.com/vercel/vercel/pull/10084))
- Add support for `vc pull` command with repo link ([#10078](https://github.com/vercel/vercel/pull/10078))
- Add support for `vc build` command with repo link ([#10075](https://github.com/vercel/vercel/pull/10075))
## 30.2.1
### Patch Changes
- Updated dependencies [[`a04bf557f`](https://github.com/vercel/vercel/commit/a04bf557fc6e1080a117428977d0993dec78b004)]:
- @vercel/node@2.15.1
- @vercel/static-build@1.3.36
## 30.2.0
### Minor Changes
- [node] Add isomorphic functions ([#9947](https://github.com/vercel/vercel/pull/9947))
### Patch Changes
- Add `client.fetchPaginated()` helper function ([#10054](https://github.com/vercel/vercel/pull/10054))
- Updated dependencies [[`bc5afe24c`](https://github.com/vercel/vercel/commit/bc5afe24c4547dbf798b939199e8212c4b34038e), [`49c717856`](https://github.com/vercel/vercel/commit/49c7178567ec5bcebe633b598c8c9c0e1aa40fbb), [`0039c8b5c`](https://github.com/vercel/vercel/commit/0039c8b5cea975316a62c4f6aaca5d66d731cc0d)]:
- @vercel/node@2.15.0
- @vercel/remix-builder@1.8.13
- @vercel/static-build@1.3.35
## 30.1.2
### Patch Changes
- Publish missing build-utils ([`cd35071f6`](https://github.com/vercel/vercel/commit/cd35071f609d615d47bc04634c123b33768436cb))
- Updated dependencies [[`cd35071f6`](https://github.com/vercel/vercel/commit/cd35071f609d615d47bc04634c123b33768436cb)]:
- @vercel/build-utils@6.7.5
- @vercel/node@2.14.5
- @vercel/remix-builder@1.8.12
- @vercel/static-build@1.3.34
## 30.1.1
### Patch Changes
- [cli] vc build ignore '.env\*' & ignore files for '@vercel/static' ([#10056](https://github.com/vercel/vercel/pull/10056))
- [cli] Ensure .npmrc does not contain use-node-version ([#10049](https://github.com/vercel/vercel/pull/10049))
## 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

View File

@@ -1,6 +1,6 @@
{
"name": "vercel",
"version": "30.0.0",
"version": "31.0.0",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Vercel",
@@ -32,20 +32,20 @@
"node": ">= 14"
},
"dependencies": {
"@vercel/build-utils": "6.7.3",
"@vercel/build-utils": "6.8.0",
"@vercel/go": "2.5.1",
"@vercel/hydrogen": "0.0.64",
"@vercel/next": "3.8.5",
"@vercel/node": "2.14.3",
"@vercel/next": "3.8.7",
"@vercel/node": "2.15.3",
"@vercel/python": "3.1.60",
"@vercel/redwood": "1.1.15",
"@vercel/remix-builder": "1.8.10",
"@vercel/remix-builder": "1.8.15",
"@vercel/ruby": "1.3.76",
"@vercel/static-build": "1.3.32"
"@vercel/static-build": "1.3.38"
},
"devDependencies": {
"@alex_neo/jest-expect-message": "1.0.5",
"@edge-runtime/node-utils": "2.0.3",
"@edge-runtime/node-utils": "2.1.0",
"@next/env": "11.1.2",
"@sentry/node": "5.5.0",
"@sindresorhus/slugify": "0.11.0",
@@ -85,13 +85,13 @@
"@types/which": "3.0.0",
"@types/write-json-file": "2.2.1",
"@types/yauzl-promise": "2.1.0",
"@vercel-internals/constants": "1.0.0",
"@vercel-internals/constants": "1.0.3",
"@vercel-internals/get-package-json": "1.0.0",
"@vercel-internals/types": "1.0.0",
"@vercel/client": "12.6.0",
"@vercel-internals/types": "1.0.3",
"@vercel/client": "12.6.3",
"@vercel/error-utils": "1.0.10",
"@vercel/frameworks": "1.4.2",
"@vercel/fs-detectors": "3.9.3",
"@vercel/frameworks": "1.4.3",
"@vercel/fs-detectors": "4.0.1",
"@vercel/fun": "1.0.4",
"@vercel/ncc": "0.24.0",
"@vercel/routing-utils": "2.2.1",
@@ -119,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",

View File

@@ -24,6 +24,7 @@ export const help = () => `
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

View File

@@ -6,21 +6,19 @@ import chalk, { Chalk } from 'chalk';
import { URLSearchParams, parse } from 'url';
import box from '../../util/output/box';
import sleep from '../../util/sleep';
import formatDate from '../../util/format-date';
import link from '../../util/output/link';
import logo from '../../util/output/logo';
import getArgs from '../../util/get-args';
import Client from '../../util/client';
import { getPkgName } from '../../util/pkg-name';
import { Deployment, PaginationOptions } from '@vercel-internals/types';
import { Deployment } from '@vercel-internals/types';
import { normalizeURL } from '../../util/bisect/normalize-url';
import getScope from '../../util/get-scope';
import getDeployment from '../../util/get-deployment';
interface Deployments {
deployments: Deployment[];
pagination: PaginationOptions;
}
const pkgName = getPkgName();
@@ -206,44 +204,34 @@ export default async function main(client: Client): Promise<number> {
// Fetch all the project's "READY" deployments with the pagination API
let deployments: Deployment[] = [];
let next: number | undefined = badDeployment.createdAt + 1;
do {
const query = new URLSearchParams();
query.set('projectId', projectId);
if (badDeployment.target) {
query.set('target', badDeployment.target);
}
query.set('limit', '100');
query.set('state', 'READY');
if (next) {
query.set('until', String(next));
}
const res = await client.fetch<Deployments>(`/v6/deployments?${query}`, {
const query = new URLSearchParams();
query.set('projectId', projectId);
if (badDeployment.target) {
query.set('target', badDeployment.target);
}
query.set('state', 'READY');
query.set('until', String(badDeployment.createdAt + 1));
for await (const chunk of client.fetchPaginated<Deployments>(
`/v6/deployments?${query}`,
{
accountId: badDeployment.ownerId,
});
next = res.pagination.next;
let newDeployments = res.deployments;
}
)) {
let newDeployments = chunk.deployments;
// If we have the "good" deployment in this chunk, then we're done
for (let i = 0; i < newDeployments.length; i++) {
if (newDeployments[i].url === good) {
// grab all deployments up until the good one
newDeployments = newDeployments.slice(0, i);
next = undefined;
break;
}
}
deployments = deployments.concat(newDeployments);
if (next) {
// Small sleep to avoid rate limiting
await sleep(100);
}
} while (next);
}
if (!deployments.length) {
output.error(

View File

@@ -1,7 +1,10 @@
import fs from 'fs-extra';
import chalk from 'chalk';
import dotenv from 'dotenv';
import semver from 'semver';
import minimatch from 'minimatch';
import { join, normalize, relative, resolve, sep } from 'path';
import frameworks from '@vercel/frameworks';
import {
getDiscontinuedNodeVersions,
normalizePath,
@@ -17,13 +20,14 @@ import {
BuildResultV3,
NowBuildError,
Cron,
validateNpmrc,
} from '@vercel/build-utils';
import {
detectBuilders,
detectFrameworkRecord,
detectFrameworkVersion,
LocalFileSystemDetector,
} from '@vercel/fs-detectors';
import minimatch from 'minimatch';
import {
appendRoutesToPhase,
getTransformedRoutes,
@@ -48,7 +52,7 @@ import {
ProjectLinkAndSettings,
readProjectSettings,
} from '../util/projects/project-settings';
import { VERCEL_DIR } from '../util/projects/link';
import { getProjectLink, VERCEL_DIR } from '../util/projects/link';
import confirm from '../util/input/confirm';
import { emoji, prependEmoji } from '../util/emoji';
import stamp from '../util/output/stamp';
@@ -62,11 +66,7 @@ import { initCorepack, cleanupCorepack } from '../util/build/corepack';
import { sortBuilders } from '../util/build/sort-builders';
import { toEnumerableError } from '../util/error';
import { validateConfig } from '../util/validate-config';
import { setMonorepoDefaultSettings } from '../util/build/monorepo';
import frameworks from '@vercel/frameworks';
import { detectFrameworkVersion } from '@vercel/fs-detectors';
import semver from 'semver';
type BuildResult = BuildResultV2 | BuildResultV3;
@@ -133,6 +133,7 @@ const help = () => {
};
export default async function main(client: Client): Promise<number> {
let { cwd } = client;
const { output } = client;
// Ensure that `vc build` is not being invoked recursively
@@ -165,16 +166,29 @@ 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']);
try {
await validateNpmrc(cwd);
} catch (err) {
output.prettyError(err);
return 1;
}
// If repo linked, update `cwd` to the repo root
const link = await getProjectLink(client, cwd);
const projectRootDirectory = link?.projectRootDirectory ?? '';
if (link?.repoRoot) {
cwd = client.cwd = link.repoRoot;
}
// TODO: read project settings from the API, fall back to local `project.json` if that fails
// Read project settings, and pull them from Vercel if necessary
let project = await readProjectSettings(join(cwd, VERCEL_DIR));
const vercelDir = join(cwd, projectRootDirectory, VERCEL_DIR);
let project = await readProjectSettings(vercelDir);
const isTTY = process.stdin.isTTY;
while (!project?.settings) {
let confirmed = yes;
@@ -201,6 +215,7 @@ export default async function main(client: Client): Promise<number> {
return 0;
}
const { argv: originalArgv } = client;
client.cwd = join(cwd, projectRootDirectory);
client.argv = [
...originalArgv.slice(0, 2),
'pull',
@@ -211,12 +226,13 @@ export default async function main(client: Client): Promise<number> {
if (result !== 0) {
return result;
}
client.cwd = cwd;
client.argv = originalArgv;
project = await readProjectSettings(join(cwd, VERCEL_DIR));
project = await readProjectSettings(vercelDir);
}
// Delete output directory from potential previous build
const defaultOutputDir = join(cwd, OUTPUT_DIR);
const defaultOutputDir = join(cwd, projectRootDirectory, OUTPUT_DIR);
const outputDir = argv['--output']
? resolve(argv['--output'])
: defaultOutputDir;
@@ -235,7 +251,12 @@ export default async function main(client: Client): Promise<number> {
const envToUnset = new Set<string>(['VERCEL', 'NOW_BUILDER']);
try {
const envPath = join(cwd, VERCEL_DIR, `.env.${target}.local`);
const envPath = join(
cwd,
projectRootDirectory,
VERCEL_DIR,
`.env.${target}.local`
);
// TODO (maybe?): load env vars from the API, fall back to the local file if that fails
const dotenvResult = dotenv.config({
path: envPath,

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,
@@ -130,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]!);
@@ -176,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
@@ -215,56 +203,6 @@ export default async (client: Client): Promise<number> => {
return target;
}
// build `--prebuilt`
if (argv['--prebuilt']) {
const prebuiltExists = await fs.pathExists(join(path, '.vercel/output'));
if (!prebuiltExists) {
error(
`The ${param(
'--prebuilt'
)} option was used, but no prebuilt output found in ".vercel/output". Run ${getCommandName(
'build'
)} to generate a local build.`
);
return 1;
}
const prebuiltBuild = await getPrebuiltJson(path);
// Ensure that there was not a build error
const prebuiltError =
prebuiltBuild?.error ||
prebuiltBuild?.builds?.find(build => 'error' in build)?.error;
if (prebuiltError) {
output.log(
`Prebuilt deployment cannot be created because ${getCommandName(
'build'
)} failed with error:\n`
);
prettyError(prebuiltError);
return 1;
}
// Ensure that the deploy target matches the build target
const assumedTarget = target || 'preview';
if (prebuiltBuild?.target && prebuiltBuild.target !== assumedTarget) {
let specifyTarget = '';
if (prebuiltBuild.target === 'production') {
specifyTarget = ` --prod`;
}
prettyError({
message: `The ${param(
'--prebuilt'
)} option was used with the target environment "${assumedTarget}", but the prebuilt output found in ".vercel/output" was built with target environment "${
prebuiltBuild.target
}". Please run ${getCommandName(`--prebuilt${specifyTarget}`)}.`,
link: 'https://vercel.link/prebuilt-environment-mismatch',
});
return 1;
}
}
const archive = argv['--archive'];
if (typeof archive === 'string' && !isValidArchive(archive)) {
output.error(`Format must be one of: ${VALID_ARCHIVE_FORMATS.join(', ')}`);
@@ -272,7 +210,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;
@@ -289,7 +227,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
));
@@ -336,7 +274,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;
@@ -344,8 +282,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,
@@ -357,11 +295,76 @@ 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`);
}
// build `--prebuilt`
if (argv['--prebuilt']) {
// For repo-style linking, update `cwd` to be the Project
// subdirectory when `rootDirectory` setting is defined
if (
link.status === 'linked' &&
link.repoRoot &&
link.project.rootDirectory
) {
cwd = join(cwd, link.project.rootDirectory);
}
const prebuiltExists = await fs.pathExists(join(cwd, '.vercel/output'));
if (!prebuiltExists) {
error(
`The ${param(
'--prebuilt'
)} option was used, but no prebuilt output found in ".vercel/output". Run ${getCommandName(
'build'
)} to generate a local build.`
);
return 1;
}
const prebuiltBuild = await getPrebuiltJson(cwd);
// Ensure that there was not a build error
const prebuiltError =
prebuiltBuild?.error ||
prebuiltBuild?.builds?.find(build => 'error' in build)?.error;
if (prebuiltError) {
output.log(
`Prebuilt deployment cannot be created because ${getCommandName(
'build'
)} failed with error:\n`
);
prettyError(prebuiltError);
return 1;
}
// Ensure that the deploy target matches the build target
const assumedTarget = target || 'preview';
if (prebuiltBuild?.target && prebuiltBuild.target !== assumedTarget) {
let specifyTarget = '';
if (prebuiltBuild.target === 'production') {
specifyTarget = ` --prod`;
}
prettyError({
message: `The ${param(
'--prebuilt'
)} option was used with the target environment "${assumedTarget}", but the prebuilt output found in ".vercel/output" was built with target environment "${
prebuiltBuild.target
}". Please run ${getCommandName(`--prebuilt${specifyTarget}`)}.`,
link: 'https://vercel.link/prebuilt-environment-mismatch',
});
return 1;
}
}
// Set the `contextName` and `currentTeam` as specified by the
// Project Settings, so that API calls happen with the proper scope
const contextName = org.slug;
@@ -371,14 +374,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`
@@ -391,7 +394,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})`);
@@ -467,7 +470,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(
@@ -518,7 +521,8 @@ export default async (client: Client): Promise<number> => {
}
try {
const autoAssignCustomDomains = !argv['--skip-domain'];
// if this flag is not set, use `undefined` to allow the project setting to be used
const autoAssignCustomDomains = argv['--skip-domain'] ? false : undefined;
const createArgs: CreateOptions = {
name,
@@ -560,11 +564,11 @@ export default async (client: Client): Promise<number> => {
client,
now,
contextName,
[sourcePath],
sourcePath,
createArgs,
org,
!project,
path,
cwd,
archive
);
@@ -596,11 +600,11 @@ export default async (client: Client): Promise<number> => {
client,
now,
contextName,
[sourcePath],
sourcePath,
createArgs,
org,
false,
path
cwd
);
}

View File

@@ -58,7 +58,13 @@ export default async function dev(
let projectSettings: ProjectSettings | undefined;
let envValues: Record<string, string> = {};
if (link.status === 'linked') {
const { project, org } = link;
const { project, org, repoRoot } = link;
// If repo linked, update `cwd` to the repo root
if (repoRoot) {
cwd = repoRoot;
}
client.config.currentTeam = org.type === 'team' ? org.id : undefined;
projectSettings = project;

View File

@@ -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)) {
@@ -168,6 +167,7 @@ export default async function main(client: Client) {
case 'pull':
return pull(
client,
link,
project,
target,
argv,

View File

@@ -2,7 +2,11 @@ import chalk from 'chalk';
import { outputFile } from 'fs-extra';
import { closeSync, openSync, readSync } from 'fs';
import { resolve } from 'path';
import type { Project, ProjectEnvTarget } from '@vercel-internals/types';
import type {
Project,
ProjectEnvTarget,
ProjectLinked,
} from '@vercel-internals/types';
import Client from '../../util/client';
import { emoji, prependEmoji } from '../../util/emoji';
import confirm from '../../util/input/confirm';
@@ -19,6 +23,7 @@ import {
createEnvObject,
} from '../../util/env/diff-env-files';
import { isErrnoException } from '@vercel/error-utils';
import { addToGitIgnore } from '../../util/link/add-to-gitignore';
const CONTENTS_PREFIX = '# Created by Vercel CLI\n';
@@ -51,6 +56,7 @@ function tryReadHeadSync(path: string, length: number) {
export default async function pull(
client: Client,
link: ProjectLinked,
project: Project,
environment: ProjectEnvTarget,
opts: Partial<Options>,
@@ -136,11 +142,22 @@ export default async function pull(
output.log('No changes found.');
}
let isGitIgnoreUpdated = false;
if (filename === '.env.local') {
// When the file is `.env.local`, we also add it to `.gitignore`
// to avoid accidentally committing it to git.
// We use '.env*.local' to match the default .gitignore from
// create-next-app template. See:
// https://github.com/vercel/next.js/blob/06abd634899095b6cc28e6e8315b1e8b9c8df939/packages/create-next-app/templates/app/js/gitignore#L28
const rootPath = link.repoRoot ?? cwd;
isGitIgnoreUpdated = await addToGitIgnore(rootPath, '.env*.local');
}
output.print(
`${prependEmoji(
`${exists ? 'Updated' : 'Created'} ${chalk.bold(
filename
)} file ${chalk.gray(pullStamp())}`,
`${exists ? 'Updated' : 'Created'} ${chalk.bold(filename)} file ${
isGitIgnoreUpdated ? 'and added it to .gitignore' : ''
} ${chalk.gray(pullStamp())}`,
emoji('success')
)}\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) {

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,6 +26,7 @@ export default new Map([
['ls', 'list'],
['project', 'project'],
['projects', 'project'],
['promote', 'promote'],
['pull', 'pull'],
['redeploy', 'redeploy'],
['remove', 'remove'],

View File

@@ -90,7 +90,7 @@ export default async function main(client: Client) {
)} instead`
);
} else {
cwd = process.cwd();
cwd = client.cwd;
}
if (argv['--repo']) {

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,124 @@
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;
}
const yes = argv['--yes'] ?? false;
// 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,
yes,
});
} 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,70 @@
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';
import confirm from '../../util/input/confirm';
/**
* 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,
yes,
}: {
client: Client;
deployId: string;
timeout?: string;
yes: boolean;
}): Promise<number> {
const { output } = client;
const { contextName, deployment, project } = await getProjectByDeployment({
client,
deployId,
output: client.output,
});
if (deployment.target !== 'production' && !yes) {
const question =
'This deployment does not target production, therefore promotion will not apply production environment variables. Are you sure you want to continue?';
const answer = await confirm(client, question, false);
if (!answer) {
output.error('Canceled');
return 0;
}
}
// 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

@@ -1,7 +1,11 @@
import chalk from 'chalk';
import { join } from 'path';
import Client from '../util/client';
import type { Project, ProjectEnvTarget } from '@vercel-internals/types';
import type {
Project,
ProjectEnvTarget,
ProjectLinked,
} from '@vercel-internals/types';
import { emoji, prependEmoji } from '../util/emoji';
import getArgs from '../util/get-args';
import logo from '../util/output/logo';
@@ -15,6 +19,7 @@ import {
getEnvTargetPlaceholder,
} from '../util/env/env-target';
import { ensureLink } from '../util/link/ensure-link';
import humanizePath from '../util/humanize-path';
const help = () => {
return console.log(`
@@ -81,6 +86,7 @@ function parseArgs(client: Client) {
async function pullAllEnvFiles(
environment: ProjectEnvTarget,
client: Client,
link: ProjectLinked,
project: Project,
argv: ReturnType<typeof processArgs>,
cwd: string
@@ -88,6 +94,7 @@ async function pullAllEnvFiles(
const environmentFile = `.env.${environment}.local`;
return envPull(
client,
link,
project,
environment,
argv,
@@ -115,7 +122,7 @@ export default async function main(client: Client) {
return argv;
}
const cwd = argv._[1] || process.cwd();
let cwd = argv._[1] || client.cwd;
const autoConfirm = Boolean(argv['--yes']);
const environment = parseEnvironment(argv['--environment'] || undefined);
@@ -124,13 +131,18 @@ export default async function main(client: Client) {
return link;
}
const { project, org } = link;
const { project, org, repoRoot } = link;
if (repoRoot) {
cwd = join(repoRoot, project.rootDirectory || '');
}
client.config.currentTeam = org.type === 'team' ? org.id : undefined;
const pullResultCode = await pullAllEnvFiles(
environment,
client,
link,
project,
argv,
cwd
@@ -141,13 +153,14 @@ export default async function main(client: Client) {
client.output.print('\n');
client.output.log('Downloading project settings');
await writeProjectSettings(cwd, project, org);
const isRepoLinked = typeof repoRoot === 'string';
await writeProjectSettings(cwd, project, org, isRepoLinked);
const settingsStamp = stamp();
client.output.print(
`${prependEmoji(
`Downloaded project settings to ${chalk.bold(
join(VERCEL_DIR, VERCEL_DIR_PROJECT)
humanizePath(join(cwd, VERCEL_DIR, VERCEL_DIR_PROJECT))
)} ${chalk.gray(settingsStamp())}`,
emoji('success')
)}\n`

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,
deployIdOrUrl: 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

@@ -144,12 +144,6 @@ const main = async () => {
return 1;
}
let cwd = argv['--cwd'];
if (cwd) {
process.chdir(cwd);
}
cwd = process.cwd();
// The second argument to the command can be:
//
// * a path to deploy (as in: `vercel path/`)
@@ -277,6 +271,12 @@ const main = async () => {
argv: process.argv,
});
// 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;
@@ -571,6 +571,9 @@ const main = async () => {
case 'project':
func = require('./commands/project').default;
break;
case 'promote':
func = require('./commands/promote').default;
break;
case 'pull':
func = require('./commands/pull').default;
break;

View File

@@ -12,7 +12,10 @@ export const build: BuildV2 = async ({ entrypoint, files, config }) => {
if (
filename.startsWith('.git/') ||
filename === 'vercel.json' ||
filename === 'now.json'
filename === '.vercelignore' ||
filename === 'now.json' ||
filename === '.nowignore' ||
filename.startsWith('.env')
) {
continue;
}

View File

@@ -131,6 +131,7 @@ async function writeBuildResultV2(
const lambdas = new Map<Lambda, string>();
const overrides: Record<string, PathOverride> = {};
for (const [path, output] of Object.entries(buildResult.output)) {
const normalizedPath = stripDuplicateSlashes(path);
if (isLambda(output)) {
@@ -156,11 +157,26 @@ async function writeBuildResultV2(
const ext = getFileExtension(fallback);
const fallbackName = `${normalizedPath}.prerender-fallback${ext}`;
const fallbackPath = join(outputDir, 'functions', fallbackName);
const stream = fallback.toStream();
await pipe(
stream,
fs.createWriteStream(fallbackPath, { mode: fallback.mode })
);
// if file is already on the disk we can hard link
// instead of creating a new copy
let usedHardLink = false;
if ('fsPath' in fallback) {
try {
await fs.link(fallback.fsPath, fallbackPath);
usedHardLink = true;
} catch (_) {
// if link fails we continue attempting to copy
}
}
if (!usedHardLink) {
const stream = fallback.toStream();
await pipe(
stream,
fs.createWriteStream(fallbackPath, { mode: fallback.mode })
);
}
fallback = new FileFsRef({
...output.fallback,
fsPath: basename(fallbackName),
@@ -288,6 +304,14 @@ async function writeStaticFile(
const dest = join(outputDir, 'static', fsPath);
await fs.mkdirp(dirname(dest));
// if already on disk hard link instead of copying
if ('fsPath' in file) {
try {
return await fs.link(file.fsPath, dest);
} catch (_) {
// if link fails we continue attempting to copy
}
}
await downloadFile(file, dest);
}

View File

@@ -19,11 +19,13 @@ import type {
Stdio,
ReadableTTY,
WritableTTY,
PaginationOptions,
} from '@vercel-internals/types';
import { sharedPromise } from './promise';
import { APIError } from './errors-ts';
import { normalizeError } from '@vercel/error-utils';
import type { Agent } from 'http';
import sleep from './sleep';
const isSAMLError = (v: any): v is SAMLError => {
return v && v.saml;
@@ -176,6 +178,31 @@ export default class Client extends EventEmitter implements Stdio {
}, opts.retry);
}
async *fetchPaginated<T>(
url: string | URL,
opts?: FetchOptions
): AsyncGenerator<T & { pagination: PaginationOptions }> {
const endpoint =
typeof url === 'string' ? new URL(url, this.apiUrl) : new URL(url.href);
if (!endpoint.searchParams.has('limit')) {
endpoint.searchParams.set('limit', '100');
}
let next: number | null | undefined;
do {
if (next) {
// Small sleep to avoid rate limiting
await sleep(100);
endpoint.searchParams.set('until', String(next));
}
const res = await this.fetch<T & { pagination: PaginationOptions }>(
endpoint.href,
opts
);
yield res;
next = res.pagination?.next;
} while (next);
}
reauthenticate = sharedPromise(async function (
this: Client,
error: SAMLError
@@ -207,4 +234,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

@@ -40,8 +40,7 @@ export default async function processDeployment({
...args
}: {
now: Now;
output: Output;
paths: string[];
path: string;
requestBody: DeploymentOptions;
uploadStamp: () => string;
deployStamp: () => string;
@@ -54,15 +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,
@@ -72,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');
@@ -87,7 +84,7 @@ export default async function processDeployment({
token,
debug: now._debug,
userAgent: ua,
path: paths[0],
path,
force,
withCache,
prebuilt,
@@ -114,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)
@@ -157,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
)})`
@@ -166,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

@@ -1131,7 +1131,7 @@ export default class DevServer {
body = redirectTemplate({ location, statusCode });
} else {
res.setHeader('content-type', 'text/plain; charset=utf-8');
body = `Redirecting to ${location} (${statusCode})\n`;
body = `Redirecting...\n`;
}
res.end(body);
}

View File

@@ -8,10 +8,7 @@ import {
import type { Server } from 'http';
import type Client from '../client';
const toHeaders = buildToHeaders({
// @ts-expect-error - `node-fetch` Headers is missing `getAll()`
Headers,
});
const toHeaders = buildToHeaders({ Headers });
export function createProxy(client: Client): Server {
return createServer(async (req, res) => {

View File

@@ -50,7 +50,7 @@ export interface CreateOptions {
projectSettings?: any;
skipAutoDetectionConfirmation?: boolean;
noWait?: boolean;
autoAssignCustomDomains: boolean;
autoAssignCustomDomains?: boolean;
}
export interface RemoveOptions {
@@ -107,7 +107,7 @@ export default class Now extends EventEmitter {
}
async create(
paths: string[],
path: string,
{
// Legacy
nowConfig: nowConfig = {},
@@ -135,8 +135,8 @@ export default class Now extends EventEmitter {
}: CreateOptions,
org: Org,
isSettingUpProject: boolean,
archive?: ArchiveFormat,
cwd?: string
cwd: string,
archive?: ArchiveFormat
) {
let hashes: any = {};
const uploadStamp = stamp();
@@ -163,9 +163,8 @@ export default class Now extends EventEmitter {
const deployment = await processDeployment({
now: this,
output: this._output,
agent: this._client.agent,
paths,
path,
requestBody,
uploadStamp,
deployStamp,

View File

@@ -1,15 +1,10 @@
import { Org, Project } from '@vercel-internals/types';
import Client from '../client';
import setupAndLink from '../link/setup-and-link';
import param from '../output/param';
import { getCommandName } from '../pkg-name';
import { getLinkedProject } from '../projects/link';
import type { SetupAndLinkOptions } from '../link/setup-and-link';
type LinkResult = {
org: Org;
project: Project;
};
import type { ProjectLinked } from '@vercel-internals/types';
/**
* Checks if a project is already linked and if not, links the project and
@@ -23,15 +18,15 @@ type LinkResult = {
* directory
* @param opts.projectName - The project name to use when linking, otherwise
* the current directory
* @returns {Promise<LinkResult|number>} Returns a numeric exit code when aborted or
* @returns {Promise<ProjectLinked|number>} Returns a numeric exit code when aborted or
* error, otherwise an object containing the org an project
*/
export async function ensureLink(
commandName: string,
client: Client,
cwd: string,
opts: SetupAndLinkOptions
): Promise<LinkResult | number> {
opts: SetupAndLinkOptions = {}
): Promise<ProjectLinked | number> {
let { link } = opts;
if (!link) {
link = await getLinkedProject(client, cwd);
@@ -61,5 +56,5 @@ export async function ensureLink(
return link.exitCode;
}
return { org: link.org, project: link.project };
return link;
}

View File

@@ -2,15 +2,11 @@ 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 { normalizePath, traverseUpDirectories } from '@vercel/build-utils';
import { lstat, readJSON, outputJSON } 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 { VERCEL_DIR, VERCEL_DIR_REPO, writeReadme } from '../projects/link';
import { getRemoteUrls } from '../create-git-meta';
import link from '../output/link';
import { emoji, prependEmoji } from '../emoji';
@@ -44,9 +40,12 @@ export interface RepoLink {
* and returns the parsed `.vercel/repo.json` file if the repository
* has already been linked.
*/
export async function getRepoLink(cwd: string): Promise<RepoLink | undefined> {
export async function getRepoLink(
client: Client,
cwd: string
): Promise<RepoLink | undefined> {
// Determine where the root of the repo is
const rootPath = await findRepoRoot(cwd);
const rootPath = await findRepoRoot(client, cwd);
if (!rootPath) return undefined;
// Read the `repo.json`, if this repo has already been linked
@@ -67,7 +66,7 @@ export async function ensureRepoLink(
): Promise<RepoLink | undefined> {
const { output } = client;
const repoLink = await getRepoLink(cwd);
const repoLink = await getRepoLink(client, cwd);
if (repoLink) {
output.debug(`Found Git repository root directory: ${repoLink.rootPath}`);
} else {
@@ -128,9 +127,30 @@ export async function ensureRepoLink(
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}`);
let projects: Project[] = [];
const query = new URLSearchParams({ repoUrl });
const projectsIterator = client.fetchPaginated<{
projects: Project[];
}>(`/v9/projects?${query}`);
let printedFound = false;
for await (const chunk of projectsIterator) {
projects = projects.concat(chunk.projects);
if (!printedFound && projects.length > 0) {
output.log(
`${pluralize('Project', chunk.projects.length)} linked to ${link(
repoUrl
)} under ${chalk.bold(org.slug)}:`
);
printedFound = true;
}
for (const project of chunk.projects) {
output.print(` * ${chalk.cyan(`${org.slug}/${project.name}\n`)}`);
}
if (chunk.pagination.next) {
output.spinner(`Found ${chalk.bold(projects.length)} Projects…`, 0);
}
}
if (projects.length === 0) {
output.log(
`No Projects are linked to ${link(repoUrl)} under ${chalk.bold(
@@ -140,24 +160,17 @@ export async function ensureRepoLink(
// 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'}?`,
`Link to ${
projects.length === 1
? 'this Project'
: `these ${chalk.bold(projects.length)} Projects`
}?`,
true
));
@@ -179,10 +192,7 @@ export async function ensureRepoLink(
};
await outputJSON(repoConfigPath, repoConfig, { spaces: 2 });
await writeFile(
join(rootPath, VERCEL_DIR, VERCEL_DIR_README),
await readFile(join(__dirname, 'VERCEL_DIR_README.txt'), 'utf8')
);
await writeReadme(rootPath);
// update .gitignore
const isGitIgnoreUpdated = await addToGitIgnore(rootPath);
@@ -211,33 +221,47 @@ export async function ensureRepoLink(
* 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)) {
export async function findRepoRoot(
client: Client,
start: string
): Promise<string | undefined> {
const { debug } = client.output;
const REPO_JSON_PATH = join(VERCEL_DIR, VERCEL_DIR_REPO);
const GIT_CONFIG_PATH = normalize('.git/config');
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.
debug('Arrived at home directory');
break;
}
const gitConfigPath = join(current, '.git/config');
const stat = await lstat(gitConfigPath).catch(err => {
// if `.vercel/repo.json` exists (already linked),
// then consider this the repo root
const repoConfigPath = join(current, REPO_JSON_PATH);
let stat = await lstat(repoConfigPath).catch(err => {
if (err.code !== 'ENOENT') throw err;
});
if (stat) {
debug(`Found "${REPO_JSON_PATH}" - detected "${current}" as repo root`);
return current;
}
// if `.git/config` exists (unlinked),
// then consider this the repo root
const gitConfigPath = join(current, GIT_CONFIG_PATH);
stat = await lstat(gitConfigPath).catch(err => {
if (err.code !== 'ENOENT') throw err;
});
if (stat) {
debug(`Found "${GIT_CONFIG_PATH}" - detected "${current}" as repo root`);
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;
}
debug('Aborting search for repo root');
}
function sortByDirectory(a: RepoProjectConfig, b: RepoProjectConfig): number {
@@ -247,19 +271,19 @@ function sortByDirectory(a: RepoProjectConfig, b: RepoProjectConfig): number {
}
/**
* Finds the matching Project from an array of Project links
* Finds the matching Projects from an array of Project links
* where the provided relative path is within the Project's
* root directory.
*/
export function findProjectFromPath(
export function findProjectsFromPath(
projects: RepoProjectConfig[],
path: string
): RepoProjectConfig | undefined {
): RepoProjectConfig[] {
const normalizedPath = normalizePath(path);
return projects
const matches = projects
.slice()
.sort(sortByDirectory)
.find(project => {
.filter(project => {
if (project.directory === '.') {
// Project has no "Root Directory" setting, so any path is valid
return true;
@@ -269,4 +293,9 @@ export function findProjectFromPath(
normalizedPath.startsWith(`${project.directory}/`)
);
});
// If there are multiple matches, we only want the most relevant
// selections (with the deepest directory depth), so pick the first
// one and filter on those matches.
const firstMatch = matches[0];
return matches.filter(match => match.directory === firstMatch.directory);
}

View File

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

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;
}

View File

@@ -0,0 +1,102 @@
import chalk from 'chalk';
import type Client from '../client';
import type { Deployment, Project, Team } from '@vercel-internals/types';
import getDeployment from '../get-deployment';
import getProjectByNameOrId from './get-project-by-id-or-name';
import getScope from '../get-scope';
import getTeamById from '../teams/get-team-by-id';
import { isValidName } from '../is-valid-name';
import { Output } from '../output';
import { ProjectNotFound } from '../errors-ts';
export default async function getProjectByDeployment({
client,
deployId,
output,
}: {
client: Client;
deployId: string;
output?: Output;
}): Promise<{
contextName: string;
deployment: Deployment;
project: Project;
}> {
const { config } = client;
const { contextName } = await getScope(client);
if (!isValidName(deployId)) {
throw new Error(
`The provided argument "${deployId}" is not a valid deployment ID or URL`
);
}
let deployment: Deployment;
let team: Team | undefined;
try {
output?.spinner(
`Fetching deployment "${deployId}" in ${chalk.bold(contextName)}`
);
const [teamResult, deploymentResult] = await Promise.allSettled([
config.currentTeam ? getTeamById(client, config.currentTeam) : undefined,
getDeployment(client, contextName, deployId),
]);
if (teamResult.status === 'rejected') {
throw new Error(
`Failed to retrieve team information: ${teamResult.reason}`
);
}
if (deploymentResult.status === 'rejected') {
throw new Error(deploymentResult.reason);
}
team = teamResult.value;
deployment = deploymentResult.value;
// re-render the spinner text
output?.log(
`Fetching deployment "${deployId}" in ${chalk.bold(contextName)}`
);
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;
}
if (!deployment.projectId) {
throw new Error('Deployment is not associated to a project');
}
const project = await getProjectByNameOrId(client, deployment.projectId);
if (project instanceof ProjectNotFound) {
throw project;
}
return {
contextName,
deployment,
project,
};
} finally {
output?.stopSpinner();
}
}

View File

@@ -5,11 +5,13 @@ import { isAPIError, ProjectNotFound } from '../errors-ts';
export default async function getProjectByNameOrId(
client: Client,
projectNameOrId: string,
accountId?: string
accountId?: string,
includeRollbackInfo?: boolean
) {
try {
const qs = includeRollbackInfo ? '?rollbackInfo=true' : '';
const project = await client.fetch<Project>(
`/v8/projects/${encodeURIComponent(projectNameOrId)}`,
`/v9/projects/${encodeURIComponent(projectNameOrId)}${qs}`,
{ accountId }
);
return project;

View File

@@ -2,7 +2,7 @@ import fs from 'fs';
import AJV from 'ajv';
import chalk from 'chalk';
import { join, relative } from 'path';
import { ensureDir, readJSON } from 'fs-extra';
import { ensureDir } from 'fs-extra';
import { promisify } from 'util';
import getProjectByIdOrName from '../projects/get-project-by-id-or-name';
@@ -10,7 +10,6 @@ import Client from '../client';
import { InvalidToken, isAPIError, ProjectNotFound } from '../errors-ts';
import getUser from '../get-user';
import getTeamById from '../teams/get-team-by-id';
import { Output } from '../output';
import type {
Project,
ProjectLinkResult,
@@ -22,8 +21,9 @@ import { isDirectory } from '../config/global-path';
import { NowBuildError, getPlatformEnv } from '@vercel/build-utils';
import outputCode from '../output/code';
import { isErrnoException, isError } from '@vercel/error-utils';
import { findProjectFromPath, findRepoRoot } from '../link/repo';
import { findProjectsFromPath, getRepoLink } from '../link/repo';
import { addToGitIgnore } from '../link/add-to-gitignore';
import type { RepoProjectConfig } from '../link/repo';
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);
@@ -69,38 +69,52 @@ export function getVercelDirectory(cwd: string): string {
return existingDirs[0] || possibleDirs[0];
}
async function getLink(path: string): Promise<ProjectLink | null> {
// Try the individual project linking style (`${cwd}/.vercel/project.json`)
const dir = getVercelDirectory(path);
const linkFromProject = await getLinkFromDir(dir);
if (linkFromProject) {
return linkFromProject;
}
// Try the repo linking style (`${repoRoot}/.vercel/repo.json`)
return getLinkFromRepo(path);
export async function getProjectLink(
client: Client,
path: string
): Promise<ProjectLink | null> {
return (
(await getProjectLinkFromRepoLink(client, path)) ||
(await getLinkFromDir(getVercelDirectory(path)))
);
}
async function getLinkFromRepo(path: string): Promise<ProjectLink | null> {
const repoRoot = await findRepoRoot(path);
if (!repoRoot) {
async function getProjectLinkFromRepoLink(
client: Client,
path: string
): Promise<ProjectLink | null> {
const repoLink = await getRepoLink(client, path);
if (!repoLink?.repoConfig) {
return null;
}
try {
const vercelDir = join(repoRoot, VERCEL_DIR);
const repoJsonPath = join(vercelDir, VERCEL_DIR_REPO);
const repoJson = await readJSON(repoJsonPath);
const project = findProjectFromPath(
repoJson.projects,
relative(repoRoot, path)
);
if (project) {
return { orgId: repoJson.orgId, projectId: project.id };
}
} catch (err: unknown) {
if (!isErrnoException(err) || err.code !== 'ENOENT') {
throw err;
}
const projects = findProjectsFromPath(
repoLink.repoConfig.projects,
relative(repoLink.rootPath, path)
);
let project: RepoProjectConfig | undefined;
if (projects.length === 1) {
project = projects[0];
} else {
const selectableProjects =
projects.length > 0 ? projects : repoLink.repoConfig.projects;
const { p } = await client.prompt({
name: 'p',
type: 'list',
message: `Please select a Project:`,
choices: selectableProjects.map(p => ({
value: p,
name: p.name,
})),
});
project = p;
}
if (project) {
return {
repoRoot: repoLink.rootPath,
orgId: repoLink.repoConfig.orgId,
projectId: project.id,
projectRootDirectory: project.directory,
};
}
return null;
}
@@ -154,9 +168,46 @@ async function getOrgById(client: Client, orgId: string): Promise<Org | null> {
return { type: 'user', id: orgId, slug: user.username };
}
async function hasProjectLink(
client: Client,
projectLink: ProjectLink,
path: string
): Promise<boolean> {
// "linked" via env vars?
const VERCEL_ORG_ID = getPlatformEnv('ORG_ID');
const VERCEL_PROJECT_ID = getPlatformEnv('PROJECT_ID');
if (
VERCEL_ORG_ID === projectLink.orgId &&
VERCEL_PROJECT_ID === projectLink.projectId
) {
return true;
}
// linked via `repo.json`?
const repoLink = await getRepoLink(client, path);
if (
repoLink?.repoConfig?.orgId === projectLink.orgId &&
repoLink.repoConfig.projects.find(p => p.id === projectLink.projectId)
) {
return true;
}
// if the project is already linked, we skip linking
const link = await getLinkFromDir(getVercelDirectory(path));
if (
link &&
link.orgId === projectLink.orgId &&
link.projectId === projectLink.projectId
) {
return true;
}
return false;
}
export async function getLinkedProject(
client: Client,
path = process.cwd()
path = client.cwd
): Promise<ProjectLinkResult> {
const { output } = client;
const VERCEL_ORG_ID = getPlatformEnv('ORG_ID');
@@ -177,7 +228,7 @@ export async function getLinkedProject(
const link =
VERCEL_ORG_ID && VERCEL_PROJECT_ID
? { orgId: VERCEL_ORG_ID, projectId: VERCEL_PROJECT_ID }
: await getLink(path);
: await getProjectLink(client, path);
if (!link) {
return { status: 'not_linked', org: null, project: null };
@@ -195,7 +246,7 @@ export async function getLinkedProject(
if (isAPIError(err) && err.status === 403) {
output.stopSpinner();
if (err.missingToken) {
if (err.missingToken || err.invalidToken) {
throw new InvalidToken();
} else {
throw new NowBuildError({
@@ -234,32 +285,26 @@ export async function getLinkedProject(
return { status: 'not_linked', org: null, project: null };
}
return { status: 'linked', org, project };
return { status: 'linked', org, project, repoRoot: link.repoRoot };
}
export async function writeReadme(path: string) {
await writeFile(
join(path, VERCEL_DIR, VERCEL_DIR_README),
await readFile(join(__dirname, 'VERCEL_DIR_README.txt'), 'utf8')
);
}
export async function linkFolderToProject(
output: Output,
client: Client,
path: string,
projectLink: ProjectLink,
projectName: string,
orgSlug: string,
successEmoji: EmojiLabel = 'link'
) {
const VERCEL_ORG_ID = getPlatformEnv('ORG_ID');
const VERCEL_PROJECT_ID = getPlatformEnv('PROJECT_ID');
// if defined, skip linking
if (VERCEL_ORG_ID || VERCEL_PROJECT_ID) {
return;
}
// if the project is already linked, we skip linking
const link = await getLink(path);
if (
link &&
link.orgId === projectLink.orgId &&
link.projectId === projectLink.projectId
) {
if (await hasProjectLink(client, projectLink, path)) {
return;
}
@@ -279,15 +324,12 @@ export async function linkFolderToProject(
JSON.stringify(projectLink)
);
await writeFile(
join(path, VERCEL_DIR, VERCEL_DIR_README),
await readFile(join(__dirname, 'VERCEL_DIR_README.txt'), 'utf8')
);
await writeReadme(path);
// update .gitignore
const isGitIgnoreUpdated = await addToGitIgnore(path);
output.print(
client.output.print(
prependEmoji(
`Linked to ${chalk.bold(
`${orgSlug}/${projectName}`

View File

@@ -1,11 +1,12 @@
import { outputJSON } from 'fs-extra';
import { Org, Project, ProjectLink } from '@vercel-internals/types';
import { getLinkFromDir, VERCEL_DIR, VERCEL_DIR_PROJECT } from './link';
import { join } from 'path';
import { outputJSON, readFile } from 'fs-extra';
import { VercelConfig } from '@vercel/client';
import { VERCEL_DIR, VERCEL_DIR_PROJECT } from './link';
import { PartialProjectSettings } from '../input/edit-project-settings';
import type { Org, Project, ProjectLink } from '@vercel-internals/types';
import { isErrnoException, isError } from '@vercel/error-utils';
export type ProjectLinkAndSettings = ProjectLink & {
export type ProjectLinkAndSettings = Partial<ProjectLink> & {
settings: {
createdAt: Project['createdAt'];
installCommand: Project['installCommand'];
@@ -26,7 +27,8 @@ export type ProjectLinkAndSettings = ProjectLink & {
export async function writeProjectSettings(
cwd: string,
project: Project,
org: Org
org: Org,
isRepoLinked: boolean
) {
let analyticsId: string | undefined;
if (
@@ -39,8 +41,8 @@ export async function writeProjectSettings(
}
const projectLinkAndSettings: ProjectLinkAndSettings = {
projectId: project.id,
orgId: org.id,
projectId: isRepoLinked ? undefined : project.id,
orgId: isRepoLinked ? undefined : org.id,
settings: {
createdAt: project.createdAt,
framework: project.framework,
@@ -60,8 +62,28 @@ export async function writeProjectSettings(
});
}
export async function readProjectSettings(cwd: string) {
return await getLinkFromDir<ProjectLinkAndSettings>(cwd);
export async function readProjectSettings(vercelDir: string) {
try {
return JSON.parse(
await readFile(join(vercelDir, VERCEL_DIR_PROJECT), 'utf8')
);
} catch (err: unknown) {
// `project.json` file does not exists, so project settings have not been pulled
if (
isErrnoException(err) &&
err.code &&
['ENOENT', 'ENOTDIR'].includes(err.code)
) {
return null;
}
// failed to parse JSON, treat the same as if project settings have not been pulled
if (isError(err) && err.name === 'SyntaxError') {
return null;
}
throw err;
}
}
export function pickOverrides(

View File

@@ -1,75 +0,0 @@
import chalk from 'chalk';
import type Client from '../client';
import type { Project } from '@vercel-internals/types';
import { getCommandName } from '../pkg-name';
import { getDeploymentByIdOrURL } from '../deploy/get-deployment-by-id-or-url';
import getScope from '../get-scope';
import { isErrnoException } from '@vercel/error-utils';
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 {Project} project - Project info instance
* @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,
deployIdOrUrl,
project,
timeout,
}: {
client: Client;
deployIdOrUrl: string;
project: Project;
timeout?: string;
}): Promise<number> {
const { output } = client;
const { contextName } = await getScope(client);
try {
const deployment = await getDeploymentByIdOrURL({
client,
contextName,
deployIdOrUrl,
});
// 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,
});
} 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,5 +1,4 @@
import { lstat as lstatRaw } from 'fs';
import { promisify } from 'util';
import { lstat } from 'fs-extra';
import { Output } from './output';
import chalk from 'chalk';
import { homedir } from 'os';
@@ -7,8 +6,6 @@ import confirm from './input/confirm';
import toHumanPath from './humanize-path';
import Client from './client';
const stat = promisify(lstatRaw);
/**
* A helper function to validate the `rootDirectory` input.
*/
@@ -18,7 +15,7 @@ export async function validateRootDirectory(
path: string,
errorSuffix: string
) {
const pathStat = await stat(path).catch(() => null);
const pathStat = await lstat(path).catch(() => null);
const suffix = errorSuffix ? ` ${errorSuffix}` : '';
if (!pathStat) {
@@ -66,7 +63,7 @@ export default async function validatePaths(
const path = paths[0];
// can only deploy a directory
const pathStat = await stat(path).catch(() => null);
const pathStat = await lstat(path).catch(() => null);
if (!pathStat) {
output.error(`Could not find ${chalk.cyan(`${toHumanPath(path)}`)}`);

View File

@@ -322,14 +322,17 @@ test('[vercel dev] should handle missing handler errors thrown in edge functions
);
validateResponseHeaders(res);
const { stderr } = await dev.kill();
const { stdout } = await dev.kill();
expect(await res.text()).toMatch(
/<strong>500<\/strong>: INTERNAL_SERVER_ERROR/g
);
expect(stderr).toMatch(
/No default export was found. Add a default export to handle requests./g
);
const url = `http://localhost:${port}/api/edge-error-no-handler`;
expect(stdout).toMatchInlineSnapshot(`
"Error from API Route /api/edge-error-no-handler: No default or HTTP-named export was found at ${url}. Add one to handle requests. Learn more: https://vercel.link/creating-edge-middleware
at (api/edge-error-no-handler.js)
"
`);
} finally {
await dev.kill();
}

View File

@@ -88,10 +88,10 @@ test(
async (testPath: any) => {
const vcRobots = `https://vercel.com/robots.txt`;
await testPath(200, '/rewrite', /User-Agent: \*/m);
await testPath(308, '/redirect', `Redirecting to ${vcRobots} (308)`, {
await testPath(308, '/redirect', `Redirecting...`, {
Location: vcRobots,
});
await testPath(307, '/tempRedirect', `Redirecting to ${vcRobots} (307)`, {
await testPath(307, '/tempRedirect', `Redirecting...`, {
Location: vcRobots,
});
}
@@ -103,10 +103,10 @@ test(
testFixtureStdio('test-routing-case-sensitive', async (testPath: any) => {
await testPath(200, '/Path', 'UPPERCASE');
await testPath(200, '/path', 'lowercase');
await testPath(308, '/GoTo', 'Redirecting to /upper.html (308)', {
await testPath(308, '/GoTo', 'Redirecting...', {
Location: '/upper.html',
});
await testPath(308, '/goto', 'Redirecting to /lower.html (308)', {
await testPath(308, '/goto', 'Redirecting...', {
Location: '/lower.html',
});
})

View File

@@ -233,7 +233,7 @@ test(
expect(res.headers.get('location')).toBe(
`http://localhost:${port}/?foo=bar`
);
expect(body).toBe('Redirecting to /?foo=bar (301)\n');
expect(body).toBe('Redirecting...\n');
}
{

View File

@@ -197,21 +197,18 @@ test(
await testPath(200, '/sub', 'Sub Index Page');
await testPath(200, '/sub/another', 'Sub Another Page');
await testPath(200, '/style.css', 'body { color: green }');
await testPath(308, '/index.html', 'Redirecting to / (308)', {
await testPath(308, '/index.html', 'Redirecting...', {
Location: '/',
});
await testPath(308, '/about.html', 'Redirecting to /about (308)', {
await testPath(308, '/about.html', 'Redirecting...', {
Location: '/about',
});
await testPath(308, '/sub/index.html', 'Redirecting to /sub (308)', {
await testPath(308, '/sub/index.html', 'Redirecting...', {
Location: '/sub',
});
await testPath(
308,
'/sub/another.html',
'Redirecting to /sub/another (308)',
{ Location: '/sub/another' }
);
await testPath(308, '/sub/another.html', 'Redirecting...', {
Location: '/sub/another',
});
})
);
@@ -225,21 +222,18 @@ test(
await testPath(200, '/sub', 'Sub Index Page');
await testPath(200, '/sub/another', 'Sub Another Page');
await testPath(200, '/style.css', 'body { color: green }');
await testPath(308, '/index.html', 'Redirecting to / (308)', {
await testPath(308, '/index.html', 'Redirecting...', {
Location: '/',
});
await testPath(308, '/about.html', 'Redirecting to /about (308)', {
await testPath(308, '/about.html', 'Redirecting...', {
Location: '/about',
});
await testPath(308, '/sub/index.html', 'Redirecting to /sub (308)', {
await testPath(308, '/sub/index.html', 'Redirecting...', {
Location: '/sub',
});
await testPath(
308,
'/sub/another.html',
'Redirecting to /sub/another (308)',
{ Location: '/sub/another' }
);
await testPath(308, '/sub/another.html', 'Redirecting...', {
Location: '/sub/another',
});
}
)
);
@@ -264,21 +258,16 @@ test(
await testPath(200, '/sub/another/', 'Sub Another Page');
await testPath(200, '/style.css', 'body { color: green }');
//TODO: fix this test so that location is `/` instead of `//`
//await testPath(308, '/index.html', 'Redirecting to / (308)', { Location: '/' });
await testPath(308, '/about.html', 'Redirecting to /about/ (308)', {
//await testPath(308, '/index.html', 'Redirecting...', { Location: '/' });
await testPath(308, '/about.html', 'Redirecting...', {
Location: '/about/',
});
await testPath(308, '/sub/index.html', 'Redirecting to /sub/ (308)', {
await testPath(308, '/sub/index.html', 'Redirecting...', {
Location: '/sub/',
});
await testPath(
308,
'/sub/another.html',
'Redirecting to /sub/another/ (308)',
{
Location: '/sub/another/',
}
);
await testPath(308, '/sub/another.html', 'Redirecting...', {
Location: '/sub/another/',
});
})
);
@@ -315,13 +304,13 @@ test(
await testPath(200, '/sub/index.html', 'Sub Index Page');
await testPath(200, '/sub/another.html', 'Sub Another Page');
await testPath(200, '/style.css', 'body { color: green }');
await testPath(308, '/about.html/', 'Redirecting to /about.html (308)', {
await testPath(308, '/about.html/', 'Redirecting...', {
Location: '/about.html',
});
await testPath(308, '/style.css/', 'Redirecting to /style.css (308)', {
await testPath(308, '/style.css/', 'Redirecting...', {
Location: '/style.css',
});
await testPath(308, '/sub', 'Redirecting to /sub/ (308)', {
await testPath(308, '/sub', 'Redirecting...', {
Location: '/sub/',
});
})
@@ -347,20 +336,15 @@ test(
await testPath(200, '/sub/index.html', 'Sub Index Page');
await testPath(200, '/sub/another.html', 'Sub Another Page');
await testPath(200, '/style.css', 'body { color: green }');
await testPath(308, '/about.html/', 'Redirecting to /about.html (308)', {
await testPath(308, '/about.html/', 'Redirecting...', {
Location: '/about.html',
});
await testPath(308, '/sub/', 'Redirecting to /sub (308)', {
await testPath(308, '/sub/', 'Redirecting...', {
Location: '/sub',
});
await testPath(
308,
'/sub/another.html/',
'Redirecting to /sub/another.html (308)',
{
Location: '/sub/another.html',
}
);
await testPath(308, '/sub/another.html/', 'Redirecting...', {
Location: '/sub/another.html',
});
})
);

View File

@@ -44,7 +44,9 @@ function fetchWithRetry(url, opts = {}) {
if (res.status !== opts.status) {
const text = await res.text();
throw new Error(
`Failed to fetch ${url} with status ${res.status} (expected ${opts.status}):\n\n${text}\n\n`
`Failed to fetch "${url}", received ${res.status}, expected ${
opts.status
}, id: ${res.headers.get('x-vercel-id')}:\n\n${text}\n\n`
);
}

View File

@@ -0,0 +1,4 @@
{
"orgId": "team_dummy",
"projectId": "build-output-api-failed-before-builds"
}

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