Commit Graph

313 Commits

Author SHA1 Message Date
Leo Lamprecht
25facf4934 [now update] Show correct global or local install command (#2719)
* [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
2019-08-20 09:59:39 +02:00
Nathan Rajlich
7f0ce26472 Update serve-handler to v6.1.1 (#2731)
* Update `serve-handler` to v6.1.1

Fixes #2697.

* Fix unit test
2019-08-20 09:59:29 +02:00
Andy
d3366403fe Bump @now/build-utils to 0.9.9 (#2713)
* Bump `@now/build-utils` to 0.9.9

* Log output

* Only log on error

* Fix tests
2019-08-07 12:24:43 +02:00
Nathan Rajlich
3ff2004929 [now dev] Print warning upon empty cwd directory (#2702)
* [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
2019-08-07 12:24:26 +02:00
Andy Bitz
0aa8fa09cb [now deploy] Check server.js file when detecting the platform version (#2664)
This reverts commit 3e5ddad5ca.
2019-08-07 12:10:59 +02:00
Andy Bitz
d71f74fa54 [now deploy] Consider --npm and --docker for platform detection (#2640)
This reverts commit 79e0792a57.
2019-08-07 12:10:53 +02:00
Andy Bitz
47ce713a86 [now deploy] Determine platform version through Dockerfile and package.json (#2633)
This reverts commit 8da0534d4f.
2019-08-07 12:10:42 +02:00
Andy Bitz
3c5b94855a [now deploy] Check if builds are ready right away (#2699)
This reverts commit 92cff5c947.
2019-08-07 12:08:43 +02:00
Andy Bitz
8da0534d4f Revert "[now deploy] Determine platform version through Dockerfile and package.json (#2633)"
This reverts commit 9244e43ccf.
2019-08-05 18:49:51 +02:00
Andy Bitz
79e0792a57 Revert "[now deploy] Consider --npm and --docker for platform detection (#2640)"
This reverts commit 69e7c57975.
2019-08-05 18:49:12 +02:00
Andy Bitz
3e5ddad5ca Revert "[now deploy] Check server.js file when detecting the platform version (#2664)"
This reverts commit 482ca7a8a6.
2019-08-05 18:44:38 +02:00
Andy Bitz
92cff5c947 Revert "[now deploy] Check if builds are ready right away (#2699)"
This reverts commit 2877563064.
2019-08-05 18:43:26 +02:00
Andy
4f8cf6793b [now update] Remove is-installed-globally (#2700)
* [now update] Remove `is-installed-globally`

* Only suggest global

* Adjust test
2019-08-05 18:40:41 +02:00
Andy
2877563064 [now deploy] Check if builds are ready right away (#2699)
* [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
2019-08-05 18:40:34 +02:00
Nathan Rajlich
4fbd75f384 Assert 200 response status on "deploy a dockerfile project" integration test (#2684)
* Assert 200 response status on "deploy a dockerfile project" integration test

* Fix
2019-08-05 18:40:22 +02:00
Nathan Rajlich
188150da26 [now dev] Allow custom 404 pages via routes (#2689)
* [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
2019-08-05 18:40:08 +02:00
Andy
83d50374ff [preinstall/now update] Check if now is installed locally (#2688)
* [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
2019-08-05 18:40:00 +02:00
Nathan Rajlich
2b3d4cd449 Fix routes definition in now-dev-static-routes test fixture (#2687)
This is the proper way to define this route because of the capture of
the initial `/`.

Matches how it works in production.
2019-08-05 18:39:52 +02:00
Nathan Rajlich
0ef680484d [now dev] Support JSON and HTML error responses (#2677)
* [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
2019-08-05 18:39:47 +02:00
Nathan Rajlich
4d81ee8c87 [now dev] Use a consistent "pod id" for x-now-id (#2679)
This matches the behavior in production.
2019-08-05 18:39:34 +02:00
Andy
33cd5d6c1d [now deploy] Change link for legacy warning (#2674)
* [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
2019-08-05 18:39:28 +02:00
Andy
482ca7a8a6 [now deploy] Check server.js file when detecting the platform version (#2664)
* [now deploy] Check `server.js` file when detecting the platform version

* Fix type
2019-08-05 18:39:11 +02:00
Andy
6322be2bf7 [CircleCI] Add more test suites for macOS support (#2663)
* [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
2019-08-05 18:38:59 +02:00
Nathan Rajlich
ba007f89ff [now dev] Bundle canary builders for Now CLI canary (#2661)
* [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
2019-08-05 18:38:45 +02:00
Andy
00129ea452 [now dev] Update outdated dependencies in tests (#2666) 2019-08-05 18:38:38 +02:00
Andy
70571d10c1 [now dev] Fix aurelia test (#2660)
* [now dev] Fix aurelia test

* Enable aurelia test again
2019-08-05 18:38:21 +02:00
Nathan Rajlich
aee22a3d38 Support Node 8 (#2648)
* 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
2019-08-05 18:38:13 +02:00
Andy
69e7c57975 [now deploy] Consider --npm and --docker for platform detection (#2640)
* [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
2019-08-05 18:37:58 +02:00
Nathan Rajlich
4e796ca952 [now dev] Redirect when request has multiple slashes (#2645)
* [now dev] Redirect when request has multiple slashes

Closes #2642.

* Add POST passthrough
2019-08-05 18:37:53 +02:00
Andy
6ea080d48b [now dev] Prevent recursive function call for handle: "filesystem" (#2630)
* [now dev] Prevent recursive function call for `handle: "filesystem"`

* Add test

* Update test/dev/integration.js

Co-Authored-By: Nathan Rajlich <n@n8.io>

* Handle recursive `serveProjectAsNowV2` call

* Fix test
2019-08-05 18:37:33 +02:00
Sophearak Tha
748e34757e [now dev] Improve integration tests for now dev (#2597)
* 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
2019-08-05 18:37:26 +02:00
Nathan Rajlich
c93c458cd4 [CircleCI] Run integration tests on multiple versions of Node.js (#2596)
* [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
2019-08-05 18:36:05 +02:00
Nathan Rajlich
3c10787621 [now dev] Add server: now response header (#2646)
Matches production.
2019-08-05 18:31:23 +02:00
Nathan Rajlich
544d26dea9 [now dev] Remove accidental test.only() (#2644)
This got committed by accident :(
2019-08-05 18:31:11 +02:00
Andy
9244e43ccf [now deploy] Determine platform version through Dockerfile and package.json (#2633)
* [now deploy] Determine platform version through `Dockerfile` and
`packge.json`

* Update src/commands/deploy/index.js

Co-Authored-By: Nathan Rajlich <n@n8.io>

* Change notification, add tests, consider `type`

* Change test

* Adjust test

* Adjust test

* Update src/util/prefer-v2-deployment.ts

Co-Authored-By: Nathan Rajlich <n@n8.io>
2019-08-05 18:31:06 +02:00
Andy
bb5fbc28a0 [now dev] Clean up before calling process.exit (#2629)
* [now dev] Clean up before calling `process.exit`

* Log error

* Update src/util/dev/server.ts

Co-Authored-By: Steven <steven@ceriously.com>
2019-08-05 18:30:53 +02:00
Nathan Rajlich
3a501a0c08 [now dev] Fix routing catch-all with no slash prefix edge case (#2626)
Fixes #2622.
2019-08-05 18:30:47 +02:00
Nathan Rajlich
cda6a2cbb6 [now update] Render the proper tag and improve yarn detection logic (#2595)
* [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
2019-08-05 18:11:49 +02:00
Sophearak Tha
50a87c4965 Remove pkg bundling (#2567)
* 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
2019-08-05 18:10:57 +02:00
Andy Bitz
53f0adb88a Revert "[now update] Render the proper tag and improve yarn detection logic (#2595)"
This reverts commit 4ceb4c8984.
2019-07-25 17:06:27 +02:00
Andy
5a187b97ab Use fs-extra instead of fs.promises to prevent warnings on Node 10 (#2602) 2019-07-25 14:00:04 +02:00
Nathan Rajlich
d78cd371ed [now dev] Wait for blocking builds to complete before handling requests (#2562)
* [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
2019-07-25 13:59:20 +02:00
Nathan Rajlich
a720d5b181 [now dev] Add warning when there are no build matches (#2594)
* [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
2019-07-25 13:59:09 +02:00
Nathan Rajlich
4ceb4c8984 [now update] Render the proper tag and improve yarn detection logic (#2595)
* [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
2019-07-25 13:58:53 +02:00
Andy
f9c262f4bb [now dev] Fix directory listing race condition (#2591)
* [now dev] Fix directory listing race condition

* Resolve file names

* Check only matched files

* Log stdout and stderr

* Log expected

* Change test

* Revert "Change test"

This reverts commit 149723be0f2015bd400dd5f2d5cce523303a05cf.

* Add timeout to request

* Adjust retries

* Don't use unref

* Remove tests

* Revert "Remove tests"

This reverts commit 6159d657bfa978719ffb23153058b791b2ce8a2a.

* Adjusted test

* Make sure directory exists

* Fix tests

* Add yarn.lock

* Adjust timeout
2019-07-25 13:58:43 +02:00
Sophearak Tha
e45e403bb3 Add configuration and basic integration tests for now dev (#2553)
* 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
2019-07-25 13:58:25 +02:00
Andy
a4ad8c64e6 [now dev] Bump @now/build-utils (#2582)
* [now dev] Bump @now/build-utils

* Replace `apollo` init example fixure with `angular`

* Update more tests

* Remove `now.json` from check
2019-07-19 22:31:24 +02:00
Andy
2aeab737d9 [now dev] Upgrade @now/build-utils and enable more support for static sites (#2575)
* [now dev] Upgrade `@now/build-utils` and enable more support for static sites

* Add tests

* Upgrade @now/build-utils
2019-07-19 14:05:52 +02:00
Matthew Sweeney
e5e33549f8 Add hint when example not found (#2572)
* add hint when example not found

* update test

* update test
2019-07-18 15:24:35 +02:00
Andy
a5e857df7b Change now update to display npm or yarn command (#2568)
* Change `now update` to display npm or yarn command

* Use `getUpgradeCommand`
2019-07-18 13:58:21 +02:00