Adds formal type interfaces for Builders into `@vercel/build-utils`, and
updates the serverless functions runtimes to utilize them. This provides
type safety for the args/return values in i.e. the `build()` functions,
where previously they were not using any explicit return type.
When an instance of this class is returned in a Builder's `output`, it is a signal to the build system that it needs to add additional files to the final Lambda before creating the zip file.
* [cli] Remove initial iteration of `vc build` and Plugins
The `vercel build` command is being restructured, so we'll remove it for
now so that this initial iteration isn't included as part of the stable
CLI release.
* Update packages/cli/src/commands/init/init.ts
Co-authored-by: Steven <steven@ceriously.com>
* Remove more `.output` references
* Remove unnecessary space
* Fix test
* Remove vc dev middleware tests for now
Co-authored-by: Steven <steven@ceriously.com>
Makes the `Lambda` class itself just a reference of the files that are
needed to produce a zip file, and adds a `createZip()` function that
does the actual zip file creation. This will allow the zip file creation
to be done in the Vercel build container instead of directly in the
Builder itself.
* Adds `files` property to `Lambda` class
* Adds `createZip()` function to `Lambda` class
* Deprecates the `createLambda()` function
* Deprecates the `zipBuffer` property (only populated when `createLambda()` is used)
* Removes the private `FILES_SYMBOL` symbol, since `files` is the same thing
This PR adds a new `vercel bisect` command which is inspired by `git bisect`. This command takes two deployment URLs as its input (one "bad" deployment that exhibits a bug, and one "good" deployment where the bug does not occur) and steps through the deployments using a binary search. The command is useful for finding a deployment (and commit if the project is connected to a Git repo) where a bug has been introduced.
<img width="582" alt="Screen Shot 2022-01-26 at 12 46 29 PM" src="https://user-images.githubusercontent.com/71256/151244295-8e90c493-c45f-40b4-8e43-f39e7fcac262.png">
These integration tests have started consistently failing with
`ECONNRESET` errors and after some debugging it's been
difficult to point the finger at anything related to Vercel
infrastructure. So possibly it's related to GitHub actions infra
changes, but either way retrying seems to help.
* [ci] Add turborepo for faster builds
* Replace yarn run with turbo run
* Fix typo
* Add `@vercel/build-utils` as explicit dev dep
* Remove unused --clean argument
* Only turbo the "build" script, leave tests as-is
* Bump turbo to 1.0.13
* Add back test-unit
* Revert "Add back test-unit"
This reverts commit 469868c5c06f6c6f15da7ef0a440587d41419fd8.
This is following a similar pattern to Next.js workflows so that the publish step is skipped and reduces the time it takes GH Actions to run since we don't need to build to know that it should be skipped.
This ensures that using `vc deploy --prebuilt` will also upload any files that `.output/**/.nft.json` points to and also handle the Root Directory correctly since `vc build` emits `rootdir/.output`.
- Related to https://github.com/vercel/runtimes/issues/304.
### Related Issues
> Fixes#7086
> Related to #7086
### 📋 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
- [x] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
We have identified that the `handler` for Lambdas does not support a dot-preceded path for Ruby, Python, and probably other languages, so we're adjusting the File System API to change `.output` inside the Lambda to something else, which requires version `2` of `functions-manifest.json`.
Furthermore, we're also bumping the `.nft.json` files to version `2`, which allows `output` to be relative to the NFT file itself, so that, inside the Lambda, the behavior mentioned at the top can be applied by the File System API.
As a nice side effect, this will also support nested API Routes, because it'll place all the dependencies next to every API Route, meaning that the launcher will have access to all of them (bundling multiple API Routes or Pages into the same Lambda currently doesn't work for non-Next.js anyways, because of https://github.com/vercel/runtimes/issues/305).
#### 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
Previously, CLI Plugins would try to mount the user-provided request handler (e.g. `api/test.rb`) at the same position inside the Lambda at which the launcher was located (e.g. `api/test.rb`), which would cause the launcher to be overwritten.
With this change, all the destination mounting points for NFT input files are becoming relative to the `.output/server/pages/api` directory instead of `.output/server/pages`, so they should no longer overwrite the launcher, and instead be loaded from the launcher, like normal.
This PR might have two problems:
- If imports in Ruby/Python/etc are relative to `cwd` and not the file from which the import is executed (which I doubt), this would fail.
- We might have to replace `api` with the exact sub folder of the API Route within `.output/server/pages/api` if the current change doesn't yet work for nested paths. Although that also means repeating all of the other dependencies (not just the user-provided request handler) in a different location for every single API Route.
The two above will be tested after this PR was merged, as there currently isn't a way to test `vercel-plugin-go`, `vercel-plugin-python`, and `vercel-plugin-ruby` without publishing a canary, because they don't bundle `@vercel/build-utils`, which was the package that was just updated.
#### 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
* Use correct Lambda handler for compiled languages
* Use the correct entrypoint
* Fixed the logic
* Perfected it
* Simpler code
* Update packages/build-utils/src/convert-runtime-to-plugin.ts
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
* Handle edge cases and simplify logic
* Fixed the logic yet again to work perfectly
* Normalize Page path
* Simplified everything
* Fixed the tests
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
* Corrected CLI Plugin output creation
* Wait for the linking to be done before removing anything
* Make it work
* Renamed variables
* Made everything work
* Removed debugging
* Fixed comment typos
* [cli] Support `next export` in `vercel build`
* Add debug line
* Remove unused import
* Ensure file is copied
* Return in `getNextExportStatus`
* Include dotNextDir
Co-authored-by: Steven <steven@ceriously.com>
### Related Issues
This fixes https://github.com/vercel/runtimes/issues/299.
#### 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
* 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
### Related Issues
x-ref: https://github.com/vercel/next.js/pull/22341
x-ref: https://github.com/vercel/next.js/issues/22345
### 📋 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 PR fixes an error that happens when `includeFiles` has `.ts` files:
```
ReferenceError: Cannot access 'tsCompile' before initialization
```
~~However its not clear what the expected behavior is. Should the `.ts` files be compiled to `.js` or should they be considered assets and included as-is?~~
We will assume that `includeFiles` is only for assets and thus `.ts` files should not be compiled, they're included as-is.
[ch20529]
* remove prefix from codeowners
* remove references from ignore files
* Remove prefix from package json and tests
* Add run js without prefixes
* Rename package folders
* Delete auto generated test files
* Remove now-node in integration test
* Put back deleted vercel json files
* Remove eol
* Add styfle suggestion to comment in utils/run.js
Co-authored-by: Steven <steven@ceriously.com>
We need to make CI explicit about the lowest common denominator for Go Version like we do with the Node.js Version.
This will add about 10 seconds to CI which is negligible to the 8 min+ CI currently.
A regression was introduced in #5873 that caused the analyze step to parse Go's internal source files (eg `golang/test/bombad.go`) instead of only parsing the user's source code (eg `api/users.go`).
This resulted in the error:
```
Failed to parse AST for "api/users.go"
Error: Command failed: /vercel/1ab928d537d26157/.build-utils/.builder/node_modules/@vercel/go/dist/analyze -modpath=/vercel/workpath1 /vercel/workpath1/api/users.go
2021/02/26 14:26:42 Could not parse Go file "/vercel/workpath1/.vercel/cache/golang/test/bombad.go"
```
Uses inspector url from api rather than generating one locally.
### 📋 Checklist
#### 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
### Related Issues
Follow up to #5888
### 📋 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
- [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
This PR updates the warning for `api` + `pages/api` to only be printed when Next.js is mixed with `@vercel/node` functions. It should not print the warning with `@vercel/go` functions for example.
### 📋 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
- [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
### 📋 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
- [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
`@babel/preset-env` shipped a change that broke Nuxt.js usage of the
module, so here we add a `yarn.lock` file that pins the preset-env
version to 7.12.17.
See: https://github.com/nuxt/nuxt.js/issues/8882
We now return a 504 for lambda timeouts
### Related Issues
Related to https://github.com/vercel/now-proxy/pull/1970
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [ ] All tests pass locally with `yarn test-unit`
#### Code Review
- [x] This PR has a concise title and thorough description useful to a reviewer
This PR removes the flags from `bundle install` which fixes the deprecated warnings such as
```
[DEPRECATED] The `--no-prune` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set --local no_prune 'true'`, and stop using this flag
```
These flags already represent the defaults for `bundle install` anyway and we can pass environment variables in the spawn options instead.
https://app.clubhouse.io/vercel/story/16876
This will fix the issue that symlinks pointing to a directory is not returned on `prepareCache` and node modules linked to local files don't work.
### Related Issues
### 📋 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
- [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
Co-authored-by: Steven <steven@ceriously.com>
Animated gif should bypass (serve as-is).
This is to avoid the time it takes to optimize animated images which can sometimes take minutes.
It also matches how `next dev` works so we want to stay consistent (this tests both dev and a deployment).
Fixes TypeScript error:
```
test/unit.framework-detector.test.ts:52:40 - error TS4104: The type 'readonly Framework[]' is 'readonly' and cannot be assigned to the mutable type 'Framework[]'.
52 expect(await detectFramework({ fs, frameworkList })).toBe(null);
~~~~~~~~~~~~~
```
This PR improves the CLI in a way that if the API from any request returns a response which contains a header with the prefix `x-vercel-warning-*`, `x-vercel-notice-*` or `x-vercel-tip-*`, it will print out the message to the output to let the user know.
This new feature also supports additional headers which improve the message, so that a link can be printed out for more information. Those are `x-vercel-link-*`, where we specify a link, and `x-vercel-action`, where we specify the text before the link.
Here's an example for a warning message which warns the user if they add a DNS record for a domain which does not use Vercel Nameservers:
<img width="719" alt="Screenshot 2021-01-18 at 17 49 14" src="https://user-images.githubusercontent.com/35507539/104943788-8da12400-59b6-11eb-8e54-77a3c517e56d.png">
The API request from above which creates a DNS record has the following HTTP response headers set:
```
x-vercel-warning-create-domain-record: Your Domain isn't using Vercel nameservers. In order for the changes to your DNS Records to get applied, however, it needs to.
x-vercel-link-create-domain-record: https://vercel.link/configure-vercel-nameservers
```
If `x-vercel-action` is not specified, it defaults to `Learn More`.
### 📋 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
- [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
* [frameworks] Add type annotations
This will be necessary for static type analysis in our API docs generator.
* Apply suggestions from code review
Co-authored-by: Steven <steven@ceriously.com>
* Add quotes to @examples
Co-authored-by: Steven <steven@ceriously.com>
This will be necessary for static type analysis in our API docs generator.
The default export is still typed as `Framework[]` for backwards-compat purposes, but the `frameworks` export is the statically typed array.
This PR converts the `frameworks.json` file to TypeScript, and extends the values with the detection logic from `@vercel/static-build`, so that it's publicly editable. You also don't need to do the type casting downstream anymore.
As a consequence, it also makes Zola a 1st-class framework, as it was previously missing from the `frameworks.json` file, but present in the static-build frameworks. An example has been included based on their "Getting Started" tutorial.
CH-3808
CH-18771
### Related
Related to #4754
### Upstream
https://aws.amazon.com/blogs/compute/node-js-14-x-runtime-now-available-in-aws-lambda/
### 📋 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
- [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
Both `vc` and `vc dev` already ask to link/setup when the project is not found, so this will update the error message to mention the possible reasons why a project was not found.
### Before
```
$ vc
Vercel CLI 21.2.1
❗️ Your project was either removed from Vercel or you’re not a member of it anymore.
? Set up and deploy “~/Code/myproject”? [Y/n]
```
### After
```
$ vc
Vercel CLI 21.2.1
❗️ Your Project was either deleted, transferred to a new Team, or you don’t have access to it anymore.
? Set up and deploy “~/Code/myproject”? [Y/n]
```
### 📋 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
- [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
There was an issue with `output.spinner()` spinner if the old-style
interface was used (invoking the return value to stop the spinner),
which caused the internal spinner instance in `output` to be defined,
but in a "stopped" state. Then later the `text` gets updated to a
different value but the spinner is still stopped and nothing gets
rendered.
The fix is to ensure that `output.stopSpinner()` is called rather
than directly invoking the cancel function. In fact, the return
value of `output.spinner()` has been removed completely.
`@vercel/python` has been incorrectly "unquoting" the incoming request
URL for all Python interfaces (basic, WSGI, ASGI). The proper behavior is
to pass along the request URL to the serverless function handler unmodified.
This is proven by the additional test that is added in this PR, which actually
fires up the corresponding Python server via i.e. `python3 api/asgi.py`,
and executes the test probes defined in the
`test/fixtures/00-request-path/vercel.json` file. Adding this test ensures
that the request URL behavior of `@vercel/python` matches the behavior
as compared to executing via `python` directly.
### 📋 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
- [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
Previously every command implementation was invoking `createOutput()` individually, causing multiple instances of `Output` to be created, which was unnecessary, and causes issues with the shared `spinner` instance introduced by #5717.
Now, the `Output` instance created in `src/index.js` is passed down to the sub-command being executed and therefore re-used.
This is a refactor of the `ora` Spinner usage to make the preferred usage be via the `output.spinner()` and `output.stopSpinner()` functions.
* The `Output` instance has a local spinner instance that can be updated via multiple calls to `output.spinner()`.
* `output.print()` and friends call `output.stopSpinner()` implicitly, so `output.stopSpinner()` doesn't need to be called unless it is desired to immediately remove the spinner before rendering the next text.
* Because there's meant to be a shared `spinner` for the `output` instance, it means that the same `output` instance needs to be used throughout the CLI lifecycle. Therefore, the `createOutput()` function now returns a singleton so that it's guaranteed to be the same instance.
https://user-images.githubusercontent.com/71256/105009979-0670a200-59f0-11eb-9853-232f92eae536.movhttps://user-images.githubusercontent.com/71256/105010034-17211800-59f0-11eb-918d-b15f457e9640.mov
In the "before" video above, note how there's a brief second where the spinner is cleared, but the deployment URL has not yet been printed. In the "after" video, this is fixed and the spinner is only cleared once the CLI is ready to render the deployment URL.
This is essentially a refactor of the `@vercel/static` builder that
simplifies the code a lot and fixes a bug where `cleanUrls: true`
was not working correctly when using an `outputDirectory`.
Add auto renew prompt to `domains buy`
```diff
> The domain "example.com" is available to buy under <username>!
> Buy now for $20 (1yr)? [y|N]
+ > Auto renew yearly for $20? [Y|n]
```
### 📋 Checklist
#### 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
Implements the ["Directory Listing" Project setting](https://vercel.com/changelog/listing-the-content-of-directories-can-now-be-toggled) in `vercel dev`.
The Dev integration test file has been updated to allow specifying custom Project settings that will be `PATCH`'d to the project document before running `vc deploy` / `vc dev`.
When `spawn()` emits an "ENOENT" error, meaning that the command was not
found, the error would only be visible if `--debug` was enabled for vc
dev.
Now we will always render any error from `startDevServer()`, as well as
special-case the "ENOENT" error informing the user to double check their
installation of the command.
These `@now` scoped packages have been published and deprecated with the following warning since May 2020:
```
DEPRECATED ⚠️ - "@now/node" is deprecated and will stop receiving updates on December 31, 2020. Please use "@vercel/node" instead.
```
Since it is now 2021, the time has come to stop publishing.
### Related Issues
[[ch3378]]
This adds tests for optional catch-all `fallback: true` pages to ensure the params are normalized correctly. These should be failing initially until the PR with the normalizing fix in Next.js is released to canary.
x-ref: https://github.com/vercel/next.js/issues/17220
This is a follow-up to https://github.com/vercel/vercel/pull/5618 ensuring the 404 route is pointing to the static 404 output correctly when `_app.gip` and getStaticProps in `/404.js` is used
### Related Issues
Fixes: https://github.com/vercel/next.js/issues/19849
#### 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
There are events (i.e. with `type: "deployment-event"`) that do not
contain a `text` property, so check that it's a string before invoking
`.replace()` on it.
Fixes this stack trace:
```
Error! An unexpected error occurred in logs: TypeError: Cannot read property 'replace' of undefined
at Object.printLogRaw [as raw] (/home/me/nextjs-site/node_modules/vercel/dist/index.js:203803:10)
at printEvent (/home/me/nextjs-site/node_modules/vercel/dist/index.js:203688:35)
at Array.forEach (<anonymous>)
at main (/home/me/nextjs-site/node_modules/vercel/dist/index.js:203690:31)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at main (/home/me/nextjs-site/node_modules/vercel/dist/index.js:207173:16)
```
The `Now` prefixed types remain as aliases for backwards-compat purposes.
#### 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
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.7.
<details>
<summary>Commits</summary>
<ul>
<li><a href="c74c8af35f"><code>c74c8af</code></a> 1.3.7</li>
<li><a href="024b8b55ac"><code>024b8b5</code></a> update deps, add linting</li>
<li><a href="032fbaf5f0"><code>032fbaf</code></a> Use Object.create(null) to avoid default object property hazards</li>
<li><a href="2da90391ef"><code>2da9039</code></a> 1.3.6</li>
<li><a href="cfea636f53"><code>cfea636</code></a> better git push script, before publish instead of after</li>
<li><a href="56d2805e07"><code>56d2805</code></a> do not allow invalid hazardous string as section name</li>
<li>See full diff in <a href="https://github.com/isaacs/ini/compare/v1.3.5...v1.3.7">compare view</a></li>
</ul>
</details>
<details>
<summary>Maintainer changes</summary>
<p>This version was pushed to npm by <a href="https://www.npmjs.com/~isaacs">isaacs</a>, a new releaser for ini since your current version.</p>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/vercel/vercel/network/alerts).
</details>
This PR completes the routes schema to be more accurate for the provided type.
This will allow us to generate the type dynamically from the JSON Schema
* [routing-utils] Handle `null` phase at the beginning
* Add fixed list
* Add tests
* Change hit and miss order
* Put null at the start
* Undo order changes
Co-authored-by: Steven <steven@ceriously.com>
* fix VERCEL_REGION and NOW_REGION
* remove VERCEL_REGION from exposeSystemEnvs
* refactor exposeSystemEnvs
* refactor getDecryptedEnvRecords
* consider project envs in exposeSystemEnvs
* simplify exposeSystemEnvs
* correctly set value of VERCEL_URL system envs
* make exposeSystemEnvs return all envs object
* parse url in server
* simplify
* refactor getDecryptedEnvRecords
* add comment
* remove unnecessary code
* add test
* fix test
* fix dev server unit tests
* always expose NOW_REGION
* fix dev test
* fix dev test
* only retrieve system env values when autoExposeSystemEnvs is true
Ref: https://app.clubhouse.io/vercel/story/15112
We added a property called `autoExposeSystemEnvs` to projects. If that property is `true`, we automatically expose system env variables such as `VERCEL=1`, `VERCEL_ENV=<production | preview>`, ... to the runtime and build time.
This PR makes sure we mirror this behavior when running `vc dev` locally.
### 📋 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
- [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
Add E2E test for to test image optimization against `vc dev` as well as a prod deployment.
### 📋 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
- [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 (CH13104)
`/.well-known` files shouldn't have trailing slashes added as these clients likely do not follow redirects
Specifically, `/.well-known/apple-developer-merchantid-domain-association` cannot have trailing slash.
### Related Issues
https://vercel.slack.com/archives/CLDDX2Y0G/p1605127589058800
#### 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 a builder wants to set a header that isn't allowed to be overridden by users, it should use `important: true`
#### 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-14921
* [build-utils] Include `installCommand` when empty string
An empty string for the Project's `installCommand` setting has different
behavior than `null`, so properly provide the empty string to the
Runtime.
* Move tests to proper section
* [@vercel/static-build] Add directory for Serverless Functions
* Update tests and only consider index.js files
* Import only once
* Only change for zeroConfig
* Update packages/now-static-build/src/utils/_shared.ts
Co-authored-by: Steven <steven@ceriously.com>
* Update packages/now-static-build/test/fixtures/62-function-output-directory-with-static/now.json
Co-authored-by: Steven <steven@ceriously.com>
* Update packages/now-static-build/test/fixtures/61-function-output-directory/now.json
Co-authored-by: Steven <steven@ceriously.com>
* Update build
* Fix type
* Remove line
* Add to .vercelignore
* Fix paths in test
* Move more files
* Remove special case for test
Co-authored-by: Steven <steven@ceriously.com>
* prompt to select env type
* improve copy
* create env variable with type
* remove nanoid dependency
* use encodeURIComponent
* refactor envType -> type
* refactor envName -> key
* do not hide value input
* adjust value prompt depending on type
* handle std input for plaintext env variables
* show custom error when secret is not found
* handle secret name input starting with `@`
* fix system env value question
* improve ui of prompts
* expand env list in vc rm
* adjust tests
* environment -> environments
* list multiple targets in vc env ls
* show value for system env vars
* adjust tests
* capitalize targets
* add <type> to arguments
* always use stdInput for envValue
* fix number of arguments error
* adjust tests
* refactor ProjectEnvType
* refactor SYSTEM_ENV_VALUES
* fix typo for typePlaceholder
* use getCommandName
* use title
* remove @ts-ignore
* improve types
* show key controls for checkbox prompt
* fix plain envs can not be retrieved
* add test
* add test for `vc dev`
* use v6 to retrieve env variables
* fix v6 return type
* use v6 to display env vars
* add test for vc env ls
* expand env vars with multiple targets
* minor type fixes
* always use v6 for getEnvVariables
Co-authored-by: luc <luc.leray@gmail.com>
We currently pass through `images` whenever its defined, but this is enabling Image Optimization in the Proxy for every Next.js project.
Instead, we should check to see if the default loader is used (the same use for `next dev`) as a signal to enable this feature in the deployment.
Related to https://github.com/vercel/next.js/issues/18122
Bumps [next](https://github.com/vercel/next.js) from 9.5.1 to 9.5.4.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/vercel/next.js/releases">next's releases</a>.</em></p>
<blockquote>
<h2>v9.5.4</h2>
<p><strong>This upgrade is <em>completely backwards compatible and recommended for all users on versions below 9.5.4.</em> For future security related communications of our OSS projects, please <a href="https://vercel.com/security">join this mailing list</a>.</strong></p>
<p>A security team from one of our partners noticed an issue in Next.js that allowed for open redirects to occur.</p>
<p>Specially encoded paths could be used with the trailing slash redirect to allow an open redirect to occur to an external site.</p>
<p>In general, this redirect does not directly harm users although can allow for phishing attacks by redirecting to an attackers domain from a trusted domain.</p>
<p>We recommend upgrading to the latest version of Next.js to improve the overall security of your application.</p>
<h2>How to Upgrade</h2>
<ul>
<li>We have released patch versions for both the stable and canary channels of Next.js.</li>
<li>To upgrade run <code>npm install next@latest --save</code></li>
</ul>
<h2>Impact</h2>
<ul>
<li><strong>Affected</strong>: Users of Next.js between 9.5.0 and 9.5.3</li>
<li><strong>Not affected</strong>: Deployments on Vercel (<a href="https://vercel.com">https://vercel.com</a>) are not affected</li>
<li><strong>Not affected</strong>: Deployments using <code>next export</code></li>
</ul>
<p>We recommend everyone to upgrade regardless of whether you can reproduce the issue or not.</p>
<h3>How to Assess Impact</h3>
<p>If you think users could have been affected, you can filter logs of affected sites by <code>%2F</code> with a 308 response.</p>
<h2>What is Being Done</h2>
<p>As Next.js has grown in popularity, it has received the attention of security teams and auditors. We are thankful to those that reached out for their investigation and discovery of the original bug and subsequent responsible disclosure.</p>
<p>We've landed a patch that ensures encoding is handled properly for these types of redirects so the open redirect can no longer occur.</p>
<p>Regression tests for this attack were added to the <a href="https://github.com/vercel/next.js/blob/canary/test/integration/production/test/security.js">security</a> integration test suite.</p>
<ul>
<li>We have notified known Next.js users in advance of this publication.</li>
<li>A public CVE was released.</li>
<li>If you want to stay on top of our security related news impacting Next.js or other Vercel projects, please <a href="https://zeit.co/security">join this mailing list</a>.</li>
<li>We encourage responsible disclosure of future issues. Please email us at <strong><a href="https://github.com/vercel/next.js/blob/HEAD/mailto:security@zeit.co">security@vercel.com</a>.</strong> We are actively monitoring this mailbox.</li>
</ul>
<hr />
<h3>Core Changes</h3>
<ul>
<li>Make the image post-processor ignore SVG images: <a href="https://github-redirect.dependabot.com/vercel/next.js/issues/16732">#16732</a></li>
<li>Only update lookups for dev overlay if mounted: <a href="https://github-redirect.dependabot.com/vercel/next.js/issues/16776">#16776</a></li>
<li>Ensure interpolating dynamic href values works correctly: <a href="https://github-redirect.dependabot.com/vercel/next.js/issues/16774">#16774</a></li>
<li>Add automatic reloading when editing GS(S)P methods: <a href="https://github-redirect.dependabot.com/vercel/next.js/issues/16744">#16744</a></li>
<li>Update to show build indicator while re-fetching GS(S)P data in dev: <a href="https://github-redirect.dependabot.com/vercel/next.js/issues/16789">#16789</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="6588108150"><code>6588108</code></a> v9.5.4</li>
<li><a href="7108567b06"><code>7108567</code></a> v9.5.4-canary.25</li>
<li><a href="5d79a8c0c4"><code>5d79a8c</code></a> Update workflow step to restore cache (<a href="https://github-redirect.dependabot.com/vercel/next.js/issues/17656">#17656</a>)</li>
<li><a href="4c38e3ed8e"><code>4c38e3e</code></a> fix typo (<a href="https://github-redirect.dependabot.com/vercel/next.js/issues/17653">#17653</a>)</li>
<li><a href="241f38eaa8"><code>241f38e</code></a> v9.5.4-canary.24</li>
<li><a href="7dec91175c"><code>7dec911</code></a> change anonymous functions to named in docs examples (<a href="https://github-redirect.dependabot.com/vercel/next.js/issues/17510">#17510</a>)</li>
<li><a href="1659e4da61"><code>1659e4d</code></a> Update migrating from Gatsby docs. (<a href="https://github-redirect.dependabot.com/vercel/next.js/issues/17636">#17636</a>)</li>
<li><a href="06a8b1ad67"><code>06a8b1a</code></a> Add docs on how to migrate from Gatsby. (<a href="https://github-redirect.dependabot.com/vercel/next.js/issues/17491">#17491</a>)</li>
<li><a href="04234cc312"><code>04234cc</code></a> Update to use hasNextSupport for custom-routes in next export check (<a href="https://github-redirect.dependabot.com/vercel/next.js/issues/17630">#17630</a>)</li>
<li><a href="742f5d9a46"><code>742f5d9</code></a> test(create-next-app): increase coverage (<a href="https://github-redirect.dependabot.com/vercel/next.js/issues/17507">#17507</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/vercel/next.js/compare/v9.5.1...v9.5.4">compare view</a></li>
</ul>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/configuring-github-dependabot-security-updates)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/vercel/vercel/network/alerts).
</details>
In some rare cases, the progress bar will still be in progress when the deployment completes, which causes the "Inspect" URL to print on the same line as the progress bar instead of a new line.
This PR fixes that corner case.
We don't support routing path aliases anymore, now that we've completely shut down the ZEIT Now 1.0 infrastructure. This PR removes path alias rules from Vercel CLI.
There was a regression when introducing multiple phases such as `hit` and `miss` which caused `routes` to stop working because the transition from `null` phase to the `filesystem` phase resets any dest rewrites.
The workaround is to detect when we don't have a `filesystem` phase and exit early.
Follow up to #5158 to add longer delay.
There is an issue with npm consistency after publishing so we wait longer before deprecating the `now` package because its a little larger than the others.
We have started migrating our projects to use Vue CLI with the Vercel zero-config builders. One particularly bug we ran into was due to the `Cache-Control` headers automatically applied on these resources that [differ from the documentation](https://vercel.com/docs/edge-network/caching#static-files):
> By default we return a `Cache-Control` header containing `public, max-age=0, must-revalidate` to prevent clients (e.g. browsers) from caching the file locally.
Instead of these headers, we were seeing `immutable` on all our resources. This is a good assumption for a vanilla Vue CLI setup because by default a content hash is used on every chunk, even the entry, which will change as soon as the file contents change. However, this may not always be the case, particularly on Vue CLI projects with any modifications to the build process, custom plugins, etc. that may exclude one or more files from the hash.
In our case this was breaking things in dramatic ways every time we deployed (and we deploy quite often!). Since the resources were being sent with the `immutable` header, the client browser was persisting these in cache and subsequent deployments with potentially breaking changes caused errors that were only resolved by clearing the client browser cache.
Example:
```
dist
├── css
│ ├── app.db598b39.css
│ └── common.css
├── js
│ ├── app.ac201ece.js
│ ├── chunk-587c608b.7d4361a1.js
│ ├── chunk-vendors.00676d62.js
│ └── common.js
└── index.html
```
In the above example, `common.css` and `common.js` are not hashed, but still have an `immutable` header preventing them from being re-validated by the client browser when a new deployment modifies their content.
To solve for this, I've updated the RegExp for Vue CLI to only apply the `immutable` caching header on files which have a content hash. This should solve for both vanilla Vue CLI setups and more advanced ones in which there may exist both files with and without a content hash.
Co-authored-by: Steven <steven@ceriously.com>
This PR solves an issue where tests would sometimes be rate limited when generating a token. This can be solved by caching the token like we do for E2E tests.
Example failure: https://github.com/vercel/vercel/runs/1098030228#step:11:9376
I also update the `@vercel/node` tests to compare the error message, exactly like how we do it with `@vercel/static-build`.
TypeScript supports comments in the `tsconfig.json` file, which is not
compatible with `JSON.parse()` so we have to use the built-in function
to parse the config file.
Fixes#4835.
Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.6.0 to 2.6.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/bitinn/node-fetch/releases">node-fetch's releases</a>.</em></p>
<blockquote>
<h2>v2.6.1</h2>
<p><strong>This is an important security release. It is strongly recommended to update as soon as possible.</strong></p>
<p>See <a href="https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md#v261">CHANGELOG</a> for details.</p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md">node-fetch's changelog</a>.</em></p>
<blockquote>
<h2>v2.6.1</h2>
<p><strong>This is an important security release. It is strongly recommended to update as soon as possible.</strong></p>
<ul>
<li>Fix: honor the <code>size</code> option after following a redirect.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="b5e2e41b2b"><code>b5e2e41</code></a> update version number</li>
<li><a href="2358a6c256"><code>2358a6c</code></a> Honor the <code>size</code> option after following a redirect and revert data uri support</li>
<li><a href="8c197f8982"><code>8c197f8</code></a> docs: Fix typos and grammatical errors in README.md (<a href="https://github-redirect.dependabot.com/bitinn/node-fetch/issues/686">#686</a>)</li>
<li><a href="1e99050f94"><code>1e99050</code></a> fix: Change error message thrown with redirect mode set to error (<a href="https://github-redirect.dependabot.com/bitinn/node-fetch/issues/653">#653</a>)</li>
<li><a href="244e6f63d4"><code>244e6f6</code></a> docs: Show backers in README</li>
<li><a href="6a5d192034"><code>6a5d192</code></a> fix: Properly parse meta tag when parameters are reversed (<a href="https://github-redirect.dependabot.com/bitinn/node-fetch/issues/682">#682</a>)</li>
<li><a href="47a24a03eb"><code>47a24a0</code></a> chore: Add opencollective badge</li>
<li><a href="7b136627c5"><code>7b13662</code></a> chore: Add funding link</li>
<li><a href="5535c2ed47"><code>5535c2e</code></a> fix: Check for global.fetch before binding it (<a href="https://github-redirect.dependabot.com/bitinn/node-fetch/issues/674">#674</a>)</li>
<li><a href="1d5778ad0d"><code>1d5778a</code></a> docs: Add Discord badge</li>
<li>Additional commits viewable in <a href="https://github.com/bitinn/node-fetch/compare/v2.6.0...v2.6.1">compare view</a></li>
</ul>
</details>
<details>
<summary>Maintainer changes</summary>
<p>This version was pushed to npm by <a href="https://www.npmjs.com/~akepinski">akepinski</a>, a new releaser for node-fetch since your current version.</p>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/configuring-github-dependabot-security-updates)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/vercel/vercel/network/alerts).
</details>
The [functions](https://vercel.com/docs/configuration#project/functions) property matches source files and it wasn't working for `index.js` or `.ts` files because `next build` converts the source file `pages/api/index.js` to the output `.next/server/pages/api.js`. So this PR fixes the logic to reverse the output page to source file.
This PR is a follow up to #5157 which was unable to deprecate a package immediately after publishing and failed with E405. So this PR adds a delay between publish and deprecate. It also uses the `-f` flag suggested in the error message. https://github.com/vercel/vercel/runs/1076007594#step:6:649
This PR is a follow up to #5119 which had the names backwards.
I fixed the variable names to avoid the confusion since "new" and "old" were ambiguous.
I also removed the incorrect deprecation message from packages published during commit c9597dc199.
We deprecated all the `now` scoped packages in favor of the `vercel` equivalents, however the deprecation message disappears after each publish, so we must to run `npm deprecate` after `npm publish` for legacy packages.
Currently on my machine, vercel --version takes 850ms to run. With this change, that execution time is reduced to ~550ms.
The reason is that source maps seem to significantly slow down Node.js execution, compounded by the size of the source map, even if it is not used.
I believe the benefits of this perf improvement outweigh the direct source maps and minification benefits.
If it is felt that direct per-file source maps are necessary for internal errors, then reducing the source map size should be investigated further to improve the runtime performance here.
This PR updates the `README.md` files with the following changes:
- Removal of CLI deployment.
- Amends Blitz.js to be in line with other `README.md` formats.
* Revert "[build-utils] Use `handle: error` for api 404 (#5064)"
This reverts commit 02e1c921ac.
* Re-enable cli changes
* Re-enable redwood changes
* Minor cleanup
Since released PR #5009, we had some users that depend on the broken behavior. This adds an arbitrary date so that old projects will use the old broken behavior, and new projects will use the new behavior from #5009.
The reason for the date is that we don't want to force users to create new projects who noticed this broken behavior months ago like this discussion: https://github.com/vercel/vercel/discussions/4138
Its better to be a bit aggressive and set the date far back because users with that want the old behavior have a workaround: select Next.js in the framework dropdown. However, users that want the new behavior with an old project will be stuck without a solution.
This PR does a few things:
- Consolidates build-utils to use both 404 routes in `handle: error` phase
- Fixes `vc dev` to process `handle: error` phase after the `handle: filesystem` phase
- Updates `/api` 404 route to be excluded for frameworks like RedwoodJS which use their own functions
The deployment API might return a learn more link to address warnings, tips, or notices
CH-568
```
HTTP/2 200
...
x-vercel-warning-bad-error: Something went wrong
x-vercel-link-bad-error: https://vercel.link/bad-error
x-vercel-notice-low-funds: You are low on funds
x-vercel-link-low-funds: https://vercel.link/increase-funds
...
```
Should output as:
```
Warning: Something went wrong
Learn More: https://vercel.link/bad-error
Notice: You are low on funds
Learn More: https://vercel.link/increase-funds
```
This pull request adds a method redirect, the behavior will be the same as that of Next.js with `pages/api`. This PR takes into account the change that is being made in Next.js with redirect due to the [error that was reported](https://github.com/vercel/next.js/issues/15594) a few hours ago.
Co-authored-by: Steven <steven@ceriously.com>
This corrects behavior that was changed when switching to use `safelyCompile` which caused some `path-to-regexp` replacing behavior to be changed like not removing brackets `{}` around params which are removed in Next.js. This updates to first attempt to use the normal replacing behavior from `path-to-regexp` falling back to the safe compiling logic added when that fails.
Additional tests have been added to ensure the brackets are stripped as expected when compiling with `path-to-regexp`
The update message was sometimes printed when there was no update.
This PR fixes the update check to ensure the that it is only printed when the latest version differs from the current version.
This fixes the case where `trailingSlash: true` is used with `next export` causing the `404` page to be output as `404/index.html` and we were previously only checking for the 404 output at `404`. This also adds a regression test for this behavior.
Closes: https://github.com/vercel/next.js/issues/16218
The CLI doesn't depend on `@vercel/redwood` for `vc dev` since PR #5036 so we can remove it.
Similarly, zero config does not install `@vercel/next` or `@vercel/static-build` during `vc dev` so these can be removed too.
In the case where the user defines `builds` in vercel.json, the runtimes will be installed during the first run of `vc dev`.
This updates to not automatically append params to the query for rewrites if one or more of the params are already used in the destination's path. No other behavior is being changed and if the user still wants the params in the query after using them in the destination's path they can manually add them like with redirects.
x-ref: https://github.com/vercel/next.js/pull/16189
This PR uses the the new property added in PR #5034 to determine if a framework has a frontend runtime defined.
It also reverts a couple workarounds add in PR #4937 which was added for RedwoodJS which is no longer necessary since RedwoodJS defines a frontend framework the same way Next.js does.
This PR adds two properties to `frameworks.json`:
1. `useRuntime` - this moves the special case for non `@vercel/static-build` frontends, so that any framework can do the same as Next.js and RedwoodJS
2. `ignoreRuntimes` - this allows a framework to opt out of api detection such as RedwoodJS which handle's its own `.js` extensions
This also fixes 2 bugs discovered during implementing the feature:
1. `test-unit.yml` was not testing Node 12, it was testing 10 for both runs
2. `sortFilesBySegmentCount()` was non-deterministic causing node 10 and 12 to sort differently
This PR updates the default build command per @thedavidprice
It also uses `@vercel/frameworks` as a source of truth for the build command.
If the user has a `build` script in `package.json`, that will take precedence over the default.
Some files require execution privileges, such as Prisma, so we must preserve the file mode.
We also want redwood to behave the same as other frameworks and use `yarn build` if available.
CH Story:
https://app.clubhouse.io/vercel/story/5291/cli-connection-pooling
(Mac) script for watching count of active connections to API:
`watch -n 0.1 'netstat -a -n | grep -E \'(13.52.46.156|52.9.164.177)\' | wc -l'`
Limiting the active connections to 50 greatly decreased the amount of active connections but did not noticeably increase the time to upload files.
For each semaphore size below, I tested uploading 200 files of random size (between 50kb and 100kb) 5 times. More tests on varying file sizes / amounts showed similar results.
Results:
```
Size: Average time in ms
50 : 25740 ms
700 : 28763 ms
10 : 29339 ms
```
I also moved the the agent creation outside of the forEach loop when uploading. This is functionally the same (as node would use the same socket for the same hostname) but makes it easier to access the agent object if we need to debug in the future, and it seems unnecessary to create a new object each call.
This fixes the scenario where 1) is Windows and 2) there is no
`.gitignore` file in the project, so `vc link` creates one. Before, it was
defaulting to `\n`. Updated to use `os.EOL` so that `\r\n` is used on
Windows.
Also removed `encoding` option to `writeFile()` since `utf8` is already the
default.
Related to #4965.
We don't need to report these errors to Sentry because the user attempted a command that requires them to login.
https://sentry.io/organizations/vercel/issues/1498276418/?project=1323225
This will print:
- `NOT_AUTHORIZED`: "The specified token is not valid. Use vc login to generate a new token."
- `TEAM_DELETED`: "Your team was deleted. You can switch to a different one using vc switch"
### Related
- Related to #4082
- Related to #3857
* [cli] Adjust output for recently changed domain commands
* Update the inspect and list page
* Remove test
* Update packages/now-cli/src/commands/domains/inspect.ts
Co-authored-by: Steven <steven@ceriously.com>
* Change output
* Remove workaround
* Update error
* Include contextName
Co-authored-by: Steven <steven@ceriously.com>
This makes sure the routes mapping to the serverless functions handle the trailing slash being present or not. This also adds additional test cases to ensure it is functioning correctly
This adds handling for more cases while updating header values to make sure to escape any characters that could break compiling with `path-to-regexp`
x-ref: https://github.com/vercel/next.js/pull/15592
This makes sure we detect a fully static `/index` page correctly since the `prerender-manifest` lists it as `/` and we were expecting `/index` during the lambda building opt-out check
x-ref: https://github.com/vercel/next.js/discussions/15619
This PR fixes a bug when running `vercel link` command in a directory with `vercel.json` that contains `builds` property. The problem is that framework auto-detection doesn't run when `builds` is used, only for zero config. So we skip the API and instead create the project without auto-detection during `vc link`.
This updates our Next.js test fixtures to run against canary.
It looks like the mono-repo fixtures will need to be updated to run against canary separately since there may be a conflict with legacy routes and the trailing slash redirect
* [client] Export `buildFileTree()` and return the ignore list
The ignore list from this function will be used in production to
render a warning if there are files listed in the `.vercelignore` file
that are being comitted to the project's git repo.
* Tests for `ignoreList`
* Update packages/now-client/src/utils/index.ts
Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Steven <steven@ceriously.com>
Previously, the zero detection would see js files in the `/api` directory and attempt to use `@vercel/node`. However, this doesn't work with RedwoodJS which uses a different format for [`/api`](https://github.com/vercel/vercel/tree/master/examples/redwoodjs/api) so we must only use `@vercel/redwood` when RedwoodJS is detected.
## Problem
`api-frameworks` is not being cached by our edge when used via the fallback-to-front mechanism. That's because the headers are only applied to `/api/frameworks` but not `/api/v1/frameworks` which is the actual path being used.
## Solution
Also apply the caching headers to `/api/<version>/frameworks`
* [now-cli] Change `now domains add` workflow to match dashboard
* Fix error throwing and add --force
* Remove `now domains verify`
* Count projects when removing a domain
* Include projects for `now inspect`
* Updated `now domains ls`
* Fix `now domains ls`
* Use Finally
* Add tests
* Use --force for domain tests
* Adjust tests
* Adjust test and fix output
* Fix padding
* Adjust more tests
* Ensure the project exists
* Log the deployment
* Fix tests again
* Remove project after test
* Fix command
* Fix test
* Change user after a couple of tests
* Add check
* Use random name for domain
* More logging
* Add more logging
* Remove logging
* Remove .now/project.json every time
* Skip test
* Add test to change user
* More logging
* Use now login
* Remove duplicated test
* Consider linked project for `domains add`
* Fix linting
* Remove unused docs
* Undo changes
* Undo more changes
* Fix typo
* Do not sort projects when there is only one record
* Fix loop
* Deploy with `-V 2`
* Remove verification
* Remove outdated link
* Update packages/now-cli/src/commands/domains/add.ts
Co-authored-by: Steven <steven@ceriously.com>
* Update packages/now-cli/src/commands/domains/add.ts
Co-authored-by: Steven <steven@ceriously.com>
* Use utils for public suffix and service type
* Update packages/now-cli/src/commands/domains/ls.ts
Co-authored-by: Steven <steven@ceriously.com>
* Update packages/now-cli/src/commands/domains/add.ts
Co-authored-by: Steven <steven@ceriously.com>
* Change link
* Undo test changes
* Fix type issues
* Update packages/now-cli/src/commands/domains/add.ts
Co-authored-by: Steven <steven@ceriously.com>
* Use domain config to print info
* Check apex domain when removing a domain
* Remove psl
* List projects when removing a domain
* Do not list projects
* Change user earlier
* Update packages/now-cli/src/commands/domains/inspect.ts
Co-authored-by: Steven <steven@ceriously.com>
* Apply suggestions from code review
Co-authored-by: Steven <steven@ceriously.com>
* Apply suggestions from code review
Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Mark Glagola <mark.glagola@gmail.com>
Co-authored-by: Steven <steven@ceriously.com>
Follow up to #4897
* `vc link` - Update message to say `Set up ~/proj`
* `vc dev` - Update message to say `Set up and develop ~/proj`
* `vc link --help` - Updated example message to include `vc link ~/proj` usage
When pages are fully static and don't leverage preview mode or revalidation we can skip tracing the pages for generating the lambdas since lambdas aren't needed in this case
* [build-utils] Make `runPackageJsonScript()` run the `vercel-` or `now-` if defined in `package.json`
* [build-utils] Export `getScriptName()`
* [next] Use `getScriptName()` and `remove()`
* [node] Update for `vercel-`
* [static-build] Update for `vercel-`
* Remove debug
* Add `getScriptName()` unit tests
* Test for `vercel-build` in e2e
* Make platform name behavior be opt-in
So that it's not a breaking behavior change.
* Check for only "vercel-build" or "now-build", but not "build"
* Simplify `getScriptName()` to return the first existing script in a possible set
* Revert change
* Fix test
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Bumps [codecov](https://github.com/codecov/codecov-node) from 3.6.5 to 3.7.1.
<details>
<summary>Commits</summary>
<ul>
<li><a href="29dd5b6b03"><code>29dd5b6</code></a> 3.7.1</li>
<li><a href="c0711c6566"><code>c0711c6</code></a> Switch from execSync to execFileSync (<a href="https://github-redirect.dependabot.com/codecov/codecov-node/issues/180">#180</a>)</li>
<li><a href="5f6cc62d4f"><code>5f6cc62</code></a> Bump lodash from 4.17.15 to 4.17.19 (<a href="https://github-redirect.dependabot.com/codecov/codecov-node/issues/183">#183</a>)</li>
<li><a href="0c4d7f3c6f"><code>0c4d7f3</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/codecov/codecov-node/issues/182">#182</a> from codecov/update-readme-badges</li>
<li><a href="cc5e121842"><code>cc5e121</code></a> Update depstat image and urls</li>
<li><a href="b44b44e1f8"><code>b44b44e</code></a> Update readme with 400 error info (<a href="https://github-redirect.dependabot.com/codecov/codecov-node/issues/181">#181</a>)</li>
<li><a href="bb79335719"><code>bb79335</code></a> V3.7.0 (<a href="https://github-redirect.dependabot.com/codecov/codecov-node/issues/179">#179</a>)</li>
<li><a href="0d7b9b01cb"><code>0d7b9b0</code></a> Remove <code>'x-amz-acl': 'public-read'</code> header (<a href="https://github-redirect.dependabot.com/codecov/codecov-node/issues/178">#178</a>)</li>
<li><a href="eeff4e1953"><code>eeff4e1</code></a> Bump acorn from 5.7.3 to 5.7.4 (<a href="https://github-redirect.dependabot.com/codecov/codecov-node/issues/174">#174</a>)</li>
<li><a href="eb8a527470"><code>eb8a527</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/codecov/codecov-node/issues/172">#172</a> from RoboCafaz/bugfix/codebuild-pr-parser</li>
<li>Additional commits viewable in <a href="https://github.com/codecov/codecov-node/compare/v3.6.5...v3.7.1">compare view</a></li>
</ul>
</details>
<br />
[](https://help.github.com/articles/configuring-automated-security-fixes)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/vercel/vercel/network/alerts).
</details>
Previously, users would have to run `vc env pull` to fetch cloud environment
variables into `.env`. After this PR, if no `.env` or `.build.env` file is present,
environment variables will be pulled by `vc dev` from your Vercel Environment
Variables settings, no file necessary.
This makes the updating logic be asynchronous instead of synchronous, and as such will make boot-up of CLI be faster.
The actual update notification display is identical to previous, we are not using `update-notifier`'s default boxen rendering.
Now that `@vercel/static-build` is being symlinked to CLI due to the
yarn workspace, `vc dev` will always use the latest code for
zero-config, so this "npm pack" logic is no longer necessary.
The `vercel.json` also no longer gets created in this test so that
zero-config is used.
Ensures that `VERCEL_REGION` is set for API calls when the runtime
implements `startDevServer()`.
Also adds `VERCEL_URL` which was previously not defined.
The Vercel proxy request headers (`x-vercel-deployment-url` for example)
were not being sent to the dev server when the Runtime defines
`startDevServer()`. This is now fixed.
Also updates the header names to match production:
- `now` -> `vercel`
- 'x-now-trace', 'x-now-id', and 'x-now-log-id' are removed
Fixes#4729.
CH-3242
When a user has project configuration in `.vercel` that corresponds to a team that they are not a part of, we currently throw a 403 error. This adds special handling so that we can show a specific message when this happens.
I didn't want to update the return type of `getProjectByIdOrName` because we only want to handle this 403 in a special case, so I `throw` it instead.
Other changes are linter.
This is for `@vercel/go` to work on Windows, which currently fails with
this error:
```
panic: write pipe: The handle is invalid.
goroutine 1 [running]:
main.main()
C:/Users/Nathan/Code/casca/vercel-go-test/.vercel/cache/go/2flefmhra8o/api/vercel-dev-server-main.go:25 +0x1ec
exit status 2
```
So this fallback writes the port number to a temp file that
`startDevServer()` polls for in order to figure out the port number.
This PR adds an optional property called `sort` to each framework so that we can change the order returned in the API.
The reason this is necessary is because the order of the original array determines the precedence of framework detection. So we need another way to indicate the order of templates/examples returned from the API.
In particular, we need "Next.js" to be first and "Other" to be last.
I also updated the deprecated `@now/node` usage to `@vercel/node` in the API.
* [@vercel/build-utils] Improve Nuxt build
Need review from @pi0 and @danielroe
* Update packages/now-static-build/src/frameworks.ts
Co-authored-by: Daniel Roe <daniel@roe.dev>
Co-authored-by: Daniel Roe <daniel@roe.dev>
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
This fixes dynamic routes missing inside of shared lambdas for non-revalidate pages that leverage preview mode which causes them to not be able to render. Additional tests have also been added to ensure preview mode is working properly
This adds failing page names to our tests which should be resolved once the correct regexes is being generated for the routes-manifest in Next.js
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
Co-authored-by: Steven <steven@ceriously.com>
When a user performs an action such as trying to add a domain they don't own, the API returns a 400-499 response code.
Previously, we would save this error in Sentry but this PR changes the behavior so that the error is printed locally for the user but not saved in Sentry.
This reverts commit f11eb32b2c.
Reverts PR #4816
This PR adds back the Blitz.js demo now that we confirmed the example works and is deployed to the correct account.
This is a re-introduction of #4697, which was reverted for performance
resons. But now that #4760 and #4793 have landed, we can enable this
behavior again.
The first version of `routeKeys` which was Array based could contain invalid named regexes which would break the build during route validation so this disables using them in that version of the manifest instead of trying to leverage them still. It also adds an additional test fixture with this version of the manifest to ensure it is still working properly
This adds [Blitz.js](https://github.com/blitz-js/blitz) to the zero-config frameworks.
Blitz compiles to a Next.js app, so it uses the same `@vercel/next` builder.
The change in `packages/now-build-utils/src/detect-builders.ts` was made according to @styfle's suggestion in Slack.
---
**This is a rerun of #4219 which had to be reverted because of this:**
> It looks like the @vercel/next package still requires next in the dependencies.
>
> When I've deployed the example I've got only a file listing, but when I added next to the dependencies it worked. I'll revert for now.
This new PR fixes that problem with a small refactor to `@vercel/next`.
`@vercel/next` was getting the Next version two different ways:
1. By checking project root package.json for `next` in deps or devDeps
2. By trying to resolve the installed next version and get `version` from its package.json
My refactor consolidates those two approaches by changing the existing `getNextVersion()` function to first try and resolve the real next version. If that fails, fall back to checking the project root.
Blitz bundles Next, so the real next package version should always be resolved.
The current code uses `getAllProjectFiles()` which globs for every file
in the project, not considering the `.vercelignore` file and default
ignore list. For example, every file in the `node_modules` directory is
selected, just for `vercel dev` to manually ignore them afterwards,
which is very slow and wasteful. For a simple Next.js project, this
globbing was taking over 3 seconds on my machine 🤯!
Solution is to use the `staticFiles()` function which is the same as
`vercel dev` uses at boot-up time. This function properly considers the
ignore list and thus is much faster, and the manual filtering is no
longer necessary by `vercel dev`. For the same simple Next.js project,
this function takes on average 10 milliseconds.
Also did a bit of cleanup and removed the `getAllProjectFiles()`
function since it is no longer used anywhere.
For `getServerSideProps` routes the non-named data route was being used for routes causing dynamic route params that were being trusted from the proxy to be incorrect. Our tests weren't failing after trusting the values from the proxy was landed in Next.js on canary due to the `21-server-props` test suite not running against the latest canary which is updated in this PR.
Note: the below Next.js PR is not needed or can be reverted if this PR is landed
x-ref: https://github.com/vercel/next.js/pull/14829
* [cli] Reduce number of times `getNowConfig()` is invoked in `vercel dev`
When using the `vercel dev` command, the `getNowConfig()` function was
being invoked many times per HTTP-request. It should only be read _once_
per HTTP request as it may be an expensive function depending on the
project size.
This change reduces the number of times the function is called to once
per HTTP request, and passes around the resulting `nowConfig` object to
the functions that require it.
* Fix default values
* Remove unnecessary type narrowing
* Remove one more `getNowConfig()` invocation
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This adds the Lockfile from Gatsby's official starter to fix deployments.
```
❯ npx gatsby-cli new ~/Desktop/scratch/test-default
❯ cp ~/Desktop/scratch/test-default/yarn.lock examples/gatsby
❯ cd examples/gatsby
❯ yarn
❯ git add examples/gatsby/yarn.lock
```
This fixes mapping dynamic routes to their shared lambdas failing from the `dynamicPageLambdaRoute` not being injected directly after the dynamic route due to dynamic routes now containing a `query` which caused the route lookup to fail.
This is resolved by making sure to parse the pathname while injecting the `dynamicPageLambdaRoute` so the route can be looked up correctly. This also adds additional test cases to prevent regressing on this along with updating existing fixtures for custom routes being de-experimentalized
This reverts commit ffb98781f1 (#4697),
because it was realized that `vc dev` reads this configuration file many
times per HTTP request, causing the server to feel extremely slow.
Reverting this optimization for now until the over-reading issue is
addressed.
This PR improves the error handling when a zero config framework has an unexpected output directory.
Previously, setting a Docusaurus 2.0 build command to `docusaurus build && mv build foo` would fail with the following:
```
Error: ENOENT: no such file or directory, scandir '/vercel/514ce14b/build'
```
With this PR, the error message will show the expected:
```
Error: No Output Directory named "build" found after the Build completed. You can configure the Output Directory in your project settings. Learn more: https://vercel.com/docs/v2/platform/frequently-asked-questions#missing-public-directory
```
I also changed the usage of [`promisify(fs)`](https://nodejs.org/docs/latest-v10.x/api/util.html#util_util_promisify_original) to [`fs.promises`](https://nodejs.org/docs/latest-v10.x/api/fs.html#fs_fs_promises_api) which is available in Node 10 or newer.
Lastly, I updated the test suite to check if the correct error message is returned for builds we expect to fail.
Previously, when a project has a specific "Output Directory" configured
in the project settings page, it was not being correctly considered when
using `vercel dev`.
The main fix here is passing in the full project settings object
(including the `outputDirectory`) to the `detectBuilders()` function.
Also cleaned up a few types and updated the error message that was
previously being rendered to use a short link.
Due to Go's peculiar package importing structure, there's unfortunately no way to _directly_ invoke a Go serverless file, so the approach for this `startDevServer()` function is:
* Create a temp directory in `.vercel/cache`
* Run the `analyze` Go program on the entrypoint file to determine the `functionName`
* Copy the entrypoint file into the temp directory, while modifying it to use `package main`
* Copy the `dev-server.go` file into the temp directory, replacing the placeholder function name with the `functionName` retrieved from the analysis step from before
* Execute `go run $tmp_dir` to spawn the Go HTTP server on an ephemeral port
* Return the Go process id and port number for `vercel dev` to proxy to
* After the Go process has exited, delete the temp directory
This adds more fine grained tests for our revalidate behavior to ensure pages are actually being updated instead of only checking the headers, it also corrects page lookups failing with shared lambdas enabled for dynamic pages using revalidate.
Closes: https://github.com/vercel/next.js/issues/14497
Since the filesystem watcher may be slow, it's actually faster and more
reliable to simply re-read the `vercel.json` configuration for every
HTTP request. This also simplifies the logic as an added benefit.
Some `sleep()` calls are removed from relevant tests that were
previously necessary due to the lag in the filesystem watcher.
This PR improves the validation error message when the user has an invalid `vercel.json` file.
Previously, the error message did not account for nested properties so `{"foo": "will error"}` looked fine because it would mention there is an additional property `foo`. However, the error message for `{ "routes": [{ "foo": "will error" }] }` did not mention anything about `routes` when it explaining there was an additional property `foo`. This became more apparent as we added nested properties for `rewrites` and `redirects` (see tests in this PR).
This PR also adds suggestions for common mistakes such as `src` vs `source`.
In the latest canary of Next.js pages are no longer nested under the `BUILD_ID` folder and instead are nested under a hash for the page bundle content. To prevent these tests from breaking too often from changes in canary this updates to locate the page bundle using the `buildManifest`. This also updates our latest SSG fixture to test against the latest canary to help ensure the feature doesn't break with a new canary release
Append `# Created by Vercel CLI` to the head of `.env` file and automatically overwrite the file if it's there next time without confirmation.
https://app.clubhouse.io/vercel/story/316
This PR fixes the error message when the client does not have internet connectivity or perhaps DNS is misconfigured such that the hostname cannot be resolved.
This PR fixes#4239 where using `vercel dev` to work on monorepos where
the Next.js app is not in the topmost directory fails to correctly route
to dynamic pages.
After investigating the devServer router, @styfle prompted me to
investigate the @vercel/next builder. He also suggested restricting
`check` to be false only when running in `now dev`.
Co-authored-by: Steven <steven@ceriously.com>
Bump node-file-trace to fix a webpack tracing bug that looks like the following:
```
TypeError: Cannot read property 'type' of null
at handleWrappers (/vercel/e77875438c1cd74b/.build-utils/.builder/node_modules/@vercel/next/dist/index.js:12763:58)
at module.exports.447.module.exports (/vercel/e77875438c1cd74b/.build-utils/.builder/node_modules/@vercel/next/dist/index.js:14674:3)
at Job.emitDependency (/vercel/e77875438c1cd74b/.build-utils/.builder/node_modules/@vercel/next/dist/index.js:11730:40)
at /vercel/e77875438c1cd74b/.build-utils/.builder/node_modules/@vercel/next/dist/index.js:11755:20
at async Promise.all (index 9)
at async Job.emitDependency (/vercel/e77875438c1cd74b/.build-utils/.builder/node_modules/@vercel/next/dist/index.js:11736:5)
at async Promise.all (index 1)
at async Object.module.exports.328.module.exports [as default] (/vercel/e77875438c1cd74b/.build-utils/.builder/node_modules/@vercel/next/dist/index.js:11514:3)
at async Object.module.exports.178.exports.build (/vercel/e77875438c1cd74b/.build-utils/.builder/node_modules/@vercel/next/dist/index.js:6076:69)
at async buildStep (/var/task/sandbox-worker.js:20407:20)
```
- [0.6.2](https://github.com/vercel/node-file-trace/releases/tag/0.6.2)
- [0.6.3](https://github.com/vercel/node-file-trace/releases/tag/0.6.3)
- [0.6.4](https://github.com/vercel/node-file-trace/releases/tag/0.6.4)
Depends on #4355
As mentioned by @dav-is we can prefix the outputs with the `basePath` instead of using a rewrite so that we make sure to 404 when the basePath isn't prefixed on the output. This behavior is also matched in Next.js with [this PR](https://github.com/zeit/next.js/pull/9988).
x-ref: https://github.com/zeit/now/pull/3478
This updates to leverage changes from https://github.com/zeit/next.js/pull/12801 which resolves invalid named regexes being used when the segments contain non-word characters e.g. `/[hello-world]`.
Failing page names have also been added to the `23-custom-routes-verbose` fixture. Since the routeKeys aren't applied for dynamic routes in this PR until the routes-manifest version is bumped in the latest canary of Next.js the added test cases will be passing now and should be re-run to ensure passing after a new canary of Next.js is released with the routes-manifest version bump
On Node 10, the `require.resolve()` with "paths" does not return the
proper value relative to the `node_modules` directory. To wit:
```
$ node -v
v10.16.3
$ node -p "require.resolve('typescript', { paths: [process.cwd()] })"
/Users/nrajlich/Code/vercel/vercel/packages/now-node/dist/typescript.js
$ node -v
v14.4.0
$ node -p "require.resolve('typescript', { paths: [process.cwd()] })"
/Users/nrajlich/Code/vercel/vercel/node_modules/typescript/lib/typescript.js
```
(**Note:** cwd when running these commands is the `dist` dir of `@vercel/node`)
So the solution is to just let `require.resolve()` throw an error so the
default string "typescript" is used instead of a resolved absolute path.
This PR adds a E2E CLI test to ensure that the Gatsby example deploys correctly and that the second deployment has the proper cached directories.
Co-authored-by: Nathan Rajlich <n@n8.io>
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
Before this, if the `vercel.json` file gets deleted while the dev server
is running, then it would still act like the file exists since it would
use the cached version.
Now it properly invalidates to an empty configuration if the
`vercel.json` file does not exist.
This is a follow up to #4514 to handle the case where there is no
`tsconfig.json` closer to the entrypoint. This is likely the case when
`.js` files with ES Modules syntax are being used instead of `.ts`.
* [cli] Better errors for conflicting configuration files
Renders the link https://vercel.link/combining-old-and-new-config
for all conflicting config errors.
* Fix unit test
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
* Fixes changing a `config` value in the `builds` array (such as `helpers: false` for `@vercel/node`) and having it be reflected in `vc dev` without restarting the dev server.
* Re-validates the env vars configuration when a `.env` file changes or the `env` object is changed in `vercel.json` (same for the builds equivalents).
* Ensures that the `NODEJS_HELPERS` build env var is being properly checked in `startDevServer()`.
* Regenerated the `yarn.lock` file because yarn was erroring when trying to add the `fast-deep-equal` dependency.
As noticed, `now.json` and `vercel.json` files aren't available during the build currently which makes feature detecting and opting out when `routes` are used not work currently so this re-disables the shared lambdas optimization by default while we investigate detecting this
* Ensures that `vc --debug projects ls` properly prints the Projects listing, rather than the usage help info.
* `vc projects` (without a subcommand) shows the Projects listing (this is consistent with i.e. `vc domains`).
* Returns with exit code `2` when the usage help info is printed (standard Unix convention).
As discussed this adds opting out of the shared lambdas optimization when a user adds a functions config in `now.json` or `vercel.json` since this could potentially be a breaking change. We plan to add new handling to still allow customizing this config for the combined lambdas that are created
This happens, for example, with a `startDevServer()` process that
crashes (i.e. a syntax error in a Node.js API endpoint) before
responding to the HTTP request.
* Fix the "Developer Documentation" link.
* Remove the "If you're a visitor" section - doesn't make sense for `vc dev` since there are no "visitors".
* Don't link to `_logs` since it's not supported in `vc dev`. Instead direct the user to look at their terminal window to see error logs.
* Link to new GH issue for non-app error 502 (I don't think this code path ever happens in `vc dev`, but might as well make it correct in case we do in the future).
<img width="1077" alt="Screen Shot 2020-06-05 at 4 15 16 PM" src="https://user-images.githubusercontent.com/71256/83929319-c7832a00-a747-11ea-9cae-b0adac97dfa5.png">
As discussed this de-experimentalizes the shared lambdas optimization now that we have tested it, it also bails out of the optimization when a `now.json` or `vercel.json` is detected that contains legacy routes
Next.js already has support for [customizing the 404 page](https://nextjs.org/docs/advanced-features/custom-error-page#customizing-the-404-page), but many other frameworks do not or they expect a 404.html in the output directory.
This PR adds support for rendering the a `404.html` page for all zero config deployments.
- Implements ch337
- Related to #3491
* [client] Throw an error if both `vercel.json` and `now.json` exist
* Update packages/now-client/src/create-deployment.ts
Co-authored-by: Steven <steven@ceriously.com>
* Check in CLI as well
* Add integration test
* Add logic to `getLocalPathConfig()` as well
* Fix import path
Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
So that if a `tsconfig.json` exists closer to the entrypoint file,
then that config file will be correctly used (rather than say, the
root-level `tsconfig.json` file, which may be specific to the frontend
configuration in Next.js for example).
Upon investigation into the `dist` dir, it appears that `ncc` is bundling some assets that don't need to be there. This change is a quick band-aid fix to remove those assets, without addressing the underlying cause of _why_ they're being bundled, which requires further investigation.
Overall about 1mb of disk space is saved.
Fixes a case when the header value contains a URL which was mistaken for a named segment.
https://sentry.io/organizations/zeithq/issues/1702692084/?project=1351065
The regression was introduced in PR #4484 where unnamed segments were implemented for `redirects` and `rewrites` but not handled properly in `headers`.
In PR #4498, the type of the routing error was changed from first error and then the remaining errors. This PR changes the type back such that `error.errors` returns all errors. This will avoid any breaking change.
This PR improves the way we handle routing errors in a few ways:
- The error response is a single error (the first) instead of an array of errors when mixing routing properties
- The error message says which route index has the error
- The error includes `link` and `action` properties to match our API
- The error message for mixed routes with new routing properties has been updated per [ch341](https://app.clubhouse.io/vercel/story/341)
Related to #3491
We renamed the GitHub repository from `zeit/now` to `vercel/vercel` so this PR updates all references to the repo URL.
There were also a few remaining references to Now CLI that have been updated to Vercel CLI.
Follow up to #4463 to fix failing windows unit tests in `now-client`.
This also fixes `now-cli` tests that started failing after renaming the repo to `vercel/vercel`.
Follow up to #4444 that makes sure we run Next.js tests.
This `--ignore-engines` flag was originally added in https://github.com/vercel/now-builders/pull/463 as a workaround. We can remove it to make sure the version of Node selected will work with the dependencies.
Removing the flag also makes sure that Yarn 2 will work properly, see #4444.
This adds a failing test for the regex from https://github.com/zeit/next.js/discussions/13347#discussion-4546
It appears the reason the regex does not work when deployed on Vercel is due to us not indexing the un-named segments and instead we filter them out as noticed by @dav-is.
This PR adds one approach to resolve this by accounting for the un-named indexes while not allowing them to be used in the destination still.
Similar to #4427 but instead of an option to turn on or off, we delay the background task that updates the Runtimes during development. The idea is that the initial install runs immediately using the bundled Runtimes from the CLI. Then if the user plans to keep developing, we'll check to see if we should update to the latest Runtime version after 30 seconds.
When debugging the CLI with `--inspect`, the flag was being passed to the child process as well since #4254.
This PR prevents any arguments from being passed to the child process.
For some reason, the glob selector was causing problems on Windows:
```
[frameworks] Running yarn test-unit
$ jest --env node --verbose --runInBand --bail test/*unit.*test.*
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In D:\a\now\now\packages\frameworks
6 files checked.
testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 1 match
testPathIgnorePatterns: \\node_modules\\ - 6 matches
testRegex: - 0 matches
Pattern: test\\*unit.*test.* - 0 matches
error Command failed with exit code 1.
```
Remove the glob pattern fixes the issue, though it's not clear why it
causes an issue in the first place.
See: https://github.com/zeit/now/runs/701043212
* Update routes order for shared lambdas
* Add test case
* update test path
* Update packages/now-next/test/fixtures/23-custom-routes-verbose-shared-lambdas/now.json
* Update headers in probes
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
This code was contributed by @nathancahill under MIT license but it is likely from the Mangum project, so we'll link to the relevant code as the original source, also MIT License.
Currently, CI is printing this:
```
Running "test-unit" on branch "(HEAD" with the following packages:
now-cli\test\dev-server.unit.js
now-cli\test\fixtures\unit\now-dev-request-body\api\data-events.js
now-cli\test\fixtures\unit\now-dev-request-body\api\req-body.js
now-node-bridge\src\bridge.ts
now-node\src\dev-server.ts
now-node\src\helpers.ts
now-node\src\launcher.ts
now-cli
[now-cli\test\dev-server.unit.js] Skipping since script "test-unit" is missing from package.json
[now-cli\test\fixtures\unit\now-dev-request-body\api\data-events.js] Skipping since script "test-unit" is missing from package.json
[now-cli\test\fixtures\unit\now-dev-request-body\api\req-body.js] Skipping since script "test-unit" is missing from package.json
[now-node-bridge\src\bridge.ts] Skipping since script "test-unit" is missing from package.json
[now-node\src\dev-server.ts] Skipping since script "test-unit" is missing from package.json
[now-node\src\helpers.ts] Skipping since script "test-unit" is missing from package.json
[now-node\src\launcher.ts] Skipping since script "test-unit" is missing from package.json
```
So, other than `now-cli` which is hard-coded to always run, no other tests were being selected on Windows. This change uses the proper path separator for the OS to fix this.
Also, the branch name detection command is changed to fix the `"(HEAD"` name that is being detected in CI.
With this change, it looks like:
```
Running "test-unit" on branch "fix/tests-windows" with the following packages:
- now-node
- now-cli
[now-node] Running yarn test-unit
…
[now-cli] Running yarn test-unit
…
```
This PR adds two additional flags to `npm install` when updating Runtimes:
- `--no-audit`: disable sending of audit reports to the configured registries
- `--no-progress`: disable the progress bar
* Removes the `get-bundled-builders.ts` file, which is no longer relevant, and was causing a false-positive for `@now/build-utils`.
* Makes the installing of `@vercel/build-utils` and `@now/build-utils` only happen if there is another Runtime to install.
* `@vercel/build-utils` and `@now/build-utils` will now be properly checked for updates (but again, only if there is another Runtime to update).
Fixes an issue from discussion #4391 so that quotes are no longer escaped per dotenv conventions.
I tested the behavior and it works correctly with Next.js and Create React App.
Fixes an issue from discussion #4391 so that quotes are no longer escaped per dotenv conventions.
I tested the behavior and it works correctly with Next.js and Create React App.
Fixes an issue from discussion #4391 so that quotes are no longer escaped per dotenv conventions.
I tested the behavior and it works correctly with Next.js and Create React App.
Fixes an issue from discussion #4391 so that quotes are no longer escaped per dotenv conventions.
I tested the behavior and it works correctly with Next.js and Create React App.
Fixes an issue from discussion #4391 so that quotes are no longer escaped per dotenv conventions.
I tested the behavior and it works correctly with Next.js and Create React App.
Fixes an issue from discussion #4391 so that quotes are no longer escaped per dotenv conventions.
I tested the behavior and it works correctly with Next.js and Create React App.
Fixes an issue from discussion #4391 so that quotes are no longer escaped per dotenv conventions.
I tested the behavior and it works correctly with Next.js and Create React App.
Fixes an issue from discussion #4391 so that quotes are no longer escaped per dotenv conventions.
I tested the behavior and it works correctly with Next.js and Create React App.
Fixes an issue from discussion #4391 so that quotes are no longer escaped per dotenv conventions.
I tested the behavior and it works correctly with Next.js and Create React App.
Fixes an issue from discussion #4391 so that quotes are no longer escaped per dotenv conventions.
I tested the behavior and it works correctly with Next.js and Create React App.
Fixes an issue from discussion #4391 so that quotes are no longer escaped per dotenv conventions.
I tested the behavior and it works correctly with Next.js and Create React App.
Fixes an issue from discussion #4391 so that quotes are no longer escaped per dotenv conventions.
I tested the behavior and it works correctly with Next.js and Create React App.
`now-bash@3.0.0` is broken in production because AWS decided to remove
the `which` command from the Lambda environment for some reason. Fixed
in the latest version which uses the updated Vercel name.
Also removes the `skipDeploy: true` flag for this test, and updates the
test names to include "vercel dev" intstead of "now dev".
This is a follow-up to #4241, which apparently caused the `vc dev` unit
tests to start timing out. After some digging, it seems the root cause
is that `proxy.close()` callback is never invoked. This makes sense
because we never call `proxy.listen()` or have the `httpProxy` actually
bind to a port.
We were already using `http-proxy`'s WebSockets option, but we were missing a step! In addition to setting `{ws: true}`, you must also forward WebSocket upgrade events from the front-facing server to the proxy. [(See this example.)](https://github.com/http-party/node-http-proxy#proxying-websockets)
Previously, the proxy server and client _would_ mutually agree to "upgrade" their connection (because we set `{ws: true}`)… but then, when the client would start sending WebSocket data instead of HTTP data, our front-facing server would drop it, because we hadn't configured a place for it to go.
In this change, we configure `this.server` to forward its `upgrade` events to the proxy server.
We also refactor `proxyPass` to use the new shared `this.proxy` instance responsible for the `upgrade` events, instead of creating a new proxy instance for every request. This isn't strictly necessary, but a helpful simplification to clarify that there's no specific reason for the proxy instances to be _different_ than the instance that manages WebSocket upgrades!
This fixes#3451: CRA apps can now auto-refresh when the source code changes, and Firefox can now load the app without crashing on the 6th attempt.
Co-authored-by: Steven <steven@ceriously.com>
* Add initial changes for grouping lambdas
* Handle more cases and clean up some stuff
* Remove logs from debugging
* Remove changes from testing and add page layers
* Update output tests
* Move new behavior behind flag
* Add separate tests for new behavior
* Clean-up style diffs
* Update error
* Update to separate out new behavior more
* Apply suggestions from review
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
* Add test to frameworks
* Add example for Docusaurus v2
* Add example for ionic-angular
* Update READMEs
* Use existing versions
* Reset yarn.lock
* Add schema validation and add missing Scully.io logo
Write the generated `tsconfig.json` files that are required to do TypeScript type checking on a single file to the dev cache directory (`.vercel/cache`). This way, they are in a location that is gitignored by default, but still has `require()` access to the types that the project uses.
* `StartDevServerOptions` had to be updated to include `meta`, at which point it's identical to `BuildOptions`, so just make it a type alias instead.
* Vercel CLI is updated to pass in the `meta` object to `startDevServer`
* Vercel CLI is updated to create the `.vercel/cache` dir upon startup, if it does not already exist
* `@vercel/node` now creates the tsconfig files in the dev cache directory, using the `wx` write flags. This ensures that the file is only created once and then cached in the dev cache dir.
An example of a generated tsconfig file for endpoint `api/foo.ts`:
```json
{
"extends": "../../tsconfig.json",
"include": ["../../api/foo.ts"]
}
```
To keep the `lerna` monorepo version pinning intact.
It should have been updated in c23b9ccd1d, but was not because the commit was created manually instead of with `lerna`.
Starting with version 18.0.0, there was a regression from ##3980 causing the deploy command to hang indefinitely at the file tree building stage. I triaged the issue to be that the call of `recursive-readdir` was now walking through my `node_modules` folder. This is an issue in my environment since I have a very intricate monorepo with circular symlinks in my node_modules, which causes `recursive-readdir` to go into an infinite loop.
This PR fixes this in 2 commits:
1) The first commit refactors out the file tree building logic into separate utility functions and adds unit tests to verify the expected behavior of not walking through `node_modules` (this commit's unit test run should fail as seen in checks on this PR). This commit does not change any behavior.
2) The second commit fixes the actual issue (causing the unit tests to pass again). When I was bisecting the issue between the 17.0.0 and 18.0.0 tags I noticed that trailing slashes were added to the default ignore's directory entries in `getVercelIgnore()`. I removed them to bring it back to how it was done in v17.0.0 and it resolved the issue.
Hopefully with the added unit tests this shouldn't regress in the future.
Co-authored-by: Steven <steven@ceriously.com>
* [now-node-bridge] Catch invalid HTTP request headers
In some rare cases, the proxy layer passes what Node.js considers an
invalid HTTP request header causing the `http.request()` function to
throw an error, such as:
```
TypeError [ERR_INVALID_HTTP_TOKEN]: Header name must be a valid HTTP token ["cookie"]
```
So instead, use `req.setHeader()` API with try/catch to skip invalid
HTTP headers and print a message for the deployment logs with debugging
information. This way, the HTTP request will still go through, with
a missing header, rather than causing the whole function to 500.
* Add test
* Don't use `typeof`
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This PR improves the error message when a user provides an invalid pattern in package.json `engines` field.
## Before
```
TypeError: Invalid comparator: => 10
at Comparator.module.exports.Comparator.parse (/zeit/9cd49d8c66a9bd43/.build-utils/node_modules/@vercel/build-utils/dist/index.js:10262:11)
at new Comparator (/zeit/9cd49d8c66a9bd43/.build-utils/node_modules/@vercel/build-utils/dist/index.js:10245:8)
at Range.<anonymous> (/zeit/9cd49d8c66a9bd43/.build-utils/node_modules/@vercel/build-utils/dist/index.js:10439:12)
at Array.map (<anonymous>)
at Range.module.exports.Range.parseRange (/zeit/9cd49d8c66a9bd43/.build-utils/node_modules/@vercel/build-utils/dist/index.js:10438:13)
at Range.<anonymous> (/zeit/9cd49d8c66a9bd43/.build-utils/node_modules/@vercel/build-utils/dist/index.js:10381:17)
at Array.map (<anonymous>)
at new Range (/zeit/9cd49d8c66a9bd43/.build-utils/node_modules/@vercel/build-utils/dist/index.js:10380:40)
at Function.intersects (/zeit/9cd49d8c66a9bd43/.build-utils/node_modules/@vercel/build-utils/dist/index.js:10998:8)
at /zeit/9cd49d8c66a9bd43/.build-utils/node_modules/@vercel/build-utils/dist/index.js:25847:29
```
## After
```
Found `engines` in `package.json` with an invalid Node.js version range: "=> 10".
Please set "engines": { "node": "12.x" } in your `package.json` file to upgrade to Node.js 12.
More details: https://vercel.com/docs/runtimes#official-runtimes/node-js/node-js-version
```
In this case, the `=>` operator is not valid so the user probably meant `>=` but we only suggest the `10.x` or `12.x` syntax because we can only guarantee a major version.
This PR fixes the scenario when a user adds an environment variable to a project but then deletes the secret associated with the environment variable.
For example:
```sh
echo 'foo' | vc env add FOO development
vc secrets rm foo-development-v1ln
vc env pull # would error with 404 every time
vc env rm FOO development # would error with 404 the first time
```
Now we'll warn for `vc env pull` and we will assume success for `vc env rm`.
Fixes https://sentry.io/organizations/zeithq/issues/1612188511/
Fixes https://sentry.io/organizations/zeithq/issues/1656997656/
* [client] Throw an error if both `.vercelignore` and `.nowignore` exist
* Remove `.`
* Add tests
* Update test
* [cli] Properly clear spinner if `createDeployment()` async generator throws an error
* Update packages/now-client/src/utils/index.ts
Co-authored-by: Steven <steven@ceriously.com>
* Update packages/now-client/tests/vercelignore.test.ts
Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Steven <steven@ceriously.com>
This PR fixes an issue where old versions of the CLI would update to the latest builder, but not have a copy of `@vercel/build-utils` because they only shipped with `@now/build-utils`. So in this case, we can fallback to the other package. We must be careful to only import types from `@vercel/build-utils` and anything needed at runtime must be imported from `./build-utils` wrapper.
This PR fixes an issue when the error message assumed the config was `vercel.json` even when the user had `now.json`.
### Before
```
Error! The property `foo` is not allowed in vercel.json – please remove it.
```
### After
```
Error! The property `foo` is not allowed in now.json – please remove it.
```
Co-authored-by: Nathan Rajlich <n@n8.io>
This PR fixes a regression from PR #4084 where secrets were paginated so some v1 deployments that had more than 20 secrets were unable to deploy since CLI version 19.
This PR adds two functions:
* `getTitleName()` - used to get the uppercase Vercel or Now package name, for example `vercel --version`
* `getCommandName()` - used to get the `vercel` command followed by subcommands, for example in error suggestions
Unset the `npm_config_registry` env var which yarn overwrites to the
yarn registry, which we don't want since the `.npmrc` file that gets
created is configured to the npm registry.
This PR adds a test for a deployment as well as `now dev` to ensure both `vercel.json` and `.vercelignore` are applied.
I also fixed the remaining test helpers to work with `vercel.json`.
* [now-build-utils] Use `@now` runtimes for zero-config
This is a temporary change until the `@vercel` runtimes work in
production.
* Temporary fix to E2E
Fixes a bug where `isOfficialRuntime('static', '@now/static-build')` was returning `true` when it should have been `false`.
And use the function from `@vercel/build-utils` in Vercel CLI.
We want to make sure the bin matches the [installed package name](https://docs.npmjs.com/files/package.json#bin).
This means `npm i -g now` will remain `now` and `npm i -g vercel` will use `vercel` as the binary name.
This allows support for different versions on one machine such as `npm i -g now@17 vercel@19` for example.
In addition, we will also install a shorthand `vc` so you can do `vc env pull` for example.
Added the following env vars, most are undocumented but its good to be consistent:
- `VERCEL_REGION`
- `VERCEL_DEBUG`
- `VERCEL_BUILDER_DEBUG`
- `VERCEL_TOKEN`
- `__VERCEL_SKIP_DEV_CMD`
I also updated the error code prefixes to remove `NOW_`.
There `code` isn't used anywhere, this is just to make it unique and a little shorter.
We renamed `.now` to `.vercel` in #4234 but still fallback to `.now` if it exists. This is because we don't want users to have to re-link all their existing projects. So we need to make sure that the Runtimes know which directory to use for caching. This PR introduces the `devCacheDir` for this purpose.
As you can see in https://github.com/zeit/now/runs/647945621,
the final step for publishing the legacy `@now` packages failed
with a 401 error from npm.
This additional logging an to attempt to debug why that is happening.
https://vercel.com/blog/zeit-is-now-vercel
* Updates all org packages from `@now` to `@vercel`
* Updates Now CLI package name from `now` to `vercel`
* Packages contains `"bin"` entries for _both_ `vercel` and `now` in the package.json
* Updates `now-client` package name to `@vercel/client` (org scoped, for authenticity)
There is also a new `publish-legacy.sh` script which ensures that all the legacy package names (i.e. `now`, `now-client`, `@now/node`, etc.) will still be published as well.
We will remove this legacy publishing logic on Jan 1, 2021.
This PR renames the CLI and config files to `vercel`.
https://vercel.com/blog/zeit-is-now-vercel
### Complete
- [x] Help menus and error messages should print cli name from `package.json`
- [x] `now.json` => `vercel.json`
- [x] `.nowignore` => `.vercelignore`
- [x] `~/.now` => `~/.vercel`
- [x] `<project>/.now/project.json` => `<project>/.vercel/project.json`
### TODO
I'm going to do the remaining work in a follow-up PR:
- [ ] `<project>/.now/cache` => `<project>/.vercel/cache` (Runtimes sometimes use this)
- [ ] `NOW_*` special cased environment variables
- [ ] `*.now.sh` special cased url suffix
This PR fixed a corner case when the user defined both `cleanUrls: true` and `trailingSlash: true` and then visited `/index.html` which would attempt to redirect to the invalid `//` path.
This PR fixes a bug where the headers were not applied when exiting with a status code such as 204.
This is a common pattern for CORS where you want `OPTIONS` method respond with 204 status due to a preflight request.
I also updated the test suite to support the `method` property and ensured a body with empty string is asserted.
As discussed this updates to leverage the new named regexes and route keys output in the `routes-manifest.json` to pass the dyname page values in the query to ensure we're handling edge cases with the new custom routes support
Note: the `yarnPreferOffline` change is unrelated and was added to make debugging easier as the build can fail when using this option and the cache is invalid for some packages.
x-ref: https://github.com/zeit/next.js/pull/12250
In PR #3514, we added a `/api` directory for functions and a `/public` directory which was created at build time.
This moves the build script to be `now-build` so we don't don't need to build everything in the repo and also no longer need to special case the git env vars.
This PR makes sure that all the `now dev` tests have a corresponding deployment and each assert is also compared to the deployment.
If you want to opt-out of this behavior, for example a test that is meant for specific dev functionality, then there is an option `skipDeploy: true`.
This also fixes a bug where headers were not assigned during proxying to a dev server.
Using `ts-node`, with asynchronous type checking via `tsc --no-emit`.
This also removes `ncc` of `typescript` during the build in favor of
having typescript be a regular npm "dependency".
Noticed that we still say `Zeit` while using the now cli.
The inspect command still points to zeit.co when I tested it some hours ago but that seems to be fixed already 😄
This was switched to `npm` for debugging purposes in #4124, but at this
point we can switch it back to `yarn` so the tests don't take as long.
Co-authored-by: Leo Lamprecht <leo@zeit.co>
As a follow up to #4178, this fixes the final lint errors so we can run in CI.
Since lint is very quick, about 8 seconds, we can run it on the entire repo instead of only changed files.
I also disabled a couple rules that were leading to 500 warnings we would likely never change.
It's not useful information and distracts from whatever the actual error
message was from the dev server, which is what the user is actually
interested in.
This updates the error message shown when we fail to load the `routes-manifest` which appears to be happening most often when an incorrect output directory is configured for a Next.js application
Rather than creating a `builders.tar.gz` file with the core Runtimes and
bundling that tarball with Now CLI, simply have them be regular npm
dependencies so that they are installed into Now CLI's `node_modules`
directory.
When one of the core runtimes is specified for a build, the runtime will be
required as a regular module dependency of Now CLI, and the builders cache
will never touched.
Bundled runtimes are also no longer updated, making the runtime versions
pinned to the version of Now CLI.
Logic for the builders cache directory still remains, but will now only be
used when using a Community Runtime (or development tarball URL).
The previous file path for ncc isn't always reliable during development,
depending on which directory `yarn` is invoked in inside the monorepo.
Using `npx` ensures the version specified in the now-cli `package.json`
is used even if it's installed at the root of the monorepo.
When Now CLI 17 introduce the `.now` directory with project settings, it started assuming that the current project scope should be used for all commands. This made `now switch` do nothing unless you changed the current directory.
This PR is a _major_ semver change so that the only commands that inherit the project settings are:
- `now deploy`
- `now dev`
- `now env`
For example, `now ls` will not observe project settings and instead observe `now switch`.
`now dev` integration tests have been failing as of recently with failures to require Runtime builders from the builder cache. Upon investigation, it turns out that the `builders.tar.gz` file was not being completely extracted since the integration tests complete quickly and then kill the Now CLI process, which has not yet completed the extraction.
Fix is to ensure the tarball extraction promise is fully resolved before cleanly shutting down.
Also now applying the clean shutdown logic upon `SIGTERM` signal, which is what the integration tests send to shut down the Now CLI process.
After #4024 was merged, I tested and still got the same error. I searched around and found that the lines of code are in wrong order (ref: https://bugs.python.org/issue37521). So this is the proper fix.
Co-authored-by: Steven <steven@ceriously.com>
Stop downloading and caching `yarn` from GitHub Releases in `now dev`,
and instead simply rely on the user having `npm` installed. The user is
extremely likely to have `npm`, since Now CLI now requires `node` to be
installed (no longer using `pkg`) which comes with `npm` bundled by
default.
DRY and removes the `pid` from the set immediately so there's no race
condition if the server is shut down shortly after an HTTP request
(like in the tests).
Previously, when `package-lock.json` was detected, we would always use `npm install`.
This PR changes the behavior to the following:
- If only `package-lock.json` is detected, we use `npm install`.
- If both `package-lock.json` and `yarn.lock` are detected, use `yarn install`.
This will avoid npm bugs such as `npm ERR! Cannot read property 'match' of undefined`.
- Print an error instead of throwing when `destination` has segment not found in `source`
- Update docs to explain how to fix this error
- Add a couple tests
- Update uncaught `path-to-regexp` error message to print the full route that caused the error
This is an extension to the Runtime API, where a runtime can optionally define a `startDevServer()` function which is responsible for spawning a single-serve dev server for an individual HTTP request (the dev server is booted up upon receiving an HTTP request, and gets shut down by `now dev` after the HTTP request is completed). For runtimes that define this function, the `build()` function will never be executed, which avoids a lot of unnecessary processing for a dev environment.
Some things this accomplishes:
* Retains the proper stack trace for errors.
* Ensures that if a source code file is changed, and then an HTTP request is sent, it's guaranteed to be using the latest code (no file watching, or re-compilations).
* Avoids creating a Lambda zip file (just to immediately unpack it for dev).
* Avoids `@zeit/fun` completely, which loses some "correctness" (i.e. function is not frozen in between requests).
* Backwards compatible with older Now CLIs - versions that don't know about `startDevServer()` will just invoke `build()`, and there's no version change required in the Runtime.
The `runNpmInstall()` function is already a no-op when invoked via `now dev` (#2926), however the "Installing" message was still being printed, leading to confusion about whether or not they actually are (they're not).
This fixes the static 404 page not being used when deploying in a mono-repo structure. Before we weren't taking into account the `entryDirectory` where we needed to causing us to deploy `_error` when we didn't need to
x-ref: https://github.com/zeit/now/discussions/4077#discussioncomment-4625
The `public` directory was missing from the `ionic-react` example because we were ignoring all `public` directories.
This PR adds the public directory back (it is copied from now-static-build test fixtures). I also updated `.gitignore` and `.gitattributes` to be a little more friendly to our test fixtures so this doesn't happen again.
- Capitalize `Environment` in all outputs
- Fix stdin detection so there is no need for timeouts
- Dont throw if the error is bad user input, only throw for unexpected errors
- Fix tests so waiting for prompt will throw if expected output is never received
The latest `now env` subcommand no longer makes the distinction between build time and runtime environment variables so this PR updates `now dev` to no longer make the distinction either.
The only exception is that some builders such as `@now/next` might still rely on the separation so we must preserve the distinction for legacy builders.
This PR adds support for empty values when using `now env add|ls|rm|pull`.
This is necessary when using system environment variables such as `NOW_GITHUB_COMMIT_SHA` which will not receive a value from the user but will instead assign a value automatically during deployment.
Without this fix, Python app which uses [Pydantic](https://pydantic-docs.helpmanual.io/usage/postponed_annotations/) for data validation will crash with log like this:
```py
File "pydantic/main.py", line 175, in pydantic.main.ModelMetaclass.__new__
annotations = resolve_annotations(namespace.get('__annotations__', {}), namespace.get('__module__', None))
File "pydantic/typing.py", line 136, in pydantic.typing.resolve_annotations
annotations = resolve_annotations(namespace.get('__annotations__', {}), namespace.get('__module__', None))
File "pydantic/typing.py", line 136, in pydantic.typing.resolve_annotations
base_globals: Optional[Dict[str, Any]] = sys.modules[module_name].__dict__
KeyError: 'api.main'
```
The added code also follow Python official documentation: https://docs.python.org/3.6/library/importlib.html#importing-a-source-file-directly
This PR does a few things:
- Change `dev.unref()` when possible and use `testFixtureStdio` instead
- Replace `fetch()` with `fetchWithRetry()` when possible
- Remove commented-out tests
There was a bug preventing `continue: true` from working between (null => filesystem) phases.
This PR fixes that bug and adds a test to ensure users can rewrite to dynamic path segments.
This PR adds framework config for Ionic Angular and also updates a mistake found in the dev script of Ionic React, which mistakenly was using the same dev script as Stencil.
This PR adds a new command `now env` for managing environment variables for a given project. This will complement the changes in the Dashboard and will provide 3 possible environments: `production`, `preview`, and `development`.
- [x] Add `now env ls`
- [x] Add `now env add`
- [x] Add `now env rm`
- [x] Add `now env pull`
- [x] Add test for `now env ls`
- [x] Add test for `now env add`
- [x] Add test for `now env rm -y`
- [x] Add test for `now env pull -y`
- [x] Add test for `now env add FOO preview < secret.txt`
- [x] Add test deployment to verify env var is assigned to both build and runtime
- [x] Test on Windows
```
▲ now env [options] <command>
Commands:
ls [environment] List all variables for the specified environment
add [name] [environment] Add an environment variable (see examples below)
rm [name] [environment] Remove an environment variable (see examples below)
pull [filename] Read development environment from the cloud and write to a file [.env]
Options:
-h, --help Output usage information
-A FILE, --local-config=FILE Path to the local `now.json` file
-Q DIR, --global-config=DIR Path to the global `.now` directory
-d, --debug Debug mode [off]
-t TOKEN, --token=TOKEN Login token
Examples:
– Add a new variable to multiple environments
$ now env add <name>
$ now env add API_TOKEN
– Add a new variable for a specific environment
$ now env add <name> <production | preview | development>
$ now env add DB_CONNECTION production
– Add a new environment variable from stdin
$ cat <file> | now env add <name> <production | preview | development>
$ cat ~/.npmrc | now env add NPM_RC preview
$ now env add DB_PASS production < secret.txt
– Remove a variable from multiple environments
$ now env rm <name>
$ now env rm API_TOKEN
– Remove a variable from a specific environment
$ now env rm <name> <production | preview | development>
$ now env rm NPM_RC preview
```
Some inputs cause `compile()` to throw but its not clear which route caused it to fail.
> TypeError: Unexpected MODIFIER at 29, expected END [see source](https://sentry.io/organizations/zeithq/issues/1593291118/?project=1351065)
This PR adds logs so we can see the bad user input and correct accordingly.
Since enabling `CI` environment variable for cloud builds, this test fails because it is meant to emit a warning however that warning has turned into an error.
```
05:40:53.148 Treating warnings as errors because process.env.CI = true.
05:40:53.148 Most CI servers set it automatically.
05:40:53.148 Failed to compile.
05:40:53.149 ./src/App.js
05:40:53.149 Line 1: 'useState' is defined but never used no-unused-vars
05:40:53.172 error Command failed with exit code 1.
```
We can again treat lint errors as warnings by setting `CI=false`.
Example build output given a user's build script named `shouldfail.js`:
## Before
```
/zeit/4af70cdc/shouldfail.js:3
throw new Error('This is my failure')
^
Error: This is my failure
at Object.<anonymous> (/zeit/4af70cdc/shouldfail.js:3:7)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Exited with 1
at ChildProcess.<anonymous> (/zeit/687b1c64/.build-utils/node_modules/@now/build-utils/dist/index.js:31350:24)
at ChildProcess.emit (events.js:223:5)
at ChildProcess.EventEmitter.emit (domain.js:475:20)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
worker exited with code 20 and signal null
Done with "package.json"
```
## After
```
/zeit/255bfdd/shouldfail.js:3
throw new Error('This is my failure')
^
Error: This is my failure
at Object.<anonymous> (/zeit/255bfdd/shouldfail.js:3:7)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Command "yarn run build" exited with 1
worker exited with code 20 and signal null
Done with "package.json"
```
The current error message prints a link that is not clickable from the terminal.
This PR adds the missing `https://` protocol prefix, so that the link is clickable.
This fixes the error when attempting to add a secret with a hyphen and underscore such as the following:
```
$ now secret add name '-foo_bar'
Error! argv._.slice is not a function
```
As discussed this removes automatically adding path segments to redirect's destination query and only adds them if manually specified
x-ref: https://github.com/zeit/next.js/pull/11497
We already ignore specific files such as `node_modules` and `.env` during the upload phase so these never make it to the build. However, if those files are generated during the build, that are still emitted.
This PR will ignore these specific files even if they end up in the output directory (for example, when the user assigns `outputDirectory='.'` in project settings)
Somehow, PR #3973 broke Go since the bridge is imported from this repo's master branch.
Go has very strict file name constraints and the file `[...path].js` is not compatible.
Here's what a `@now/go` deployment error message looks like:
```
Error: Command failed: go mod tidy
go: finding github.com/zeit/now latest
go: downloading github.com/zeit/now v0.0.0-20200326223129-c91495338d5e
go: extracting github.com/zeit/now v0.0.0-20200326223129-c91495338d5e
-> unzip /tmp/5a0676f5/pkg/mod/cache/download/github.com/zeit/now/@v/v0.0.0-20200326223129-c91495338d5e.zip: malformed file path "packages/now-next/test/fixtures/22-ssg-v2-catchall/pages/[...path].js": double dot
handler imports
github.com/zeit/now/utils/go/bridge: unzip /tmp/5a0676f5/pkg/mod/cache/download/github.com/zeit/now/@v/v0.0.0-20200326223129-c91495338d5e.zip: malformed file path "packages/now-next/test/fixtures/22-ssg-v2-catchall/pages/[...path].js": double dot
```
The solution is to move Go Bridge into a separate repository: https://github.com/zeit/now-go-bridge
This will also have the side effect of speeding up Go imports because the repo will be much smaller.
@tootallnate's bug fix for `SIGHUB` on Windows has been merged and
published as `signal-exit@3.0.3`, so no more need for the "resolutions"
field in `package.json`.
The `yarn.lock` file has been updated accordingly.
When using a catch-all route at the base of the project it would cause it to be prioritized over any GS(S)P `/_next/data` routes. This fixes the order putting `/_next/data` routes first as they have higher specificity and adds tests to ensure we don't regress on this
Fixes an issue with a dependency that was bumped but typescript was pinned in `ionic-react`.
```
$ react-scripts build
Creating an optimized production build...
Failed to compile.
/zeit/333ecfab/node_modules/@types/testing-library__react/node_modules/pretty-format/build/index.d.ts
TypeScript error in /zeit/333ecfab/node_modules/@types/testing-library__react/node_modules/pretty-format/build/index.d.ts(7,13):
'=' expected. TS1005
5 | * LICENSE file in the root directory of this source tree.
6 | */
> 7 | import type * as PrettyFormat from './types';
| ^
8 | /**
9 | * Returns a presentation string of your `val` object
10 | * @param val any potential JavaScript object
error Command failed with exit code 1.
```
This PR does a few things:
- Separate tests into multiple workflows
- Rename a few package.json scripts to make naming consistent
- Rename workflows to be uppercase and jobs to be lowercase
The benefits here are:
- Restart a workflow if it fails, for example only restart `now dev` tests
- Easier to read when we need to understand a workflow or modify env vars
After merging, we'll need to modify the required checks in the repo settings.
We'll also need to update the cancel workflow (that will need to be a separate PR).
This updates the error message to offer action items when an ambiguous argument is provided.
## Before
```
Error! The supplied argument "secrets" is ambiguous. Both a directory and a subcommand are known
```
## After
```
Error! The supplied argument "secrets" is ambiguous.
If you wish to deploy the subdirectory "secrets", first run "cd secrets".
If you wish to use the subcommand "secrets", use "secret" instead.
```
- Change default version to Ruby `2.7.x` to match our static builds such as jekyll
- Detect ruby version in `Gemfile` in case the user wishes to downgrade to Ruby `2.5.x`
- Print nicer error message in `now dev`
cc @nathancahill @m5o
We recently updated the build image to add the necessary dependencies so that `puppeteer` can run during the build step.
This PR adds a test that takes a screenshot and prints metrics during a static build.
This is necessary to support `react-snap` (along with a few flags in `package.json`).
```json
{
"reactSnap": {
"puppeteerArgs": [
"--no-sandbox",
"--disable-setuid-sandbox"
]
}
}
```
- Fixes https://github.com/zeit/now-builders/issues/517
- Fixes#2357
https://zeit.atlassian.net/browse/PRODUCT-1380
This makes `now-next` consider the `node_modules/.bin` path if a custom build command was specified, which makes it work like `now-static-build`.
This PR updates API Errors to support the `error.link` property.
Unlike `error.slug` which is only a path to an error message, `error.link` contains the full URL.
### Example Output
```
$ now
Error! Serverless Functions.........etc
> More details: https://zeit.ink/...etc
```
This PR updates the way we run integration tests (the ones that create test deployments) so that it will be less likely to fail.
A couple side effects to this PR:
- To run the tests locally, you must set `NOW_TOKEN` env var (can be found in `~/.now/auth.json`).
- PRs from forked repos won't run tests because they now rely on a secret in GH Actions.
- A couple alias tests that require certs need to be disabled because they will fail.
[PRODUCT-2093]
[PRODUCT-2093]: https://zeit.atlassian.net/browse/PRODUCT-2093
"ESRCH" error means that the process is no longer running, and thus
already shut down. No need to throw in that case so just ignore the
error.
Fixes: https://sentry.io/organizations/zeithq/issues/1568104652
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Fixes test warnings from `jest-hast-map`:
```
[now-static-build] Running yarn test-integration-once
$ jest --env node --verbose --runInBand test/integration.test.js
jest-haste-map: Haste module naming collision: 12-create-react-app
The following files share their name; please adjust your hasteImpl:
* <rootDir>/test/fixtures/12-create-react-app/package.json
* <rootDir>/test/fixtures/26-ejected-cra/package.json
jest-haste-map: Haste module naming collision: gatsby-starter-default
The following files share their name; please adjust your hasteImpl:
* <rootDir>/test/fixtures/10-gatsby/package.json
* <rootDir>/test/fixtures/10-gatsby-without-build-script/package.json
jest-haste-map: Haste module naming collision: gohugo-default-theme
The following files share their name; please adjust your hasteImpl:
* <rootDir>/test/fixtures/31-hugo/themes/ananke/package.json
* <rootDir>/test/fixtures/46-hugo-with-framework/themes/ananke/package.json
jest-haste-map: Haste module naming collision: gohugo-default-styles
The following files share their name; please adjust your hasteImpl:
* <rootDir>/test/fixtures/31-hugo/themes/ananke/src/package.json
* <rootDir>/test/fixtures/46-hugo-with-framework/themes/ananke/src/package.json
jest-haste-map: Haste module naming collision: 47-nuxt-with-custom-output
The following files share their name; please adjust your hasteImpl:
* <rootDir>/test/fixtures/47-nuxt-with-custom-output/package.json
* <rootDir>/test/fixtures/48-nuxt-without-framework/package.json
```
Also increased test retry to 5.
These examples were using an old version of Bundler which didn't match our tests and would fail with:
```
/ruby27/lib/ruby/2.7.0/rubygems.rb:275:in `find_spec_for_exe': Could not find 'bundler' (1.17.2) required by your /zeit/6f4b9e46/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:1.17.2`
from /ruby27/lib/ruby/2.7.0/rubygems.rb:294:in `activate_bin_path'
from /ruby27/bin/bundle:23:in `<main>'
```
I ran `bundle update --bundler` in each of these directories and it only updated the version in `Gemfile.lock` because 2.x is mostly backwards compatible.
This PR improves the error message and prevents "An unexpected error occurred" when the token is invalid during a project link step.
I also added the `--token` option to `now dev --help` .
Lastly, I updated `now logout` to work correctly when the token is invalid.
- Fixes#3772
- Fixes#3786
This implements the new handles from https://github.com/zeit/now/pull/3876 to allow us to ensure the proper order for `rewrites`, `redirects`, and `headers` in Next.js. I also added in the tests from the Next.js [custom-routes test suite](https://github.com/zeit/next.js/tree/canary/test/integration/custom-routes) to ensure we're matching behavior.
To help keep track of what each probe is testing I added support for parsing the `now.json` files in `testDeployment` as [JSON5](https://www.npmjs.com/package/json5) to allow adding comments before each probe. If this is undesired I can remove this specific change even though it makes managing the fixture tests much easier
When running a framework like Create React App or Gridsome, the console gets cleared. This prevented the user from seeing the message printed from `now dev` which is typically `http://localhost:3000`. Instead the user would see the framework's URL such as `http://localhost:54684`.
See #3497 for an example.
The solution is to change the child process to pipe stdout/stderr. Since most frameworks detect [`process.stdout.isTTY`](7e6d6cd05f/packages/react-scripts/scripts/start.js (L141-L143)) before clearing the console, this will solve the problem. I was also able to intercept stdout to replace the framework's port with the `now dev` port and I think this will also help prevent confusion.
I also had to set `FORCE_COLOR=1` to avoid losing ANSI colors.
- Related to https://github.com/facebook/create-react-app/issues/2495
- Fixes#3497
When we ask the question "In which directory is your code located?" we were displaying a prefix of `cwd/` which is confusing because it seems like you are supposed to type in the current directory. It also doesn't match what is displayed in the Project Settings after it is deployed.
This changes the prefix to `./` so that `rootDirectory` is set to the current directory and the user can type in a subdirectory if they wish such as `./packages/web` for example.
### Before
```
? Set up and deploy “~/Code/app”? [Y/n] y
? Which scope do you want to deploy to? Testing
? Link to existing project? [y/N] n
? What’s your project’s name? app
? In which directory is your code located? app/
```
### After
```
? Set up and deploy “~/Code/app”? [Y/n] y
? Which scope do you want to deploy to? Testing
? Link to existing project? [y/N] n
? What’s your project’s name? app
? In which directory is your code located? ./
```
In PR #3847 we fixed a bug that prevented installing `devDependencies` when `NODE_ENV=production` this is typically what users want, but there are some cases where a user may wish to skip installing `devDependencies`. For example, if you have more than 500 MB worth of dependencies.
This PR introduces `NPM_ONLY_PRODUCTION=1` which can be used to skip installing `devDependencies` in these rare cases. It is the equivalent of `npm install --production` or `yarn install --production`. There is also `npm install --only=production` for which this new env var gets its name.
#### References
- https://docs.npmjs.com/cli/install
- https://classic.yarnpkg.com/en/docs/cli/install/#toc-yarn-install-production-true-false
In Now CLI 17 when Next.js is detected, the `next dev` command is proxied from `now dev`.
This brings Next.js into alignment as other other frameworks such as Gatsby and CRA. But those other frameworks are building static websites, so we were only passing build time env vars. However, Next.js needs runtime env vars for APIs in `/pages/api`.
So the solution is to special case until Next.js can read these files directly. See https://github.com/zeit/next.js/pull/10525Fixes#3758
This adds support for the new internal `handle` types `error` and `rewrite` and also updates the error messages to be more verbose since additional keys are allowed when using `handle: 'error'`.
This is needed so that we can implement utilize the new handles in `@now/next` for the new custom-routes support
This PR adds issue templates for common cases:
- Bug Report - to be submitted through the ZEIT Now support form.
- Feature Request - to be handled as a discussion between the community and ZEIT staff.
- Ask a Question - to be posted in Discussions for all to answer.
In addition to this, the PR also removes the Spectrum link from the README.
Fixes a regression in #3847 which was preventing the user from assigning `NODE_ENV`.
The root cause was that the spread operator (`...`) performs a shallow clone, not a deep clone. So we must perform another spread to clone the user-provided `env` object before deleting `NODE_ENV` during `npm install`.
The code coverage report stopped uploading after we switched to GitHub Actions because its not a recognized CI provider.
This PR adds a secret with the code coverage token from [codecov.io](https://codecov.io/gh/zeit/now/settings).
This PR changes the behavior of error reporting and metrics so that developers who build and run Now CLI locally won't accidentally report any metrics. It also prevents errors during CI tests from being reported.
The env vars are only assigned during the publishing step so that the official Now CLI hosted on npm is the only way to report metrics.
* add ruby ActiveSupport test fixture
> ActiveSupport is a Ruby module & a stand-alone component of Rails that includes additional functionality to core Ruby classes, like Array, String & Numeric.
🔗https://guides.rubyonrails.org/active_support_core_extensions.html
* add `Date.current + 10.years` calculation example
This fixes a bug in our `@now/build-utils` tests that pair the current build-utils with a stable builder. Since ncc was bundling `@now/build-utils`, we weren't able to configure a different version and these tests were not actually testing the correct version of build-utils.
A nice side-effect is that each builder will be about 50% smaller (compared by measuring `dist`).
* [now-next] Add Support for Prerender v2
* Copy test suite
* Test that fallback doesn't work for fallback: false
* record omitted lambdas
* Improve test case
* improve omitted routes logic
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Some build utilities and SSG Frameworks instruct users to set `NODE_ENV=production` which typically means updating `now.json` to the following:
```json
{
"build": {
"env": {
"NODE_ENV": "production"
}
}
}
```
The problem is that this environment variable is assigned during `npm install` or `yarn install` which is the equivalent of running install with the `--production` flag. This flag prevents `devDependencies` from installing. This is almost never what the user intends so they have to remove `now.json` and instead updating their build script to `NODE_ENV=production yarn build`.
This PR improves the experience by deleting `NODE_ENV` during the install step.
This PR fixes `@now/routing-utils` when the input routes are null. It used to return the empty array but now it will still append.
I also added many more tests to `@now/build-utils` when `featureHandleMiss: true` and refactored the code a bit to make dynamic routes and api routes a little more clear.
This PR refactors the rewrites (the dynamic routes as well as the route that prevents directory listing for zero config deployments) so they are not in the `handle: miss` phase.
This is necessary because the behavior of `handle: miss` will change in an upcoming release.
The solution is to separate these into `rewriteRoutes` that can then be merged properly with the user's routes. They will be appended to the `handle: filesystem` phase (or add the phase if it doesn't exist).
* [now-cli] Remove v1 "static build" integration tests
These are the last remaining v1 static type deployments being created.
* Remove from `integration.js` as well
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
There was a bug in `now-client` when deploying a directory that ends with a slash, for example `/Users/styfle/Code/myapp/` instead of the usual `/Users/styfle/Code/myapp`.
This never affected `now-cli` until we added support for defining the `rootDirectory` which allows the user to type whatever they wish in the Project Settings.
The fix is to use `path.relative()` instead of substring.
The combination of file renaming and brackets doesn't work well for go build so we need to add the file extension back before building.
I also simplified the `.now/cache/folder` logic because it should be the same whether `builds` is defined or not (aka zero config).
The combination of file renaming and brackets doesn't work well for python imports so we need too add the file extension back before importing the python module.
I also simplified the `.now/cache/folder` logic because it should be the same whether `builds` is defined or not (aka zero config).
This updates to not pass segments already used in a redirect's destination query since these values are most likely unwanted and can still be manually added if desired. This change does not affect rewrites and we still pass through all segments in the query
This adds handling for treating `pages/404.js` as the custom error page in Next.js to allow for more flexible auto static optimization on the 404 page. This makes sure we handle `pages/404.js` being a lambda due to `_app` having `getInitialProps` and also makes sure that visiting `/404` doesn't respond with a 200 status code
~We can add tests for this behavior after the below PR has been released in a canary of Next.js~
x-ref: https://github.com/zeit/next.js/pull/10329
x-ref: https://github.com/zeit/next.js/pull/10593
Bumps [codecov](https://github.com/codecov/codecov-node) from 3.1.0 to 3.6.5.
<details>
<summary>Release notes</summary>
*Sourced from [codecov's releases](https://github.com/codecov/codecov-node/releases).*
> ## v3.6.4
> Fix for Cirrus CI
>
> ## v3.6.3
> AWS Codebuild fixes + package updates
>
> ## v3.6.2
> command line args sanitised
>
> ## v3.6.1
> Fix for Semaphore
>
> ## v3.6.0
> AWS CodeBuild
> Semaphore v2
>
> ## v3.3.0
> Added pipe `--pipe`, `-l`
</details>
<details>
<summary>Commits</summary>
- See full diff in [compare view](https://github.com/codecov/codecov-node/commits)
</details>
<details>
<summary>Maintainer changes</summary>
This version was pushed to npm by [drazisil](https://www.npmjs.com/~drazisil), a new releaser for codecov since your current version.
</details>
<br />
[](https://help.github.com/articles/configuring-automated-security-fixes)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/zeit/now/network/alerts).
</details>
When testing, you can set `NOW_BUILDER_DEBUG=1` to print verbose logs from builders.
However, this was causing some tests to fail that depended on a build environment variable.
This PR fixes the assignment so that it preserves the environment variables from the tests by adding `NOW_BUILDER_DEBUG` instead of replacing.
This handles an edge case where deeply nested dynamic routes were handling `_next` 404s that were cached forever since the immutable header we set isn't cleared after not matching on the filesystem.
I updated our cache-header fixture to check for this edge case also to make sure we don't regress on this
Some users wish to put all Go related code in the `/api` directory and the root is reserved for a frontend framework.
This PR adds support for `/api/go.mod` which will act the same as `/go.mod` by moving the file to the root.
This adds support for using the fallback file for dynamic (lazy) SSG pages to allow showing a loading state while the cache is populated with data. We can add tests for this behavior once the below referenced PR is shipped on canary
x-ref: https://github.com/zeit/next.js/pull/10424
~Update: added tests now that fallback support has landed in Next.js although it appears `now-proxy` might need to be updated to revalidate the fallback correctly since the initial fallback is always being shown for lazy SSG pages with these changes~
Looks like this is working properly in `now-proxy` and we were overriding the prerender output with the static page output, thanks @juancampa for helping investigate! 🙏
Previously, `@now/go` would fail when using [Path Segments](https://zeit.co/docs/v2/serverless-functions/introduction#path-segments) since `go build` [doesn't support](https://stackoverflow.com/q/60140859/266535) files that begin with square bracket.
This PR changes the build logic so that the entrypoint file is renamed if if begins with a square bracket.
The output file is not renamed because v3 builders can't rename outputs which works great for this feature.
This adds initial support for Windows in GitHub Actions CI tests.
There is still work to be done to prevent certain tests from hanging in CI so those are skipped for now.
We used to require a `package.json` but we have since introduced [Advanced Project Settings](https://zeit.co/blog/advanced-project-settings) which will ask the user for a build command during the first deploy.
Updates go to the latest version 1.13.7 (https://golang.org/doc/devel/release.html#go1.13). This allows users to use the new error functionality that was introduced in go 1.13 (https://blog.golang.org/go1.13-errors) and also includes a couple of security fixes.
Looking at the last PR that updated the version (https://github.com/zeit/now-builders/pull/247/files) this should be as simple as updating the version number.
P.S. I tried to follow the contribution guidelines, but `yarn lint` fails with `exit code 1`/`295 problems (33 errors, 262 warnings)` and `yarn test` returns `error Command "test" not found` on master. But `yarn test-unit` shows no errors.
* [now-cli] Consider root directory for now.json
* Adjust message check in test
* Fallback if config does not exist as well
* Assign localConfig later and add debug
* Prefere now.json from root directory
* Comment
* Adjust test and add warning
This fixes a regression from #3749 where the PORT env var was removed. This is necessary so frameworks like create-react-app and gatsby can proxy to `now dev`.
Fixes#3761
Previously, the changelog script was looking for the last "Publish Stable" commit, but it should really be looking for the last Stable release of Now CLI.
This PR updates the changelog script so that it fetches the latest GH Release (which should be Now CLI) and then compares that to the HEAD.
This PR changes the behavior of `trailingSlash: true` after we received feedback that files should not be redirected with a trailing slash. This matches the behavior of `serve` and `serve-handler`.
### Examples
* `/index.html` => serve
* `/assets/style.css` => serve
* `/assets` => redirect to `/assets/`
* `/assets/style` => redirect to `/assets/style/`
### Additional
In order to avoid duplicate content, this PR also adds redirects to files without a trailing slash.
* `/about.html/` => redirect to `/about.html`
* `/assets/style.css/` => redirect to `/assets/style.css`
Fixes#3731
* use npx when available
* add --no-install
* replace $PORT and %PORT% in devCommand
* remove PORT from env variables
* replace more than one $PORT or %PORT%
* fix regex
The Hugo theme was lost when transferring from `zeit/now-examples` to `zeit/now`.
This PR fixes the `.gitignore` file to include the `dist` directory and override our root `.gitignore`.
* do not prompt for root directory when linked
* run tests
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Leo Lamprecht <mindrun@icloud.com>
Typically, Go tests are side-by-side with their source files in a `_test.go`.
The Go documentation says the following:
> To write a new test suite, create a file whose name ends _test.go that contains the TestXxx functions as described here. Put the file in the same package as the one being tested. The file will be excluded from regular package builds but will be included when the “go test” command is run. [View Docs](https://golang.org/pkg/testing/)
This PR excludes the test files from being turned into Serverless Functions.
This PR is a follow up to #3703 which fixes file output renaming on initial boot but not when files are added or removed while `now dev` is running. This PR fixes that behavior.
Fixes GH pull request auto-lint:
> #### Check warning on line 2 in `packages/now-cli/src/util/input/input-root-directory.ts`:
>
> ## GitHub Actions / Unit Tests (ubuntu-latest, 12)
>
> `packages/now-cli/src/util/input/input-root-directory.ts#L2`
>
> ```
> 'fs' is defined but never used
> ```
This PR adds a `config.excludeFiles` pattern for `@now/python` that defaults to `node_modules/**` for users who are using a Node.js SSG frontend with Python APIs backend.
If the user chooses, they can override to any glob pattern such as `{.cache,node_modules}/**`.
Related to #2830
Related to #3416
There was a bug where python src files were being renamed when it really should be the output files only.
This is a tricky bug because production deployments build all files first and then perform routing. So we simply rename lambda outputs with prod deployments. But `now dev` matches a request URL to a build before performing the build lazily so we have to rename source files.
The solution is to add both the original file name and the renamed file name in the `files` map so that it matches correctly but `zeit/fun` will still copy the original source files in the output correctly.
Routing will match on the extensionless file, the builder will use the file with extension (it doesn't know about file renaming), then the build results in a lambda output which is renamed to extensionless.
I added a test for `@now/python` and updated the `@now/bash` test.
Fixes#3638
* [now-cli] Add support for the `rootDirectory` property
* Only check if rootDirectory exists
* Add test
* Support now dev
* Use defaults
* Comment
* Normalize the path input
* Adjust test
* Remove .only
* Adjust more tests
* Adjust test
* Fix test
* Remove unused import
* Update packages/now-cli/src/util/validate-paths.ts
Co-Authored-By: Luc <luc.leray@gmail.com>
* Run check on normalized path
* Add more checks
* Change error message
* Use basename as prefix
* Use correct path when linking
* Update packages/now-cli/src/util/input/input-root-directory.ts
Co-Authored-By: Luc <luc.leray@gmail.com>
Co-authored-by: Luc <luc.leray@gmail.com>
* [tests] Run unit tests on ubuntu and macos
* Add back Node 10 for Now CLI Tests
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This enables case sensitive rewrites and redirects. It also changes the delimiter to `/` to match Next.js.
Unlike `routes` which were case insensitive, `rewrites` and `redirects` are case sensitive.
In the future, we may wish to add an option to toggle the sensitivity.
* use .now scope for commands
* add cache to getUser
* add cache on getTeams
* add cache for link
* refactor
* add error if NOW_ORG_ID is missing
* remove link cache
* refactor
* fix whoami
* add tests
* move fetching scope/org after subcommand condition
* Update packages/now-cli/src/util/projects/link.ts
Co-Authored-By: Andy <AndyBitz@users.noreply.github.com>
* remove userId from global scope
* show team and user in whoami command
* reset whoami
* Revert "move fetching scope/org after subcommand condition"
This reverts commit d145e6164074fe2442178cd8fafbeb225c978b9c.
* remove `client` from main scope
* tests adjustments
* adjust tests
* adjust tests (bis)
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This PR changes the behavior so that `:segment` in the `source` is always added to the query string unless the `destination` query string already contains a key with the same name.
* deprecate uploading files instead of erroring
* fix misc bugs
* remove final `.`
* add test
* check .now folder does not exist in test
* clean up after test
Deployments no longer support Node 8 since reaching EOL so we can also drop all of the special casing used to support Node 8 in Now CLI and Now Client.
The `tsconfig.json` has been updated to ES2018 per [Node-Target-Mapping](https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping).
* Checkout master on master
* Check if checkout works
* Revert "Check if checkout works"
This reverts commit 66f712a43edfb938c551110c214661e4a920b492.
* Revert "Checkout master on master"
This reverts commit 41b6eab926474830629e758a51e7cfdd1947bdf2.
* Use --depth=10
* Add another fetch
* Initial Build step
* Typo
* Remove circleci config
* Fix command
* Change Node version
* Add unit tests
* Use artifact
* Fix workflow file
* Remove node_modules
* Remove .git
* Do not upload files
* Checkout master branch
* Use git fetch
* Add now-dev tests
* Fix workflow file
* Use node10 for building
* Use node12 for building
* Download Hugo before building
* Fetch master branch
* Do not cancel other jobs when one fails
* Add all tests
* Remove needs
* Add build step
* Move test up
* Use isCanary function and remove tests
* Update Publish workflow
* Update .github/workflows/continuous-integration.yml
Co-Authored-By: Steven <steven@ceriously.com>
* Specify more events
* Add publish.sh script
* Remove Node8
Co-authored-by: Steven <steven@ceriously.com>
* [now-client][now-cli] Remove builds check from now-client
* [now-client] Adjust README and change version
* Change events and adjust build error
* Use message from error
* Update packages/now-cli/src/util/deploy/process-deployment.ts
Co-Authored-By: Luc <luc.leray@gmail.com>
* [now-cli] Rename event
* Make types more consistent
* Fix type in process-legacy-deployment
* Adjust type in test
* Update type
* Make events type simpler
Co-authored-by: Max <8418866+rdev@users.noreply.github.com>
Co-authored-by: Luc <luc.leray@gmail.com>
This PR a regression when path segments are used in the query string.
Take a look at the following ASCII Table for why I had to delete certain parts of the parsed url before formatting again.
https://nodejs.org/api/url.html#url_url_strings_and_url_objects
Related to #3539
This adds support for `headers` in custom-routes which was landed in Next.js.
This also updates `@now/routing-utils` `convertHeaders` to call `sourceToRegex` to match behavior with Next.js and allow using `segments` to match in the header `source` as not being able to use the same syntax for a header `source` as a `redirect` source could get confusing
This is required to match custom-routes behavior in Next.js by checking dynamic routes after each rewrite although is currently blocked on `now dev` also supporting the feature
This reverts commit 0da98a7f5d.
- [x] Add tests from now-proxy for `handle: miss`
- [x] Add tests from now-proxy for `handle: hit`
- [x] Add file output renaming when `featHandleMiss` is true (also assign true for now dev)
This adds initial support for static 404 pages when enabled for Next.js applications > `9.2.1-canary.3` it also disables tracing/logging related to lambdas when there aren't any lambdas besides the `_error` when a static 404 is being used
Closes: #3368
I was getting errors when running `yarn build` locally because the public directory already exists.
This will make sure the public directory is deleted before generating it again.
This adds `permanent: boolean` to the redirects in the custom-routes tests for `@now/next` since this field is required for redirects in Next.js in the latest version
unblocks: https://github.com/zeit/now/pull/3613
This PR adds `NOW_PROJECT_ID` and `NOW_ORG_ID` environment variables as a way to specify a project to deploy to when running `now`.
eg.
```
NOW_ORG_ID=abc NOW_PROJECT_ID=123 now
```
When using these environment variables:
- the folder is not linked to the project (ie. no `.now` is created)
- we interrupt the process and show an error message if the project is not found:

Since v2 deployments are auto-assigned aliases, render as such to match more closely to the v2 pipeline when a static deployments was implicitly upgraded to the v2 platform.
* [api] Add Sentry
* Use function name
* Add test error
* Revert "Add test error"
This reverts commit 39cf8a61dad9fcdcb616e418a0deb6ffe9e04ea9.
* Revert "Revert "Add test error""
This reverts commit c718f201da9d80743319ac87e0d4560e718fff53.
* Add logging
* Revert "Add logging"
This reverts commit 39cd46c8bbeef9024e71fe70478068480a51545b.
* Revert "Revert "Revert "Add test error"""
This reverts commit e6f63ee21fabb4ac8fc065b74281dbcdf5811216.
* Ignore .env
* Use init function for Sentry inline
* Print warnings / notices from the API
* Print `v2` instead of `v1` when upgraded to v2
* Wait for "alias-assigned" event in v1 pipeline when upgraded to v2
This PR updates the framework auto-detection flow in `deploy` command to not show "overwrite project settings?" prompt when the API returns a `framework` property that is `null`.
In a previous release, we pinned the node version to the project so that we could upgrade new projects to a newer version of Node.js while maintaining backwards compatibility with existing projects.
This puts some burden on the user when they're deployment is a year old and their pinned version of Node reaches EOL. Because we currently force the user to add a package.json.
This PR changes the behavior so projects are no longer pinned. Instead, newer deployments get the latest Node unless they opt-in and pin via package.json.
* fix "in your organization"
* add feedback link to canary version prompt
* `Detecting framework` -> `Setting up project`
* "Auto-detect project settings (<framework>)"
* "What’s your project’s name?"
* ✅ -> ☑️
* "organizations" -> "scope"
* always show feedback prompt for `now dev`
* dim feedback prompt
* [now-build-utils] Error for unused `functions`
* Update packages/now-build-utils/src/detect-builders.ts
Co-Authored-By: Steven <steven@ceriously.com>
Co-authored-by: Steven <steven@ceriously.com>
This behavior is legacy from the very early days of `now dev`
(before the `files` array was returned from Runtimes) and adds
complexity. We can remove it at this point to simplify dev server.
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
Co-authored-by: Leo Lamprecht <mindrun@icloud.com>
* Revert "[frameworks] Fix import in test (#3570)"
This reverts commit 9ee86df69d.
* Revert "[frameworks] Rename frameworks to now-frameworks (#3569)"
This reverts commit daa5cbdd4b.
This PR fixes an issue where certain patterns caused `path-to-regexp` to throw when it should be returning an error object. The fix is to make sure all inputs work properly with `path-to-regexp` before continuing.
While migrating redirects on `/docs` I noticed we don't update segments in the `hash` of the destination. This updates to also handle these segments and adds a test for this behavior
* Add API for frameworks and examples
* Adjust headers
* Update frameworks list
* Always use latest
* Add types
* Use now repo for downloading and listing
* Use .existsSync
* Remove unused packages
* Use 307 for redirect
* Add examples
* Update tsconfig.json
Co-Authored-By: Steven <steven@ceriously.com>
* Make examples unique
* Remove detectors from frameworks API
* Use /api instead of Next.js
* Install dependencies
* Rename project
* Change name
* Empty
* Change name
* Update api/tsconfig.json
Co-Authored-By: Steven <steven@ceriously.com>
* Update examples
Co-authored-by: Steven <steven@ceriously.com>
This PR will use the system installed version of Node.js and avoid printing a warning or error if a discontinued version is selected.
This optimization was already in `@now/node` but for some reason it was never add to `@now/next`.
The reason why its relevant today is because the warnings turned into errors due to Node 8 deprecation and we don't have the "Project" in `now dev` so we don't know which version of node to select.
So instead of determining the version, `now dev` will always use `node` in the PATH and avoid printing warnings or errors. This also results in less FS reads since we no longer need to read package.json.
There was a regression with framework detection that was preferring the frameworks output directory instead of the `distDir` defined in the `@now/static-build`.
The fix is to only run framework detection when `builds` is not defined (ie zero config).
Related to https://github.com/Ebury/chameleon/pull/63
This extends the behavior of `featHandleMiss: true` flag to do the following:
- Reduce zero config API routes so that only dynamic path segment files (`api/[id].js`) get a route.
- Remove zero config out directory route (`public/`)—the files will be renamed instead.
- Use redirects for API routes when `cleanUrls: true` and use rewrites when `cleanUrls: false` from extension to the extension-less file.
- Normalize existing routes to begin with `^` and end with `$`.
This PR does the following
- Add and export class, `NowBuildError`, that can be thrown to stop the build and print an error but it will not print a stack trace.
- Improve logic for discontinued node versions and add more tests
- Remove hack (#3425) for undefined TERM, fixed by updating dependencies
- Rename `silent` variable to `isAuto` which means the node version was automatically selected, not defined in `package.json`
- Rename `test` deployments to `test2020` so that a fresh project is created with latest Node.js 12.x
We want to take advantage of the better defaults and retry policies (among others).
This bumps `@zeit/fetch` and replaces `node-fetch` with `@zeit/fetch` in `now-client`.
Also update retry policy for "uploading" files to:
- base 10ms
- 5 retries
- factor 6
which means the timeouts are 10, 60, 360, 2160, 12960
2020-01-06 09:01:17 +00:00
4595 changed files with 482680 additions and 296718 deletions
When contributing to this repository, please first discuss the change you wish to make via [GitHub Discussions](https://github.com/vercel/vercel/discussions/new) with the owners of this repository before submitting a Pull Request.
Please read our [Code of Conduct](CODE_OF_CONDUCT.md) and follow it in all your interactions with the project.
## Local development
This project is configured in a monorepo, where one repository contains multiple npm packages. Dependencies are installed and managed with `yarn`, not `npm` CLI.
To get started, execute the following:
```
git clone https://github.com/vercel/vercel
yarn install
yarn bootstrap
yarn build
yarn lint
yarn test
```
Make sure all the tests pass before making changes.
## Verifying your change
Once you are done with your changes (we even suggest doing it along the way), make sure all the test still run by running:
```
yarn build && yarn test
```
from the root of the project.
If any test fails, make sure to fix it along with your changes. See [Interpreting test errors](#Interpreting-test-errors) for more information about how the tests are executed, especially the integration tests.
## Pull Request Process
Once you are confident that your changes work properly, open a pull request on the main repository.
The pull request will be reviewed by the maintainers and the tests will be checked by our continuous integration platform.
## Interpreting test errors
There are 2 kinds of tests in this repository – Unit tests and Integration tests.
Unit tests are run locally with `jest` and execute quickly because they are testing the smallest units of code.
### Integration tests
Integration tests create deployments to your Vercel account using the `test` project name. After each test is deployed, the `probes` key is used to check if the response is the expected value. If the value doesn't match, you'll see a message explaining the difference. If the deployment failed to build, you'll see a more generic message like the following:
```
[Error: Fetched page https://test-8ashcdlew.vercel.app/root.js does not contain hello Root!. Instead it contains An error occurred with this application.
NO_STATUS_CODE_FRO Response headers:
cache-control=s-maxage=0
connection=close
content-type=text/plain; charset=utf-8
date=Wed, 19 Jun 2019 18:01:37 GMT
server=now
strict-transport-security=max-age=63072000
transfer-encoding=chunked
x-now-id=iad1:hgtzj-1560967297876-44ae12559f95
x-now-trace=iad1]
```
In such cases you can visit the URL of the failed deployment and append `/_logs` so see the build error. In the case above, that would be https://test-8ashcdlew.vercel.app/_logs
The logs of this deployment will contain the actual error which may help you to understand what went wrong.
### @vercel/nft
Some of the Builders use `@vercel/nft` to tree-shake files before deployment. If you suspect an error with this tree-shaking mechanism, you can create the following script in your project:
```js
const{nodeFileTrace}=require('@vercel/nft');
nodeFileTrace(['path/to/entrypoint.js'],{
ts:true,
mixedModules:true,
})
.then(o=>console.log(o.fileList))
.then(e=>console.error(e));
```
When you run this script, you'll see all imported files. If anything file is missing, the bug is in [@vercel/nft](https://github.com/vercel/nft) and not the Builder.
## Deploy a Builder with existing project
Sometimes you want to test changes to a Builder against an existing project, maybe with `vercel dev` or an actual deployment. You can avoid publishing every Builder change to npm by uploading the Builder as a tarball.
1. Change directory to the desired Builder `cd ./packages/node`
2. Run `yarn build` to compile typescript and other build steps
3. Run `npm pack` to create a tarball file
4. Run `vercel *.tgz` to upload the tarball file and get a URL
5. Edit any existing `vercel.json` project and replace `use` with the URL
6. Run `vercel` or `vercel dev` to deploy with the experimental Builder
This directory is a brief example of a [Name](site-link) site that can be deployed to Vercel with zero configuration.
## Deploy Your Own
Deploy your own [Name] project with Vercel.
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/example-directory)
### How We Created This Example
To get started with [Name] on Vercel, you can use the [CLI Tool Used](CLI-link) to initialize the project:
```shell
$ vercel init [Name]]
```
### Deploying From Your Terminal
Once initialized, you can deploy the [Name] example with just a single command:
When contributing to this repository, please first discuss the change you wish to make via [GitHub Issue](https://github.com/zeit/now/issues/new) or [Spectrum](https://spectrum.chat/zeit) with the owners of this repository before submitting a Pull Request.
Please read our [code of conduct](CODE_OF_CONDUCT.md) and follow it in all your interactions with the project.
## Local development
This project is configured in a monorepo pattern where one repo contains multiple npm packages. Dependencies are installed and managed with `yarn`, not `npm` CLI.
To get started, execute the following:
```
git clone https://github.com/zeit/now
yarn install
yarn bootstrap
yarn build
yarn lint
yarn test
```
Make sure all the tests pass before making changes.
## Verifying your change
Once you are done with your changes (we even suggest doing it along the way ), make sure all the test still run by running
```
yarn build && yarn test
```
from the root of the project.
If any test fails, make sure to fix it along with your changes. See [Interpreting test errors](#Interpreting-test-errors) for more information about how the tests are executed, especially the integration tests.
## Pull Request Process
Once you are confident that your changes work properly, open a pull request on the main repository.
The pull request will be reviewed by the maintainers and the tests will be checked by our continuous integration platform.
## Interpreting test errors
There are 2 kinds of tests in this repository – Unit tests and Integration tests.
Unit tests are run locally with `jest` and execute quickly because they are testing the smallest units of code.
### Integration tests
Integration tests create deployments to your ZEIT account using the `test` project name. After each test is deployed, the `probes` key is used to check if the response is the expected value. If the value doesn't match, you'll see a message explaining the difference. If the deployment failed to build, you'll see a more generic message like the following:
```
[Error: Fetched page https://test-8ashcdlew.now.sh/root.js does not contain hello Root!. Instead it contains An error occurred with this application.
NO_STATUS_CODE_FRO Response headers:
cache-control=s-maxage=0
connection=close
content-type=text/plain; charset=utf-8
date=Wed, 19 Jun 2019 18:01:37 GMT
server=now
strict-transport-security=max-age=63072000
transfer-encoding=chunked
x-now-id=iad1:hgtzj-1560967297876-44ae12559f95
x-now-trace=iad1]
```
In such cases you can visit the URL of the failed deployment and append `/_logs` so see the build error. In the case above, that would be https://test-8ashcdlew.now.sh/_logs
The logs of this deployment will contain the actual error which may help you to understand what went wrong.
### @zeit/node-file-trace
Some of the Builders use `@zeit/node-file-trace` to tree-shake files before deployment. If you suspect an error with this tree-shaking mechanism, you can create the following script in your project:
```js
consttrace=require('@zeit/node-file-trace');
trace(['path/to/entrypoint.js'],{
ts:true,
mixedModules:true,
})
.then(o=>console.log(o.fileList))
.then(e=>console.error(e));
```
When you run this script, you'll see all imported files. If anything file is missing, the bug is in [@zeit/node-file-trace](https://github.com/zeit/node-file-trace) and not the Builder.
## Deploy a Builder with existing project
Sometimes you want to test changes to a Builder against an existing project, maybe with `now dev` or an actual deployment. You can avoid publishing every Builder change to npm by uploading the Builder as a tarball.
1. Change directory to the desired Builder `cd ./packages/now-node`
2. Run `yarn build` to compile typescript and other build steps
3. Run `npm pack` to create a tarball file
4. Run `now *.tgz` to upload the tarball file and get a URL
5. Edit any existing `now.json` project and replace `use` with the URL
6. Run `now` or `now dev` to deploy with the experimental Builder
The following page is a reference for how to create a Runtime using the available Runtime API.
The following page is a reference for how to create a Runtime by implementing
the Runtime API interface.
A Runtime is an npm module that exposes a `build` function and optionally an `analyze` function and `prepareCache` function.
Official Runtimes are published to [npmjs.com](https://npmjs.com) as a package and referenced in the `use` property of the `now.json` configuration file.
However, the `use` property will work with any [npm install argument](https://docs.npmjs.com/cli/install) such as a git repo url which is useful for testing your Runtime.
A Runtime is an npm module that implements the following interface:
See the [Runtimes Documentation](https://zeit.co/docs/runtimes) to view example usage.
The `version` property and the `build()` function are the only _required_ fields.
The rest are optional extensions that a Runtime _may_ implement in order to
enhance functionality. These functions are documented in more detail below.
Official Runtimes are published to [the npm registry](https://npmjs.com) as a package and referenced in the `use` property of the `vercel.json` configuration file.
> **Note:** The `use` property in the `builds` array will work with any [npm
> install argument](https://docs.npmjs.com/cli/install) such as a git repo URL,
> which is useful for testing your Runtime. Alternatively, the `functions` property
> requires that you specify a specifc tag published to npm, for stability purposes.
See the [Runtimes Documentation](https://vercel.com/docs/runtimes) to view example usage.
## Runtime Exports
@@ -16,146 +39,170 @@ A **required** exported constant that decides which version of the Runtime API t
The latest and suggested version is `3`.
### `analyze`
**Example:**
An **optional** exported function that returns a unique fingerprint used for the purpose of [build de-duplication](https://zeit.co/docs/v2/advanced/concepts/immutability#deduplication-algorithm). If the `analyze` function is not supplied, a random fingerprint is assigned to each build.
```js
exportanalyze({
files:Files,
entrypoint:String,
workPath:String,
config:Object
}):Stringfingerprint
```typescript
exportconstversion=3;
```
If you are using TypeScript, you should use the following types:
### `build()`
```ts
import{AnalyzeOptions}from'@now/build-utils'
A **required** exported function that returns a Serverless Function.
exportanalyze(options: AnalyzeOptions){
return'fingerprint goes here'
> What's a Serverless Function? Read about [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) to learn more.
// Create a mapping of file names and `File` object instances to cache here…
return{
output:{
'path-to-file':File,
'path-to-lambda':Lambda
},
watch:[],
routes:{}
}
'path-to-file':File,
};
}
```
### `prepareCache`
### `shouldServe()`
An **optional** exported function that is equivalent to [`build`](#build), but it executes the instructions necessary to prepare a cache for the next run.
An **optional** exported function that is only used by `vercel dev` in [Vercel
CLI](https://vercel.com/download) and indicates whether a
[Runtime](https://vercel.com/docs/runtimes) wants to be responsible for responding
to a certain request path.
```js
prepareCache({
files:Files,
entrypoint:String,
workPath:String,
cachePath:String,
config:Object
}):FilescacheOutput
```
**Example:**
If you are using TypeScript, you can import the types for each of these functions by using the following:
// Determine whether or not the Runtime should respond to the request path here…
exportprepareCache(options: PrepareCacheOptions){
return{'path-to-file':File}
returnoptions.requestPath===options.entrypoint;
}
```
### `shouldServe`
If this function is not defined, Vercel CLI will use the [default implementation](https://github.com/vercel/vercel/blob/52994bfe26c5f4f179bdb49783ee57ce19334631/packages/now-build-utils/src/should-serve.ts).
An **optional** exported function that is only used by `now dev` in [Now CLI](https:///download) and indicates whether a [Runtime](https://zeit.co/docs/v2/advanced/runtimes) wants to be responsible for building a certain request path.
### `startDevServer()`
```js
shouldServe({
entrypoint:String,
files:Files,
config:Object,
requestPath:String,
workPath:String
}):Boolean
```
An **optional** exported function that is only used by `vercel dev` in [Vercel
CLI](https://vercel.com/download). If this function is defined, Vercel CLI will
**not** invoke the `build()` function, and instead invoke this function for every
HTTP request. It is an opportunity to provide an optimized development experience
rather than going through the entire `build()` process that is used in production.
If you are using TypeScript, you can import the types for each of these functions by using the following:
This function is invoked _once per HTTP request_and is expected to spawn a child
process which creates an HTTP server that will execute the entrypoint code when
an HTTP request is received. This child process is _single-serve_ (only used for
a single HTTP request). After the HTTP response is complete, `vercel dev` sends
a shut down signal to the child process.
```ts
import{ShouldServeOptions}from'@now/build-utils'
The `startDevServer()` function returns an object with the `port` number that the
child process' HTTP server is listening on (which should be an [ephemeral
port](https://stackoverflow.com/a/28050404/376773)) as well as the child process'
Process ID, which `vercel dev` uses to send the shut down signal to.
exportshouldServe(options: ShouldServeOptions){
returnBoolean
> **Hint:** To determine which ephemeral port the child process is listening on,
> some form of [IPC](https://en.wikipedia.org/wiki/Inter-process_communication) is
> required. For example, in `@vercel/go` the child process writes the port number
> to [_file descriptor 3_](https://en.wikipedia.org/wiki/File_descriptor), which is read by the `startDevServer()` function
> implementation.
It may also return `null` to opt-out of this behavior for a particular request
// In this example, the child process will write the port number to FD 3…
constportPipe=child.stdio[3];
constchildPort=awaitnewPromise(resolve=>{
portPipe.setEncoding('utf8');
portPipe.once('data',data=>{
resolve(Number(data));
});
});
return{pid: child.pid,port: childPort};
}
```
If this method is not defined, Now CLI will default to [this function](https://github.com/zeit/now/blob/52994bfe26c5f4f179bdb49783ee57ce19334631/packages/now-build-utils/src/should-serve.ts).
### Runtime Options
The exported functions [`analyze`](#analyze), [`build`](#build), and [`prepareCache`](#preparecache) receive one argument with the following properties.
**Properties:**
-`files`: All source files of the project as a [Files](#files) data structure.
-`entrypoint`: Name of entrypoint file for this particular build job. Value `files[entrypoint]` is guaranteed to exist and be a valid [File](#files) reference. `entrypoint` is always a discrete file and never a glob, since globs are expanded into separate builds at deployment time.
-`workPath`: A writable temporary directory where you are encouraged to perform your build process. This directory will be populated with the restored cache from the previous run (if any) for [`analyze`](#analyze) and [`build`](#build).
-`cachePath`: A writable temporary directory where you can build a cache for the next run. This is only passed to `prepareCache`.
-`config`: An arbitrary object passed from by the user in the [Build definition](#defining-the-build-step) in `now.json`.
## Examples
Check out our [Node.js Runtime](https://github.com/zeit/now/tree/master/packages/now-node), [Go Runtime](https://github.com/zeit/now/tree/master/packages/now-go), [Python Runtime](https://github.com/zeit/now/tree/master/packages/now-python) or [Ruby Runtime](https://github.com/zeit/now/tree/master/packages/now-ruby) for examples of how to build one.
## Technical Details
### Execution Context
A [Serverless Function](https://zeit.co/docs/v2/advanced/concepts/lambdas) is created where the Runtime logic is executed. The lambda is run using the Node.js 8 runtime. A brand new sandbox is created for each deployment, for security reasons. The sandbox is cleaned up between executions to ensure no lingering temporary files are shared from build to build.
- Runtimes are executed in a Linux container that closely matches the Servereless Function runtime environment.
- The Runtime code is executed using Node.js version **12.x**.
- A brand new sandbox is created for each deployment, for security reasons.
- The sandbox is cleaned up between executions to ensure no lingering temporary files are shared from build to build.
All the APIs you export ([`analyze`](#analyze), [`build`](#build) and [`prepareCache`](#preparecache)) are not guaranteed to be run in the same process, but the filesystem we expose (e.g.: `workPath` and the results of calling [`getWriteableDirectory`](#getWriteableDirectory) ) is retained.
All the APIs you export ([`analyze()`](#analyze), [`build()`](#build),
[`prepareCache()`](#preparecache), etc.) are not guaranteed to be run in the
same process, but the filesystem we expose (e.g.: `workPath` and the results
of calling [`getWritableDirectory`](#getWritableDirectory) ) is retained.
If you need to share state between those steps, use the filesystem.
@@ -165,22 +212,20 @@ When a new build is created, we pre-populate the `workPath` supplied to `analyze
The `analyze` step can modify that directory, and it will not be re-created when it's supplied to `build` and `prepareCache`.
To learn how the cache key is computed and invalidated, refer to the [overview](https://zeit.co/docs/v2/advanced/runtimes#technical-details).
### Accessing Environment and Secrets
The env and secrets specified by the user as `build.env` are passed to the Runtime process. This means you can access user env via `process.env` in Node.js.
### Utilities as peerDependencies
When you publish your Runtime to npm, make sure to not specify `@now/build-utils` (as seen below in the API definitions) as a dependency, but rather as part of `peerDependencies`.
When you publish your Runtime to npm, make sure to not specify `@vercel/build-utils` (as seen below in the API definitions) as a dependency, but rather as part of `peerDependencies`.
## Types
## `@vercel/build-utils` Types
### `Files`
```ts
import{File}from'@now/build-utils';
```typescript
import{File}from'@vercel/build-utils';
typeFiles={[filePath: string]:File};
```
@@ -190,7 +235,7 @@ When used as an input, the `Files` object will only contain `FileRefs`. When `Fi
An example of a valid output `Files` object is:
```json
```javascript
{
"index.html":FileRef,
"api/index.js":Lambda
@@ -201,8 +246,8 @@ An example of a valid output `Files` object is:
This is an abstract type that can be imported if you are using TypeScript.
```ts
import{File}from'@now/build-utils';
```typescript
import{File}from'@vercel/build-utils';
```
Valid `File` types include:
@@ -213,71 +258,71 @@ Valid `File` types include:
### `FileRef`
```ts
import{FileRef}from'@now/build-utils';
```typescript
import{FileRef}from'@vercel/build-utils';
```
This is a [JavaScript class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) that represents an abstract file instance stored in our platform, based on the file identifier string (its checksum). When a `Files` object is passed as an input to `analyze` or `build`, all its values will be instances of `FileRef`.
This is a [class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) that represents an abstract file instance stored in our platform, based on the file identifier string (its checksum). When a `Files` object is passed as an input to `analyze` or `build`, all its values will be instances of `FileRef`.
**Properties:**
-`mode: Number` file mode
-`digest: String` a checksum that represents the file
-`mode: Number` file mode
-`digest: String` a checksum that represents the file
**Methods:**
-`toStream(): Stream` creates a [Stream](https://nodejs.org/api/stream.html) of the file body
-`toStream(): Stream` creates a [Stream](https://nodejs.org/api/stream.html) of the file body
### `FileFsRef`
```ts
import{FileFsRef}from'@now/build-utils';
```typescript
import{FileFsRef}from'@vercel/build-utils';
```
This is a [JavaScript class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) that represents an abstract instance of a file present in the filesystem that the build process is executing in.
This is a [class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) that represents an abstract instance of a file present in the filesystem that the build process is executing in.
**Properties:**
-`mode: Number` file mode
-`fsPath: String` the absolute path of the file in file system
-`mode: Number` file mode
-`fsPath: String` the absolute path of the file in file system
**Methods:**
-`static async fromStream({ mode: Number, stream: Stream, fsPath: String }): FileFsRef` creates an instance of a [FileFsRef](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) from `Stream`, placing file at `fsPath` with `mode`
-`toStream(): Stream` creates a [Stream](https://nodejs.org/api/stream.html) of the file body
-`static async fromStream({ mode: Number, stream: Stream, fsPath: String }): FileFsRef` creates an instance of a [FileFsRef](#FileFsRef) from `Stream`, placing file at `fsPath` with `mode`
-`toStream(): Stream` creates a [Stream](https://nodejs.org/api/stream.html) of the file body
### `FileBlob`
```ts
import{FileBlob}from'@now/build-utils';
```typescript
import{FileBlob}from'@vercel/build-utils';
```
This is a [JavaScript class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) that represents an abstract instance of a file present in memory.
This is a [class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) that represents an abstract instance of a file present in memory.
**Properties:**
-`mode: Number` file mode
-`data: String | Buffer` the body of the file
-`mode: Number` file mode
-`data: String | Buffer` the body of the file
**Methods:**
-`static async fromStream({ mode: Number, stream: Stream }):FileBlob` creates an instance of a [FileBlob](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) from [`Stream`](https://nodejs.org/api/stream.html) with `mode`
-`toStream(): Stream` creates a [Stream](https://nodejs.org/api/stream.html) of the file body
-`static async fromStream({ mode: Number, stream: Stream }):FileBlob` creates an instance of a [FileBlob](#FileBlob) from [`Stream`](https://nodejs.org/api/stream.html) with `mode`
-`toStream(): Stream` creates a [Stream](https://nodejs.org/api/stream.html) of the file body
### `Lambda`
```ts
import{Lambda}from'@now/build-utils';
```typescript
import{Lambda}from'@vercel/build-utils';
```
This is a [JavaScript class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), called a Serverless Function, that can be created by supplying `files`, `handler`, `runtime`, and `environment` as an object to the [`createLambda`](#createlambda) helper. The instances of this class should not be created directly. Instead, invoke the [`createLambda`](#createlambda) helper function.
This is a [class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) that represents a Serverless Function. An instance can be created by supplying `files`, `handler`, `runtime`, and `environment` as an object to the [`createLambda`](#createlambda) helper. The instances of this class should not be created directly. Instead, invoke the [`createLambda`](#createlambda) helper function.
**Properties:**
-`files: Files` the internal filesystem of the lambda
-`handler: String` path to handler file and (optionally) a function name it exports
-`runtime: LambdaRuntime` the name of the lambda runtime
-`environment: Object` key-value map of handler-related (aside of those passed by user) environment variables
-`files: Files` the internal filesystem of the lambda
-`handler: String` path to handler file and (optionally) a function name it exports
-`runtime: LambdaRuntime` the name of the lambda runtime
-`environment: Object` key-value map of handler-related (aside of those passed by user) environment variables
### `LambdaRuntime`
@@ -287,28 +332,28 @@ 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`
-`provided`
## JavaScript API
## `@vercel/build-utils` Helper Functions
The following is exposed by `@now/build-utils` to simplify the process of writing Runtimes, manipulating the file system, using the above types, etc.
The following is exposed by `@vercel/build-utils` to simplify the process of writing Runtimes, manipulating the file system, using the above types, etc.
This utility allows you to download the contents of a [`Files`](#files) data structure, therefore creating the filesystem represented in it.
This utility allows you to download the contents of a [`Files`](#files) data
structure, therefore creating the filesystem represented in it.
Since `Files` is an abstract way of representing files, you can think of`download` as a way of making that virtual filesystem _real_.
Since `Files` is an abstract way of representing files, you can think of
`download()` as a way of making that virtual filesystem _real_.
If the **optional**`meta` property is passed (the argument for [build](#build)), only the files that have changed are downloaded. This is decided using `filesRemoved` and `filesChanged` inside that object.
If the **optional**`meta` property is passed (the argument for
[`build()`](#build)), only the files that have changed are downloaded.
This is decided using `filesRemoved` and `filesChanged` inside that object.
```js
awaitdownload(files,workPath,meta);
```
### `glob`
### `glob()`
Signature: `glob(): Files`
Signature: `glob(): Files`
```ts
import{glob}from'@now/build-utils';
```typescript
import{glob}from'@vercel/build-utils';
```
This utility allows you to _scan_ the filesystem and return a [`Files`](#files) representation of the matched glob search string. It can be thought of as the reverse of [`download`](#download).
@@ -349,36 +398,36 @@ 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)):
To install the latest version of Now CLI, visit [zeit.co/download](https://zeit.co/download) or run this command:
## Vercel
```
npm i -g now
```
Vercel is a platform for **static sites and frontend frameworks**, built to integrate with your headless content, commerce, or database.
To quickly start a new project, run the following commands:
We provide a **frictionless developer experience** to take care of the hard things: deploy instantly, scale automatically, and serve personalized content around the globe.
```
now init # Pick an example project to clone
cd <PROJECT> # Change directory to the newly created project
now dev # Run locally during development
now # Deploy to the cloud
```
We make it easy for frontend teams to **develop, preview, and ship** delightful user experiences, where performance is the default.
## Deploy
Get started by [importing a project](https://vercel.com/new) or using the [Vercel CLI](https://vercel.com/cli). Then, `git push` to deploy.
## Documentation
For details on how to use Now CLI, check out our [documentation](https://zeit.co/docs).
For details on how to use Vercel, check out our [documentation](https://vercel.com/docs).
## Caught a Bug?
## Contributing
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
2. Install dependencies with `yarn install`
3. Compile the code: `yarn build`
4. Link the package to the global module directory: `yarn link`
5. You can now start using `now` anywhere inside the command line
As always, you should use `yarn test-unit` to run the tests and see if your changes have broken anything.
## How to Create a Release
If you have write access to this repository, you can read more about how to publish a release [here](https://github.com/zeit/now/wiki/Creating-a-Release).
- [Code of Conduct](https://github.com/vercel/vercel/blob/main/.github/CODE_OF_CONDUCT.md)
@@ -8,7 +8,7 @@ the provider couldn’t solve the requested challenges.
## How to Fix It
If your domain is pointing to ZEIT World DNS and you’re getting this error,
If your domain is pointing to Vercel DNS and you’re getting this error,
it could be that:
- The domain was acquired recently, and it might not be ready for use yet.
@@ -17,11 +17,11 @@ it could be that:
When running into this, ensure that your nameservers are configured correctly. Also, if you bought the domain recently or have made changes, please be patient,
it might take a while for these to be ready.
If your domain is _not_ pointing to ZEIT World DNS and you’re getting this
If your domain is _not_ pointing to Vercel DNS and you’re getting this
error, the following methods could help:
- When solving challenges *manually*, ensure that the TXT
records required to solve the challenges exist and are propagated. You can do so by querying the nameservers with `nslookup -q=TXT _acme-challenge.domain.com` depending on the Common Names you want for your certificate.
- When solving challenges _manually_, ensure that the TXT
records required to solve the challenges exist and are propagated. You can do so by querying the nameservers with `nslookup -q=TXT _acme-challenge.domain.com` depending on the Common Names you want for your certificate.
- If you are not solving the challenges manually you must ensure that you have an
`ALIAS` and `CNAME` records in place. Ensure also that you have disabled automatic redirects to `https` and ensure all changes were propagated.
`ALIAS` and `CNAME` records in place. Ensure also that you have disabled automatic redirects to `https` and ensure all changes were propagated.
When generating a certificate, we have to prove ownership over the domain
for the Certificate Authority (CA) that issues it. We also run some pretests
to make sure the DNS is properly configured before submitting the request to
to make sure the DNS is properly configured before submitting the request to
the CA. This error means that these pretests did not succeed.
## How to Fix It
If your domain is pointing to ZEIT World DNS and you’re getting this error,
If your domain is pointing to Vercel DNS and you’re getting this error,
it could be that:
- The domain was acquired recently, and it might not be ready for use yet.
@@ -18,6 +18,6 @@ it could be that:
When running into this, ensure that your nameservers have configuration is correct. Also, if you bought the domain recently or have made changes, please be patient,
it might take a while for these to be ready.
If your domain is _not_ pointing to ZEIT World DNS and you’re getting this
If your domain is _not_ pointing to Vercel DNS and you’re getting this
error, you must ensure that you have an `ALIAS` and `CNAME` records in place.
Ensure also that you have disabled automatic redirects to `https` and ensure all changes were propagated.
The domain you supplied cannot be verified using either the intended set of nameservers or the given verification TXT record.
The domain you supplied cannot be verified using the intended nameservers.
#### Possible Ways to Fix It
#### Possible Way to Fix It
Apply the intended set of nameservers to your domain or add the given TXT verification record through your domain provider.
Apply the intended set of nameservers to your domain.
You can retrieve both the intended nameservers and TXT verification record for the domain you wish to verify by running `now domains inspect <domain>`.
You can retrieve both the intended nameservers and TXT verification record for the domain you wish to verify by running `vercel domains inspect <domain>`.
When you have added either verification method to your domain, you can run `now domains verify <domain>` again to complete verification for your domain.
Vercel will also automatically check periodically that your domain has been verified and automatically mark it as such if we detect either verification method on the domain.
ZEIT will also automatically check periodically that your domain has been verified and automatically mark it as such if we detect either verification method on the domain.
If you would not like to verify your domain, you can remove it from your account using `now domains rm <domain>`.
If you would not like to verify your domain, you can remove it from your account using `vercel domains rm <domain>`.
When defining custom routes a route was added that causes an error during parsing. This can be due to trying to use normal `RegExp` syntax like negative lookaheads (`?!exclude`) without following `path-to-regexp`'s syntax for it.
#### Possible Ways to Fix It
Wrap the `RegExp` part of your `source` as an un-named parameter.
**Before**
```js
{
source:'/feedback/(?!general)',
destination:'/api/feedback/general'
}
```
**After**
```js
{
source:'/feedback/((?!general).*)',
destination:'/api/feedback/general'
}
```
Ensure any segments used in the `destination` property are also used in the `source` property.
@@ -8,4 +8,4 @@ The `--token` flag was specified, but its contents are invalid.
The `--token` flag must only contain numbers (0-9) and letters from the alphabet (a-z and A-Z). This needs to be the token of the user account as which you'd like to act.
You can either get the token from the `./now/auth.json` file located in your user directory or [from the dashboard](https://zeit.co/account/tokens).
You can either get the token from the `./vercel/auth.json` file located in your user directory or [from the dashboard](https://vercel.com/account/tokens).
You specified a path as the value for the `--dotenv` flag, but the target of the path doesn't exist.
#### Possible Ways to Fix It
Make sure the target file you've specified exists and is readable by Now CLI. In addition, please ensure that the filename starts with a dot (example: `.env`) - then it should work.
You ran `now dev` inside a project that contains a `now.json` file with `env` or `build.env` properties that use [Now Secrets](https://zeit.co/docs/v2/deployments/environment-variables-and-secrets).
In order to use environment variables in your project locally that have values defined using the Now Secrets format (e.g. `@my-secret-value`), you will need to provide the value as an environmentvariable using a `.env` or `.env.build` file.
You ran `vercel dev` inside a project that contains a `vercel.json` file with `env` or `build.env` properties that use [Vercel Secrets](https://vercel.com/docs/v2/build-step#environment-variables).
We require this to ensure your app works as you intend it to, in the Now Dev environment, and to provide you with a way to mirror or separate private environment variables within your applications, for example when connecting to a database.
In order to use environment variables in your project locally that have values defined using the Vercel Secrets format (e.g. `@my-secret-value`), you will need to provide the value as an environment variable using a `.env`.
We require this to ensure your app works as you intend it to, in the development environment, and to provide you with a way to mirror or separate private environment variables within your applications, for example when connecting to a database.
Read below for how to address this error.
#### Possible Ways to Fix It
The error message will list environment variables that are required and which file they are required to be included in (either `.env` or `.env.build`).
The error message will list environment variables that are required and which file they are required to be included in `.env`.
If the file does not exist yet, please create the file that the error message mentions and insert the missing environment variable into it.
@@ -23,4 +24,4 @@ TEST=value
In the above example, `TEST` represents the name of the environment variable and `value` its value.
For more information on Environment Variables in development, [see the documentation](https://zeit.co/docs/v2/development/environment-variables/).
For more information on Environment Variables in development, [see the documentation](https://vercel.com/docs/v2/build-step#environment-variables).
@@ -8,4 +8,4 @@ The `--scope` flag was specified, but there's no value for it available.
In order to make it work, you need to specify a value for the `--scope` flag. This needs to be the slug or ID of the team as which you'd like to act or the username or ID of a user you'd like to act as.
As an example, if your team URL is `https://zeit.co/teams/zeit`, you would set `--scope` to `zeit`.
As an example, if your team URL is `https://vercel.com/my-team`, you would set `--scope` to `my-team`.
@@ -8,4 +8,4 @@ The `--token` flag was specified, but there's no value for it available.
In order to make it work, you need to specify a value for the `--token` flag. This needs to be the token of the user account as which you'd like to act.
You can either get the token from the `./now/auth.json` file located in your user directory or [from the dashboard](https://zeit.co/account/tokens).
You can either get the token from the `./vercel/auth.json` file located in your user directory or [from the dashboard](https://vercel.com/account/tokens).
`@vercel/next` by default now bundles pages into optimized functions, minimizing bootup time and increasing overall application throughput.
When legacy `routes` are added in `now.json` or `vercel.json`, they cause conflicts with this optimization, so it is opted-out.
#### Possible Ways to Fix It
Migrate from using legacy `routes` to the new `rewrites`, `redirects`, and `headers` configurations in your `now.json` or `vercel.json` file or leverage them directly in your `next.config.js` with the built-in [custom routes support](https://github.com/vercel/next.js/issues/9081)
You're running Now CLI in a non-terminal context and there are no credentials available. This means that Now CLI is not able to authenticate against our service.
You're running Vercel CLI in a non-terminal context and there are no credentials available. This means that Vercel CLI is not able to authenticate against our service.
#### Possible Ways to Fix It
- Specify a value for the `--token` flag (this needs to be the token of the user account as which you'd like to act). You can either get the token from the `./now/auth.json` file located in your user directory or [from the dashboard](https://zeit.co/account/tokens).
-Ensure that both `~/now/auth.json` and `~/now/config.json` exist
- Specify a value for the `--token` flag (this needs to be the token of the user account as which you'd like to act). You can create a new token on your [Settings page](https://vercel.com/account/tokens).
-Run `vercel login` to sign in and generate a new token
You attempted to create a Vercel deployment where the input is a file, rather than a directory. Previously this was allowed, however this behavior has been removed as of Vercel CLI v24.0.0 because it exposed a potential security risk if the user accidentally created a deployment from a sensitive file.
#### Possible Ways to Fix It
- Run the `vercel deploy` command against a directory, instead of a file.
You tried to run a command that doesn't allow the `--token` flag (like `now switch`). This is not allowed because commands like these are influencing the configuration files.
You tried to run a command that doesn't allow the `--token` flag (like `vercel switch`). This is not allowed because commands like these are influencing the configuration files.
In turn, they would have to take the value of the `--token` flag into consideration (which is not a good idea, because flags in Now CLI should never change the configuration).
In turn, they would have to take the value of the `--token` flag into consideration (which is not a good idea, because flags in Vercel CLI should never change the configuration).
#### Possible Ways to Fix It
Specify a value for the `--scope` flag. This needs to be the slug or ID of the team as which you'd like to act (as an example, if your team URL is `https://zeit.co/teams/zeit`, the value can be `zeit`) or the username or ID of a user you'd like to act as.
Specify a value for the `--scope` flag. This needs to be the slug or ID of the team as which you'd like to act (as an example, if your team URL is `https://vercel.com/my-team`, the value can be `my-team`) or the username or ID of a user you'd like to act as.
This could be caused by a misconfigured "Build Command" or "Output Directory" for your Next.js project.
#### Possible Ways to Fix It
In the Vercel dashboard, open your "Project Settings" and draw attention to "Build & Development Settings":
1. Ensure that the "Build Command" setting is not changed, or that it calls `next build`. If this command is not changed but you are seeing this error, double check that your `build` script in `package.json` calls `next build`.
2. Ensure that the "Output Directory" setting is not changed. This value almost never needs to be configured, and is only necessary if you override `distDir` in `next.config.js`.
3. For `next export` users: **do not override the "Output Directory"**. Next.js automatically detects what folder you outputted `next export` to.
In rare scenarios, this error message can also be caused by a Next.js build failure (if your "Build Command" accidentally returns an exit code that is not 0).
Double check for any error messages above the Routes Manifest error, which may provide additional details.
# `@now/static-build` Failed to detect a server running
# `@vercel/static-build` Failed to detect a server running
#### Why This Warning Occurred
When running `now dev`, the `@now/static-build` builder proxies relevant HTTP
requests to the server that is created by the `now-dev` script in the
When running `vercel dev`, the `@vercel/static-build` builder proxies relevant HTTP
requests to the server that is created by the `dev` script in the
`package.json` file.
In order for `now dev` to know which port the server is running on, the builder
In order for `vercel dev` to know which port the server is running on, the builder
is provided a `$PORT` environment variable that the server _must_ bind to. The
error "Failed to detect a server running on port" is printed if the builder fails
to detect a server listening on that specific port within five minutes.
#### Possible Ways to Fix It
Please ensure that your `now-dev` script binds the spawned development server on
Please ensure that your `dev` script binds the spawned development server on
the provided `$PORT` that the builder expects the server to bind to.
For example, if you are using Gatsby, your `now-dev` script must use the `-p`
For example, if you are using Gatsby, your `dev` script must use the `-p`
(port) option to bind to the `$PORT` specified from the builder:
> *In Windows environments, reference the `PORT` environment variable with `%PORT%`*
> _In Windows environments, reference the `PORT` environment variable with `%PORT%`_
```
{
...
"scripts": {
...
"now-dev": "gatsby develop -p $PORT"
"dev": "gatsby develop -p $PORT"
}
}
```
@@ -34,7 +34,3 @@ For example, if you are using Gatsby, your `now-dev` script must use the `-p`
Consult your static builder program's `--help` or documentation to figure out what
the command line flag to bind to a specific port is (in many cases, it is one of:
`-p` / `-P` / `--port`).
### Useful Links
- [`@now/static-build` Local Development Documentation](https://zeit.co/docs/v2/deployments/official-builders/static-build-now-static-build#local-development)
You either tried to run Now CLI inside a directory that should never be deployed, or you specified a directory that should never be deployed like this: `now <directory>`.
You either tried to run Vercel CLI inside a directory that should never be deployed, or you specified a directory that should never be deployed like this: `vercel <directory>`.
@@ -6,5 +6,6 @@ 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 `now ls` work just fine. This will ensure that your user credentials are valid. If it's not working correctly, please log in again using `now login`.
-Ensure that the scope you specified using `--scope` shows up in the output of `now 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.
- 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.
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.
@@ -6,4 +6,4 @@ You tried to add or update a domain's configuration, but you don't have permissi
#### Possible Ways to Fix It
If you or your team owns the domain, then you are most likely in the wrong context. Use `now switch` to select the team or user that owns the domain.
If you or your team owns the domain, then you are most likely in the wrong context. Use `vercel switch` to select the team or user that owns the domain.
To get started using any of these examples as your own project, [install Vercel](https://vercel.com/cli) and use either of the following commands in your terminal:
```sh
vercel init # Pick an example in the CLI
vercel init <example> # Create a new project from a specific <example>
vercel init <example> <name> # Create a new project from a specific <example> with a different folder <name>
```
Deploying your project can be done with **a single command**:
```sh
vercel # Deploy your project with the CLI
```
With the `vercel` command, your project will be built and served by Vercel, providing you with a URL that can be shared immediately.
## How to Contribute
Contributing examples should be an enjoyable experience, as such we have created a set of [contributing guidelines](https://github.com/vercel/vercel/blob/main/.github/CONTRIBUTING.md) to help you do so.
The guidelines cover important information such as the requirements for new examples and where to get help if you have any questions.
We have tried to make contributing to examples as easy as possible, especially for those new to Open Source. If anything is unclear or you have any questions then please reach out to us on [GitHub Discussions](https://github.com/vercel/vercel/discussions) where we will do our best to help you.
## Reporting Issues
We actively encourage our community to raise issues and provide feedback on areas of examples that could be improved.
An issue can be raised by clicking the 'Issues' tab at the top of the repository, followed by the Green 'New issue' button.
When submitting an issue, please thoroughly and concisely describe the problem you are experiencing so that we may easily understand and resolve the issue in a timely manner.
## Get In Touch
If you have any questions that are not covered by raising an issue then please get in touch with us on [GitHub Discussions](https://github.com/vercel/vercel/discussions). There you will find both members of the community and staff who are happy to help answer questions on anything Vercel related.
[](https://github.com/vercel/vercel/discussions)
This directory is a brief example of an [AMP](https://amp.dev/) site that can be deployed to Vercel with zero configuration.
## Deploy Your Own
Deploy your own AMP project with Vercel.
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/amp)
_Live Example: https://amp-template.vercel.app_
### How We Created This Example
To get started deploying AMP with Vercel, you can use the [Vercel CLI](https://vercel.com/download) to initialize the project:
This directory is a brief example of an [Angular](https://angular.io/) app that can be deployed to Vercel with zero configuration.
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.1.3.
## Deploy Your Own
Deploy your own Angular project with Vercel.
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/angular&template=angular)
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
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.