Commit Graph

57 Commits

Author SHA1 Message Date
Nathan Rajlich
97eeddb6ac [cli][node] Re-apply @TooTallNate's vc dev updates (#4254)
This reverts commit 099bc6dbf6 (#4231).
2020-05-12 13:58:05 -07:00
Steven
c8e7b266bc [cli] Fix new routing props to be case sensitive (#4341)
This PR fixes a bug where `vc dev` acted differently than real deployments which are supposed to have case sensitive `rewrites` and `redirects`.
2020-05-11 19:55:11 +00:00
Steven
f459db9f83 [now-cli] Add e2e test for vercel.json and .vercelignore (#4292)
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`.
2020-05-07 18:04:37 +00:00
Steven
ba25004ea8 [all] Check for VERCEL_ environment variables with getPlatformEnv() (#4274)
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.
2020-05-06 22:13:12 +00:00
Steven
6b52cfdbc7 [now-cli][now-client] Add support for vercel config files (#4234)
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
2020-05-05 14:58:05 -04:00
Nathan Rajlich
099bc6dbf6 Temporarily revert @TooTallNate's now dev updates (#4231)
Needs more time for testing, and we are preparing a new stable release.

This will be un-reverted after the stable release is tagged.
2020-05-02 00:52:21 +00:00
Steven
fe0d762aca Revert "[now-routing-utils] Fix redirect // when cleanUrls and trailingSlash enabled" (#4232)
Reverts zeit/now#4227

This somehow got merged even though the tests didn't pass. Reverting until it can be merged cleanly.
2020-05-01 22:59:53 +00:00
Steven
07c9c0bb6e [now-routing-utils] Fix redirect // when cleanUrls and trailingSlash enabled (#4227)
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.
2020-05-01 20:44:39 +00:00
Steven
243018b736 [now-cli] Fix CORS headers in now dev (#4225)
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.
2020-05-01 14:29:36 -04:00
Steven
d360169b06 [now dev] Fix handle: miss override headers (#4217)
Fixes a bug with `now dev` where headers from the `miss` phase were overriding when they shouldn't be.

```json
{
  "version": 2,
  "routes": [
    {
      "handle": "filesystem"
    },
    {
      "src": "/([^/]+)",
      "headers": { "override": "one" },
      "dest": "/blog/$1",
      "check": true
    },
    {
      "handle": "miss"
    },
    {
      "src": "/(.*)",
      "dest": "/src/$1",
      "check": true
    },
    {
      "src": "/src/blog/([^/]+)",
      "headers": { "test": "1", "override": "two" },
      "dest": "/src/blog/$1.html",
      "check": true
    }
  ]
}
```
2020-04-30 23:51:02 +00:00
Steven
fb07360b71 [tests] Run now dev tests agains real deployments (#4183)
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.
2020-04-30 17:36:32 -04:00
Nathan Rajlich
e85a62703c [now-cli] Use yarn for now dev integration tests (#4175)
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>
2020-04-28 21:09:49 +02:00
Nathan Rajlich
1e221c48f9 [now-cli] Ensure the builders.tar.gz file is finished extracting (#4124)
`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.
2020-04-23 21:49:20 +00:00
Steven
28e01528c5 [all] Rename ZEIT Now to Vercel (#4112)
https://vercel.com/blog/zeit-is-now-vercel

Co-authored-by: Nathan Rajlich <n@n8.io>
2020-04-21 19:11:12 -04:00
Steven
252363cce4 [now-cli] Prefer .env over .env.build during now dev (#4057)
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.
2020-04-13 18:22:21 +00:00
Steven
c0aff5cf4a [now-cli] Clean up tests for now dev (#4038)
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
2020-04-09 23:30:22 +00:00
Steven
40e4b69267 [now-cli] Fix now dev routing for continue: true (#4033)
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.
2020-04-09 21:35:13 +00:00
Andy
79e7a9f477 [now-cli] Update docusaurus test (#3963) 2020-03-25 13:43:53 +01:00
Steven
6b3908d4dc [now-cli] Fix now dev env vars in Next.js APIs (#3891)
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/10525

Fixes #3758
2020-03-06 22:43:51 +00:00
Steven
b50e4209e1 [now-cli] Fix "The specified token is not valid" (#3857)
Fixes https://sentry.io/organizations/zeithq/issues/1537743736/?project=1323225&referrer=slack
2020-02-28 19:59:51 +00:00
Steven
3b396f29e9 [now-build-utils][now-routing-utils] Fix appendRoutesToPhase() when input is null (#3843)
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.
2020-02-26 23:30:50 +00:00
Steven
d999a3b2ad [now-routing-utils][now-build-utils] Refactor zero-config rewrites (#3832)
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).
2020-02-25 22:30:36 +00:00
Steven
eb793ba139 [tests] Add windows to CI unit tests (#3727)
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.
2020-02-11 01:16:14 +00:00
Steven
e938b298e2 [now-cli] Fix port assignment for now dev (#3769)
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
2020-02-07 19:03:56 -05:00
Steven
adf31c3fcc [now-routing-utils] Change behavior of trailingSlash: true redirects (#3745)
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
2020-02-06 09:07:46 -05:00
Steven
4ca0ff8426 [now-cli] Fix now dev file output renaming (#3703)
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
2020-01-31 12:20:46 +00:00
Luc
fbf659e4e1 [now-cli] Add error message when running now dev on an unlinked folder (#3692)
* refactor getLinkedProject

* adjustments

* refactor getLinkedOrg

* refactor linkFolderToProject to skip linking

* fix dev tests

* adjust tests

* print deployment url for files

* fix missing `NOW_PROJECT_ID` check

* `process.status` -> `link.status`
2020-01-29 21:09:08 +01:00
Andy
b0ed1f2be0 [now-cli] Remove unused code (#3674)
* [now-cli] Remove unused code

* [now-cli] Remove more unused code
2020-01-27 15:19:41 +01:00
Steven
4ac33e1c03 [now-cli][now-client] Drop support for Node 8 (#3670)
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).
2020-01-27 13:32:07 +00:00
Steven
5dd2daa970 [now dev] Add support for handle: miss and handle: hit (#3537)
- [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)
2020-01-22 00:54:24 +00:00
Luc
a63ea8c884 [tests] Fix now-cli tests (#3576)
- [x] adds `--confirm` to `now deploy` command
- [x] adds `--confirm` to existing tests
- [x] fix settings types in `@now/frameworks`
- [x] write deployment url to stdout (instead of an alias)
2020-01-14 10:58:29 +00:00
Andy
f35f244deb [now-build-utils] Only allow Serverless Functions in api/ (#3566)
Only allow Serverless Functions in `api/`.
2020-01-10 19:22:59 +00:00
Andy
3794234d7a [now-build-utils][now-static-build][now-cli] Update detectors and undo previous changes (#3452)
* Revert detect-builders and detect-routes changes

* Add `projectSettings` and support non-api routes

* Start with framework detectors

* Update @now/static-build

* Update now-dev

* Update tests

* Use local builders fro testing with now-dev

* Add outputDirectory to @now/static builds

* Ignore update only for bundeled builders

* Revert now-dev builder changes

* Revert more changes

* Adjust tests further

* Update gridsome test

* Adjust hugo test

* Undo version change

* Read file instead of importing

* Ignore failed.page.txt

* Update packages/now-build-utils/src/detect-builders.ts

Co-Authored-By: Steven <steven@ceriously.com>

* Simplify outputDirectory

* Remove NODE_ENV

* Convert tests to typescript

* Remove console.log

Co-authored-by: Steven <steven@ceriously.com>
2019-12-20 16:29:39 +01:00
Andy
ffaed62094 [now-dev] Update tests with verbose logging (#3447)
Updates the tests for `now dev` to log more and make the hopefully more reliable.
2019-12-18 21:57:59 +00:00
Andy
aa8d002309 [now-cli][now-build-utils] Adjust tests for new detectors (#3443)
* 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
2019-12-17 15:27:12 +01:00
Andy
67a80d6b83 [now-cli][now-build-utils] Update detectors (#3402)
* [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
2019-12-12 18:28:24 +01:00
Steven
44ae0b654e [now-routing-utils] Use 308 status code (#3392)
We decided that all of the new properties should default to 301 status code for any redirects.
2019-12-07 00:38:26 +00:00
Steven
eea7f902b5 [now-cli] Add support for check: true routes in now dev (#3364)
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
2019-11-28 10:58:13 +00:00
Nathan Rajlich
2f7f965188 [now-cli] Update execa to v3.2.0 (#3292)
* [now-cli] Update `execa` to v3.2.0

Also requires updating TypeScript to v3.4+
(See: https://github.com/sindresorhus/execa/issues/336)

* Fix tests: code -> exitCode

* code -> exitCode

* More .code to .exitCode

* Update `@zeit/fun` to v0.10.3
2019-11-11 14:21:27 -08:00
Nathan Rajlich
89114179da [now-cli] Remove test.only() in now dev tests (#3278) 2019-11-10 21:45:14 -08:00
Steven
1fd630460c [now-dev][now-routing-utils] Fix trailingSlash (#3250)
Fixes `trailingSlash: true` in now dev
2019-11-07 15:27:53 +00:00
Andy
abacaf8d40 [all] Fix functions property and update Lambda (#3252)
* 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
2019-11-07 14:31:51 +01:00
Steven
4e4b672af9 [now dev] Add support for cleanUrls (#3240)
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.
2019-11-04 23:42:21 +00:00
Steven
2dee810e74 [now-dev] Fix route normalization (#3225)
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 👍
2019-11-01 20:57:17 +00:00
Andy
31fcc56dbd [now-cli][now-client] Add support for functions property (#3231)
* [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
2019-11-01 17:47:50 +01:00
Nathan Rajlich
34dce350be [now-cli] Loosen "engines" requirement to Node >= 8 (#3195)
Now that `now-client` does not use `fetch-h2`, any version of Node 8 or newer should work with `now-cli`.

Related to #2711.
2019-10-25 00:38:21 +00:00
Steven
dc9b9c240a [now-cli] Add support for new keys in now dev (#3174)
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
2019-10-21 21:55:28 +00:00
JJ Kasper
16ef6229e4 Add test for now dev and Next.js src dir (#3149)
Follow up on #3140 we needed to publish the change before we could test it in `now dev`
2019-10-10 20:36:24 +00:00
Max
73ce59b492 [now-client] Use ignore module to handle file ignoring logic (#3092)
This implements ignore handling using `ignore` module, in the same way CLI stable does it
2019-09-27 19:19:35 +00:00
Max
0383b9112b [now-cli] Move hexo test to testFixtureStdio (#3076)
This should fix the `now dev` tests that periodically hang
2019-09-26 05:33:43 +00:00