* Fixed error with API directory
* Made output work
* Use handler as API Route
* Correctly find the handler
* Fixed a missing instance
* Made handler logic work
* Made it work as expected
* Exclude unnecessary files
* Use a method that always works
* Additional comment
* Made everything work
* Cleaner tests
* Clean up all the useless files
* Fixed missing instance
* Speed up the code
* Removed useless lines
* Update packages/build-utils/src/convert-runtime-to-plugin.ts
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
* Clarified comment
* Use relative logic again
* Fixed tests
* Deleted useless file
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
### Related Issues
This applies what was mentioned in https://github.com/vercel/runtimes/issues/288#issuecomment-984101750.
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [x] This PR has a concise title and thorough description useful to a reviewer
- [x] Issue from task tracker has a link to this PR
After https://github.com/vercel/vercel/pull/7088, `dist` now contains `package.json`, which made `tsc` move `index.js` a level deeper, effectively breaking the `main` property of all of the affected CLI Plugins.
This change makes them work again.
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [x] This PR has a concise title and thorough description useful to a reviewer
- [x] Issue from task tracker has a link to this PR
* Avoid unnecessary Gemfile installations
* Do not bundle `.output` or `.vercel` into Lambdas
* Use the same input hash format for all CLI Plugins and `vercel build`
* Fixed unit tests
* Fixed the unit tests again
* Fixed the unit tests
* Fixed all the tests
* Exclude useless files
* Consider `.vercelignore` and `.nowignore`
* Fixed error
* Reverted changes
* Deleted useless file
* Fixed tests
* Share input hash format with `vercel-plugin-node`
* Make output inspectable
* Fixed build error
* Extended comment
* Bump Ruby version
* Update Gemfiles
* Update bundles
* Fixed tests
Co-authored-by: Andy Bitz <artzbitz@gmail.com>
* Stop passing `functions` and `regions` to Runtimes
* Added required types back
* Removed `vercelConfig` from `vercel-plugin-node`
* Fixed unit test
* Fixed test
* [cli] Consider `envPrefix` for the framework
* Fix env
* Remove type
* Resolve .nft.json files correctly
* Fix public and static directory handling
* Do not use .replace
* Consider the output directory
* Added Remix to the list of frameworks
* Replaced Development Command
* Polished config
* Added headers
* Added example
* Fixed logo
* Trigger a Deployment
* Added vercel.json
* Port is automatically parsed through remix.config.js
* Fixed sorting
* Moved it down a bit
* Trigger a Deployment
* Removed useless property
* Reverted readme
* Fully reverted readme
* [plugin-node][node] Fix dependency installation, handler path, and build script
* Use smaller library for testing
* Make test work on windows
* Remove .output before fixture runs and update routes update
* Apply suggestions from code review
Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Steven <steven@ceriously.com>
### Related Issues
The Parcel template via the Project Creating Flow returns a build error because the default output directory for the Parcel **Framework Preset** is searching for `public` instead of `dist`. The default behavior of Parcel's CLI I believe is `dist`.
### 📋 Checklist
<!--
Please keep your PR as a Draft until the checklist is complete
-->
#### Tests
- [ ] The code changed/added as part of this PR has been covered with tests
- [ ] All tests pass locally with `yarn test-unit`
#### Code Review
- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
* [python] Upgrade python 3.9
* Fix python path
* Improve testing
* Add support for version selection via Pipfile
* Parse the "Pipfile.lock" instead
* Fix support for Node.js 12
* Switch from hardlinks to symlinks in vc build
* Remove error handling that fs-extra already takes care of
* Add comment
* Put back symlink error handling
Seems like macOS sometimes exceeds 60 min so this bumps the timeout.
The build can be between 3 minutes and 5 minutes. The tests can be between 45 minutes and 55 minutes.
* Prevent infinite recursion of vercel build and dev
* Improved text
* Improved the text further
* Add tests
* Debug test
* Add debug log
* Debug test
* debug test
* Debug test
* Fix test
* Debug tests
* Debug test
* Remove only from tests
* Add error documentation
* Improved docs
* Fix other test
* Fixed links to error docs
* Remove legacy error page
* Use nicer error links
Co-authored-by: Leo Lamprecht <leo@vercel.com>
* Fix middleware build result. Return middleware next when invalid result.
* Add a unit test that would have failed before previous commit.
* Copy next.js behavior.
* Add a test for invalid responses from middleware.
Co-authored-by: Leo Lamprecht <leo@vercel.com>
### Related Issues
x-ref: https://github.com/vercel/customer-issues/issues/34
### 📋 Checklist
<!--
Please keep your PR as a Draft until the checklist is complete
-->
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
* Move loadPlugins to a utils file to be shared w/ dev server.
* Update loadCliPlugins to also return startDevServer and runDevMiddleware based plugins.
* Move plugins back to dependencies.
These can't be bundled as it interferes with plugin resolution.
* Hook up middleware plugins to dev server.
* Pass output object to loadCliPlugins instead of a logging function.
* Allow more than one runDevMiddleware defining plugins.
* Bundle esbuild w/ middleware plugin.
* Keep esbuild as an external
* Update middleware's esbuild.
* set old space size
* Revert "set old space size"
This reverts commit b579194a862949a11769e9087f01c31f2e1f3b60.
* Use --max-old-space-size for CLI unit tests
* Increase memory
* Use `run.js` to set the memory
* Make NODE_OPTIONS optional
Co-authored-by: Leo Lamprecht <leo@vercel.com>
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
Co-authored-by: Andy Bitz <artzbitz@gmail.com>
* [node] Refactor to Vercel CLI Plugin
* Enforce "index" suffix on output Serverless Functions
So that nesting works properly
* Some cleanup
* Add version
* Use `@vercel/static-config`
* .
* Add support for wildcard routes
* Don't compile dotfiles, underscore prefixed files, files within `node_modules`, nor TypeScript definition files
Matches the logic from `maybeGetBuilder()` in `@vercel/build-utils`.
* Bump version
* Introduce testing framework
* Debug
* Add test without any deps
* Longer timeout to install Node.js for vercel/fun
* Install deps
* Add legacy Node.js server interface test
* More tests
* Test "assets" fixture
* Test "helpers" fixture
* fix
* Support AWS native API
* Remove debugging `console.log()` calls
* Use plugin-node for new plugin instead
* Revert "Use plugin-node for new plugin instead"
This reverts commit f317b8c6ecdc67a74d5f2b12a2e7567a27d4b6b8.
* Move to `plugin-node` directory
* Update plugin-node version in package.json
* Checkout node from main
* Add yarn.lock files for tests
* Update node-bridge
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
Co-authored-by: Andy Bitz <artzbitz@gmail.com>
### Related Issues
> Fixes https://github.com/vercel/runtimes/issues/219
### 📋 Checklist
<!--
Please keep your PR as a Draft until the checklist is complete
-->
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
* Use ncc to bundle middleware plugin, move dependencies to devDependencies, remove querystring
* Switch from globby (deprecated dependencies) to glob in middleware plugin.
* Bundle the node-plugin and middleware-plugin into cli.
* Add initial `vercel-plugin-middleware`
* Ignore `entries.js` from ESLint
* Add `runDevMiddleware()` stub
* Add test
* Add support for "_middleware.{js,ts}" to `vercel dev` (#6880)
* Add websandbox from next.js codebase.
* Use node-fetch instead of next's polyfilled fetch.
* Handle middleware rewrites.
* Add response, headers, and request to websandbox context.
* Move websandbox dependency to middleware plugin.
* Add integration tests, update websandbox to support ts files and json imports.
* commit yarn.lock changes after rebasing
* Clean up left over console.logs, fix some tsc issues, and rebase issue.
* Fix failing test and eslint.
* Fix middleware test on windows.
* [examples] Update Vercel Next.js example template to 12.0.1 (#6905)
* Mark the Plugins as external to CLI's ncc build
* [cli] Improve tracing in vc build (#6898)
* [cli] Fix tracing for `vc build`
* Ignore object when there are no changes
* Make Next < 12 work with FS API w/ nft
* Update packages/cli/src/commands/build.ts
Co-authored-by: Nathan Rajlich <n@n8.io>
* Document how Next.js processing works in build
* [cli] Fix static assets (#6906)
* Make sure output path is .next
* Fix up require-server-files for processing
* Fix typo
* Move static
* Update static rename
Co-authored-by: Andy Bitz <artzbitz@gmail.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
* Publish Canary
- vercel@23.1.3-canary.17
- @vercel/client@10.2.3-canary.15
- @vercel/static-config@0.0.1-canary.0
* [cli] Ignore `.env` and `.gitignore` in "vc build" (#6910)
* Publish Canary
- vercel@23.1.3-canary.18
* Pass workPath to plugins.
The new plugin architecture doesn't pass a full BuildOptions object, previous
to this commit it wasn't passing any options at all. I've added workingPath to
support running dev/build from directories other than the project root.
* Remove error state when package.json exists, but no build script
This allows vercel build to continue working for projects that are not using
frameworks, but use package.json to manage dependencies.
* Fix types, pull in middleware header fix from next.js
Next js PR w/ the header fix:
https://github.com/vercel/next.js/pull/30560
* Fix missing entries file for vc build.
* Update call signature of middleware when using vc build.
Co-authored-by: Drew Bredvick <dbredvick@gmail.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
Co-authored-by: Jared Palmer <jared@jaredpalmer.com>
Co-authored-by: Andy Bitz <artzbitz@gmail.com>
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
Co-authored-by: Gary Borton <gdborton@gmail.com>
Co-authored-by: Drew Bredvick <dbredvick@gmail.com>
Co-authored-by: Jared Palmer <jared@jaredpalmer.com>
Co-authored-by: Andy Bitz <artzbitz@gmail.com>
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
* [cli] Fix tracing for `vc build`
* Ignore object when there are no changes
* Make Next < 12 work with FS API w/ nft
* Update packages/cli/src/commands/build.ts
Co-authored-by: Nathan Rajlich <n@n8.io>
* Document how Next.js processing works in build
* [cli] Fix static assets (#6906)
* Make sure output path is .next
* Fix up require-server-files for processing
* Fix typo
* Move static
* Update static rename
Co-authored-by: Andy Bitz <artzbitz@gmail.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
* Add PoC pull command
* Improve pull's linking logic
* Remove `__VERCEL_SKIP_PULL_CMD` env var and unneeded type narrowing
* Improve pull's link logic
* Fix team mock
* Add smoke test for vc pull
* Add setupFixture helper
* Remove debug duplicate
* Use a fixture in pull test
* Put back debug
* Fix unit test
* Fix test on windows
* Remove mock-stdin
* Pass cwd to link and pull
* Add help command for `vc pull`
* Organize imports
* Update packages/cli/src/commands/deploy/args.ts
Co-authored-by: Steven <steven@ceriously.com>
* Use tmp-promise instead of tmp
* Update packages/cli/src/commands/pull.ts
Co-authored-by: Steven <steven@ceriously.com>
* Update packages/cli/src/commands/pull.ts
Co-authored-by: Steven <steven@ceriously.com>
* Clean up pull comments and variable declarations
* Remove graceful tmp directory cleanup
* Put back graceful cleanup
* Print output for debugging
* Moar debug
* Set 10s timeout for `vc pull` test
* Change fixture to now-pull-next
* Fix pull test name
* Switch project mock to use encrypted env
* Add --env flag
* Update fixtures
* Remove now- from everywhere
* Remove instrumentation
* Rename setupFixture to setup-fixture
* Add deprecation warning to `vc env pull`
* Update packages/cli/src/commands/deploy/args.ts
Co-authored-by: Nathan Rajlich <nathan@tootallnate.net>
* Update packages/cli/src/commands/env/pull.ts
Co-authored-by: Nathan Rajlich <nathan@tootallnate.net>
* Fix pull and update imports
* Revamped build command
* printConfig -> renderConfig
* Remove frameworks
* Add build state unit test for gatsby
* Update packages/cli/src/commands/pull.ts
Co-authored-by: Steven <steven@ceriously.com>
* Update packages/cli/src/commands/env/index.ts
Co-authored-by: Steven <steven@ceriously.com>
* Update packages/cli/src/util/projects/write-project-settings.ts
Co-authored-by: Nathan Rajlich <nathan@tootallnate.net>
* Update packages/cli/src/commands/pull.ts
Co-authored-by: Nathan Rajlich <nathan@tootallnate.net>
* Don't writeProjectSettings in env pull
* Cleanup fixtures once afterAll
* Add help text for --env and -y
* Add output for pull
* Write project settings output after env output
* Pushing for Nate
* Add todo about handling Other's build output directory
* Add support for plugins
* Improve prompt logic loop
* Pluralize plugin output
* Better plugin failure handling
* Refactor away from BuildState class
* Remove unused file
* Correct framework detection logic, smart copy w/hardlinks
* Generate build manifest
* Generate routes-manifest.json
* Remove ambiguity when calling vc build
* Make sure manifests have all keys
* Ensure that .output is added to .gitignore in vc link
* Remove directoryListing from project settings
* Add support for default cli plugins
* Remove directory listing
* Install vercel-plugin-node
* Patch console.log and console.error for plugins
* Improve build output
* Remove unused unit tests
* Allow build without token
* Add vercel plugin middleware
* Bump vercel-plugin-middleware
* Bump middleware plugin
* Tweak require.resolve
* Tweak require.resolve to __dirname
* Update `vercel-plugin-node`
* Fix prefixed logs when using formatters i.e. `%j`
* Pretty print the manifest files
* Get unique CLI deps
For the case where the local project has one of the CLI default plugins
specified.
* Update packages/cli/package.json
Co-authored-by: Nathan Rajlich <nathan@tootallnate.net>
* Add help output
* Remove p-limit properly
* Confirm before pull in build
* Bump `vercel-plugin-node`
* [cli] Make Next.js move files into .output (#6885)
* Use OUTPUT_DIR
* Return properly if no package.json exists and no build command
* Invert logic for runPackageJsonScript
* Bump `vercel-plugin-middleware`
* Fix defaultHeaders in frameworks
* Fix build when nft files is object
* Update `yarn.lock`
* 2nd attempt at --prebuilt (#6888)
Co-authored-by: Andy Bitz <artzbitz@gmail.com>
* Add beta and feedback to vc build
Co-authored-by: Nathan Rajlich <n@n8.io>
Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Nathan Rajlich <nathan@tootallnate.net>
Co-authored-by: Andy Bitz <artzbitz@gmail.com>
Add `vercel pull` command. Closes https://github.com/vercel/runtimes/issues/142.

It does the following:
- Pull the `.env` file (it calls `pull` internally)
- Adds the following to `.vercel/project.json` (which will then be used by `vercel build`):
```tsx
interface ProjectLink {
projectId: string
orgId: string
settings: {
buildCommand: string | null,
devCommand: string | null,
directoryListing: string | null,
outputDirectory: string | null,
rootDirectory: string | null,
framework: string | null,
}
}
```
This PR also deprecates `vc env pull` with a warning:

### 📋 Checklist
- [x] Help output
- [x] Flags (need to combine flags from `env pull`)
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [x] This PR has a concise title and thorough description useful to a reviewer
- [x] Issue from task tracker has a link to this PR
Adds an additional property for the `routes` schema.
### Related Issues
N/A
### 📋 Checklist
<!--
Please keep your PR as a Draft until the checklist is complete
-->
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
This will prevent any issues where the `Now` instance is out-of-sync with the `Client` instance, for example, during a re-auth where a new auth token is issued. Also reduces a bit of code which is nice.
Fixes an issue where the token would not be properly upgraded while
a Team scope was currently active, causing a new auth token to be issued
and lose the previous access scope(s).
These changes originally from #6652, but pulled out to be merged
separately.
`outputBuffer` is a simpler way of asserting tests against the CLI
output instead of working directly withe Jest mock function.
`output.isTTY` is also now mutable, so that we can write tests for both
cases when the output is different based on TTY-ness (for example,
see the updated `vc whoami` tests in this PR).
This adds an argument to allow passing internal param names that should be ignored when considering whether params should be auto-added to a rewrite's destination query. After adding this we should be able to resolve https://github.com/vercel/next.js/issues/27563 in the runtime where `convertRewrites` is called.
This matches Next.js' handling for internal params which can be seen [here](e90825ad88/packages/next/shared/lib/router/utils/prepare-destination.ts (L203))
### Related Issues
x-ref: https://github.com/vercel/next.js/issues/27563
### 📋 Checklist
<!--
Please keep your PR as a Draft until the checklist is complete
-->
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
This ensures we replace header values correctly when no named segments are used and only has items are used.
### Related Issues
Fixes: https://vercel.slack.com/archives/CHTTGQYQ4/p1631023974185700
### 📋 Checklist
<!--
Please keep your PR as a Draft until the checklist is complete
-->
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
* Rewrites the CLI unit tests to be TypeScript and use Jest (consistent with the unit tests in the other packages in this repo).
* The file structure of the new test files mirrors that of the `src` directory, so that it's easy to find the relevant tests.
* Code coverage is also properly set up through Jest - you can already see a big increase in coverage from this PR.
* Adds a mock API server framework, with the intention of making it possible to write granular tests of the CLI commands. Using mocks also has the benefit of not requiring `VERCEL_TOKEN` env var to be set, so 3rd party PRs will be able to have their tests run. Ultimately this will also help with test coverage, since we will be writing unit tests that test the commands' code directly.
* Converts `Output` into a proper class (which is subclassed for the mocks).
To make setting up local dev README instructions easier for new users being introduced to a Vercel project, support flags to make the `vc link` command be non-interactive, in the case where the project name does not match the name of the directory where the code is located:
```
$ vc link --scope acme --project docs
```
Related to https://github.com/vercel/front/pull/10732.
Before:
```
Error! Unexpected error. Please try again later. ()
```
After:
```
Error! An unexpected error happened when running this build. We have been notified of the problem. If you have any questions, please contact support@vercel.com.
```
### Related Issues
Check the project's nodeVersion setting for when we release Node 16 and later
### 📋 Checklist
<!--
Please keep your PR as a Draft until the checklist is complete
-->
#### Tests
- [ ] The code changed/added as part of this PR has been covered with tests
- [ ] All tests pass locally with `yarn test-unit`
#### Code Review
- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
Currently, when `scanParentDirs()` finds the closest `package.json` file, it stops iteration regardless of whether or not a lockfile was found. For npm Workspaces, this is problematic because if you are deploying a subdirectory of a monorepo, then there will be no lockfile in the subdirectory (the `package-lock.json` file is at the root of the project). So instead of stopping once the `package.json` file is found, instead stop when the first lockfile is found.
And remove `jest`/`ts-jest` from the individual packages. It is important to have a consistent version of `jest` being used throughout the monorepo, otherwise bizarre errors surface that cause jest to crash, such as [here](https://github.com/vercel/vercel/runs/3255999061?check_suite_focus=true):
```
TypeError: this._environment.runScript is not a function
at Runtime._execModule (../../node_modules/jest-runner/node_modules/jest-runtime/build/index.js:856:41)
```
As the title suggests, this PR makes it such that npm 7 will be invoked when there is a `package-lock.json` file with `lockfileVersion` 2 or greater, by prepending the the `$PATH` a directory within the build container where npm 7 is located.
The test fixture `20-npm-7` is also enabled for E2E testing, to ensure that the proper npm version is enabled in the production build.
Makes the `test/unit.test.ts` file be TypeScript, and import from the source TypeScript code. This way, we don't need to run `yarn build` to test local changes when testing.
Also, VS Code was complaining about the types for jest `describe()`/`it()` not being installed, even though they are. After some digging, I found that TypeScript has a peculiar behavior with types in monorepo setups. [This solution](https://github.com/microsoft/TypeScript-Node-Starter/issues/196#issuecomment-771988960) describing adding a `tsconfig.json` inside of the `tests` dir seems to do the trick.
Like this, we can avoid that the dashboard will ask people to pass `--port` when running SvelteKit's Development Command.
Only `vercel dev` will make use of it.
This ensures we validate segments being used from `has` in the `destination` correctly
### Related Issues
x-ref: https://vercel.slack.com/archives/CLDDX2Y0G/p1627285500281300
### 📋 Checklist
<!--
Please keep your PR as a Draft until the checklist is complete
-->
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
Follow up to #6508. Adds a request "counter" that increments for every API request, matching how `front` does it.
Also tweaks the `output.time()` output a bit by rendering the timestamp in gray, and with `[]` brackets. If the time diff is < 1000ms then the full milliseconds will be printed intstead of the seconds.
<img width="710" alt="Screen Shot 2021-07-22 at 2 45 39 PM" src="https://user-images.githubusercontent.com/71256/126713843-db70ed9c-4752-4ca9-8f54-313c4cb44914.png">
Updates the `output.time()` function to accept a function as the "label" parameter. When a function is passed, it will be invoked twice, once at the beginning of the promise being executed, and a second time after the promise has resolved. The second time, the return value of the promise is passed to the label function, so that the resolved value may be used to create the label.
Drops usage of Node's `console.time()` and `console.timeEnd()` since we were using it in a hacky and unnecessary way.
Adds an "out-of-band" login mode to the `vc login` command, for use in headless environments like inside a Docker container or an SSH session. In these situations, spawning a localhost HTTP server won't work, because the HTTP server will not be accessible to the web browser that is doing the authentication.
In "out-of-band" mode, the login URL is simply presented to the user, and they must visit the login URL in their web browser and complete the authentication. The callback URL is a page on front that shows the verification token to the user and instructs them to copy + paste the token back into the CLI, at which point the login can complete.
Docker/SSH sessions are attempted to be automatically detected, and "out-of-band" mode is enabled implicitly. But there is also an `--oob` flag in case that detection logic were to fail (or if you'd like to run OOB mode locally).
This PR also adds shortcut flags for the Git provider login mechanisms, i.e. `vc login --github`.
https://user-images.githubusercontent.com/71256/125129304-1f5f3380-e0b4-11eb-8139-d1109811bd86.mov
This is a continuation of https://github.com/vercel/vercel/pull/6382 (thank you @markozxuu!) with merge conflicts addressed and pushed to a local branch, so that CI tests run.
Currently the `06-rails` test is failing at build time with:
```
16:27:09.550 'Your bundle is locked to mimemagic (0.3.3) from rubygems repository\n' +
16:27:09.550 'https://rubygems.org/ or installed locally, but that version can no longer be\n' +
16:27:09.550 'found in that source. That means the author of mimemagic (0.3.3) has removed it.\n' +
16:27:09.550 "You'll need to update your bundle to a version other than mimemagic (0.3.3) that\n" +
16:27:09.550 "hasn't been removed in order to install.",
```
So I ran `bundler update` in the "06-rails" Ruby test fixture to update the deps in the Gemfile.lock file.
Fixes an edge case bug when the user has a current scope that is
different than the owner of the project that is being deployed.
When this was the case, the API call to get the certs for a domain at
the end of the `vc deploy` command was using the incorrect `teamId`,
potentially causing a 403 error (when the current auth token does not
have access to the selected scope).
`vc deploy` doesn't care about the current "scope" that the CLI has selected, since it uses the `.vercel` directory to determine the ownerId and projectId.
Therefore, it should not be fetching the team details of the selected scope during `vc deploy`, since it's possible that the token might not have access to the current scope and returns a 403, even though that API call is unnecessary for the `vc deploy` command to complete.
Closing keep-alive HTTP connections was causing the `server.close()` call
to take a few seconds before completing, so set the `Connection: close`
response header in order to make the connections close immediately,
so that `server.close()` is fast.
Considering that it's a development environment, it's not important to wait for ongoing HTTP request connections to complete. Sometimes it takes a long time for all the shutdown operations to complete, which makes the command feel sluggish. So let's just `process.exit()` and exit quickly.
This Runtime is very old, outdated, unmaintained, and has never been documented.
Additionally, it no longer compiles with the latest version of Go. So
rather than fixing it, let's just remove it since we don't want to
invest any more time into it.
In some cases (i.e. when SSH'd to a remote machine) the `open` command will not work reliably. So we need to print the URL to the user as a fallback for those cases when the web browser is not automatically opened.
This also moves where `tokenName` is specified to be in the "verify" endpoint, so that it does not need to be part of the URL that gets printed to the user.
<img width="738" alt="Screen Shot 2021-06-07 at 2 12 47 PM" src="https://user-images.githubusercontent.com/71256/121089239-b5452d00-c79b-11eb-85b2-0e45b817dff0.png">
* refactor: Remove unncessary file
* feat(cli/alias): Migration to TS
* refactor(cli/alias): Add a line break
* refactor(cli/alias): Remove unnecesary code
* feat(cli): Add `Paginationoptions` type to `pagination`
* feat(cli/commands): Rewrite th `alias ls` command to TS
* refactor: Remove unncessary code
* feat: Create helper function for `getSafeAlias`
* refactor: Remove unnecessary code
* feat: Remove parameter generic, "null" for the fetch
* feat(cli/alias): Rewritten in full TS
* feat: Add Partial to opts
* refactor: Remove comment @ts-ignore
* feat: Add Partial to opts
* feat: Only should be return `alias.uid`
* refactor: Remove `Alias` type from of the parameter `id`
* refactor: Remove destructuring from alias object
* refactor: Remove unnecessary code
* feat: Rename `created` property to `createdAt` of number type
* refactor: Move getSafeAlias function in the same file
* refactor: Simplifying code
* refactor: Intentation did not affect diff on git
* Add null back to type
Co-authored-by: Steven <steven@ceriously.com>
The call to `GET /projects/info` is used to check existence but it can cause a race condition if the project was removed before the `DELETE /v2/projects` is called.
Instead, we rely on the response from `DELETE /v2/projects` to determine if the project exists or not.
This will also allow us to remove a legacy API endpoint in the future (see related API PR)
This ensures we normalize header `key` values in `has` items to be lower-case as the proxy currently only matches against the lower-case variant. Updated superstatic tests to ensure the header key is normalized correctly.
### Related Issues
[related thread](https://vercel.slack.com/archives/C01N3RWTE5V/p1621937306006400)
### 📋 Checklist
<!--
Please keep your PR as a Draft until the checklist is complete
-->
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
In the `vc switch` command, if your current access token results in
"limited" Team information being returned, then show a lock emoji
next to the team/user name in the select input.
When a locked scope is selected, then pre-emptively prompt the
user to re-authenticate using a valid login method in relation to
the desired scope.
https://user-images.githubusercontent.com/71256/119441172-87abae80-bcda-11eb-801a-cb6837bae353.mov
[ch21964]
We're not currently setting the `tokenName` when logging in via a
Git provider, so the name becomes the default "Website" one which
is confusing / incorrect.
Refactors the `vc switch` command to more closely match how the team picker works on the Vercel dashboard:
* Converts to TypeScript
* Adds separator between user scope and team scopes
* Sorts teams by name
* No longer places the current scope at the top of the list (but the current scope is still selected by default)
It's failing during runtime, like here: https://github.com/vercel/vercel/runs/2520732314
With an error like so:
```
[GET] / 2021-05-06T20:02:55.411Z undefined ERROR The gRPC
binary module was not installed. This may be fixed by running "npm rebuild"
Original error: Cannot find module
'/var/task/node_modules/grpc/src/node/extension_binary/node-v83-linux-x64-glibc/grpc_node.node'
Require stack:
- /var/task/node_modules/grpc/src/grpc_extension.js
- /var/task/node_modules/grpc/src/client_interceptors.js
- /var/task/node_modules/grpc/src/client.js
- /var/task/node_modules/grpc/index.js
- /var/task/node_modules/google-gax/build/src/grpc.js
- /var/task/node_modules/google-gax/build/src/index.js
-
/var/task/node_modules/@google-cloud/scheduler/src/v1beta1/cloud_scheduler_client.js
- /var/task/node_modules/@google-cloud/scheduler/src/v1beta1/index.js
- /var/task/node_modules/@google-cloud/scheduler/src/index.js
- /var/task/index.js
- /var/task/___vc_launcher.js
- /var/runtime/UserFunction.js
- /var/runtime/index.js 2021-05-06T20:02:55.411Z undefined ERROR
Did you forget to add it to "dependencies" in `package.json`? RequestId:
2cdba37e-4bf4-4a2f-b443-4ebcc99fe308 Error: Runtime exited with error: exit
status 1 Runtime.ExitError
```
Because grpc is failing with NFT.
But also, the test is no longer necessary because we no longer support Node 8 which was what the original test intended https://github.com/vercel/now-builders/pull/463
Refactors the CLI `vc login` command with the following features:
* Adds GitHub, GitLab and Bitbucket as login options
* Uses a "list" input to select which login method to use (same list as `vc init`)
* Support connecting SAML Profile to Vercel user during login
This ensures that when segments are coming from only `has` items we still replace them correctly as they currently don't get replaced if the `source` doesn't have any segments as well.
### Related Issues
x-ref: https://vercel.slack.com/archives/CLDDX2Y0G/p1619061783470000
### 📋 Checklist
<!--
Please keep your PR as a Draft until the checklist is complete
-->
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
* Ensure has segments are replaced in destination
* update type
* Use regex lexar for gathering named groups from has
* Update to use shared repo for regex lexer
* apply suggestions
* remove regexr from .eslintignore
Node.js 10 is about to reach EOL so we can drop CLI support in the next major release. We'll support 12+ going forward.
Node.js 12 needs `es2019` because it doesn't support the `es2020` features of optional chaining and nullish coalescing as seen from the [compatibility table](https://kangax.github.io/compat-table/es2016plus/#node12_11).
### Changes
- Add support for Git Branch
- Use a single env type: "encrypted"
- Remove unnecessary questions during `vc env add`
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [x] This PR has a concise title and thorough description useful to a reviewer
- [x] Issue from task tracker has a link to this PR
If the user is signed in to a team with SAML enforced, but the
current token is not a SAML token, then `getScope()` will fail.
So add the option to opt-out of team information in `getScope()`
and use that new option in `vc whoami` since it doesn't require
team information.
When the API returns a `saml: true` error, CLI will re-trigger the SSO
auth browser window so that the user can sign into their identity
provider again. Once the new token is received, it is saved to the
`auth.json` file (unless the token was specified via `--token`) for
future use.
This is a rather large refactor of the CLI codebase that merges the
`NowContext` object into the `Client` class.
There's a few reasons to do this:
1. Nearly every sub-command was creating its own `Client` instance, leading to a lot of duplicated code. It makes more sense to create one instance and pass it to every sub-command, which deletes a lot of code as well.
2. There's a lot of overlap between `NowContext` and the props on the `Client` class, so it was a relatively easy transition.
3. The main reason is so the same `authConfig` is used throughout the program lifecycle. This paves the way for updating the token mid-flight when i.e. a SAML token has expired. In a follow-up PR, CLI will handle that scenario gracefully by re-triggering the SAML auth flow.
* Add yarn.lock to all examples
* Add missing yarn lock
* Deploy all examples after yarn.lock changes
* Remove package-lock
* Update ionic angular to working version
* Skip libCheck to make ionic-angular build
* Rename nowignore to vercelignore, remove yarn.lock from ignore
* Revert zola changes
Our automated documentation requires descriptions in the schema
#### Tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [x] This PR has a concise title and thorough description useful to a reviewer
We need to support `{ "source": "/", "has": { "type", "host", "value": "vercel.com" }, "destination": "/prod" }`
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [x] This PR has a concise title and thorough description useful to a reviewer
- [x] Issue from task tracker has a link to this PR
CH-19565
Since CRA is an SPA (all routes fallback to index.html), we can't do a proper custom 404.
But we can do a custom 404 when accessing the static directory, for example `/static/foo.html`.
To handle something like `/foo`, the user needs to do a client-side routing 404 like this example: https://reactrouter.com/web/example/no-match
### 📋 Checklist
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
@@ -6,7 +6,7 @@ This directory is a brief example of a [Name](site-link) site that can be deploy
Deploy your own [Name] project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/example-directory)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/example-directory)
@@ -332,7 +332,7 @@ This is an abstract enumeration type that is implemented by one of the following
-`nodejs10.x`
-`go1.x`
-`java11`
-`python3.8`
-`python3.9`
-`python3.6`
-`dotnetcore2.1`
-`ruby2.5`
@@ -398,12 +398,12 @@ This utility allows you to _scan_ the filesystem and return a [`Files`](#files)
The following trivial example downloads everything to the filesystem, only to return it back (therefore just re-creating the passed-in [`Files`](#files)):
[](https://github.com/vercel/vercel/discussions)
## Usage
Vercel is the optimal workflow for frontend teams. All-in-one: Static and Jamstack deployment, Serverless Functions, and Global CDN.
Vercel is a platform for **static sites and frontend frameworks**, built to integrate with your headless content, commerce, or database.
Get started by [Importing a Git Project](https://vercel.com/import) and use `git push` to deploy. Alternatively, you can [install Vercel CLI](https://vercel.com/download).
We provide a **frictionless developer experience** to take care of the hard things: deploy instantly, scale automatically, and serve personalized content around the globe.
We make it easy for frontend teams to **develop, preview, and ship** delightful user experiences, where performance is the default.
Get started by [Importing a Git Project](https://vercel.com/new) and use `git push` to deploy. Alternatively, you can [install Vercel CLI](https://vercel.com/cli).
@@ -7,4 +7,5 @@ You specified the `--scope` flag and specified the ID or slug of a team that you
#### Possible Ways to Fix It
- Make sure commands like `vercel ls` work just fine. This will ensure that your user credentials are valid. If it's not working correctly, please log in again using `vercel login`.
-Ensure that the scope you specified using `--scope` shows up in the output of `vercel switch`. If it doesn't, you're either not part of the team (if you specified a team) or you logged into the wrong user account.
-If you're using the `--token` flag, make sure your token is not expired. You can generate a new token on your [Settings page](https://vercel.com/account/tokens).
- Ensure that the scope you specified using `--scope` flag shows up in the output of `vercel switch`. If it doesn't, you're either not a member of the team or you logged into the wrong user account. You can ask an owner of the team to invite you.
You specified the `--scope` flag and specified the ID or slug of a team that does not exist or that you're not a part of. Similarly you might have specified the ID or username of user whose account you don't own.
You specified the `--scope` flag and specified the ID or slug of a team that does not exist or that you're not a member. Similarly you might have specified the ID or username of user whose account you don't own.
#### Possible Ways to Fix It
If you're sure the specified team exists, please make sure that you're a part of it (ask an owner of the team to invite you). If you specified the identifier of a user, make sure you are actually the owner of this account.
Otherwise, either create a team with the specified slug or ensure that the identifier is correct if you're sure that the scope exists.
- Make sure commands like `vercel ls` work just fine. This will ensure that your user credentials are valid. If it's not working correctly, please log in again using `vercel login`.
- If you're using the `--token` flag, make sure your token is not expired. You can generate a new token on your [Settings page](https://vercel.com/account/tokens).
- Ensure that the scope you specified using `--scope` flag shows up in the output of `vercel switch`. If it doesn't, you're either not a member of the team or you logged into the wrong user account. You can ask an owner of the team to invite you.
@@ -44,13 +44,13 @@ We are continuously improving our examples based on best practices and feedback
For example, the previous `nodejs` example showed a static frontend with a Node.js API. This is illustrated in the `svelte` example. Below is a table that lists some of the most popular previous examples and the equivalent replacement:
@@ -6,7 +6,7 @@ This directory is a brief example of an [AMP](https://amp.dev/) site that can be
Deploy your own AMP project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/amp)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/amp)
@@ -8,7 +8,7 @@ This directory is a brief example of an [Angular](https://angular.io/) app that
Deploy your own Angular project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/angular)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/angular&template=angular)
@@ -8,7 +8,7 @@ This directory is a brief example of a [Blitz.js](https://blitzjs.com/) project
Deploy your own Blitz.js project with Vercel by viewing the [documentation on deploying to Vercel](https://blitzjs.com/docs/deploy-vercel)
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/blitzjs)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/blitzjs&template=blitzjs)
@@ -6,7 +6,7 @@ This directory is a brief example of a [Brunch](https://brunch.io/) site that ca
Deploy your own Brunch project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/brunch)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/brunch&template=brunch)
@@ -8,7 +8,7 @@ This directory is a brief example of a [React](https://reactjs.org/) app with [S
Deploy your own React project, along with Serverless Functions, with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/create-react-app-functions)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/create-react-app-functions&template=create-react-app)
@@ -6,7 +6,7 @@ This directory is a brief example of using a Custom Build script that can be dep
Deploy your own Custom Built project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/custom-build)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/custom-build)
@@ -6,7 +6,7 @@ This directory is a brief example of a [Docusaurus](https://v2.docusaurus.io) si
Deploy your own Docusaurus project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/docusaurus-2)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/docusaurus-2&template=docusaurus-2)
@@ -8,7 +8,7 @@ This directory is a brief example of a [Docusaurus](https://docusaurus.io/) site
Deploy your own Docusaurus project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/docusaurus)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/docusaurus&template=docusaurus)
@@ -6,7 +6,7 @@ This directory is a brief example of a [Dojo](https://dojo.io) site that can be
Deploy your own Dojo project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/dojo)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/dojo&template=dojo)
@@ -8,7 +8,7 @@ This directory is a brief example of a [Eleventy](https://www.11ty.io/) site tha
Deploy your own Eleventy project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/eleventy)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/eleventy&template=eleventy)
@@ -8,7 +8,7 @@ This directory is a brief example of an [Ember](https://emberjs.com/) app that c
Deploy your own Ember project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/ember)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/ember&template=ember)
@@ -8,7 +8,7 @@ This directory is a brief example of a [Gatsby](https://www.gatsbyjs.org/) app w
Deploy your own Gatsby project, along with Serverless Functions, with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/gatsby)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/gatsby&template=gatsby)
@@ -8,7 +8,7 @@ This directory is a brief example of a [Gridsome](https://gridsome.org/) app tha
Deploy your own Gridsome project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/gridsome)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/gridsome&template=gridsome)
@@ -8,7 +8,7 @@ This directory is a brief example of a [Hexo](https://hexo.io/) site that can be
Deploy your own Hexo project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/hexo)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/hexo&template=hexo)
@@ -6,7 +6,7 @@ This directory is a brief example of a [Hugo](https://gohugo.io/) app that can b
Deploy your own Hugo project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/hugo)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/hugo&template=hugo)
@@ -6,7 +6,7 @@ This directory is a brief example of an [Ionic Angular](https://ionicframework.c
Deploy your own Ionic Angular project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/ionic-angular)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/ionic-angular&template=ionic-angular)
@@ -6,7 +6,7 @@ This directory is a brief example of an [Ionic React](https://ionicframework.com
Deploy your own Ionic React project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/ionic-react)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/ionic-react&template=ionic-react)
@@ -6,7 +6,7 @@ This directory is a brief example of a [Jekyll](https://jekyllrb.com/) site that
Deploy your own Jekyll project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/jekyll)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/jekyll&template=jekyll)
@@ -6,7 +6,7 @@ This directory is a brief example of a [Middleman](https://middlemanapp.com/) si
Deploy your own Middleman project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/master/examples/middleman)
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/middleman&template=middleman)
@@ -29,6 +29,6 @@ You can check out [the Next.js GitHub repository](https://github.com/vercel/next
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/import?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.