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
This PR does a few things:
1. Add functions `getLatestNodeVersion()` and `getOldestNodeVersion()` for use in api-project.
2. Add property `config.nodeVersion` which has precedence over default Node 8.
We want new projects to use the latest node version without setting any configuration but we don't want to break old projects. So during project creation, the value of `getLatestNodeVersion()` will be saved and then each deployment of that project will assign that value to `config.nodeVersion`.
Implements [PRODUCT-837]
[PRODUCT-837]: https://zeit.atlassian.net/browse/PRODUCT-837
This implements `{ handle: 'miss' }` which will allow more efficiently checking dynamic routes after a matching rewrite. This is not fully available in production yet and the tests will fail for this PR until it is ready in Now
x-ref: https://github.com/zeit/next.js/pull/9568
This handles the new `routes-manifest` version in the latest canary of Next.js since we throw an error if the version isn't handled by `@now/next`
unblocks: https://github.com/zeit/now/pull/3481
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.1.2 to 4.5.3.
<details>
<summary>Changelog</summary>
*Sourced from [handlebars's changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md).*
> ## v4.5.3 - November 18th, 2019
> Bugfixes:
>
> - fix: add "no-prototype-builtins" eslint-rule and fix all occurences - f7f05d7
> - fix: add more properties required to be enumerable - 1988878
>
> Chores / Build:
> - fix: use !== 0 instead of != 0 - c02b05f
> - add chai and dirty-chai and sinon, for cleaner test-assertions and spies,
> deprecate old assertion-methods - 93e284e, 886ba86, 0817dad, 93516a0
>
> Security:
>
> - The properties `__proto__`, `__defineGetter__`, `__defineSetter__` and `__lookupGetter__`
> have been added to the list of "properties that must be enumerable".
> If a property by that name is found and not enumerable on its parent,
> it will silently evaluate to `undefined`. This is done in both the compiled template and the "lookup"-helper.
> This will prevent new Remote-Code-Execution exploits that have been
> published recently.
>
> Compatibility notes:
>
> - Due to the security-fixes. The semantics of the templates using
> `__proto__`, `__defineGetter__`, `__defineSetter__` and `__lookupGetter__` in the respect that those expression now return
> `undefined` rather than their actual value from the proto.
> - The semantics have not changed in cases where the properties are enumerable, as in:
>
> ```js
> {
> __proto__: 'some string'
> }
> ```
>
> - The change may be breaking in that respect, but we still only
> increase the patch-version, because the incompatible use-cases
> are not intended, undocumented and far less important than fixing
> Remote-Code-Execution exploits on existing systems.
>
>
>
> [Commits](https://github.com/wycats/handlebars.js/compare/v4.5.2...v4.5.3)
>
> ## v4.5.2 - November 13th, 2019
> # Bugfixes
>
> - fix: use String(field) in lookup when checking for "constructor" - d541378
> - test: add fluent API for testing Handlebars - c2ac79c
>
> Compatibility notes:
> - no incompatibility are to be expected
></tr></table> ... (truncated)
</details>
<details>
<summary>Commits</summary>
- [`c819c8b`](c819c8b533) v4.5.3
- [`827c9d0`](827c9d0747) Update release notes
- [`f7f05d7`](f7f05d7558) fix: add "no-prototype-builtins" eslint-rule and fix all occurences
- [`1988878`](1988878087) fix: add more properties required to be enumerable
- [`886ba86`](886ba86c2f) test/chore: add chai/expect and sinon to "runtime"-environment
- [`0817dad`](0817dad7e7) test: add sinon as global variable to eslint in the specs
- [`93516a0`](93516a0b07) test: add sinon.js for spies, deprecate current assertions
- [`93e284e`](93e284ed9b) chore: add chai and dirty-chai for better test assertions
- [`c02b05f`](c02b05fa81) fix: use !== 0 instead of != 0
- [`8de121d`](8de121d21c) v4.5.2
- Additional commits viewable in [compare view](https://github.com/wycats/handlebars.js/compare/v4.1.2...v4.5.3)
</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 ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major 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>
There is an undocumented feature that adds a route when a single file is deployed, for example a single image or a zip file. This was causing the legacy routes to be added even when `rewrites` or `redirects` was defined. This PR fixes that case when the user has a single file, `now.json`, with redirects defined.
* [now-build-utils] Only add 404 route when there are no api routes
* Fix startWith
* Update packages/now-build-utils/src/detect-routes.ts
Co-Authored-By: Steven <steven@ceriously.com>
* Import isHandler
Co-authored-by: Steven <steven@ceriously.com>
This PR adds the route `handle: miss` and a catch-all route for the api directory.
The plan is to rename files in `/api` and `/public` (in a future PR) to be extension-less and then the route is only used to rewrite the extension to the extension-less file (for example, `/api/user.go` => `/api/user`)
This reduces the routes needed for zero config (previously N routes for N files down to 1 route for N files).
This PR deletes the incorrect `Route` type defined in `@now/build-utils` and instead relies on the correct type defined in `@now/routing-utils`. There is no change to runtime code since this is strictly a change to the typescript types. The one exception to this is I had to change the sort order for our build script so that `@now/routing-utils` is built first.
This is necessary for PR #3403
This makes sure to replace multi-match characters used in `path-to-regexp` when converting redirects.
Fixes `/:path*/` being converted to `/$1*/` and now converts it to `/$1/`
As requested by @timneutkens after investigating we're disabling auto running `next export` for the user during a build since most users who want their app exported will define `next export` in their `build` script
* Adjust README
* Fix now-dev test
* Add hugo to the PATH
* Fix Hugo build
* Add more logging
* Resolve path
* Do not use the build script as dev command
* Update yarn.lock file
* fetch with retry
* Remove sh from README
* Use Set for Hugo config files
* Revert "Revert "[now-static-build] Add support `buildCommand`, `devCommand` and `outputDirectory` (#3422)" (#3428)"
This reverts commit f7b4dd4458.
* Handle generic node projects with /public
* Remove .only
* Ensure node_modules/.bin is also available during `now dev`
* Remove config log
* Adjust test
* Fix integration tests
* Fix public check
* Remove build + public
* Remove _scan
* Remove any casting
* Use `spawnCommand` for dev
* Remove unused import
* Remove cross-spawn
* Fix null config
* Fix build
* Only do a single Buffer.concat
Follow up to #3431 adding tests for this behavior
Tests to add:
- [x] custom routes: redirects
- [x] custom routes: rewrites
- [x] confirming each test is actually a `next export` deploy somehow
* [now-static-build] Handle `buildCommand`, `devCommand` and `outputDirectory`
* Adjust tests
* Swap order
* Add `node_modules/.bin` to PATH
* Remove @types/execa
* Append PATH only to spawn options
* Remove test check
* Only add when there is a command
This PR reduces the time running Circle CI tests.
Since creating the monorepo in #2812, the coverage broke and then was fixed in #2876 with a workaround which would run unit tests twice.
More recently, we enabled Now CLI to always run tests in #3305 so that means coverage data is always generated.
This PR is a final proper fix so that unit tests run once which saves approximately 2 minutes per push (CI workflow).
We used to have a default `maxLambdaSize` and allow the user to increase to 50 MB.
However, this is no longer true. Today, the `maxLambdaSize` for every function is 50 MB and is not configurable, it's a hard limit.
This PR removes the dead link to avoid confusion like in Issue #3416.
* [now-build-utils] Consider `yarn build` and `npm run build` as `buildCommand`
* [@now/build-utils] Update new detectors
* Update unit tests
* [@now/build-utils] Update detect-builder and detect-routes
* Update tests
* Run prettier
* Add more tests
* [now-cli] Use default detectors
* Add now-dev test
* Add a generic node project fallback
* Fix build
* Use public as default
* Ensure generic node project is last
* Update tests
* Update tests again
* Update packages/now-build-utils/src/detectors/filesystem.ts
Co-Authored-By: Nathan Rajlich <n@n8.io>
* Remove parentheses
* Revert "Remove parentheses"
This reverts commit 03f9aba07b0a6d4088719ca9afd602ce8fb1e9c1.
* Use getDependencyVersion instead of hasDependency
* [@now/build-utils] Add functions schema
* [now-cli] Use functions schema from build-utils
* Move buildsSchema to build-utils
* Add retries to test
* Add await
Follow up to #3408 .
```
> Error! Checking for updates failed
> Now CLI 16.6.3 dev (beta) — https://zeit.co/feedback/dev
> Error! Invalid `functions` property: ['api/test.js'] should NOT have additional properties
```
This PR adds a `discontinueDate` to Node 8 and prints a warning if the current deployment is using it.
```
┌──────────────────────────────────────────────────────────────────────────────────────────────┐
│ │
│ WARNING │
│ │
│ Node.js 8.10.x will be discontinued on 2020-01-06. │
│ Deployments created on or after 2020-01-06 will fail to build. │
│ Please use one of the following supported `engines` in `package.json`: ["12.x","10.x"] │
│ This change is a result of a decision made by an upstream infrastructure provider (AWS). │
│ Read more: https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────┘
```
Starting January 2020, Node 8 deployments will fail to build and print an error.
```
Found `engines` in `package.json` with an unsupported Node.js version range: 8.10.x
Please use one of the following supported ranges: ["12.x","10.x"]
```
[PRODUCT-796]
[PRODUCT-796]: https://zeit.atlassian.net/browse/PRODUCT-796
Before, the debug log message "Downloading user files..." was copy+pasted to all the builders.
This change centralizes that log message to be inside the `download()` function for consistency and DRY purposes.
Additionally, the wording has changed as per [INFRA-289], and a resulting timestamp message is also printed.
[INFRA-289]: https://zeit.atlassian.net/browse/INFRA-289
Before this change, in `@now/next` when running via `now dev`,
the runtime env vars get passed to the child `dev-server.js`
process via argv.
This is problematic because it causes the env vars to be visible in
the process listing, and also causes the command itself to be very
large.
In some cases, with a lot of env vars, we've seen the command be too
large and it will fail to spawn (https://serverfault.com/a/163390/294389).
This changes the start-up process such that the env vars are passed
in via Node.js `fork()` IPC, rather than via `argv`.
Saw my `pre-commit` hook wasn't being triggered after running `yarn` and noticed it was due to an un-used `pre-commit` dependency in `now-cli` overriding the changes to my `.git/hooks/pre-commit` file done by `husky`
**Note**: you will probably need to run `yarn install --force` after this is applied before the correct `pre-commit` changes are applied by `husky`
We've shut down our Typeform for feedback, so we can simply the feedback link. The old one will continue working, but we should start using the new one.
Pending on https://github.com/zeit/front/pull/5874.
Fixes#3377
The lock files should not be cached because the user may wish to make a new deployment without a `yarn.lock` or `package-lock.json`.
This recently started causing problems because of the order of downloading cache changed from before user files to after user files.
So we need to be extra careful to only cache outputs and not source files.
This PR will reduce deployment time when a `package-lock.json` file is found by avoiding the audit step which usually [sends audit reports](https://docs.npmjs.com/cli/audit#description) to the registry.
The [--no-audit](https://docs.npmjs.com/cli/install) flag was introduced in [npm@6](
https://medium.com/npm-inc/announcing-npm-6-5d0b1799a905) which shipped with Node 10. However, using the flag with npm@5 does not do anything which is great because npm@5 doesn't audit. So this PR is backwards compatible.
### Performance
I tried `npm install` and `npm install --no-audit` with a large project, [StateOfJS](a9fa6d47f9/homepages/stateofjs), which has 2206 packages (audited 21778 packages).
I made sure to `rm -rf node_modules` each time and ran both commands 5 times to make sure it was always faster with `--no-audit`.
- Before: 61 seconds
- After: 49 seconds
Since we switched to a single branch (instead of master/canary), lerna gets confused about which packages to publish because stable and canary releases are in the same branch.
This PR fixes the confusion by looking at the git history and using [--force-publish](https://github.com/lerna/lerna/tree/master/commands/version#--force-publish) on the changed packages.
In order to avoid confusion for the person publishing, I removed the `yarn publish-stable` script in favor of `yarn changelog` which will print the change log and emit a script that can be used to publish stable.
<details><summary>View Example Output</summary>
<p>
```
$ yarn changelog
yarn run v1.19.1
$ node changelog.js
Changes since the last Stable release (21fe0a2):
- [now-cli] Change `--debug` to avoid debugging builders (#3386) [Steven]
- [now-next] Update routes for new check: true behavior (#3383) [JJ Kasper]
- [now-build-utils] Update Detectors API (#3384) [Nathan Rajlich]
- [now-client] Bump version (#3385) [Andy]
- [now-client] (Major) Split `now-client` options (#3382) [Andy]
- [now-cli][now-client] Fix user agent (#3381) [Steven]
- [now-client] Fix `main` in package.json (#3344) [Max]
- [now-build-utils] Change `script` to `scripts` in error message (#3376) [Andy]
- [now-cli] Add support for `check: true` routes in `now dev` (#3364) [Steven]
- [now-cli] Fix preinstall script on windows when `LOCALAPPDATA` is missing (#3365) [Steven]
- [now dev] skip installing already installed versioned runtimes (#3354) [Tommaso De Rossi]
- [now-routing-utils] Update `path-to-regexp` to v6.1.0 (#3361) [Steven]
- [now-routing-utils] Add mergeRoutes function (#3358) [Steven]
- [docs] Remove deprecated LambdaRuntimes (#3346) [Steven]
- [now-routing-utils] Add support for `check: true` (#3343) [Steven]
- [now-static-build] Cache `.cache` folder for gatsby deployments (#3260) (#3342) [Luc]
To publish a stable release, execute the following:
git pull && lerna version --message 'Publish Stable' --exact --force-publish=@now/build-utils,now,now-client,@now/next,@now/routing-utils,@now/static-build
```
</p>
</details>
* [now-cli] Remove `github` property from payload before sending it
* Add test and remove unused one
* Remove .only
* Remove unused fixture
* Use correct github properties
Since switching to a single branch, each package in the monorepo can be independently versioned so that some packages are using a canary version and others using a stable version.
This PR fixes an issue where a canary version of `now-cli` is bundling a stable version of `now-client` and thus does does not deploy zero config using canary builders.
The solution is to pass the User Agent from `now-cli` to `now-client` in a new option.
A nice side-effect of this PR is that we will switch the User Agent back to what it used to be pre-now-client days. It will look something like `now 16.6.1-canary.0 node-v10.17.0 darwin (x64)`.
This PR adds `now dev` support for routes that define `check: true`.
The algorithm is as follows:
- If a matching `dest` file is found, then serve it
- If a matching `src` file is found, then serve it
- Otherwise, behave the same as `continue: true` and continue processing routes
Fixes#3353
The current solution might break if a user interrupts `now dev` while yarn wrote the package in the cache package.json but has not yet added to node_modules.
This happens in like 20 ms but is possible, so we could execute `yarn` every time to be sure.
Tell me if the above is a problem or not
This moves the merging logic to `@now/routing-utils` and adds support for `check: true`.
- Builder before filesystem, continue: true
- User before filesystem
- Builder before filesystem, check: true
- Builder before filesystem, continue: false
- Handle filesystem
- Builder after filesystem, continue: true
- User after filesystem
- Builder after filesystem, check: true
- Builder after filesystem, continue: false
Apply 77348ea71e again.
> Adds `.cache` folder to the Now cache for Gatsby deployments.
> Also adds a generic optional `cachePattern` property to the frameworks array so we can optimize cache paths for other frameworks in the future.
Fixes a confusing error message.
<details>
<summary>Click to view error message</summary>
<pre>> Ready! Available at http://localhost:3000
> Building @now/node:index.js
Installing dependencies...
Running "yarn run now-build"
yarn run v1.17.3
error @: The engine "node" is incompatible with this module. Expected version "10.x". Got "12.13.1"
error Commands cannot run with an incompatible environment.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Exited with 1
at ChildProcess.<anonymous> (/Users/styfle/Library/Caches/co.zeit.now/dev/builders/node_modules/@now/node/dist/index.js:78518:24)
at ChildProcess.emit (events.js:210: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) {
message: 'Exited with 1'
}</pre>
</details>
The `--ignore-engines` flag was added to `yarn install` many months ago but not `yarn run`.
This PR adds the flag to `yarn run`.
This is useful in `now dev` when the user might have a different Node version installed than what is specified by `engines` in `package.json`.
Reverts #3311
Previously, we thought we were going to use version 4 to support builder rewrites/redirects => routes. But that is no longer necessary. So instead version 4 will be builders that accept multiple file entrypoints.
Until v4 can be implemented, this reverts v4 changes.
Additionally, I added a helpful error message when the CLI does not support the builder version. In a future PR, we will add better version locking to avoid this type of version mismatch.
We expect `now@canary` to use canary builders. This PR fixes a bug where a zero config deployment was selecting `@now/static-build` instead of `@now/static-build@canary`.
Fixes#3334.
```
$ node ~/now-cli/dist/index.js --token $'he˚ll,o\n'
> Error! You defined "--token", but its contents are invalid. Must not contain: "\n", ",", "˚"
> More details: https://err.sh/now/invalid-token-value
```
Renames `test/unit.test.detectors.ts` -> `test/unit.detectors.test.ts`
and adjusts npm `test-unit` command.
Jest only runs tests for files that end in `*.test.ts` or `*.test.js`.
* [now-build-utils] Add framework detector functions
As described in [PRODUCT-399]. This is similar in nature to the
current framework detection logic in static-build, however the detectors
are now functions which allow for detection of frameworks without
a `package.json` file (i.e. jekyll), and also includes detection of
build and dev commands for use in project settings.
* Dedup `aggregate-error` dep in yarn.lock
* Simplify `hasDependency()`
* Adjust hugo detect logic
* Add "jekyll" detector
* Add "next" detector
* Optimize "gatsby" detector
Check the `package.json` first
* Add optimization to check "package.json" based detectors first
They're by far the most common and only rely on checking the single
`package.json` file. If no pkg-based detector succeeds then the non-pkg
detectors are consulted afterwards.
* Add "vue" detector
* Add "angular" detector
* Add "polymer" detector
* Add "svelte" detector
* Add "create-react-app-ejected" detector
* Add "gridsome" detector
* Add "umi" detector
* Add "sapper" detector
* Add "saber" detector
* Add "stencil" detector
* Add CRA ejected commands
* Add "brunch" detector
* Add "middleman" detector
* Add missing commands
* `buildCommand` is required
* Add initial unit tests
* Fix unit tests on Circle
* Move "jest" and "ts-jest" to the root of the monorepo
* Fix integration tests
* Fix test again
* Update packages/now-build-utils/src/detectors/middleman.ts
Co-Authored-By: Steven <steven@ceriously.com>
* Move `@types/jest` to root level package.json
* Update packages/now-build-utils/src/detectors/ember.ts
Co-Authored-By: Steven <steven@ceriously.com>
* Add `cachePattern`
* Address PR comments
* Add missing `$PORT` entries for devCommands
* Add `firstTruthy()` tests
* Revert some changes
Maybe it fixes CI build?
* Test remove `yaml` module
* Update packages/now-build-utils/src/detectors/next.ts
* Remove `toml`
* Test out "@iarna/toml" module
* Fix build
* Test out "js-yaml" module
* Add new routing properties
* Rename `test/unit.test.ts` to `test/unit.test.detectors.ts`
* Remove `@types/yaml`
Converts `reportError()` to typescript and adds an ignore list.
In particular, `uv_cwd` comes from `process.cwd()` so we don't need to track these errors in the case the user deletes their current working directory.
This is a follow up to #3194 which handled only one scenario.
* [now-build-utils] Ensure function paths are relative to the project and improve the error message
* Update packages/now-build-utils/src/detect-builders.ts
Co-Authored-By: Steven <steven@ceriously.com>
* Update packages/now-build-utils/src/detect-builders.ts
Co-Authored-By: Steven <steven@ceriously.com>
- Add now dev `BuildResultV4` type similar to V3 but no routes, only superstatic keys
- Add validation to `@now/routing-utils` to ensure V4 Builders do not return `routes`
Note, no builders have been changed yet because this needs to be shipped first so we can bump build-utils and then builders will work in production. Then in a separate PR, we can update builders to V4.
Fixes#3310
The root `package.json` file is copied to `dist` by tsc because of a relative import. This causes npm `files` property to be nested and therefore skip publishing most of the files.
```ts
import pkg from '../../package.json';
```
Disabling `resolveJsonModule` and using `require()` instead fixed it.
However, this change caused `now-cli` build to fail so I had to change the way `now-client` gets imported.
Previously, the `typescript` dependency resolution was using the package.json beside the `now.json` base directory.
This PR changes the behavior to start looking for package.json in the entrypoint directory.
Fixes#3258
This test was failing for the last week.
The issue was fixed in the build environment. The root cause was [ruby-build](https://github.com/rbenv/ruby-build) which is used to install the version of Ruby used in `@now/ruby`. It started using an older (possible broken) version of `bundler`. I pinned `ruby-build` to a previous version so that deployments continue working.
So now we can enable the Rails test again (which uses nokogiri).
Fixes#3246Closes#3274
This PR is an attempt to automatically inject `gatsby-plugin-now` in Gatsby projects, as an optimisation.
- [x] avoid conflicts with existing files
- [x] refactor
* [now-node] Use builder version 3
* [now-cgi] Use builder version 3
* [now-go] Use builder version 3
* [now-python] Use builder version 3
* [now-ruby] Use builder version 3
* Adjust docs
* [now-ruby] Remove unused import
* Temp. test in iad1
* Revert "Temp. test in iad1"
This reverts commit 4c495baa5888dda5ae8f184f679613e91ab7268c.
* [now-cli] Adjust `now dev` for builder version 3
* [now-build-utils] Do not allow non Community Runtimes
* Temp. Force Build in iad1
* Update DEVELOPING_A_RUNTIME.md
Co-Authored-By: Steven <steven@ceriously.com>
* Update docs
* Update test/lib/deployment/now-deploy.js
Co-Authored-By: Steven <steven@ceriously.com>
* Remove temp. iad1 check
* Check memory and maxDuration
* Use memory for Lambda
* Only cast once
* Skip tests
* Allow functions + next.js
* Don't allow empty or invalid functions
* Make sure runtimes match a source
* Update now-dev to use the functions property
* Functions must match a source file
* Split up functions
* Make sure @now/next does not receive any unused functions
* Allow memory and maxDuration properties on Lambdas
* Add lambda options to @now/node
* Add lambda options to @now/go
* Add lambda options to @now/python
* Add lambda options to @now/ruby
* Update lambda options on @now/node
* Add lambda optiosn to @now/cgi
* Make options optional
* Add lambda options to @now/next
* Fix assertion
* Add test
* Fix tests
* Skip 06-ruby test
* Skip correct tests
* Fix options and cache src check
* Adjust memory test
Fix https://github.com/zeit/now/issues/3247.
Adds `.cache` folder to the Now cache for Gatsby deployments.
Also adds a generic optional `cachePattern` property to the frameworks array so we can optimize cache paths for other frameworks in the future.
This PR implements `cleanUrls` for now dev which is similar to the implementation in fmeta-util.
I also added an integration test to ensure correctness.
This PR fixes a regression introduced in #3174 when removing the `^` and `$` normalization.
The previous PR was normalizing user-defined routes but forgot to normalize builder routes.
This PR normalizes builder routes 👍
This PR does 3 things:
- add default caching headers
- redirect all missed requests to Gatsby's own 404.html page
- add deprecation message to `gatsby-plugin-now` since we're auto injecting it and it's not needed anymore
Fixes#2859
This allows us to start de-coupling the builder from relying on inner utils of Next.js to generate dynamic routes for Now by leveraging a `routes-manifest` output during the build
Relies on: https://github.com/zeit/next.js/pull/9347
There was a regression since 16.3.0 (now-client refactor) causing file permissions for source files to be not be preserved.
The solution was to add the FS `mode` to each file.
Fixes#3172
This PR updates the link to the missing build script FAQ, pending a change to the structure of the documentation.
This PR should be merged only when the documentation PR has been - https://github.com/zeit/docs/pull/1423
If someone uses a wildcard in the root of pages, it could collide with internal `_next` files:
```
pages/
[slug]/
[slug]/
[slug]/
[slug].js
```
For example:
`/_next/static/runtime/webpack-hash.js` exists and has no problem routing
`/_next/static/runtime/webpack-old-hash.js` doesn't exist on the server any more but would route to `/[slug].js` with status 200
This could cause strange edge cases related to loading a new version of a Next.js site along with the possible cost of execution if it's a lambda plus the cost of however large the response is.
# Side Notes
Should this:
92d9f2d809/packages/now-next/src/index.ts (L839)
Instead be this?
```
src: path.join('/', entryDirectory, '_next/static/(?:[^/]+/pages|chunks|runtime|css|media)/.+'),
```
If this is the case, I need to adjust my PR to do the same
* [now-cli][now-client] Add support for `functions` property
* Fix typo
* Update yarn.lock for test
* Update all yarn.lock files for now dev
* Log fixture that failed
* Use catch instead
* Run dev tests not serial
* Revert "Run dev tests not serial"
This reverts commit bfcd83642bcd2275daaac129b2c8b233f582eaae.
* Do not throw
* Skip nextjs tests on node 8
* Remove only flag
* Ignore 19-mithril
* Revert "Ignore 19-mithril"
This reverts commit d438c40c26a8ef2227a0a0dd7caba8600503d585.
* Revert "Remove only flag"
This reverts commit caff05ad82a184706eb48b6b39df550f8d17bb1d.
* Revert "Skip nextjs tests on node 8"
This reverts commit 3b45ca33b969a56da0bccce4c95cae3b34af98e0.
* Revert "Do not throw"
This reverts commit 55624b9193d7751e1dc16cbee9005fe23ff19662.
* Revert "Revert "Run dev tests not serial""
This reverts commit cd5260a205b6478cb7a44c9ea982b99f26f2f2e9.
* Revert "Run dev tests not serial"
This reverts commit bfcd83642bcd2275daaac129b2c8b233f582eaae.
* Revert "Use catch instead"
This reverts commit fe652995c08e1e8b2ba581aaf7304b5432718161.
* Revert "Log fixture that failed"
This reverts commit feb0e7b393626ce1c117ef95f9e95f7a148e3dab.
* Revert "Update all yarn.lock files for now dev"
This reverts commit 36be4dd98ca6d65850843dc958727952dd7461ee.
* Update yarn.lock for 14-svelte-node
* Update es-abstract in all yarn.lock files
* Skip node test
* Revert "Skip node test"
This reverts commit c9c45ec8d6fcef13cbd300db410699b167d76ed2.
* Remove test.only
* Only execute node test in now-dev
* Revert "Only execute node test in now-dev"
This reverts commit 8ab7a88d696c1faa5fe0fbcca9dcfb0dd375925f.
* Clean cache on macos node8
* Fix query
* Use --skip-integrity-check
* Add --skip-integrity-check to different yarn call
* Add --network-concurrency 1
* Add retry
This fixes the scenario where the user defines `trailingSlash: true` and creates a file `/api/users.js`. They would expect to be able to visit `/api/users/` and it should run that function.
This PR removes the individual lambda zip prints since they're not very useful. We've already printed this information above and will time them as a group!
This fixes the scenario when both `{ cleanUrls: true, and trailingSlash: true }` so that only one redirect occurs when visiting `/file.html`.
Previously, this would have redirected twice from `/file.html` => `/file` => `/file/`.
Now it will redirect once from `/file.html` => `/file/`.
This PR refactors a few things:
- enhance validation so that invalid regex is caught before transforming to routes
- remove `filePaths` input parameter since it is no longer used
After this PR is merged and released, we'll be able to perform validation earlier in the build pipeline and report the errors to the user.
* [now-build-utils] Validate functions and allow them as config
* Apply suggestions from code review
Co-Authored-By: Steven <steven@ceriously.com>
* Change memory check
* Adjust test
We used to read the output files and create a route for each redirect when `cleanUrls: true`.
Instead, this PR will add 2 redirects for `cleanUrls: true` no matter how many files are in the outputs.
This updates `@now/build-utils` to add support for the function property including types and tests.
Related: [PRODUCT-27]
[PRODUCT-27]: https://zeit.atlassian.net/browse/PRODUCT-27
This allows us to start de-coupling the builder from relying on inner utils of Next.js to generate dynamic routes for Now by leveraging a `routes-manifest` output during the build
Relies on: https://github.com/zeit/next.js/pull/9347
* [now-node] Use builder version 3
* [now-cgi] Use builder version 3
* [now-go] Use builder version 3
* [now-python] Use builder version 3
* [now-ruby] Use builder version 3
* Adjust docs
* [now-ruby] Remove unused import
* Temp. test in iad1
* Revert "Temp. test in iad1"
This reverts commit 4c495baa5888dda5ae8f184f679613e91ab7268c.
* [now-cli] Adjust `now dev` for builder version 3
* [now-build-utils] Do not allow non Community Runtimes
* Temp. Force Build in iad1
* Update DEVELOPING_A_RUNTIME.md
Co-Authored-By: Steven <steven@ceriously.com>
* Update docs
* Update test/lib/deployment/now-deploy.js
Co-Authored-By: Steven <steven@ceriously.com>
* Remove temp. iad1 check
* Check memory and maxDuration
* Use memory for Lambda
* Only cast once
* Skip tests
There was a regression since 16.3.0 (now-client refactor) causing file permissions for source files to be not be preserved.
The solution was to add the FS `mode` to each file.
Fixes#3172
Fix https://github.com/zeit/now/issues/3247.
Adds `.cache` folder to the Now cache for Gatsby deployments.
Also adds a generic optional `cachePattern` property to the frameworks array so we can optimize cache paths for other frameworks in the future.
After upgrading to macOS Catalina I get this error on some now-deploys:
```
> Error! ENOENT: no such file or directory, stat '<file that not exist>'
```
and the file is below a folder that should be ignored by `.nowignore`, think this is due to some fs-bug in my node version, but did also discover that the ignore-array returned from `getNowIgnore` did not include the ignores from my `.nowignore`, but only the default defined in the top of the function.
Is this a bug?
* Allow functions + next.js
* Don't allow empty or invalid functions
* Make sure runtimes match a source
* Update now-dev to use the functions property
* Functions must match a source file
* Split up functions
* Make sure @now/next does not receive any unused functions
* Allow memory and maxDuration properties on Lambdas
* Add lambda options to @now/node
* Add lambda options to @now/go
* Add lambda options to @now/python
* Add lambda options to @now/ruby
* Update lambda options on @now/node
* Add lambda optiosn to @now/cgi
* Make options optional
* Add lambda options to @now/next
* Fix assertion
* Add test
* Fix tests
* Skip 06-ruby test
* Skip correct tests
* Fix options and cache src check
* Adjust memory test
This PR updates the link to the missing build script FAQ, pending a change to the structure of the documentation.
This PR should be merged only when the documentation PR has been - https://github.com/zeit/docs/pull/1423
If someone uses a wildcard in the root of pages, it could collide with internal `_next` files:
```
pages/
[slug]/
[slug]/
[slug]/
[slug].js
```
For example:
`/_next/static/runtime/webpack-hash.js` exists and has no problem routing
`/_next/static/runtime/webpack-old-hash.js` doesn't exist on the server any more but would route to `/[slug].js` with status 200
This could cause strange edge cases related to loading a new version of a Next.js site along with the possible cost of execution if it's a lambda plus the cost of however large the response is.
# Side Notes
Should this:
92d9f2d809/packages/now-next/src/index.ts (L839)
Instead be this?
```
src: path.join('/', entryDirectory, '_next/static/(?:[^/]+/pages|chunks|runtime|css|media)/.+'),
```
If this is the case, I need to adjust my PR to do the same
This PR implements `cleanUrls` for now dev which is similar to the implementation in fmeta-util.
I also added an integration test to ensure correctness.
This PR fixes a regression introduced in #3174 when removing the `^` and `$` normalization.
The previous PR was normalizing user-defined routes but forgot to normalize builder routes.
This PR normalizes builder routes 👍
* [now-cli][now-client] Add support for `functions` property
* Fix typo
* Update yarn.lock for test
* Update all yarn.lock files for now dev
* Log fixture that failed
* Use catch instead
* Run dev tests not serial
* Revert "Run dev tests not serial"
This reverts commit bfcd83642bcd2275daaac129b2c8b233f582eaae.
* Do not throw
* Skip nextjs tests on node 8
* Remove only flag
* Ignore 19-mithril
* Revert "Ignore 19-mithril"
This reverts commit d438c40c26a8ef2227a0a0dd7caba8600503d585.
* Revert "Remove only flag"
This reverts commit caff05ad82a184706eb48b6b39df550f8d17bb1d.
* Revert "Skip nextjs tests on node 8"
This reverts commit 3b45ca33b969a56da0bccce4c95cae3b34af98e0.
* Revert "Do not throw"
This reverts commit 55624b9193d7751e1dc16cbee9005fe23ff19662.
* Revert "Revert "Run dev tests not serial""
This reverts commit cd5260a205b6478cb7a44c9ea982b99f26f2f2e9.
* Revert "Run dev tests not serial"
This reverts commit bfcd83642bcd2275daaac129b2c8b233f582eaae.
* Revert "Use catch instead"
This reverts commit fe652995c08e1e8b2ba581aaf7304b5432718161.
* Revert "Log fixture that failed"
This reverts commit feb0e7b393626ce1c117ef95f9e95f7a148e3dab.
* Revert "Update all yarn.lock files for now dev"
This reverts commit 36be4dd98ca6d65850843dc958727952dd7461ee.
* Update yarn.lock for 14-svelte-node
* Update es-abstract in all yarn.lock files
* Skip node test
* Revert "Skip node test"
This reverts commit c9c45ec8d6fcef13cbd300db410699b167d76ed2.
* Remove test.only
* Only execute node test in now-dev
* Revert "Only execute node test in now-dev"
This reverts commit 8ab7a88d696c1faa5fe0fbcca9dcfb0dd375925f.
* Clean cache on macos node8
* Fix query
* Use --skip-integrity-check
* Add --skip-integrity-check to different yarn call
* Add --network-concurrency 1
* Add retry
This fixes the scenario where the user defines `trailingSlash: true` and creates a file `/api/users.js`. They would expect to be able to visit `/api/users/` and it should run that function.
This PR removes the individual lambda zip prints since they're not very useful. We've already printed this information above and will time them as a group!
This fixes the scenario when both `{ cleanUrls: true, and trailingSlash: true }` so that only one redirect occurs when visiting `/file.html`.
Previously, this would have redirected twice from `/file.html` => `/file` => `/file/`.
Now it will redirect once from `/file.html` => `/file/`.
This PR does 3 things:
- add default caching headers
- redirect all missed requests to Gatsby's own 404.html page
- add deprecation message to `gatsby-plugin-now` since we're auto injecting it and it's not needed anymore
Fixes#2859
This PR refactors a few things:
- enhance validation so that invalid regex is caught before transforming to routes
- remove `filePaths` input parameter since it is no longer used
After this PR is merged and released, we'll be able to perform validation earlier in the build pipeline and report the errors to the user.
* [now-build-utils] Validate functions and allow them as config
* Apply suggestions from code review
Co-Authored-By: Steven <steven@ceriously.com>
* Change memory check
* Adjust test
We used to read the output files and create a route for each redirect when `cleanUrls: true`.
Instead, this PR will add 2 redirects for `cleanUrls: true` no matter how many files are in the outputs.
This updates `@now/build-utils` to add support for the function property including types and tests.
Related: [PRODUCT-27]
[PRODUCT-27]: https://zeit.atlassian.net/browse/PRODUCT-27
This PR is an attempt to automatically inject `gatsby-plugin-now` in Gatsby projects, as an optimisation.
- [x] avoid conflicts with existing files
- [x] refactor
There have been Sentry errors where `process.cwd()` fails and throws an error. This patch handles that scenario gracefully by printing a more clear error message to the user and avoids sending a report to Sentry.
Fixes#3193.
* Update version of deployment API
* Add `alias-assigned` event and handling
* Replace v9 api with v10
* Don't return on immediate ready
* Handle alias-assigned for v1 deployments
* Improve event ordering
* Detect upload deployment readiness by `alias-assigned`
* rebuild
* Fix upload readiness event type
* Check for aliases before running status checks
* Improve event flow and wait for `ready` in v1 deployments
* Remove console.log
Disables `--user` parameter of the `pip` utility, which is forcibly set under the hood on Debian systems and causes an error in the `pipInstall` function:
`distutils.errors.DistutilsOptionError: can't combine user with prefix, exec_prefix/home, or install_(plat)base`
Fixes#3089
This PR disables Now 1.0 production deployments with the following error message:
> Option --prod is not supported for Now 1.0 deployments. To manually alias a deployment, use `now alias` instead.
It looks like this:
<img width="835" alt="Capture d’écran 2019-10-23 à 19 42 09" src="https://user-images.githubusercontent.com/6616955/67419574-3e125380-f5cd-11e9-81ff-63bde292539b.png">
Also disables `--target` for Now 1.0 deployments.
* Update version of deployment API
* Add `alias-assigned` event and handling
* Replace v9 api with v10
* Don't return on immediate ready
* Handle alias-assigned for v1 deployments
* Improve event ordering
* Detect upload deployment readiness by `alias-assigned`
* rebuild
* Fix upload readiness event type
* Check for aliases before running status checks
* Improve event flow and wait for `ready` in v1 deployments
* Remove console.log
When `cleanUrls` is true, the redirects will be applied to the routes however there are no longer any rewrites. Instead (through a different PR to fmeta-util) we will rename the file output to remove the `.html` extension.
When `cleanUrls` is true, the redirects will be applied to the routes however there are no longer any rewrites. Instead (through a different PR to fmeta-util) we will rename the file output to remove the `.html` extension.
There have been Sentry errors where `process.cwd()` fails and throws an error. This patch handles that scenario gracefully by printing a more clear error message to the user and avoids sending a report to Sentry.
Fixes#3193.
This PR disables Now 1.0 production deployments with the following error message:
> Option --prod is not supported for Now 1.0 deployments. To manually alias a deployment, use `now alias` instead.
It looks like this:
<img width="835" alt="Capture d’écran 2019-10-23 à 19 42 09" src="https://user-images.githubusercontent.com/6616955/67419574-3e125380-f5cd-11e9-81ff-63bde292539b.png">
Also disables `--target` for Now 1.0 deployments.
Disables `--user` parameter of the `pip` utility, which is forcibly set under the hood on Debian systems and causes an error in the `pipInstall` function:
`distutils.errors.DistutilsOptionError: can't combine user with prefix, exec_prefix/home, or install_(plat)base`
Fixes#3089
This PR is a followup to #3138 so that `now dev` will validate and transform the following `now.json` config keys to routes:
- cleanUrls
- rewrites
- redirects
- headers
- trailingSlash
[PRODUCT-341] #close
[PRODUCT-341]: https://zeit.atlassian.net/browse/PRODUCT-341
This PR adds a `contentType` to the File interface.
This is necessary for [PRODUCT-341] to work properly with `cleanUrls` which will strip the file name but we will still need specify `contentType: 'text/html'`.
This is required for @dav-is `api-builds` PR 633 to work properly.
[PRODUCT-341]: https://zeit.atlassian.net/browse/PRODUCT-341
The `@now/node` helpers json parsing is too strict and doesn't match the behavior of Express when an incoming request has `{ method: 'POST', Content-Type: 'application/json', body: '' }`.
Instead of returning 400, this PR will continue with `body = {}` to match Express.
Fixes https://spectrum.chat/zeit/now/klarna-with-zeit-now~60852003-4db6-4ec4-a611-83b2349ece08
This PR does a few things
- Separate tests into `integration.test.js` and `unit.test.js`
- Use one static build instead of many to avoid `should NOT have more than 128 items` error
- Add a new unit test so we don't regress
Fixes#3159
This implements a new function `getTransformedRoutes()` which transforms some [superstatic](https://github.com/firebase/superstatic#configuration) configuration keys to Now routes so we can eventually use this new keys in `now.json`.
In particular, the following new keys are transformed to `routes`.
- cleanUrls
- rewrites
- redirects
- headers
- trailingSlash
[PRODUCT-341] #close
[PRODUCT-341]: https://zeit.atlassian.net/browse/PRODUCT-341
Our tests periodically fail because we're creating too many v1 deployments on a free plan and it times out.
This limits the number of deployments by running v1 exclusively under Node 12.
It also adds a missing waitForDeployment().
This makes it so that a programatically created `DevServer` instance that has `debug` mode enabled also gets set on the builder child processes as expected, rather than only when invoked via CLI.
For example, the `dev-server.unit.js` tests can set `debug: true` and with this change the builder child processes will also have debug logs enabled. See [here](https://git.io/JeW0O).
Explicitly send the SIGINT / SIGTERM signal to `now dev` server child processes, so that they are not left running when running the now-dev unit tests.
Related to #3113 which has hanging unit tests that never "complete".
Explicitly send the SIGINT / SIGTERM signal to `now dev` server child processes, so that they are not left running when running the now-dev unit tests.
Related to #3113 which has hanging unit tests that never "complete".
This PR should fixes `ENOENT` related errors
```
> Error! ENOENT: no such file or directory, stat '.../node_modules/.bin/...'
```
Related: https://github.com/zeit/now/issues/3104
As of https://github.com/zeit/now-builders/pull/679, this logic is unnecessary because the `@now/static-build` builder will never end up executing the `dev` script when there is a `now.json` file present (and thus, no builds present, aka zero config mode).
Also, statically detecting the `now dev` command from the script command is brittle, as the command could execute a separate shell script that ends up executing `now dev` (and this detection logic would be a false negative).
This is a follow up to #3117 which added a fix for `files` but did not observe directories.
This PR fixes the scenario where a directory is defined such that all files inside the directory should be added uploaded (recursively).
Thanks to @williamli
[PRODUCT-350] #close
[PRODUCT-350]: https://zeit.atlassian.net/browse/PRODUCT-350
Since `@now/static-build` is no longer sniffing the stdio streams for the bound port number in `now dev`, there's no need to have separate stdio streams for the "dev" script. Instead, inherit stdio from the parent process, which will allow for ANSI colors to be used when stdout is a TTY in `now dev`.
Also simplifies the `checkForPort()` function and removes the `promise-timeout` dependency.
When now-client was implemented, it did not work with `--local-config` flag from now-cli because the only parameters it looks at are the files in a directory.
This fixes the regression in now@16.3.0 so that now-client can accept an optional `nowConfig` object or fallback to the `now.json` file.
Fixes#3099Fixes#3105Fixes#3107Fixes#3109
[PRODUCT-350] #close
[PRODUCT-350]: https://zeit.atlassian.net/browse/PRODUCT-350
For context, when you have a script that generates a new static file at build time (`sitemap.xml` for example), it has to be inside `.next/static`, and then you'll need a Now route for it, with this change you could generate the file inside `public`/`static` and the builder will now take care of it.
The util `includeOnlyEntryDirectory` is no longer being used after this change, should I remove it?
This PR integrates v2 of Projects API that fixes an issue for projects named `list` or `remove`, because of the naming of the endpoints in v1. For listing all projects, previously in v1 it was `GET /v1/projects/list` and now it is `GET /v2/projects/`, and for removing a project it was `DELETE /v1/projects/remove`.
It will print `[v2]` for 1.0 deployments when logging initially:
```
• go $ now --force
> WARN! You are using an old version of the Now Platform. More: https://zeit.co/docs/v2/advanced/platform/changes-in-now-2-0
> Deploying ~/projects/zeit/now-builder-v1/examples/docker/go under andyschneider
> Using project now-v1-go-docker
> now-v1-go-docker-xxxxxxx.now.sh [v2] [1s]
> Build completed
> https://now-v1-go-docker-xxxxxxx.now.sh [v1] [in clipboard] (sfo1) [1m]
> Verifying instantiation in sfo1
> ✔ Scaled 1 instance in sfo1 [22s]
> Success! Deployment ready
```
Expected:
```
• go $ nowl --force
> WARN! You are using an old version of the Now Platform. More: https://zeit.co/docs/v2/advanced/platform/changes-in-now-2-0
> Deploying ~/projects/zeit/now-builder-v1/examples/docker/go under andyschneider
> Using project now-v1-go-docker
> now-v1-go-docker-xxxxxxx.now.sh [v1] [2s]
> Build completed
> https://now-v1-go-docker-xxxxxxx.now.sh [v1] [in clipboard] (sfo1) [1m]
> Verifying instantiation in sfo1
> ✔ Scaled 1 instance in sfo1 [23s]
> Success! Deployment ready
```
For v2 it shouldn't print anything, as it's the default.
This makes downstream compilation with `tsc` work correctly.
Otherwise, compilation fails with errors such as:
```
../now-client/dist/src/index.d.ts:1:40 - error TS2304: Cannot find name 'CreateDeploymentFunction'.
1 export declare const createDeployment: CreateDeploymentFunction;
~~~~~~~~~~~~~~~~~~~~~~~~
````
As of https://github.com/zeit/now/pull/3081, we make it necessary to group `Prerenders` together for being invalidated at the same time.
However, you might not want that. In turn, we'll make it optional.
This pull request removes the `PrerenderGroup` type in favor of a `group` parameter for the existing `Prerender` type.
This parameter takes in an integer that defines a group of prerenders that should be invalidated at the same time:
```
interface Prerender {
expiration: number;
lambda: Lambda;
fallback: FileBlob | FileFsRef | FileRef;
group: number;
}
```
**Example:** If two `Prerender` instances exist that have `group` set to `1`, they will both be invalidated at the same time.
This PR adds extensive debug logging to `now-client` and enables it in CLI based on the `--debug` flag
Debug logging works in either of the following two conditions:
- `debug: true` is provided in the `options` object of `createDeployment`/`createLegacyDeployment`
- `process.env.NOW_CLIENT_DEBUG` environment variable is set
Previously, if you ran `now ls` with a URL for a path alias, then an
error message `Cannot read property 'replace' of undefined` would occur.
Now, a message is logged saying to instead run `now alias ls $url` which
is the correct command to get path rules relevant to a path alias URL.
> Found matching path alias: rules.domain.com
> Please run `now alias ls rules.domain.com` instead
Fixes#2987.
* [now-static-build] Run `bundle install` for Gemfile
* Add logs
* Add timeout in case proc hangs
* Rename test
* Remove console.log()
* Hide warnings
* Use runBundleInstall()
* [now-build-utils] Remove --deployment flag
* Run tests for build-utils
* [now-build-utils] Add function `runBundleInstall`
* Add additional flags
* Set jobs to number of cpus
* Format
* Fix formatting
* Add BUNDLE_APP_CONFIG
* [now-static-build] Fix dev server detection
* Code review
* Remove unused dependency
* Fix the checking by really waiting until the port is reachable
* [now-build-utils][now-cli] Warn instead of throwing on `api` and `pages/api`
* Remove slash and adjust tests
* Remove @now/build-utils
* Hardcode builders
* Add build-utils
* Change default flag
* More logging
* Add static-build
* Remove other packages from package.json
* New file for bundled function
No functionality change here, this just removes the `Package` and
`BuildConfig` types from `src/util/dev/types.ts` in favor of the
matching types from `@now/build-utils`.
Also a lot of prettier formatting…
* [now-cli] Fix `now certs ls` when the user or team has no certs
* Add tests and move to typescript
* Move index and add to typescript
* Fix reduce function in ls
* Added linebreak
* Update packages/now-cli/src/commands/certs/add.ts
Co-Authored-By: Naoyuki Kanezawa <naoyuki.kanezawa@gmail.com>
* [now-cli] Install dependencies before running `now dev` in tests
* Check install exit code
* Add more logging
* Add more logging
* More logging
* Include yarn.lock file
* Add lock files to dev fixtures
* Ignore test
* Ignore another test
* Ignore another test
* Whitespace
* Install deps for unit tests
* Whitespace
* add gatsby-plugin-now
* add test
* adjust with lerna
* fix test
* add tests to circleci
* add support for defaultRoutes functions
* add defaultRoutes to gatsby
* fix types
* add test case for gatsby redirects
* remove gatsby, react, react-dom from monorepo deps
* chmod +x build.sh
* add missing build script in fixtures
* do stuff during tests to avoid persistence issue
* move tests setup to build step
* copy gatsby plugin files in test case
* bring back ncc step
* prettier gatsby-plugin-now
* add missing semicolons
* remove eslint, prettier from plugin
* persist build step copied file
* fetch without following redirects
* add files in package.json
* remove force
* fix tests probes
* fetch location is not raw location
* fix test
* add readme
* fix type error
* adjust tests
* add support for `force`
* add tests for `force`
* adjust tests again
* gatsby-plugin-now@1.1.0
* `"` -> `'`
* tweak redirect names in test by precaution
* change file name and delete when consumed
* format files
* gatsby-plugin-now@1.2.0
* Apply suggestions from code review
Co-Authored-By: Steven <steven@ceriously.com>
* tests -> test
* add --verbose
* adjust circleci to persist fixtures
* trigger tests
* add repository and homepage in package.json
* glob files after `defaultRoute` invocation
No improvements, per say, but the module has been converted to
TypeScript so it supplies its own type definitions now, and we
can delete our hand-crafted typings from this repo.
* [now-cli] Use `xdg-app-paths` for `now dev` cache dir
For consistency, because #2877 uses this module.
No need for multiple modules that do the same thing.
* Update `@zeit/fun` to v0.9.3
* Use XDG standard instead of writing to home directory
* Fix typos
* Use dependencies as dev dependencies
* Remove lodash dependency
* Use xdg-app-paths instead of xdg-portable
* use find instead of filter(...)[0]
Otherwise, JavaScript Object built-ins such as `hasOwnProperty` are
incorrectly considered a valid subcommand, but fail afterwards with
a `require()` error and confusing error message.
* Optimize zipping lambdas for now-next
* Update to use jszip to get around bug in yazl
* Add pseudo layer utils
* Apply suggestions from code review
Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>
* Update sema concurrency from tests
* Update packages/now-next/src/index.ts
* Use custom types to fix broken @types package
* Add license header
* Revert "Use custom types to fix broken @types package"
This reverts commit 82441285155f6e0899c43dffdd5e000ecbd7b1b6.
* Fix CI Yarn installation
* TypeScript types should never be hoisted
* Fix all typechecking
* [now-cli] Validate inputs for alias, list and remove
* Log test output
* Add more logging to test
* Change to execa
* Use `split`
* Only validate when it exists
* [now-cli] Change success message after login
* Linting
* Test now login
* Linting
* Revert "Test now login"
This reverts commit 690360db3f148552a456b4ee1bd2a59b8d09216c.
* Revert "Linting"
This reverts commit 3d5ebfaa76ecdcc2152c8344c8e1205b241abe09.
* Adjust test
* Remove binaryPath from args
* Fix loggin test
This enables https://github.com/zeit/now-cli/pull/2747 from @nkzawa again.
We had to revert the previous one, because we didn't want to include it in
the next stable release.
This further makes sure that we don't display `https://` in front of a
wildcard alias, since `https://*.mydomain.tld` is not a valid URL.
* [now-go] Use `debug()` from build-utils (#923)
* Use `debug()` from build-utils
* Apply suggestions from code review
Co-Authored-By: Steven <steven@ceriously.com>
* Print errors
* Apply suggestions from code review
Co-Authored-By: Steven <steven@ceriously.com>
* [now-cli] Validate builds and routes for `now dev`
* Remove @ts-ignore
* Sort the matches such that `utils` modules are compiled first
Because other packages may rely on them
* Prettier
* Add `reject: false` to tests
* Prettier
* Make validation async
* Fix syntax
* Fix type
* Linting
* Fix error check
* [now dev] Update `yarn` to v1.17.3
* Wait longer for angular integration test
It keeps on failing
* Only run angular test on Node 10.x
* Revert "Wait longer for angular integration test"
This reverts commit 19d70d4ba9aee49a5114b65f00ef97e2a88dc7ef.
* Update links to `now-builders` repo to `now` repo
Also copies over the `.md` files from the now-builders' `errors`
directory so that the https://err.sh links work correctly.
Part of #2782.
* Update `err.sh` links that were formerly `now-cli`
* Empty commit for CI
* Make CircleCI `run.sh` script a bit better
Before it would fail with exit code 1 if there were no matching modified
files because of the `grep` call failing without any `packages` prefixed
files.
* [tests] Change run script from bash to node
* Fix loop for runScript
* Fix `all` script test
* Improve console.log() messages
* Use -l instead of -p
* Delete yarn.lock from now-python
* Move now-cli to /packages/now-cli
* Fix .gitignore paths
* Add now-client
* Add lerna to top level
* Add scripts
* Update codeowners
* Fix `/now-cli/build.ts` script
* Fix circleci path to artifacts
* Use relative paths
* Fix path to scripts
* Add test-lint script
* Add missing return type
* Fix typo in test-lint
* Fix string match in shell scripts
* Fix path to hugo
* Add package node_modules
* Delete lock files in packages, use root yarn.lock
* Add missing b.js file
* Add test-integration-now-dev script
* Add missing test files
* Add missing integration test script
* Add missing test files
* Delete travis.yml
* Fix ts-jest in now-client
* Add support for Node 8 (ES2015 target)
* Add support for Node 8
* Add polyfill for Node 8
* Fix polyfill for Node 8
* Only run coverage for now-cli
* Add packages from now-builders
* Run integration tests for builders
* Add node_modules to cache
* Add root readme.md
* Move readme to top level
* Add yarn bootstrap
* Add bootstrap step
* Add dist to `persist_to_workspace`
* Fix 08-yarn-npm integration test
* Remove duplicate path
* Change stdio to inherit
* Add back store_artifacts
* testing - remove bootstrap step
* Add back now-build-utils
* Remove bootstrap step
* Fix test again
* Add console.log()
* Fix lint
* Use local ncc version
* Install go
* Revert changes to stdio and console.log()
* Add missing now-go test
* Add missing integration tests
* Add --runInBand flag
* Fix now-node-bridge persistence
* Add missing symlinks
* Add codeowners
* Consolidate into single run.sh function
* Run uniq
* Fix typo
* Change now-routing-utils to test-unit
* Special case test for node 8
* Add docs from builders
* Only run script for modified packages
* Add test-integration-once which only runs once
* Fix set intersection
* [now deploy] Add `--production` and `--staging` flag
* Change message
* Fix tests
* Fix test
* Add another test
* Fix production test
* Update message and add `--prod`
* Update help
* Remove `--staging`
* Use only `--prod`
* Add test
* Add aliasError output
* Fix output
* [now rm] Use the proper `client` so that the process does not hang
The crux of this fix is that `getDeploymentByIdOrHost()` and
`getProjectByIdOrName()` were improperly being passed the `Now`
instance instead of the expected `Client` instance, and for some
reason that would cause the process to hang until the underlying
`http.Agent` timed out its connection to the API server.
Also ran `prettier` on this file.
Fixes#2760.
* Remove `console.error()`
* Add integration test
* Fix syntax error
* Add `now rm` 404 integration test
* Remove `.only`
* Use canary builders for the canary version
* Use the `getDistTag` function instead
* Fix function call
* Add tests
* Remove unused code
* Remove logging
* [now dev] Add `--bind` / `-b` flag
This changes the default network interface that `now dev` binds to, in
order to prevent operating system firewalls from showing a confirmation
prompt in order to run.
Fixes#2704.
* Change to `--listen`
* Default port 3000
* Fix unit
* Fix `--port`
* Use `-l` for integration tests
* Add unit tests
* [now update] Show correct global or local install command
* Remove `canRead` check
* Change bin to lib since the actual script will be there
* Use realpath
* Remove console.error
All of the APIs already support JSON by default, so this is a no-op for
our APIs, however the proxy layer _does_ respect the `Accept` header to
send JSON error responses, which is useful for more gracefully handling
outage responses (previously they were being returned as plain text,
which Now CLI blindfully tries to parse as JSON and fails with an
unhelpful error message).
Related to #2681.
For some reason, `ava` was silently skipping these tests on CI because
the process was crashing. According to sindre, this is a bug in `ava`,
but with some digging I was able to determine that the root cause of the
crash was that the `builders.tar.gz` file from the `assets` dir was not
being persisted from the previous `build` job in CI.
With the `assets` dir being persisted I now see the `dev-server` unit
tests being executed once again as expected.
Related to: https://twitter.com/sindresorhus/status/1157614353375551493
* [now deploy] Use the project when checking the platform version
* Update src/util/prefer-v2-deployment.ts
Co-Authored-By: Leo Lamprecht <mindrun@icloud.com>
* Update src/util/prefer-v2-deployment.ts
Co-Authored-By: Leo Lamprecht <mindrun@icloud.com>
* Adjust message
* Fallback for local config
* [now update] Show correct global or local install command
* Remove `canRead` check
* Change bin to lib since the actual script will be there
* Use realpath
* Remove console.error
This changes the default network interface that `now dev` binds to, in
order to prevent operating system firewalls from showing a confirmation
prompt in order to run.
Fixes#2704.
* [now dev] Render warning upon empty `cwd` directory
The warning matches the one that `now deploy` prints, and only
prints the warning once (rather then upon every HTTP request).
Closes#2696.
* Fix eslint warning
* Add "pipe"
* Debugging…
* Fix integration test
* Debugging…
* Add `--verbose` to "test-integration-now-dev" script
* Ignore `yarn.lock` and `node_modules` in test dir
* Ignore `hugo` binary
* Ignore `public` dir in hugo test fixture
* Add `.gitignore` to `empty` test fixture
* Revert "Debugging…"
This reverts commit 27c6d2e06fe7eff12077a0e88915cf46b39b00ea.
* Ignore `public` / `dist` dirs in fixtures
This is to prevent false-positives like this from occurring,
and fixes the warning from `node`:
```
$ ts-node ./scripts/build.ts
Creating builders tarball with: @now/build-utils@canary, @now/go@canary, @now/next@canary, @now/node@canary, @now/php@canary, @now/static-build@canary
(node:156) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '/home/circleci/repo/assets/builders.tar.gz'
at ReadStream.evt.error.err (/home/circleci/repo/node_modules/promisepipe/index.js:30:23)
at ReadStream.emit (events.js:198:13)
at ReadStream.EventEmitter.emit (domain.js:448:20)
at /home/circleci/repo/node_modules/graceful-fs/graceful-fs.js:207:14
at /home/circleci/repo/node_modules/graceful-fs/graceful-fs.js:258:16
at FSReqWrap.args [as oncomplete] (fs.js:140:20)
(node:156) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:156) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
```
* [now deploy] Check if builds are ready right away
* Adjust tests
* Remove test
* Log more while testing
* Remove check in tests
* Adjust all tests
* Log more
* [now dev] Support JSON and HTML redirect responses
Matches the production behavior.
* Set Now response headers during redirect
* Set `location` header
* Remove unused `matched_route` var
* [now dev] Allow custom 404 pages via `routes`
This matches the behavior in production, which allows a `dest` to be
provided when defining a `status: 404` in the routes configuration.
Related to #2638.
* Fix typo
* [preinstall/now update] Check if now is installed locally and adjust messages
* Adjust test
* Add tests
* Wait for deployment to be ready
* Removed log
* Adjust prefix in test
* Adjust path
* Only wait 4 minutes
* More logging
* Change binPrefix to prefix
* Remove all linting warnings
* Adjust env vars for test
* Don't test on node 8
* Log more error information and fail right after 500
* Move docker test up
* [now dev] Support JSON and HTML error responses
Closes#2609.
* Compile templates for unit tests in CircleCI
* Update `ts-node` to v8.3.0
* Convert doT.js compiled templates to TypeScript
* Compile templates for lint tests in CircleCI
* Print convert time
* Add 502 error template
* Remove `message` param from `sendError()`
* Prettier
* Add 404 tests
* Fix test
* [now deploy] Change link for legacy warning
* Remove trailing slash
Co-Authored-By: Steven <steven@ceriously.com>
* Simplify `link` function
Co-Authored-By: Nathan Rajlich <n@n8.io>
* Determine which link to show and add test
* Adjust link for configuration
Co-Authored-By: Steven <steven@ceriously.com>
* Adjust Package type
* [CircleCI] Add more tests for macos support
* Change xcode version since node 8.9.x is required
* Log stderr and stdout
* Add custom start script
* Make tests use custom start script
* Made start script executable
* Use correct node path
* Fix script path
* Handle status code
* Use latest Node.js version for macos tests
* Include yarn.lock for ember test
* Only use start script in tests
* Change start script for macos
* Change start script for linux
* Change start script for linux
* Update `NOW_BUILDER_DEBUG` base on `--debug` flag
* No need to reset `NOW_BUILDER_DEBUG`
* Add comment for `NOW_BUILDER_DEBUG`
* Apply suggestions from code review
Co-Authored-By: Andy <AndyBitz@users.noreply.github.com>
* [now dev] Bundle `canary` builders for Now CLI canary
Closes#2641.
* Add unit tests
* More unit tests
* Use `semver.parse()` in `getDistTag()`
* Convert build script to TypeScript, DRY the `getDistTag()` function
* Prettier
Run the `now dev` integration tests in parallel with the "standard"
integration tests, since they both take a long time. This should
cut the CI testing time in about half.
* Support Node 8
This changes the TypeScript compilation target to "es2015" so that
async generator functions are transpiled, which enables Node 8 to be
supported.
As a side-effect, any of the files that utilize `async function*` or
`for await` needed to be converted to TypeScript so that the
transpilation actually happens.
It was painful to do this process for `src/commands/deploy/legacy.ts`,
and since it is legacy code I did not want to make too many changes to
the code, so there's a log of `@ts-ignore` and `any` types being used.
But the behavior of the file should not have changed at all.
* Make `engines` field be ">= 8"
* Add Node 8 to CircleCI matrix
* Remove `console.error()`
* Remove `.ts` extension on import calls
* Use `Now` instead of `any`
* Use native `url` module instead of `whatwg-url`
* Debug integration test
* Skip `02-angular-node` test on Node 8
* Remove debugging
* Add "Downloading Hugo" step to Node 8 tests
* Skip `03-aurelia` test on Node 8
* Skip `03-aurelia` test for all
All node versions are failing with the same error:
https://circleci.com/gh/zeit/now-cli/29922
* Use `fs-extra` instead of `fs.promises` for Node 8
* [now deploy] Consider `--npm` and `--docker` for platform detection
* Change order
* Change prepare
* Await fixtures
* Remove check
* Revert "Remove check"
This reverts commit 7a5c1c901085d4e22c5a34cc48b5d929a9ee3b80.
* Use async-retry
* Fix fetch
* Log token
* Retry user creation
* Add async
* Add try-catch
* Decrease the retries
* Use original way to get context name
* Using `stdio` to resolve `now dev` Ready
* Update test/dev/integration.js
Co-Authored-By: Andy <AndyBitz@users.noreply.github.com>
* Improve `testFixtureStdio` and update aurelia fixture
* Remove duplicate test
* Update `create-react-app` and `gatsby` test fixture
* Update `gridsome` test fixture
* Update `hugo` test fixture
* Update `jekyll` test fixture
* Add `marko` test fixture
* Add `mithril` test fixture
* Add `riot` test fixture
* Add `charge` test fixture
* Add `brunch` test fixture
* Add `docusaurus` and `ember` test fixtures
* Install ruby for `jekyll`
* Update base on platform for `jekyll` and `hugo`
* Use `sudo` to when installing `gem`
* Remove `09-jekyll`
* Extract the right filename
* Remove `-L` flag from `curl` for macOS
* Use different version of `hugo`
* Remove `min_version` from `08-hugo` theme
While debugging #2606, I noticed that the `Client` instances for
`now deploy` were not being supplied the appropriate `debug` flag
based on the command line args.
PR #2562 caused an issue with blocking builds at bootup being built
twice, which is problematic when i.e. running `yarn` simultaneously
on the same directory causing cache corruption issues.
The `getNowConfig(false)` used to be within this `if` branch, so the
debug call made sense there at the time, but as of zero config it got
moved to always be invoked, so this `debug()` call doesn't make sense
anymore.
* [CircleCI] Run integration tests on multiple versions of Node.js
* Test Node 10 and Node 12
* Remove `fs.promises` usage for Node 8
* More `fs.promises` removal
* Remove Node 8, it is unsupported due to `async` function usage
* [now dev] Wait for blocking builds to complete before handling requests
After the `now dev` server has already booted, if you delete a build
match that previously required a build at bootup time (i.e. `@now/next`)
from the `builds` array in `now.json` (i.e. change the builder to
`@now/static`), and then change it back to `@now/next`, then previously
the build would never execute.
With this change, the blocking build occurs as expected, and any HTTP
requests that occur are blocked until that build has completed.
* Prettier
* Better diff
* Add test
* [now dev] Add warning when there are no build matches
This matches the error in production, except it's just a non-fatal
warning when running in `now dev`. This is so that the user can fix
the warning without having to restart the `now dev` server.
* Add integration test
* [now update] Render the proper tag and improve `yarn` detection logic
Before this the suggested command would always have you install the
stable version of `now`.
With this change the `@canary` tag will be suggested if the version of
`now` is from the canary release channel.
Also updates the `isYarn` detection logic to not consider the cwd, and
instead check the installed version of now's `package.json` for clues.
* Move `getUpdateCommand` to util
* Add a unit test
* Use integration test instead
* Remove `pkg` bundling
* Remove `(dev)` from `--version`
* Remove `test/dev-builder.unit.js`
* Temporary disable `update now to canary test`
* Update `now update` command
* Removed useless jobs
* Removed useless code
* Removed more useless code
* Use update command
* Only run publish upon tag
* Removed code
* No need bin, use dist directly
* Update test, using the right file
* Reslove `iconv-lite@0.5.0` version
* Removed useless file
* Added scripts directory
* Removed useless stuff
* Fixed build script
* Fix `now dev` integration test
* Also block coverage on linting
* [now dev] Print `Serving all files as static` only once
* Track the config state
* Revert "Track the config state"
This reverts commit 9766941ca8cd1ffeae5fb0729800f05f2547099c.
* Revert "[now dev] Print `Serving all files as static` only once"
This reverts commit 3e30c2440b6c4deed8a14f2359696e7bf8dcdcad.
* Add `isInitialLoad` param
* Add configuration and basic integration tests for `now dev`
* Add test fixtures from `now-examples`
* Add `include` to `tsconfig.json`
* Increase retries for 00-list-directory
* Increase retries for `03-aurelia-node`
* Enable test fixtures for hexo, hugo, next, polymer, preact, svelte, vue, and vuepress
* Increase retries for `08-hugo-node`
* Disable `08-hugo-node` fixture
* Enable `04-create-react-app-node` test
* Disable `04-create-react-app-node` test
* Better name for now dev test job
* [now init] Add suggestions for old examples
* Add support for selecting an old example
* Add message for selection
* Wait for user interaction
* Fix typo
* Use v2 api instead
* Move message label to first param
* Bump api url to latest, update download to v2
* Rename found to visible
The `getNowConfig()` function gets invoked frequently, and it is also
async and makes mutations to the cached now config object. This ends
up being a race condition when `getNowConfig()` is invoked concurrently,
since one of the invocations may end up with an incomplete `NowConfig`
object (namely, with missing `builds`/`routes` arrays due to the
zero-config processing).
This change makes it so that there's only one `getNowConfig()` invocation
being executed at a time, and other concurrent executions will await the
same promise that the original invocation is responsible for.
* Update deps of deps in `yarn.lock` file
To fix #lodashgate:
* Upgrade `lodash.merge` to version 4.6.2 or later.
* Upgrade `lodash` to version 4.17.13 or later.
* Regenerate `yarn.lock`
* [now dev] Wait for `updateBuilders()` to complete before `stop()` completes
Since #2477, the unit tests related to `now dev` have become flaky, and
need to be retried a couple of times before running successfully. My
theory is that this is related to having concurrent `yarn` processes
operating on the builders module directory, causing corruption with yarn's
cache. Waiting for the lazy updating `yarn` process to complete makes
sense to me, hopefully CircleCI agrees.
* Debugging "list the scopes" integration test
* Moar debug
* Use regular `require()` when not in a webpack build (ava tests)
* Remove debug
Fixes this error from the pkg'd binary:
```
Error: File or directory '/**/now-cli/dist/builders.tar.gz'
was not included into executable at compilation stage.
Please recompile adding it as asset or script.
```
* [now dev] Bundle the most popular core builders into CLI binary
Makes Now CLI bundle a tarball inside its snapshot filesystem that
includes the following builders:
* @now/go
* @now/next
* @now/node
* @now/php
* @now/static-build
The tarball is generated by the `build.js` script and ensures the
"latest" version of the builders are included into the tarball.
When `now dev` is run, the tarball will be extracted upon the first
run to make these builders "pre-installed" to avoid the "Installing
builders" phase during boot-up.
Overall, this should make booting up `now dev` a lot faster, and help
with offline support.
* Don't install builders if they are bundled
* Persist `assets` dir to CircleCI workspace
* Delete build assets
* Fix installing builders from URL
* Finish builder installation filtering logic
* Still install `@now/build-utils`
* Implement builders installation "stale-while-revalidate"
* Remove `console.time()`
* Fix unit test
* Add `Readonly<>` to `BuilderWithPackage` type props
* Add debug log stack trace upon builder update failure
* Disable automatic signup
* Use shorter error message
* Update tests
* Update tests with user info
* Create tmpDir before tests
* Tweak fixtures and assertions for new login
* Don't pre-create the test directory in CI
* Use `os.homedir` instead of `~` in tests
* Pre-create auth directory conditionally
* [now dev] Render directory listing for Now v2 projects
Before directory listings only worked for "all static" deployments since
`now dev` would shell out to `serve-handler` to do the rendering.
Now the directory listing rendering logic is moved into `now dev` which
allows projects with Lambdas to also serve the directory listing
(previously they would just 404).
This removes the special-casing of "all static" deployments so that
there's only one code path.
Fixes#2161.
Fixes#2417.
* Move `serve-handler/src/directory` types to root
* Set `Content-Length` header for dir listing
* Add unit tests for directory listing
* Fix unit test
* [now dev] Update @now/build-utils and handle warnings
* Display warnings from response headers for deployment creation
* Update src/util/dev/server.ts
Co-Authored-By: Nathan Rajlich <n@n8.io>
* Apply routes only when there are no builds
* Updated the build utils
* [now dev] Update `serve-handler` to v6.1.0 and enable `etag` option
Sending the `ETag` response header matches how Now in production works.
* Test file contents as well
* [now dev] Revert "Add `etag` response header for Lambda invocations"
This reverts commit f80f1f79a6 (#2502).
`ETag` header is only sent in production when the lambda function sets
the "stale-while-revalidate" cache-control header, which will be
implemented in a separate PR.
* Remove `etag` test assertion
* [now-dev] Add zero config
* Update @now/build-utils
* Update @now/build-utils
* Escape glob
* Fix windows and group globbing
* Made sure routes and builds get updated on file events
* Removed useless check
* Add unit tests
* Use fetch instead of get
Before this change, the `installBuilders()` function was only run at
bootup, so if you modify `now.json` during runtime and add a builder
that's not installed, then a `MODULE_NOT_FOUND` error occurs.
Now the `installBuilders()` function is run with the missing builder
so that the builder can be properly loaded.
* [now dev] Allow `cache-control` header to be overwritten
This matches the behavior in production.
* Add `now-dev-headers` unit test fixture
* Remove `console.error()` call
This matches the production router behavior, and prevents running `now
dev` on a different project from serving stale content from a different
project.
Also update the `x-now-id` header to match the production behavior (it
changed at some point).
* [now update] Add message saying that Windows is not supported
And direct the user back to the download page in order to re-install.
Closes#2492.
* Exit 1
Co-Authored-By: Steven <steven@ceriously.com>
`validateEnvConfig()` used to be invoked inside of `validateNowConfig()`,
but now it is invoked separately.
Explicitly exiting the process avoids reports going to Sentry.
* [now dev] Use system installed version of Node.js for builds
Rather than downloading the 8.10 Node.js binary, simply assume that the
user has their preferred version of `node` already installed onto the
system and use that version.
If there is no `node` binary in the $PATH, then `process.execPath` is
used instead, meaning that the pkg binary node version will be used.
* Simplify `getNodeBin()` using `nothrow` option
* Fix build
* ignore metrics with environment variable
* collect exception and exit code
* add deprecated warning for `now alias [id] [url]`
* add exception in util error
* consistent format
* ensure no duplicate warning
* using the right error message
* refactor metrics util
This error happens when Ctrl+C is pressed before the `http.Server`
instance is listening, meaning that the user attempted to quit very
quickly after starting `now dev`.
This change makes the process exit immediately instead of throwing,
which also causes the error to be sent to Sentry (which we do not want).
* More cert errors handling for deploy command
* Apply suggestions from code review
Co-Authored-By: Andy <AndyBitz@users.noreply.github.com>
* Revisions based on review
* Minor revision
* Adds get-deployment-by-id which uses latest v9 endpoint
* Refactor to use apiVersion
* Update now rm
* Fixed typo
* Don't use .flat() because of node 10
* Exit process
* Remove only the project instead of all deployments of it
* Changed output text
* Headlines for projects and deployments
* Typo and number prefix
1. Handle permissions errors in both update mechanisms
2. Handle `EBUSY` (Windows) as a file busy error
3. Update permissions error prompt to say "Administrator Command Prompt" on Windows
4. Add message about "unexpected end of file" error
Rather then throwing which causes the process to exit.
Better to give the developer a chance to fix the syntax
error without having to restart the dev server afterwards.
* Use v4 instead to prevent listing the same deployment multiple times
* Remove the latestDeployments since it is depracted and doesn't have the
`readyState` property and only get 35 projects instead of 50 to lower
the rate limit
* Fix tests
* [now dev] Strip prefixed `/` when doing routes matching
The prefixed `/` is implicit when matching routes, so strip them
so that they are optional. This matches the behavior in production.
* Fix unit tests
* More readable
* Add unit test
* integrate universal metrics
* Update src/index.js
Co-Authored-By: Leo Lamprecht <mindrun@icloud.com>
* Add default `collectMetrics` config
* Remove flag, only using global config to disable metrics
* Add GA tracking ID
* Move constant to file
* Rename constant to constants
* Rename `dsn` to `SENTRY_DSN`
* Apply suggestions from code review
Co-Authored-By: Leo Lamprecht <mindrun@icloud.com>
* Remove extra space
* Update event category and action
* Remove usagestate to use universal-analytics
* Chain timing and event function
* Make sure to user are unique
* Ensure unique User ID
* Add extra User-Agent and move metrics into its own file
* Use default export
People are often trying to store secrets starting with dashes such as
private keys. These dashes get interpreted as command line options which
effectively prevents a storage of private keys.
Fortunately, this is easily resolved by using bash -- convention to mark
an end of options, such as:
`now secret add google-secret-key -- "-----BEGIN PRIVATE KEY-----
abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVXYZ+/a
-----END PRIVATE KEY-----"
The problem is also discussed in following issues:
https://github.com/zeit/now-cli/issues/749https://github.com/zeit/now-cli/issues/80
* [now dev] Use `chokidar` for file watching
`nsfw` is not suitable for very large projects because it does not
have any "ignore" functionality implemented.
For macOS, the `useFsEvents` option is _disabled_, so that the
`fsevents.node` binary file does not need to be cached onto the
filesystem, which simplifies things for use with `pkg` binaries.
* Delete the `fsevents` module during build
* Add proper `.nowignore` logic to the chokidar watcher
Alpha versions of `now dev` that used npm instead of yarn were
installing the packages to `devDependencies` rather than `dependencies`,
so this fixes package name lookup when a legacy cache like that is on
the user's machine.
* [now dev] Use the dev server `cwd` as builder's `workPath`
Rather than copying the source files into a temporary directory,
simply use the existing source files in the `cwd`. This will make
subsequent boots of `now dev` be faster (i.e. because the `node_modules`
directory will already be in place), as well as use much less space on
the filesystem because temporary directory are no longer being used.
This will require some changes to the builders and `@now/build-utils`,
to ensure that the `download()` function is always installing into
`workPath`, and that the `meta` object passed to the `build()` function
is also passed into the `download()` function.
For example:
- https://github.com/zeit/now-builders/pull/474
- https://github.com/zeit/now-builders/pull/475
* Update `@now/build-utils` to v0.5.5-canary.1
This makes `download()` be a no-op when running in `now dev`.
* Add test case for `@now/next`
* Fix debug log formatting
* [now dev] Mix in routes query params when proxying to a URL
Fixes#2289.
* Refactor unit tests and add a unit test for proxy passing with query params
* Fix TypeScript compile error
* [DEBUG] Disable proxy pass unit test
* Run unit tests serially
* Remove `console.error()` in unit test
* Temporarily disable integration test "try to create a builds deployments with wrong config"
* Adjust `now init` and `now dev` to not require a login token
These two commands should not require a login token because
they do not interact with the Now API.
* Remove `config` from `subcommandsWithoutToken` array
It's not an existing command.
* [now dev] Inherit env vars from `now.json`
Before it was only using env vars defined in the `.env` and `.env.build`
dotenv files.
* Fix secrets validation
Some builders require access to the runtime env vars, i.e. `@now/next`
since it spawns a `next dev` subprocess and should be passing the
runtime env vars to that.
Before it was only respecting the status code for 301, 302 and 303
status codes. Now it handles any status code defined in the routes
config.
Fixes#2294.
* [now dev] Show build logs if a build fails during bootup
Before, the logs were never shown because `buildProcess` does not emit
an `error` event when the child process exits.
Also updates `ora` to the latest version.
* Remove `@types/ora`
`ora` includes its own TypeScript definitions now.
Which includes this fix: https://github.com/zeit/pkg/issues/671
Relevant to `now dev` invoking `yarn` when a package includes
a postinstall script that invokes `node`.
* [now dev] Install builders with `yarn` instead of `npm`
Also invokes via `process.execPath` so that the pkg'd node is used
instead of a global one.
Depends on #2270.
* Install `yarn` to the builder cache dir
Not the `node_modules/.bin` dir, because `yarn` cleans up that directory
when installing modules, so it deletes itself.
* Remove unnecessary unit test
* Always install `yarn`
* Pass in the `yarnPath` to `installBuilders()`
* Restore unit test
* Remove unused `delimiter` import
Co-Authored-By: TooTallNate <n@n8.io>
This is important for builders like `@now/next` and `@now/static-build`
which launch a child process dev server, and we want those logs to be
visible from the `now dev` console output.
* Do not report env errors to Sentry
* Added guide for missing env file in dev mode
* Update errors/missing-env-file.md
Co-Authored-By: leo <mindrun@icloud.com>
* Update errors/missing-env-file.md
Co-Authored-By: leo <mindrun@icloud.com>
* [now dev] Refactor builders installation logic
- Don't run `npm update`, only `npm install`, so no more "Checking for
builder updates".
- Don't save `package-lock.json`, to allow builders with newer versions
than already installed to be updated.
- Properly supports non-npm-registry builders (i.e. an HTTP URL,
`github:` syntax, etc.
* Use `Object.entries()`
- Have the builder exit if a rejection occurs
- Respawn the builder upon next rebuild after the builder has exited
- Log when builder is starting and completed with build time
- Render build error in the HTTP response
This forces all the files to be served as static assets using
`@now/static`, rather than having a special branch that dishes
out to `serve-static`. This is better because it keeps the logic
consistent with when a `now.json` is supplied vs. when it is not,
and allows the code to be simplified by removing checks for if
`getNowJson()` returned anything (previously it could return `null`,
but now that is not the case). Also allows us to remove the now-unused
`serveProjectAsStatic()` function.
* [now dev] Force `@now/static` to run in-memory
The logic for `@now/static` builder is bundled into the `pkg` binary,
and thus is not requireable, so it must instead be run in-memory.
* Also check for stdout TTY before doing the erase lines stuff
* Update `@zeit/fun` to v0.7.0
* Remove `builderCachePromise`
No longer used.
* Remove `intercept-stdout`
* WIP invoke the builder in a forked child process
* WIP Add `builder.js` file
* Remove `BuildResultV1 | BuildResultV2` distinction
Prefer normalizing the `build()` function result to `BuildResult` v2
shape so that we don't have to cast everywhere else.
* Apply build env vars to builder child process
* Copy the `builder.js` file from the pkg filesystem snapshot to the builder cache dir
* Map `FileFsRef` and `FileBlob` of the builder's output back into instances
* Fix `@now/next` :/
* Cleanup
* Print number of initial builds
* Add spinner for building process
* Refine logs
* Support none-tty
* Crop long lines
* Clean up imports
* Refine logs wording
The `entrypoint` should always be watched, since we know that it was used
to produce the build output. This is for builders that don't implement
a fully featured `watch` return value.
* [now dev] Don't include a file in both `filesChanged` and `filesRemoved` list
This makes it so that if a file is added to the "changed" array, then it
is also removed from the "deleted" array, and vice-versa.
* Only render the "files changed/remove" debug log if there are entries
This will be necessary for `@now/static-build` since it needs to watch
all files in the dir containing the entrypoint. For example:
```
watch: [ path.join(path.dirname(entrypoint), '**/*') ]
```
The file watcher logic expects that there is no `'./'` prefix on the
watched file paths/patterns, but `path.dirname('foo')` returns `'.'`
which turns into `'./foo'` with `path.join()`. So this allows those
file paths to be returned from the builder and `now dev` normalizes the
paths after the build has completed.
The dev server `cwd` is not correct working path of a build match, so
pass in the correct one. This property will be used by
`@now/static-build`'s dev mode.
* [now dev] Remove `requiresInitialBuild` and make `shouldServe()` optional for v2 Builders
`@now/next` will be removing `shouldServe()` in favor of returning
a `routes` config array upon bootup. This makes now dev's
`shouldServe()` wrapper function support matching a `routes` config
entry when `shouldServe()` is not defined.
* Remove `console.error()` debugging calls
* Remove `mergeRoutes()` logic
This was incorrect behavior, and more like what `continue: true` is
supposed to do.
* Remove invalid test case
* Remove from the `files` array when ENOENT occurs in file watcher
* Prettier
* Pass workPath to builder.shouldServe() (#2211)
* [now dev] Resolve built routes after matching builder
This removes the `combineRoutes()` function since it was problematic and
triggered rebuilds upon every HTTP request, which is not necessary and
makes development slower.
Now, when an HTTP request comes in, the `now.json` routes are resolved
first, and then the matched build is checked if it defines any `routes`
in the build output. If it does, and a matching route is found then the
route is handled accordingly.
* Fix dev router unit tests
* Only try to match build routes if `.length > 0`
* Remove `routes` config from `@now/static` build results
This would cause an infinite loop of resolving `entrypoint` to
`entrypoint`, and is not necessary for this builder.
* [now dev] Reuse the same `workPath` for subsequent builds
Reusing the same `workPath` for subsequent builds makes rebuilding
faster, as well as it's necessary for webpack's watcher to work
correctly as it relies on the full filesystem paths being intact.
`prepareCache()` also no longer needs to be invoked, since the
previous `workPath` directory will already contain the necessary files
that the cache would otherwise produce.
* Prettier
* [now dev] Don't trigger a rebuild if an asset was deleted
This handles the case where an asset was deleted and should no longer be
served after a filesystem watcher event. For example, if a Next.js page
was previously built and the files was deleted from the `pages`
directory, then the rebuild should not happen since it will fail in the
`build()` function anyways.
* Add `config` to `shouldServe()`
* Remove unused `builder` var
* Show a upgrade message if the build limit is exceeded
* Typo
* Update src/commands/deploy/latest.js
Co-Authored-By: AndyBitz <AndyBitz@users.noreply.github.com>
Editors like `vim` like to use temporary files in the file's working
directory and quickly rename / delete them. This makes `now dev` handle
that gracefully and not crash.
This matches the behavior in production, so it is more correct.
This new common `getMimeType()` function also centralizes a place where
we can overwrite the `mime-types` return value to other values to match
production for other future discrepancies.
* [now dev] Add `nsfw` file watcher
WIP for triggering background rebuilds. So far the `files` mapping is
now kept in sync via the events produced by `nsfw`.
* Add `now.json` caching and invalidation from nsfw events
* Add initial rebuilding logic from filesystem watching
* Remove previously built assets when a rebuild occurs
* Make `@now/static` not require a hard refresh
* Shut down the `nsfw` instance when stopping the DevServer
* Prettier and some minor tweaks
* Ship module
* Support private deps
* Fixed tests
* Fixed integration tests
* Revert "Support private deps"
This reverts commit 0b4991b87641d693fa61f81223e0efc2b7006f83.
* Support multiple platforms
* Typed
* Consider Alpine
* Bumped @zeit/nsfw to latest version
* Update src/commands/dev/lib/nsfw-module.ts
Co-Authored-By: leo <mindrun@icloud.com>
* Pass module path differently
* Bumped package
* Make binary executable
* Wait until piping is complete
* Added debug statements
If you run `yarn build-dev`, then now source maps are enabled, allowing
us to see the proper line of an error in the source code file instead of
the huge `dist/index.js` file.
Previously they were only enabled for production builds.
* Handle additional errors when issuing a certificate
* Rename errors
* Provide more context in CertsDNSError
* Fix CertsDNSError structure
* Display cns with join
* Fix CertsDNSError
* WIP refactor to Now Builders v2 API
* More WIP
* Finish up refactor
* Remove `BuiltAsset` type
These properties are on the the `BuildMatch` interface now.
* Fix `handle: filesystem` route post-refactor
* Prettier
* Update src/commands/dev/lib/builder-cache.ts
Co-Authored-By: leo <mindrun@icloud.com>
- Get `.ts` files covered 🎉
- Update eslint related dependencies
- Add typescript-eslint [recommended rules](3e26ab684a/packages/eslint-plugin/src/configs/recommended.json), but only enabled ones we already followed, commented ones causing errors.
Commented rules including:
```yaml
# '@typescript-eslint/no-unused-vars': 1
# '@typescript-eslint/indent': ['error', 2]
# '@typescript-eslint/array-type': error
# '@typescript-eslint/ban-types': error
# '@typescript-eslint/explicit-member-accessibility': error
# '@typescript-eslint/member-delimiter-style': error
# '@typescript-eslint/no-angle-bracket-type-assertion': error
# '@typescript-eslint/no-explicit-any': warn
# '@typescript-eslint/no-object-literal-type-assertion': error
# '@typescript-eslint/no-use-before-define': error
# '@typescript-eslint/no-var-requires': error
# '@typescript-eslint/prefer-interface': error
```
### TODO
Go through these commented rules one by one, enable & fix for it or confirm it's disabled. Since enabling some rules would cause massive code change (like `'@typescript-eslint/indent': ['error', 2]`), which might conflict with our ongoing development, we better do this in separated PRs.
* Revert "Stop indicating whether CDN is enabled (#2132)"
This reverts commit 3dda3e84bf.
* Add a note about the CDN always being enabled
* Removed useless flag
* Added correct table heading
This is the same de-duping logic that occurs when you hard refresh,
but the unbuilt case was still not being considered. This fixes clicking
on an unbuilt link more than once from triggering multiple builds of the
same asset.
* [now dev] Run `prepareCache()` asynchronous
And also wait a few seconds before running the actual logic,
since the `prepareCache()` function may be computationally expensive,
and its run in the same process as `now dev` (for now), so allow
some time for the current HTTP request to complete.
* Add symlinks support to `glob()`, instrument prepareCache time
If a builder defines the `prepareCache()` function, then it gets invoked
after `build()` has completed to set up the initial build state of the
next build for this same asset.
For example, the goal for `@now/node` if the package.json has not
changed is to have yarn produce the "Already up-to-date" message on the
next build, because installing dependencies ends up taking a long time
on bigger projects.
This is more inline with how a fresh Now deployment works, where
is has to download fresh files each time. This will also fix the issue
with `@now/next` that deleted the `.next` output dir and deleting static
files upon subsequent builds.
This is still a bit unoptimized because `prepareCache()` from the
builder is not yet being invoked, but it's still more correct than
reusing the `workPath`.
Because `now dev` uses these dotenv files to define the Now secrets to
use, it would be bad practice to include them in the deployment files
since they will be using development values instead of production values.
* [now dev] Clean up `dev-router` a bit
This is a follow up to #2095 to move the `resolveRouteParameters()`
funcrtion to the top-level and other slight optimizations like not
re-parsing the URL multiple times.
* Remove unused `qs` import
This test is very flaky causing us to constantly restart CircleCI jobs
in order to do releases of `now-cli`. Considering that it's testing the
1.0 pipeline, let's just remove this one to make life easier.
This passes in the resolved `assetKey` instead of `req.url` to the
builder `requestPath` when a hard-refresh is requested, allowing the
proper single-page rebuild to happen.
* [now dev] Fix subscription resolving logic
Strip the leading `/` since the builder outputs don't have one, match
index routes, and pass the resulting subscription key to the builder.
* Fix `index` matching
* Update `@now/build-utils` to v0.4.39-canary.0
* Update `@now/build-utils` to v0.4.39
In the case of a keep-alive connection from the web browser, and a page
continuing to send HTTP requests to the dev server, sometimes the server
never shuts down. So send a 404 response with `Connection: close` to
force the web browser to close the connection.
If the builder has a `subscribe()` function, then the initial
builds are not run and instead an array of "subscriptions" is
created. When an HTTP request comes in that matches one of the
subscription patterns, then this builder will be actually be
executed.
This introduces a new object called `meta` that gets passed to the
Now Builders' `build()` function. The `isDev` property is moved to
this object, and a new property `requestPath` is also introduced.
`requestPath` represents the URL that was requested to trigger the
`build()` to be called. It may be used by builders to do incremental
compilation and only re-build the assets related to the URL that was
requested. For example, `@now/next` may use this property to only build
the page that was requested.
For `now dev`, this fixes an edge case in named capture groups
in some `routes` definitions that would lead to an error being thrown:
```
Cannot read property '1' of null
```
Also ignoring "handler" routes for now.
* [now dev] Add support for `.env` file to define Now secrets
If a `now.json` files relies on secret env vars, then they must be
defined in the user's local `.env` file otherwise `now dev` exits with
an error.
* Prettier
* Fix multi-line error output
* Use `code()` to format the dotenv file name
* Add "file" to error message for clarity
* Use `hasOwnProperty()` instead of `in`
* Apply `build.env` vars during builder `build()` invocations
Fixes#2046.
Consider the scenario where an HTML asset is built and references other
files that were produced by the build (CSS/JS/img/etc. files). The build
will happen and then the HTML page will be served, and then the browser
will request the assets on the page also with the `no-cache` header,
which would cause a second build right after the first one completed,
which is bad DX and unnecessary.
This commit introduces "build deduping logic" so that this scenario is
avoided by doing two things:
1. Not allowing the same entrypoint to be built at the same time (so if
a concurrent request happens for an asset that was produced by the same
entrypoint, the subsequent requests will wait on the already running build
instead of triggering a new one in parallel.
2. Not allowing an asset to be rebuilt if the previous build completed
less than two seconds ago. This is to catch the scenario where the
HTML page is served and the browser quickly requests the assets on
the page to avoid triggering a second rebuild.
* [now dev] Set the Now proxy and response headers
* Add `X-Real-IP` proxy header
* Set any headers defined in the matched `route` config
* Apply @amio's suggestions
This is mostly to appease TypeScript since `fn` is an optional prop,
but this shouldn't really ever happen since we run the builds before
responding to HTTP requests.
* Group builds with similar paths together to reduce the output
* Style the new output
* Ensure space between state and time
* Update src/util/output/builds.js
Co-Authored-By: AndyBitz <AndyBitz@users.noreply.github.com>
* Add comma between ready states
* Tell what is hidden
* Change builds and items
This matches how the Now proxy invokes the lambdas, where the route
`dest` query params are mixed-in to the provided `req.url`, with the
dest query params taking precedence over any conflicting user-provided
query params.
* [now dev] Use `pcre-to-regexp` to match `routes`
The now.json `routes` support PCRE syntax like named captures,
so use the `pcre-to-regexp` module to match the routes.
Fixes#2023.
* Pass the resolved router `dest` and query params to the Lambda
This just DRYs up the code a bit and centralizes the error sending logic
so that we can more easily add the HTML and JSON versions of the
responses as well.
`.gitignore` is not respected anymore for Now v2, so this was a bug.
Also removes `ncc` and `user` from the ignore list, since that issue was
fixed a while back as well.
Fixes#2021.
* [WIP] now-dev
* try invoking lambda
* add error status to dev-server
* add basic routing
* add entry for custom @now/static builder
* honor .gitignore & .nowignore while collecting files
* add route for single static file
* add test fixtures for now-dev (nodejs)
* fix miss typed @now/statics
* import types from @now/build-utils
* fix typo @now/statics -> @now/static
* revamped router
* typescript-eslint-parser -> @typescript-eslint/parser
Eliminate error while running pre-commit hooks:
SUPPORTED TYPESCRIPT VERSIONS: ~3.1.1
YOUR TYPESCRIPT VERSION: 3.2.2
* send files from local @now/static builder
* use serve-handler when no now.json
* remove http-proxy
* add type def for serve-handler
* code cleanup
* move type declarations to types.ts
* dont rely on `this.cwd` while running builder
* more type definitions
* fix invoking error
* clean code
* better debug logging
* refined request handler logic
* handle /favicon.ico with serve-handler
* make builder-cache self contained
* move builder works to dev-builder.ts
* add proxy_pass handler
* support named groups in routes
* fix creating cache dir error
* add "--nodejs-preview" solely for nodejs
* clean require.cache after required user js
* fix router & header issue in nodejs preview
* [wip] add tests for dev-router
* add tests for dev-router
* lookup "/index.*" for indexes
* refine logging
* [WIP] `now dev` progress point
Actually invoking the `@zeit/fun` module at this point.
Still lots of work to be done…
* Update `@zeit/fun` to v0.0.4
* Remove `--nodejs-preview`
To be replaced by `@zeit/fun`.
* Remove `decache` and `import-fresh`
Leftover from the `--nodejs-preview`.
* Remove "declaration: true" from `tsconfig.json`
Otherwise the ncc `dist` dir ends up full of generated `.d.ts` files.
* Remove `ignore` dep, always use `@zeit/dockerignore`
* Use tarball URL for `@zeit/fun`
Because `@zeit/fun` is not yet public on npm.
* Regenerate `yarn.lock` to fix bad integrity check on fun tarball
* Upgrade to `@zeit/fun` v0.0.6
With re-written unzipping logic utilizing `yauzl`.
* Add lambda function handling logic for the HTTP response
* Match the lambda invoke shape that Now's proxy provides
* Move deps to devDependencies
* Update `@zeit/fun` to v0.0.8
* Update `@zeit/ncc` to v0.15.0
* Attempt to fix unit test for `wait()` helper function
* Add `build.sh` script to work around ncc issues
* Fix `build.sh` script for BSD's chmod
No `--changes` flag.
* Update `@zeit/fun` to v0.0.11
* Update `@zeit/fun` to v0.0.12
* Tweak some comments
* Update `@zeit/fun` to v0.0.13
* Add `now.json` env vars to lambda functions
* Finish removing `--nodejs-preview` flag
* Style tweaks
* Use `npm-package-arg` to parse the "use" builder
* Styling
* Use the parsed `pathname` when matching routes
The querystring portion needs to be removed to match properly.
* Update `@zeit/fun` to v0.1.1
* Support `-d` for debug flag
It was already listed as such in the `--help` output.
* List the `dist/runtimes` dir as pkg "assets"
* Update `@now/build-utils` to v0.4.37-canary.0
* Update `@zeit/fun` to v0.2.0
* Update `@zeit/fun` to v0.2.1
* Rewrite the `req.url` to fix serving FileFsRef assets
* Disable re-building, build all `builds` upon server bootup
* 404 is not a redirect
* warning on more than one argument
* Fix `index` without a file extension matching
* Update `@zeit/fun` to v0.2.2
* Use `async-listen`
* Add shutdown cleanup logic
* Rename `buildLambdas()` to `executeBuilds()`
* Rename `lambda` prop to `fn`
* Misc tweaks
* Pass `isDev: true` to the builder `build()` function
* Use `Object.assign()` instead of object spread
* Set `res.statusCode` instead of `writeHead()`
* Create Lambda functions during build-time
This way, the lambda instance is re-used for subsequent HTTP requests
* Wait for cleanup operations to complete in `stop()`
* Destructure `path` for join()
* Add some missing types
* Store the `buildConfig` on the assets for reverse lookup
* Remove `console.log()`
* Attempt to make globbing faster and ignore files more accurately
* Rewrite `installBuilders()` to be idempotent
So that npm is not executed for canary tags, for example.
This is done by comparing the contents of the package.json file rather
then the `node_modules` directory.
* Use `ignore` instead of `@zeit/dockerignore` for glob-gitignore
It seems that the object produced by `@zeit/dockerignore` is not
compatible with the `glob-gitignore` module, so use the vanilla
`ignore` module instead for now as a workaround.
* Implement a `GlobIgnore` class to replace `glob-gitignore`
This allows us to continue using `@zeit/dockerignore` for proper
consistency.
Closes#1899.
* Prettier
* Skip installing built-in builders (i.e. `@now/static`)
* Remove `console.error()` calls
* Use a deterministic `workPath` directory
So that the same one is re-used in-between subsequent boots of `now dev`
* Add `now.json` validation logic
* Fix serving static assets outside the project working directory
This fixes, for example, `@now/mdx-deck` which outputs static files
from its build process.
* Add comment
* Validate the `now.json` file before launching the dev server
* Respect `maxLambdaSize` config
Closes#1950.
* Add `@types/bytes` dependency
* Make `maxLambdaSize` be optional
Co-Authored-By: TooTallNate <n@n8.io>
* WIP force reload in browser = rebuild asset behavior
* Resolve the `asset` again after re-build
* Remove logging
* Update `@zeit/fun` to v0.3.0
* Update `@now/build-utils` to v0.4.37-canary.1
Sets `npm_config_target` to the proper Node.js version for native
modules.
* Update `@zeit/fun` to v0.3.1
* Fix "hard refresh to reload" after the first rebuild
The `buildConfig` and `buildEntry` proper were not being set on the
rebuilt assets, causing the rebuild to only work the first time.
Now fixed.
* Add logic for the `now dev cache clean` command (#1977)
* Added the cache-clean command
* censer code :)
* Fix non-route match `dest` param
This makes the `go-image-to-ascii` work, since the query param URL gets
properly routed to the `/` route.
* Add support for `FileBlob` outputs
Fixes `@now/optipng`, `@now/html-minifier` and `@now/md` builders.
* Remove `console.error()` call
* Add `now dev cache clean` command
* Use the `assetKey` to look up the Content-Type on FileBlobs
Instead of the `fsPath` of the entrypoint file.
This fixes `@now/md` to return `text/html` Content-Type instead of
`text/markdown` which does not render properly in the web browser.
* Update `@zeit/ncc` to v0.16.1
Co-Authored-By: TooTallNate <n@n8.io>
* Regenerate `yarn.lock` file
* Remove leading `/` on build `src` specifications
* Use `rsync` to copy over all of `fun`'s runtime files
* Update `@zeit/fun` to v0.5.0
* Update `@zeit/fun` to v0.5.1
* try/catch the lambda invoke and send 500 upon error
* Add `rsync` to CircleCI build
* Convert `errors.js` to TypeScript to fix compilation errors
* Also accept `Cache-Control: no-cache` for rebuilding
* Prettier
* Update `@now/build-utils` to v0.4.38-canary.1
* Update `@zeit/ncc` to v0.17.0 (#2017)
* Install `@zeit/fun` from npm
* Remove `console.error()` call
Co-Authored-By: TooTallNate <n@n8.io>
* Create `NowError` subclasses
* Add `LambdaSizeExceededError`
* Return early if there's no builds
* Fixed `GET /v3/now/certs`
- Limit the response size to 20 because the endpoint doesn't have a default limit
- If the id in `/v3/now/certs/{id}` isn't a valid id the endpoint responds with a set or certs instead
- The route `/v3/now/certs/{idOrCn}` isn't supported any more
* removed limit of 20, the endpoint was updated
Before this change, only if `user` or `team` could be read from
the scope would stdarg be reported to Sentry, however it's
completely unrelated to the existence of the former and is always
useful debugging information.
* Added basics for new --scope flag
* Fixed usage information
* Fixed integration test
* Fixed usage information about whoami
* Brought back missing whitespace
* Do not push scope property to API
* Ensure we're only reading local config in one place
* Fixed build
* Added test
* Made scope from config work
* Correctly handle error
* Handle Now errors too when loading local config
* Removed NowError
* Revert "Removed NowError"
This reverts commit cfeebc65251d3eb07f9aeb3e548af1d23c00a18e.
* Fixed CI
* Fixed final bug
* Do not consider switch command
* Made it work as expected
* Added test
* Added yet another test for the scope property
* Added space
* fix unexpected `payment_error`
* fix unexpected `deployment_not_found`
* fix unexpected `not_authorized` and `team_deleted`
* make id optional in DeploymentNotFound
* Add support for the target flag
* Show the given alias at the end
* Use the proper naming for the alias properies and include arrays
* Use the correct output
* Make sure that aliasFinal has properties
* Display transfer renewal price for domain transfers
* Check domain transferable status immediately on transfer-in
* Transfer status endpoint change to .../registry
* spelling fix
* Enable transferable check
* Update dependencies
* Added default script that will run if now fails to install
* Don't overwrite the default now script before publishing
* Copy the default now binary on publish instead of keeping it inside the dist folder
* Removed download/dist/now
* Changed text
* Send project property to api-deployments.
* Allow to talk to local api-deployments temporarly.
* Introduce the getProjectName utility.
* Use getProjectName on both legacy and latest deploy commands.
* Add now projects ls support.
* Implement 'now project add' and 'now project rm'
* Show project id
* Add basic now ls support with projects.
* Add some cosmetics changes.
* Make the UI colorful.
* Set the name as project
* Notify the user about the project name
* Remove legacy list
* Make sure 'now projects xxx' possible
* Set the project name in the list header
* Remove unwanted package
* Use --project in tests
* Force --project instead of --name
* Force the use of project property inside now.json
* Update ncc to the latest
* Remove -w from ncc
* Deprecate --name and .name instead of throwing errors
* Use the built-in fetch client
* Fix tests
* Change the order of tests
* Reset integration tests
* Remove some debug logs
* Bumped `@zeit/ncc` to latest
* Reverted lockfile
* Make linking build for dev
* Cover line 21 in util/config/local-path.js
* Heavily improved unit test coverage
* Fixed space
* Got to 90% coverage
* Removed useless code
* Made builds work
* Fixed a few lines
* Fully covered read-metadata.js
* Brought coverage to 95.38
* Removed code that was never executed
* Track everything
* Don't show badge for now
* Add now-init
* fix ci error
* refactor: (now-init) js => ts, some improvements.
- now-init works like git-clone
(create new directory / complain about overwritten / can be forced)
- Better guess user intention
(use jaro-winkler algorithm with "-" awareness)
- Stricter on arguments
- Non-TTY frendly
* add now-init to main help message
* fix miss typed args in didYouMean
* clean console.log
* output a new-line after any response to promptBool
Fix the missing '\n' when promptBool get an negative input ("n"/"N"/Enter/Abort).
Before:
~/git » now init koa
> Did you mean nodejs-koa? [y|N] > No changes made.
After:
~/git » now init koa
> Did you mean nodejs-koa? [y|N]
> No changes made.
* refine now-init output messages
* prettier code format
* update tests for now-init
* put "init" before "help" in now-help message
* remove redundant semicolon
* More flexible response error
* Consider async domain purchases
* Jumpline for domains ls
* Jumpline in domains verify
* Remove not needed body performing verification
* Add orderedAt to domains inspect
If a domain is not found the DNS record arrays are aligned
incorrectly and finally some records are shown under wrong domains.
It happens because the length of the domains array differs from the
length of array of record arrays.
* Migrate getDomainDNSRecords to Typescript
* Migrate getDNSRecords to Typescript and fix it
* Migrate cert functions to Typescript and fix issues
* Migrate certs issue to Typescript
* Minor fixes
* Removed legacy dependencies
* Added @zeit/git-hooks
* Added scripts to run before commit
* Format only the modified files
* Revert "Format only the modified files"
This reverts commit 9f4a58d2b978fa286eb7fcf38186bd9d53a2cda1.
* Revert "Added scripts to run before commit"
This reverts commit 07636d945374e404161ad281feed4180801b3509.
* Revert "Added @zeit/git-hooks"
This reverts commit 3f44f401f36fa6965d36ef28b81907c137c08abc.
* Revert "Removed legacy dependencies"
This reverts commit bb02465c59d75bf6b32bd449a04832cf4e2f4bf4.
* Fixed setup
* Print important test parts
* Logged kind
* Added more logs
* No need to remove deployments, we will prune
* Update `now alias` error to mention potentially missing name config
Running `now alias` in a project that has no `package.json` and doesn't
have a `name` property defined in `now.json` fails with a cryptic
error currently. This, in combination with
https://github.com/zeit/docs/pull/378 tries to better guide the user.
* Add a link to the `name` config property
* Handle EPERM errors when creating config files
* Catch errors when retrieving scope
* Added validation for the API URL
* Removed useless whitespace
* Removed useless file
* Cleaned up `setRawMode` mess
* Removed tests that are erroring on non-TTY
* Set environment based on release channel
* Fixed syntax
* Configure releases and environment for Sentry
* Correctly send development errors away
* Report Sentry errors with metadata
* Report username and full name of user too
* Better release name
* Bumped `@zeit/ncc` to latest version
* Do not report user errors
* Do not report mistyped arguments to Sentry
* Do not report when user aborts action
* Removed all occurances of user errors
* Do not report arg errors
* Correctly report teams and billing errors
* Prevent `setRawMode` from causing an error
* Do not report errors while developing
* Revert "Prevent `setRawMode` from causing an error"
This reverts commit 323296f30bfcca70ea5bb736db98357212f86a0a.
* Fixed whitespace
* Added code coverage report
* Correctly include everything
* Ignored useless stuff
* Combine all the coverages
* Corrected requiring
* Persist only what is needed
* Send errors away for inspection
* Allow Sentry to send them away
* Fixed dependency
* Fix credit card input
* Do not test for something that requires TTY
* Track properly
* Make it extra safe
* Added back test
* Added tests for `-V` option
* Pushed for testing
* Correctly set it
* Revert "Correctly set it"
This reverts commit c76286082d90f091ecec4a317856e91b4558e781.
* Create a new deployment each time
Made `--build-env`, `--meta` and `--dotenv` work for v1
* Locked multi static file test to v1
* Correct fix
* Final fix
* Config also adds to count
* Fixed single file test
* legacy => old
* Correctly set it
* Removed external providers
* Renamed sh provider
* Removed serverless stuff
* Fixed paths
* Properly pass token
* Fixed paths
* Check for token correctly
* Remove useless properties
* Fixed unit tests
* Keep certain things
* Adjusted remaining parts
* Fixed login
* Remove user properties that are not needed
* Store `platformVersion` for teams
* Store `platformVersion` for users
* Delete team order when logging out
* Made team commands work with tiny config
* Load data dynamically
* Made billing command show correct context
* Fixed remaining occurences of context name
* Fixed remaining pieces
* Test CI
* Clean strings when testing
* Better error check
* Render correct information when asking for credit card
* Migrate from objects to strings
* Better migration message and keep tips
* Remove the old property
* Use note for migration message
* Don't show spinner for loading missing data
* Allow for current team or user to be deleted
* Two deploy files
* Consume context name correctly
* Removed deployment types from new deployer
* Also check for bigger than 1
* Better file names
* Added upgrade message for legacy deployer
* Make help work when logged out
* Error if sub command doesn't exist when requesting help
* Fixed wording
* Support for version property added
* Better handling
* Removed useless props from deploy help
* Don't show version warnings when rendering help
* Fixed wording in readme
* Migrate even if in the middleground
* Make `now whoami` work
* Deprecated support for deploying Git repo in latest deployer
* Added usage information
* Load config separately
* Don't need local config on root
* Correct status code for help test
* Show error only in correct case
* Properly error if path does not exist
* Fixed types
* Fixed remaining occurances of old config
* Don't show warning when rendering help
* Consider version when outputting help
* Only error if path does not exist if it's not help
* Remove testing logging
* Don't error for no-verify
* Stop logging
* Fixed last test
* Added missing semicolons
* Fix indent
* Fix indent again
* Ran prettier over everything
* Added missing types
* Brought test hashes back to normal
* Exit properly when deploying
* Show clipboard note in gray and remove Node.js version
* Completed usage information
* Ensure `now whoami` only outputs the user
* Don not save user data to config
* Removed last traces of `user` and `.api` and `--team` work
* Made `now upgrade` and `now downgrade` correctly render context
* Fixed upgrade/downgrade URL for teams
* Ability to load required data
* Better file name
* Corrected check for current scope
* Don't render version warning when showing help
* Keep polling for handlers
* Render handlers
* Removed useless file
* Much better transpilation setup
* Sweetened logging
* Shortened time it takes to render ready
* Support for error ready states
* Make sure table is not wobbling
* Show times for every handler
* Attach env and build env
* Don't pass useless stuff
* Re-structured pipeline
* Allow empty config
* Do not support package.json config for new pipeline
* Removed occurances of AWS
* Drop useless packages
* Removed useless file
* Ensure the legacy pipeline is working
* Test staging proxy with legacy pipeline
* Adjust test
* Stop testing staging proxy
* Allow for anything
* Pass `handlers` and `routes` to creation endpoint
* Fixed tests
* Revert "Fixed tests"
This reverts commit e0d18a61b9520728089cb2f9e6877c1b91016312.
* Running tests should not be optional
* Support for `-m` and `--meta` added
* Support reading `meta` in local config
* Allow reading `name` from local config
* The `public` prop in local config should be considered
* Handlers deployments should use `.nowignore` and nothing else
* Allow handlers deployments without `handlers` and `routes` in the config
* Locked legacy tests to legacy platform version
* Support aliasing handlers deployments
* Removed useless condition
* Don't allow scaling handlers deployments
* Don't show warning message when deploying single file
* Fixed tests
* Made `now inspect` work
* No type for handlers deployments in list
* Indicate whether a deployment is legacy in `now inspect`
* Made `--force` work for handlers deployments
* Do not document `--dotenv` for handlers (not supported)
* Do not strip `hdl_` from handler IDs
* Fixed for upgrading to latest platform
* Better error for when `version` property is missing
* Render platform version while deploying
* Strip `hdl_` from handler IDs
This reverts commit 750d38ba9074bdc3e63ad2dab8538e51dbba5f03.
* Removed `https://` from handler list
* Removed demo mock
* Cleaner errors
* Make times and erroring work properly
* Print final deployment error
* Removed useless promise
* Prettified code
* Put config utils into correct location
* Moved even more config files
* Removed useless directory
* Removed last useless file
* Fixed wrong paths
* Fixed unit tests
* Update deployment according to handler state, like the server-side loop
* More robust deployment mechanism
* Poll every 1.5 seconds
* Prevent many requests
* Show spinner while waiting for deployment to be ready
* Render how long the deployment took
* Avoid unnecessary repainting
* Automatically remove useless `user` property from config when migrating
* Fixed property names in `now inspect`
* Render platform version for legacy pipeline
* Shortened error messages
* Support `regions` in the local config
* Support for `--regions` added
* Add metadata support for legacy deployments (#2)
* Share handlers table between deploying and inspecting
* Make `now inspect` work nicely
* Renamed handlers to builds
* Stop sending away description
* Bare UI support for builds
* Simper logic for rendering builds
* Render output of builds
* Indicate lambdas in a better way
* Render size for build output
* Do not show type for version 2 deployments
* Fixed time output for `now inspect`
* Don't handle BUILDS type
* Allow for 100% non-config deployments
* Add metadata support for now ls (#3)
* Add metadata support for now ls
So, we can do things like this:
now ls -m key1=value1 -m key2=value2
* Better description
* Fix wording
* Added final newline
* Add sentry (#4)
* Revert "Add sentry (#4)"
This reverts commit 851d1bdb0e1bbc8f329a45388865b2c41395d8c2.
* Only render build output if it was not copied
* Made `now alias` work with latest staging proxy
* Revert "Made `now alias` work with latest staging proxy"
This reverts commit 16e8998435ef03c50d2737f3ef17fa5c0c2dd33f.
* Bumped deployments API to the latest version
* Made `now rm` work
* Do not print `version` warning for single files
* Removed useless `fs-extra` dependency
* Removed useless dependencies
* Default binaries to Node 10
* Bumped Node.js in Circle CI to latest
* Bumped Xcode to get latest Node.js for integration tests
* Enabled HTTP/2 support
* Removed useless code
* Added integration test for builds
* Bumped `fetch-h2` to the latest version
* Avoid performing network request for rendering help
* Render note when viewing latest help
* Return status code `2` when exiting with help
* Fixed test for usage information
* Removed wrong text in usage info for Now 2.0
* Removed support for `--links` from v2 pipeline
* migrated => upgraded
* Added default routing for single files
* Make `--token` work as expected
* Better message for build errors
* Prevent update notification
* Prevent update notifications from showing
* Only show migration message in debug output
* Prevent flickering of state
* Improved output
* Removed useless assignment
* Corrected padding
* Less padding before state
* Corrected links for global configuration
* Fixed integration tests
* Render region for Lambdas
* Join regions in a better way
* Ensure `now.json` and `.nowignore` (the latter worked anyways) are uploaded
* Fix `build.env` in new deployment API call (#6)
* JSON log the deployment body when debugging (#8)
Otherwise it's just `[object Object]` which is useless.
* Retry to fetch on error on follow mode (#5)
* retry fetch on error on follow mode
* improve logging
* Fixed `--env` and `--build-env` CLI args (#7)
* Fix `--env` and `--build-env` CLI args
* Fall back to `undefined`
* Ensure `now switch` lists active scope in the beginning
* Removed useless code
* Error if `env` or `build.env` have wrong types
* Made `now inspect` look great
* Fixed wrong protocol in URL
* Made `now --team` work with users
* Leave PHP out of integration test for now
* Do not select PHP build
* Fixed integration tests
* Revert "12.0.0-canary.93"
This reverts commit 70a0a594b4.
* Revert "Revert "Add support for top-level "sh" auth""
This reverts commit 4273d62460.
* Revert "12.0.0-canary.92"
This reverts commit 847c71ecf2.
* Revert "Add support for top-level "sh" auth"
This reverts commit c493d651db.
* Revert "12.0.0-canary.91"
This reverts commit 06c954f8fe.
* Revert "Added metadata support for `now inspect` (#1634)"
This reverts commit 9567656b45.
* Revert "12.0.0-canary.90"
This reverts commit 966737be23.
* Revert "Added support for deployment metadata (#1604)"
This reverts commit 6c1188a787.
* Allow to add metadata in the now deploy command.
Use can add multiple items of metadata with:
'-m key1=val1 -m key2=val2'
* Add a test case.
* Update to accept and send metadata as meta.
* Use correct fields in now.create
* Add now ls support.
* Add an integration tests for ls with metadata
* Added newline
* Removed semicolon
`slot` and `limits` are now rendered when it is a Cloud v2 deployment.
Also fixes an issue with static deployments always
rendering `affinity: undefined`.
* Move getDomainNameservers function
* Don't show an error as unexpected if there is a code in the error payload
* Add start and finish cert order functions
* Integrate add wildcard cert for external domains
* Use a different endpoint to get a cert by id
* Add new command to download a certificate
* If there are no pending challenges, try to generate the cert right away
* Remove cert download
* Move DNS table options to an object
* Bugfix: cancel spinner message when finish order fails
* Restore add to work only with cert add
* Refactor obtaining cns
* Add start and finish order commands
```
> Error! An unexpected error occurred in scale: Error: This region (gru1) only accepts Serverless Docker Deployments (400)
```
This is happening because `now-cli` is validating DC names and
expanding "all" locally. However not all DCs have same features but
the client can't be aware of that. Instead of making the client
aware of the differing capabilities of the available DCs we should
pass "all" as a special DC selector, and let the backend handle
scaling properly.
* Have returnify use generators and reinstantiate them upon error
* check for status not_ready instead of 412
* poll every 5s instead of 1s for ready state notification
* poll every 2s for scale verification
* checks it is a npm deployment before reading package.json
* checks if you have a config.type first
* checks if you have a config.type first
* fixed logic for config.type
* Use correct source when listing
* Use correct source when buying domains
* Replaced the rest too
* Make adding work nicely
* Make listing work for all scopes
* Don't require address
* Bumped lockfile
* Removed more useless code
* Renamed file
* Fixed weird zlib error
* Fixed output
* Added some tests
* Add `--build-env` to `now deploy` command
Build env vars are only visible during build-time, compared to
regular env vars which are only exposed during runtime.
This also removes the client-side validation of the deployment
schema, because it makes it difficult to keep the client and server
in sync, especially as new features are added. Instead `now-cli`
should be responsible for knowing how to render the server's error
message in an informative and future-proof way so that we can
update the server and even older clients would show the validation
error properly.
* Remove `only` dependency
* Add `--build-env` CLI flag integration test
* Add more integration tests related to static builds and env
Here we are adding a few more integration tests for static builds and for using env vars in the build step.
* Add build-env related test case.
* Do not allow adding domains with subdomains
* Do not ask for confirmation when the domain exists
* Improve message when the domain is under a different account
* Fix flow errors
* Revamp domains add command
* Remove setting dns records when setting up the domain
* Refactor DNS commands
* Hide fields in system dns records and show creator
* Better formatting for dns ls
* Remove exhaustive check of dns record type
* Remove domain ids from responses in domain commands
* Change all `domains` API references to use `v3`
* Update to domains API v3
* Remove NeedUpgrade error and use CDNNeedsUpgrade where it proceeds
* Update copies when adding domains
* Remove extra blank line
* Fix flow errors
* Change params order in createAlias
* Make setupDomain return domainInfo
* Do not try to get a wildcard cert for alias when domain is external
* Update setup-domain.js
* Revert "12.0.0-canary.51"
This reverts commit 5e17fe5ad6.
* Revert "Update `@zeit/schemas` to v1.6.0"
This reverts commit b216adadc0.
* Revert "Upload the Dockerfile if it's a static deployment. (#1437)"
This reverts commit 5078c95667.
* Revert "Upgrade to webpack 4 and latest Babel (#1436)"
This reverts commit 7612d77647.
* Upload the Dockerfile if it's a static deployment.
This allows us to build the Dockerfile and upload static assets
* Allow to upload package.json as well for static deployments.
* Try to purchase a domain only when there is no other choice
* Allow eventsStream to fail during deployment
* Allow to verify instantiation without events API
* Move domains command to its own folder
* Refactor domains commands
* Add cdn to domain ls
* Add function to patch domains
* Support toggling cdnEnabled
* Better messages
* Add new cdn options to help command in domains
* use push instead of read
* don't auto-clear
* single progress bar that hangs till last chink
* print symmary beofre link
* print smmary faster
* print more discreet timestamps
* fix tests
* fix flow error
* Allow to fallback to passed body parsing a response error
* Extract domain purchase from setup-domain
* Move getCertRequestSettings
* Add create method to Now interface
* Extract print dns table and zeit world table functions
* Add support to generate certificates during deploy
* Point to v5 in deploy endpoint
* Add feedback messages when creating a cert during deployment
* Remove hardcoded references to now.sh
* Dont bump create endpoint version
* Support empty reponses in fetch
* Strip quotes from Dockerfile labels
* remove console.log
* add test
* issue normal cert for nested subdomain (#1344)
* Prefer HTTP challenge for regular certs
* 12.0.0-canary.31
* Update non-existing team test
* 12.0.0-canary.32
* Bumped `update-check` to the latest version (#1354)
* 12.0.0-canary.33
* Strip quotes from Dockerfile labels
* remove console.log
* add test
* Load schema from package
* Send config to deployment endpoint
* Upgraded @zeit/schemas to the latest version
* Removed type for now
* Added config correctly
* Corrected license file name
* Corrected readme name
* Added editorconfig
* Account for npm being down
* Print full error
* Only show full error while debugging
* Initialize polling function from args
* Remove rule of having a mandatory dest field in path alias rules
* Wait 5 seconds after getting the deployment ready
* Ignore errors coming from events stream
* Migrate to arg@2.0.0
* Refactor scale command
* Move alias.js to alias/index.js
* Move alias set to its own file
* Move alias ls to its own file
* Move alias rm to its own file
* Remove old alias and scale files
* Update alias integration test
* Fix scaling to 0
* Read scale params from now.json on deploy
* Move deploy command to its own directory
* Do not show success on downscale message
* Move getDeploymentByIdOrHost to /util/deploy
* Remove unneeded parameter in getAppName
* Better types for copyToClipboard
* Update to babel 7
* Add generator utility functions
* Add function to get deployment events
* Finish getDeploymentEvents after getting one state-change event
* Refactor deploy events and reduce verification timeout
* Reduce verification timeout for scale and alias
* Use output.log for success message in scale
* Fix integration tests
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 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/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.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.
### @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 with Vercel and zero configuration.
## Deploy Your Own
Deploy your own [Name] project with Vercel.
[](https://vercel.com/import/project?template=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 Builder using the available Builder's API.
A Builder is an npm module that exposes a `build` function and optionally an `analyze` function and `prepareCache` function.
Official Builders 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 Builder.
See the [Builders Documentation](https://zeit.co/docs/v2/advanced/builders) to view example usage.
## Builder Exports
### `version`
A **required** exported constant that decides which version of the Builder API to use.
The latest and suggested version is `2`.
### `analyze`
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
```
If you are using TypeScript, you should use the following types:
```ts
import{AnalyzeOptions}from'@now/build-utils'
exportanalyze(options: AnalyzeOptions){
return'fingerprint goes here'
}
```
### `build`
A **required** exported function that returns a [Files](#files) data structure that contains the Build outputs, which can be a [Static File](#file) or a [Serverless Function](#serverless-function).
What's a Serverless Function? Read about [Serverless Function concepts](https://zeit.co/docs/v2/deployments/concepts/lambdas) to learn more.
```js
build({
files:Files,
entrypoint:String,
workPath:String,
config:Object,
meta?:{
isDev?:Boolean,
requestPath?:String,
filesChanged?:Array<String>,
filesRemoved?:Array<String>
}
}):{
watch:Array<String>,
output:Filesoutput,
routes:Object
}
```
If you are using TypeScript, you should use the following types:
```ts
import{BuildOptions}from'@now/build-utils'
exportbuild(options: BuildOptions){
// Build the code here
return{
output:{
'path-to-file':File,
'path-to-lambda':Lambda
},
watch:[],
routes:{}
}
}
```
### `prepareCache`
An **optional** exported function that is equivalent to [`build`](#build), but it executes the instructions necessary to prepare a cache for the next run.
```js
prepareCache({
files:Files,
entrypoint:String,
workPath:String,
cachePath:String,
config:Object
}):FilescacheOutput
```
If you are using TypeScript, you can import the types for each of these functions by using the following:
```ts
import{PrepareCacheOptions}from'@now/build-utils'
exportprepareCache(options: PrepareCacheOptions){
return{'path-to-file':File}
}
```
### `shouldServe`
An **optional** exported function that is only used by `now dev` in [Now CLI](https:///download) and indicates whether a [Builder](https://zeit.co/docs/v2/advanced/builders) wants to be responsible for building a certain request path.
```js
shouldServe({
entrypoint:String,
files:Files,
config:Object,
requestPath:String,
workPath:String
}):Boolean
```
If you are using TypeScript, you can import the types for each of these functions by using the following:
```ts
import{ShouldServeOptions}from'@now/build-utils'
exportshouldServe(options: ShouldServeOptions){
returnBoolean
}
```
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).
### Builder 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`.
## Example: html-minifier
Let's walk through what it takes to create a simple builder that takes in a HTML source file and yields a minified HTML static file as its build output.
While this is a very simple builder, the approach demonstrated here can be used to return anything: one or more static files and/or one or more lambdas.
## Setting up the module
### Defining the analyze step
The `analyze` hook is optional. Its goal is to give the developer a tool to avoid wasting time _re-computing a build_ that has already occurred.
The return value of `analyze` is a _fingerprint_: a simple string that uniquely identifies the build process.
If `analyze` is not specified, its behavior is to use as the fingerprint the combined checksums of **all the files in the same directory level as the entrypoint**. This is a default that errs on making sure that we re-execute builds when files _other than the entrypoint_ (like dependencies, manifest files, etc) have changed.
For our `html-minify` example, we know that HTML files don't have dependencies. Therefore, our analyze step can just return the `digest` of the entrypoint.
Our `index.js` file looks as follows:
```js
exports.analyze=function({files,entrypoint}){
returnfiles[entrypoint].digest
}
```
This means that we will only re-minify and re-create the build output _only if the file contents (and therefore its digest) change._
### Defining the build step
Your module will need some utilities to manipulate the data structures we pass you, create new ones and alter the filesystem.
To that end, we expose our API as part of a `@now/build-utils` package. This package is always loaded on your behalf, so make sure it's only included as `peerDependencies` in your `package.json`.
Builders can include dependencies of their liking:
If our builder had performed work that could be re-used in the next build invocation, we could define a `prepareCache` step.
In this case, there are not intermediate artifacts that we can cache, and our `analyze` step already takes care of caching the full output based on the fingerprint of the input.
## Technical Details
### Execution Context
A [Serverless Function](https://zeit.co/docs/v2/advanced/concepts/lambdas) is created where the builder 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.
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.
If you need to share state between those steps, use the filesystem.
### Directory and Cache Lifecycle
When a new build is created, we pre-populate the `workPath` supplied to `analyze` with the results of the `prepareCache` step of the previous build.
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/builders#technical-details).
### Accessing Environment and Secrets
The env and secrets specified by the user as `build.env` are passed to the builder process. This means you can access user env via `process.env` in Node.js.
### Utilities as peerDependencies
When you publish your builder 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`.
## Types
### `Files`
```ts
import{File}from'@now/build-utils'
typeFiles={[filePath: string]:File}
```
This is an abstract type that is implemented as a plain [JavaScript Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object). It's helpful to think of it as a virtual filesystem representation.
When used as an input, the `Files` object will only contain `FileRefs`. When `Files` is an output, it may consist of `Lambda` (Serverless Functions) types as well as `FileRefs`.
An example of a valid output `Files` object is:
```json
{
"index.html":FileRef,
"api/index.js":Lambda
}
```
### `File`
This is an abstract type that can be imported if you are using TypeScript.
```ts
import{File}from'@now/build-utils'
```
Valid `File` types include:
- [`FileRef`](#fileref)
- [`FileFsRef`](#filefsref)
- [`FileBlob`](#fileblob)
### `FileRef`
```ts
import{FileRef}from'@now/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`.
**Properties:**
-`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
### `FileFsRef`
```ts
import{FileFsRef}from'@now/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.
**Properties:**
-`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
### `FileBlob`
```ts
import{FileBlob}from'@now/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.
**Properties:**
-`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
### `Lambda`
```ts
import{Lambda}from'@now/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 use a call to [`createLambda`](#createlambda).
**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
### `LambdaRuntime`
This is an abstract enumeration type that is implemented by one of the following possible `String` values:
-`nodejs10.x`
-`nodejs8.10`
-`go1.x`
-`java-1.8.0-openjdk`
-`python3.6`
-`python2.7`
-`dotnetcore2.1`
-`dotnetcore2.0`
-`dotnetcore1.0`
## JavaScript API
The following is exposed by `@now/build-utils` to simplify the process of writing Builders, 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.
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.
```js
awaitdownload(files,workPath,meta)
```
### `glob`
Signature: `glob() : Files`
```ts
import{glob}from'@now/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).
The following trivial example downloads everything to the filesystem, only to return it back (therefore just re-creating the passed-in [`Files`](#files)):
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
### `version`
A **required** exported constant that decides which version of the Runtime API to use.
The latest and suggested version is `3`.
**Example:**
```typescript
exportconstversion=3;
```
### `build()`
A **required** exported function that returns a Serverless Function.
> What's a Serverless Function? Read about [Serverless Functions](https://vercel.com/docs/v2/serverless-functions/introduction) to learn more.
// Determine whether or not the Runtime should respond to the request path here…
returnoptions.requestPath===options.entrypoint;
}
```
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).
### `startDevServer()`
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.
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.
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.
> **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};
}
```
### Execution Context
- 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),
[`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.
### Directory and Cache Lifecycle
When a new build is created, we pre-populate the `workPath` supplied to `analyze` with the results of the `prepareCache` step of the previous build.
The `analyze` step can modify that directory, and it will not be re-created when it's supplied to `build` and `prepareCache`.
### 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 `@vercel/build-utils` (as seen below in the API definitions) as a dependency, but rather as part of `peerDependencies`.
## `@vercel/build-utils` Types
### `Files`
```typescript
import{File}from'@vercel/build-utils';
typeFiles={[filePath: string]:File};
```
This is an abstract type that is implemented as a plain [JavaScript Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object). It's helpful to think of it as a virtual filesystem representation.
When used as an input, the `Files` object will only contain `FileRefs`. When `Files` is an output, it may consist of `Lambda` (Serverless Functions) types as well as `FileRefs`.
An example of a valid output `Files` object is:
```javascript
{
"index.html":FileRef,
"api/index.js":Lambda
}
```
### `File`
This is an abstract type that can be imported if you are using TypeScript.
```typescript
import{File}from'@vercel/build-utils';
```
Valid `File` types include:
- [`FileRef`](#fileref)
- [`FileFsRef`](#filefsref)
- [`FileBlob`](#fileblob)
### `FileRef`
```typescript
import{FileRef}from'@vercel/build-utils';
```
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
**Methods:**
-`toStream(): Stream` creates a [Stream](https://nodejs.org/api/stream.html) of the file body
### `FileFsRef`
```typescript
import{FileFsRef}from'@vercel/build-utils';
```
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
**Methods:**
-`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`
```typescript
import{FileBlob}from'@vercel/build-utils';
```
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
**Methods:**
-`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`
```typescript
import{Lambda}from'@vercel/build-utils';
```
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
### `LambdaRuntime`
This is an abstract enumeration type that is implemented by one of the following possible `String` values:
-`nodejs12.x`
-`nodejs10.x`
-`go1.x`
-`java11`
-`python3.8`
-`python3.6`
-`dotnetcore2.1`
-`ruby2.5`
-`provided`
## `@vercel/build-utils` Helper Functions
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.
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.
```js
awaitdownload(files,workPath,meta);
```
### `glob()`
Signature: `glob(): Files`
```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).
The following trivial example downloads everything to the filesystem, only to return it back (therefore just re-creating the passed-in [`Files`](#files)):
[](https://spectrum.chat/zeit)
**Note**: The [canary](https://github.com/zeit/now/tree/canary) branch is under heavy development – the stable release branch is [master](https://github.com/zeit/now/tree/master).
[](https://github.com/vercel/vercel/discussions)
## Usage
To install the latest version of Now CLI, visit [zeit.co/download](https://zeit.co/download) or run this command:
Vercel is the optimal workflow for frontend teams. All-in-one: Static and Jamstack deployment, Serverless Functions, and Global CDN.
```
npm i -g now
```
To quickly start a new project, run the following commands:
```
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
```
Get started by [Importing a Git Project](https://vercel.com/import) and use `git push` to deploy. Alternatively, you can [install Vercel CLI](https://vercel.com/download).
## 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?
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
4. Link the package to the global module directory: `cd ./packages/cli && yarn link`
5. You can start using `vercel` 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).
If you have write access to this repository, you can read more about how to publish a release [here](https://github.com/vercel/vercel/wiki/Creating-a-Release).
All PRs are submitted to the `canary` branch. Once a PR is merged into the `canary` branch, it should be published to npm immediately using the Canary Channel.
## Version Selection
Since Builders are published to [npmjs.com](https://npmjs.com), this makes versioning works the same for Builders as it does for any npm package. The `use` statement in [now.json](https://zeit.co/docs/v2/advanced/configuration#builds) has a similar syntax to `npm install`.
The following are valid examples [@now/node](https://www.npmjs.com/package/@now/node?activeTab=versions):
-`@now/node`
-`@now/node@0.7.3`
-`@now/node@canary`
-`@now/node@0.7.2-canary.2`
We always recommend using the latest version by leaving off the dist-tag suffix, `@now/node` for example.
@@ -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 of 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.
The `--token` flag was specified, but its contents are invalid.
#### Possible Ways to Fix It
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 `./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/zeit/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 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%`_
```
{
...
"scripts": {
...
"now-dev": "gatsby develop -p $PORT"
"dev": "gatsby develop -p $PORT"
}
}
```
@@ -32,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.
This is the public list of examples for **Vercel**.
All of these ready to deploy examples feature a frontend framework or static site, created with zero configuration using the CLI tools they provide.
The `+functions` examples feature an `/api` directory as well, highlighting how to use serverless functions on top of a framework, again with zero configuration required.
## What is Vercel?
Vercel is a cloud platform for static frontends and serverless functions. It enables developers to host websites and web applications that deploy instantly, scale automatically, and require no supervision.
## What Does this Repository Contain?
This repository consists of multiple examples, created for use with the [Vercel](https://vercel.com) platform. In addition to this, it also contains:
- [Code of Conduct](https://github.com/vercel/vercel/blob/master/.github/CODE_OF_CONDUCT.md) - our Code of Conduct, adapted from the [Contributor Covenant](http://contributor-covenant.org)
- [Contributing Guidelines](https://github.com/vercel/vercel/blob/master/.github/CONTRIBUTING.md) - a guide on how to contribute to the examples repository
- [License](https://github.com/vercel/vercel/blob/master/LICENSE) - the standard MIT license under which these examples are published
We recommend familiarizing yourself with the above sections, particularly if you are looking to make a contribution.
## Deploying Examples
To get started using any of these examples as your own project, [install Vercel](https://vercel.com/download) 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 takes seconds and can be done with **just 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.
## New Examples
We are continuously improving our examples based on best practices and feedback from the community. As a result, it is possible that example names will change and on occasion deprecated in favor of an improved implementation.
For example, the previous `nodejs` example showed a static frontend with a Node.js API. This is illustrated in the `svelte` example. Below is a table that lists some of the most popular previous examples and the equivalent replacement:
If you have an existing project you would like to deploy with Vercel, we recommend reading our guide on [migrating to Vercel and zero configuration](https://vercel.com/guides/migrate-to-vercel). By combining the guide with this repository, you will quickly be able to understand how to deploy your application.
If you would like to upgrade a project to take advantage of zero configuration, you may find the [upgrade guide](https://vercel.com/guides/upgrade-to-zero-configuration) useful. The upgrade guide covers how to remove configuration from existing projects along with how to use the `/api` directory.
## 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/master/.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.
## License
This repository is an open source project. See the [License](https://github.com/vercel/vercel/blob/master/LICENSE).
## 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 [Angular](https://angular.io/) app that can be deployed with Vercel and zero configuration.
## Deploy Your Own
Deploy your own Angular project with Vercel.
[](https://vercel.com/import/project?template=https://github.com/vercel/vercel/tree/main/examples/angular)
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.