Compare commits

...

1598 Commits

Author SHA1 Message Date
Steven
aee33f040d Publish Stable
- @now/build-utils@1.2.0
 - @now/cgi@1.0.1
 - now@16.7.0
 - @now/go@1.0.1
 - @now/next@2.2.0
 - @now/node@1.3.0
 - @now/python@1.0.1
 - @now/ruby@1.0.1
 - @now/static-build@0.14.0
2019-12-14 07:58:04 -05:00
Steven
b100677b3b Publish Canary
- @now/next@2.1.2-canary.3
2019-12-14 07:18:41 -05:00
Joe Haddad
9241b3ae2f [now-next] Compute Rewrites & Redirects Earlier (#3430)
This PR strictly moves code to make the diff for an upcoming PR cleaner.
2019-12-14 03:04:35 +00:00
Steven
1088da6871 Publish Canary
- @now/build-utils@1.1.2-canary.5
 - now@16.6.4-canary.6
 - @now/next@2.1.2-canary.2
 - @now/node@1.2.2-canary.2
 - @now/static-build@0.13.2-canary.3
2019-12-13 18:12:54 -05:00
Andy
f7b4dd4458 Revert "[now-static-build] Add support buildCommand, devCommand and outputDirectory (#3422)" (#3428)
This reverts commit 5a6d1a135f.
2019-12-13 18:12:16 -05:00
Steven
fb85b6b27a Publish Canary
- @now/build-utils@1.1.2-canary.4
 - now@16.6.4-canary.5
 - @now/next@2.1.2-canary.1
 - @now/node@1.2.2-canary.1
 - @now/static-build@0.13.2-canary.2
2019-12-13 17:24:55 -05:00
Steven
2e5e9b9a6f [now-build-utils] Fix error tput: No value for $TERM and no -T specified (#3425) 2019-12-13 17:23:41 -05:00
Steven
d3cc306e5b [now-build-utils] Remove unused execa (#3427)
~~Reverts the execa bump from #3422~~

Removes `execa` since it is no longer used.
2019-12-13 17:23:18 -05:00
Steven
d6c6a2a271 [docs] Fix broken link to runtimes (#3424) 2019-12-13 15:48:06 -05:00
Andy Bitz
6171a58ae3 Publish Canary
- @now/build-utils@1.1.2-canary.3
 - now@16.6.4-canary.4
 - @now/static-build@0.13.2-canary.1
2019-12-13 19:39:50 +01:00
Andy
5a6d1a135f [now-static-build] Add support buildCommand, devCommand and outputDirectory (#3422)
* [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
2019-12-13 19:30:09 +01:00
Steven
68deab9007 [tests] Fix unit test coverage (#3420)
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).
2019-12-12 22:13:02 +00:00
Steven
d6114e2bef [deps] Fix yarn.lock signal-exit (#3419)
This patch was lost in a previous PR so I added it back
2019-12-12 20:16:21 +00:00
Steven
5fdc55f3fb [now-cli] Remove dead link to max lambda size (#3418)
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.
2019-12-12 19:41:54 +00:00
Mark Glagola
751b166536 [now-cli] Add renewal price to now domains inspect (#3401)
Adds `Renewal Price` to `now domains inspect` command if the domain was bought with ZEIT.
2019-12-12 18:03:19 +00:00
Andy Bitz
6ffc8d97f4 Publish Canary
- @now/build-utils@1.1.2-canary.2
 - now@16.6.4-canary.3
2019-12-12 18:37:10 +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
934cf772bc Publish Canary
- @now/build-utils@1.1.2-canary.1
 - now@16.6.4-canary.2
2019-12-12 10:58:21 -05:00
Andy
b01a24afdb [now-build-utils][now-cli] Move builds schema and functions schema to build-utils (#3417)
* [@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
2019-12-12 16:02:19 +01:00
hi_Haowen
0ad75b52bf [now dev] Fix validate functions config failed in now json (#3414)
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
```
2019-12-12 13:59:39 +00:00
Andy Bitz
050772e78a Publish Canary
- now@16.6.4-canary.1
2019-12-12 13:23:12 +01:00
Andy
7c05dc1420 [now-cli] Do not handle cert errors for deployments (#3409)
Domain related things for deployment will now happen async
2019-12-12 13:19:26 +01:00
Steven
bdd25ac727 Publish Canary
- @now/build-utils@1.1.2-canary.0
 - @now/cgi@1.0.1-canary.1
 - now@16.6.4-canary.0
 - @now/go@1.0.1-canary.1
 - @now/next@2.1.2-canary.0
 - @now/node@1.2.2-canary.0
 - @now/python@1.0.1-canary.1
 - @now/ruby@1.0.1-canary.1
 - @now/static-build@0.13.2-canary.0
2019-12-11 17:30:11 -05:00
Steven
3a27328828 [now-build-utils] Discontinue Node 8 (#3406)
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
2019-12-11 22:27:16 +00:00
Nathan Rajlich
c076a5620f [all] Move "Downloading deployment source files" message to download() (#3413)
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
2019-12-11 20:59:14 +00:00
Nathan Rajlich
2bd8ef9eed [now-next] Do not pass runtime env vars via argv in now dev (#3340)
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`.
2019-12-11 19:18:08 +00:00
JJ Kasper
500014f2fc [now-next] Handle symlinks in createPseudoLayer (#3404)
This makes sure to handle symlinks created in mono repos while creating the zip for a lambda based page in Next.js

Fixes #3400
2019-12-11 15:43:14 +00:00
JJ Kasper
17687e9bcd Fix unused pre-commit package overriding husky (#3405)
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`
2019-12-11 14:35:30 +00:00
Andy
90354e9fe7 [now-cgi][now-next][now-ruby] Unify logging about downloading user files (#3397)
* [now-cgi][now-next][now-ruby] Unify logging about downloading user files

* Update next tests

* Bump Next.js Version
2019-12-10 21:15:32 +01:00
Leo Lamprecht
6236631beb [now-dev] Improved feedback link (#3399)
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
2019-12-10 18:18:10 +00:00
Steven
75aefdddd6 Publish Stable
- @now/build-utils@1.1.1
 - now@16.6.3
 - now-client@6.0.0
 - @now/next@2.1.1
 - @now/node@1.2.1
 - @now/routing-utils@1.4.0
 - @now/static-build@0.13.1
2019-12-09 08:03:47 -05:00
Steven
566d82e873 Publish Canary
- now@16.6.3-canary.0
 - @now/next@2.1.1-canary.1
 - @now/node@1.2.1-canary.0
 - @now/routing-utils@1.3.4-canary.6
 - @now/static-build@0.13.1-canary.1
2019-12-06 19:49:27 -05: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
d8cfaae596 [now-node][now-next][now-static-build] Remove lockfiles from cache (#3391)
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.
2019-12-06 23:35:17 +00:00
Steven
a40e0f21ee Publish Canary
- @now/build-utils@1.1.1-canary.2
2019-12-06 15:57:33 -05:00
Steven
ac1f506c98 [now-build-utils] Add --no-audit flag to npm install (#3390)
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
2019-12-06 20:48:30 +00:00
Steven
68d5bdcf3d [script] Fix stable publish script (#3389)
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>
2019-12-06 19:31:38 +00:00
Andy Bitz
beb51f8c67 Publish Stable
- now@16.6.2
2019-12-06 13:48:44 +01:00
Andy
b881cb7111 [now-cli] Remove github property from payload before sending it (#3388)
* [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
2019-12-06 13:47:16 +01:00
Andy Bitz
d83bc59257 Publish Stable
- now@16.6.1
2019-12-06 00:18:57 +01:00
Steven
5be9f297de [now-cli] Change --debug to avoid debugging builders (#3386)
* [now-cli] Change `--debug` to avoid debugging builders

* Fix tests

* Replace test with on/off
2019-12-06 00:11:22 +01:00
JJ Kasper
51d440431e Publish Canary
- @now/build-utils@1.1.1-canary.1
 - @now/next@2.1.1-canary.0
2019-12-05 15:18:35 -06:00
JJ Kasper
7cf061122c [now-next] Update routes for new check: true behavior (#3383)
As discussed this moves the `handle: filesystem` usage to the right location now that we have `check: true` for the `rewrites`
2019-12-05 20:48:17 +00:00
Nathan Rajlich
1254368505 [now-build-utils] Update Detectors API (#3384)
* Changes the `buildCommand` and `devCommand` from `string[]` to `string`
 * Renames `buildEnv` to `buildVariables` and `devEnv` to `devVariables`
2019-12-05 20:01:28 +00:00
Andy Bitz
9d4b830c5f Publish Canary
- now@16.6.1-canary.1
 - now-client@6.0.0-canary.1
2019-12-05 14:14:50 +01:00
Andy
37401b4363 [now-client] Bump version (#3385) 2019-12-05 14:14:00 +01:00
Andy
10fe08e14f [now-client] (Major) Split now-client options (#3382)
* Change types

* Split options for now-client

* Fix query and teamId

* Adjust tests

* Fix linting

* Ignore scope

* Adjust now-client tests

* Adjust more tests

* Apply prettier
2019-12-05 14:08:39 +01:00
Steven
0ecdb35d50 [now-cli][now-client] Fix user agent (#3381)
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)`.
2019-12-04 23:10:31 +00:00
Steven
caee8fe9ef Publish Canary
- now-client@5.2.5-canary.0
2019-12-04 16:46:43 -05:00
Max
7d92c27b2d [now-client] Fix main in package.json (#3344)
This sets `main` in `now-client` to a proper path.

Follow up to #3315.

Fixes #3373.
2019-12-04 13:25:27 -08:00
Steven
701eabbaba Publish Canary
- now@16.6.1-canary.0
2019-12-04 09:28:21 -05:00
Andy Bitz
e74a1b2d1a Publish Canary
- @now/build-utils@1.1.1-canary.0
2019-12-02 23:41:28 +01:00
Andy
e087b02333 [now-build-utils] Change script to scripts in error message (#3376)
Change `script` to `scripts` in error message.

[PRODUCT-740]

[PRODUCT-740]: https://zeit.atlassian.net/browse/PRODUCT-740
2019-12-02 22:33:27 +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
Steven
db7583201b [now-cli] Fix preinstall script on windows when LOCALAPPDATA is missing (#3365)
Usually `LOCALAPPDATA` is set to `C:\Users\{username}\AppData\Local` but occasionally, it is unassigned and causes installation failures. Looks like this could be due to the [registry](https://liquidwarelabs.zendesk.com/hc/en-us/articles/210634163-How-To-Make-APPDATA-and-LOCALAPPDATA-Environment-Variables-Follow-The-Registry-Keys).

If `LOCALAPPDATA` is missing, we can assume that now.exe was not installed before and can skip the deletion step that happens in the preinstall script.
2019-11-28 00:35:53 +00:00
Tommaso De Rossi
023001a8b1 [now dev] skip installing already installed versioned runtimes (#3354)
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
2019-11-27 11:33:18 +00:00
Steven
4ff8ab2435 Publish Canary
- @now/routing-utils@1.3.4-canary.5
2019-11-26 19:00:34 -05:00
Steven
d2cccbfce6 [now-routing-utils] Update path-to-regexp to v6.1.0 (#3361)
This bumps `path-to-regexp` to the latest version 6.1.0 which fixes optional capture groups like the test I added for `/next.js`.
2019-11-26 23:41:35 +00:00
Steven
970e6c400c Publish Canary
- @now/routing-utils@1.3.4-canary.4
2019-11-26 13:10:09 -05:00
Steven
b4cb7345a1 [now-routing-utils] Add mergeRoutes function (#3358)
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
2019-11-26 17:51:19 +00:00
Steven
7e75d8c1a3 [docs] Remove deprecated LambdaRuntimes (#3346)
- Removes Node 8.10 and old .NET which are EOL
- Adds a couple missing such as Ruby
2019-11-22 21:12:23 +00:00
Steven
a4ea551160 Publish Canary
- @now/routing-utils@1.3.4-canary.3
2019-11-22 14:41:33 -05:00
Steven
f56ad447a0 [now-routing-utils] Add support for check: true (#3343)
This PR adds support for `check: true` for a route object. It is basically a way to add a rewrite and still check the filesystem.
2019-11-22 19:03:45 +00:00
luc
7656422057 Publish Canary
- @now/static-build@0.13.1-canary.0
2019-11-22 17:39:35 +08:00
Luc
afa2231add [now-static-build] Cache .cache folder for gatsby deployments (#3260) (#3342)
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.
2019-11-22 09:16:51 +00:00
Steven
21fe0a2006 Publish Stable
- @now/build-utils@1.1.0
 - now@16.6.0
 - now-client@5.2.4
 - @now/next@2.1.0
 - @now/node@1.2.0
 - @now/static-build@0.13.0
2019-11-21 13:14:17 -05:00
Steven
23acd3cec6 Publish Canary
- @now/build-utils@1.0.1-canary.4
 - now@16.5.3-canary.6
 - @now/routing-utils@1.3.4-canary.2
2019-11-21 11:45:19 -05:00
Steven
7892f88a42 [now-build-utils] Ignore engines for yarn run (#3341)
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`.
2019-11-21 16:41:55 +00:00
Steven
aae0e3bec7 Revert [now-cli][now-routing-utils] Add support for v4 builders #3311 (#3333)
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.
2019-11-21 15:49:33 +00:00
Steven
0f8bf39421 Publish Canary
- now@16.5.3-canary.5
 - @now/next@2.0.1-canary.1
 - @now/node@1.1.3-canary.2
 - @now/static-build@0.12.3-canary.2
2019-11-20 15:33:13 -05:00
Steven
36fd96cc6c Publish Canary
- @now/build-utils@1.0.1-canary.3
2019-11-20 11:19:07 -05:00
Steven
3de08e9f3b [now-build-utils] Fix canary selection for static build (#3339)
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`.
2019-11-20 16:17:55 +00:00
Steven
3e739724b3 Publish Canary
- @now/build-utils@1.0.1-canary.2
 - now@16.5.3-canary.4
 - now-client@5.2.4-canary.2
 - @now/node@1.1.3-canary.1
 - @now/static-build@0.12.3-canary.1
2019-11-20 08:55:18 -05:00
Nathan Rajlich
847e538c69 [now-cli] Render an error message when the --token content is invalid (#3335)
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
```
2019-11-20 11:05:45 +00:00
Nathan Rajlich
64684dd486 [now-build-utils] Run detectors unit tests (#3336)
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`.
2019-11-19 18:48:15 -08:00
Steven
a229747249 [now-build-utils][now-static-build][now-node] Add node 12.x (#3330)
This PR adds support for Node 12 when the user defines `engines` in their `package.json`
2019-11-20 02:34:01 +00:00
Nathan Rajlich
d1b59c3543 [now-build-utils] Add framework detector functions (#3296)
* [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`
2019-11-19 17:16:49 -08:00
JJ Kasper
b241441e37 Publish Canary
- now@16.5.3-canary.3
 - @now/next@2.0.1-canary.0
2019-11-19 15:06:43 -06:00
JJ Kasper
40bfa25b1b [now-next] Fix custom routes order (#3327)
This updates the routes order to make sure `_next/*` routes are at the top so that custom `rewrites`/`redirects` don't conflict with them

x-ref: https://github.com/zeit/next.js/issues/9081#issuecomment-555161265
2019-11-19 21:05:02 +00:00
Nathan Rajlich
c5a4386c1d [now-cli] Update @zeit/fun to v0.10.4 (#3332)
Possibly fixes #3323 (because of zeit/fun#43).
2019-11-19 20:32:36 +00:00
Nathan Rajlich
b3aa3be4b8 [CircleCI] Remove rsync apt-get install (#3329)
Used to be used in the now-cli build script when it was a bash script.
Now it's a TypeScript file and the `cpy` module is used instead.
2019-11-19 08:55:42 +01:00
Steven
528aefcc1e [now-cli] Handle uv_cwd error when cwd is deleted (#3326)
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.
2019-11-18 22:27:46 +00:00
Andy
620ee2b7e4 [now-cli] Ensure that stdin exists when calling setRawMode (#3321)
Ensure that `stdin` exists when calling `setRawMode`.

[Error on Sentry](https://sentry.io/organizations/zeithq/issues/1310516610/?project=1323225)

[PRODUCT-637]

[PRODUCT-637]: https://zeit.atlassian.net/browse/PRODUCT-637
2019-11-18 21:22:29 +00:00
Andy Bitz
d55acc246a Publish Canary
- @now/build-utils@1.0.1-canary.1
2019-11-18 11:54:08 +01:00
Andy
2a59db3029 [now-build-utils] Ensure function paths are relative to the project and improve the error message (#3312)
* [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>
2019-11-15 18:56:23 +01:00
Andy Bitz
990dec0fec Publish Stable
- @now/next@2.0.0
2019-11-15 15:33:18 +01:00
Andy
162b17b249 [now-next] Make lambda memory more reliable (#3319) 2019-11-15 15:28:28 +01:00
Steven
e0aea30618 Publish Canary
- now@16.5.3-canary.2
 - @now/routing-utils@1.3.4-canary.1
2019-11-14 16:00:47 -05:00
Steven
49cba94178 [now-cli][now-routing-utils] Add support for v4 builders (#3311)
- 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.
2019-11-14 20:48:13 +00:00
Steven
7dd87815f3 Publish Canary
- now@16.5.3-canary.1
 - now-client@5.2.4-canary.1
2019-11-14 14:18:50 -05:00
Steven
f6fdde816f [now-client] Fix publish output (#3315)
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.
2019-11-14 19:09:03 +00:00
Steven
4c8c6ff236 [script] Cleanup changelog script (#3306)
This script is only used for stable releases so we should filter out canary publish commits.
2019-11-14 18:31:04 +00:00
Steven
46b615a963 [now-cli] Fix localConfig when file is above the target directory (#3293)
Fixes #3209
2019-11-14 18:00:39 +00:00
Steven
8e293dd633 Publish Canary
- gatsby-plugin-now@1.2.6-canary.0
 - @now/build-utils@1.0.1-canary.0
 - @now/cgi@1.0.1-canary.0
 - now@16.5.3-canary.0
 - now-client@5.2.4-canary.0
 - @now/go@1.0.1-canary.0
 - @now/next@1.0.6-canary.0
 - @now/node-bridge@1.2.7-canary.1
 - @now/node@1.1.3-canary.0
 - @now/python@1.0.1-canary.0
 - @now/routing-utils@1.3.4-canary.0
 - @now/ruby@1.0.1-canary.0
 - @now/static-build@0.12.3-canary.0
2019-11-13 10:28:12 -05:00
Thew Dhanat
e040753b27 [now-node] Ignore babel.config.js (#3295)
@now/node shouldn't read user's Babel configuration.
Fix #3280
2019-11-13 14:36:33 +00:00
Andy
463aaf094d [now-cli] Make lambda memory test more consistent (#3301)
Make lambda memory test more consistent
2019-11-13 11:21:53 +00:00
Steven
bf867b028d [tests] Always test now-cli (#3305)
Previously, only the changed package's tests would run.

This PR makes sure that the changed package + `now-cli` tests run every time.
2019-11-13 02:32:02 +00:00
Steven
6dfefc2fe4 Publish Stable
- gatsby-plugin-now@1.2.5
 - now@16.5.2
 - @now/node@1.1.2
 - @now/static-build@0.12.2
2019-11-12 18:52:28 -05:00
Steven
9ba8a8454c Bump versions 2019-11-12 18:51:32 -05:00
Steven
9c72839bfa Empty commit 2019-11-12 18:48:26 -05:00
Steven
2e24c92799 Publish Canary
- gatsby-plugin-now@1.2.4-canary.0
 - @now/node@1.1.1-canary.0
 - @now/static-build@0.12.1-canary.0
2019-11-12 18:18:17 -05:00
Andy
fa98c8aeeb Revert "[now-static-build] Inject gatsby-plugin-now in Gatsby deployments (#3182)" (#3303)
This reverts the following gatsby changes:

- Reverts #3182
- Reverts #3260
- Reverts #3212
2019-11-12 23:13:39 +00:00
Steven
f92e3496b1 [now-node] Bump now-node-bridge (#3304)
A trivial change to follow up to #3300 so that the latest `@now/node-bridge` is bundled with `ncc`.
2019-11-12 22:37:49 +00:00
Steven
0ceea76aa4 Publish Canary
- now@16.5.1-canary.0
 - @now/node-bridge@1.2.7-canary.0
2019-11-12 14:57:22 -05:00
Steven
897d11a1e1 [now-node] Disable default node timeout (#3300)
Node had a default [timeout](https://nodejs.org/api/http.html#http_server_timeout) of 2 minutes until Node 13.x so we'll need to manually disable the timeout so that the `maxDuration` config works properly.
2019-11-12 19:54:05 +00:00
Andy Bitz
8ed59fcdd3 Publish Stable
- gatsby-plugin-now@1.2.3
 - @now/build-utils@1.0.0
 - @now/cgi@1.0.0
 - now@16.5.0
 - now-client@5.2.3
 - @now/go@1.0.0
 - @now/node-bridge@1.2.6
 - @now/node@1.1.0
 - @now/python@1.0.0
 - @now/routing-utils@1.3.3
 - @now/ruby@1.0.0
 - @now/static-build@0.12.0
2019-11-12 15:55:59 +01:00
Andy
7f211cc7fc [all] Set the versions to stable (#3297) 2019-11-12 15:52:16 +01:00
Andy Bitz
c511147c7c Publish Canary
- @now/build-utils@1.0.0-canary.23
 - now@16.1.4-canary.43
 - now-client@5.1.1-canary.18
 - @now/node@1.0.0-canary.17
2019-11-11 23:33:18 +01: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
Andy
24da26e7cf [@now/build-utils] Add support for includeFiles and excludeFiles to Functions (#3285)
Add support for `includeFiles` and `excludeFiles` to Functions.

[PRODUCT-27]

[PRODUCT-27]: https://zeit.atlassian.net/browse/PRODUCT-27
2019-11-11 22:17:59 +00:00
Andy
f8f9d656e8 [@now/node] Configure helpers and handler with env variables (#3286)
Allow to configure helpers and handler with env variables.

[PRODUCT-27]

[PRODUCT-27]: https://zeit.atlassian.net/browse/PRODUCT-27
2019-11-11 21:24:28 +00:00
Steven
b357f3055d [docs] Cleanup canary links, use master instead (#3291)
Follow up to #3287
2019-11-11 19:54:40 +00:00
Max
f9c1f519f4 [now-client] Clean up fetch headers (#3290)
Reopen of #3255
2019-11-11 19:31:20 +00:00
Steven
057f9f7045 Publish Canary
- now@16.1.4-canary.42
 - @now/node@1.0.0-canary.16
 - @now/ruby@0.1.5-canary.8
2019-11-11 13:53:20 -05:00
Steven
58ec38437d [now-node] Fix TS version selection (#3289)
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
2019-11-11 18:45:39 +00:00
Steven
2964bf50e0 [now-ruby] Fix rails test (#3288)
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 #3246
Closes #3274
2019-11-11 16:34:20 +00:00
Leo Lamprecht
c9572c352a Adjust commands for creating releases (#3287)
* Adjust commands for creating releases

* Update package.json

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

* Update package.json

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

* Adjusted log line

* Deleted diff.js

* Remove script

* Fix run.js to use master
2019-11-11 10:50:04 -05:00
Andy
b69f176143 [now-cli] Enable Runtime tests (#3284)
Enable Runtime tests, since a new version of the `now-php` package was released.
2019-11-11 12:33:54 +00:00
Leo Lamprecht
484dcd5dc1 Publish
- now@16.1.4-canary.41
2019-11-11 12:59:08 +01:00
Leo Lamprecht
a3412113b7 Trigger publish 2019-11-11 12:58:49 +01:00
Leo Lamprecht
693043bc27 Fixed dependencies 2019-11-11 12:57:44 +01:00
Leo Lamprecht
82a5bafb42 Fixed dependencies (#3283) 2019-11-11 12:51:44 +01:00
Leo Lamprecht
1c8c4c6f72 Publish
- gatsby-plugin-now@1.2.1-canary.5
 - @now/build-utils@1.0.0-canary.22
 - @now/cgi@0.1.5-canary.4
 - now@16.1.4-canary.40
 - now-client@5.1.1-canary.17
 - @now/go@0.5.11-canary.9
 - @now/next@1.0.0-canary.22
 - @now/node-bridge@1.2.4-canary.3
 - @now/node@1.0.0-canary.15
 - @now/python@0.2.17-canary.11
 - @now/routing-utils@1.2.3-canary.12
 - @now/ruby@0.1.5-canary.7
 - @now/static-build@0.9.9-canary.20
2019-11-11 12:49:21 +01:00
Leo Lamprecht
28a2e354d3 Fixed dependencies 2019-11-11 12:48:58 +01:00
Leo Lamprecht
c89e478fc1 Merge branch 'canary' 2019-11-11 12:40:13 +01:00
Luc
7e29a24ea6 [now-static-build] Inject gatsby-plugin-now in Gatsby deployments (#3182)
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
2019-11-11 12:39:18 +01:00
JJ Kasper
5fc9b7d36d [now-next] Add loading of custom routes (#3279)
This adds loading of `redirects` and `rewrites` from the `routes-manifest` in supported Next.js versions
2019-11-11 12:36:00 +01:00
Nathan Rajlich
a211c648ed [now-cli] Purge require cache after packages install in now dev (#3277) 2019-11-11 12:34:49 +01:00
Andy
c24d8de960 [all] Updated builders to version: 3 (#3273)
* [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
2019-11-11 12:33:08 +01:00
Andy
34f6e52335 [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-11 12:31:57 +01:00
Luc
77348ea71e [now-static-build] Cache .cache folder for gatsby deployments (#3260)
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.
2019-11-11 12:27:57 +01:00
Steven
a1273d1c9e [now-dev][now-routing-utils] Fix trailingSlash (#3250)
Fixes `trailingSlash: true` in now dev
2019-11-11 12:22:52 +01:00
Steven
4e6e51af9c [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-11 12:21:48 +01:00
Steven
a6366eaff6 [now-cli] Fix test invalid-builder-routes (#3249) 2019-11-11 12:20:36 +01:00
Steven
1403cf47b2 [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-11 12:20:22 +01:00
Luc
6a5a964b55 [now-static-build] Improve Gatsby default routes (#3212)
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
2019-11-11 12:18:30 +01:00
JJ Kasper
1c40d693c1 [now-next] Add Beta iSSG Support (#3067)
Adds support for new SPRv2 handling in Next.js.

x-ref: #3021
2019-11-11 12:16:36 +01:00
Leo Lamprecht
9cff4ca2c3 Publish
- now@16.1.4-canary.39
2019-11-11 12:15:41 +01:00
JJ Kasper
d1f675bd46 [now-next] Leverage routes-manifest if available for dynamic routes (#3271)
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
2019-11-11 12:10:41 +01:00
Igor Klopov
cce292f639 [now-node] fix reportTSError exiting (#3244)
This fixes abnormal process exit when there is an error like `console.log(Math.round("42"));` and `compilerOptions.noEmitOnError` is `true` in `tsconfig.json`. See 2dee810e74/packages/now-node/src/typescript.ts (L307) and 2dee810e74/packages/now-node/src/typescript.ts (L197)
2019-11-11 12:10:07 +01:00
Andy
adbf2d9c31 [docs] Add memory and maxDuration to runtime development docs (#3261)
Add `memory` and `maxDuration` to runtime development docs
2019-11-11 12:10:03 +01:00
Leo Lamprecht
06e94a1f6f Improve functions check (#3268)
This pull request ensures we're rendering a proper error message if people are trying to use both the `builds` AND the new `functions` property.
2019-11-11 12:09:58 +01:00
Ana Trajkovska
92e396830a [now-cli] Replace Hosts with Deployments API (#3257)
* Replace Hosts with Deployments API

* Trigger tests
2019-11-11 12:09:54 +01:00
Steven
f4df1dfe41 [now-client] Fix file permissions for source files (#3180)
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
2019-11-11 12:09:49 +01:00
Andy
be3bc4273d [now-cli][now-client] Use v11 endpoint for functions (#3266)
* [now-cli][now-client] Use v11 endpoint for functions

* Adjust now-client

* Change version check

* Fix typescript in test
2019-11-11 12:09:45 +01:00
Michel Moreau
b12ed4127e [docs] Update domain-verification error message (#3263)
Closes #3263.
2019-11-11 12:09:36 +01:00
Steven
b6311d5897 [all] Update homepage in package.json (#3265) 2019-11-11 12:09:31 +01:00
Max
cb40985b0e [now-client] Add .nowignore test (#3264)
This adds a test for https://github.com/zeit/now/pull/3186
2019-11-11 12:09:15 +01:00
Steven
7ace8b7103 [now-cli] Fix integration test for maxDuration (#3259)
This test started failing because the error message changed.
2019-11-11 12:08:51 +01:00
Cam Smith
aea17f0c6f [now-cli] Add note for Windows environment variable syntax (#3243) 2019-11-11 12:08:47 +01:00
Leo Lamprecht
5d56eeb871 [docs] Rename "Builders" to "Runtimes" (#3256)
* Renamed "Builders" to "Runtimes"

* Brought html-minifier back

* Adjusted examples
2019-11-11 12:08:43 +01:00
Matthew Sweeney
f3cb60f707 Update Public Directory Link (#3221)
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
2019-11-11 12:08:39 +01:00
Connor Davis
1e57be0710 [now-next] 404 Known Static Files Before Dynamic Routes (#3238)
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
2019-11-11 12:08:34 +01:00
Sophearak Tha
ee8e4bfb20 [now-cli] Adjust now ls according to new project overview (#3229)
Fix: [PRODUCT-493]

[PRODUCT-493]: https://zeit.atlassian.net/browse/PRODUCT-493
2019-11-11 12:08:20 +01:00
Sophearak Tha
7355182586 [now-cli] Remove now upgrade command (#3228)
Fix: [PRODUCT-489]

[PRODUCT-489]: https://zeit.atlassian.net/browse/PRODUCT-489
2019-11-11 12:08:00 +01:00
Andy
e0683d51fa [now-build-utils] Fix custom function runtimes (#3239)
* [now-build-utils] Fix custom runtimes for functions

* [now-cli] Change order
2019-11-11 12:07:28 +01:00
Andy
1f1d5ca8bf [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-11 12:07:22 +01:00
Max
4dfd11ad8e Fix racing spinners (#3232) 2019-11-11 12:07:16 +01:00
Steven
d46e106dba [now-routing-utils] Fix newline in error message (#3234)
The newlines were not being applied properly since the entry array was stringified.

This PR fixes the newlines for route errors.
2019-11-11 12:07:10 +01:00
Steven
cd7eabb6b6 [now-build-utils] Fix zero config trailing slash (#3233)
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.
2019-11-11 12:07:05 +01:00
Leo Lamprecht
bfedde6a4d [now-routing-utils] Improve error message for invalid regexes (#3230)
Currently, this is what you see if you enter invalid regexes with any of the new routing properties:

![image](https://user-images.githubusercontent.com/6170607/67955351-c0fd6480-fbf2-11e9-999c-b36509b5c405.png)

Instead of printing JSON, we want to print a list of all error messages.
2019-11-11 12:06:57 +01:00
Joe Haddad
ece00674b6 [now-next] Use Past Tense (#3226) 2019-11-11 12:06:52 +01:00
Joe Haddad
aa51f9005a [now-next] Reduce Build Noise (#3224)
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!
2019-11-11 12:06:48 +01:00
Steven
836d0dd6ec [now-routing-utils] Fix redirects when cleanUrls and trailingSlash (#3223)
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/`.
2019-11-11 12:06:34 +01:00
Steven
1947813f04 [now-routing-utils] Return null routes when provided null (#3222)
This PR ensures that null routes are returned as null instead of the empty array.
2019-11-11 12:06:29 +01:00
Steven
9a1eeb6fca [now-routing-utils] Enhance superstatic validation (#3219)
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.
2019-11-11 12:05:32 +01:00
Andy
ca8f347e3a [now-build-utils] Validate functions and allow them as config (#3218)
* [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
2019-11-11 12:05:14 +01:00
Steven
51146f5baf [now-routing-utils] Fix html redirects for cleanUrls (#3217)
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.
2019-11-11 12:05:09 +01:00
Andy
f2bd36b4f9 [now-build-utils] Add functions property (#3213)
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
2019-11-11 12:04:54 +01:00
Nathan Rajlich
818018ce42 [now-cli] Remove now dev cleanCacheDir() function (#3214)
Dead code as of #2097.
2019-11-11 12:04:44 +01:00
Nathan Rajlich
89114179da [now-cli] Remove test.only() in now dev tests (#3278) 2019-11-10 21:45:14 -08:00
JJ Kasper
d50c72f2c3 Publish
- now@16.1.4-canary.38
 - @now/next@1.0.0-canary.21
2019-11-09 23:26:49 -08:00
JJ Kasper
ce241e7690 [now-next] Add loading of custom routes (#3279)
This adds loading of `redirects` and `rewrites` from the `routes-manifest` in supported Next.js versions
2019-11-10 07:17:58 +00:00
JJ Kasper
b72cbfb708 [now-next] Leverage routes-manifest if available for dynamic routes (#3271)
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
2019-11-10 02:02:02 +00:00
Nathan Rajlich
ef7b60225d [now-cli] Purge require cache after packages install in now dev (#3277) 2019-11-09 15:52:55 -08:00
Andy Bitz
b3718d9378 Publish
- @now/build-utils@1.0.0-canary.21
 - @now/cgi@0.1.5-canary.3
 - now@16.1.4-canary.37
 - @now/go@0.5.11-canary.8
 - @now/node@1.0.0-canary.14
 - @now/python@0.2.17-canary.10
 - @now/ruby@0.1.5-canary.6
2019-11-08 22:09:26 +01:00
Andy
c8c56bcdb1 [all] Updated builders to version: 3 (#3273)
* [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
2019-11-08 21:58:34 +01:00
Igor Klopov
a84b9273b2 [now-node] fix reportTSError exiting (#3244)
This fixes abnormal process exit when there is an error like `console.log(Math.round("42"));` and `compilerOptions.noEmitOnError` is `true` in `tsconfig.json`. See 2dee810e74/packages/now-node/src/typescript.ts (L307) and 2dee810e74/packages/now-node/src/typescript.ts (L197)
2019-11-08 17:28:38 +00:00
Andy Bitz
3d67ad16ff Publish
- now@16.1.4-canary.36
 - now-client@5.1.1-canary.16
 - @now/node@1.0.0-canary.13
2019-11-08 02:28:20 +01:00
Andy
dd5d4491e2 [docs] Add memory and maxDuration to runtime development docs (#3261)
Add `memory` and `maxDuration` to runtime development docs
2019-11-08 01:23:10 +00:00
Leo Lamprecht
7dd1199ce0 Improve functions check (#3268)
This pull request ensures we're rendering a proper error message if people are trying to use both the `builds` AND the new `functions` property.
2019-11-08 00:11:46 +00:00
Ana Trajkovska
ee7b64ff3a [now-cli] Replace Hosts with Deployments API (#3257)
* Replace Hosts with Deployments API

* Trigger tests
2019-11-08 00:00:38 +01:00
Steven
6efe7d04bc [now-client] Fix file permissions for source files (#3180)
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
2019-11-07 22:38:35 +00:00
Andy Bitz
b7f8f7c366 Publish
- gatsby-plugin-now@1.2.1-canary.4
 - @now/build-utils@1.0.0-canary.20
 - now@16.1.4-canary.35
 - now-client@5.1.1-canary.15
 - @now/go@0.5.11-canary.7
 - @now/next@1.0.0-canary.20
 - @now/node@1.0.0-canary.12
 - @now/python@0.2.17-canary.9
 - @now/ruby@0.1.5-canary.5
 - @now/static-build@0.9.9-canary.19
2019-11-07 23:28:56 +01:00
Andy
9adbb10fca [now-cli][now-client] Use v11 endpoint for functions (#3266)
* [now-cli][now-client] Use v11 endpoint for functions

* Adjust now-client

* Change version check

* Fix typescript in test
2019-11-07 23:28:14 +01:00
Andy
6646b97a65 Revert "[now-client] ignores is missing ignores added from .nowignore (#3186)" (#3267)
This reverts commit 2a39f61f34.
2019-11-07 22:54:31 +01:00
Michel Moreau
939c3a11d7 [docs] Update domain-verification error message (#3263)
Closes #3263.
2019-11-07 13:04:56 -08:00
Steven
363c3ea39f [all] Update homepage in package.json (#3265) 2019-11-07 14:31:07 -05:00
luc
935fca6986 Publish
- now-client@5.1.1-canary.14
 - @now/static-build@0.9.9-canary.18
2019-11-08 02:08:12 +08:00
Luc
7e20c585a1 [now-static-build] Cache .cache folder for gatsby deployments (#3260)
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.
2019-11-07 17:58:28 +00:00
Max
7ecdfbb043 [now-client] Add .nowignore test (#3264)
This adds a test for https://github.com/zeit/now/pull/3186
2019-11-07 17:23:11 +00:00
Gerhard Sletten
2a39f61f34 [now-client] ignores is missing ignores added from .nowignore (#3186)
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?
2019-11-07 16:30:13 +00:00
Steven
6e0182af02 Publish
- now@16.1.4-canary.34
 - @now/routing-utils@1.2.3-canary.11
2019-11-07 10:48:41 -05: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 Bitz
4583880377 Publish
- @now/build-utils@1.0.0-canary.19
 - @now/cgi@0.1.5-canary.2
 - now@16.1.4-canary.33
 - @now/go@0.5.11-canary.6
 - @now/next@1.0.0-canary.19
 - @now/node@1.0.0-canary.11
 - @now/python@0.2.17-canary.8
 - @now/ruby@0.1.5-canary.4
 - @now/static-build@0.9.9-canary.17
2019-11-07 14:32:35 +01: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
de8829ccfe [now-cli] Fix integration test for maxDuration (#3259)
This test started failing because the error message changed.
2019-11-07 12:26:23 +00:00
Cam Smith
ba18a3a0cb [now-cli] Add note for Windows environment variable syntax (#3243) 2019-11-06 17:34:07 -08:00
Leo Lamprecht
0a0f13994f [docs] Rename "Builders" to "Runtimes" (#3256)
* Renamed "Builders" to "Runtimes"

* Brought html-minifier back

* Adjusted examples
2019-11-06 21:20:01 +01:00
Matthew Sweeney
eff29463e7 Update Public Directory Link (#3221)
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
2019-11-05 21:39:32 +00:00
Connor Davis
9c62b74122 Publish
- @now/next@1.0.0-canary.18
2019-11-05 11:26:00 -05:00
Connor Davis
5f19e63409 [now-next] 404 Known Static Files Before Dynamic Routes (#3238)
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
2019-11-05 14:53:57 +00:00
Sophearak Tha
1fd4c3a278 Publish
- now@16.1.4-canary.32
2019-11-05 09:35:53 +07:00
Sophearak Tha
281b385188 [now-cli] Adjust now ls according to new project overview (#3229)
Fix: [PRODUCT-493]

[PRODUCT-493]: https://zeit.atlassian.net/browse/PRODUCT-493
2019-11-05 02:25:01 +00: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
b70ac1ca1c [now-cli] Fix test invalid-builder-routes (#3249) 2019-11-04 17:31:20 -05:00
Sophearak Tha
36fc64d0ed [now-cli] Remove now upgrade command (#3228)
Fix: [PRODUCT-489]

[PRODUCT-489]: https://zeit.atlassian.net/browse/PRODUCT-489
2019-11-04 15:24:49 +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 Bitz
4fa468299f Publish
- @now/build-utils@1.0.0-canary.18
 - now@16.1.4-canary.31
2019-11-01 19:21:53 +01:00
Andy
90eac2cf54 [now-build-utils] Fix custom function runtimes (#3239)
* [now-build-utils] Fix custom runtimes for functions

* [now-cli] Change order
2019-11-01 19:20:56 +01:00
Andy Bitz
63ad08074c Publish
- now@16.1.4-canary.30
 - now-client@5.1.1-canary.13
2019-11-01 17:49:59 +01: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
Max Rovensky
958b067303 Publish
- now@16.1.4-canary.29
2019-11-01 21:32:49 +08:00
Max
6af183c7f1 Fix racing spinners (#3232) 2019-11-01 21:30:25 +08:00
Steven
92d9f2d809 Publish
- @now/build-utils@1.0.0-canary.17
 - @now/routing-utils@1.2.3-canary.10
2019-10-31 13:13:40 -04:00
Steven
4d7aaff8d0 [now-routing-utils] Fix newline in error message (#3234)
The newlines were not being applied properly since the entry array was stringified.

This PR fixes the newlines for route errors.
2019-10-31 16:49:05 +00:00
Steven
68b19c8122 [now-build-utils] Fix zero config trailing slash (#3233)
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.
2019-10-31 16:27:29 +00:00
Steven
5b600fea44 Publish
- @now/routing-utils@1.2.3-canary.9
2019-10-31 11:24:13 -04:00
Leo Lamprecht
2c867295e6 [now-routing-utils] Improve error message for invalid regexes (#3230)
Currently, this is what you see if you enter invalid regexes with any of the new routing properties:

![image](https://user-images.githubusercontent.com/6170607/67955351-c0fd6480-fbf2-11e9-999c-b36509b5c405.png)

Instead of printing JSON, we want to print a list of all error messages.
2019-10-31 15:22:34 +00:00
Joe Haddad
996c0ffffc Publish
- @now/next@1.0.0-canary.17
2019-10-30 17:47:02 -04:00
Joe Haddad
2344357113 [now-next] Use Past Tense (#3226) 2019-10-30 21:20:51 +00:00
Joe Haddad
e919c591fe Publish
- @now/next@1.0.0-canary.16
2019-10-30 16:45:47 -04:00
Joe Haddad
88516137de [now-next] Reduce Build Noise (#3224)
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!
2019-10-30 20:43:48 +00:00
Steven
f515138074 Publish
- @now/routing-utils@1.2.3-canary.8
2019-10-30 14:29:11 -04:00
Steven
6d04016054 [now-routing-utils] Fix redirects when cleanUrls and trailingSlash (#3223)
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/`.
2019-10-30 18:27:07 +00:00
Steven
eb968d813c Publish
- @now/routing-utils@1.2.3-canary.7
2019-10-30 10:54:16 -04:00
Steven
37881e0830 [now-routing-utils] Return null routes when provided null (#3222)
This PR ensures that null routes are returned as null instead of the empty array.
2019-10-30 14:51:50 +00:00
luc
e3dd13ba9e Publish
- gatsby-plugin-now@1.2.1-canary.3
 - @now/routing-utils@1.2.3-canary.6
 - @now/static-build@0.9.9-canary.16
2019-10-30 12:14:09 +08:00
Luc
9054b7f2f5 [now-static-build] Improve Gatsby default routes (#3212)
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
2019-10-30 04:12:06 +00:00
Steven
17cd17ac96 [now-routing-utils] Enhance superstatic validation (#3219)
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.
2019-10-29 23:03:39 +00:00
Andy Bitz
d7c2d071c1 Publish
- @now/build-utils@1.0.0-canary.16
2019-10-29 21:07:06 +01:00
Andy
483a117a6a [now-build-utils] Validate functions and allow them as config (#3218)
* [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
2019-10-29 21:03:04 +01:00
Steven
3c630343d0 Publish
- @now/routing-utils@1.2.3-canary.5
2019-10-29 10:38:40 -04:00
Steven
fe61b31197 [now-routing-utils] Fix html redirects for cleanUrls (#3217)
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.
2019-10-29 14:23:23 +00:00
Joe Haddad
af14d0af4b Publish
- @now/build-utils@1.0.0-canary.15
 - now@16.1.4-canary.28
 - @now/next@1.0.0-canary.15
2019-10-28 21:28:24 -04:00
JJ Kasper
e04e6bb188 [now-next] Add Beta iSSG Support (#3067)
Adds support for new SPRv2 handling in Next.js.

x-ref: #3021
2019-10-29 01:26:42 +00:00
Andy
e36f3d355e [now-build-utils] Add functions property (#3213)
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
2019-10-28 23:47:45 +00:00
Nathan Rajlich
24891e3ce8 [now-cli] Remove now dev cleanCacheDir() function (#3214)
Dead code as of #2097.
2019-10-28 16:26:13 -07:00
Steven
147c703cce Publish
- now@16.4.4
 - @now/routing-utils@1.3.2
2019-10-28 10:47:33 -04:00
Steven
3aa92c3f27 [now-routing-utils] Fix validation for routes/cleanUrls (#3211) 2019-10-28 10:41:11 -04:00
Steven
0d29e37dcb Publish
- now@16.1.4-canary.27
 - @now/routing-utils@1.2.3-canary.4
2019-10-28 10:40:03 -04:00
Steven
089b29c2ca [now-routing-utils] Fix validation for routes/cleanUrls (#3211) 2019-10-28 10:38:58 -04:00
Leo Lamprecht
af513c249c Improve test stability (#3208)
This pull request aims to make our test suite more stable.
2019-10-26 17:58:21 +02:00
Leo Lamprecht
d567b5f2fc Improve test stability (#3208)
This pull request aims to make our test suite more stable.
2019-10-26 15:53:38 +00:00
Max Rovensky
c336353020 Publish
- now@16.4.3
2019-10-26 06:03:24 +08:00
Max
523b9de1e0 Separate out queued into it's own spinner (#3206) 2019-10-26 06:02:57 +08:00
Max Rovensky
6151f11657 Publish
- now@16.1.4-canary.26
2019-10-26 05:50:49 +08:00
Max
c0d3847aab Separate out queued into it's own spinner (#3206) 2019-10-26 05:50:15 +08:00
Max Rovensky
93d295ac5c Publish
- now@16.4.2
2019-10-26 04:47:41 +08:00
Max
8430de13c2 Add Queued spinner (#3205)
* Add `Queued` indication before builds begin

* Fix second spinner condition
2019-10-26 04:47:02 +08:00
luc
c78af57d76 Publish
- gatsby-plugin-now@1.2.1-canary.2
 - now@16.1.4-canary.25
 - @now/next@1.0.0-canary.14
 - @now/node@1.0.0-canary.10
 - @now/static-build@0.9.9-canary.15
2019-10-25 22:01:19 +02:00
Max
172605d77d Add Queued spinner (#3205)
* Add `Queued` indication before builds begin

* Fix second spinner condition
2019-10-25 21:59:51 +02:00
Michael Zetterberg fd. Lopez
d7dc5a0c45 [gatsby-plugin-now] Fix logic error for redirect check (#3203)
Currently `__now_routes_g4t5bY.json` always gets created, regardless of existing redirects in Gatsby.

This PR fixes that.

PS. According to https://github.com/zeit/now/blob/canary/CONTRIBUTING.md I should run `yarn lint` and `yarn test` but both fail on a clean clone. Not sure how to handle that.

gist for errors:
- [yarn lint](https://gist.github.com/michaellopez/ae187969b64da017de295967cb0d7539)
- [yarn test](https://gist.github.com/michaellopez/024c484bedca8018e933d61b3a2c13ee)
2019-10-25 19:42:20 +00:00
Steven
75edd0bab5 [now-node][now-next] Bump node-file-trace to 0.4.0 (#3204)
Bump `@zeit/node-file-trace` to version [0.4.0](https://github.com/zeit/node-file-trace/releases/tag/0.4.0).
2019-10-25 18:56:31 +00:00
Luc
ac60b3660c [now-static-build] Inject gatsby-plugin-now in Gatsby deployments (#3182)
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
2019-10-25 12:54:14 +00:00
Sophearak Tha
372a674625 Publish
- @now/build-utils@0.11.1
 - now@16.4.1
 - now-client@5.2.2
 - @now/next@1.0.5
 - @now/python@0.3.3
2019-10-25 19:34:00 +07:00
Sophearak Tha
fafeadb7ba update now-cli readme (#3202) 2019-10-25 14:14:24 +02:00
Max
966b1e763f Add apiUrl debug log to now-client (#3201) 2019-10-25 14:14:19 +02:00
Sophearak Tha
6e22c07ecc Publish
- now@16.1.4-canary.24
 - now-client@5.1.1-canary.12
2019-10-25 19:04:10 +07:00
Sophearak Tha
857e4ef874 update now-cli readme (#3202) 2019-10-25 14:02:41 +02:00
Max
aa03f69bdc Add apiUrl debug log to now-client (#3201) 2019-10-25 13:38:58 +02:00
Sophearak Tha
8fc77139e0 Publish
- now@16.1.4-canary.23
2019-10-25 18:04:04 +07:00
Luc
bb60e1a5fe Improve styling of 1.0 message (#3200) 2019-10-25 12:47:19 +02:00
Luc
87802cb002 Improve styling of 1.0 message (#3200) 2019-10-25 12:38:02 +02:00
Nathan Rajlich
cac9f807cc [now-cli] Gracefully exit when the cwd does not exist (#3194)
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.
2019-10-25 11:49:45 +02:00
Steven
a0b1254820 Fix circle ci xcode version (#3197) 2019-10-25 11:48:27 +02:00
Nathan Rajlich
0faff4132b [now-build-utils] Add more complete PackageJson typings (#3198)
* [now-build-utils] Add more complete `PackageJson` typings

Planning on using this in `now-cli`.

* Make "name" optional

* Use a namespace
2019-10-25 11:47:36 +02:00
Joe Haddad
1793a1287d [now-next] Cache All Next.js Directories (#3190)
Next.js now uses the `css` and `media` folders for its build-in CSS support. These files should be cached forever.
2019-10-25 11:45:37 +02:00
Max
5b572239c1 [now-client] Yield an error event if path provided is not absolute (#3173)
This adds an `error` event when provided path to `now-client` isn't absolute
2019-10-25 11:43:34 +02:00
Steven
f6a66d937e [now-client] Change npm publish to use files key (#3181)
- remove `.npmignore`
- use [`files`](https://docs.npmjs.com/files/package.json#files) key in `package.json`
- update metadata in `package.json`
- fix test harness to generate a token for each test deployment

This PR will prevent publishing [tests](https://cdn.jsdelivr.net/npm/now-client@5.2.0/tests/) to npm and any other unused files.
2019-10-25 11:43:29 +02:00
Sophearak Tha
2cf9a2f489 [now-client] [now-cli] Update version of deployment API (#3188)
* 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
2019-10-25 11:42:18 +02:00
Nathan Rajlich
454f4dcc61 [now-cli] Don't throw if builder child process can not be killed (#3192)
The Sentry error reports that the process has already been killed, so no need to throw in this case.

Fixes #3191.
2019-10-25 11:42:09 +02:00
Yevhen Amelin
6e1065fde2 [now-python] Set PIP_USER environment variable (#3111)
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
2019-10-25 11:41:19 +02:00
Max
80ce06b20c [now-client] Add apiUrl support (#3168)
This PR adds support for `apiUrl` option to `now-client` as well as a test for it
2019-10-25 11:41:01 +02:00
Nathan Rajlich
99f3ab8b64 [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 11:40:23 +02:00
Luc
ca4f6d2491 [now-cli] Disable --prod and --target for Now 1.0 deployments (#3189)
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.
2019-10-25 11:39:53 +02:00
Sophearak Tha
dcd57e148f Publish
- @now/build-utils@1.0.0-canary.14
 - now@16.1.4-canary.22
 - now-client@5.1.1-canary.11
2019-10-25 11:32:43 +07:00
Sophearak Tha
18fa193a17 [now-client] [now-cli] Update version of deployment API (#3188)
* 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
2019-10-25 11:28:36 +07: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
Nathan Rajlich
c7caa7b905 [now-build-utils] Add more complete PackageJson typings (#3198)
* [now-build-utils] Add more complete `PackageJson` typings

Planning on using this in `now-cli`.

* Make "name" optional

* Use a namespace
2019-10-24 16:02:16 -07:00
Steven
2ceb2a78aa Publish
- @now/routing-utils@1.3.1
2019-10-24 16:59:56 -04:00
Steven
d97da21afc [now-routing-utils] Change cleanUrls to redirect only (#3196)
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.
2019-10-24 16:58:38 -04:00
Steven
7b52b26ff0 Publish
- now@16.1.4-canary.21
 - now-client@5.1.1-canary.10
 - @now/next@1.0.0-canary.13
 - @now/python@0.2.17-canary.7
 - @now/routing-utils@1.2.3-canary.3
2019-10-24 16:09:06 -04:00
Steven
3c958a4429 [now-routing-utils] Change cleanUrls to redirect only (#3196)
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.
2019-10-24 20:07:16 +00:00
Steven
d8660b1db3 Fix circle ci xcode version (#3197) 2019-10-24 15:34:38 -04:00
Nathan Rajlich
0996640798 [now-cli] Gracefully exit when the cwd does not exist (#3194)
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.
2019-10-24 13:15:27 +00:00
Nathan Rajlich
079f4ba6bf [now-cli] Don't throw if builder child process can not be killed (#3192)
The Sentry error reports that the process has already been killed, so no need to throw in this case.

Fixes #3191.
2019-10-23 21:23:03 +00:00
Luc
bdf78efbfb [now-cli] Disable --prod and --target for Now 1.0 deployments (#3189)
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.
2019-10-23 20:26:09 +00:00
Joe Haddad
07ba180ede [now-next] Cache All Next.js Directories (#3190)
Next.js now uses the `css` and `media` folders for its build-in CSS support. These files should be cached forever.
2019-10-23 17:34:13 +00:00
Max
94a2b017d4 [now-client] Add apiUrl support (#3168)
This PR adds support for `apiUrl` option to `now-client` as well as a test for it
2019-10-23 09:32:47 +00:00
Yevhen Amelin
37c06c89d0 [now-python] Set PIP_USER environment variable (#3111)
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
2019-10-22 22:26:54 +00:00
Max
42ffc2dafb [now-client] Yield an error event if path provided is not absolute (#3173)
This adds an `error` event when provided path to `now-client` isn't absolute
2019-10-22 20:19:11 +00:00
Steven
cf65fabe27 [now-client] Change npm publish to use files key (#3181)
- remove `.npmignore`
- use [`files`](https://docs.npmjs.com/files/package.json#files) key in `package.json`
- update metadata in `package.json`
- fix test harness to generate a token for each test deployment

This PR will prevent publishing [tests](https://cdn.jsdelivr.net/npm/now-client@5.2.0/tests/) to npm and any other unused files.
2019-10-22 15:30:57 +00:00
Nathan Rajlich
03b5a0c0bf Publish
- @now/build-utils@0.11.0
 - now@16.4.0
 - now-client@5.2.1
 - @now/node@1.0.2
 - @now/python@0.3.2
 - @now/routing-utils@1.3.0
 - @now/static-build@0.11.0
2019-10-21 16:19:11 -07:00
Steven
f76abe3372 [now-build-utils] Add contentType prop to File (#3178)
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
2019-10-21 16:11:16 -07:00
Steven
cdd43b74ae [now-node] Fix helpers when POST json has empty body (#3177)
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
2019-10-21 16:11:09 -07:00
Nathan Rajlich
fa633d0e02 [now-cli] Temporarily force TooTallNate/signal-exit#update/sighub-to-sigint-on-windows for "signal-exit" module (#3171)
Fixes https://github.com/zeit/now/issues/2564.

Upstream fix PR: https://github.com/tapjs/signal-exit/pull/55.
2019-10-21 16:11:00 -07:00
Nathan Rajlich
9b46e60c09 [now-cli] Remove serveProjectAsStatic() (#3170)
Because we treat purely static projects as v2 projects with a `@now/static` builder specified, this is now dead code.
2019-10-21 16:10:54 -07:00
Steven
58eef7f394 [now-build-utils] Fix static file serving from now dev (#3167)
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
2019-10-21 16:10:39 -07:00
Nathan Rajlich
e97e0fbb64 [now-cli] Spawn builder child processes with stdio: 'inherit' in now dev (#3113)
Inherit the `now dev` process stdio streams in builder child processes, so that ANSI color codes may be used when stdout is a TTY.

**Examples:**

_Next.js_

<img width="523" alt="Screen Shot 2019-10-01 at 3 42 33 PM" src="https://user-images.githubusercontent.com/71256/66006087-4fe75780-e462-11e9-927f-1e81466c4108.png">

_Gatsby_ (depends on #3112)

<img width="507" alt="Screen Shot 2019-10-01 at 3 40 02 PM" src="https://user-images.githubusercontent.com/71256/66006094-5d9cdd00-e462-11e9-81da-e60bd9516778.png">

Fixes #3135.
2019-10-21 16:10:32 -07:00
Steven
b82876fd82 [now-routing-utils] Add superstatic transformations (#3138)
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
2019-10-21 16:10:08 -07:00
Steven
02ad32ec22 [tests] Fix tests so they wait for v1 deployments (#3162)
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().
2019-10-21 16:09:16 -07:00
Allen Hai
433fe35c93 [now-static-build] Add stencil to list of optimized static frameworks (#3158)
This PR enables a zero-config deployment experience for `stencil` projects. The default build command outputs to a `www` directory.
2019-10-21 16:09:06 -07:00
Jacob Mischka
90c59d6ae2 [now-python] Fix UnicodeDecodeError for binary response from handler (#3148)
Fixes #3147
2019-10-21 16:08:51 -07:00
Joe Haddad
33672c3d78 [now-build-utils] Allow a null fallback in Prerender (#3144)
This allows a `null` `fallback` to be provided to a `Prerender`. The use case is a lazily prerendered route (often meaning dynamically rendered).
2019-10-21 16:08:42 -07:00
Nathan Rajlich
59ae7a989a [now-cli] Set the builder's debug env var based on DevServer.debug (#3139)
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).
2019-10-21 16:08:35 -07:00
Nathan Rajlich
5767e9e8c2 [now-static-build] Exit dev server child processes upon SIGINT/SIGTERM (#3136)
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".
2019-10-21 16:08:26 -07:00
Steven
e62b9e8ed9 [now-build-utils] Fix typo occurres => occurs (#3132)
Fixes #2931
2019-10-21 16:08:10 -07:00
Sophearak Tha
59597ccd17 [now-cli] Update readme (#3128) 2019-10-21 16:07:57 -07:00
Andy
7be49c66ef Revert "[now-cli] Remove dev: "now dev" script detection logic in now dev (#3088)" (#3127)
This reverts commit 85170d7231.
2019-10-21 16:07:50 -07:00
Sophearak Tha
1380e25ef3 [now-client] Fix ENOENT regression in now-client (#3125)
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
2019-10-21 16:07:45 -07:00
Nathan Rajlich
e825ce746f [now-cli] Remove dev: "now dev" script detection logic in now dev (#3088)
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).
2019-10-21 16:07:38 -07: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
Steven
84d8f73a2d Publish
- @now/build-utils@1.0.0-canary.13
2019-10-21 13:35:03 -04:00
Steven
b24cfb605b [now-build-utils] Add contentType prop to File (#3178)
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
2019-10-21 17:27:46 +00:00
Steven
57f66fe62f Publish
- now@16.1.4-canary.20
 - @now/node@1.0.0-canary.9
2019-10-21 11:57:06 -04:00
Steven
d2cd4a3c5a [now-node] Fix helpers when POST json has empty body (#3177)
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
2019-10-21 15:45:38 +00:00
Joe Haddad
4e58951808 Publish
- @now/next@1.0.4
2019-10-20 14:56:29 -04:00
Joe Haddad
fbd805aad7 [now-next] Update console.time labels for clarity (#3157) 2019-10-20 14:37:35 -04:00
JJ Kasper
2a2705c6e3 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-20 14:37:27 -04:00
JJ Kasper
986c957183 [now-next] Add support for src dir in now-dev (#3140)
Fixes: #3133
Fixes: https://github.com/zeit/next.js/issues/9007
2019-10-20 14:37:13 -04:00
Nathan Rajlich
c5d063e876 [now-next] Exit dev server child processes upon SIGINT/SIGTERM (#3137)
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".
2019-10-20 14:37:07 -04:00
Nathan Rajlich
110e1445fa [now-cli] Temporarily force TooTallNate/signal-exit#update/sighub-to-sigint-on-windows for "signal-exit" module (#3171)
Fixes https://github.com/zeit/now/issues/2564.

Upstream fix PR: https://github.com/tapjs/signal-exit/pull/55.
2019-10-18 15:53:00 +00:00
Nathan Rajlich
f9355cbc77 [now-cli] Remove serveProjectAsStatic() (#3170)
Because we treat purely static projects as v2 projects with a `@now/static` builder specified, this is now dead code.
2019-10-18 13:25:01 +00:00
Steven
0a9bbd902f Publish
- @now/build-utils@1.0.0-canary.12
2019-10-17 14:41:00 -04:00
Steven
c8c960f785 [now-build-utils] Fix static file serving from now dev (#3167)
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
2019-10-17 18:38:25 +00:00
Steven
fb0f4beca6 Publish
- now@16.1.4-canary.19
 - @now/next@1.0.0-canary.12
 - @now/routing-utils@1.2.3-canary.2
2019-10-17 08:32:17 -04:00
Nathan Rajlich
21398d7214 [now-cli] Spawn builder child processes with stdio: 'inherit' in now dev (#3113)
Inherit the `now dev` process stdio streams in builder child processes, so that ANSI color codes may be used when stdout is a TTY.

**Examples:**

_Next.js_

<img width="523" alt="Screen Shot 2019-10-01 at 3 42 33 PM" src="https://user-images.githubusercontent.com/71256/66006087-4fe75780-e462-11e9-927f-1e81466c4108.png">

_Gatsby_ (depends on #3112)

<img width="507" alt="Screen Shot 2019-10-01 at 3 40 02 PM" src="https://user-images.githubusercontent.com/71256/66006094-5d9cdd00-e462-11e9-81da-e60bd9516778.png">

Fixes #3135.
2019-10-17 00:18:14 +00:00
Steven
a5a56836a8 [now-routing-utils] Add superstatic transformations (#3138)
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
2019-10-16 22:34:52 +00:00
Steven
e7fd1e3c3f [tests] Fix tests so they wait for v1 deployments (#3162)
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().
2019-10-16 21:47:31 +00:00
Joe Haddad
64b24bde56 [now-next] Update console.time labels for clarity (#3157) 2019-10-15 12:39:40 +00:00
Allen Hai
613958d6a5 Publish
- now@16.1.4-canary.18
 - @now/python@0.2.17-canary.6
 - @now/static-build@0.9.9-canary.14
2019-10-14 19:08:32 -05:00
Allen Hai
21e4ebc7a9 [now-static-build] Add stencil to list of optimized static frameworks (#3158)
This PR enables a zero-config deployment experience for `stencil` projects. The default build command outputs to a `www` directory.
2019-10-14 23:49:59 +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
Jacob Mischka
9ecb011732 [now-python] Fix UnicodeDecodeError for binary response from handler (#3148)
Fixes #3147
2019-10-10 16:51:37 +00:00
JJ Kasper
de48e28fa1 Publish
- @now/build-utils@1.0.0-canary.11
 - now@16.1.4-canary.17
 - @now/next@1.0.0-canary.11
2019-10-10 10:43:51 -05:00
JJ Kasper
3aecb0905a [now-next] Add support for src dir in now-dev (#3140)
Fixes: #3133
Fixes: https://github.com/zeit/next.js/issues/9007
2019-10-10 14:40:38 +00:00
Joe Haddad
c1b2da1d57 [now-build-utils] Allow a null fallback in Prerender (#3144)
This allows a `null` `fallback` to be provided to a `Prerender`. The use case is a lazily prerendered route (often meaning dynamically rendered).
2019-10-10 05:07:26 +00:00
Nathan Rajlich
c4bee64abd [now-cli] Set the builder's debug env var based on DevServer.debug (#3139)
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).
2019-10-09 01:19:10 +00:00
Nathan Rajlich
dbf9c5c46b Publish
- @now/build-utils@1.0.0-canary.10
 - @now/next@1.0.0-canary.10
 - @now/static-build@0.9.9-canary.13
2019-10-08 16:04:24 -07:00
Nathan Rajlich
630ec06d48 [now-static-build] Exit dev server child processes upon SIGINT/SIGTERM (#3136)
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".
2019-10-08 22:57:29 +00:00
Nathan Rajlich
d38e464bfe [now-next] Exit dev server child processes upon SIGINT/SIGTERM (#3137)
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".
2019-10-08 22:25:47 +00:00
Steven
49bd2439a7 [now-build-utils] Fix typo occurres => occurs (#3132)
Fixes #2931
2019-10-07 20:44:44 +00:00
Sophearak Tha
e97314a3c7 Publish
- now@16.1.4-canary.16
2019-10-04 20:25:15 +07:00
Sophearak Tha
acb46cef14 [now-cli] Update readme (#3128) 2019-10-04 20:23:45 +07:00
Sophearak Tha
06b9ff233e Publish
- now-client@5.1.1-canary.9
2019-10-04 19:59:22 +07:00
Andy
a189e72fbe Revert "[now-cli] Remove dev: "now dev" script detection logic in now dev (#3088)" (#3127)
This reverts commit 85170d7231.
2019-10-04 14:54:27 +02:00
Sophearak Tha
75e6b15199 [now-client] Fix ENOENT regression in now-client (#3125)
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
2019-10-04 10:25:26 +00:00
Nathan Rajlich
85170d7231 [now-cli] Remove dev: "now dev" script detection logic in now dev (#3088)
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).
2019-10-03 21:29:54 +00:00
Steven
500c36f5d4 Publish
- now@16.3.1
 - now-client@5.2.0
 - @now/next@1.0.3
 - @now/python@0.3.1
 - @now/static-build@0.10.1
2019-10-03 13:54:14 -04:00
Steven
eeffb55021 Publish
- now@16.1.4-canary.15
 - now-client@5.1.1-canary.8
2019-10-03 13:44:39 -04:00
Steven
69dbbeac44 [now-cli][now-client] Fix v1 files when defining a directory (#3123)
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
2019-10-03 13:44:21 -04:00
Steven
1fe8317f1e [now-cli][now-client] Fix v1 files when defining a directory (#3123)
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
2019-10-03 17:41:37 +00:00
Sophearak Tha
69486c3adb [now-client] [now-cli] Handle notice type (#3122)
This PR handle `notice` type from API respond.
2019-10-03 12:14:02 -04:00
Sophearak Tha
6398ef194c [now-client] [now-cli] Handle notice type (#3122)
This PR handle `notice` type from API respond.
2019-10-03 14:58:00 +00:00
Steven
e6692bb79b [now-cli][now-client] Fix --local-config flag and files key (#3117)
This PR is a followup to #3110 that fixes the first deployment when using the `--local-config` flag and also fixes v1 deployments using the [`files`](https://zeit.co/docs/v1/features/configuration/#files-(array)) key.

The tests have been adjusted so we don't regress in both cases.

Fixes #3099 
Fixes #3105
Fixes #3107
Fixes #3109

[PRODUCT-350] #close

[PRODUCT-350]: https://zeit.atlassian.net/browse/PRODUCT-350
2019-10-03 09:07:01 -04:00
Chris
94fba1d7af [now-python] Encode body as utf-8 before making a request (#3093)
Fixes #3091
2019-10-03 09:06:54 -04:00
Sophearak Tha
223d8f4774 [now-cli] Rename lambda to serverless function (#3100)
This PR fix: [PRODUCT-66] #close

[PRODUCT-66]: https://zeit.atlassian.net/browse/PRODUCT-66
2019-10-03 09:06:49 -04:00
Nathan Rajlich
42e7a7e4e3 [now-static-build] Use stdio: 'inherit' for "dev" script child process (#3112)
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.
2019-10-03 09:06:44 -04:00
Steven
6716fdd49b [now-cli][now-client] Add parameter nowConfig for custom now.json (#3110)
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 #3099 
Fixes #3105
Fixes #3107
Fixes #3109

[PRODUCT-350] #close


[PRODUCT-350]: https://zeit.atlassian.net/browse/PRODUCT-350
2019-10-03 09:06:38 -04:00
Steven
3b69092fd8 Revert "[tests] Add test all script" since it runs on commit (#3108)
Reverts #3106 from @MAPESO 

The tests seem to be running on each commit which is going to slow down development.
2019-10-03 09:06:32 -04:00
Luis Alvarez D
aa8eaedbc8 [now-next] Upload build-time generated static artifacts (#3096)
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?
2019-10-03 09:06:25 -04:00
Mark
f519ed373f [tests] Add test all script (#3106)
This PR focuses on adding the `test` script to the `package.json` : )

## Main problem 

Previously there was no `test` script that includes all the tests

<img width="924" alt="Screen Shot 2019-10-01 at 8 13 13 AM" src="https://user-images.githubusercontent.com/16585386/65968681-26f6a080-e429-11e9-9f29-c6fd343fdb12.png">
2019-10-03 09:06:20 -04:00
Ana Trajkovska
851dff4b03 [now-cli] Integrate Projects API v2 (#3063)
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`.
2019-10-03 09:06:14 -04:00
Steven
e4d691eda1 Publish
- now@16.1.4-canary.14
 - now-client@5.1.1-canary.7
 - @now/next@1.0.0-canary.9
 - @now/python@0.2.17-canary.5
 - @now/static-build@0.9.9-canary.12
2019-10-03 08:24:31 -04:00
Steven
d9bb6c8a54 [now-cli][now-client] Fix --local-config flag and files key (#3117)
This PR is a followup to #3110 that fixes the first deployment when using the `--local-config` flag and also fixes v1 deployments using the [`files`](https://zeit.co/docs/v1/features/configuration/#files-(array)) key.

The tests have been adjusted so we don't regress in both cases.

Fixes #3099 
Fixes #3105
Fixes #3107
Fixes #3109

[PRODUCT-350] #close

[PRODUCT-350]: https://zeit.atlassian.net/browse/PRODUCT-350
2019-10-03 02:17:11 +00:00
Chris
c3020e3071 [now-python] Encode body as utf-8 before making a request (#3093)
Fixes #3091
2019-10-02 18:04:16 -04:00
Sophearak Tha
e3f31e3e52 [now-cli] Rename lambda to serverless function (#3100)
This PR fix: [PRODUCT-66] #close

[PRODUCT-66]: https://zeit.atlassian.net/browse/PRODUCT-66
2019-10-02 10:35:01 +00:00
Nathan Rajlich
8c40e1be0f [now-static-build] Use stdio: 'inherit' for "dev" script child process (#3112)
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.
2019-10-02 09:42:01 +00:00
Steven
b278c7148b Publish
- now@16.1.4-canary.13
 - now-client@5.1.1-canary.6
 - @now/next@1.0.0-canary.8
2019-10-01 21:36:12 -04:00
Steven
2791338e04 [now-cli][now-client] Add parameter nowConfig for custom now.json (#3110)
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 #3099 
Fixes #3105
Fixes #3107
Fixes #3109

[PRODUCT-350] #close


[PRODUCT-350]: https://zeit.atlassian.net/browse/PRODUCT-350
2019-10-02 01:28:58 +00:00
Steven
0af87dc2be Revert "[tests] Add test all script" since it runs on commit (#3108)
Reverts #3106 from @MAPESO 

The tests seem to be running on each commit which is going to slow down development.
2019-10-01 20:54:04 +00:00
Luis Alvarez D
32134dd1f5 [now-next] Upload build-time generated static artifacts (#3096)
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?
2019-10-01 18:57:41 +00:00
Mark
bdd4441d5c [tests] Add test all script (#3106)
This PR focuses on adding the `test` script to the `package.json` : )

## Main problem 

Previously there was no `test` script that includes all the tests

<img width="924" alt="Screen Shot 2019-10-01 at 8 13 13 AM" src="https://user-images.githubusercontent.com/16585386/65968681-26f6a080-e429-11e9-9f29-c6fd343fdb12.png">
2019-10-01 16:44:02 +00:00
Ana Trajkovska
99bc1ae7b6 [now-cli] Integrate Projects API v2 (#3063)
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`.
2019-09-30 23:16:40 +00:00
Steven
c5ebaa11ea Publish
- gatsby-plugin-now@1.2.2
 - @now/build-utils@0.10.1
 - now@16.3.0
 - now-client@5.1.4
 - @now/go@0.6.0
 - @now/next@1.0.2
 - @now/node@1.0.1
 - @now/python@0.3.0
 - @now/ruby@0.1.7
 - @now/static-build@0.10.0
2019-09-30 09:41:51 -04:00
Andy
934fbc8992 [now-cli] Fix deployment version output (#3097)
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.
2019-09-30 09:38:16 -04:00
Max
72cb5515fd [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-30 09:38:06 -04:00
Steven
c7f0770d53 [now-static-build] Make curl silent (#3090)
We added a message in #3068 so this PR makes curl silent unless it errors.

Also fix typo in Gutenberg 😉 

PRODUCT-7 #close
2019-09-30 09:38:00 -04:00
Max
7ea49e8ada [now-cli] Add not_domain_owner error handling (#3045)
This adds missing error handler for `not_domain_owner` error (fixes #3042)
2019-09-30 09:37:55 -04:00
Nathan Rajlich
cae6ce96b3 [now-client] Export TypeScript types (#3087)
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;
                                         ~~~~~~~~~~~~~~~~~~~~~~~~
````
2019-09-30 09:37:49 -04:00
Sophearak Tha
3699dfd756 [now-next] Invoke build script (#3073)
This PR make `@now/next` invoke `build` script if user defined.

PRODUCT-106 #close
2019-09-30 09:37:41 -04:00
Leo Lamprecht
6dca96d877 [now-build-utils] Make grouping prerenders optional (#3082)
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.
2019-09-30 09:37:36 -04:00
Leo Lamprecht
88c14b27a2 [now-build-utils] Allow prerender groups to be defined with an integer (#3081)
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.
2019-09-30 09:37:31 -04:00
Max
0d2a9539f6 [now-cli] Add logging to execa calls in tests (#3077)
This implements #3075 for all integration tests
2019-09-30 09:37:25 -04:00
Max
bae160bd7c [now-client] Retry on network error (#3072)
This PR improves handling of occasional network errors in `now-client` which should improve benchmarking introduced in #3062
2019-09-30 09:37:19 -04:00
Max
92852ecff2 [now-cli] Move hexo test to testFixtureStdio (#3076)
This should fix the `now dev` tests that periodically hang
2019-09-30 09:37:12 -04:00
Max
ac0c841cb8 [now-client] Add debug logs (#2997)
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
2019-09-30 09:37:05 -04:00
Sophearak Tha
53e4b71f89 [now-cli] Render prompt when deploying home directory (#3057)
Fixes #3069 

PRODUCT-160 #close
2019-09-30 09:36:53 -04:00
Steven
017a2692ca [now-static-build] Add test for BUNDLE_WITHOUT env var (#3070)
This adds a test which confirms that `BUNDLE_WITHOUT="test:development"` works properly.

This env var is equivalent to `bundle install --without test development`.

There's no code change here because groups are defined by the user, therefore they must define which ones to ignore (if any).

- Groups Guide: https://bundler.io/v2.0/guides/groups.html
- BUNDLER_WITHOUT: https://bundler.io/v2.0/bundle_config.html#LIST-OF-AVAILABLE-KEYS
- Example Gemfile: https://github.com/thoughtbot/administrate/blob/master/Gemfile

PRODUCT-133 #close
2019-09-30 09:36:45 -04:00
Steven
311f89eecb Use PR description for merge commit body (#3071) 2019-09-30 09:36:39 -04:00
Steven
40d2bc4743 [now-static-build] Print version of static generator during build (#3068)
* [now-static-build] Print version of static generator

* Use curl progress bar
2019-09-30 09:36:33 -04:00
Steven
37160cbc8b [tests] Add benchmark script to randomly generate projects files (#3062) 2019-09-30 09:36:28 -04:00
Steven
3807a2b018 [now-node] Fix sharp test using lock file (#3064) 2019-09-30 09:36:21 -04:00
Steven
b6697dd432 [now-static-build] Add Eleventy to optimized framework list (#3060)
* [now-static-build] Add eleventy to frameworks

* Add test using eleventy-base-blog

* Fix tests with dot files

* Add now.json to 27-eleventy fixture
2019-09-30 09:36:16 -04:00
Sophearak Tha
6c33496e8a [now-cli] Add NOW_BUILDER_DEBUG to build env if --debug (#3041)
* Add `NOW_BUILDER_DEBUG` to build env if `--debug`

* Add `--debug` build env check

* Add `build-env-debug` to prepare
2019-09-30 09:36:08 -04:00
Sophearak Tha
89f32625ed [now-cli] Fix 02-angular-node test fail (#3058)
* Improve `02-angular-node` test

* Add `yarn.lock` with pin version
2019-09-30 09:35:53 -04:00
Steven
8253e76ec0 [now-python] Fix headers with multiple values (#3053)
* [now-python] Add format_headers()

* Add tests

* Fix filenames

* Fix test probes
2019-09-30 09:35:44 -04:00
Andy
e0b3e9606a [now-cli][now-static-build] Ignore output directory from now dev (#3024)
* [now-cli][now-static-build] Ignore output directory from `now dev`

* Add test

* Logging

* Fix test

* Fix test

* Adjust test

* Log failed test

* Log stderr

* Change now.json

* Change Ready check

* Dynamically create now.json

* Log error

* Log stderr on error

* Create now.json first

* Handle JSON error

* Don't use JSON output

* Join path

* Add quotes

* Use .values
2019-09-30 09:35:38 -04:00
Sophearak Tha
dc75a303f7 [now-build-utils] Remove NOW_BUILDER_ANNOTATE (#3027) 2019-09-30 09:35:33 -04:00
Steven
c1eb8ec78c [now-static-build][now-build-utils] Add python static generators (#3048)
* [now-static-build] Run pip install requirements.txt

* Add test for pelican

* Add test for mkdocs
2019-09-30 09:35:26 -04:00
Sophearak Tha
12435f25fd [builders] Consistently capitalize first letter of logs (#3039)
* Consistency capitalize logs line `@now/next`

* Consistency capitalize logs line `@now/node`

* Consistency capitalize logs line `@now/go`

* Consistency capitalize logs line `@now/python`

* Always show `Installing dependencies...`

* Consistency capitalize logs line `run-user-scripts`

* Capitalize `Running`
2019-09-30 09:35:21 -04:00
Steven
d4dc5222cf [now-static-build] Add prepareCache() function (#3047) 2019-09-30 09:35:14 -04:00
Steven
bf1e59b2d3 [now-static-build] Add support for hugo extended (#3043) 2019-09-30 09:35:06 -04:00
Nathan Rajlich
3657e4a36e [now-cli] Update @zeit/fun to v0.10.2 (#3038)
Fixes #2901.
2019-09-30 09:34:43 -04:00
Nathan Rajlich
09efc1d865 [now-cli] Render logs containing "warning" as yellow (#3035) 2019-09-30 09:34:19 -04:00
Leo Lamprecht
32aa94bf3d Publish
- now@16.1.4-canary.12
2019-09-30 11:13:18 +02:00
Andy
3201227430 [now-cli] Fix deployment version output (#3097)
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.
2019-09-28 15:01:22 +00:00
Max Rovensky
09a421c23b Publish
- @now/build-utils@1.0.0-canary.9
 - now@16.1.4-canary.11
 - now-client@5.1.1-canary.5
 - @now/next@1.0.0-canary.7
 - @now/static-build@0.9.9-canary.11
2019-09-28 03:21:27 +08: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
Steven
7911d5857d [now-static-build] Make curl silent (#3090)
We added a message in #3068 so this PR makes curl silent unless it errors.

Also fix typo in Gutenberg 😉 

PRODUCT-7 #close
2019-09-27 14:16:48 +00:00
Max
05a44a0c70 [now-cli] Add not_domain_owner error handling (#3045)
This adds missing error handler for `not_domain_owner` error (fixes #3042)
2019-09-27 12:40:51 +00:00
Nathan Rajlich
efd8863f8b [now-client] Export TypeScript types (#3087)
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;
                                         ~~~~~~~~~~~~~~~~~~~~~~~~
````
2019-09-27 14:02:35 +08:00
Sophearak Tha
6699028342 [now-next] Invoke build script (#3073)
This PR make `@now/next` invoke `build` script if user defined.

PRODUCT-106 #close
2019-09-27 02:09:45 +00:00
Leo Lamprecht
aa9a234a0b [now-build-utils] Make grouping prerenders optional (#3082)
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.
2019-09-26 20:48:04 +00:00
Leo Lamprecht
91f836818c [now-build-utils] Allow prerender groups to be defined with an integer (#3081)
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.
2019-09-26 18:20:56 +00:00
Max
5e37bdc54c [now-cli] Add logging to execa calls in tests (#3077)
This implements #3075 for all integration tests
2019-09-26 15:13:03 +00:00
Max
31c48df795 [now-client] Retry on network error (#3072)
This PR improves handling of occasional network errors in `now-client` which should improve benchmarking introduced in #3062
2019-09-26 14:17:54 +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
Max
f4fe8be4df [now-client] Add debug logs (#2997)
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
2019-09-25 14:38:50 +00:00
Sophearak Tha
cc643e373d [now-cli] Render prompt when deploying home directory (#3057)
Fixes #3069 

PRODUCT-160 #close
2019-09-25 05:34:27 +00:00
Steven
651429cb52 [now-static-build] Add test for BUNDLE_WITHOUT env var (#3070)
This adds a test which confirms that `BUNDLE_WITHOUT="test:development"` works properly.

This env var is equivalent to `bundle install --without test development`.

There's no code change here because groups are defined by the user, therefore they must define which ones to ignore (if any).

- Groups Guide: https://bundler.io/v2.0/guides/groups.html
- BUNDLER_WITHOUT: https://bundler.io/v2.0/bundle_config.html#LIST-OF-AVAILABLE-KEYS
- Example Gemfile: https://github.com/thoughtbot/administrate/blob/master/Gemfile

PRODUCT-133 #close
2019-09-24 22:36:06 +00:00
Steven
a374a5ce96 Use PR description for merge commit body (#3071) 2019-09-24 17:53:14 -04:00
Steven
bbb4501e9b Publish
- now@16.1.4-canary.10
 - @now/node@1.0.0-canary.8
 - @now/static-build@0.9.9-canary.10
2019-09-24 17:15:45 -04:00
Steven
947f9093be [now-static-build] Print version of static generator during build (#3068)
* [now-static-build] Print version of static generator

* Use curl progress bar
2019-09-24 21:14:00 +00:00
Steven
42f16b6d1e [tests] Add benchmark script to randomly generate projects files (#3062) 2019-09-24 19:31:44 +00:00
Steven
9ae747a612 [now-node] Fix sharp test using lock file (#3064) 2019-09-24 01:47:46 +00:00
Steven
9217c5e436 [now-static-build] Add Eleventy to optimized framework list (#3060)
* [now-static-build] Add eleventy to frameworks

* Add test using eleventy-base-blog

* Fix tests with dot files

* Add now.json to 27-eleventy fixture
2019-09-23 15:15:28 +00:00
Sophearak Tha
d23e7b1054 [now-cli] Add NOW_BUILDER_DEBUG to build env if --debug (#3041)
* Add `NOW_BUILDER_DEBUG` to build env if `--debug`

* Add `--debug` build env check

* Add `build-env-debug` to prepare
2019-09-23 14:03:30 +00:00
Sophearak Tha
d23eab61cf [now-cli] Fix 02-angular-node test fail (#3058)
* Improve `02-angular-node` test

* Add `yarn.lock` with pin version
2019-09-23 20:30:27 +07:00
Steven
e631de4cfe Publish
- @now/build-utils@1.0.0-canary.8
 - now@16.1.4-canary.9
 - @now/python@0.2.17-canary.4
 - @now/static-build@0.9.9-canary.9
2019-09-21 17:20:40 -04:00
Steven
0814bef36f [now-python] Fix headers with multiple values (#3053)
* [now-python] Add format_headers()

* Add tests

* Fix filenames

* Fix test probes
2019-09-20 21:55:39 +00:00
Andy
ddce65416c [now-cli][now-static-build] Ignore output directory from now dev (#3024)
* [now-cli][now-static-build] Ignore output directory from `now dev`

* Add test

* Logging

* Fix test

* Fix test

* Adjust test

* Log failed test

* Log stderr

* Change now.json

* Change Ready check

* Dynamically create now.json

* Log error

* Log stderr on error

* Create now.json first

* Handle JSON error

* Don't use JSON output

* Join path

* Add quotes

* Use .values
2019-09-20 13:26:55 +00:00
Sophearak Tha
9e66f9bb08 [now-build-utils] Remove NOW_BUILDER_ANNOTATE (#3027) 2019-09-20 09:07:36 +00:00
Steven
961fbfde55 Publish
- @now/build-utils@1.0.0-canary.7
 - @now/go@0.5.11-canary.5
 - @now/next@1.0.0-canary.6
 - @now/node@1.0.0-canary.7
 - @now/python@0.2.17-canary.3
 - @now/static-build@0.9.9-canary.8
2019-09-19 15:58:01 -04:00
Steven
22550c0c48 [now-static-build][now-build-utils] Add python static generators (#3048)
* [now-static-build] Run pip install requirements.txt

* Add test for pelican

* Add test for mkdocs
2019-09-19 19:44:38 +00:00
Sophearak Tha
4336f48d22 [builders] Consistently capitalize first letter of logs (#3039)
* Consistency capitalize logs line `@now/next`

* Consistency capitalize logs line `@now/node`

* Consistency capitalize logs line `@now/go`

* Consistency capitalize logs line `@now/python`

* Always show `Installing dependencies...`

* Consistency capitalize logs line `run-user-scripts`

* Capitalize `Running`
2019-09-19 17:21:43 +00:00
Steven
cf299562e3 Publish
- @now/static-build@0.9.9-canary.7
2019-09-19 11:17:33 -04:00
Steven
2cd5b35603 [now-static-build] Add prepareCache() function (#3047) 2019-09-19 15:11:37 +00:00
Steven
81abab81f7 [now-static-build] Add support for hugo extended (#3043) 2019-09-19 13:27:01 +00:00
Max Rovensky
ad0d7bd560 Publish
- @now/build-utils@1.0.0-canary.6
 - now@16.1.4-canary.8
 - @now/node@1.0.0-canary.6
 - @now/static-build@0.9.9-canary.6
2019-09-19 19:36:51 +08:00
Nathan Rajlich
140d10e87b [now-cli] Update @zeit/fun to v0.10.2 (#3038)
Fixes #2901.
2019-09-18 10:11:12 +00:00
Nathan Rajlich
6bebc49607 [now-cli] Render logs containing "warning" as yellow (#3035) 2019-09-17 23:14:34 +00:00
Steven
22bded50b6 [master only] Fix merge conflict 2019-09-17 18:39:06 -04:00
Steven
b5b02be3c2 [docs] Update CI badge to use master (#3037) 2019-09-17 18:36:49 -04:00
Steven
776f372eb3 [tests] Add env var FORCE_BUILD_IN_REGION (#3036)
* [tests] Add env var FORCE_BUILD_IN_REGION

* Add missing config
2019-09-17 18:35:42 -04:00
Steven
81279fd40b [now-static-build] Add hugo, zola, and gutenberg versioning (#3025)
* [now-static-build] Add hugo, zola, and gutenberg versioning

* Add tests

* Export spawnAsync

* Change spawnAsync to remove cwd
2019-09-17 18:35:34 -04:00
Leo Lamprecht
3342485d29 [now-build-utils] Add types for SPRv2 (#3021)
* Add `Prerender` type for SPRv2

* Make it a default export

* Added `PrerenderGroup` type

* Renamed interface
2019-09-17 18:35:27 -04:00
Andy
028ee848f5 [now-cli] Fix fetch body and add secrets tests (#3030) 2019-09-17 18:35:19 -04:00
Nathan Rajlich
7e64c3b8a9 [now-cli] Assign process.exitCode (#3028)
No real functional change here, but assigning to `process.exitCode`
is the more proper Node.js way to set the exit code for the process.
2019-09-17 18:35:09 -04:00
Nathan Rajlich
704031f7b2 [now-cli] Render "stderr" as red in now logs (#3026) 2019-09-17 18:35:02 -04:00
Andy
5e3c184735 [now-cli] Adjust the printed version for the deployment (#3014) 2019-09-17 18:34:54 -04:00
Steven
88a8022787 [docs] Add scripts for changelog and diff (#3017)
* [release] Add scripts for changelog and diff

* Remove publish docs since it in the wiki

* Add support for windows
2019-09-17 18:34:49 -04:00
Steven
96844dc4a5 [now-node] Change trace errors to warnings (#3016) 2019-09-17 18:34:44 -04:00
Max
a09acd6969 [now-cli][now-client] Remove fetch-h2 (#3011)
* Remove fetch-h2

* Fix package.json

* Fix migration issue

* Improve time() call and ensure consistent header names

* Remove unused agent.ts
2019-09-17 18:34:38 -04:00
Andy
4e232f78de [now-cli] Add test for zero-config and canary builders (#3009)
* [now-cli] Add test for zero-config and canary builders

* Fix test

* Fix test

* Fix url

* Fix path and export

* Make public
2019-09-17 18:34:29 -04:00
Steven
b146a04772 [now-node] Add support for AWS Gateway Event (#3010)
* [now-node] Add support for AWS Gateway Event

* Fix funcName

* Fix makeAwsLauncher export

* Add missing return
2019-09-17 18:34:20 -04:00
Steven
eaaa50e616 Add release notes script to PUBLISHING.md (#3006) 2019-09-17 18:34:14 -04:00
Andy
c893eaeb7a [now-cli] Default to empty string for undefined env var when checking (#3008) 2019-09-17 18:34:08 -04:00
Andy
5bf7d7fd07 [now-cli] Add changelog link to update message (#3001) 2019-09-17 18:34:00 -04:00
Max
ca8fc92b94 [now-cli] Fix links output during deployment (#2966)
* Fix links output during deployment

* Move "synced" log to `total-fileds` event

* Pluralize synced messages

* Update packages/now-cli/src/util/deploy/process-deployment.ts

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

* Fix failing tests due to stdout mismatch
2019-09-17 18:33:53 -04:00
Steven
9956e85f12 [now-ruby] Use pre-installed ruby 2.5 (#2991)
* [now-ruby] Use pre-installed ruby 2.5

* Change GEM_HOME

* Add polyfill for Node 8
2019-09-17 18:33:47 -04:00
Nathan Rajlich
7fa4739c78 [now-cli] Show a warning for invalid env vars in now dev (#3002)
* [now-cli] Show a warning for invalid env vars in `now dev`

Closes #2982.

* Add "validate env var names" integration test
2019-09-17 18:33:40 -04:00
Andy
0ef2e2a7ec [now-cli] Add tests for alias rules (#3003) 2019-09-17 18:33:34 -04:00
Sophearak Tha
8fd1752acf [now-go] Improve test for custom build flags (#2999) 2019-09-17 18:33:29 -04:00
Nathan Rajlich
14a1446faf [now-cli] Render correct command for now ls $path_alias_url (#2988)
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.
2019-09-17 18:33:16 -04:00
Steven
0c2c8c5ae5 [now-static-build] Run bundle install when Gemfile is found (#2980)
* [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
2019-09-17 18:33:07 -04:00
Steven
a3aa855290 [docs] Update CI badge to use master (#3037) 2019-09-17 22:33:02 +00:00
Steven
511b27ad39 [now-node][now-next] Bump node-file-trace to 0.3.1 (#2990) 2019-09-17 18:33:00 -04:00
Sophearak Tha
e22ce7da0a [now-cli] Hide Init Duration and XRAY TraceId by default (#2984) 2019-09-17 18:32:54 -04:00
Steven
d9a4ce06bc [now-build-utils] Add function runBundleInstall() (#2986)
* [now-build-utils] Add function `runBundleInstall`

* Add additional flags

* Set jobs to number of cpus

* Format

* Fix formatting

* Add BUNDLE_APP_CONFIG
2019-09-17 18:32:46 -04:00
Steven
77fb14cc60 [now-node] Bump node-file-trace to 0.3.0 and print warnings (#2985)
* Bump node-file-trace to 0.3.0

* [now-node] Print warnings from node-file-trace
2019-09-17 18:32:39 -04:00
Clément ALLAIN
17c397211e [now-static-build] Fix dev server port detection (#2879)
* [now-static-build] Fix dev server detection

* Code review

* Remove unused dependency

* Fix the checking by really waiting until the port is reachable
2019-09-17 18:32:20 -04:00
Andy
6ca83644bc [now-build-utils][now-cli] Warn instead of throwing on api and pages/api (#2976)
* [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
2019-09-17 18:31:56 -04:00
Andy
d1946ea9b6 [now-cli] Display warning when changing the secret name (#2975) 2019-09-17 18:31:44 -04:00
Nathan Rajlich
cc9eae3b71 [now-cli] Use PackageJson and Builder types from @now/build-utils (#2971)
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…
2019-09-17 18:31:37 -04:00
Nathan Rajlich
7bbc17df4b [now-build-utils] Add env and buildEnv to Meta type (#2970)
* [now-build-utils] Add `env` and `buildEnv` to `Meta` type

`now dev` passes in these variables to the "meta" object.

* Fix build
2019-09-17 18:31:31 -04:00
Andy
df6b2be482 [now-build-utils] Throw error on Next.js pages/api and api/ (#2964) 2019-09-17 18:30:40 -04:00
Sophearak Tha
5ff6263fb7 [now-cli] Add platform in Sentry report (#2960) 2019-09-17 18:30:33 -04:00
Luc
04dc8aaf73 [gatsby-plugin-now] Add keywords in package.json (#2965)
* add keywords to gatsby-plugin-now

* add #readme in homepage url
2019-09-17 18:30:25 -04:00
Sophearak Tha
5435805e58 [now-build-utils] Use debug() on installing to and missing engines (#2954)
* Use debug() on `installing to` output

* Use debug() on `getSupportedNodeVersion` output
2019-09-17 18:30:16 -04:00
Nathan Rajlich
903f819c5d [now-cli] Fix now alias with no arguments (#2959)
Fixes #2941.
2019-09-17 18:29:41 -04:00
Nathan Rajlich
5d927b2d25 [CircleCI] Remove publish-stable and publish-canary steps (#2957)
Publishing to npm is now handled by GitHub Actions.

Aside from that, the Circle publishing was broken.
See: https://circleci.com/gh/zeit/now/7213
2019-09-17 18:29:11 -04:00
Steven
b7a260cc6d [now-python] Use system python with now dev (#2956) 2019-09-17 18:29:03 -04:00
Steven
e8ba8fb97b [now-cli] Bump @zeit/fun to 0.10.0 (#2955) 2019-09-17 18:28:49 -04:00
Max
dd1d9d856b [now-cli] Implement now-client deployments in Now CLI (#2875)
* Imlement `now-client` deployments in Now CLI

* Move now-client to dev dependencies

* Fix missing config for legacy deployments

* Restore no files warning

* Improve error handling

* Port over `--prod`

* Handle single files and warnings better

* Fix legacy deployment env config

* Handle build errors in events

* Don't use ncc for now-client

* Extract `for...await` logic into a `.ts` file

* Revert "Don't use ncc for now-client"

This reverts commit e481a04058952f7011bf5523445256f1b8882dda.

* Add `typings` field to `now-client`

* Regenerate yarn.lock

* Add bootstrap step to CircleCI

* Add bootstrap step before build

* Revert "Add bootstrap step before build"

This reverts commit db9e1113937f113cca8c7c05d5c800fd5d61e84b.

* Revert "Add bootstrap step to CircleCI"

This reverts commit 02c0006a073614814fd174ccbaf1e4e0d8dd3dbf.

* Build `now-client` before CLI

* Sort build scripts

* Tweak empty deployment detection

* Add bootstrap step before build

* Remove now-client dependency from now-client

* Use local dependencies

* Fix paths and regenerate lockfile

* Bypass broken linting rule

* Remove lint ignore

* Use `tsc` instead of `ncc` for `now-client`

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

* Fix output path for tsc build

* [test] Supress TS warning

* Update packages/now-cli/src/commands/deploy/latest.js

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

* Update packages/now-cli/src/commands/deploy/latest.js

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

* Update packages/now-client/package.json

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

* Change `now-client` output to `dist`

* Implement file events in now-client and bring back progressbar

* Update build script sorting

* Add new logic tests for `now-client`

* Remove redundant target check

* Remove now-client dependency and use local code

* Set exact dependency versions

* Revert "Set exact dependency versions"

This reverts commit e0a31eaf10e498271c9253439d4bbd650738c694.

* Revert local now-client import

* Revert `now-client` dependency to local path

* Implement feedback

* Fix formatting

* Only handle alias errors if `readyState` is `READY`

* Update packages/now-cli/src/commands/deploy/latest.js

Co-Authored-By: Andy <AndyBitz@users.noreply.github.com>

* Update packages/now-cli/src/commands/deploy/latest.js

Co-Authored-By: Andy <AndyBitz@users.noreply.github.com>
2019-09-17 18:27:13 -04:00
Steven
a853cb84cd [tests] Add env var FORCE_BUILD_IN_REGION (#3036)
* [tests] Add env var FORCE_BUILD_IN_REGION

* Add missing config
2019-09-17 21:56:46 +00:00
Steven
eef4c65e5f Publish
- @now/next@1.0.1
2019-09-17 17:44:26 -04:00
Joe Haddad
3f64594a22 [now-next] Add monorepo autosetup support (#2961)
* [now-next] Add monorepo autosetup support

* Add actual tests

* Remove invalid test

* Correct contents directory

* Update tests

* Support new Next.js canaries
2019-09-17 17:22:22 -04:00
Steven
a07082ca5c [now-static-build] Add hugo, zola, and gutenberg versioning (#3025)
* [now-static-build] Add hugo, zola, and gutenberg versioning

* Add tests

* Export spawnAsync

* Change spawnAsync to remove cwd
2019-09-17 19:14:39 +00:00
Leo Lamprecht
81c27771bc [now-build-utils] Add types for SPRv2 (#3021)
* Add `Prerender` type for SPRv2

* Make it a default export

* Added `PrerenderGroup` type

* Renamed interface
2019-09-17 18:28:04 +00:00
Andy
502f78e835 [now-cli] Fix fetch body and add secrets tests (#3030) 2019-09-17 13:21:18 +00:00
Nathan Rajlich
d8935cf121 [now-cli] Assign process.exitCode (#3028)
No real functional change here, but assigning to `process.exitCode`
is the more proper Node.js way to set the exit code for the process.
2019-09-17 06:58:43 +00:00
Nathan Rajlich
e3c61ac5b7 [now-cli] Render "stderr" as red in now logs (#3026) 2019-09-17 06:24:34 +00:00
Andy
e8e95b8df6 [now-cli] Adjust the printed version for the deployment (#3014) 2019-09-14 01:15:39 +00:00
Steven
f55be4f2de [docs] Add scripts for changelog and diff (#3017)
* [release] Add scripts for changelog and diff

* Remove publish docs since it in the wiki

* Add support for windows
2019-09-13 23:35:40 +00:00
Steven
ef081cc4b8 [now-node] Change trace errors to warnings (#3016) 2019-09-13 22:40:26 +00:00
Max Rovensky
8e2444d3cd Publish
- now@16.1.4-canary.7
 - now-client@5.1.1-canary.4
2019-09-14 02:32:19 +08:00
Max
f26407e282 [now-cli][now-client] Remove fetch-h2 (#3011)
* Remove fetch-h2

* Fix package.json

* Fix migration issue

* Improve time() call and ensure consistent header names

* Remove unused agent.ts
2019-09-13 18:23:34 +00:00
Andy
cded895bf7 [now-cli] Add test for zero-config and canary builders (#3009)
* [now-cli] Add test for zero-config and canary builders

* Fix test

* Fix test

* Fix url

* Fix path and export

* Make public
2019-09-13 01:59:49 +00:00
Steven
1211ee4fb3 Publish
- now@16.1.4-canary.6
 - @now/go@0.5.11-canary.4
 - @now/node@1.0.0-canary.5
 - @now/ruby@0.1.5-canary.3
2019-09-12 19:29:03 -04:00
Steven
a42bdefe1a [now-node] Add support for AWS Gateway Event (#3010)
* [now-node] Add support for AWS Gateway Event

* Fix funcName

* Fix makeAwsLauncher export

* Add missing return
2019-09-12 23:26:11 +00:00
Steven
f025f1007b Add release notes script to PUBLISHING.md (#3006) 2019-09-12 18:26:21 +00:00
Andy
1c11a57371 [now-cli] Default to empty string for undefined env var when checking (#3008) 2019-09-12 17:48:32 +00:00
Andy
db2d033484 [now-cli] Add changelog link to update message (#3001) 2019-09-12 16:15:33 +00:00
Max
40537c9eba [now-cli] Fix links output during deployment (#2966)
* Fix links output during deployment

* Move "synced" log to `total-fileds` event

* Pluralize synced messages

* Update packages/now-cli/src/util/deploy/process-deployment.ts

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

* Fix failing tests due to stdout mismatch
2019-09-12 14:40:46 +00:00
Steven
5cabcb7a27 [now-ruby] Use pre-installed ruby 2.5 (#2991)
* [now-ruby] Use pre-installed ruby 2.5

* Change GEM_HOME

* Add polyfill for Node 8
2019-09-12 13:34:54 +00:00
Nathan Rajlich
1be9ac59f0 [now-cli] Show a warning for invalid env vars in now dev (#3002)
* [now-cli] Show a warning for invalid env vars in `now dev`

Closes #2982.

* Add "validate env var names" integration test
2019-09-12 00:12:29 +00:00
Andy
64356baed3 [now-cli] Add tests for alias rules (#3003) 2019-09-11 23:32:20 +00:00
Sophearak Tha
c944706a0f [now-go] Improve test for custom build flags (#2999) 2019-09-11 16:23:54 +00:00
Nathan Rajlich
f15deaa51e [now-cli] Render correct command for now ls $path_alias_url (#2988)
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.
2019-09-11 15:47:56 +00:00
Steven
61c3b94460 Publish
- @now/build-utils@1.0.0-canary.5
 - @now/static-build@0.9.9-canary.5
2019-09-11 10:32:20 -04:00
Steven
89b018240f [now-static-build] Run bundle install when Gemfile is found (#2980)
* [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
2019-09-11 10:28:24 -04:00
Steven
0124dc9969 Publish
- now@16.1.4-canary.5
 - @now/next@1.0.0-canary.5
 - @now/node@1.0.0-canary.4
2019-09-10 12:38:03 -04:00
Steven
936441c8a6 [now-node][now-next] Bump node-file-trace to 0.3.1 (#2990) 2019-09-10 16:12:24 +00:00
Sophearak Tha
c80570e096 [now-cli] Hide Init Duration and XRAY TraceId by default (#2984) 2019-09-10 14:22:08 +00:00
Steven
11c67e1c4c Publish
- @now/build-utils@1.0.0-canary.4
2019-09-10 09:18:57 -04:00
Steven
0d1c0e0f30 [now-build-utils] Add function runBundleInstall() (#2986)
* [now-build-utils] Add function `runBundleInstall`

* Add additional flags

* Set jobs to number of cpus

* Format

* Fix formatting

* Add BUNDLE_APP_CONFIG
2019-09-09 21:51:46 +00:00
Steven
f50572813e Publish
- gatsby-plugin-now@1.2.1-canary.1
 - @now/build-utils@1.0.0-canary.3
 - now@16.1.4-canary.4
 - now-client@5.1.1-canary.3
 - @now/next@1.0.0-canary.4
 - @now/node@1.0.0-canary.3
 - @now/static-build@0.9.9-canary.4
2019-09-09 13:09:08 -04:00
Steven
648b3a4ae2 [now-node] Bump node-file-trace to 0.3.0 and print warnings (#2985)
* Bump node-file-trace to 0.3.0

* [now-node] Print warnings from node-file-trace
2019-09-09 16:39:40 +00:00
Max Rovensky
3f5f71f8ab Publish
- now-client@5.1.3
2019-09-09 23:32:19 +08:00
Max
2a44179898 [now-client] Fix windows paths handling (#2974)
* Fix windows paths handling in now-client

* Tweak windows paths  handling
2019-09-09 23:31:16 +08:00
Joe Haddad
efe114fa86 [now-next] Add monorepo autosetup support (#2961)
* [now-next] Add monorepo autosetup support

* Add actual tests

* Remove invalid test

* Correct contents directory

* Update tests

* Support new Next.js canaries
2019-09-09 14:42:26 +00:00
Max
4445d5e00f [now-client] Fix windows paths handling (#2974)
* Fix windows paths handling in now-client

* Tweak windows paths  handling
2019-09-09 04:05:20 +00:00
Clément ALLAIN
96b3c1ee7f [now-static-build] Fix dev server port detection (#2879)
* [now-static-build] Fix dev server detection

* Code review

* Remove unused dependency

* Fix the checking by really waiting until the port is reachable
2019-09-06 23:38:49 +00:00
Andy
e1a770ac29 [now-build-utils][now-cli] Warn instead of throwing on api and pages/api (#2976)
* [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
2019-09-06 22:02:33 +00:00
Andy
db1a2e6482 [now-cli] Display warning when changing the secret name (#2975) 2019-09-06 10:45:57 +00:00
Nathan Rajlich
ecdde7c367 [now-cli] Use PackageJson and Builder types from @now/build-utils (#2971)
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…
2019-09-06 00:35:49 +00:00
Nathan Rajlich
4d31291ea4 [now-build-utils] Add env and buildEnv to Meta type (#2970)
* [now-build-utils] Add `env` and `buildEnv` to `Meta` type

`now dev` passes in these variables to the "meta" object.

* Fix build
2019-09-05 15:19:17 -07:00
Andy
b70bd670fd [now-build-utils] Throw error on Next.js pages/api and api/ (#2964) 2019-09-05 19:21:59 +00:00
Sophearak Tha
d3017649e0 [now-cli] Add platform in Sentry report (#2960) 2019-09-05 18:57:15 +00:00
Luc
e970584219 [gatsby-plugin-now] Add keywords in package.json (#2965)
* add keywords to gatsby-plugin-now

* add #readme in homepage url
2019-09-05 18:04:32 +00:00
Andy Bitz
4a6ddf8b1d Publish
- gatsby-plugin-now@1.2.1
 - @now/build-utils@0.10.0
 - @now/cgi@0.1.6
 - now@16.2.0
 - now-client@5.1.2
 - @now/go@0.5.12
 - @now/next@1.0.0
 - @now/node-bridge@1.2.5
 - @now/node@1.0.0
 - @now/python@0.2.18
 - @now/routing-utils@1.2.4
 - @now/ruby@0.1.6
 - @now/static-build@0.9.10
2019-09-05 18:25:48 +02:00
Sophearak Tha
c6205293a9 [now-build-utils] Use debug() on installing to and missing engines (#2954)
* Use debug() on `installing to` output

* Use debug() on `getSupportedNodeVersion` output
2019-09-05 13:19:32 +00:00
Max Rovensky
cb47f7bf4b Publish
- now@16.1.4-canary.3
 - @now/python@0.2.17-canary.2
2019-09-05 17:07:52 +08:00
Nathan Rajlich
a60f107e4b [now-cli] Fix now alias with no arguments (#2959)
Fixes #2941.
2019-09-05 00:09:17 +00:00
Andy Bitz
eeb1b2442c Revert "[now-cli] Implement now-client deployments in Now CLI (#2875)"
This reverts commit 129f234aaa.
2019-09-05 00:03:23 +02:00
Max
129f234aaa [now-cli] Implement now-client deployments in Now CLI (#2875)
* Imlement `now-client` deployments in Now CLI

* Move now-client to dev dependencies

* Fix missing config for legacy deployments

* Restore no files warning

* Improve error handling

* Port over `--prod`

* Handle single files and warnings better

* Fix legacy deployment env config

* Handle build errors in events

* Don't use ncc for now-client

* Extract `for...await` logic into a `.ts` file

* Revert "Don't use ncc for now-client"

This reverts commit e481a04058952f7011bf5523445256f1b8882dda.

* Add `typings` field to `now-client`

* Regenerate yarn.lock

* Add bootstrap step to CircleCI

* Add bootstrap step before build

* Revert "Add bootstrap step before build"

This reverts commit db9e1113937f113cca8c7c05d5c800fd5d61e84b.

* Revert "Add bootstrap step to CircleCI"

This reverts commit 02c0006a073614814fd174ccbaf1e4e0d8dd3dbf.

* Build `now-client` before CLI

* Sort build scripts

* Tweak empty deployment detection

* Add bootstrap step before build

* Remove now-client dependency from now-client

* Use local dependencies

* Fix paths and regenerate lockfile

* Bypass broken linting rule

* Remove lint ignore

* Use `tsc` instead of `ncc` for `now-client`

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

* Fix output path for tsc build

* [test] Supress TS warning

* Update packages/now-cli/src/commands/deploy/latest.js

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

* Update packages/now-cli/src/commands/deploy/latest.js

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

* Update packages/now-client/package.json

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

* Change `now-client` output to `dist`

* Implement file events in now-client and bring back progressbar

* Update build script sorting

* Add new logic tests for `now-client`

* Remove redundant target check

* Remove now-client dependency and use local code

* Set exact dependency versions

* Revert "Set exact dependency versions"

This reverts commit e0a31eaf10e498271c9253439d4bbd650738c694.

* Revert local now-client import

* Revert `now-client` dependency to local path

* Implement feedback

* Fix formatting

* Only handle alias errors if `readyState` is `READY`

* Update packages/now-cli/src/commands/deploy/latest.js

Co-Authored-By: Andy <AndyBitz@users.noreply.github.com>

* Update packages/now-cli/src/commands/deploy/latest.js

Co-Authored-By: Andy <AndyBitz@users.noreply.github.com>
2019-09-04 23:54:21 +02:00
Nathan Rajlich
331c352e2b [now-cli] Update pcre-to-regexp to v1.0.0 (#2932)
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.
2019-09-04 23:46:31 +02:00
Nathan Rajlich
2ccbaea9dd [now-cli] Remove deprecated @now/php builder from bundled builders tarball (#2907)
`@now/php` has been deprecated in favor of community-maintained
`now-php`, so don't bundle the deprecated builder with Now CLI.
2019-09-04 23:45:44 +02:00
Sophearak Tha
069eca3c62 [now-cli] Remove annotate from now logs (#2937)
* Remove annotate from `now logs`

* Filter out runtime logs to be consistency with dashboard logs

* Add integration test
2019-09-04 23:44:13 +02:00
Nathan Rajlich
305e364f8b [now-cli] Output --json to stdout for now alias ls <url> (#2922)
Fixes #1337.
2019-09-04 23:41:27 +02:00
Nathan Rajlich
4068805ae0 [now-cli] Use xdg-app-paths for now dev cache dir (#2921)
* [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
2019-09-04 23:36:16 +02:00
Andy
9a1e7a4a7a [now-cli] Handle now certs ls for users and teams without certificates (#2945)
* [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>
2019-09-04 23:25:31 +02:00
Naoyuki Kanezawa
bbad3d1b96 Add the nameservers verification check and improve messages (#2943)
* add the nameservers verification check and improve messages

* fix verify message condition
2019-09-04 23:25:23 +02:00
Nathan Rajlich
c62116d9a4 [now-cli] Remove now update from --help output (#2951)
Fixes #2940.
2019-09-04 23:25:11 +02:00
Nathan Rajlich
c94086ff21 [now-cli] Remove scale subcommand from --help (#2923)
Fixes #1998.
2019-09-04 23:25:00 +02:00
Andy
e99caa7b97 Fix the prettier config (#2946)
* Fix the prettier config

* Try prettier
2019-09-04 23:24:52 +02:00
Andy
658b9e9007 [now-cli] Install dependencies before running now dev in tests (#2948)
* [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
2019-09-04 23:24:45 +02:00
Luc
3ef27ae45c [gatsby-plugin-now] Add new package w/support for Gatsby Redirects (#2897)
* 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
2019-09-04 23:23:58 +02:00
Andy
e669cd1152 [now-node][now-next] Skip installing user dependencies for now dev (#2926)
* Skip installing user dependencies for `now dev`

* Update type

* Install dependecies for test

* Add comma-dangle for @now/next

* Revert "Add comma-dangle for @now/next"

This reverts commit 720d5630f309ec44eb65e280af29db5b14bd50eb.

* Add trailing commas

* Reset typescript update

* Add trailing commas

* Bump @zeit/node-file-trace

* Readd trailing comma

* Bump @zeit/node-file-trace in @now/node
2019-09-04 23:23:47 +02:00
Sophearak Tha
b22aa7c0cf [now-go] Add GO_BUILD_FLAGS support for go build custom flags (#2916)
* Add `GO_BUILD_FLAGS` support for go build custom flags

* Using string-argv package

* Simplify condition
2019-09-04 23:23:33 +02:00
Joe Haddad
582cbb61fb [now-next] Create default file with correct target (#2924) 2019-09-04 23:23:10 +02:00
Sophearak Tha
7f4197cf43 [now-node] Cleanup debug output (#2927)
* Ensure traced files have annotate present in all lines

* Remove traced file logs

* Remove `compiling es module file` log

* Cleanup debug output
2019-09-04 23:22:49 +02:00
JJ Kasper
30889db487 [now-next] Use patched version of yazl and trace API pages separate (#2919)
* Update to trace API files separately and use modified yazl

* Remove jszip dependency

* Pin yazl dependency and add types

* Update more types
2019-09-04 23:22:30 +02:00
Luc
2d08d5d23e [tests] Unify .editorconfig (#2920) 2019-09-04 23:22:16 +02:00
Luc
59e7367e03 [tests] Unify linting and autoformatting (#2914)
* add prettier and eslint on root

* remove eslint from now-cli

* adjust root package.json

* adjust eslintignore

* adjust now-cli rules

* remove @zeit/git-hooks in packages

* adjust now-client eslint config

* add lint-staged and hook on pre-commit

* add pre-commit script

* replace @zeit/git-hooks with husky

* remove unnecessary script

* fix eslint errors

* trigger tests

* fix fixable errors

* fix fixable errors (bis)

* revert two changes
2019-09-04 23:22:02 +02:00
Naoyuki Kanezawa
84af278e86 [tests] Remove fixtures files for integration tests (#2910) 2019-09-04 23:21:51 +02:00
JJ Kasper
67d9ee39e2 [now-next] Optimize lambda creation (#2892)
* 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
2019-09-04 23:21:32 +02:00
Joe Haddad
6c67bb81f7 [now-next] Do not add initial files to lambda (#2894) 2019-09-04 23:21:03 +02:00
Steven
aba19701c0 [tests] Ignore fixtures in GitHub Languages & fix yarn.lock (#2890) 2019-09-04 23:20:47 +02:00
Sophearak Tha
bb79402999 [now-next] Use debug() from build-utils (#2881)
* [now-next] Use `debug()` from build-utils (#909)

* Use `debug()` from build-utils

* Revert back to warning output

* Remove unnecessary debug check
2019-09-04 23:20:37 +02:00
Sophearak Tha
420bc4b244 [now-go] Use debug() from build-utils (#2885)
* [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>
2019-09-04 23:20:27 +02:00
Sophearak Tha
323c3d74cb [now-ruby] Use debug() from build-utils (#2883) 2019-09-04 23:20:20 +02:00
Sophearak Tha
4ecec8a8f6 [now-node] Use debug() from build-utils (#2880)
* Use `debug()` from build-utils

* Remove condition
2019-09-04 23:20:13 +02:00
Sophearak Tha
98883f9978 [now-static-build] Use debug() from build-utils (#2884) 2019-09-04 23:20:04 +02:00
Sophearak Tha
37cf3be437 [now-python] Use debug() from build-utils (#2882)
* Use `debug()` from build-utils

* Apply suggestions from code review

Co-Authored-By: Steven <steven@ceriously.com>
2019-09-04 23:19:45 +02:00
Nathan Rajlich
6e43c322cc [CircleCI] Remove publish-stable and publish-canary steps (#2957)
Publishing to npm is now handled by GitHub Actions.

Aside from that, the Circle publishing was broken.
See: https://circleci.com/gh/zeit/now/7213
2019-09-04 20:33:19 +00:00
Steven
4b6387bdb5 [now-python] Use system python with now dev (#2956) 2019-09-04 18:35:33 +00:00
Steven
bcd770c0fe [now-cli] Bump @zeit/fun to 0.10.0 (#2955) 2019-09-04 18:10:33 +00:00
Max Rovensky
bb8c7e9f3b Publish
- now@16.1.4-canary.2
 - now-client@5.1.1-canary.2
2019-09-05 01:03:31 +08:00
Max
6e469272c3 [now-cli] Implement now-client deployments in Now CLI (#2875)
* Imlement `now-client` deployments in Now CLI

* Move now-client to dev dependencies

* Fix missing config for legacy deployments

* Restore no files warning

* Improve error handling

* Port over `--prod`

* Handle single files and warnings better

* Fix legacy deployment env config

* Handle build errors in events

* Don't use ncc for now-client

* Extract `for...await` logic into a `.ts` file

* Revert "Don't use ncc for now-client"

This reverts commit e481a04058952f7011bf5523445256f1b8882dda.

* Add `typings` field to `now-client`

* Regenerate yarn.lock

* Add bootstrap step to CircleCI

* Add bootstrap step before build

* Revert "Add bootstrap step before build"

This reverts commit db9e1113937f113cca8c7c05d5c800fd5d61e84b.

* Revert "Add bootstrap step to CircleCI"

This reverts commit 02c0006a073614814fd174ccbaf1e4e0d8dd3dbf.

* Build `now-client` before CLI

* Sort build scripts

* Tweak empty deployment detection

* Add bootstrap step before build

* Remove now-client dependency from now-client

* Use local dependencies

* Fix paths and regenerate lockfile

* Bypass broken linting rule

* Remove lint ignore

* Use `tsc` instead of `ncc` for `now-client`

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

* Fix output path for tsc build

* [test] Supress TS warning

* Update packages/now-cli/src/commands/deploy/latest.js

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

* Update packages/now-cli/src/commands/deploy/latest.js

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

* Update packages/now-client/package.json

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

* Change `now-client` output to `dist`

* Implement file events in now-client and bring back progressbar

* Update build script sorting

* Add new logic tests for `now-client`

* Remove redundant target check

* Remove now-client dependency and use local code

* Set exact dependency versions

* Revert "Set exact dependency versions"

This reverts commit e0a31eaf10e498271c9253439d4bbd650738c694.

* Revert local now-client import

* Revert `now-client` dependency to local path

* Implement feedback

* Fix formatting

* Only handle alias errors if `readyState` is `READY`

* Update packages/now-cli/src/commands/deploy/latest.js

Co-Authored-By: Andy <AndyBitz@users.noreply.github.com>

* Update packages/now-cli/src/commands/deploy/latest.js

Co-Authored-By: Andy <AndyBitz@users.noreply.github.com>
2019-09-04 16:50:09 +00:00
Andy Bitz
5e7fa71148 Publish
- now@16.1.4-canary.1
 - @now/next@1.0.0-canary.3
2019-09-04 12:44:04 +02:00
Andy Bitz
12d9a4b4f4 [now-cli] Bump version 2019-09-04 12:42:50 +02:00
Andy
084ab2d0e5 [now-cli] Handle now certs ls for users and teams without certificates (#2945)
* [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>
2019-09-04 10:35:20 +00:00
Naoyuki Kanezawa
4ca0d936aa Add the nameservers verification check and improve messages (#2943)
* add the nameservers verification check and improve messages

* fix verify message condition
2019-09-04 15:44:49 +09:00
Nathan Rajlich
5d5a55e7e1 [now-cli] Remove now update from --help output (#2951)
Fixes #2940.
2019-09-04 03:30:25 +00:00
Nathan Rajlich
e033e5e0ca [now-cli] Remove scale subcommand from --help (#2923)
Fixes #1998.
2019-09-03 20:08:41 +00:00
Andy
7cb36ef1dd Fix the prettier config (#2946)
* Fix the prettier config

* Try prettier
2019-09-03 18:56:34 +00:00
Andy
9aafb168e9 [now-cli] Install dependencies before running now dev in tests (#2948)
* [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
2019-09-03 18:05:21 +00:00
Andy Bitz
fbb5caf955 Publish
- gatsby-plugin-now@1.2.1-canary.0
 - @now/build-utils@1.0.0-canary.2
 - now@16.1.3-canary.6
 - @now/go@0.5.11-canary.3
 - @now/next@1.0.0-canary.2
 - @now/node@1.0.0-canary.2
 - @now/static-build@0.9.9-canary.3
2019-09-03 09:57:03 +02:00
Andy
3f93da550b [now-build-utils][now-next][now-node] Bump version (#2942)
* [now-build-utils][now-next][now-node] Bump version

* Bump build-utils in @now-cli
2019-09-03 07:53:19 +00:00
Luc
a194e0cc6e [gatsby-plugin-now] Add new package w/support for Gatsby Redirects (#2897)
* 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
2019-09-03 04:19:32 +00:00
Andy
b007200bcf [now-node][now-next] Skip installing user dependencies for now dev (#2926)
* Skip installing user dependencies for `now dev`

* Update type

* Install dependecies for test

* Add comma-dangle for @now/next

* Revert "Add comma-dangle for @now/next"

This reverts commit 720d5630f309ec44eb65e280af29db5b14bd50eb.

* Add trailing commas

* Reset typescript update

* Add trailing commas

* Bump @zeit/node-file-trace

* Readd trailing comma

* Bump @zeit/node-file-trace in @now/node
2019-09-02 19:35:48 +00:00
Sophearak Tha
05d88da887 [now-cli] Remove annotate from now logs (#2937)
* Remove annotate from `now logs`

* Filter out runtime logs to be consistency with dashboard logs

* Add integration test
2019-09-02 16:32:45 +00:00
Sophearak Tha
0a429bb2f3 [now-go] Add GO_BUILD_FLAGS support for go build custom flags (#2916)
* Add `GO_BUILD_FLAGS` support for go build custom flags

* Using string-argv package

* Simplify condition
2019-09-02 15:45:13 +00:00
Joe Haddad
468ccb7598 [now-next] Create default file with correct target (#2924) 2019-09-02 13:28:36 +00:00
Andy Bitz
e47f6f55dc Publish
- now@16.1.3-canary.5
2019-09-02 15:11:14 +02:00
Nathan Rajlich
17deed91b2 [now-cli] Update pcre-to-regexp to v1.0.0 (#2932)
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.
2019-09-02 12:47:25 +00:00
Nathan Rajlich
cc0bd9f0a2 [now-cli] Use xdg-app-paths for now dev cache dir (#2921)
* [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
2019-09-01 14:25:26 +00:00
Steven
f6f99fef25 Publish
- now@16.1.3-canary.4
 - @now/go@0.5.11-canary.2
 - @now/node@0.12.8-canary.3
2019-08-30 14:36:09 -04:00
Nathan Rajlich
eb252edc7f [now-cli] Output --json to stdout for now alias ls <url> (#2922)
Fixes #1337.
2019-08-30 18:29:28 +00:00
Sophearak Tha
f3213dbcdc [now-node] Cleanup debug output (#2927)
* Ensure traced files have annotate present in all lines

* Remove traced file logs

* Remove `compiling es module file` log

* Cleanup debug output
2019-08-30 16:42:23 +00:00
Sophearak Tha
c637da7710 [now-go] Fix analyze.go fails to parse source file with comments (#2911)
* Fix `analyze.go` fails to parse source file with comments

* Add more tests

* Improve fallback

* Improve check for http.HandlerFunc signature`
2019-08-30 15:32:51 +00:00
Joe Haddad
ab05595582 Publish
- @now/build-utils@0.9.14-canary.2
 - @now/cgi@0.1.5-canary.1
 - now@16.1.3-canary.3
 - now-client@5.1.1-canary.1
 - @now/go@0.5.11-canary.1
 - @now/next@0.7.1-canary.3
 - @now/node-bridge@1.2.4-canary.2
 - @now/node@0.12.8-canary.2
 - @now/python@0.2.17-canary.1
 - @now/routing-utils@1.2.3-canary.1
 - @now/ruby@0.1.5-canary.2
 - @now/static-build@0.9.9-canary.2
2019-08-29 23:15:18 -04:00
JJ Kasper
ba8e714329 [now-next] Use patched version of yazl and trace API pages separate (#2919)
* Update to trace API files separately and use modified yazl

* Remove jszip dependency

* Pin yazl dependency and add types

* Update more types
2019-08-30 02:40:45 +00:00
Luc
ef86bb0bd9 [tests] Unify .editorconfig (#2920) 2019-08-29 23:56:10 +00:00
Andy
be18b54bfd [now-cli] Improve check for update command (#2915)
* [now-cli] Improve check for update command

* Use path.sep

* Fix build
2019-08-29 23:47:53 +00:00
Max Strübing
ed168db23c [now-cli] Use XDG standard instead of writing to home directory (#2877)
* 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]
2019-08-29 23:04:47 +00:00
Luc
236f5f4159 [tests] Unify linting and autoformatting (#2914)
* add prettier and eslint on root

* remove eslint from now-cli

* adjust root package.json

* adjust eslintignore

* adjust now-cli rules

* remove @zeit/git-hooks in packages

* adjust now-client eslint config

* add lint-staged and hook on pre-commit

* add pre-commit script

* replace @zeit/git-hooks with husky

* remove unnecessary script

* fix eslint errors

* trigger tests

* fix fixable errors

* fix fixable errors (bis)

* revert two changes
2019-08-29 19:17:40 +00:00
Steven
e44a91634e [now-cli] Update readme and links (#2886)
* Update readme and links

* Fix readme image

* Fix homepage

* Update banner image to v3
2019-08-29 16:47:36 +00:00
Naoyuki Kanezawa
8b9426eb6c [tests] Remove fixtures files for integration tests (#2910) 2019-08-29 13:57:26 +00:00
Nathan Rajlich
c62c57f122 [now-cli] Implement continue: true with dest (#2908)
Closes #2685.
2019-08-29 12:39:55 +00:00
Nathan Rajlich
c81db0c8d2 [now-cli] Use a Map for the valid sub-commands (#2913)
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.
2019-08-29 07:56:36 +00:00
Naoyuki Kanezawa
1c64990e9f [now-cli] fix login test (#2909) 2019-08-29 05:45:40 +00:00
Joe Haddad
f1dc7fd14a Publish
- now@16.1.3-canary.2
 - @now/next@0.7.1-canary.2
 - @now/node-bridge@1.2.4-canary.1
 - @now/node@0.12.8-canary.1
 - @now/ruby@0.1.5-canary.1
 - @now/static-build@0.9.9-canary.1
2019-08-28 21:18:57 -04:00
Nathan Rajlich
6079d4be25 [now-cli] Remove deprecated @now/php builder from bundled builders tarball (#2907)
`@now/php` has been deprecated in favor of community-maintained
`now-php`, so don't bundle the deprecated builder with Now CLI.
2019-08-29 00:42:06 +00:00
Andy
2c4b8335ce [now-cli] Allow to fetch more certificates with paging (#2905)
* [now-cli] Allow to fetch more certificates with paging

* Linting

* Update packages/now-cli/src/commands/certs/ls.js

Co-Authored-By: Nathan Rajlich <n@n8.io>
2019-08-28 23:51:10 +00:00
JJ Kasper
9bd2f22d5c [now-next] Optimize lambda creation (#2892)
* 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
2019-08-28 22:43:26 +00:00
Andy
7c421f92e1 [now-cli] Validate inputs for alias, list and remove (#2903)
* [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
2019-08-28 21:30:27 +00:00
Andy
0626db51bd [now-cli] Change success message after login (#2898)
* [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
2019-08-28 22:41:56 +02:00
Kaito Sugimoto
dc29a8b816 [now-cli] Update now alias warning for --prod (#2902) 2019-08-28 18:27:21 +00:00
Joe Haddad
e00e5e18ea Publish
- @now/build-utils@0.9.14-canary.1
 - now@16.1.3-canary.1
 - @now/next@0.7.1-canary.1
2019-08-28 08:28:56 -04:00
Joe Haddad
d0999e7937 [now-build-utils] Add mutable option for backwards compatibility (#2895) 2019-08-28 05:29:34 +00:00
Joe Haddad
158cfad978 [now-next] Do not add initial files to lambda (#2894) 2019-08-28 02:14:02 +00:00
Andy
9145b43a62 [now alias] Improve alias support (#2787)
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.
2019-08-28 00:47:39 +00:00
Steven
479d271356 Publish
- @now/build-utils@0.9.14-canary.0
 - @now/cgi@0.1.5-canary.0
 - now@16.1.3-canary.0
 - now-client@5.1.1-canary.0
 - @now/go@0.5.11-canary.0
 - @now/next@0.7.1-canary.0
 - @now/node-bridge@1.2.4-canary.0
 - @now/node@0.12.8-canary.0
 - @now/python@0.2.17-canary.0
 - @now/routing-utils@1.2.3-canary.0
 - @now/ruby@0.1.5-canary.0
 - @now/static-build@0.9.9-canary.0
2019-08-27 18:57:46 -04:00
Steven
8119f4cad2 Add GH Actions Publish Workflow (#2891) 2019-08-27 22:35:12 +00:00
Steven
e73b32e9cc [tests] Ignore fixtures in GitHub Languages & fix yarn.lock (#2890) 2019-08-27 17:55:43 +00:00
Sophearak Tha
45bd08e4e5 [now-next] Use debug() from build-utils (#2881)
* [now-next] Use `debug()` from build-utils (#909)

* Use `debug()` from build-utils

* Revert back to warning output

* Remove unnecessary debug check
2019-08-27 15:40:39 +00:00
Sophearak Tha
4528243b5c [now-go] Use debug() from build-utils (#2885)
* [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>
2019-08-27 15:25:31 +00:00
Sophearak Tha
bd741cfbeb [now-ruby] Use debug() from build-utils (#2883) 2019-08-27 15:05:13 +00:00
Sophearak Tha
b3b10f0fd7 [now-node] Use debug() from build-utils (#2880)
* Use `debug()` from build-utils

* Remove condition
2019-08-27 10:36:04 -04:00
Sophearak Tha
084c014fff [now-static-build] Use debug() from build-utils (#2884) 2019-08-27 14:15:11 +00:00
Andy
63614e5303 [now-cli] Validate builds and routes for now dev (#2871)
* [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
2019-08-27 13:29:23 +00:00
Sophearak Tha
099d2c8195 [now-cli] Make sure to have event action as string (#2870) 2019-08-27 13:11:09 +00:00
Sophearak Tha
ae813423d8 [now-python] Use debug() from build-utils (#2882)
* Use `debug()` from build-utils

* Apply suggestions from code review

Co-Authored-By: Steven <steven@ceriously.com>
2019-08-27 09:10:43 -04:00
Nathan Rajlich
2a5f3f779e [now dev] Update yarn to v1.17.3 (#2780)
* [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.
2019-08-26 23:10:06 +00:00
Andy
89e1d83ad4 [now-static-build] Support ejected create-react-app (#2873) 2019-08-26 22:10:31 +00:00
Steven
ce23f9e204 [tests] Fix unit tests & coverage step (#2876)
* Fix unit tests & coverage

* Add missing compile-templates step
2019-08-26 21:17:57 +00:00
Nathan Rajlich
743eb21682 Update links to now-builders repo to now repo (#2862)
* 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.
2019-08-26 15:13:08 -04:00
Steven
b9f5de2b7a [tests] Change run script from bash to node (#2874)
* [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
2019-08-26 17:49:47 +00:00
Steven
229a62d8b6 Create monorepo (#2812)
* 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
2019-08-23 17:00:31 -07:00
Andy Bitz
52a6e60f78 16.1.2-canary.7 2019-08-20 18:58:27 +02:00
Andy
a7cb747130 Use short-form for the update command (#2801)
* Use short-form for the update command

* Adjust test
2019-08-20 18:56:31 +02:00
Andy
918d60576f [now deploy] Fix builds output for failed deployments (#2799)
* [now deploy] Fix builds output for failed deployments

* Add test
2019-08-20 18:13:43 +02:00
Andy
62111977fd [now deploy] Fix --prod flag and adjust message for --target (#2797)
* [now deploy] Fix `--prod` flag and adjust message for `--target`

* Fix tests

* Fix fetch

* Change api version

* Fix url

* Fix test
2019-08-20 17:29:43 +02:00
Andy Bitz
00c05b95e4 16.1.2-canary.6 2019-08-20 00:12:56 +02:00
Andy
9ee83b858c [now deploy] Added --prod flag (#2789)
* [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
2019-08-20 00:12:14 +02:00
Andy Bitz
e4a181321a Revert "Add more alias support (#2747)"
This reverts commit 957fe9084a.
2019-08-19 11:34:42 +02:00
Andy Bitz
dd6f6aa418 16.1.2-canary.5 2019-08-19 09:55:17 +02:00
Andy
b37bfbc1ed Bump @now/build-utils to 0.9.13 (#2784) 2019-08-19 01:21:49 +02:00
Leo Lamprecht
dd06c4c63d 16.1.2-canary.4 2019-08-18 12:01:43 +00:00
Nathan Rajlich
a6174cde03 [now domain] Handle thrown API errors when purchasing domain fails (#2779)
Fixes #2759.
2019-08-16 02:43:30 +00:00
Nathan Rajlich
c85ab97321 Remove a couple unused import (#2777)
Fixes lint
2019-08-15 19:12:59 -07:00
Naoyuki Kanezawa
957fe9084a Add more alias support (#2747)
* add more alias support

* Update src/util/domains/setup-domain.ts

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

* Update src/util/domains/setup-domain.ts

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

* add tests
2019-08-16 00:48:29 +00:00
Nathan Rajlich
70f72e5bb8 Sleep 2 seconds after the now rm integration test (#2776)
Sometimes it fails with a stale 200 status code.
This should make it less flaky.
2019-08-15 16:19:52 -07:00
Nathan Rajlich
4feb961091 16.1.2-canary.3 2019-08-15 11:59:08 -07:00
Nathan Rajlich
6ddc252978 Display rate limit errors message from API response (#2767)
* Display rate limit errors message from API response

Closes #2738.

* Update src/util/handle-error.ts

Co-Authored-By: Steven <steven@ceriously.com>
2019-08-15 07:39:12 +00:00
Naoyuki Kanezawa
5eca7cf5f7 add misssing defaultArgs (#2770) 2019-08-15 11:23:01 +09:00
Nathan Rajlich
76486246c5 Remove leftover console.log() in integration tests (#2768) 2019-08-15 01:17:38 +00:00
Nathan Rajlich
740a7c8886 [now rm] Use the proper client so that the process does not hang (#2762)
* [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`
2019-08-15 00:41:53 +00:00
Nathan Rajlich
40b69b4924 [now scale] Fix default max: auto value in --help output (#2763)
Fixes #2368.
Also related to zeit/docs#838.
2019-08-14 10:07:55 -07:00
Nathan Rajlich
c5ef4b1dc5 Fix "occured" -> "occurred" typos (#2761)
See: https://tinyurl.com/occured
2019-08-13 23:47:48 +00:00
Andy
ef793bf7e9 [now dev] Use canary builders for the canary version (#2753)
* Use canary builders for the canary version

* Use the `getDistTag` function instead

* Fix function call

* Add tests

* Remove unused code

* Remove logging
2019-08-13 19:30:48 +00:00
Nathan Rajlich
2be1dd4fcb Use the correct URL in the auth.json and config.json files (#2755)
Fixes #2754.
2019-08-13 17:40:48 +00:00
Nathan Rajlich
a734eb79d9 [now projects] Add subcommand alias for now project (#2750)
Fixes #2162.
2019-08-13 02:37:03 +00:00
Naoyuki Kanezawa
24dc2a36de remove unused HTTP/HTTPS Agent (#2749) 2019-08-13 11:05:45 +09:00
Naoyuki Kanezawa
12881c1b57 support to set api host for development (#2748) 2019-08-13 09:44:45 +09:00
Nathan Rajlich
c66188a6f2 Update clipboardy to v2.1.0 (#2737)
Fixes #564.

Related to #1924.
2019-08-10 12:15:36 +00:00
Andy
61457b532a Bump @now/build-utils to 0.9.12 (#2736) 2019-08-09 20:35:40 +00:00
Nathan Rajlich
d2ff3749ca [now dev] Remove leftover console.error() call (#2735)
Accidentally added in #2720.
2019-08-09 18:48:34 +00:00
Leo Lamprecht
38bc7cc6d6 [now dev] Add --listen / -l flag, deprecate --port / -p (#2720)
* [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
2019-08-09 11:16:21 -07:00
Arunoda Susiripala
413fdd7c39 Update index.js (#2733) 2019-08-09 16:07:39 +02:00
Leo Lamprecht
f48bb493b0 [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-09 01:05:44 +02:00
Nathan Rajlich
962c5db9fe Update serve-handler to v6.1.1 (#2731)
* Update `serve-handler` to v6.1.1

Fixes #2697.

* Fix unit test
2019-08-08 22:26:02 +00:00
Nathan Rajlich
9e961b479c Print HTTP status code upon API JSON parse errors (#2727)
Fixes #2681.
2019-08-08 20:51:23 +00:00
Nathan Rajlich
718100fafc Add accept: application/json header to API HTTP requests (#2726)
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.
2019-08-08 20:15:29 +00:00
Steven
2b38f545d0 Add automerge config (#2729) 2019-08-07 18:41:51 -07:00
Nathan Rajlich
55b1327119 [CircleCI] Fix test/dev-server.unit.js being run on CI (#2725)
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
2019-08-07 12:17:55 -07:00
wtgtybhertgeghgtwtg
a75ec505ad Remove vestigial mkdirp packages (#2724) 2019-08-07 11:15:50 -07:00
Andy Bitz
36b1e129b4 16.1.2-canary.2 2019-08-07 17:32:01 +02:00
Andy
331b6e0a23 [now deploy] Use the project when checking the platform version (#2722)
* [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
2019-08-07 17:31:02 +02:00
Andy Bitz
fc72ecb223 16.1.2-canary.1 2019-08-07 14:32:04 +02:00
Andy
ca51cbcc6b Fix colored text and remove version warning (#2721) 2019-08-07 14:30:30 +02:00
Andy Bitz
6ce8acc4db 16.0.1-canary.3 2019-08-07 11:57:55 +02:00
Andy
a9edec1619 [now deploy] Change the warning messages when the platform version is changed (#2717)
* [now deploy] Change warning message

* Change text

* Add link to message

* Change text
2019-08-07 11:55:44 +02:00
Leo Lamprecht
8638d17d87 Revert "[now dev] Add --bind / -b flag (#2705)"
This reverts commit efe0ca57f0.
2019-08-07 08:12:50 +00:00
Leo Lamprecht
db6ae2998b Revert "[now update] Show correct global or local install command (#2716)"
This reverts commit d667a83af5.
2019-08-07 08:12:32 +00:00
Andy
d667a83af5 [now update] Show correct global or local install command (#2716)
* [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-06 22:59:07 +02:00
Andy Bitz
f2a1fb50da 16.0.1-canary.2 2019-08-06 20:10:48 +02:00
Andy
eb356a5d3d [now dev] Bump @now/build-utils to 0.9.10 (#2715) 2019-08-06 20:09:27 +02:00
Nathan Rajlich
efe0ca57f0 [now dev] Add --bind / -b flag (#2705)
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.
2019-08-06 14:55:04 +02:00
Andy Bitz
409b7099be 16.0.1-canary.1 2019-08-06 12:51:51 +02:00
Andy
e6653992a7 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-06 12:50:46 +02:00
Nathan Rajlich
c133e81f6e Require Node.js >= 8.11 in "engines" (#2714)
Closes #2711.
2019-08-05 20:14:42 -07:00
Nathan Rajlich
28bfcb4c58 [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-05 19:54:19 -07:00
Nathan Rajlich
5cf8f8a70a Add unhandledRejection and uncaughtException handlers to scripts (#2709)
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.
```
2019-08-05 18:11:43 -07:00
Nathan Rajlich
b31ab033c2 Fix format-modified script (#2708)
Before it was only updating _non-staged_ files.

Now, it updates _all_ modified files, staged or not.
2019-08-05 15:50:04 -07:00
Nathan Rajlich
24a3b99ee3 Upgrade ava to v2.2.0 (#2703)
See: https://twitter.com/sindresorhus/status/1157614353375551493
2019-08-05 14:32:39 -07:00
Andy Bitz
9a6ad1ae43 15.9.0-canary.28 2019-08-05 17:36:13 +02:00
Andy
687ef375c8 [now update] Remove is-installed-globally (#2700)
* [now update] Remove `is-installed-globally`

* Only suggest global

* Adjust test
2019-08-05 17:26:45 +02:00
Andy Bitz
538525e639 15.9.0-canary.27 2019-08-05 15:22:56 +02:00
Andy
aff5a0cbed [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 15:20:02 +02:00
Nathan Rajlich
b1b1529bd6 15.9.0-canary.26 2019-08-02 16:11:34 -07:00
Andy
bb934f0146 Update @now/build-utils to v0.9.8 (#2694)
* Bump `@now/build-utils` to 0.9.7

* Handle 404 status

* Revert "Handle 404 status"

This reverts commit 6aa25097beb96c8d56ab40c91319278da68d5851.

* Render 404 page

* Bump @now/build-utils
2019-08-02 15:59:00 -07:00
Nathan Rajlich
7d2c5dc39a 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-02 12:42:09 -07:00
Nathan Rajlich
9894869427 [now dev] Support JSON and HTML redirect responses (#2690)
* [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
2019-08-02 12:01:55 -07:00
Nathan Rajlich
8e0c1da441 [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-02 11:26:02 -07:00
Andy
6a165e8377 [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-02 20:10:32 +02:00
Nathan Rajlich
eeed5a8273 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-01 17:56:34 -07:00
Nathan Rajlich
75d98c649a [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-01 17:56:06 -07:00
Andy Bitz
d54cc4df51 15.9.0-canary.25 2019-08-01 18:52:26 +02:00
Andy
f211f1fa70 [preinstall] Adjust the error messages (#2682)
* [preinstall] Adjust the error messages

* Remove dot
2019-08-01 18:40:55 +02:00
Nathan Rajlich
f60a373479 [now dev] Use a consistent "pod id" for x-now-id (#2679)
This matches the behavior in production.
2019-07-31 16:31:56 -07:00
Andy
80a82ba276 [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-01 00:14:18 +02:00
Andy
8a3d0fb370 [now dev] Bump @now/build-utils to 0.9.6 (#2672) 2019-07-31 18:22:45 +02:00
Andy Bitz
20c2930a90 15.9.0-canary.24 2019-07-31 16:47:00 +02:00
Andy
bccf602496 [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-07-31 16:01:15 +02:00
dependabot[bot]
ed92ef8952 Bump yarn to v1.17.3 (#2669)
Bumps [yarn](https://github.com/yarnpkg/yarn) from 1.13.0 to 1.17.3.
- [Release notes](https://github.com/yarnpkg/yarn/releases)
- [Changelog](https://github.com/yarnpkg/yarn/blob/v1.17.3/CHANGELOG.md)
- [Commits](https://github.com/yarnpkg/yarn/compare/v1.13.0...v1.17.3)

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-30 22:05:59 -07:00
Andy
1b9c14bd30 [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-07-31 03:03:14 +02:00
Sophearak Tha
c287cbeb22 [now dev] Update NOW_BUILDER_DEBUG base on --debug flag (#2655)
* 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>
2019-07-30 14:56:38 -07:00
Nathan Rajlich
d29b1b9cfa [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-07-30 14:56:00 -07:00
Andy
49293ae44b [now dev] Update outdated dependencies in tests (#2666) 2019-07-30 11:47:38 -07:00
Andy Bitz
39103f5ae6 15.9.0-canary.23 2019-07-30 15:00:03 +02:00
Nathan Rajlich
af2c894fb9 [CircleCI] Add seperate jobs for now dev integration tests (#2662)
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.
2019-07-30 11:25:55 +02:00
Andy Bitz
42f9745420 Revert "Revert "15.9.0-canary.22""
This reverts commit 35c3d87055.
2019-07-30 02:25:01 +02:00
Andy
f016f05c11 [now dev] Fix aurelia test (#2660)
* [now dev] Fix aurelia test

* Enable aurelia test again
2019-07-30 02:22:18 +02:00
Nathan Rajlich
257f5f293e 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-07-29 16:29:15 -07:00
Andy Bitz
35c3d87055 Revert "15.9.0-canary.22"
This reverts commit a78813bd74.
2019-07-30 01:19:44 +02:00
Andy Bitz
a78813bd74 15.9.0-canary.22 2019-07-29 23:02:01 +02:00
Andy
05c2f69523 [now update] Change update notification and remove previous Now CLI installation on preinstall (#2659)
* [now update] Change update notification and remove previous Now CLI installation on `preinstall`

* Use plain js for preinstall script

* Removed unused `rename` import

* Simplified code
2019-07-29 13:22:13 -07:00
Andy
e389a836e1 [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-07-29 21:44:37 +02:00
Nathan Rajlich
64c526fe1d [now dev] Redirect when request has multiple slashes (#2645)
* [now dev] Redirect when request has multiple slashes

Closes #2642.

* Add POST passthrough
2019-07-29 11:19:04 -07:00
Max Chehab
e132d74aa8 [now deploy] Fix variable name typo (#2649) 2019-07-29 10:26:56 -07:00
Andy
975c8dc5fc [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-07-29 19:09:37 +02:00
Sophearak Tha
3d2929b345 [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-07-29 09:44:30 +07:00
Nathan Rajlich
c91e529782 [now dev] Add server: now response header (#2646)
Matches production.
2019-07-26 17:24:04 -07:00
Nathan Rajlich
495ba3bf98 Add information when team/user/args parsing fails to Sentry reports (#2635)
* Add information when team/user/args parsing fails to Sentry reports

This should give us some insight into #2627.

* Add `node` reporting
2019-07-26 16:41:16 -07:00
Nathan Rajlich
c799886f53 [now dev] Remove accidental test.only() (#2644)
This got committed by accident :(
2019-07-26 16:10:30 -07:00
Andy
bcbaad4371 [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-07-25 17:35:50 -07:00
Nathan Rajlich
91c80ca0a9 Remove leftover references to pkg (#2632)
* Remove leftover references to `pkg`

We are no longer compiling `now-cli` with `pkg` so this is dead code.

* Enable source maps
2019-07-25 17:03:21 -07:00
Andy
e7e0ab7d0d [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-07-25 22:04:29 +02:00
Nathan Rajlich
0b6b74938f [now dev] Fix routing catch-all with no slash prefix edge case (#2626)
Fixes #2622.
2019-07-25 11:33:57 -07:00
Andy Bitz
256ca8796f 15.9.0-canary.21 2019-07-25 13:56:20 +02:00
Nathan Rajlich
17c659124b [now deploy] Respect --debug flag for API Client (#2625)
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.
2019-07-24 16:23:37 -07:00
Steven
bcac213114 15.9.0-canary.20 2019-07-24 18:43:07 -04:00
Steven
7f4b2bdc87 [now init] Download /v1 examples without suggestions (#2623) 2019-07-24 18:42:01 -04:00
Nathan Rajlich
94a958f460 [now deploy] Change "Aliases assigned" to "Deployment complete" (#2620)
* [now deploy] Change "Aliases assigned" to "Deployment complete"

Closes #2617.

* Change instances of "Aliased" to "Deployed"
2019-07-24 14:11:31 -07:00
Andy Bitz
7a02249f37 15.9.0-canary.19 2019-07-24 22:55:37 +02:00
Andy
94681f28c6 [now dev] Bump @now/build-utils to 0.9.4 (#2621) 2019-07-24 22:54:41 +02:00
Nathan Rajlich
9fd1cee6f0 [now dev] Fix creating duplicate blocking builds upon bootup (#2618)
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.
2019-07-24 12:39:42 -07:00
Nathan Rajlich
2054bb06f1 [now dev] Remove useless debug() call (#2619)
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.
2019-07-24 12:39:26 -07:00
Sophearak Tha
c0b5a01cae 15.9.0-canary.18 2019-07-24 21:05:10 +07:00
Sophearak Tha
0bbe5f7806 Remove Buffer() deprecation message (#2604)
* Remove `Buffer()` deprecation message

* Switch `micro` back to `9.1.2`
2019-07-24 20:57:55 +07:00
Nathan Rajlich
9e25d8e11c 15.9.0-canary.17 2019-07-23 17:50:44 -07:00
Nathan Rajlich
8623c5201c Add "engines" field to package.json for Node 10 or newer (#2603)
`now-cli` does not work on Node 8 and below because generator
functions are not supported.
2019-07-23 17:50:13 -07:00
Andy
862728f889 Use fs-extra instead of fs.promises to prevent warnings on Node 10 (#2602) 2019-07-23 17:29:37 -07:00
Nathan Rajlich
ad4e20c7e6 [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-07-23 16:16:12 -07:00
Andy Bitz
62d782255a Revert "Disable warnings (#2601)"
This reverts commit 23318d9fc9.
2019-07-24 00:10:52 +02:00
Nathan Rajlich
3f18d24915 [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-23 14:58:19 -07:00
Andy
23318d9fc9 Disable warnings (#2601)
* Disable warnings

* Fix execution bits

* Revert "Fix execution bits"

This reverts commit f054f6695fe015896a5f6aa8354ac61a57b3cf81.

* Revert "Disable warnings"

This reverts commit 9321cea2820857060db7275eda9c94d951908714.

* Add --no-warnings
2019-07-23 23:40:11 +02:00
Nathan Rajlich
c413cc7349 [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-23 11:12:34 -07:00
Andy
f268a1b390 [now update] Don't check for updates on now update (#2599) 2019-07-23 19:56:50 +02:00
Nathan Rajlich
19dd33b037 [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-23 17:31:15 +02:00
Andy Bitz
a29890c8ee 15.9.0-canary.16 2019-07-22 19:33:20 +02:00
Andy
6e3a495914 [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-22 18:34:27 +02:00
Sophearak Tha
e1005deeb3 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-07-22 15:04:51 +02:00
Andy
c61502e24c [now dev] Print Serving all files as static only once (#2590)
* [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
2019-07-22 02:47:09 +02:00
Sophearak Tha
7674a4af4a 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-22 01:48:23 +02:00
Andy
0245a04db9 Handle more errors when deploying (#2589) 2019-07-22 00:31:56 +02:00
Andy
340537bc0b [now dev] Bump @now/build-utils and throw errors (#2588)
* [now dev] Bump `@now/build-utils` and throw errors

* Fix error handling
2019-07-21 21:37:49 +02:00
Steven
c9383b2535 [now init] Add suggestions for old examples (#2584)
* [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
2019-07-19 19:29:02 -04:00
Andy Bitz
eae9f9ed42 15.9.0-canary.15 2019-07-19 22:29:52 +02:00
Mark Glagola
dfa134e8e4 handle no-change domain transfer policy (#2570) 2019-07-19 13:59:11 -05:00
Sophearak Tha
bb7b99bcf9 15.9.0-canary.14 2019-07-19 22:54:44 +07:00
Andy
074e96e117 Fix update command message (#2581)
* Fix update command

* Update src/commands/update.ts

Co-Authored-By: Leo Lamprecht <mindrun@icloud.com>
2019-07-19 22:48:41 +07:00
Andy
0b82c74c58 [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:15:39 +07:00
Andy Bitz
5cc4af257e 15.9.0-canary.13 2019-07-19 14:03:40 +02:00
Andy
1979e2074f [now init] Remove now dev suggestion from now init (#2580) 2019-07-19 14:01:45 +02:00
Andy
e788743f58 [now dev] Remove package.json message (#2576)
* [now dev] Remove package.json message

* Add message that all files are served as static
2019-07-19 11:53:29 +02:00
Sophearak Tha
dae525e56a Remove deprecation message from now alias with args (#2578) 2019-07-19 11:42:32 +02:00
Andy
0e32313395 Fix building indicator jittering (#2577) 2019-07-19 11:22:31 +02:00
Andy Bitz
2ea1b00fda 15.9.0-canary.12 2019-07-19 02:42:03 +02:00
Andy
398b371ded [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 02:40:17 +02:00
Andy Bitz
da89cecaab 15.9.0-canary.11 2019-07-18 15:11:41 +02:00
Matthew Sweeney
e821d28ccd Add hint when example not found (#2572)
* add hint when example not found

* update test

* update test
2019-07-18 13:29:43 +01:00
Andy Bitz
3cd2de7728 15.9.0-canary.10 2019-07-18 12:30:15 +02:00
Andy
8e32c66840 Bump mime-types to 2.1.24 (#2571) 2019-07-18 12:29:54 +02:00
Andy Bitz
7716bb5439 15.9.0-canary.9 2019-07-17 23:45:35 +02:00
Andy
42a8dc14b0 Change now update to display npm or yarn command (#2568)
* Change `now update` to display npm or yarn command

* Use `getUpgradeCommand`
2019-07-17 23:39:16 +02:00
Andy Bitz
97ff4515ae 15.9.0-canary.8 2019-07-17 19:32:07 +02:00
Andy
ad6c04b78d [now dev] Fix builder sorting when use is undefined (#2566)
* [now dev] Fix function sorting when `use` is undefined

* Update type

* Add filter

* Fix build
2019-07-17 17:31:37 +02:00
Andy Bitz
68c1f7163f 15.9.0-canary.7 2019-07-17 14:46:29 +02:00
Andy
b94e8a1563 Fix tests order (#2565) 2019-07-17 14:45:58 +02:00
Andy Bitz
60a5659dff Revert "15.9.0-canary.7"
This reverts commit 06b8ccb672.
2019-07-17 14:34:28 +02:00
Andy Bitz
06b8ccb672 15.9.0-canary.7 2019-07-17 12:04:58 +02:00
Andy
ca06186cfe [now dev] Fix builder sorting (#2563)
* [now dev] Fix builder sorting

* Add tests

* Fix path

* Add sleep

* Revert "Add sleep"

This reverts commit 86f0057808eab50f1c977d19989425d633488e23.

* Revert "Fix path"

This reverts commit 14327b83145c8cb24d5e45ac6e91534a7ef093ec.

* Revert "Add tests"

This reverts commit 76849a7a5ce79b54f102a11f66920dccaabeadb6.
2019-07-17 11:49:32 +02:00
Andy
b5349fe6a5 [now dev] Allow now dev as package.json script (#2559)
* [now dev] Allow `now dev` as package.json script

* Fix absolute path for now dev

* Fix directory issue

* Typo

* Update src/commands/dev/dev.ts

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

* Whitespace

* Make code simpler

* Extend type

* Update errors/now-dev-as-dev-script.md

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

* Update errors/now-dev-as-dev-script.md

Co-Authored-By: Nathan Rajlich <n@n8.io>
2019-07-17 01:31:56 +02:00
Nathan Rajlich
7ac3c75ee8 15.9.0-canary.6 2019-07-16 14:44:46 -07:00
Nathan Rajlich
00437fe3f8 [now dev] Memoize the getNowConfig() promise (#2561)
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.
2019-07-16 14:27:35 -07:00
Nathan Rajlich
930648da13 [now dev] Rename nowJson variables to nowConfig (#2558)
This is only a cosmetic code change, but aligns more nicely with
the new zero-config approach (where there is no `now.json`).
2019-07-16 13:28:18 -07:00
Andy
4945218ea6 [now dev] Bump @now/build-utils to 0.8.8 (#2557) 2019-07-16 20:23:40 +02:00
Andy
12c3987e94 [now dev] Bump @now/build-utils (#2556) 2019-07-16 18:21:09 +02:00
Nathan Rajlich
18cedcb7e6 Update @sentry/node to v5.5.0 (#2542)
Because Sentry gives a big banner saying to update on the error reports.

Related: https://github.com/getsentry/sentry-javascript/blob/master/MIGRATION.md
2019-07-15 17:59:29 -07:00
Nathan Rajlich
925af8066d Update deps of deps in yarn.lock file (#2543)
* 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`
2019-07-15 17:14:23 -07:00
Nathan Rajlich
5f46eb9dd7 [now dev] Wait for updateBuilders() to complete before stop() completes (#2551)
* [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
2019-07-15 16:45:05 -07:00
Andy Bitz
24245bd4bb 15.9.0-canary.5 2019-07-15 16:48:43 +02:00
Andy
005dd24b18 [now dev] Apply the ignore pattern to api files (#2548) 2019-07-15 15:32:05 +02:00
Nathan Rajlich
116ee34a10 15.9.0-canary.4 2019-07-12 13:40:03 -07:00
Nathan Rajlich
81cf441f66 Add builders.tar.gz to pkg "assets" configuration (#2541)
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.
```
2019-07-12 13:39:43 -07:00
Nathan Rajlich
c5a588744a 15.9.0-canary.3 2019-07-12 12:46:00 -07:00
Nathan Rajlich
48c126a911 [now dev] Bundle the most popular core builders into CLI binary with lazy builder updates (#2477)
* [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
2019-07-12 12:33:06 -07:00
Sophearak Tha
18c295a88e 15.9.0-canary.2 2019-07-12 22:25:54 +07:00
Sophearak Tha
893871e043 [now dev] Improve max lambda size error message (#2539)
* Improve max lambda size error message

* Better wording
2019-07-12 22:24:49 +07:00
Andy
f2b1c89a53 Remove files from 15.7.0-canary.17 and 15.7.0-canary.14 (#2537) 2019-07-12 15:39:15 +02:00
Andy Bitz
271d7ffc29 15.9.0-canary.1 2019-07-12 15:13:02 +02:00
Andy
fd99217303 Bump @now/build-utils (#2535) 2019-07-12 14:50:14 +02:00
Max Rovensky
77d07f838f 15.7.0-canary.18 2019-07-12 16:38:06 +07:00
Max
1f81d80505 Disable automatic signup (#2530)
* 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
2019-07-12 15:34:26 +07:00
Sophearak Tha
7e950496ae 15.7.0-canary.17 2019-07-12 13:10:49 +07:00
Sophearak Tha
ec43780e1b Increase default maxLambdaSize (#2534) 2019-07-12 13:07:27 +07:00
Luc
66fe14d8e2 Remove "missing alias in now.json" warning (#2533) 2019-07-11 16:35:10 -07:00
Andy Bitz
a29abc7d45 15.7.0-canary.16 2019-07-11 13:06:54 +02:00
Nathan Rajlich
5d329e0bc3 [now dev] Render directory listing for Now v2 projects (#2528)
* [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
2019-07-10 19:34:16 -07:00
Andy Bitz
2de9edeed4 15.7.0-canary.15 2019-07-10 21:48:18 +02:00
Andy
954d433f6f [now dev] Update @now/build-utils and handle warnings (#2523)
* [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
2019-07-10 18:14:08 +02:00
Nathan Rajlich
b18196b394 15.7.0-canary.14 2019-07-09 18:58:23 -07:00
Nathan Rajlich
926c14e0ef [now dev] Update serve-handler to v6.1.0 and enable etag option (#2525)
* [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
2019-07-09 18:49:38 -07:00
Nathan Rajlich
c2c986e780 Add .gitignore file to test/fixtures/unit/now-dev-default-builds-and-routes (#2524) 2019-07-09 17:50:33 -07:00
Nathan Rajlich
26e87093e1 Add @AndyBitz to now dev CODEOWNERS (#2522) 2019-07-09 14:43:35 -07:00
Nathan Rajlich
ba0323e434 [now dev] Revert "Add etag response header for Lambda invocations" (#2520)
* [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
2019-07-09 14:40:48 -07:00
Nathan Rajlich
55229e1ed7 Add /src/util/dev to CODEOWNERS file (#2521) 2019-07-09 14:37:12 -07:00
Andy
064213ce52 [now dev] Fix @now/static-build sorting (#2519)
* [now dev] Fix @now/static-build sorting

* Change tests

* Update src/util/dev/server.ts

Co-Authored-By: Nathan Rajlich <n@n8.io>
2019-07-09 23:03:37 +02:00
Andy
f0802c681c [now dev] Tests for routing and apply default frontend builder last (#2518) 2019-07-09 20:58:04 +02:00
Sophearak Tha
a6d2ab7d77 15.7.0-canary.13 2019-07-10 00:06:49 +07:00
Sophearak Tha
c5ced92978 [now-dev] Fix flickering and improve message (#2516)
* Fix flickering and improve message

* Pluralize builds

* Properly handle pluralize form
2019-07-10 00:05:40 +07:00
Andy Bitz
7efe32f9c8 15.7.0-canary.12 2019-07-09 18:16:10 +02:00
Andy
60f163d540 [now dev] Allow the default static build without an api (#2515) 2019-07-09 18:15:34 +02:00
Sophearak Tha
f507f28f30 15.7.0-canary.11 2019-07-09 22:11:57 +07:00
Sophearak Tha
54ae7001ec Handle 400 create alias error (#2514) 2019-07-09 22:04:48 +07:00
Sophearak Tha
d044cfe142 Simplify builds output message (#2512)
* Simplify builds output message

* Properly stop the spinner

* Handle stop spinning properly and remove unused import

* Update src/commands/deploy/latest.js

Co-Authored-By: Leo Lamprecht <mindrun@icloud.com>

* Update src/commands/deploy/latest.js

Co-Authored-By: Leo Lamprecht <mindrun@icloud.com>

* Properly handle stop spinning at build failed

* Update build failed message

* Remove unused variable

* Remove punctuation in error message

* Update integration test reflect latest change
2019-07-09 20:22:07 +07:00
Sophearak Tha
3a1c68b439 Improve now dev output message (#2506)
* Improve `now dev` output message

* Update src/util/dev/builder.ts

Co-Authored-By: Leo Lamprecht <mindrun@icloud.com>
2019-07-09 12:32:24 +02:00
Sophearak Tha
e0489dc171 Throw an error if dev scripts contain now dev in package.json (#2507)
* Throw an error if `dev` scripts contain `now dev` in package.json

* Use proper Package type

* Update src/commands/dev/index.ts
2019-07-09 17:10:57 +07:00
Nathan Rajlich
9919701e2d [now dev] Add test case for lazily installing builders (#2510)
This is a follow up for #2509 to add a unit/regression test ensuring
correct functionality.
2019-07-08 17:44:36 -07:00
Andy Bitz
9ed9ba472e 15.7.0-canary.10 2019-07-08 23:05:40 +02:00
Andy
8513ff260b [now dev] Add support for deployments without now.json (#2498)
* [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
2019-07-08 23:04:57 +02:00
Nathan Rajlich
900c2a11f7 [now dev] Set Now response headers when proxy passing in routes (#2500)
* [now dev] Set Now response headers when proxy passing in `routes`

* Fix unit test
2019-07-08 22:02:42 +02:00
Nathan Rajlich
00ffd8d46c [now dev] Install missing builders during runtime (#2509)
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.
2019-07-08 11:33:54 -07:00
Leo Lamprecht
cfc326b1ce 15.7.0-canary.9 2019-07-07 16:10:51 +00:00
Olli Vanhoja
dab4c6bf66 Use v3 user tokens API (#2482) 2019-07-07 15:53:46 +02:00
Nathan Rajlich
e21ece1626 [now dev] Allow cache-control header to be overwritten (#2501)
* [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
2019-07-07 15:43:14 +02:00
Nathan Rajlich
f80f1f79a6 [now dev] Add etag response header for Lambda invocations (#2502)
This matches the behavior in production.
2019-07-07 15:19:54 +02:00
Nathan Rajlich
2414767026 [now dev] Set "must-revalidate" cache-control response header (#2499)
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).
2019-07-06 00:22:38 +02:00
Nathan Rajlich
887b2ccc6b [now update] Add message saying that Windows is not supported (#2493)
* [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>
2019-07-05 13:04:01 -07:00
Sophearak Tha
164d29ccbe 15.7.0-canary.8 2019-07-05 19:31:12 +07:00
Sophearak Tha
4eb46d0436 Bump serve-handler version (#2497) 2019-07-05 19:29:22 +07:00
Nathan Rajlich
e0c6bb4094 [now dev] Move the MissingDotenvVarsError handling to the correct place (#2489)
`validateEnvConfig()` used to be invoked inside of `validateNowConfig()`,
but now it is invoked separately.

Explicitly exiting the process avoids reports going to Sentry.
2019-07-02 11:42:33 -07:00
Steven
3926055a5e 15.7.0-canary.7 2019-07-01 17:55:31 -04:00
Nathan Rajlich
8c00134ad1 [now dev] Use system installed version of Node.js for builds (#2480)
* [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
2019-07-01 17:54:29 -04:00
Andy Bitz
6a104004e0 15.7.0-canary.6 2019-07-01 19:40:41 +02:00
Sophearak Tha
52df58b7dc 15.7.0-canary.5 2019-07-01 21:21:50 +07:00
Sophearak Tha
983d58c5a6 Improve metrics (#2472)
* 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
2019-07-01 21:19:49 +07:00
Nathan Rajlich
ec46e616db Remove mkdirp-promise (#2478)
Use the implemention from `fs-extra` instead.
2019-06-28 17:26:02 -07:00
Nathan Rajlich
3758e57cb8 [now dev] Exit the process upon ERR_SERVER_NOT_RUNNING (#2479)
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).
2019-06-28 17:25:21 -07:00
Mark Glagola
1eaa8f76ea 15.7.0-canary.4 2019-06-28 18:42:10 -05:00
Mark Glagola
8e64d0b5ef More cert error handling for deploy command (#2475)
* 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
2019-06-28 18:28:30 -05:00
Nathan Rajlich
baceee2ecf Update @now/build-utils to v0.7.0 (#2474) 2019-06-28 15:23:55 -07:00
Mark Glagola
a23b7dd2bc Adds --target to arg-common (#2473) 2019-06-28 09:55:43 -05:00
Andy Bitz
0225163353 15.7.0-canary.3 2019-06-28 12:10:34 +02:00
Andy
9dbe89f5aa Change url for revert-alias tests to make it more reliable (#2471)
* Change url for revert-alias tests to make it more reliable

* Use project name from now.json

* Remove unused import in tests
2019-06-28 01:45:52 +02:00
Andy
f89effaa66 Don't verify the user for now dev (#2470) 2019-06-28 00:26:54 +02:00
Andy Bitz
b7e37af8f1 15.7.0-canary.2 2019-06-27 18:32:30 +02:00
Andy
1436e636d3 Don't show warning (#2468) 2019-06-27 18:18:11 +02:00
Andy Bitz
d2c33bbb06 15.7.0-canary.1 2019-06-26 19:28:56 +02:00
Andy Bitz
c5c22620a6 15.6.0-canary.4 2019-06-26 19:02:32 +02:00
Andy
fb7b890e40 Make sure to call secrets API only once (#2464)
* Make sure to call secrets API only once

* Use const
2019-06-26 17:29:35 +02:00
Andy
4e8512e660 Handle deployments rate limit (#2463) 2019-06-26 02:11:30 +02:00
Andy
29de58b5a7 Upgrade esm (#2458)
* Upgrade esm

* Use version 3.1.0

* Use version 3.1.4
2019-06-25 15:04:07 +02:00
Mark Glagola
7a36b9c6a3 15.6.0-canary.3 2019-06-24 13:16:35 -05:00
Mark Glagola
85ba820b27 Handle cert errors in create-deployment (#2455)
* handle cert errors in create-deployment

* Capture challenge_error and txt_record_not_found in mapCertError
2019-06-24 13:02:16 -05:00
Mark Glagola
54ff8ca196 Prompt based DNS add command (#2450)
* Initial prompt based DNS add command

* Adds verify step to dns record prompts

* handle prompt abort
2019-06-24 05:51:59 -05:00
Andy Bitz
9f40a7cca6 15.6.0-canary.2 2019-06-21 18:35:02 +02:00
Andy
9be5970378 now rm improvements (#2449)
* Handle --safe

* Fix  option

* Slice deployments
2019-06-21 18:33:44 +02:00
Andy
2214516689 Handle --safe (#2448)
* Handle --safe

* Fix  option
2019-06-21 17:57:22 +02:00
Andy Bitz
b7f6d4a859 15.6.0-canary.1 2019-06-21 11:31:02 +02:00
Steven
03404e9858 15.4.0-canary.10 2019-06-20 18:11:04 -04:00
Steven
236edcc535 Bump @zeit/fun to 0.9.0 (#2445) 2019-06-20 18:09:06 -04:00
Steven
822b12cc96 [now dev] Improve tests for @now/build-utils@canary (#2444) 2019-06-20 14:38:07 -04:00
Mark Glagola
79d8157798 Move dns_error to generic CertError (#2443) 2019-06-20 09:25:18 -05:00
Mark Glagola
12795f7298 15.4.0-canary.9 2019-06-19 12:35:28 -05:00
Mark Glagola
86f6df6607 Cert error handling revisions/additions (#2437)
* Cert error handling revisions/additions

* Adds certs/add.js back + updated cert error handling to be pipeable

* remove //todo
2019-06-19 12:34:38 -05:00
Steven
b837aca0f8 [now dev] Use canary @now/build-utils or stable based on builders (#2441)
* [now dev] Use canary build utils or stable

* Fix version selection

* Fix test

* Fix typo

* Add tests for getBuildUtils

* Add `latest`
2019-06-18 19:01:16 -04:00
Steven
557ea38869 15.4.0-canary.8 2019-06-18 13:55:55 -04:00
Steven
6a78563b32 Bump @now/build-utils to 0.6.0 (#2440) 2019-06-18 13:49:05 -04:00
Andy Bitz
ec6f71aed9 15.4.0-canary.7 2019-06-18 19:32:09 +02:00
Andy
faccd7fb9e Update help (#2438)
* Update help

* Make whoami advanced

* Make init basic

* Moved update down
2019-06-18 19:19:58 +02:00
Andy Bitz
796bc0acee 15.4.0-canary.6 2019-06-17 23:29:46 +02:00
Andy
ae2638f7a9 Update now rm (#2412)
* 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
2019-06-17 23:28:16 +02:00
Nathan Rajlich
51b7716cc7 [now update] Handle permissions errors in the file replacement method (#2430)
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
2019-06-17 13:51:51 -07:00
Nathan Rajlich
c368f98ded 15.4.0-canary.5 2019-06-12 11:09:50 -07:00
Nathan Rajlich
5f1e77cd67 [now dev] Move helper modules to src/util/dev (#2422)
This organization is consistent with how other commands are structured.
2019-06-10 15:41:26 -07:00
Nathan Rajlich
a5b4f0bd87 Lowercase the x-forwarded-* and x-real-ip headers (#2420)
Fixes #2238.
2019-06-10 14:21:53 -07:00
Nathan Rajlich
aab2acf008 [now dev] Run prettier (#2419)
Run `prettier` on the `now dev` codebase since the formatting has
gotten out-of-sync over time.

Also removes a stale TODO comment.
2019-06-10 14:07:02 -07:00
Nathan Rajlich
d740df9600 [now dev] Show a warning when now.json contains a syntax error (#2418)
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.
2019-06-10 13:17:23 -07:00
Nathan Rajlich
cb464939a0 15.4.0-canary.4 2019-06-10 11:50:48 -07:00
Nathan Rajlich
0f2b35175c [now dev] Implement continue: true routes (#2413)
* [now dev] Implement `continue: true` routes

Fixes #2088.

* Add `continue: true` unit test

* Add a `continue: true` unit test that matches
2019-06-10 11:38:22 -07:00
JJ Kasper
33fe99ea43 15.4.0-canary.3 2019-06-08 14:02:45 -07:00
Nathan Rajlich
22344045b8 Add whoami command back (#2411)
* Add `whoami` command back

It was accidentally removed.

Fixes #2410.

* Add `whoami` regression test
2019-06-07 15:14:14 -07:00
JJ Kasper
a81ed47ebc [now-dev] Add checking of RegExp src with beginning slash (#2398)
* Add checking of RegExp src with beginning slash

* Move slash no slash check to same line

* Add unit test for dev-router
2019-06-07 12:40:04 -07:00
Nathan Rajlich
9d247a4fb6 15.4.0-canary.2 2019-06-05 14:55:30 -07:00
Luc
33f6db1daf [now update] Add integration test (#2405)
* add simple integration to test `now update`

* remove `.only`

* verify that `now --version` includes `canary`
2019-06-05 23:46:03 +02:00
Nathan Rajlich
cf7e0e14f5 [now update] No login required (#2406) 2019-06-05 14:12:11 -07:00
Andy Bitz
88a896684f 15.4.0-canary.1 2019-06-05 19:08:51 +02:00
Andy Bitz
55f5aa5b79 15.2.1-canary.7 2019-06-05 14:14:25 +02:00
Andy
a4be2eb79d Fix now rm and decrease total projects for now ls (#2404)
* 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
2019-06-05 14:13:38 +02:00
Andy Bitz
81c7705690 15.2.1-canary.6 2019-06-05 02:45:24 +02:00
Nathan Rajlich
4dda34fe28 Add now update command (#2388)
* Add `now update` command

Updates the `now` binary in-place.

* Tweaks

* Remove `.ts` suffix in `import` statement

* Remove unused imports

* Implement `getPlatform()`

* Add `ETXTBSY` error fallback method

* Remove `StreamError` import

* Add `chown()` logic

* Remove `console.error()`

* Add `now update` to --help

* Add beta message with feedback URL

* Deprecate `now upgrade` and `now downgrade` commands

* Mention `now upgrade` when a new version is available

* Add `now update` message to `now upgrade`

* Final tweaks
2019-06-05 02:43:43 +02:00
Andy
5a05f6896f Use the projects API for now ls (#2403)
* Use the projects API for `now ls`

* Use recentDeployments
2019-06-05 01:20:14 +02:00
Mark Glagola
e8f7158d52 15.2.1-canary.5 2019-06-04 15:39:04 -05:00
Mark Glagola
fa10b78b30 Handle transfer-in registration_failed (#2402) 2019-06-04 13:08:49 -05:00
Mark
b9be120b17 Update @zeit/ncc to v0.18.5 (#2389) 2019-05-29 17:19:50 -07:00
Nathan Rajlich
4020eb1254 Update @zeit/fun to v0.8.1 (#2391) 2019-05-29 11:16:32 -07:00
Nathan Rajlich
15178f0332 15.2.1-canary.4 2019-05-27 12:54:03 -07:00
Nathan Rajlich
04c11e266a [now dev] Strip prefixed / when doing routes matching (#2361)
* [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
2019-05-27 12:16:57 -07:00
Steven
7bd40f0aae [now-init] Check for dir existence prior to download (#2379) 2019-05-25 13:53:10 -04:00
Nathan Rajlich
ca17c6da36 [now dev] Use empty string for missing matches (#2376)
Rather than `undefined`. This matches the behavior in production.

Fixes #2375.
2019-05-22 13:04:03 -07:00
Sophearak Tha
16b99a6f72 Mimic browser user agent (#2372) 2019-05-22 09:37:39 +07:00
Sophearak Tha
88a4f52ccd 15.2.1-canary.3 2019-05-20 17:46:46 +07:00
Sophearak Tha
e975ddca8b Add .now ignore by default (#2365) 2019-05-20 17:44:07 +07:00
Leo Lamprecht
225afafe43 15.2.1-canary.2 2019-05-17 18:45:04 +00:00
Andy
1bafb4686f Increase the time we wait for the aliasing (#2360) 2019-05-17 20:43:25 +02:00
Sophearak Tha
2777ec3e2c Integrate universal metrics (#2346)
* 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
2019-05-17 19:15:56 +02:00
Samuel Hapák
6f817971d0 Help users to deal with secrets starting with dash (#2253)
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/749
https://github.com/zeit/now-cli/issues/80
2019-05-17 18:42:42 +02:00
Nathan Rajlich
9358b01cac [now dev] Create yarn.cmd file on Windows (#2358)
The `yarn.cmd` file is necessary for `yarn` to be executable
when running `now dev` through cmd.exe
2019-05-17 18:41:02 +02:00
Nathan Rajlich
a8f8da9906 15.2.1-canary.1 2019-05-16 10:49:33 -07:00
Nathan Rajlich
b2d8550777 [now dev] Use chokidar for file watching (#2350)
* [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
2019-05-16 10:40:09 -07:00
Nathan Rajlich
51b6031eab [now dev] Consider devDependencies when looking up package name (#2352)
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.
2019-05-15 17:47:56 -07:00
Nathan Rajlich
370961e872 15.2.1-canary.0 2019-05-13 12:51:07 -07:00
Nathan Rajlich
43e2970620 15.1.1-canary.4 2019-05-10 20:05:15 -07:00
Nathan Rajlich
385c4e4a2f [now dev] Use the dev server cwd as builder's workPath (#2326)
* [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
2019-05-10 17:13:51 -07:00
Nathan Rajlich
39591b4776 Re-enable "try to create a builds deployments with wrong config" integration test (#2337)
It was temporarily disabled due to server-side issues, but that has been
fixed now.
2019-05-10 11:08:39 -07:00
Mark Glagola
2f0218aaa5 Fix transfer in price for some TLDs (#2334) 2019-05-10 07:54:58 -05:00
Nathan Rajlich
9ed897c6be [now dev] Mix in routes query params when proxying to a URL (#2330)
* [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"
2019-05-10 13:09:28 +02:00
Nathan Rajlich
b53d907b74 Adjust now init and now dev to not require a login token (#2325)
* 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.
2019-05-07 15:56:08 -07:00
Nathan Rajlich
7aa2a27fc9 15.1.1-canary.3 2019-05-06 16:39:44 -07:00
Nathan Rajlich
742be77cfb [now dev] Inherit env vars from now.json (#2321)
* [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
2019-05-06 14:38:11 -07:00
Andy Bitz
44946520ef 15.1.1-canary.2 2019-05-06 21:59:43 +02:00
Andy
35d45f7493 Fix Git Bash and make update/uninstall work on Windows (#2322)
* Update index.js

* Fix bash file
2019-05-06 21:58:11 +02:00
Nathan Rajlich
a6fa395822 [now dev] Add meta.env and meta.buildEnv for builders (#2320)
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.
2019-05-06 11:06:38 -07:00
Leo Lamprecht
48ff96d9e7 15.1.1-canary.1 2019-05-06 12:03:36 +00:00
Spellar Bot
53e0f89311 Fix a few typos in err.sh pages (#2311) 2019-05-03 17:17:44 -07:00
Timothy
871a89bf50 Update missing-env-file.md (#2281)
* Update missing-env-file.md

* Update missing-env-file.md
2019-05-03 17:17:34 -07:00
Nathan Rajlich
648fb6f949 15.0.11-canary.3 2019-05-03 10:37:35 -07:00
Steven
709fd1bf12 Update Readme with now dev workflow (#2308) 2019-05-03 10:18:40 -07:00
Nathan Rajlich
cf51fdb026 [now dev] Implement methods in routes config (#2306)
Fixes #2148.
2019-05-03 14:21:26 +02:00
Nathan Rajlich
1e8a825e94 [now dev] Send all status codes if routes config contains one (#2307)
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.
2019-05-03 14:20:33 +02:00
Nathan Rajlich
2ab71798de 15.0.11-canary.2 2019-05-02 12:26:18 -07:00
Matthew Sweeney
683de6048e [now init] Add line breaks to success message (#2285)
* add line break to success message

* change to using original util

* Update src/commands/init/init.ts

Co-Authored-By: msweeneydev <26944716+msweeneydev@users.noreply.github.com>
2019-05-02 12:06:40 -07:00
Nathan Rajlich
49e619ce11 [now dev] Update @zeit/fun and @now/build-utils for Windows (#2302)
Not all builders will be working yet, but this adds minimal Windows
support for `now dev`.
2019-05-02 13:21:01 +02:00
Nathan Rajlich
fc5c8dd74f Convert the build script to Node.js (#2301)
Because, you know, Windows.
2019-05-02 00:11:07 -07:00
Nathan Rajlich
fb46cc7761 [now dev] Show build logs if a build fails during bootup (#2297)
* [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.
2019-05-01 23:43:07 -07:00
Nathan Rajlich
332867a9f5 [now dev] Set NOW_REGION: 'dev1' env on the builder processes (#2298) 2019-05-01 13:02:23 -07:00
Steven
dfea510e68 Add .next and .cache to default ignore (#2295) 2019-05-01 14:21:02 -04:00
Nathan Rajlich
baff58eecc Update pkg to v4.3.8 (#2293)
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`.
2019-05-01 10:01:59 -07:00
Steven
0db933b6a3 Create CODE_OF_CONDUCT.md (#2290) 2019-05-01 09:38:57 -04:00
Nathan Rajlich
4552ad9b36 [now dev] Use consistent cache directory for nsfw module download (#2280) 2019-04-30 10:08:21 -07:00
Shuying
78a04905f1 Update feedback url (#2278) 2019-04-30 18:49:26 +02:00
Nathan Rajlich
3caa922e76 [now dev] Convert path backslashes to forward slashes for Windows (#2279) 2019-04-30 09:48:12 -07:00
Leo Lamprecht
24572b554b 15.0.11-canary.1 2019-04-30 10:11:51 +00:00
Nathan Rajlich
35109800d5 [now dev] Enable cleanUrls option when deployment is all static (#2277)
So that rendering `index.html` as root works as expected.
2019-04-30 11:17:24 +02:00
Nathan Rajlich
1c009266cc 15.0.10-canary.2 2019-04-29 20:14:50 -07:00
Nathan Rajlich
5ec45459e5 [now dev] Install builders with yarn instead of npm (#2272)
* [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>
2019-04-29 19:57:57 -07:00
Steven
37964c1e0f [now dev] Install yarn into builder cache (#2270)
Closes #2063.
2019-04-29 17:44:14 -07:00
Nathan Rajlich
ea8add7316 Update CODEOWNERS for dev, certs and domains commands (#2275)
* Update CODEOWNERS for `dev` command

Also added a fallback for @leo

* Remove `init`, add `domains` and `certs`
2019-04-29 16:38:00 -07:00
Nathan Rajlich
baed2da509 [now dev] Show build timestamps (#2273)
* [now dev] Show build timestamps

Except when running the initial builds

* Fix bad logic
2019-04-29 15:05:10 -07:00
Steven
7be66960b7 [now-dev] Fix .nowignore to match production (#2233)
* Fix now dev usage of .nowignore

* Fix now dev usage of .nowignore

* Move env before nowjson

* Remove console.log()

* Remove comments & unused imports

* Fix merge conflicts

* Fix merge conflicts

* Add docs

* Fix stat mode
2019-04-29 17:35:19 -04:00
Nathan Rajlich
ab6f72e44d [now dev] Don't render initial builds spinner when debug is enabled (#2271) 2019-04-29 13:58:22 -07:00
Leo Lamprecht
251083bf38 15.0.10-canary.1 2019-04-29 18:19:30 +00:00
Leo Lamprecht
6426b1e430 Revert "Enable cleanUrls for entirely static projects (#2268)"
This reverts commit c7ed5d7850.
2019-04-29 18:19:07 +00:00
Nathan Rajlich
635b20d4ab [now dev] Show builder logs, even after build completes (#2269)
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.
2019-04-29 18:41:01 +02:00
Leo Lamprecht
f38669576a 15.0.9-canary.3 2019-04-29 14:05:32 +00:00
Leo Lamprecht
c7ed5d7850 Enable cleanUrls for entirely static projects (#2268) 2019-04-29 15:25:33 +02:00
Leo Lamprecht
67a918401c Correctly log when setting up Builders (#2267)
* Correctly log when setting up Builders

* Added message about beta
2019-04-29 14:33:23 +02:00
Leo Lamprecht
08f0e02f42 Do not print installing builders for no builds (#2266)
* Do not print installing builders for no builds

* Added unit test
2019-04-29 13:46:18 +02:00
Andy
0748cb7698 Display handle in now inspect (#2265) 2019-04-29 11:47:12 +02:00
Leo Lamprecht
76c9a233b9 15.0.9-canary.2 2019-04-28 21:11:32 +00:00
Leo Lamprecht
b3f584686b Make the message for when the server is running shorter (#2262) 2019-04-28 23:01:24 +02:00
Leo Lamprecht
18f06fde2a Fixed error for .env and .env.build (#2261)
* 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>
2019-04-28 21:45:35 +02:00
Nathan Rajlich
c13545d585 [now dev] Refactor builders installation logic (#2254)
* [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()`
2019-04-28 12:38:08 -07:00
Matthew Sweeney
112497d55e Adds 'to develop' to now init (#2260)
Adds 'to develop' to now init
2019-04-28 18:58:32 +02:00
Amio
91069f6d38 [now dev] fix directory listing (#2256) 2019-04-28 17:50:23 +02:00
Andy
2cf846ead3 Wait for aliases in tests (#2257) 2019-04-28 17:35:50 +02:00
Leo Lamprecht
310e1b4247 Revert "Add a logout test case" (#2258)
This reverts commit 5754360684c1e34b0351fadd9e2a6e5ef4b8b82f.
2019-04-28 17:22:52 +02:00
Olli Vanhoja
2f12b08616 Use the single request logout endpoint (#2201)
Logout by deleting the currently used auth token.
2019-04-28 10:58:56 +02:00
Nathan Rajlich
744ef92faa [now dev] Don't render building/built logging for @now/static
Since it's a built-in builder.
2019-04-27 18:55:14 -07:00
Leo Lamprecht
aa8d77e571 15.0.9-canary.1 2019-04-27 14:11:26 +00:00
Steven
6f8c9fe548 Add python virtual environment to default ignore (#2241) 2019-04-27 14:11:11 +00:00
Leo Lamprecht
b6ded9a7fe Do not check for @now/static Builder updates (#2251) 2019-04-27 16:10:31 +02:00
Leo Lamprecht
468fa88139 Print missing line when stopping server (#2250) 2019-04-27 15:49:33 +02:00
Leo Lamprecht
1aa46713c2 Only print stopping server if already printed URL (#2249) 2019-04-27 15:40:44 +02:00
JJ Kasper
9029a51707 Update to make sure query isn't stripped (#2246)
* Update to make sure query isn't stripped
before ProxyPass in dev-server

* Add test for stripping query

* normalize semis in test
2019-04-27 14:23:11 +02:00
Nathan Rajlich
6df363e2da [now dev] Better logging while building and error recovery (#2244)
- 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
2019-04-27 13:23:45 +02:00
Amio
36f5b265c8 Refine dev log layout (#2245) 2019-04-27 13:13:33 +02:00
Nathan Rajlich
929ea187ce [now dev] Lazily initialize the nodejs8.10 runtime for builds (#2243) 2019-04-26 22:23:43 +02:00
Leo Lamprecht
822f203f5a Bumped @zeit/nsfw to latest (#2242) 2019-04-26 22:20:15 +02:00
Leo Lamprecht
54d02b6ab2 Support Windows when downloading file watcher (#2240) 2019-04-26 21:59:06 +02:00
Andy
f9919fe854 Modify the gitbash file correctly (#2223) 2019-04-26 21:46:12 +02:00
Amio
73de0f228a [now dev] exit on MissingDotenvVarsError (#2237) 2019-04-26 20:09:06 +08:00
Steven
9d73f7735e Convert get-files from JS to TS (#2207)
* Convert get-files from JS to TS

* Bump @zeit/dockerignore to 0.0.5

* Fix types

* Fix typo

* Remove arr-flatten dependency
2019-04-25 16:47:21 -04:00
Leo Lamprecht
a0209f4667 15.0.8-canary.1 2019-04-25 19:29:01 +00:00
Nathan Rajlich
60b36cb3f8 [now dev] Supply empty default now.json if one does not exist (#2231)
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.
2019-04-25 11:56:20 -07:00
Nathan Rajlich
454ce02565 [now dev] Force @now/static to run in-memory (#2230)
* [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
2019-04-25 11:13:14 -07:00
Leo Lamprecht
048434a564 15.0.7-canary.8 2019-04-25 14:29:38 +00:00
Nathan Rajlich
0334b75cfa [now dev] Invoke builders in a forked child process (#2227)
* 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
2019-04-25 16:28:58 +02:00
Nathan Rajlich
ce0ed935c8 [now dev] Always watch the entrypoint for triggering rebuilds (#2226)
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.
2019-04-24 13:49:50 -07:00
Leo Lamprecht
ad89a63091 15.0.7-canary.7 2019-04-24 18:54:02 +00:00
Nathan Rajlich
d148edcb67 [now dev] Don't include a file in both filesChanged and filesRemoved list (#2225)
* [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
2019-04-24 20:53:29 +02:00
Leo Lamprecht
36d2e29954 15.0.7-canary.6 2019-04-24 17:05:42 +00:00
Leo Lamprecht
76d3643e0f Bumped @now/build-utils to latest version (#2220) 2019-04-24 19:05:07 +02:00
Leo Lamprecht
a12e228cc4 15.0.7-canary.5 2019-04-24 12:21:56 +00:00
Amio
669ee6a65f [now-dev] Exit when incorrect cwd config (#2218)
* [now-dev] Exit when incorrect cwd config

* better wording
2019-04-24 13:25:20 +02:00
Nathan Rajlich
a7f734fadf [now dev] Use minimatch on the watch array to support globs (#2216)
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), '**/*') ]
```
2019-04-24 10:21:43 +08:00
Nathan Rajlich
8405c2d6cd [now dev] Allow a builder watch array to contain "./" prefixed paths (#2217)
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.
2019-04-23 19:17:02 -07:00
Leo Lamprecht
10316c871b 15.0.7-canary.4 2019-04-23 19:06:55 +00:00
Nathan Rajlich
3b94b105fe [now dev] Add xfwd option to http-proxy (#2215)
This makes the `http-proxy` module set the `X-Forwarded-*` HTTP request
headers to the destination endpoint.
2019-04-23 11:21:41 -07:00
Nathan Rajlich
d7abf96414 [now dev] Pass in the builder-specific workPath to shouldServe() (#2214)
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.
2019-04-23 10:49:53 -07:00
Steven
2c4d9d5af0 Ignore __pycache__ directories (#2213) 2019-04-23 11:38:12 -04:00
Mark
e14ddc11ee Update @zeit/ncc to v0.18.1 (#2210) 2019-04-23 17:31:17 +02:00
Leo Lamprecht
11eb122ecc 15.0.7-canary.3 2019-04-23 12:05:47 +00:00
Nathan Rajlich
40be8ef688 [now dev] Remove requiresInitialBuild and make shouldServe() optional for v2 Builders (#2209)
* [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)
2019-04-23 13:14:19 +02:00
Amio
d7a72a92f2 Support env NOW_BUILDER_CACHE_DIR for debugging builders (#2212)
* Support env NOW_BUILDER_CACHE_DIR for debugging builders

* resolve NOW_BUILDER_CACHE_DIR
2019-04-23 15:25:05 +08:00
Nathan Rajlich
6338809487 [now dev] Resolve built routes after matching builder (#2208)
* [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.
2019-04-22 15:39:25 -07:00
Leo Lamprecht
68408df4d6 Initial build should set requestPath to null (#2200)
* Initial build should set `requestPath` to `null`

* Fixed types

* Fixed type
2019-04-22 20:29:49 +02:00
Nathan Rajlich
7266a97b54 [now dev] Fix typo in debug log (#2206)
Also switch to present-tense wording.
2019-04-22 10:28:08 -07:00
Amio
808038160f [now-dev] make routes from v2 builders optional (#2204) 2019-04-22 15:49:41 +08:00
Leo Lamprecht
994b01719e Better name for continuous property (#2199) 2019-04-21 20:29:47 +02:00
Leo Lamprecht
6e6330bf07 Prevent exit if client closes proxy connection (#2198) 2019-04-21 18:46:57 +02:00
Leo Lamprecht
f8b4958986 15.0.7-canary.2 2019-04-20 00:19:11 +00:00
Leo Lamprecht
b7530d494c Match only the important part while routing (#2195) 2019-04-20 02:19:00 +02:00
Leo Lamprecht
e6aed4bd71 15.0.7-canary.1 2019-04-19 22:11:09 +00:00
Amio
57d6723adb Made sure support for routes works as expected (#2194)
* Fix lost concat result

* Made it work

* Fixed several tests

* Fixed more tests

* Fixed tests
2019-04-20 00:09:00 +02:00
Amio
c0ee3f071e Added support for routes (#2191)
* Add types for updated builder v2 api

* Fix type errors

* outputs => output

* Combine builder routes before routing

* Combine builder routes for all v2 builders

* [temporarily] reveal logs from builder

* Revert "[temporarily] reveal logs from builder"

This reverts commit 9dac764f33d96b5fd004e0839b41228786f83d14.
2019-04-19 16:28:39 +02:00
Amio
54cfe2e99e Reveal builder logs when --debug (#2193)
And added a `debug` flag to `DevServer` class
2019-04-19 21:57:01 +08:00
Andy Bitz
25f6cb7522 15.0.5-canary.5 2019-04-18 15:08:24 +02:00
Andy
0a69920b3f Show all aliases instead of just the first one (#2188) 2019-04-18 15:06:35 +02:00
Andy
adad86401f Now CLI gets a fixed alias (#2189) 2019-04-18 14:56:09 +02:00
Nathan Rajlich
6b3a5880b1 [now dev] Reuse the same workPath for subsequent builds (#2185)
* [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
2019-04-18 11:57:23 +02:00
Nathan Rajlich
de4e340338 [now dev] Don't trigger a rebuild if an asset was deleted (#2184)
* [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
2019-04-17 21:25:08 -07:00
Andy Bitz
c10519acc2 15.0.5-canary.4 2019-04-17 23:36:33 +02:00
Andy
dfb4e8921a Show a upgrade message if the build limit is exceeded (#2182)
* 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>
2019-04-17 23:34:00 +02:00
Andy Bitz
6e51e5db30 15.0.5-canary.3 2019-04-17 20:32:14 +02:00
Andy
7a9e12affa Show the domain purchase UI (#2168)
* Show the domain purchase UI

* Show the correct error message

* Exit after the domain purchase
2019-04-17 20:27:54 +02:00
Andy
011d41af57 Add tests for the new automatic aliasing in the v9 API (#2180)
* Add tests for the new automatic aliasing in the v9 API

* Show a more descriptive message

* Await sleep

* Add sleep to test

* Decrease sleep
2019-04-17 19:27:07 +02:00
Amio
469e8c0505 Add some debug logs for now-dev (#2181)
* Add some debug logs

* Fix eslint warnings
2019-04-17 18:06:21 +02:00
Duncan
d59bc07b89 Fix batch file command to work from paths with spaces. (#2144)
Fixes #2413.
2019-04-17 10:56:42 +02:00
Nathan Rajlich
e7d101c37e [now dev] Handle filesystem events where the file has already been deleted (#2179)
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.
2019-04-16 21:22:42 -07:00
Andy Bitz
b0f83bd1a0 15.0.5-canary.2 2019-04-17 01:25:30 +02:00
Andy
9016f25504 Bump @zeit/nsfw to 2.0.2 (#2178) 2019-04-17 01:09:08 +02:00
Andy
02134807d8 Use the v9 deployments API (#2176) 2019-04-17 00:39:41 +02:00
Nathan Rajlich
fb4da34562 [now dev] Default the Content-Type to "application/octet-stream" (#2177)
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.
2019-04-17 00:14:47 +02:00
Leo Lamprecht
0da322560c 15.0.5-canary.1 2019-04-16 19:51:14 +00:00
William Li
4aece1395e [BUG-FIX] team invite ignored scope error (#2140)
* expose teams command to --scope change, fixes #2139
2019-04-16 19:51:00 +00:00
Leo Lamprecht
cc06b39905 15.0.4-canary.8 2019-04-16 19:09:17 +00:00
Amio
de9eebdf76 Mute install logs from @now/node builder (#2171)
* [wip] Mute install logs from @now/node builder

* Bumped build utils
2019-04-16 21:07:40 +02:00
Nathan Rajlich
db1af88681 Pass filesChanges and filesRemoved array to builder's build() (#2174)
This will be required to implement the `@now/node` ncc watcher logic.
2019-04-16 20:24:45 +02:00
Nathan Rajlich
7979110f2b Added file watcher to now dev (#2153)
* [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
2019-04-16 20:13:15 +02:00
Amio
9a81b5a598 Enable '@typescript-eslint/no-unused-vars': 'warn' (#2172)
* Enable '@typescript-eslint/no-unused-vars': 'warn'

* Clean comments
2019-04-16 20:07:37 +02:00
Nathan Rajlich
23d44347ac Enable source maps for development builds of now-cli (#2170)
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.
2019-04-15 18:27:59 -07:00
Ana Trajkovska
6f2526a75a 15.0.4-canary.7 2019-04-15 22:54:42 +02:00
Ana Trajkovska
2bd4341c07 Handle additional errors when issuing a certificate (#2165)
* Handle additional errors when issuing a certificate

* Rename errors

* Provide more context in CertsDNSError

* Fix CertsDNSError structure

* Display cns with join

* Fix CertsDNSError
2019-04-15 22:47:42 +02:00
Nathan Rajlich
2f3581fe1c [now dev] Add host property to the invoke payload (#2164)
Fixes https://github.com/zeit/now-builders/issues/390.
2019-04-14 15:40:07 -07:00
Nathan Rajlich
6ddb7246d8 [now dev] Use empty version string for @now/static (#2159)
This is just a cosmetic fix so that "vbuilt-in" isn't printed when
`--debug` is enabled.
2019-04-13 14:19:25 -07:00
Nathan Rajlich
ce2773491a 15.0.4-canary.6 2019-04-12 16:16:46 -07:00
Nathan Rajlich
614b9c412a [now dev] Don't run every build when a v1 builder is detected (#2151)
Before this, if a v1 builder was detected then every build match was
built instead of only the matches that use a v1 builder.
2019-04-12 12:00:51 -07:00
Nathan Rajlich
2dfd4e84e1 [now dev] Fix index-based asset lookup logic (#2138)
There was a bug in the index lookup logic such that `GET /404` would be
matching the `/index.*` file. Fixed in this commit.
2019-04-11 18:50:54 -07:00
Leo Lamprecht
0f74a0695c 15.0.4-canary.5 2019-04-11 11:10:37 +00:00
Nathan Rajlich
e85c416d01 [now dev] Refactor to support shouldServe() in Now Builders (#2134)
* 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>
2019-04-11 13:10:27 +02:00
Leo Lamprecht
6ac63baaa5 15.0.4-canary.4 2019-04-11 10:52:41 +00:00
Amio
96c630b27c Improve eslint config (#2042)
- 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.
2019-04-11 17:29:54 +08:00
Mark Glagola
ff353a264e Handle CAA cert conflict error (#2121)
* Handle CAA cert conflict error

* Fixed error description

* using output.success instead of console.log(...)

* Revert "using output.success instead of console.log(...)"

This reverts commit 2db9a834f3d22ec2da7c692b0e67ea2863078489.
2019-04-10 15:37:59 -05:00
Leo Lamprecht
45097563f0 15.0.4-canary.3 2019-04-10 20:24:31 +00:00
Leo Lamprecht
12370a8033 Add a note about the CDN always being enabled (#2133)
* 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
2019-04-10 22:24:14 +02:00
Leo Lamprecht
d1c67b013b 15.0.4-canary.2 2019-04-10 20:02:03 +00:00
Leo Lamprecht
3dda3e84bf Stop indicating whether CDN is enabled (#2132) 2019-04-10 20:47:42 +02:00
Leo Lamprecht
a1a85732d4 15.0.4-canary.1 2019-04-10 17:20:35 +00:00
Leo Lamprecht
bc4a2c8dce Print full validation error message (#2131)
* Print full validation error message

* Shortened second message

* Updated latest pipeline too
2019-04-10 19:19:40 +02:00
Mark Glagola
f22c288bf4 fixes certs rate limited cns arg (#2130) 2019-04-10 11:27:48 -05:00
Amio
37a63e1c70 Bump ava to 1.4.1 (#2128) 2019-04-10 23:55:12 +08:00
Mark Glagola
0c50c5a1a6 15.0.3-canary.6 2019-04-10 10:50:26 -05:00
Mark Glagola
f2c487162f Handle unsupported tld purchase (#2129) 2019-04-10 10:50:10 -05:00
Nathan Rajlich
430696f486 [now dev] Add logging of the builder package versions (#2125)
* [now dev] Add logging of the builder package versions

To aid in debugging errors reported by users.

* Remove bad
2019-04-09 18:50:11 -07:00
Mark Glagola
2426547762 15.0.3-canary.5 2019-04-09 17:21:11 -05:00
Mark Glagola
e877467a98 Fix getCertsById + handle cert not found by id error (#2101)
* fix certs delete + handle not found error

* Converted rm.js -> rm.ts
2019-04-09 17:17:57 -05:00
Nathan Rajlich
060c3de74e [now dev] Add build de-duping for the lazy initial builds case (#2124)
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.
2019-04-09 10:07:56 -07:00
Nathan Rajlich
4c297d2ab4 15.0.3-canary.4 2019-04-07 21:59:44 -07:00
Nathan Rajlich
53ccc9e02b [now dev] Update @now/build-utils to v0.4.40 (#2119) 2019-04-07 21:50:45 -07:00
Nathan Rajlich
477b30583e [now dev] Update @now/build-utils to v0.4.40-canary.0 (#2118) 2019-04-07 19:58:35 -07:00
Nathan Rajlich
315bbbe25e 15.0.3-canary.3 2019-04-07 15:18:16 -07:00
Nathan Rajlich
62cc84fc9a [now dev] Add handle: filesystem support (#2116) 2019-04-07 15:17:54 -07:00
Nathan Rajlich
e28bf1152c [now dev] Run npm update to get builder updates (#2117) 2019-04-07 15:13:21 -07:00
Leo Lamprecht
9519b3b0e7 15.0.3-canary.2 2019-04-07 13:49:10 +00:00
Mark
b7462211e6 Update @zeit/ncc to v0.17.4 (#2107) 2019-04-07 15:47:56 +02:00
Nathan Rajlich
13d447a81b [now dev] Run prepareCache() asynchronous (#2105)
* [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
2019-04-07 15:47:40 +02:00
Nathan Rajlich
049d6e61df [now dev] Invoke prepareCache() from Builders (#2104)
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.
2019-04-05 20:26:44 -07:00
Andy Bitz
482aba0c45 15.0.3-canary.1 2019-04-05 23:57:37 +02:00
Andy
f9a931dbd2 Exit if assigning an alias failed while deploying (#2103)
* Error if aliasFinal is an empty array

* Return if alias assignment failed
2019-04-05 23:53:05 +02:00
Leo Lamprecht
ec376e272d 15.0.2-canary.5 2019-04-05 13:37:09 +00:00
William Li
c13d250577 Don't forget to do a yarn install before linking (#2094) 2019-04-05 13:37:04 +00:00
Joe Haddad
c372f1b66b 15.0.2-canary.4 2019-04-04 20:59:24 -04:00
Nathan Rajlich
bd1aa229e3 [now dev] Use a different workPath for every build (#2100)
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`.
2019-04-05 02:21:59 +02:00
Leo Lamprecht
1819c69de5 15.0.2-canary.3 2019-04-05 00:19:55 +00:00
Nathan Rajlich
4fb043c46a Ignore .env and .env.build for deployments by default (#2083)
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.
2019-04-05 02:11:08 +02:00
Nathan Rajlich
4995318418 [now dev] Clean up dev-router a bit (#2099)
* [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
2019-04-04 15:05:18 -07:00
Nathan Rajlich
6eaf6ecd14 [now dev] Remove now dev cache clean (#2097) 2019-04-04 14:36:05 -07:00
William Li
822971fc7d [now dev] Apply route params to headers (#2095)
* version bump (canary)

* inject paramters into headers.Location fixes #2092

* refactored route parameter resolving function

* Revert "version bump (canary)"

This reverts commit 5857489ceffcbcce07eb6e5d6fcc20279d0ba5fd.

* Update src/commands/dev/lib/dev-router.ts

Co-Authored-By: williamli <email@williamli.dev>

* refactor headers resolution

* try to resolve all parameters inside each child of headers
2019-04-04 13:33:04 -07:00
Nathan Rajlich
fb48402f87 [now dev] Set the same MemorySize on the lambdas as production (#2096)
This should fix https://spectrum.chat/zeit/now/now-dev-javascript-heap-out-of-memory~3fd6e823-59de-426b-ade0-af48d18f3494
2019-04-04 12:25:07 -07:00
Nathan Rajlich
fd241c1e85 Remove 'output logs of a 1.0 deployment' integration test (#2085)
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.
2019-04-04 12:14:42 -07:00
Nathan Rajlich
a3fc36e573 [now dev] Fix the requestPath for the hard-refresh case (#2086)
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.
2019-04-03 18:37:47 -07:00
Nathan Rajlich
402b4d3457 15.0.2-canary.2 2019-04-03 17:41:19 -07:00
Nathan Rajlich
62625df203 [now dev] Fix subscription resolving logic (#2082)
* [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
2019-04-03 17:39:14 -07:00
Leo Lamprecht
658c220c85 15.0.2-canary.1 2019-04-03 11:02:43 +00:00
Leo Lamprecht
4190a6bfbc Revert "[now dev] Less verbose "listening" message (#2062)"
This reverts commit a3f4c6290d.
2019-04-03 10:57:09 +00:00
Nathan Rajlich
7aea928a5a [now dev] Respond with 404 once the server is shutting down (#2070)
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.
2019-04-03 12:55:11 +02:00
Nathan Rajlich
58d4326511 [now dev] Add support for Builder "subscriptions" (#2071)
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.
2019-04-03 12:53:35 +02:00
Nathan Rajlich
f7b782440a [now dev] Pass meta object to Builders' build() function (#2069)
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.
2019-04-02 18:53:06 -07:00
Nathan Rajlich
17422184e4 Update pcre-to-regexp to v0.0.5 (#2068)
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.
2019-04-02 15:32:47 -07:00
Nathan Rajlich
c765e7efbb Update @zeit/ncc to v0.17.3 (#2058) 2019-04-01 15:55:02 -07:00
Nathan Rajlich
a3f4c6290d [now dev] Less verbose "listening" message (#2062)
* [now dev] Less verbose "listening" message

* Add "Listening on"

* Use "Running at"
2019-04-01 14:57:21 -07:00
Leo Lamprecht
c0cd13abcd 14.3.0-canary.27 2019-04-01 15:41:08 +00:00
Nathan Rajlich
6fab380cd9 [now dev] Update bootup message (#2056)
This looks a bit cleaner since the user just typed `now dev` into their
CLI so no need to print the same command again.
2019-04-01 08:18:00 -07:00
Nathan Rajlich
3732f89362 Update @now/build-utils to v0.4.38 (#2055) 2019-04-01 16:58:23 +02:00
Nathan Rajlich
e25388066d 14.3.0-canary.26 2019-03-31 23:56:49 -07:00
Nathan Rajlich
a7f823609d [now dev] Add support for .env and .env.build file to define Now secrets (#2048)
* [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.
2019-03-31 23:54:12 -07:00
Nathan Rajlich
f9362a1e53 Update @zeit/fun to v0.6.0 (#2049) 2019-03-31 23:17:24 -07:00
Nathan Rajlich
7a9d5e646f 14.3.0-canary.25 2019-03-31 13:38:05 -07:00
Nathan Rajlich
1108daa8ed [now dev] Use cyan for link color
Blue is hard to read on terminals with a black background.
2019-03-31 13:29:21 -07:00
Nathan Rajlich
d59de91fd6 [now dev] Add build deduping (#2044)
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.
2019-03-31 13:28:26 -07:00
Nathan Rajlich
0cfc31f4ad [now dev] Set the Now proxy and response headers (#2041)
* [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
2019-03-31 12:56:40 -07:00
Nathan Rajlich
e1df47dedc [now dev] Send INTERNAL_LAMBDA_NOT_FOUND (#2039)
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.
2019-03-30 18:26:30 -07:00
Nathan Rajlich
b6e4e0d670 [now dev] Use the Output helper (#2038)
* [now dev] Use the `Output` helper

For more consistent logging / styling with the other `now` commands.

* Put `setStatusError()` back
2019-03-30 18:25:22 -07:00
Andy Bitz
5d0338a278 14.3.0-canary.24 2019-03-29 23:01:31 +01:00
Andy
57aad64c23 Group builds with similar paths together to reduce the output (#2015)
* 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
2019-03-29 22:59:27 +01:00
Amio
743db0d265 Refine test jobs (#2028)
- Include `.ts` extension
- Include all `test/*unit.js` (`test-unit` task)
- Make coverage reporting a separate job in circleci config
2019-03-29 20:13:38 +08:00
Nathan Rajlich
a96a3c6623 14.3.0-canary.23 2019-03-28 19:02:49 -07:00
Nathan Rajlich
60c17953c9 [now dev] Send the NO_STATUS_CODE_FROM_LAMBDA upon lambda error (#2037) 2019-03-28 18:01:56 -07:00
Nathan Rajlich
2068de722c [now dev] Fix the path provided to lambda invocations (#2036)
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.
2019-03-28 15:55:02 -07:00
Leo Lamprecht
33d86505e8 14.3.0-canary.22 2019-03-28 22:11:03 +00:00
Leo Lamprecht
2a52d04064 Made aliases clickable after assigning (#2035)
* Made aliases clickable after assigning

* Set in correct place

* Fixed URL

* Attached alias

* Added missing https
2019-03-28 22:54:07 +01:00
Nathan Rajlich
7911bc6aea Add output to DevServer class (#2034) 2019-03-28 22:22:53 +01:00
Nathan Rajlich
733d908c89 [now dev] Listen on the next available port when requested port is taken (#2032)
Fixes #2024.
2019-03-28 21:53:58 +01:00
Leo Lamprecht
798ea44c60 Adjusted aliasing error message to match server (#2030)
* Adjusted aliasing error message to match server

* Correctly escape
2019-03-28 21:19:48 +01:00
Leo Lamprecht
08d4a3759b 14.3.0-canary.21 2019-03-28 13:06:13 +00:00
Nathan Rajlich
b29f602ce9 [now dev] Use pcre-to-regexp to match routes (#2027)
* [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
2019-03-27 18:37:43 -07:00
Nathan Rajlich
09c8144f31 [now dev] Centralize error responses logic (#2026)
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.
2019-03-27 17:29:11 -07:00
Nathan Rajlich
b3bd8c5929 [now dev] Don't add .gitignore to the ignore list (#2025)
`.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.
2019-03-27 12:32:50 -07:00
Julian Gruber
99790b1560 14.3.0-canary.19 2019-03-27 13:58:24 +01:00
Julian Gruber
31441e8890 Fix the handling of unexpected user errors (#2022)
* fix unexpected `DNSConflictingRecord`

* fix unexpected `EBADF`

* fix unexpected `InvalidDeploymentId`

* fix unexpected `InvalidDomain`

* fix unexpected `DomainNotFound`
2019-03-27 13:34:22 +01:00
Nathan Rajlich
f693acbaa9 14.3.0-canary.18 2019-03-26 18:12:38 -07:00
Amio
c1548a8cbb Add now dev (#1883)
* [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
2019-03-26 16:47:35 -07:00
Julian Gruber
fc7a75cae2 Fixed GET /v3/now/certs (#2005)
* 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
2019-03-26 19:55:13 +01:00
Julian Gruber
adced907c9 Fixed the handling of user errors in legacy deploy command (#2006)
* fix disconnected promise chain in legacy deploy
* fix `size_limit_exceeded` in legacy
2019-03-26 19:54:32 +01:00
Julian Gruber
49ae9d43ad Fixed the handling of unexpected DeploymentFailedAliasImpossible (#2020) 2019-03-26 19:53:32 +01:00
Joe Cohen
b40ae12e63 fix typo on domains inspect (#2016) 2019-03-26 10:25:04 +01:00
Leo Lamprecht
0ae9fa8342 14.3.0-canary.17 2019-03-22 00:40:24 +00:00
Leo Lamprecht
833d0b293f Make deployments without builds work (#2004)
* Make deployments without builds work

* Added integration test

* Fixed test
2019-03-22 01:39:58 +01:00
Leo Lamprecht
ea9a870604 14.3.0-canary.16 2019-03-21 02:55:30 +00:00
Leo Lamprecht
c7e5427200 Only block deployment exit if not error (#2000) 2019-03-21 03:53:18 +01:00
Leo Lamprecht
96ddda0009 14.3.0-canary.15 2019-03-20 22:54:26 +00:00
Leo Lamprecht
635115f94b Only announce deployment as ready if alias is set (#1997) 2019-03-20 23:54:01 +01:00
Julian Gruber
9bb1d799d8 14.3.0-canary.14 2019-03-20 22:37:10 +01:00
Julian Gruber
eabd15092c Fixed the handling of user errors (#1989)
* Fixed duplicate `--local-config` option
* Fixed uncaught `ERRORS.DomainPermissionDenied`
* Fixed uncaught `ERRORS.DeploymentNotFound`
* Added arguments parsing errors to Sentry scope
* Fixed stale stream in `cleanup()` of `promptOptions()`
* Fixed uncaught `USER_ABORT`
* Fixed uncaught `ENOENT`
2019-03-20 22:36:17 +01:00
Leo Lamprecht
5e85389792 14.3.0-canary.13 2019-03-19 09:27:59 +00:00
Leo Lamprecht
42eb69bb95 Made -S short flag work properly (#1988) 2019-03-19 10:27:44 +01:00
Julian Gruber
09c9ff5ecd 14.3.0-canary.12 2019-03-18 18:38:38 +01:00
Julian Gruber
2678656f12 Add always report stdarg to Sentry (#1982)
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.
2019-03-18 18:36:57 +01:00
Julian Gruber
eb2a7b56b0 Fix the handling of user errors (#1984)
* fix `ms(null)` in `certs rm`

* fix uncaught `InvalidDomain`
2019-03-18 18:15:45 +01:00
Julian Gruber
f33329d396 Fix null pointer access in error reporting (#1983)
* fix null pointer access in error reporting

* refactor
2019-03-18 18:08:38 +01:00
Leo Lamprecht
7d7340bbfc 14.3.0-canary.11 2019-03-18 13:05:36 +00:00
Leo Lamprecht
0bf2115701 Make --scope take priority over scope (#1985) 2019-03-18 14:04:10 +01:00
Leo Lamprecht
0357bfdbaa 14.3.0-canary.10 2019-03-18 09:38:07 +00:00
Amio
52a76299c5 Add hint about -f in now init error message (#1971) 2019-03-17 23:14:44 +08:00
Leo Lamprecht
8de3151b8f 14.3.0-canary.9 2019-03-16 18:04:31 +00:00
Andy
2b3ceba353 Handle the DomainNotVerified error for deployments (#1973) 2019-03-16 19:04:13 +01:00
Leo Lamprecht
378274bc3f Warn of now alias was used (#1972)
* Warn of `now alias` was used

* Mention deploy command
2019-03-16 18:58:14 +01:00
Leo Lamprecht
c3145b0801 14.3.0-canary.8 2019-03-15 23:05:31 +00:00
Leo Lamprecht
5aca7dafec Improved deployment output (#1968)
* Prefix all aliases that are printed

* Pass local config

* Print if --target production is defined, but not alias prop

* Moved warning message
2019-03-15 23:58:32 +01:00
Julian Gruber
803b1ae91b Fix the handling of user errors (#1959)
* fix unexpected `size_limit_exceeded`

* fix unexpected `deployment_type_unsupported`

* fix unexpected `JSONError`

* check if err.sizeLimit exists
2019-03-15 22:17:33 +01:00
Julian Gruber
402c4e75a2 Added back sending process args to Sentry (#1966)
* add `process.argv` to Sentry, without sensitive data

* refactor using `arg` parser

* add secret alias support
2019-03-15 18:54:49 +01:00
Mark Glagola
7a1859d1dd 14.3.0-canary.7 2019-03-14 17:56:15 -05:00
Mark Glagola
927117d5db adds prompt when moving domain to team user is not member of (#1965) 2019-03-14 23:53:41 +01:00
Leo Lamprecht
837f433b5c Revert "Warning w/ prompt when moving to a destination the user is not a member of (#1961)"
This reverts commit 48451e3f81.
2019-03-14 22:32:53 +00:00
Leo Lamprecht
b5b18ffefe 14.3.0-canary.6 2019-03-14 19:45:59 +00:00
Mark Glagola
48451e3f81 Warning w/ prompt when moving to a destination the user is not a member of (#1961) 2019-03-14 20:39:51 +01:00
Leo Lamprecht
ec9e334f9a Improved output for deploy command (#1962)
* Make alias links clickable

* Make output print Ready instead of Success

* Fixed missing export
2019-03-14 20:39:32 +01:00
Leo Lamprecht
f646ddfc0f 14.3.0-canary.5 2019-03-13 21:21:43 +00:00
Leo Lamprecht
2102441cd0 Added warning message about files with no deployments (#1960)
* Added warning message about files with no deployments

* Added integration test

* Fixed charset of test
2019-03-13 22:21:25 +01:00
Julian Gruber
95149c3fe4 14.3.0-canary.4 2019-03-13 20:36:48 +01:00
Julian Gruber
0bfbd40810 Fixed the handling of user errors (#1958) 2019-03-13 20:30:15 +01:00
Julian Gruber
b3a70e980e Refactored flow error checks (#1953) 2019-03-13 20:24:56 +01:00
Leo Lamprecht
952c369646 14.3.0-canary.3 2019-03-13 14:25:41 +00:00
Leo Lamprecht
3effec0dd5 Soft-deprecate the --team flag (#1956)
* Soft-deprecate the `--team` flag

* Check for warning message

* Removed useless error
2019-03-13 14:08:11 +01:00
Amio /
2d563e1694 Added a deploy hint after now init. (#1952)
* [now-init] add a deploy hint after init

* add CODEOWNERS
2019-03-13 10:45:49 +08:00
Leo Lamprecht
e9ceac13b8 14.3.0-canary.2 2019-03-12 23:09:58 +00:00
Leo Lamprecht
06a0607287 Added --scope flag and scope config property (#1939)
* 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
2019-03-13 00:09:43 +01:00
Leo Lamprecht
7e159646fb 14.3.0-canary.1 2019-03-12 19:36:01 +00:00
Leo Lamprecht
d2781430d3 Allow --target to be set to staging (#1955)
* Allow `--target` to be set to `staging`

* Properly format output

* Added clipboard support

* Send target to server

* Make target optional
2019-03-12 20:35:18 +01:00
Mark Glagola
1bb8c80342 Fallback to descriptive api error message if we cannot resolve domain rm|move conflict (#1951)
* On domain conflict error, use api error message & check resolvable flag

* Updated domain rm w/ attempt precaution

* smaller domain removal conflict construction
2019-03-12 14:14:07 -05:00
Julian Gruber
01e83247ee 14.1.0-canary.7 2019-03-12 19:05:35 +01:00
Julian Gruber
12653f97ad Fixed the handling of user errors
* fix unexpected `payment_error`

* fix unexpected `deployment_not_found`

* fix unexpected `not_authorized` and `team_deleted`

* make id optional in DeploymentNotFound
2019-03-12 19:04:13 +01:00
Mark Glagola
6bcb8651a0 14.1.0-canary.6 2019-03-08 09:53:23 -06:00
Mark Glagola
0071ca68be Adds alias removal warning on domains move (#1933)
* fixes double caret for domains move

* using output.success

* Adds alias removal warning to domains move
2019-03-07 09:43:38 -06:00
Mark Glagola
a89bbdfdf9 14.1.0-canary.5 2019-03-05 20:32:34 -06:00
Mark Glagola
c7bd599e16 Revised domains move flow (#1928)
* Revised domains move flow (rm move-in & move-out for move)

* fixed integration tests for domains move api changes

* handle immediate domain moves

* fixed list scopes integration test

* more integration test fixes
2019-03-05 18:32:41 -06:00
Andy Bitz
c66a5b580d 14.1.0-canary.4 2019-03-03 16:53:39 +01:00
Andy
f145b6a7d2 Overwrite the default batch file on windows (#1922)
* Overwrite the default batch file on windows

* Suppress echoing of the command
2019-03-03 16:48:18 +01:00
Leo Lamprecht
4337f0bab0 14.1.0-canary.3 2019-02-28 19:35:14 +00:00
Javi Velasco
6b37797de9 Add --no-scale option (#1918)
* Add no-scale option

* Reword --no-scale warning
2019-02-28 20:34:44 +01:00
Mark Glagola
1843ac4d31 Added warning for domains-move token expiration (#1916) 2019-02-27 17:24:22 -06:00
Mark Glagola
6399253318 14.1.0-canary.2 2019-02-27 15:47:38 -06:00
Mark Glagola
f3638fb871 Domain move-in & move-out implementation (#1906)
* Initial domain move-in & move-out implementation

* adjusted move apis

* domains move revisions based on API changes

* root domain func fix

* Minor copy fixes + added some integration test for move-in/out

* Handling move in|out conflict

* rm random quotes
2019-02-27 15:46:35 -06:00
Andy Bitz
dc88a310cb 14.1.0-canary.1 2019-02-27 19:36:23 +01:00
Andy
aea9bd4882 Added support for the --target flag (#1893)
* 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
2019-02-27 19:33:27 +01:00
Olli Vanhoja
b69bb4346c Set verify-deployment-scale timeout to 5 minutes (#1915)
The current client side timeout is shorter than the backend
timeout.
2019-02-27 11:40:22 +01:00
Leo Lamprecht
9af6aa4ba3 14.0.1-canary.1 2019-02-25 20:42:49 +00:00
Leo Lamprecht
dff2704662 Prevent error in now inspect if no dest (#1913) 2019-02-25 21:33:22 +01:00
Mark Glagola
4849352b34 Using @types/psl typings + handling all potential error cases with psl (#1911) 2019-02-25 20:59:43 +01:00
Javi Velasco
87700d9ab9 Fix wrong error message (#1904) 2019-02-25 20:58:37 +01:00
Javi Velasco
c69c0fd915 13.2.0-canary.6 2019-02-10 18:07:34 +01:00
Mark Glagola
4c4d5c7baa Revised the way conflicts are handled when removing a domain (#1884)
* Revised the way conflicts are handled when rm domain

* agent.ts accepts absolute urls

* "delete" copy -> "remove" for consistency

* Revert "agent.ts accepts absolute urls"

This reverts commit 200158d06fcb80417f197910c40e364f8ea5abb2.

* using proper set custom suffix endpoint

* Reuse InvalidDomain error
2019-02-10 17:21:54 +01:00
Sergii Paryzhskyi
1e9d2cf9a0 Add a hint to an error message about missing token (#1877) 2019-02-10 17:21:27 +01:00
Steve Kaliski
5579aba636 fix typo in alias command (#1870) 2019-02-10 17:20:30 +01:00
Olli Vanhoja
c66ad6a60f Handle dns add 400 errors properly (#1867)
Currently 400 errors are left unhandled.
2019-02-10 17:20:03 +01:00
Mark Glagola
8e7f087a68 Handle domain rm attempt for an in progress transfer (#1880) 2019-02-06 23:42:19 +01:00
Mark Glagola
72142c32a1 Catch SourceNotFound error for domains transfer-in (#1879) 2019-02-06 21:51:50 +01:00
Javi Velasco
5999ec7acd Update inspect copy (#1875) 2019-02-04 23:29:33 +01:00
Mark Glagola
af401cdc9b Added import help info to now-cli (now dns -h) (#1876) 2019-02-04 23:29:17 +01:00
Javi Velasco
f879e3ebdd 13.2.0-canary.5 2019-02-04 04:07:49 +01:00
Javi Velasco
a0b838c947 Enhance login (#1873)
* Enhance login

* Consume error from api
2019-02-04 01:05:30 -02:00
Leo Lamprecht
eb2fac75cd 13.2.0-canary.4 2019-02-01 23:11:00 +00:00
Leo Lamprecht
f0b1e57dcb Bumped fetch-h2 to latest version (#1869)
* Bumped `fetch-h2` to latest version

* Fixed code
2019-02-02 00:10:31 +01:00
Olli Vanhoja
f8f12b0596 Show builds rate limit message correctly (#1866) 2019-02-01 22:29:23 +01:00
Javi Velasco
de25859329 13.2.0-canary.3 2019-02-01 22:20:34 +01:00
Mark Glagola
b4430de8de Handle known domains rm errors (#1868) 2019-02-01 14:33:44 -06:00
Mark Glagola
6d6c4aa4b8 Added transferredAt and transferStartedAt (#1865) 2019-02-01 13:32:10 +01:00
Leo Lamprecht
baadff146e 13.2.0-canary.2 2019-01-31 22:47:33 +00:00
Javi Velasco
0b85490804 Remove cf cdn enabled flag (#1852)
* Remove CDN toggling

* Rename cdnEnabled to cfEnabled

* Rename cfEnabled to cloudfareEnabled

* Remove missing error
2019-01-31 23:38:23 +01:00
Andy
8d256228a0 Check if deploymentId exists (#1857)
* Check if deploymentId exists

* Make deploymentId optional for Alias
2019-01-31 13:37:09 +01:00
Arunoda Susiripala
5ad1af6d91 Check the existence of the project before we delete it (#1837) 2019-01-31 13:18:42 +01:00
Leo Lamprecht
38b3095b82 13.2.0-canary.1 2019-01-31 11:57:18 +00:00
Leo Lamprecht
9289d0cd43 Render validation errors for Now 1.0 (#1862) 2019-01-31 12:54:45 +01:00
Mark Glagola
d834c0fc0a Domain transfer in copy change (#1861) 2019-01-30 16:34:24 -06:00
Javi Velasco
7a995c3801 Add import zonefile copy (#1860) 2019-01-30 17:37:08 +01:00
Javi Velasco
2f41a2bc09 Add ability to import a zone file (#1851)
* Add ability to import a zone file

* Use an arg instead of an option for the zone file
2019-01-30 16:21:56 +01:00
Javi Velasco
e1a80c30be Add missing error: InvalidAuthCode (#1859) 2019-01-30 16:08:53 +01:00
Mark Glagola
19994ccf60 Add domain transfer in pricing (#1849)
* 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
2019-01-30 14:56:38 +01:00
George Tsiolis
1a59b0605f Update legacy note structure (#1855) 2019-01-29 17:06:20 +01:00
Mark Glagola
1c9aeee901 13.1.2-canary.3 2019-01-22 18:44:01 -06:00
Mark Glagola
31bfaa0569 "now domains transfer-in" support (#1767) 2019-01-22 17:31:51 -06:00
Leo Lamprecht
b24182df5b 13.1.2-canary.2 2019-01-22 16:22:32 +00:00
Andy
38923e1f91 Added default script that will run if now fails to install (#1832)
* 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
2019-01-21 19:59:40 +01:00
Leo Lamprecht
aefee0fad2 13.1.2-canary.1 2019-01-17 12:15:18 +00:00
Leo Lamprecht
aa2f53f2d5 Ensure name in package.json works for Now 1.0 (#1835)
* Ensure `name` in `package.json` works for Now 1.0

* Fixed integration test
2019-01-17 13:13:32 +01:00
Leo Lamprecht
a0bce9b3c5 13.1.1-canary.1 2019-01-16 22:59:45 +00:00
Arunoda Susiripala
8e5b7fdc19 Fix formatting issues on project rm confirmation (#1834) 2019-01-16 23:56:16 +01:00
Leo Lamprecht
4ee63506f8 13.1.0-canary.4 2019-01-16 18:43:16 +00:00
Leo Lamprecht
1a239f92f4 Ensure project name is always defined (#1833) 2019-01-16 19:41:03 +01:00
Leo Lamprecht
4f15b724ac 13.1.0-canary.3 2019-01-16 14:20:55 +00:00
Max
1c68a24a70 Support new invite format (#1831)
* Support new invite format

* Use null as initial userInfo value

Co-Authored-By: rdev <8418866+rdev@users.noreply.github.com>

* Add missing semicolon

Co-Authored-By: rdev <8418866+rdev@users.noreply.github.com>

* Add missing semicolon

Co-Authored-By: rdev <8418866+rdev@users.noreply.github.com>
2019-01-16 15:20:24 +01:00
Leo Lamprecht
d863acbc65 13.1.0-canary.2 2019-01-16 10:51:37 +00:00
Leo Lamprecht
c736f2ccb4 Revert "Show deployment URL at the end too (#1827)"
This reverts commit 0f2c677035.
2019-01-16 10:51:10 +00:00
Arunoda Susiripala
3942b88565 Get back the --name property (#1828)
* Get back the --name property
This also removes --project and consider --name as the project name

* Fix unit tests.

* Fix integration tests
2019-01-15 16:15:38 -08:00
Leo Lamprecht
a5ac2aca10 13.1.0-canary.1 2019-01-15 21:21:53 +00:00
Arunoda Susiripala
55ced7a3e5 Added support for projects (#1719)
* 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
2019-01-15 22:11:21 +01:00
Leo Lamprecht
0f2c677035 Show deployment URL at the end too (#1827) 2019-01-15 20:31:07 +01:00
Leo Lamprecht
7493f7d485 Allow user to abort now init (#1826) 2019-01-15 16:49:52 +01:00
Javi Velasco
ccbe18b520 Move all dns commands and subcommands to typescript (#1825) 2019-01-15 11:18:51 +01:00
Andy Bitz
8bde0bc204 13.0.4-canary.2 2019-01-14 22:14:28 +01:00
Leo Lamprecht
28df25e804 Improved test suite (#1820)
* 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
2019-01-14 21:53:13 +01:00
Andy
fa5cb50df9 Add the command to sentry (#1824)
Add the current command to sentry as extra
2019-01-14 21:40:58 +01:00
Timothy
b847e02ff8 Fix config file message (#1821) 2019-01-12 01:05:26 +01:00
Leo Lamprecht
3e7411440b 13.0.4-canary.1 2019-01-10 11:24:25 +00:00
Leo Lamprecht
52fa239ae1 Fixed now logs for 2.0 deployments (#1819)
* Fixed `now logs` for 2.0 deploymens

* Added log test for 2.0

* Make test work
2019-01-10 12:23:39 +01:00
Amio /
fdaed3fd8f better did-you-mean (#1817)
ensure 'node' => 'nodejs' insteadof 'node-server'
2019-01-09 19:43:26 -08:00
Leo Lamprecht
8a3235ce6f 13.0.3-canary.3 2019-01-09 22:01:56 +00:00
Leo Lamprecht
e054c17e31 Do not render that status was inferred (#1816) 2019-01-09 23:01:00 +01:00
Leo Lamprecht
c7b6b4fc3e 13.0.1-canary.3 2019-01-09 14:29:32 +00:00
Leo Lamprecht
4d60b96a75 Made now domains inspect match now inspect (#1815) 2019-01-09 15:29:15 +01:00
Leo Lamprecht
0f0b546fa6 13.0.1-canary.2 2019-01-09 10:54:39 +00:00
Leo Lamprecht
ed454218b6 Bumped update-check to latest version (#1814) 2019-01-09 10:54:18 +00:00
Leo Lamprecht
b2345de9cc Revert "Bumped update-check to latest version (#1813)"
This reverts commit 5dc393f397.
2019-01-09 10:29:22 +00:00
Leo Lamprecht
5dc393f397 Bumped update-check to latest version (#1813) 2019-01-09 11:06:56 +01:00
Leo Lamprecht
ca654d938b 13.0.1-canary.1 2019-01-08 20:24:59 +00:00
Leo Lamprecht
0b0fb6bf1f Fixed several errors (#1811)
* Fixed NOW-CLI-HB

* Fixed code
2019-01-08 15:45:27 +01:00
Leo Lamprecht
ce85bb0578 13.0.0-canary.39 2019-01-07 22:47:07 +00:00
Leo Lamprecht
4c9538d51f Fixed several errors and removed useless file (#1807)
* Fixed NOW-CLI-FK

* Fixed NOW-CLI-F0

* Fixed NOW-CLI-D2

* Fixed NOW-CLI-GK

* Do not render clipboard indicator if error occured

* Removed useless file

* Fixed NOW-CLI-GW

* Fixed NOW-CLI-H3
2019-01-07 23:46:48 +01:00
Timothy
dc5157a252 Add domain verification error document (#1806) 2019-01-07 23:36:10 +01:00
Leo Lamprecht
9cc6d7f4da Overhauled now inspect (#1804)
* Show routes in `now inspect`

* Removed whitespace

* Made UI gorgeous

* Use cyan for meta keys
2019-01-07 20:08:10 +01:00
Leo Lamprecht
18b301e2a6 13.0.0-canary.38 2019-01-04 21:04:30 +00:00
Javi Velasco
35f52410d9 Style fixes (#1796) 2019-01-04 12:57:35 -08:00
Amio /
cf55c05691 Add now-init (#1780)
* 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
2019-01-04 09:55:00 -08:00
Leo Lamprecht
be9360fbf3 13.0.0-canary.37 2019-01-04 11:47:35 +00:00
Javi Velasco
3fc07738cb Domains improvements (#1795)
* 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
2019-01-04 12:47:21 +01:00
Leo Lamprecht
299452eb8d Only run prettier for JS/TS files (#1791)
* Only pass modified js files

* Look for TS too
2019-01-03 20:06:57 +01:00
Leo Lamprecht
655bce7795 13.0.0-canary.36 2019-01-01 18:07:40 +00:00
Leo Lamprecht
0289b38e4e Improved performance when creating deployment (#1787) 2019-01-01 18:07:00 +00:00
Leo Lamprecht
bceb401d19 13.0.0-canary.35 2019-01-01 13:41:01 +00:00
Leo Lamprecht
cef74ff787 Moved docs about publishing a release to Wiki (#1786) 2019-01-01 14:40:49 +01:00
Leo Lamprecht
de3b1c896f 13.0.0-canary.34 2019-01-01 12:13:54 +00:00
Olli Vanhoja
c94bbbc3d3 Fix now dns ls misalignment when a domain is not found (#1777)
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.
2018-12-27 13:46:37 +02:00
Javi Velasco
877737d872 13.0.0-canary.33 2018-12-19 17:33:43 +01:00
Javi Velasco
2c47baeed4 Remove extra request when adding a domain (#1762) 2018-12-19 16:30:26 +01:00
Javi Velasco
0321a03e38 13.0.0-canary.32 2018-12-19 01:20:27 +01:00
Javi Velasco
ba28773dae Do not use certs and aliases in now domains rm (#1761)
* Update types to the new API contract

* Do not use aliases and certs from domain fetch

* Add a dash per row in ns table
2018-12-19 01:18:59 +01:00
Leo Lamprecht
fcb3f7fb4f 13.0.0-canary.31 2018-12-18 22:50:52 +00:00
Leo Lamprecht
1db52a9384 Wait for unhandled rejections to be reported before exiting (#1760) 2018-12-18 23:50:38 +01:00
Javi Velasco
47986470a3 13.0.0-canary.30 2018-12-18 00:40:53 +01:00
Javi Velasco
4ddafa700f Fix issue when we define aliases in now.json array (#1757) 2018-12-18 00:40:22 +01:00
Javi Velasco
2d90f1b02d 13.0.0-canary.29 2018-12-17 23:58:05 +01:00
Javi Velasco
19d67cb42b Domains enhancements (#1755)
* Show a dash where there are no nameservers

* Show actual serviceType in domains

* Format ns table with ticks

* More enhancements
2018-12-17 11:15:35 -08:00
Leo Lamprecht
df2e5c8ab0 13.0.0-canary.28 2018-12-16 16:31:20 +00:00
Leo Lamprecht
02d43366c7 Render better error when source missing (#1754)
* Render better error when source missing

* Added integration test

* Fixed missing
2018-12-16 17:31:08 +01:00
Leo Lamprecht
b51ceb26f8 13.0.0-canary.27 2018-12-13 15:28:41 +00:00
Leo Lamprecht
96f559c513 Ran prettier over the entire codebase (#1749)
* Use correct parser

* Ran prettier over the entire codebase
2018-12-13 16:28:21 +01:00
Javi Velasco
1ed613d5be Fix list DNS issue and migrate certs issue to Typescript (#1747)
* 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
2018-12-13 15:27:21 +01:00
Leo Lamprecht
2cba7cad2a Use our own @zeit/git-hooks package (#1748)
* 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
2018-12-13 15:13:55 +01:00
Javi Velasco
57c684abf3 13.0.0-canary.26 2018-12-12 23:35:49 +01:00
Javi Velasco
eb3970d779 New domains API + Typescript migrations (#1728)
New domains API + Typescript migrations
2018-12-12 23:35:08 +01:00
Leo Lamprecht
39f09d1b4b 13.0.0-canary.25 2018-12-12 17:24:10 +00:00
Mudit Ameta
b876da60aa Update now alias error to mention potentially missing name config (#1742)
* 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
2018-12-12 18:23:25 +01:00
Joe Cohen
48f85b4450 Use single domain call to remove add domains domains (#1743)
* use single domain call to remove add domains domains

* update sigle domain endpoint and error handling
2018-12-12 18:22:42 +01:00
Leo Lamprecht
6af4b9ecd5 13.0.0-canary.24 2018-12-10 14:26:40 +00:00
Leo Lamprecht
7441730b24 Hot fix for now teams ls (#1737)
* Hot fix for `now teams ls`

* Added integration test
2018-12-10 15:10:33 +01:00
Leo Lamprecht
f444350a4f Revert "Add husky"
This reverts commit 0892443104.
2018-12-10 11:14:02 +00:00
Javi Velasco
0892443104 Add husky 2018-12-10 00:30:16 +01:00
Leo Lamprecht
c97a0cffe1 13.0.0-canary.23 2018-12-07 23:07:06 +00:00
Leo Lamprecht
8ff7340eb2 Make download script work properly (#1729) 2018-12-08 00:06:40 +01:00
Leo Lamprecht
9dcf4d0264 13.0.0-canary.22 2018-12-07 22:37:31 +00:00
Leo Lamprecht
4a38798595 Re-enabled minification and source map reporting (#1727)
* Test tag logging

* Track source maps on Sentry

* Bumped @zeit/ncc to the latest version
2018-12-07 23:37:00 +01:00
Leo Lamprecht
b80804dae5 13.0.0-canary.21 2018-12-07 15:18:30 +00:00
Leo Lamprecht
8e4d885268 Fixed even more Sentry errors (#1726)
* Fixed NOW-CLI-A5

* Fixed NOW-CLI-AW

* Fixed NOW-CLI-B4

* Fixed NOW-CLI-8G

* Fixed NOW-CLI-BV

* Fixed NOW-CLI-6Z

* Fixed NOW-CLI-AV

* Fixed NOW-CLI-6A

* Fixed NOW-CLI-24
2018-12-07 16:18:11 +01:00
Leo Lamprecht
51f229b0bd 13.0.0-canary.20 2018-12-06 22:31:58 +00:00
Leo Lamprecht
c6a16a0279 Downgrade @zeit/ncc (#1725)
* Downgrade `@zeit/ncc`

* Fixed package.json
2018-12-06 23:31:49 +01:00
Leo Lamprecht
16c0a93d46 13.0.0-canary.19 2018-12-06 22:07:41 +00:00
Leo Lamprecht
857129c60f Fixed several errors (#1724)
* 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
2018-12-06 23:07:08 +01:00
Leo Lamprecht
84e6a52834 Improved error reporting system (#1723)
* 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
2018-12-06 15:23:46 +01:00
Leo Lamprecht
9a47c6c6d5 Added legacy preferGlobal flag (#1722) 2018-12-06 14:06:36 +01:00
Leo Lamprecht
17362c0cad 13.0.0-canary.18 2018-12-05 22:16:39 +00:00
Leo Lamprecht
e022bffe40 Improved Sentry error reporting (#1720)
* 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
2018-12-05 23:16:20 +01:00
Leo Lamprecht
f3381e95ef 13.0.0-canary.17 2018-11-30 23:32:14 +00:00
Leo Lamprecht
294f1d7983 Made npm run link work (#1715) 2018-12-01 00:24:48 +01:00
Leo Lamprecht
9bfb33d88c Replaced webpack with ncc (#1710)
* Removed useless stuff

* Removed types

* Removed types file

* Made the build work

* Fixed bundling

* Fixed linting

* Fixed download compiler

* Try to fix bundling problem

* Ignored two things

* Upgraded pkg to stable

* Fixed syntax finally

* Fixed unit tests

* Removed shebangs

* Fixed integration tests

* Made download script work
2018-12-01 00:14:32 +01:00
Leo Lamprecht
12b874507f Changed default of sessionAffinity to random (#1713) 2018-11-30 21:48:43 +01:00
Leo Lamprecht
cee97582fc 13.0.0-canary.16 2018-11-29 18:33:49 +00:00
Gustaf Räntilä
c66b6843a4 Improved http2 stability (#1705) 2018-11-29 19:30:43 +01:00
Leo Lamprecht
9fc03bbc9a Correctly report code coverage (#1709) 2018-11-29 19:30:00 +01:00
Leo Lamprecht
36c875a7f7 Added code coverage report (#1708)
* Added code coverage report

* Correctly include everything

* Ignored useless stuff

* Combine all the coverages

* Corrected requiring

* Persist only what is needed
2018-11-29 19:03:32 +01:00
Leo Lamprecht
48b175fa43 13.0.0-canary.15 2018-11-29 16:01:04 +00:00
Leo Lamprecht
4d35ea9bf3 Ensured now -V 1 owner/repo continues working (#1707)
* Ensured `now -V 1 owner/repo` continues working

* Added newline

* Added tests
2018-11-29 17:00:49 +01:00
Leo Lamprecht
62368fda23 13.0.0-canary.14 2018-11-27 22:37:15 +00:00
Leo Lamprecht
6b89eca022 Render more accurate error when offline (#1704) 2018-11-27 23:36:02 +01:00
Leo Lamprecht
000c02247d 13.0.0-canary.13 2018-11-27 21:19:35 +01:00
Leo Lamprecht
6b899188c4 Render a proper error when offline (#1702)
* Made debugging entry file work

* Render proper error when offline

* Return proper exit code
2018-11-27 21:16:34 +01:00
Leo Lamprecht
24f0efc0e2 13.0.0-canary.12 2018-11-27 19:48:43 +01:00
Leo Lamprecht
b6bbb28757 Render more detailed error when files are not there (#1700) 2018-11-27 19:46:03 +01:00
Leo Lamprecht
8e1cd54c92 13.0.0-canary.11 2018-11-26 11:09:02 +01:00
Leo Lamprecht
8b3dff12e8 Do not render instance count for 2.0 deployments (#1697)
* Do not render instance count for 2.0 deployments

* Added integration test
2018-11-26 11:08:40 +01:00
Leo Lamprecht
c82b18f772 13.0.0-canary.10 2018-11-23 12:11:10 +01:00
Leo Lamprecht
2642e15aff Do not send github property to API (#1694) 2018-11-23 12:10:56 +01:00
Leo Lamprecht
bf4dac5c3b 13.0.0-canary.9 2018-11-22 16:47:53 +01:00
Leo Lamprecht
8729214f8b Do not send alias to the API (#1690) 2018-11-22 16:47:31 +01:00
Leo Lamprecht
ff6073a932 13.0.0-canary.8 2018-11-22 13:39:17 +01:00
Leo Lamprecht
2cfee720a3 Properly render schema validation errors (#1689)
* Properly render schema validation errors

* Added integration test

* Removed useless properties
2018-11-22 13:38:46 +01:00
Leo Lamprecht
061e3d212d 13.0.0-canary.7 2018-11-21 18:11:55 +01:00
Leo Lamprecht
04bb549e36 Make now teams add work (#1684)
* Make `now teams add` work

* Added integration test

* Added comment
2018-11-21 18:11:33 +01:00
Leo Lamprecht
68fcb587a9 13.0.0-canary.6 2018-11-19 13:23:03 +01:00
Leo Lamprecht
93165ef0b2 Do not store a backup of the binary (#1676) 2018-11-19 13:16:31 +01:00
Leo Lamprecht
a616124cc6 Build for dev and not for prod when linking (#1671) 2018-11-16 22:54:20 +01:00
Leo Lamprecht
2ccb8f9a17 13.0.0-canary.5 2018-11-16 00:16:29 +01:00
Leo Lamprecht
4b58fac608 Made publishing work (#1669) 2018-11-16 00:16:02 +01:00
Leo Lamprecht
a4a3d8a6eb 13.0.0-canary.4 2018-11-15 22:21:45 +01:00
Leo Lamprecht
dbcb18bffc Upgrade to Webpack 4.0 (#1667)
* Added support for Webpack 4

* Brought performance back

* Default output dir

* Made it take effect

* Made binary work
2018-11-15 22:19:51 +01:00
Leo Lamprecht
a499580b4d 13.0.0-canary.3 2018-11-15 01:26:16 +01:00
Leo Lamprecht
4fd952b0da Report server errors that are unhandled (#1658) 2018-11-15 01:26:02 +01:00
Evil Rabbit
234ed2718f Update repo banner (#1659) 2018-11-15 01:17:49 +01:00
Leo Lamprecht
77c1818572 13.0.0-canary.2 2018-11-15 01:07:06 +01:00
Leo Lamprecht
b704aca0fe Send unexpected errors away for inspection (#1657)
* 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
2018-11-15 01:03:46 +01:00
Leo Lamprecht
8226f81026 Added new now upgrade and now downgrade commands (#1656)
* Handle cancelation

* Fixed imports

* Added support for old plans

* Removed test that does not apply anymore
2018-11-14 23:53:46 +01:00
Leo Lamprecht
1b062aa597 Fixed error message for minimum instance count (#1655) 2018-11-14 14:27:14 +01:00
Leo Lamprecht
3f863cace4 13.0.0-canary.1 2018-11-13 23:52:48 +01:00
Leo Lamprecht
737536297c Allow re-using aliases that point to deleted deployments (#1653)
* Allow re-using aliases that point to deleted deployments

* Removed
2018-11-13 23:48:40 +01:00
Leo Lamprecht
c9017b5bf9 12.0.0-canary.100 2018-11-13 20:10:39 +01:00
Leo Lamprecht
89dc51fab5 Log version when debugging (#1652) 2018-11-13 19:03:21 +01:00
Leo Lamprecht
78067113d7 Decrease amount of retries for download (#1651)
This fixes #1622.
2018-11-13 19:00:07 +01:00
Leo Lamprecht
bef3abbe2c Return code 0 if no deployments found when removing (#1650)
* Return code 0 if no deployments found when removing

This fixes #1605.

* Fixed integration test

* Fixed second example too

* Fixed all occurances
2018-11-13 18:54:18 +01:00
Leo Lamprecht
1255c24898 12.0.0-canary.99 2018-11-12 22:12:39 +01:00
Leo Lamprecht
4e0b923552 Made default value for --dotenv (v1) work again (#1649) 2018-11-12 22:12:18 +01:00
Leo Lamprecht
ef9a6ac6aa 12.0.0-canary.98 2018-11-12 13:07:56 +01:00
Leo Lamprecht
60c0d725c9 Added -V to the usage information (#1648) 2018-11-12 12:53:12 +01:00
Leo Lamprecht
59450f470a 12.0.0-canary.97 2018-11-12 12:48:21 +01:00
Leo Lamprecht
09dfd736db Added tests for -V option (#1647)
* 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
2018-11-12 12:48:08 +01:00
Leo Lamprecht
3852c9bf3f 12.0.0-canary.96 2018-11-10 20:55:57 +01:00
Leo Lamprecht
f3d9208d08 Added support for -V option (#1644) 2018-11-10 20:55:35 +01:00
Leo Lamprecht
c62236791a 12.0.0-canary.95 2018-11-08 22:21:24 +01:00
Leo Lamprecht
bbe6ff820a Made --build-env, --meta and --dotenv work for v1 (#1637)
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
2018-11-08 22:20:33 +01:00
Bart Deslagmulder
47679469ac Updated error documentation about not nameservers (#1629) 2018-11-08 18:49:15 +01:00
Leo Lamprecht
f7e79a31a0 12.0.0-canary.94 2018-11-08 16:27:27 +01:00
Leo Lamprecht
2d8c995756 Added support for Now 2.0 (#1636)
* 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.
2018-11-08 16:24:31 +01:00
Leo Lamprecht
70a0a594b4 12.0.0-canary.93 2018-11-03 17:54:47 +01:00
Leo Lamprecht
4273d62460 Revert "Add support for top-level "sh" auth"
This reverts commit c493d651db.
2018-11-03 17:54:36 +01:00
Nathan Rajlich
847c71ecf2 12.0.0-canary.92 2018-11-02 21:01:32 -07:00
Nathan Rajlich
c493d651db Add support for top-level "sh" auth 2018-11-02 21:00:45 -07:00
Leo Lamprecht
06c954f8fe 12.0.0-canary.91 2018-11-02 21:26:13 +01:00
Arunoda Susiripala
9567656b45 Added metadata support for now inspect (#1634) 2018-11-02 21:25:50 +01:00
Leo Lamprecht
966737be23 12.0.0-canary.90 2018-11-02 21:14:24 +01:00
Arunoda Susiripala
6c1188a787 Added support for deployment metadata (#1604)
* 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
2018-11-02 21:05:47 +01:00
Leo Lamprecht
39fffe6874 12.0.0-canary.89 2018-09-23 17:32:13 +02:00
Evil Rabbit
a75ae8a1b1 Update repo banner 2018-09-23 12:04:53 -03:00
Leo Lamprecht
c1d49fe8aa 12.0.0-canary.88 2018-09-20 15:50:23 +02:00
Mark
577831f775 Suppress the warning of a dependency based on an expression (#1588) 2018-09-20 15:50:07 +02:00
Leo Lamprecht
098ad6e98c 12.0.0-canary.87 2018-09-18 23:07:21 +02:00
Javi Velasco
248fdbaddf Change copy for finish cert message (#1590) 2018-09-18 23:06:56 +02:00
Leo Lamprecht
417a1abcf7 12.0.0-canary.86 2018-09-14 20:43:13 +02:00
Javi Velasco
d36ecec9c4 Bring back now certs add (#1583) 2018-09-14 20:42:57 +02:00
Leo Lamprecht
7a2895d3a3 12.0.0-canary.85 2018-09-12 23:43:53 +02:00
Nathan Rajlich
58f156a491 Render Cloud v2 info about deployments in now inspect (#1577)
`slot` and `limits` are now rendered when it is a Cloud v2 deployment.

Also fixes an issue with static deployments always
rendering `affinity: undefined`.
2018-09-12 23:39:16 +02:00
Nathan Rajlich
02ee8602cd Add "all" pseudo-DC to the constants mapping (#1581) 2018-09-12 23:31:58 +02:00
Nathan Rajlich
e999f5dd72 Add now inspect to --help (#1578) 2018-09-12 23:31:29 +02:00
Leo Lamprecht
5e1b099285 12.0.0-canary.84 2018-09-11 18:34:26 +02:00
Matheus Fernandes
87b1f5a5fb Added new iad1 data center (#1575) 2018-09-11 18:34:08 +02:00
Leo Lamprecht
ae8cbdce0a 12.0.0-canary.83 2018-09-10 19:09:42 +02:00
Cygnusfear
95de48c03f Changed error to log to avoid breaking automatic deployments (#1572)
throwing an error re-opened this issue:
https://github.com/zeit/now-cli/issues/1044

breaks automation when no deployments are found or deployment name is changed
2018-09-10 19:09:36 +02:00
Nathan Rajlich
5ea4fd9a5e Add now whoami to --help (#1573) 2018-09-10 19:06:19 +02:00
Leo Lamprecht
1f3d9e7e0f 12.0.0-canary.82 2018-09-06 21:00:04 +02:00
Jaga Santagostino
05e4528b1c Add changelog link when new version is available (#1530)
* add changelog link if new version is available

* Linked directly
2018-09-06 20:59:24 +02:00
Jarmo Isotalo
40789776bc Prefer URL over deployment ID as the ID not shown in now ls (#1554) 2018-09-06 20:59:19 +02:00
Zeke Sikelianos
75759edd26 Use consistent wording in usage (#1541) 2018-09-06 20:39:53 +02:00
Nathan Rajlich
2a5dc1dba6 Update @zeit/dockerignore to v0.0.3 (#1560)
* Update `@zeit/dockerignore` to v0.0.2

To fix https://github.com/zeit/now-cli/issues/1441.

* Update `@zeit/dockerignore` to v0.0.3
2018-09-06 20:39:09 +02:00
Javi Velasco
0cbf50b7ff 12.0.0-canary.81 2018-09-05 18:00:07 +02:00
Javi Velasco
a3f5b805bb Restructure certs command (#1567)
* Restructure add command

* Remove cert start and finish

* Rename certs add to issue

* Better errors and add cant-solve-challenge

* Show err.sh for dns configuration errors generating certs

* Add err.sh to solve challenges manually

* Add deprecation message to certs add

* Improve grammar

* Minor fixes
2018-09-05 17:58:22 +02:00
Javi Velasco
c337877501 12.0.0-canary.80 2018-09-02 23:24:48 +02:00
Javi Velasco
a6e9dd850a Allow to generate certs solving challenges manually (#1566)
* 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
2018-09-02 23:24:04 +02:00
Leo Lamprecht
a14d4057de 12.0.0-canary.79 2018-09-01 12:18:06 +02:00
Olli Vanhoja
210240ce66 Fix scaling v1 deployments to all DCs (#1556)
```
> 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.
2018-08-28 18:51:52 -07:00
timothyis
d21f7fe75c 12.0.0-canary.78 2018-08-25 15:52:37 +01:00
Timothy
54805cd2a0 Add gru1 (#1545)
* Add gru1

* Add gru to errors

* Hard code sfo,bru scale

* Add --regions argument

* Push with console.log

* Scale to `bru`

* Scale down in bru only
2018-08-25 15:52:16 +01:00
Javi Velasco
c7da2e732a 12.0.0-canary.77 2018-08-24 02:41:01 +02:00
Javi Velasco
4b4beaa892 Pass domain to verify insted of alias when verifying on alias (#1548) 2018-08-24 02:40:35 +02:00
Javi Velasco
e13596acae 12.0.0-canary.76 2018-08-20 20:10:08 +02:00
Javi Velasco
8eb065181f Return scaling validation errors on alias (#1538)
* Return scaling errors on alias

* Join pattern match error in one expression
2018-08-20 19:52:29 +02:00
Javi Velasco
1d97219fef 12.0.0-canary.75 2018-08-20 05:13:55 +02:00
Javi Velasco
d312f94825 Fix updating scale (#1536) 2018-08-20 04:46:55 +02:00
Javi Velasco
478a6f7369 12.0.0-canary.74 2018-08-19 18:22:22 +02:00
Javi Velasco
e309123296 Try to verify against domain name instead of alias (#1534) 2018-08-19 18:21:46 +02:00
Leo Lamprecht
777646cb0e 12.0.0-canary.73 2018-08-13 19:23:27 +02:00
Arunoda Susiripala
39e23f7144 Remove @zeit/schemas (#1507)
We no longer use it inside this repository.
2018-08-13 18:52:58 +02:00
Leo Lamprecht
b68b5c0ea3 12.0.0-canary.72 2018-08-09 12:23:10 +02:00
Sean
46dfeb8ca9 Less cryptic invalid alias message (#1506)
* Less cryptic invalid alias message

* URL -> hostname
2018-08-09 12:23:05 +02:00
Leo Lamprecht
6771ad43af Point Spectrum badge to correct location (#1516) 2018-08-09 12:21:35 +02:00
Luciano Pellacani Franca
1881b9c6cb fixing typo (#1509) 2018-08-07 20:26:05 +01:00
Pranay Prakash
dae6b7a980 12.0.0-canary.71 2018-08-04 03:08:37 +00:00
Pranay Prakash
aed6209f6a Bugfixes and improvements for deployment READY status detection (#1501)
* 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
2018-08-03 19:31:23 -07:00
Leo Lamprecht
b44a590aa0 12.0.0-canary.70 2018-08-03 08:16:35 +02:00
Olli Vanhoja
936b5fc983 Show selected session affinity when inspecting a deployment (#1489) 2018-08-03 08:12:43 +02:00
yairhaimo
473d6617f2 Include correct help command in now domains (#1492) 2018-08-03 08:11:29 +02:00
Leo Lamprecht
fcf50b5aeb 12.0.0-canary.69 2018-08-02 10:55:58 +02:00
Pranay Prakash
a3835d2e8a Retry 412 errors (#1494)
* retry on 412

* add comment for returnify and exit when the iterator ends
2018-08-02 10:55:02 +02:00
Pranay Prakash
d89481966e poll every 5s (#1496) 2018-08-01 22:56:19 -07:00
Leo Lamprecht
3148ce0f31 12.0.0-canary.68 2018-08-02 07:29:37 +02:00
Leo Lamprecht
f65363856a Better error message for rate limiting deployments (#1495)
* Better error message for rate limiting deployments

* Fixed typo

* Show time until reset

* Removed logging
2018-08-02 07:28:31 +02:00
Leo Lamprecht
e205b57352 12.0.0-canary.67 2018-08-01 13:49:54 +02:00
Aria Malkani
f44a1dbf21 Checks if it is an npm deployment before getting the aliased name (#1490)
* 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
2018-08-01 13:49:27 +02:00
Leo Lamprecht
b7fe2f606c 12.0.0-canary.66 2018-07-31 10:27:36 +02:00
Leo Lamprecht
6e81c1795c Bumped configuration schemas to the latest version (#1488) 2018-07-31 10:27:22 +02:00
Leo Lamprecht
141d8e4467 12.0.0-canary.65 2018-07-30 13:35:55 +02:00
Robin Millette
edbfeab75f Updated link about authentication file (#1483)
* Fix link to config help

* Update get-default-auth-cfg.js
2018-07-30 13:35:34 +02:00
Robin Millette
e48ea10ebb Updated link about global configuration file (#1482)
* Fix link to config help

* Update get-default-cfg.js
2018-07-30 13:34:52 +02:00
Leo Lamprecht
8565af5526 12.0.0-canary.64 2018-07-30 13:23:30 +02:00
Leo Lamprecht
511d3bae8f Added schema for static header configuration (#1486)
* Added schema for static header configuration

* Bumped yet again
2018-07-30 13:23:07 +02:00
Pranay Prakash
8df233fef1 12.0.0-canary.63 2018-07-29 22:07:06 +00:00
Pranay Prakash
4b97410cc0 Don't downscale previous slot deployment on alias (#1485)
* don't downscale

* use /now/v4/deployments/:id
2018-07-29 15:05:34 -07:00
Leo Lamprecht
aadf8097d1 12.0.0-canary.62 2018-07-24 23:48:57 +02:00
Leo Lamprecht
40d8b74b1b Fixed now billing and use new API (#1477)
* 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
2018-07-24 23:48:00 +02:00
Leo Lamprecht
8c4d42891c 12.0.0-canary.61 2018-07-22 01:54:51 +02:00
Leo Lamprecht
3672374d23 Fixed integration tests (#1476) 2018-07-22 01:54:05 +02:00
Leo Lamprecht
9ff9d3f174 12.0.0-canary.60 2018-07-19 19:54:19 +02:00
Nathan Rajlich
86540fa7fd Add --build-env to now deploy command (#1459)
* 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
2018-07-19 19:53:52 +02:00
Pranay Prakash
1538c80a7d 12.0.0-canary.59 2018-07-18 23:29:18 +00:00
Pranay Prakash
0225fcfe51 Improvements to the CLI to handle slot specific flows (#1475)
* Handle scale slots error

* generate and send a requestID when verifying instantiation

* Don't compy incompatible scale settings

* deprecate BinaryDeployment

* add err.sh link

* swap cuid for uuid
2018-07-18 16:26:07 -07:00
Leo Lamprecht
57f3861de6 12.0.0-canary.58 2018-07-17 09:50:26 +02:00
Arunoda Susiripala
04c365a251 Add more integration tests (#1466)
* 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.
2018-07-17 09:47:21 +02:00
Nathan Rajlich
7dfe4690ce 12.0.0-canary.57 2018-07-17 00:10:17 -07:00
Nathan Rajlich
92bcf1b7c9 Remove shallow deployment verification (#1474)
Remove shallow deployment verification
2018-07-17 00:08:55 -07:00
Igor Klopov
8a15d5c65a retry createDeploy if files are missing. addresses #1463 (#1465) 2018-07-13 18:26:12 +03:00
Leo Lamprecht
f64374225d 12.0.0-canary.56 2018-07-11 15:37:44 +02:00
Javi Velasco
7537eac6a7 Control can't solve challenge errors (#1458) 2018-07-11 15:37:22 +02:00
Leo Lamprecht
e2880d2434 12.0.0-canary.55 2018-07-10 19:28:01 +02:00
Javi Velasco
8296de16ef Check domain after adding (#1455)
* Check domain info after adding it

* Add message spiner to show while adding a domain
2018-07-10 19:27:42 +02:00
Leo Lamprecht
5cff5e9dfd 12.0.0-canary.54 2018-07-10 12:16:13 +02:00
Javi Velasco
cb07a748c2 Refactor DNS and update domains with CDN improvements (#1438)
* 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
2018-07-10 12:13:45 +02:00
Nathan Rajlich
c7b985bdc6 Remove legacy atlas logic (#1451)
* Remove legacy `atlas` logic

No longer used for anything.

* Remove another `atlas`
2018-07-10 11:43:00 +02:00
Javi Velasco
bf32ca0e4a Dont try to generate always wildcard certs when aliasing (#1445)
* 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
2018-07-10 11:42:37 +02:00
Javi Velasco
a4e52de0e3 Add retryAfter info to rate limit errors (#1442) 2018-07-10 11:41:28 +02:00
Nathan Rajlich
e43e9b11a0 Wait for static builds to be ready and show logs (#1452)
Implicitly sets the `noVerify` option since there is nothing to verify.
2018-07-10 01:11:10 -07:00
Javi Velasco
847b9e97c4 12.0.0-canary.53 2018-07-09 13:05:01 +02:00
Javi Velasco
baad689286 Fix typo when checking NS during setup domain (#1450) 2018-07-09 12:53:11 +02:00
Arunoda Susiripala
5e7afc4385 12.0.0-canary.52 2018-07-09 09:40:37 +05:30
Matheus Fernandes
d724b7a631 Revert "Upgrade to webpack 4 and latest Babel" (#1448)
* 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.
2018-07-08 20:48:55 -07:00
Nathan Rajlich
5e17fe5ad6 12.0.0-canary.51 2018-07-05 17:52:14 -07:00
Nathan Rajlich
b216adadc0 Update @zeit/schemas to v1.6.0 2018-07-05 17:39:38 -07:00
Arunoda Susiripala
5078c95667 Upload the Dockerfile if it's a static deployment. (#1437)
* 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.
2018-07-05 22:32:19 +05:30
Javi Velasco
7612d77647 Upgrade to webpack 4 and latest Babel (#1436)
* Upgrade to webpack 4 and last latest

* Fix building commands

* Do not call yarn build when yarn link

* Use resolved paths in webpack config
2018-07-04 17:51:16 +01:00
Leo Lamprecht
0d76041c10 12.0.0-canary.50 2018-07-03 21:20:17 +02:00
Javi Velasco
59be596d24 Allow to deploy and alias when non essential APIs are down (#1435)
* 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
2018-07-03 12:18:54 -07:00
Leo Lamprecht
63e51a3c98 12.0.0-canary.49 2018-07-02 11:31:15 +02:00
Leo Lamprecht
7f3128b3e5 Fixed the tests (#1430)
* Fixed the tests

* Wrapped up
2018-07-02 11:30:44 +02:00
Leo Lamprecht
c235813ae7 12.0.0-canary.48 2018-06-22 21:50:33 +02:00
Javi Velasco
3ee18e7051 Small fixes (#1418)
* Remove FlowFixMe in deploy command

* Show success message when creating a cert for alias based on response cns
2018-06-21 23:04:40 -07:00
Leo Lamprecht
14fc5d8796 12.0.0-canary.47 2018-06-21 12:53:44 +02:00
Leo Lamprecht
9fb0077385 Improved error message for schema validation (#1416)
* Bumped schema

* Improved error message for schema validation
2018-06-21 12:53:12 +02:00
Javi Velasco
2e9c7265b6 12.0.0-canary.46 2018-06-19 17:13:48 +02:00
Javi Velasco
d9e77b784a Allow to enable and disable CDN for domains and refactor domains (#1413)
* 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
2018-06-19 17:12:55 +02:00
Javi Velasco
b5b296ad7f 12.0.0-canary.45 2018-06-15 17:35:53 +02:00
Javi Velasco
acdfde5aa2 Deeply nested wildcard certs (#1407)
* Better error when we can't verify a domain during alias

* Remove preferDNS option from CLI and allow wildcard certs for deeply nested
2018-06-15 12:04:10 +02:00
Pranay Prakash
0eddfbd28c Improve the progress bar during upload (#1406)
* 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
2018-06-13 23:21:39 -04:00
Javi Velasco
037f0610bc 12.0.0-canary.44 2018-06-13 15:39:27 +02:00
Javi Velasco
dd45f8f2ab Request normal cert for deeply nested alias (#1404)
* Request normal cert for deeply nested alias

* When is a deeply nested domain request a normal cert
2018-06-13 15:38:47 +02:00
Leo Lamprecht
d454c84f61 12.0.0-canary.43 2018-06-11 10:40:32 +02:00
Felix Yan
a4c98e07a5 Fix a typo in unique-strings.js (#1400) 2018-06-08 12:20:57 -07:00
Igor Klopov
85715630bd test-integration: test deployment logs output (#1398) 2018-06-08 04:31:36 -07:00
Nathan Rajlich
45d8d4a84f 12.0.0-canary.42 2018-06-07 14:48:16 -07:00
Nathan Rajlich
690882c97a Fix shallow verify (#1397) 2018-06-07 14:45:27 -07:00
Leo Lamprecht
e03836e4a1 12.0.0-canary.41 2018-06-07 11:00:32 +02:00
Leo Lamprecht
d4ec54135a Updated configuration schema (#1394) 2018-06-07 10:59:51 +02:00
Javi Velasco
b29785d851 Ensure there is scale rules before trying to apply (#1389) 2018-06-07 10:52:24 +02:00
Javi Velasco
148870d706 Fixed unexpected error while aliasing (#1387) 2018-06-07 10:50:49 +02:00
Nathan Rajlich
ed1f7e335d Add shallow deployment verification (#1367)
* Add shallow deployment verification

* Add Flow type for `now.retry()`

* Add 3 fetch retries to shallow verify

* Use generics

* Collapse

* Fix

* Add `X-Now-Shallow` verification
2018-06-06 13:08:19 -07:00
Matheus Fernandes
eaf4695194 12.0.0-canary.40 2018-06-01 15:59:43 -07:00
Igor Klopov
c312d42302 reuse getSafeAlias function for all callers of findAliasByAliasOrId (#1385) 2018-06-02 01:27:47 +03:00
Leo Lamprecht
a8a2a6c066 12.0.0-canary.39 2018-05-29 20:07:19 +02:00
Leo Lamprecht
8b3512cb07 Bumped configuration schemas to the latest version (#1379) 2018-05-29 20:06:57 +02:00
Leo Lamprecht
945facdd2c 12.0.0-canary.38 2018-05-29 18:36:15 +02:00
Javi Velasco
8676ed4cff Support for Custom Deployment Suffix (#1378)
* 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
2018-05-29 07:58:24 -07:00
Leo Lamprecht
e4d4afa840 12.0.0-canary.37 2018-05-28 13:16:13 +02:00
Leo Lamprecht
81cf286ea4 Bumped configuration schemas to the latest version (#1374) 2018-05-28 13:15:58 +02:00
Leo Lamprecht
e834625728 12.0.0-canary.36 2018-05-28 09:07:30 +02:00
Pranay Prakash
a7c22eb08c add @zeit/dockerignore (#1373) 2018-05-26 09:51:56 -07:00
Leo Lamprecht
837c358371 12.0.0-canary.35 2018-05-25 20:58:30 +02:00
Leo Lamprecht
9743db27e7 Updated configuration schemas to the latest version (#1372) 2018-05-25 11:54:27 -07:00
Tim Neutkens
ce725143e6 12.0.0-canary.34 2018-05-22 17:32:26 +02:00
Tim Neutkens
677805c33a Make sure subdomain is correctly typed / checked (#1364)
Fixes an error introduced in #1344 when running `now alias` on a naked domain like `example.com`.
2018-05-22 17:31:25 +02:00
Pranay Prakash
3d3f1fe39b Make the progress bar for uploads consider bytes, not number of files (#1335)
* use got and propogate uploadProgress

* Accept comma separated cns (#1336)

* use got and propogate uploadProgress

* hook into stream.read

* revert `got` stuff

* remove stray whitespace
2018-05-21 16:40:24 -07:00
Pranay Prakash
123c68ad2b fix clipboard arg parsing (#1358) 2018-05-21 16:39:40 -07:00
Timothy
86861c58af Fix error message via #1350 (#1361) 2018-05-21 16:39:22 -07:00
Pranay Prakash
d4ddb6b3f9 Strip quotes from Dockerfile labels (#1351)
* 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
2018-05-21 16:39:06 -07:00
Leo Lamprecht
0fc7de40d4 12.0.0-canary.33 2018-05-18 14:06:57 +02:00
Leo Lamprecht
3cb4a9c8dd Bumped update-check to the latest version (#1354) 2018-05-18 14:06:18 +02:00
Javi Velasco
d681289457 12.0.0-canary.32 2018-05-18 03:24:28 +02:00
Javi Velasco
bc1c3c3f5b Update non-existing team test 2018-05-18 03:24:08 +02:00
Javi Velasco
5ae4287c0f 12.0.0-canary.31 2018-05-18 03:02:00 +02:00
Javi Velasco
cde9f56886 Prefer HTTP challenge for regular certs 2018-05-18 03:01:26 +02:00
Pranay Prakash
2b6b006bbd issue normal cert for nested subdomain (#1344) 2018-05-18 02:32:12 +02:00
Leo Lamprecht
54e1bcafc0 12.0.0-canary.30 2018-05-16 21:28:21 +02:00
Leo Lamprecht
7e98d0a22b Store config on platform & load schema from package (#1349)
* Load schema from package

* Send config to deployment endpoint

* Upgraded @zeit/schemas to the latest version

* Removed type for now

* Added config correctly
2018-05-16 21:26:41 +02:00
Tim Neutkens
c27b4a6aaf 12.0.0-canary.29 2018-05-16 18:08:53 +02:00
Javi Velasco
8f17ffd817 Fix table import (#1348) 2018-05-16 18:07:58 +02:00
Leo Lamprecht
0a7d688d32 12.0.0-canary.28 2018-05-15 21:58:07 +02:00
Leo Lamprecht
8cb2fe1284 Account for npm being down (#1346)
* Corrected license file name

* Corrected readme name

* Added editorconfig

* Account for npm being down

* Print full error

* Only show full error while debugging
2018-05-15 21:57:40 +02:00
Leo Lamprecht
e6e375232e 12.0.0-canary.27 2018-05-15 10:07:03 +02:00
Guillermo Rauch
08c4ab8a0c Updated error message about verification timeout 2018-05-15 10:06:37 +02:00
Leo Lamprecht
f86647fc26 12.0.0-canary.26 2018-05-15 10:01:29 +02:00
Javi Velasco
f310f6a86f Accept comma separated cns (#1336) 2018-05-08 21:36:53 +02:00
Javi Velasco
58c6acd265 12.0.0-canary.25 2018-04-27 22:02:10 -07:00
Igor Klopov
c7d97e3866 ignore keep-alive packets for now logs -f (#1331) 2018-04-27 21:45:47 -07:00
Javi Velasco
0890144c61 12.0.0-canary.24 2018-04-26 11:13:14 -07:00
Javi Velasco
69a7d91b57 Safe deployment polling and other minor fixes (#1330)
* 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
2018-04-26 11:07:15 -07:00
Javi Velasco
a9016c88f6 Refactor scale and remove old alias and scale (#1321)
* 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
2018-04-24 19:16:25 -07:00
Igor Klopov
e8990742cf handle keep-alive event in inspect command (#1326) 2018-04-22 20:16:02 -07:00
Javi Velasco
f51400a3a1 12.0.0-canary.23 2018-04-18 11:27:15 -07:00
Javi Velasco
e763ee5301 Handle ENOENT error when deploying unexistent path (#1320)
* Handle ENOENT error when deploying unexistent path

* Show success on dedupped deployments
2018-04-18 11:26:47 -07:00
Javi Velasco
fd978699e8 Migrate to arg@2.0.0 (#1316) 2018-04-17 19:28:45 -07:00
Javi Velasco
bbd9585829 Fix double ambiguous deploy prompt (#1318) 2018-04-17 19:20:27 -07:00
Javi Velasco
54cf1ebb31 12.0.0-canary.22 2018-04-17 18:07:07 -07:00
Javi Velasco
6fc77c6cfa Fix 0 min scale (#1317) 2018-04-17 18:05:04 -07:00
Javi Velasco
f8372e3bb9 12.0.0-canary.21 2018-04-17 10:49:33 -07:00
Naoyuki Kanezawa
6728be7b1a improve image upload (#1293) 2018-04-17 10:37:17 -07:00
Javi Velasco
65e1a1e731 Fix number of instances verification (#1315) 2018-04-17 10:32:32 -07:00
Javi Velasco
cd9478e853 12.0.0-canary.20 2018-04-16 17:46:47 -07:00
Javi Velasco
b9364ed4fc Improve instance verification for deploy (#1313)
* Refactor verify instances for deploy

* Don't rely on return

* Use new verify instances in alias

* Use new verify instances in alias
2018-04-16 17:45:19 -07:00
Leo Lamprecht
2715e8e9d8 12.0.0-canary.19 2018-04-13 23:23:44 -07:00
Javi Velasco
f987c93cf0 Replace combine-async-generators (#1305)
* Replace combine-asyng-generators

* Ignore empty objects from events stream

* Update type for alias event
2018-04-13 21:55:06 -07:00
Javi Velasco
5c254a7151 Print response in docker test (#1304)
* Print response when failing in docker test file

* Add line

* Parse response text as JSON, print if it fails
2018-04-13 19:49:18 -07:00
Leo Lamprecht
f253e29f33 12.0.0-canary.18 2018-04-13 19:05:49 -07:00
Leo Lamprecht
f37fa13eab Added missing dependencies (#1303) 2018-04-13 19:00:17 -07:00
Javi Velasco
64765b393a Refactor deploy events printing (#1302)
* 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
2018-04-13 18:33:27 -07:00
Leo Lamprecht
54c84b4ce0 12.0.0-canary.17 2018-04-11 12:23:06 -07:00
Javi Velasco
146bcba794 Remove old certs command (#1295) 2018-04-11 12:22:49 -07:00
Leo Lamprecht
d3dd1b731d 12.0.0-canary.16 2018-04-11 11:43:12 -07:00
Javi Velasco
d608ee7390 Remove old alias command (#1294) 2018-04-11 11:42:38 -07:00
Leo Lamprecht
4e2e0950c7 12.0.0-canary.15 2018-04-10 17:53:51 -07:00
Leo Lamprecht
ddc7e97ab6 Fixed typo in release instructions 2018-04-10 17:53:27 -07:00
Leo Lamprecht
a21759ee42 Resolved conflicts 2018-04-10 17:53:02 -07:00
Leo Lamprecht
cc4beb94cf Merge branch 'master' into canary 2018-04-10 17:47:11 -07:00
Leo Lamprecht
0bfafa9311 12.0.0-canary.14 2018-04-10 16:38:48 -07:00
Leo Lamprecht
4eefc34629 Moved documentation for releasing out 2018-04-10 16:26:44 -07:00
Leo Lamprecht
4d3f882dc0 Make clear how a release works exactly 2018-04-10 16:08:39 -07:00
Leo Lamprecht
3a802fbb70 Improved intro and contribution section 2018-04-10 16:07:31 -07:00
Leo Lamprecht
6f00b03d24 Made sure the integration tests work as expected 2018-04-10 15:46:41 -07:00
773 changed files with 177277 additions and 7229 deletions

View File

@@ -1,6 +1,5 @@
version: 2
jobs:
install:
docker:
- image: circleci/node:10
@@ -11,9 +10,9 @@ jobs:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "yarn.lock" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- v1-dependencies-{{ checksum "yarn.lock" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: Updating apt packages
command: sudo apt-get update
@@ -22,10 +21,11 @@ jobs:
command: sudo apt-get install golang-go
- run:
name: Installing Dependencies
command: yarn install
command: yarn install --check-files --frozen-lockfile
- save_cache:
paths:
- node_modules
- packages/gatsby-plugin-now/node_modules
- packages/now-build-utils/node_modules
- packages/now-cgi/node_modules
- packages/now-cli/node_modules
@@ -43,6 +43,7 @@ jobs:
root: .
paths:
- node_modules
- packages/gatsby-plugin-now/node_modules
- packages/now-build-utils/node_modules
- packages/now-cgi/node_modules
- packages/now-cli/node_modules
@@ -62,11 +63,11 @@ jobs:
working_directory: ~/repo
steps:
- checkout
- run:
name: Installing apt dependencies
command: sudo apt install -y rsync
- attach_workspace:
at: .
- run:
name: Linking dependencies
command: yarn bootstrap
- run:
name: Building
command: yarn build
@@ -75,6 +76,7 @@ jobs:
- persist_to_workspace:
root: .
paths:
- packages/gatsby-plugin-now/test/fixtures
- packages/now-build-utils/dist
- packages/now-cgi/dist
- packages/now-cli/dist
@@ -91,6 +93,7 @@ jobs:
- packages/now-routing-utils/dist
- packages/now-ruby/dist
- packages/now-static-build/dist
- packages/now-static-build/test/fixtures/10a-gatsby-redirects/plugins
test-lint:
docker:
@@ -107,36 +110,14 @@ jobs:
name: Linting Code
command: yarn test-lint
# test-unit:
# docker:
# - image: circleci/node:10
# working_directory: ~/repo
# steps:
# - checkout
# - attach_workspace:
# at: .
# - run:
# name: Compiling `now dev` HTML error templates
# command: node packages/now-cli/scripts/compile-templates.js
# - run:
# name: Running Unit Tests
# command: yarn test-unit --clean false
# - persist_to_workspace:
# root: .
# paths:
# - packages/now-cli/.nyc_output
test-integration-macos-node-8:
macos:
xcode: '9.2.0'
xcode: '9.0.1'
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Update Node.js
command: curl -sfLS install-node.now.sh/8.11 | sh -s -- --yes
- run:
name: Output version
command: node --version
@@ -221,15 +202,12 @@ jobs:
test-integration-macos-now-dev-node-8:
macos:
xcode: '9.2.0'
xcode: '9.0.1'
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Update Node.js
command: curl -sfLS install-node.now.sh/8.11 | sh -s -- --yes
- run:
name: Output version
command: node --version
@@ -345,7 +323,7 @@ jobs:
name: Running Integration Tests Once
command: yarn test-integration-once --clean false
coverage:
test-unit:
docker:
- image: circleci/node:10
working_directory: ~/repo
@@ -357,8 +335,24 @@ jobs:
name: Compiling `now dev` HTML error templates
command: node packages/now-cli/scripts/compile-templates.js
- run:
name: Run unit tests
command: yarn workspace now run test-unit
name: Output version
command: node --version
- run:
name: Running Unit Tests
command: yarn test-unit --clean false
- persist_to_workspace:
root: .
paths:
- packages/now-cli/.nyc_output
coverage:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Run coverage report
command: yarn workspace now run coverage
@@ -384,36 +378,6 @@ jobs:
name: Finalize Sentry Release
command: sentry-cli releases finalize now-cli@`git describe --tags`
publish-stable:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Saving Authentication Information
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run:
name: Publishing to Stable Channel
command: npm publish --tag latest
publish-canary:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Saving Authentication Information
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run:
name: Publishing to Canary Channel
command: npm publish --tag canary
workflows:
version: 2
unscheduled:
@@ -434,12 +398,6 @@ workflows:
filters:
tags:
only: /.*/
# - test-unit:
# requires:
# - build
# filters:
# tags:
# only: /.*/
- test-integration-macos-node-8:
requires:
- build
@@ -515,12 +473,14 @@ workflows:
- test-integration-once:
requires:
- build
- test-unit:
requires:
- build
filters:
tags:
only: /.*/
- coverage:
requires:
#- test-unit
- test-integration-macos-node-8
- test-integration-macos-node-10
- test-integration-macos-node-12
@@ -534,23 +494,8 @@ workflows:
- test-integration-linux-now-dev-node-10
- test-integration-linux-now-dev-node-12
- test-integration-once
- test-unit
- test-lint
filters:
tags:
only: /.*/
- publish-canary:
requires:
- coverage
filters:
tags:
only: /^.*canary.*($|\b)/
branches:
ignore: /.*/
- publish-stable:
requires:
- coverage
filters:
tags:
only: /^(\d+\.)?(\d+\.)?(\*|\d+)$/
branches:
ignore: /.*/

35
.eslintignore Normal file
View File

@@ -0,0 +1,35 @@
node_modules
dist
# gatsby-plugin-now
packages/gatsby-plugin-now/test/fixtures
# now-build-utils
packages/now-build-utils/test/fixtures
# now-cli
packages/now-cli/@types
packages/now-cli/download
packages/now-cli/dist
packages/now-cli/test/fixtures
packages/now-cli/test/dev/fixtures
packages/now-cli/bin
packages/now-cli/link
packages/now-cli/src/util/dev/templates/*.ts
# now-client
packages/now-client/tests/fixtures
packages/now-client/lib
# now-next
packages/now-next/test/fixtures
# now-node
packages/now-node/src/bridge.ts
packages/now-node/test/fixtures
# now-node-bridge
packages/now-node-bridge/bridge.*
# now-static-build
packages/now-static-build/test/fixtures

64
.eslintrc.json Normal file
View File

@@ -0,0 +1,64 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"modules": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
],
"env": {
"node": true,
"jest": true,
"es6": true
},
"rules": {
"require-atomic-updates": 0,
"@typescript-eslint/ban-ts-ignore": 0,
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-use-before-define": 0
},
"overrides": [
{
"files": ["**/*.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
},
{
"files": ["packages/now-cli/**/*"],
"rules": {
"lines-between-class-members": 0,
"no-async-promise-executor": 0,
"no-control-regex": 0,
"no-empty": 0,
"prefer-const": 0,
"prefer-destructuring": 0,
"@typescript-eslint/ban-types": 0,
"@typescript-eslint/consistent-type-assertions": 0,
"@typescript-eslint/member-delimiter-style": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-inferrable-types": 0,
"@typescript-eslint/no-var-requires": 0
}
},
{
"files": ["packages/now-client/**/*"],
"rules": {
"prefer-const": 0,
"require-atomic-updates": 0,
"@typescript-eslint/ban-ts-ignore": 0,
"@typescript-eslint/no-explicit-any": 0
}
}
]
}

3
.gitattributes vendored Normal file
View File

@@ -0,0 +1,3 @@
# Ignore test fixtures in GitHub Languages
# See https://github.com/github/linguist#vendored-code
packages/*/test/* linguist-vendored

View File

@@ -9,7 +9,7 @@ on:
- '!*'
jobs:
publish:
Publish:
runs-on: ubuntu-latest
@@ -24,7 +24,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: yarn install --pure-lockfile
run: yarn install --check-files --frozen-lockfile
- name: Build
run: yarn build
- name: Publish

3
.gitignore vendored
View File

@@ -1,6 +1,7 @@
node_modules
package-lock.json
dist
.vscode
npm-debug.log
yarn-error.log
.nyc_output
@@ -12,7 +13,9 @@ packages/now-cli/.builders
packages/now-cli/assets
packages/now-cli/src/util/dev/templates/*.ts
packages/now-cli/test/**/yarn.lock
!packages/now-cli/test/dev/**/yarn.lock
packages/now-cli/test/**/node_modules
packages/now-cli/test/dev/fixtures/08-hugo/hugo
packages/now-cli/test/dev/fixtures/**/dist
packages/now-cli/test/dev/fixtures/**/public
packages/now-cli/test/fixtures/integration

View File

@@ -12,5 +12,6 @@ optimistic_updates = true
[merge.message]
title = "pull_request_title"
body = "pull_request_body"
include_pr_number = true
body_type = "markdown"

4
.prettierrc Normal file
View File

@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "es5"
}

View File

@@ -1,20 +1,20 @@
# Builders Developer Reference
# Runtime Developer Reference
The following page is a reference for how to create a Builder using the available Builder's API.
The following page is a reference for how to create a Runtime using the available Runtime 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.
A Runtime is an npm module that exposes a `build` function and optionally an `analyze` function and `prepareCache` function.
Official Runtimes are published to [npmjs.com](https://npmjs.com) as a package and referenced in the `use` property of the `now.json` configuration file.
However, the `use` property will work with any [npm install argument](https://docs.npmjs.com/cli/install) such as a git repo url which is useful for testing your Runtime.
See the [Builders Documentation](https://zeit.co/docs/v2/advanced/builders) to view example usage.
See the [Runtimes Documentation](https://zeit.co/docs/runtimes) to view example usage.
## Builder Exports
## Runtime Exports
### `version`
A **required** exported constant that decides which version of the Builder API to use.
A **required** exported constant that decides which version of the Runtime API to use.
The latest and suggested version is `2`.
The latest and suggested version is `3`.
### `analyze`
@@ -41,7 +41,7 @@ export analyze(options: AnalyzeOptions) {
### `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).
A **required** exported function that returns 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.
@@ -58,9 +58,9 @@ build({
filesRemoved?: Array<String>
}
}) : {
watch: Array<String>,
output: Files output,
routes: Object
watch?: Array<String>,
output: Lambda,
routes?: Object
}
```
@@ -109,7 +109,7 @@ export prepareCache(options: PrepareCacheOptions) {
### `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.
An **optional** exported function that is only used by `now dev` in [Now CLI](https:///download) and indicates whether a [Runtime](https://zeit.co/docs/v2/advanced/runtimes) wants to be responsible for building a certain request path.
```js
shouldServe({
@@ -133,7 +133,7 @@ export shouldServe(options: ShouldServeOptions) {
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
### Runtime Options
The exported functions [`analyze`](#analyze), [`build`](#build), and [`prepareCache`](#preparecache) receive one argument with the following properties.
@@ -145,78 +145,15 @@ The exported functions [`analyze`](#analyze), [`build`](#build), and [`prepareCa
- `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
## Examples
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 }) {
return files[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:
```js
const htmlMinifier = require('html-minifier')
exports.version = 2
exports.analyze = ({ files, entrypoint }) => files[entrypoint].digest
exports.build = async ({ files, entrypoint, config }) => {
const stream = files[entrypoint].toStream()
const options = Object.assign({}, config || {})
const { data } = await FileBlob.fromStream({ stream })
const content = data.toString()
const minified = htmlMinifier(content, options)
const result = new FileBlob({ data: minified })
return {
output: {
[entrypoint]: result
},
watch: [],
routes: {}
}
}
```
### Defining a `prepareCache` step
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.
Check out our [Node.js Runtime](https://github.com/zeit/now/tree/master/packages/now-node), [Go Runtime](https://github.com/zeit/now/tree/master/packages/now-go), [Python Runtime](https://github.com/zeit/now/tree/master/packages/now-python) or [Ruby Runtime](https://github.com/zeit/now/tree/master/packages/now-ruby) for examples of how to build one.
## Technical Details
### Execution Context
A [Serverless Function](https://zeit.co/docs/v2/advanced/concepts/lambdas) is created where the 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.
A [Serverless Function](https://zeit.co/docs/v2/advanced/concepts/lambdas) is created where the Runtime logic is executed. The lambda is run using the Node.js 8 runtime. A brand new sandbox is created for each deployment, for security reasons. The sandbox is cleaned up between executions to ensure no lingering temporary files are shared from build to build.
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.
@@ -228,23 +165,23 @@ When a new build is created, we pre-populate the `workPath` supplied to `analyze
The `analyze` step can modify that directory, and it will not be re-created when it's supplied to `build` and `prepareCache`.
To learn how the cache key is computed and invalidated, refer to the [overview](https://zeit.co/docs/v2/advanced/builders#technical-details).
To learn how the cache key is computed and invalidated, refer to the [overview](https://zeit.co/docs/v2/advanced/runtimes#technical-details).
### Accessing Environment and Secrets
The env and secrets specified by the user as `build.env` are passed to the builder process. This means you can access user env via `process.env` in Node.js.
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 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`.
When you publish your Runtime to npm, make sure to not specify `@now/build-utils` (as seen below in the API definitions) as a dependency, but rather as part of `peerDependencies`.
## Types
### `Files`
```ts
import { File } from '@now/build-utils'
type Files = { [filePath: string]: File }
import { File } from '@now/build-utils';
type Files = { [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.
@@ -265,7 +202,7 @@ An example of a valid output `Files` object is:
This is an abstract type that can be imported if you are using TypeScript.
```ts
import { File } from '@now/build-utils'
import { File } from '@now/build-utils';
```
Valid `File` types include:
@@ -277,7 +214,7 @@ Valid `File` types include:
### `FileRef`
```ts
import { FileRef } from '@now/build-utils'
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`.
@@ -294,7 +231,7 @@ This is a [JavaScript class](https://developer.mozilla.org/en-US/docs/Web/JavaSc
### `FileFsRef`
```ts
import { FileFsRef } from '@now/build-utils'
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.
@@ -312,7 +249,7 @@ This is a [JavaScript class](https://developer.mozilla.org/en-US/docs/Web/JavaSc
### `FileBlob`
```ts
import { FileBlob } from '@now/build-utils'
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.
@@ -330,10 +267,10 @@ This is a [JavaScript class](https://developer.mozilla.org/en-US/docs/Web/JavaSc
### `Lambda`
```ts
import { Lambda } from '@now/build-utils'
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).
This is a [JavaScript class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), called a Serverless Function, that can be created by supplying `files`, `handler`, `runtime`, and `environment` as an object to the [`createLambda`](#createlambda) helper. The instances of this class should not be created directly. Instead, invoke the [`createLambda`](#createlambda) helper function.
**Properties:**
@@ -346,39 +283,39 @@ This is a [JavaScript class](https://developer.mozilla.org/en-US/docs/Web/JavaSc
This is an abstract enumeration type that is implemented by one of the following possible `String` values:
- `nodejs12.x`
- `nodejs10.x`
- `nodejs8.10`
- `go1.x`
- `java-1.8.0-openjdk`
- `java11`
- `python3.8`
- `python3.6`
- `python2.7`
- `dotnetcore2.1`
- `dotnetcore2.0`
- `dotnetcore1.0`
- `ruby2.5`
- `provided`
## 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.
The following is exposed by `@now/build-utils` to simplify the process of writing Runtimes, manipulating the file system, using the above types, etc.
### `createLambda`
Signature: `createLambda(Object spec) : Lambda`
```ts
import { createLambda } from '@now/build-utils'
import { createLambda } from '@now/build-utils';
```
Constructor for the [`Lambda`](#lambda) type.
```js
const { createLambda, FileBlob } = require('@now/build-utils')
const { createLambda, FileBlob } = require('@now/build-utils');
await createLambda({
runtime: 'nodejs8.10',
handler: 'index.main',
files: {
'index.js': new FileBlob({ data: 'exports.main = () => {}' })
}
})
'index.js': new FileBlob({ data: 'exports.main = () => {}' }),
},
});
```
### `download`
@@ -386,7 +323,7 @@ await createLambda({
Signature: `download() : Files`
```ts
import { download } from '@now/build-utils'
import { download } from '@now/build-utils';
```
This utility allows you to download the contents of a [`Files`](#files) data structure, therefore creating the filesystem represented in it.
@@ -396,7 +333,7 @@ Since `Files` is an abstract way of representing files, you can think of `downlo
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
await download(files, workPath, meta)
await download(files, workPath, meta);
```
### `glob`
@@ -404,7 +341,7 @@ await download(files, workPath, meta)
Signature: `glob() : Files`
```ts
import { glob } from '@now/build-utils'
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).
@@ -425,7 +362,7 @@ exports.build = ({ files, workPath }) => {
Signature: `getWriteableDirectory() : String`
```ts
import { getWriteableDirectory } from '@now/build-utils'
import { getWriteableDirectory } from '@now/build-utils';
```
In some occasions, you might want to write to a temporary directory.
@@ -435,7 +372,7 @@ In some occasions, you might want to write to a temporary directory.
Signature: `rename(Files) : Files`
```ts
import { rename } from '@now/build-utils'
import { rename } from '@now/build-utils';
```
Renames the keys of the [`Files`](#files) object, which represent the paths. For example, to remove the `*.go` suffix you can use:

View File

@@ -1,40 +0,0 @@
# Publishing to npm
Always publish to the Canary Channel as soon as a PR is merged into the `canary` branch.
```
yarn publish-canary
```
Publish the Stable Channel weekly.
- Cherry pick each commit from `canary` to `master` branch
- Verify that you are _in-sync_ with canary (with the exception of the `version` line in `package.json`)
- Deploy the modified Builders
```
# View differences excluding "Publish" commits
git checkout canary && git pull
git log --pretty=format:"$ad- %s [%an]" | grep -v Publish > ~/Desktop/canary.txt
git checkout master && git pull
git log --pretty=format:"$ad- %s [%an]" | grep -v Publish > ~/Desktop/master.txt
diff ~/Desktop/canary.txt ~/Desktop/master.txt
# Cherry pick all PRs from canary into master ...
git cherry-pick <PR501_COMMIT_SHA>
git cherry-pick <PR502_COMMIT_SHA>
git cherry-pick <PR503_COMMIT_SHA>
git cherry-pick <PR504_COMMIT_SHA>
# Verify the only difference is "version" in package.json
git diff origin/canary
# Ship it
yarn publish-stable
```
After running this publish step, GitHub Actions will take care of publishing the modified Builder packages to npm.
If for some reason GitHub Actions fails to publish the npm package, you may do so
manually by running `npm publish` from the package directory. Make sure to
use `npm publish --tag canary` if you are publishing a canary release!

View File

@@ -1,10 +1,8 @@
![now](https://assets.zeit.co/image/upload/v1542240976/repositories/now-cli/now-cli-repo-banner-v3.png)
[![Build Status](https://circleci.com/gh/zeit/now.svg?&style=shield)](https://circleci.com/gh/zeit/workflows/now)
[![Build Status](https://badgen.net/circleci/github/zeit/now/master)](https://circleci.com/gh/zeit/workflows/now/tree/master)
[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](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).
## Usage
To install the latest version of Now CLI, visit [zeit.co/download](https://zeit.co/download) or run this command:

View File

@@ -1,25 +0,0 @@
# Versioning
Builders are released to two different channels.
## Channels
| Channel | Git Branch | npm dist-tag | use example |
| ------- | ------------------------------------------------------------- | ------------ | ------------------ |
| Canary | [canary](https://github.com/zeit/now/commits/canary) | `@canary` | `@now/node@canary` |
| Stable | [master](https://github.com/zeit/now/commits/master) | `@latest` | `@now/node@latest` |
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.

42
changelog.js Normal file
View File

@@ -0,0 +1,42 @@
const { execSync } = require('child_process');
const commit = execSync('git log --pretty=format:"%s %H"')
.toString()
.trim()
.split('\n')
.find(line => line.startsWith('Publish Stable '))
.split(' ')
.pop();
if (!commit) {
throw new Error('Unable to find last publish commit');
}
const log =
execSync(`git log --pretty=format:"- %s [%an]" ${commit}...HEAD`)
.toString()
.trim()
.split('\n')
.filter(line => !line.startsWith('- Publish Canary '))
.join('\n') || 'NO CHANGES DETECTED';
console.log(`Changes since the last Stable release (${commit.slice(0, 7)}):`);
console.log(`\n${log}\n`);
const pkgs =
Array.from(
new Set(
execSync(`git diff --name-only ${commit}...HEAD`)
.toString()
.trim()
.split('\n')
.filter(line => line.startsWith('packages/'))
.map(line => line.split('/')[1])
.map(pkgName => require(`./packages/${pkgName}/package.json`).name)
)
).join(',') || 'now';
console.log('To publish a stable release, execute the following:');
console.log(
`\ngit pull && lerna version --message 'Publish Stable' --exact --force-publish=${pkgs}\n`
);

View File

@@ -2,7 +2,7 @@
#### Why This Error Occurred
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 either the intended set of nameservers or the given verification TXT record.
#### Possible Ways to Fix It

View File

@@ -0,0 +1,11 @@
# Invalid Token Value
#### Why This Error Occurred
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 `./now/auth.json` file located in your user directory or [from the dashboard](https://zeit.co/account/tokens).

View File

@@ -19,6 +19,8 @@ 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`
(port) option to bind to the `$PORT` specified from the builder:
> *In Windows environments, reference the `PORT` environment variable with `%PORT%`*
```
{
...

View File

@@ -1,32 +1,64 @@
{
"name": "now-builders",
"version": "0.0.0",
"private": true,
"license": "MIT",
"workspaces": [
"packages/*"
],
"dependencies": {
"lerna": "3.16.4"
},
"devDependencies": {
"@zeit/ncc": "0.20.4",
"async-retry": "1.2.3",
"buffer-replace": "1.0.0",
"node-fetch": "2.6.0"
},
"scripts": {
"lerna": "lerna",
"bootstrap": "lerna bootstrap",
"publish-stable": "git checkout master && git pull && lerna version --exact",
"publish-canary": "git checkout canary && git pull && lerna version prerelease --preid canary --exact",
"publish-from-github": "./.circleci/publish.sh",
"build": "node run.js build all",
"test-lint": "node run.js test-lint",
"test-unit": "node run.js test-unit",
"test-integration": "node run.js test-integration",
"test-integration-once": "node run.js test-integration-once",
"test-integration-now-dev": "node run.js test-integration-now-dev"
"name": "now-builders",
"version": "0.0.0",
"private": true,
"license": "MIT",
"workspaces": {
"packages": [
"packages/*"
],
"nohoist": [
"**/@types/**"
]
},
"dependencies": {
"lerna": "3.16.4"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "2.0.0",
"@typescript-eslint/parser": "2.0.0",
"@zeit/ncc": "0.20.4",
"async-retry": "1.2.3",
"buffer-replace": "1.0.0",
"eslint": "6.2.2",
"eslint-config-prettier": "6.1.0",
"husky": "3.0.4",
"lint-staged": "9.2.5",
"node-fetch": "2.6.0",
"prettier": "1.18.2"
},
"scripts": {
"lerna": "lerna",
"bootstrap": "lerna bootstrap",
"publish-stable": "echo 'Run `yarn changelog` for instructions'",
"publish-canary": "git pull && lerna version prerelease --preid canary --message 'Publish Canary' --exact",
"publish-from-github": "./.circleci/publish.sh",
"changelog": "node changelog.js",
"build": "node run.js build all",
"test-lint": "node run.js test-lint",
"test-unit": "node run.js test-unit",
"test-integration": "node run.js test-integration",
"test-integration-once": "node run.js test-integration-once",
"test-integration-now-dev": "node run.js test-integration-now-dev",
"lint": "eslint . --ext .ts,.js"
},
"lint-staged": {
"*.{js,ts}": [
"prettier --write",
"eslint",
"git add"
],
"*.{json,md}": [
"prettier --write",
"git add"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"resolutions": {
"signal-exit": "TooTallNate/signal-exit#update/sighub-to-sigint-on-windows"
}
}

View File

@@ -0,0 +1,6 @@
#!/bin/bash
set -euo pipefail
# build fixtures for tests
yarn --cwd test/fixtures install
yarn --cwd test/fixtures run build

View File

@@ -0,0 +1,33 @@
const path = require('path');
const writeFile = require('util').promisify(require('fs').writeFile);
const REDIRECT_FILE_NAME = '__now_routes_g4t5bY.json';
exports.onPostBuild = async ({ store }) => {
const { redirects, program } = store.getState();
if (!redirects.length === 0) {
return;
}
const routes = [{ handle: 'filesystem' }];
for (const redirect of redirects) {
const route = {
src: redirect.fromPath,
status: redirect.statusCode || (redirect.isPermanent ? 301 : 302),
headers: { Location: redirect.toPath },
};
if (redirect.force) {
routes.unshift(route);
} else {
routes.push(route);
}
}
await writeFile(
path.join(program.directory, 'public', REDIRECT_FILE_NAME),
JSON.stringify(routes)
);
};

View File

@@ -0,0 +1 @@
// noop

View File

@@ -0,0 +1,36 @@
{
"name": "gatsby-plugin-now",
"version": "1.2.6-canary.0",
"main": "index.js",
"license": "MIT",
"homepage": "https://zeit.co/guides/deploying-gatsby-with-now",
"repository": {
"type": "git",
"url": "https://github.com/zeit/now.git",
"directory": "packages/gatsby-plugin-now"
},
"keywords": [
"gatsby",
"gatsby-plugin"
],
"scripts": {
"build": "./build.sh",
"test-integration-once": "jest --verbose"
},
"files": [
"index.js",
"gatsby-node.js"
],
"peerDependencies": {
"gatsby": ">=2.0.0"
},
"devDependencies": {
"jest": "24.9.0"
},
"jest": {
"testPathIgnorePatterns": [
"/node_modules/",
"<rootDir>/test/fixtures/"
]
}
}

View File

@@ -0,0 +1,24 @@
# gatsby-plugin-now
This plugin generates [Now Routes](https://zeit.co/docs/v2/advanced/routes) for [redirects](https://www.gatsbyjs.org/docs/actions/#createRedirect) you configured for to your Gatsby project.
### Usage
1. Install the plugin:
```
npm install gatsby-plugin-now --save-dev
```
2. Add it to the configuration file:
```
// gatsby-config.js
module.exports = {
plugins: [
'gatsby-plugin-now'
]
}
```
3. [Deploy your project to ZEIT Now](https://www.gatsbyjs.org/docs/deploying-to-zeit-now/)

View File

@@ -0,0 +1,86 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test generated now routes 1`] = `
Array [
Object {
"headers": Object {
"Location": "/",
},
"src": "/my-special-redirect",
"status": 302,
},
Object {
"handle": "filesystem",
},
Object {
"headers": Object {
"Location": "/page-2",
},
"src": "/page2",
"status": 301,
},
Object {
"headers": Object {
"Location": "/page-2/",
},
"src": "/page2/",
"status": 301,
},
Object {
"headers": Object {
"Location": "/",
},
"src": "/orange",
"status": 302,
},
Object {
"headers": Object {
"Location": "/",
},
"src": "/grape",
"status": 302,
},
Object {
"headers": Object {
"Location": "/page-2/",
},
"src": "/blue",
"status": 302,
},
Object {
"headers": Object {
"Location": "/page-2/",
},
"src": "/randirect",
"status": 302,
},
Object {
"headers": Object {
"Location": "/",
},
"src": "/juice",
"status": 302,
},
Object {
"headers": Object {
"Location": "/",
},
"src": "/soda",
"status": 302,
},
Object {
"headers": Object {
"Location": "/page-2/",
},
"src": "/donut",
"status": 302,
},
Object {
"headers": Object {
"Location": "/page-2/",
},
"src": "/randorect",
"status": 302,
},
]
`;

View File

@@ -0,0 +1,4 @@
public
node_modules
.cache
yarn.lock

View File

@@ -0,0 +1,3 @@
module.exports = {
plugins: [{ resolve: require.resolve('../../') }]
};

View File

@@ -0,0 +1,105 @@
'use strict';
// Implement the Gatsby API “createPages”. This is called once the
// data layer is bootstrapped to let plugins create pages from data.
exports.createPages = ({ actions }) => {
// need createRedirect action in actions collection
// to make the redirection magic happen.
// https://www.gatsbyjs.org/docs/bound-action-creators/
const { createRedirect } = actions;
// Lets set up some string consts to use thoroughout the following.
// MDN > JavaScript reference > Statements and declarations
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const
// Maybe we usually redirect to page 2, with trailing slash.
const page2Path = `/page-2/`;
// But sometimes to homepage.
const homePath = `/`;
// One-off redirect, note trailing slash missing on fromPath and
// toPath here.
createRedirect({
fromPath: `/page2`,
isPermanent: true,
redirectInBrowser: true,
toPath: `/page-2`
});
// Another one-off redirect, note trailing slash on toPath here.
// This time we want trailing slash on toPath so we use
// page2Path. Need to handle trailing-slashed and non-trailing-
// slashed fromPaths separately, Gatsby serves page components
// at either version by default, but we need to explicitly redirect
// both versions independently, more on page components:
// Docs > Building with Components
// https://www.gatsbyjs.org/docs/building-with-components/
// and handling trailing slashes:
// Docs > Creating and modifying pages > Removing trailing slashes
// https://www.gatsbyjs.org/docs/creating-and-modifying-pages/#removing-trailing-slashes
createRedirect({
fromPath: `/page2/`,
isPermanent: true,
redirectInBrowser: true,
toPath: page2Path
});
// One approach to handle several redirects at once is to create an
// array of from/to path pairs.
let redirectBatch1 = [
{ f: `/orange`, t: `/` },
// We could use homePath and page2Path directly here.
{ f: `/grape`, t: homePath },
{ f: `/blue`, t: page2Path },
// or leave to empty and swap for page2Path later on.
{ f: `/randirect`, t: `` }
];
// Then we can loop through the array of object literals to create
// each redirect. A for loop would do the trick
for (var { f: f, t: t } of redirectBatch1) {
// Here we swap any empty toPath values for trusty page 2 via
// page2Path.
if (t === ``) {
t = page2Path;
}
createRedirect({
fromPath: f,
redirectInBrowser: true,
toPath: t
});
// Uncomment next line to see loop in action during build
// console.log('\nRedirecting:\n' + f + '\nTo:\n' + t + '\n');
// or check .cache/redirects.json post-compile.
}
// A more modern approach might use forEach rather than for...of
// Compare
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#for...of_statement
// and
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
let redirectBatch2 = [
{ f: `/juice`, t: `/` },
{ f: `/soda`, t: `/` },
{ f: `/donut`, t: page2Path },
{ f: `/randorect`, t: `` }
];
redirectBatch2.forEach(({ f, t }) => {
if (t === ``) {
t = page2Path;
}
createRedirect({
fromPath: f,
redirectInBrowser: true,
toPath: t
});
// Uncomment next line to see forEach in action during build
// console.log('\nRedirecting:\n' + f + '\nTo:\n' + t + '\n');
});
createRedirect({
fromPath: '/my-special-redirect',
toPath: homePath,
force: true
});
};

View File

@@ -0,0 +1,11 @@
{
"name": "fixtures",
"dependencies": {
"gatsby": "2.14.0",
"react": "16.9.0",
"react-dom": "16.9.0"
},
"scripts": {
"build": "gatsby build"
}
}

View File

@@ -0,0 +1,9 @@
import React from 'react';
const IndexPage = () => (
<div>
<h1>Hi people</h1>
</div>
);
export default IndexPage;

View File

@@ -0,0 +1,5 @@
test('test generated now routes', async () => {
const nowRoutes = require('./fixtures/public/__now_routes_g4t5bY.json');
expect(nowRoutes).toMatchSnapshot();
});

View File

@@ -1,3 +1,4 @@
?.js
dist
test/symlinks-out
test/symlinks.zip

View File

@@ -1,6 +1,12 @@
#!/bin/sh
set -eu
out="dist"
rm -rf "$out"
tsc
rm dist/index.js
ncc build src/index.ts -o dist/main
mv dist/main/index.js dist/index.js
rm -rf dist/main
rm "$out/index.js"
ncc build "src/index.ts" -o "$out/main"
mv "$out/main/index.js" "$out/index.js"
rm -rf "$out/main"

View File

@@ -0,0 +1,5 @@
module.exports = {
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
};

View File

@@ -1,10 +1,10 @@
{
"name": "@now/build-utils",
"version": "0.9.14",
"version": "1.2.0",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.js",
"homepage": "https://zeit.co/docs/v2/deployments/builders/developer-guide",
"homepage": "https://github.com/zeit/now/blob/master/DEVELOPING_A_RUNTIME.md",
"repository": {
"type": "git",
"url": "https://github.com/zeit/now.git",
@@ -12,31 +12,39 @@
},
"scripts": {
"build": "./build.sh",
"test-integration-once": "jest --env node --verbose --runInBand",
"test-unit": "jest --env node --verbose --runInBand test/unit.*test.*",
"test-integration-once": "jest --env node --verbose --runInBand test/integration.test.js",
"prepublishOnly": "./build.sh"
},
"devDependencies": {
"@iarna/toml": "2.2.3",
"@types/async-retry": "^1.2.1",
"@types/cross-spawn": "6.0.0",
"@types/end-of-stream": "^1.4.0",
"@types/fs-extra": "^5.0.5",
"@types/glob": "^7.1.1",
"@types/jest": "24.0.22",
"@types/js-yaml": "3.12.1",
"@types/multistream": "2.1.1",
"@types/node-fetch": "^2.1.6",
"@types/semver": "6.0.0",
"@types/yazl": "^2.4.1",
"aggregate-error": "3.0.1",
"async-retry": "1.2.3",
"async-sema": "2.1.4",
"boxen": "4.2.0",
"cross-spawn": "6.0.5",
"end-of-stream": "1.4.1",
"execa": "^1.0.0",
"fs-extra": "7.0.0",
"glob": "7.1.3",
"into-stream": "5.0.0",
"jest": "24.9.0",
"js-yaml": "3.13.1",
"minimatch": "3.0.4",
"multistream": "2.1.1",
"node-fetch": "2.2.0",
"semver": "6.1.1",
"ts-jest": "24.1.0",
"typescript": "3.5.2",
"yazl": "2.4.3"
}

View File

@@ -1,7 +1,5 @@
export default function debug(message: string, ...additional: any[]) {
if (process.env.NOW_BUILDER_DEBUG) {
console.log(message, ...additional);
} else if (process.env.NOW_BUILDER_ANNOTATE) {
console.log(`[now-builder-debug] ${message}`, ...additional);
}
}

View File

@@ -1,5 +1,12 @@
import { PackageJson, Builder, Config } from './types';
import minimatch from 'minimatch';
import { valid as validSemver } from 'semver';
import {
Builder,
Config,
BuilderFunctions,
DetectorResult,
DetectorOutput,
} from './types';
interface ErrorResponse {
code: string;
@@ -8,81 +15,139 @@ interface ErrorResponse {
interface Options {
tag?: 'canary' | 'latest' | string;
}
const src: string = 'package.json';
const config: Config = { zeroConfig: true };
const MISSING_BUILD_SCRIPT_ERROR: ErrorResponse = {
code: 'missing_build_script',
message:
'Your `package.json` file is missing a `build` property inside the `script` property.' +
'\nMore details: https://zeit.co/docs/v2/advanced/platform/frequently-asked-questions#missing-build-script',
};
// Static builders are special cased in `@now/static-build`
function getBuilders(): Map<string, Builder> {
return new Map<string, Builder>([
['next', { src, use: '@now/next', config }],
]);
functions?: BuilderFunctions;
}
// Must be a function to ensure that the returned
// object won't be a reference
function getApiBuilders(): Builder[] {
function getApiBuilders({ tag }: Pick<Options, 'tag'> = {}): Builder[] {
const withTag = tag ? `@${tag}` : '';
const config = { zeroConfig: true };
return [
{ src: 'api/**/*.js', use: '@now/node', config },
{ src: 'api/**/*.ts', use: '@now/node', config },
{ src: 'api/**/*.go', use: '@now/go', config },
{ src: 'api/**/*.py', use: '@now/python', config },
{ src: 'api/**/*.rb', use: '@now/ruby', config },
{ src: 'api/**/*.js', use: `@now/node${withTag}`, config },
{ src: 'api/**/*.ts', use: `@now/node${withTag}`, config },
{ src: 'api/**/*.go', use: `@now/go${withTag}`, config },
{ src: 'api/**/*.py', use: `@now/python${withTag}`, config },
{ src: 'api/**/*.rb', use: `@now/ruby${withTag}`, config },
];
}
function hasPublicDirectory(files: string[]) {
return files.some(name => name.startsWith('public/'));
function hasDirectory(fileName: string, files: string[]) {
return files.some(name => name.startsWith(`${fileName}/`));
}
function hasBuildScript(pkg: PackageJson | undefined) {
const { scripts = {} } = pkg || {};
return Boolean(scripts && scripts['build']);
}
function getApiFunctionBuilder(
file: string,
prevBuilder: Builder | undefined,
{ functions = {} }: Pick<Options, 'functions'>
) {
const key = Object.keys(functions).find(
k => file === k || minimatch(file, k)
);
const fn = key ? functions[key] : undefined;
async function detectBuilder(pkg: PackageJson): Promise<Builder> {
for (const [dependency, builder] of getBuilders()) {
const deps = Object.assign({}, pkg.dependencies, pkg.devDependencies);
// Return the builder when a dependency matches
if (deps[dependency]) {
return builder;
}
if (!fn || (!fn.runtime && !prevBuilder)) {
return prevBuilder;
}
// By default we'll choose the `static-build` builder
return { src, use: '@now/static-build', config };
const src = (prevBuilder && prevBuilder.src) || file;
const use = fn.runtime || (prevBuilder && prevBuilder.use);
const config: Config = { zeroConfig: true };
if (key) {
Object.assign(config, {
functions: {
[key]: fn,
},
});
}
const { includeFiles, excludeFiles } = fn;
if (includeFiles) Object.assign(config, { includeFiles });
if (excludeFiles) Object.assign(config, { excludeFiles });
return use ? { use, src, config } : prevBuilder;
}
function detectFrontBuilder(
detectorResult: Partial<DetectorOutput>,
builders: Builder[],
options: Options
): Builder {
const { tag } = options;
const withTag = tag ? `@${tag}` : '';
const { framework, buildCommand, outputDirectory } = detectorResult;
const frameworkSlug = framework ? framework.slug : null;
const config: Config = {
zeroConfig: true,
};
if (buildCommand) {
config.buildCommand = buildCommand;
}
if (outputDirectory) {
config.outputDirectory = outputDirectory;
}
// All unused functions will be used for the frontend
if (options.functions) {
Object.entries(options.functions).forEach(([key, func]) => {
if (
builders.every(
b => !(b.config && b.config.functions && b.config.functions[key])
)
) {
config.functions = config.functions || {};
config.functions[key] = { ...func };
}
});
}
if (frameworkSlug === 'next') {
return { src: 'package.json', use: `@now/next${withTag}`, config };
}
return { src: 'package.json', use: `@now/static-build${withTag}`, config };
}
// Files that match a specific pattern will get ignored
export function ignoreApiFilter(file: string) {
if (file.includes('/.')) {
return false;
export function getIgnoreApiFilter(optionsOrBuilders: Options | Builder[]) {
const possiblePatterns: string[] = getApiBuilders().map(b => b.src);
if (Array.isArray(optionsOrBuilders)) {
optionsOrBuilders.forEach(({ src }) => possiblePatterns.push(src));
} else if (optionsOrBuilders.functions) {
Object.keys(optionsOrBuilders.functions).forEach(p =>
possiblePatterns.push(p)
);
}
if (file.includes('/_')) {
return false;
}
return (file: string) => {
if (file.includes('/.')) {
return false;
}
if (file.endsWith('.d.ts')) {
return false;
}
if (file.includes('/_')) {
return false;
}
// If the file does not match any builder we also
// don't want to create a route e.g. `package.json`
if (getApiBuilders().every(({ src }) => !minimatch(file, src))) {
return false;
}
if (file.endsWith('.d.ts')) {
return false;
}
return true;
if (possiblePatterns.every(p => !(file === p || minimatch(file, p)))) {
return false;
}
return true;
};
}
// We need to sort the file paths by alphabet to make
@@ -91,92 +156,257 @@ export function sortFiles(fileA: string, fileB: string) {
return fileA.localeCompare(fileB);
}
async function detectApiBuilders(files: string[]): Promise<Builder[]> {
function detectApiBuilders(files: string[], options: Options): Builder[] {
const builds = files
.sort(sortFiles)
.filter(ignoreApiFilter)
.filter(getIgnoreApiFilter(options))
.map(file => {
const result = getApiBuilders().find(
({ src }): boolean => minimatch(file, src)
);
return result ? { ...result, src: file } : null;
const apiBuilders = getApiBuilders(options);
const apiBuilder = apiBuilders.find(b => minimatch(file, b.src));
const fnBuilder = getApiFunctionBuilder(file, apiBuilder, options);
return fnBuilder ? { ...fnBuilder, src: file } : null;
});
const finishedBuilds = builds.filter(Boolean);
return finishedBuilds as Builder[];
return builds.filter(Boolean) as Builder[];
}
// When a package has files that conflict with `/api` routes
// e.g. Next.js pages/api we'll check it here and return an error.
function checkConflictingFiles(
files: string[],
builders: Builder[]
): ErrorResponse | null {
// For Next.js
if (builders.some(b => b.use.startsWith('@now/next'))) {
const hasApiPages = files.some(file => file.startsWith('pages/api/'));
const hasApiBuilders = builders.some(b => b.src.startsWith('api/'));
if (hasApiPages && hasApiBuilders) {
return {
code: 'conflicting_files',
message:
'It is not possible to use `api` and `pages/api` at the same time, please only use one option',
};
}
}
return null;
}
// When e.g. Next.js receives a `functions` property it has to make sure,
// that it can handle those files, otherwise there are unused functions.
function checkUnusedFunctionsOnFrontendBuilder(
files: string[],
builder: Builder
): ErrorResponse | null {
const { config: { functions = undefined } = {} } = builder;
if (!functions) return null;
if (builder.use.startsWith('@now/next')) {
const matchingFiles = files.filter(file =>
Object.keys(functions).some(key => file === key || minimatch(file, key))
);
for (const matchedFile of matchingFiles) {
if (
!matchedFile.startsWith('src/pages/') &&
!matchedFile.startsWith('pages/')
) {
return {
code: 'unused_function',
message:
`The function for "${matchedFile}" can't be handled by any runtime. ` +
`Please provide one with the "runtime" option.`,
};
}
}
}
return null;
}
function validateFunctions(files: string[], { functions = {} }: Options) {
for (const [path, func] of Object.entries(functions)) {
if (path.length > 256) {
return {
code: 'invalid_function_glob',
message: 'Function globs must be less than 256 characters long.',
};
}
if (!func || typeof func !== 'object') {
return {
code: 'invalid_function',
message: 'Function must be an object.',
};
}
if (Object.keys(func).length === 0) {
return {
code: 'invalid_function',
message: 'Function must contain at least one property.',
};
}
if (
func.maxDuration !== undefined &&
(func.maxDuration < 1 ||
func.maxDuration > 900 ||
!Number.isInteger(func.maxDuration))
) {
return {
code: 'invalid_function_duration',
message: 'Functions must have a duration between 1 and 900.',
};
}
if (
func.memory !== undefined &&
(func.memory < 128 || func.memory > 3008 || func.memory % 64 !== 0)
) {
return {
code: 'invalid_function_memory',
message:
'Functions must have a memory value between 128 and 3008 in steps of 64.',
};
}
if (path.startsWith('/')) {
return {
code: 'invalid_function_source',
message: `The function path "${path}" is invalid. The path must be relative to your project root and therefore cannot start with a slash.`,
};
}
if (files.some(f => f === path || minimatch(f, path)) === false) {
return {
code: 'invalid_function_source',
message: `No source file matched the function for ${path}.`,
};
}
if (func.runtime !== undefined) {
const tag = `${func.runtime}`.split('@').pop();
if (!tag || !validSemver(tag)) {
return {
code: 'invalid_function_runtime',
message:
'Function Runtimes must have a valid version, for example `now-php@1.0.0`.',
};
}
}
if (func.includeFiles !== undefined) {
if (typeof func.includeFiles !== 'string') {
return {
code: 'invalid_function_property',
message: `The property \`includeFiles\` must be a string.`,
};
}
}
if (func.excludeFiles !== undefined) {
if (typeof func.excludeFiles !== 'string') {
return {
code: 'invalid_function_property',
message: `The property \`excludeFiles\` must be a string.`,
};
}
}
}
return null;
}
// When zero config is used we can call this function
// to determine what builders to use
export async function detectBuilders(
files: string[],
pkg?: PackageJson | undefined | null,
options?: Options
detectorResult: Partial<DetectorResult> | null = null,
options: Options = {}
): Promise<{
builders: Builder[] | null;
errors: ErrorResponse[] | null;
warnings: ErrorResponse[];
}> {
const errors: ErrorResponse[] = [];
const warnings: ErrorResponse[] = [];
// Detect all builders for the `api` directory before anything else
let builders = await detectApiBuilders(files);
const functionError = validateFunctions(files, options);
if (pkg && hasBuildScript(pkg)) {
builders.push(await detectBuilder(pkg));
} else {
if (pkg && builders.length === 0) {
// We only show this error when there are no api builders
// since the dependencies of the pkg could be used for those
errors.push(MISSING_BUILD_SCRIPT_ERROR);
return { errors, builders: null };
}
// We allow a `public` directory
// when there are no build steps
if (hasPublicDirectory(files)) {
builders.push({
use: '@now/static',
src: 'public/**/*',
config,
});
} else if (builders.length > 0) {
// We can't use pattern matching, since `!(api)` and `!(api)/**/*`
// won't give the correct results
builders.push(
...files
.filter(name => !name.startsWith('api/'))
.filter(name => !(name === 'package.json'))
.map(name => ({
use: '@now/static',
src: name,
config,
}))
);
}
if (functionError) {
return {
builders: null,
errors: [functionError],
warnings,
};
}
// Change the tag for the builders
if (builders && builders.length) {
const tag = options && options.tag;
// Detect all builders for the `api` directory before anything else
const builders = detectApiBuilders(files, options);
if (tag) {
builders = builders.map((originBuilder: Builder) => {
// Copy builder to make sure it is not a reference
const builder = { ...originBuilder };
if (detectorResult && detectorResult.buildCommand) {
const frontendBuilder = detectFrontBuilder(
detectorResult,
builders,
options
);
builders.push(frontendBuilder);
// @now/static has no canary builder
if (builder.use !== '@now/static') {
builder.use = `${builder.use}@${tag}`;
}
const conflictError = checkConflictingFiles(files, builders);
return builder;
});
if (conflictError) {
warnings.push(conflictError);
}
const unusedFunctionError = checkUnusedFunctionsOnFrontendBuilder(
files,
frontendBuilder
);
if (unusedFunctionError) {
return {
builders: null,
errors: [unusedFunctionError],
warnings,
};
}
} else if (
detectorResult &&
detectorResult.outputDirectory &&
hasDirectory(detectorResult.outputDirectory, files)
) {
builders.push({
use: '@now/static',
src: [...detectorResult.outputDirectory.split('/'), '**', '*']
.filter(Boolean)
.join('/'),
config: { zeroConfig: true },
});
} else if (hasDirectory('public', files)) {
builders.push({
use: '@now/static',
src: 'public/**/*',
config: { zeroConfig: true },
});
} else if (
builders.length > 0 &&
files.some(f => !f.startsWith('api/') && f !== 'package.json')
) {
// Everything besides the api directory
// and package.json can be served as static files
builders.push({
use: '@now/static',
src: '!{api/**,package.json}',
config: { zeroConfig: true },
});
}
return {
builders: builders.length ? builders : null,
errors: errors.length ? errors : null,
warnings,
};
}

View File

@@ -1,6 +1,6 @@
import { Route, Builder } from './types';
import { parse as parsePath } from 'path';
import { ignoreApiFilter, sortFiles } from './detect-builders';
import { Route, Builder } from './types';
import { getIgnoreApiFilter, sortFiles } from './detect-builders';
function escapeName(name: string) {
const special = '[]^$.|?*+()'.split('');
@@ -43,37 +43,35 @@ function getSegmentName(segment: string): string | null {
function createRouteFromPath(filePath: string): Route {
const parts = filePath.split('/');
let counter: number = 1;
let counter = 1;
const query: string[] = [];
const srcParts = parts.map(
(segment, index): string => {
const name = getSegmentName(segment);
const isLast = index === parts.length - 1;
const srcParts = parts.map((segment, index): string => {
const name = getSegmentName(segment);
const isLast = index === parts.length - 1;
if (name !== null) {
// We can't use `URLSearchParams` because `$` would get escaped
query.push(`${name}=$${counter++}`);
return `([^\\/]+)`;
} else if (isLast) {
const { name: fileName, ext } = parsePath(segment);
const isIndex = fileName === 'index';
const prefix = isIndex ? '\\/' : '';
if (name !== null) {
// We can't use `URLSearchParams` because `$` would get escaped
query.push(`${name}=$${counter++}`);
return `([^\\/]+)`;
} else if (isLast) {
const { name: fileName, ext } = parsePath(segment);
const isIndex = fileName === 'index';
const prefix = isIndex ? '\\/' : '';
const names = [
prefix,
prefix + escapeName(fileName),
prefix + escapeName(fileName) + escapeName(ext),
].filter(Boolean);
const names = [
isIndex ? prefix : `${fileName}\\/`,
prefix + escapeName(fileName),
prefix + escapeName(fileName) + escapeName(ext),
].filter(Boolean);
// Either filename with extension, filename without extension
// or nothing when the filename is `index`
return `(${names.join('|')})${isIndex ? '?' : ''}`;
}
return segment;
// Either filename with extension, filename without extension
// or nothing when the filename is `index`
return `(${names.join('|')})${isIndex ? '?' : ''}`;
}
);
return segment;
});
const { name: fileName } = parsePath(filePath);
const isIndex = fileName === 'index';
@@ -120,7 +118,7 @@ function partiallyMatches(pathA: string, pathB: string): boolean {
return false;
}
// Counts how often a path occurres when all placeholders
// Counts how often a path occurs when all placeholders
// got resolved, so we can check if they have conflicts
function pathOccurrences(filePath: string, files: string[]): string[] {
const getAbsolutePath = (unresolvedPath: string): string => {
@@ -199,7 +197,10 @@ interface RoutesResult {
error: { [key: string]: string } | null;
}
async function detectApiRoutes(files: string[]): Promise<RoutesResult> {
async function detectApiRoutes(
files: string[],
builders: Builder[]
): Promise<RoutesResult> {
if (!files || files.length === 0) {
return { defaultRoutes: null, error: null };
}
@@ -207,7 +208,7 @@ async function detectApiRoutes(files: string[]): Promise<RoutesResult> {
// The deepest routes need to be
// the first ones to get handled
const sortedFiles = files
.filter(ignoreApiFilter)
.filter(getIgnoreApiFilter(builders))
.sort(sortFiles)
.sort(sortFilesBySegmentCount);
@@ -216,7 +217,10 @@ async function detectApiRoutes(files: string[]): Promise<RoutesResult> {
for (const file of sortedFiles) {
// We only consider every file in the api directory
// as we will strip extensions as well as resolving "[segments]"
if (!file.startsWith('api/')) {
if (
!file.startsWith('api/') &&
!builders.some(b => b.src === file && b.config!.functions)
) {
continue;
}
@@ -228,7 +232,7 @@ async function detectApiRoutes(files: string[]): Promise<RoutesResult> {
error: {
code: 'conflicting_path_segment',
message:
`The segment "${conflictingSegment}" occurres more than ` +
`The segment "${conflictingSegment}" occurs more than ` +
`one time in your path "${file}". Please make sure that ` +
`every segment in a path is unique`,
},
@@ -270,26 +274,31 @@ async function detectApiRoutes(files: string[]): Promise<RoutesResult> {
return { defaultRoutes, error: null };
}
function hasPublicBuilder(builders: Builder[]): boolean {
return builders.some(
function getPublicBuilder(builders: Builder[]): Builder | null {
const builder = builders.find(
builder =>
builder.use === '@now/static' &&
builder.src === 'public/**/*' &&
/^.*\/\*\*\/\*$/.test(builder.src) &&
builder.config &&
builder.config.zeroConfig === true
);
return builder || null;
}
export async function detectRoutes(
files: string[],
builders: Builder[]
): Promise<RoutesResult> {
const routesResult = await detectApiRoutes(files);
const routesResult = await detectApiRoutes(files, builders);
const publicBuilder = getPublicBuilder(builders);
if (routesResult.defaultRoutes && publicBuilder) {
const directory = publicBuilder.src.replace('/**/*', '');
if (routesResult.defaultRoutes && hasPublicBuilder(builders)) {
routesResult.defaultRoutes.push({
src: '/(.*)',
dest: '/public/$1',
dest: `/${directory}/$1`,
});
}

View File

@@ -0,0 +1,27 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectAngular({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('@angular/cli');
if (!version) return false;
return {
buildCommand: (await getPackageJsonBuildCommand()) || 'ng build',
outputDirectory: 'dist',
devCommand: 'ng serve --port $PORT',
framework: {
slug: '@angular/cli',
version,
},
minNodeRange: '10.x',
routes: [
{
handle: 'filesystem',
},
{
src: '/(.*)',
dest: '/index.html',
},
],
};
}

View File

@@ -0,0 +1,22 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectBrunch({
fs: { exists, getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('brunch');
if (!version) return false;
const hasConfig = await exists('brunch-config.js');
if (!hasConfig) return false;
return {
buildCommand:
(await getPackageJsonBuildCommand()) || 'brunch build --production',
outputDirectory: 'public',
devCommand: 'brunch watch --server --port $PORT',
framework: {
slug: 'brunch',
version,
},
};
}

View File

@@ -0,0 +1,44 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectCreateReactAppEjected({
fs: { getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('react-dev-utils');
if (!version) {
return false;
}
return {
buildCommand: 'node scripts/build.js',
outputDirectory: 'build',
devCommand: 'node scripts/start.js',
framework: {
slug: 'react-dev-utils',
version,
},
devVariables: { BROWSER: 'none' },
routes: [
{
src: '/static/(.*)',
headers: { 'cache-control': 's-maxage=31536000, immutable' },
continue: true,
},
{
src: '/service-worker.js',
headers: { 'cache-control': 's-maxage=0' },
continue: true,
},
{
src: '/sockjs-node/(.*)',
dest: '/sockjs-node/$1',
},
{
handle: 'filesystem',
},
{
src: '/(.*)',
headers: { 'cache-control': 's-maxage=0' },
dest: '/index.html',
},
],
};
}

View File

@@ -0,0 +1,44 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectCreateReactApp({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('react-scripts');
if (!version) {
return false;
}
return {
buildCommand: (await getPackageJsonBuildCommand()) || 'react-scripts build',
outputDirectory: 'build',
devCommand: 'react-scripts start',
devVariables: { BROWSER: 'none' },
framework: {
slug: 'react-scripts',
version,
},
routes: [
{
src: '/static/(.*)',
headers: { 'cache-control': 's-maxage=31536000, immutable' },
continue: true,
},
{
src: '/service-worker.js',
headers: { 'cache-control': 's-maxage=0' },
continue: true,
},
{
src: '/sockjs-node/(.*)',
dest: '/sockjs-node/$1',
},
{
handle: 'filesystem',
},
{
src: '/(.*)',
headers: { 'cache-control': 's-maxage=0' },
dest: '/index.html',
},
],
};
}

View File

@@ -0,0 +1,17 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectDocusaurus({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('docusaurus');
if (!version) return false;
return {
buildCommand: (await getPackageJsonBuildCommand()) || 'docusaurus-build',
outputDirectory: 'build',
devCommand: 'docusaurus-start --port $PORT',
framework: {
slug: 'docusaurus',
version,
},
};
}

View File

@@ -0,0 +1,17 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectEleventy({
fs: { getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('@11ty/eleventy');
if (!version) return false;
return {
buildCommand: 'npx @11ty/eleventy',
outputDirectory: '_site',
devCommand: 'npx @11ty/eleventy --serve --watch --port $PORT',
framework: {
slug: '@11ty/eleventy',
version,
},
};
}

View File

@@ -0,0 +1,26 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectEmber({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('ember-cli');
if (!version) return false;
return {
buildCommand: (await getPackageJsonBuildCommand()) || 'ember build',
outputDirectory: 'dist',
devCommand: 'ember serve --port $PORT',
framework: {
slug: 'ember-cli',
version,
},
routes: [
{
handle: 'filesystem',
},
{
src: '/(.*)',
dest: '/index.html',
},
],
};
}

View File

@@ -0,0 +1,141 @@
import yaml from 'js-yaml';
import toml from '@iarna/toml';
import { PackageJson } from '../types';
/**
* `DetectorFilesystem` is an abstract class that represents a virtual filesystem
* to perform read-only operations on in order to detect which framework is being
* used.
*
* Its abstract methods must be implemented by a subclass that perform the actual
* FS operations. Example subclasses could be implemented as:
*
* - Local filesystem, which proxies the FS operations to the equivalent `fs`
* module functions.
* - HTTP filesystem, which implements the FS operations over an HTTP server
* and does not require a local copy of the files.
* - `Files` filesystem, which operates on a virtual `Files` object (i.e. from
* the `glob()` function) which could include `FileFsRef`, `FileBlob`, etc.
*
* This base class implements various helper functions for common tasks (i.e.
* read and parse a JSON file). It also includes caching for all FS operations
* so that multiple detector functions de-dup read operations on the same file
* to reduce network/filesystem overhead.
*
* **NOTE:** It's important that all instance methods in this base class are
* bound to `this` so that the `fs` object may be destructured in the detector
* functions. The easiest way to do this is to use the `=` syntax when defining
* methods in this class definition.
*/
export default abstract class DetectorFilesystem {
protected abstract _readFile(name: string): Promise<Buffer>;
protected abstract _exists(name: string): Promise<boolean>;
private existsCache: Map<string, Promise<boolean>>;
private readFileCache: Map<string, Promise<Buffer>>;
private readJsonCache: Map<string, Promise<any>>;
constructor() {
this.existsCache = new Map();
this.readFileCache = new Map();
this.readJsonCache = new Map();
}
public exists = async (name: string): Promise<boolean> => {
let p = this.existsCache.get(name);
if (!p) {
p = this._exists(name);
this.existsCache.set(name, p);
}
return p;
};
public readFile = async (name: string): Promise<Buffer> => {
let p = this.readFileCache.get(name);
if (!p) {
p = this._readFile(name);
this.readFileCache.set(name, p);
}
return p;
};
public readJson = async <T>(name: string): Promise<T> => {
let p = this.readJsonCache.get(name);
if (!p) {
p = this.readFile(name).then(d => JSON.parse(d.toString('utf8')));
this.readJsonCache.set(name, p);
}
return p;
};
public readFileOrNull = async (name: string): Promise<Buffer | null> => {
return nullEnoent(this.readFile(name));
};
public readJsonOrNull = async <T>(name: string): Promise<T | null> => {
return nullEnoent(this.readJson<T>(name));
};
public readPackageJson = async (): Promise<PackageJson | null> => {
return await this.readJsonOrNull<PackageJson>('package.json');
};
public readConfigFile = async <T>(...names: string[]): Promise<T | null> => {
for (const name of names) {
const data = await this.readFileOrNull(name);
if (data) {
const str = data.toString('utf8');
if (name.endsWith('.json')) {
return JSON.parse(str);
} else if (name.endsWith('.toml')) {
return (toml.parse(str) as unknown) as T;
} else if (name.endsWith('.yaml') || name.endsWith('.yml')) {
return yaml.safeLoad(str, { filename: name });
}
}
}
return null;
};
public hasDependency = async (name: string): Promise<boolean> => {
const pkg = await this.readPackageJson();
const { dependencies = {}, devDependencies = {} } = pkg || {};
return name in dependencies || name in devDependencies;
};
public isNpm = async (): Promise<boolean> => {
return this.exists('package-lock.json');
};
public getPackageJsonCommand = async (
name: string
): Promise<string | null> => {
const pkg = await this.readPackageJson();
const { scripts = {} } = pkg || {};
return scripts[name] || null;
};
public getPackageJsonBuildCommand = async (): Promise<string | null> => {
const buildCommand = (await this.isNpm())
? 'npm run build'
: 'yarn run build';
return (await this.getPackageJsonCommand('build')) ? buildCommand : null;
};
public getDependencyVersion = async (name: string): Promise<string> => {
const pkg = await this.readPackageJson();
const { dependencies = {}, devDependencies = {} } = pkg || {};
return dependencies[name] || devDependencies[name];
};
}
async function nullEnoent<T>(p: Promise<T>): Promise<T | null> {
try {
return await p;
} catch (err) {
if (err.code === 'ENOENT') {
return null;
}
throw err;
}
}

View File

@@ -0,0 +1,20 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectGatsby({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('gatsby');
if (!version) {
return false;
}
return {
buildCommand: (await getPackageJsonBuildCommand()) || 'gatsby build',
outputDirectory: 'public',
devCommand: 'gatsby develop -p $PORT',
framework: {
slug: 'gatsby',
version,
},
cachePattern: '.cache/**',
};
}

View File

@@ -0,0 +1,21 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectGenericNodeProject({
fs: { isNpm, getPackageJsonCommand },
}: DetectorParameters): Promise<DetectorResult> {
const useNpm = await isNpm();
const devCommand = await getPackageJsonCommand('dev');
const buildCommand = await getPackageJsonCommand('build');
if (!buildCommand) {
return false;
}
return {
buildCommand: `${useNpm ? 'npm' : 'yarn'} run build`,
devCommand: `${useNpm ? 'npm' : 'yarn'} run ${
devCommand ? 'dev' : 'build'
}`,
outputDirectory: 'public',
};
}

View File

@@ -0,0 +1,19 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectGridsome({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('gridsome');
if (!version) {
return false;
}
return {
buildCommand: (await getPackageJsonBuildCommand()) || 'gridsome build',
outputDirectory: 'dist',
devCommand: 'gridsome develop -p $PORT',
framework: {
slug: 'gridsom',
version,
},
};
}

View File

@@ -0,0 +1,17 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectHexo({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('hexo');
if (!version) return false;
return {
buildCommand: (await getPackageJsonBuildCommand()) || 'hexo generate',
outputDirectory: 'public',
devCommand: 'hexo server --port $PORT',
framework: {
slug: 'hexo',
version,
},
};
}

View File

@@ -0,0 +1,30 @@
import { DetectorParameters, DetectorResult } from '../types';
/**
* https://gohugo.io/getting-started/configuration/#configuration-file
*/
interface HugoConfig {
publishDir?: string;
}
export default async function detectHugo({
fs: { readConfigFile },
}: DetectorParameters): Promise<DetectorResult> {
const config = await readConfigFile<HugoConfig>(
'config.toml',
'config.yaml',
'config.json'
);
if (!config) {
return false;
}
return {
buildCommand: 'hugo',
outputDirectory: config.publishDir || 'public',
devCommand: 'hugo server -D -w -p $PORT',
framework: {
slug: 'hugo',
version: 'latest',
},
};
}

View File

@@ -0,0 +1,89 @@
import AggregateError from 'aggregate-error';
import { Detector, DetectorParameters, DetectorResult } from '../types';
import angular from './angular';
import brunch from './brunch';
import createReactApp from './create-react-app';
import createReactAppEjected from './create-react-app-ejected';
import docusaurus from './docusaurus';
import eleventy from './eleventy';
import ember from './ember';
import gatsby from './gatsby';
import genericNodeProject from './generic-node-project';
import gridsome from './gridsome';
import hexo from './hexo';
import hugo from './hugo';
import jekyll from './jekyll';
import middleman from './middleman';
import next from './next';
import polymer from './polymer';
import preact from './preact';
import saber from './saber';
import sapper from './sapper';
import stencil from './stencil';
import svelte from './svelte';
import umi from './umi';
import vue from './vue';
export const pkgDetectors: Detector[] = [
angular,
brunch,
createReactApp,
createReactAppEjected,
docusaurus,
eleventy,
ember,
gatsby,
gridsome,
hexo,
next,
polymer,
preact,
saber,
sapper,
stencil,
svelte,
umi,
vue,
];
export const detectors: Detector[] = [hugo, jekyll, middleman];
export function firstTruthy<T>(promises: Promise<T>[]) {
return new Promise<T>((resolve, reject) => {
const errors: Array<Error> = [];
let unresolved = promises.length;
for (const p of promises) {
p.then(v => {
if (v || --unresolved === 0) {
resolve(v);
}
}).catch(err => {
errors.push(err);
if (--unresolved === 0) {
reject(new AggregateError(errors));
}
});
}
});
}
export async function detectDefaults(
params: DetectorParameters
): Promise<DetectorResult> {
// The `package.json` detectors are run first, since they share the common
// file read of `package.json` and are the most popular frameworks
let d: Detector[] = params.pkgDetectors || pkgDetectors;
let result: DetectorResult = await firstTruthy(
d.map(detector => detector(params))
);
if (!result) {
// If no `package.json` framework was detected then check the non-pkg ones
d = params.detectors || detectors;
result = await firstTruthy(d.map(detector => detector(params)));
}
if (!result) {
result = await genericNodeProject(params);
}
return result;
}

View File

@@ -0,0 +1,26 @@
import { DetectorParameters, DetectorResult } from '../types';
/**
* https://jekyllrb.com/docs/configuration/options/
*/
interface JekyllConfig {
destination?: string;
}
export default async function detectJekyll({
fs: { readConfigFile },
}: DetectorParameters): Promise<DetectorResult> {
const config = await readConfigFile<JekyllConfig>('_config.yml');
if (!config) {
return false;
}
return {
buildCommand: 'jekyll build',
outputDirectory: config.destination || '_site',
devCommand: 'bundle exec jekyll serve --watch --port $PORT',
framework: {
slug: 'jekyll',
version: 'latest',
},
};
}

View File

@@ -0,0 +1,18 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectMiddleman({
fs: { exists },
}: DetectorParameters): Promise<DetectorResult> {
const hasConfig = await exists('config.rb');
if (!hasConfig) return false;
return {
buildCommand: 'bundle exec middleman build',
outputDirectory: 'build',
devCommand: 'bundle exec middleman server -p $PORT',
framework: {
slug: 'middleman',
version: 'latest',
},
};
}

View File

@@ -0,0 +1,17 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectNext({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('next');
if (!version) return false;
return {
buildCommand: (await getPackageJsonBuildCommand()) || 'next build',
outputDirectory: '.next/static',
devCommand: 'next -p $PORT',
framework: {
slug: 'next',
version,
},
};
}

View File

@@ -0,0 +1,26 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectPolymer({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('polymer-cli');
if (!version) return false;
return {
buildCommand: (await getPackageJsonBuildCommand()) || 'polymer build',
outputDirectory: 'build',
devCommand: 'polymer serve --port $PORT',
framework: {
slug: 'polymer-cli',
version,
},
routes: [
{
handle: 'filesystem',
},
{
src: '/(.*)',
dest: '/index.html',
},
],
};
}

View File

@@ -0,0 +1,26 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectPreact({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('preact-cli');
if (!version) return false;
return {
buildCommand: (await getPackageJsonBuildCommand()) || 'preact build',
outputDirectory: 'build',
devCommand: 'preact watch --port $PORT',
framework: {
slug: 'preact-cli',
version,
},
routes: [
{
handle: 'filesystem',
},
{
src: '/(.*)',
dest: '/index.html',
},
],
};
}

View File

@@ -0,0 +1,31 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectSaber({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('saber');
if (!version) return false;
return {
buildCommand: (await getPackageJsonBuildCommand()) || 'saber build',
outputDirectory: 'public',
devCommand: 'saber --port $PORT',
routes: [
{
src: '/_saber/.*',
headers: { 'cache-control': 'max-age=31536000, immutable' },
},
{
handle: 'filesystem',
},
{
src: '.*',
status: 404,
dest: '404.html',
},
],
framework: {
slug: 'saber',
version,
},
};
}

View File

@@ -0,0 +1,17 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectSapper({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('sapper');
if (!version) return false;
return {
buildCommand: (await getPackageJsonBuildCommand()) || 'sapper export',
outputDirectory: '__sapper__/export',
devCommand: 'sapper dev --port $PORT',
framework: {
slug: 'sapper',
version,
},
};
}

View File

@@ -0,0 +1,26 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectStencil({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('@stencil/core');
if (!version) return false;
return {
buildCommand: (await getPackageJsonBuildCommand()) || 'stencil build',
outputDirectory: 'www',
devCommand: 'stencil build --dev --watch --serve --port $PORT',
framework: {
slug: '@stencil/core',
version,
},
routes: [
{
handle: 'filesystem',
},
{
src: '/(.*)',
dest: '/index.html',
},
],
};
}

View File

@@ -0,0 +1,26 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectSvelte({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('sirv-cli');
if (!version) return false;
return {
buildCommand: (await getPackageJsonBuildCommand()) || 'rollup -c',
outputDirectory: 'public',
devCommand: 'sirv public --single --dev --port $PORT',
framework: {
slug: 'sirv-cli',
version,
},
routes: [
{
handle: 'filesystem',
},
{
src: '/(.*)',
dest: '/index.html',
},
],
};
}

View File

@@ -0,0 +1,26 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectUmiJS({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('umi');
if (!version) return false;
return {
buildCommand: (await getPackageJsonBuildCommand()) || 'umi build',
outputDirectory: 'dist',
devCommand: 'umi dev --port $PORT',
framework: {
slug: 'umi',
version,
},
routes: [
{
handle: 'filesystem',
},
{
src: '/(.*)',
dest: '/index.html',
},
],
};
}

View File

@@ -0,0 +1,37 @@
import { DetectorParameters, DetectorResult } from '../types';
export default async function detectVue({
fs: { getPackageJsonBuildCommand, getDependencyVersion },
}: DetectorParameters): Promise<DetectorResult> {
const version = await getDependencyVersion('@vue/cli-service');
if (!version) return false;
return {
buildCommand:
(await getPackageJsonBuildCommand()) || 'vue-cli-service build',
outputDirectory: 'dist',
devCommand: 'vue-cli-service serve --port $PORT',
framework: {
slug: '@vue/cli-service',
version,
},
routes: [
{
src: '^/[^/]*\\.(js|txt|ico|json)',
headers: { 'cache-control': 'max-age=300' },
continue: true,
},
{
src: '^/(img|js|css|fonts|media)/.*',
headers: { 'cache-control': 'max-age=31536000, immutable' },
continue: true,
},
{
handle: 'filesystem',
},
{
src: '^.*',
dest: '/index.html',
},
],
};
}

View File

@@ -4,11 +4,13 @@ import { File } from './types';
interface FileBlobOptions {
mode?: number;
contentType?: string;
data: string | Buffer;
}
interface FromStreamOptions {
mode?: number;
contentType?: string;
stream: NodeJS.ReadableStream;
}
@@ -16,16 +18,22 @@ export default class FileBlob implements File {
public type: 'FileBlob';
public mode: number;
public data: string | Buffer;
public contentType: string | undefined;
constructor({ mode = 0o100644, data }: FileBlobOptions) {
constructor({ mode = 0o100644, contentType, data }: FileBlobOptions) {
assert(typeof mode === 'number');
assert(typeof data === 'string' || Buffer.isBuffer(data));
this.type = 'FileBlob';
this.mode = mode;
this.contentType = contentType;
this.data = data;
}
static async fromStream({ mode = 0o100644, stream }: FromStreamOptions) {
static async fromStream({
mode = 0o100644,
contentType,
stream,
}: FromStreamOptions) {
assert(typeof mode === 'number');
assert(typeof stream.pipe === 'function'); // is-stream
const chunks: Buffer[] = [];
@@ -37,7 +45,7 @@ export default class FileBlob implements File {
});
const data = Buffer.concat(chunks);
return new FileBlob({ mode, data });
return new FileBlob({ mode, contentType, data });
}
toStream(): NodeJS.ReadableStream {

View File

@@ -9,11 +9,13 @@ const semaToPreventEMFILE = new Sema(20);
interface FileFsRefOptions {
mode?: number;
contentType?: string;
fsPath: string;
}
interface FromStreamOptions {
mode: number;
contentType?: string;
stream: NodeJS.ReadableStream;
fsPath: string;
}
@@ -22,17 +24,20 @@ class FileFsRef implements File {
public type: 'FileFsRef';
public mode: number;
public fsPath: string;
public contentType: string | undefined;
constructor({ mode = 0o100644, fsPath }: FileFsRefOptions) {
constructor({ mode = 0o100644, contentType, fsPath }: FileFsRefOptions) {
assert(typeof mode === 'number');
assert(typeof fsPath === 'string');
this.type = 'FileFsRef';
this.mode = mode;
this.contentType = contentType;
this.fsPath = fsPath;
}
static async fromFsPath({
mode,
contentType,
fsPath,
}: FileFsRefOptions): Promise<FileFsRef> {
let m = mode;
@@ -40,11 +45,12 @@ class FileFsRef implements File {
const stat = await fs.lstat(fsPath);
m = stat.mode;
}
return new FileFsRef({ mode: m, fsPath });
return new FileFsRef({ mode: m, contentType, fsPath });
}
static async fromStream({
mode = 0o100644,
contentType,
stream,
fsPath,
}: FromStreamOptions): Promise<FileFsRef> {
@@ -63,7 +69,7 @@ class FileFsRef implements File {
dest.on('error', reject);
});
return new FileFsRef({ mode, fsPath });
return new FileFsRef({ mode, contentType, fsPath });
}
async toStreamAsync(): Promise<NodeJS.ReadableStream> {

View File

@@ -8,6 +8,7 @@ import { File } from './types';
interface FileRefOptions {
mode?: number;
digest: string;
contentType?: string;
mutable?: boolean;
}
@@ -26,14 +27,21 @@ export default class FileRef implements File {
public type: 'FileRef';
public mode: number;
public digest: string;
public contentType: string | undefined;
private mutable: boolean;
constructor({ mode = 0o100644, digest, mutable = false }: FileRefOptions) {
constructor({
mode = 0o100644,
digest,
contentType,
mutable = false,
}: FileRefOptions) {
assert(typeof mode === 'number');
assert(typeof digest === 'string');
this.type = 'FileRef';
this.mode = mode;
this.digest = digest;
this.contentType = contentType;
this.mutable = mutable;
}

View File

@@ -1,4 +1,5 @@
import path from 'path';
import debug from '../debug';
import FileFsRef from '../file-fs-ref';
import { File, Files, Meta } from '../types';
import { remove, mkdirp, readlink, symlink } from 'fs-extra';
@@ -39,8 +40,12 @@ export default async function download(
basePath: string,
meta?: Meta
): Promise<DownloadedFiles> {
const { isDev = false, skipDownload = false, filesChanged = null, filesRemoved = null } =
meta || {};
const {
isDev = false,
skipDownload = false,
filesChanged = null,
filesRemoved = null,
} = meta || {};
if (isDev || skipDownload) {
// In `now dev`, the `download()` function is a no-op because
@@ -48,11 +53,14 @@ export default async function download(
// source files are already available.
return files as DownloadedFiles;
}
debug('Downloading deployment source files...');
const start = Date.now();
const files2: DownloadedFiles = {};
const filenames = Object.keys(files);
await Promise.all(
Object.keys(files).map(async name => {
filenames.map(async name => {
// If the file does not exist anymore, remove it.
if (Array.isArray(filesRemoved) && filesRemoved.includes(name)) {
await removeFile(basePath, name);
@@ -71,5 +79,8 @@ export default async function download(
})
);
const duration = Date.now() - start;
debug(`Downloaded ${filenames.length} source files: ${duration}ms`);
return files2;
}

View File

@@ -1,11 +1,21 @@
import { intersects } from 'semver';
import boxen from 'boxen';
import { NodeVersion } from '../types';
import debug from '../debug';
const supportedOptions: NodeVersion[] = [
const allOptions: NodeVersion[] = [
{ major: 12, range: '12.x', runtime: 'nodejs12.x' },
{ major: 10, range: '10.x', runtime: 'nodejs10.x' },
{ major: 8, range: '8.10.x', runtime: 'nodejs8.10' },
{
major: 8,
range: '8.10.x',
runtime: 'nodejs8.10',
discontinueDate: new Date('2020-01-06'),
},
];
const supportedOptions = allOptions.filter(o => !isDiscontinued(o));
// This version should match Fargate's default in the PATH
// Today that is Node 8
export const defaultSelection = supportedOptions.find(
@@ -20,34 +30,71 @@ export async function getSupportedNodeVersion(
if (!engineRange) {
if (!silent) {
console.log(
'missing `engines` in `package.json`, using default range: ' +
debug(
'Missing `engines` in `package.json`, using default range: ' +
selection.range
);
}
} else {
const found = supportedOptions.some(o => {
const found = allOptions.some(o => {
// the array is already in order so return the first
// match which will be the newest version of node
selection = o;
return intersects(o.range, engineRange);
});
if (found) {
const discontinued = isDiscontinued(selection);
if (found && !discontinued) {
if (!silent) {
console.log(
debug(
'Found `engines` in `package.json`, selecting range: ' +
selection.range
);
}
} else {
if (!silent) {
throw new Error(
'found `engines` in `package.json` with an unsupported node range: ' +
engineRange +
'\nplease use `10.x` or `8.10.x` instead'
);
}
throw new Error(
'Found `engines` in `package.json` with an unsupported Node.js version range: ' +
engineRange +
'\nPlease use one of the following supported ranges: ' +
JSON.stringify(supportedOptions.map(o => o.range)) +
(discontinued
? '\nThis change is the result of a decision made by an upstream infrastructure provider (AWS).' +
'\nRead more: https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html'
: '')
);
}
}
const { range, discontinueDate } = selection;
if (discontinueDate && !isDiscontinued(selection)) {
const d = discontinueDate.toISOString().split('T')[0];
const validRanges = supportedOptions
.filter(o => !o.discontinueDate)
.map(o => o.range);
const prevTerm = process.env.TERM;
if (!prevTerm) {
// workaround for https://github.com/sindresorhus/term-size/issues/13
process.env.TERM = 'xterm';
}
console.warn(
boxen(
'NOTICE' +
'\n' +
`\nNode.js version ${range} has reached end-of-life.` +
`\nAs a result, deployments created on or after ${d} will fail to build.` +
'\nPlease use one of the following supported `engines` in `package.json`: ' +
JSON.stringify(validRanges) +
'\nThis change is the result of a decision made by an upstream infrastructure provider (AWS).' +
'\nRead more: https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html',
{ padding: 1 }
)
);
process.env.TERM = prevTerm;
}
return selection;
}
function isDiscontinued({ discontinueDate }: NodeVersion): boolean {
const today = new Date();
return discontinueDate !== undefined && discontinueDate <= today;
}

View File

@@ -1,21 +1,22 @@
import assert from 'assert';
import fs from 'fs-extra';
import path from 'path';
import debug from '../debug';
import spawn from 'cross-spawn';
import { SpawnOptions } from 'child_process';
import { deprecate } from 'util';
import { cpus } from 'os';
import { Meta, PackageJson, NodeVersion, Config } from '../types';
import { getSupportedNodeVersion } from './node-version';
function spawnAsync(
export function spawnAsync(
command: string,
args: string[],
cwd: string,
opts: SpawnOptions = {}
) {
return new Promise<void>((resolve, reject) => {
const stderrLogs: Buffer[] = [];
opts = { stdio: 'inherit', cwd, ...opts };
opts = { stdio: 'inherit', ...opts };
const child = spawn(command, args, opts);
if (opts.stdio === 'pipe' && child.stderr) {
@@ -54,7 +55,10 @@ export async function runShellScript(
assert(path.isAbsolute(fsPath));
const destPath = path.dirname(fsPath);
await chmodPlusX(fsPath);
await spawnAsync(`./${path.basename(fsPath)}`, args, destPath, spawnOpts);
await spawnAsync(`./${path.basename(fsPath)}`, args, {
cwd: destPath,
...spawnOpts,
});
return true;
}
@@ -128,38 +132,100 @@ async function scanParentDirs(destPath: string, readPackageJson = false) {
export async function runNpmInstall(
destPath: string,
args: string[] = [],
spawnOpts?: SpawnOptions
spawnOpts?: SpawnOptions,
meta?: Meta
) {
if (meta && meta.isDev) {
debug('Skipping dependency installation because dev mode is enabled');
return;
}
assert(path.isAbsolute(destPath));
let commandArgs = args;
console.log(`installing to ${destPath}`);
debug(`Installing to ${destPath}`);
const { hasPackageLockJson } = await scanParentDirs(destPath);
const opts = spawnOpts || { env: process.env };
const opts = { cwd: destPath, ...spawnOpts } || {
cwd: destPath,
env: process.env,
};
if (hasPackageLockJson) {
commandArgs = args.filter(a => a !== '--prefer-offline');
await spawnAsync(
'npm',
commandArgs.concat(['install', '--unsafe-perm']),
destPath,
commandArgs.concat(['install', '--no-audit', '--unsafe-perm']),
opts
);
} else {
await spawnAsync(
'yarn',
commandArgs.concat(['--ignore-engines', '--cwd', destPath]),
destPath,
opts
);
}
}
export async function runBundleInstall(
destPath: string,
args: string[] = [],
spawnOpts?: SpawnOptions,
meta?: Meta
) {
if (meta && meta.isDev) {
debug('Skipping dependency installation because dev mode is enabled');
return;
}
assert(path.isAbsolute(destPath));
const opts = { cwd: destPath, ...spawnOpts } || {
cwd: destPath,
env: process.env,
};
await spawnAsync(
'bundle',
args.concat([
'install',
'--no-prune',
'--retry',
'3',
'--jobs',
String(cpus().length || 1),
]),
opts
);
}
export async function runPipInstall(
destPath: string,
args: string[] = [],
spawnOpts?: SpawnOptions,
meta?: Meta
) {
if (meta && meta.isDev) {
debug('Skipping dependency installation because dev mode is enabled');
return;
}
assert(path.isAbsolute(destPath));
const opts = { cwd: destPath, ...spawnOpts } || {
cwd: destPath,
env: process.env,
};
await spawnAsync(
'pip3',
['install', '--disable-pip-version-check', ...args],
opts
);
}
export async function runPackageJsonScript(
destPath: string,
scriptName: string,
opts?: SpawnOptions
spawnOpts?: SpawnOptions
) {
assert(path.isAbsolute(destPath));
const { packageJson, hasPackageLockJson } = await scanParentDirs(
@@ -174,15 +240,16 @@ export async function runPackageJsonScript(
);
if (!hasScript) return false;
const opts = { cwd: destPath, ...spawnOpts };
if (hasPackageLockJson) {
console.log(`running "npm run ${scriptName}"`);
await spawnAsync('npm', ['run', scriptName], destPath, opts);
console.log(`Running "npm run ${scriptName}"`);
await spawnAsync('npm', ['run', scriptName], opts);
} else {
console.log(`running "yarn run ${scriptName}"`);
console.log(`Running "yarn run ${scriptName}"`);
await spawnAsync(
'yarn',
['--cwd', destPath, 'run', scriptName],
destPath,
['--ignore-engines', '--cwd', destPath, 'run', scriptName],
opts
);
}

View File

@@ -1,15 +1,19 @@
import FileBlob from './file-blob';
import FileFsRef from './file-fs-ref';
import FileRef from './file-ref';
import { Lambda, createLambda } from './lambda';
import download, { DownloadedFiles } from './fs/download';
import { Lambda, createLambda, getLambdaOptionsFromFunction } from './lambda';
import { Prerender } from './prerender';
import download, { DownloadedFiles, isSymbolicLink } from './fs/download';
import getWriteableDirectory from './fs/get-writable-directory';
import glob from './fs/glob';
import rename from './fs/rename';
import {
spawnAsync,
installDependencies,
runPackageJsonScript,
runNpmInstall,
runBundleInstall,
runPipInstall,
runShellScript,
getNodeVersion,
getSpawnOptions,
@@ -18,6 +22,7 @@ import streamToBuffer from './fs/stream-to-buffer';
import shouldServe from './should-serve';
import { detectBuilders } from './detect-builders';
import { detectRoutes } from './detect-routes';
import DetectorFilesystem from './detectors/filesystem';
import debug from './debug';
export {
@@ -25,15 +30,20 @@ export {
FileFsRef,
FileRef,
Lambda,
DetectorFilesystem,
createLambda,
Prerender,
download,
DownloadedFiles,
getWriteableDirectory,
glob,
rename,
spawnAsync,
installDependencies,
runPackageJsonScript,
runNpmInstall,
runBundleInstall,
runPipInstall,
runShellScript,
getNodeVersion,
getSpawnOptions,
@@ -42,6 +52,10 @@ export {
detectBuilders,
detectRoutes,
debug,
isSymbolicLink,
getLambdaOptionsFromFunction,
};
export { detectDefaults } from './detectors';
export * from './schemas';
export * from './types';

View File

@@ -1,8 +1,9 @@
import assert from 'assert';
import Sema from 'async-sema';
import { ZipFile } from 'yazl';
import minimatch from 'minimatch';
import { readlink } from 'fs-extra';
import { Files } from './types';
import { Files, Config } from './types';
import FileFsRef from './file-fs-ref';
import { isSymbolicLink } from './fs/download';
import streamToBuffer from './fs/stream-to-buffer';
@@ -15,6 +16,8 @@ interface LambdaOptions {
zipBuffer: Buffer;
handler: string;
runtime: string;
memory?: number;
maxDuration?: number;
environment: Environment;
}
@@ -22,21 +25,39 @@ interface CreateLambdaOptions {
files: Files;
handler: string;
runtime: string;
memory?: number;
maxDuration?: number;
environment?: Environment;
}
interface GetLambdaOptionsFromFunctionOptions {
sourceFile: string;
config?: Config;
}
export class Lambda {
public type: 'Lambda';
public zipBuffer: Buffer;
public handler: string;
public runtime: string;
public memory?: number;
public maxDuration?: number;
public environment: Environment;
constructor({ zipBuffer, handler, runtime, environment }: LambdaOptions) {
constructor({
zipBuffer,
handler,
runtime,
maxDuration,
memory,
environment,
}: LambdaOptions) {
this.type = 'Lambda';
this.zipBuffer = zipBuffer;
this.handler = handler;
this.runtime = runtime;
this.memory = memory;
this.maxDuration = maxDuration;
this.environment = environment;
}
}
@@ -48,6 +69,8 @@ export async function createLambda({
files,
handler,
runtime,
memory,
maxDuration,
environment = {},
}: CreateLambdaOptions): Promise<Lambda> {
assert(typeof files === 'object', '"files" must be an object');
@@ -55,6 +78,14 @@ export async function createLambda({
assert(typeof runtime === 'string', '"runtime" is not a string');
assert(typeof environment === 'object', '"environment" is not an object');
if (memory !== undefined) {
assert(typeof memory === 'number', '"memory" is not a number');
}
if (maxDuration !== undefined) {
assert(typeof maxDuration === 'number', '"maxDuration" is not a number');
}
await sema.acquire();
try {
@@ -63,6 +94,8 @@ export async function createLambda({
zipBuffer,
handler,
runtime,
memory,
maxDuration,
environment,
});
} finally {
@@ -105,3 +138,23 @@ export async function createZip(files: Files): Promise<Buffer> {
return zipBuffer;
}
export async function getLambdaOptionsFromFunction({
sourceFile,
config,
}: GetLambdaOptionsFromFunctionOptions): Promise<
Pick<LambdaOptions, 'memory' | 'maxDuration'>
> {
if (config && config.functions) {
for (const [pattern, fn] of Object.entries(config.functions)) {
if (sourceFile === pattern || minimatch(sourceFile, pattern)) {
return {
memory: fn.memory,
maxDuration: fn.maxDuration,
};
}
}
}
return {};
}

View File

@@ -0,0 +1,42 @@
import FileBlob from './file-blob';
import FileFsRef from './file-fs-ref';
import FileRef from './file-ref';
import { Lambda } from './lambda';
interface PrerenderOptions {
expiration: number;
lambda: Lambda;
fallback: FileBlob | FileFsRef | FileRef | null;
group?: number;
}
export class Prerender {
public type: 'Prerender';
public expiration: number;
public lambda: Lambda;
public fallback: FileBlob | FileFsRef | FileRef | null;
public group?: number;
constructor({ expiration, lambda, fallback, group }: PrerenderOptions) {
this.type = 'Prerender';
this.expiration = expiration;
this.lambda = lambda;
if (
typeof group !== 'undefined' &&
(group <= 0 || !Number.isInteger(group))
) {
throw new Error(
'The `group` argument for `Prerender` needs to be a natural number.'
);
}
this.group = group;
if (typeof fallback === 'undefined') {
throw new Error(
'The `fallback` argument for `Prerender` needs to be a `FileBlob`, `FileFsRef`, `FileRef`, or null.'
);
}
this.fallback = fallback;
}
}

View File

@@ -0,0 +1,61 @@
export const functionsSchema = {
type: 'object',
minProperties: 1,
maxProperties: 50,
additionalProperties: false,
patternProperties: {
'^.{1,256}$': {
type: 'object',
additionalProperties: false,
properties: {
runtime: {
type: 'string',
maxLength: 256,
},
memory: {
// Number between 128 and 3008 in steps of 64
enum: Object.keys(Array.from({ length: 50 }))
.slice(2, 48)
.map(x => Number(x) * 64),
},
maxDuration: {
type: 'number',
minimum: 1,
maximum: 900,
},
includeFiles: {
type: 'string',
maxLength: 256,
},
excludeFiles: {
type: 'string',
maxLength: 256,
},
},
},
},
};
export const buildsSchema = {
type: 'array',
minItems: 0,
maxItems: 128,
items: {
type: 'object',
additionalProperties: false,
required: ['use'],
properties: {
src: {
type: 'string',
minLength: 1,
maxLength: 4096,
},
use: {
type: 'string',
minLength: 3,
maxLength: 256,
},
config: { type: 'object' },
},
},
};

View File

@@ -1,9 +1,15 @@
import FileRef from './file-ref';
import FileFsRef from './file-fs-ref';
import DetectorFilesystem from './detectors/filesystem';
export interface Env {
[name: string]: string | undefined;
}
export interface File {
type: string;
mode: number;
contentType?: string;
toStream: () => NodeJS.ReadableStream;
/**
* The absolute path to the file in the filesystem
@@ -34,6 +40,7 @@ export interface Config {
| boolean
| number
| { [key: string]: string }
| BuilderFunctions
| undefined;
maxLambdaSize?: string;
includeFiles?: string | string[];
@@ -44,6 +51,7 @@ export interface Config {
debug?: boolean;
zeroConfig?: boolean;
import?: { [key: string]: string };
functions?: BuilderFunctions;
}
export interface Meta {
@@ -52,6 +60,8 @@ export interface Meta {
requestPath?: string;
filesChanged?: string[];
filesRemoved?: string[];
env?: Env;
buildEnv?: Env;
}
export interface AnalyzeOptions {
@@ -184,29 +194,117 @@ export interface ShouldServeOptions {
config: Config;
}
/**
* Credit to Iain Reid, MIT license.
* Source: https://gist.github.com/iainreid820/5c1cc527fe6b5b7dba41fec7fe54bf6e
*/
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace PackageJson {
/**
* An author or contributor
*/
export interface Author {
name: string;
email?: string;
homepage?: string;
}
/**
* A map of exposed bin commands
*/
export interface BinMap {
[commandName: string]: string;
}
/**
* A bugs link
*/
export interface Bugs {
email: string;
url: string;
}
export interface Config {
name?: string;
config?: unknown;
}
/**
* A map of dependencies
*/
export interface DependencyMap {
[dependencyName: string]: string;
}
/**
* CommonJS package structure
*/
export interface Directories {
lib?: string;
bin?: string;
man?: string;
doc?: string;
example?: string;
}
export interface Engines {
node?: string;
npm?: string;
}
export interface PublishConfig {
registry?: string;
}
/**
* A project repository
*/
export interface Repository {
type: string;
url: string;
}
export interface ScriptsMap {
[scriptName: string]: string;
}
}
export interface PackageJson {
name: string;
version: string;
engines?: {
[key: string]: string;
node: string;
npm: string;
};
scripts?: {
[key: string]: string;
};
dependencies?: {
[key: string]: string;
};
devDependencies?: {
[key: string]: string;
};
readonly name?: string;
readonly version?: string;
readonly description?: string;
readonly keywords?: string[];
readonly homepage?: string;
readonly bugs?: string | PackageJson.Bugs;
readonly license?: string;
readonly author?: string | PackageJson.Author;
readonly contributors?: string[] | PackageJson.Author[];
readonly files?: string[];
readonly main?: string;
readonly bin?: string | PackageJson.BinMap;
readonly man?: string | string[];
readonly directories?: PackageJson.Directories;
readonly repository?: string | PackageJson.Repository;
readonly scripts?: PackageJson.ScriptsMap;
readonly config?: PackageJson.Config;
readonly dependencies?: PackageJson.DependencyMap;
readonly devDependencies?: PackageJson.DependencyMap;
readonly peerDependencies?: PackageJson.DependencyMap;
readonly optionalDependencies?: PackageJson.DependencyMap;
readonly bundledDependencies?: string[];
readonly engines?: PackageJson.Engines;
readonly os?: string[];
readonly cpu?: string[];
readonly preferGlobal?: boolean;
readonly private?: boolean;
readonly publishConfig?: PackageJson.PublishConfig;
}
export interface NodeVersion {
major: number;
range: string;
runtime: string;
discontinueDate?: Date;
}
export interface Builder {
@@ -214,3 +312,64 @@ export interface Builder {
src: string;
config?: Config;
}
export interface BuilderFunctions {
[key: string]: {
memory?: number;
maxDuration?: number;
runtime?: string;
includeFiles?: string;
excludeFiles?: string;
};
}
export interface NowRewrite {
source: string;
destination: string;
}
export interface NowRedirect {
source: string;
destination: string;
statusCode?: number;
}
export interface NowHeader {
source: string;
headers: NowHeaderKeyValue[];
}
export interface NowHeaderKeyValue {
key: string;
value: string;
}
export type Detector = (params: DetectorParameters) => Promise<DetectorResult>;
export interface DetectorParameters {
fs: DetectorFilesystem;
detectors?: Detector[];
pkgDetectors?: Detector[];
}
export interface DetectorOutput {
buildCommand: string;
outputDirectory: string;
buildVariables?: Env;
devCommand?: string;
devVariables?: Env;
minNodeRange?: string;
cachePattern?: string;
routes?: Route[];
cleanUrls?: boolean;
rewrites?: NowRewrite[];
redirects?: NowRedirect[];
headers?: NowHeader[];
trailingSlash?: boolean;
framework?: {
slug: string;
version: string;
};
}
export type DetectorResult = DetectorOutput | false;

View File

@@ -0,0 +1,13 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false

View File

@@ -0,0 +1,46 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out
# dependencies
/node_modules
# profiling files
chrome-profiler-events*.json
speed-measure-plugin*.json
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db

View File

@@ -0,0 +1,27 @@
# Angular
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.3.17.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

View File

@@ -0,0 +1,114 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/angular",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": false,
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.css"],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "angular:build"
},
"configurations": {
"production": {
"browserTarget": "angular:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "angular:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.css"],
"scripts": []
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": ["**/node_modules/**"]
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "angular:serve"
},
"configurations": {
"production": {
"devServerTarget": "angular:serve:production"
}
}
}
}
}
},
"defaultProject": "angular"
}

View File

@@ -0,0 +1,12 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# You can see what browsers were selected by your queries by running:
# npx browserslist
> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11 # For IE 9-11 support, remove 'not'.

View File

@@ -0,0 +1,32 @@
// @ts-check
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
/**
* @type { import("protractor").Config }
*/
exports.config = {
allScriptsTimeout: 11000,
specs: ['./src/**/*.e2e-spec.ts'],
capabilities: {
browserName: 'chrome',
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {},
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.json'),
});
jasmine
.getEnv()
.addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
},
};

View File

@@ -0,0 +1,28 @@
import { AppPage } from './app.po';
import { browser, logging } from 'protractor';
describe('workspace-project App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', () => {
page.navigateTo();
expect(page.getTitleText()).toEqual('angular app is running!');
});
afterEach(async () => {
// Assert that there are no errors emitted from the browser
const logs = await browser
.manage()
.logs()
.get(logging.Type.BROWSER);
expect(logs).not.toContain(
jasmine.objectContaining({
level: logging.Level.SEVERE,
} as logging.Entry)
);
});
});

View File

@@ -0,0 +1,13 @@
import { browser, by, element } from 'protractor';
export class AppPage {
navigateTo() {
return browser.get(browser.baseUrl) as Promise<any>;
}
getTitleText() {
return element(by.css('app-root .content span')).getText() as Promise<
string
>;
}
}

View File

@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"types": ["jasmine", "jasminewd2", "node"]
}
}

View File

@@ -0,0 +1,32 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma'),
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/angular'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true,
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true,
});
};

View File

@@ -0,0 +1,47 @@
{
"name": "angular",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~8.2.13",
"@angular/common": "~8.2.13",
"@angular/compiler": "~8.2.13",
"@angular/core": "~8.2.13",
"@angular/forms": "~8.2.13",
"@angular/platform-browser": "~8.2.13",
"@angular/platform-browser-dynamic": "~8.2.13",
"@angular/router": "~8.2.13",
"rxjs": "~6.4.0",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.17",
"@angular/cli": "~8.3.17",
"@angular/compiler-cli": "~8.2.13",
"@angular/language-service": "~8.2.13",
"@types/node": "~8.9.4",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.5.3"
}
}

View File

@@ -0,0 +1,536 @@
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * * The content below * * * * * * * * * * * -->
<!-- * * * * * * * * * * is only a placeholder * * * * * * * * * * -->
<!-- * * * * * * * * * * and can be replaced. * * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * Delete the template below * * * * * * * * * * -->
<!-- * * * * * * * to get started with your project! * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<style>
:host {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-size: 14px;
color: #333;
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 8px 0;
}
p {
margin: 0;
}
.spacer {
flex: 1;
}
.toolbar {
height: 60px;
margin: -8px;
display: flex;
align-items: center;
background-color: #1976d2;
color: white;
font-weight: 600;
}
.toolbar img {
margin: 0 16px;
}
.toolbar #twitter-logo {
height: 40px;
margin: 0 16px;
}
.toolbar #twitter-logo:hover {
opacity: 0.8;
}
.content {
display: flex;
margin: 32px auto;
padding: 0 16px;
max-width: 960px;
flex-direction: column;
align-items: center;
}
svg.material-icons {
height: 24px;
width: auto;
}
svg.material-icons:not(:last-child) {
margin-right: 8px;
}
.card svg.material-icons path {
fill: #888;
}
.card-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
margin-top: 16px;
}
.card {
border-radius: 4px;
border: 1px solid #eee;
background-color: #fafafa;
height: 40px;
width: 200px;
margin: 0 8px 16px;
padding: 16px;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
transition: all 0.2s ease-in-out;
line-height: 24px;
}
.card-container .card:not(:last-child) {
margin-right: 0;
}
.card.card-small {
height: 16px;
width: 168px;
}
.card-container .card:not(.highlight-card) {
cursor: pointer;
}
.card-container .card:not(.highlight-card):hover {
transform: translateY(-3px);
box-shadow: 0 4px 17px rgba(black, 0.35);
}
.card-container .card:not(.highlight-card):hover .material-icons path {
fill: rgb(105, 103, 103);
}
.card.highlight-card {
background-color: #1976d2;
color: white;
font-weight: 600;
border: none;
width: auto;
min-width: 30%;
position: relative;
}
.card.card.highlight-card span {
margin-left: 60px;
}
svg#rocket {
width: 80px;
position: absolute;
left: -10px;
top: -24px;
}
svg#rocket-smoke {
height: 100vh;
position: absolute;
top: 10px;
right: 180px;
z-index: -10;
}
a,
a:visited,
a:hover {
color: #1976d2;
text-decoration: none;
}
a:hover {
color: #125699;
}
.terminal {
position: relative;
width: 80%;
max-width: 600px;
border-radius: 6px;
padding-top: 45px;
margin-top: 8px;
overflow: hidden;
background-color: rgb(15, 15, 16);
}
.terminal::before {
content: "\2022 \2022 \2022";
position: absolute;
top: 0;
left: 0;
height: 4px;
background: rgb(58, 58, 58);
color: #c2c3c4;
width: 100%;
font-size: 2rem;
line-height: 0;
padding: 14px 0;
text-indent: 4px;
}
.terminal pre {
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
color: white;
padding: 0 1rem 1rem;
margin: 0;
}
.circle-link {
height: 40px;
width: 40px;
border-radius: 40px;
margin: 8px;
background-color: white;
border: 1px solid #eeeeee;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
transition: 1s ease-out;
}
.circle-link:hover {
transform: translateY(-0.25rem);
box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
}
footer {
margin-top: 8px;
display: flex;
align-items: center;
line-height: 20px;
}
footer a {
display: flex;
align-items: center;
}
.github-star-badge {
color: #24292e;
display: flex;
align-items: center;
font-size: 12px;
padding: 3px 10px;
border: 1px solid rgba(27,31,35,.2);
border-radius: 3px;
background-image: linear-gradient(-180deg,#fafbfc,#eff3f6 90%);
margin-left: 4px;
font-weight: 600;
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
}
.github-star-badge:hover {
background-image: linear-gradient(-180deg,#f0f3f6,#e6ebf1 90%);
border-color: rgba(27,31,35,.35);
background-position: -.5em;
}
.github-star-badge .material-icons {
height: 16px;
width: 16px;
margin-right: 4px;
}
svg#clouds {
position: fixed;
bottom: -160px;
left: -230px;
z-index: -10;
width: 1920px;
}
/* Responsive Styles */
@media screen and (max-width: 767px) {
.card-container > *:not(.circle-link) ,
.terminal {
width: 100%;
}
.card:not(.highlight-card) {
height: 16px;
margin: 8px 0;
}
.card.highlight-card span {
margin-left: 72px;
}
svg#rocket-smoke {
right: 120px;
transform: rotate(-5deg);
}
}
@media screen and (max-width: 575px) {
svg#rocket-smoke {
display: none;
visibility: hidden;
}
}
</style>
<!-- Toolbar -->
<div class="toolbar" role="banner">
<img
width="40"
alt="Angular Logo"
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg=="
/>
<span>Welcome</span>
<div class="spacer"></div>
<a aria-label="Angular on twitter" target="_blank" rel="noopener" href="https://twitter.com/angular" title="Twitter">
<svg id="twitter-logo" height="24" data-name="Logo — FIXED" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400">
<defs>
<style>
.cls-1 {
fill: none;
}
.cls-2 {
fill: #ffffff;
}
</style>
</defs>
<rect class="cls-1" width="400" height="400" />
<path class="cls-2" d="M153.62,301.59c94.34,0,145.94-78.16,145.94-145.94,0-2.22,0-4.43-.15-6.63A104.36,104.36,0,0,0,325,122.47a102.38,102.38,0,0,1-29.46,8.07,51.47,51.47,0,0,0,22.55-28.37,102.79,102.79,0,0,1-32.57,12.45,51.34,51.34,0,0,0-87.41,46.78A145.62,145.62,0,0,1,92.4,107.81a51.33,51.33,0,0,0,15.88,68.47A50.91,50.91,0,0,1,85,169.86c0,.21,0,.43,0,.65a51.31,51.31,0,0,0,41.15,50.28,51.21,51.21,0,0,1-23.16.88,51.35,51.35,0,0,0,47.92,35.62,102.92,102.92,0,0,1-63.7,22A104.41,104.41,0,0,1,75,278.55a145.21,145.21,0,0,0,78.62,23"
/>
</svg>
</a>
</div>
<div class="content" role="main">
<!-- Highlight Card -->
<div class="card highlight-card card-small">
<svg id="rocket" alt="Rocket Ship" xmlns="http://www.w3.org/2000/svg" width="101.678" height="101.678" viewBox="0 0 101.678 101.678">
<g id="Group_83" data-name="Group 83" transform="translate(-141 -696)">
<circle id="Ellipse_8" data-name="Ellipse 8" cx="50.839" cy="50.839" r="50.839" transform="translate(141 696)" fill="#dd0031"/>
<g id="Group_47" data-name="Group 47" transform="translate(165.185 720.185)">
<path id="Path_33" data-name="Path 33" d="M3.4,42.615a3.084,3.084,0,0,0,3.553,3.553,21.419,21.419,0,0,0,12.215-6.107L9.511,30.4A21.419,21.419,0,0,0,3.4,42.615Z" transform="translate(0.371 3.363)" fill="#fff"/>
<path id="Path_34" data-name="Path 34" d="M53.3,3.221A3.09,3.09,0,0,0,50.081,0,48.227,48.227,0,0,0,18.322,13.437c-6-1.666-14.991-1.221-18.322,7.218A33.892,33.892,0,0,1,9.439,25.1l-.333.666a3.013,3.013,0,0,0,.555,3.553L23.985,43.641a2.9,2.9,0,0,0,3.553.555l.666-.333A33.892,33.892,0,0,1,32.647,53.3c8.55-3.664,8.884-12.326,7.218-18.322A48.227,48.227,0,0,0,53.3,3.221ZM34.424,9.772a6.439,6.439,0,1,1,9.106,9.106,6.368,6.368,0,0,1-9.106,0A6.467,6.467,0,0,1,34.424,9.772Z" transform="translate(0 0.005)" fill="#fff"/>
</g>
</g>
</svg>
<span>{{ title }} app is running!</span>
<svg id="rocket-smoke" alt="Rocket Ship Smoke" xmlns="http://www.w3.org/2000/svg" width="516.119" height="1083.632" viewBox="0 0 516.119 1083.632">
<path id="Path_40" data-name="Path 40" d="M644.6,141S143.02,215.537,147.049,870.207s342.774,201.755,342.774,201.755S404.659,847.213,388.815,762.2c-27.116-145.51-11.551-384.124,271.9-609.1C671.15,139.365,644.6,141,644.6,141Z" transform="translate(-147.025 -140.939)" fill="#f5f5f5"/>
</svg>
</div>
<!-- Resources -->
<h2>Resources</h2>
<p>Here are some links to help you get started:</p>
<div class="card-container">
<a class="card" target="_blank" rel="noopener" href="https://angular.io/tutorial">
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M5 13.18v4L12 21l7-3.82v-4L12 17l-7-3.82zM12 3L1 9l11 6 9-4.91V17h2V9L12 3z"/></svg>
<span>Learn Angular</span>
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg> </a>
<a class="card" target="_blank" rel="noopener" href="https://angular.io/cli">
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"/></svg>
<span>CLI Documentation</span>
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>
</a>
<a class="card" target="_blank" rel="noopener" href="https://blog.angular.io/">
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M13.5.67s.74 2.65.74 4.8c0 2.06-1.35 3.73-3.41 3.73-2.07 0-3.63-1.67-3.63-3.73l.03-.36C5.21 7.51 4 10.62 4 14c0 4.42 3.58 8 8 8s8-3.58 8-8C20 8.61 17.41 3.8 13.5.67zM11.71 19c-1.78 0-3.22-1.4-3.22-3.14 0-1.62 1.05-2.76 2.81-3.12 1.77-.36 3.6-1.21 4.62-2.58.39 1.29.59 2.65.59 4.04 0 2.65-2.15 4.8-4.8 4.8z"/></svg>
<span>Angular Blog</span>
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>
</a>
</div>
<!-- Next Steps -->
<h2>Next Steps</h2>
<p>What do you want to do next with your app?</p>
<input type="hidden" #selection>
<div class="card-container">
<div class="card card-small" (click)="selection.value = 'component'" tabindex="0">
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
<span>New Component</span>
</div>
<div class="card card-small" (click)="selection.value = 'material'" tabindex="0">
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
<span>Angular Material</span>
</div>
<div class="card card-small" (click)="selection.value = 'dependency'" tabindex="0">
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
<span>Add Dependency</span>
</div>
<div class="card card-small" (click)="selection.value = 'test'" tabindex="0">
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
<span>Run and Watch Tests</span>
</div>
<div class="card card-small" (click)="selection.value = 'build'" tabindex="0">
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
<span>Build for Production</span>
</div>
</div>
<!-- Terminal -->
<div class="terminal" [ngSwitch]="selection.value">
<pre *ngSwitchDefault>ng generate component xyz</pre>
<pre *ngSwitchCase="'material'">ng add @angular/material</pre>
<pre *ngSwitchCase="'dependency'">ng add _____</pre>
<pre *ngSwitchCase="'test'">ng test</pre>
<pre *ngSwitchCase="'build'">ng build --prod</pre>
</div>
<!-- Links -->
<div class="card-container">
<a class="circle-link" title="Animations" href="https://angular.io/guide/animations" target="_blank" rel="noopener">
<svg id="Group_20" data-name="Group 20" xmlns="http://www.w3.org/2000/svg" width="21.813" height="23.453" viewBox="0 0 21.813 23.453">
<path id="Path_15" data-name="Path 15" d="M4099.584,972.736h0l-10.882,3.9,1.637,14.4,9.245,5.153,9.245-5.153,1.686-14.4Z" transform="translate(-4088.702 -972.736)" fill="#ffa726"/>
<path id="Path_16" data-name="Path 16" d="M4181.516,972.736v23.453l9.245-5.153,1.686-14.4Z" transform="translate(-4170.633 -972.736)" fill="#fb8c00"/>
<path id="Path_17" data-name="Path 17" d="M4137.529,1076.127l-7.7-3.723,4.417-2.721,7.753,3.723Z" transform="translate(-4125.003 -1058.315)" fill="#ffe0b2"/>
<path id="Path_18" data-name="Path 18" d="M4137.529,1051.705l-7.7-3.723,4.417-2.721,7.753,3.723Z" transform="translate(-4125.003 -1036.757)" fill="#fff3e0"/>
<path id="Path_19" data-name="Path 19" d="M4137.529,1027.283l-7.7-3.723,4.417-2.721,7.753,3.723Z" transform="translate(-4125.003 -1015.199)" fill="#fff"/>
</svg>
</a>
<a class="circle-link" title="CLI" href="https://cli.angular.io/" target="_blank" rel="noopener">
<svg alt="Angular CLI Logo" xmlns="http://www.w3.org/2000/svg" width="21.762" height="23.447" viewBox="0 0 21.762 23.447">
<g id="Group_21" data-name="Group 21" transform="translate(0)">
<path id="Path_20" data-name="Path 20" d="M2660.313,313.618h0l-10.833,3.9,1.637,14.4,9.2,5.152,9.244-5.152,1.685-14.4Z" transform="translate(-2649.48 -313.618)" fill="#37474f"/>
<path id="Path_21" data-name="Path 21" d="M2741.883,313.618v23.447l9.244-5.152,1.685-14.4Z" transform="translate(-2731.05 -313.618)" fill="#263238"/>
<path id="Path_22" data-name="Path 22" d="M2692.293,379.169h11.724V368.618h-11.724Zm11.159-.6h-10.608v-9.345h10.621v9.345Z" transform="translate(-2687.274 -362.17)" fill="#fff"/>
<path id="Path_23" data-name="Path 23" d="M2709.331,393.688l.4.416,2.265-2.28-2.294-2.294-.4.4,1.893,1.893Z" transform="translate(-2702.289 -380.631)" fill="#fff"/>
<rect id="Rectangle_12" data-name="Rectangle 12" width="3.517" height="0.469" transform="translate(9.709 13.744)" fill="#fff"/>
</g>
</svg>
</a>
<a class="circle-link" title="Augury" href="https://augury.rangle.io/" target="_blank" rel="noopener">
<svg alt="Angular Augury Logo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="21.81" height="23.447" viewBox="0 0 21.81 23.447">
<defs>
<clipPath id="clip-path">
<rect id="Rectangle_13" data-name="Rectangle 13" width="10.338" height="10.27" fill="none"/>
</clipPath>
</defs>
<g id="Group_25" data-name="Group 25" transform="translate(0)">
<path id="Path_24" data-name="Path 24" d="M3780.155,311.417h0l-10.881,3.9,1.637,14.4,9.244,5.152,9.244-5.152,1.685-14.4Z" transform="translate(-3769.274 -311.417)" fill="#4a3493"/>
<path id="Path_25" data-name="Path 25" d="M3862.088,311.417v23.447l9.244-5.152,1.685-14.4Z" transform="translate(-3851.207 -311.417)" fill="#311b92"/>
<g id="Group_24" data-name="Group 24" transform="translate(6.194 6.73)" opacity="0.5">
<g id="Group_23" data-name="Group 23" transform="translate(0 0)">
<g id="Group_22" data-name="Group 22" clip-path="url(#clip-path)">
<path id="Path_26" data-name="Path 26" d="M3832.4,373.252a5.168,5.168,0,1,1-5.828-4.383,5.216,5.216,0,0,1,2.574.3,3.017,3.017,0,1,0,3.252,4.086Z" transform="translate(-3822.107 -368.821)" fill="#fff"/>
</g>
</g>
</g>
<path id="Path_27" data-name="Path 27" d="M3830.582,370.848a5.162,5.162,0,1,1-3.254-4.086,3.017,3.017,0,1,0,3.252,4.086Z" transform="translate(-3814.311 -359.969)" fill="#fff"/>
</g>
</svg>
</a>
<a class="circle-link" title="Protractor" href="https://www.protractortest.org/" target="_blank" rel="noopener">
<svg alt="Angular Protractor Logo" xmlns="http://www.w3.org/2000/svg" width="21.81" height="23.447" viewBox="0 0 21.81 23.447">
<g id="Group_26" data-name="Group 26" transform="translate(0)">
<path id="Path_28" data-name="Path 28" d="M4620.155,311.417h0l-10.881,3.9,1.637,14.4,9.244,5.152,9.244-5.152,1.685-14.4Z" transform="translate(-4609.274 -311.417)" fill="#e13439"/>
<path id="Path_29" data-name="Path 29" d="M4702.088,311.417v23.447l9.244-5.152,1.685-14.4Z" transform="translate(-4691.207 -311.417)" fill="#b52f32"/>
<path id="Path_30" data-name="Path 30" d="M4651.044,369.58v-.421h1.483a7.6,7.6,0,0,0-2.106-5.052l-1.123,1.123-.3-.3,1.122-1.121a7.588,7.588,0,0,0-4.946-2.055v1.482h-.421v-1.485a7.589,7.589,0,0,0-5.051,2.058l1.122,1.121-.3.3-1.123-1.123a7.591,7.591,0,0,0-2.106,5.052h1.482v.421h-1.489v1.734h15.241V369.58Zm-10.966-.263a4.835,4.835,0,0,1,9.67,0Z" transform="translate(-4634.008 -355.852)" fill="#fff"/>
</g>
</svg>
</a>
<a class="circle-link" title="Find a Local Meetup" href="https://www.meetup.com/find/?keywords=angular" target="_blank" rel="noopener">
<svg alt="Meetup Logo" xmlns="http://www.w3.org/2000/svg" width="24.607" height="23.447" viewBox="0 0 24.607 23.447">
<path id="logo--mSwarm" d="M21.221,14.95A4.393,4.393,0,0,1,17.6,19.281a4.452,4.452,0,0,1-.8.069c-.09,0-.125.035-.154.117a2.939,2.939,0,0,1-2.506,2.091,2.868,2.868,0,0,1-2.248-.624.168.168,0,0,0-.245-.005,3.926,3.926,0,0,1-2.589.741,4.015,4.015,0,0,1-3.7-3.347,2.7,2.7,0,0,1-.043-.38c0-.106-.042-.146-.143-.166a3.524,3.524,0,0,1-1.516-.69A3.623,3.623,0,0,1,2.23,14.557a3.66,3.66,0,0,1,1.077-3.085.138.138,0,0,0,.026-.2,3.348,3.348,0,0,1-.451-1.821,3.46,3.46,0,0,1,2.749-3.28.44.44,0,0,0,.355-.281,5.072,5.072,0,0,1,3.863-3,5.028,5.028,0,0,1,3.555.666.31.31,0,0,0,.271.03A4.5,4.5,0,0,1,18.3,4.7a4.4,4.4,0,0,1,1.334,2.751,3.658,3.658,0,0,1,.022.706.131.131,0,0,0,.1.157,2.432,2.432,0,0,1,1.574,1.645,2.464,2.464,0,0,1-.7,2.616c-.065.064-.051.1-.014.166A4.321,4.321,0,0,1,21.221,14.95ZM13.4,14.607a2.09,2.09,0,0,0,1.409,1.982,4.7,4.7,0,0,0,1.275.221,1.807,1.807,0,0,0,.9-.151.542.542,0,0,0,.321-.545.558.558,0,0,0-.359-.534,1.2,1.2,0,0,0-.254-.078c-.262-.047-.526-.086-.787-.138a.674.674,0,0,1-.617-.75,3.394,3.394,0,0,1,.218-1.109c.217-.658.509-1.286.79-1.918a15.609,15.609,0,0,0,.745-1.86,1.95,1.95,0,0,0,.06-1.073,1.286,1.286,0,0,0-1.051-1.033,1.977,1.977,0,0,0-1.521.2.339.339,0,0,1-.446-.042c-.1-.092-.2-.189-.307-.284a1.214,1.214,0,0,0-1.643-.061,7.563,7.563,0,0,1-.614.512A.588.588,0,0,1,10.883,8c-.215-.115-.437-.215-.659-.316a2.153,2.153,0,0,0-.695-.248A2.091,2.091,0,0,0,7.541,8.562a9.915,9.915,0,0,0-.405.986c-.559,1.545-1.015,3.123-1.487,4.7a1.528,1.528,0,0,0,.634,1.777,1.755,1.755,0,0,0,1.5.211,1.35,1.35,0,0,0,.824-.858c.543-1.281,1.032-2.584,1.55-3.875.142-.355.28-.712.432-1.064a.548.548,0,0,1,.851-.24.622.622,0,0,1,.185.539,2.161,2.161,0,0,1-.181.621c-.337.852-.68,1.7-1.018,2.552a2.564,2.564,0,0,0-.173.528.624.624,0,0,0,.333.71,1.073,1.073,0,0,0,.814.034,1.22,1.22,0,0,0,.657-.655q.758-1.488,1.511-2.978.35-.687.709-1.37a1.073,1.073,0,0,1,.357-.434.43.43,0,0,1,.463-.016.373.373,0,0,1,.153.387.7.7,0,0,1-.057.236c-.065.157-.127.316-.2.469-.42.883-.846,1.763-1.262,2.648A2.463,2.463,0,0,0,13.4,14.607Zm5.888,6.508a1.09,1.09,0,0,0-2.179.006,1.09,1.09,0,0,0,2.179-.006ZM1.028,12.139a1.038,1.038,0,1,0,.01-2.075,1.038,1.038,0,0,0-.01,2.075ZM13.782.528a1.027,1.027,0,1,0-.011,2.055A1.027,1.027,0,0,0,13.782.528ZM22.21,6.95a.882.882,0,0,0-1.763.011A.882.882,0,0,0,22.21,6.95ZM4.153,4.439a.785.785,0,1,0,.787-.78A.766.766,0,0,0,4.153,4.439Zm8.221,18.22a.676.676,0,1,0-.677.666A.671.671,0,0,0,12.374,22.658ZM22.872,12.2a.674.674,0,0,0-.665.665.656.656,0,0,0,.655.643.634.634,0,0,0,.655-.644A.654.654,0,0,0,22.872,12.2ZM7.171-.123A.546.546,0,0,0,6.613.43a.553.553,0,1,0,1.106,0A.539.539,0,0,0,7.171-.123ZM24.119,9.234a.507.507,0,0,0-.493.488.494.494,0,0,0,.494.494.48.48,0,0,0,.487-.483A.491.491,0,0,0,24.119,9.234Zm-19.454,9.7a.5.5,0,0,0-.488-.488.491.491,0,0,0-.487.5.483.483,0,0,0,.491.479A.49.49,0,0,0,4.665,18.936Z" transform="translate(0 0.123)" fill="#f64060"/>
</svg>
</a>
<a class="circle-link" title="Join the Conversation on Gitter" href="https://gitter.im/angular/angular" target="_blank" rel="noopener">
<svg alt="Gitter Logo" xmlns="http://www.w3.org/2000/svg" width="19.447" height="19.447" viewBox="0 0 19.447 19.447">
<g id="Group_40" data-name="Group 40" transform="translate(-1612 -405)">
<rect id="Rectangle_19" data-name="Rectangle 19" width="19.447" height="19.447" transform="translate(1612 405)" fill="#e60257"/>
<g id="gitter" transform="translate(1617.795 408.636)">
<g id="Group_33" data-name="Group 33" transform="translate(0 0)">
<rect id="Rectangle_15" data-name="Rectangle 15" width="1.04" height="9.601" transform="translate(2.304 2.324)" fill="#fff"/>
<rect id="Rectangle_16" data-name="Rectangle 16" width="1.04" height="9.601" transform="translate(4.607 2.324)" fill="#fff"/>
<rect id="Rectangle_17" data-name="Rectangle 17" width="1.04" height="4.648" transform="translate(6.91 2.324)" fill="#fff"/>
<rect id="Rectangle_18" data-name="Rectangle 18" width="1.04" height="6.971" transform="translate(0 0)" fill="#fff"/>
</g>
</g>
</g>
</svg>
</a>
</div>
<!-- Footer -->
<footer>
Love Angular?&nbsp;
<a href="https://github.com/angular/angular" target="_blank" rel="noopener"> Give our repo a star.
<div class="github-star-badge">
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"/></svg>
Star
</div>
</a>
<a href="https://github.com/angular/angular" target="_blank" rel="noopener">
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" fill="#1976d2"/><path d="M0 0h24v24H0z" fill="none"/></svg>
</a>
</footer>
<svg id="clouds" alt="Gray Clouds Background" xmlns="http://www.w3.org/2000/svg" width="2611.084" height="485.677" viewBox="0 0 2611.084 485.677">
<path id="Path_39" data-name="Path 39" d="M2379.709,863.793c10-93-77-171-168-149-52-114-225-105-264,15-75,3-140,59-152,133-30,2.83-66.725,9.829-93.5,26.25-26.771-16.421-63.5-23.42-93.5-26.25-12-74-77-130-152-133-39-120-212-129-264-15-54.084-13.075-106.753,9.173-138.488,48.9-31.734-39.726-84.4-61.974-138.487-48.9-52-114-225-105-264,15a162.027,162.027,0,0,0-103.147,43.044c-30.633-45.365-87.1-72.091-145.206-58.044-52-114-225-105-264,15-75,3-140,59-152,133-53,5-127,23-130,83-2,42,35,72,70,86,49,20,106,18,157,5a165.625,165.625,0,0,0,120,0c47,94,178,113,251,33,61.112,8.015,113.854-5.72,150.492-29.764a165.62,165.62,0,0,0,110.861-3.236c47,94,178,113,251,33,31.385,4.116,60.563,2.495,86.487-3.311,25.924,5.806,55.1,7.427,86.488,3.311,73,80,204,61,251-33a165.625,165.625,0,0,0,120,0c51,13,108,15,157-5a147.188,147.188,0,0,0,33.5-18.694,147.217,147.217,0,0,0,33.5,18.694c49,20,106,18,157,5a165.625,165.625,0,0,0,120,0c47,94,178,113,251,33C2446.709,1093.793,2554.709,922.793,2379.709,863.793Z" transform="translate(142.69 -634.312)" fill="#eee"/>
</svg>
</div>
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * * The content above * * * * * * * * * * * -->
<!-- * * * * * * * * * * is only a placeholder * * * * * * * * * * -->
<!-- * * * * * * * * * * and can be replaced. * * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * End of Placeholder * * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->

View File

@@ -0,0 +1,31 @@
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [AppComponent],
}).compileComponents();
}));
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'angular'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('angular');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('.content span').textContent).toContain(
'angular app is running!'
);
});
});

View File

@@ -0,0 +1,10 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title = 'angular';
}

View File

@@ -0,0 +1,12 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule],
providers: [],
bootstrap: [AppComponent],
})
export class AppModule {}

View File

@@ -0,0 +1,3 @@
export const environment = {
production: true,
};

View File

@@ -0,0 +1,16 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false,
};
/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.

Binary file not shown.

After

Width:  |  Height:  |  Size: 948 B

View File

@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Angular</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
</html>

View File

@@ -0,0 +1,13 @@
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic()
.bootstrapModule(AppModule)
.catch(err => console.error(err));

View File

@@ -0,0 +1,62 @@
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/guide/browser-support
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
* because those flags need to be set before `zone.js` being loaded, and webpack
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags.ts';
*
* The flags allowed in zone-flags.ts are listed here.
*
* The following flags will work for all browsers.
*
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*
* (window as any).__Zone_enable_cross_context_check = true;
*
*/
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/

View File

@@ -0,0 +1 @@
/* You can add global styles to this file, and also import other style files */

View File

@@ -0,0 +1,20 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
} from '@angular/platform-browser-dynamic/testing';
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);

View File

@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": ["src/main.ts", "src/polyfills.ts"],
"include": ["src/**/*.ts"],
"exclude": ["src/test.ts", "src/**/*.spec.ts"]
}

View File

@@ -0,0 +1,21 @@
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"typeRoots": ["node_modules/@types"],
"lib": ["es2018", "dom"]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}

Some files were not shown because too many files have changed in this diff Show More