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`.
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.
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.
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.
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>
`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.
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 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.
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 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).
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.
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
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
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
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).
- [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)
* 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
* [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
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
* 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 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 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